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
|
# -*- Autotest -*-
AT_BANNER([Semantics.])
# Copyright (C) 2000-2002, 2004-2007, 2009-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/>.
## -------------------------------- ##
## Members of the AC_CHECK family. ##
## -------------------------------- ##
# AC_CHECK_LIB
# ------------
# Test for symbols in a library that is very likely to be available
# and can be used from both C and C++: zlib, which we assume is
# available unless <zlib.h> doesn't exist.
# We used to use math library symbols for this, but that no longer
# works, because some C++ compilers pull in libm by default when the
# matching C compiler doesn't, breaking AT_CHECK_MACRO's expectations.
AT_CHECK_MACRO([AC_CHECK_LIB], [[
AC_CHECK_HEADER([zlib.h], [], [
AC_MSG_NOTICE([zlib not available, skipping test])
AS_EXIT(77)
])
# Using : for the ACTION-IF-FOUND in each call to AC_CHECK_LIB
# prevents LIBS from accumulating copies of "-lz".
AC_CHECK_LIB([z], [zlibVersion], [:], [
AC_MSG_ERROR([cannot find zlibVersion in libz])
])
if test "${ac_cv_lib_z_zlibVersion+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_zlibVersion not set])
fi
# No kidding, using variables was broken in 2.50 :(
ac_deflate=deflate
AC_CHECK_LIB([z], [$ac_deflate], [:], [
AC_MSG_ERROR([cannot find \$ac_deflate (= $ac_deflate) in libz])
])
if test "${ac_cv_lib_z_deflate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_deflate not set])
fi
ac_z=z
AC_CHECK_LIB([$ac_z], [deflateEnd], [:], [
AC_MSG_ERROR([cannot find deflateEnd in lib\$ac_z (= lib$ac_z)])
])
if test "${ac_cv_lib_z_deflateEnd+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_deflateEnd not set])
fi
ac_inflate=inflate
AC_CHECK_LIB([$ac_z], [$ac_inflate], [:], [
AC_MSG_ERROR(
[cannot find \$ac_inflate (= $ac_inflate) in lib\$ac_z (= lib$ac_z)])
])
if test "${ac_cv_lib_z_inflate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_inflate not set])
fi
# Also test for symbols that don't (well, shouldn't) exist.
# These should still set their cache variables!
AC_CHECK_LIB([z], [deflagrate], [
AC_MSG_ERROR([found deflagrate in libz])
], [:])
if test "${ac_cv_lib_z_deflagrate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_zlibVersion not set])
fi
ac_defenestrate=defenestrate
AC_CHECK_LIB([z], [$ac_defenestrate], [
AC_MSG_ERROR([found \$ac_defenestrate (= $ac_defenestrate) in libz])
], [:])
if test "${ac_cv_lib_z_defenestrate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_defenestrate not set])
fi
AC_CHECK_LIB([$ac_z], [defoliate], [
AC_MSG_ERROR([found defoliate in lib\$ac_z (= lib$ac_z)])
], [:])
if test "${ac_cv_lib_z_defoliate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_defoliate not set])
fi
ac_infiltrate=infiltrate
AC_CHECK_LIB([$ac_z], [$ac_infiltrate], [
AC_MSG_ERROR(
[found \$ac_infiltrate (= $ac_infiltrate) in lib\$ac_z (= lib$ac_z)])
], [:])
if test "${ac_cv_lib_z_infiltrate+set}" != set; then
AC_MSG_ERROR([ac_cv_lib_z_infiltrate not set])
fi
]])
# AC_SEARCH_LIBS
# --------------
# Like AC_CHECK_LIBS, we use zlib here because we need the behavior to
# be consistent between the C and C++ compilers.
AT_CHECK_MACRO([AC_SEARCH_LIBS (needed)], [[
AC_CHECK_HEADER([zlib.h], [], [
AC_MSG_NOTICE([zlib not available, skipping test])
AS_EXIT(77)
])
# Unlike AC_CHECK_LIBS, AC_SEARCH_LIBS sets $LIBS *even if*
# ACTION-IF-FOUND is given, so we need to reset it after each test.
ac_at_save_LIBS="$LIBS"
AC_SEARCH_LIBS([zlibVersion], [z], [:], [:])
if test x"$ac_cv_search_zlibVersion" != x-lz; then
AC_MSG_ERROR([wrong zlibVersion search result: $ac_cv_search_zlibVersion])
fi
LIBS="$ac_at_save_LIBS"
# No kidding, using variables was broken in 2.50 :(
ac_deflate=deflate
AC_SEARCH_LIBS([$ac_deflate], [z], [:], [:])
if test x"$ac_cv_search_deflate" != x-lz; then
AC_MSG_ERROR([wrong deflate search result: $ac_cv_search_deflate])
fi
LIBS="$ac_at_save_LIBS"
ac_z=z
AC_SEARCH_LIBS([deflateEnd], [$ac_z], [:], [:])
if test x"$ac_cv_search_deflateEnd" != x-lz; then
AC_MSG_ERROR([wrong deflateEnd search result: $ac_cv_search_deflateEnd])
fi
LIBS="$ac_at_save_LIBS"
ac_inflate=inflate
AC_SEARCH_LIBS([$ac_inflate], [$ac_z], [:], [:])
if test x"$ac_cv_search_inflate" != x-lz; then
AC_MSG_ERROR([wrong inflate search result: $ac_cv_search_inflate])
fi
LIBS="$ac_at_save_LIBS"
# Also test for symbols that don't (well, shouldn't) exist.
# These should still set their cache variables!
AC_SEARCH_LIBS([deflagrate], [z], [:], [:])
if test x"$ac_cv_search_deflagrate" != xno; then
AC_MSG_ERROR([wrong deflagrate search result: $ac_cv_search_deflagrate])
fi
LIBS="$ac_at_save_LIBS"
ac_defenestrate=defenestrate
AC_SEARCH_LIBS([$ac_defenestrate], [z], [:], [:])
if test x"$ac_cv_search_defenestrate" != xno; then
AC_MSG_ERROR([wrong defenestrate search result: $ac_cv_search_defenestrate])
fi
LIBS="$ac_at_save_LIBS"
AC_SEARCH_LIBS([defoliate], [$ac_z], [:], [:])
if test x"$ac_cv_search_defoliate" != xno; then
AC_MSG_ERROR([wrong defoliate search result: $ac_cv_search_defoliate])
fi
LIBS="$ac_at_save_LIBS"
ac_infiltrate=infiltrate
AC_SEARCH_LIBS([$ac_infiltrate], [$ac_z], [:], [:])
if test x"$ac_cv_search_infiltrate" != xno; then
AC_MSG_ERROR([wrong infiltrate search result: $ac_cv_search_infiltrate])
fi
LIBS="$ac_at_save_LIBS"
]])
# AC_SEARCH_LIBS (none needed)
# ----------------------------
# This test doesn't need to be nearly as thorough as the above; its
# purpose is simply to ensure that when no library is needed,
# AC_SEARCH_LIBS really does produce "none needed" as its result.
AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)], [[
# No library should be required to link with printf, but we throw
# -lc in the search list so that it includes both libraries that
# don't exist and libraries that probably do.
AC_SEARCH_LIBS([printf], [oser c ust], [:], [:])
if test x"$ac_cv_search_printf" != "xnone required"; then
AC_MSG_ERROR([wrong printf search result: $ac_cv_search_printf])
fi
]])
# AC_CHECK_DECLS
# --------------
# Check that it performs the correct actions:
AT_CHECK_MACRO([AC_CHECK_DECLS],
[[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
[[extern int yes;
enum { myenum };
extern struct mystruct_s { int x[20]; } mystruct;
extern int myfunc (int);
#define mymacro1(arg) arg
#define mymacro2]])
# Ensure we can detect missing declarations of functions whose
# signature may be built into the compiler.
AC_CHECK_DECLS([memcpy, strchr, strerror],,, [[]])
# The difference in space-before-open-paren is intentional.
AC_CHECK_DECLS([basenam (char *), dirnam(char *),
moreargs (char, short, int, long, void *, char *, float, double)],,,
[[#ifdef __cplusplus
extern "C++" char *basenam (char *);
extern "C++" const char *basenam (const char *);
#else
extern char *basenam (const char *);
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int moreargs (char, short, int, long, void *,
char [], float, double);
#ifdef __cplusplus
}
#endif
]])
AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
[[#ifdef __cplusplus
extern "C++" char *declared (char *);
extern "C++" const char *declared (const char *);
#else
extern char *declared (const char *);
#endif
]])
AC_LANG_WERROR
AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
if test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag"; then
AC_MSG_ERROR([ac_]_AC_LANG_ABBREV[_werror_flag overwritten])
fi
]],
[AT_CHECK_DEFINES(
[#define HAVE_DECL_BASENAM 1
#define HAVE_DECL_DIRNAM 0
#define HAVE_DECL_MEMCPY 0
#define HAVE_DECL_MOREARGS 1
#define HAVE_DECL_MYENUM 1
#define HAVE_DECL_MYFUNC 1
#define HAVE_DECL_MYMACRO1 1
#define HAVE_DECL_MYMACRO2 1
#define HAVE_DECL_MYSTRUCT 1
#define HAVE_DECL_NO 0
#define HAVE_DECL_STRCHR 0
#define HAVE_DECL_STRERROR 0
#define HAVE_DECL_YES 1
])])
# AC_CHECK_FUNCS
# --------------
# Check that it performs the correct actions:
# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
AT_CHECK_MACRO([AC_CHECK_FUNCS],
[AC_CHECK_FUNCS(printf autoconf_ftnirp)],
[AT_CHECK_DEFINES(
[/* #undef HAVE_AUTOCONF_FTNIRP */
#define HAVE_PRINTF 1
])])
# AC_REPLACE_FUNCS
# ----------------
# Check that it performs the correct actions: autoconf_ftnirp.c must
# be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
# FIXME: Maybe check the traces?
AT_SETUP([AC_REPLACE_FUNCS])
AT_DATA([config.in],
[@LIBOBJS@
])
# AC_REPLACE_FUNCS has an AS_LITERAL_IF optimization; test both paths.
# Manual invocation of AH_TEMPLATE should only be necessary for functions
# whose names are hidden inside a shell variable at m4 expansion time.
AT_CONFIGURE_AC(
[[AC_CONFIG_FILES([config.libobjs:config.in])
AC_REPLACE_FUNCS([printf autoconf_ftnirp])
funcs='fprintf autoconf_ftnirpf'
AH_TEMPLATE([HAVE_FPRINTF], [])
AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
AC_REPLACE_FUNCS([\
$funcs \
fopen \
autoconf_nepof])
AS@&t@_UNSET([funcs])]])
AT_CHECK_AUTOCONF([], [], [],
[[configure.ac:9: warning: AC_REPLACE_FUNCS($funcs): you should use literals
functions.m4: AC_REPLACE_FUNCS is expanded from...
configure.ac:9: the top level
]])
AT_CHECK_AUTOHEADER([], [
HAVE_AUTOCONF_FTNIRP
HAVE_AUTOCONF_FTNIRPF
HAVE_AUTOCONF_NEPOF
HAVE_FOPEN
HAVE_FPRINTF
HAVE_PRINTF
])
AT_CHECK_CONFIGURE
AT_CHECK_ENV
AT_CHECK_DEFINES(
[/* #undef HAVE_AUTOCONF_FTNIRP */
/* #undef HAVE_AUTOCONF_FTNIRPF */
/* #undef HAVE_AUTOCONF_NEPOF */
#define HAVE_FOPEN 1
#define HAVE_FPRINTF 1
#define HAVE_PRINTF 1
])
AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs | tr ' ' '
' | sort], [],
[${LIBOBJDIR}autoconf_ftnirp$U.o
${LIBOBJDIR}autoconf_ftnirpf$U.o
${LIBOBJDIR}autoconf_nepof$U.o
])
AT_CLEANUP
# AC_CHECK_HEADERS
# ----------------
# Check that it performs the correct actions:
# Must define HAVE_FLOAT_H, but not HAVE_AUTOCONF_IO_H.
AT_SETUP([AC_CHECK_HEADERS])
AT_DATA([autoconf_io.h],
[blah blah
])
AT_CONFIGURE_AC([AC_CHECK_HEADERS([float.h autoconf_io.h])])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([], [
HAVE_AUTOCONF_IO_H
HAVE_FLOAT_H
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
])
AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
AT_CHECK_ENV
AT_CHECK_DEFINES(
[/* #undef HAVE_AUTOCONF_IO_H */
#define HAVE_FLOAT_H 1
])
AT_CLEANUP
# AC_CHECK_HEADERS_OLD
# --------------------
# Check that it performs the correct actions:
# Must not check prerequisites, hence define header2.h
AT_SETUP([AC_CHECK_HEADERS (preprocessor test)])
AT_DATA([header1.h],
[typedef int foo;
])
AT_DATA([header2.h],
[typedef foo bar;
])
AT_CONFIGURE_AC([[AC_CHECK_HEADERS([header2.h], [], [], [-])]])
AT_CHECK_AUTOCONF([], 0, [],
[[configure.ac:4: warning: Checking for headers with the preprocessor is
configure.ac:4: deprecated. Specify prerequisite code to AC_CHECK_HEADER
configure.ac:4: instead of using fourth argument '-'. (Many headers need
configure.ac:4: no prerequisites. If you truly need to test whether
configure.ac:4: something passes the preprocessor but not the compiler,
configure.ac:4: use AC_PREPROC_IFELSE.)
headers.m4: _AC_CHECK_HEADER_PREPROC is expanded from...
headers.m4: AC_CHECK_HEADER is expanded from...
headers.m4: AC_CHECK_HEADERS is expanded from...
configure.ac:4: the top level
]])
AT_CHECK_AUTOHEADER([-W no-obsolete], [HAVE_HEADER2_H])
AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
AT_CHECK_ENV
AT_CHECK_DEFINES(
[#define HAVE_HEADER2_H 1
])
AT_CLEANUP
# AC_CHECK_HEADERS_NEW
# --------------------
# Check that it performs the correct actions:
# Must check prerequisites, hence define header2.h but not header3.h
AT_SETUP([AC_CHECK_HEADERS (compiler test)])
AT_DATA([header1.h],
[typedef int foo;
])
AT_DATA([header2.h],
[typedef foo bar;
])
AT_DATA([header3.h],
[typedef bar wow;
])
AT_CONFIGURE_AC(
[AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
AT_CHECK_AUTOCONF
AT_CHECK_AUTOHEADER([], [
HAVE_HEADER2_H
HAVE_HEADER3_H
])
AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
AT_CHECK_ENV
AT_CHECK_DEFINES(
[#define HAVE_HEADER2_H 1
/* #undef HAVE_HEADER3_H */
])
AT_CLEANUP
# AC_CHECK_MEMBER
# ---------------
# Check that it performs the correct actions.
# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
AT_CHECK_MACRO([AC_CHECK_MEMBER],
[[AC_CHECK_MEMBER([struct yes_s.yes],
[AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
[Define to 1 if 'yes' is a member of 'struct yes_s'.])],,
[struct sub { int x; };
struct yes_s { int yes; struct sub substruct; };])
AC_CHECK_MEMBER([struct yes_s.no],
[AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
[Define to 1 if 'no' is a member of 'struct yes_s'.])],,
[struct sub { int x; };
struct yes_s { int yes; struct sub substruct; };])
AC_CHECK_MEMBER([struct yes_s.substruct],
[AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
[Define to 1 if 'substruct' is a member of 'struct yes_s'.])],,
[struct sub { int x; };
struct yes_s { int yes; struct sub substruct; };])]],
[AT_CHECK_DEFINES(
[/* #undef HAVE_STRUCT_YES_S_NO */
#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
#define HAVE_STRUCT_YES_S_YES 1
])])
# AC_CHECK_MEMBERS
# ----------------
# Check that it performs the correct actions.
# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
AT_CHECK_MACRO([AC_CHECK_MEMBERS],
[[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
[struct sub { int x; };
struct yes_s { int yes; struct sub substruct; };])]],
[AT_CHECK_DEFINES(
[/* #undef HAVE_STRUCT_YES_S_NO */
#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
#define HAVE_STRUCT_YES_S_YES 1
])
AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
])
# AC_CHECK_ALIGNOF
# ----------------
AT_CHECK_MACRO([AC_CHECK_ALIGNOF],
[[AC_CHECK_ALIGNOF(char)
AC_CHECK_ALIGNOF(charchar,
[[#include <stddef.h>
#include <stdio.h>
typedef char charchar[2];]])
AC_CHECK_ALIGNOF(charcharchar)
]],
[AT_CHECK_DEFINES(
[#define ALIGNOF_CHAR 1
#define ALIGNOF_CHARCHAR 1
#define ALIGNOF_CHARCHARCHAR 0
])])
# AC_CHECK_ALIGNOF struct
# -----------------------
AT_CHECK_MACRO([AC_CHECK_ALIGNOF struct],
[[AC_CHECK_ALIGNOF([struct { char c; }])
AC_CHECK_ALIGNOF([struct nosuchstruct])
]],
[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
0, ignore)
AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
0, ignore)
])
# AC_CHECK_SIZEOF
# ---------------
AT_CHECK_MACRO([AC_CHECK_SIZEOF],
[[AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(charchar,,
[[#include <stdio.h>
typedef char charchar[2];]])
AC_CHECK_SIZEOF(charcharchar)
]],
[AT_CHECK_DEFINES(
[#define SIZEOF_CHAR 1
#define SIZEOF_CHARCHAR 2
#define SIZEOF_CHARCHARCHAR 0
])])
# AC_CHECK_SIZEOF struct
# ----------------------
AT_CHECK_MACRO([AC_CHECK_SIZEOF struct],
[[AC_C_CONST
AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
AC_CHECK_SIZEOF([struct nosuchstruct])
# Taken from autoconf.texi:Generic Compiler Characteristics.
AC_CHECK_SIZEOF([int *])
]],
[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
0, ignore)
AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
0, ignore)
AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
0, ignore)
AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
0, ignore)
])
# AC_CHECK_TYPES
# --------------
# Check that it performs the correct actions.
# Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
# 'int' and 'struct yes_s' are both checked to test both the compiler
# builtin types, and defined types.
AT_CHECK_MACRO([AC_CHECK_TYPES],
[[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
[struct yes_s { int yes ;} ;])]],
[AT_CHECK_DEFINES(
[#define HAVE_INT 1
/* #undef HAVE_STRUCT_NO_S */
#define HAVE_STRUCT_YES_S 1
])])
# AC_CHECK_TYPES
# --------------
# Check that we properly dispatch properly to the old implementation
# or to the new one.
AT_SETUP([AC_CHECK_TYPES: backward compatibility])
AT_DATA([configure.ac],
[[AC_INIT
define([_AC_CHECK_TYPE_NEW], [NEW])
define([_AC_CHECK_TYPE_OLD], [OLD])
#(cut-from-here
AC_CHECK_TYPE(ptrdiff_t)
AC_CHECK_TYPE(ptrdiff_t, int)
AC_CHECK_TYPE(quad, long long int)
AC_CHECK_TYPE(table_42, [int[42]])
# Nice machine!
AC_CHECK_TYPE(uint8_t, uint65536_t)
AC_CHECK_TYPE(a,b,c,d)
#to-here)
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
0,
[NEW
OLD
OLD
OLD
OLD
NEW
])
AT_CLEANUP
# AC_CHECK_FILES
# --------------
# FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
# open AH_TEMPLATE to 'configure.ac', which is not yet the case.
# Don't use AT_CHECK_MACRO for this one because AC_CHECK_FILES can't be
# used when cross compiling.
AT_CHECK_CONFIGURE_AC([AC_CHECK_FILES],
[[touch at-exists1 at-exists2
ac_exists2=at-exists2
ac_missing2=at-missing2
AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
rm at-exists1 at-exists2]],
[], [],
[AT_CHECK_DEFINES(
[#define HAVE_AT_EXISTS1 1
/* #undef HAVE_AT_MISSING1 */
])])
## ------------------------------ ##
## AC_CHECK_PROG & AC_PATH_PROG. ##
## ------------------------------ ##
# AT_CHECK_PROGS_PREPARE
# ----------------------
# Create a sub directory 'path' with 6 subdirs which all 7 contain
# an executable 'tool'. '6' contains a 'better' tool.
m4_define([AT_CHECK_PROGS_PREPARE],
[mkdir path
cat >path/tool <<\EOF
#! /bin/sh
exit 0
EOF
chmod +x path/tool
for i in 1 2 3 4 5 6
do
mkdir path/$i
cp path/tool path/$i
done
cp path/tool path/6/better])
# -------------------------------- #
# AC_CHECK_PROG & AC_CHECK_PROGS. #
# -------------------------------- #
AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
AT_CHECK_PROGS_PREPARE
AT_DATA([configure.ac],
[[AC_INIT
pwd=`pwd`
p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
fail=false
AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
test "$TOOL1" = found || fail=:
# Yes, the semantics of this macro is weird.
AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
test "$TOOL2" = not-found || fail=:
AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
test "$TOOL3" = "$pwd/path/2/tool" || fail=:
AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
test "$TOOL4" = better || fail=:
# When a tool is not found, and no value is given for not-found,
# the variable is left empty.
AC_CHECK_PROGS(TOOL5, missing,, $path)
test -z "$TOOL5" || fail=:
AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
test "$TOOL6" = tool || fail=:
$fail &&
AC_MSG_ERROR([[CHECK_PROG failed]])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
## ---------------- ##
## AC_C_BIGENDIAN. ##
## ---------------- ##
AT_SETUP([AC_C_BIGENDIAN])
AT_KEYWORDS([cross])
# Make sure that AC_C_BIGENDIAN behave the same whether we are
# cross-compiling or not.
_AT_CHECK_AC_MACRO(
[[AC_C_BIGENDIAN(
[ac_endian=big],
[ac_endian=little],
[ac_endian=unknown],
[ac_endian=universal])
echo $ac_endian > at-endian
]])
rm -f config.hin # So that next run of autoheader is quiet.
_AT_CHECK_AC_MACRO(
[[# Force cross compiling.
cross_compiling=yes
ac_tool_warned=yes
AC_C_BIGENDIAN(
[ac_endian=big],
[ac_endian=little],
[ac_endian=unknown],
[ac_endian=universal])
ac_prevendian=`cat at-endian`
# Check that we have found the same result as in the previous run
# or unknown (because the cross-compiling check is allowed to fail;
# although it might be interesting to suppress this comparison, just
# to know on which system it fails if it ever does).
if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
fi
]])
# Make sure AC_C_BIGENDIAN with no argument will create a config.h template
# containing "WORDS_BIGENDIAN".
AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
# --force is necessary, the computer might be too fast.
AT_CHECK_AUTOHEADER([--force], [
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([grep WORDS_BIGENDIAN config.hin], [], [ignore])
AT_CLEANUP
# ------------------------------ #
# AC_PATH_PROG & AC_PATH_PROGS. #
# ------------------------------ #
AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
AT_CHECK_PROGS_PREPARE
AT_DATA([configure.ac],
[[AC_INIT
pwd=`pwd`
p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
fail=false
AC_PATH_PROG(TOOL1, tool, not-found, $path)
test "$TOOL1" = "$pwd/path/1/tool" || fail=:
AC_PATH_PROG(TOOL2, better, not-found, $path)
test "$TOOL2" = "$pwd/path/6/better" || fail=:
# When a tool is not found, and no value is given for not-found,
# the variable is left empty.
AC_PATH_PROGS(TOOL3, missing,, $path)
test -z "$TOOL3" || fail=:
AC_PATH_PROGS(TOOL4, missing tool better,, $path)
test "$TOOL4" = "$pwd/path/1/tool" || fail=:
$fail &&
AC_MSG_ERROR([[PATH_PROG failed]])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
# ----------------------------- #
# AC_PATH_PROGS_FEATURE_CHECK. #
# ----------------------------- #
AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
# This test doesn't work if `pwd` contains white space
case `pwd` in
*\ * | *\ *) AT_CHECK([exit 77]) ;;
esac
AT_CHECK_PROGS_PREPARE
AT_DATA([configure.ac],
[[AC_INIT
pwd=`pwd`
p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
fail=false
# Find first candidate and stop search
AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
[$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
fail=:, $path)
test -z "$TOOL1" || fail=:
test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
# Keep searching each candidate
AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
[$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
fail=:, $path)
test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
# Only accept better candidate
AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
[case "$ac_path_TOOL3" in #(
*better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
esac],
fail=:, $path)
test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
# When a tool is not found, and no action is given for not-found,
# the variable is left empty.
AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
[ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
test -z "$ac_cv_path_TOOL4" || fail=:
# Test action when tool is not found
AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
[ac_cv_path_TOOL5='not found'], $path)
test "$ac_cv_path_TOOL5" = "not found" || fail=:
# Test that pre-set tool bypasses feature test
TOOL6=$pwd/path/6/better
AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
# A blank pre-set does not bypass feature test
TOOL7=
AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
[$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
fail=:, $path)
test -z "$TOOL7" || fail=:
test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
$fail &&
AC_MSG_ERROR([[PATH_PROG failed]])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
AT_CLEANUP
## -------------- ##
## AC_PATH_XTRA. ##
## -------------- ##
AT_SETUP([AC_PATH_XTRA])
_AT_CHECK_AC_MACRO([AC_PATH_XTRA])
# Check X_DISPLAY_MISSING.
AT_CHECK_CONFIGURE([--without-x])
AT_CHECK_DEFINES(
[#define X_DISPLAY_MISSING 1
])
AT_CLEANUP
## -------------------------------------------------------------------- ##
## AC_SYS_LARGEFILE, AC_SYS_YEAR2038, and AC_SYS_YEAR2038_RECOMMENDED. ##
## -------------------------------------------------------------------- ##
AT_CHECK_MACRO([AC_SYS_LARGEFILE], [],
[AT_CHECK([./configure --help |
$EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
[0],
[ --disable-largefile omit support for large files
--enable-year2038 support timestamps after 2038
],
[])])
AT_CHECK_MACRO([AC_SYS_YEAR2038], [],
[AT_CHECK([./configure --help |
$EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
[0],
[ --disable-largefile omit support for large files
--disable-year2038 don't support timestamps after 2038
],
[])])
AT_CHECK_MACRO([AC_SYS_YEAR2038_RECOMMENDED], [],
[AT_CHECK([./configure --help |
$EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
[0],
[ --disable-largefile omit support for large files
--disable-year2038 don't support timestamps after 2038
],
[])],
[], [],
[dnl Skip this test on systems that do not support 64-bit time_t at
dnl all. AC_SYS_YEAR2038_RECOMMENDED will make configure fail on
dnl those systems. I'd like to make this be a test that it *does*
dnl make configure fail on those systems, but that would require
dnl adding features to AT_CHECK_MACRO.
AT_DATA([configure.ac],
[[AC_INIT
AC_PROG_CC
AC_SYS_YEAR2038
AC_COMPUTE_INT([sizeof_time_t], [sizeof(time_t)],
[@%:@include <time.h>],
[sizeof_time_t=0])
AS@&t@_IF([test $sizeof_time_t -lt 8],
[AC_MSG_FAILURE([could not widen time_t])])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CAPTURE_FILE([config.log])
AT_CHECK([./configure $configure_options || exit 77], [0], [ignore], [])
])
## ------------------------------- ##
## Obsolete non-updatable macros. ##
## ------------------------------- ##
AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete], [no-cross])
AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete], [no-cross])
## ------------------------------------- ##
## Obsolete macros requiring arguments. ##
## ------------------------------------- ##
# These all wrap the macro under test in an AC_CACHE_CHECK and an
# AC_DEFINE so the full verification machinery of AT_CHECK_MACRO is
# effective. Caution: AT_CHECK_AU_MACRO expects that after an
# autoupdate run, a naive grep will not find the old macro name
# anywhere in the updated configure.ac, not even as part of a
# longer identifier. (But it's case sensitive.)
AT_CHECK_AU_MACRO([AC_TRY_CPP],
[[AC_CACHE_CHECK([working ac_try_cpp], [ac_cv_ac_try_cpp_works], [
AC_TRY_CPP([
@%:@if 2 + 2 != 4
@%:@error "SEVEN!" /* in memory of Stanislaw Lem */
@%:@endif
], [ac_cv_ac_try_cpp_works=yes],
[ac_cv_ac_try_cpp_works=no])
])
if test $ac_cv_ac_try_cpp_works = yes; then
AC_DEFINE([ac_try_cpp_works], [1], [label])
fi
]])
AT_CHECK_AU_MACRO([AC_TRY_COMPILE],
[[AC_CACHE_CHECK([working ac_try_compile], [ac_cv_ac_try_compile_works], [
AC_TRY_COMPILE([int variable;], [return variable;],
[ac_cv_ac_try_compile_works=yes],
[ac_cv_ac_try_compile_works=no])
])
if test $ac_cv_ac_try_compile_works = yes; then
AC_DEFINE([ac_try_compile_works], [1], [label])
fi
]])
AT_CHECK_AU_MACRO([AC_TRY_LINK],
[[AC_CACHE_CHECK([working ac_try_link], [ac_cv_ac_try_link_works], [
AC_TRY_LINK([@%:@include <stdio.h>], [return !feof(stdin);],
[ac_cv_ac_try_link_works=yes],
[ac_cv_ac_try_link_works=no])
])
if test $ac_cv_ac_try_link_works = yes; then
AC_DEFINE([ac_try_link_works], [1], [label])
fi
]])
# Oddly enough, AC_COMPILE_CHECK was shorthand for AC_MSG_CHECKING +
# AC_TRY_LINK, not AC_TRY_COMPILE. When not cached, this will print
# checking for working ac_compile_check... checking for feof ... yes
# but whatever.
AT_CHECK_AU_MACRO([AC_COMPILE_CHECK],
[[AC_CACHE_CHECK([working ac_compile_check], [ac_cv_ac_compile_check_works], [
AC_COMPILE_CHECK([feof], [@%:@include <stdio.h>], [return !feof(stdin);],
[ac_cv_ac_compile_check_works=yes],
[ac_cv_ac_compile_check_works=no])
])
if test $ac_cv_ac_compile_check_works = yes; then
AC_DEFINE([ac_compile_check_works], [1], [label])
fi
]])
AT_CHECK_AU_MACRO([AC_TRY_RUN],
[[AC_CACHE_CHECK([working ac_try_run], [ac_cv_ac_try_run_works], [
AC_TRY_RUN([int main(void) { return 0; }],
[ac_cv_ac_try_run_works=yes],
[ac_cv_ac_try_run_works=no],
[ac_cv_ac_try_run_works=yes]) # cross compile, assume it works
])
if test $ac_cv_ac_try_run_works = yes; then
AC_DEFINE([ac_try_run_works], [1], [label])
fi
]])
# For purpose of this test, we don't care whether these libraries
# exist (as long as the result is consistent between C and C++)
# but we _do_ need to make sure that autoupdate correctly handles
# AC_HAVE_LIBRARY's acceptance of "-lfoo" and "libfoo.a" as the
# LIBRARY argument, where AC_CHECK_LIB only takes "foo".
AT_CHECK_AU_MACRO([AC_HAVE_LIBRARY],
[[AC_HAVE_LIBRARY([alice])
AC_HAVE_LIBRARY([-lbob])
AC_HAVE_LIBRARY([libmallory.a])
]])
## ----------------------------------------- ##
## Expansion of whitespace-separated lists. ##
## ----------------------------------------- ##
m4_define([AT_CHECK_EXPANSION_IN_FUNCS],
[AT_SETUP([Macro expansion in $1]m4_if([$2],[literal],[],[ (literal)]))
AT_CONFIGURE_AC([[
m4@&t@_define([fn_bar],[fn_quux])
$1([dn@&t@l
fn_foo dn@&t@l
fn_nocomment
fn_bar dn@&t@l Ordinary comment
fn_blurf dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:6: warning: whitespace-separated list contains macros;
configure.ac:6: in a future version of Autoconf they will not be expanded
configure.ac:6: note: 'dn@&t@l' is a macro
functions.m4: $1 is expanded from...
configure.ac:6: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete], [
HAVE_FN_BLURF
HAVE_FN_FOO
HAVE_FN_NOCOMMENT
HAVE_FN_QUUX
])
AT_CHECK_CONFIGURE
AT_CLEANUP
m4_if([$2], [literal], [], [
AT_SETUP([Macro expansion in $1 (variable)])
AT_CONFIGURE_AC([[
m4@&t@_define([fn_bar],[fn_quux])
fns="fn_foo" _AH_CHECK_FUNC([fn_foo])
fns="$fns fn_nocomment" _AH_CHECK_FUNC([fn_nocomment])
$1([dn@&t@l
$[]fns
fn_bar dn@&t@l Ordinary comment
fn_blurf dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:8: warning: whitespace-separated list contains macros;
configure.ac:8: in a future version of Autoconf they will not be expanded
configure.ac:8: note: 'dn@&t@l' is a macro
functions.m4: $1 is expanded from...
configure.ac:8: the top level
configure.ac:8: warning: $1($fns): you should use literals
functions.m4: $1 is expanded from...
configure.ac:8: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete], [
HAVE_FN_BLURF
HAVE_FN_FOO
HAVE_FN_NOCOMMENT
HAVE_FN_QUUX
])
AT_CHECK_CONFIGURE
AT_CLEANUP
])])
m4_define([AT_CHECK_EXPANSION_IN_HEADERS],
[AT_SETUP([Macro expansion in $1]m4_if([$2],[literal],[],[ (literal)]))
AT_CONFIGURE_AC([[
m4@&t@_define([bar],[quux])
$1([dn@&t@l
foo.h dn@&t@l
nocomment.h
bar.h dn@&t@l Ordinary comment
blurf.h dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:6: warning: whitespace-separated list contains macros;
configure.ac:6: in a future version of Autoconf they will not be expanded
configure.ac:6: note: 'dn@&t@l' is a macro
headers.m4: $1 is expanded from...
configure.ac:6: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete], [
HAVE_BLURF_H
HAVE_FOO_H
HAVE_INTTYPES_H
HAVE_NOCOMMENT_H
HAVE_QUUX_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
])
AT_CHECK_CONFIGURE
AT_CLEANUP
m4_if([$2], [literal], [], [
AT_SETUP([Macro expansion in $1 (variable)])
AT_CONFIGURE_AC([[
m4@&t@_define([bar],[quux])
hs="foo.h" _AH_CHECK_HEADER([foo.h])
hs="$hs nocomment.h" _AH_CHECK_HEADER([nocomment.h])
$1([dn@&t@l
$[]hs
bar.h dn@&t@l Ordinary comment
blurf.h dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:8: warning: whitespace-separated list contains macros;
configure.ac:8: in a future version of Autoconf they will not be expanded
configure.ac:8: note: 'dn@&t@l' is a macro
headers.m4: $1 is expanded from...
configure.ac:8: the top level
configure.ac:8: warning: $1($hs): you should use literals
headers.m4: $1 is expanded from...
configure.ac:8: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete], [
HAVE_BLURF_H
HAVE_FOO_H
HAVE_INTTYPES_H
HAVE_NOCOMMENT_H
HAVE_QUUX_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
])
AT_CHECK_CONFIGURE
AT_CLEANUP
])])
AT_CHECK_EXPANSION_IN_FUNCS([AC_CHECK_FUNCS])
AT_CHECK_EXPANSION_IN_FUNCS([AC_CHECK_FUNCS_ONCE], [literal])
AT_CHECK_EXPANSION_IN_FUNCS([AC_REPLACE_FUNCS])
AT_CHECK_EXPANSION_IN_HEADERS([AC_CHECK_HEADERS])
AT_CHECK_EXPANSION_IN_HEADERS([AC_CHECK_HEADERS_ONCE], [literal])
AT_SETUP([Macro expansion in AC_CHECK_FILES])
AT_CONFIGURE_AC([[
m4@&t@_define([f_bar], [f_quux])
AC_CHECK_FILES([dn@&t@l
/nonex/f_foo
/nonex/f_bar dn@&t@l Ordinary comment
/nonex/f_blurf dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:6: warning: whitespace-separated list contains macros;
configure.ac:6: in a future version of Autoconf they will not be expanded
configure.ac:6: note: 'dn@&t@l' is a macro
general.m4: AC_CHECK_FILES is expanded from...
configure.ac:6: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete], [
HAVE__NONEX_F_BLURF
HAVE__NONEX_F_FOO
HAVE__NONEX_F_QUUX
])
AT_CHECK_CONFIGURE
AT_CLEANUP
AT_SETUP([Macro expansion in AC_CONFIG_MACRO_DIRS])
AT_CONFIGURE_AC([[
m4@&t@_define([d_bar], [d_quux])
AC_CONFIG_MACRO_DIRS([dn@&t@l
d_foo
d_bar dn@&t@l Ordinary comment
d_blurf dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR_TRACE], [0],
[configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_foo
configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_quux
configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_blurf
],
[configure.ac:6: warning: whitespace-separated list contains macros;
configure.ac:6: in a future version of Autoconf they will not be expanded
configure.ac:6: note: 'dn@&t@l' is a macro
general.m4: AC_CONFIG_MACRO_DIRS is expanded from...
configure.ac:6: the top level
])
AT_CLEANUP
AT_SETUP([Macro expansion in AC_CONFIG_SUBDIRS])
(set -ex
for d in d_foo d_bar d_blurf d_quux; do
mkdir $d
printf '%s\n%s\n' '#! /bin/sh' "echo entered $d/configure" \
> $d/configure
chmod +x $d/configure
done)
AT_CONFIGURE_AC([[
m4@&t@_define([d_bar], [d_quux])
AC_CONFIG_SUBDIRS([dn@&t@l
d_foo
d_bar dn@&t@l Ordinary comment
d_blurf dn@&t@l Apos'trophed comment
])
]])
AT_CHECK_AUTOCONF([], [0], [],
[configure.ac:6: warning: whitespace-separated list contains macros;
configure.ac:6: in a future version of Autoconf they will not be expanded
configure.ac:6: note: 'dn@&t@l' is a macro
status.m4: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:6: the top level
])
AT_CHECK_AUTOHEADER([-W no-obsolete])
AT_CHECK_CONFIGURE([], [0], [stdout])
AT_CHECK([grep '^entered' stdout], [0],
[[entered d_foo/configure
entered d_quux/configure
entered d_blurf/configure
]])
AT_CLEANUP
## ------------------------------------- ##
## AC_PROG_LEX with and without yywrap. ##
## ------------------------------------- ##
# We don't currently have a good way of verifying that each mode
# does what it's supposed to, but we can at least put them through
# their paces as much as the autogenerated AT_CHECK_MACRO invocation
# used to, back when AC_PROG_LEX took no arguments.
AT_CHECK_MACRO([AC_PROG_LEX with noyywrap], [AC_PROG_LEX([noyywrap])])
AT_CHECK_MACRO([AC_PROG_LEX with yywrap], [AC_PROG_LEX([yywrap])],
[], [], [],
[# Skip this test on OSes where there is no -ll nor -lfl.
AT_DATA([configure.ac],
[[AC_INIT([lexlib-probe], [1])
AC_PROG_CC
AC_SEARCH_LIBS([yywrap], [l fl], [], [AS_EXIT(77)])
AC_OUTPUT
]])
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE
])
AT_SETUP([AC_PROG_LEX in legacy mode])
AT_CONFIGURE_AC([[AC_PROG_LEX]])
AT_CHECK_AUTOHEADER([], [ignore])
AT_CHECK_AUTOCONF([], [], [],
[[configure.ac:4: warning: AC_PROG_LEX without either yywrap or noyywrap is obsolete
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
]])
AT_CHECK_CONFIGURE
AT_CLEANUP
## ---------------------------------- ##
## Invalid arguments to AC_PROG_LEX. ##
## ---------------------------------- ##
AT_SETUP([Invalid arguments to AC_PROG_LEX])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([nonsense])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: nonsense
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([too],[many])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: too many arguments to AC_PROG_LEX
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([yywrap noyywrap])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: AC_PROG_LEX: yywrap and noyywrap are mutually exclusive
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([noyywrap yywrap])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: AC_PROG_LEX: yywrap and noyywrap are mutually exclusive
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([yywrap nonsense])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: yywrap nonsense
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
AT_CONFIGURE_AC(
[[AC_PROG_LEX([nonsense noyywrap])
]])
AT_CHECK_AUTOCONF([], [1], [],
[[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: nonsense noyywrap
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:4: the top level
autom4te: error: m4 failed with exit status: 1
]])
# A double invocation with matching arguments should be accepted
# without complaint. FIXME: verify that it runs the test only once.
AT_CONFIGURE_AC(
[[AC_PROG_LEX([noyywrap])
AC_PROG_LEX([noyywrap])
]])
AT_CHECK_AUTOCONF
# A double invocation with matching arguments should trigger a warning.
AT_CONFIGURE_AC(
[[AC_PROG_LEX([yywrap])
AC_PROG_LEX([noyywrap])
]])
AT_CHECK_AUTOCONF([], [0], [],
[[configure.ac:5: warning: AC_PROG_LEX used twice with mismatched options
programs.m4: _AC_PROG_LEX is expanded from...
programs.m4: AC_PROG_LEX is expanded from...
configure.ac:5: the top level
]])
AT_CLEANUP
|