1 # Configure template for GNU M4. -*-Autoconf-*-
2 # Copyright (C) 1991, 1993-1994, 2004-2011 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.1 dist-bzip2 dist-xz color-tests parallel-tests
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],
56 if test "$gl_gcc_warnings" = yes; then
57 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
58 AC_SUBST([WERROR_CFLAGS])
61 nw="$nw -Waggregate-return" # C90 is anachronistic
62 nw="$nw -Wlong-long" # C90 is anachronistic
63 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
64 nw="$nw -Wtraditional" # Warns on #elif which we use often
65 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
66 nw="$nw -Wpadded" # Our structs are not packed
67 nw="$nw -Wredundant-decls" # Gnulib has multiple decls
68 nw="$nw -Wformat-nonliteral" # Needed in builtin.c
69 nw="$nw -Wunreachable-code" # Needed in output.c
70 nw="$nw -Wconversion" # Too many warnings for now
71 nw="$nw -Wsign-conversion" # Too many warnings for now
72 nw="$nw -Wtraditional-conversion" # Too many warnings for now
73 nw="$nw -Wcast-qual" # Too many warnings for now
74 nw="$nw -Wswitch-enum" # Too many warnings for now
75 # This, $nw, is the list of warnings we disable.
77 gl_MANYWARN_ALL_GCC([ws])
78 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
83 gl_WARN_ADD([-fdiagnostics-show-option])
84 gl_WARN_ADD([-funit-at-a-time])
86 AC_SUBST([WARN_CFLAGS])
88 AC_DEFINE([_FORTIFY_SOURCE], [2],
89 [enable compile-time and run-time bounds-checking, and some warnings])
92 # Tandem/NSK is broken - it has 'long long int' but not
93 # 'unsigned long long int', which confuses assumptions made by gnulib.
94 # Simply pretend that neither type exists if both do not work.
96 AC_TYPE_UNSIGNED_LONG_LONG_INT
97 if test $ac_cv_type_long_long_int:$ac_cv_type_unsigned_long_long_int = yes:no
99 ac_cv_type_long_long_int=no
100 AC_DEFINE([HAVE_LONG_LONG_INT], 0,
101 [Define to 1 if the system has the type `long long int'.])
106 AC_CACHE_CHECK([whether an open file can be renamed],
107 [M4_cv_func_rename_open_file_works],
108 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
109 [FILE *f = fopen ("conftest.1", "w+");
110 int result = rename ("conftest.1", "conftest.2");
111 fclose (f); remove ("conftest.1"); remove ("conftest.2");
113 [M4_cv_func_rename_open_file_works=yes],
114 [M4_cv_func_rename_open_file_works=no],
115 [M4_cv_func_rename_open_file_works='guessing no'])])
116 if test "$M4_cv_func_rename_open_file_works" = yes ; then
117 M4_rename_open_works=1
119 M4_rename_open_works=0
121 AC_DEFINE_UNQUOTED([RENAME_OPEN_FILE_WORKS], [$M4_rename_open_works],
122 [Define to 1 if a file can be renamed while open, or to 0 if not.])
124 dnl Don't let changeword get in our way, if bootstrapping with a version of
125 dnl m4 that already turned the feature on.
126 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
128 AC_MSG_CHECKING([[if changeword is wanted]])
129 AC_ARG_ENABLE([changeword],
130 [AS_HELP_STRING([--enable-changeword],
131 [enable -W and changeword() builtin])],
132 [if test "$enableval" = yes; then
134 AC_DEFINE([ENABLE_CHANGEWORD], [1],
135 [Define to 1 if the changeword(REGEXP) functionality is wanted])
138 fi], [AC_MSG_RESULT([no])])
140 AC_MSG_CHECKING([[which shell to use for syscmd]])
141 AC_ARG_WITH([syscmd-shell],
142 [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
144 yes[)] with_syscmd_shell=no;;
145 esac], [with_syscmd_shell=no])
146 if test "$with_syscmd_shell" = no ; then
147 with_syscmd_shell=/bin/sh
148 if test "$cross_compiling" != yes ; then
149 dnl Give mingw a default that is more likely to be available.
150 AS_IF([AS_EXECUTABLE_P([/bin/sh])], [],
151 [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
152 dnl Too bad _AS_PATH_WALK is not public.
153 M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
154 for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
155 command -p getconf PATH
157 echo "/bin$PATH_SEPARATOR$PATH"
161 test -z "$M4_dir" && continue
162 AS_EXECUTABLE_P(["$M4_dir/sh"]) \
163 && { with_syscmd_shell=$M4_dir/sh; break; }
168 AC_MSG_RESULT([$with_syscmd_shell])
169 AC_DEFINE_UNQUOTED([SYSCMD_SHELL], ["$with_syscmd_shell"],
170 [Shell used by syscmd and esyscmd, must accept -c argument.])
174 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
176 AC_CONFIG_FILES([Makefile