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
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
|
# -*- Autotest -*-
# Copyright (C) 2000-2017, 2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
AT_BANNER([[Testing config.status.]])
## ---------------------------------------- ##
## AC_CONFIG_COMMANDS with empty commands. ##
## ---------------------------------------- ##
AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
[[AC_CONFIG_COMMANDS([foo], [], [:])
]])
## --------------------------------------------- ##
## AC_CONFIG_COMMANDS with temporary directory. ##
## --------------------------------------------- ##
AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
[[AC_CONFIG_COMMANDS([foo], [
case $ACTION in
use)
echo "$tmp" > tmpdir
test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
echo garbage-in > "$tmp/garbage-out"
;;
corrupt)
echo "$tmp" > tmpdir
tmp=./nosuch
;;
*) ;;
esac
])
]], [
AT_CHECK([test ! -f tmpdir])
AT_CHECK([ACTION=use ./config.status], [], [ignore])
AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
])
## -------------------------- ##
## Multiple AC_CONFIG_FILES. ##
## -------------------------- ##
AT_SETUP([Multiple AC_CONFIG_FILES])
AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
AT_CHECK_AUTOCONF([], 1, [], [ignore])
AT_CLEANUP
## ------------------------------- ##
## parameterized AC_CONFIG_FILES. ##
## ------------------------------- ##
AT_SETUP([Parameterized AC_CONFIG_FILES])
AT_CONFIGURE_AC([[
files="foo
bar"
AC_CONFIG_FILES([$files])]])
AT_CHECK_AUTOCONF([], [], [], [ignore])
touch foo.in bar.in config.hin
AT_CHECK_CONFIGURE
AT_CLEANUP
## ------------ ##
## AC_ARG_VAR. ##
## ------------ ##
# AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
# ------------------------------------------------------------
# Check that AC_ARG_VAR caches the latest values, diagnoses
# inconsistencies, and arms config.status. Check that recheck
# returns STATUS, save configure output in files 'stdout' and 'stderr'
# for further inspection.
m4_define([AT_CHECK_AC_ARG_VAR],
[rm -f config.cache
# Initial value.
m4_ifval([$1],
[precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
[unset precious])
AT_CHECK_CONFIGURE([--config-cache -q])
AT_CHECK([cat file], [], [`$1'
])
# Testing --recheck: 1. have the environment `forget' about PRECIOUS.
unset precious
# 2. Rerun config.status to recreate `file'.
AT_CHECK([./config.status --recheck], [], [ignore])
AT_CHECK([./config.status], [], [ignore])
# 3. Check that file contains the old value of PRECIOUS.
AT_CHECK([cat file], [], [`$1'
])
# Second value: we should issue an error here: the value
# has changed!
m4_ifval([$2],
[precious='$2'; export precious],
[unset precious])
AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
])# AT_CHECK_AC_ARG_VAR
AT_SETUP([AC_ARG_VAR])
# We don't want to run this test if this shell doesn't support
# `unset'.
AT_CHECK([
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
exit 0
else
exit 77
fi
])
AT_DATA([configure.ac],
[[AC_INIT
AC_ARG_VAR([precious], [this variable costs a lot])
echo "precious:$precious"
AC_OUTPUT(file)
]])
AT_DATA([file.in],
[[`@precious@'
]])
AT_CHECK_AUTOCONF([], 0, [],
[[configure.ac:4: warning: AC_OUTPUT should be used without arguments.
configure.ac:4: You should run autoupdate.
]])
# Set a precious variable
AT_CHECK_AC_ARG_VAR([], [apple of my eye])
# Unset a precious variable
AT_CHECK_AC_ARG_VAR([apple of my eye], [])
# Change a precious variable
AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
# Change a precious variable that contains braces
AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
# Change a precious variable that contains all kinds of fun
AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
dnl restore font-lock: "
# Warn (but do not fail) about a whitespace-only change
AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
[0], ["has whitespace changes"])
mv stdout configure-output
AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
AT_CLEANUP
## ---------------------------------------------- ##
## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
## ---------------------------------------------- ##
AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
AT_DATA([configure.ac],
[[AC_INIT
AC_PROG_FGREP
rm -f -r header var-header file var-file link var-link command var-command
echo 'OK' >input
# Be sure to also stress the associated INIT-CMDS.
case $what_to_test in
header)
AC_CONFIG_HEADERS(header:input);;
var-header)
AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
file)
AC_CONFIG_FILES(file:input);;
var-file)
AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
command)
AC_CONFIG_COMMANDS(command,
[cp input command]);;
var-command)
AC_CONFIG_COMMANDS(var-command,
[cp $command_in var-command], [command_in=input]);;
link)
AC_CONFIG_LINKS(link:input);;
var-link)
AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
esac
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
# AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
# ------------------------------------------------------------------
# Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
# are properly created, with the right content.
# Use `grep OK' instead of a simple `cat' to avoid banners such as in
# AC_CONFIG_HEADERS.
m4_define([AT_CHECK_CONFIG_CREATION],
[AT_CHECK_CONFIGURE([what_to_test=$1])
AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
[ignore], [$1
])
AT_CHECK([grep OK $1], [], [OK
])
AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
# config.status might be stupidly expecting data on stdin, if it's
# really broken...
AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
[ignore], [var-$1
])
AT_CHECK([grep OK var-$1], [], [OK
])
])# AT_CHECK_CONFIG_CREATION
# AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
# --------------------------------------------------------------------------
# Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
# are properly created, with the right content.
# Use `grep OK' instead of a simple `cat' to avoid banners such as in
# AC_CONFIG_HEADERS.
m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
[AT_CHECK_CONFIGURE([what_to_test=$1])
AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
[ignore], [$1
])
AT_CHECK([grep OK $1], [], [OK
])
AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
# config.status might be stupidly expecting data on stdin, if it's
# really broken...
# Skip check if user can rename files into a read-only directory (when
# run by root or on w32).
touch t
chmod a-w .
mv t t1 >/dev/null 2>&1 \
|| AT_CHECK([./config.status var-$1 </dev/null || exit 1],
[1], [ignore], [ignore])
chmod u+w .
rm -rf t t1
])# AT_CHECK_CONFIG_CREATION_NOWRITE
# Create a file
AT_CHECK_CONFIG_CREATION(file)
# Create a header
AT_CHECK_CONFIG_CREATION(header)
# Execute a command
AT_CHECK_CONFIG_CREATION(command)
# Create a link
AT_CHECK_CONFIG_CREATION(link)
# Now check for write errors
# Create a file
AT_CHECK_CONFIG_CREATION_NOWRITE(file)
# Create a file with bits from stdin
AT_CHECK([echo from-stdin | ./config.status --file=file:-],
[0], [ignore])
AT_CHECK([grep from-stdin file], [], [from-stdin
])
# Force write error creating a file on stdout
if test -w /dev/full && test -c /dev/full; then
AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
[1], [ignore], [ignore])
fi
# Validate that --file requires an argument
AT_CHECK([./config.status --file], [1], [ignore], [stderr])
AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
# Create a header
AT_CHECK_CONFIG_CREATION_NOWRITE(header)
# Create a header on stdout
AT_CHECK([./config.status --header=-:input </dev/null],
[0], [stdout], [ignore])
AT_CHECK([grep OK stdout], [], [OK
])
# Force write error creating a header on stdout
if test -w /dev/full && test -c /dev/full; then
AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
[1], [ignore], [ignore])
fi
# Execute a command
AT_CHECK_CONFIG_CREATION_NOWRITE(command)
# Create a link
AT_CHECK_CONFIG_CREATION_NOWRITE(link)
# Check that no use of `ac_write_fail' escaped into config.status
AT_CHECK([grep ac_write_fail config.status], [1])
# Check that --file and --header accept funny file names
AT_DATA([fgrep.in],
[[FGREP="@FGREP@"
]])
./config.status --file=fgrep:fgrep.in
. ./fgrep
x=
export x
for file in \
'with funny '\'' $x & #! name' \
'file with funny \ '\'' \'\'' $ & #!*? name' \
'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
do
# The function func_sanitize_file_name comes from tools.at
file=`func_sanitize_file_name "$file"`
cat >"$file.in" <<'END'
@configure_input@
END
AT_CHECK([./config.status "--file=$file:$file.in"],
[0], [ignore])
AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
AT_CHECK([./config.status "--header=$file:$file.in"],
[0], [ignore])
# Run the same test a 2nd time to see that config.status does not recreate
# the header (regression test)
AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
[0], [config.status: creating $file
config.status: $file is unchanged
])
AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
[/* $file. Generated from $file.in by configure. */
])
AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
done
AT_CLEANUP
## ---------------------------------------- ##
## Macro calls in AC_CONFIG_COMMANDS tags. ##
## ---------------------------------------- ##
AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
AT_DATA_M4SUGAR([configure.ac],
[[AC_INIT
AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
## ------------------- ##
## Missing templates. ##
## ------------------- ##
# Check that config.status detects missing input files
AT_SETUP([Missing templates])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_FILES([nonexistent])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
mkdir build
AT_CAPTURE_FILE([build/config.log])[]dnl
cd build
AT_CHECK([../configure], [1], [ignore],
[[config.status: error: cannot find input file: `nonexistent.in'
]])
# Make sure that the output file doesn't exist
AT_CHECK([test -f nonexistent], 1)
cd ..
AT_CHECK_CONFIGURE([], [1], [],
[[config.status: error: cannot find input file: `nonexistent.in'
]])
# Make sure that the output file doesn't exist
AT_CHECK([test -f nonexistent], 1)
AT_CLEANUP
## ---------------------- ##
## configure invocation. ##
## ---------------------- ##
# Check that `configure' and `config.status' honor their interface.
#
# We run `./configure one=val1 --enable-two=val2 --with-three=val3'
# and verify that (i) `configure' correctly receives the arguments,
# (ii) correctly passes them to `config.status', which we check by
# running `config.status --recheck', (iii) correctly passes them
# to sub-configure scripts, and (iv) correctly reproduces them with
# `config.status --config'.
AT_SETUP([configure invocation])
mkdir sub
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_SUBDIRS([sub])
echo "result=$one$enable_two$with_three"
AC_OUTPUT
]])
AT_DATA([sub/configure.ac],
[[AC_INIT
echo "result=$one$enable_two$with_three"
AC_OUTPUT
]])
echo fake install-sh script >install-sh
AT_CHECK_AUTOCONF
cd sub
AT_CHECK_AUTOCONF
cd ..
AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
sed -n -e 's/^result=//p'], 0,
[m4_do([onetwothree
], [onetwothree
])])
AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
[onetwothree
])
AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
sed -n -e 's/^result=//p'], 0,
[m4_do([onetwothree
], [onetwothree
])])
AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
sed -n -e 's/^result=//p'], 0,
[m4_do(["'$ " ' $ "'$
], ["'$ " ' $ "'$
])])
AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
["'$ " ' $ "'$
])
dnl restore font-lock: "
AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
sed -n -e 's/^result=//p'], 0,
[m4_do(["'$ " ' $ "'$
], ["'$ " ' $ "'$
])])
AT_CLEANUP
## ---------------------- ##
## --help and --version. ##
## ---------------------- ##
AT_SETUP([--help and --version in unwritable directory])
AS_MKDIR_P([inner])
AT_DATA([inner/configure.ac],
[[AC_INIT
AC_OUTPUT
]])
AT_CHECK_M4([(cd inner && autoconf --force)])
AT_CHECK([test -s inner/configure])
if test "$SHELL_N" != none; then
AT_CHECK_SHELL_SYNTAX([inner/configure])
fi
chmod a-w inner
AT_CHECK([(cd inner && ./configure --help)], 0, [ignore], [ignore])
AT_CHECK([(cd inner && ./configure --version)], 0, [ignore], [ignore])
chmod u+w inner
AT_CLEANUP
## -------------------------------------------- ##
## Check that `#define' templates are honored. ##
## -------------------------------------------- ##
# Use various forms of `#define' templates, and make sure there are no
# problems when a symbol is prefix of another.
AT_SETUP([@%:@define header templates])
AT_KEYWORDS([AC@&t@_DEFINE])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
# I18n of dummy variables: their French translations.
AC_DEFINE(foo, toto)
AC_DEFINE(bar, tata)
AC_DEFINE(baz, titi)
AC_DEFINE(fubar, tutu)
# Symbols which are prefixes of another.
AC_DEFINE(a, A)
AC_DEFINE(aaa, AAA)
AC_DEFINE(aa, AA)
# backslash-newline combinations
AC_DEFINE([multiline], [line1\
line2\
line3 \
line4])
AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
ARG1])
AC_CONFIG_FILES(defs)
# underquoted #
AC_DEFINE([paste(a,b)], [a##b])
# Things included in confdefs.h, but which make no sense in
# config.h, nor in $DEFS.
cat <<\EOF >>confdefs.h
/* Hi Mum! Look, I am doing C++! */
#ifdef __cplusplus
void exit (int status);
#endif
EOF
# In addition of config.h output a full DEFS
AC_OUTPUT_MAKE_DEFS
DEFS_SAVED=$DEFS
AC_SUBST(DEFS_SAVED)
AC_OUTPUT
]])
AT_DATA([defs.in],
[[@DEFS_SAVED@
]])
AT_DATA([config.hin],
[[#define foo 0
# define bar bar
# define baz "Archimedes was sinking in his baz"
# define fubar tutu
#define a B
#define aa BB
# define aaa BBB
#undef a
# undef aa
#undef aaa
#define aaa(a, aa) aa a
#define aaab
#define aaac(a, aa) aa a
#undef multiline
# undef multiline_args
#define paste(a,b) a##b
/* an ugly one: */
#define str(define) \
#define
#define stringify(arg) str(arg)
#undef aaa /* with comments */
#undef not_substed /* with comments */
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_DATA([expout],
[[/* config.h. Generated from config.hin by configure. */
#define foo toto
# define bar tata
# define baz titi
# define fubar tutu
#define a A
#define aa AA
# define aaa AAA
#define a A
# define aa AA
#define aaa AAA
#define aaa AAA
#define aaab
#define aaac(a, aa) aa a
#define multiline line1\
line2\
line3 \
line4
# define multiline_args(ARG1, ARG2) ARG2 \
ARG1
#define paste(a,b) a##b
/* an ugly one: */
#define str(define) \
#define
#define stringify(arg) str(arg)
#define aaa AAA
/* #undef not_substed */
]])
AT_CHECK([cat config.h], 0, expout)
# Check the value of DEFS.
AT_DATA([expout],
[[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
]])
# Because we strip trailing spaces in `testsuite' we can't leave one in
# expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
AT_CHECK([sed -e 's/ $//' defs], 0, expout)
AT_CLEANUP
## ------------------------- ##
## Torturing config.status. ##
## ------------------------- ##
## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
## big value. This is mostly to check that Autoconf produces portable sed
## scripts in config.status. sed is used to skip the first two lines
## `Generated by ...'.
# We use m4_for many times.
m4_pattern_allow([^m4_for$])
AT_SETUP([Torturing config.status])
dnl The value used as a big value for AC_DEFINE.
dnl Don't use sh active chars here, below it is also used in a sh
dnl assignment.
m4_define([AT_BIG_VALUE],
[This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
m4_define([AT_DESCRIPTION],
[Define to a long string if your `Autoconf' works properly.])
# AT_DUMMY_VAR(NUMBER)
# --------------------
# Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
# so that the check for user name space invasion does not complain
# of the new variables defined.
#
# Note that you should not use the name ac_dummy, because it will be
# turned into ac_uummy during the construction of config.status. Yes,
# this is admittedly a bug, but it would be too hard to fix this.
# There is really no point in AC_DEFINE a var named ac_d.*.
m4_pattern_allow([^m4_bpatsubst$])
m4_define([AT_DUMMY_VAR],
[ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
AT_DATA([dummy.in],
[m4_for([AT_Count], 1, 100, 1,
[@AT_DUMMY_VAR(AT_Count)@
@[f]AT_Count@
])])
i=1
while test $i != 101; do
echo "content of file $i" > file_$i
AS_VAR_ARITH([i], [$i + 1])
done
# ------------ #
# configure.ac #
# ------------ #
m4_pattern_allow([^m4_(define|defun)$])
AT_DATA([configure.ac],
dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
[[m4_define([AC_DUMMY_VAR],]
m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
[[m4_define([AC_DESCRIPTION],]
m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
[[m4_define([AC_BIG_VALUE],]
m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
[[# AC_DEFUBST(NAME)
# ----------------
# Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
# used in the torture tests.
m4_defun([AC_DEFUBST],
[AC_DUMMY_VAR($1)="AC_BIG_VALUE"
AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
AC_DESCRIPTION)
AC_SUBST(AC_DUMMY_VAR($1))
AC_SUBST_FILE([f]$1)
f$1=file_$1
])
AC_INIT
AC_CONFIG_HEADERS(config.h:config.hin)
AC_CONFIG_FILES(dummy)
m4_for(AC_Count, 1, 100, 1,
[AC_DEFUBST(AC_Count)])
AC_PROG_AWK
AC_OUTPUT
]])# configure.ac
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([],
m4_for(AT_Count, 1, 100, 1, [ AT_DUMMY_VAR(AT_Count)]))
# Check both awk and the result of AC_PROG_AWK.
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
AT_CHECK_CONFIGURE([$awk_arg])
# Checking that AC_DEFINE worked properly.
AT_DATA([expout],
[/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
m4_for(AT_Count, 1, 100, 1,
[
/* AT_DESCRIPTION */
[#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
])])
AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
# Checking that AC_SUBST worked properly.
AT_DATA([expout],
[m4_for(AT_Count, 1, 100, 1,
[AT_BIG_VALUE
content of file AT_Count
])])
AT_CHECK([cat dummy], 0, expout)
done
AT_CLEANUP
## ------------------------------- ##
## Substitute a 2000-byte string. ##
## ------------------------------- ##
# Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
# sed dumps core around 8 KiB. However, POSIX says that sed need not
# handle lines longer than 2048 bytes (including the trailing newline).
# So we'll just test a 2000-byte value, and for awk, we test a line with
# almost 1000 words, and one variable with 5 lines of 2000 bytes each:
# multi-line values should allow to get around the limitations.
# We also test runs of around 148 backslashes: they need to be escaped,
# and 148 is the portable limit for awk string literals. config.status
# uses concatenation to generate longer strings.
AT_SETUP([Substitute a 2000-byte string])
AT_DATA([Foo.in], [@foo@
])
AT_DATA([Bar.in], [@bar@
])
AT_DATA([Baz.in], [@baz@
])
AT_DATA([Boo.in], [@b147@
@b148@
@b149@
@b295@
@b296@
@b297@
])
AT_DATA([configure.ac],
[[AC_INIT
AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
"
baz=$baz$baz$baz$baz$baz
AC_SUBST([baz])
b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
b147=$b29$b29$b29$b29$b29'\\'
b148=$b147'\'
b149=$b148'\'
b295=$b147$b147'\'
b296=$b295'\'
b297=$b296'\'
AC_SUBST([b147])
AC_SUBST([b148])
AC_SUBST([b149])
AC_SUBST([b295])
AC_SUBST([b296])
AC_SUBST([b297])
AC_PROG_AWK
AC_CONFIG_FILES([Foo Bar Baz Boo])
AC_OUTPUT
]])
cp "$abs_top_srcdir/build-aux/install-sh" .
b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
b147=$b29$b29$b29$b29$b29'\\'
b295=$b147$b147'\'
cat >Boo-exp <<EOF
$b147
$b147\\
$b147\\\\
$b295
$b295\\
$b295\\\\
EOF
AT_CHECK_AUTOCONF
# Check both awk and the result of AC_PROG_AWK
# Quote the first word in the for list for Solaris sh.
for awk_arg in "Foo=" AWK=awk; do
AT_CHECK_CONFIGURE([$awk_arg])
AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
)
AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
)
AT_DATA([stdout],
[m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
)])
AT_CHECK([cat Baz], 0, [stdout])
AT_CHECK([diff Boo-exp Boo])
done
AT_CLEANUP
## ------------------------------ ##
## Define to a 2000-byte string. ##
## ------------------------------ ##
AT_SETUP([Define to a 2000-byte string])
AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
AT_CONFIGURE_AC(
[[
AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
]])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([], [foo fooq])
AT_CHECK_CONFIGURE
AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
@%:@define fooq m4_for([n], 1, 100,, ....................)
])
AT_CLEANUP
## ------------------------------------------ ##
## Substitute and define special characters. ##
## ------------------------------------------ ##
# Use characters special to the shell, sed, awk, and M4.
AT_SETUP([Substitute and define special characters])
AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
AT_XFAIL_IF([byte=\\200s; dnl
test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
AT_DATA([Foo.in], [@foo@
@bar@@notsubsted@@baz@ stray @ and more@@@baz@
abc@bar@baz@baz
abc@bar@@baz@baz
abc@bar@@baz@baz@
abc@bar @baz@baz
abc@bar @baz@baz@
abc@bar @baz@@baz@
@file@
@file@
X@file@
@file@X
])
AT_DATA([File],
[@foo@@bar@
])
AT_DATA([Zardoz.in], [@zardoz@
])
AT_CONFIGURE_AC(
[[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
#"
bar="@foo@ @baz@"
baz=bla
( for i in 0 1 2 3; do
for j in 0 1 2 3 4 5 6 7; do
for k in 0 1 2 3 4 5 6 7; do
case $i$j$k in #(
000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
# the wrong thing for CR on MinGW.
#(
*) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
esac
done
done
done
printf \\n
) >allowed-chars
zardoz=`cat allowed-chars`
AC_SUBST([foo])
AC_SUBST([bar])
AC_SUBST([baz])
AC_SUBST([zardoz])
file=File
AC_SUBST_FILE([file])
AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
AC_PROG_AWK
AC_CONFIG_FILES([Foo Zardoz])]])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([],
[foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7])
# Check both awk and the result of AC_PROG_AWK
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
AT_CHECK_CONFIGURE([$awk_arg])
AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
@foo@ @baz@@notsubsted@bla stray @ and more@@bla
abc@foo@ @baz@baz@baz
abc@foo@ @baz@blabaz
abc@foo@ @baz@blabaz@
abc@bar blabaz
abc@bar blabaz@
abc@bar blabla
@foo@@bar@
@foo@@bar@
X@file@
@file@X
]])
AT_CHECK([cmp allowed-chars Zardoz])
AT_CHECK_DEFINES([[#define bar %!_!# X
#define barq %!_!# X
#define foo X*'[]+ ", & &`\($foo !
#define fooq X*'[]+ ", & &`\($foo !
#define unq1 bla
#define unq2 $baz
#define unq3 "bla"
#define unq4 set
#define unq5 "a b"
#define unq6 hi
#define unq7 '\"'
]])
done
AT_CLEANUP
## ---------------------- ##
## Substitute a newline. ##
## ---------------------- ##
AT_SETUP([Substitute a newline])
AT_DATA([Foo.in],
[@foo@
@bar@
])
AT_DATA([configure.ac],
[[AC_INIT
foo='one
two'
bar='%!_!# ''
x'
AC_SUBST([foo])
AC_SUBST([bar])
AC_CONFIG_FILES([Foo])
AC_PROG_AWK
AC_OUTPUT
]])
cp "$abs_top_srcdir/build-aux/install-sh" .
echo 'one
two
%!_!# ''
x' >expout
AT_CHECK_AUTOCONF
# Check both awk and the result of AC_PROG_AWK
# Quote the first word in the for list for Solaris sh.
for awk_arg in "FOO=" AWK=awk; do
AT_CHECK_CONFIGURE([$awk_arg])
AT_CHECK([cat Foo], 0, [expout])
done
AT_CLEANUP
## ------------------ ##
## Define a newline. ##
## ------------------ ##
AT_SETUP([Define a newline])
AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
two], [This spans two lines.])
]])
AT_CHECK_AUTOCONF([], [], [], [stderr])
dnl Older versions of m4 report error at line 5 (end of macro);
dnl newer versions report it at line 4 (start of macro).
AT_CHECK([[sed '/trailer\.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE: `one
two' is not a valid preprocessor define value
]])
AT_CHECK_AUTOHEADER([], [foo])
AT_CHECK_CONFIGURE
AT_CHECK_DEFINES([[#define foo one
]])
rm -rf autom4te.cache
AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
two], [This spans two lines.])
]])
AT_CHECK_AUTOCONF([], [], [], [stderr])
AT_CHECK([[sed '/trailer.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
[[warning: AC_DEFINE_UNQUOTED: `one
two' is not a valid preprocessor define value
]])
AT_CHECK_AUTOHEADER([], [foo])
AT_CHECK_CONFIGURE
AT_CHECK_DEFINES([[#define foo one
]])
AT_CLEANUP
## ------------------------------------ ##
## AC_SUBST: variable name validation. ##
## ------------------------------------ ##
AT_SETUP([AC_SUBST: variable name validation])
AT_CONFIGURE_AC([[AC_SUBST(, [])
AC_CONFIG_FILES([Makefile])
]])
AT_DATA([Makefile.in], [[
]])
mv -f configure.ac configure.tmpl
# Invalid names.
for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
AT_CHECK_AUTOCONF([], [1], [], [ignore])
done
# Valid names.
for var in ab a4 'a@@&t@\&t@b'; do
sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER
AT_CHECK_CONFIGURE
done
AT_CLEANUP
## ------------------------ ##
## datarootdir workaround. ##
## ------------------------ ##
AT_SETUP([datarootdir workaround])
AT_DATA([Foo.in],
[@datadir@
@docdir@
@infodir@
@localedir@
@mandir@
])
AT_DATA([Bar.in],
[@mydatadir@
])
AT_DATA([configure.ac],
[[AC_INIT
d@&t@nl The following line silences the warnings, if uncommented:
d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
# This substitution is wrong and bogus! Don't use it in your own code!
# Read `info Autoconf "Defining Directories"'!
AC_SUBST([mydatadir], [${datadir}/my])
AC_CONFIG_FILES([Foo Bar])
AC_OUTPUT
]])
cp "$abs_top_srcdir/build-aux/install-sh" .
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [], [],
[config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
config.status: WARNING: Bar contains a reference to the variable `datarootdir'
which seems to be undefined. Please make sure it is defined
])
AT_CHECK([grep datarootdir Foo], 1, [])
rm configure
sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
mv t configure.ac
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
## -------- ##
## srcdir. ##
## -------- ##
AT_SETUP([srcdir])
rm -f -r at-dir
mkdir at-dir
: >at-dir/bar.in
: >foo.in
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_FILES([foo at-dir/bar])
# Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
# containing e.g., spaces or shell meta-characters.
# Use *single* quotes because the context is an unquoted here-doc.
AC_CONFIG_COMMANDS([report],
[test -f "$srcdir/configure.ac" ||
AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
[srcdir='$srcdir'])
AC_OUTPUT
rm -f -r foo at-dir/bar
]])
AT_CHECK_AUTOCONF
# In place.
AT_CHECK([./configure $configure_options], [], [ignore])
# Relative name.
AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
# Absolute name.
at_here=`pwd`
AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
AT_CLEANUP
## ------- ##
## VPATH. ##
## ------- ##
AT_SETUP([VPATH])
dirs='at paren brace space'
for dir in $dirs; do
mkdir $dir $dir/s1 $dir/s2
touch $dir/f $dir/s1/f1 $dir/s2/f2
done
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
AC_OUTPUT
]])
AT_DATA([at/Makefile.in],
[[# This is what you should use in order to be portable to old makes.
srcdir = @srcdir@
VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
all: f f1 f2
@echo ok
]])
AT_DATA([paren/Makefile.in],
[[# This works with some makes but not with old ones.
srcdir = @srcdir@
VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
all: f f1 f2
@echo ok
]])
AT_DATA([brace/Makefile.in],
[[# This works with some makes but not with old ones.
srcdir = @srcdir@
VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
all: f f1 f2
@echo ok
]])
AT_DATA([space/Makefile.in],
[[# This fails with FreeBSD make, for example.
srcdir = @srcdir@
VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
all: f f1 f2
@echo ok
]])
AT_CHECK_AUTOCONF
# In place.
AT_CHECK([./configure $configure_options], [], [ignore])
# Treat BSD make separately, afterwards, for maximal coverage.
dirs='at paren brace'
for dir in $dirs; do
AT_CHECK_MAKE([], [$dir])
done
rm -f config.status
mkdir build absbuild
# Relative name.
AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
for dir in $dirs; do
AT_CHECK_MAKE([], [build/$dir])
done
# Absolute name.
at_here=`pwd`
AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
for dir in $dirs; do
AT_CHECK_MAKE([], [absbuild/$dir])
done
# These will not pass with BSD make.
AT_CHECK_MAKE([|| exit 77], [space])
AT_CHECK_MAKE([], [build/space])
AT_CHECK_MAKE([], [absbuild/space])
AT_CLEANUP
## ----------------- ##
## Signal handling. ##
## ----------------- ##
AT_SETUP([Signal handling])
AT_DATA([configure.ac],
[[AC_INIT
kill -2 $$
exit 77
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [1], [ignore], [ignore])
AT_CLEANUP
## ----------------- ##
## AC_CONFIG_LINKS. ##
## ----------------- ##
AT_SETUP([AC_CONFIG_LINKS])
AT_DATA([configure.ac],
[[AC_INIT([config links to config files test], [1.0])
AC_CONFIG_SRCDIR([sub1/file1.in])
AC_CONFIG_FILES([sub1/file1 file2])
AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
AC_OUTPUT
]])
mkdir sub1
AT_DATA([sub1/file1.in],
[[/* @configure_input@ */
#define PACKAGE_STRING "@PACKAGE_STRING@"
]])
AT_DATA([file2.in],
[[/* @configure_input@ */
#define PACKAGE_STRING "@PACKAGE_STRING@"
]])
mkdir build
AT_CHECK_AUTOCONF
cd build
AT_CHECK([../configure && ../configure], 0, [ignore])
AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
])
AT_CHECK([../configure && ../configure], 0, [ignore])
AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
])
cd ..
rm -rf build
mkdir build
cd build
cwd=`pwd`
AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
])
cd ..
AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
])
cwd=`pwd`
AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
])
AT_CLEANUP
## ------------------------------------- ##
## AC_CONFIG_LINKS and identical files. ##
## ------------------------------------- ##
AT_SETUP([AC_CONFIG_LINKS and identical files])
AT_DATA([configure.ac],
[[AC_INIT
AC_CONFIG_LINKS([src/s:src/s])
test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
AC_OUTPUT
]])
mkdir src build
echo file1 > src/s
echo file2 > src/t
AT_CHECK_AUTOCONF
cd build
AT_CHECK([../configure $configure_options && ../configure $configure_options],
0, [ignore])
AT_CHECK([cat src/s src/t], 0, [file1
file2
])
cd ..
rm -rf build
mkdir build
cd build
cwd=`pwd`
AT_CHECK(["$cwd"/../configure], 0, [ignore])
AT_CHECK([cat src/s src/t], 0, [file1
file2
])
AT_CHECK(["$cwd"/../configure], 0, [ignore])
AT_CHECK([cat src/s src/t], 0, [file1
file2
])
cd ..
AT_CHECK([./configure $configure_options && ./configure $configure_options],
0, [ignore], [stderr])
AT_CHECK([grep src/t stderr], 1)
AT_CHECK([cat src/s src/t], 0, [file1
file2
])
cwd=`pwd`
AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
AT_CHECK([cat src/s src/t], 0, [file1
file2
])
AT_CLEANUP
AT_BANNER([autoreconf.])
## ---------------------------- ##
## Configuring subdirectories. ##
## ---------------------------- ##
# .
# |-- builddir
# | |-- config.log
# | |-- config.status
# | `-- inner
# | |-- config.log
# | |-- config.status
# | `-- innermost
# | `-- config
# |-- configure
# |-- configure.ac
# |-- inner
# | |-- configure
# | |-- configure.ac
# | `-- innermost
# | `-- config.in
# `-- install-sh
#
AT_SETUP([Configuring subdirectories])
AT_KEYWORDS(autoreconf)
# We use aclocal (via autoreconf).
AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
# It should understand configure.ac.
AT_CHECK([[grep '[^0-9]1\.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
# Prevent aclocal from reading third-party macros, in case they are buggy.
mkdir empty
ACLOCAL="aclocal --system-acdir=`cd empty && pwd`"
export ACLOCAL
# The contents of `inner/', and `inner/innermost/'.
AS_MKDIR_P([inner/innermost])
AT_DATA([inner/configure.ac],
[[AC_INIT(GNU Inner, 1.0)
AC_CONFIG_SRCDIR([innermost/config.in])
AC_ARG_VAR([INNER], [an inner variable])
AC_SUBST([INNER])
if test "x$INNER" = x; then
INNER=inner
fi
AC_CONFIG_FILES([innermost/config])
AC_OUTPUT
]])
AT_DATA([inner/innermost/config.in],
[INNER=@INNER@
srcdir=@srcdir@
top_srcdir=@top_srcdir@
prefix=@prefix@
])
# The contents of `.'
AT_DATA([install-sh], [])
# nonexistent is allowed not to exist.
AT_DATA([configure.ac],
[[AC_INIT(GNU Outer, 1.0)
AC_ARG_VAR([OUTER], [an outer variable])
if false; then
AC_CONFIG_SUBDIRS([nonexistent])
fi
AC_CONFIG_SUBDIRS([inner])
AC_OUTPUT
]])
AT_CHECK([autoreconf])
AT_CHECK([test -f inner/configure])
# Running the outer configure recursively should provide the innermost
# help strings.
chmod a-w inner/innermost inner .
AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
[ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod u+w . inner inner/innermost
# Running the outer configure should trigger the inner.
AT_CHECK_CONFIGURE
AT_CHECK([cat inner/innermost/config], 0,
[INNER=inner
srcdir=.
top_srcdir=..
prefix=/usr/local
])
# The same, but from a builddir.
AS_MKDIR_P([builddir])
AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
AT_CHECK([cat builddir/inner/innermost/config], 0,
[INNER=inner
srcdir=../../../inner/innermost
top_srcdir=../../../inner
prefix=/usr/local
])
# Make sure precious variables and command line options are properly
# passed, even when there are duplicates.
AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
0, [ignore])
AT_CHECK([cat builddir/inner/innermost/config], 0,
[INNER=good
srcdir=../../../inner/innermost
top_srcdir=../../../inner
prefix=/good
])
# Make sure --prefix is properly quoted
AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
AT_CHECK([cat builddir/inner/innermost/config], 0,
[INNER=inner
srcdir=../../../inner/innermost
top_srcdir=../../../inner
prefix=/a b c$ 'd
])
# Make sure --silent is properly passed...
AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
# ...but not stored in config.status.
AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
# --cache-file is adjusted for subdirectories, so the cache is shared.
AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
[], [stdout])
AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
# Make sure we can run autoreconf on a subdirectory
rm -f configure configure.ac
AT_CHECK([autoreconf inner], [], [], [ignore])
# Make sure we can pass a configure.ac name
AT_CHECK([cd inner && autoreconf configure.ac], [], [], [ignore])
AT_CHECK([autoreconf inner/configure.ac], [], [], [ignore])
AT_CLEANUP
## -------------- ##
## Deep Package. ##
## -------------- ##
AT_SETUP([Deep Package])
AT_KEYWORDS(autoreconf)
# We use aclocal (via autoreconf).
AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
# Prevent aclocal from reading third-party macros, in case they are buggy.
mkdir empty
ACLOCAL="aclocal --system-acdir=`cd empty && pwd`"
export ACLOCAL
# The contents of `.'
AT_DATA([install-sh], [])
AT_DATA([configure.ac],
[[AC_INIT(GNU Outer, 1.0)
AC_ARG_VAR([OUTER], [an outer variable])
AC_CONFIG_SUBDIRS([
inner
inner2
])
AC_OUTPUT
]])
# The contents of `inner/', and `inner/innermost/'.
AS_MKDIR_P([inner/innermost])
AS_MKDIR_P([inner2])
AT_DATA([inner/configure.ac],
[[AC_INIT(GNU Inner, 1.0)
AC_ARG_VAR([INNER], [an inner variable])
AC_CONFIG_SUBDIRS(innermost)
AC_OUTPUT
]])
AT_DATA([inner/innermost/configure.ac],
[[AC_INIT(GNU Innermost, 1.0)
AC_ARG_VAR([INNERMOST], [an innermost variable])
AC_CONFIG_HEADERS(config.h:config.hin)
AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
if test -n "$innermost_error"; then
AC_MSG_FAILURE([error in $PACKAGE_NAME])
fi
AC_OUTPUT
]])
AT_DATA([inner2/configure.ac],
[[AC_INIT(GNU Inner 2, 1.0)
AC_ARG_VAR([INNER2], [an inner2 variable])
AC_OUTPUT
]])
AT_CHECK([autoreconf -Wall], [0], [ignore])
AT_CHECK([test -f inner/configure])
AT_CHECK([test -f inner/innermost/configure])
AT_CHECK([test -f inner/innermost/config.hin])
AT_CHECK([test -f inner2/configure])
# Running the outer configure recursively should provide the innermost
# help strings.
chmod a-w inner/innermost inner
AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w .
AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w .
AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w .
AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w .
AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w .
AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod u+w inner inner/innermost
# Running the outer configure should trigger the inner.
AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
[[#define INNERMOST tsomrenni
]])
# Ensure we point to the right config.log file for errors.
AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
cd inner
AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
AT_CHECK([grep 'innermost' stderr], [], [ignore])
cd ..
# The same, but from a builddir.
AS_MKDIR_P([builddir])
chmod a-w builddir inner/innermost inner
AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w builddir
AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w builddir
AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w builddir
AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod a-w builddir
# Not all shells search $PATH for scripts.
if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
fi
AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
0, [ignore], [stderr],
[AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
chmod u+w builddir inner inner/innermost
AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
[[#define INNERMOST build/tsomrenni
]])
AT_CLEANUP
## -------------------------------- ##
## Non-Autoconf AC_CONFIG_SUBDIRS. ##
## -------------------------------- ##
AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
AT_KEYWORDS([autoreconf])
# We use aclocal (via autoreconf).
AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
# Prevent aclocal from reading third-party macros, in case they are buggy.
mkdir empty
ACLOCAL="aclocal --system-acdir=`cd empty && pwd`"
export ACLOCAL
AT_DATA([install-sh], [])
AT_DATA([configure.ac],
[[AC_INIT(GNU Outer, 1.0)
AC_CONFIG_SUBDIRS([inner])
AC_OUTPUT
]])
AS_MKDIR_P([inner])
AT_DATA([inner/configure],
[[#! /bin/sh
case "$*" in
*--help*) echo 'No Autoconf here, folks!' ;;
*) echo got_it >myfile ;;
esac
exit 0
]])
chmod +x inner/configure
AT_CHECK([autoreconf -Wall], 0, [ignore])
# Running the outer configure recursively should provide the innermost
# help strings.
AT_CHECK([./configure $configure_options --help=recursive | grep "folks"],
[0], [ignore])
# Running the outer configure should trigger the inner.
AT_CHECK([./configure $configure_options], 0, [ignore])
AT_CHECK([test -f inner/myfile], 0)
AT_CLEANUP
## ------------------------------- ##
## Non-literal AC_CONFIG_SUBDIRS. ##
## ------------------------------- ##
AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
AT_KEYWORDS([autoreconf])
AT_DATA([install-sh], [])
AT_DATA([configure.ac],
[[AC_INIT(GNU Outer, 1.0)
my_subdirs=
# Taken from autoconf.texi:Subdirectories.
if test "x$package_foo_enabled" = xyes; then
my_subdirs="$my_subdirs foo"
fi
AC_CONFIG_SUBDIRS([$my_subdirs])
AC_OUTPUT
]])
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
AS_MKDIR_P([foo])
AT_DATA([foo/configure],
[[#! /bin/sh
touch innerfile
exit 0
]])
chmod +x foo/configure
# autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
AT_CHECK([./configure $configure_options], [0], [ignore])
AT_CHECK([test ! -f foo/innerfile])
# Running the outer configure should trigger the inner.
AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
AT_CHECK([test -f foo/innerfile])
AT_CLEANUP
## ------------------------- ##
## Empty AC_CONFIG_SUBDIRS. ##
## ------------------------- ##
AT_SETUP([Empty AC_CONFIG_SUBDIRS])
AT_KEYWORDS([autoreconf])
AT_DATA([install-sh], [])
AT_DATA([configure.ac],
[[AC_INIT(GNU Outer, 1.0)
AC_CONFIG_SUBDIRS()
AC_OUTPUT
]])
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
# autoreconf should have no complaints, and the generated configure
# script should run fine with or without --no-recursion.
AT_CHECK([autoreconf -Werror], [0], [ignore])
AT_CHECK_CONFIGURE()
AT_CHECK_CONFIGURE([--no-recursion])
AT_CLEANUP
## ----------------- ##
## Empty directory. ##
## ----------------- ##
AT_SETUP([Empty directory])
AT_KEYWORDS([autoreconf])
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
ACLOCAL=true
export ACLOCAL
# The test group directory is not necessarily _empty_, but it does not contain
# files meaningful to `autoreconf'.
AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
AT_CLEANUP
## ------------------------------ ##
## Unusual Automake input files. ##
## ------------------------------ ##
# This parallels gnumake.test in Automake.
AT_SETUP([Unusual Automake input files])
AT_KEYWORDS([autoreconf])
# We use aclocal and automake via autoreconf.
AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
# Prevent aclocal from reading third-party macros, in case they are buggy.
# (AM_INIT_AUTOMAKE will still be available via the default --automake-acdir.)
mkdir empty
ACLOCAL="aclocal --system-acdir=`cd empty && pwd`"
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT(GNU foo, 1.0)
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([HeeHee])
AC_OUTPUT
]])
AT_DATA([HeeHee.am],
[[# Humans do no worse than `GNUmakefile.am'.
AUTOMAKE_OPTIONS = foreign 1.8
]])
AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
[AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
AT_CHECK([test -f HeeHee.in])
AT_CLEANUP
## ------------------------------ ##
## Specific warnings options. ##
## ------------------------------ ##
AT_SETUP([Specific warnings options for autoreconf])
AT_KEYWORDS([autoreconf])
# If autoreconf is given a -W option that's mentioned in its own
# --help output, that option should not cause errors, even if some
# of the subsidiary programs don't support it.
# We use aclocal and automake via autoreconf.
AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
# Prevent aclocal from reading third-party macros, in case they are buggy.
# (AM_INIT_AUTOMAKE will still be available via the default --automake-acdir.)
mkdir empty
ACLOCAL="aclocal --system-acdir=`cd empty && pwd`"
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT(GNU foo, 1.0)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])
AT_DATA([Makefile.am],
[[AUTOMAKE_OPTIONS = foreign
]])
# To silence complaints about required helper scripts from automake.
# We aren't going to run the generated Makefile so we don't need the
# real helper scripts.
AT_DATA([install-sh], [])
AT_DATA([missing], [])
# In order to cut down the time this test takes, we do not test all
# of the supported warning categories, just the most common case
# (-Wall) and some specific categories that are known to have been a
# problem in the past.
AT_CHECK([autoreconf -Werror -Wall], 0, [], [])
rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
AT_CHECK([autoreconf -Werror -Wcross], 0, [], [])
rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
AT_CHECK([autoreconf -Werror -Wportability-recursive], 0, [], [])
rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
AT_CLEANUP
## ------------------------- ##
## Missing auxiliary files. ##
## ------------------------- ##
AT_SETUP([Missing auxiliary files (config.*)])
AT_KEYWORDS([autoreconf])
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT([GNU foo], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AC_CANONICAL_HOST
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
# Both configure and autoreconf should detect the missing files.
AT_CHECK_CONFIGURE([], [1], [ignore],
[configure: error: cannot find required auxiliary files: config.guess config.sub
])
AT_CHECK([autoreconf], 1, [],
[configure.ac: error: required file 'config.sub' not found
configure.ac: error: required file 'config.guess' not found
configure.ac: try running autoreconf --install
])
# If only one file is missing, the error messages should only report
# that one. Also, the above invocation of autoreconf should _not_
# have created build-aux, because it wasn't called with --install.
AT_CHECK([test ! -e build-aux])
mkdir build-aux
: > build-aux/config.guess
AT_CHECK_CONFIGURE([], [1], [ignore],
[configure: error: cannot find required auxiliary files: config.sub
])
AT_CHECK([autoreconf], 1, [],
[configure.ac: error: required file 'config.sub' not found
configure.ac: try running autoreconf --install
])
# Missing aux files should not interfere with --help and --version.
AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
# autoreconf --install should be able to install config.sub and config.guess.
rm build-aux/config.guess
AT_CHECK([autoreconf --install])
AT_CHECK([test -x build-aux/config.guess])
AT_CHECK([test -x build-aux/config.sub])
AT_CHECK([test ! -e build-aux/install-sh])
AT_CHECK_CONFIGURE
AT_CLEANUP
AT_SETUP([Missing auxiliary files (install-sh)])
AT_KEYWORDS([autoreconf])
# Same as "Missing auxiliary files (config.*)" except that the
# configure script _doesn't_ need config.{sub,guess} but does need
# install-sh.
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT([GNU foo], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AC_PROG_INSTALL
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
# Both configure and autoreconf should detect the missing files.
AT_CHECK_CONFIGURE([], [1], [ignore],
[configure: error: cannot find required auxiliary files: install-sh
])
AT_CHECK([autoreconf], 1, [],
[configure.ac: error: required file 'install-sh' not found
configure.ac: try running autoreconf --install
])
AT_CHECK([test ! -e build-aux])
AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
AT_CHECK([autoreconf --install])
AT_CHECK([test ! -e build-aux/config.guess])
AT_CHECK([test ! -e build-aux/config.sub])
AT_CHECK([test -x build-aux/install-sh])
AT_CHECK_CONFIGURE
AT_CLEANUP
AT_SETUP([Missing auxiliary files (foreign)])
AT_KEYWORDS([autoreconf])
# If an aux file is required that autoreconf doesn't know how to install,
# it shouldn't suggest autoreconf --install.
# This also verifies that AC_REQUIRE_AUX_FILE can be used outside of a
# macro definition, which was always the intent, and was recommended
# usage in some automake recipes, but which was broken in autoconf
# beta 2.69d (see https://savannah.gnu.org/support/?110363).
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT([GNU foo], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([], [1], [ignore],
[configure: error: cannot find required auxiliary files: tap-driver.sh
])
AT_CHECK([autoreconf], 1, [],
[configure.ac: error: required file 'tap-driver.sh' not found
])
AT_CHECK([test ! -e build-aux])
AT_CHECK([autoreconf --install], 1, [],
[configure.ac: error: required file 'tap-driver.sh' not found
])
# autoreconf --install always creates the aux directory.
AT_CHECK([test -e build-aux])
touch build-aux/tap-driver.sh
AT_CHECK([autoreconf])
AT_CHECK_CONFIGURE
AT_CLEANUP
AT_SETUP([Missing auxiliary files (--force)])
AT_KEYWORDS([autoreconf])
# Aux files that already exist should not be overwritten, unless
# --force is used, in which case they *should* be overwritten.
# Additional wrinkle: in case automake got to the files we install
# first, we need to *not* overwrite a newer copy supplied by them.
# Prevent autoreconf from running aclocal, which might not exist,
# or could barf over warnings in third-party macro files.
AT_DATA([aclocal.m4])
ACLOCAL=true
export ACLOCAL
AT_DATA([configure.ac],
[[AC_INIT([GNU foo], [1.0])
AC_CONFIG_AUX_DIR([build-aux])
AC_PROG_INSTALL
AC_CANONICAL_HOST
AC_OUTPUT
]])
mkdir build-aux
AT_DATA([build-aux/config-guess.old],
[[#! /bin/sh
timestamp='1970-01-01'
printf '%s\n' 'frobozz-bogon-bogos1'
]])
AT_DATA([build-aux/config-sub.new],
[[#! /bin/sh
scriptversion='9999-12-31'
printf '%s\n' "$*"
]])
AT_DATA([build-aux/install-sh.old],
[[#! /bin/sh
# Old versions of install-sh did not have a timestamp line.
]])
cp build-aux/config-guess.old build-aux/config.guess
cp build-aux/config-sub.new build-aux/config.sub
cp build-aux/install-sh.old build-aux/install-sh
chmod +x build-aux/config.sub build-aux/config.guess build-aux/install-sh
# This pass should not change any of the files.
AT_CHECK([autoreconf --install])
AT_CMP([build-aux/config-guess.old], [build-aux/config.guess])
AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
AT_CMP([build-aux/install-sh.old], [build-aux/install-sh])
# This pass should change only config.guess and install-sh, not config.sub.
AT_CHECK([autoreconf --install --force])
AT_CHECK(
[if cmp build-aux/config-guess.old build-aux/config.guess > /dev/null 2>&1
then exit 1
fi])
AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
AT_CHECK(
[if cmp build-aux/install-sh.old build-aux/install-sh > /dev/null 2>&1
then exit 1
fi])
AT_CLEANUP
## ------------------------------ ##
## Files clobbered by AC_OPENMP. ##
## ------------------------------ ##
AT_SETUP([Files clobbered by AC_OPENMP])
AT_CONFIGURE_AC(
[[AC_PROG_CC
AC_OPENMP
]])
AT_CHECK_AUTOHEADER
# autoconf should bomb out if either 'mp' or 'openmp' exists in the
# srcdir.
AT_DATA([mp])
AT_CHECK_AUTOCONF([], [1], [], [stderr])
AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
[0], [ignore], [ignore])
rm -f mp
AT_DATA([penmp])
AT_CHECK_AUTOCONF([], [1], [], [stderr])
AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
[0], [ignore], [ignore])
rm -f penmp
# If neither of these files exist, autoconf should go through...
AT_CHECK_AUTOCONF
# ... but configure should bomb out, and *not* delete the files,
# if they are added after autoconf is run.
AT_DATA([mp])
AT_CHECK_CONFIGURE([], [1], [], [stderr])
AT_CHECK([test -e mp])
AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
[0], [ignore], [ignore])
rm -f mp
AT_DATA([penmp])
AT_CHECK_CONFIGURE([], [1], [], [stderr])
AT_CHECK([test -e penmp])
AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
[0], [ignore], [ignore])
rm -f penmp
AT_CHECK_CONFIGURE
AT_CHECK_ENV
AT_CLEANUP
|