summaryrefslogtreecommitdiff
path: root/tests/foreign.at
blob: f3a53420ef807036313ffe44e4dcb473ae23acbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#							-*- Autotest -*-

AT_BANNER([Compatibility with external tools and macros.])

# Copyright (C) 2000-2007, 2009-2017, 2020 Free Software Foundation,
# Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


## --------- ##
## Libtool.  ##
## --------- ##

AT_SETUP([Libtool])

# Skip this test if there is no libtoolize.
AT_CHECK([libtoolize --version || exit 77],
	 [ignore], [ignore], [ignore])
# Modern Libtool has further tests for compatibility with older autoconf;
# from the Autoconf side, we will merely assume newer libtool.
AT_CHECK([[
case `libtoolize --version |
      sed -n '/^.* \([0-9][0-9.a-z]*\)$/{
		s//\1/
		p
		q
	}'` in
  0.*    ) exit 77;;
  1.*    ) exit 77;;
esac]],
	 [ignore], [ignore], [ignore])

# Using a configure.ac, have libtoolize confess where libtool.m4 is.
AT_DATA([configure.ac],
[[AC_INIT
# State that we explicitly want auxiliary files here, so libtoolize
# won't pollute files outside the test directory.
AC_CONFIG_AUX_DIR([.])
AC_PROG_LIBTOOL
]])
AT_CHECK([LC_ALL=C libtoolize -i], [0], [stdout], [ignore])

# Some broken libtoolize fail to install a functional config.guess.
AT_CHECK([LC_ALL=C ./config.guess || exit 77], [], [ignore], [ignore])

# Make sure at-path contains something valid, and let the test suite
# display it when verbose.  And fail, skipping would too easily hide
# problems.
AT_CHECK([sed -n ["s,^[^']*[\`']\\(/[^']*\\)'.*,\\1,p"] stdout], [0], [stdout])
AT_CHECK([test -f "`sed -n 1p stdout`"])

# Older libtoolize installed everything but install-sh...
AT_CHECK([test -f install-sh || touch install-sh])

# Build the concatenation of libtool.m4 and configure.ac.
AT_CHECK([[sed 's/.*/m4''_include([&])/' stdout]], [0], [stdout])
AT_CHECK([mv stdout aclocal.m4])
cat >configure.ac <<_EOF
AC_INIT
AC_CONFIG_AUX_DIR([.])
AC_CANONICAL_SYSTEM
AC_PROG_LIBTOOL
_EOF

# FIXME: Once Libtool really fixed, stop ignoring stderr.
AT_CHECK_AUTOCONF([], [], [], [ignore])

# Ignore stderr, because ltconfig always loads the cache, which is
# /dev/null, and some shells choke on this.  For instance with Bash
# 2.05, you get:
#
#   loading cache /dev/null within ltconfig
#   ./ltconfig: .: /dev/null: not a regular file
#
# But the script executes properly.
AT_CHECK_CONFIGURE([], [], [], [ignore])

AT_CLEANUP


AT_SETUP([shtool])

