1 # Configure template for GNU M4. -*-Autoconf-*-
2 # Copyright (C) 1991, 1993, 1994, 2004, 2005, 2006, 2007, 2008 Free
3 # Software 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/>.
21 AC_INIT([GNU M4], m4_esyscmd([build-aux/git-version-gen .version]),
23 AC_CONFIG_AUX_DIR([build-aux])
25 AM_INIT_AUTOMAKE([1.10.1 dist-bzip2 dist-lzma gnu])
27 m4_pattern_forbid([^M4_[A-Z]])
29 AC_CONFIG_SRCDIR([src/m4.h])
30 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
38 AC_CHECK_HEADERS_ONCE([limits.h siginfo.h sys/wait.h])
39 AC_CHECK_TYPES([siginfo_t], [], [],
45 AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], [], [],
48 AC_CHECK_MEMBERS([stack_t.ss_sp], [], [],
58 AC_CHECK_FUNCS_ONCE([sigaction sigaltstack sigstack sigvec strerror])
60 # Tandem/NSK is broken - it has 'long long int' but not
61 # 'unsigned long long int', which confuses assumptions made by gnulib.
62 # Simply pretend that neither type exists if both do not work.
64 AC_TYPE_UNSIGNED_LONG_LONG_INT
65 if test $ac_cv_type_long_long_int:$ac_cv_type_unsigned_long_long_int = yes:no
67 ac_cv_type_long_long_int=no
68 AC_DEFINE([HAVE_LONG_LONG_INT], 0,
69 [Define to 1 if the system has the type `long long int'.])
74 # Code from Jim Avera <jima@netcom.com>.
75 # stackovf.c requires:
76 # 1. Either sigaction with SA_ONSTACK, or sigvec with SV_ONSTACK
77 # 2. Either sigaltstack or sigstack
78 # 3. getrlimit, including support for RLIMIT_STACK
79 AC_CACHE_CHECK([if stack overflow is detectable], [M4_cv_use_stackovf],
80 [M4_cv_use_stackovf=no
81 if test "$ac_cv_func_sigaction" = yes || test "$ac_cv_func_sigvec" = yes; then
82 if test "$ac_cv_func_sigaltstack" = yes || test "$ac_cv_func_sigstack" = yes; then
83 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
85 #include <sys/resource.h>
87 ]], [[struct rlimit r; getrlimit (RLIMIT_STACK, &r);
88 #if (!defined(HAVE_SIGACTION) || !defined(SA_ONSTACK)) \
89 && (!defined(HAVE_SIGVEC) || !defined(SV_ONSTACK))
90 choke me /* SA_ONSTACK and/or SV_ONSTACK are not defined */
92 ]])], [M4_cv_use_stackovf=yes])
95 AM_CONDITIONAL([STACKOVF], [test "$M4_cv_use_stackovf" = yes])
96 if test "$M4_cv_use_stackovf" = yes; then
97 AC_DEFINE([USE_STACKOVF], [1],
98 [Define to 1 if using stack overflow detection])
99 AC_CHECK_TYPES([rlim_t], [],
100 [AC_DEFINE([rlim_t], [int],
101 [Define to int if rlim_t is not defined in sys/resource.h])],
102 [[#include <sys/resource.h>
104 AC_CHECK_TYPES([stack_t], [],
105 [AC_DEFINE([stack_t], [struct sigaltstack],
106 [Define to struct sigaltstack if stack_t is not in signal.h])],
107 [[#include <signal.h>
109 AC_CHECK_TYPES([sigcontext], [], [], [[#include <signal.h>
113 AC_CACHE_CHECK([if system() agrees with pclose()],
114 [M4_cv_func_system_consistent],
115 [AC_RUN_IFELSE([AC_LANG_PROGRAM([
121 i1 = system ("exit 2");
124 f = popen ("exit 2", "r");
129 [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no],
131 /* EMX on OS/2 defines WEXITSTATUS to be (x>>8)&0xff, and uses that for
132 pclose(), but for system() it uses x&0xff instead. Otherwise, we assume
133 your system is sane and that pclose() and system() are consistent in their
134 values. If this heuristic is wrong for your platform, report it as a bug
135 to bug-m4@gnu.org. */
139 ], [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no])])])
140 if test "$M4_cv_func_system_consistent" = no ; then
141 AC_DEFINE([FUNC_SYSTEM_BROKEN], [1],
142 [Define to 1 if the return value of system() disagrees with pclose().])
145 dnl Don't let changeword get in our way, if bootstrapping with a version of
146 dnl m4 that already turned the feature on.
147 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
149 AC_MSG_CHECKING([[if changeword is wanted]])
150 AC_ARG_ENABLE([changeword],
151 [AS_HELP_STRING([--enable-changeword],
152 [enable -W and changeword() builtin])],
153 [if test "$enableval" = yes; then
155 AC_DEFINE([ENABLE_CHANGEWORD], [1],
156 [Define to 1 if the changeword(REGEXP) functionality is wanted])
159 fi], [AC_MSG_RESULT([no])])
163 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
165 dnl Allow maintainer rules under GNU make even in VPATH builds. This does
166 dnl not work in autoconf 2.61 or earlier, but we don't want to require
167 dnl non-maintainers to use unreleased autoconf, hence the version test.
168 dnl TODO remove the version check once autoconf 2.62 is released.
169 dnl Meanwhile, we must use a shell variable so that we bypass automake's
170 dnl attempts to remove the sole copy of GNUmakefile in a non-VPATH build
171 dnl during 'make distclean'.
172 dnl TODO avoid the shell variable once automake is fixed.
173 GNUmakefile=GNUmakefile
174 m4_if(m4_version_compare([2.61a.100],
175 m4_defn([m4_PACKAGE_VERSION])), [1], [],
176 [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
177 [GNUmakefile=$GNUmakefile])])
179 AC_CONFIG_FILES([Makefile