resetting manifest requested domain to floor
[platform/upstream/m4.git] / configure.ac
1 # Configure template for GNU M4.           -*-Autoconf-*-
2 # Copyright (C) 1991, 1993-1994, 2004-2013 Free Software Foundation,
3 # Inc.
4 #
5 # This file is part of GNU M4.
6 #
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.
11 #
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.
16 #
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/>.
19
20 AC_PREREQ([2.62])
21 AC_INIT([GNU M4], m4_esyscmd([build-aux/git-version-gen .tarball-version]),
22   [bug-m4@gnu.org])
23 AC_CONFIG_AUX_DIR([build-aux])
24
25 AM_INIT_AUTOMAKE([1.11.6 dist-bzip2 dist-xz color-tests parallel-tests
26 silent-rules subdir-objects gnu])
27
28 m4_pattern_forbid([^M4_[A-Z]])
29
30 AC_CONFIG_SRCDIR([src/m4.h])
31 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
32
33 AC_PROG_CC
34 AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])
35 M4_EARLY
36
37 # Maintainer note - comment this line out if you plan to rerun
38 # GNULIB_POSIXCHECK testing to see if M4 should be using more modules.
39 # Leave it uncommented for normal releases, for faster ./configure.
40 gl_ASSERT_NO_GNULIB_POSIXCHECK
41
42 # M4 is single-threaded; so we can optimize gnulib code by using this:
43 gl_DISABLE_THREADS
44
45 AC_ARG_ENABLE([gcc-warnings],
46   [AS_HELP_STRING([--enable-gcc-warnings],
47                   [turn on lots of GCC warnings (for developers)])],
48   [case $enableval in
49      yes|no) ;;
50      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
51    esac
52    gl_gcc_warnings=$enableval],
53   [if test -d "$srcdir"/.git; then
54      gl_gcc_warnings=yes
55    else
56      gl_gcc_warnings=no
57    fi]
58 )
59
60 if test "$gl_gcc_warnings" = yes; then
61   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
62   AC_SUBST([WERROR_CFLAGS])
63
64   # We use '#pragma GCC diagnostic push' to silence some
65   # warnings, but older gcc doesn't support this.
66   AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
67     [M4_cv_gcc_pragma_push_works], [
68     save_CFLAGS=$CFLAGS
69     CFLAGS='-Wunknown-pragmas -Werror'
70     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
71       #pragma GCC diagnostic push
72       #pragma GCC diagnostic pop
73     ]])],
74     [M4_cv_gcc_pragma_push_works=yes],
75     [M4_cv_gcc_pragma_push_works=no])
76     CFLAGS=$save_CFLAGS])
77
78   # This, $nw, is the list of warnings we disable.
79   nw=
80   nw="$nw -Waggregate-return"       # K&R is anachronistic
81   nw="$nw -Wtraditional-conversion" # K&R is anachronistic
82   nw="$nw -Wundef"                  # K&R is anachronistic
83   nw="$nw -Wtraditional"            # K&R is anachronistic
84   nw="$nw -Wlong-long"              # C90 is anachronistic
85   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
86   nw="$nw -Wpadded"                 # Our structs are not packed
87   nw="$nw -Wconversion"             # Too many warnings for now
88   nw="$nw -Wsign-conversion"        # Too many warnings for now
89   nw="$nw -Wcast-qual"              # Too many warnings for now
90   nw="$nw -Wswitch-enum"            # Too many warnings for now
91   # gcc 4.4.6 complains enum-compare is C++ only; gcc 4.7.0 implies it in -Wall
92   nw="$nw -Wenum-compare"
93
94   # Gnulib uses '#pragma GCC diagnostic push' to silence some
95   # warnings, but older gcc doesn't support this.
96   AC_CACHE_CHECK([whether pragma GCC diagnostic push works],
97     [M4_cv_gcc_pragma_push_works], [
98     save_CFLAGS=$CFLAGS
99     CFLAGS='-Wunknown-pragmas -Werror'
100     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
101       #pragma GCC diagnostic push
102       #pragma GCC diagnostic pop
103     ]])],
104     [M4_cv_gcc_pragma_push_works=yes],
105     [M4_cv_gcc_pragma_push_works=no])
106     CFLAGS=$save_CFLAGS])
107   if test $M4_cv_gcc_pragma_push_works = no; then
108     nw="$nw -Wmissing-prototypes"
109     nw="$nw -Wmissing-declarations"
110     nw="$nw -Wunreachable-code"
111   fi
112
113   gl_MANYWARN_ALL_GCC([ws])
114   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
115   for w in $ws; do
116     gl_WARN_ADD([$w])
117   done
118
119   # Gnulib turns on -Wformat=2, which implies -Wformat-nonliteral, but
120   # we temporarily override it in format.c if possible.
121   if test $M4_cv_gcc_pragma_push_works = no; then
122     gl_WARN_ADD([-Wno-format-nonliteral])
123   fi
124
125   gl_WARN_ADD([-fdiagnostics-show-option])
126   gl_WARN_ADD([-funit-at-a-time])
127
128   AC_SUBST([WARN_CFLAGS])
129
130   AH_VERBATIM([FORTIFY_SOURCE],
131   [/* Enable compile-time and run-time bounds-checking, and some warnings,
132       without upsetting newer glibc. */
133    #if defined __OPTIMIZE__ && __OPTIMIZE__
134    # define _FORTIFY_SOURCE 2
135    #endif
136   ])
137 fi
138
139 # Tandem/NSK is broken - it has 'long long int' but not
140 # 'unsigned long long int', which confuses assumptions made by gnulib.
141 # Simply pretend that neither type exists if both do not work.
142 AC_TYPE_LONG_LONG_INT
143 AC_TYPE_UNSIGNED_LONG_LONG_INT
144 if test $ac_cv_type_long_long_int:$ac_cv_type_unsigned_long_long_int = yes:no
145 then
146   ac_cv_type_long_long_int=no
147   AC_DEFINE([HAVE_LONG_LONG_INT], 0,
148     [Define to 1 if the system has the type `long long int'.])
149 fi
150
151 M4_INIT
152
153 AC_CACHE_CHECK([whether an open file can be renamed],
154   [M4_cv_func_rename_open_file_works],
155   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
156       [FILE *f = fopen ("conftest.1", "w+");
157        int result = rename ("conftest.1", "conftest.2");
158        fclose (f); remove ("conftest.1"); remove ("conftest.2");
159        return result;])],
160     [M4_cv_func_rename_open_file_works=yes],
161     [M4_cv_func_rename_open_file_works=no],
162     [M4_cv_func_rename_open_file_works='guessing no'])])
163 if test "$M4_cv_func_rename_open_file_works" = yes ; then
164   M4_rename_open_works=1
165 else
166   M4_rename_open_works=0
167 fi
168 AC_DEFINE_UNQUOTED([RENAME_OPEN_FILE_WORKS], [$M4_rename_open_works],
169   [Define to 1 if a file can be renamed while open, or to 0 if not.])
170
171 dnl Don't let changeword get in our way, if bootstrapping with a version of
172 dnl m4 that already turned the feature on.
173 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
174
175 AC_MSG_CHECKING([[if changeword is wanted]])
176 AC_ARG_ENABLE([changeword],
177   [AS_HELP_STRING([--enable-changeword],
178      [enable -W and changeword() builtin])],
179   [if test "$enableval" = yes; then
180     AC_MSG_RESULT([yes])
181     AC_DEFINE([ENABLE_CHANGEWORD], [1],
182       [Define to 1 if the changeword(REGEXP) functionality is wanted])
183   else
184     AC_MSG_RESULT([no])
185   fi], [AC_MSG_RESULT([no])])
186
187 AC_MSG_CHECKING([[which shell to use for syscmd]])
188 AC_ARG_WITH([syscmd-shell],
189   [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
190   [case $withval in
191     yes[)] with_syscmd_shell=no;;
192    esac], [with_syscmd_shell=no])
193 if test "$with_syscmd_shell" = no ; then
194   with_syscmd_shell=/bin/sh
195   if test "$cross_compiling" != yes ; then
196 dnl Give mingw a default that is more likely to be available.
197     AS_IF([AS_EXECUTABLE_P([/bin/sh])], [],
198       [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
199 dnl Too bad _AS_PATH_WALK is not public.
200     M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
201     for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
202         command -p getconf PATH
203       else
204         echo "/bin$PATH_SEPARATOR$PATH"
205       fi`
206     do
207       IFS=$M4_save_IFS
208       test -z "$M4_dir" && continue
209       AS_EXECUTABLE_P(["$M4_dir/sh"]) \
210         && { with_syscmd_shell=$M4_dir/sh; break; }
211     done
212     IFS=$M4_save_IFS
213   fi
214 fi
215 AC_MSG_RESULT([$with_syscmd_shell])
216 AC_DEFINE_UNQUOTED([SYSCMD_SHELL], ["$with_syscmd_shell"],
217   [Shell used by syscmd and esyscmd, must accept -c argument.])
218
219 M4_WITH_DMALLOC
220
221 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
222
223 AC_CONFIG_FILES([Makefile
224                  doc/Makefile
225                  lib/Makefile
226                  src/Makefile
227                  tests/Makefile
228                  checks/Makefile
229                  examples/Makefile
230 ])
231
232 AC_OUTPUT