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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734
|
# -*- Autotest -*-
AT_BANNER([Executables (autoheader, autoupdate...).])
# Copyright (C) 2000-2001, 2003-2004, 2006-2017, 2020-2023 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/>.
## ----------------------------- ##
## Syntax of the shell scripts. ##
## ----------------------------- ##
# We use '/bin/sh -n script' to check that there are no syntax errors
# in the scripts. Although incredible, there are /bin/sh that go into
# endless loops with '-n', e.g., SunOS's:
#
# $ uname -a
# SunOS ondine 4.1.3 2 sun4m unknown
# $ cat endless.sh
# while false
# do
# :
# done
# exit 0
# $ time sh endless.sh
# sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total
# $ time sh -nx endless.sh
# ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total
#
# So before using '/bin/sh -n' to check our scripts, we first check
# that '/bin/sh -n' is not broken to death.
AT_SETUP([Syntax of the shell scripts])
AT_CHECK([test "$SHELL_N" != none || exit 77])
# Specify the absolute name of the tool, as some shells don't honor PATH when
# running 'sh PROG'.
AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"])
AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"])
# These are not built, they are in the src tree.
AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"])
AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"])
AT_CLEANUP
## ---------------------------- ##
## Syntax of the Perl scripts. ##
## ---------------------------- ##
AT_SETUP([Syntax of the Perl scripts])
AT_CHECK_PERL_SYNTAX([autoconf])
AT_CHECK_PERL_SYNTAX([autoheader])
AT_CHECK_PERL_SYNTAX([autom4te])
AT_CHECK_PERL_SYNTAX([autoreconf])
AT_CHECK_PERL_SYNTAX([autoscan])
AT_CHECK_PERL_SYNTAX([autoupdate])
AT_CHECK_PERL_SYNTAX([ifnames])
AT_CLEANUP
## ------------------ ##
## autom4te's cache. ##
## ------------------ ##
AT_SETUP([autom4te cache])
AT_DATA_M4SUGAR([[script.4s]],
[[m4_include([foo])
]])
# Everything is OK.
touch foo
AT_CHECK_M4SUGAR
# We moved a file: it should fail
mkdir sub
mv foo sub
AT_CHECK_M4SUGAR([], [1], [],
[m4:script.4s:1: cannot open 'foo': No such file or directory
autom4te: error: m4 failed with exit status: 1
])
# But if we change the main file, then we should no longer complain of
# missing files.
AT_DATA_M4SUGAR([[script.4s]],
[[m4_include([sub/foo])
]])
AT_CHECK_M4SUGAR
AT_CLEANUP
# autom4te --force
# ----------------
AT_SETUP([autom4te --force])
AT_DATA([file.m4],
[[right
]])
AT_CHECK_AUTOM4TE([-o file file.m4])
# Create a file whose timestamp is in the future.
# (next year)-01-01 00:01 UTC should always be in the future,
# even on slow machines.
echo BAD >file
this_year=`TZ=UTC0 date +%Y`
AS_VAR_ARITH([next_year], [$this_year + 1])
TZ=UTC0 touch -t ${next_year}01010001 file
AT_CHECK_AUTOM4TE([--force -o file file.m4])
AT_CHECK([cat file], 0,
[[right
]])
AT_CLEANUP
# autom4te and file names containing whitespace
# ---------------------------------------------
AT_SETUP([autom4te and whitespace in file names])
x=
export x
rm -f a b
for funny in \
'with funny '\'' $x & #! name' \
'with funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
do
funny=`func_sanitize_file_name "$funny"`
file=" file $funny"
outfile="$file out "
dir=`func_sanitize_dir_name " dir $funny"`
cachedir=" cache$dir"
TMPDIR=" tmp$dir"
export TMPDIR
# skip if we cannot create such a file or directory
AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77])
cat >"$file" <<'END'
[m4@&t@_init[]m4@&t@_include(foo.m4)
m4@&t@_divert([])d@&t@nl
FOO]
END
cat >"$dir"/foo.m4 <<'END'
[m4@&t@_define([FOO], [bar])]
END
AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"])
AT_CHECK([cat "$outfile"], [],
[[bar
]])
rm -rf "$outfile" "$cachedir"
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"])
AT_CHECK([cat "$outfile"], [],
[[bar
]])
# This exercises a slightly different code path and will catch an open with
# trailing whitespace:
cat >"$file" <<'END'
[m4@&t@_init[]m4@&t@_include(foo.m4)
m4@&t@_pattern_forbid([^bar$])
m4@&t@_divert([])d@&t@nl
FOO]
END
rm -rf "$outfile" "$cachedir"
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"],
[1], [], [stderr])
AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore])
cat >"$file" <<'END'
[m4@&t@_init[]m4@&t@_include(foo.m4)
m4@&t@_divert([])d@&t@nl]
END
rm -rf "$file.m4f"
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"])
AT_CHECK([test -s "$file.m4f"])
# Check --reload-state
AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null])
test ! -f b
done
AT_CLEANUP
# autom4te --trace and unusual macro names
# ----------------------------------------
AT_SETUP([autom4te --trace and unusual macro names])
AT_DATA([file.m4],
[[
]])
AT_CHECK_AUTOM4TE([-t 'TR A CE' -t 'TR(A)CE' file.m4])
AT_CLEANUP
AT_SETUP([autom4te --trace and whitespace])
dnl line numbering differs between m4 1.4.6 and 1.4.13 if we don't
dnl go through a single line wrapper
AT_DATA_M4SUGAR([file.m4],
[[m4_define([foo], [m4_echo([ a
b c ], [\
d\
])])
foo
]])
AT_CHECK_AUTOM4TE([--language=m4sugar -t 'm4@&t@_echo' file.m4], [0],
[[file.m4:5:m4@&t@_echo: a b c :d
]])
AT_CLEANUP
## ------------------ ##
## autoconf --trace. ##
## ------------------ ##
# autoconf --trace: user macros
# -----------------------------
AT_SETUP([autoconf --trace: user macros])
AT_DATA([configure.ac],
[[m4_define([active], [ACTIVE])
m4_define([TRACE1], [TRACE2(m4_shift($@))])
m4_define([TRACE2], [[$2], $1])
# No arguments.
TRACE1
TRACE2
# With arguments, single line.
TRACE1(foo, @bar, @baz)
TRACE1(foo, TRACE1(bar, baz))
TRACE1(foo, active, baz)
TRACE1(foo, [active], TRACE1(active, [active]))
]])
# Several --traces.
AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
[[configure.ac:6:TRACE1:
configure.ac:6:TRACE2:
configure.ac:7:TRACE2:
configure.ac:10:TRACE1:foo:@bar:@baz
configure.ac:10:TRACE2:@bar:@baz
configure.ac:11:TRACE1:bar:baz
configure.ac:11:TRACE2:baz
configure.ac:11:TRACE1:foo::baz
configure.ac:11:TRACE2::baz
configure.ac:12:TRACE1:foo:ACTIVE:baz
configure.ac:12:TRACE2:ACTIVE:baz
configure.ac:13:TRACE1:ACTIVE:active
configure.ac:13:TRACE2:active
configure.ac:13:TRACE1:foo:active::ACTIVE
configure.ac:13:TRACE2:active::ACTIVE
]])
# Several line requests.
AT_CHECK_AUTOCONF([[-t TRACE1:'
[$1], [$2], [$3].']], 0,
[[
[], [], [].
[foo], [@bar], [@baz].
[bar], [baz], [].
[foo], [], [baz].
[foo], [ACTIVE], [baz].
[ACTIVE], [active], [].
[foo], [active], [].
]])
# ${sep}@.
AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
[[[]
[]
[@bar])===([@baz]
[baz]
[])===([baz]
[ACTIVE])===([baz]
[active]
[active])===([])===([ACTIVE]
]])
# Arguments spanning multiple lines.
AT_DATA([configure.ac],
[[m4_define([TRACE], [])
TRACE(foo
bar,
bar
foo)
]])
AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0,
[[foo bar:bar foo
]])
AT_CLEANUP
# autoconf --trace: builtins
# --------------------------
AT_SETUP([autoconf --trace: builtins])
AT_DATA([configure.ac],
[[define([active], [ACTIVE])
]])
AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
0,
[[configure.ac:1:define:active:ACTIVE
]])
# FIXME: Without '$1' the following test dies. Groumphf, once again to
# dive into obscure feature interaction...
# Note that using '-i' means we need the *.m4 files, not the *.m4f files,
# hence we need srcdir, not builddir.
AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
0,
[[active
]])
AT_CLEANUP
# autoconf --trace: AC_CONFIG_MACRO_DIRS
# --------------------------------------
AT_SETUP([autoconf --trace: AC_CONFIG_MACRO_DIRS])
AT_KEYWORDS([AC_CONFIG_MACRO_DIR AC_CONFIG_MACRO_DIR_TRACE])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_MACRO_DIR([dir1])
AC_CONFIG_MACRO_DIRS([dir2 dir3 \
dir4])
AC_CONFIG_MACRO_DIRS([dir5])
]])
# Legacy tracing
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR], 0,
[[configure.ac:2:AC_CONFIG_MACRO_DIR:dir1
]])
# Preferred tracing
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR_TRACE], 0,
[[configure.ac:2:AC_CONFIG_MACRO_DIR_TRACE:dir1
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir2
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir3
configure.ac:3:AC_CONFIG_MACRO_DIR_TRACE:dir4
configure.ac:5:AC_CONFIG_MACRO_DIR_TRACE:dir5
]])
# Legacy macro can only be used once
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_MACRO_DIR([dir1])
AC_CONFIG_MACRO_DIR([dir2])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF([], [1], [], [stderr])
AT_CHECK([grep 'error: AC_CONFIG_MACRO_DIR can only be used once' stderr],
[], [ignore])
# Legacy macro must be used first, if present
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_MACRO_DIRS([dir1])
AC_CONFIG_MACRO_DIR([dir2])
]])
AT_CHECK_AUTOCONF([], [1], [], [stderr])
AT_CHECK([grep 'error: AC_CONFIG_MACRO_DIR can only be used once' stderr],
[], [ignore])
# Only use the public macros
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_MACRO_DIR_TRACE([dir1])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:2: error: Do not invoke AC_CONFIG_MACRO_DIR_TRACE directly
configure.ac:2: the top level
autom4te: error: m4 failed with exit status: 1
]])
# Legacy macro use is not required, but still gets traced
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_MACRO_DIRS([dir1])
AC_CONFIG_MACRO_DIRS([dir2])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF([], [0], [], [])
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR], [0],
[[configure.ac:2:AC_CONFIG_MACRO_DIR:dir1
]])
AT_CLEANUP
## ---------------------------- ##
## autoconf: forbidden tokens. ##
## ---------------------------- ##
# autoconf: forbidden tokens, basic
# ---------------------------------
AT_SETUP([autoconf: forbidden tokens,[] basic])
AT_DATA_M4SH([configure.ac],
[[AS_INIT
m4_foo
_m4_bar
AS_FOO
_AS_BAR
[dnl]
]])
# This test needs autom4te's cache, in spite of any ~/.autom4te.cfg.
AT_DATA([.autom4te.cfg], [[
begin-language: "Autoconf"
args: --cache=autom4te.cache
end-language: "Autoconf"
begin-language: "Autoconf-without-aclocal-m4"
args: --cache=autom4te.cache
end-language: "Autoconf-without-aclocal-m4"
]])
AT_MTIME_DELAY
AT_CHECK_AUTOCONF([], 1, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
configure.ac:2: error: possibly undefined macro: m4@&t@_foo
If this token and others are legitimate, please use m4@&t@_pattern_allow.
See the Autoconf documentation.
configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
configure.ac:6: error: possibly undefined macro: d@&t@nl
]])
# On a file system with coarse timestamp resolution (1 or 2s),
# configure and autom4te's cache files can easily have equal
# timestamps, in which case autom4te will consider the cache
# to be stale. Ensure configure's timestamp is newer.
AT_MTIME_DELAY
touch configure
# Since warnings are replicated from the cache but "possibly undefined
# macro" errors are not, a second run, without --force, should succeed
# and should yield only the warnings about AC_INIT and AC_OUTPUT.
AT_CHECK_M4([autoconf], 0, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
]])
AT_CLEANUP
# autoconf: forbidden tokens, exceptions
# --------------------------------------
AT_SETUP([autoconf: forbidden tokens,[] exceptions])
AT_DATA_M4SH([configure.ac],
[[AS_INIT
# This is allowed in spite of the name.
# It is on purpose that we check the case where there are several
# tokens on the same line.
m4_pattern_allow([^AS_ALLOWED$])
NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
# Test forbidding.
m4_pattern_forbid([^FORBIDDEN$])
NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
# Test Autoconf's patterns.
AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
# This is legal, although there is 'AS_DEFINE' in there.
BAS_DEFINE
# AS_THIS_IS_A_COMMENT so just shut up.
It would be very bad if Autoconf forgot to expand [AS_]INIT!
]])
AT_CHECK_AUTOCONF([], 1, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
If this token and others are legitimate, please use m4@&t@_pattern_allow.
See the Autoconf documentation.
configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
configure.ac:10: error: possibly undefined macro: FORBIDDEN
configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
]])
AT_CLEANUP
# autoconf: automatically allowed tokens
# --------------------------------------
AT_SETUP([autoconf: automatically allowed tokens])
AT_DATA_M4SH([configure.ac],
[[AC_INIT
m4_pattern_forbid([^FB_])
AC_DEFINE([FB_ONE])
AC_SUBST([FB_TWO])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CLEANUP
# autoconf: do not forbid the empty token
# ---------------------------------------
AT_SETUP([autoconf: the empty token])
AT_DATA_M4SH([configure.ac],
[[m4_init[]m4_pattern_allow([^foo$])
m4_divert([])dnl
line that begins with a space
]])
AT_CHECK_AUTOCONF([], 0, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
]])
AT_CLEANUP
# autoconf: subdirectories
# ------------------------
AT_SETUP([autoconf: subdirectories])
AT_DATA([configure.ac],
[[AC_INIT
AC_PROG_MKDIR_P
AC_CONFIG_FILES(sub/foo)
AC_OUTPUT
]])
mkdir sub
AT_DATA([sub/foo.in],
[[@MKDIR_P@
]])
AT_DATA([install-sh])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
AT_CLEANUP
# autoconf: input from stdin
# --------------------------
AT_SETUP([autoconf: input from stdin])
# Past Autoconf versions failed to read from stdin when other, non-frozen input
# files were present.
AT_DATA([aclocal.m4])
AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org
])
AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org
])
AT_CLEANUP
# autoconf: AC_AUTOCONF_VERSION
# -----------------------------
AT_SETUP([autoconf: AC_AUTOCONF_VERSION])
AT_DATA([configure.ac],
[[AC_INIT
version m4@&t@_defn([AC_AUTOCONF_VERSION]) version
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]],
0, [ignore])
AT_CLEANUP
# autoconf: AC_PRESERVE_HELP_ORDER
# --------------------------------
AT_SETUP([autoconf: AC_PRESERVE_HELP_ORDER])
AT_KEYWORDS([m4@&t@_divert_text])
AT_DATA_AUTOCONF([configure.ac],
[[AC_INIT
AC_PRESERVE_HELP_ORDER
AC_ARG_WITH([one], [ --with-one])
AC_ARG_ENABLE([two], [ --enable-two])
m4_divert_text([HELP_ENABLE], [arbitrary $text])
AC_ARG_WITH([three], [ --with-three])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([--help], [], [stdout])
AT_CHECK([sed -n '/^Optional/,/^$/p' stdout], [],
[[Optional Features and Packages:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-one
--enable-two
arbitrary $text
--with-three
]])
AT_CLEANUP
# autoconf: timestamp changes
# ---------------------------
# Automake needs autoconf to update the timestamp on the configure script
# whenever configure.ac or aclocal.m4 changes, even if the contents of the
# configure script have not changed.
AT_SETUP([autoconf: timestamp changes])
AT_DATA([aclocal.m4],
[[AC_DEFUN([local_KILROY], [# kilroy was here
])
]])
AT_DATA_AUTOCONF([configure.ac],
[[AC_INIT
AC_PROG_CC
local_KILROY
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
cp configure configure.1
AT_MTIME_DELAY
printf '%s\n' 'AC_LIBSOURCES([foo.c])dn@&t@l' >> configure.ac
# This step must not use --force.
# We don't need to check shell syntax, because if all goes well,
# the script will be unchanged from what it was in the first autoconf
# pass, and that was already checked.
AT_CHECK_M4([autoconf])
AT_CHECK([cmp configure configure.1])
AT_CHECK([test configure -nt configure.1])
cp configure configure.2
AT_MTIME_DELAY
printf '%s\n' \
'AC_DEFUN([unused_MACRO], [# bob was there too' \
'])' >> aclocal.m4
# Same as above.
AT_CHECK_M4([autoconf])
AT_CHECK([cmp configure configure.2])
AT_CHECK([test configure -nt configure.2])
AT_CLEANUP
## --------- ##
## ifnames. ##
## --------- ##
AT_SETUP([ifnames])
AT_DATA([iftest1.c],
[[#ifdef DEF1
#ifndef DEF2
#if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
# if SPACES
# if TABS
/* #if C_COMMENTS */
// #if CXX_COMMENTS
#if LINE1 = \
LINE2
#if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
]])
AT_DATA([iftest2.c],
[[#ifdef IFTEST2
#if VAL1
]])
AT_CHECK([ifnames iftest1.c iftest2.c], 0,
[DEF1 iftest1.c
DEF2 iftest1.c
DEF3 iftest1.c
DEF4 iftest1.c
IFTEST2 iftest2.c
LINE1 iftest1.c
LINE2 iftest1.c
SPACES iftest1.c
TABS iftest1.c
VAL1 iftest1.c iftest2.c
VAL2 iftest1.c
VAL3 iftest1.c
VAL4 iftest1.c
], [])
AT_CLEANUP
## ------------ ##
## autoheader. ##
## ------------ ##
# autoheader is intensively used in its modern form throughout this
# test suite. But we also have to check that acconfig.h still works.
# autoheader uses autoconf --trace, so traces first.
AT_SETUP([autoheader])
AT_DATA([acconfig.h],
[[/* Define this to whatever you want. */
#undef this
]])
# 1. Check that 'acconfig.h' is still honored.
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE(this, "whatever you want.")
]])
AT_CHECK_AUTOHEADER([], [this], [0], [], [ignore])
AT_CHECK([cat config.hin], 0,
[[/* config.hin. Generated from configure.ac by autoheader. */
/* Define this to whatever you want. */
#undef this
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
]])
# 2. Check that missing templates are a fatal error.
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE(that, "whatever you want.")
]])
# The test suite goes too fast for the cache timestamps...
# Pass --force.
AT_CHECK_AUTOHEADER([--force], [], [1], [], [ignore])
# 3. Check TOP and BOTTOM.
AT_DATA([acconfig.h],
[[/* Top from acconfig.h. */
@TOP@
/* Middle from acconfig.h. */
@BOTTOM@
/* Bottom from acconfig.h. */
]])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AH_TOP([Top1 from configure.ac.])
AH_TOP([Top2 from configure.ac.])
AH_TOP([The Cat in a h@t.])
AH_VERBATIM([Middle], [Middle from configure.ac.])
AH_VERBATIM([Mouse], [The Mouse in a h@t.])
AH_BOTTOM([Bottom1 from configure.ac.])
AH_BOTTOM([Bottom2 from configure.ac.])
AH_BOTTOM([The Dog in a h@t.])
AC_DEFINE([ANT], [@], [The Ant in a h@t.])
]])
# Yes, that's right: the 'middle' part of 'acconfig.h' is still before
# the AH_TOP part. But so what, you're not supposed to use the two
# together.
# Ignore STDERR which is the longish complaint against autoheader junk
# files.
AT_CHECK_AUTOHEADER([--force], [ANT], [], [], [ignore])
AT_CHECK([cat config.hin], 0,
[[/* config.hin. Generated from configure.ac by autoheader. */
/* Top from acconfig.h. */
/* Middle from acconfig.h. */
Top1 from configure.ac.
Top2 from configure.ac.
The Cat in a h@t.
/* The Ant in a h@t. */
#undef ANT
Middle from configure.ac.
The Mouse in a h@t.
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
Bottom1 from configure.ac.
Bottom2 from configure.ac.
The Dog in a h@t.
/* Bottom from acconfig.h. */
]])
AT_CLEANUP
# autoheader should see through m4 macros, just like autoconf
# https://lists.gnu.org/archive/html/bug-autoconf/2009-06/msg00000.html
AT_SETUP([autoheader and macros])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS([config.h])
m4_define([PETER], [SIMSALABIM])
m4_define([PAUL], [OPENSESAME])
AC_DEFINE([PETER], [10], [Peter's public info])
AC_DEFINE_UNQUOTED([PAUL], [`expr 4 + 6`], [Paul's public info])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([], [OPENSESAME SIMSALABIM])
AT_CHECK([grep -c SIMSALABIM configure config.h.in], [0],
[[configure:1
config.h.in:1
]])
AT_CHECK([grep -c OPENSESAME configure config.h.in], [0],
[[configure:1
config.h.in:1
]])
AT_CHECK([grep -c PETER configure config.h.in], [1],
[[configure:0
config.h.in:0
]])
AT_CHECK([grep -c PAUL configure config.h.in], [1],
[[configure:0
config.h.in:0
]])
AT_CLEANUP
# autoheader should take all config header inputs into account when
# checking for missing templates.
AT_SETUP([autoheader with multiple headers])
AT_DATA([config-extra.h.in],
[[/* Define this to whatever you want. */
#undef HANNA
]])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS([config.h config-extra.h])
AC_DEFINE([HANNA], ["Hanna"])
AC_DEFINE([SEAN], ["Sean"], [Sean's name])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([], [SEAN])
AT_CHECK([grep HANNA configure], [0], [ignore], [ignore])
AT_CHECK([grep HANNA config.h.in], [1], [ignore], [ignore])
AT_CHECK([grep SEAN configure], [0], [ignore], [ignore])
AT_CHECK([grep SEAN config.h.in], [0], [ignore], [ignore])
AT_CLEANUP
## ------------ ##
## autoupdate. ##
## ------------ ##
# Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
AT_SETUP([autoupdate])
AT_DATA([configure.ac],
[[AC_INIT(Test, 1.0)
AC_CANONICAL_SYSTEM
# The doc says 27 is a valid fubar.
fubar=27
AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
]])
AT_DATA([expout],
[[AC_INIT([Test],[1.0])
AC_CANONICAL_TARGET
# The doc says 27 is a valid fubar.
fubar=27
AC_CONFIG_FILES([Makefile])
AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE
AT_CHECK([cat configure.ac], 0, [expout])
# Checking that 'autoupdate' is idempotent
AT_CHECK_AUTOUPDATE
AT_CHECK([cat configure.ac], 0, [expout])
AT_CLEANUP
# autoupdating AC_LINK_FILES
# --------------------------
AT_SETUP([autoupdating AC_LINK_FILES])
AT_DATA([configure.ac],
[[AC_INIT
AC_LINK_FILES(dst1 dst2, src1 src2)
AC_OUTPUT
]])
AT_DATA([dst1], dst1
)
AT_DATA([dst2], dst2
)
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], 0, [], ignore)
# The replacement for AC_LINK_FILES includes a forced -Wobsolete
# warning, because it needs to be manually adjusted afterward.
# Look for it in the autoconf output.
AT_CHECK_AUTOCONF([], 0, [], stderr)
AT_CHECK([grep 'AC_LINK_FILES' stderr], 0, ignore, ignore)
AT_CHECK([grep 'AC_CONFIG_LINKS' stderr], 0, ignore, ignore)
AT_CHECK([grep 'warning: It is technically impossible' stderr],
0, ignore, ignore)
AT_CHECK([grep 'tune the result yourself' stderr], 0, ignore, ignore)
AT_CHECK_CONFIGURE
AT_CHECK([cat src1], 0, [dst1
])
AT_CHECK([cat src2], 0, [dst2
])
AT_CLEANUP
# autoupdating AC_PREREQ
# ----------------------
AT_SETUP([autoupdating AC_PREREQ])
# Produce 'AC_PREREQ(<AUTOUPDATE VERSION>)'.
AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
autoupdate_version=`cat stdout`
[echo "AC_PREREQ([$autoupdate_version])" >expout]
AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
0, [expout], [])
AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
0, [expout], [])
AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
63, [], [ignore])
AT_CLEANUP
# autoupdating AU_ALIAS
# ---------------------
AT_SETUP([autoupdating AU_ALIAS])
AT_DATA([configure.ac],
[[AC_INIT
AC_DEFUN([FOO], [$#])
AU_ALIAS([BAZ],[FOO])
test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
AC_PROG_CC
AC_WORDS_BIGENDIAN
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE
# autoupdate does not replace AU_DEFUNs/AU_ALIASes defined by
# configure.ac itself, nor by aclocal.m4, so BAZ will still be present
# in the updated configure.ac. This is actually desirable for this
# test: the point of that part of the above configure.ac is to
# verify that the expansion of an AU_ALIAS definition handles $#
# correctly. If BAZ got turned into FOO by the above call to
# autoupdate, we would need to run autoconf and configure twice in
# this test. However, it does also mean that by default we get a
# -Wobsolete warning because of BAZ, so turn that off so it doesn't
# cause a spurious failure.
AT_CHECK_AUTOCONF([-Wno-obsolete])
AT_CHECK_AUTOHEADER([-Wno-obsolete], [
AC_APPLE_UNIVERSAL_BUILD
HAVE_INTTYPES_H
HAVE_STDINT_H
HAVE_STDIO_H
HAVE_STDLIB_H
HAVE_STRINGS_H
HAVE_STRING_H
HAVE_SYS_STAT_H
HAVE_SYS_TYPES_H
HAVE_UNISTD_H
STDC_HEADERS
WORDS_BIGENDIAN
])
AT_CHECK_CONFIGURE
AT_CHECK([grep 'AC_C_BIGENDIAN[(]' configure.ac], 1, [ignore], [ignore])
AT_CHECK([grep 'AC_C_BIGENDIAN' configure.ac], 0, [ignore], [ignore])
AT_CLEANUP
# autoupdating OLD to NEW
# -----------------------
# The example taken from the code comments.
AT_SETUP([autoupdating OLD to NEW])
AT_DATA([aclocal.m4],
[[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
AC_DEFUN([NEW], [echo "sum($1) = $2"])
]])
AT_DATA([configure.ac],
[[AC_INIT
OLD(1, 2)
NEW([0, 0], [0])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
AT_CLEANUP
# autoupdating macros recursively
# -------------------------------
AT_SETUP([autoupdating macros recursively])
AT_XFAIL_IF([:])
AT_DATA([configure.ac],
[[AC_INIT
AC_PROG_CC
AC_TRY_COMPILE([], [choke me], [echo bogus1],
[AC_TRY_COMPILE([], [return 0;], [echo good], [echo bogus2])])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE
AT_CHECK([grep changequote configure.ac], [1])
AT_CHECK([grep TRY_COMPILE configure.ac], [1])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
# autoupdating AC_HELP_STRING
# ---------------------------
AT_SETUP([autoupdating AC_HELP_STRING])
AT_DATA([configure.ac],
[[AC_INIT
AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [], [], [ignore])
AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
AT_CLEANUP
# autoupdating with m4sugar
# -------------------------
AT_SETUP([autoupdating with m4sugar])
AT_DATA([aclocal.m4],
[[AU_DEFUN([OLD],
[m4@&t@_pushdef([foo], [bar])dn@&t@l
echo "foo $1 foo"
m4@&t@_popdef([foo])dn@&t@l
])
]])
touch foo.in
AT_DATA([configure.ac],
[[AC_PREREQ(2.54)
m4_define([gnumeric_version_epoch], [1])
AC_INIT
OLD([ bla bla ])
AC_FOREACH([name], [n1 n2],
[echo name
])
AC_CHECKING([for feature])
AC_MSG_RESULT_UNQUOTED([`echo done`])
AC_OUTPUT([foo])
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [], [], [ignore])
AT_CLEANUP
# autoupdating with m4_pushdef
# ----------------------------
AT_SETUP([autoupdating with m4@&t@_pushdef])
AT_XFAIL_IF([:])
touch foo.in
AT_DATA([configure.ac],
[[AC_INIT
AC_PROG_CC
# temporarily override this macro
m4@&t@_pushdef([AC_MSG_RESULT_UNQUOTED], [:])
AC_C_BIGENDIAN
m4@&t@_popdef([AC_MSG_RESULT_UNQUOTED])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK([grep changequote configure.ac], [1])
AT_CHECK([grep [pushdef.*AC_MSG_RESULT_UNQUOTED] configure.ac], [0], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [], [], [ignore])
AT_CLEANUP
# autoupdating with AC_REQUIRE
# ----------------------------
AT_SETUP([autoupdating with AC_REQUIRE])
AT_XFAIL_IF([:])
AT_DATA([configure.ac],
[[AC_DEFUN([MACRO],
[AC_REQUIRE([AC_DECL_SYS_SIGLIST])
AC_CHECK_DECLS([_sys_siglist], [], [], [#include <signal.h>])
])
AC_INIT
MACRO
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [], [], [ignore])
AT_CLEANUP
# autoupdating with complex quoting
# ---------------------------------
AT_SETUP([autoupdating with complex quoting])
AT_XFAIL_IF([:])
AT_DATA([configure.ac],
[[m4_define([MACRO],
[[#define STRING "hello, world\n"
]])
AC_INIT
AC_TRY_COMPILE([#include <stdio.h>
]MACRO[], [printf (STRING);],
[], [AS_EXIT([1])])
AC_OUTPUT
]])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK([grep MACRO configure], [1])
AT_CHECK_CONFIGURE([], [], [], [ignore])
AT_CLEANUP
# autoupdating AC_LANG_SAVE
# -------------------------
AT_SETUP([autoupdating AC_LANG_SAVE])
AT_DATA([configure.ac],
[[AC_INIT
AC_LANG_SAVE
AC_LANG_RESTORE
AC_LANG_SAVE
AC_LANG_RESTORE
AC_OUTPUT
]])
# Checking 'autoupdate'.
# Both the autoupdate and autoconf invocations will complain about
# AC_LANG_SAVE being obsolete, because autoupdate cannot replace
# two-macro sequences (e.g. AC_LANG_SAVE \n AC_LANG([C]) ideally would
# become AC_LANG_PUSH([C]) but we can't do that) so an m4_warn
# is left in place to remind people they need to do some hand edits.
# Ignore these diagnostics.
AT_CHECK_AUTOUPDATE([], [], [], [ignore])
AT_CHECK_AUTOCONF([], [], [], [ignore])
AT_CHECK_CONFIGURE
AT_CLEANUP
# autoupdating AC_FOREACH
# -----------------------
AT_SETUP([autoupdating AC_FOREACH])
AT_DATA([aclocal.m4],
[[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
]])
AT_DATA([configure.ac],
[[AC_INIT
echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
AC_OUTPUT
]])
# Checking 'autoupdate'.
# AC_FOREACH is replaced with an m4sugar macro, so we must make sure
# the m4sugar macro wasn't expanded.
AT_CHECK_AUTOUPDATE
AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
AT_CHECK([[grep "echo ' 1'' 2'' 3'' 4'' 5'' 6'" configure.ac]], 1,
[ignore], [ignore])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [0], [stdout])
AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
AT_CLEANUP
# autoupdating AC_OBSOLETE
# ------------------------
AT_SETUP([autoupdating AC_OBSOLETE])
AT_DATA([aclocal.m4],
[[AC_DEFUN([OLD],
[AC_OBSOLETE([$0], [; convert to NEW])
NEW([$2], [$1])])
AC_DEFUN([NEW],
[AS@&t@_ECHO(["dst=$1 src=$2"])])
]])
AT_DATA([configure.ac],
[[AC_INIT
OLD([src], [dst])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF([-Werror], 1, [],
[[configure.ac:2: warning: OLD is obsolete; convert to NEW
general.m4: AC_OBSOLETE is expanded from...
aclocal.m4:1: OLD is expanded from...
configure.ac:2: the top level
configure.ac:2: warning: The macro 'AC_OBSOLETE' is obsolete.
configure.ac:2: You should run autoupdate.
general.m4: AC_OBSOLETE is expanded from...
aclocal.m4:1: OLD is expanded from...
configure.ac:2: the top level
]])
# autoupdate does not know how to replace OLD with NEW
AT_CHECK_AUTOUPDATE
AT_CHECK([[grep OLD configure.ac]], 0, [ignore], [ignore])
# autoupdate _does_ know how to remove AC_OBSOLETE from aclocal.m4
AT_CHECK_AUTOUPDATE([aclocal.m4], 0, [],
[[aclocal.m4:2: warning: if possible, define this macro using AU_DEFUN.
]])
# AC_OBSOLETE is replaced with an m4sugar macro, so we must make sure
# the m4sugar macro wasn't expanded.
AT_CHECK([[grep 'm4@&t@_warn' aclocal.m4]], 0, [ignore], [ignore])
AT_CHECK([[grep 'if possible, define this' aclocal.m4]], 0, [ignore], [ignore])
AT_CHECK([[grep 'AC_OBSOLETE(' aclocal.m4]], 1, [ignore], [ignore])
AT_CHECK_AUTOCONF([-Wobsolete -Wno-error], 0, [],
[[configure.ac:2: warning: if possible, define this macro using AU_DEFUN.
aclocal.m4:1: OLD is expanded from...
configure.ac:2: the top level
configure.ac:2: warning: OLD is obsolete; convert to NEW
aclocal.m4:1: OLD is expanded from...
configure.ac:2: the top level
]])
AT_CHECK_CONFIGURE([], 0,
[[dst=dst src=src
configure: creating ./config.status
]])
AT_CLEANUP
# autoupdating AC_DIAGNOSE and AC_WARNING
-----------------------------------------
AT_SETUP([autoupdating AC_DIAGNOSE and AC_WARNING])
AT_DATA([configure.ac],
[[AC_INIT
AC_DIAGNOSE([gnu], [The gnu has escaped])
AC_WARNING([funny punctu&tion])
AC_OUTPUT
]])
# Checking 'autoupdate'.
# AC_DIAGNOSE and AC_WARNING are replaced with m4sugar macros, so we
# must make sure the m4sugar macros weren't expanded.
AT_CHECK_AUTOUPDATE
AT_CHECK([[grep 'm4@&t@_warn' configure.ac]], 0, [ignore], [ignore])
AT_CHECK([[grep 'The gnu has escaped' configure.ac]], 0, [ignore], [ignore])
AT_CHECK([[grep 'funny punctu&tion' configure.ac]], 0, [ignore], [ignore])
# The diagnostics should appear when autoconf is run.
AT_CHECK_AUTOCONF([-Wall], [0], [],
[[configure.ac:2: warning: The gnu has escaped
configure.ac:3: warning: funny punctu&tion
]])
AT_CHECK_CONFIGURE
AT_CLEANUP
# autoupdating AC_FATAL
-----------------------
AT_SETUP([autoupdating AC_FATAL])
AT_DATA([configure.ac],
[[AC_INIT
AC_FATAL([what did you do this time])
AC_OUTPUT
]])
# Checking 'autoupdate'.
# AC_FATAL is replaced with a m4sugar macro, so we
# must make sure the m4sugar macro wasn't expanded.
AT_CHECK_AUTOUPDATE
AT_CHECK([[grep 'm4@&t@_fatal' configure.ac]], 0, [ignore], [ignore])
AT_CHECK([[grep 'what did you do this time' configure.ac]],
0, [ignore], [ignore])
# The diagnostic should appear when autoconf is run.
AT_CHECK_AUTOCONF([-Wall], [1], [],
[[configure.ac:2: error: what did you do this time
configure.ac:2: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CHECK([[test \! -f configure]])
AT_CLEANUP
# autoupdating with aclocal and m4_include
# ----------------------------------------
AT_SETUP([autoupdating with aclocal and m4@&t@_include])
AT_REQUIRE_ACLOCAL
mkdir m4 aclocal
AT_DATA([configure.ac],
[[AC_INIT(x,0)
AC_UNCHANGED_MACRO
AC_OLD_MACRO
AC_OUTPUT
]])
AT_DATA([m4/stuff.m4],
[[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
AC_DEFUN([AC_NEW_MACRO], [echo hi])
AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
]])
cp m4/stuff.m4 aclocal/stuff.m4
AT_CHECK([$ACLOCAL -I aclocal], [0], [ignore], [ignore])
# Checking 'autoupdate'.
AT_CHECK_AUTOUPDATE
AT_CHECK([$ACLOCAL -I m4], [0], [ignore], [ignore])
AT_CHECK_AUTOUPDATE
AT_CLEANUP
# Keeping autom4te.cfg complete
# -----------------------------
AT_SETUP([autom4te preselections])
AT_REQUIRE_AUTOMAKE
AT_REQUIRE_ACLOCAL
# This user configuration file will interfere with this test.
AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
AT_DATA([configure.ac],
[[AC_INIT(GNU foo, 1.0)
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])
AT_DATA([Makefile.am],
[[AUTOMAKE_OPTIONS = foreign
]])
AT_MTIME_DELAY
# If Autoconf is too old, or the user has turned caching off, skip:
AT_CHECK([$ACLOCAL || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }],
[], [], [ignore])
AT_CHECK([test -d autom4te.cache || exit 77])
AT_CHECK([autoconf])
# On a file system with coarse timestamp resolution (1 or 2s),
# configure and autom4te's cache files can easily have equal
# timestamps, in which case autom4te will consider the cache
# to be stale. Ensure configure's timestamp is newer.
AT_MTIME_DELAY
touch configure
# If this test fails due to missing entries in lib/autom4te.in, then
# comparing the old and new requests is a good place to start debugging:
sort autom4te.cache/requests >old-requests
# if 'configure' is regenerated, we want it to be strictly newer,
# to catch the error consistently.
echo newer >newer
AT_MTIME_DELAY
AT_CHECK([$ACLOCAL], [], [], [ignore])
AT_CHECK([automake --no-force --add-missing], [], [], [ignore])
AT_CHECK([autoconf])
AT_CHECK([test "`find configure -newer newer`" = "" ||
{ sort autom4te.cache/requests | diff old-requests -; exit 1; }],
[], [], [],
[extract_version=['s/^[^0-9]*\([0-9][^ ]*\).*/\1/;q']
automake_version=`automake --version | sed "$extract_version"`
used_automake_version=`sed "$extract_version" "$abs_top_srcdir/Makefile.in"`
AT_CHECK([if test "$automake_version" = "$used_automake_version"; ]dnl
[then exit 1; else exit 77; fi])])
AT_CLEANUP
# autom4te cache creation
# -----------------------
# Ensure autom4te fails when it cannot create the cache directory
# or create files there.
AT_SETUP([autom4te cache creation])
AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
# Work in a subdirectory so autotest can scribble in the toplevel.
mkdir sub
chmod a-w sub
AT_DATA([configure.ac],
[[AC_INIT
AC_OUTPUT
]])
AT_DATA([.autom4te.cfg],
[[begin-language: "Autoconf-without-aclocal-m4"
args: --cache=sub/autom4te.cache
end-language: "Autoconf-without-aclocal-m4"
]])
# Do not try this when we are root or on systems without permissions.
# A failed redirection may cause a status of 2 with FreeBSD sh.
AT_CHECK([(: > sub/some-file) || exit 1 && exit 77], 1, [ignore], [ignore])
# Failure to create cache directory due to access permissions.
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr])
AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore])
AT_CHECK([grep ': Permission denied' stderr], [0], [ignore])
AT_CHECK([test -f configure], [1])
# Failure to create cache directory due to something else in the way.
chmod u+w sub
: > sub/autom4te.cache
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr])
AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore])
AT_CHECK([grep ': File exists' stderr], [0], [ignore])
AT_CHECK([test -f configure], [1])
# This time, creation should succeed.
rm -f sub/autom4te.cache
AT_CHECK_AUTOCONF
AT_CHECK([test -d sub/autom4te.cache])
rm -f configure sub/autom4te.cache/*
chmod a-w sub/autom4te.cache
# Failure to create a file in the cache directory.
AT_CHECK_AUTOCONF([], [1], [ignore], [stderr])
AT_CHECK([grep 'cannot open .*autom4te.cache' stderr], [0], [ignore])
AT_CHECK([test -f configure], [1])
# If the directory already exists, that should be fine.
chmod u+w sub/autom4te.cache
AT_CHECK_AUTOCONF
AT_CLEANUP
# autom4te cache locking
# ----------------------
AT_SETUP([autom4te cache locking])
# Expect this test to fail if Perl file locking does not work.
AT_XFAIL_IF([$PERL -I "$top_srcdir/lib" -e '
use Autom4te::XFile;
my $fh = new Autom4te::XFile "lockfile", O_RDWR|O_CREAT;
flock ($fh, LOCK_EX) && exit 1;
'])
# Cannot use AT_CHECK here, autotest internals could be messed up.
# This sleep is not because of file timestamps, it's to make the
# locks conflict.
(echo AC_INIT; sleep 2; echo) \
| (autom4te --language=autoconf -o configure -; echo $? >&2 ) 2>errlog &
AT_CHECK([echo AC_INIT | autom4te --language=autoconf -o configure -])
wait
# Ignore additional output from shell verbose or xtrace mode.
AT_CHECK([grep 'cannot rename' errlog], [1])
AT_CHECK([grep '^0$' errlog], [], [ignore])
AT_CHECK_CONFIGURE
AT_CLEANUP
# autotools and file names containing whitespace
# ----------------------------------------------
AT_SETUP([autotools and whitespace in file names])
AT_SUPPRESS_ACLOCAL
x=
export x
rm -f a b
for funny in \
'with funny '\'' $x & #! name ' \
'with funny \ '\'' \'\'' " <a >b * ? name ' #"
do
funny=`func_sanitize_file_name "$funny"`
file=" file $funny"
dir=`func_sanitize_dir_name " dir $funny"`
TMPDIR="./ tmp$dir"
export TMPDIR
# skip if we cannot create such a file or directory
AT_CHECK([mkdir "$dir" "$TMPDIR" && touch "$file.ac" || exit 77])
cat >"$file.ac" <<'END'
[AC_INIT(x,0)
m4@&t@_include([foo.m4])
AC_CONFIG_HEADERS([config.h:config.hin])
AC_MACRO
AC_OUTPUT]
END
cat >"$dir"/foo.m4 <<'END'
[AC_DEFUN([AC_MACRO], [echo hi])]
END
AT_CHECK_AUTOHEADER([-B "$dir" "$file.ac"])
AT_CHECK_AUTOHEADER([--force -I "$dir" "$file.ac"])
AT_CHECK_AUTOUPDATE([-B "$dir" "$file.ac"])
AT_CHECK_AUTOUPDATE([--force -I "$dir" "$file.ac"])
AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.ac"], [], [ignore])
AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.ac"])
AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.ac"])
# In autoconf, these exercise a slightly different code path:
AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.ac"])
AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.ac"])
AT_CHECK([autoscan -B "$dir"], [], [], [ignore])
AT_CHECK([autoscan --force -I "$dir"], [], [], [ignore])
# autoreconf requires a sane input file name.
mv -f "$file.ac" configure.ac
AT_CHECK([autoreconf -B "$dir"])
AT_CHECK([autoreconf --force -I "$dir"])
cat >"$file.c" <<'END'
#if FOO
#endif
END
AT_CHECK([ifnames "$file.c"], [], [ignore])
test ! -f b
done
AT_CLEANUP
# autotools and file names containing whitespace
# ----------------------------------------------
AT_SETUP([autotools and relative TMPDIR])
AT_REQUIRE_ACLOCAL
mkdir _tmp
TMPDIR=_tmp
export TMPDIR
AT_DATA([configure.ac],
[[AC_INIT(x,0)
AC_CONFIG_HEADERS([config.h:config.hin])
AC_MACRO
AC_OUTPUT
]])
mkdir m4
AT_DATA([m4/foo.m4],
[[AC_DEFUN([AC_MACRO],
[AC_DEFINE([HAVE_MACROS], 1, [Define if you have macros.])])
]])
AT_CHECK([$ACLOCAL -I m4])
AT_CHECK_AUTOHEADER([], [HAVE_MACROS])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
|