AS_IF: Handle else clause being empty after macro expansion (#110369)
[autoconf.git] / configure.ac
blob56d275491327695031009c02d9ea85c15da6eef0
1 #                                                       -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 # Copyright (C) 1992-1995, 1999-2017, 2020 Free Software Foundation,
5 # Inc.
7 # This program 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 # This program 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 <https://www.gnu.org/licenses/>.
20 AC_PREREQ([2.62])
22 AC_INIT([GNU Autoconf],
23         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
24         [bug-autoconf@gnu.org])
25 AC_CONFIG_SRCDIR([lib/autoconf/autoconf.m4])
27 AC_CONFIG_AUX_DIR([build-aux])
29 AM_INIT_AUTOMAKE([1.11 dist-xz readme-alpha no-texinfo.tex std-options])
31 # Keep this on a line of its own, since it must be found and processed
32 # by the 'update-release-year' rule in our Makefile.
33 RELEASE_YEAR=2020
34 AC_SUBST([RELEASE_YEAR])
36 AB_INIT
38 # We use 'sh -n script' to check that there are no syntax errors
39 # in the scripts.  Although incredible, there are sh implementations
40 # that go into endless loops with '-n', e.g., SunOS's:
42 #   $ uname -a
43 #   SunOS ondine 4.1.3 2 sun4m unknown
44 #   $ cat endless.sh
45 #   while false
46 #   do
47 #     :
48 #   done
49 #   exit 0
50 #   $ time sh endless.sh
51 #   sh endless.sh  0,02s user 0,03s system 78% cpu 0,064 total
52 #   $ time sh -nx endless.sh
53 #   ^Csh -nx endless.sh  3,67s user 0,03s system 63% cpu 5,868 total
55 # Also, some implementations (e.g., Solaris 8) are soooo slow
56 # that they are unusable on large scripts like our testsuite.
58 # So we must identify a shell whose -n can safely be used.
60 AC_CACHE_CHECK([for a shell whose -n mode is known to work],
61                [ac_cv_sh_working_n],
62 [ac_cv_sh_working_n=none
63 # Start by trying the shell that autoconf decided to use for this script,
64 # follow with a hardwired list of shells that are known to work and can
65 # be identified as such, starting with the ones with the fewest
66 # syntactic extensions.  Unfortunately, several shells that are also
67 # known to work can't be easily identified (e.g. some BSD shells and dash).
68 # Try ksh93, which is often buggy, and plain ksh and sh last.
69 for cand_sh in "$SHELL" pdksh bash zsh ksh93 ksh sh
71   if (
72     unset BASH_VERSION ZSH_VERSION
73     "$cand_sh" -c '
74       test ${BASH_VERSION+y} || # Bash
75       test ${KSH_VERSION+y}  || # pdksh
76       test ${ZSH_VERSION+y}  || # zsh
77       test ${NETBSD_SHELL+y} || # NetBSD sh
78       test -n "${.sh.version}" # ksh93; put this last since its syntax is dodgy
79     '
80   ) 2>/dev/null
81   then
82     ac_cv_sh_working_n="$cand_sh"
83     break
84   fi
85 done
87 AC_SUBST([SHELL_N], [$ac_cv_sh_working_n])
89 AC_MSG_CHECKING([for characters that cannot appear in file names])
90 AC_CACHE_VAL([ac_cv_unsupported_fs_chars],
91 [ac_cv_unsupported_fs_chars=
92 for c in '\\' \" '<' '>' '*' '?' '|'
94   touch "conftest.t${c}t" 2>/dev/null
95   test -f "conftest.t${c}t" && rm -f "conftest.t${c}t" && continue
96   # $c cannot be used in a file name.
97   ac_cv_unsupported_fs_chars=$ac_cv_unsupported_fs_chars$c
98 done
100 if test -n "$ac_cv_unsupported_fs_chars"; then
101   AC_MSG_RESULT([$ac_cv_unsupported_fs_chars])
102 else
103   AC_MSG_RESULT([none])
106 AC_SUBST([ac_cv_unsupported_fs_chars])
108 AC_CACHE_CHECK([whether directories can have trailing spaces],
109                [ac_cv_dir_trailing_space],
110 [rm -rf 'conftest.d ' && mkdir 'conftest.d ' && touch 'conftest.d /tfile' 2>/dev/null
111 stat=$?
112 rm -rf 'conftest.d '
113 case $stat$? in #(
114    00) ac_cv_dir_trailing_space=yes ;; #(
115    *) ac_cv_dir_trailing_space=no ;;
116 esac
118 AC_SUBST([ac_cv_dir_trailing_space])
120 # Initialize the test suite.
121 AC_CONFIG_TESTDIR([tests])
122 AC_CONFIG_FILES([tests/atlocal])
123 AC_PATH_PROG([EXPR], [expr])
126 ## ---- ##
127 ## M4.  ##
128 ## ---- ##
130 # We use an absolute name for GNU m4 so even if users have another m4 first in
131 # their path, the installer can configure with a path that has GNU m4
132 # on it and get that path embedded in the installed autoconf and
133 # autoheader scripts.
134 AC_PROG_GNU_M4
136 ## ----------- ##
137 ## Man pages.  ##
138 ## ----------- ##
140 AM_MISSING_PROG([HELP2MAN], [help2man])
143 ## ------ ##
144 ## Perl.  ##
145 ## ------ ##
147 # We use an absolute name for perl so the #! line in autoscan will work.
148 AC_PATH_PROG([PERL], [perl], [no])
149 AC_SUBST([PERL])dnl
150 if test "$PERL" = no; then
151   AC_MSG_ERROR([perl is not found])
153 $PERL -e 'require 5.006;' || {
154    AC_MSG_ERROR([Perl 5.006 or better is required])
157 # Find out whether the system supports flock
158 # Note this test does not try to find out whether it works with this
159 # particular file system.  It merely avoids us running flock on systems
160 # where that bails out.
161 AC_CACHE_CHECK([whether $PERL Fcntl::flock is implemented],
162   [ac_cv_perl_flock_implemented],
163   [echo lock me > conftest.fil
164    if $PERL -e 'use Fcntl ":flock"; flock("conftest.fil", LOCK_EX); 1;'; then
165      ac_cv_perl_flock_implemented=yes
166    else
167      ac_cv_perl_flock_implemented=no
168    fi
169    rm -f conftest.fil
170   ])
171 AC_SUBST([PERL_FLOCK], [$ac_cv_perl_flock_implemented])
174 ## ------- ##
175 ## Emacs.  ##
176 ## ------- ##
178 TEST_EMACS=$EMACS
179 test x"$TEST_EMACS" = xt && TEST_EMACS=
180 AC_CHECK_PROGS([TEST_EMACS], [emacs xemacs], [no])
182 # autoconf-mode.el and autotest-mode.el do not work with older version of
183 # Emacs (i.e. 18.x.x).  During byte-compilation, Emacs complains:
184 # "Variable (broken nil) seen on pass 2 of byte compiler but not pass 1"
185 # We detect this problem here.
186 AS_IF([test "$TEST_EMACS" != no],
187   [AC_CACHE_CHECK([whether $TEST_EMACS is sufficiently recent],
188     [ac_cv_prog_emacs_ok],
189     [# Note: The quoted "EOF" is intentional.  It protects the ` in the text.
190     cat >conftest.el << "EOF"
191       (defvar broken)
192       (defun broken-mode () (setq broken-defaults `(broken nil)))
194     AS_IF([AC_RUN_LOG(
195       [$TEST_EMACS -batch -q -f batch-byte-compile conftest.el 1>&2])],
196       [ac_cv_prog_emacs_ok=yes], [ac_cv_prog_emacs_ok=no])
197     rm -f conftest.el conftest.elc])
198   AS_IF([test $ac_cv_prog_emacs_ok = no], [TEST_EMACS=no])])
200 AC_SUBST([EMACS], [$TEST_EMACS])
202 AM_PATH_LISPDIR
205 ## ---------------- ##
206 ## Grep, sed, awk.  ##
207 ## ---------------- ##
208 AC_PROG_GREP
209 AC_PROG_EGREP
210 AC_PROG_SED
211 # AC_PROG_AWK should have already been performed by AM_INIT_AUTOMAKE.
212 # AC_REQUIRE([AC_PROG_AWK]) doesn't work outside of an AC_DEFUN.
213 m4_provide_if([AC_PROG_AWK], [], [AC_PROG_AWK])
216 ## ----- ##
217 ## Make. ##
218 ## ----- ##
219 AC_PROG_MAKE_CASE_SENSITIVE
222 ## ------------ ##
223 ## Conclusion.  ##
224 ## ------------ ##
226 dnl Allow maintainer rules under GNU make even in VPATH builds.
227 AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])
229 AC_CONFIG_FILES([Makefile])
231 AC_OUTPUT
232 # Report the state of this version of Autoconf if this is a beta.
233 m4_bmatch(m4_defn([AC_PACKAGE_VERSION]), [[-a-z]],
234 [    cat <<EOF
236 You are about to use an experimental version of Autoconf.  Be sure to
237 read the relevant mailing lists, most importantly <autoconf@gnu.org>.
239 Below you will find information on the status of this version of Autoconf.
242     sed -n '/^\* Status/,$p' $srcdir/BUGS
243 echo
244 ])dnl