Improve AC_FUNC_MMAP comments
[autoconf.git] / tests / foreign.at
blob6a1eb1b572515448d1042a7d4ff343848e57484c
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Compatibility with external tools and macros.])
5 # Copyright (C) 2000-2007, 2009-2017, 2020-2023 Free Software
6 # Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
22 ## --------- ##
23 ## Libtool.  ##
24 ## --------- ##
26 AT_SETUP([Libtool])
28 # Skip this test if there is no libtoolize.
29 AT_CHECK([libtoolize --version || exit 77],
30          [ignore], [ignore], [ignore])
31 # Modern Libtool has further tests for compatibility with older autoconf;
32 # from the Autoconf side, we will merely assume newer libtool.
33 AT_CHECK([[
34 case `libtoolize --version |
35       sed -n '/^.* \([0-9][0-9.a-z]*\)$/{
36                 s//\1/
37                 p
38                 q
39         }'` in
40   0.*    ) exit 77;;
41   1.*    ) exit 77;;
42 esac]],
43          [ignore], [ignore], [ignore])
45 # Using a configure.ac, have libtoolize confess where libtool.m4 is.
46 AT_DATA([configure.ac],
47 [[AC_INIT
48 # State that we explicitly want auxiliary files here, so libtoolize
49 # won't pollute files outside the test directory.
50 AC_CONFIG_AUX_DIR([.])
51 AC_PROG_LIBTOOL
52 ]])
53 AT_CHECK([LC_ALL=C libtoolize -i], [0], [stdout], [ignore])
55 # Some broken libtoolize fail to install a functional config.guess.
56 AT_CHECK([LC_ALL=C ./config.guess || exit 77], [], [ignore], [ignore])
58 # Make sure at-path contains something valid, and let the test suite
59 # display it when verbose.  And fail, skipping would too easily hide
60 # problems.
61 AT_CHECK([sed -n ["s,^[^']*[\`']\\(/[^']*\\)'.*,\\1,p"] stdout], [0], [stdout])
62 AT_CHECK([test -f "`sed -n 1p stdout`"])
64 # Older libtoolize installed everything but install-sh...
65 AT_CHECK([test -f install-sh || touch install-sh])
67 # Build the concatenation of libtool.m4 and configure.ac.
68 AT_CHECK([[sed 's/.*/m4''_include([&])/' stdout]], [0], [stdout])
69 AT_CHECK([mv stdout aclocal.m4])
70 cat >configure.ac <<_EOF
71 AC_INIT
72 AC_CONFIG_AUX_DIR([.])
73 AC_CANONICAL_SYSTEM
74 AC_PROG_LIBTOOL
75 _EOF
77 # FIXME: Once Libtool really fixed, stop ignoring stderr.
78 AT_CHECK_AUTOCONF([], [], [], [ignore])
80 # Ignore stderr, because ltconfig always loads the cache, which is
81 # /dev/null, and some shells choke on this.  For instance with Bash
82 # 2.05, you get:
84 #   loading cache /dev/null within ltconfig
85 #   ./ltconfig: .: /dev/null: not a regular file
87 # But the script executes properly.
88 AT_CHECK_CONFIGURE([], [], [], [ignore])
90 AT_CLEANUP
93 AT_SETUP([shtool])
95 AT_DATA([configure.ac],
96 [[AC_INIT([shtool test], [1.0])
97 AC_CONFIG_AUX_DIR([build-aux])
98 AC_PATH_PROG([SHTOOL], [shtool], [false])
99 AC_PROG_INSTALL
100 AC_SUBST([ac_install_sh])
101 AC_CONFIG_FILES([Makefile])
102 AC_OUTPUT
105 AT_DATA([Makefile.in],
106 [[SHTOOL = @SHTOOL@
107 # fake these, so that we use shtool wherever possible.
108 INSTALL_PROGRAM = $(ac_install_sh)
109 INSTALL_DATA = $(ac_install_sh) -m 644
110 prefix = @prefix@
111 ac_install_sh = @ac_install_sh@
113 install:
114         $(INSTALL_PROGRAM) file1 $(prefix)/file1
115         $(INSTALL_DATA) file2 $(prefix)/file2
117 copy-shtool:
118         test '$(SHTOOL)' != false
119         cp '$(SHTOOL)' build-aux
122 : >file1
123 : >file2
124 chmod +x file1
125 mkdir build-aux inst
126 instdir=`pwd`/inst
127 AT_CHECK_AUTOCONF
128 cp "$abs_top_srcdir/build-aux/install-sh" build-aux
129 AT_CHECK_CONFIGURE
130 AT_SKIP_IF([grep 'SHTOOL = false' Makefile > /dev/null 2>&1])
132 AT_CHECK_MAKE([copy-shtool])
133 AT_CHECK([test -s build-aux/shtool])
135 # AC_PROG_INSTALL should pick up shtool from build-aux, even though
136 # we're forcing AC_PATH_PROG not to find it on the host system.
137 rm -f build-aux/install-sh
138 AT_CHECK_CONFIGURE([--prefix="$instdir" ac_cv_path_SHTOOL=false])
139 AT_CHECK([grep '^ac_install_sh = .*shtool install -c' Makefile], [], [ignore])
140 AT_CHECK_MAKE([install])
141 AT_CHECK([test -f inst/file1 && test -f inst/file2 && test -x inst/file1])
143 AT_CLEANUP
145 AT_SETUP([AX_PROG_CC_FOR_BUILD])
147 cp "$abs_top_srcdir/build-aux/install-sh" \
148    "$abs_top_srcdir/build-aux/config.guess" \
149    "$abs_top_srcdir/build-aux/config.sub" .
151 # The Autoconf Macro Archive's AX_PROG_CC_FOR_BUILD invokes AC_PROG_CC
152 # twice, with a whole bunch of shell variables renamed at the m4 level
153 # the second time.  Git commit 18c140b50b0619454d4da50d58a318cc257d580a
154 # broke this usage and the breakage went unnoticed for *eight years*.
156 cp "$abs_top_srcdir/tests/data/ax_prog_cc_for_build_v18.m4" \
157    aclocal.m4
159 AT_DATA([configure.ac],
160 [[AC_INIT([foo], [1.0])
161 AX_PROG_CC_FOR_BUILD
162 AC_CONFIG_FILES([Makefile])
163 AC_OUTPUT
166 AT_DATA([Makefile.in],
167 [[CC = @CC@
168 CC_FOR_BUILD = @CC_FOR_BUILD@
171 AT_CHECK_AUTOCONF
172 AT_CHECK_CONFIGURE
174 AT_CHECK([grep '^CC = ..*$' Makefile > /dev/null 2>&1])
175 AT_CHECK([grep '^CC_FOR_BUILD = ..*$' Makefile > /dev/null 2>&1])
177 AT_CLEANUP
179 AT_SETUP([AX_PROG_CXX_FOR_BUILD])
181 cp "$abs_top_srcdir/build-aux/install-sh" \
182    "$abs_top_srcdir/build-aux/config.guess" \
183    "$abs_top_srcdir/build-aux/config.sub" .
185 # The Autoconf Macro Archive's AX_PROG_CXX_FOR_BUILD invokes AC_PROG_CXX
186 # twice, with a whole bunch of shell variables renamed at the m4 level
187 # the second time.  This usage was never broken (unlike with AC_PROG_CC)
188 # but it seems sensible to make sure it doesn't *get* broken.
190 cat "$abs_top_srcdir/tests/data/ax_prog_cc_for_build_v18.m4" \
191     "$abs_top_srcdir/tests/data/ax_prog_cxx_for_build_v3.m4" \
192    > aclocal.m4
194 AT_DATA([configure.ac],
195 [[AC_INIT([foo], [1.0])
196 AX_PROG_CXX_FOR_BUILD
197 AC_CONFIG_FILES([Makefile])
198 AC_OUTPUT
201 AT_DATA([Makefile.in],
202 [[CXX = @CXX@
203 CXX_FOR_BUILD = @CXX_FOR_BUILD@
206 AT_CHECK_AUTOCONF
207 AT_CHECK_CONFIGURE
209 AT_CHECK([grep '^CXX = ..*$' Makefile > /dev/null 2>&1])
210 AT_CHECK([grep '^CXX_FOR_BUILD = ..*$' Makefile > /dev/null 2>&1])
212 AT_CLEANUP
215 AT_SETUP([gnulib-std-gnu11.m4])
217 # Gnulib's std-gnu11.m4 (last significant change 2016-03-15) overrides
218 # most but not all of the internal macros used by AC_PROG_CC and AC_PROG_CXX.
219 # Commit 131d8c69f31dc6fc8dc93abe1096d52d1fe19fd3 changed the calling
220 # convention of _AC_C_STD_TRY, causing configure scripts that load
221 # std-gnu11.m4 to have shell syntax errors.
223 cp "$abs_top_srcdir/tests/data/gnulib_std_gnu11_2020_08_17.m4" \
224    aclocal.m4
226 AT_DATA([configure.ac],
227 [[AC_INIT([foo], [1.0])
228 AC_PROG_CC
229 AC_PROG_CXX
230 AC_OUTPUT
233 AT_CHECK_AUTOCONF
234 AT_CHECK_CONFIGURE
236 AT_CLEANUP