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