AT_DATA([configure.ac],
[[AC_INIT([shtool test], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AC_PATH_PROG([SHTOOL], [shtool], [false])
AC_PROG_INSTALL
AC_SUBST([ac_install_sh])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([Makefile.in],
[[SHTOOL = @SHTOOL@
# fake these, so that we use shtool wherever possible.
INSTALL_PROGRAM = $(ac_install_sh)
INSTALL_DATA = $(ac_install_sh) -m 644
prefix = @prefix@
ac_install_sh = @ac_install_sh@

install:
	$(INSTALL_PROGRAM) file1 $(prefix)/file1
	$(INSTALL_DATA) file2 $(prefix)/file2

copy-shtool:
	test '$(SHTOOL)' != false
	cp '$(SHTOOL)' build-aux
]])

: >file1
: >file2
chmod +x file1
mkdir build-aux inst
instdir=`pwd`/inst
AT_CHECK_AUTOCONF
cp "$abs_top_srcdir/build-aux/install-sh" build-aux
AT_CHECK_CONFIGURE
AT_SKIP_IF([grep 'SHTOOL = false' Makefile > /dev/null 2>&1])

AT_CHECK_MAKE([copy-shtool])
AT_CHECK([test -s build-aux/shtool])

# AC_PROG_INSTALL should pick up shtool from build-aux, even though
# we're forcing AC_PATH_PROG not to find it on the host system.
rm -f build-aux/install-sh
AT_CHECK_CONFIGURE([--prefix="$instdir" ac_cv_path_SHTOOL=false])
AT_CHECK([grep '^ac_install_sh = .*shtool install -c' Makefile], [], [ignore])
AT_CHECK_MAKE([install])
AT_CHECK([test -f inst/file1 && test -f inst/file2 && test -x inst/file1])

AT_CLEANUP

AT_SETUP([AX_PROG_CC_FOR_BUILD])

cp "$abs_top_srcdir/build-aux/install-sh" \
   "$abs_top_srcdir/build-aux/config.guess" \
   "$abs_top_srcdir/build-aux/config.sub" .

# The Autoconf Macro Archive's AX_PROG_CC_FOR_BUILD invokes AC_PROG_CC
# twice, with a whole bunch of shell variables renamed at the m4 level
# the second time.  Git commit 18c140b50b0619454d4da50d58a318cc257d580a
# broke this usage and the breakage went unnoticed for *eight years*.

AT_DATA([aclocal.m4],
[[# ax_prog_cc_for_build.m4
# serial 18
# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>

AC_DEFUN([AX_PROG_CC_FOR_BUILD], [
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
AC_REQUIRE([AC_CANONICAL_BUILD])

# Use the standard macros, but make them use other variable names
m4@&t@_pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)
m4@&t@_pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)
m4@&t@_pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)
m4@&t@_pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)
m4@&t@_pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)
m4@&t@_pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)
m4@&t@_pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)
m4@&t@_pushdef([ac_cv_exeext], ac_cv_build_exeext)
m4@&t@_pushdef([ac_cv_objext], ac_cv_build_objext)
m4@&t@_pushdef([ac_exeext], ac_build_exeext)
m4@&t@_pushdef([ac_objext], ac_build_objext)
m4@&t@_pushdef([CC], CC_FOR_BUILD)
m4@&t@_pushdef([CPP], CPP_FOR_BUILD)
m4@&t@_pushdef([GCC], GCC_FOR_BUILD)
m4@&t@_pushdef([CFLAGS], CFLAGS_FOR_BUILD)
m4@&t@_pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)
m4@&t@_pushdef([EXEEXT], BUILD_EXEEXT)
m4@&t@_pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)
m4@&t@_pushdef([OBJEXT], BUILD_OBJEXT)
m4@&t@_pushdef([host], build)
m4@&t@_pushdef([host_alias], build_alias)
m4@&t@_pushdef([host_cpu], build_cpu)
m4@&t@_pushdef([host_vendor], build_vendor)
m4@&t@_pushdef([host_os], build_os)
m4@&t@_pushdef([ac_cv_host], ac_cv_build)
m4@&t@_pushdef([ac_cv_host_alias], ac_cv_build_alias)
m4@&t@_pushdef([ac_cv_host_cpu], ac_cv_build_cpu)
m4@&t@_pushdef([ac_cv_host_vendor], ac_cv_build_vendor)
m4@&t@_pushdef([ac_cv_host_os], ac_cv_build_os)
m4@&t@_pushdef([ac_tool_prefix], ac_build_tool_prefix)
m4@&t@_pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)
m4@&t@_pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)
m4@&t@_pushdef([cross_compiling], cross_compiling_build)

cross_compiling_build=no

ac_build_tool_prefix=
AS@&t@_IF([test -n "$build"],      [ac_build_tool_prefix="$build-"],
          [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])

