modules: Use LT_MODULE_EXT for host module file extension.
[m4/ericb.git] / configure.ac
blob2688a7f1491e2ab1d08a546c5984073c4b21110a
1 # Configure template for GNU m4.           -*-Autoconf-*-
2 # Copyright (C) 1991-1994, 2000-2002, 2004-2014 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([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 ## ------------------ ##
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 ## C compiler characteristics. ##
83 ## --------------------------- ##
84 AC_TYPE_SIZE_T
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 ## ----------------------- ##
94 LT_PREREQ([2.2])
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)])],
100   [case $enableval in
101      yes|no) ;;
102      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
103    esac
104    gl_gcc_warnings=$enableval],
105   [gl_gcc_warnings=no]
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.
113   nw=
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], [
132     save_CFLAGS=$CFLAGS
133     CFLAGS='-Wunknown-pragmas -Werror'
134     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
135       #pragma GCC diagnostic push
136       #pragma GCC diagnostic pop
137     ]])],
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"
145   fi
147   gl_MANYWARN_ALL_GCC([ws])
148   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
149   for w in $ws; do
150     gl_WARN_ADD([$w])
151   done
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
163    #endif
164   ])
167 # Use gcc's -pipe option if available: for faster compilation.
168 case "$CFLAGS" in
169   *-pipe* ) ;;
170         * ) _LT_COMPILER_OPTION([if $compiler supports -pipe],
171                 [M4_cv_prog_compiler_pipe],
172                 [-pipe -c conftest.$ac_ext], [],
173                 [CFLAGS="$CFLAGS -pipe"])
174               ;;
175 esac
178 ## ------------------------------- ##
179 ## Dynamic Loader Characteristics. ##
180 ## ------------------------------- ##
182 LT_LIB_DLLOAD
183 LT_SYS_SYMBOL_USCORE
185 LT_SYS_MODULE_EXT
186 libm4_shlibext=$libltdl_cv_shlibext
188 if test yes = "$sys_symbol_underscore"; then
189   AC_MSG_CHECKING([whether dlsym requires underscore prefixed symbols])
190   AC_CACHE_VAL([mfour_cv_sys_dlsym_uscore], [dnl
191     # Use Libtool to make a loadable module
192     cat >conftest_loadme.$ac_ext <<_M4_EOF
193 [#line $LINENO "configure"
194 #include "confdefs.h"
195 /* When -fvisibility=hidden is used, assume the code has been annotated
196    correspondingly for the symbols needed.  */
197 #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
198 int fnord () __attribute__((visibility("default")));
199 #endif
200 int fnord () { return 42; }]
201 _M4_EOF
202     libobjs=conftest_loadme.$ac_objext; lib=conftest_loadme$libm4_shlibext
203     save_module_cmds=$module_cmds; module_cmds=`eval echo $module_cmds`
204     test -n "$module_cmds" || module_cmds=`eval echo $archive_cmds`
205     $CC $pic_flag -c conftest_loadme.$ac_ext
206     eval "wl=\"$lt_prog_compiler_wl\"; major=; versuffix=; verstring=; deplibs=; \
207           rpath=/not-exists/conftest_loadme$libm4_shlibext; $module_cmds"
208     module_cmds=$save_module_cmds
210     # Try to fetch fnord with dlsym().
211     mfour_dlunknown=0; mfour_dlnouscore=1; mfour_dluscore=2
212     cat >conftest.$ac_ext <<_M4_EOF
213 [#line $LINENO "configure"
214 #include "confdefs.h"
215 #if HAVE_DLFCN_H
216 #include <dlfcn.h>
217 #endif
218 #include <stdio.h>
219 #ifndef RTLD_GLOBAL
220 #  ifdef DL_GLOBAL
221 #    define RTLD_GLOBAL DL_GLOBAL
222 #  else
223 #    define RTLD_GLOBAL 0
224 #  endif
225 #endif
226 #ifndef RTLD_NOW
227 #  ifdef DL_NOW
228 #    define RTLD_NOW DL_NOW
229 #  else
230 #    define RTLD_NOW 0
231 #  endif
232 #endif
233 int main () {
234   void *handle = dlopen ("`pwd`/$objdir/conftest_loadme$libm4_shlibext", RTLD_GLOBAL|RTLD_NOW);
235   int status = $mfour_dlunknown;
236   if (handle) {
237     if (dlsym (handle, "fnord"))
238       status = $mfour_dlnouscore;
239     else {
240       if (dlsym (handle, "_fnord"))
241         status = $mfour_dluscore;
242       else
243         puts (dlerror ());
244     }
245     dlclose (handle);
246   } else
247     puts (dlerror ());
248   return status;
250 _M4_EOF
251     if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
252       (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
253       mfour_status=$?
254       case x$mfour_status in
255         x$mfour_dlnouscore) mfour_cv_sys_dlsym_uscore=no ;;
256         x$mfour_dluscore) mfour_cv_sys_dlsym_uscore=yes ;;
257         x*) mfour_cv_sys_dlsym_uscore=unknown ;;
258       esac
259     fi
260     rm -rf conftest*
261   ])
262   sys_dlsym_uscore=$mfour_cv_sys_dlsym_uscore
263   AC_MSG_RESULT($sys_dlsym_uscore)
264   if test yes = "$sys_dlsym_uscore"; then
265     AC_DEFINE([DLSYM_USCORE], [1],
266       [Define if dlsym() requires a leading underscore in symbol names.])
267   fi
270 AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['$PATH_SEPARATOR'],
271                    [Define this to system search path delimiter])
274 ## ------------------------------- ##
275 ## Preloaded module configuration. ##
276 ## ------------------------------- ##
277 AS_IF([test "x$enable_shared" != xno],
278       [DYNAMIC_MODULES=yes], [DYNAMIC_MODULES=no])
279 AC_SUBST([DYNAMIC_MODULES], [$DYNAMIC_MODULES])
281 AC_MSG_CHECKING([for modules to preload])
282   DLPREOPEN=
284   AC_ARG_WITH([modules],
285     [AS_HELP_STRING([--with-modules=MODULES],
286                     [preload MODULES @<:@default: ]M4_DEFAULT_PRELOAD[@:>@])],
287     [use_modules="$withval"],
288     [use_modules="$M4_default_preload"])
290   PREOPEN_DEPENDENCIES=
291   DLPREOPEN="-dlpreopen force"
292   if test -z "$use_modules"; then
293     use_modules=none
294   else
295     if test "$use_modules" != yes; then
296       for module in $use_modules; do
297         case $module in
298           no|none) break ;;
299           m4|traditional|gnu|load|mpeval) dir=modules ;;
300           import|modtest|shadow|stdlib|time) dir=tests ;;
301           *) AC_MSG_ERROR([Unrecognized module `$module' in --with-modules])
302             ;;
303         esac
304         DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
305         PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
306       done
307     fi
308   fi
309 AC_MSG_RESULT([$use_modules])
310 AC_SUBST([DLPREOPEN])
311 AC_SUBST([PREOPEN_DEPENDENCIES])
314 ## ---------------- ##
315 ## Gettext support. ##
316 ## ---------------- ##
317 AM_GNU_GETTEXT([external])
318 AM_GNU_GETTEXT_NEED([need-formatstring-macros])
319 AM_GNU_GETTEXT_VERSION([0.16])
320 M4_GNU_GETTEXT
323 ## --------------- ##
324 ## Gnulib support. ##
325 ## --------------- ##
326 M4_INIT
328 gl_VERSION_ETC
330 # Gnulib doesn't always do things quite the way M4 would like...
331 M4_ERROR
332 M4_GETOPT
333 M4_OBSTACK
334 M4_REGEX
335 M4_RENAME
338 ## ------------------------- ##
339 ## C headers required by M4. ##
340 ## ------------------------- ##
341 AC_CHECK_HEADERS_ONCE([limits.h])
343 if test $ac_cv_header_stdbool_h = yes; then
344   INCLUDE_STDBOOL_H='#include <stdbool.h>'
345 else
346   INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
348 AC_SUBST([INCLUDE_STDBOOL_H])
351 ## --------------------------------- ##
352 ## Library functions required by M4. ##
353 ## --------------------------------- ##
354 AC_CHECK_FUNCS_ONCE([calloc strerror])
356 AM_WITH_DMALLOC
358 M4_SYS_STACKOVF
360 # This is for the modules
361 AC_STRUCT_TM
362 AC_FUNC_STRFTIME
363 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
366 ## ------------------ ##
367 ## Configure options. ##
368 ## ------------------ ##
370 M4_LIB_GMP
371 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
372 M4_SYSCMD
375 ## -------- ##
376 ## Outputs. ##
377 ## -------- ##
378 AC_CONFIG_FILES([
379 Makefile
380 doc/Makefile
381 m4/gnu/Makefile
382 m4/system.h:m4/system_.h
383 tests/atlocal
384 tests/gnu/Makefile
387 AC_OUTPUT