summaryrefslogtreecommitdiff
path: root/tests/local.at
blob: a7fdbb1689448f9f773c085a4000fcb07533fcb2 (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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# M4 macros used in building Autoconf test suites.        -*- Autotest -*-

# Copyright (C) 2000-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/>.

m4_version_prereq([2.57])

# Used in many tests.
m4_pattern_allow([^AS_EXIT$])
m4_pattern_allow([^m4_(define|shift)$])

# Programs this package provides
AT_TESTED([autom4te autoconf autoheader autoupdate autoreconf ifnames])

# Enable colored test output.
AT_COLOR_TESTS

# Sanitize the environment used for tests.
AT_PREPARE_TESTS(
[# These variables should not be inherited from the
# parent environment.
AS_UNSET([CONFIG_SITE])
AS_UNSET([MAKEFLAGS])

# Ensure MAKE is set to a useful value.  Unlike the above, we *do*
# want to inherit this variable from the parent environment and/or
# our command line.
: "${MAKE=make}"
export MAKE
])



## ---------------- ##
## Utility macros.  ##
## ---------------- ##

# AT_CMP(FILE-1, FILE-2)
# ----------------------
# Check FILE-1 and FILE-2 for equality, like `cmp FILE-1 FILE-2'.
m4_define([AT_CMP],
[m4_ifval([$2],, [m4_fatal([AT_CMP takes two arguments.])])[]dnl
AT_CHECK([$at_diff "$1" "$2"])
])# AT_CMP


## ---------------- ##
## Testing syntax.  ##
## ---------------- ##

# AT_CHECK_SHELL_SYNTAX(PROGRAM)
# ------------------------------
# If the shell handles `-n' well, use it to check the syntax of PROGRAM;
# otherwise, do nothing.  ksh93 -n also spits outs loads of warnings
# about older constructs, but we don't care about the warnings.
m4_define([AT_CHECK_SHELL_SYNTAX],
[AT_SKIP_IF([test "$SHELL_N" = none])
AT_CHECK(["$SHELL_N" -n $1], [], [], [ignore])])

m4_define([AT_CHECK_PERL_SYNTAX],
[AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1],
          0, [], [ignore])])

## ------------------ ##
## Testing autom4te.  ##
## ------------------ ##


