* src/builtin.c (includes): Adjust to gnulib changes.
[m4.git] / configure.ac
blobf63427f8eaf841af8d4db89911d3354a9f817be9
1 # Configure template for GNU M4.                        -*-Autoconf-*-
2 # Copyright (C) 1991, 1993, 1994, 2004, 2005, 2006, 2007 Free Software
3 # Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 # 02110-1301  USA
20 AC_PREREQ([2.60])
21 AC_INIT([GNU M4], [1.4.8a], [bug-m4@gnu.org])
22 AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 gnu])
23 PACKAGE=$PACKAGE_TARNAME; AC_SUBST([PACKAGE])
24 VERSION=$PACKAGE_VERSION; AC_SUBST([VERSION])
26 m4_pattern_forbid([^M4_[A-Z]])
28 AC_CONFIG_SRCDIR([src/m4.h])
29 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
31 AC_CANONICAL_BUILD
32 AC_CANONICAL_HOST
33 AC_PROG_CC
34 M4_EARLY
36 AC_SYS_LARGEFILE
37 AC_CHECK_HEADERS_ONCE([limits.h siginfo.h sys/wait.h])
38 AC_CHECK_TYPES([siginfo_t], [], [],
39 [[#include <signal.h>
40 #if HAVE_SIGINFO_H
41 # include <siginfo.h>
42 #endif
43 ]])
44 AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], [], [],
45 [[#include <signal.h>
46 ]])
47 AC_CHECK_MEMBERS([stack_t.ss_sp], [], [],
48 [[#include <signal.h>
49 #if HAVE_SIGINFO_H
50 # include <siginfo.h>
51 #endif
52 ]])
54 AC_TYPE_SIGNAL
55 AC_TYPE_SIZE_T
57 AC_CHECK_FUNCS_ONCE([sigaction sigaltstack sigstack sigvec strerror])
59 M4_INIT
61 # Code from Jim Avera <jima@netcom.com>.
62 # stackovf.c requires:
63 #  1. Either sigaction with SA_ONSTACK, or sigvec with SV_ONSTACK
64 #  2. Either sigaltstack or sigstack
65 #  3. getrlimit, including support for RLIMIT_STACK
66 AC_CACHE_CHECK([if stack overflow is detectable], [M4_cv_use_stackovf],
67 [M4_cv_use_stackovf=no
68 if test "$ac_cv_func_sigaction" = yes || test "$ac_cv_func_sigvec" = yes; then
69   if test "$ac_cv_func_sigaltstack" = yes || test "$ac_cv_func_sigstack" = yes; then
70     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
71 #include <sys/time.h>
72 #include <sys/resource.h>
73 #include <signal.h>
74 ]], [[struct rlimit r; getrlimit (RLIMIT_STACK, &r);
75 #if (!defined(HAVE_SIGACTION) || !defined(SA_ONSTACK)) \
76     && (!defined(HAVE_SIGVEC) || !defined(SV_ONSTACK))
77 choke me                /* SA_ONSTACK and/or SV_ONSTACK are not defined */
78 #endif
79 ]])], [M4_cv_use_stackovf=yes])
80   fi
81 fi])
82 AM_CONDITIONAL([STACKOVF], [test "$M4_cv_use_stackovf" = yes])
83 if test "$M4_cv_use_stackovf" = yes; then
84   AC_DEFINE([USE_STACKOVF], [1],
85     [Define to 1 if using stack overflow detection])
86   AC_CHECK_TYPES([rlim_t], [],
87     [AC_DEFINE([rlim_t], [int],
88       [Define to int if rlim_t is not defined in sys/resource.h])],
89     [[#include <sys/resource.h>
90   ]])
91   AC_CHECK_TYPES([stack_t], [],
92     [AC_DEFINE([stack_t], [struct sigaltstack],
93       [Define to struct sigaltstack if stack_t is not in signal.h])],
94     [[#include <signal.h>
95   ]])
96   AC_CHECK_TYPES([sigcontext], [], [], [[#include <signal.h>
97   ]])
100 AC_CACHE_CHECK([if system() agrees with pclose()],
101   [M4_cv_func_system_consistent],
102   [AC_RUN_IFELSE([AC_LANG_PROGRAM([
103 #include <stdio.h>
104 #include <stdlib.h>
105 #include <errno.h>
106 ], [int i1, i2;
107   FILE *f;
108   i1 = system ("exit 2");
109   if (i1 == -1)
110     return 1;
111   f = popen ("exit 2", "r");
112   if (!f)
113     return 1;
114   i2 = pclose (f);
115   return i1 != i2;])],
116   [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no],
117   [AC_COMPILE_IFELSE([
118 /* EMX on OS/2 defines WEXITSTATUS to be (x>>8)&0xff, and uses that for
119    pclose(), but for system() it uses x&0xff instead.  Otherwise, we assume
120    your system is sane and that pclose() and system() are consistent in their
121    values.  If this heuristic is wrong for your platform, report it as a bug
122    to bug-m4@gnu.org.  */
123 #ifdef __EMX__
124 choke me
125 #endif
126 ], [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no])])])
127 if test "$M4_cv_func_system_consistent" = no ; then
128   AC_DEFINE([FUNC_SYSTEM_BROKEN], [1],
129     [Define to 1 if the return value of system() disagrees with pclose().])
132 dnl Don't let changeword get in our way, if bootstrapping with a version of
133 dnl m4 that already turned the feature on.
134 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
136 AC_MSG_CHECKING([[if changeword is wanted]])
137 AC_ARG_ENABLE([changeword],
138   [AS_HELP_STRING([--enable-changeword],
139      [enable -W and changeword() builtin])],
140   [if test "$enableval" = yes; then
141     AC_MSG_RESULT([yes])
142     AC_DEFINE([ENABLE_CHANGEWORD], [1],
143       [Define to 1 if the changeword(REGEXP) functionality is wanted])
144   else
145     AC_MSG_RESULT([no])
146   fi], [AC_MSG_RESULT([no])])
148 M4_WITH_DMALLOC
150 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
152 AC_CONFIG_FILES([Makefile
153                  doc/Makefile
154                  lib/Makefile
155                  src/Makefile
156                  checks/Makefile
157                  examples/Makefile
160 AC_OUTPUT