modules: use only host system module file extension in searches.
[m4/ericb.git] / configure.ac
blob04da7e966dbfbb5ff2af510aba5c9301fc0fb009
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 save_module=$module; module=yes
186 mfour_shrext=`eval printf '%s' \"$shrext_cmds\"`
187 module=$save_module
188 AC_DEFINE_UNQUOTED([SYS_SHREXT], ["$mfour_shrext"],
189         [Define this to the system shared module file extension])
191 if test yes = "$sys_symbol_underscore"; then
192   AC_MSG_CHECKING([whether dlsym requires underscore prefixed symbols])
193   AC_CACHE_VAL([mfour_cv_sys_dlsym_uscore], [dnl
194     # Use Libtool to make a loadable module
195     cat >conftest_loadme.$ac_ext <<_M4_EOF
196 [#line $LINENO "configure"
197 #include "confdefs.h"
198 /* When -fvisibility=hidden is used, assume the code has been annotated
199    correspondingly for the symbols needed.  */
200 #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
201 int fnord () __attribute__((visibility("default")));
202 #endif
203 int fnord () { return 42; }]
204 _M4_EOF
205     libobjs=conftest_loadme.$ac_objext; lib=conftest_loadme$mfour_shrext
206     save_module_cmds=$module_cmds; module_cmds=`eval echo $module_cmds`
207     test -n "$module_cmds" || module_cmds=`eval echo $archive_cmds`
208     $CC $pic_flag -c conftest_loadme.$ac_ext
209     eval "wl=\"$lt_prog_compiler_wl\"; major=; versuffix=; verstring=; deplibs=; \
210           rpath=/not-exists/conftest_loadme$mfour_shrext; $module_cmds"
211     module_cmds=$save_module_cmds
213     # Try to fetch fnord with dlsym().
214     mfour_dlunknown=0; mfour_dlnouscore=1; mfour_dluscore=2
215     cat >conftest.$ac_ext <<_M4_EOF
216 [#line $LINENO "configure"
217 #include "confdefs.h"
218 #if HAVE_DLFCN_H
219 #include <dlfcn.h>
220 #endif
221 #include <stdio.h>
222 #ifndef RTLD_GLOBAL
223 #  ifdef DL_GLOBAL
224 #    define RTLD_GLOBAL DL_GLOBAL
225 #  else
226 #    define RTLD_GLOBAL 0
227 #  endif
228 #endif
229 #ifndef RTLD_NOW
230 #  ifdef DL_NOW
231 #    define RTLD_NOW DL_NOW
232 #  else
233 #    define RTLD_NOW 0
234 #  endif
235 #endif
236 int main () {
237   void *handle = dlopen ("`pwd`/$objdir/conftest_loadme$mfour_shrext", RTLD_GLOBAL|RTLD_NOW);
238   int status = $mfour_dlunknown;
239   if (handle) {
240     if (dlsym (handle, "fnord"))
241       status = $mfour_dlnouscore;
242     else {
243       if (dlsym (handle, "_fnord"))
244         status = $mfour_dluscore;
245       else
246         puts (dlerror ());
247     }
248     dlclose (handle);
249   } else
250     puts (dlerror ());
251   return status;
253 _M4_EOF
254     if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
255       (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
256       mfour_status=$?
257       case x$mfour_status in
258         x$mfour_dlnouscore) mfour_cv_sys_dlsym_uscore=no ;;
259         x$mfour_dluscore) mfour_cv_sys_dlsym_uscore=yes ;;
260         x*) mfour_cv_sys_dlsym_uscore=unknown ;;
261       esac
262     fi
263     rm -rf conftest*
264   ])
265   sys_dlsym_uscore=$mfour_cv_sys_dlsym_uscore
266   AC_MSG_RESULT($sys_dlsym_uscore)
267   if test yes = "$sys_dlsym_uscore"; then
268     AC_DEFINE([DLSYM_USCORE], [1],
269       [Define if dlsym() requires a leading underscore in symbol names.])
270   fi
273 AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['$PATH_SEPARATOR'],
274                    [Define this to system search path delimiter])
277 ## ------------------------------- ##
278 ## Preloaded module configuration. ##
279 ## ------------------------------- ##
280 AS_IF([test "x$enable_shared" != xno],
281       [DYNAMIC_MODULES=yes], [DYNAMIC_MODULES=no])
282 AC_SUBST([DYNAMIC_MODULES], [$DYNAMIC_MODULES])
284 AC_MSG_CHECKING([for modules to preload])
285   DLPREOPEN=
287   AC_ARG_WITH([modules],
288     [AS_HELP_STRING([--with-modules=MODULES],
289                     [preload MODULES @<:@default: ]M4_DEFAULT_PRELOAD[@:>@])],
290     [use_modules="$withval"],
291     [use_modules="$M4_default_preload"])
293   PREOPEN_DEPENDENCIES=
294   DLPREOPEN="-dlpreopen force"
295   if test -z "$use_modules"; then
296     use_modules=none
297   else
298     if test "$use_modules" != yes; then
299       for module in $use_modules; do
300         case $module in
301           no|none) break ;;
302           m4|traditional|gnu|load|mpeval) dir=modules ;;
303           import|modtest|shadow|stdlib|time) dir=tests ;;
304           *) AC_MSG_ERROR([Unrecognized module `$module' in --with-modules])
305             ;;
306         esac
307         DLPREOPEN="$DLPREOPEN -dlpreopen $dir/$module.la"
308         PREOPEN_DEPENDENCIES="$PREOPEN_DEPENDENCIES $dir/$module.la"
309       done
310     fi
311   fi
312 AC_MSG_RESULT([$use_modules])
313 AC_SUBST([DLPREOPEN])
314 AC_SUBST([PREOPEN_DEPENDENCIES])
317 ## ---------------- ##
318 ## Gettext support. ##
319 ## ---------------- ##
320 AM_GNU_GETTEXT([external])
321 AM_GNU_GETTEXT_NEED([need-formatstring-macros])
322 AM_GNU_GETTEXT_VERSION([0.16])
323 M4_GNU_GETTEXT
326 ## --------------- ##
327 ## Gnulib support. ##
328 ## --------------- ##
329 M4_INIT
331 gl_VERSION_ETC
333 # Gnulib doesn't always do things quite the way M4 would like...
334 M4_ERROR
335 M4_GETOPT
336 M4_OBSTACK
337 M4_REGEX
338 M4_RENAME
341 ## ------------------------- ##
342 ## C headers required by M4. ##
343 ## ------------------------- ##
344 AC_CHECK_HEADERS_ONCE([limits.h])
346 if test $ac_cv_header_stdbool_h = yes; then
347   INCLUDE_STDBOOL_H='#include <stdbool.h>'
348 else
349   INCLUDE_STDBOOL_H='#include <gnu/stdbool.h>'
351 AC_SUBST([INCLUDE_STDBOOL_H])
354 ## --------------------------------- ##
355 ## Library functions required by M4. ##
356 ## --------------------------------- ##
357 AC_CHECK_FUNCS_ONCE([calloc strerror])
359 AM_WITH_DMALLOC
361 M4_SYS_STACKOVF
363 # This is for the modules
364 AC_STRUCT_TM
365 AC_FUNC_STRFTIME
366 AC_CHECK_FUNCS_ONCE([getcwd gethostname mktime uname])
369 ## ------------------ ##
370 ## Configure options. ##
371 ## ------------------ ##
373 M4_LIB_GMP
374 AM_CONDITIONAL([USE_GMP], [test "x$USE_GMP" = xyes])
375 M4_SYSCMD
378 ## -------- ##
379 ## Outputs. ##
380 ## -------- ##
381 AC_CONFIG_FILES([
382 Makefile
383 doc/Makefile
384 m4/gnu/Makefile
385 m4/system.h:m4/system_.h
386 tests/atlocal
387 tests/gnu/Makefile
390 AC_OUTPUT