# AT_CHECK_M4(COMMAND, [EXIT-STATUS = 0], STDOUT, STDERR)
# -------------------------------------------------------
# If stderr is specified, normalize the observed stderr.
# This (using GNU M4 1.4.6)
#
#  /usr/local/bin/m4:script.4s:1: cannot open `foo': No such file or directory
#  autom4te: /usr/local/bin/m4 failed with exit status: 1
#
# or this (GNU M4 1.4.11)
#
#  /usr/local/bin/m4:script.4s:1: include: cannot open `foo': No such file or directory
#  autom4te: /usr/local/bin/m4 failed with exit status: 1
#
# or this (GNU M4 1.4 installed as gm4)
#
#  script.4s:1: /usr/local/bin/gm4: Cannot open foo: No such file or directory
#  autom4te: /usr/local/bin/gm4 failed with exit status: 1
#
# or this (GNU M4 1.4.13 installed as m4-1.4.13):
#
#  /usr/bin/m4-1.4.13:script.4s:1: include: cannot open `foo': No such file or directory
#  autom4te: /usr/bin/m4-1.4.13 failed with exit status: 1
#
# becomes
#
#  m4:script.4s:1: cannot open `foo': No such file or directory
#  autom4te: m4 failed with exit status: 1
#
# Also, this
#
#  configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete.
#  configure.ac:6: You should run autoupdate.
#  ../../lib/autoconf/lang.m4:125: AC_LANG_SAVE is expanded from...
#  configure.ac:6: the top level
#
# becomes
#
#  configure.ac:6: warning: The macro `AC_LANG_SAVE' is obsolete.
#  configure.ac:6: You should run autoupdate.
#  lang.m4: AC_LANG_SAVE is expanded from...
#  configure.ac:6: the top level
#
# We use the following sed patterns:
#
#     (m4): ?(file): ?(line):
# or  (file): ?(line): ?(m4):
# to  m4:(file):(line):
#
# and
#     m4:(file):(line): Cannot open foo:
# or  m4:(file):(line): include: cannot open `foo':
# to  m4:(file):(line): cannot open `foo':
#
# and
#     autom4te: [^ ]m4
# or  autom4te: [^ ]m4.exe
# to  autom4te: m4
#
# and
#     (path)/(basename).m4: ?(line): (message)
# to  (basename).m4: (message)
#
# Moreover, DJGPP error messages include the error code in brackets;
# remove the error code during normalization.
#
m4_define([AT_CHECK_M4],
[AT_CHECK([$1], [$2], [$3],
          m4_case([$4], [], [], [ignore], [ignore], [stderr]))
m4_case([$4], [], [], [ignore], [],
[AT_CHECK([[mv stderr stderr-raw &&
   sed 's/^[^:]*m4[-.ex0-9]*: *\([^:]*:\) *\([0-9][0-9]*: \)/m4:\1\2/
	s/^\([^:]*:\) *\([0-9][0-9]*:\)[^:]*m4[-.ex0-9]*: /m4:\1\2 /
	s/: C\(annot open \)\([^`:]*\):/: c\1`\2'\'':/
	s/: include:\( cannot open\)/:\1/
	s/^autom4te: [^ ]*m4[.ex]* /autom4te: m4 /
	s/^autom4te: error: [^ ]*m4[.ex]* /autom4te: error: m4 /
        s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *!\1.m4: !
        s!^.*/\([^/][^/]*\)\.m4: *[0-9][0-9]*: *[0-9][0-9]*: *!\1.m4: !
	s/ (E[A-Z]*)$//
    ' stderr-raw >&2]], [0], [], [$4])])
])

# AT_CHECK_AUTOM4TE(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
# -----------------------------------------------------------
m4_define([AT_CHECK_AUTOM4TE],
[AT_CHECK_M4([autom4te $1], [$2], [$3], [$4])])



## ----------------- ##
## Testing M4sugar.  ##
## ----------------- ##


# AT_DATA_M4SUGAR(FILE-NAME, CONTENTS)
# ------------------------------------
# Escape the invalid tokens with @&t@.
m4_define([AT_DATA_M4SUGAR],
[AT_DATA([$1],
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\)\(_\)\|\(d\)\(nl\)],
              [\1\3\5@&t@\2\4\6])])])


# AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
# ----------------------------------------------------------
m4_define([AT_CHECK_M4SUGAR],
[AT_KEYWORDS([m4sugar])
AT_CHECK_AUTOM4TE([--language=m4sugar script.4s -o script $1],
	           [$2], [$3], [$4])])



## -------------- ##
## Testing M4sh.  ##
## -------------- ##


# AT_DATA_M4SH(FILE-NAME, CONTENTS)
# ---------------------------------
# Escape the invalid tokens with @&t@.
m4_define([AT_DATA_M4SH],
[AT_DATA([$1],
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\)\(_\)\|\(d\)\(nl\)],
              [\1\3\5@&t@\2\4\6])])])


# AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
# -------------------------------------------------------
m4_define([AT_CHECK_M4SH],
[AT_CHECK_AUTOM4TE([--language=m4sh script.as -o script $1],
	           [$2], [$3], [$4])])



## ------------------ ##
## Testing Autoconf.  ##
## ------------------ ##


# AT_DATA_AUTOCONF(FILE-NAME, CONTENTS)
# -------------------------------------
# Escape the invalid tokens with @&t@.
m4_define([AT_DATA_AUTOCONF],
[AT_DATA([$1],
[m4_bpatsubst([$2], [\(@.\)\(.@\)\|\(m4\|AS\|AC\)\(_\)\|\(d\)\(nl\)],
              [\1\3\5@&t@\2\4\6])])])



