Debian Codegraph @

tests/local.at

raw
1 # M4 macros used in building Autoconf test suites. -*- Autotest -*-
2
3 # Copyright (C) 2000-2017, 2020-2026 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18 m4_version_prereq([2.57])
19
20 # Used in many tests.
21 m4_pattern_allow([^AS_EXIT$])
22 m4_pattern_allow([^m4_(define|shift)$])
23
24 # Programs this package provides
25 AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
26
27
28 # Enable colored test output.
29 AT_COLOR_TESTS
30
31 # Sanitize the environment used for tests.
32 AT_PREPARE_TESTS(
33 [# MAKEFLAGS should not be inherited from the parent environment.
34 AS_UNSET([MAKEFLAGS])
35
36 # We do not want to read any external config.site file.
37 # If CONFIG_SITE is not set, autoconf will look for config.site in
38 # $prefix/share and $prefix/etc.
39 AS_IF([test -e nonexistent],
40 [AS_ERROR([something named 'nonexistent' exists in the test directory])])
41 CONFIG_SITE=`pwd`/nonexistent/config.site
42 export CONFIG_SITE
43
44 # Ensure MAKE, AUTOMAKE, and ACLOCAL are set to useful values. Unlike
45 # the above, we *do* want to inherit these variables from the parent
46 # environment and/or our command line. Also, detect now whether
47 # automake and aclocal are unavailable or too old.
48 : "${MAKE=make}"
49 export MAKE
50
51 # Some old versions of automake, when used with newer Perl interpreters,
52 # will print a warning message about their own Perl code on every
53 # invocation, which breaks various tests' expectations for output.
54 # This also weeds out broken wrapper scripts; in the past some vendors
55 # have shipped an 'automake' that didn't work without user configuration.
56 : "${AUTOMAKE=automake}"
57 at_automake_version="`$AUTOMAKE --version 2>&1 || :`"
58 at_automake_version_1="`AS_ECHO(["$at_automake_version"]) | sed 1q`"
59 AS_CASE([$at_automake_version_1],
60 [[*GNU*\)\ [1-9]\.[0-9]*]], [],
61 [AUTOMAKE=false])
62 export AUTOMAKE
63
64 # Used in the code below that decides delay intervals.
65 if test "$AUTOMAKE" = false
66 then
67 # If automake is unavailable, then whether it supports subsecond
68 # mtime is moot.
69 at_automake_subsecond_mtime=:
70 elif AS_ECHO(["$at_automake_version"]) |
71 grep 'Features: subsecond-mtime' > /dev/null 2>&1
72 then
73 at_automake_subsecond_mtime=:
74 else
75 at_automake_subsecond_mtime=false
76 fi
77
78 # The same Perl and wrapper issues exist with aclocal. Also, we
79 # require a version that understands --system-acdir and configure.ac.
80 : "${ACLOCAL=aclocal}"
81 at_aclocal_version="`$ACLOCAL --version 2>&1 || :`"
82 at_aclocal_version_1="`AS_ECHO(["$at_aclocal_version"]) | sed 1q`"
83 AS_CASE([$at_aclocal_version_1],
84 [[*GNU*\)\ [1-9]\.[0-9]*]],
85 [mkdir at_scratch
86 (cd at_scratch &&
87 touch configure.ac &&
88 mkdir empty &&
89 $ACLOCAL --system-acdir=`pwd`/empty) || ACLOCAL=false
90 rm -rf at_scratch],
91 [ACLOCAL=false])
92 export ACLOCAL
93
94 # Prevent aclocal from reading third-party macros, in case they are buggy.
95 # (AM_INIT_AUTOMAKE will still be available via the default --automake-acdir.)
96 if test "$ACLOCAL" != false; then
97 test -d at_empty_dir || mkdir at_empty_dir
98 ACLOCAL="$ACLOCAL --system-acdir=`cd at_empty_dir && pwd`"
99 fi
100
101 # Similarly for the add-on programs that autoreconf can run:
102 # libtoolize, intltoolize, gtkdocize, and autopoint.
103 : "${LIBTOOLIZE=libtoolize}"
104 at_libtoolize_version="`$LIBTOOLIZE --version 2>&1 || :`"
105 at_libtoolize_version_1="`AS_ECHO(["$at_libtoolize_version"]) | sed 1q`"
106 AS_CASE([$at_libtoolize_version_1],
107 [[*GNU*\)\ [1-9]\.[0-9]*]], [],
108 [LIBTOOLIZE=false])
109 export LIBTOOLIZE
110
111 : "${INTLTOOLIZE=intltoolize}"
112 at_intltoolize_version="`$INTLTOOLIZE --version 2>&1 || :`"
113 at_intltoolize_version_1="`AS_ECHO(["$at_intltoolize_version"]) | sed 1q`"
114 AS_CASE([$at_intltoolize_version_1],
115 [[*GNU*\)\ [0-9]\.[0-9]*]], [],
116 [INTLTOOLIZE=false])
117 export INTLTOOLIZE
118
119 : "${GTKDOCIZE=gtkdocize}"
120 at_gtkdocize_version="`$GTKDOCIZE --version 2>&1 || :`"
121 at_gtkdocize_version_1="`AS_ECHO(["$at_gtkdocize_version"]) | sed 1q`"
122 AS_CASE([$at_gtkdocize_version_1],
123 [[*gtk-doc*\)\ [1-9]\.[0-9]*]], [],
124 [GTKDOCIZE=false])
125 export GTKDOCIZE
126
127 : "${AUTOPOINT=autopoint}"
128 at_autopoint_version="`$AUTOPOINT --version 2>&1 || :`"
129 at_autopoint_version_1="`AS_ECHO(["$at_autopoint_version"]) | sed 1q`"
130 AS_CASE([$at_autopoint_version_1],
131 [[*GNU*\)\ [0-9]\.[0-9]*]], [],
132 [AUTOPOINT=false])
133 export AUTOPOINT
134
135 # Older versions of autopoint cannot handle a configure.ac that has
136 # AM_GNU_GETTEXT but doesn't have one of AM_GNU_GETTEXT_VERSION or
137 # AM_GNU_GETTEXT_REQUIRE_VERSION. The versions that *do* handle
138 # this correctly are
139 # - 0.23.x, x >= 2
140 # - 0.24.x, x >= 2
141 # - 0.25.x, x >= 1
142 # - 0.26(.0) and up.
143 # This logic needs to agree with the logic for $autopoint_works_without_gtver
144 # in bin/autoreconf.in.
145 AS_CASE(["`AS_ECHO(["$at_autopoint_version_1"]) | sed 's/^.*) *//'`"],
146 [[ [1-9][.0-9]* | \
147 0.[3-9][0-9]* | \
148 0.2[6-9] | \
149 0.2[6-9][.0-9]* | \
150 0.25.[1-9]* | \
151 0.2[34].[2-9]* ]],
152 [at_autopoint_modern=:],
153 [at_autopoint_modern=false])
154
155 # Determine how long we need to delay in between operations that might
156 # modify autom4te.cache. This depends on three factors: whether the
157 # 'sleep' utility supports fractional seconds in its argument; what
158 # the resolution of last-modification timestamps is on the file system
159 # hosting the build; and whether autom4te and automake can both make
160 # use of high-resolution file timestamps (this is not entirely under
161 # our control because it depends on the capabilities of the Perl
162 # installation).
163 #
164 # This series of tests mostly cribbed from automake/m4/sanity.m4.
165 # We cannot rely on the execution of that code inside autoconf's own
166 # configure script, because (depending on what version of automake was
167 # used to generate the configure script) it might not be there at all,
168 # or might be buggy. Also, even if it's present and correct, it didn't
169 # probe the autom4te we just built, which is the one we care about.
170 #
171 # The coarsest file system we know of is FAT, with a resolution
172 # of only two seconds, even with the most recent "exFAT" extensions.
173 # The finest (e.g. ext4 with large inodes, XFS, ZFS) is one
174 # nanosecond, matching clock_gettime. However, it is probably not
175 # possible to delay execution of a shell script for less than one
176 # millisecond, due to process creation overhead and scheduling
177 # granularity, so we don't check for anything finer than that.
178
179 # Default to the coarsest case.
180 at_ts_resolution=2
181
182 # Only try to go finer than 1s if sleep, autom4te, and automake (if present)
183 # can all handle it.
184 at_try_resolutions=1
185 if sleep 0.001 2>/dev/null &&
186 autom4te --version 2>&1 |
187 grep 'Features:.*subsecond-mtime' > /dev/null 2>&1 &&
188 $at_automake_subsecond_mtime
189 then
190 at_try_resolutions="0.001 0.01 0.1 $at_try_resolutions"
191 fi
192
193 # In order to catch current-generation FAT out, we must *modify* files
194 # that already exist; the *creation* timestamp is finer.
195 rm -f conftest.ts?
196 : > conftest.ts1
197 : > conftest.ts2
198 : > conftest.ts3
199
200 for at_try_res in $at_try_resolutions; do
201 # Any one fine-grained sleep might happen to cross the boundary
202 # between two values of a coarser actual resolution, but if we do
203 # two fine-grained sleeps in a row, at least one of them will fall
204 # entirely within a coarse interval.
205 echo alpha > conftest.ts1
206 sleep $at_try_res
207 echo beta > conftest.ts2
208 sleep $at_try_res
209 echo gamma > conftest.ts3
210
211 if test conftest.ts1 -ot conftest.ts2 &&
212 test conftest.ts2 -ot conftest.ts3; then
213 at_ts_resolution=$at_try_res
214 break
215 fi
216 done
217 rm -f conftest.ts?
218
219 # AT_TESTED doesn't support variables in its argument, particularly
220 # when they might contain the name of a program along with some
221 # arguments, or when they might evaluate to 'false'.
222 # Do this in a subshell to contain the effects of 'set'.
223 (status=0
224 AS_BOX([System supplied programs that we depend on.])
225 echo
226 for at_program in \
227 "r m4 $M4" \
228 "r perl $PERL" \
229 "r sh ${CONFIG_SHELL-$SHELL}" \
230 "r make $MAKE" \
231 "o automake $AUTOMAKE" \
232 "o aclocal $ACLOCAL" \
233 "o libtoolize $LIBTOOLIZE" \
234 "o intltoolize $INTLTOOLIZE" \
235 "o gtkdocize $GTKDOCIZE" \
236 "o autopoint $AUTOPOINT"
237 do
238 # The first three words of $at_program are a code for whether
239 # it's required (r) or optional (o); the conventional name of the
240 # program (for error messages); and the name (possibly a pathname)
241 # we were told to use for it.
242 set dummy $at_program
243 at_required=$[]2
244 at_prog_name=$[]3
245 at_prog_use=$[]4
246 at_prog_use_=
247
248 AS_CASE(["$at_prog_use"],
249 [: | true | false], [],
250 [[[\\/]* | ?:[\\/]*]],
251 [test -f "$at_prog_use" && at_prog_use_=$at_prog_use],
252 [_AS_PATH_WALK([$PATH],
253 [if test -f "$as_dir$at_prog_use"; then
254 at_prog_use_=$as_dir$at_prog_use
255 break
256 fi])])
257
258 if test -n "$at_prog_use_"; then
259 {
260 AS_ECHO(["# $at_prog_name is $at_prog_use_"])
261 AS_ECHO(["$at_prog_use_ --version"])
262 "$at_prog_use_" --version </dev/null
263 } >&AS_MESSAGE_LOG_FD 2>&1
264 elif test $at_required = r; then
265 AS_ECHO(["*** Required program $at_prog_name is unavailable."])
266 status=1
267 else
268 AS_ECHO(["# $at_prog_name is unavailable"])
269 fi
270 echo
271 done
272
273 AS_ECHO(["$at_srcdir/AT_LINE: using ${at_ts_resolution}s as mtime resolution"])
274
275 if test x"$AUTOPOINT" != xfalse; then
276 if $at_autopoint_modern; then
277 at_autopoint_status="supports AM_GNU_GETTEXT by itself"
278 else
279 at_autopoint_status="does not support AM_GNU_GETTEXT by itself"
280 fi
281 AS_ECHO(["$at_srcdir/AT_LINE: $AUTOPOINT $at_autopoint_status"])
282 fi
283
284 echo
285 exit $status
286 ) >&AS_MESSAGE_LOG_FD 2>&1
287
288 if test $? -ne 0; then
289 AS_ERROR([*** Some required programs were not found.])
290 fi
291 ])
292
293
294
295 ## ---------------- ##
296 ## Utility macros. ##
297 ## ---------------- ##
298
299 # AT_CMP(FILE-1, FILE-2)
300 # ----------------------
301 # Check FILE-1 and FILE-2 for equality, like 'cmp FILE-1 FILE-2'.
302 m4_define([AT_CMP],
303 [m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])]dnl
304 [AT_CHECK([$at_diff "$1" "$2"])])
305
306 # AT_MTIME_DELAY
307 # --------------
308 # Wait for a short time, to ensure that files created before this
309 # command are considered to be older than files created afterward.
310 m4_define([AT_MTIME_DELAY],
311 [sleep $at_ts_resolution])
312
313 # AT_REQUIRE_AUTOMAKE
314 # -------------------
315 # Skip this test if automake is unavailable or too old.
316 m4_define([AT_REQUIRE_AUTOMAKE],
317 [AT_SKIP_IF([test "$AUTOMAKE" = false])])
318
319 # AT_REQUIRE_ACLOCAL
320 # ------------------
321 # Skip this test if aclocal is unavailable or too old.
322 m4_define([AT_REQUIRE_ACLOCAL],
323 [AT_SKIP_IF([test "$ACLOCAL" = false])])
324
325 # AT_SUPPRESS_ACLOCAL
326 # -------------------
327 # Prevent autoreconf from running aclocal, which might not be available.
328 # Use this instead of AT_REQUIRE_ACLOCAL in tests that run autoreconf
329 # but don't need aclocal to do anything.
330 m4_define([AT_SUPPRESS_ACLOCAL],
331 [AT_DATA([aclocal.m4])
332 ACLOCAL=true])
333
334 # AT_REQUIRE_LIBTOOL
335 # ------------------
336 # Skip this test if libtool is unavailable or too old.
337 m4_define([AT_REQUIRE_LIBTOOL],
338 [AT_SKIP_IF([test "$LIBTOOLIZE" = false])])
339
340 # AT_REQUIRE_AUTOPOINT
341 # --------------------
342 # Skip this test if autopoint is unavailable or too old.
343 m4_define([AT_REQUIRE_AUTOPOINT],
344 [AT_SKIP_IF([test "$AUTOPOINT" = false])])
345
346 # AT_REQUIRE_INTLTOOLIZE
347 # ----------------------
348 # Skip this test if intltoolize is unavailable or too old.
349 m4_define([AT_REQUIRE_INTLTOOLIZE],
350 [AT_SKIP_IF([test "$INTLTOOLIZE" = false])])
351
352 # AT_REQUIRE_GTKDOCIZE
353 # --------------------
354 # Skip this test if gtkdocize is unavailable or too old.
355 m4_define([AT_REQUIRE_GTKDOCIZE],
356 [AT_SKIP_IF([test "$GTKDOCIZE" = false])])
357
358
359
360 # AT_STATE_SAVE_DIR, AT_STATE_SAVE_ENV, and AT_STATE_SAVE
361 # -------------------------------------------------------
362 # These are the AC_ macros of the same names, from statesave.m4,
363 # renamed into the AT_ namespace. In tests that don't use
364 # AT_CHECK_CONFIGURE_AC, you can do
365 #
366 # AT_STATE_SAVE_DIR([before])
367 # ... commands ...
368 # AT_CHECK_ENV
369 #
370 # to verify that the 'commands' did not change the contents of the
371 # current working directory.
372 #
373 # The other two macros seem unlikely to be useful, as they record all
374 # the internal variables of the test script and AT_CHECK_ENV is not
375 # currently set up to deal with that, but you never know.
376 m4_include([statesave.m4])
377 m4_rename([AC_STATE_SAVE_DIR], [AT_STATE_SAVE_DIR])
378 m4_rename([AC_STATE_SAVE_ENV], [AT_STATE_SAVE_ENV])
379 m4_rename([AC_STATE_SAVE], [AT_STATE_SAVE])
380
381 ## ---------------- ##
382 ## Testing syntax. ##
383 ## ---------------- ##
384
385 # AT_CHECK_SHELL_SYNTAX(PROGRAM)
386 # ------------------------------
387 # If the shell handles '-n' well, use it to check the syntax of PROGRAM;
388 # otherwise, do nothing. ksh93 -n also spits outs loads of warnings
389 # about older constructs, but we don't care about the warnings.
390 m4_define([AT_CHECK_SHELL_SYNTAX],
391 [AT_SKIP_IF([test "$SHELL_N" = none])
392 AT_CHECK(["$SHELL_N" -n $1], [], [], [ignore])])
393
394 m4_define([AT_CHECK_PERL_SYNTAX],
395 [AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],
396 0, [], [ignore])])
397
398 ## ------------------ ##
399 ## Testing autom4te. ##
400 ## ------------------ ##
401
402
403 # AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR)
404 # -------------------------------------------------------
405 # If stderr is specified, normalize the observed stderr.
406 # This (using GNU M4 1.4.6)
407 #
408 # /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory
409 # autom4te: /usr/local/bin/m4 failed with exit status: 1
410 #
411 # or this (GNU M4 1.4.11)
412 #
413 # /usr/local/bin/m4:script.4s:1: include: cannot open `foo': No such file or directory
414 # autom4te: /usr/local/bin/m4 failed with exit status: 1
415 #
416 # or this (GNU M4 1.4 installed as gm4)
417 #
418 # script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory
419 # autom4te: /usr/local/bin/gm4 failed with exit status: 1
420 #
421 # or this (GNU M4 1.4.13 installed as m4-1.4.13):
422 #
423 # /usr/bin/m4-1.4.13:script.4s:1: include: cannot open `foo': No such file or directory
424 # autom4te: /usr/bin/m4-1.4.13 failed with exit status: 1
425 #
426 # becomes
427 #
428 # m4:script.4s:1: cannot open 'foo': No such file or directory
429 # autom4te: m4 failed with exit status: 1
430 #
431 # Also, this
432 #
433 # configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
434 # configure.ac:6: You should run autoupdate.
435 # ../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from...
436 # configure.ac:6: the top level
437 #
438 # becomes
439 #
440 # configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
441 # configure.ac:6: You should run autoupdate.
442 # lang.m4: AC_LANG_SAVE is expanded from...
443 # configure.ac:6: the top level
444 #
445 # We use the following sed patterns:
446 #
447 # (m4): ?(file): ?(line):
448 # or (file): ?(line): ?(m4):
449 # to m4:(file):(line):
450 #
451 # and
452 # m4:(file):(line): Cannot open foo:
453 # or m4:(file):(line): include: cannot open [`']foo':
454 # to m4:(file):(line): cannot open 'foo':
455 #
456 # and
457 # autom4te: [^ ]m4
458 # or autom4te: [^ ]m4.exe
459 # to autom4te: m4
460 #
461 # and
462 # (path)/(basename).m4: ?(line): (message)
463 # to (basename).m4: (message)
464 #
465 # Moreover, DJGPP error messages include the error code in brackets;
466 # remove the error code during normalization.
467 #
468 m4_define([AT_CHECK_M4],
469 [AT_CHECK([$1], [$2], [$3],
470 m4_case([$4], [], [], [ignore], [ignore], [stderr]))
471 m4_case([$4], [], [], [ignore], [],
472 [AT_CHECK([[mv stderr stderr-raw &&
473 sed 's/^[^:]*m4[-.ex0-9]*: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/
474 s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4[-.ex0-9]*: /m4:\1\2 /
475 s/: include: [cC]\(annot open\)/: c\1/
476 s/: [cC]\(annot open \)[`'\'']*\([^'\'':]*\)'\''*:/: c\1'\''\2'\'':/
477 s/^autom4te: [^ ]*m4[.ex]* /autom4te: m4 /
478 s/^autom4te: error: [^ ]*m4[.ex]* /autom4te: error: m4 /
479 s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *!\1.m4: !
480 s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *[0-9][0-9]*: *!\1.m4: !
481 s/ (E[A-Z]*)$//
482 ' stderr-raw >&2]], [0], [], [$4])])
483 ])
484
485 # AT_CHECK_AUTOM4TE(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
486 # -----------------------------------------------------------
487 m4_define([AT_CHECK_AUTOM4TE],
488 [AT_CHECK_M4([autom4te $1], [$2], [$3], [$4])])
489
490
491
492 ## ----------------- ##
493 ## Testing M4sugar. ##
494 ## ----------------- ##
495
496
497 # AT_DATA_M4SUGAR(FILE-NAME, CONTENTS)
498 # ------------------------------------
499 # Escape the invalid tokens with @&t@.
500 m4_define([AT_DATA_M4SUGAR],
501 [AT_DATA([$1],
502 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\)\(_\)\|\(d\)\(nl\)],
503 [\1\3\5@&t@\2\4\6])])])
504
505
506 # AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
507 # ----------------------------------------------------------
508 m4_define([AT_CHECK_M4SUGAR],
509 [AT_KEYWORDS([m4sugar])
510 AT_CHECK_AUTOM4TE([--language=m4sugar script.4s -o script $1],
511 [$2], [$3], [$4])])
512
513
514
515 ## -------------- ##
516 ## Testing M4sh. ##
517 ## -------------- ##
518
519
520 # AT_DATA_M4SH(FILE-NAME, CONTENTS)
521 # ---------------------------------
522 # Escape the invalid tokens with @&t@.
523 m4_define([AT_DATA_M4SH],
524 [AT_DATA([$1],
525 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\)\(_\)\|\(d\)\(nl\)],
526 [\1\3\5@&t@\2\4\6])])])
527
528
529 # AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
530 # -------------------------------------------------------
531 m4_define([AT_CHECK_M4SH],
532 [AT_CHECK_AUTOM4TE([--language=m4sh script.as -o script $1],
533 [$2], [$3], [$4])])
534
535
536
537 ## ------------------ ##
538 ## Testing Autoconf. ##
539 ## ------------------ ##
540
541
542 # AT_DATA_AUTOCONF(FILE-NAME, CONTENTS)
543 # -------------------------------------
544 # Escape the invalid tokens with @&t@.
545 m4_define([AT_DATA_AUTOCONF],
546 [AT_DATA([$1],
547 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AC\)\(_\)\|\(d\)\(nl\)],
548 [\1\3\5@&t@\2\4\6])])])
549
550
551
552 # AT_CONFIGURE_AC(BODY)
553 # ---------------------
554 # Create a full configure.ac running BODY, with a config header set up,
555 # AC_OUTPUT, and environment checking hooks.
556 m4_define([AT_CONFIGURE_AC],
557 [AT_DATA([configure.ac],
558 [[AC_INIT
559 AC_CONFIG_HEADERS(config.h:config.hin)
560 AC_STATE_SAVE(before)]
561 $1
562 [AC_OUTPUT
563 AC_STATE_SAVE(after)
564 ]])
565 cp "$abs_top_srcdir/build-aux/install-sh" \
566 "$abs_top_srcdir/build-aux/config.guess" \
567 "$abs_top_srcdir/build-aux/config.sub" .
568 cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
569 ])# AT_CONFIGURE_AC
570
571
572 # AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
573 # ----------------------------------------------------------
574 # We always use "--force", to prevent problems with timestamps if the testsuite
575 # were running too fast.
576 m4_define([AT_CHECK_AUTOCONF],
577 [AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4])
578 if test -s configure && test "$SHELL_N" != none; then
579 AT_CHECK_SHELL_SYNTAX([configure])
580 fi
581 ])
582
583
584 # AT_CHECK_AUTOHEADER(ARGS, EXPECTED_TMPLS, [EXIT-STATUS = 0], STDOUT, STDERR)
585 # ----------------------------------------------------------------------------
586 # EXPECTED_TMPLS is a whitespace-separated list of template
587 # definitions that should appear in the generated config.hin.
588 # The stock definitions made by AC_INIT are also checked for.
589 # If EXPECTED_TMPLS is the single word 'ignore', or if the
590 # expected exit status is not 0, this test is skipped.
591 m4_define([AT_CHECK_AUTOHEADER],
592 [AT_CHECK_M4([autoheader $1], [$3], [$4], [$5])
593 m4_if(m4_strip([$2]), [ignore], [],
594 [m4_if(m4_default_nblank([$3], [0]), [0], [dnl
595 if test -f config.h.in
596 then config_h_in=config.h.in
597 elif test -f config.hin
598 then config_h_in=config.hin
599 else AT_FAIL_IF([: "Cannot find autoheader template file"])
600 fi
601 m4_set_add_all([ah_expected_tmpls],
602 [PACKAGE_BUGREPORT],
603 [PACKAGE_NAME],
604 [PACKAGE_STRING],
605 [PACKAGE_TARNAME],
606 [PACKAGE_URL],
607 [PACKAGE_VERSION])dnl
608 m4_map_args_w([$2],
609 [m4_set_add([ah_expected_tmpls],], [)])dnl
610 AT_DATA([expout.in],[m4_set_dump([ah_expected_tmpls],[
611 ])
612 ])
613 AT_CHECK([sort -o expout expout.in])
614 AT_CHECK([[sed -ne 's/^[ ]*#[ ]*undef[ ][ ]*//p' \
615 $config_h_in | sort]],
616 [0], [expout], [])
617 AS_UNSET([config_h_in])
618 ])])])
619
620
621 # AT_CHECK_CONFIGURE(END-COMMAND,
622 # [EXIT-STATUS = 0],
623 # [STDOUT = IGNORE], STDERR)
624 # ---------------------------------------------
625 # 'abs_top_srcdir' is needed so that './configure' finds install-sh.
626 # Using --srcdir is more expensive.
627 m4_define([AT_CHECK_CONFIGURE],
628 [AT_CAPTURE_FILE([config.log])[]dnl
629 AT_CHECK([./configure $configure_options $1],
630 [$2],
631 m4_default([$3], [ignore]), [$4])])
632
633
634 # AT_CHECK_ENV
635 # ------------
636 # Check that the full configure run remained in its variable name space,
637 # and cleaned up tmp files.
638 #
639 # Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
640 # In this case just don't pay attention to the env. It would be great
641 # to keep the error message but we can't: that would break AT_CHECK.
642 #
643 # FreeBSD sh may intermingle the trace output from the egrep and grep
644 # commands in the pipe, so turn off tracing for these.
645 #
646 # Some tests might exit prematurely when they find a problem, in
647 # which case 'env-after' is probably missing. Don't check it then.
648 #
649 # Here are the variables 'configure' may modify during execution:
650 # - ^as_
651 # M4sh's shell name space.
652 # - ^ac_
653 # Autoconf's shell name space.
654 # - prefix and exec_prefix
655 # are kept undefined (NONE) until AC_OUTPUT which then sets them to
656 # '/usr/local' and '${prefix}' for make.
657 # - (host|build|target)(_(alias|cpu|vendor|os))?
658 # Set by AC_CANONICAL_(HOST|BUILD|TARGET).
659 # - cross_compiling
660 # Set by AC_INIT.
661 # - interpval
662 # Set by AC_SYS_INTERPRETER.
663 # - enableval, withval, enable_*, with_*
664 # Set by AC_ARG_ENABLE and AC_ARG_WITH.
665 # - CONFIG_STATUS and DEFS
666 # Set by AC_OUTPUT.
667 # - AC_SUBST'ed variables
668 # (FIXME: Generate a list of these automatically.)
669 # - _|@|.[*#?$].|argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS
670 # |SHLVL|START_TIME|ToD|_AST_FEATURES
671 # Some variables some shells use and change.
672 # '.[*#?$].' catches '$#' etc. which are displayed like this:
673 # | '!'=18186
674 # | '#'=0
675 # | '$'=6908
676 #
677 m4_defun([AT_CHECK_ENV],
678 [m4_require([_AT_CHECK_ENV])]dnl
679 [AT_CHECK([ath_fn_check_env])])
680
681 m4_defun([_AT_CHECK_ENV],
682 [AT_TEST_HELPER_FN([check_env], [],
683 [Compare the directory and environment state both before and after a run,
684 and return non-zero status if they differ inappropriately.],
685 [# Compare directory listings.
686 test -f state-ls.before ||
687 AS_ERROR([state-ls.before not present])
688 test -f state-ls.after \
689 && { $at_diff state-ls.before state-ls.after || return 1; }
690 # Compare variable space dumps.
691 if test -f state-env.before && test -f state-env.after; then
692 set +x
693 grep_failed=false
694 for act_file in state-env.before state-env.after
695 do
696 ($EGREP -v '^(m4_join([|],
697 [a[cs]_.*],
698 [(exec_)?prefix|DEFS|CONFIG_STATUS],
699 [A68|A68FLAGS|CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
700 [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
701 [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
702 [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
703 [OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
704 [GOC|GOFLAGS],
705 [OPENMP_(C|CXX)FLAGS],
706 [LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
707 [INSTALL(_(DATA|PROGRAM|SCRIPT))?],
708 [EXEEXT|OBJEXT],
709 [CYGWIN|EMXOS2|ISC|MINGW32|MINIX|MSYS|XENIX],
710 [X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
711 [(host|build|target)(_(alias|cpu|vendor|os))?],
712 [cross_compiling|U],
713 [enableval|enable_.*|withval|with_.*],
714 [interpval|PATH_SEPARATOR],
715 [GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
716 [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],
717 [ALLOCA|GETGROUPS_LIB|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
718 [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|AR|RANLIB|SET_MAKE|YACC],
719 [EGREP_TRADITIONAL],
720 [GREP|[EF]GREP|SED],
721 [[_@]|.[*@%:@?$].],
722 [argv|ARGC|LINENO|BASH_ARGC|BASH_ARGV|OLDPWD|PIPESTATUS|RANDOM],
723 [SECONDS|SHLVL|START_TIME|ToD|_AST_FEATURES]))=' \
724 $act_file ||
725 test $? -eq 1 || echo failed >&2
726 ) 2>stderr-$act_file |
727 # There may be variables spread on several lines; remove latter lines.
728 $GREP '^m4_defn([m4_re_word])=' >clean-$act_file ||
729 test $? -eq 1 || grep_failed=:
730 test -s stderr-$act_file && grep_failed=:
731 done
732 $at_traceon
733 $grep_failed || $at_diff clean-state-env.before clean-state-env.after
734 fi
735 ])])
736
737
738 # AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B, [EXTRA-VARIANCE])
739 # -------------------------------------------------------
740 # Check the outcomes of two configure runs for equality by comparing dumps of
741 # their shell variables. VAR-FILE-A and VAR-FILE-B are two 'set'-style shell
742 # variable space dumps.
743 #
744 # We permit variance between runs in the following shell variables:
745 # - ^as_
746 # M4sh's shell name space.
747 # - ^ac_, excluding ^ac_cv_
748 # Autoconf's private shell name space.
749 # - Variables with unstable values in at least some shells:
750 # - OLDPWD [bash, zsh]
751 # - PPID [bash, zsh]
752 # - RANDOM [bash, zsh]
753 # - SECONDS [bash, zsh]
754 # - SHLVL [bash]
755 # - START_TIME [NetBSD sh]
756 # - ToD [NetBSD sh]
757 # - '$' [zsh]
758 # - argv [zsh]
759 # - ARGC [zsh]
760 # - BASH_ARGC [bash]
761 # - BASH_ARGV [bash]
762 # - LINENO [POSIX]
763 # - _AST_FEATURES [ksh93]
764 # - Optionally, variables that are expected to vary in a particular test.
765 # This is controlled by the EXTRA-VARIANCE argument, which is a
766 # whitespace-separated sequence of tokens. Each token means to ignore
767 # one or more additional variables and/or rename some variables, as follows:
768 #
769 # cross: ignore cross_compiling
770 # cxx: ignore all of:
771 # - CC, CPP, CCC, CXX, CXXCPP, CFLAGS, CXXFLAGS, GCC, GXX
772 # - ac_cv_env_(any of the above)_(set|value)
773 # - ac_cv_(c|cxx)_compiler_gnu
774 # - ac_cv_(c|cxx)_undeclared_builtin_options
775 # - ac_cv_prog_c_*, ac_cv_prog_cxx_*
776 # - ac_cv_prog_(ac_ct_)?(CC|CXX|CPP|CXXCPP)
777 # + other ac_cv_c_* are renamed to ac_cv_cxx_*
778 # + OPENMP_CFLAGS is renamed to OPENMP_CXXFLAGS
779 # vary:NAME (where NAME is any identifier): ignore ac_cv_NAME
780 #
781 # Furthermore, it is okay for a non-cache variable initialized to empty in one
782 # run to be unset in another run. This happens when, for example, cache update
783 # code tries a number of values in LIBS and eventually restores LIBS to its
784 # original value. If LIBS was previously unset, it will have become set and
785 # empty. (OTOH, cache variables indicate the result of the test even if they
786 # are empty, so we have to be strict about them.)
787 #
788 # Lines that do not look like 'foo=bar' are probably latter lines of
789 # multiline values; trim them.
790 m4_define([AT_CONFIG_CMP],
791 [for act_file in $1 $2
792 do
793 $SED '/^ac_cv_/ b skip
794 /^m4_defn([m4_re_word])=./ !d
795 /^[[^=]]*='\'''\''$/ d
796 /^[[^=]]*=""$/ d
797 /^a[[cs]]_/ d
798 : skip
799 /^OLDPWD=/ d
800 /^PPID=/ d
801 /^RANDOM=/ d
802 /^SECONDS=/ d
803 /^SHLVL=/ d
804 /^START_TIME=/ d
805 /^ToD=/ d
806 /'\'\\\$\''=/ d
807 /^argv=/ d
808 /^ARGC=/ d
809 /^BASH_ARGC=/ d
810 /^BASH_ARGV=/ d
811 /^LINENO=/ d
812 /^_AST_FEATURES=/ d
813 m4_map_args_w([$3], [_AT_CONFIG_CMP_PRUNE(], [)])dnl
814 ' < $act_file > at_config_vars-$act_file
815 done
816 AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl
817 ])# AT_CONFIG_CMP
818
819 # _AT_CONFIG_CMP_PRUNE(TOKEN)
820 # ---------------------------
821 # Subroutine of AT_CONFIG_CMP which implements the extra-variance rules
822 # described above. Expands to additional sed commands to be inserted in
823 # the program above.
824 # Note for future readers: not all sed implementations allow alternations
825 # in regexes (e.g. /^ac_cv_env_CC_\(set\|value\)=/ would not be portable).
826 m4_define([_AT_CONFIG_CMP_PRUNE],
827 [m4_bmatch([$1],
828 [^cross$],
829 [ /^cross_compiling=/ d
830 ],
831 [^cxx$],
832 [ /^CC=/ d
833 /^CPP=/ d
834 /^CCC=/ d
835 /^CXX=/ d
836 /^CXXCPP=/ d
837 /^CFLAGS=/ d
838 /^CXXFLAGS=/ d
839 /^GCC=/ d
840 /^GXX=/ d
841 /^ac_cv_env_CC_set=/ d
842 /^ac_cv_env_CC_value=/ d
843 /^ac_cv_env_CPP_set=/ d
844 /^ac_cv_env_CPP_value=/ d
845 /^ac_cv_env_CFLAGS_set=/ d
846 /^ac_cv_env_CFLAGS_value=/ d
847 /^ac_cv_env_GCC_set=/ d
848 /^ac_cv_env_GCC_value=/ d
849 /^ac_cv_env_CCC_set=/ d
850 /^ac_cv_env_CCC_value=/ d
851 /^ac_cv_env_CXX_set=/ d
852 /^ac_cv_env_CXX_value=/ d
853 /^ac_cv_env_CXXCPP_set=/ d
854 /^ac_cv_env_CXXCPP_value=/ d
855 /^ac_cv_env_CXXFLAGS_set=/ d
856 /^ac_cv_env_CXXFLAGS_value=/ d
857 /^ac_cv_env_GXX_set=/ d
858 /^ac_cv_env_GXX_value=/ d
859 /^ac_cv_prog_CC=/ d
860 /^ac_cv_prog_CXX=/ d
861 /^ac_cv_prog_CPP=/ d
862 /^ac_cv_prog_CXXCPP=/ d
863 /^ac_cv_prog_ac_ct_CC=/ d
864 /^ac_cv_prog_ac_ct_CXX=/ d
865 /^ac_cv_prog_ac_ct_CPP=/ d
866 /^ac_cv_prog_ac_ct_CXXCPP=/ d
867 /^ac_cv_c_compiler_gnu=/ d
868 /^ac_cv_cxx_compiler_gnu=/ d
869 /^ac_cv_c_undeclared_builtin_options=/ d
870 /^ac_cv_cxx_undeclared_builtin_options=/ d
871 /^ac_cv_prog_c_@<:@^=@:>@*=/ d
872 /^ac_cv_prog_cc_@<:@^=@:>@*=/ d
873 /^ac_cv_prog_cxx_@<:@^=@:>@*=/ d
874 s/^ac_cv_c_/ac_cv_cxx_/
875 s/^OPENMP_CFLAGS=/OPENMP_CXXFLAGS=/
876 ],
877 [^vary:],
878 [ /^ac_cv_]m4_bpatsubsts([$1], [\<vary:], [])[=/ d
879 ],
880 [m4_fatal([unrecognized AT_CONFIG_CMP variance token: "$1"])])])
881
882
883 # AT_DEFINES_CMP(CONFIG-H-A, CONFIG-H-B, [EXTRA-VARIANCE])
884 # --------------------------------------------------------
885 # Check the outcomes of two configure runs for equality by comparing the
886 # config.h headers they produced. Optionally, ignore changes to particular
887 # defines, under the control of the EXTRA-VARIANCE argument, which is a
888 # whitespace-separated sequence of tokens. Each token means to ignore
889 # one or more additional defines, as follows:
890 # vary:NAME (where NAME is any identifier): ignore #define/#undef NAME
891 m4_define([AT_DEFINES_CMP],
892 [m4_ifblank([$3], [AT_CMP([$1], [$2])],
893 [for act_file in $1 $2
894 do
895 $SED '
896 m4_map_args_w([$3], [_AT_DEFINES_CMP_PRUNE(], [)])
897 ' < $act_file > at_defines-$act_file
898 done
899 AT_CMP([at_defines-$1], [at_defines-$2])[]dnl
900 ])])# AT_DEFINES_CMP
901
902
903 # _AT_DEFINES_CMP_PRUNE(TOKEN)
904 # ---------------------------
905 # Subroutine of AT_DEFINES_CMP which implements the extra-variance rules
906 # described above. Expands to one or more sed commands.
907 # After quadrigraph replacement, each sed command group will be
908 # /#define macro_name[ (]/ d ;#)
909 # /#undef macro_name[ (]/ d ;#)
910 # AC_DEFINE never emits tabs or puts whitespace between '#' and
911 # 'define' or 'undef', so this is sufficient.
912 m4_define([_AT_DEFINES_CMP_PRUNE],
913 [m4_bmatch([$1],
914 [^vary:],
915 [ /@%:@define ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
916 [@<:@ @{:@@:>@/ d ;@%:@@:}@
917 /@%:@undef ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
918 [@<:@ @{:@@:>@/ d ;@%:@@:}@
919 ],
920 [m4_fatal([unrecognized AT_DEFINES_CMP variance token: "$1"])])])
921
922
923 # AT_PRESERVE_CONFIG_STATUS(SUFFIX)
924 # ---------------------------------
925 # Copy the files 'state-env.after', 'config.h', 'config.log', and
926 # 'config.status' to names ending with SUFFIX, so they are not
927 # clobbered by a subsequent run of configure.
928 m4_define([AT_PRESERVE_CONFIG_STATUS],
929 [cp -f state-env.after state-env.$1
930 cp -f config.h config-h.$1
931 cp -f config.log config-log.$1
932 cp -f config.status config-status.$1
933 ])
934
935
936 # AT_CHECK_DEFINES(CONTENT)
937 # -------------------------
938 # Verify that config.h, once stripped, is CONTENT.
939 # Stripping consists of keeping CPP lines (i.e. containing a hash),
940 # but those of automatically checked features (STDC_HEADERS etc.)
941 # and symbols (PACKAGE_...).
942 # AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
943 m4_define([AT_CHECK_DEFINES],
944 [AT_CHECK([[sed '/#/!d
945 /INTTYPES_H/d
946 /MEMORY_H/d
947 /PACKAGE_/d
948 /STDC_HEADERS/d
949 /STDINT_H/d
950 /STDIO_H/d
951 /STDLIB_H/d
952 /STRING_H/d
953 /STRINGS_H/d
954 /SYS_STAT_H/d
955 /SYS_TYPES_H/d
956 /UNISTD_H/d' config.h]],,
957 [$1])])
958
959
960 # AT_CHECK_AUTOUPDATE
961 # -------------------
962 m4_define([AT_CHECK_AUTOUPDATE],
963 [AT_CHECK([autoupdate $1], [$2], [$3], [$4])
964 ])
965
966
967 # AT_CHECK_MAKE(MAKEARGS, DIRECTORY, EXIT-STATUS,
968 # [STDOUT = IGNORE], [STDERR = IGNORE])
969 # ---------------------------------------------------------------
970 # Run make in DIRECTORY (default '.'), passing MAKEARGS on the command
971 # line. EXIT-STATUS, STDOUT, and STDERR are as for AT_CHECK.
972 # The environment variable MAKE is honored if present.
973 # The environment variable MAKEFLAGS is *cleared*.
974 # If EXIT-STATUS is 1, an exit status of either 1 or 2 is considered
975 # an acceptable result, because there are situations where BSD make will
976 # exit with status 1 but GNU make will instead exit with status 2.
977 m4_define([AT_CHECK_MAKE],
978 [AT_CHECK(
979 m4_if(m4_default([$2], [.]), [.], [],
980 [cd "$2" && ])[$][MAKE]m4_ifnblank([$1],[ $1])[]m4_if([$3], [1], [[
981 dnl pacify editors that don't understand sh case: ((
982 case $? in 1|2) exit 1;; *) exit $?;; esac]]),
983 [$3],
984 m4_default([$4], [ignore]),
985 m4_default([$5], [ignore]))
986 ])
987
988
989 # _AT_CHECK_AC_MACRO(AC-BODY, [PRE-TESTS], [AUTOCONF-FLAGS])
990 # ----------------------------------------------------------
991 # Create a minimalist configure.ac running the macro named
992 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
993 # and that the generated configure script runs without error.
994 m4_define([_AT_CHECK_AC_MACRO],
995 [AT_CONFIGURE_AC([$1])
996 $2
997 AT_CHECK_AUTOCONF([$3])
998 AT_CHECK_AUTOHEADER([$3], [ignore])
999 AT_CHECK_CONFIGURE
1000 AT_CHECK_ENV
1001 ])# _AT_CHECK_AC_MACRO
1002
1003 # AT_CHECK_CONFIGURE_AC(NAME, AC-BODY, [AUTOCONF-FLAGS],
1004 # [PRE-TESTS], [POST-TESTS])
1005 # -----------------------------------------------------
1006 # Shorthand for a complete test "group" consisting of a single
1007 # invocation of _AT_CHECK_AC_MACRO, possibly with some additional
1008 # tests executed before and after.
1009 m4_define([AT_CHECK_CONFIGURE_AC],
1010 [AT_SETUP([$1])
1011 _AT_CHECK_AC_MACRO([$2], [$4], [$3])
1012 $5
1013 AT_CLEANUP
1014 ])
1015
1016 # AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
1017 # [AUTOCONF-FLAGS], [TEST-PARAMETERS], [PRETEST-CMDS])
1018 # -----------------------------------------------------
1019 # Create a minimalist configure.ac running the macro named MACRO
1020 # (using the code in MACRO-USE if that argument is not empty,
1021 # otherwise a bare invocation of MACRO with no arguments),
1022 # check that autoconf runs on that script,
1023 # and that the generated configure script runs without error.
1024 # AUTOCONF-FLAGS are passed to all invocations of autoconf.
1025 #
1026 # We always generate two variants of the minimalist configure.ac,
1027 # with and without forcing the script into cross-compilation mode
1028 # before executing MACRO-USE. If a C++ compiler is available, we
1029 # generate two more variants in which MACRO-USE is invoked while
1030 # AC_LANG([C++]) is in effect; as before, one forces the script into
1031 # cross-compilation mode and the other doesn't. All variants of the
1032 # generated configure script are run twice, once with an empty cache,
1033 # and once with a cache primed by the previous run.
1034 #
1035 # All four (or eight, if C++ is available) runs are expected to
1036 # produce the same results, except for the value of 'cross_compiling'
1037 # and differences due to running AC_PROG_CXX instead of AC_PROG_CC.
1038 # (See AT_CONFIG_CMP for details.)
1039 #
1040 # If ADDITIONAL-CMDS are present, they are executed after the first
1041 # pair of tests (with the C compiler, in native mode).
1042 #
1043 # If PRETEST-CMDS are present, they are executed immediately after
1044 # AT_SETUP; use this if the test needs to be skipped conditionally,
1045 # for example.
1046 #
1047 # If TEST-PARAMETERS are present, they should be a space-separated
1048 # list of modifiers to how the test is carried out. Currently
1049 # the following modifiers are defined:
1050 #
1051 # - 'no-cross': Don't test this macro in cross-compilation mode.
1052 # This is for macros that use AC_RUN_IFELSE, and therefore, when
1053 # cross-compiling, they either crash or give a 'best guess' answer
1054 # that may be wrong.
1055 #
1056 # - 'cxx_cv_varies:NAME': The value of the cache variable ac_cv_NAME
1057 # may legitimately vary between the C tests and the C++ tests.
1058 #
1059 # - 'cxx_define_varies:NAME' The value of the AC_DEFINEd macro NAME
1060 # may legitimately vary between the C tests and the C++ tests.
1061 m4_define([AT_CHECK_MACRO],
1062 [AT_SETUP([$1])
1063 m4_n([$6])dnl
1064
1065 # C compiler, native mode.
1066 AT_CONFIGURE_AC([m4_default([$2], [$1])])
1067 AT_CHECK_AUTOCONF([$4])
1068 AT_CHECK_AUTOHEADER([$4], [ignore])
1069
1070 cp -f configure.ac configure-ac.c-native
1071 cp -f configure configure.c-native
1072 cp -f config.hin config-hin.c-native
1073
1074 AT_CHECK_CONFIGURE([-C])
1075 AT_PRESERVE_CONFIG_STATUS([c-native-r1])
1076 AT_CHECK_ENV
1077 AT_CHECK_CONFIGURE([-C])
1078 AT_PRESERVE_CONFIG_STATUS([c-native-r2])
1079 AT_CHECK_ENV
1080
1081 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-native-r2])
1082 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-native-r2])
1083
1084 m4_n([$3])dnl
1085 m4_bmatch([$5], [\<no-cross\>], [], [dnl
1086
1087 # C compiler, cross-compilation mode.
1088 rm -rf config.cache autom4te.cache
1089 AT_CONFIGURE_AC(
1090 [cross_compiling=yes
1091 ac_tool_warned=yes
1092 m4_default([$2], [$1])])
1093 AT_CHECK_AUTOCONF([$4])
1094 AT_CHECK_AUTOHEADER([$4], [ignore])
1095
1096 cp -f configure.ac configure-ac.c-cross
1097 cp -f configure configure.c-cross
1098 cp -f config.hin config-hin.c-cross
1099
1100 AT_CHECK_CONFIGURE([-C])
1101 AT_PRESERVE_CONFIG_STATUS([c-cross-r1])
1102 AT_CHECK_ENV
1103 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r1])
1104 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r1], [cross])
1105
1106 AT_CHECK_CONFIGURE([-C])
1107 AT_PRESERVE_CONFIG_STATUS([c-cross-r2])
1108 AT_CHECK_ENV
1109 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r2])
1110 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r2], [cross])
1111 ])dnl
1112
1113 # To save time, skip the C++-mode tests for any macro that did not
1114 # transitively require AC_PROG_CC; it won't make any difference.
1115 if grep '^CC=' state-env.c-native-r1 > /dev/null 2>&1; then
1116
1117 # C++ compiler, native mode.
1118 rm -rf config.cache autom4te.cache
1119 AT_CONFIGURE_AC(
1120 [AC_LANG([C++])
1121 m4_default([$2], [$1])])
1122
1123 # Autoconf may fail here because of an AC_LANG_ASSERT([C]); this
1124 # means the macro is specific to C and should not be tested with the
1125 # C++ compiler.
1126 AT_CHECK_AUTOCONF([$4], [ignore], [ignore], [stderr])
1127 if test -s stderr; then
1128 AT_CHECK([grep 'error: AC_LANG_ASSERT: current language is not C' stderr],
1129 [0], [ignore], [ignore])
1130 else
1131 AT_CHECK_AUTOHEADER([$4], [ignore])
1132
1133 cp -f configure.ac configure-ac.cxx-native
1134 cp -f configure configure.cxx-native
1135 cp -f config.hin config-hin.cxx-native
1136
1137 # If this configure pass fails with code 77, that means there is no
1138 # C++ compiler available; don't mark the entire test group skipped,
1139 # just skip the rest of the C++ testing.
1140 AT_CHECK_CONFIGURE([-C;
1141 status=$?
1142 if test $status -eq 77; then
1143 touch at-no-cxx
1144 exit 0
1145 else
1146 exit $status
1147 fi
1148 ])
1149 if test ! -f at-no-cxx; then
1150 AT_PRESERVE_CONFIG_STATUS([cxx-native-r1])
1151 AT_CHECK_ENV
1152 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.cxx-native-r1],
1153 _AT_FILTER_CXX_DEFINE_VARIES([$5]))
1154 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.cxx-native-r1],
1155 [cxx ]_AT_FILTER_CXX_CV_VARIES([$5]))
1156
1157 AT_CHECK_CONFIGURE([-C])
1158 AT_PRESERVE_CONFIG_STATUS([cxx-native-r2])
1159 AT_CHECK_ENV
1160 AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-native-r2])
1161 AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-native-r2])
1162 m4_bmatch([$5], [\<no-cross\>], [], [dnl
1163
1164 # Fourth run: C++ compiler, cross-compilation mode.
1165
1166 rm -rf config.cache autom4te.cache
1167 AT_CONFIGURE_AC(
1168 [cross_compiling=yes
1169 ac_tool_warned=yes
1170 AC_LANG([C++])
1171 m4_default([$2], [$1])])
1172 AT_CHECK_AUTOCONF([$4])
1173 AT_CHECK_AUTOHEADER([$4], [ignore])
1174
1175 cp -f configure.ac configure-ac.cxx-cross
1176 cp -f configure configure.cxx-cross
1177 cp -f config.hin config-hin.cxx-cross
1178
1179 AT_CHECK_CONFIGURE([-C])
1180 AT_PRESERVE_CONFIG_STATUS([cxx-cross-r1])
1181 AT_CHECK_ENV
1182 AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-cross-r1])
1183 AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-cross-r1],
1184 [cross])
1185
1186 AT_CHECK_CONFIGURE([-C])
1187 AT_PRESERVE_CONFIG_STATUS([cxx-cross-r2])
1188 AT_CHECK_ENV
1189 AT_DEFINES_CMP([config-h.cxx-cross-r1], [config-h.cxx-cross-r2])
1190 AT_CONFIG_CMP([state-env.cxx-cross-r1], [state-env.cxx-cross-r2])
1191 ])dnl
1192 fi # C++ compiler available
1193 fi # macro can be used with C++
1194 fi # C++ makes a difference
1195
1196 AT_CLEANUP
1197 ])# AT_CHECK_MACRO
1198
1199
1200 # _AT_FILTER_CXX_CV_VARIES(TEST-PARAMETERS)
1201 # ---------------------------------------------
1202 # Subroutine of AT_CHECK_MACRO that expands to a sequence of
1203 # zero or more 'vary:NAME' tokens, one for each occurrence of
1204 # 'cxx_cv_varies:NAME' in TEST-PARAMETERS.
1205 m4_define([_AT_FILTER_CXX_CV_VARIES],
1206 [m4_map_args_w([$1], [_AT_FILTER_CXX_CV_VARY(], [)], [ ])])
1207
1208 m4_define([_AT_FILTER_CXX_CV_VARY],
1209 [m4_bmatch([$1], [^cxx_cv_varies:],
1210 [m4_bpatsubsts([$1], [\<cxx_cv_varies:], [vary:])])])
1211
1212
1213 # _AT_FILTER_CXX_DEFINE_VARIES(TEST-PARAMETERS)
1214 # ---------------------------------------------
1215 # Subroutine of AT_CHECK_MACRO that expands to a sequence of
1216 # zero or more 'vary:NAME' tokens, one for each occurrence of
1217 # 'cxx_define_varies:NAME' in TEST-PARAMETERS.
1218 m4_define([_AT_FILTER_CXX_DEFINE_VARIES],
1219 [m4_map_args_w([$1], [_AT_FILTER_CXX_DEFINE_VARY(], [)], [ ])])
1220
1221 m4_define([_AT_FILTER_CXX_DEFINE_VARY],
1222 [m4_bmatch([$1], [^cxx_define_varies:],
1223 [m4_bpatsubsts([$1], [\<cxx_define_varies:], [vary:])])])
1224
1225
1226 # AT_CHECK_AU_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
1227 # [AUTOCONF-FLAGS], [TEST-PARAMETERS])
1228 # ------------------------
1229 # Do all the tests that AT_CHECK_MACRO(...) would do.
1230 #
1231 # In addition, run autoupdate on configure.ac; afterward, verify that
1232 # MACRO no longer appears in configure.ac, autoconf runs on the
1233 # updated script, the configure script still runs without error, and
1234 # the result of configuration is unchanged.
1235 #
1236 # Before running autoupdate, check for a -Wobsolete warning naming
1237 # MACRO from configure. After running autoupdate, *don't* check for
1238 # the absence of -Wobsolete warnings, because many of autoupdate's
1239 # edits leave the configure.ac author with some manual work to do, and
1240 # indicate this by inserting an m4_warn message to be removed after
1241 # the manual work is complete.
1242 m4_define([AT_CHECK_AU_MACRO],
1243 [AT_CHECK_MACRO([$1], [$2], [$3], [-Wno-obsolete $4], [$5])
1244
1245 AT_SETUP([autoupdating $1])
1246 AT_KEYWORDS([autoupdate])
1247
1248 AT_CONFIGURE_AC([m4_default([$2], [$1])])
1249
1250 AT_CHECK_AUTOCONF([$4], 0, [], [stderr])
1251 AT_CHECK([grep 'macro .$1. is obsolete' stderr], 0, [ignore], [ignore])
1252 AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
1253 AT_CHECK_CONFIGURE
1254 AT_CHECK_ENV
1255 AT_PRESERVE_CONFIG_STATUS([before-au])
1256
1257 rm config.hin
1258 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
1259 AT_CHECK([grep '^$1$' configure.ac], 1)
1260
1261 AT_CHECK_AUTOCONF([-Wno-obsolete $4])
1262 AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
1263 AT_CHECK_CONFIGURE
1264 AT_CHECK_ENV
1265 AT_PRESERVE_CONFIG_STATUS([after-au])
1266
1267 AT_CMP([config-h.before-au], [config-h.after-au])
1268 AT_CONFIG_CMP([state-env.before-au], [state-env.after-au])
1269
1270 AT_CLEANUP[]dnl
1271 ])# AT_CHECK_AU_MACRO
1272
1273
1274
1275 ## ----------------------- ##
1276 ## Launch the test suite. ##
1277 ## ----------------------- ##
1278
1279 AT_INIT