| 1 |
# -*- autoconf -*- |
| 2 |
|
| 3 |
AT_BANNER([[Testing config.status. |
| 4 |
|
| 5 |
## ---------------------------------------------------------------- ## |
| 6 |
## This section of torture tests is trying to make Autoconf produce ## |
| 7 |
## failing `configure' scripts, which must never happen. If one of ## |
| 8 |
## these tests ever fails, it is extremely important that you ## |
| 9 |
## report the failure to [email protected]. ## |
| 10 |
## ---------------------------------------------------------------- ##]]) |
| 11 |
|
| 12 |
|
| 13 |
## ------------ ## |
| 14 |
## AC_ARG_VAR. ## |
| 15 |
## ------------ ## |
| 16 |
|
| 17 |
# AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE) |
| 18 |
# ---------------------------------------------- |
| 19 |
# Check that AC_ARG_VAR caches the latest values, diagnoses |
| 20 |
# inconsistances, and arms config.status. |
| 21 |
m4_define([AT_CHECK_AC_ARG_VAR], |
| 22 |
[rm -f config.cache |
| 23 |
|
| 24 |
# Initial value. |
| 25 |
m4_ifval([$1], |
| 26 |
[precious='$1'; export precious], |
| 27 |
[unset precious]) |
| 28 |
AT_CHECK_CONFIGURE([--config-cache]) |
| 29 |
AT_CHECK([cat file], [], [`$1' |
| 30 |
]) |
| 31 |
|
| 32 |
# Testing --recheck. |
| 33 |
unset precious |
| 34 |
AT_CHECK([./config.status --recheck], [], [ignore]) |
| 35 |
AT_CHECK([./config.status], [], [ignore]) |
| 36 |
AT_CHECK([cat file], [], [`$1' |
| 37 |
]) |
| 38 |
|
| 39 |
# Second value. |
| 40 |
m4_ifval([$2], |
| 41 |
[precious='$2'; export precious], |
| 42 |
[unset precious]) |
| 43 |
AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore]) |
| 44 |
|
| 45 |
])# AT_CHECK_AC_ARG_VAR |
| 46 |
|
| 47 |
|
| 48 |
AT_SETUP([AC_ARG_VAR]) |
| 49 |
|
| 50 |
# We don't want to run this test if this shell doesn't support |
| 51 |
# `unset'. |
| 52 |
AT_CHECK([ |
| 53 |
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then |
| 54 |
exit 0 |
| 55 |
else |
| 56 |
exit 77 |
| 57 |
fi |
| 58 |
]) |
| 59 |
|
| 60 |
AT_DATA([configure.ac], |
| 61 |
[[AC_INIT |
| 62 |
AC_ARG_VAR([precious], [this variable costs a lot]) |
| 63 |
AC_OUTPUT(file) |
| 64 |
]]) |
| 65 |
|
| 66 |
AT_DATA([file.in], |
| 67 |
[[`@precious@' |
| 68 |
]]) |
| 69 |
|
| 70 |
AT_CHECK_AUTOCONF |
| 71 |
|
| 72 |
# Set a precious variable |
| 73 |
AT_CHECK_AC_ARG_VAR([], [apple of my eye]) |
| 74 |
|
| 75 |
# Unset a precious variable |
| 76 |
AT_CHECK_AC_ARG_VAR([apple of my eye], []) |
| 77 |
|
| 78 |
# Change a precious variable |
| 79 |
AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye]) |
| 80 |
|
| 81 |
AT_CLEANUP |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
## ---------------------------------------------- ## |
| 87 |
## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ## |
| 88 |
## ---------------------------------------------- ## |
| 89 |
|
| 90 |
AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]) |
| 91 |
|
| 92 |
AT_DATA(configure.ac, |
| 93 |
[[AC_INIT |
| 94 |
rm -rf header var-header file var-file link var-link command var-command |
| 95 |
echo 'OK' >input |
| 96 |
|
| 97 |
# Be sure to also stress the associated INIT-CMDS. |
| 98 |
case $what_to_test in |
| 99 |
header) |
| 100 |
AC_CONFIG_HEADERS(header:input);; |
| 101 |
var-header) |
| 102 |
AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);; |
| 103 |
|
| 104 |
file) |
| 105 |
AC_CONFIG_FILES(file:input);; |
| 106 |
var-file) |
| 107 |
AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);; |
| 108 |
|
| 109 |
command) |
| 110 |
AC_CONFIG_COMMANDS(command:input, |
| 111 |
[cp input command]);; |
| 112 |
var-command) |
| 113 |
AC_CONFIG_COMMANDS(var-command:$command_in, |
| 114 |
[cp $command_in var-command], [command_in=input]);; |
| 115 |
|
| 116 |
link) |
| 117 |
AC_CONFIG_LINKS(link:input);; |
| 118 |
var-link) |
| 119 |
AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);; |
| 120 |
esac |
| 121 |
AC_OUTPUT |
| 122 |
]]) |
| 123 |
|
| 124 |
AT_CHECK_AUTOCONF |
| 125 |
|
| 126 |
|
| 127 |
# AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command)) |
| 128 |
# ------------------------------------------------------------------ |
| 129 |
# Check that THING and var-THING (which uses variables in AC_CONFIG_THING) |
| 130 |
# are properly created, with the right content. |
| 131 |
# Use `grep OK' instead of a simple `cat' to avoid banners such as in |
| 132 |
# AC_CONFIG_HEADERS. |
| 133 |
m4_define([AT_CHECK_CONFIG_CREATION], |
| 134 |
[AT_CHECK_CONFIGURE([what_to_test=$1]) |
| 135 |
AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null], |
| 136 |
[ignore], [$1 |
| 137 |
]) |
| 138 |
AT_CHECK([grep OK $1], [], [OK |
| 139 |
]) |
| 140 |
|
| 141 |
AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create]) |
| 142 |
# config.status might be stupidly expecting data on stdin, if it's |
| 143 |
# really broken... |
| 144 |
AT_CHECK([./config.status var-$1 </dev/null], [], [ignore]) |
| 145 |
AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null], |
| 146 |
[ignore], [var-$1 |
| 147 |
]) |
| 148 |
AT_CHECK([grep OK var-$1], [], [OK |
| 149 |
]) |
| 150 |
])# AT_CHECK_CONFIG_CREATION |
| 151 |
|
| 152 |
|
| 153 |
# Create a file |
| 154 |
AT_CHECK_CONFIG_CREATION(file) |
| 155 |
|
| 156 |
# Create a header |
| 157 |
AT_CHECK_CONFIG_CREATION(header) |
| 158 |
|
| 159 |
# Execute a command |
| 160 |
AT_CHECK_CONFIG_CREATION(command) |
| 161 |
|
| 162 |
# Create a link |
| 163 |
AT_CHECK_CONFIG_CREATION(link) |
| 164 |
|
| 165 |
AT_CLEANUP(header file link commandvar-header var-file var-link var-command |
| 166 |
input) |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
## ------------------- ## |
| 171 |
## Missing templates. ## |
| 172 |
## ------------------- ## |
| 173 |
|
| 174 |
# Check that config.status detects missing input files |
| 175 |
AT_SETUP([Missing templates]) |
| 176 |
|
| 177 |
AT_DATA(configure.ac, |
| 178 |
[[AC_INIT |
| 179 |
AC_CONFIG_FILES([nonexistent]) |
| 180 |
AC_OUTPUT |
| 181 |
]]) |
| 182 |
|
| 183 |
AT_CHECK_AUTOCONF |
| 184 |
AT_CHECK_CONFIGURE([], [1], [], |
| 185 |
[[config.status: error: cannot find input file: nonexistent.in |
| 186 |
]]) |
| 187 |
# Make sure that the output file doesn't exist |
| 188 |
AT_CHECK([test -f nonexistent], 1) |
| 189 |
|
| 190 |
AT_CLEANUP |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
## ---------------------- ## |
| 196 |
## configure invocation. ## |
| 197 |
## ---------------------- ## |
| 198 |
|
| 199 |
# Check that `configure' and `config.status' honor their interface. |
| 200 |
# |
| 201 |
# We run `./configure one=val1 --enable-two=val2 --with-three=val3' |
| 202 |
# and verify that (i) `configure' correctly receives the arguments and |
| 203 |
# (ii) correctly passes them to `config.status', which we check by |
| 204 |
# running `config.status --recheck'. |
| 205 |
|
| 206 |
AT_SETUP([configure invocation]) |
| 207 |
|
| 208 |
AT_DATA(configure.ac, |
| 209 |
[[AC_INIT |
| 210 |
echo "result=$one$enable_two$with_three" |
| 211 |
AC_OUTPUT |
| 212 |
]]) |
| 213 |
|
| 214 |
AT_CHECK_AUTOCONF |
| 215 |
|
| 216 |
AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three | |
| 217 |
sed -n -e 's/^result=//p'], 0, |
| 218 |
[onetwothree |
| 219 |
]) |
| 220 |
AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0, |
| 221 |
[onetwothree |
| 222 |
]) |
| 223 |
|
| 224 |
AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"| |
| 225 |
sed -n -e 's/^result=//p'], 0, |
| 226 |
["'$ " ' $ "'$ |
| 227 |
]) |
| 228 |
AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0, |
| 229 |
["'$ " ' $ "'$ |
| 230 |
]) |
| 231 |
|
| 232 |
AT_CLEANUP(configure config.status config.log config.cache) |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
## -------------------------------------------- ## |
| 237 |
## Check that `#define' templates are honored. ## |
| 238 |
## -------------------------------------------- ## |
| 239 |
|
| 240 |
# Use various forms of `#define' templates, and make sure there are no |
| 241 |
# problems when a symbol is prefix of another. |
| 242 |
|
| 243 |
AT_SETUP([#define header templates]) |
| 244 |
|
| 245 |
AT_DATA([configure.ac], |
| 246 |
[[AC_INIT |
| 247 |
AC_CONFIG_HEADERS(config.h:config.hin) |
| 248 |
|
| 249 |
# I18n of dummy variables: their French translations. |
| 250 |
AC_DEFINE(foo, toto) |
| 251 |
AC_DEFINE(bar, tata) |
| 252 |
AC_DEFINE(baz, titi) |
| 253 |
AC_DEFINE(fubar, tutu) |
| 254 |
|
| 255 |
# Symbols which are prefixes of another. |
| 256 |
AC_DEFINE(a, A) |
| 257 |
AC_DEFINE(aaa, AAA) |
| 258 |
AC_DEFINE(aa, AA) |
| 259 |
AC_CONFIG_FILES(defs) |
| 260 |
|
| 261 |
# Things included in confdefs.h, but which make no sense in |
| 262 |
# config.h, nor in $DEFS. |
| 263 |
cat <<\EOF >>confdefs.h |
| 264 |
/* Hi Mum! Look, I'm doing C++! */ |
| 265 |
#ifdef __cplusplus |
| 266 |
void exit (int status); |
| 267 |
#endif |
| 268 |
EOF |
| 269 |
|
| 270 |
# In addition of config.h output a full DEFS |
| 271 |
AC_OUTPUT_MAKE_DEFS |
| 272 |
DEFS_SAVED=$DEFS |
| 273 |
AC_SUBST(DEFS_SAVED) |
| 274 |
AC_OUTPUT |
| 275 |
]]) |
| 276 |
|
| 277 |
AT_DATA([defs.in], |
| 278 |
[[@DEFS_SAVED@ |
| 279 |
]]) |
| 280 |
|
| 281 |
AT_DATA([config.hin], |
| 282 |
[[#define foo 0 |
| 283 |
# define bar bar |
| 284 |
# define baz "Archimedes was sinking in his baz" |
| 285 |
# define fubar tutu |
| 286 |
#define a B |
| 287 |
#define aa BB |
| 288 |
#define aaa BBB |
| 289 |
#undef a |
| 290 |
#undef aa |
| 291 |
#undef aaa |
| 292 |
]]) |
| 293 |
|
| 294 |
AT_CHECK_AUTOCONF |
| 295 |
AT_CHECK_CONFIGURE |
| 296 |
|
| 297 |
AT_DATA([expout], |
| 298 |
[[/* config.h. Generated automatically by configure. */ |
| 299 |
#define foo toto |
| 300 |
# define bar tata |
| 301 |
# define baz titi |
| 302 |
# define fubar tutu |
| 303 |
#define a A |
| 304 |
#define aa AA |
| 305 |
#define aaa AAA |
| 306 |
#define a A |
| 307 |
#define aa AA |
| 308 |
#define aaa AAA |
| 309 |
]]) |
| 310 |
AT_CHECK([cat config.h], 0, expout) |
| 311 |
|
| 312 |
# Check the value of DEFS. Note the leading space. |
| 313 |
AT_DATA([expout], |
| 314 |
[[-Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA] |
| 315 |
]) |
| 316 |
|
| 317 |
# Because we strip trailing spaces in `testsuite' we can't leave one in |
| 318 |
# expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS. |
| 319 |
AT_CHECK([sed -e 's/ $//' defs], 0, expout) |
| 320 |
|
| 321 |
AT_CLEANUP |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
## ------------------------- ## |
| 326 |
## Torturing config.status. ## |
| 327 |
## ------------------------- ## |
| 328 |
|
| 329 |
## Require 100 AC_DEFINE and AC_SUBST with a significantly big value. |
| 330 |
## This is mostly to check that Autoconf produces portable sed scripts |
| 331 |
## in config.status. sed is used to skip the first two lines |
| 332 |
## `Generated by...'. |
| 333 |
|
| 334 |
AT_SETUP([Torturing config.status]) |
| 335 |
|
| 336 |
dnl The value used as a big value for AC_DEFINE. |
| 337 |
dnl Don't use sh active chars here, below it is also used in a sh |
| 338 |
dnl assignment. |
| 339 |
m4_define([AT_BIG_VALUE], |
| 340 |
[This value should be long enough to torture the various limits of sed and other tools used by Autoconf.]) |
| 341 |
|
| 342 |
m4_define([AT_DESCRIPTION], |
| 343 |
[Define to a long string if your `Autoconf' works properly.]) |
| 344 |
|
| 345 |
|
| 346 |
# AT_DUMMY_VAR(NUMBER) |
| 347 |
# -------------------- |
| 348 |
# Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it |
| 349 |
# so that the check for user name space invasion does not complain |
| 350 |
# of the new variables defined. |
| 351 |
# |
| 352 |
# Note that you should not use the name ac_dummy, because it will be |
| 353 |
# turned into ac_uummy during the construction of config.status. Yes, |
| 354 |
# this is admittedly a bug, but it would be too hard to fix this. |
| 355 |
# There is really no point in AC_DEFINE a var named ac_d.*. |
| 356 |
m4_define([AT_DUMMY_VAR], |
| 357 |
[ac_Dummy_[]m4_patsubst([000$1], [.*\(...\)$], [\1])]) |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
AT_DATA([dummy.in], |
| 362 |
[m4_for([AT_Count], 1, 100, 1, |
| 363 |
[@AT_DUMMY_VAR(AT_Count)@ |
| 364 |
])]) |
| 365 |
|
| 366 |
|
| 367 |
# ------------ # |
| 368 |
# configure.ac # |
| 369 |
# ------------ # |
| 370 |
|
| 371 |
AT_DATA(configure.ac, |
| 372 |
dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and |
| 373 |
dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc. |
| 374 |
[[m4_define([AC_DUMMY_VAR],] |
| 375 |
m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]] |
| 376 |
|
| 377 |
[[m4_define([AC_DESCRIPTION],] |
| 378 |
m4_dquote(m4_defn([AT_DESCRIPTION]))[)]] |
| 379 |
|
| 380 |
[[m4_define([AC_BIG_VALUE],] |
| 381 |
m4_dquote(m4_defn([AT_BIG_VALUE]))[)]] |
| 382 |
|
| 383 |
[[# AC_DEFUBST(NAME) |
| 384 |
# ---------------- |
| 385 |
# Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is |
| 386 |
# used in the torture tests. |
| 387 |
m4_defun([AC_DEFUBST], |
| 388 |
[AC_DUMMY_VAR($1)="AC_BIG_VALUE" |
| 389 |
AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)", |
| 390 |
AC_DESCRIPTION) |
| 391 |
AC_SUBST(AC_DUMMY_VAR($1))]) |
| 392 |
|
| 393 |
AC_INIT |
| 394 |
AC_CONFIG_HEADERS(config.h:config.hin) |
| 395 |
AC_CONFIG_FILES(dummy) |
| 396 |
m4_for(AC_Count, 1, 100, 1, |
| 397 |
[AC_DEFUBST(AC_Count)]) |
| 398 |
AC_OUTPUT |
| 399 |
]])# configure.ac |
| 400 |
|
| 401 |
AT_CHECK_AUTOCONF |
| 402 |
AT_CHECK_AUTOHEADER |
| 403 |
AT_CHECK_CONFIGURE |
| 404 |
|
| 405 |
# Checking that AC_DEFINE worked properly. |
| 406 |
AT_DATA(expout, |
| 407 |
[m4_for(AT_Count, 1, 100, 1, |
| 408 |
[ |
| 409 |
/* AT_DESCRIPTION */ |
| 410 |
[#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE" |
| 411 |
])]) |
| 412 |
AT_CHECK([sed -n '3,$ p' config.h], 0, expout) |
| 413 |
|
| 414 |
# Checking that AC_SUBST worked properly. |
| 415 |
AT_DATA(expout, |
| 416 |
[m4_for(AT_Count, 1, 100, 1, |
| 417 |
[AT_BIG_VALUE |
| 418 |
])]) |
| 419 |
|
| 420 |
AT_CLEANUP(dummy) |
| 421 |
|
| 422 |
|
| 423 |
## -------- ## |
| 424 |
## srcdir. ## |
| 425 |
## -------- ## |
| 426 |
|
| 427 |
AT_SETUP([srcdir]) |
| 428 |
|
| 429 |
rm -rf at-dir |
| 430 |
mkdir at-dir |
| 431 |
: >at-dir/bar.in |
| 432 |
: >foo.in |
| 433 |
|
| 434 |
AT_DATA([configure.ac], |
| 435 |
[[AC_INIT |
| 436 |
|
| 437 |
AC_CONFIG_FILES([foo at-dir/bar]) |
| 438 |
|
| 439 |
AC_CONFIG_COMMANDS([report], |
| 440 |
[test -f $srcdir/configure.ac || |
| 441 |
AC_MSG_ERROR([cannot find $srcdir/configure.ac])], |
| 442 |
[srcdir=$srcdir]) |
| 443 |
|
| 444 |
AC_OUTPUT |
| 445 |
rm -rf foo at-dir/bar |
| 446 |
]]) |
| 447 |
|
| 448 |
AT_CHECK_AUTOCONF |
| 449 |
|
| 450 |
# In place. |
| 451 |
AT_CHECK([./configure], [], [ignore]) |
| 452 |
|
| 453 |
# Relative path. |
| 454 |
AT_CHECK([cd at-dir && ../configure], [], [ignore]) |
| 455 |
|
| 456 |
# Absolute path. |
| 457 |
at_here=`pwd` |
| 458 |
AT_CHECK([cd at-dir && $at_here/configure], [], [ignore]) |
| 459 |
|
| 460 |
AT_CLEANUP(at-dir foo.in foo) |
| 461 |
|
| 462 |
|
| 463 |
## ----------------- ## |
| 464 |
## Signal handling. ## |
| 465 |
## ----------------- ## |
| 466 |
|
| 467 |
AT_SETUP([Signal handling]) |
| 468 |
|
| 469 |
AT_DATA([configure.ac], |
| 470 |
[[AC_INIT |
| 471 |
kill -2 $$ |
| 472 |
exit 77 |
| 473 |
]]) |
| 474 |
|
| 475 |
AT_CHECK_AUTOCONF |
| 476 |
AT_CHECK_CONFIGURE([], 1, ignore, ignore) |
| 477 |
|
| 478 |
AT_CLEANUP |