# AT_CONFIGURE_AC(BODY)
# ---------------------
# Create a full configure.ac running BODY, with a config header set up,
# AC_OUTPUT, and environment checking hooks.
m4_define([AT_CONFIGURE_AC],
[AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AC_STATE_SAVE(before)]
$1
[AC_OUTPUT
AC_STATE_SAVE(after)
]])
cp "$abs_top_srcdir/build-aux/install-sh" \
   "$abs_top_srcdir/build-aux/config.guess" \
   "$abs_top_srcdir/build-aux/config.sub" .
cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4
])# AT_CONFIGURE_AC


# AT_CHECK_AUTOCONF(ARGS, [EXIT-STATUS = 0], STDOUT, STDERR)
# ----------------------------------------------------------
# We always use "--force", to prevent problems with timestamps if the testsuite
# were running too fast.
m4_define([AT_CHECK_AUTOCONF],
[AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4])
if test -s configure && test "$SHELL_N" != none; then
  AT_CHECK_SHELL_SYNTAX([configure])
fi
])


# AT_CHECK_AUTOHEADER(ARGS, EXPECTED_TMPLS, [EXIT-STATUS = 0], STDOUT, STDERR)
# ----------------------------------------------------------------------------
# EXPECTED_TMPLS is a whitespace-separated list of template
# definitions that should appear in the generated config.hin.
# The stock definitions made by AC_INIT are also checked for.
# If EXPECTED_TMPLS is the single word `ignore', or if the
# expected exit status is not 0, this test is skipped.
m4_define([AT_CHECK_AUTOHEADER],
[AT_CHECK_M4([autoheader $1], [$3], [$4], [$5])
m4_if(m4_strip([$2]), [ignore], [],
  [m4_if(m4_default_nblank([$3], [0]), [0], [dnl
if test -f config.h.in
then config_h_in=config.h.in
elif test -f config.hin
then config_h_in=config.hin
else AT_FAIL_IF([: "Cannot find autoheader template file"])
fi
m4_set_add_all([ah_expected_tmpls],
  [PACKAGE_BUGREPORT],
  [PACKAGE_NAME],
  [PACKAGE_STRING],
  [PACKAGE_TARNAME],
  [PACKAGE_URL],
  [PACKAGE_VERSION])dnl
m4_map_args_w([$2],
  [m4_set_add([ah_expected_tmpls],], [)])dnl
AT_DATA([expout.in],[m4_set_dump([ah_expected_tmpls],[
])
])
AT_CHECK([sort -o expout expout.in])
AT_CHECK([[sed -ne 's/^[	 ]*#[	 ]*undef[	 ][	 ]*//p' \
           $config_h_in | sort]],
  [0], [expout], [])
AS_UNSET([config_h_in])
])])])


# AT_CHECK_CONFIGURE(END-COMMAND,
#                    [EXIT-STATUS = 0],
#                    [STDOUT = IGNORE], STDERR)
# ---------------------------------------------
# `abs_top_srcdir' is needed so that `./configure' finds install-sh.
# Using --srcdir is more expensive.
m4_define([AT_CHECK_CONFIGURE],
[AT_CAPTURE_FILE([config.log])[]dnl
 AT_CHECK([./configure $configure_options $1],
	  [$2],
	  m4_default([$3], [ignore]), [$4])])


# AT_CHECK_ENV
# ------------
# Check that the full configure run remained in its variable name space,
# and cleaned up tmp files.
#
# Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
# In this case just don't pay attention to the env.  It would be great
# to keep the error message but we can't: that would break AT_CHECK.
#
# FreeBSD sh may intermingle the trace output from the egrep and grep
# commands in the pipe, so turn off tracing for these.
#
# Some tests might exit prematurely when they find a problem, in
# which case `env-after' is probably missing.  Don't check it then.
#
# Here are the variables `configure' may modify during execution:
# - ^as_
#   M4sh's shell name space.
# - ^ac_
#   Autoconf's shell name space.
# - prefix and exec_prefix
#   are kept undefined (NONE) until AC_OUTPUT which then sets them to
#   `/usr/local' and `${prefix}' for make.
# - (host|build|target)(_(alias|cpu|vendor|os))?
#   Set by AC_CANONICAL_(HOST|BUILD|TARGET).
# - cross_compiling
#   Set by AC_INIT.
# - interpval
#   Set by AC_SYS_INTERPRETER.
# - CONFIG_STATUS and DEFS
#   Set by AC_OUTPUT.
# - AC_SUBST'ed variables
#   (FIXME: Generate a list of these automatically.)
# - _|@|.[*#?$].|argv|ARGC|LINENO|OLDPWD|PIPESTATUS|RANDOM|SECONDS
#   |START_TIME|ToD|_AST_FEATURES
#   Some variables some shells use and change.
#   `.[*#?$].' catches `$#' etc. which are displayed like this:
#      | '!'=18186
#      | '#'=0
#      | '$'=6908
#
m4_defun([AT_CHECK_ENV],
[m4_require([_AT_CHECK_ENV])]dnl
[AT_CHECK([ath_fn_check_env])])