AC_LANG_PUSH([C])
AC_PROG_CC
_AC_COMPILER_EXEEXT
_AC_COMPILER_OBJEXT
AC_PROG_CPP

# Restore the old definitions
m4@&t@_popdef([cross_compiling])
m4@&t@_popdef([am_cv_prog_cc_c_o])
m4@&t@_popdef([am_cv_CC_dependencies_compiler_type])
m4@&t@_popdef([ac_tool_prefix])
m4@&t@_popdef([ac_cv_host_os])
m4@&t@_popdef([ac_cv_host_vendor])
m4@&t@_popdef([ac_cv_host_cpu])
m4@&t@_popdef([ac_cv_host_alias])
m4@&t@_popdef([ac_cv_host])
m4@&t@_popdef([host_os])
m4@&t@_popdef([host_vendor])
m4@&t@_popdef([host_cpu])
m4@&t@_popdef([host_alias])
m4@&t@_popdef([host])
m4@&t@_popdef([OBJEXT])
m4@&t@_popdef([LDFLAGS])
m4@&t@_popdef([EXEEXT])
m4@&t@_popdef([CPPFLAGS])
m4@&t@_popdef([CFLAGS])
m4@&t@_popdef([GCC])
m4@&t@_popdef([CPP])
m4@&t@_popdef([CC])
m4@&t@_popdef([ac_objext])
m4@&t@_popdef([ac_exeext])
m4@&t@_popdef([ac_cv_objext])
m4@&t@_popdef([ac_cv_exeext])
m4@&t@_popdef([ac_cv_c_compiler_gnu])
m4@&t@_popdef([ac_cv_prog_cc_g])
m4@&t@_popdef([ac_cv_prog_cc_cross])
m4@&t@_popdef([ac_cv_prog_cc_works])
m4@&t@_popdef([ac_cv_prog_cc_c89])
m4@&t@_popdef([ac_cv_prog_gcc])
m4@&t@_popdef([ac_cv_prog_CPP])

# restore global variables ac_ext, ac_cpp, ac_compile,
# ac_link, ac_compiler_gnu (dependant on the current
# language after popping):
AC_LANG_POP([C])

# Finally, set Makefile variables
AC_SUBST(BUILD_EXEEXT)
AC_SUBST(BUILD_OBJEXT)
AC_SUBST([CFLAGS_FOR_BUILD])
AC_SUBST([CPPFLAGS_FOR_BUILD])
AC_SUBST([LDFLAGS_FOR_BUILD])
])
]])

