Make GNUmakefile work with in-place builds.
[m4/ericb.git] / configure.ac
bloba8d92002b1a529a27880f06590bada651c19c69d
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/>.
20 AC_PREREQ([2.60])
21 AC_INIT([GNU M4], m4_esyscmd([build-aux/git-version-gen .version]),
22   [bug-m4@gnu.org])
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])
32 AC_CANONICAL_BUILD
33 AC_CANONICAL_HOST
34 AC_PROG_CC
35 M4_EARLY
37 AC_SYS_LARGEFILE
38 AC_CHECK_HEADERS_ONCE([limits.h siginfo.h sys/wait.h])
39 AC_CHECK_TYPES([siginfo_t], [], [],
40 [[#include <signal.h>
41 #if HAVE_SIGINFO_H
42 # include <siginfo.h>
43 #endif
44 ]])
45 AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], [], [],
46 [[#include <signal.h>
47 ]])
48 AC_CHECK_MEMBERS([stack_t.ss_sp], [], [],
49 [[#include <signal.h>
50 #if HAVE_SIGINFO_H
51 # include <siginfo.h>
52 #endif
53 ]])
55 AC_TYPE_SIGNAL
56 AC_TYPE_SIZE_T
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.
63 AC_TYPE_LONG_LONG_INT
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
66 then
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'.])
72 M4_INIT
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([[
84 #include <sys/time.h>
85 #include <sys/resource.h>
86 #include <signal.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 */
91 #endif
92 ]])], [M4_cv_use_stackovf=yes])
93   fi
94 fi])
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>
103   ]])
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>
108   ]])
109   AC_CHECK_TYPES([sigcontext], [], [], [[#include <signal.h>
110   ]])
113 AC_CACHE_CHECK([if system() agrees with pclose()],
114   [M4_cv_func_system_consistent],
115   [AC_RUN_IFELSE([AC_LANG_PROGRAM([
116 #include <stdio.h>
117 #include <stdlib.h>
118 #include <errno.h>
119 ], [int i1, i2;
120   FILE *f;
121   i1 = system ("exit 2");
122   if (i1 == -1)
123     return 1;
124   f = popen ("exit 2", "r");
125   if (!f)
126     return 1;
127   i2 = pclose (f);
128   return i1 != i2;])],
129   [M4_cv_func_system_consistent=yes], [M4_cv_func_system_consistent=no],
130   [AC_COMPILE_IFELSE([
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.  */
136 #ifdef __EMX__
137 choke me
138 #endif
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
154     AC_MSG_RESULT([yes])
155     AC_DEFINE([ENABLE_CHANGEWORD], [1],
156       [Define to 1 if the changeword(REGEXP) functionality is wanted])
157   else
158     AC_MSG_RESULT([no])
159   fi], [AC_MSG_RESULT([no])])
161 M4_WITH_DMALLOC
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
180                  doc/Makefile
181                  lib/Makefile
182                  src/Makefile
183                  tests/Makefile
184                  checks/Makefile
185                  examples/Makefile
188 AC_OUTPUT