m4_defun([_AT_CHECK_ENV],
[AT_TEST_HELPER_FN([check_env], [],
[Compare the directory and environment state both before and after a run,
and return non-zero status if they differ inappropriately.],
[# Compare directory listings.
test -f state-ls.before ||
  AS_ERROR([state-ls.before not present])
test -f state-ls.after \
  && { $at_diff state-ls.before state-ls.after || return 1; }
# Compare variable space dumps.
if test -f state-env.before && test -f state-env.after; then
  set +x
  grep_failed=false
  for act_file in state-env.before state-env.after
  do
    ($EGREP -v '^(m4_join([|],
      [a[cs]_.*],
      [(exec_)?prefix|DEFS|CONFIG_STATUS],
      [CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
      [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
      [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
      [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
      [OBJCXX|OBJCXXCPP|OBJCXXFLAGS],
      [GOC|GOFLAGS],
      [OPENMP_CFLAGS],
      [LIBS|LIB@&t@OBJS|LTLIBOBJS|LDFLAGS],
      [INSTALL(_(DATA|PROGRAM|SCRIPT))?],
      [EXEEXT|OBJEXT],
      [CYGWIN|EMXOS2|ISC|MINGW32|MINIX|MSYS|XENIX],
      [X_(CFLAGS|(EXTRA_|PRE_)?LIBS)|x_(includes|libraries)|(have|no)_x],
      [(host|build|target)(_(alias|cpu|vendor|os))?],
      [cross_compiling|U],
      [interpval|PATH_SEPARATOR],
      [GFC|F77_DUMMY_MAIN|f77_(case|underscore)],
      [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_[fF]|_MODEXT|_MODINC|_MODOUT|_DEFINE)?],
      [ALLOCA|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
      [AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|RANLIB|SET_MAKE|YACC],
      [GREP|[EF]GREP|SED],
      [[_@]|.[*@%:@?$].],
      [argv|ARGC|LINENO|BASH_ARGC|BASH_ARGV|OLDPWD|PIPESTATUS|RANDOM],
      [SECONDS|START_TIME|ToD|_AST_FEATURES]))=' \
     $act_file ||
       test $? -eq 1 || echo failed >&2
    ) 2>stderr-$act_file |
      # There may be variables spread on several lines; remove latter lines.
      $GREP '^m4_defn([m4_re_word])=' >clean-$act_file ||
        test $? -eq 1 || grep_failed=:
    test -s stderr-$act_file && grep_failed=:
  done
  $at_traceon
  $grep_failed || $at_diff clean-state-env.before clean-state-env.after
fi
])])


# AT_CONFIG_CMP(VAR-FILE-A, VAR-FILE-B)
# -------------------------------------
# Check the outcomes of two configure runs for equality by comparing dumps of
# their shell variables.  VAR-FILE-A and VAR-FILE-B are two `set'-style shell
# variable space dumps.
#
# We permit variance between runs in the following shell variables:
# - ^as_
#   M4sh's shell name space.
# - ^ac_, excluding ^ac_cv_
#   Autoconf's private shell name space.
# - Variables with unstable values in at least some shells:
#   - OLDPWD [bash, zsh]
#   - PPID [bash, zsh]
#   - RANDOM [bash, zsh]
#   - SECONDS [bash, zsh]
#   - START_TIME [NetBSD sh]
#   - ToD [NetBSD sh]
#   - '$' [zsh]
#   - argv [zsh]
#   - ARGC [zsh]
#   - BASH_ARGC [bash]
#   - BASH_ARGV [bash]
#   - LINENO [Posix]
#   - _AST_FEATURES [ksh93]
#
# Furthermore, it is okay for a non-cache variable initialized to empty in one
# run to be unset in another run.  This happens when, for example, cache update
# code tries a number of values in LIBS and eventually restores LIBS to its
# original value. If LIBS was previously unset, it will have become set and
# empty.  (OTOH, cache variables indicate the result of the test even if they
# are empty, so we have to be strict about them.)
#
# Lines that do not look like `foo=bar' are probably latter lines of
# multiline values; trim them.
#
m4_define([AT_CONFIG_CMP],
[for act_file in $1 $2
do
  $SED '/^ac_cv_/ b
	/^m4_defn([m4_re_word])=./ !d
	/^[[^=]]*='\'''\''$/ d
	/^a[[cs]]_/ d
	/^OLDPWD=/ d
	/^PPID=/ d
	/^RANDOM=/ d
	/^SECONDS=/ d
	/^START_TIME=/ d
	/^ToD=/ d
	/'\'\\\$\''=/ d
	/^argv=/ d
	/^ARGC=/ d
	/^BASH_ARGC=/ d
	/^BASH_ARGV=/ d
	/^LINENO=/ d
	/^_AST_FEATURES=/ d
	' $act_file >at_config_vars-$act_file
done
AT_CMP([at_config_vars-$1], [at_config_vars-$2])[]dnl
])# AT_CONFIG_CMP


# AT_CHECK_DEFINES(CONTENT)
# -------------------------
# Verify that config.h, once stripped, is CONTENT.
# Stripping consists of keeping CPP lines (i.e. containing a hash),
# but those of automatically checked features (STDC_HEADERS etc.)
# and symbols (PACKAGE_...).
# AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
m4_define([AT_CHECK_DEFINES],
[AT_CHECK([[sed '/#/!d
/INTTYPES/d
/MEMORY/d
/PACKAGE_/d
/STDC_HEADERS/d
/STDINT/d
/STDLIB/d
/STRING/d
/SYS_STAT/d
/SYS_TYPES/d
/UNISTD/d' config.h]],,
	  [$1])])


# AT_CHECK_AUTOUPDATE
# -------------------
m4_define([AT_CHECK_AUTOUPDATE],
[AT_CHECK([autoupdate $1], [$2], [$3], [$4])
])


# AT_CHECK_MAKE(MAKEARGS, DIRECTORY, EXIT-STATUS,
#               [STDOUT = IGNORE], [STDERR = IGNORE])
# ---------------------------------------------------------------
# Run make in DIRECTORY (default `.'), passing MAKEARGS on the command
# line.  EXIT-STATUS, STDOUT, and STDERR are as for AT_CHECK.
# The environment variable MAKE is honored if present.
# The environment variable MAKEFLAGS is *cleared*.
# If EXIT-STATUS is 1, an exit status of either 1 or 2 is considered
# an acceptable result, because there are situations where BSD make will
# exit with status 1 but GNU make will instead exit with status 2.
m4_define([AT_CHECK_MAKE],
[AT_CHECK(
  m4_if(m4_default([$2], [.]), [.], [],
        [cd "$2" && ])[$][MAKE]m4_ifnblank([$1],[ $1])[]m4_if([$3], [1], [[
dnl pacify editors that don't understand sh case: ((
  case $? in 1|2) exit 1;; *) exit $?;; esac]]),
  [$3],
  m4_default([$4], [ignore]),
  m4_default([$5], [ignore]))
])


# _AT_CHECK_AC_MACRO(AC-BODY, PRE-TESTS, [AUTOCONF-FLAGS])
# --------------------------------------
# Create a minimalist configure.ac running the macro named
# NAME-OF-THE-MACRO, check that autoconf runs on that script,
# and that the generated configure script runs without error.
m4_define([_AT_CHECK_AC_MACRO],
[AT_CONFIGURE_AC([$1])
$2
AT_CHECK_AUTOCONF([$3])
AT_CHECK_AUTOHEADER([$3], [ignore])
AT_CHECK_CONFIGURE
AT_CHECK_ENV
])# _AT_CHECK_AC_MACRO


# AT_CHECK_MACRO(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
#                [AUTOCONF-FLAGS])
# -----------------------------------------------------
# Create a minimalist configure.ac running the macro named
# NAME-OF-THE-MACRO, check that autoconf runs on that script,
# and that the generated configure script runs without error.
#
# We run `configure' twice, both times with a cache, and compare
# the environment after each run to detect inconsistencies.
m4_define([AT_CHECK_MACRO],
[AT_SETUP([$1])

AT_CONFIGURE_AC([m4_default([$2], [$1])])

AT_CHECK_AUTOCONF([$4])
AT_CHECK_AUTOHEADER([$4], [ignore])

for at_run in r1 r2
do
    AT_CHECK_CONFIGURE([-C])
    cp -f state-env.after state-env.$at_run
    cp -f config.h config-h.$at_run
    cp -f config.log config-log.$at_run
    cp -f config.status config-status.$at_run
    AT_CHECK_ENV
done

AT_CMP([config-h.r1], [config-h.r2])
AT_CONFIG_CMP([state-env.r1], [state-env.r2])

$3

AT_CLEANUP[]dnl
])# AT_CHECK_MACRO


# AT_CHECK_MACRO_CROSS(MACRO, [MACRO-USE], [ADDITIONAL-CMDS],
#                      [AUTOCONF-FLAGS])
# -----------------------------------------------------------
# Like the previous one, but creates two checks: for native
# compile and for cross-compile.
m4_define([AT_CHECK_MACRO_CROSS],
[AT_CHECK_MACRO($@)
AT_CHECK_MACRO([$1 (cross compile)],
  [AT_KEYWORDS([cross])
  # Exercise the code used when cross-compiling.
  cross_compiling=yes
  ac_tool_warned=yes
  m4_default([$2], [$1])],
  [$3], [$4])
])


# AT_CHECK_AU_MACRO(MACRO)
# ------------------------
# Create a minimalist configure.ac running the macro named
# NAME-OF-THE-MACRO, check that autoconf runs on that script,
# and that the generated configure script runs without error.
#
# Then run autoupdate on that script, and check that NAME-OF-THE-MACRO
# no longer appears in configure.ac, autoconf runs on the updated
# script, the configure script still runs without error, and the
# result is unchanged.
#
# On the first pass, check for a -Wobsolete warning naming
# NAME-OF-THE-MACRO.  On the second pass, *don't* check for the
# absence of -Wobsolete warnings, because many of autoupdate's edits
# leave the configure.ac author with some manual work to do, and
# indicate this by inserting an m4_warn message to be removed
# after the manual work is complete.
m4_define([AT_CHECK_AU_MACRO],
[AT_SETUP([$1])
AT_KEYWORDS([autoupdate])

AT_CONFIGURE_AC([$1])

AT_CHECK_AUTOCONF([], 0, [], [stderr])
AT_CHECK([grep 'macro .$1. is obsolete' stderr], 0, [ignore], [ignore])
AT_CHECK_AUTOHEADER([-Wno-obsolete], [ignore])
AT_CHECK_CONFIGURE
AT_CHECK_ENV

rm config.hin
AT_CHECK_AUTOUPDATE([], 0, [], ignore)
AT_CHECK([grep '^$1$' configure.ac], 1)

AT_CHECK_AUTOCONF([-Wno-obsolete])
AT_CHECK_AUTOHEADER([-Wno-obsolete], [ignore])
AT_CHECK_CONFIGURE
AT_CHECK_ENV

AT_CLEANUP[]dnl
])# AT_CHECK_AU_MACRO



## ----------------------- ##
## Launch the test suite.  ##
## ----------------------- ##

AT_INIT