AT_DATA([configure.ac],
[[AC_INIT([foo], [1.0])
AX_PROG_CC_FOR_BUILD
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([Makefile.in],
[[CC = @CC@
CC_FOR_BUILD = @CC_FOR_BUILD@
]])

AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE

AT_CHECK([grep '^CC = ..*$' Makefile > /dev/null 2>&1])
AT_CHECK([grep '^CC_FOR_BUILD = ..*$' Makefile > /dev/null 2>&1])

AT_CLEANUP

AT_SETUP([AX_PROG_CXX_FOR_BUILD])

cp "$abs_top_srcdir/build-aux/install-sh" \
   "$abs_top_srcdir/build-aux/config.guess" \
   "$abs_top_srcdir/build-aux/config.sub" .

# The Autoconf Macro Archive's AX_PROG_CXX_FOR_BUILD invokes AC_PROG_CXX
# twice, with a whole bunch of shell variables renamed at the m4 level
# the second time.  This usage was never broken (unlike with AC_PROG_CC)
# but it seems sensible to make sure it doesn't *get* broken.

AT_DATA([aclocal.m4],
[[# ax_prog_cxx_for_build.m4
# serial 3
# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
# Copyright (c) 2012 Avionic Design GmbH

AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [
AC_LANG_PUSH([C++])

AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([AC_PROG_CXXCPP])
AC_REQUIRE([AC_CANONICAL_HOST])

# Use the standard macros, but make them use other variable names
m4@&t@_pushdef([ac_cv_prog_CXXCPP], ac_cv_build_prog_CXXCPP)
m4@&t@_pushdef([ac_cv_prog_gxx], ac_cv_build_prog_gxx)
m4@&t@_pushdef([ac_cv_prog_cxx_works], ac_cv_build_prog_cxx_works)
m4@&t@_pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)
m4@&t@_pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)
m4@&t@_pushdef([CXX], CXX_FOR_BUILD)
m4@&t@_pushdef([CXXCPP], CXXCPP_FOR_BUILD)
m4@&t@_pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)
m4@&t@_pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)
m4@&t@_pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)
m4@&t@_pushdef([host], build)
m4@&t@_pushdef([host_alias], build_alias)
m4@&t@_pushdef([host_cpu], build_cpu)
m4@&t@_pushdef([host_vendor], build_vendor)
m4@&t@_pushdef([host_os], build_os)
m4@&t@_pushdef([ac_cv_host], ac_cv_build)
m4@&t@_pushdef([ac_cv_host_alias], ac_cv_build_alias)
m4@&t@_pushdef([ac_cv_host_cpu], ac_cv_build_cpu)
m4@&t@_pushdef([ac_cv_host_vendor], ac_cv_build_vendor)
m4@&t@_pushdef([ac_cv_host_os], ac_cv_build_os)
m4@&t@_pushdef([ac_cxxcpp], ac_build_cxxcpp)
m4@&t@_pushdef([ac_compile], ac_build_compile)
m4@&t@_pushdef([ac_link], ac_build_link)

save_cross_compiling=$cross_compiling
save_ac_tool_prefix=$ac_tool_prefix
cross_compiling=no
ac_tool_prefix=

AC_PROG_CXX
AC_PROG_CXXCPP

ac_tool_prefix=$save_ac_tool_prefix
cross_compiling=$save_cross_compiling

# Restore the old definitions
m4@&t@_popdef([ac_link])
m4@&t@_popdef([ac_compile])
m4@&t@_popdef([ac_cxxcpp])
m4@&t@_popdef([ac_cv_host_os])
m4@&t@_popdef([ac_cv_host_vendor])
m4@&t@_popdef([ac_cv_host_cpu])
m4@&t@_popdef([ac_cv_host_alias])
m4@&t@_popdef([ac_cv_host])
m4@&t@_popdef([host_os])
m4@&t@_popdef([host_vendor])
m4@&t@_popdef([host_cpu])
m4@&t@_popdef([host_alias])
m4@&t@_popdef([host])
m4@&t@_popdef([CXXCPPFLAGS])
m4@&t@_popdef([CPPFLAGS])
m4@&t@_popdef([CXXFLAGS])
m4@&t@_popdef([CXXCPP])
m4@&t@_popdef([CXX])
m4@&t@_popdef([ac_cv_prog_cxx_g])
m4@&t@_popdef([ac_cv_prog_cxx_cross])
m4@&t@_popdef([ac_cv_prog_cxx_works])
m4@&t@_popdef([ac_cv_prog_gxx])
m4@&t@_popdef([ac_cv_prog_CXXCPP])

# Finally, set Makefile variables
AC_SUBST([CXXFLAGS_FOR_BUILD])
AC_SUBST([CXXCPPFLAGS_FOR_BUILD])

AC_LANG_POP([C++])
])
]])

AT_DATA([configure.ac],
[[AC_INIT([foo], [1.0])
AX_PROG_CXX_FOR_BUILD
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([Makefile.in],
[[CXX = @CXX@
CXX_FOR_BUILD = @CXX_FOR_BUILD@
]])

AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE

AT_CHECK([grep '^CXX = ..*$' Makefile > /dev/null 2>&1])
AT_CHECK([grep '^CXX_FOR_BUILD = ..*$' Makefile > /dev/null 2>&1])

AT_CLEANUP