1 # Configure template for GNU m4. -*-Autoconf-*-
2 # Copyright (C) 1991-1994, 2000-2002, 2004-2014 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 ## C compiler characteristics. ##
83 ## --------------------------- ##
85 AC_CHECK_SIZEOF([long long int])
87 AS_CASE([$host], [*-*-os2*], [OS2_LDFLAGS=-Zargs-resp])
88 AC_SUBST([OS2_LDFLAGS])
91 ## ----------------------- ##
92 ## Libtool initialization. ##
93 ## ----------------------- ##
95 LT_INIT([shared dlopen win32-dll])
97 AC_ARG_ENABLE([gcc-warnings],
98 [AS_HELP_STRING([--enable-gcc-warnings],
99 [turn on lots of GCC warnings (for developers)])],
102 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
104 gl_gcc_warnings=$enableval],
108 if test "$gl_gcc_warnings" = yes; then
109 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
110 AC_SUBST([WERROR_CFLAGS])
112 # This, $nw, is the list of warnings we disable.
114 nw="$nw -Waggregate-return" # K&R is anachronistic
115 nw="$nw -Wtraditional-conversion" # K&R is anachronistic
116 nw="$nw -Wundef" # K&R is anachronistic
117 nw="$nw -Wlong-long" # C90 is anachronistic
118 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
119 nw="$nw -Wpadded" # Our structs are not packed
120 nw="$nw -Wformat-nonliteral" # Needed in builtin.c
121 nw="$nw -Wconversion" # Too many warnings for now
122 nw="$nw -Wsign-conversion" # Too many warnings for now
123 nw="$nw -Wcast-qual" # Too many warnings for now
124 nw="$nw -Wswitch-enum" # Too many warnings for now
125 # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
126 nw="$nw -Wenum-compare"
128 # Gnulib uses '#pragma GCC diagnostic push' to silence some
129 # warnings, but older gcc doesn't support this.
130 AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
131 [M4_cv_gcc_pragma_push_works], [
133 CFLAGS='-Wunknown-pragmas -Werror'
134 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
135 #pragma GCC diagnostic push
136 #pragma GCC diagnostic pop
138 [M4_cv_gcc_pragma_push_works=yes],
139 [M4_cv_gcc_pragma_push_works=no])
140 CFLAGS=$save_CFLAGS])
141 if test $M4_cv_gcc_pragma_push_works = no; then
142 nw="$nw -Wmissing-prototypes"
143 nw="$nw -Wmissing-declarations"
144 nw="$nw -Wunreachable-code"
147 gl_MANYWARN_ALL_GCC([ws])
148 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
153 gl_WARN_ADD([-fdiagnostics-show-option])
154 gl_WARN_ADD([-funit-at-a-time])
156 AC_SUBST([WARN_CFLAGS])
158 AH_VERBATIM([FORTIFY_SOURCE],
159 [/* Enable compile-time and run-time bounds-checking, and some warnings,
160 without upsetting newer glibc. */
161 #if defined __OPTIMIZE__ && __OPTIMIZE__
162 # define _FORTIFY_SOURCE 2
167 # Use gcc's -pipe option if available: for faster compilation.
170 * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
171 [M4_cv_prog_compiler_pipe],
172 [-pipe -c conftest.$ac_ext], [],
173 [CFLAGS="$CFLAGS -pipe"])
178 ## ------------------------------- ##
179 ## Dynamic Loader Characteristics. ##
180 ## ------------------------------- ##
187 if test yes = "$sys_symbol_underscore"; then
188 libm4_shlibext=$libltdl_cv_shlibext
190 AC_MSG_CHECKING([whether dlsym requires underscore prefixed symbols])
191 AC_CACHE_VAL([libm4_cv_sys_dlsym_uscore], [dnl
192 libname=conftmod # stay within 8.3 filename limits!
193 cat >$libname.$ac_ext <<_M4_EOF
194 [#line $LINENO "configure"
195 #include "confdefs.h"
196 /* When -fvisibility=hidden is used, assume the code has been annotated
197 correspondingly for the symbols needed. */
198 #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
199 int fnord () __attribute__((visibility("default")));
201 int fnord () { return 42; }]
204 # fn_module_cmds module_cmds
205 # Execute tilde-delimited MODULE_CMDS with environment primed for
206 # ${module_cmds} or ${archive_cmds} type content.
208 {( # subshell avoids polluting parent global environment
209 module_cmds_save_ifs=$IFS; IFS='~'
211 IFS=$module_cmds_save_ifs
212 libobjs=$libname.$ac_objext; lib=$libname$libm4_shlibext
213 rpath=/not-exists; soname=$libname$libm4_shlibext; output_objdir=.
214 major=; versuffix=; verstring=; deplibs=
215 ECHO=echo; wl=$lt_prog_compiler_wl; allow_undefined_flag=
218 IFS=$module_cmds_save_ifs
221 # Compile a loadable module using libtool macro expansion results.
222 $CC $pic_flag -c $libname.$ac_ext
223 fn_module_cmds "${module_cmds:-$archive_cmds}"
225 # Try to fetch fnord with dlsym().
226 libm4_dlunknown=0; libm4_dlnouscore=1; libm4_dluscore=2
227 cat >conftest.$ac_ext <<_M4_EOF
228 [#line $LINENO "configure"
229 #include "confdefs.h"
236 # define RTLD_GLOBAL DL_GLOBAL
238 # define RTLD_GLOBAL 0
243 # define RTLD_NOW DL_NOW
249 void *handle = dlopen ("`pwd`/$libname$libm4_shlibext", RTLD_GLOBAL|RTLD_NOW);
250 int status = $libm4_dlunknown;
252 if (dlsym (handle, "fnord"))
253 status = $libm4_dlnouscore;
255 if (dlsym (handle, "_fnord"))
256 status = $libm4_dluscore;
266 if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
267 (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
269 case x$libm4_status in
270 x$libm4_dlnouscore) libm4_cv_sys_dlsym_uscore=no ;;
271 x$libm4_dluscore) libm4_cv_sys_dlsym_uscore=yes ;;
272 x*) libm4_cv_sys_dlsym_uscore=unknown ;;
275 rm -rf conftest* $libname*
277 sys_dlsym_uscore=$libm4_cv_sys_dlsym_uscore
278 AC_MSG_RESULT($sys_dlsym_uscore)
279 if test yes = "$sys_dlsym_uscore"; then
280 AC_DEFINE([DLSYM_USCORE], [1],
281 [Define if dlsym() requires a leading underscore in symbol names.])
285 AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['$PATH_SEPARATOR'],
286 [Define this to system search path delimiter])
289 ## ---------------- ##
290 ## Gettext support. ##
291 ## ---------------- ##
292 AM_GNU_GETTEXT([external])
293 AM_GNU_GETTEXT_NEED([need-formatstring-macros])
294 AM_GNU_GETTEXT_VERSION([0.16])
298 ## --------------- ##
299 ## Gnulib support. ##
300 ## --------------- ##
305 # Gnulib doesn't always do things quite the way M4 would like...
313 ## ------------------------- ##
314 ## C headers required by M4. ##
315 ## ------------------------- ##
316 AC_CHECK_HEADERS_ONCE([limits.h])
318 if test $ac_cv_header_stdbool_h = yes; then
319 INCLUDE_STDBOOL_H='#include <stdbool.h>'
321 INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
323 AC_SUBST([INCLUDE_STDBOOL_H])
326 ## --------------------------------- ##
327 ## Library functions required by M4. ##
328 ## --------------------------------- ##
329 AC_CHECK_FUNCS_ONCE([calloc strerror])
335 # This is for the modules
338 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
341 ## ------------------ ##
342 ## Configure options. ##
343 ## ------------------ ##
346 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
357 m4/system.h:m4/system_.h