1 # Configure template for GNU m4. -*-Autoconf-*-
2 # Copyright (C) 1991-1994, 2000-2002, 2004-2013 Free Software
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/>.
20 dnl We depend on autotest's ./testsuite -C.
23 ## ------------------------ ##
24 ## Autoconf initialization. ##
25 ## ------------------------ ##
26 m4_define([M4_VERSION],
27 m4_esyscmd([build-aux/git-version-gen .tarball-version]))
28 m4_bmatch(m4_defn([M4_VERSION]), [^[0-9]], [],
29 [m4_define([M4_VERSION], [1.9a])])
30 AC_INIT([GNU M4], m4_defn([M4_VERSION]), [bug-m4@gnu.org])
32 AC_CONFIG_SRCDIR([src/m4.h])
33 AC_CONFIG_AUX_DIR([build-aux])
34 AC_CONFIG_MACRO_DIR([build-aux/m4])
35 AC_CONFIG_LIBOBJ_DIR([m4/gnu])
36 AC_CONFIG_TESTDIR([tests])
37 AC_CONFIG_HEADERS([config.h])
38 AC_CONFIG_FILES([tests/m4], [chmod +x tests/m4])
41 ## -------------------------- ##
42 ## M4 specific configuration. ##
43 ## -------------------------- ##
44 dnl Autoconf recommends that packages use lowercase for their package-specific
45 dnl prefix for cache variables. But in the case of m4, that collides with
46 dnl the m4_ namespace provided by m4sugar, so we prefer M4_ as our
47 dnl package-specific prefix.
48 m4_pattern_forbid([^M4_[A-Z]])
50 AC_DEFUN([M4_DEFAULT_PRELOAD], [])
51 M4_default_preload="M4_DEFAULT_PRELOAD"
54 ## ------------------------ ##
55 ## Automake Initialization. ##
56 ## ------------------------ ##
57 AM_INIT_AUTOMAKE([1.10b subdir-objects dist-bzip2 dist-xz
58 color-tests parallel-tests silent-rules]
59 m4_if(m4_index(m4_defn([M4_VERSION]), [-]), [-1], [gnits], [gnu]))
60 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
63 ## ------------------ ##
64 ## C compiler checks. ##
65 ## ------------------ ##
67 AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])
70 # Maintainer note - comment this line out if you plan to rerun
71 # GNULIB_POSIXCHECK testing to see if M4 should be using more modules.
72 # Leave it uncommented for normal releases, for faster ./configure.
73 gl_ASSERT_NO_GNULIB_POSIXCHECK
81 ## ----------------------- ##
82 ## Libtool initialization. ##
83 ## ----------------------- ##
85 LT_INIT([shared dlopen win32-dll])
87 AC_ARG_ENABLE([gcc-warnings],
88 [AS_HELP_STRING([--enable-gcc-warnings],
89 [turn on lots of GCC warnings (for developers)])],
92 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
94 gl_gcc_warnings=$enableval],
98 if test "$gl_gcc_warnings" = yes; then
99 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
100 AC_SUBST([WERROR_CFLAGS])
102 # This, $nw, is the list of warnings we disable.
104 nw="$nw -Waggregate-return" # K&R is anachronistic
105 nw="$nw -Wtraditional-conversion" # K&R is anachronistic
106 nw="$nw -Wundef" # K&R is anachronistic
107 nw="$nw -Wlong-long" # C90 is anachronistic
108 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
109 nw="$nw -Wpadded" # Our structs are not packed
110 nw="$nw -Wformat-nonliteral" # Needed in builtin.c
111 nw="$nw -Wconversion" # Too many warnings for now
112 nw="$nw -Wsign-conversion" # Too many warnings for now
113 nw="$nw -Wcast-qual" # Too many warnings for now
114 nw="$nw -Wswitch-enum" # Too many warnings for now
115 # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
116 nw="$nw -Wenum-compare"
118 # Gnulib uses '#pragma GCC diagnostic push' to silence some
119 # warnings, but older gcc doesn't support this.
120 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
121 [M4_cv_gcc_pragma_push_works], [
123 CFLAGS='-Wunknown-pragmas -Werror'
124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
125 #pragma GCC diagnostic push
126 #pragma GCC diagnostic pop
128 [M4_cv_gcc_pragma_push_works=yes],
129 [M4_cv_gcc_pragma_push_works=no])
130 CFLAGS=$save_CFLAGS])
131 if test $M4_cv_gcc_pragma_push_works = no; then
132 nw="$nw -Wmissing-prototypes"
133 nw="$nw -Wmissing-declarations"
134 nw="$nw -Wunreachable-code"
137 gl_MANYWARN_ALL_GCC([ws])
138 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
143 gl_WARN_ADD([-fdiagnostics-show-option])
144 gl_WARN_ADD([-funit-at-a-time])
146 AC_SUBST([WARN_CFLAGS])
148 AH_VERBATIM([FORTIFY_SOURCE],
149 [/* Enable compile-time and run-time bounds-checking, and some warnings,
150 without upsetting newer glibc. */
151 #if defined __OPTIMIZE__ && __OPTIMIZE__
152 # define _FORTIFY_SOURCE 2
157 # Use gcc's -pipe option if available: for faster compilation.
160 * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
161 [M4_cv_prog_compiler_pipe],
162 [-pipe -c conftest.$ac_ext], [],
163 [CFLAGS="$CFLAGS -pipe"])
167 ## ------------------------------- ##
168 ## Preloaded module configuration. ##
169 ## ------------------------------- ##
170 AS_IF([test "x$enable_shared" != xno],
171 [DYNAMIC_MODULES=yes], [DYNAMIC_MODULES=no])
172 AC_SUBST([DYNAMIC_MODULES], [$DYNAMIC_MODULES])
174 AC_MSG_CHECKING([for modules to preload])
177 AC_ARG_WITH([modules],
178 [AS_HELP_STRING([--with-modules=MODULES],
179 [preload MODULES @<:@default: ]M4_DEFAULT_PRELOAD[@:>@])],
180 [use_modules="$withval"],
181 [use_modules="$M4_default_preload"])
183 PREOPEN_DEPENDENCIES=
184 DLPREOPEN="-dlpreopen force"
185 if test -z "$use_modules"; then
188 if test "$use_modules" != yes; then
189 for module in $use_modules; do
192 m4|traditional|gnu|load|mpeval) dir=modules ;;
193 import|modtest|shadow|stdlib|time) dir=tests ;;
194 *) AC_MSG_ERROR([Unrecognized module `$module' in --with-modules])
197 DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
198 PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
202 AC_MSG_RESULT([$use_modules])
203 AC_SUBST([DLPREOPEN])
204 AC_SUBST([PREOPEN_DEPENDENCIES])
207 ## ---------------- ##
208 ## Gettext support. ##
209 ## ---------------- ##
210 AM_GNU_GETTEXT([external])
211 AM_GNU_GETTEXT_NEED([need-formatstring-macros])
212 AM_GNU_GETTEXT_VERSION([0.16])
217 ## --------------- ##
218 ## Gnulib support. ##
219 ## --------------- ##
224 # Gnulib doesn't always do things quite the way M4 would like...
232 ## --------------------------- ##
233 ## C compiler characteristics. ##
234 ## --------------------------- ##
236 AC_CHECK_SIZEOF([long long int])
240 ## ------------------------- ##
241 ## C headers required by M4. ##
242 ## ------------------------- ##
243 AC_CHECK_HEADERS_ONCE([limits.h])
245 if test $ac_cv_header_stdbool_h = yes; then
246 INCLUDE_STDBOOL_H='#include <stdbool.h>'
248 INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
250 AC_SUBST([INCLUDE_STDBOOL_H])
254 ## --------------------------------- ##
255 ## Library functions required by M4. ##
256 ## --------------------------------- ##
257 AC_CHECK_FUNCS_ONCE([calloc strerror])
263 # This is for the modules
266 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
269 ## ------------------ ##
270 ## Configure options. ##
271 ## ------------------ ##
274 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
284 m4/system.h:m4/system_.h