1 # Configure template for GNU M4. -*-Autoconf-*-
2 # Copyright (C) 1991, 1993-1994, 2004-2013 Free Software Foundation,
5 # This file is part of GNU M4.
7 # GNU M4 is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # GNU M4 is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 AC_INIT([GNU M4], m4_esyscmd([build-aux/git-version-gen .tarball-version]),
23 AC_CONFIG_AUX_DIR([build-aux])
25 AM_INIT_AUTOMAKE([1.11.6 dist-bzip2 dist-xz color-tests parallel-tests
26 silent-rules subdir-objects gnu])
28 m4_pattern_forbid([^M4_[A-Z]])
30 AC_CONFIG_SRCDIR([src/m4.h])
31 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
34 AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])
37 # Maintainer note - comment this line out if you plan to rerun
38 # GNULIB_POSIXCHECK testing to see if M4 should be using more modules.
39 # Leave it uncommented for normal releases, for faster ./configure.
40 gl_ASSERT_NO_GNULIB_POSIXCHECK
42 # M4 is single-threaded; so we can optimize gnulib code by using this:
45 AC_ARG_ENABLE([gcc-warnings],
46 [AS_HELP_STRING([--enable-gcc-warnings],
47 [turn on lots of GCC warnings (for developers)])],
50 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
52 gl_gcc_warnings=$enableval],
53 [if test -d "$srcdir"/.git; then
60 if test "$gl_gcc_warnings" = yes; then
61 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
62 AC_SUBST([WERROR_CFLAGS])
64 # We use '#pragma GCC diagnostic push' to silence some
65 # warnings, but older gcc doesn't support this.
66 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
67 [M4_cv_gcc_pragma_push_works], [
69 CFLAGS='-Wunknown-pragmas -Werror'
70 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
71 #pragma GCC diagnostic push
72 #pragma GCC diagnostic pop
74 [M4_cv_gcc_pragma_push_works=yes],
75 [M4_cv_gcc_pragma_push_works=no])
78 # This, $nw, is the list of warnings we disable.
80 nw="$nw -Waggregate-return" # K&R is anachronistic
81 nw="$nw -Wtraditional-conversion" # K&R is anachronistic
82 nw="$nw -Wundef" # K&R is anachronistic
83 nw="$nw -Wtraditional" # K&R is anachronistic
84 nw="$nw -Wlong-long" # C90 is anachronistic
85 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
86 nw="$nw -Wpadded" # Our structs are not packed
87 nw="$nw -Wconversion" # Too many warnings for now
88 nw="$nw -Wsign-conversion" # Too many warnings for now
89 nw="$nw -Wcast-qual" # Too many warnings for now
90 nw="$nw -Wswitch-enum" # Too many warnings for now
91 # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
92 nw="$nw -Wenum-compare"
94 # Gnulib uses '#pragma GCC diagnostic push' to silence some
95 # warnings, but older gcc doesn't support this.
96 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
97 [M4_cv_gcc_pragma_push_works], [
99 CFLAGS='-Wunknown-pragmas -Werror'
100 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
101 #pragma GCC diagnostic push
102 #pragma GCC diagnostic pop
104 [M4_cv_gcc_pragma_push_works=yes],
105 [M4_cv_gcc_pragma_push_works=no])
106 CFLAGS=$save_CFLAGS])
107 if test $M4_cv_gcc_pragma_push_works = no; then
108 nw="$nw -Wmissing-prototypes"
109 nw="$nw -Wmissing-declarations"
110 nw="$nw -Wunreachable-code"
113 gl_MANYWARN_ALL_GCC([ws])
114 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
119 # Gnulib turns on -Wformat=2, which implies -Wformat-nonliteral, but
120 # we temporarily override it in format.c if possible.
121 if test $M4_cv_gcc_pragma_push_works = no; then
122 gl_WARN_ADD([-Wno-format-nonliteral])
125 gl_WARN_ADD([-fdiagnostics-show-option])
126 gl_WARN_ADD([-funit-at-a-time])
128 AC_SUBST([WARN_CFLAGS])
130 AH_VERBATIM([FORTIFY_SOURCE],
131 [/* Enable compile-time and run-time bounds-checking, and some warnings,
132 without upsetting newer glibc. */
133 #if defined __OPTIMIZE__ && __OPTIMIZE__
134 # define _FORTIFY_SOURCE 2
139 # Tandem/NSK is broken - it has 'long long int' but not
140 # 'unsigned long long int', which confuses assumptions made by gnulib.
141 # Simply pretend that neither type exists if both do not work.
142 AC_TYPE_LONG_LONG_INT
143 AC_TYPE_UNSIGNED_LONG_LONG_INT
144 if test $ac_cv_type_long_long_int:$ac_cv_type_unsigned_long_long_int = yes:no
146 ac_cv_type_long_long_int=no
147 AC_DEFINE([HAVE_LONG_LONG_INT], 0,
148 [Define to 1 if the system has the type `long long int'.])
153 AC_CACHE_CHECK([whether an open file can be renamed],
154 [M4_cv_func_rename_open_file_works],
155 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
156 [FILE *f = fopen ("conftest.1", "w+");
157 int result = rename ("conftest.1", "conftest.2");
158 fclose (f); remove ("conftest.1"); remove ("conftest.2");
160 [M4_cv_func_rename_open_file_works=yes],
161 [M4_cv_func_rename_open_file_works=no],
162 [M4_cv_func_rename_open_file_works='guessing no'])])
163 if test "$M4_cv_func_rename_open_file_works" = yes ; then
164 M4_rename_open_works=1
166 M4_rename_open_works=0
168 AC_DEFINE_UNQUOTED([RENAME_OPEN_FILE_WORKS], [$M4_rename_open_works],
169 [Define to 1 if a file can be renamed while open, or to 0 if not.])
171 dnl Don't let changeword get in our way, if bootstrapping with a version of
172 dnl m4 that already turned the feature on.
173 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
175 AC_MSG_CHECKING([[if changeword is wanted]])
176 AC_ARG_ENABLE([changeword],
177 [AS_HELP_STRING([--enable-changeword],
178 [enable -W and changeword() builtin])],
179 [if test "$enableval" = yes; then
181 AC_DEFINE([ENABLE_CHANGEWORD], [1],
182 [Define to 1 if the changeword(REGEXP) functionality is wanted])
185 fi], [AC_MSG_RESULT([no])])
187 AC_MSG_CHECKING([[which shell to use for syscmd]])
188 AC_ARG_WITH([syscmd-shell],
189 [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
191 yes[)] with_syscmd_shell=no;;
192 esac], [with_syscmd_shell=no])
193 if test "$with_syscmd_shell" = no ; then
194 with_syscmd_shell=/bin/sh
195 if test "$cross_compiling" != yes ; then
196 dnl Give mingw a default that is more likely to be available.
197 AS_IF([AS_EXECUTABLE_P([/bin/sh])], [],
198 [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
199 dnl Too bad _AS_PATH_WALK is not public.
200 M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
201 for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
202 command -p getconf PATH
204 echo "/bin$PATH_SEPARATOR$PATH"
208 test -z "$M4_dir" && continue
209 AS_EXECUTABLE_P(["$M4_dir/sh"]) \
210 && { with_syscmd_shell=$M4_dir/sh; break; }
215 AC_MSG_RESULT([$with_syscmd_shell])
216 AC_DEFINE_UNQUOTED([SYSCMD_SHELL], ["$with_syscmd_shell"],
217 [Shell used by syscmd and esyscmd, must accept -c argument.])
221 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
223 AC_CONFIG_FILES([Makefile