c: port YY_ATTRIBUTE_UNUSED to Sun C 5.12
[bison.git] / configure.ac
blob0c1efde1f7fa4b124c0f63a19492a70b4d60b8e7
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.
23 AC_PREREQ([2.68])
24 m4_pattern_forbid([^_?(gl_[A-Z]|AX_|BISON_)])
25 m4_pattern_allow([^BISON_USE_NLS$])
27 AC_INIT([GNU Bison],
28         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
29         [bug-bison@gnu.org])
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
47                  silent-rules]
48                  m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-_]],
49                            [gnu], [gnits]))
50 AM_SILENT_RULES([yes])
51 AC_CONFIG_HEADERS([lib/config.h:lib/config.in.h])
53 # Checks for the compiler.
54 AC_PROG_CC_STDC
55 AC_PROG_CXX
57 # Gnulib (early checks).
58 gl_EARLY
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], [
64   save_CFLAGS=$CFLAGS
65   CFLAGS='-Wunknown-pragmas -Werror'
66   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
67     #pragma GCC diagnostic push
68     #pragma GCC diagnostic pop
69   ]])],
70   [lv_cv_gcc_pragma_push_works=yes],
71   [lv_cv_gcc_pragma_push_works=no])
72   CFLAGS=$save_CFLAGS])
74 AC_LANG_PUSH([C++])
75 gl_WARN_ADD([-fno-exceptions], [NO_EXCEPTIONS_CXXFLAGS])
76 BISON_CXXSTD([98])
77 BISON_CXXSTD([03])
78 BISON_CXXSTD([11])
79 BISON_CXXSTD([14])
80 BISON_CXXSTD([17])
81 BISON_CXXSTD([2a])
82 AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x])
83 AM_CONDITIONAL([ENABLE_CXX14], [test x"$CXX14_CXXFLAGS" != x])
84 AC_LANG_POP([C++])
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
91    yes|no) ;;
92    *)  AC_MSG_ERROR([invalid value for --gcc-warnings: $enable_gcc_warnings]);;
93  esac],
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
101     -Wwrite-strings'
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.
105   #
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).
109   #
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
116     -Wno-keyword-macro'
119   AC_LANG_PUSH([C])
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
125   # error.
126   #
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.
130   save_CFLAGS=$CFLAGS
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
133   # and 3.4).
134   gl_WARN_ADD([-Wunreachable-code], [WARN_CFLAGS],
135               [AC_LANG_PROGRAM([],
136               [[if (sizeof (long) < sizeof (int)) return 1;]])])
137   for i in $warn_common $warn_c;
138   do
139     gl_WARN_ADD([$i], [WARN_CFLAGS])
140   done
141   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
143   # Warnings for the test suite, and maybe for bison if GCC is modern
144   # enough.
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;
152   do
153     gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
154   done
155   CFLAGS=$save_CFLAGS
156   AC_LANG_POP([C])
159   AC_LANG_PUSH([C++])
160   save_CXXFLAGS=$CXXFLAGS
161   gl_WARN_ADD([-Werror=unknown-warning-option], [CXXFLAGS])
162   for i in $warn_common $warn_cxx;
163   do
164     gl_WARN_ADD([$i], [WARN_CXXFLAGS])
165   done
166   # Accept this warning only if it is not too touchy (e.g., clang 3.3
167   # and 3.4).
168   gl_WARN_ADD([-Wunreachable-code], [WARN_CXXFLAGS],
169               [AC_LANG_PROGRAM([],
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;
176   do
177     gl_WARN_ADD([$i], [WARN_CXXFLAGS_TEST])
178   done
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
184   AC_LANG_POP([C++])
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
193 # D.
194 AC_CHECK_PROGS([DC], [dmd])
195 AC_CHECK_PROGS([DCFLAGS], [-g])
196 AM_CONDITIONAL([ENABLE_D], [test x"$DC" != x])
198 # Java.
199 gt_JAVACOMP([1.7], [1.7])
200 gt_JAVAEXEC
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])],
207   , [enable_yacc=yes])
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])
213 AC_PROG_LEX
214 if ! "$LEX_IS_FLEX" || test "X$LEX" = X:; then
215   AC_MSG_WARN([bypassing lex because flex is required])
216   LEX=:
218 AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX])
219 AM_CONDITIONAL([FLEX_CXX_WORKS],
220   [$LEX_IS_FLEX && test $bison_cv_cxx_works = yes])
221 AC_PROG_YACC
222 AC_PROG_RANLIB
223 AC_PROG_GNU_M4
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 AM_MISSING_PROG([HELP2MAN], [help2man])
229 AC_PATH_PROG([XSLTPROC], [xsltproc])
230 AC_SUBST([XSLTPROC])
232 # Checks for header files.
233 AC_CHECK_HEADERS_ONCE([locale.h])
235 # Checks for compiler characteristics.
236 AC_C_INLINE
238 # Gnulib (later checks).  Putting them here rather than right after
239 # gl_EARLY avoids some redundant checks.
240 gl_INIT
242 # Checks for library functions.
243 AC_CHECK_FUNCS_ONCE([setlocale])
244 AM_WITH_DMALLOC
246 # Gettext.
247 # We use gnulib, which is only guaranteed to work properly with the
248 # latest Gettext.
249 AM_GNU_GETTEXT([external], [need-ngettext])
250 AM_GNU_GETTEXT_VERSION([0.19])
251 BISON_I18N
252 AC_CONFIG_FILES([gnulib-po/Makefile.in])
254 # Internationalized parsers.
255 AC_CONFIG_FILES([runtime-po/Makefile.in])
256 # Autoconf macros for packages using internationalized parsers.
257 aclocaldir='${datadir}/aclocal'
258 AC_SUBST([aclocaldir])
260 # Create the benchmark script.
261 AC_CONFIG_FILES([etc/bench.pl], [chmod +x etc/bench.pl])
263 # Initialize the test suite.
264 AC_CONFIG_TESTDIR(tests)
265 AC_CONFIG_FILES([tests/atlocal])
266 AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
268 AC_CHECK_PROGS([VALGRIND], [valgrind])
269 # Use something simpler that $host_os to select our suppression file.
270 uname=`uname`
271 case $VALGRIND:$uname in
272   '':*) ;;
273   *:Darwin)
274     # See README-hacking.
275     VALGRIND=;;
276   *:*)
277     suppfile=build-aux/$uname.valgrind
278     if test -f "$srcdir/$suppfile"; then
279       AC_SUBST([VALGRIND_OPTS_SUPPRESSION],
280                ["--suppressions=\$(abs_top_srcdir)/$suppfile"])
281     fi
282     ;;
283 esac
284 AC_MSG_CHECKING([Valgrind suppression file])
285 AC_MSG_RESULT([$suppfile])
287 # Whether we cannot run the compiled bison.
288 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
290 AM_MISSING_PROG([AUTOM4TE], [autom4te])
291 # Needed by tests/atlocal.in.
292 AC_SUBST([GCC])
294 AC_CONFIG_FILES([Makefile
295                  po/Makefile.in
296                  doc/yacc.1])
298 # Fix LIBOBJS to give the Makefile the right file names.  Otherwise
299 # compilation works, but with unexpected file names, so clean rules don't
300 # remove the actual files and distcheck fails.
301 AC_CONFIG_COMMANDS_PRE([
302   case $am__api_version in
303     1.14*|1.15*) gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/lib_libbison_a-,g'`;;
304     *)           gl_LIBOBJS=`echo "$gl_LIBOBJS" | sed -e 's, lib/, lib/libbison_a-,g'`;;
305   esac
308 AC_OUTPUT