Imported Upstream version 1.4.16
[platform/upstream/m4.git] / configure.ac
1 # Configure template for GNU M4.           -*-Autoconf-*-
2 # Copyright (C) 1991, 1993-1994, 2004-2011 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.1 dist-bzip2 dist-xz color-tests parallel-tests
26 silent-rules 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   [gl_gcc_warnings=no]
54 )
55
56 if test "$gl_gcc_warnings" = yes; then
57   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
58   AC_SUBST([WERROR_CFLAGS])
59
60   nw=
61   nw="$nw -Waggregate-return"       # C90 is anachronistic
62   nw="$nw -Wlong-long"              # C90 is anachronistic
63   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
64   nw="$nw -Wtraditional"            # Warns on #elif which we use often
65   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
66   nw="$nw -Wpadded"                 # Our structs are not packed
67   nw="$nw -Wredundant-decls"        # Gnulib has multiple decls
68   nw="$nw -Wformat-nonliteral"      # Needed in builtin.c
69   nw="$nw -Wunreachable-code"       # Needed in output.c
70   nw="$nw -Wconversion"             # Too many warnings for now
71   nw="$nw -Wsign-conversion"        # Too many warnings for now
72   nw="$nw -Wtraditional-conversion" # Too many warnings for now
73   nw="$nw -Wcast-qual"              # Too many warnings for now
74   nw="$nw -Wswitch-enum"            # Too many warnings for now
75   # This, $nw, is the list of warnings we disable.
76
77   gl_MANYWARN_ALL_GCC([ws])
78   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
79   for w in $ws; do
80     gl_WARN_ADD([$w])
81   done
82
83   gl_WARN_ADD([-fdiagnostics-show-option])
84   gl_WARN_ADD([-funit-at-a-time])
85
86   AC_SUBST([WARN_CFLAGS])
87
88   AC_DEFINE([_FORTIFY_SOURCE], [2],
89     [enable compile-time and run-time bounds-checking, and some warnings])
90 fi
91
92 # Tandem/NSK is broken - it has 'long long int' but not
93 # 'unsigned long long int', which confuses assumptions made by gnulib.
94 # Simply pretend that neither type exists if both do not work.
95 AC_TYPE_LONG_LONG_INT
96 AC_TYPE_UNSIGNED_LONG_LONG_INT
97 if test $ac_cv_type_long_long_int:$ac_cv_type_unsigned_long_long_int = yes:no
98 then
99   ac_cv_type_long_long_int=no
100   AC_DEFINE([HAVE_LONG_LONG_INT], 0,
101     [Define to 1 if the system has the type `long long int'.])
102 fi
103
104 M4_INIT
105
106 AC_CACHE_CHECK([whether an open file can be renamed],
107   [M4_cv_func_rename_open_file_works],
108   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
109       [FILE *f = fopen ("conftest.1", "w+");
110        int result = rename ("conftest.1", "conftest.2");
111        fclose (f); remove ("conftest.1"); remove ("conftest.2");
112        return result;])],
113     [M4_cv_func_rename_open_file_works=yes],
114     [M4_cv_func_rename_open_file_works=no],
115     [M4_cv_func_rename_open_file_works='guessing no'])])
116 if test "$M4_cv_func_rename_open_file_works" = yes ; then
117   M4_rename_open_works=1
118 else
119   M4_rename_open_works=0
120 fi
121 AC_DEFINE_UNQUOTED([RENAME_OPEN_FILE_WORKS], [$M4_rename_open_works],
122   [Define to 1 if a file can be renamed while open, or to 0 if not.])
123
124 dnl Don't let changeword get in our way, if bootstrapping with a version of
125 dnl m4 that already turned the feature on.
126 m4_ifdef([changeword], [m4_undefine([changeword])])dnl
127
128 AC_MSG_CHECKING([[if changeword is wanted]])
129 AC_ARG_ENABLE([changeword],
130   [AS_HELP_STRING([--enable-changeword],
131      [enable -W and changeword() builtin])],
132   [if test "$enableval" = yes; then
133     AC_MSG_RESULT([yes])
134     AC_DEFINE([ENABLE_CHANGEWORD], [1],
135       [Define to 1 if the changeword(REGEXP) functionality is wanted])
136   else
137     AC_MSG_RESULT([no])
138   fi], [AC_MSG_RESULT([no])])
139
140 AC_MSG_CHECKING([[which shell to use for syscmd]])
141 AC_ARG_WITH([syscmd-shell],
142   [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
143   [case $withval in
144     yes[)] with_syscmd_shell=no;;
145    esac], [with_syscmd_shell=no])
146 if test "$with_syscmd_shell" = no ; then
147   with_syscmd_shell=/bin/sh
148   if test "$cross_compiling" != yes ; then
149 dnl Give mingw a default that is more likely to be available.
150     AS_IF([AS_EXECUTABLE_P([/bin/sh])], [],
151       [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
152 dnl Too bad _AS_PATH_WALK is not public.
153     M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
154     for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
155         command -p getconf PATH
156       else
157         echo "/bin$PATH_SEPARATOR$PATH"
158       fi`
159     do
160       IFS=$M4_save_IFS
161       test -z "$M4_dir" && continue
162       AS_EXECUTABLE_P(["$M4_dir/sh"]) \
163         && { with_syscmd_shell=$M4_dir/sh; break; }
164     done
165     IFS=$M4_save_IFS
166   fi
167 fi
168 AC_MSG_RESULT([$with_syscmd_shell])
169 AC_DEFINE_UNQUOTED([SYSCMD_SHELL], ["$with_syscmd_shell"],
170   [Shell used by syscmd and esyscmd, must accept -c argument.])
171
172 M4_WITH_DMALLOC
173
174 AC_CONFIG_COMMANDS([stamp-h], [[test -z "$CONFIG_HEADERS" || date > stamp-h]])
175
176 AC_CONFIG_FILES([Makefile
177                  doc/Makefile
178                  lib/Makefile
179                  src/Makefile
180                  tests/Makefile
181                  checks/Makefile
182                  examples/Makefile
183 ])
184
185 AC_OUTPUT