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([ltdl/m4])
35 AC_CONFIG_LIBOBJ_DIR([gnu])
36 AC_CONFIG_TESTDIR([tests])
37 AC_CONFIG_HEADERS([gnu/config.h:gnu/config.hin])
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], [m4 traditional gnu])
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_CONFIG_LTDL_DIR([ltdl])
86 LT_INIT([shared dlopen win32-dll])
87 LTDL_INIT([nonrecursive])
89 # The lt_dlhandle_iterate symbol was added with libtool-2.2
90 if test "x$with_included_ltdl" != "xyes"; then
92 save_LDFLAGS="$LDFLAGS"
93 CFLAGS="$CFLAGS $LTDLINCL"
94 LDFLAGS="$LDFLAGS $LIBLTDL"
95 AC_CHECK_LIB([ltdl], [lt_dlhandle_iterate],
97 [AC_MSG_ERROR([installed libltdl is too old])])
98 LDFLAGS="$save_LDFLAGS"
102 AC_ARG_ENABLE([gcc-warnings],
103 [AS_HELP_STRING([--enable-gcc-warnings],
104 [turn on lots of GCC warnings (for developers)])],
107 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
109 gl_gcc_warnings=$enableval],
113 if test "$gl_gcc_warnings" = yes; then
114 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
115 AC_SUBST([WERROR_CFLAGS])
117 # This, $nw, is the list of warnings we disable.
119 nw="$nw -Waggregate-return" # K&R is anachronistic
120 nw="$nw -Wtraditional-conversion" # K&R is anachronistic
121 nw="$nw -Wundef" # K&R is anachronistic
122 nw="$nw -Wlong-long" # C90 is anachronistic
123 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
124 nw="$nw -Wpadded" # Our structs are not packed
125 nw="$nw -Wformat-nonliteral" # Needed in builtin.c
126 nw="$nw -Wconversion" # Too many warnings for now
127 nw="$nw -Wsign-conversion" # Too many warnings for now
128 nw="$nw -Wcast-qual" # Too many warnings for now
129 nw="$nw -Wswitch-enum" # Too many warnings for now
130 # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
131 nw="$nw -Wenum-compare"
133 # Gnulib uses '#pragma GCC diagnostic push' to silence some
134 # warnings, but older gcc doesn't support this.
135 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
136 [M4_cv_gcc_pragma_push_works], [
138 CFLAGS='-Wunknown-pragmas -Werror'
139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
140 #pragma GCC diagnostic push
141 #pragma GCC diagnostic pop
143 [M4_cv_gcc_pragma_push_works=yes],
144 [M4_cv_gcc_pragma_push_works=no])
145 CFLAGS=$save_CFLAGS])
146 if test $M4_cv_gcc_pragma_push_works = no; then
147 nw="$nw -Wmissing-prototypes"
148 nw="$nw -Wmissing-declarations"
149 nw="$nw -Wunreachable-code"
152 gl_MANYWARN_ALL_GCC([ws])
153 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
158 gl_WARN_ADD([-fdiagnostics-show-option])
159 gl_WARN_ADD([-funit-at-a-time])
161 AC_SUBST([WARN_CFLAGS])
163 AH_VERBATIM([FORTIFY_SOURCE],
164 [/* Enable compile-time and run-time bounds-checking, and some warnings,
165 without upsetting newer glibc. */
166 #if defined __OPTIMIZE__ && __OPTIMIZE__
167 # define _FORTIFY_SOURCE 2
172 # Use gcc's -pipe option if available: for faster compilation.
175 * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
176 [M4_cv_prog_compiler_pipe],
177 [-pipe -c conftest.$ac_ext], [],
178 [CFLAGS="$CFLAGS -pipe"])
182 ## ------------------------------- ##
183 ## Preloaded module configuration. ##
184 ## ------------------------------- ##
185 AS_IF([test "x$enable_shared" != xno],
186 [DYNAMIC_MODULES=yes], [DYNAMIC_MODULES=no])
187 AC_SUBST([DYNAMIC_MODULES], [$DYNAMIC_MODULES])
189 AC_MSG_CHECKING([for modules to preload])
192 AC_ARG_WITH([modules],
193 [AS_HELP_STRING([--with-modules=MODULES],
194 [preload MODULES @<:@default: ]M4_DEFAULT_PRELOAD[@:>@])],
195 [use_modules="$withval"],
196 [use_modules="$M4_default_preload"])
198 PREOPEN_DEPENDENCIES=
199 DLPREOPEN="-dlpreopen force"
200 if test -z "$use_modules"; then
203 if test "$use_modules" != yes; then
204 for module in $use_modules; do
207 m4|traditional|gnu|load|mpeval) dir=modules ;;
208 import|modtest|shadow|stdlib|time) dir=tests ;;
209 *) AC_MSG_ERROR([Unrecognized module `$module' in --with-modules])
212 DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
213 PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
217 AC_MSG_RESULT([$use_modules])
218 AC_SUBST([DLPREOPEN])
219 AC_SUBST([PREOPEN_DEPENDENCIES])
222 ## ---------------- ##
223 ## Gettext support. ##
224 ## ---------------- ##
225 AM_GNU_GETTEXT([external], [need-formatstring-macros])
226 AM_GNU_GETTEXT_VERSION([0.16])
231 ## --------------- ##
232 ## Gnulib support. ##
233 ## --------------- ##
238 # Gnulib doesn't always do things quite the way M4 would like...
246 ## ------------------------ ##
247 ## Other external programs. ##
248 ## ------------------------ ##
249 AC_PATH_PROG([PERL], [perl])
253 ## --------------------------- ##
254 ## C compiler characteristics. ##
255 ## --------------------------- ##
257 AC_CHECK_SIZEOF([long long int])
261 ## ------------------------- ##
262 ## C headers required by M4. ##
263 ## ------------------------- ##
264 AC_CHECK_HEADERS_ONCE([limits.h])
266 if test $ac_cv_header_stdbool_h = yes; then
267 INCLUDE_STDBOOL_H='#include <stdbool.h>'
269 INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
271 AC_SUBST([INCLUDE_STDBOOL_H])
275 ## --------------------------------- ##
276 ## Library functions required by M4. ##
277 ## --------------------------------- ##
278 AC_CHECK_FUNCS_ONCE([calloc strerror])
284 # This is for the modules
287 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
290 ## ------------------ ##
291 ## Configure options. ##
292 ## ------------------ ##
295 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
306 m4/system.h:m4/system_.h