1 # Configure template for GNU Bison. -*-Autoconf-*-
3 # Copyright (C) 2001-2015, 2018-2019 Free Software Foundation, Inc.
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.
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.
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/>.
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.
24 m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
25 m4_pattern_allow([^BISON_USE_NLS$])
28 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
30 AC_SUBST([PACKAGE_COPYRIGHT_YEAR], [2019])
31 AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT_YEAR], [$PACKAGE_COPYRIGHT_YEAR],
32 [The copyright year for this package])
34 AC_CONFIG_AUX_DIR([build-aux])
35 AC_CONFIG_MACRO_DIR([m4])
37 # We use Automake 1.14's %D% and %C%.
39 # We want gnits strictness only when rolling a stable release. For
40 # release candidates, we use version strings like 2.4.3_rc1, but gnits
41 # doesn't like that, so we let the underscore disable gnits. Between
42 # releases, we want to be able run make dist without being required to
43 # add a bogus NEWS entry. In that case, the version string
44 # automatically contains a dash, which we also let disable gnits.
45 AM_INIT_AUTOMAKE([1.14 dist-xz nostdinc
46 color-tests parallel-tests
48 m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
50 AM_SILENT_RULES([yes])
51 AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h])
53 # Checks for the compiler.
57 # Gnulib (early checks).
60 # Gnulib uses '#pragma GCC diagnostic push' to silence some
61 # warnings, but older gcc doesn't support this.
62 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
63 [lv_cv_gcc_pragma_push_works], [
65 CFLAGS='-Wunknown-pragmas -Werror'
66 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
67 #pragma GCC diagnostic push
68 #pragma GCC diagnostic pop
70 [lv_cv_gcc_pragma_push_works=yes],
71 [lv_cv_gcc_pragma_push_works=no])
75 gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
82 AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x])
83 AM_CONDITIONAL([ENABLE_CXX14], [test x"$CXX14_CXXFLAGS" != x])
86 AC_ARG_ENABLE([gcc-warnings],
87 [ --enable-gcc-warnings turn on lots of GCC warnings (not recommended).
88 Also, issue synclines from the examples/ to
89 the corresponding source in the Texinfo doc.],
90 [case $enable_gcc_warnings in
92 *) AC_MSG_ERROR([invalid value for --gcc-warnings: $enable_gcc_warnings]);;
94 [enable_gcc_warnings=no])
95 AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
96 if test "$enable_gcc_warnings" = yes; then
97 warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
98 -fparse-all-comments -Wdocumentation
99 -Wformat -Wimplicit-fallthrough -Wnull-dereference
100 -Wpointer-arith -Wshadow
102 warn_c='-Wbad-function-cast -Wstrict-prototypes'
103 warn_cxx='-Wextra-semi -Wnoexcept -Wundefined-func-template -Wweak-vtables'
104 # Warnings for the test suite only.
106 # -fno-color-diagnostics: Clang's use of colors in the error
107 # messages is confusing the tests looking at the compiler's output
108 # (e.g., synclines.at).
110 # -Wno-keyword-macro: We use the "#define private public" dirty
111 # trick in the test suite to check some private implementation
112 # details for lalr1.cc.
113 warn_tests='-Wundef -pedantic -Wconversion
114 -Wdeprecated -Wsign-compare -Wsign-conversion
115 -fno-color-diagnostics
120 # Clang supports many of GCC's -W options, but only issues warnings
121 # on the ones it does not recognize. In that case, gl_WARN_ADD
122 # thinks the option is supported, and unknown options are then added
123 # to CFLAGS. But then, when -Werror is added in the test suite for
124 # instance, the warning about the unknown option turns into an
127 # This should be addressed by gnulib's gl_WARN_ADD, but in the
128 # meanwhile, turn warnings about unknown options into errors in
129 # CFLAGS, and restore CFLAGS after the tests.
131 gl_WARN_ADD([-Werror=unknown-warning-option], [CFLAGS])
132 # Accept this warning only if it is not too touchy (e.g., clang 3.3
134 gl_WARN_ADD([-Wunreachable-code], [WARN_CFLAGS],
136 [[if (sizeof (long) < sizeof (int)) return 1;]])])
137 for i in $warn_common $warn_c;
139 gl_WARN_ADD([$i], [WARN_CFLAGS])
141 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
143 # Warnings for the test suite, and maybe for bison if GCC is modern
145 gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
146 gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
147 test $lv_cv_gcc_pragma_push_works = yes &&
148 AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
150 # Warnings for the test suite only.
151 for i in $warn_tests -Wincompatible-pointer-types;
153 gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
160 save_CXXFLAGS=$CXXFLAGS
161 gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
162 for i in $warn_common $warn_cxx;
164 gl_WARN_ADD([$i], [WARN_CXXFLAGS])
166 # Accept this warning only if it is not too touchy (e.g., clang 3.3
168 gl_WARN_ADD([-Wunreachable-code], [WARN_CXXFLAGS],
170 [[if (sizeof (long) < sizeof (int)) return 1;]])])
171 gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
172 [AC_LANG_PROGRAM([], [nullptr])])
173 gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
174 # Warnings for the test suite only.
175 for i in $warn_tests;
177 gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
179 # Too many compilers complain about Flex generated code.
180 gl_WARN_ADD([-Wno-error], [FLEX_SCANNER_CXXFLAGS])
181 # Clang++ deprecates compiling C.
182 gl_WARN_ADD([-Wno-deprecated], [WNO_DEPRECATED_CXXFLAGS])
183 CXXFLAGS=$save_CXXFLAGS
188 BISON_TEST_FOR_WORKING_C_COMPILER
189 BISON_C_COMPILER_POSIXLY_CORRECT
190 BISON_TEST_FOR_WORKING_CXX_COMPILER
191 BISON_CXX_COMPILER_POSIXLY_CORRECT
194 AC_CHECK_PROGS([DC], [dmd])
195 AC_CHECK_PROGS([DCFLAGS], [-g])
196 AM_CONDITIONAL([ENABLE_D], [test x"$DC" != x])
199 gt_JAVACOMP([1.7], [1.7])
201 AM_CONDITIONAL([ENABLE_JAVA], [test x"$CONF_JAVAC" != x && test x"$CONF_JAVA" != x])
204 AC_ARG_ENABLE([yacc],
205 [AC_HELP_STRING([--disable-yacc],
206 [do not build a yacc command or an -ly library])],
208 AM_CONDITIONAL([ENABLE_YACC], [test "$enable_yacc" = yes])
209 AC_CONFIG_FILES([src/yacc], [chmod +x src/yacc])
211 # Checks for programs.
212 AM_MISSING_PROG([DOT], [dot])
214 $LEX_IS_FLEX || test "X$LEX" = X: || {
215 AC_MSG_WARN([bypassing lex because flex is required])
218 AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
219 AM_CONDITIONAL([FLEX_CXX_WORKS],
220 [$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
224 AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
225 AC_DEFINE_UNQUOTED([M4_GNU_OPTION], ["$M4_GNU"], [Define to "-g" if GNU M4
226 supports -g, otherwise to "".])
227 AC_PATH_PROG([PERL], [perl])
228 if test -z "$PERL"; then
229 AC_MSG_ERROR([perl not found])
231 AM_MISSING_PROG([HELP2MAN], [help2man])
232 AC_PATH_PROG([XSLTPROC], [xsltproc])
235 # Checks for header files.
236 AC_CHECK_HEADERS_ONCE([locale.h])
238 # Checks for compiler characteristics.
241 # Gnulib (later checks). Putting them here rather than right after
242 # gl_EARLY avoids some redundant checks.
245 # Checks for library functions.
246 AC_CHECK_FUNCS_ONCE([setlocale])
250 # We use gnulib, which is only guaranteed to work properly with the
252 AM_GNU_GETTEXT([external], [need-ngettext])
253 AM_GNU_GETTEXT_VERSION([0.19])
255 AC_CONFIG_FILES([gnulib-po/Makefile.in])
257 # Internationalized parsers.
258 AC_CONFIG_FILES([runtime-po/Makefile.in])
259 # Autoconf macros for packages using internationalized parsers.
260 aclocaldir='${datadir}/aclocal'
261 AC_SUBST([aclocaldir])
263 # Create the benchmark script.
264 AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
266 # Initialize the test suite.
267 AC_CONFIG_TESTDIR(tests)
268 AC_CONFIG_FILES([tests/atlocal])
269 AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
271 AC_CHECK_PROGS([VALGRIND], [valgrind])
272 # Use something simpler that $host_os to select our suppression file.
274 case $VALGRIND:$uname in
277 # See README-hacking.
280 suppfile=build-aux/$uname.valgrind
281 if test -f "$srcdir/$suppfile"; then
282 AC_SUBST([VALGRIND_OPTS_SUPPRESSION],
283 ["--suppressions=\$(abs_top_srcdir)/$suppfile"])
287 AC_MSG_CHECKING([Valgrind suppression file])
288 AC_MSG_RESULT([$suppfile])
290 # Whether we cannot run the compiled bison.
291 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
293 AM_MISSING_PROG([AUTOM4TE], [autom4te])
294 # Needed by tests/atlocal.in.
297 AC_CONFIG_FILES([Makefile
301 # Fix LIBOBJS to give the Makefile the right file names. Otherwise
302 # compilation works, but with unexpected file names, so clean rules don't
303 # remove the actual files and distcheck fails.
304 AC_CONFIG_COMMANDS_PRE([
305 case $am__api_version in
306 1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
307 *) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;