1 # M4 macros used in building Autoconf test suites. -*- Autotest -*-
3 # Copyright (C) 2000-2017, 2020-2023 Free Software Foundation, Inc.
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.
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.
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/>.
18 m4_version_prereq([2.57])
21 m4_pattern_allow([^AS_EXIT$])
22 m4_pattern_allow([^m4_(define|shift)$])
24 # Programs this package provides
25 AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])
27 # System-provided programs that this package relies on
28 AT_TESTED([$PERL $M4])
30 # Enable colored test output.
33 # Sanitize the environment used for tests.
35 [# MAKEFLAGS should not be inherited from the parent environment.
38 # We do not want to read any external config.site file.
39 # If CONFIG_SITE is not set, autoconf will look for config.site in
40 # $prefix/share and $prefix/etc.
41 AS_IF([test -e nonexistent],
42 [AS_ERROR([something named 'nonexistent' exists in the test directory])])
43 CONFIG_SITE=`pwd`/nonexistent/config.site
46 # Ensure MAKE is set to a useful value. Unlike the above, we *do*
47 # want to inherit this variable from the parent environment and/or
55 ## ---------------- ##
57 ## ---------------- ##
59 # AT_CMP(FILE-1, FILE-2)
60 # ----------------------
61 # Check FILE-1 and FILE-2 for equality, like 'cmp FILE-1 FILE-2'.
63 [m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])[]dnl
64 AT_CHECK([$at_diff "$1" "$2"])
68 ## ---------------- ##
70 ## ---------------- ##
72 # AT_CHECK_SHELL_SYNTAX(PROGRAM)
73 # ------------------------------
74 # If the shell handles '-n' well, use it to check the syntax of PROGRAM;
75 # otherwise, do nothing. ksh93 -n also spits outs loads of warnings
76 # about older constructs, but we don't care about the warnings.
77 m4_define([AT_CHECK_SHELL_SYNTAX],
78 [AT_SKIP_IF([test "$SHELL_N" = none])
79 AT_CHECK(["$SHELL_N" -n $1], [], [], [ignore])])
81 m4_define([AT_CHECK_PERL_SYNTAX],
82 [AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],
85 ## ------------------ ##
86 ## Testing autom4te. ##
87 ## ------------------ ##
90 # AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR)
91 # -------------------------------------------------------
92 # If stderr is specified, normalize the observed stderr.
93 # This (using GNU M4 1.4.6)
95 # /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory
96 # autom4te: /usr/local/bin/m4 failed with exit status: 1
98 # or this (GNU M4 1.4.11)
100 # /usr/local/bin/m4:script.4s:1: include: cannot open `foo': No such file or directory
101 # autom4te: /usr/local/bin/m4 failed with exit status: 1
103 # or this (GNU M4 1.4 installed as gm4)
105 # script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory
106 # autom4te: /usr/local/bin/gm4 failed with exit status: 1
108 # or this (GNU M4 1.4.13 installed as m4-1.4.13):
110 # /usr/bin/m4-1.4.13:script.4s:1: include: cannot open `foo': No such file or directory
111 # autom4te: /usr/bin/m4-1.4.13 failed with exit status: 1
115 # m4:script.4s:1: cannot open 'foo': No such file or directory
116 # autom4te: m4 failed with exit status: 1
120 # configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
121 # configure.ac:6: You should run autoupdate.
122 # ../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from...
123 # configure.ac:6: the top level
127 # configure.ac:6: warning: The macro 'AC_LANG_SAVE' is obsolete.
128 # configure.ac:6: You should run autoupdate.
129 # lang.m4: AC_LANG_SAVE is expanded from...
130 # configure.ac:6: the top level
132 # We use the following sed patterns:
134 # (m4): ?(file): ?(line):
135 # or (file): ?(line): ?(m4):
136 # to m4:(file):(line):
139 # m4:(file):(line): Cannot open foo:
140 # or m4:(file):(line): include: cannot open [`']foo':
141 # to m4:(file):(line): cannot open 'foo':
145 # or autom4te: [^ ]m4.exe
149 # (path)/(basename).m4: ?(line): (message)
150 # to (basename).m4: (message)
152 # Moreover, DJGPP error messages include the error code in brackets;
153 # remove the error code during normalization.
155 m4_define([AT_CHECK_M4],
156 [AT_CHECK([$1], [$2], [$3],
157 m4_case([$4], [], [], [ignore], [ignore], [stderr]))
158 m4_case([$4], [], [], [ignore], [],
159 [AT_CHECK([[mv stderr stderr-raw &&
160 sed 's/^[^:]*m4[-.ex0-9]*: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/
161 s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4[-.ex0-9]*: /m4:\1\2 /
162 s/: include: [cC]\(annot open\)/: c\1/
163 s/: [cC]\(annot open \)[`'\'']*\([^'\'':]*\)'\''*:/: c\1'\''\2'\'':/
164 s/^autom4te: [^ ]*m4[.ex]* /autom4te: m4 /
165 s/^autom4te: error: [^ ]*m4[.ex]* /autom4te: error: m4 /
166 s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *!\1.m4: !
167 s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *[0-9][0-9]*: *!\1.m4: !
169 ' stderr-raw >&2]], [0], [], [$4])])
172 # AT_CHECK_AUTOM4TE(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
173 # -----------------------------------------------------------
174 m4_define([AT_CHECK_AUTOM4TE],
175 [AT_CHECK_M4([autom4te $1], [$2], [$3], [$4])])
179 ## ----------------- ##
180 ## Testing M4sugar. ##
181 ## ----------------- ##
184 # AT_DATA_M4SUGAR(FILE-NAME, CONTENTS)
185 # ------------------------------------
186 # Escape the invalid tokens with @&t@.
187 m4_define([AT_DATA_M4SUGAR],
189 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\)\(_\)\|\(d\)\(nl\)],
190 [\1\3\5@&t@\2\4\6])])])
193 # AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
194 # ----------------------------------------------------------
195 m4_define([AT_CHECK_M4SUGAR],
196 [AT_KEYWORDS([m4sugar])
197 AT_CHECK_AUTOM4TE([--language=m4sugar script.4s -o script $1],
207 # AT_DATA_M4SH(FILE-NAME, CONTENTS)
208 # ---------------------------------
209 # Escape the invalid tokens with @&t@.
210 m4_define([AT_DATA_M4SH],
212 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\)\(_\)\|\(d\)\(nl\)],
213 [\1\3\5@&t@\2\4\6])])])
216 # AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
217 # -------------------------------------------------------
218 m4_define([AT_CHECK_M4SH],
219 [AT_CHECK_AUTOM4TE([--language=m4sh script.as -o script $1],
224 ## ------------------ ##
225 ## Testing Autoconf. ##
226 ## ------------------ ##
229 # AT_DATA_AUTOCONF(FILE-NAME, CONTENTS)
230 # -------------------------------------
231 # Escape the invalid tokens with @&t@.
232 m4_define([AT_DATA_AUTOCONF],
234 [m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AC\)\(_\)\|\(d\)\(nl\)],
235 [\1\3\5@&t@\2\4\6])])])
239 # AT_CONFIGURE_AC(BODY)
240 # ---------------------
241 # Create a full configure.ac running BODY, with a config header set up,
242 # AC_OUTPUT, and environment checking hooks.
243 m4_define([AT_CONFIGURE_AC],
244 [AT_DATA([configure.ac],
246 AC_CONFIG_HEADERS(config.h:config.hin)
247 AC_STATE_SAVE(before)]
252 cp "$abs_top_srcdir/build-aux/install-sh" \
253 "$abs_top_srcdir/build-aux/config.guess" \
254 "$abs_top_srcdir/build-aux/config.sub" .
255 cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
259 # AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
260 # ----------------------------------------------------------
261 # We always use "--force", to prevent problems with timestamps if the testsuite
262 # were running too fast.
263 m4_define([AT_CHECK_AUTOCONF],
264 [AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4])
265 if test -s configure && test "$SHELL_N" != none; then
266 AT_CHECK_SHELL_SYNTAX([configure])
271 # AT_CHECK_AUTOHEADER(ARGS, EXPECTED_TMPLS, [EXIT-STATUS = 0], STDOUT, STDERR)
272 # ----------------------------------------------------------------------------
273 # EXPECTED_TMPLS is a whitespace-separated list of template
274 # definitions that should appear in the generated config.hin.
275 # The stock definitions made by AC_INIT are also checked for.
276 # If EXPECTED_TMPLS is the single word 'ignore', or if the
277 # expected exit status is not 0, this test is skipped.
278 m4_define([AT_CHECK_AUTOHEADER],
279 [AT_CHECK_M4([autoheader $1], [$3], [$4], [$5])
280 m4_if(m4_strip([$2]), [ignore], [],
281 [m4_if(m4_default_nblank([$3], [0]), [0], [dnl
282 if test -f config.h.in
283 then config_h_in=config.h.in
284 elif test -f config.hin
285 then config_h_in=config.hin
286 else AT_FAIL_IF([: "Cannot find autoheader template file"])
288 m4_set_add_all([ah_expected_tmpls],
294 [PACKAGE_VERSION])dnl
296 [m4_set_add([ah_expected_tmpls],], [)])dnl
297 AT_DATA([expout.in],[m4_set_dump([ah_expected_tmpls],[
300 AT_CHECK([sort -o expout expout.in])
301 AT_CHECK([[sed -ne 's/^[ ]*#[ ]*undef[ ][ ]*//p' \
302 $config_h_in | sort]],
304 AS_UNSET([config_h_in])
308 # AT_CHECK_CONFIGURE(END-COMMAND,
310 # [STDOUT = IGNORE], STDERR)
311 # ---------------------------------------------
312 # 'abs_top_srcdir' is needed so that './configure' finds install-sh.
313 # Using --srcdir is more expensive.
314 m4_define([AT_CHECK_CONFIGURE],
315 [AT_CAPTURE_FILE([config.log])[]dnl
316 AT_CHECK([./configure $configure_options $1],
318 m4_default([$3], [ignore]), [$4])])
323 # Check that the full configure run remained in its variable name space,
324 # and cleaned up tmp files.
326 # Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
327 # In this case just don't pay attention to the env. It would be great
328 # to keep the error message but we can't: that would break AT_CHECK.
330 # FreeBSD sh may intermingle the trace output from the egrep and grep
331 # commands in the pipe, so turn off tracing for these.
333 # Some tests might exit prematurely when they find a problem, in
334 # which case 'env-after' is probably missing. Don't check it then.
336 # Here are the variables 'configure' may modify during execution:
338 # M4sh's shell name space.
340 # Autoconf's shell name space.
341 # - prefix and exec_prefix
342 # are kept undefined (NONE) until AC_OUTPUT which then sets them to
343 # '/usr/local' and '${prefix}' for make.
344 # - (host|build|target)(_(alias|cpu|vendor|os))?
345 # Set by AC_CANONICAL_(HOST|BUILD|TARGET).
349 # Set by AC_SYS_INTERPRETER.
350 # - enableval, withval, enable_*, with_*
351 # Set by AC_ARG_ENABLE and AC_ARG_WITH.
352 # - CONFIG_STATUS and DEFS
354 # - AC_SUBST'ed variables
355 # (FIXME: Generate a list of these automatically.)
356 # - _|@|.[*#?$].|argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS
357 # |SHLVL|START_TIME|ToD|_AST_FEATURES
358 # Some variables some shells use and change.
359 # '.[*#?$].' catches '$#' etc. which are displayed like this:
364 m4_defun([AT_CHECK_ENV],
365 [m4_require([_AT_CHECK_ENV])]dnl
366 [AT_CHECK([ath_fn_check_env])])
368 m4_defun([_AT_CHECK_ENV],
369 [AT_TEST_HELPER_FN([check_env], [],
370 [Compare the directory and environment state both before and after a run,
371 and return non-zero status if they differ inappropriately.],
372 [# Compare directory listings.
373 test -f state-ls.before ||
374 AS_ERROR([state-ls.before not present])
375 test -f state-ls.after \
376 && { $at_diff state-ls.before state-ls.after || return 1; }
377 # Compare variable space dumps.
378 if test -f state-env.before && test -f state-env.after; then
381 for act_file in state-env.before state-env.after
383 ($EGREP -v '^(m4_join([|],
385 [(exec_)?prefix|DEFS|CONFIG_STATUS],
386 [CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
387 [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
388 [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
389 [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
390 [OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
392 [OPENMP_(C|CXX)FLAGS],
393 [LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
394 [INSTALL(_(DATA|PROGRAM|SCRIPT))?],
396 [CYGWIN|EMXOS2|ISC|MINGW32|MINIX|MSYS|XENIX],
397 [X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
398 [(host|build|target)(_(alias|cpu|vendor|os))?],
400 [enableval|enable_.*|withval|with_.*],
401 [interpval|PATH_SEPARATOR],
402 [GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
403 [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],
404 [ALLOCA|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
405 [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|AR|RANLIB|SET_MAKE|YACC],
409 [argv|ARGC|LINENO|BASH_ARGC|BASH_ARGV|OLDPWD|PIPESTATUS|RANDOM],
410 [SECONDS|SHLVL|START_TIME|ToD|_AST_FEATURES]))=' \
412 test $? -eq 1 || echo failed >&2
413 ) 2>stderr-$act_file |
414 # There may be variables spread on several lines; remove latter lines.
415 $GREP '^m4_defn([m4_re_word])=' >clean-$act_file ||
416 test $? -eq 1 || grep_failed=:
417 test -s stderr-$act_file && grep_failed=:
420 $grep_failed || $at_diff clean-state-env.before clean-state-env.after
425 # AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B, [EXTRA-VARIANCE])
426 # -------------------------------------------------------
427 # Check the outcomes of two configure runs for equality by comparing dumps of
428 # their shell variables. VAR-FILE-A and VAR-FILE-B are two 'set'-style shell
429 # variable space dumps.
431 # We permit variance between runs in the following shell variables:
433 # M4sh's shell name space.
434 # - ^ac_, excluding ^ac_cv_
435 # Autoconf's private shell name space.
436 # - Variables with unstable values in at least some shells:
437 # - OLDPWD [bash, zsh]
439 # - RANDOM [bash, zsh]
440 # - SECONDS [bash, zsh]
442 # - START_TIME [NetBSD sh]
450 # - _AST_FEATURES [ksh93]
451 # - Optionally, variables that are expected to vary in a particular test.
452 # This is controlled by the EXTRA-VARIANCE argument, which is a
453 # whitespace-separated sequence of tokens. Each token means to ignore
454 # one or more additional variables and/or rename some variables, as follows:
456 # cross: ignore cross_compiling
457 # cxx: ignore all of:
458 # - CC, CPP, CCC, CXX, CXXCPP, CFLAGS, CXXFLAGS, GCC, GXX
459 # - ac_cv_env_(any of the above)_(set|value)
460 # - ac_cv_(c|cxx)_compiler_gnu
461 # - ac_cv_(c|cxx)_undeclared_builtin_options
462 # - ac_cv_prog_c_*, ac_cv_prog_cxx_*
463 # - ac_cv_prog_(ac_ct_)?(CC|CXX|CPP|CXXCPP)
464 # + other ac_cv_c_* are renamed to ac_cv_cxx_*
465 # + OPENMP_CFLAGS is renamed to OPENMP_CXXFLAGS
466 # vary:NAME (where NAME is any identifier): ignore ac_cv_NAME
468 # Furthermore, it is okay for a non-cache variable initialized to empty in one
469 # run to be unset in another run. This happens when, for example, cache update
470 # code tries a number of values in LIBS and eventually restores LIBS to its
471 # original value. If LIBS was previously unset, it will have become set and
472 # empty. (OTOH, cache variables indicate the result of the test even if they
473 # are empty, so we have to be strict about them.)
475 # Lines that do not look like 'foo=bar' are probably latter lines of
476 # multiline values; trim them.
477 m4_define([AT_CONFIG_CMP],
478 [for act_file in $1 $2
480 $SED '/^ac_cv_/ b skip
481 /^m4_defn([m4_re_word])=./ !d
482 /^[[^=]]*='\'''\''$/ d
500 m4_map_args_w([$3], [_AT_CONFIG_CMP_PRUNE(], [)])dnl
501 ' < $act_file > at_config_vars-$act_file
503 AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl
506 # _AT_CONFIG_CMP_PRUNE(TOKEN)
507 # ---------------------------
508 # Subroutine of AT_CONFIG_CMP which implements the extra-variance rules
509 # described above. Expands to additional sed commands to be inserted in
511 # Note for future readers: not all sed implementations allow alternations
512 # in regexes (e.g. /^ac_cv_env_CC_\(set\|value\)=/ would not be portable).
513 m4_define([_AT_CONFIG_CMP_PRUNE],
516 [ /^cross_compiling=/ d
528 /^ac_cv_env_CC_set=/ d
529 /^ac_cv_env_CC_value=/ d
530 /^ac_cv_env_CPP_set=/ d
531 /^ac_cv_env_CPP_value=/ d
532 /^ac_cv_env_CFLAGS_set=/ d
533 /^ac_cv_env_CFLAGS_value=/ d
534 /^ac_cv_env_GCC_set=/ d
535 /^ac_cv_env_GCC_value=/ d
536 /^ac_cv_env_CCC_set=/ d
537 /^ac_cv_env_CCC_value=/ d
538 /^ac_cv_env_CXX_set=/ d
539 /^ac_cv_env_CXX_value=/ d
540 /^ac_cv_env_CXXCPP_set=/ d
541 /^ac_cv_env_CXXCPP_value=/ d
542 /^ac_cv_env_CXXFLAGS_set=/ d
543 /^ac_cv_env_CXXFLAGS_value=/ d
544 /^ac_cv_env_GXX_set=/ d
545 /^ac_cv_env_GXX_value=/ d
549 /^ac_cv_prog_CXXCPP=/ d
550 /^ac_cv_prog_ac_ct_CC=/ d
551 /^ac_cv_prog_ac_ct_CXX=/ d
552 /^ac_cv_prog_ac_ct_CPP=/ d
553 /^ac_cv_prog_ac_ct_CXXCPP=/ d
554 /^ac_cv_c_compiler_gnu=/ d
555 /^ac_cv_cxx_compiler_gnu=/ d
556 /^ac_cv_c_undeclared_builtin_options=/ d
557 /^ac_cv_cxx_undeclared_builtin_options=/ d
558 /^ac_cv_prog_c_@<:@^=@:>@*=/ d
559 /^ac_cv_prog_cc_@<:@^=@:>@*=/ d
560 /^ac_cv_prog_cxx_@<:@^=@:>@*=/ d
561 s/^ac_cv_c_/ac_cv_cxx_/
562 s/^OPENMP_CFLAGS=/OPENMP_CXXFLAGS=/
565 [ /^ac_cv_]m4_bpatsubsts([$1], [\<vary:], [])[=/ d
567 [m4_fatal([unrecognized AT_CONFIG_CMP variance token: "$1"])])])
570 # AT_DEFINES_CMP(CONFIG-H-A, CONFIG-H-B, [EXTRA-VARIANCE])
571 # --------------------------------------------------------
572 # Check the outcomes of two configure runs for equality by comparing the
573 # config.h headers they produced. Optionally, ignore changes to particular
574 # defines, under the control of the EXTRA-VARIANCE argument, which is a
575 # whitespace-separated sequence of tokens. Each token means to ignore
576 # one or more additional defines, as follows:
577 # vary:NAME (where NAME is any identifier): ignore #define/#undef NAME
578 m4_define([AT_DEFINES_CMP],
579 [m4_ifblank([$3], [AT_CMP([$1], [$2])],
580 [for act_file in $1 $2
583 m4_map_args_w([$3], [_AT_DEFINES_CMP_PRUNE(], [)])
584 ' < $act_file > at_defines-$act_file
586 AT_CMP([at_defines-$1], [at_defines-$2])[]dnl
590 # _AT_DEFINES_CMP_PRUNE(TOKEN)
591 # ---------------------------
592 # Subroutine of AT_DEFINES_CMP which implements the extra-variance rules
593 # described above. Expands to one or more sed commands.
594 # After quadrigraph replacement, each sed command group will be
595 # /#define macro_name[ (]/ d ;#)
596 # /#undef macro_name[ (]/ d ;#)
597 # AC_DEFINE never emits tabs or puts whitespace between '#' and
598 # 'define' or 'undef', so this is sufficient.
599 m4_define([_AT_DEFINES_CMP_PRUNE],
602 [ /@%:@define ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
603 [@<:@ @{:@@:>@/ d ;@%:@@:}@
604 /@%:@undef ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
605 [@<:@ @{:@@:>@/ d ;@%:@@:}@
607 [m4_fatal([unrecognized AT_DEFINES_CMP variance token: "$1"])])])
610 # AT_PRESERVE_CONFIG_STATUS(SUFFIX)
611 # ---------------------------------
612 # Copy the files 'state-env.after', 'config.h', 'config.log', and
613 # 'config.status' to names ending with SUFFIX, so they are not
614 # clobbered by a subsequent run of configure.
615 m4_define([AT_PRESERVE_CONFIG_STATUS],
616 [cp -f state-env.after state-env.$1
617 cp -f config.h config-h.$1
618 cp -f config.log config-log.$1
619 cp -f config.status config-status.$1
623 # AT_CHECK_DEFINES(CONTENT)
624 # -------------------------
625 # Verify that config.h, once stripped, is CONTENT.
626 # Stripping consists of keeping CPP lines (i.e. containing a hash),
627 # but those of automatically checked features (STDC_HEADERS etc.)
628 # and symbols (PACKAGE_...).
629 # AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
630 m4_define([AT_CHECK_DEFINES],
631 [AT_CHECK([[sed '/#/!d
643 /UNISTD_H/d' config.h]],,
647 # AT_CHECK_AUTOUPDATE
648 # -------------------
649 m4_define([AT_CHECK_AUTOUPDATE],
650 [AT_CHECK([autoupdate $1], [$2], [$3], [$4])
654 # AT_CHECK_MAKE(MAKEARGS, DIRECTORY, EXIT-STATUS,
655 # [STDOUT = IGNORE], [STDERR = IGNORE])
656 # ---------------------------------------------------------------
657 # Run make in DIRECTORY (default '.'), passing MAKEARGS on the command
658 # line. EXIT-STATUS, STDOUT, and STDERR are as for AT_CHECK.
659 # The environment variable MAKE is honored if present.
660 # The environment variable MAKEFLAGS is *cleared*.
661 # If EXIT-STATUS is 1, an exit status of either 1 or 2 is considered
662 # an acceptable result, because there are situations where BSD make will
663 # exit with status 1 but GNU make will instead exit with status 2.
664 m4_define([AT_CHECK_MAKE],
666 m4_if(m4_default([$2], [.]), [.], [],
667 [cd "$2" && ])[$][MAKE]m4_ifnblank([$1],[ $1])[]m4_if([$3], [1], [[
668 dnl pacify editors that don't understand sh case: ((
669 case $? in 1|2) exit 1;; *) exit $?;; esac]]),
671 m4_default([$4], [ignore]),
672 m4_default([$5], [ignore]))
676 # _AT_CHECK_AC_MACRO(AC-BODY, [PRE-TESTS], [AUTOCONF-FLAGS])
677 # ----------------------------------------------------------
678 # Create a minimalist configure.ac running the macro named
679 # NAME-OF-THE-MACRO, check that autoconf runs on that script,
680 # and that the generated configure script runs without error.
681 m4_define([_AT_CHECK_AC_MACRO],
682 [AT_CONFIGURE_AC([$1])
684 AT_CHECK_AUTOCONF([$3])
685 AT_CHECK_AUTOHEADER([$3], [ignore])
688 ])# _AT_CHECK_AC_MACRO
690 # AT_CHECK_CONFIGURE_AC(NAME, AC-BODY, [AUTOCONF-FLAGS],
691 # [PRE-TESTS], [POST-TESTS])
692 # -----------------------------------------------------
693 # Shorthand for a complete test "group" consisting of a single
694 # invocation of _AT_CHECK_AC_MACRO, possibly with some additional
695 # tests executed before and after.
696 m4_define([AT_CHECK_CONFIGURE_AC],
698 _AT_CHECK_AC_MACRO([$2], [$4], [$3])
703 # AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
704 # [AUTOCONF-FLAGS], [TEST-PARAMETERS], [PRETEST-CMDS])
705 # -----------------------------------------------------
706 # Create a minimalist configure.ac running the macro named MACRO
707 # (using the code in MACRO-USE if that argument is not empty,
708 # otherwise a bare invocation of MACRO with no arguments),
709 # check that autoconf runs on that script,
710 # and that the generated configure script runs without error.
711 # AUTOCONF-FLAGS are passed to all invocations of autoconf.
713 # We always generate two variants of the minimalist configure.ac,
714 # with and without forcing the script into cross-compilation mode
715 # before executing MACRO-USE. If a C++ compiler is available, we
716 # generate two more variants in which MACRO-USE is invoked while
717 # AC_LANG([C++]) is in effect; as before, one forces the script into
718 # cross-compilation mode and the other doesn't. All variants of the
719 # generated configure script are run twice, once with an empty cache,
720 # and once with a cache primed by the previous run.
722 # All four (or eight, if C++ is available) runs are expected to
723 # produce the same results, except for the value of 'cross_compiling'
724 # and differences due to running AC_PROG_CXX instead of AC_PROG_CC.
725 # (See AT_CONFIG_CMP for details.)
727 # If ADDITIONAL-CMDS are present, they are executed after the first
728 # pair of tests (with the C compiler, in native mode).
730 # If PRETEST-CMDS are present, they are executed immediately after
731 # AT_SETUP; use this if the test needs to be skipped conditionally,
734 # If TEST-PARAMETERS are present, they should be a space-separated
735 # list of modifiers to how the test is carried out. Currently
736 # the following modifiers are defined:
738 # - 'no-cross': Don't test this macro in cross-compilation mode.
739 # This is for macros that use AC_RUN_IFELSE, and therefore, when
740 # cross-compiling, they either crash or give a 'best guess' answer
743 # - 'cxx_cv_varies:NAME': The value of the cache variable ac_cv_NAME
744 # may legitimately vary between the C tests and the C++ tests.
746 # - 'cxx_define_varies:NAME' The value of the AC_DEFINEd macro NAME
747 # may legitimately vary between the C tests and the C++ tests.
748 m4_define([AT_CHECK_MACRO],
752 # C compiler, native mode.
753 AT_CONFIGURE_AC([m4_default([$2], [$1])])
754 AT_CHECK_AUTOCONF([$4])
755 AT_CHECK_AUTOHEADER([$4], [ignore])
757 cp -f configure.ac configure-ac.c-native
758 cp -f configure configure.c-native
759 cp -f config.hin config-hin.c-native
761 AT_CHECK_CONFIGURE([-C])
762 AT_PRESERVE_CONFIG_STATUS([c-native-r1])
764 AT_CHECK_CONFIGURE([-C])
765 AT_PRESERVE_CONFIG_STATUS([c-native-r2])
768 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-native-r2])
769 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-native-r2])
772 m4_bmatch([$5], [\<no-cross\>], [], [dnl
774 # C compiler, cross-compilation mode.
775 rm -rf config.cache autom4te.cache
779 m4_default([$2], [$1])])
780 AT_CHECK_AUTOCONF([$4])
781 AT_CHECK_AUTOHEADER([$4], [ignore])
783 cp -f configure.ac configure-ac.c-cross
784 cp -f configure configure.c-cross
785 cp -f config.hin config-hin.c-cross
787 AT_CHECK_CONFIGURE([-C])
788 AT_PRESERVE_CONFIG_STATUS([c-cross-r1])
790 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r1])
791 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r1], [cross])
793 AT_CHECK_CONFIGURE([-C])
794 AT_PRESERVE_CONFIG_STATUS([c-cross-r2])
796 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.c-cross-r2])
797 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.c-cross-r2], [cross])
800 # To save time, skip the C++-mode tests for any macro that did not
801 # transitively require AC_PROG_CC; it won't make any difference.
802 if grep '^CC=' state-env.c-native-r1 > /dev/null 2>&1; then
804 # C++ compiler, native mode.
805 rm -rf config.cache autom4te.cache
808 m4_default([$2], [$1])])
810 # Autoconf may fail here because of an AC_LANG_ASSERT([C]); this
811 # means the macro is specific to C and should not be tested with the
813 AT_CHECK_AUTOCONF([$4], [ignore], [ignore], [stderr])
814 if test -s stderr; then
815 AT_CHECK([grep 'error: AC_LANG_ASSERT: current language is not C' stderr],
816 [0], [ignore], [ignore])
818 AT_CHECK_AUTOHEADER([$4], [ignore])
820 cp -f configure.ac configure-ac.cxx-native
821 cp -f configure configure.cxx-native
822 cp -f config.hin config-hin.cxx-native
824 # If this configure pass fails with code 77, that means there is no
825 # C++ compiler available; don't mark the entire test group skipped,
826 # just skip the rest of the C++ testing.
827 AT_CHECK_CONFIGURE([-C;
829 if test $status -eq 77; then
836 if test ! -f at-no-cxx; then
837 AT_PRESERVE_CONFIG_STATUS([cxx-native-r1])
839 AT_DEFINES_CMP([config-h.c-native-r1], [config-h.cxx-native-r1],
840 _AT_FILTER_CXX_DEFINE_VARIES([$5]))
841 AT_CONFIG_CMP([state-env.c-native-r1], [state-env.cxx-native-r1],
842 [cxx ]_AT_FILTER_CXX_CV_VARIES([$5]))
844 AT_CHECK_CONFIGURE([-C])
845 AT_PRESERVE_CONFIG_STATUS([cxx-native-r2])
847 AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-native-r2])
848 AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-native-r2])
849 m4_bmatch([$5], [\<no-cross\>], [], [dnl
851 # Fourth run: C++ compiler, cross-compilation mode.
853 rm -rf config.cache autom4te.cache
858 m4_default([$2], [$1])])
859 AT_CHECK_AUTOCONF([$4])
860 AT_CHECK_AUTOHEADER([$4], [ignore])
862 cp -f configure.ac configure-ac.cxx-cross
863 cp -f configure configure.cxx-cross
864 cp -f config.hin config-hin.cxx-cross
866 AT_CHECK_CONFIGURE([-C])
867 AT_PRESERVE_CONFIG_STATUS([cxx-cross-r1])
869 AT_DEFINES_CMP([config-h.cxx-native-r1], [config-h.cxx-cross-r1])
870 AT_CONFIG_CMP([state-env.cxx-native-r1], [state-env.cxx-cross-r1],
873 AT_CHECK_CONFIGURE([-C])
874 AT_PRESERVE_CONFIG_STATUS([cxx-cross-r2])
876 AT_DEFINES_CMP([config-h.cxx-cross-r1], [config-h.cxx-cross-r2])
877 AT_CONFIG_CMP([state-env.cxx-cross-r1], [state-env.cxx-cross-r2])
879 fi # C++ compiler available
880 fi # macro can be used with C++
881 fi # C++ makes a difference
887 # _AT_FILTER_CXX_CV_VARIES(TEST-PARAMETERS)
888 # ---------------------------------------------
889 # Subroutine of AT_CHECK_MACRO that expands to a sequence of
890 # zero or more 'vary:NAME' tokens, one for each occurrence of
891 # 'cxx_cv_varies:NAME' in TEST-PARAMETERS.
892 m4_define([_AT_FILTER_CXX_CV_VARIES],
893 [m4_map_args_w([$1], [_AT_FILTER_CXX_CV_VARY(], [)], [ ])])
895 m4_define([_AT_FILTER_CXX_CV_VARY],
896 [m4_bmatch([$1], [^cxx_cv_varies:],
897 [m4_bpatsubsts([$1], [\<cxx_cv_varies:], [vary:])])])
900 # _AT_FILTER_CXX_DEFINE_VARIES(TEST-PARAMETERS)
901 # ---------------------------------------------
902 # Subroutine of AT_CHECK_MACRO that expands to a sequence of
903 # zero or more 'vary:NAME' tokens, one for each occurrence of
904 # 'cxx_define_varies:NAME' in TEST-PARAMETERS.
905 m4_define([_AT_FILTER_CXX_DEFINE_VARIES],
906 [m4_map_args_w([$1], [_AT_FILTER_CXX_DEFINE_VARY(], [)], [ ])])
908 m4_define([_AT_FILTER_CXX_DEFINE_VARY],
909 [m4_bmatch([$1], [^cxx_define_varies:],
910 [m4_bpatsubsts([$1], [\<cxx_define_varies:], [vary:])])])
913 # AT_CHECK_AU_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
914 # [AUTOCONF-FLAGS], [TEST-PARAMETERS])
915 # ------------------------
916 # Do all the tests that AT_CHECK_MACRO(...) would do.
918 # In addition, run autoupdate on configure.ac; afterward, verify that
919 # MACRO no longer appears in configure.ac, autoconf runs on the
920 # updated script, the configure script still runs without error, and
921 # the result of configuration is unchanged.
923 # Before running autoupdate, check for a -Wobsolete warning naming
924 # MACRO from configure. After running autoupdate, *don't* check for
925 # the absence of -Wobsolete warnings, because many of autoupdate's
926 # edits leave the configure.ac author with some manual work to do, and
927 # indicate this by inserting an m4_warn message to be removed after
928 # the manual work is complete.
929 m4_define([AT_CHECK_AU_MACRO],
930 [AT_CHECK_MACRO([$1], [$2], [$3], [-Wno-obsolete $4], [$5])
932 AT_SETUP([autoupdating $1])
933 AT_KEYWORDS([autoupdate])
935 AT_CONFIGURE_AC([m4_default([$2], [$1])])
937 AT_CHECK_AUTOCONF([$4], 0, [], [stderr])
938 AT_CHECK([grep 'macro .$1. is obsolete' stderr], 0, [ignore], [ignore])
939 AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
942 AT_PRESERVE_CONFIG_STATUS([before-au])
945 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
946 AT_CHECK([grep '^$1$' configure.ac], 1)
948 AT_CHECK_AUTOCONF([-Wno-obsolete $4])
949 AT_CHECK_AUTOHEADER([-Wno-obsolete $4], [ignore])
952 AT_PRESERVE_CONFIG_STATUS([after-au])
954 AT_CMP([config-h.before-au], [config-h.after-au])
955 AT_CONFIG_CMP([state-env.before-au], [state-env.after-au])
958 ])# AT_CHECK_AU_MACRO
962 ## ----------------------- ##
963 ## Launch the test suite. ##
964 ## ----------------------- ##