modules: store module name in the module struct.
[m4/ericb.git] / configure.ac
blob904f6247abf2236aa03bf7419cb485a68efd8e52
1 # Configure template for GNU m4.           -*-Autoconf-*-
2 # Copyright (C) 1991-1994, 2000-2002, 2004-2013 Free Software
3 # Foundation, Inc.
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.
21 AC_PREREQ([2.62])
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 ## ------------------ ##
66 AC_PROG_CC
67 AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])
68 M4_EARLY
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
75 AC_SYS_LARGEFILE
76 AC_PROG_CPP
77 AM_PROG_CC_C_O
78 M4_CHECK_DEBUGGING
81 ## ----------------------- ##
82 ## Libtool initialization. ##
83 ## ----------------------- ##
84 LT_PREREQ([2.2])
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
91   save_CFLAGS="$CFLAGS"
92   save_LDFLAGS="$LDFLAGS"
93   CFLAGS="$CFLAGS $LTDLINCL"
94   LDFLAGS="$LDFLAGS $LIBLTDL"
95   AC_CHECK_LIB([ltdl], [lt_dlhandle_iterate],
96              [],
97      [AC_MSG_ERROR([installed libltdl is too old])])
98   LDFLAGS="$save_LDFLAGS"
99   CFLAGS="$save_CFLAGS"
102 AC_ARG_ENABLE([gcc-warnings],
103   [AS_HELP_STRING([--enable-gcc-warnings],
104                   [turn on lots of GCC warnings (for developers)])],
105   [case $enableval in
106      yes|no) ;;
107      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
108    esac
109    gl_gcc_warnings=$enableval],
110   [gl_gcc_warnings=no]
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.
118   nw=
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], [
137     save_CFLAGS=$CFLAGS
138     CFLAGS='-Wunknown-pragmas -Werror'
139     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
140       #pragma GCC diagnostic push
141       #pragma GCC diagnostic pop
142     ]])],
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"
150   fi
152   gl_MANYWARN_ALL_GCC([ws])
153   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
154   for w in $ws; do
155     gl_WARN_ADD([$w])
156   done
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
168    #endif
169   ])
172 # Use gcc's -pipe option if available: for faster compilation.
173 case "$CFLAGS" in
174   *-pipe* ) ;;
175         * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
176                 [M4_cv_prog_compiler_pipe],
177                 [-pipe -c conftest.$ac_ext], [],
178                 [CFLAGS="$CFLAGS -pipe"])
179               ;;
180 esac
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])
190   DLPREOPEN=
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
201     use_modules=none
202   else
203     if test "$use_modules" != yes; then
204       for module in $use_modules; do
205         case $module in
206           no|none) break ;;
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])
210             ;;
211         esac
212         DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
213         PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
214       done
215     fi
216   fi
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])
227 M4_GNU_GETTEXT
231 ## --------------- ##
232 ## Gnulib support. ##
233 ## --------------- ##
234 M4_INIT
236 gl_VERSION_ETC
238 # Gnulib doesn't always do things quite the way M4 would like...
239 M4_ERROR
240 M4_GETOPT
241 M4_OBSTACK
242 M4_REGEX
243 M4_RENAME
246 ## ------------------------ ##
247 ## Other external programs. ##
248 ## ------------------------ ##
249 AC_PATH_PROG([PERL], [perl])
253 ## --------------------------- ##
254 ## C compiler characteristics. ##
255 ## --------------------------- ##
256 AC_TYPE_SIZE_T
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>'
268 else
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])
280 AM_WITH_DMALLOC
282 M4_SYS_STACKOVF
284 # This is for the modules
285 AC_STRUCT_TM
286 AC_FUNC_STRFTIME
287 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
290 ## ------------------ ##
291 ## Configure options. ##
292 ## ------------------ ##
294 M4_LIB_GMP
295 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
296 M4_SYSCMD
299 ## -------- ##
300 ## Outputs. ##
301 ## -------- ##
302 AC_CONFIG_FILES([
303 Makefile
304 gnu/Makefile
305 doc/Makefile
306 m4/system.h:m4/system_.h
307 tests/atlocal
308 tests/gnu/Makefile
311 AC_OUTPUT