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
|
# Manually written configuration script for yash
# (C) 2007-2025 magicant
#
# 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 2 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 <http://www.gnu.org/licenses/>.
set +Ceu
makefile="Makefile"
makefilein="Makefile.in"
configlog="config.log"
configstatus="config.status"
configh="config.h"
tempsrc=".temp.c"
tempo=".temp.o"
tempd=".temp.d"
tempout="./.temp.out"
temptxt="./.temp.txt"
dirs=". builtins doc doc/ja lineedit po tests"
target="yash"
version="2.60"
copyright="Copyright (C) 2007-2025 magicant"
# object files to be linked as `yash'
objs='$(MAIN_OBJS)'
# object files compiled into builtins.a
builtin_objs=''
null=""
help="false"
nocreate="false"
debug="false"
enable_array="true"
enable_dirstack="true"
enable_double_bracket="true"
enable_nls="true"
enable_help="true"
enable_history="true"
enable_lineedit="true"
enable_printf="true"
enable_socket="true"
enable_test="true"
enable_ulimit="true"
default_loadpath='$(yashdatadir)'
ctags_args=""
etags_args=""
intl_lib='intl'
term_lib='tinfo curses ncurses ncursesw'
prefix='/usr/local'
exec_prefix='$(prefix)'
bindir='$(exec_prefix)/bin'
datarootdir='$(prefix)/share'
datadir='$(datarootdir)'
localedir='$(datarootdir)/locale'
mandir='$(datarootdir)/man'
docdir='$(datarootdir)/doc/'"$target"
htmldir='$(docdir)'
install_program='$(INSTALL) -c'
install_data='$(INSTALL) -c -m 644'
install_dir='$(INSTALL) -d'
unset checkresult
unset MAKEFLAGS
umask u=rwx
quoted0="'"$(printf '%s\n' "$0" | sed -e "s/'/'\\\\''/g")"'"
quoted_args=
for i
do
if [ x"$i" != x"--no-create" ]
then
quoted_args="${quoted_args} '"$(printf '%s\n' "$i" |
sed -e "s/'/'\\\\''/g")"'"
fi
done
parseenable() {
case "$1" in
--enable-*=yes|--enable-*=true) val=true ;;
--enable-*=no|--enable-*=false) val=false ;;
*=*) echo "$0: $1: invalid option" >&2; exit 2 ;;
--enable-*) val=true ;;
--disable-*) val=false ;;
esac
opt="${1#--*able-}"
opt="${opt%%=*}"
case "$opt" in
array) enable_array=$val ;;
dirstack) enable_dirstack=$val ;;
double-bracket) enable_double_bracket=$val ;;
help) enable_help=$val ;;
history) enable_history=$val ;;
lineedit) enable_lineedit=$val ;;
nls) enable_nls=$val ;;
printf) enable_printf=$val ;;
socket) enable_socket=$val ;;
test) enable_test=$val ;;
ulimit) enable_ulimit=$val ;;
*) echo "$0: $1: invalid option" >&2; exit 2 ;;
esac
}
# parse options
for i
do
case "$i" in
-h|--help)
help="true" ;;
--no-create)
nocreate="true" ;;
-d|--debug)
debug="true" ;;
--prefix=*)
prefix="${i#--prefix=}" ;;
--exec-prefix=*)
exec_prefix="${i#--exec-prefix=}" ;;
--bindir=*)
bindir="${i#--bindir=}" ;;
--datarootdir=*)
datarootdir="${i#--datarootdir=}" ;;
--datadir=*)
datadir="${i#--datadir=}" ;;
--localedir=*)
localedir="${i#--localedir=}" ;;
--mandir=*)
mandir="${i#--mandir=}" ;;
--docdir=*)
docdir="${i#--docdir=}" ;;
--htmldir=*)
htmldir="${i#--htmldir=}" ;;
--enable-*|--disable-*)
parseenable "$i" ;;
--default-loadpath=*)
default_loadpath="${i#--default-loadpath=}" ;;
--with-intl-lib=*)
intl_lib="${i#--with-intl-lib=}" ;;
--with-term-lib=*)
term_lib="${i#--with-term-lib=}" ;;
?*=*)
# parse variable assignment
if echo "$i" | grep -E "^[[:alpha:]][[:alnum:]]*=" >/dev/null
then
export "$i"
else
echo "$0: $i: unknown argument" >&2
exit 1
fi
;;
*)
echo "$0: $i: unknown argument" >&2
exit 1
esac
done
if ${help}
then
exec cat <<END
Usage: sh $0 [options...]
Available options:
--no-create do not create output files
--debug configure for debug build (GCC or Clang required)
Installation options:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
--bindir=DIR install executable in DIR [EPREFIX/bin]
--datarootdir=DIR architecture-independent data root [PREFIX/share]
--datadir=DIR architecture-independent data [DATAROOTDIR]
--localedir=DIR localization data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/$target]
--htmldir=DIR html documentation [DOCDIR]
Optional features:
--enable-FEATURE[=ARG] enable or disable FEATURE [ARG=yes]
--disable-FEATURE disable FEATURE (same as --enable-FEATURE=no)
--enable-array enable the array builtin
--enable-dirstack enable the directory stack (pushd, popd, dirs)
--enable-double-bracket enable the double-bracket command
--enable-help enable the help builtin
--enable-history enable history
--enable-lineedit enable command line editing
--enable-nls enable native language support
--enable-printf enable the echo/printf builtins
--enable-socket enable socket redirection by /dev/tcp, /dev/udp
--enable-test enable the test builtin
--enable-ulimit enable the ulimit builtin
--default-loadpath=DIR specify the default \$YASH_LOADPATH value
Optional packages:
--with-intl-lib=LIBS search space-separated LIBS for NLS
--with-term-lib=LIBS search space-separated LIBS for terminal handling
Influential environment variables:
CC, CFLAGS, CADDS, CPPFLAGS, CPPADDS, LDFLAGS, LDADDS, LDLIBS, AR, ARFLAGS,
ARCHIVER, LINGUAS, XGETTEXT, XGETTEXTFLAGS, MSGFMT, MSGFMTFLAGS, MSGMERGE,
MSGMERGEFLAGS, MSGINIT, MSGCONV, MSGFILTER,
ASCIIDOC, ASCIIDOCFLAGS, ASCIIDOCATTRS, A2X, A2XFLAGS,
INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR,
CTAGS, CTAGSARGS, ETAGS, ETAGSARGS, CSCOPE, CSCOPEARGS
END
exit
fi
clean_up () {
rm -f "${tempsrc}" "${tempo}" "${tempout}" "${temptxt}" "${tempd}"
}
trap 'clean_up' EXIT
trap 'clean_up; exit 1' HUP INT QUIT ABRT TERM PIPE USR1 USR2
trap '' ALRM
exec 5>"${configlog}"
{
printf '===== Configuration log: generated by %s\n' "${0##*/}"
echo
LC_TIME=C date
echo
printf '# Invocation command line was:\n%%'
for i in "$0" "$@"
do
printf ' %s' "$(printf '%s\n' "$i" |
sed -e '\|[^[:alnum:]./=-]| {
s/'"'"'/'"'\\''"'/g
s/\(.*\)/'"'"'\1'"'"'/
}')"
done
echo
echo
printf '# uname -i = %s\n' "$(uname -i 2>/dev/null || echo \?)"
printf '# uname -n = %s\n' "$(uname -n 2>/dev/null || echo \?)"
printf '# uname -m = %s\n' "$(uname -m 2>/dev/null || echo \?)"
printf '# uname -o = %s\n' "$(uname -o 2>/dev/null || echo \?)"
printf '# uname -p = %s\n' "$(uname -p 2>/dev/null || echo \?)"
printf '# uname -r = %s\n' "$(uname -r 2>/dev/null || echo \?)"
printf '# uname -s = %s\n' "$(uname -s 2>/dev/null || echo \?)"
printf '# uname -v = %s\n' "$(uname -v 2>/dev/null || echo \?)"
printf '# uname -a = %s\n' "$(uname -a 2>/dev/null || echo \?)"
echo
printf '# PATH=%s\n' "$PATH"
echo
} >&5
checking () {
printf 'checking %s... ' "$1"
printf '\nchecking %s...\n' "$1" >&5
}
checkby () {
printf '%% %s\n' "$*" >&5
"$@" >&5 2>&1
laststatus=$?
if [ ${laststatus} -eq 0 ]
then
checkresult="yes"
else
printf '# exit status: %d\n' "${laststatus}" >&5
checkresult="no"
return ${laststatus}
fi
}
trymake () {
checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \
${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \
${LDFLAGS-${ldflags}} ${LDADDS-${null}} -o "${tempout}" "${tempsrc}" \
"$@" ${LDLIBS-${ldlibs}}
}
trycompile () {
checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \
${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \
-c -o "${tempo}" "${tempsrc}" "$@"
}
trylink () {
checkby ${CC-${cc}} ${LDFLAGS-${ldflags}} ${LDADDS-${null}} \
-o "${tempout}" "${tempo}" "$@" ${LDLIBS-${ldlibs}}
}
tryexec () {
checkby "${tempout}"
}
checked () {
if [ $# -ge 1 ]
then
checkresult="$1"
fi
printf '%s\n' "${checkresult}"
printf '# result: %s\n' "${checkresult}" >&5
}
defconfigh () {
printf '# defining %s=%s in %s\n' "$1" "${2-1}" "${configh}" >&5
confighdefs="${confighdefs}
#define ${1} ${2-1}"
}
fail () {
echo "configuration failed" >&2
exit 1
}
cc="${CC-c99}"
cflags="${CFLAGS--O1 -g}"
cppflags="${CPPFLAGS-${null}}"
ldflags="${LDFLAGS-${null}}"
ldlibs="${LDLIBS-${null}}"
ar="${AR-ar}"
arflags="${ARFLAGS--rc}"
xgettext="${XGETTEXT-xgettext}"
xgettextflags="${XGETTEXTFLAGS--kgt -kNgt -kngt:1,2 \
--flag=sb_vprintf:1:c-format --flag=sb_printf:1:c-format \
--flag=malloc_vprintf:1:c-format --flag=malloc_printf:1:c-format \
--flag=xerror:1:c-format --flag=serror:1:c-format \
--flag=le_compdebug:1:c-format}"
msginit="${MSGINIT-msginit}"
msgfmt="${MSGFMT-msgfmt}"
msgfmtflags="${MSGFMTFLAGS--c}"
msgmerge="${MSGMERGE-msgmerge}"
msgmergeflags="${MSGMERGEFLAGS-${null}}"
msgconv="${MSGCONV-msgconv}"
msgfilter="${MSGFILTER-msgfilter}"
asciidoc="${ASCIIDOC-asciidoc}"
asciidocflags="${ASCIIDOCFLAGS-}"
asciidocattrs="${ASCIIDOCATTRS--a docdate=\"\`date +%Y-%m-%d\`\" \
-a yashversion=\"\$(VERSION)\" -a linkcss -a disable-javascript}"
a2x="${A2X-a2x}"
a2xflags="${A2XFLAGS-}"
ctags="${CTAGS-ctags}"
etags="${ETAGS-etags}"
cscope="${CSCOPE-cscope}"
confighdefs=''
# check OS type
checking 'operating system'
ostype=$(uname -s | tr "[:upper:]" "[:lower:]")
checked "${ostype}"
case "${ostype}" in
darwin)
defconfigh "_DARWIN_C_SOURCE"
;;
sunos)
defconfigh "__EXTENSIONS__"
;;
esac
# check POSIX conformance
checking 'POSIX conformance'
posixver=$(getconf _POSIX_VERSION 2>/dev/null)
if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ]
then
checked "${posixver}"
else
checked "no"
posixver=""
fi
checking 'SUS conformance'
xopenver=$(getconf _XOPEN_VERSION 2>/dev/null)
if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ]
then
checked "${xopenver}"
else
checked "no"
xopenver=""
fi
case "${ostype}" in
freebsd)
# FreeBSD doesn't have a feature test macro to enable non-POSIX
# extensions. We don't define _POSIX_C_SOURCE or _XOPEN_SOURCE so that
# non-POSIX extensions are available.
posix=
xopen=
;;
*)
posix=${posixver}
xopen=${xopenver}
;;
esac
# define options for debugging
if ${debug}
then
cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -Og -fno-inline -ggdb}"
else
defconfigh "NDEBUG"
fi
# check if the compiler works
checking 'whether the compiler works'
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trymake && tryexec
then
checked "yes"
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='gcc'
trymake && tryexec
)
then
checked "yes (using gcc)"
cc='gcc'
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='clang'
trymake && tryexec
)
then
checked "yes (using clang)"
cc='clang'
else
checked "no"
printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
printf 'The compiler is expected to accept these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi
# check if the compiler accepts the -O2 option if we are not debugging
if ! ${debug} && [ x"${CFLAGS+set}" != x"set" ]
then
checking 'whether the compiler accepts -O2 flag'
savecflags=${cflags}
cflags="-O2 -g"
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trycompile
then
checked "yes"
else
checked "no"
cflags=${savecflags}
fi
unset savecflags
fi
# find compiler option for C99 support
checking 'additional option to compile C99 code'
cat >"${tempsrc}" <<END
int main(int argc, char **argv) {
if (argc == 0) return 0;
int vla[argc];
vla[0] = 42;
// one-line comment
struct s { int v; } i = { .v = argv[0][0] };
return vla[0] + i.v;
}
END
if
trycompile
then
checked "none needed"
elif
[ x"${CFLAGS+set}" != x"set" ] &&
cflags="${cflags} -std=c99" &&
trycompile
then
checked "with -std=c99"
else
checked "failed"
printf 'Compiler "%s" does not seem to support C99.\n' "${CC-${cc}}" >&2
printf 'The compiler was tested with these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi
# check if make supports include statements
checking 'whether make supports include statements'
if
cat >"${temptxt}" <<END
_TEST_:
@echo >/dev/null
END
checkby eval "${MAKE-make} -f - _TEST_ <<END
.POSIX:
include ${temptxt}
END
"
then
checked "yes"
make_supports_include=true make_include='include'
else
checked "no"
make_supports_include=false make_include='# include'
fi
# check if make sets the $SHELL macro
checking 'whether make sets $SHELL macro'
checkby eval "SHELL=false ${MAKE-make} -f - <<END
.POSIX:
_TEST_:
\\\$(SHELL) -c :
END
"
checked
if [ x"${checkresult}" = x"yes" ]
then
make_shell='# SHELL = sh'
else
make_shell='SHELL = sh'
fi
# check if the pax command is available
if [ x"${ARCHIVER+set}" != x"set" ]
then
checking 'for the pax command'
>|"${tempsrc}"
checkby pax -w -x ustar -f "${tempout}" "${tempsrc}"
checked
if [ x"${checkresult}" = x"yes" ]
then
archiver='pax -w -x ustar -f'
else
archiver='tar cf'
fi
fi
# check if the install command is available
if [ x"${INSTALL+set}" != x"set" ]
then
checking 'for the install command'
>|"${tempsrc}"
checkby install -c -m 644 "${tempsrc}" "${tempout}"
checked
if [ x"${checkresult}" = x"yes" ]
then
install='install'
else
install='$(topdir)/install-sh'
fi
fi
# check if defining _POSIX_C_SOURCE and _XOPEN_SOURCE as values larger than
# _POSIX_VERSION and _XOPEN_VERSION is accepted.
if [ -n "${posix}" ]
then
checking 'what values _POSIX_C_SOURCE and _XOPEN_SOURCE should have'
if
cat >"${tempsrc}" <<END
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#include <unistd.h>
int main(void) { fork(); return 0; }
END
trycompile
then
checked "_POSIX_C_SOURCE=200809L, _XOPEN_SOURCE=700"
posix=200809 xopen=700
elif
cat >"${tempsrc}" <<END
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
#include <unistd.h>
int main(void) { fork(); return 0; }
END
trycompile
then
checked "_POSIX_C_SOURCE=200112L, _XOPEN_SOURCE=600"
posix=200112 xopen=600
else
checked "failed"
fi
fi
if [ -n "${posix}" ]
then
defconfigh "_POSIX_C_SOURCE" "${posix}L"
fi
if [ -n "${xopen}" ]
then
defconfigh "_XOPEN_SOURCE" "${xopen}"
fi
# check if we need -lm
if [ x"${LDLIBS+set}" != x"set" ]
then
checking 'if loader flag -lm can be omitted'
cat >"${tempsrc}" <<END
${confighdefs}
#include <math.h>
int main(int argc, char **argv) {
return fmod(argc, 1.1) == trunc(argc) || argv == 0;
}
END
trymake
checked
if [ x"${checkresult}" = x"no" ]
then
ldlibs="${ldlibs} -lm"
fi
fi
# enable/disable socket redirection
if ${enable_socket}
then
checking 'for socket library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <netdb.h>
#include <sys/socket.h>
int main(void) {
struct addrinfo ai = {
.ai_flags = 0, .ai_family = AF_UNSPEC, .ai_protocol = 0,
.ai_socktype = 1 ? SOCK_STREAM : SOCK_DGRAM,
.ai_addrlen = 0, .ai_addr = (void*)0, .ai_canonname = (void*)0,
.ai_next = (void*)0
};
gai_strerror(getaddrinfo("", "", &ai, (void*)0));
connect(socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol),
ai.ai_addr, ai.ai_addrlen);
freeaddrinfo(&ai);
}
END
saveldlibs="${ldlibs}"
if
trymake
then
checked "yes"
else
for lib in '-lxnet' '-lsocket' '-lnsl' '-lsocket -lnsl'
do
ldlibs="${saveldlibs} ${lib}"
if trymake
then
checked "with ${lib}"
break
fi
done
fi
case "${checkresult}" in
yes|with*)
defconfigh "YASH_ENABLE_SOCKET"
unset saveldlibs
;;
no)
checked "no"
printf 'The socket library is unavailable!\n' >&2
printf 'Add the "--disable-socket" option and try again.\n' >&2
fail
;;
esac
fi
# check if gettext is available
if ${enable_nls}
then
checking 'for ngettext'
cat >"${tempsrc}" <<END
${confighdefs}
#include <libintl.h>
int main(void) { const char *s = ngettext("foo", "bar", 1); return s == 0; }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_NGETTEXT"
fi
checking 'for gettext library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <libintl.h>
int main(void) {
bindtextdomain("", "");
textdomain("");
const char *s = gettext("");
#if HAVE_NGETTEXT
s = ngettext("", "", 0);
#endif
return s == 0;
}
END
if
trycompile
then
saveldlibs="${ldlibs}"
if trylink
then
checked "yes"
else
for lib in ${intl_lib}
do
ldlibs="${saveldlibs} -l${lib}"
if trylink
then
checked "with -l${lib}"
break
fi
done
fi
fi
case "${checkresult}" in
yes|with*)
defconfigh "HAVE_GETTEXT"
unset saveldlibs
;;
no)
checked "no"
printf 'The gettext library is unavailable!\n' >&2
printf 'Add the "--disable-nls" option and try again.\n' >&2
fail
;;
esac
fi
# check if terminfo is available
if ${enable_lineedit}
then
for i in curses.h:CURSES_H ncurses.h:NCURSES_H \
ncurses/ncurses.h:NCURSES_NCURSES_H \
ncursesw/ncurses.h:NCURSESW_NCURSES_H
do
checking "for ${i%:*}"
cat >"${tempsrc}" <<END
${confighdefs}
#include <${i%:*}>
int main(void) { return ERR; }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_${i#*:}"
break
fi
done
for i in term.h:TERM_H ncurses/term.h:NCURSES_TERM_H \
ncursesw/term.h:NCURSESW_TERM_H
do
checking "for ${i%:*}"
cat >"${tempsrc}" <<END
${confighdefs}
#if HAVE_CURSES_H
#include <curses.h>
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#elif HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#endif
#include <${i%:*}>
#ifndef putchar
int putchar(int);
#endif
int main(void) {
/* Undeclared identifiers are a syntax error in C99, but many compilers assume
* implicit declarations when they appear in a function call. We force compilers
* to reject undeclared functions by using them in a non-call expression. */
(void) setupterm, (void) tigetflag, (void) tigetnum, (void) tigetstr;
(void) tparm, (void) tputs, (void) del_curterm, (void) cur_term;
/* Check if we can actually call them with arguments of suitable types */
int i1 = setupterm("", 1, (int*)0);
int i2 = tigetflag("");
int i3 = tigetnum("");
char *s1 = tigetstr("");
char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L);
int i4 = tputs(s2, 1, putchar);
(void) del_curterm(cur_term);
return i4;
}
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_${i#*:}"
break
fi
done
checking 'for terminfo library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdio.h>
#if HAVE_CURSES_H
#include <curses.h>
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#elif HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#endif
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#elif HAVE_NCURSESW_TERM_H
#include <ncursesw/term.h>
#endif
int main(void) {
int i1 = setupterm((char*)0, 1, (int*)0);
int i2 = tigetflag("");
int i3 = tigetnum("");
char *s1 = tigetstr("");
char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L);
int i4 = tputs(s2, 1, putchar);
del_curterm(cur_term);
return i4;
}
END
if
trycompile
then
saveldlibs="${ldlibs}"
if trylink
then
checked "yes"
else
for lib in ${term_lib}
do
ldlibs="${saveldlibs} -l${lib}"
if trylink
then
checked "with -l${lib}"
break
fi
done
fi
fi
case "${checkresult}" in
yes|with*)
defconfigh "YASH_ENABLE_LINEEDIT"
unset saveldlibs
;;
no)
checked "no"
printf 'The terminfo (curses) library is unavailable!\n' >&2
printf 'Add the "--disable-lineedit" option and try again.\n' >&2
fail
;;
esac
fi
# check whether system has /proc/self/exe or similar utility file
if
checking 'for /proc/self/exe'
checkby /proc/self/exe -c true
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_SELF_EXE"
elif
checking 'for /proc/curproc/file'
checkby /proc/curproc/file -c true
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_CURPROC_FILE"
elif
checking 'for /proc/$$/object/a.out'
checkby eval '/proc/$$/object/a.out -c true'
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_OBJECT_AOUT"
fi
# check for strnlen
checking 'for strnlen'
cat >"${tempsrc}" <<END
${confighdefs}
#include <string.h>
#ifndef strnlen
size_t strnlen(const char*, size_t);
#endif
int main(void) { return strnlen("12345", 3) != 3; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_STRNLEN"
fi
# check for strdup
checking 'for strdup'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdlib.h>
#include <string.h>
#ifndef strdup
char *strdup(const char*);
#endif
int main(void) {
char *dup = strdup("12345");
if (!dup) return 1;
int cmp = strcmp(dup, "12345");
free(dup);
return cmp != 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_STRDUP"
fi
# check for wcsnlen
checking 'for wcsnlen'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcsnlen
size_t wcsnlen(const wchar_t*, size_t);
#endif
int main(void) { return wcsnlen(L"12345", 3) != 3; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSNLEN"
fi
# check for wcsdup
checking 'for wcsdup'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdlib.h>
#include <wchar.h>
#ifndef wcsdup
wchar_t *wcsdup(const wchar_t*);
#endif
int main(void) {
wchar_t *dup = wcsdup(L"12345");
if (!dup) return 1;
int cmp = wcscmp(dup, L"12345");
free(dup);
return cmp != 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSDUP"
fi
# check for wcscasecmp
checking 'for wcscasecmp'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcscasecmp
int wcscasecmp(const wchar_t*, const wchar_t*);
#endif
int main(void) { return wcscasecmp(L"1a2b3c", L"1A2B3C") != 0; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSCASECMP"
fi
# check for wcsnrtombs
checking 'for wcsnrtombs'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#ifndef wcsnrtombs
size_t wcsnrtombs(char *restrict, const wchar_t **restrict, size_t, size_t,
mbstate_t *restrict);
#endif
int main(void) {
mbstate_t s;
char out[10];
const wchar_t w[] = L"abcde";
const wchar_t *in = w;
memset(&s, 0, sizeof s);
return wcsnrtombs(out, &in, SIZE_MAX, sizeof out, &s) != 5 ||
in != NULL ||
strcmp(out, "abcde") != 0 ||
wcsnrtombs(out, (in = &w[1], &in), 3, sizeof out, &s) != 3 ||
in != &w[4] ||
strncmp(out, "bcd", 3) != 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSNRTOMBS"
fi
# check for wcstold
checking 'for wcstold'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcstold
long double wcstold(const wchar_t *restrict, wchar_t **restrict);
#endif
int main(void) { return wcstold(L"10.0", (wchar_t **) 0) != 10.0; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSTOLD"
fi
# check for wcwidth
checking 'for wcwidth'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcwidth
int wcwidth(wchar_t);
#endif
int main(void) { return wcwidth(L'\0'); }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCWIDTH"
fi
# check if sys/stat.h defines S_ISVTX
checking 'if <sys/stat.h> defines S_ISVTX'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) { return S_ISVTX & 0; }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_S_ISVTX"
fi
# check if unsetenv returns int
checking 'if unsetenv returns int'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdlib.h>
int main(void) { return 0 != unsetenv("x"); }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "UNSETENV_RETURNS_INT"
fi
# check if the "st_atim"/"st_atimespec"/"st_atimensec"/"__st_atimensec" member
# of the "stat" structure is available
if ${enable_test}
then
if
checking 'for st_atim'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_atim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 };
struct timespec ts = st.st_atim;
return ts.tv_nsec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_ATIM"
elif
checking 'for st_atimespec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_atimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 };
struct timespec ts = st.st_atimespec;
return ts.tv_nsec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_ATIMESPEC"
elif
checking 'for st_atimensec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_atimensec = 0;
return st.st_atimensec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_ATIMENSEC"
elif
checking 'for __st_atimensec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.__st_atimensec = 0;
return st.__st_atimensec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE___ST_ATIMENSEC"
fi
fi
# check if the "st_mtim"/"st_mtimespec"/"st_mtimensec"/"__st_mtimensec" member
# of the "stat" structure is available
if
checking 'for st_mtim'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_mtim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 };
struct timespec ts = st.st_mtim;
return ts.tv_nsec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_MTIM"
elif
checking 'for st_mtimespec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_mtimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 };
struct timespec ts = st.st_mtimespec;
return ts.tv_nsec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_MTIMESPEC"
elif
checking 'for st_mtimensec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.st_mtimensec = 0;
return st.st_mtimensec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_ST_MTIMENSEC"
elif
checking 'for __st_mtimensec'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/stat.h>
int main(void) {
struct stat st;
st.__st_mtimensec = 0;
return st.__st_mtimensec != 0;
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE___ST_MTIMENSEC"
fi
# check if WCONTINUED and WIFCONTINUED are available
checking 'for WCONTINUED and WIFCONTINUED'
cat >"${tempsrc}" <<END
${confighdefs}
#include <errno.h>
#include <sys/wait.h>
static int s;
int main(void) {
if (WIFCONTINUED(s)) { }
return waitpid(-1, &s, WNOHANG|WCONTINUED) < 0 && errno == EINVAL;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCONTINUED"
fi
# check for faccessat/eaccess
if
checking 'for faccessat'
cat >"${tempsrc}" <<END
${confighdefs}
#include <fcntl.h>
#include <unistd.h>
#ifndef faccessat
extern int faccessat(int, const char *, int, int);
#endif
int main(void) {
faccessat(AT_FDCWD, ".", F_OK | R_OK | W_OK | X_OK, AT_EACCESS);
}
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_FACCESSAT"
elif
checking 'for eaccess'
cat >"${tempsrc}" <<END
${confighdefs}
#include <unistd.h>
#ifndef eaccess
extern int eaccess(const char *, int);
#endif
int main(void) { eaccess(".", F_OK | R_OK | W_OK | X_OK); }
END
trymake
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_EACCESS"
fi
# check for strsignal
checking 'for strsingal'
cat >"${tempsrc}" <<END
${confighdefs}
#include <signal.h>
#include <string.h>
#ifndef strsignal
char *strsignal(int);
#endif
int main(void) { (void) strsignal(SIGKILL); }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_STRSIGNAL"
fi
# check for setpwent & getpwent & endpwent
checking 'for setpwent/getpwent/endpwent'
cat >"${tempsrc}" <<END
${confighdefs}
#include <pwd.h>
#ifndef setpwent
void setpwent(void);
#endif
#ifndef getpwent
struct passwd *getpwent(void);
#endif
#ifndef endpwent
void endpwent(void);
#endif
struct passwd *p;
int main(void) { setpwent(); p = getpwent(); endpwent(); }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_GETPWENT"
# check for pw_gecos
checking 'for pw_gecos'
cat >"${tempsrc}" <<END
${confighdefs}
#include <pwd.h>
const char *s;
struct passwd pwd;
int main(void) { pwd.pw_gecos = ""; s = pwd.pw_gecos; }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PW_GECOS"
fi
fi
# check for setgrent & getgrent & endgrent
checking 'for setgrent/getgrent/endgrent'
cat >"${tempsrc}" <<END
${confighdefs}
#include <grp.h>
/* don't declare setgrent to avoid conflict on BSD */
#ifndef getgrent
struct group *getgrent(void);
#endif
#ifndef endgrent
void endgrent(void);
#endif
struct group *g;
int main(void) { setgrent(); g = getgrent(); endgrent(); }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_GETGRENT"
fi
# check for sethostent & gethostent & endhostent
# This check may fail if socket redirection is disabled
# because the -lxnet compiler option is not specified.
checking 'for sethostent/gethostent/endhostent'
cat >"${tempsrc}" <<END
${confighdefs}
#include <netdb.h>
/* don't declare sethostent and endhostent to avoid conflict on SunOS */
#ifndef gethostent
struct hostent *gethostent(void);
#endif
struct hostent *h;
int main(void) { sethostent(1); h = gethostent(); endhostent(); }
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_GETHOSTENT"
fi
# check for paths.h
checking 'for paths.h'
cat >"${tempsrc}" <<END
${confighdefs}
#include <paths.h>
#include <stdio.h>
int main(void) { printf("%s\n", _PATH_BSHELL); }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PATHS_H"
fi
# check if getcwd accepts (NULL,0) as argument
checking "if getcwd(NULL,0) returns malloc'ed string"
cat >"${tempsrc}" <<END
${confighdefs}
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char *xgetcwd(void) {
size_t pwdlen = 80;
char *pwd = malloc(pwdlen);
if (!pwd) return NULL;
while (getcwd(pwd, pwdlen) == NULL) {
if (errno == ERANGE) {
pwdlen *= 2;
if (!pwdlen) return NULL;
pwd = realloc(pwd, pwdlen);
if (!pwd) return NULL;
} else {
free(pwd);
return NULL;
}
}
return pwd;
}
int main(void) {
char *wd1 = getcwd(NULL, 0);
if (!wd1) return 1;
char *wd2 = xgetcwd();
if (!wd2 || strcmp(wd1, wd2) != 0) return 1;
char *wd11 = realloc(wd1, strlen(wd1) + 10);
if (!wd11 || strcmp(wd11, wd2) != 0) return 1;
free(wd11); free(wd2); return 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "GETCWD_AUTO_MALLOC"
fi
# check if ioctl supports TIOCGWINSZ
if ${enable_lineedit}
then
checking 'if ioctl supports TIOCGWINSZ'
cat >"${tempsrc}" <<END
${confighdefs}
#include <sys/ioctl.h>
int main(void) {
struct winsize ws;
ioctl(0, TIOCGWINSZ, &ws);
(void) ws.ws_row, (void) ws.ws_col;
}
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_TIOCGWINSZ"
fi
fi
# check if wide-oriented I/O is working
checking 'if wide-oriented I/O is fully working'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdio.h>
#include <wchar.h>
#define LEN 12345
int main(void)
{
FILE *f;
fpos_t pos;
f = fopen("${tempsrc}", "w+");
if (f == NULL) return 1;
if (fwprintf(f, L"123\n") != 4) return 2;
if (fseek(f, 0, SEEK_SET) != 0) return 3;
if (fgetwc(f) != L'1') return 4;
if (fgetwc(f) != L'2') return 5;
if (fgetpos(f, &pos) != 0) return 6;
if (fseek(f, 0, SEEK_SET) != 0) return 7;
if (fgetwc(f) != L'1') return 8;
if (fsetpos(f, &pos) != 0) return 9;
if (fgetwc(f) != L'3') return 10;
if (fseek(f, 0, SEEK_SET) != 0) return 11;
for (size_t i = 0; i < LEN; i++)
if (fputwc(L'0', f) != L'0') return 12;
if (fgetpos(f, &pos) != 0) return 13;
if (fputwc(L'1', f) != L'1') return 14;
if (fseek(f, 0, SEEK_SET) != 0) return 15;
if (fgetwc(f) != L'0') return 16;
if (fsetpos(f, &pos) != 0) return 17;
if (fgetwc(f) != L'1') return 18;
if (fseek(f, 0, SEEK_SET) != 0) return 19;
for (size_t i = 0; i < LEN; i++)
if (fgetwc(f) != L'0') return 20;
if (fgetwc(f) != L'1') return 21;
if (fgetpos(f, &pos) != 0) return 22;
rewind(f);
if (fgetwc(f) != L'0') return 23;
if (fsetpos(f, &pos) != 0) return 24;
if (fgetwc(f) != WEOF) return 25;
if (ferror(f) != 0) return 26;
if (fclose(f) != 0) return 27;
return 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"no" ]
then
defconfigh "WIO_BROKEN"
fi
# check if fgetws is working
checking 'if fgetws is fully working'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wchar_t buf[100];
FILE *f = fopen("${tempsrc}", "w+");
if (f == NULL) return 1;
if (fwprintf(f, L"123\n") != 4) return 2;
if (fseek(f, 0, SEEK_SET) != 0) return 3;
if (fgetws(buf, 2, f) == NULL) return 4;
if (wcscmp(buf, L"1") != 0) return 5;
if (fclose(f) != 0) return 6;
return 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"no" ]
then
defconfigh "FGETWS_BROKEN"
fi
echo >&5
# enable/disable the array builtin
if ${enable_array}
then
defconfigh "YASH_ENABLE_ARRAY"
fi
# enable/disable the double-bracket command
if ${enable_double_bracket}
then
defconfigh "YASH_ENABLE_DOUBLE_BRACKET"
fi
# enable/disable the directory stack
if ${enable_dirstack}
then
defconfigh "YASH_ENABLE_DIRSTACK"
fi
# enable/disable the help builtin
if ${enable_help}
then
defconfigh "YASH_ENABLE_HELP"
fi
# enable/disable history
if ${enable_history}
then
defconfigh "YASH_ENABLE_HISTORY"
objs="$objs "'$(HISTORY_OBJS)'
else
if ${enable_lineedit}
then
printf 'History is required for lineedit but disabled.\n' >&2
printf 'Add the "--disable-lineedit" option and try again.\n' >&2
fail
fi
fi
# enable/disable the echo/printf builtins
if ${enable_printf}
then
defconfigh "YASH_ENABLE_PRINTF"
builtin_objs="$builtin_objs "'$(PRINTF_OBJS)'
fi
# enable/disable the test builtin
if ${enable_test}
then
defconfigh "YASH_ENABLE_TEST"
builtin_objs="$builtin_objs "'$(TEST_OBJS)'
else
if ${enable_double_bracket}
then
cat >&2 <<END
The test built-in is required for the double-bracket command, but disabled.
Add the "--disable-double-bracket" option and try again.
END
fail
fi
fi
# check for getrlimit and setrlimit
checking "for getrlimit and setrlimit"
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdint.h> /* required before <sys/resource.h> on freebsd */
#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */
#include <sys/resource.h>
int main(void) {
struct rlimit l = { .rlim_cur = RLIM_INFINITY, .rlim_max = RLIM_INFINITY };
getrlimit(RLIMIT_FSIZE, &l);
setrlimit(RLIMIT_FSIZE, &l);
}
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_RLIMIT"
fi
if ${enable_ulimit}
then
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "YASH_ENABLE_ULIMIT"
builtin_objs="$builtin_objs "'$(ULIMIT_OBJS)'
else
printf 'The getrlimit and setrlimit functions are unavailable.\n' >&2
printf 'Add the "--disable-ulimit" option and try again.\n' >&2
fail
fi
# check for RLIM_SAVED_CUR & RLIM_SAVED_MAX
for i in CUR MAX
do
checking "for RLIM_SAVED_${i}"
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdint.h> /* required before <sys/resource.h> on freebsd */
#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */
#include <sys/resource.h>
int main(void) {
struct rlimit l = { .rlim_cur = RLIM_SAVED_${i}, .rlim_max = RLIM_SAVED_${i} };
return l.rlim_cur == l.rlim_max;
}
END
trymake
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_RLIM_SAVED_${i}"
fi
done
# check for RLIMIT_***
for i in AS LOCKS MEMLOCK MSGQUEUE NICE NPROC RSS RTPRIO SIGPENDING
do
checking "for RLIMIT_${i}"
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdint.h> /* required before <sys/resource.h> on freebsd */
#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */
#include <sys/resource.h>
int main(void) {
if (0) {
struct rlimit r;
getrlimit(RLIMIT_${i}, &r);
}
#if HAVE_RLIMIT_AS
return RLIMIT_${i} == RLIMIT_AS;
#else
return 0;
#endif
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_RLIMIT_${i}"
fi
done
fi
# check if ctags/etags accepts the --recurse option
if [ x"${CTAGSARGS+set}" != x"set" ]
then
checking "if ctags accepts --recurse option"
rm -fr "${temptxt}"
printf 'int f(int){}\n' >|"${tempsrc}"
checkby ${ctags} --recurse -f "${temptxt}" "${tempsrc}"
checked
if [ x"${checkresult}" = x"yes" ]
then
CTAGSARGS='--recurse'
else
CTAGSARGS='*.[ch]'
fi
fi
if [ x"${ETAGSARGS+set}" != x"set" ]
then
checking "if etags accepts --recurse option"
rm -fr "${temptxt}"
printf 'int f(int){}\n' >|"${tempsrc}"
checkby ${etags} --recurse -o "${temptxt}" "${tempsrc}"
checked
if [ x"${checkresult}" = x"yes" ]
then
ETAGSARGS='--recurse'
else
ETAGSARGS='*.[ch]'
fi
fi
# set cscope invocation parameter
: ${CSCOPEARGS=-bR}
if [ -n "${builtin_objs}" ]
then
objs="${objs} "'$(BUILTINS_ARCHIVE)'
fi
if ${enable_lineedit}
then
objs="${objs} "'$(LINEEDIT_ARCHIVE)'
fi
if [ x"${LINGUAS+set}" = x"set" ]
then
CATALOGS=''
for i in ${LINGUAS}
do
CATALOGS="${CATALOGS} ${i}.mo"
done
else
CATALOGS='$(MOFILES)'
fi
MAKE_INCLUDE="${MAKE_INCLUDE-${make_include}}"
MAKE_SHELL="${MAKE_SHELL-${make_shell}}"
CC="${CC-${cc}}"
CFLAGS="${CFLAGS-${cflags}}${CADDS:+ ${CADDS}}"
CPPFLAGS="${CPPFLAGS-${cppflags}}${CPPADDS:+ ${CPPADDS}}"
LDFLAGS="${LDFLAGS-${ldflags}}${LDADDS:+ ${LDADDS}}"
LDLIBS="${LDLIBS-${ldlibs}}"
AR="${AR-${ar}}"
ARFLAGS="${ARFLAGS-${arflags}}"
ARCHIVER="${ARCHIVER-${archiver}}"
XGETTEXT="${XGETTEXT-${xgettext}}"
XGETTEXTFLAGS="${XGETTEXTFLAGS-${xgettextflags}}"
MSGINIT="${MSGINIT-${msginit}}"
MSGFMT="${MSGFMT-${msgfmt}}"
MSGFMTFLAGS="${MSGFMTFLAGS-${msgfmtflags}}"
MSGMERGE="${MSGMERGE-${msgmerge}}"
MSGMERGEFLAGS="${MSGMERGEFLAGS-${msgmergeflags}}"
MSGCONV="${MSGCONV-${msgconv}}"
MSGFILTER="${MSGFILTER-${msgfilter}}"
ASCIIDOC="${ASCIIDOC-${asciidoc}}"
ASCIIDOCFLAGS="${ASCIIDOCFLAGS-${asciidocflags}}"
ASCIIDOCATTRS="${ASCIIDOCATTRS-${asciidocattrs}}"
A2X="${A2X-${a2x}}"
A2XFLAGS="${A2XFLAGS-${a2xflags}}"
CTAGS="${CTAGS-${ctags}}"
ETAGS="${ETAGS-${etags}}"
CSCOPE="${CSCOPE-${cscope}}"
DIRS="${dirs}"
OBJS="${objs}"
BUILTIN_OBJS="${builtin_objs}"
TARGET="${target}"
VERSION="${version}"
COPYRIGHT="${copyright}"
INSTALL="${INSTALL-${install}}"
INSTALL_PROGRAM="${INSTALL_PROGRAM-${install_program}}"
INSTALL_DATA="${INSTALL_DATA-${install_data}}"
INSTALL_DIR="${INSTALL_DIR-${install_dir}}"
case "${prefix}" in
/ ) prefix= ;;
//) prefix=/ ;;
esac
case "${exec_prefix}" in
/ ) exec_prefix= ;;
//) exec_prefix=/ ;;
esac
case "${bindir}" in
/ ) bindir= ;;
//) bindir=/ ;;
esac
case "${datarootdir}" in
/ ) datarootdir= ;;
//) datarootdir=/ ;;
esac
case "${datadir}" in
/ ) datadir= ;;
//) datadir=/ ;;
esac
case "${localedir}" in
/ ) localedir= ;;
//) localedir=/ ;;
esac
case "${mandir}" in
/ ) mandir= ;;
//) mandir=/ ;;
esac
case "${docdir}" in
/ ) docdir= ;;
//) docdir=/ ;;
esac
case "${htmldir}" in
/ ) htmldir= ;;
//) htmldir=/ ;;
esac
sed_subst_cmd="
s!@MAKE_INCLUDE@!${MAKE_INCLUDE}!g
s!@MAKE_SHELL@!${MAKE_SHELL}!g
s!@CC@!${CC}!g
s!@CFLAGS@!${CFLAGS}!g
s!@CPPFLAGS@!${CPPFLAGS}!g
s!@LDFLAGS@!${LDFLAGS}!g
s!@LDLIBS@!${LDLIBS}!g
s!@AR@!${AR}!g
s!@ARFLAGS@!${ARFLAGS}!g
s!@ARCHIVER@!${ARCHIVER}!g
s!@XGETTEXT@!${XGETTEXT}!g
s!@XGETTEXTFLAGS@!${XGETTEXTFLAGS}!g
s!@MSGINIT@!${MSGINIT}!g
s!@MSGFMT@!${MSGFMT}!g
s!@MSGFMTFLAGS@!${MSGFMTFLAGS}!g
s!@MSGMERGE@!${MSGMERGE}!g
s!@MSGMERGEFLAGS@!${MSGMERGEFLAGS}!g
s!@MSGCONV@!${MSGCONV}!g
s!@MSGFILTER@!${MSGFILTER}!g
s!@ASCIIDOC@!${ASCIIDOC}!g
s!@ASCIIDOCFLAGS@!${ASCIIDOCFLAGS}!g
s!@ASCIIDOCATTRS@!${ASCIIDOCATTRS}!g
s!@A2X@!${A2X}!g
s!@A2XFLAGS@!${A2XFLAGS}!g
s!@CATALOGS@!${CATALOGS}!g
s!@CTAGS@!${CTAGS}!g
s!@CTAGSARGS@!${CTAGSARGS}!g
s!@ETAGS@!${ETAGS}!g
s!@ETAGSARGS@!${ETAGSARGS}!g
s!@CSCOPE@!${CSCOPE}!g
s!@CSCOPEARGS@!${CSCOPEARGS}!g
s!@DIRS@!${DIRS}!g
s!@OBJS@!${OBJS}!g
s!@BUILTIN_OBJS@!${BUILTIN_OBJS}!g
s!@TARGET@!${TARGET}!g
s!@VERSION@!${VERSION}!g
s!@COPYRIGHT@!${COPYRIGHT}!g
s!@INSTALL@!${INSTALL}!g
s!@INSTALL_PROGRAM@!${INSTALL_PROGRAM}!g
s!@INSTALL_DATA@!${INSTALL_DATA}!g
s!@INSTALL_DIR@!${INSTALL_DIR}!g
s!@prefix@!${prefix}!g
s!@exec_prefix@!${exec_prefix}!g
s!@bindir@!${bindir}!g
s!@datarootdir@!${datarootdir}!g
s!@datadir@!${datadir}!g
s!@localedir@!${localedir}!g
s!@mandir@!${mandir}!g
s!@docdir@!${docdir}!g
s!@htmldir@!${htmldir}!g
s!@default_loadpath@!${default_loadpath}!g
s!@enable_nls@!${enable_nls}!g
"
printf '\n\n===== Output variables =====\n%s\n' "${sed_subst_cmd}" >&5
# create dependency files if there are none
find . -name '*.c' -exec sh -c '
dfile="${1%.c}.d"
[ -f "$dfile" ] && exit
printf "touching %s\n" "$dfile"
>>"$dfile"
printf "Touched %s\n" "$dfile" >&5
' x {} \;
# create config.status
printf 'creating %s... ' "${configstatus}"
cat >"${configstatus}" <<CONFIG_STATUS_END
# ${configstatus##*/}: generated by ${0##*/}
# $(LC_TIME=C date)
help=false
recheck=false
dirs='${dirs}'
targets='${configh}'
for i in \${dirs}
do
targets="\${targets} \${i}/${makefile}"
done
# parse options
while [ \$# -gt 0 ]
do
case "\$1" in
-h|--help)
help=true ;;
--recheck)
recheck=true ;;
--)
shift
break ;;
-*)
echo "\$0: \$i: unknown option" >&2
exit 1 ;;
*)
break ;;
esac
shift
done
if \$help
then
exec cat <<END
This shell script instantiates files from templates according to the
configuration result
Usage: sh \$0 [options...] [files...]
Available options:
--recheck update config.status by reconfiguring in the same conditions
Configuration files:
\${targets}
END
exit
fi
if \$recheck
then
exec \${CONFIG_SHELL-sh} ${quoted0}${quoted_args} --no-create
exit
fi
if [ \$# -eq 0 ]
then
set \${targets}
fi
for target
do
printf 'creating %s... ' "\${target}"
case \${target} in
'${configh}')
cat >'${configh}' <<END
/* ${configh##*/}: generated by \${0##*/} */
#ifndef YASH_CONFIG_H
#define YASH_CONFIG_H
${confighdefs}
#endif
END
;;
'${makefile}' | */'${makefile}')
dir=\$(dirname "\${target}")
sed -e '${sed_subst_cmd}' -e "1i\\\\
# \${target##*/}: generated by \${0##*/}" "\${dir}/${makefilein}" >"\${target}"
if ! ${make_supports_include} &&
ls "\${dir}"/*.d >/dev/null 2>&1
then
printf '(including dependencies) '
cat "\${dir}"/*.d >>"\${target}"
fi
;;
esac
printf 'done\n'
done
CONFIG_STATUS_END
chmod a+x "${configstatus}"
printf 'done\n'
printf 'Created %s\n' "${configstatus}" >&5
if ! ${nocreate}
then
printf '%% %s\n' "${CONFIG_SHELL-sh} ${configstatus}" >&5
${CONFIG_SHELL-sh} ${configstatus}
fi
# print warning if POSIX conformance is missing
if [ -z "${posixver}" ] || [ "${posixver}" -lt 200112 ]
then
echo "WARNING: yash is designed for systems that conform to POSIX.1-2001"
echo " but your system does not"
fi
# vim: set ft=sh ts=8 sts=4 sw=4 et tw=80:
|