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