Minor consistency fixes wrt. piyacc.git commit 6558f0b
[bootstrap_bison.git] / configure.ac
1 # Configure template for GNU Bison.                   -*-Autoconf-*-
2 #
3 # Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # In order for some versions of Sun Studio to compile our C++ test cases
19 # correctly, we need Autoconf 2.64 or better to handle the restrict
20 # keyword in at least string.h from gnulib.  We need Autoconf 2.68 or
21 # better to avoid a typo in the 'configure --help' entry for the YACC
22 # environment variable.
23 AC_PREREQ([2.68])
24 m4_pattern_forbid([^gl_[A-Z]])
25
26 AC_INIT([GNU Bison],
27         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
28         [bug-bison@gnu.org])
29 AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2018])
30 AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
31                    [The copyright year for this package])
32
33 AC_CONFIG_AUX_DIR([build-aux])
34 AC_CONFIG_MACRO_DIR([m4])
35
36 # We use Automake 1.14's %D% and %C%.
37 #
38 # We want gnits strictness only when rolling a stable release.  For
39 # release candidates, we use version strings like 2.4.3_rc1, but gnits
40 # doesn't like that, so we let the underscore disable gnits.  Between
41 # releases, we want to be able run make dist without being required to
42 # add a bogus NEWS entry.  In that case, the version string
43 # automatically contains a dash, which we also let disable gnits.
44 AM_INIT_AUTOMAKE([1.14 dist-xz nostdinc
45                  color-tests parallel-tests
46                  silent-rules]
47                  m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
48                            [gnu], [gnits]))
49 AM_SILENT_RULES([yes])
50 AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h])
51
52 # Checks for the compiler.
53 AC_PROG_CC_STDC
54 AC_PROG_CXX
55
56 # Gnulib (early checks).
57 gl_EARLY
58
59 # Gnulib uses '#pragma GCC diagnostic push' to silence some
60 # warnings, but older gcc doesn't support this.
61 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
62   [lv_cv_gcc_pragma_push_works], [
63   save_CFLAGS=$CFLAGS
64   CFLAGS='-Wunknown-pragmas -Werror'
65   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
66     #pragma GCC diagnostic push
67     #pragma GCC diagnostic pop
68   ]])],
69   [lv_cv_gcc_pragma_push_works=yes],
70   [lv_cv_gcc_pragma_push_works=no])
71   CFLAGS=$save_CFLAGS])
72
73 AC_ARG_ENABLE([gcc-warnings],
74 [  --enable-gcc-warnings   turn on lots of GCC warnings (not recommended).
75                            Also, issue synclines from the examples/ to
76                            the corresponding source in the Texinfo doc.],
77 [case $enable_gcc_warnings in
78    yes|no) ;;
79    *)  AC_MSG_ERROR([invalid value for --gcc-warnings: $enable_gcc_warnings]);;
80  esac],
81               [enable_gcc_warnings=no])
82 AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
83 if test "$enable_gcc_warnings" = yes; then
84   warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation
85     -Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
86   warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
87   warn_cxx='-Wnoexcept'
88   # Warnings for the test suite only.
89   #
90   # -fno-color-diagnostics: Clang's use of colors in the error
91   # messages is confusing the tests looking at the compiler's output
92   # (e.g., synclines.at).
93   #
94   # -Wno-keyword-macro: We use the "#define private public" dirty
95   # trick in the test suite to check some private implementation
96   # details for lalr1.cc.
97   warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare -fno-color-diagnostics
98     -Wno-keyword-macro'
99
100   AC_LANG_PUSH([C])
101   # Clang supports many of GCC's -W options, but only issues warnings
102   # on the ones it does not recognize.  In that case, gl_WARN_ADD
103   # thinks the option is supported, and unknown options are then added
104   # to CFLAGS.  But then, when -Werror is added in the test suite for
105   # instance, the warning about the unknown option turns into an
106   # error.
107   #
108   # This should be addressed by gnulib's gl_WARN_ADD, but in the
109   # meanwhile, turn warnings about unknown options into errors in
110   # CFLAGS, and restore CFLAGS after the tests.
111   save_CFLAGS=$CFLAGS
112   gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS])
113   for i in $warn_common $warn_c;
114   do
115     gl_WARN_ADD([$i], [WARN_CFLAGS])
116   done
117   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
118
119   # Warnings for the test suite, and maybe for bison if GCC is modern
120   # enough.
121   gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
122   gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
123   test $lv_cv_gcc_pragma_push_works = yes &&
124     AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
125
126   # Warnings for the test suite only.
127   for i in $warn_tests;
128   do
129     gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
130   done
131   CFLAGS=$save_CFLAGS
132   AC_LANG_POP([C])
133
134   AC_LANG_PUSH([C++])
135   save_CXXFLAGS=$CXXFLAGS
136   gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
137   for i in $warn_common $warn_cxx;
138   do
139     gl_WARN_ADD([$i], [WARN_CXXFLAGS])
140   done
141   gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
142               [AC_LANG_PROGRAM([], [nullptr])])
143   gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
144   # Warnings for the test suite only.
145   for i in $warn_tests;
146   do
147     gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
148   done
149   # Clang++ 3.2+ reject C code generated by Flex.
150   gl_WARN_ADD([-Wno-null-conversion], [FLEX_SCANNER_CXXFLAGS])
151   # So does G++ 4.8...
152   gl_WARN_ADD([-Wno-sign-compare], [FLEX_SCANNER_CXXFLAGS])
153   # ... possiby in std=c++11 mode.
154   gl_WARN_ADD([-Wno-zero-as-null-pointer-constant], [FLEX_SCANNER_CXXFLAGS])
155   CXXFLAGS=$save_CXXFLAGS
156   AC_LANG_POP([C++])
157 fi
158
159 BISON_TEST_FOR_WORKING_C_COMPILER
160 BISON_C_COMPILER_POSIXLY_CORRECT
161 BISON_TEST_FOR_WORKING_CXX_COMPILER
162 BISON_CXX_COMPILER_POSIXLY_CORRECT
163
164 AC_ARG_ENABLE([yacc],
165   [AC_HELP_STRING([--disable-yacc],
166      [do not build a yacc command or an -ly library])],
167   , [enable_yacc=yes])
168 AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
169
170 # Checks for programs.
171 AM_MISSING_PROG([DOT], [dot])
172 AC_PROG_LEX
173 $LEX_IS_FLEX || test "X$LEX" = X: || {
174   AC_MSG_WARN([bypassing lex because flex is required])
175   LEX=:
176 }
177 AM_CONDITIONAL([FLEX_CXX_WORKS],
178   [$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
179 AC_PROG_YACC
180 AC_PROG_RANLIB
181 AC_PROG_GNU_M4
182 AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
183 AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
184 supports -g, otherwise to "".])
185 AC_PATH_PROG([PERL], [perl])
186 if test -z "$PERL"; then
187    AC_MSG_ERROR([perl not found])
188 fi
189 AM_MISSING_PROG([HELP2MAN], [help2man])
190 AC_PATH_PROG([XSLTPROC], [xsltproc])
191 AC_SUBST([XSLTPROC])
192
193 # Checks for header files.
194 AC_CHECK_HEADERS_ONCE([locale.h])
195
196 # Checks for compiler characteristics.
197 AC_C_INLINE
198
199 # Gnulib (later checks).  Putting them here rather than right after
200 # gl_EARLY avoids some redundant checks.
201 gl_INIT
202
203 # Checks for library functions.
204 AC_CHECK_FUNCS_ONCE([setlocale])
205 AM_WITH_DMALLOC
206 BISON_PREREQ_TIMEVAR
207
208 # Gettext.
209 # We use gnulib, which is only guaranteed to work properly with the
210 # latest Gettext.
211 AM_GNU_GETTEXT([external], [need-ngettext])
212 AM_GNU_GETTEXT_VERSION([0.18])
213 BISON_I18N
214
215 # Internationalized parsers.
216 AC_CONFIG_FILES([runtime-po/Makefile.in])
217 # Autoconf macros for packages using internationalized parsers.
218 aclocaldir='${datadir}/aclocal'
219 AC_SUBST([aclocaldir])
220
221 # Create the benchmark script.
222 AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
223
224 # Initialize the test suite.
225 AC_CONFIG_TESTDIR(tests)
226 AC_CONFIG_FILES([tests/atlocal])
227 AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
228
229 AC_CHECK_PROGS([VALGRIND], [valgrind])
230 # Use something simpler that $host_os to select our suppression file.
231 uname=`uname`
232 case $VALGRIND:$uname in
233   '':*) ;;
234   *:Darwin)
235     # See README-hacking.
236     VALGRIND=;;
237   *:*)
238     suppfile=build-aux/$uname.valgrind
239     if test -f "$srcdir/$suppfile"; then
240       AC_SUBST([VALGRIND_OPTS_SUPPRESSION],
241                ["--suppressions=\$(abs_top_srcdir)/$suppfile"])
242     fi
243     ;;
244 esac
245
246 # Whether we cannot run the compiled bison.
247 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
248
249 AM_MISSING_PROG([AUTOM4TE], [autom4te])
250 # Needed by tests/atlocal.in.
251 AC_SUBST([GCC])
252
253 gt_JAVACOMP([1.3], [1.4])
254 gt_JAVAEXEC
255
256 AC_CONFIG_FILES([Makefile
257                  po/Makefile.in
258                  doc/yacc.1])
259 AC_OUTPUT