| 1 |
# -*- Autotest -*- |
| 2 |
|
| 3 |
AT_BANNER([Executables (autoheader, autoupdate...).]) |
| 4 |
|
| 5 |
# Copyright (C) 2000-2001, 2003-2004, 2006-2017, 2020-2026 Free Software |
| 6 |
# Foundation, Inc. |
| 7 |
# |
| 8 |
# This program is free software: you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation, either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This program is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
|
| 22 |
## ----------------------------- ## |
| 23 |
## Syntax of the shell scripts. ## |
| 24 |
## ----------------------------- ## |
| 25 |
|
| 26 |
# We use '/bin/sh -n script' to check that there are no syntax errors |
| 27 |
# in the scripts. Although incredible, there are /bin/sh that go into |
| 28 |
# endless loops with '-n', e.g., SunOS's: |
| 29 |
# |
| 30 |
# $ uname -a |
| 31 |
# SunOS ondine 4.1.3 2 sun4m unknown |
| 32 |
# $ cat endless.sh |
| 33 |
# while false |
| 34 |
# do |
| 35 |
# : |
| 36 |
# done |
| 37 |
# exit 0 |
| 38 |
# $ time sh endless.sh |
| 39 |
# sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total |
| 40 |
# $ time sh -nx endless.sh |
| 41 |
# ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total |
| 42 |
# |
| 43 |
# So before using '/bin/sh -n' to check our scripts, we first check |
| 44 |
# that '/bin/sh -n' is not broken to death. |
| 45 |
|
| 46 |
AT_SETUP([Syntax of the shell scripts]) |
| 47 |
|
| 48 |
AT_CHECK([test "$SHELL_N" != none || exit 77]) |
| 49 |
|
| 50 |
# Specify the absolute name of the tool, as some shells don't honor PATH when |
| 51 |
# running 'sh PROG'. |
| 52 |
|
| 53 |
AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"]) |
| 54 |
AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"]) |
| 55 |
|
| 56 |
# These are not built, they are in the src tree. |
| 57 |
AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"]) |
| 58 |
AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"]) |
| 59 |
|
| 60 |
AT_CLEANUP |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
## ---------------------------- ## |
| 66 |
## Syntax of the Perl scripts. ## |
| 67 |
## ---------------------------- ## |
| 68 |
|
| 69 |
AT_SETUP([Syntax of the Perl scripts]) |
| 70 |
|
| 71 |
AT_CHECK_PERL_SYNTAX([autoconf]) |
| 72 |
AT_CHECK_PERL_SYNTAX([autoheader]) |
| 73 |
AT_CHECK_PERL_SYNTAX([autom4te]) |
| 74 |
AT_CHECK_PERL_SYNTAX([autoreconf]) |
| 75 |
AT_CHECK_PERL_SYNTAX([autoscan]) |
| 76 |
AT_CHECK_PERL_SYNTAX([autoupdate]) |
| 77 |
AT_CHECK_PERL_SYNTAX([ifnames]) |
| 78 |
|
| 79 |
AT_CLEANUP |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
## ------------------ ## |
| 85 |
## autom4te's cache. ## |
| 86 |
## ------------------ ## |
| 87 |
|
| 88 |
AT_SETUP([autom4te cache]) |
| 89 |
|
| 90 |
AT_DATA_M4SUGAR([[script.4s]], |
| 91 |
[[m4_include([foo]) |
| 92 |
]]) |
| 93 |
|
| 94 |
# Everything is OK. |
| 95 |
touch foo |
| 96 |
AT_CHECK_M4SUGAR |
| 97 |
|
| 98 |
# We moved a file: it should fail |
| 99 |
mkdir sub |
| 100 |
mv foo sub |
| 101 |
AT_CHECK_M4SUGAR([], [1], [], |
| 102 |
[m4:script.4s:1: cannot open 'foo': No such file or directory |
| 103 |
autom4te: error: m4 failed with exit status: 1 |
| 104 |
]) |
| 105 |
|
| 106 |
# But if we change the main file, then we should no longer complain of |
| 107 |
# missing files. |
| 108 |
AT_DATA_M4SUGAR([[script.4s]], |
| 109 |
[[m4_include([sub/foo]) |
| 110 |
]]) |
| 111 |
AT_CHECK_M4SUGAR |
| 112 |
|
| 113 |
AT_CLEANUP |
| 114 |
|
| 115 |
|
| 116 |
# autom4te --force |
| 117 |
# ---------------- |
| 118 |
|
| 119 |
AT_SETUP([autom4te --force]) |
| 120 |
|
| 121 |
AT_DATA([file.m4], |
| 122 |
[[right |
| 123 |
]]) |
| 124 |
AT_CHECK_AUTOM4TE([-o file file.m4]) |
| 125 |
|
| 126 |
# Create a file whose timestamp is in the future. |
| 127 |
# (next year)-01-01 00:01 UTC should always be in the future, |
| 128 |
# even on slow machines. |
| 129 |
echo BAD >file |
| 130 |
this_year=`TZ=UTC0 date +%Y` |
| 131 |
AS_VAR_ARITH([next_year], [$this_year + 1]) |
| 132 |
TZ=UTC0 touch -t ${next_year}01010001 file |
| 133 |
|
| 134 |
AT_CHECK_AUTOM4TE([--force -o file file.m4]) |
| 135 |
AT_CHECK([cat file], 0, |
| 136 |
[[right |
| 137 |
]]) |
| 138 |
|
| 139 |
AT_CLEANUP |
| 140 |
|
| 141 |
|
| 142 |
# autom4te and file names containing whitespace |
| 143 |
# --------------------------------------------- |
| 144 |
|
| 145 |
AT_SETUP([autom4te and whitespace in file names]) |
| 146 |
|
| 147 |
x= |
| 148 |
export x |
| 149 |
rm -f a b |
| 150 |
for funny in \ |
| 151 |
'with funny '\'' $x & #! name' \ |
| 152 |
'with funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock |
| 153 |
do |
| 154 |
funny=`func_sanitize_file_name "$funny"` |
| 155 |
file=" file $funny" |
| 156 |
outfile="$file out " |
| 157 |
dir=`func_sanitize_dir_name " dir $funny"` |
| 158 |
cachedir=" cache$dir" |
| 159 |
TMPDIR=" tmp$dir" |
| 160 |
export TMPDIR |
| 161 |
|
| 162 |
# skip if we cannot create such a file or directory |
| 163 |
AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77]) |
| 164 |
|
| 165 |
cat >"$file" <<'END' |
| 166 |
[m4@&t@_init[]m4@&t@_include(foo.m4) |
| 167 |
m4@&t@_divert([])d@&t@nl |
| 168 |
FOO] |
| 169 |
END |
| 170 |
cat >"$dir"/foo.m4 <<'END' |
| 171 |
[m4@&t@_define([FOO], [bar])] |
| 172 |
END |
| 173 |
|
| 174 |
AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"]) |
| 175 |
AT_CHECK([cat "$outfile"], [], |
| 176 |
[[bar |
| 177 |
]]) |
| 178 |
rm -rf "$outfile" "$cachedir" |
| 179 |
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"]) |
| 180 |
AT_CHECK([cat "$outfile"], [], |
| 181 |
[[bar |
| 182 |
]]) |
| 183 |
|
| 184 |
# This exercises a slightly different code path and will catch an open with |
| 185 |
# trailing whitespace: |
| 186 |
cat >"$file" <<'END' |
| 187 |
[m4@&t@_init[]m4@&t@_include(foo.m4) |
| 188 |
m4@&t@_pattern_forbid([^bar$]) |
| 189 |
m4@&t@_divert([])d@&t@nl |
| 190 |
FOO] |
| 191 |
END |
| 192 |
rm -rf "$outfile" "$cachedir" |
| 193 |
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"], |
| 194 |
[1], [], [stderr]) |
| 195 |
AT_CHECK([grep 'undefined or overquoted macro' stderr], [], [ignore]) |
| 196 |
|
| 197 |
cat >"$file" <<'END' |
| 198 |
[m4@&t@_init[]m4@&t@_include(foo.m4) |
| 199 |
m4@&t@_divert([])d@&t@nl] |
| 200 |
END |
| 201 |
rm -rf "$file.m4f" |
| 202 |
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"]) |
| 203 |
AT_CHECK([test -s "$file.m4f"]) |
| 204 |
|
| 205 |
# Check --reload-state |
| 206 |
AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null]) |
| 207 |
|
| 208 |
test ! -f b |
| 209 |
done |
| 210 |
|
| 211 |
AT_CLEANUP |
| 212 |
|
| 213 |
|
| 214 |
# autom4te --trace and unusual macro names |
| 215 |
# ---------------------------------------- |
| 216 |
|
| 217 |
AT_SETUP([autom4te --trace and unusual macro names]) |
| 218 |
|
| 219 |
AT_DATA([file.m4], |
| 220 |
[[ |
| 221 |
]]) |
| 222 |
AT_CHECK_AUTOM4TE([-t 'TR A CE' -t 'TR(A)CE' file.m4]) |
| 223 |
|
| 224 |
AT_CLEANUP |
| 225 |
|
| 226 |
|
| 227 |
AT_SETUP([autom4te --trace and whitespace]) |
| 228 |
|
| 229 |
dnl line numbering differs between m4 1.4.6 and 1.4.13 if we don't |
| 230 |
dnl go through a single line wrapper |
| 231 |
AT_DATA_M4SUGAR([file.m4], |
| 232 |
[[m4_define([foo], [m4_echo([ a |
| 233 |
b c ], [\ |
| 234 |
d\ |
| 235 |
])]) |
| 236 |
foo |
| 237 |
]]) |
| 238 |
AT_CHECK_AUTOM4TE([--language=m4sugar -t 'm4@&t@_echo' file.m4], [0], |
| 239 |
[[file.m4:5:m4@&t@_echo: a b c :d |
| 240 |
]]) |
| 241 |
|
| 242 |
AT_CLEANUP |
| 243 |
|
| 244 |
|
| 245 |
## ------------------ ## |
| 246 |
## autoconf --trace. ## |
| 247 |
## ------------------ ## |
| 248 |
|
| 249 |
|
| 250 |
# autoconf --trace: user macros |
| 251 |
# ----------------------------- |
| 252 |
AT_SETUP([autoconf --trace: user macros]) |
| 253 |
|
| 254 |
AT_DATA([configure.ac], |
| 255 |
[[m4_define([active], [ACTIVE]) |
| 256 |
m4_define([TRACE1], [TRACE2(m4_shift($@))]) |
| 257 |
m4_define([TRACE2], [[$2], $1]) |
| 258 |
|
| 259 |
# No arguments. |
| 260 |
TRACE1 |
| 261 |
TRACE2 |
| 262 |
|
| 263 |
# With arguments, single line. |
| 264 |
TRACE1(foo, @bar, @baz) |
| 265 |
TRACE1(foo, TRACE1(bar, baz)) |
| 266 |
TRACE1(foo, active, baz) |
| 267 |
TRACE1(foo, [active], TRACE1(active, [active])) |
| 268 |
]]) |
| 269 |
|
| 270 |
# Several --traces. |
| 271 |
AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0, |
| 272 |
[[configure.ac:6:TRACE1: |
| 273 |
configure.ac:6:TRACE2: |
| 274 |
configure.ac:7:TRACE2: |
| 275 |
configure.ac:10:TRACE1:foo:@bar:@baz |
| 276 |
configure.ac:10:TRACE2:@bar:@baz |
| 277 |
configure.ac:11:TRACE1:bar:baz |
| 278 |
configure.ac:11:TRACE2:baz |
| 279 |
configure.ac:11:TRACE1:foo::baz |
| 280 |
configure.ac:11:TRACE2::baz |
| 281 |
configure.ac:12:TRACE1:foo:ACTIVE:baz |
| 282 |
configure.ac:12:TRACE2:ACTIVE:baz |
| 283 |
configure.ac:13:TRACE1:ACTIVE:active |
| 284 |
configure.ac:13:TRACE2:active |
| 285 |
configure.ac:13:TRACE1:foo:active::ACTIVE |
| 286 |
configure.ac:13:TRACE2:active::ACTIVE |
| 287 |
]]) |
| 288 |
|
| 289 |
# Several line requests. |
| 290 |
AT_CHECK_AUTOCONF([[-t TRACE1:' |
| 291 |
[$1], [$2], [$3].']], 0, |
| 292 |
[[ |
| 293 |
[], [], []. |
| 294 |
|
| 295 |
[foo], [@bar], [@baz]. |
| 296 |
|
| 297 |
[bar], [baz], []. |
| 298 |
|
| 299 |
[foo], [], [baz]. |
| 300 |
|
| 301 |
[foo], [ACTIVE], [baz]. |
| 302 |
|
| 303 |
[ACTIVE], [active], []. |
| 304 |
|
| 305 |
[foo], [active], []. |
| 306 |
]]) |
| 307 |
|
| 308 |
# ${sep}@. |
| 309 |
AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0, |
| 310 |
[[[] |
| 311 |
[] |
| 312 |
[@bar])===([@baz] |
| 313 |
[baz] |
| 314 |
[])===([baz] |
| 315 |
[ACTIVE])===([baz] |
| 316 |
[active] |
| 317 |
[active])===([])===([ACTIVE] |
| 318 |
]]) |
| 319 |
|
| 320 |
# Arguments spanning multiple lines. |
| 321 |
AT_DATA([configure.ac], |
| 322 |
[[m4_define([TRACE], []) |
| 323 |
TRACE(foo |
| 324 |
bar, |
| 325 |
bar |
| 326 |
foo) |
| 327 |
]]) |
| 328 |
|
| 329 |
AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0, |
| 330 |
[[foo bar:bar foo |
| 331 |
]]) |
| 332 |
|
| 333 |
AT_CLEANUP |
| 334 |
|
| 335 |
|
| 336 |
# autoconf --trace: builtins |
| 337 |
# -------------------------- |
| 338 |
AT_SETUP([autoconf --trace: builtins]) |
| 339 |
|
| 340 |
AT_DATA([configure.ac], |
| 341 |
[[define([active], [ACTIVE]) |
| 342 |
]]) |
| 343 |
|
| 344 |
AT_CHECK_AUTOCONF([[-t define | sed -n '$p']], |
| 345 |
0, |
| 346 |
[[configure.ac:1:define:active:ACTIVE |
| 347 |
]]) |
| 348 |
|
| 349 |
# FIXME: Without '$1' the following test dies. Groumphf, once again to |
| 350 |
# dive into obscure feature interaction... |
| 351 |
# Note that using '-i' means we need the *.m4 files, not the *.m4f files, |
| 352 |
# hence we need srcdir, not builddir. |
| 353 |
AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']], |
| 354 |
0, |
| 355 |
[[active |
| 356 |
]]) |
| 357 |
|
| 358 |
AT_CLEANUP |
| 359 |
|
| 360 |
|
| 361 |
# autoconf --trace: AC_CONFIG_MACRO_DIRS |
| 362 |
# -------------------------------------- |
| 363 |
AT_SETUP([autoconf --trace: AC_CONFIG_MACRO_DIRS]) |
| 364 |
AT_KEYWORDS([AC_CONFIG_MACRO_DIR AC_CONFIG_MACRO_DIR_TRACE]) |
| 365 |
|
| 366 |
AT_DATA([configure.ac], |
| 367 |
[[AC_INIT |
| 368 |
AC_CONFIG_MACRO_DIR([dir1]) |
| 369 |
AC_CONFIG_MACRO_DIRS([dir2 dir3 \ |
| 370 |
dir4]) |
| 371 |
AC_CONFIG_MACRO_DIRS([dir5]) |
| 372 |
]]) |
| 373 |
|
| 374 |
# Legacy tracing |
| 375 |
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR], 0, |
| 376 |
[[configure.ac:2:AC_CONFIG_MACRO_DIR:dir1 |
| 377 |
]]) |
| 378 |
|
| 379 |
# Preferred tracing |
| 380 |
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR_TRACE], 0, |
| 381 |
[[configure.ac:2:AC_CONFIG_MACRO_DIR_TRACE:dir1 |
| 382 |
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir2 |
| 383 |
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir3 |
| 384 |
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir4 |
| 385 |
configure.ac:5:AC_CONFIG_MACRO_DIR_TRACE:dir5 |
| 386 |
]]) |
| 387 |
|
| 388 |
# Legacy macro can only be used once |
| 389 |
AT_DATA([configure.ac], |
| 390 |
[[AC_INIT |
| 391 |
AC_CONFIG_MACRO_DIR([dir1]) |
| 392 |
AC_CONFIG_MACRO_DIR([dir2]) |
| 393 |
AC_OUTPUT |
| 394 |
]]) |
| 395 |
AT_CHECK_AUTOCONF([], [1], [], [stderr]) |
| 396 |
AT_CHECK([grep 'error: AC_CONFIG_MACRO_DIR can only be used once' stderr], |
| 397 |
[], [ignore]) |
| 398 |
|
| 399 |
# Legacy macro must be used first, if present |
| 400 |
AT_DATA([configure.ac], |
| 401 |
[[AC_INIT |
| 402 |
AC_CONFIG_MACRO_DIRS([dir1]) |
| 403 |
AC_CONFIG_MACRO_DIR([dir2]) |
| 404 |
]]) |
| 405 |
AT_CHECK_AUTOCONF([], [1], [], [stderr]) |
| 406 |
AT_CHECK([grep 'error: AC_CONFIG_MACRO_DIR can only be used once' stderr], |
| 407 |
[], [ignore]) |
| 408 |
|
| 409 |
# Only use the public macros |
| 410 |
AT_DATA([configure.ac], |
| 411 |
[[AC_INIT |
| 412 |
AC_CONFIG_MACRO_DIR_TRACE([dir1]) |
| 413 |
]]) |
| 414 |
AT_CHECK_AUTOCONF([], [1], [], |
| 415 |
[[configure.ac:2: error: Do not invoke AC_CONFIG_MACRO_DIR_TRACE directly |
| 416 |
configure.ac:2: the top level |
| 417 |
autom4te: error: m4 failed with exit status: 1 |
| 418 |
]]) |
| 419 |
|
| 420 |
# Legacy macro use is not required, but still gets traced |
| 421 |
AT_DATA([configure.ac], |
| 422 |
[[AC_INIT |
| 423 |
AC_CONFIG_MACRO_DIRS([dir1]) |
| 424 |
AC_CONFIG_MACRO_DIRS([dir2]) |
| 425 |
AC_OUTPUT |
| 426 |
]]) |
| 427 |
AT_CHECK_AUTOCONF([], [0], [], []) |
| 428 |
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR], [0], |
| 429 |
[[configure.ac:2:AC_CONFIG_MACRO_DIR:dir1 |
| 430 |
]]) |
| 431 |
|
| 432 |
AT_CLEANUP |
| 433 |
|
| 434 |
|
| 435 |
## ---------------------------- ## |
| 436 |
## autoconf: forbidden tokens. ## |
| 437 |
## ---------------------------- ## |
| 438 |
|
| 439 |
|
| 440 |
# autoconf: forbidden tokens, basic |
| 441 |
# --------------------------------- |
| 442 |
AT_SETUP([autoconf: forbidden tokens,[] basic]) |
| 443 |
|
| 444 |
AT_DATA_M4SH([configure.ac], |
| 445 |
[[AS_INIT |
| 446 |
m4_foo |
| 447 |
_m4_bar |
| 448 |
AS_FOO |
| 449 |
_AS_BAR |
| 450 |
[dnl] |
| 451 |
]]) |
| 452 |
|
| 453 |
# This test needs autom4te's cache, in spite of any ~/.autom4te.cfg. |
| 454 |
AT_DATA([.autom4te.cfg], [[ |
| 455 |
begin-language: "Autoconf" |
| 456 |
args: --cache=autom4te.cache |
| 457 |
end-language: "Autoconf" |
| 458 |
begin-language: "Autoconf-without-aclocal-m4" |
| 459 |
args: --cache=autom4te.cache |
| 460 |
end-language: "Autoconf-without-aclocal-m4" |
| 461 |
]]) |
| 462 |
|
| 463 |
AT_MTIME_DELAY |
| 464 |
|
| 465 |
AT_CHECK_AUTOCONF([], 1, [], |
| 466 |
[[trailer.m4: warning: AC_INIT was never used |
| 467 |
trailer.m4: warning: AC_OUTPUT was never used |
| 468 |
configure.ac:2: error: undefined or overquoted macro: m4@&t@_foo |
| 469 |
If this token and others are legitimate, please use m4@&t@_pattern_allow. |
| 470 |
See the Autoconf documentation. |
| 471 |
configure.ac:3: error: undefined or overquoted macro: _m4@&t@_bar |
| 472 |
configure.ac:4: error: undefined or overquoted macro: AS@&t@_FOO |
| 473 |
configure.ac:5: error: undefined or overquoted macro: _AS@&t@_BAR |
| 474 |
configure.ac:6: error: undefined or overquoted macro: d@&t@nl |
| 475 |
]]) |
| 476 |
|
| 477 |
# On a file system with coarse timestamp resolution (1 or 2s), |
| 478 |
# configure and autom4te's cache files can easily have equal |
| 479 |
# timestamps, in which case autom4te will consider the cache |
| 480 |
# to be stale. Ensure configure's timestamp is newer. |
| 481 |
AT_MTIME_DELAY |
| 482 |
touch configure |
| 483 |
|
| 484 |
# Since warnings are replicated from the cache but "undefined or overquoted |
| 485 |
# macro" errors are not, a second run, without --force, should succeed |
| 486 |
# and should yield only the warnings about AC_INIT and AC_OUTPUT. |
| 487 |
AT_CHECK_M4([autoconf], 0, [], |
| 488 |
[[trailer.m4: warning: AC_INIT was never used |
| 489 |
trailer.m4: warning: AC_OUTPUT was never used |
| 490 |
]]) |
| 491 |
|
| 492 |
AT_CLEANUP |
| 493 |
|
| 494 |
|
| 495 |
# autoconf: forbidden tokens, exceptions |
| 496 |
# -------------------------------------- |
| 497 |
AT_SETUP([autoconf: forbidden tokens,[] exceptions]) |
| 498 |
|
| 499 |
AT_DATA_M4SH([configure.ac], |
| 500 |
[[AS_INIT |
| 501 |
|
| 502 |
# This is allowed in spite of the name. |
| 503 |
# It is on purpose that we check the case where there are several |
| 504 |
# tokens on the same line. |
| 505 |
m4_pattern_allow([^AS_ALLOWED$]) |
| 506 |
NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT |
| 507 |
|
| 508 |
# Test forbidding. |
| 509 |
m4_pattern_forbid([^FORBIDDEN$]) |
| 510 |
NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT |
| 511 |
|
| 512 |
# Test Autoconf's patterns. |
| 513 |
AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO |
| 514 |
BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS |
| 515 |
# This is legal, although there is 'AS_DEFINE' in there. |
| 516 |
BAS_DEFINE |
| 517 |
# AS_THIS_IS_A_COMMENT so just shut up. |
| 518 |
It would be very bad if Autoconf forgot to expand [AS_]INIT! |
| 519 |
]]) |
| 520 |
|
| 521 |
AT_CHECK_AUTOCONF([], 1, [], |
| 522 |
[[trailer.m4: warning: AC_INIT was never used |
| 523 |
trailer.m4: warning: AC_OUTPUT was never used |
| 524 |
configure.ac:1: error: undefined or overquoted macro: AS@&t@_INIT |
| 525 |
If this token and others are legitimate, please use m4@&t@_pattern_allow. |
| 526 |
See the Autoconf documentation. |
| 527 |
configure.ac:7: error: undefined or overquoted macro: AS@&t@_ALLOWED_NOT |
| 528 |
configure.ac:10: error: undefined or overquoted macro: FORBIDDEN |
| 529 |
configure.ac:14: error: undefined or overquoted macro: AS@&t@_THIS_IS_INVALID |
| 530 |
configure.ac:14: error: undefined or overquoted macro: _AS@&t@_THIS_IS_INVALID_TOO |
| 531 |
]]) |
| 532 |
|
| 533 |
AT_CLEANUP |
| 534 |
|
| 535 |
|
| 536 |
# autoconf: automatically allowed tokens |
| 537 |
# -------------------------------------- |
| 538 |
AT_SETUP([autoconf: automatically allowed tokens]) |
| 539 |
|
| 540 |
AT_DATA_M4SH([configure.ac], |
| 541 |
[[AC_INIT |
| 542 |
m4_pattern_forbid([^FB_]) |
| 543 |
AC_DEFINE([FB_ONE]) |
| 544 |
AC_SUBST([FB_TWO]) |
| 545 |
AC_OUTPUT |
| 546 |
]]) |
| 547 |
|
| 548 |
AT_CHECK_AUTOCONF |
| 549 |
|
| 550 |
AT_CLEANUP |
| 551 |
|
| 552 |
|
| 553 |
# autoconf: do not forbid the empty token |
| 554 |
# --------------------------------------- |
| 555 |
AT_SETUP([autoconf: the empty token]) |
| 556 |
|
| 557 |
AT_DATA_M4SH([configure.ac], |
| 558 |
[[m4_init[]m4_pattern_allow([^foo$]) |
| 559 |
m4_divert([])dnl |
| 560 |
line that begins with a space |
| 561 |
]]) |
| 562 |
|
| 563 |
AT_CHECK_AUTOCONF([], 0, [], |
| 564 |
[[trailer.m4: warning: AC_INIT was never used |
| 565 |
trailer.m4: warning: AC_OUTPUT was never used |
| 566 |
]]) |
| 567 |
|
| 568 |
AT_CLEANUP |
| 569 |
|
| 570 |
|
| 571 |
# autoconf: subdirectories |
| 572 |
# ------------------------ |
| 573 |
AT_SETUP([autoconf: subdirectories]) |
| 574 |
|
| 575 |
AT_DATA([configure.ac], |
| 576 |
[[AC_INIT |
| 577 |
AC_PROG_MKDIR_P |
| 578 |
AC_CONFIG_FILES(sub/foo) |
| 579 |
AC_OUTPUT |
| 580 |
]]) |
| 581 |
|
| 582 |
mkdir sub |
| 583 |
|
| 584 |
AT_DATA([sub/foo.in], |
| 585 |
[[@MKDIR_P@ |
| 586 |
]]) |
| 587 |
|
| 588 |
AT_DATA([install-sh]) |
| 589 |
|
| 590 |
AT_CHECK_AUTOCONF |
| 591 |
AT_CHECK_CONFIGURE |
| 592 |
AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1) |
| 593 |
|
| 594 |
AT_CLEANUP |
| 595 |
|
| 596 |
|
| 597 |
# autoconf: input from stdin |
| 598 |
# -------------------------- |
| 599 |
AT_SETUP([autoconf: input from stdin]) |
| 600 |
|
| 601 |
# Past Autoconf versions failed to read from stdin when other, non-frozen input |
| 602 |
# files were present. |
| 603 |
AT_DATA([aclocal.m4]) |
| 604 |
|
| 605 |
AT_CHECK([echo 'AC_INIT(X, 1.0, [email protected])' | autoconf -t AC_INIT -], |
| 606 |
0, [stdin:1:AC_INIT:X:1.0:[email protected] |
| 607 |
]) |
| 608 |
AT_CHECK([echo 'AC_INIT(X, 2.0, [email protected])' | autoconf -t AC_INIT -], |
| 609 |
0, [stdin:1:AC_INIT:X:2.0:[email protected] |
| 610 |
]) |
| 611 |
|
| 612 |
AT_CLEANUP |
| 613 |
|
| 614 |
|
| 615 |
# autoconf: AC_AUTOCONF_VERSION |
| 616 |
# ----------------------------- |
| 617 |
AT_SETUP([autoconf: AC_AUTOCONF_VERSION]) |
| 618 |
|
| 619 |
AT_DATA([configure.ac], |
| 620 |
[[AC_INIT |
| 621 |
version m4@&t@_defn([AC_AUTOCONF_VERSION]) version |
| 622 |
AC_OUTPUT |
| 623 |
]]) |
| 624 |
|
| 625 |
AT_CHECK_AUTOCONF |
| 626 |
AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]], |
| 627 |
0, [ignore]) |
| 628 |
|
| 629 |
AT_CLEANUP |
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
# autoconf: AC_PRESERVE_HELP_ORDER |
| 634 |
# -------------------------------- |
| 635 |
AT_SETUP([autoconf: AC_PRESERVE_HELP_ORDER]) |
| 636 |
AT_KEYWORDS([m4@&t@_divert_text]) |
| 637 |
|
| 638 |
AT_DATA_AUTOCONF([configure.ac], |
| 639 |
[[AC_INIT |
| 640 |
AC_PRESERVE_HELP_ORDER |
| 641 |
AC_ARG_WITH([one], [ --with-one]) |
| 642 |
AC_ARG_ENABLE([two], [ --enable-two]) |
| 643 |
m4_divert_text([HELP_ENABLE], [arbitrary $text]) |
| 644 |
AC_ARG_WITH([three], [ --with-three]) |
| 645 |
AC_OUTPUT |
| 646 |
]]) |
| 647 |
|
| 648 |
AT_CHECK_AUTOCONF |
| 649 |
AT_CHECK_CONFIGURE([--help], [], [stdout]) |
| 650 |
AT_CHECK([sed -n '/^Optional/,/^$/p' stdout], [], |
| 651 |
[[Optional Features and Packages: |
| 652 |
--disable-option-checking ignore unrecognized --enable/--with options |
| 653 |
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) |
| 654 |
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] |
| 655 |
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] |
| 656 |
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) |
| 657 |
--with-one |
| 658 |
--enable-two |
| 659 |
arbitrary $text |
| 660 |
--with-three |
| 661 |
|
| 662 |
]]) |
| 663 |
|
| 664 |
AT_CLEANUP |
| 665 |
|
| 666 |
|
| 667 |
# autoconf: timestamp changes |
| 668 |
# --------------------------- |
| 669 |
# Automake needs autoconf to update the timestamp on the configure script |
| 670 |
# whenever configure.ac or aclocal.m4 changes, even if the contents of the |
| 671 |
# configure script have not changed. |
| 672 |
AT_SETUP([autoconf: timestamp changes]) |
| 673 |
|
| 674 |
AT_DATA([aclocal.m4], |
| 675 |
[[AC_DEFUN([local_KILROY], [# kilroy was here |
| 676 |
]) |
| 677 |
]]) |
| 678 |
|
| 679 |
AT_DATA_AUTOCONF([configure.ac], |
| 680 |
[[AC_INIT |
| 681 |
AC_PROG_CC |
| 682 |
local_KILROY |
| 683 |
AC_OUTPUT |
| 684 |
]]) |
| 685 |
|
| 686 |
AT_CHECK_AUTOCONF |
| 687 |
|
| 688 |
cp configure configure.1 |
| 689 |
AT_MTIME_DELAY |
| 690 |
printf '%s\n' 'AC_LIBSOURCES([foo.c])dn@&t@l' >> configure.ac |
| 691 |
|
| 692 |
# This step must not use --force. |
| 693 |
# We don't need to check shell syntax, because if all goes well, |
| 694 |
# the script will be unchanged from what it was in the first autoconf |
| 695 |
# pass, and that was already checked. |
| 696 |
AT_CHECK_M4([autoconf]) |
| 697 |
AT_CHECK([cmp configure configure.1]) |
| 698 |
AT_CHECK([test configure -nt configure.1]) |
| 699 |
|
| 700 |
cp configure configure.2 |
| 701 |
AT_MTIME_DELAY |
| 702 |
printf '%s\n' \ |
| 703 |
'AC_DEFUN([unused_MACRO], [# bob was there too' \ |
| 704 |
'])' >> aclocal.m4 |
| 705 |
|
| 706 |
# Same as above. |
| 707 |
AT_CHECK_M4([autoconf]) |
| 708 |
AT_CHECK([cmp configure configure.2]) |
| 709 |
AT_CHECK([test configure -nt configure.2]) |
| 710 |
|
| 711 |
AT_CLEANUP |
| 712 |
|
| 713 |
|
| 714 |
## --------- ## |
| 715 |
## ifnames. ## |
| 716 |
## --------- ## |
| 717 |
|
| 718 |
AT_SETUP([ifnames]) |
| 719 |
|
| 720 |
AT_DATA([iftest1.c], |
| 721 |
[[#ifdef DEF1 |
| 722 |
#ifndef DEF2 |
| 723 |
#if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */ |
| 724 |
# if SPACES |
| 725 |
# if TABS |
| 726 |
/* #if C_COMMENTS */ |
| 727 |
// #if CXX_COMMENTS |
| 728 |
#if LINE1 = \ |
| 729 |
LINE2 |
| 730 |
#if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */ |
| 731 |
]]) |
| 732 |
|
| 733 |
AT_DATA([iftest2.c], |
| 734 |
[[#ifdef IFTEST2 |
| 735 |
#elifdef IFTEST3 |
| 736 |
#elifndef IFTEST4 |
| 737 |
#if VAL1 |
| 738 |
]]) |
| 739 |
|
| 740 |
AT_CHECK([ifnames iftest1.c iftest2.c], 0, |
| 741 |
[DEF1 iftest1.c |
| 742 |
DEF2 iftest1.c |
| 743 |
DEF3 iftest1.c |
| 744 |
DEF4 iftest1.c |
| 745 |
IFTEST2 iftest2.c |
| 746 |
IFTEST3 iftest2.c |
| 747 |
IFTEST4 iftest2.c |
| 748 |
LINE1 iftest1.c |
| 749 |
LINE2 iftest1.c |
| 750 |
SPACES iftest1.c |
| 751 |
TABS iftest1.c |
| 752 |
VAL1 iftest1.c iftest2.c |
| 753 |
VAL2 iftest1.c |
| 754 |
VAL3 iftest1.c |
| 755 |
VAL4 iftest1.c |
| 756 |
], []) |
| 757 |
|
| 758 |
AT_CLEANUP |
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
## ------------ ## |
| 763 |
## autoheader. ## |
| 764 |
## ------------ ## |
| 765 |
|
| 766 |
# autoheader is intensively used in its modern form throughout this |
| 767 |
# test suite. But we also have to check that acconfig.h still works. |
| 768 |
# autoheader uses autoconf --trace, so traces first. |
| 769 |
|
| 770 |
AT_SETUP([autoheader]) |
| 771 |
|
| 772 |
AT_DATA([acconfig.h], |
| 773 |
[[/* Define this to whatever you want. */ |
| 774 |
#undef this |
| 775 |
]]) |
| 776 |
|
| 777 |
|
| 778 |
# 1. Check that 'acconfig.h' is still honored. |
| 779 |
AT_DATA([configure.ac], |
| 780 |
[[AC_INIT |
| 781 |
AC_CONFIG_HEADERS(config.h:config.hin) |
| 782 |
AC_DEFINE(this, "whatever you want.") |
| 783 |
]]) |
| 784 |
|
| 785 |
AT_CHECK_AUTOHEADER([], [this], [0], [], [ignore]) |
| 786 |
AT_CHECK([cat config.hin], 0, |
| 787 |
[[/* config.hin. Generated from configure.ac by autoheader. */ |
| 788 |
/* Define this to whatever you want. */ |
| 789 |
#undef this |
| 790 |
|
| 791 |
/* Define to the address where bug reports for this package should be sent. */ |
| 792 |
#undef PACKAGE_BUGREPORT |
| 793 |
|
| 794 |
/* Define to the full name of this package. */ |
| 795 |
#undef PACKAGE_NAME |
| 796 |
|
| 797 |
/* Define to the full name and version of this package. */ |
| 798 |
#undef PACKAGE_STRING |
| 799 |
|
| 800 |
/* Define to the one symbol short name of this package. */ |
| 801 |
#undef PACKAGE_TARNAME |
| 802 |
|
| 803 |
/* Define to the home page for this package. */ |
| 804 |
#undef PACKAGE_URL |
| 805 |
|
| 806 |
/* Define to the version of this package. */ |
| 807 |
#undef PACKAGE_VERSION |
| 808 |
]]) |
| 809 |
|
| 810 |
|
| 811 |
# 2. Check that missing templates are a fatal error. |
| 812 |
AT_DATA([configure.ac], |
| 813 |
[[AC_INIT |
| 814 |
AC_CONFIG_HEADERS(config.h:config.hin) |
| 815 |
AC_DEFINE(that, "whatever you want.") |
| 816 |
]]) |
| 817 |
|
| 818 |
# The test suite goes too fast for the cache timestamps... |
| 819 |
# Pass --force. |
| 820 |
AT_CHECK_AUTOHEADER([--force], [], [1], [], [ignore]) |
| 821 |
|
| 822 |
|
| 823 |
# 3. Check TOP and BOTTOM. |
| 824 |
AT_DATA([acconfig.h], |
| 825 |
[[/* Top from acconfig.h. */ |
| 826 |
@TOP@ |
| 827 |
/* Middle from acconfig.h. */ |
| 828 |
@BOTTOM@ |
| 829 |
/* Bottom from acconfig.h. */ |
| 830 |
]]) |
| 831 |
|
| 832 |
AT_DATA([configure.ac], |
| 833 |
[[AC_INIT |
| 834 |
AC_CONFIG_HEADERS(config.h:config.hin) |
| 835 |
AH_TOP([Top1 from configure.ac.]) |
| 836 |
AH_TOP([Top2 from configure.ac.]) |
| 837 |
AH_TOP([The Cat in a h@t.]) |
| 838 |
AH_VERBATIM([Middle], [Middle from configure.ac.]) |
| 839 |
AH_VERBATIM([Mouse], [The Mouse in a h@t.]) |
| 840 |
AH_BOTTOM([Bottom1 from configure.ac.]) |
| 841 |
AH_BOTTOM([Bottom2 from configure.ac.]) |
| 842 |
AH_BOTTOM([The Dog in a h@t.]) |
| 843 |
|
| 844 |
AC_DEFINE([ANT], [@], [The Ant in a h@t.]) |
| 845 |
]]) |
| 846 |
|
| 847 |
|
| 848 |
# Yes, that's right: the 'middle' part of 'acconfig.h' is still before |
| 849 |
# the AH_TOP part. But so what, you're not supposed to use the two |
| 850 |
# together. |
| 851 |
# Ignore STDERR which is the longish complaint against autoheader junk |
| 852 |
# files. |
| 853 |
AT_CHECK_AUTOHEADER([--force], [ANT], [], [], [ignore]) |
| 854 |
AT_CHECK([cat config.hin], 0, |
| 855 |
[[/* config.hin. Generated from configure.ac by autoheader. */ |
| 856 |
/* Top from acconfig.h. */ |
| 857 |
/* Middle from acconfig.h. */ |
| 858 |
|
| 859 |
Top1 from configure.ac. |
| 860 |
|
| 861 |
Top2 from configure.ac. |
| 862 |
|
| 863 |
The Cat in a h@t. |
| 864 |
|
| 865 |
/* The Ant in a h@t. */ |
| 866 |
#undef ANT |
| 867 |
|
| 868 |
Middle from configure.ac. |
| 869 |
|
| 870 |
The Mouse in a h@t. |
| 871 |
|
| 872 |
/* Define to the address where bug reports for this package should be sent. */ |
| 873 |
#undef PACKAGE_BUGREPORT |
| 874 |
|
| 875 |
/* Define to the full name of this package. */ |
| 876 |
#undef PACKAGE_NAME |
| 877 |
|
| 878 |
/* Define to the full name and version of this package. */ |
| 879 |
#undef PACKAGE_STRING |
| 880 |
|
| 881 |
/* Define to the one symbol short name of this package. */ |
| 882 |
#undef PACKAGE_TARNAME |
| 883 |
|
| 884 |
/* Define to the home page for this package. */ |
| 885 |
#undef PACKAGE_URL |
| 886 |
|
| 887 |
/* Define to the version of this package. */ |
| 888 |
#undef PACKAGE_VERSION |
| 889 |
|
| 890 |
Bottom1 from configure.ac. |
| 891 |
|
| 892 |
Bottom2 from configure.ac. |
| 893 |
|
| 894 |
The Dog in a h@t. |
| 895 |
/* Bottom from acconfig.h. */ |
| 896 |
]]) |
| 897 |
|
| 898 |
AT_CLEANUP |
| 899 |
|
| 900 |
|
| 901 |
# autoheader should see through m4 macros, just like autoconf |
| 902 |
# https://lists.gnu.org/archive/html/bug-autoconf/2009-06/msg00000.html |
| 903 |
AT_SETUP([autoheader and macros]) |
| 904 |
|
| 905 |
AT_DATA([configure.ac], |
| 906 |
[[AC_INIT |
| 907 |
AC_CONFIG_HEADERS([config.h]) |
| 908 |
m4_define([PETER], [SIMSALABIM]) |
| 909 |
m4_define([PAUL], [OPENSESAME]) |
| 910 |
AC_DEFINE([PETER], [10], [Peter's public info]) |
| 911 |
AC_DEFINE_UNQUOTED([PAUL], [`expr 4 + 6`], [Paul's public info]) |
| 912 |
AC_OUTPUT |
| 913 |
]]) |
| 914 |
|
| 915 |
AT_CHECK_AUTOCONF |
| 916 |
AT_CHECK_AUTOHEADER([], [OPENSESAME SIMSALABIM]) |
| 917 |
AT_CHECK([grep -c SIMSALABIM configure config.h.in], [0], |
| 918 |
[[configure:1 |
| 919 |
config.h.in:1 |
| 920 |
]]) |
| 921 |
AT_CHECK([grep -c OPENSESAME configure config.h.in], [0], |
| 922 |
[[configure:1 |
| 923 |
config.h.in:1 |
| 924 |
]]) |
| 925 |
AT_CHECK([grep -c PETER configure config.h.in], [1], |
| 926 |
[[configure:0 |
| 927 |
config.h.in:0 |
| 928 |
]]) |
| 929 |
AT_CHECK([grep -c PAUL configure config.h.in], [1], |
| 930 |
[[configure:0 |
| 931 |
config.h.in:0 |
| 932 |
]]) |
| 933 |
|
| 934 |
AT_CLEANUP |
| 935 |
|
| 936 |
|
| 937 |
# autoheader should take all config header inputs into account when |
| 938 |
# checking for missing templates. |
| 939 |
AT_SETUP([autoheader with multiple headers]) |
| 940 |
|
| 941 |
AT_DATA([config-extra.h.in], |
| 942 |
[[/* Define this to whatever you want. */ |
| 943 |
#undef HANNA |
| 944 |
]]) |
| 945 |
AT_DATA([configure.ac], |
| 946 |
[[AC_INIT |
| 947 |
AC_CONFIG_HEADERS([config.h config-extra.h]) |
| 948 |
AC_DEFINE([HANNA], ["Hanna"]) |
| 949 |
AC_DEFINE([SEAN], ["Sean"], [Sean's name]) |
| 950 |
AC_OUTPUT |
| 951 |
]]) |
| 952 |
|
| 953 |
AT_CHECK_AUTOCONF |
| 954 |
AT_CHECK_AUTOHEADER([], [SEAN]) |
| 955 |
AT_CHECK([grep HANNA configure], [0], [ignore], [ignore]) |
| 956 |
AT_CHECK([grep HANNA config.h.in], [1], [ignore], [ignore]) |
| 957 |
AT_CHECK([grep SEAN configure], [0], [ignore], [ignore]) |
| 958 |
AT_CHECK([grep SEAN config.h.in], [0], [ignore], [ignore]) |
| 959 |
|
| 960 |
AT_CLEANUP |
| 961 |
|
| 962 |
# autoheader should not clobber a hand-written config header template, |
| 963 |
# even if it is the only one. |
| 964 |
AT_SETUP([autoheader preserves a hand-written template]) |
| 965 |
|
| 966 |
AT_DATA([config.h.in], |
| 967 |
[[/* Define this to whatever you want. */ |
| 968 |
#undef HANNA |
| 969 |
]]) |
| 970 |
|
| 971 |
AT_DATA([configure.ac], |
| 972 |
[[AC_INIT |
| 973 |
AC_CONFIG_HEADERS([config.h]) |
| 974 |
AC_DEFINE([HANNA], ["Hanna"], [Define this however you want]) |
| 975 |
AC_DEFINE([SEAN], ["Sean"], [Sean's name]) |
| 976 |
AC_OUTPUT |
| 977 |
]]) |
| 978 |
|
| 979 |
AT_CHECK_AUTOCONF |
| 980 |
AT_CHECK([grep HANNA configure], [0], [ignore], [ignore]) |
| 981 |
AT_CHECK([grep SEAN configure], [0], [ignore], [ignore]) |
| 982 |
|
| 983 |
AT_CHECK_AUTOHEADER([-Wall], [ignore], [0], [], |
| 984 |
[autoheader: warning: config.h.in was not generated by autoheader |
| 985 |
autoheader: warning: leaving it alone (force update with --replace-handwritten) |
| 986 |
]) |
| 987 |
|
| 988 |
# autoreconf should not run autoheader either |
| 989 |
AT_CHECK([autoreconf]) |
| 990 |
|
| 991 |
AT_CHECK([grep Generated config.h.in], [1], [ignore], [ignore]) |
| 992 |
AT_CHECK([grep however config.h.in], [1], [ignore], [ignore]) |
| 993 |
AT_CHECK([grep whatever config.h.in], [0], [ignore], [ignore]) |
| 994 |
|
| 995 |
AT_CHECK([grep HANNA config.h.in], [0], [ignore], [ignore]) |
| 996 |
AT_CHECK([grep SEAN config.h.in], [1], [ignore], [ignore]) |
| 997 |
|
| 998 |
AT_CHECK_AUTOHEADER([-Wall --replace-handwritten], |
| 999 |
[HANNA SEAN], [0], [], []) |
| 1000 |
|
| 1001 |
AT_CHECK([grep Generated config.h.in], [0], [ignore], [ignore]) |
| 1002 |
AT_CHECK([grep however config.h.in], [0], [ignore], [ignore]) |
| 1003 |
AT_CHECK([grep whatever config.h.in], [1], [ignore], [ignore]) |
| 1004 |
|
| 1005 |
AT_CLEANUP |
| 1006 |
|
| 1007 |
|
| 1008 |
# autoheader _should_ update an empty template file. |
| 1009 |
AT_SETUP([autoheader updates an empty template]) |
| 1010 |
|
| 1011 |
AT_DATA([config.h.in], [[]]) |
| 1012 |
|
| 1013 |
AT_DATA([configure.ac], |
| 1014 |
[[AC_INIT |
| 1015 |
AC_CONFIG_HEADERS([config.h]) |
| 1016 |
AC_DEFINE([HANNA], ["Hanna"], [Define this however you want]) |
| 1017 |
AC_DEFINE([SEAN], ["Sean"], [Sean's name]) |
| 1018 |
AC_OUTPUT |
| 1019 |
]]) |
| 1020 |
|
| 1021 |
AT_CHECK_AUTOCONF |
| 1022 |
AT_CHECK([grep HANNA configure], [0], [ignore], [ignore]) |
| 1023 |
AT_CHECK([grep SEAN configure], [0], [ignore], [ignore]) |
| 1024 |
|
| 1025 |
AT_CHECK_AUTOHEADER([-Wall], [HANNA SEAN], [0], [], []) |
| 1026 |
|
| 1027 |
AT_CHECK([grep Generated config.h.in], [0], [ignore], [ignore]) |
| 1028 |
AT_CHECK([grep however config.h.in], [0], [ignore], [ignore]) |
| 1029 |
|
| 1030 |
AT_CLEANUP |
| 1031 |
|
| 1032 |
|
| 1033 |
## ------------ ## |
| 1034 |
## autoupdate. ## |
| 1035 |
## ------------ ## |
| 1036 |
|
| 1037 |
# Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated. |
| 1038 |
AT_SETUP([autoupdate]) |
| 1039 |
|
| 1040 |
AT_DATA([configure.ac], |
| 1041 |
[[AC_INIT(Test, 1.0) |
| 1042 |
AC_CANONICAL_SYSTEM |
| 1043 |
# The doc says 27 is a valid fubar. |
| 1044 |
fubar=27 |
| 1045 |
AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar) |
| 1046 |
]]) |
| 1047 |
|
| 1048 |
AT_DATA([expout], |
| 1049 |
[[AC_INIT([Test],[1.0]) |
| 1050 |
AC_CANONICAL_TARGET |
| 1051 |
# The doc says 27 is a valid fubar. |
| 1052 |
fubar=27 |
| 1053 |
AC_CONFIG_FILES([Makefile]) |
| 1054 |
AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar]) |
| 1055 |
AC_OUTPUT |
| 1056 |
]]) |
| 1057 |
|
| 1058 |
# Checking 'autoupdate'. |
| 1059 |
AT_CHECK_AUTOUPDATE |
| 1060 |
AT_CHECK([cat configure.ac], 0, [expout]) |
| 1061 |
# Checking that 'autoupdate' is idempotent |
| 1062 |
AT_CHECK_AUTOUPDATE |
| 1063 |
AT_CHECK([cat configure.ac], 0, [expout]) |
| 1064 |
|
| 1065 |
AT_CLEANUP |
| 1066 |
|
| 1067 |
|
| 1068 |
# autoupdating AC_LINK_FILES |
| 1069 |
# -------------------------- |
| 1070 |
AT_SETUP([autoupdating AC_LINK_FILES]) |
| 1071 |
|
| 1072 |
AT_DATA([configure.ac], |
| 1073 |
[[AC_INIT |
| 1074 |
AC_LINK_FILES(dst1 dst2, src1 src2) |
| 1075 |
AC_OUTPUT |
| 1076 |
]]) |
| 1077 |
|
| 1078 |
AT_DATA([dst1], dst1 |
| 1079 |
) |
| 1080 |
AT_DATA([dst2], dst2 |
| 1081 |
) |
| 1082 |
|
| 1083 |
# Checking 'autoupdate'. |
| 1084 |
AT_CHECK_AUTOUPDATE([], 0, [], ignore) |
| 1085 |
|
| 1086 |
# The replacement for AC_LINK_FILES includes a forced -Wobsolete |
| 1087 |
# warning, because it needs to be manually adjusted afterward. |
| 1088 |
# Look for it in the autoconf output. |
| 1089 |
AT_CHECK_AUTOCONF([], 0, [], stderr) |
| 1090 |
AT_CHECK([grep 'AC_LINK_FILES' stderr], 0, ignore, ignore) |
| 1091 |
AT_CHECK([grep 'AC_CONFIG_LINKS' stderr], 0, ignore, ignore) |
| 1092 |
AT_CHECK([grep 'warning: It is technically impossible' stderr], |
| 1093 |
0, ignore, ignore) |
| 1094 |
AT_CHECK([grep 'tune the result yourself' stderr], 0, ignore, ignore) |
| 1095 |
|
| 1096 |
AT_CHECK_CONFIGURE |
| 1097 |
AT_CHECK([cat src1], 0, [dst1 |
| 1098 |
]) |
| 1099 |
AT_CHECK([cat src2], 0, [dst2 |
| 1100 |
]) |
| 1101 |
|
| 1102 |
AT_CLEANUP |
| 1103 |
|
| 1104 |
|
| 1105 |
# autoupdating AC_PREREQ |
| 1106 |
# ---------------------- |
| 1107 |
AT_SETUP([autoupdating AC_PREREQ]) |
| 1108 |
|
| 1109 |
# Produce 'AC_PREREQ(<AUTOUPDATE VERSION>)'. |
| 1110 |
AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout]) |
| 1111 |
autoupdate_version=`cat stdout` |
| 1112 |
[echo "AC_PREREQ([$autoupdate_version])" >expout] |
| 1113 |
|
| 1114 |
AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -], |
| 1115 |
0, [expout], []) |
| 1116 |
|
| 1117 |
AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -], |
| 1118 |
0, [expout], []) |
| 1119 |
|
| 1120 |
AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -], |
| 1121 |
63, [], [ignore]) |
| 1122 |
|
| 1123 |
AT_CLEANUP |
| 1124 |
|
| 1125 |
|
| 1126 |
# autoupdating AU_ALIAS |
| 1127 |
# --------------------- |
| 1128 |
AT_SETUP([autoupdating AU_ALIAS]) |
| 1129 |
|
| 1130 |
AT_DATA([configure.ac], |
| 1131 |
[[AC_INIT |
| 1132 |
AC_DEFUN([FOO], [$#]) |
| 1133 |
AU_ALIAS([BAZ],[FOO]) |
| 1134 |
test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1 |
| 1135 |
AC_PROG_CC |
| 1136 |
AC_WORDS_BIGENDIAN |
| 1137 |
AC_CONFIG_HEADERS([config.h]) |
| 1138 |
AC_OUTPUT |
| 1139 |
]]) |
| 1140 |
|
| 1141 |
# Checking 'autoupdate'. |
| 1142 |
AT_CHECK_AUTOUPDATE |
| 1143 |
|
| 1144 |
# autoupdate does not replace AU_DEFUNs/AU_ALIASes defined by |
| 1145 |
# configure.ac itself, nor by aclocal.m4, so BAZ will still be present |
| 1146 |
# in the updated configure.ac. This is actually desirable for this |
| 1147 |
# test: the point of that part of the above configure.ac is to |
| 1148 |
# verify that the expansion of an AU_ALIAS definition handles $# |
| 1149 |
# correctly. If BAZ got turned into FOO by the above call to |
| 1150 |
# autoupdate, we would need to run autoconf and configure twice in |
| 1151 |
# this test. However, it does also mean that by default we get a |
| 1152 |
# -Wobsolete warning because of BAZ, so turn that off so it doesn't |
| 1153 |
# cause a spurious failure. |
| 1154 |
AT_CHECK_AUTOCONF([-Wno-obsolete]) |
| 1155 |
AT_CHECK_AUTOHEADER([-Wno-obsolete], [ |
| 1156 |
AC_APPLE_UNIVERSAL_BUILD |
| 1157 |
HAVE_INTTYPES_H |
| 1158 |
HAVE_STDINT_H |
| 1159 |
HAVE_STDIO_H |
| 1160 |
HAVE_STDLIB_H |
| 1161 |
HAVE_STRINGS_H |
| 1162 |
HAVE_STRING_H |
| 1163 |
HAVE_SYS_STAT_H |
| 1164 |
HAVE_SYS_TYPES_H |
| 1165 |
HAVE_UNISTD_H |
| 1166 |
STDC_HEADERS |
| 1167 |
WORDS_BIGENDIAN |
| 1168 |
]) |
| 1169 |
AT_CHECK_CONFIGURE |
| 1170 |
AT_CHECK([grep 'AC_C_BIGENDIAN[(]' configure.ac], 1, [ignore], [ignore]) |
| 1171 |
AT_CHECK([grep 'AC_C_BIGENDIAN' configure.ac], 0, [ignore], [ignore]) |
| 1172 |
|
| 1173 |
AT_CLEANUP |
| 1174 |
|
| 1175 |
|
| 1176 |
# autoupdating OLD to NEW |
| 1177 |
# ----------------------- |
| 1178 |
|
| 1179 |
# The example taken from the code comments. |
| 1180 |
AT_SETUP([autoupdating OLD to NEW]) |
| 1181 |
|
| 1182 |
AT_DATA([aclocal.m4], |
| 1183 |
[[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))]) |
| 1184 |
AC_DEFUN([NEW], [echo "sum($1) = $2"]) |
| 1185 |
]]) |
| 1186 |
|
| 1187 |
AT_DATA([configure.ac], |
| 1188 |
[[AC_INIT |
| 1189 |
OLD(1, 2) |
| 1190 |
NEW([0, 0], [0]) |
| 1191 |
AC_OUTPUT |
| 1192 |
]]) |
| 1193 |
|
| 1194 |
# Checking 'autoupdate'. |
| 1195 |
AT_CHECK_AUTOUPDATE |
| 1196 |
AT_CHECK_AUTOCONF |
| 1197 |
AT_CHECK_CONFIGURE |
| 1198 |
AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore]) |
| 1199 |
AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore]) |
| 1200 |
|
| 1201 |
AT_CLEANUP |
| 1202 |
|
| 1203 |
|
| 1204 |
# autoupdating macros recursively |
| 1205 |
# ------------------------------- |
| 1206 |
|
| 1207 |
AT_SETUP([autoupdating macros recursively]) |
| 1208 |
|
| 1209 |
AT_XFAIL_IF([:]) |
| 1210 |
|
| 1211 |
AT_DATA([configure.ac], |
| 1212 |
[[AC_INIT |
| 1213 |
AC_PROG_CC |
| 1214 |
AC_TRY_COMPILE([], [choke me], [echo bogus1], |
| 1215 |
[AC_TRY_COMPILE([], [return 0;], [echo good], [echo bogus2])]) |
| 1216 |
AC_OUTPUT |
| 1217 |
]]) |
| 1218 |
|
| 1219 |
# Checking 'autoupdate'. |
| 1220 |
AT_CHECK_AUTOUPDATE |
| 1221 |
AT_CHECK([grep changequote configure.ac], [1]) |
| 1222 |
AT_CHECK([grep TRY_COMPILE configure.ac], [1]) |
| 1223 |
AT_CHECK_AUTOCONF |
| 1224 |
AT_CHECK_CONFIGURE |
| 1225 |
|
| 1226 |
AT_CLEANUP |
| 1227 |
|
| 1228 |
|
| 1229 |
# autoupdating AC_HELP_STRING |
| 1230 |
# --------------------------- |
| 1231 |
AT_SETUP([autoupdating AC_HELP_STRING]) |
| 1232 |
|
| 1233 |
AT_DATA([configure.ac], |
| 1234 |
[[AC_INIT |
| 1235 |
AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:]) |
| 1236 |
AC_OUTPUT |
| 1237 |
]]) |
| 1238 |
|
| 1239 |
# Checking 'autoupdate'. |
| 1240 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1241 |
AT_CHECK_AUTOCONF |
| 1242 |
AT_CHECK_CONFIGURE([], [], [], [ignore]) |
| 1243 |
AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore]) |
| 1244 |
|
| 1245 |
AT_CLEANUP |
| 1246 |
|
| 1247 |
|
| 1248 |
# autoupdating with m4sugar |
| 1249 |
# ------------------------- |
| 1250 |
AT_SETUP([autoupdating with m4sugar]) |
| 1251 |
|
| 1252 |
AT_DATA([aclocal.m4], |
| 1253 |
[[AU_DEFUN([OLD], |
| 1254 |
[m4@&t@_pushdef([foo], [bar])dn@&t@l |
| 1255 |
echo "foo $1 foo" |
| 1256 |
m4@&t@_popdef([foo])dn@&t@l |
| 1257 |
]) |
| 1258 |
]]) |
| 1259 |
|
| 1260 |
touch foo.in |
| 1261 |
|
| 1262 |
AT_DATA([configure.ac], |
| 1263 |
[[AC_PREREQ(2.54) |
| 1264 |
m4_define([gnumeric_version_epoch], [1]) |
| 1265 |
AC_INIT |
| 1266 |
OLD([ bla bla ]) |
| 1267 |
AC_FOREACH([name], [n1 n2], |
| 1268 |
[echo name |
| 1269 |
]) |
| 1270 |
AC_CHECKING([for feature]) |
| 1271 |
AC_MSG_RESULT_UNQUOTED([`echo done`]) |
| 1272 |
|
| 1273 |
AC_OUTPUT([foo]) |
| 1274 |
]]) |
| 1275 |
|
| 1276 |
# Checking 'autoupdate'. |
| 1277 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1278 |
AT_CHECK_AUTOCONF |
| 1279 |
AT_CHECK_CONFIGURE([], [], [], [ignore]) |
| 1280 |
|
| 1281 |
AT_CLEANUP |
| 1282 |
|
| 1283 |
|
| 1284 |
# autoupdating with m4_pushdef |
| 1285 |
# ---------------------------- |
| 1286 |
AT_SETUP([autoupdating with m4@&t@_pushdef]) |
| 1287 |
|
| 1288 |
AT_XFAIL_IF([:]) |
| 1289 |
|
| 1290 |
touch foo.in |
| 1291 |
AT_DATA([configure.ac], |
| 1292 |
[[AC_INIT |
| 1293 |
AC_PROG_CC |
| 1294 |
# temporarily override this macro |
| 1295 |
m4@&t@_pushdef([AC_MSG_RESULT_UNQUOTED], [:]) |
| 1296 |
AC_C_BIGENDIAN |
| 1297 |
m4@&t@_popdef([AC_MSG_RESULT_UNQUOTED]) |
| 1298 |
AC_OUTPUT |
| 1299 |
]]) |
| 1300 |
|
| 1301 |
# Checking 'autoupdate'. |
| 1302 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1303 |
AT_CHECK([grep changequote configure.ac], [1]) |
| 1304 |
AT_CHECK([grep [pushdef.*AC_MSG_RESULT_UNQUOTED] configure.ac], [0], [ignore]) |
| 1305 |
AT_CHECK_AUTOCONF |
| 1306 |
AT_CHECK_CONFIGURE([], [], [], [ignore]) |
| 1307 |
|
| 1308 |
AT_CLEANUP |
| 1309 |
|
| 1310 |
|
| 1311 |
# autoupdating with AC_REQUIRE |
| 1312 |
# ---------------------------- |
| 1313 |
AT_SETUP([autoupdating with AC_REQUIRE]) |
| 1314 |
|
| 1315 |
AT_XFAIL_IF([:]) |
| 1316 |
|
| 1317 |
AT_DATA([configure.ac], |
| 1318 |
[[AC_DEFUN([MACRO], |
| 1319 |
[AC_REQUIRE([AC_DECL_SYS_SIGLIST]) |
| 1320 |
AC_CHECK_DECLS([_sys_siglist], [], [], [#include <signal.h>]) |
| 1321 |
]) |
| 1322 |
|
| 1323 |
AC_INIT |
| 1324 |
MACRO |
| 1325 |
AC_OUTPUT |
| 1326 |
]]) |
| 1327 |
|
| 1328 |
# Checking 'autoupdate'. |
| 1329 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1330 |
AT_CHECK_AUTOCONF |
| 1331 |
AT_CHECK_CONFIGURE([], [], [], [ignore]) |
| 1332 |
|
| 1333 |
AT_CLEANUP |
| 1334 |
|
| 1335 |
|
| 1336 |
# autoupdating with complex quoting |
| 1337 |
# --------------------------------- |
| 1338 |
AT_SETUP([autoupdating with complex quoting]) |
| 1339 |
|
| 1340 |
AT_XFAIL_IF([:]) |
| 1341 |
|
| 1342 |
AT_DATA([configure.ac], |
| 1343 |
[[m4_define([MACRO], |
| 1344 |
[[#define STRING "hello, world\n" |
| 1345 |
]]) |
| 1346 |
|
| 1347 |
AC_INIT |
| 1348 |
AC_TRY_COMPILE([#include <stdio.h> |
| 1349 |
]MACRO[], [printf (STRING);], |
| 1350 |
[], [AS_EXIT([1])]) |
| 1351 |
AC_OUTPUT |
| 1352 |
]]) |
| 1353 |
|
| 1354 |
# Checking 'autoupdate'. |
| 1355 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1356 |
AT_CHECK_AUTOCONF |
| 1357 |
AT_CHECK([grep MACRO configure], [1]) |
| 1358 |
AT_CHECK_CONFIGURE([], [], [], [ignore]) |
| 1359 |
|
| 1360 |
AT_CLEANUP |
| 1361 |
|
| 1362 |
|
| 1363 |
# autoupdating AC_LANG_SAVE |
| 1364 |
# ------------------------- |
| 1365 |
AT_SETUP([autoupdating AC_LANG_SAVE]) |
| 1366 |
|
| 1367 |
AT_DATA([configure.ac], |
| 1368 |
[[AC_INIT |
| 1369 |
AC_LANG_SAVE |
| 1370 |
AC_LANG_RESTORE |
| 1371 |
AC_LANG_SAVE |
| 1372 |
AC_LANG_RESTORE |
| 1373 |
AC_OUTPUT |
| 1374 |
]]) |
| 1375 |
|
| 1376 |
# Checking 'autoupdate'. |
| 1377 |
|
| 1378 |
# Both the autoupdate and autoconf invocations will complain about |
| 1379 |
# AC_LANG_SAVE being obsolete, because autoupdate cannot replace |
| 1380 |
# two-macro sequences (e.g. AC_LANG_SAVE \n AC_LANG([C]) ideally would |
| 1381 |
# become AC_LANG_PUSH([C]) but we can't do that) so an m4_warn |
| 1382 |
# is left in place to remind people they need to do some hand edits. |
| 1383 |
# Ignore these diagnostics. |
| 1384 |
AT_CHECK_AUTOUPDATE([], [], [], [ignore]) |
| 1385 |
AT_CHECK_AUTOCONF([], [], [], [ignore]) |
| 1386 |
AT_CHECK_CONFIGURE |
| 1387 |
|
| 1388 |
AT_CLEANUP |
| 1389 |
|
| 1390 |
|
| 1391 |
# autoupdating AC_FOREACH |
| 1392 |
# ----------------------- |
| 1393 |
AT_SETUP([autoupdating AC_FOREACH]) |
| 1394 |
|
| 1395 |
AT_DATA([aclocal.m4], |
| 1396 |
[[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])]) |
| 1397 |
]]) |
| 1398 |
|
| 1399 |
AT_DATA([configure.ac], |
| 1400 |
[[AC_INIT |
| 1401 |
echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD |
| 1402 |
AC_OUTPUT |
| 1403 |
]]) |
| 1404 |
|
| 1405 |
# Checking 'autoupdate'. |
| 1406 |
# AC_FOREACH is replaced with an m4sugar macro, so we must make sure |
| 1407 |
# the m4sugar macro wasn't expanded. |
| 1408 |
AT_CHECK_AUTOUPDATE |
| 1409 |
AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore]) |
| 1410 |
AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore]) |
| 1411 |
AT_CHECK([[grep "echo ' 1'' 2'' 3'' 4'' 5'' 6'" configure.ac]], 1, |
| 1412 |
[ignore], [ignore]) |
| 1413 |
AT_CHECK_AUTOCONF |
| 1414 |
AT_CHECK_CONFIGURE([], [0], [stdout]) |
| 1415 |
AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore]) |
| 1416 |
|
| 1417 |
AT_CLEANUP |
| 1418 |
|
| 1419 |
# autoupdating AC_OBSOLETE |
| 1420 |
# ------------------------ |
| 1421 |
AT_SETUP([autoupdating AC_OBSOLETE]) |
| 1422 |
|
| 1423 |
AT_DATA([aclocal.m4], |
| 1424 |
[[AC_DEFUN([OLD], |
| 1425 |
[AC_OBSOLETE([$0], [; convert to NEW]) |
| 1426 |
NEW([$2], [$1])]) |
| 1427 |
AC_DEFUN([NEW], |
| 1428 |
[AS@&t@_ECHO(["dst=$1 src=$2"])]) |
| 1429 |
]]) |
| 1430 |
|
| 1431 |
AT_DATA([configure.ac], |
| 1432 |
[[AC_INIT |
| 1433 |
OLD([src], [dst]) |
| 1434 |
AC_OUTPUT |
| 1435 |
]]) |
| 1436 |
|
| 1437 |
AT_CHECK_AUTOCONF([-Werror], 1, [], |
| 1438 |
[[configure.ac:2: warning: OLD is obsolete; convert to NEW |
| 1439 |
general.m4: AC_OBSOLETE is expanded from... |
| 1440 |
aclocal.m4:1: OLD is expanded from... |
| 1441 |
configure.ac:2: the top level |
| 1442 |
configure.ac:2: warning: The macro 'AC_OBSOLETE' is obsolete. |
| 1443 |
configure.ac:2: You should run autoupdate. |
| 1444 |
general.m4: AC_OBSOLETE is expanded from... |
| 1445 |
aclocal.m4:1: OLD is expanded from... |
| 1446 |
configure.ac:2: the top level |
| 1447 |
]]) |
| 1448 |
|
| 1449 |
# autoupdate does not know how to replace OLD with NEW |
| 1450 |
AT_CHECK_AUTOUPDATE |
| 1451 |
AT_CHECK([[grep OLD configure.ac]], 0, [ignore], [ignore]) |
| 1452 |
|
| 1453 |
# autoupdate _does_ know how to remove AC_OBSOLETE from aclocal.m4 |
| 1454 |
AT_CHECK_AUTOUPDATE([aclocal.m4], 0, [], |
| 1455 |
[[aclocal.m4:2: warning: if possible, define this macro using AU_DEFUN. |
| 1456 |
]]) |
| 1457 |
|
| 1458 |
# AC_OBSOLETE is replaced with an m4sugar macro, so we must make sure |
| 1459 |
# the m4sugar macro wasn't expanded. |
| 1460 |
AT_CHECK([[grep 'm4@&t@_warn' aclocal.m4]], 0, [ignore], [ignore]) |
| 1461 |
AT_CHECK([[grep 'if possible, define this' aclocal.m4]], 0, [ignore], [ignore]) |
| 1462 |
AT_CHECK([[grep 'AC_OBSOLETE(' aclocal.m4]], 1, [ignore], [ignore]) |
| 1463 |
|
| 1464 |
AT_CHECK_AUTOCONF([-Wobsolete -Wno-error], 0, [], |
| 1465 |
[[configure.ac:2: warning: if possible, define this macro using AU_DEFUN. |
| 1466 |
aclocal.m4:1: OLD is expanded from... |
| 1467 |
configure.ac:2: the top level |
| 1468 |
configure.ac:2: warning: OLD is obsolete; convert to NEW |
| 1469 |
aclocal.m4:1: OLD is expanded from... |
| 1470 |
configure.ac:2: the top level |
| 1471 |
]]) |
| 1472 |
|
| 1473 |
AT_CHECK_CONFIGURE([], 0, |
| 1474 |
[[dst=dst src=src |
| 1475 |
configure: creating ./config.status |
| 1476 |
]]) |
| 1477 |
|
| 1478 |
AT_CLEANUP |
| 1479 |
|
| 1480 |
|
| 1481 |
# autoupdating AC_DIAGNOSE and AC_WARNING |
| 1482 |
----------------------------------------- |
| 1483 |
AT_SETUP([autoupdating AC_DIAGNOSE and AC_WARNING]) |
| 1484 |
|
| 1485 |
AT_DATA([configure.ac], |
| 1486 |
[[AC_INIT |
| 1487 |
AC_DIAGNOSE([gnu], [The gnu has escaped]) |
| 1488 |
AC_WARNING([funny punctu&tion]) |
| 1489 |
AC_OUTPUT |
| 1490 |
]]) |
| 1491 |
|
| 1492 |
# Checking 'autoupdate'. |
| 1493 |
# AC_DIAGNOSE and AC_WARNING are replaced with m4sugar macros, so we |
| 1494 |
# must make sure the m4sugar macros weren't expanded. |
| 1495 |
AT_CHECK_AUTOUPDATE |
| 1496 |
AT_CHECK([[grep 'm4@&t@_warn' configure.ac]], 0, [ignore], [ignore]) |
| 1497 |
AT_CHECK([[grep 'The gnu has escaped' configure.ac]], 0, [ignore], [ignore]) |
| 1498 |
AT_CHECK([[grep 'funny punctu&tion' configure.ac]], 0, [ignore], [ignore]) |
| 1499 |
|
| 1500 |
# The diagnostics should appear when autoconf is run. |
| 1501 |
AT_CHECK_AUTOCONF([-Wall], [0], [], |
| 1502 |
[[configure.ac:2: warning: The gnu has escaped |
| 1503 |
configure.ac:3: warning: funny punctu&tion |
| 1504 |
]]) |
| 1505 |
AT_CHECK_CONFIGURE |
| 1506 |
|
| 1507 |
AT_CLEANUP |
| 1508 |
|
| 1509 |
|
| 1510 |
# autoupdating AC_FATAL |
| 1511 |
----------------------- |
| 1512 |
AT_SETUP([autoupdating AC_FATAL]) |
| 1513 |
|
| 1514 |
AT_DATA([configure.ac], |
| 1515 |
[[AC_INIT |
| 1516 |
AC_FATAL([what did you do this time]) |
| 1517 |
AC_OUTPUT |
| 1518 |
]]) |
| 1519 |
|
| 1520 |
# Checking 'autoupdate'. |
| 1521 |
# AC_FATAL is replaced with a m4sugar macro, so we |
| 1522 |
# must make sure the m4sugar macro wasn't expanded. |
| 1523 |
AT_CHECK_AUTOUPDATE |
| 1524 |
AT_CHECK([[grep 'm4@&t@_fatal' configure.ac]], 0, [ignore], [ignore]) |
| 1525 |
AT_CHECK([[grep 'what did you do this time' configure.ac]], |
| 1526 |
0, [ignore], [ignore]) |
| 1527 |
|
| 1528 |
# The diagnostic should appear when autoconf is run. |
| 1529 |
AT_CHECK_AUTOCONF([-Wall], [1], [], |
| 1530 |
[[configure.ac:2: error: what did you do this time |
| 1531 |
configure.ac:2: the top level |
| 1532 |
autom4te: error: m4 failed with exit status: 1 |
| 1533 |
]]) |
| 1534 |
AT_CHECK([[test \! -f configure]]) |
| 1535 |
|
| 1536 |
AT_CLEANUP |
| 1537 |
|
| 1538 |
|
| 1539 |
# autoupdating with aclocal and m4_include |
| 1540 |
# ---------------------------------------- |
| 1541 |
AT_SETUP([autoupdating with aclocal and m4@&t@_include]) |
| 1542 |
|
| 1543 |
AT_REQUIRE_ACLOCAL |
| 1544 |
|
| 1545 |
mkdir m4 aclocal |
| 1546 |
AT_DATA([configure.ac], |
| 1547 |
[[AC_INIT(x,0) |
| 1548 |
AC_UNCHANGED_MACRO |
| 1549 |
AC_OLD_MACRO |
| 1550 |
AC_OUTPUT |
| 1551 |
]]) |
| 1552 |
AT_DATA([m4/stuff.m4], |
| 1553 |
[[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO]) |
| 1554 |
AC_DEFUN([AC_NEW_MACRO], [echo hi]) |
| 1555 |
AC_DEFUN([AC_UNCHANGED_MACRO], [echo one]) |
| 1556 |
]]) |
| 1557 |
cp m4/stuff.m4 aclocal/stuff.m4 |
| 1558 |
AT_CHECK([$ACLOCAL -I aclocal], [0], [ignore], [ignore]) |
| 1559 |
# Checking 'autoupdate'. |
| 1560 |
AT_CHECK_AUTOUPDATE |
| 1561 |
AT_CHECK([$ACLOCAL -I m4], [0], [ignore], [ignore]) |
| 1562 |
AT_CHECK_AUTOUPDATE |
| 1563 |
|
| 1564 |
AT_CLEANUP |
| 1565 |
|
| 1566 |
|
| 1567 |
# Keeping autom4te.cfg complete |
| 1568 |
# ----------------------------- |
| 1569 |
|
| 1570 |
AT_SETUP([autom4te preselections]) |
| 1571 |
|
| 1572 |
AT_REQUIRE_AUTOMAKE |
| 1573 |
AT_REQUIRE_ACLOCAL |
| 1574 |
|
| 1575 |
# This user configuration file will interfere with this test. |
| 1576 |
AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore]) |
| 1577 |
|
| 1578 |
AT_DATA([configure.ac], |
| 1579 |
[[AC_INIT(GNU foo, 1.0) |
| 1580 |
AM_INIT_AUTOMAKE |
| 1581 |
AC_CONFIG_FILES([Makefile]) |
| 1582 |
AC_OUTPUT |
| 1583 |
]]) |
| 1584 |
|
| 1585 |
AT_DATA([Makefile.am], |
| 1586 |
[[AUTOMAKE_OPTIONS = foreign |
| 1587 |
]]) |
| 1588 |
|
| 1589 |
AT_MTIME_DELAY |
| 1590 |
|
| 1591 |
# If Autoconf is too old, or the user has turned caching off, skip: |
| 1592 |
AT_CHECK([$ACLOCAL || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }], |
| 1593 |
[], [], [ignore]) |
| 1594 |
AT_CHECK([test -d autom4te.cache || exit 77]) |
| 1595 |
AT_CHECK([autoconf]) |
| 1596 |
|
| 1597 |
# On a file system with coarse timestamp resolution (1 or 2s), |
| 1598 |
# configure and autom4te's cache files can easily have equal |
| 1599 |
# timestamps, in which case autom4te will consider the cache |
| 1600 |
# to be stale. Ensure configure's timestamp is newer. |
| 1601 |
AT_MTIME_DELAY |
| 1602 |
touch configure |
| 1603 |
|
| 1604 |
# If this test fails due to missing entries in lib/autom4te.in, then |
| 1605 |
# comparing the old and new requests is a good place to start debugging: |
| 1606 |
sort autom4te.cache/requests >old-requests |
| 1607 |
|
| 1608 |
# if 'configure' is regenerated, we want it to be strictly newer, |
| 1609 |
# to catch the error consistently. |
| 1610 |
echo newer >newer |
| 1611 |
AT_MTIME_DELAY |
| 1612 |
|
| 1613 |
AT_CHECK([$ACLOCAL], [], [], [ignore]) |
| 1614 |
AT_CHECK([automake --no-force --add-missing], [], [], [ignore]) |
| 1615 |
AT_CHECK([autoconf]) |
| 1616 |
AT_CHECK([test "`find configure -newer newer`" = "" || |
| 1617 |
{ sort autom4te.cache/requests | diff old-requests -; exit 1; }], |
| 1618 |
[], [], [], |
| 1619 |
[extract_version=['s/^[^0-9]*\([0-9][^ ]*\).*/\1/;q'] |
| 1620 |
automake_version=`automake --version | sed "$extract_version"` |
| 1621 |
used_automake_version=`sed "$extract_version" "$abs_top_srcdir/Makefile.in"` |
| 1622 |
AT_CHECK([if test "$automake_version" = "$used_automake_version"; ]dnl |
| 1623 |
[then exit 1; else exit 77; fi])]) |
| 1624 |
AT_CLEANUP |
| 1625 |
|
| 1626 |
|
| 1627 |
# autom4te cache creation |
| 1628 |
# ----------------------- |
| 1629 |
# Ensure autom4te fails when it cannot create the cache directory |
| 1630 |
# or create files there. |
| 1631 |
AT_SETUP([autom4te cache creation]) |
| 1632 |
|
| 1633 |
AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore]) |
| 1634 |
|
| 1635 |
# Work in a subdirectory so autotest can scribble in the toplevel. |
| 1636 |
mkdir sub |
| 1637 |
chmod a-w sub |
| 1638 |
|
| 1639 |
AT_DATA([configure.ac], |
| 1640 |
[[AC_INIT |
| 1641 |
AC_OUTPUT |
| 1642 |
]]) |
| 1643 |
|
| 1644 |
AT_DATA([.autom4te.cfg], |
| 1645 |
[[begin-language: "Autoconf-without-aclocal-m4" |
| 1646 |
args: --cache=sub/autom4te.cache |
| 1647 |
end-language: "Autoconf-without-aclocal-m4" |
| 1648 |
]]) |
| 1649 |
|
| 1650 |
# Do not try this when we are root or on systems without permissions. |
| 1651 |
# A failed redirection may cause a status of 2 with FreeBSD sh. |
| 1652 |
AT_CHECK([(: > sub/some-file) || exit 1 && exit 77], 1, [ignore], [ignore]) |
| 1653 |
|
| 1654 |
# Failure to create cache directory due to access permissions. |
| 1655 |
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr]) |
| 1656 |
AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore]) |
| 1657 |
AT_CHECK([grep ': Permission denied' stderr], [0], [ignore]) |
| 1658 |
AT_CHECK([test -f configure], [1]) |
| 1659 |
|
| 1660 |
# Failure to create cache directory due to something else in the way. |
| 1661 |
chmod u+w sub |
| 1662 |
: > sub/autom4te.cache |
| 1663 |
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr]) |
| 1664 |
AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore]) |
| 1665 |
AT_CHECK([grep ': File exists' stderr], [0], [ignore]) |
| 1666 |
AT_CHECK([test -f configure], [1]) |
| 1667 |
|
| 1668 |
# This time, creation should succeed. |
| 1669 |
rm -f sub/autom4te.cache |
| 1670 |
AT_CHECK_AUTOCONF |
| 1671 |
AT_CHECK([test -d sub/autom4te.cache]) |
| 1672 |
|
| 1673 |
rm -f configure sub/autom4te.cache/* |
| 1674 |
chmod a-w sub/autom4te.cache |
| 1675 |
|
| 1676 |
# Failure to create a file in the cache directory. |
| 1677 |
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr]) |
| 1678 |
AT_CHECK([grep 'cannot open .*autom4te.cache' stderr], [0], [ignore]) |
| 1679 |
AT_CHECK([test -f configure], [1]) |
| 1680 |
|
| 1681 |
# If the directory already exists, that should be fine. |
| 1682 |
chmod u+w sub/autom4te.cache |
| 1683 |
AT_CHECK_AUTOCONF |
| 1684 |
|
| 1685 |
AT_CLEANUP |
| 1686 |
|
| 1687 |
|
| 1688 |
# autom4te cache locking |
| 1689 |
# ---------------------- |
| 1690 |
|
| 1691 |
AT_SETUP([autom4te cache locking]) |
| 1692 |
|
| 1693 |
# Expect this test to fail if Perl file locking does not work. |
| 1694 |
AT_XFAIL_IF([$PERL -I "$top_srcdir/lib" -e ' |
| 1695 |
use Autom4te::XFile; |
| 1696 |
my $fh = new Autom4te::XFile "lockfile", O_RDWR|O_CREAT; |
| 1697 |
flock ($fh, LOCK_EX) && exit 1; |
| 1698 |
']) |
| 1699 |
|
| 1700 |
# Cannot use AT_CHECK here, autotest internals could be messed up. |
| 1701 |
# This sleep is not because of file timestamps, it's to make the |
| 1702 |
# locks conflict. |
| 1703 |
(echo AC_INIT; sleep 2; echo) \ |
| 1704 |
| (autom4te --language=autoconf -o configure -; echo $? >&2 ) 2>errlog & |
| 1705 |
AT_CHECK([echo AC_INIT | autom4te --language=autoconf -o configure -]) |
| 1706 |
wait |
| 1707 |
|
| 1708 |
# Ignore additional output from shell verbose or xtrace mode. |
| 1709 |
AT_CHECK([grep 'cannot rename' errlog], [1]) |
| 1710 |
AT_CHECK([grep '^0$' errlog], [], [ignore]) |
| 1711 |
AT_CHECK_CONFIGURE |
| 1712 |
|
| 1713 |
AT_CLEANUP |
| 1714 |
|
| 1715 |
|
| 1716 |
# autotools and file names containing whitespace |
| 1717 |
# ---------------------------------------------- |
| 1718 |
|
| 1719 |
AT_SETUP([autotools and whitespace in file names]) |
| 1720 |
|
| 1721 |
AT_SUPPRESS_ACLOCAL |
| 1722 |
|
| 1723 |
x= |
| 1724 |
export x |
| 1725 |
rm -f a b |
| 1726 |
for funny in \ |
| 1727 |
'with funny '\'' $x & #! name ' \ |
| 1728 |
'with funny \ '\'' \'\'' " <a >b * ? name ' #" |
| 1729 |
do |
| 1730 |
funny=`func_sanitize_file_name "$funny"` |
| 1731 |
file=" file $funny" |
| 1732 |
dir=`func_sanitize_dir_name " dir $funny"` |
| 1733 |
TMPDIR="./ tmp$dir" |
| 1734 |
export TMPDIR |
| 1735 |
|
| 1736 |
# skip if we cannot create such a file or directory |
| 1737 |
AT_CHECK([mkdir "$dir" "$TMPDIR" && touch "$file.ac" || exit 77]) |
| 1738 |
|
| 1739 |
cat >"$file.ac" <<'END' |
| 1740 |
[AC_INIT(x,0) |
| 1741 |
m4@&t@_include([foo.m4]) |
| 1742 |
AC_CONFIG_HEADERS([config.h:config.hin]) |
| 1743 |
AC_MACRO |
| 1744 |
AC_OUTPUT] |
| 1745 |
END |
| 1746 |
cat >"$dir"/foo.m4 <<'END' |
| 1747 |
[AC_DEFUN([AC_MACRO], [echo hi])] |
| 1748 |
END |
| 1749 |
|
| 1750 |
AT_CHECK_AUTOHEADER([-B "$dir" "$file.ac"]) |
| 1751 |
AT_CHECK_AUTOHEADER([--force -I "$dir" "$file.ac"]) |
| 1752 |
AT_CHECK_AUTOUPDATE([-B "$dir" "$file.ac"]) |
| 1753 |
AT_CHECK_AUTOUPDATE([--force -I "$dir" "$file.ac"]) |
| 1754 |
AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.ac"], [], [ignore]) |
| 1755 |
AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.ac"]) |
| 1756 |
AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.ac"]) |
| 1757 |
# In autoconf, these exercise a slightly different code path: |
| 1758 |
AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.ac"]) |
| 1759 |
AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.ac"]) |
| 1760 |
AT_CHECK([autoscan -B "$dir"], [], [], [ignore]) |
| 1761 |
AT_CHECK([autoscan --force -I "$dir"], [], [], [ignore]) |
| 1762 |
# autoreconf requires a sane input file name. |
| 1763 |
mv -f "$file.ac" configure.ac |
| 1764 |
AT_CHECK([autoreconf -B "$dir"]) |
| 1765 |
AT_CHECK([autoreconf --force -I "$dir"]) |
| 1766 |
|
| 1767 |
cat >"$file.c" <<'END' |
| 1768 |
#if FOO |
| 1769 |
#endif |
| 1770 |
END |
| 1771 |
AT_CHECK([ifnames "$file.c"], [], [ignore]) |
| 1772 |
|
| 1773 |
test ! -f b |
| 1774 |
done |
| 1775 |
|
| 1776 |
AT_CLEANUP |
| 1777 |
|
| 1778 |
# autotools and file names containing whitespace |
| 1779 |
# ---------------------------------------------- |
| 1780 |
|
| 1781 |
AT_SETUP([autotools and relative TMPDIR]) |
| 1782 |
|
| 1783 |
AT_REQUIRE_ACLOCAL |
| 1784 |
|
| 1785 |
mkdir _tmp |
| 1786 |
TMPDIR=_tmp |
| 1787 |
export TMPDIR |
| 1788 |
|
| 1789 |
AT_DATA([configure.ac], |
| 1790 |
[[AC_INIT(x,0) |
| 1791 |
AC_CONFIG_HEADERS([config.h:config.hin]) |
| 1792 |
AC_MACRO |
| 1793 |
AC_OUTPUT |
| 1794 |
]]) |
| 1795 |
|
| 1796 |
mkdir m4 |
| 1797 |
AT_DATA([m4/foo.m4], |
| 1798 |
[[AC_DEFUN([AC_MACRO], |
| 1799 |
[AC_DEFINE([HAVE_MACROS], 1, [Define if you have macros.])]) |
| 1800 |
]]) |
| 1801 |
|
| 1802 |
AT_CHECK([$ACLOCAL -I m4]) |
| 1803 |
AT_CHECK_AUTOHEADER([], [HAVE_MACROS]) |
| 1804 |
AT_CHECK_AUTOCONF |
| 1805 |
AT_CHECK_CONFIGURE |
| 1806 |
|
| 1807 |
AT_CLEANUP |