1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052
|
#!/bin/sh
#
# /*--------------------------------------------------------------------*/
# /* */
# /* VCG : Visualization of Compiler Graphs */
# /* -------------------------------------- */
# /* */
# /* file: config */
# /* version: 1.00.00 */
# /* creation: 1.4.1993 */
# /* author: I. Lemke (...-Version 0.99.99) */
# /* G. Sander (Version 1.00.00-...) */
# /* Universitaet des Saarlandes, W-66041 Saarbruecken */
# /* ESPRIT Project #5399 Compare */
# /* description: Configuring script */
# /* status: in work */
# /* */
# /*--------------------------------------------------------------------*/
#
# SCCS-info %W% %E%
# $Id$
#
# Shell script to configure the tMakefile, demo/demo.csh, src/globals.h
#
# ====================== Change area ============================
# WARNING: The following words are internally used and should not be
# ------- used as substitute names, file names etc.
#
# GSGSTARTGSG, GSGENDGSG, GSGTRENNERGSG, GSGSPACEGSG
# Standard places we look for Unix tools like rm, wc, awk, etc.
#
STDPATH="/bin /usr/bin /usr/ucb /etc /usr/etc /usr/bsd /usr/sbin /usr/local/bin"
# Standard Unix tools we look for.
# Please note: we do not need to add the tools sed, sync, touch, rm, chmod,
# sleep here, because these utilities are checked always.
# If cc is in this list, there is a special treatment of it, see
# ANSI and NOANSI.
#
# TOOLS="wc awk cc"
TOOLS="cc cat wc fgrep make mv ln clear"
# Tool substitute names we use in the files to configure.
# The substitute names are substituted by the access pathes we found
# at the standard pathes or user pathes.
# Note: The order in TOOLS and TOOLSUBSTITUTES must be the same.
# The substitute names for the predefined utilities are
# CCLINKNAME, SEDNAME, SYNCNAME, TOUCHNAME, RMNAME, CHMODNAME,
# SLEEPNAME.
#
# TOOLSUBSTITUTES="WCNAME AWKNAME CCNAME"
TOOLSUBSTITUTES="CCNAME CATNAME WCNAME FGREPNAME MAKENAME MVNAME \
LNNAME CLEARNAME"
# Programs where we should force to ask for a name, because the name
# is not standard. These tools need not to be in the TOOLS list.
# First, we look for the existence of the tool and give that as
# proposal. Then we ask.
# IMPORTANT: Please use the Underscore _ instead of blancs to
# separate the options.
#
# PROGRAMS="bison_-ydt flex"
PROGRAMS=""
# Program substitute names we use in the files to configure.
# The substitute names are substituted by the access pathes we entered
# for the programs.
# Note: The order in PROGRAMS and PROGRAMSUBSTITUTES must be the same.
#
# PROGRAMSUBSTITUTES="BISONNAME FLEXNAME"
PROGRAMSUBSTITUTES=""
# Program descriptions (short, only few words) for the programs
# listed in PROGRAMS.
# Note: The order in PROGRAMS and PROGRAMDESCRIPTIONS must be the same.
# IMPORTANT: Please use the Underscore _ instead of blancs.
PROGRAMDESCRIPTIONS=""
# If cc is not in the list TOOLS, please ignore the following.
# If we look for cc, and ANSI is set to "yes", we first look for gcc.
# If we do not get gcc, we ask whether it is an ANSI C compiler.
# If yes, we set the ANSINAME to #define ANSI_C, otherwise to
# #undef ANSI_C.
#
# ANSI="no"
ANSI="yes"
# If cc is not in the list TOOLS, please ignore the following.
# If ANSI="yes" but NOANSI="no", we give a warning if a nonansi
# compiler was selected.
#
# NOANSI="no"
NOANSI="yes"
# Files that must be configured. We assume that for each file, a template
# exists that has the ending tpl, e.g. globals.h.tpl is configured to
# the file globals.h.
#
# CONFIGFILES="tMakefile src/globals.h"
CONFIGFILES="tMakefile src/globals.h demo/demo.csh"
# Files that must be touched. We touch the files exactly in the order
# specified here. Between the touches, we synchronize the file system and
# sleep 3 seconds. As side effect, the files become writable for the
# user.
# It is recommended to touch the sources first, then the files generated
# from these sources, etc. This is needed for the make time stamp algorithm
# to avoid to generate files that are already there.
#
# TOUCHFILES="src/lex.yy.c y.tab.c y.tab.h"
TOUCHFILES=
# TOUCHFILES="src/grammar.pgs src/grammar.y src/grammar.h src/grammar.l \
# src/lex.yy.c src/y.tab.h src/y.tab.c"
# ================== End of Change area =========================
# --------------------------------------------------------------
# ======================
# Exit, cleanup routines
# ======================
# Cleanup before abortion
# -----------------------
# Synopsis: cleanup (no arguments)
# Result: no result
#
cleanup() {
echo "Cleanup ... "
$myrm -f configure.1 configure.2
}
# Abort on error
# --------------
# Synopsis: abort_unsuccessfully (no arguments)
# Result: no result
#
abort_unsuccessfully() {
echo "Abort unsuccessfully ..."
$myrm -f stamp-doc stamp-shortdoc
cleanup
exit 1
}
# Abort
# -----
# Synopsis: abort_successfully (no arguments)
# Result: no result
#
abort_successfully() {
echo "Ready ..."
cleanup
echo "Good bye."
exit 0
}
# --------------------------------------------------------------
# ===================
# Utilities for lists
# ===================
# Shift the tool list to the left
# -------------------------------
# i.e. consume the first argument. A "list tail" command.
# Synopsis: shift_toollist list
# Result: toollist contains the shifted list
#
shift_toollist() {
shift
toollist="$*"
}
# Get the first element of a list
# -------------------------------
# A "list head" command.
# Synopsis: toollist_first list
# Result: tool contains the shifted list
#
toollist_first() {
tool="$1"
}
# Remove the blancs from a subsitute string
# -----------------------------------------
# All blancs are replaced by GSGSPACEGSG.
# Synopsis: remove_blancs subststring
# Result: myresult contains the subststring without blancs
#
remove_blancs() {
myresult=`echo "$1" | "$mysed" -e "s/ /GSGSPACEGSG/g"`
}
# Add a substitute to the TOOLNAMES and TOOLSUBSTITUTES
# -----------------------------------------------------
# We protect the spaces first such that the shell is not
# confused by spaces in the string.
# Synopsis: add_substitute substitutestring substitutename
# Result: no result, but TOOLSUBSTITUTES and TOOLNAMES changed.
#
add_substitute() {
tmp="$2"
remove_blancs "$1"
TOOLNAMES="$TOOLNAMES $myresult"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES $tmp"
}
# --------------------------------------------------------------
# ===============================
# Check the important basic tools
# ===============================
#
# We look for the tools (see variable TOOLS) at the standard places
# (see variable STDPATH) and at the user path (imported variable PATH).
# If the tool was not found, we ask for an appropriate name of the
# tool. Note: We do not check the answer.
#
# Search a tool at the standard places
# ------------------------------------
# This is only executed if myresult is still empty.
# Synopsis: search_tool_at_stdplaces tool
# Result: myresult contains the access path
#
search_tool_at_stdplaces() {
if (test -n "$myresult") then return; fi
for i in $STDPATH; do
if (test -x "$i/$1") then
myresult="$i/$1"
break
fi
done
}
# Search a tool in the user path
# ------------------------------
# This is only executed if myresult is still empty.
# Synopsis: search_tool_in_path tool
# Result: myresult contains the access path
#
search_tool_in_path() {
if (test -n "$myresult") then return; fi
for i in $MYPATH; do
if (test -x "$i/$1") then
myresult="$i/$1"
break
fi
done
}
# Ask for the access path of a tool
# ---------------------------------
# This is only executed if myresult is still empty.
# Synopsis: ask_for_tool tool
# Result: myresult contains the access path
#
ask_for_tool() {
if (test -n "$myresult") then return; fi
while (test ! -n "$myresult") do
echo "Command $1 not found."
echo "Please enter the name (access path)"
echo "of the $1 command."
read myresult
done
}
# Ask for the access path of a program
# ------------------------------------
# Different than tools, the name of the program is not standard.
# Thus we ask which program should be used and give a default proposal.
# Synopsis: ask_for_program description default
# Result: myresult contains the access path
#
ask_for_program() {
mydefault="$2"
echo ""
echo "Please enter the name (access path + options) "
echo "of $1 [$mydefault]"
myresult=""
read myresult
if (test ! -n "$myresult") then
myresult="$mydefault"
fi
echo "$myresult found. I take it."
remove_blancs "$myresult"
}
# Look for one tool
# -----------------
# We look in the standard path, the user path, and finally, we ask
# for the access path.
# Synopsis: search_a_tool toolname
# Result: myresult contains the access path
#
search_a_tool() {
myresult=""
tmpa="$1"
search_tool_at_stdplaces "$tmpa"
search_tool_in_path "$tmpa"
ask_for_tool "$tmpa"
echo "$myresult found. I take it."
if (test -n "$mysed") then
remove_blancs "$myresult"
fi
}
# Main routine to look for tools
# ------------------------------
# Check the places of all tools in the variable TOOLS.
# Synopsis: search_tools (no arguments)
# Result: TOOLNAMES contains the list of access pathes of tools
#
search_tools() {
if (test ! -n "$TOOLS") then return; fi
echo ""
for j in $TOOLS; do
case "$j" in
cc|gcc) case "$ANSI" in
yes) check_ansi_cc;;
*) search_a_tool $j
mycclink="$myresult";;
esac;;
*) search_a_tool $j;;
esac
TOOLNAMES="$TOOLNAMES $myresult"
done
}
# --------------------------------------------------------------
# ========================
# Ask for special programs
# ========================
#
# We look for the programs (see variable PROGRAMS) at the standard places
# (see variable STDPATH) and at the user path (imported variable PATH).
# We take the found path as default, but ask for the real name,
# because the user may wish to use another program instead.
# Note: We do not check the answer.
#
# Look for one program
# --------------------
# We look in the standard path, the user path, but only to find
# the default.
# In any case, we ask for the access path.
# Synopsis: search_a_program programname description
# Result: myresult contains the access path
#
search_a_program() {
mydescr=`echo "$2" | $mysed -e "s/_/ /g"`
toollist=`echo "$1" | $mysed -e "s/_/ /g"`
toollist_first $toollist
shift_toollist $toollist
myprog="$tool"
myopts="$toollist"
myresult=""
search_tool_at_stdplaces "$myprog"
search_tool_in_path "$myprog"
if (test ! -n "$myresult") then
mydefault="no_default"
else
mydefault="$myresult $myopts"
fi
myresult="GSGSPACEGSG"
while (true) do
case "$myresult" in
GSGSPACEGSG)
ask_for_program "$mydescr" "$mydefault";;
no_default)
echo "*** invalid input, try again ***"
ask_for_program "$mydescr" "$mydefault";;
*) break;;
esac
done
}
# Main routine to look for programs
# ---------------------------------
# Ask for the names (pathes) of all programs in the variable PROGRAMS.
# Note: this should be called after search_tools.
# Synopsis: search_programs (no arguments)
# Result: no result, but TOOLSUBSTITUTES and TOOLNAMES changed.
#
search_programs() {
if (test ! -n "$PROGRAMS") then return; fi
echo ""
descrlist="$PROGRAMDESCRIPTIONS"
substitutelist="$PROGRAMSUBSTITUTES"
for j in $PROGRAMS; do
toollist="$descrlist"
toollist_first $toollist
shift_toollist $toollist
descrlist="$toollist"
descr="$tool"
toollist="$substitutelist"
toollist_first $toollist
shift_toollist $toollist
substitutelist="$toollist"
mysubstitute="$tool"
search_a_program "$j" "$descr"
add_substitute "$myresult" "$mysubstitute"
done
}
# --------------------------------------------------------------
# =====================================
# Check for tools needed in this script
# =====================================
#
# These tools are always checked and aliased to names according
# to the following scheme:
# sed -> $mysed -> SEDNAME
# Look for these tools
# --------------------
# The very first we do, is to look for the tools we need in
# this configure script itself. Note: mycclink is set, if an
# C compiler is needed.
# Synopsis: init_tools_needed_by_myself (no arguments)
# Result: mysed, mysync, mytouch, myrm, etc.
#
init_tools_needed_by_myself() {
echo "If the following does not work, please move demotrue"
echo "to true and add the true command into your PATH."
echo "If it works, you will see the message: Okay, it works."
while (true) do
echo "Okay, it works"
break
done
mysed="";
echo "If the following does not work, you cannot use config."
echo "If it works, you will see the message: Okay, it works."
while (test ! -n "$mysed") do
echo "Okay, it works"
break
done
search_a_tool "sed"
mysed="$myresult"
MYPATH=`echo $PATH | $mysed -e "s/:/ /g"`
search_a_tool "sync"
mysync="$myresult"
search_a_tool "touch"
mytouch="$myresult"
search_a_tool "rm"
myrm="$myresult"
search_a_tool "chmod"
mychmod="$myresult"
search_a_tool "sleep"
mysleep="$myresult"
mycclink=""
mysystem="UNKNOWN"
myresult=""
search_tool_at_stdplaces "uname"
search_tool_in_path "uname"
if (test -n "$myresult") then
mysystem=`$myresult`
fi
echo ""
echo "=========================================================="
echo "System is $mysystem"
echo "=========================================================="
echo ""
case "$mysystem" in
OSF1) echo "Operating system seems okay.";;
AIX) echo "Operating system seems okay.";;
SunOS) echo "Operating system seems okay.";;
IRIX) echo "Operating system seems okay.";;
HP-UX) echo "Operating system seems okay.";;
Linux) echo "Operating system seems okay.";;
ULTRIX) echo "Operating system ULTRIX is only partially tested.";;
*) echo "WARNING: operating system is unknown."
echo "I have never tested this script on $mysystem."
echo "Some of my guesses might be wrong.";;
esac
}
# Update TOOLSUBSTITUTES and TOOLNAMES
# ------------------------------------
# The substitute name (e.g. SEDNAME) is added to the TOOLSUBSTITUTES
# and the access path (e.g. $mysed) is added to the TOOLNAMES.
# If no C compiler is needed, we also do not need a cclink.
# Synopsis: update_toolnames_needed_by_myself (no arguments)
# Result: no result, but TOOLSUBSTITUES and TOOLNAMES changed.
#
update_toolnames_needed_by_myself() {
TOOLNAMES="$TOOLNAMES $mysed"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES SEDNAME"
TOOLNAMES="$TOOLNAMES $mysync"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES SYNCNAME"
TOOLNAMES="$TOOLNAMES $mytouch"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES TOUCHNAME"
TOOLNAMES="$TOOLNAMES $myrm"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES RMNAME"
TOOLNAMES="$TOOLNAMES $mychmod"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES CHMODNAME"
TOOLNAMES="$TOOLNAMES $mysleep"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES SLEEPNAME"
if (test -n "$mycclink") then
TOOLNAMES="$TOOLNAMES $mycclink"
TOOLSUBSTITUTES="$TOOLSUBSTITUTES CCLINKNAME"
fi
}
# --------------------------------------------------------------
# =====================================================
# Print the list of substitutes and ask for configuring
# =====================================================
final_check_of_substitutes() {
echo ""
echo "==================================================="
echo "LIST OF SUBSTITUTES"
echo "-------------------"
toollist="$TOOLNAMES"
for i in $TOOLSUBSTITUTES; do
toollist_first $toollist
shift_toollist $toollist
mytext=`echo "$tool" | $mysed -e "s/GSGSPACEGSG/ /g"`
echo "$i == $mytext"
done
echo "==================================================="
myresult=""
while (test ! -n "$myresult") do
echo ""
echo "Please enter: Are these substitutes correct ?"
echo "1|y|Y|yes|Yes = yes 2|n|N|no|No = no"
read myresult
case "$myresult" in
Y) myresult="yes";;
N) myresult="no";;
y) myresult="yes";;
n) myresult="no";;
Yes) myresult="yes";;
No) myresult="no";;
yes) myresult="yes";;
no) myresult="no";;
1) myresult="yes";;
2) myresult="no";;
*) echo "*** invalid input ***"
myresult="";;
esac
done
case "$myresult" in
yes) echo "Okay, we continue ...";;
no) echo "Configuration not done."
echo "Restart this shellscript to correct errors."
abort_unsuccessfully;;
esac
}
# --------------------------------------------------------------
# ==========================================
# Update the tools in the files to configure
# ==========================================
#
# Configure one file
# ------------------
# We subsequently replace the words listed in TOOLSUBSTITUTES by
# the access pathes we found in TOOLNAMES.
# Synopsis: config_one_file filename
# Result: no result
#
config_one_file() {
tmpb="$1"
$myrm -f configure.1 configure.2
$myrm -f $tmpb
if (test ! -r $tmpb.tpl) then
echo "File $tmpb.tpl is not readable or does not exist."
abort_unsuccessfully
fi
toollist="$TOOLNAMES"
for i in $TOOLSUBSTITUTES; do
toollist_first $toollist
shift_toollist $toollist
echo $i "GSGTRENNERGSG" $tool >> configure.1
done
$mysed -e "s/ //" configure.1 |\
$mysed -e "s/ //" |\
$mysed -e "s/\//\\\\\//g" |\
$mysed -e "s/GSGSPACEGSG/ /g" |\
$mysed -e "s/.*/GSGSTARTGSG&GSGENDGSG/" |\
$mysed -e "s/GSGSTARTGSG/s\//" |\
$mysed -e "s/GSGENDGSG/\//" |\
$mysed -e "s/GSGTRENNERGSG/\//" > configure.2
echo "s/.*/&GSGENDGSG/" >> configure.2
echo "s/[ ]*GSGENDGSG/GSGENDGSG/g" >> configure.2
echo "s/GSGENDGSG//" >> configure.2
$mysed -f configure.2 $tmpb.tpl > $tmpb
}
# Configure all files in CONFIGFILES
# ----------------------------------
# Synopsis: config_files (no argument)
# Result: no result
#
config_files() {
if (test ! -n "$CONFIGFILES") then return; fi
# tMakefile
echo "Configure tMakefile"
$myrm -f configure.1 configure.2
$myrm -f tMakefile
if (test ! -r tMakefile.tpl) then
echo "File tMakefile.tpl is not readable or does not exist."
abort_unsuccessfully
fi
toollist="$TOOLNAMES"
for i in $TOOLSUBSTITUTES; do
toollist_first $toollist
shift_toollist $toollist
echo $i "GSGTRENNERGSG" $tool >> configure.1
done
$mysed -e "s/ //" configure.1 |\
$mysed -e "s/ //" |\
$mysed -e "s/\//\\\\\//g" |\
$mysed -e "s/GSGSPACEGSG/ /g" |\
$mysed -e "s/.*/GSGSTARTGSG&GSGENDGSG/" |\
$mysed -e "s/GSGSTARTGSG/s\//" |\
$mysed -e "s/GSGENDGSG/\//" |\
$mysed -e "s/GSGTRENNERGSG/\//" > configure.2
echo "s/.*/&GSGENDGSG/" >> configure.2
echo "s/[ ]*GSGENDGSG/GSGENDGSG/g" >> configure.2
echo "s/GSGENDGSG//" >> configure.2
$mysed -f configure.2 tMakefile.tpl > tMakefile
# src/globals.h
echo "Configure src/globals.h"
$myrm -f configure.1 configure.2
$myrm -f src/globals.h
if (test ! -r src/globals.h.tpl) then
echo "File src/globals.h.tpl is not readable or does not exist."
abort_unsuccessfully
fi
toollist="$TOOLNAMES"
for i in $TOOLSUBSTITUTES; do
toollist_first $toollist
shift_toollist $toollist
echo $i "GSGTRENNERGSG" $tool >> configure.1
done
$mysed -e "s/ //" configure.1 |\
$mysed -e "s/ //" |\
$mysed -e "s/\//\\\\\//g" |\
$mysed -e "s/GSGSPACEGSG/ /g" |\
$mysed -e "s/.*/GSGSTARTGSG&GSGENDGSG/" |\
$mysed -e "s/GSGSTARTGSG/s\//" |\
$mysed -e "s/GSGENDGSG/\//" |\
$mysed -e "s/GSGTRENNERGSG/\//" > configure.2
echo "s/.*/&GSGENDGSG/" >> configure.2
echo "s/[ ]*GSGENDGSG/GSGENDGSG/g" >> configure.2
echo "s/GSGENDGSG//" >> configure.2
$mysed -f configure.2 src/globals.h.tpl > src/globals.h
# demo/demo.csh
echo "Configure demo/demo.csh"
$myrm -f configure.1 configure.2
$myrm -f demo/demo.csh
if (test ! -r demo/demo.csh.tpl) then
echo "File demo/demo.csh.tpl is not readable or does not exist."
abort_unsuccessfully
fi
toollist="$TOOLNAMES"
for i in $TOOLSUBSTITUTES; do
toollist_first $toollist
shift_toollist $toollist
echo $i "GSGTRENNERGSG" $tool >> configure.1
done
$mysed -e "s/ //" configure.1 |\
$mysed -e "s/ //" |\
$mysed -e "s/\//\\\\\//g" |\
$mysed -e "s/GSGSPACEGSG/ /g" |\
$mysed -e "s/.*/GSGSTARTGSG&GSGENDGSG/" |\
$mysed -e "s/GSGSTARTGSG/s\//" |\
$mysed -e "s/GSGENDGSG/\//" |\
$mysed -e "s/GSGTRENNERGSG/\//" > configure.2
echo "s/.*/&GSGENDGSG/" >> configure.2
echo "s/[ ]*GSGENDGSG/GSGENDGSG/g" >> configure.2
echo "s/GSGENDGSG//" >> configure.2
$mysed -f configure.2 demo/demo.csh.tpl > demo/demo.csh
}
# --------------------------------------------------------------
# ======================================
# Touch the files in a file to configure
# ======================================
#
# We touch all files in TOUCHFILES in exactly this order,
# synchronize the file system and wait for 3 seconds in between.
# This is needed for the make time stamp algorithm
# to avoid to generate files that are already there.
# Synopsis: touch_files (no argument)
# Result: no result
#
touch_files() {
if (test ! -n "$TOUCHFILES") then return; fi
for j in $TOUCHFILES; do
echo "Touch $j ..."
if (test -r $j) then
$mychmod 644 $j
$mysync
$mytouch $j
$mysync
$mysync
$mysleep 3
else
echo "WARNING: File $j is not readable or does not exist."
echo " This may be fatal or not. Try to make."
echo " If make does not work, files or generators"
echo " are missing. Then it is fatal."
fi
done
}
# --------------------------------------------------------------
# ====================================
# Check anything around the C compiler
# ====================================
# Look for the gcc first. If gcc is available, we set mycc and mycclink
# to gcc, and set ansidef to #define ANSI_C.
# If gcc is not available, we ask for cc and cclink, and ask wether
# it is ANSI. If NOANSI="no", we give a warning, if a nonansi compiler
# is selected.
# Synopsis: check_ansi_cc (no argument)
# Result: myresult contains the access path of cc
# mycclink contains the access path of the cc linker
# ansidef contains the #define for ANSI_C
# gccavail is "yes" if gcc is available
#
check_ansi_cc() {
echo ""
echo "For the case, that you do not have gcc, my compiler estimate:"
case "$mysystem" in
OSF1) echo "On OSF systems, cc should be an ANSI C compiler.";;
AIX) echo "On AIX systems, cc is an ANSI C compiler.";;
IRIX) echo "On IRIX systems, cc is an ANSI C compiler.";;
HP-UX) echo "On HP-UX systems, c89 is an ANSI C compiler,"
echo "while, cc is a K&R C compiler.";;
SunOS) echo "On Suns, cc is probably a K&R C compiler.";;
ULTRIX) echo "On ULTRIX, preferably gcc should be used.";;
*) echo "I do not know it.";;
esac
myresult=""
search_tool_at_stdplaces "gcc"
search_tool_in_path "gcc"
if (test -n "$myresult") then
gccavail="yes"
echo "Gnu gcc ($myresult) is available, thus we use it."
else
gccavail="no"
search_tool_at_stdplaces "cc"
search_tool_in_path "cc"
ask_for_program "the C compiler (preferably ANSI C)" \
"$myresult"
fi
mycc="$myresult"
case "$gccavail" in
yes) mycclink="$mycc"
echo "Gnu gcc ($myresult) is available, thus we link with gcc.";;
no) echo ""
ask_for_program "the C object file linker" "$mycc"
mycclink="$myresult";;
esac
ansidef=""
case "$gccavail" in
yes) echo "Okay, it is ANSI C."
ansidef="#define ANSI_C";;
esac
while (test ! -n "$ansidef") do
echo ""
echo "Please select: Is the C compiler ANSI C ?"
echo "1 : ANSI C 2 : traditional K&R C"
read myresult
case "$myresult" in
1) ansidef="#define ANSI_C";;
2) ansidef="#undef ANSI_C";;
*) echo "*** invalid input ***";;
esac
done
case "$NOANSI" in
no) case "$ansidef" in
"#undef ANSI_C")
echo ""
echo "WARNING: We need an ANSI C compiler"
echo " to compile this software.";;
esac;;
esac
myresult="$mycc"
}
# --------------------------------------------------------------
# ==========================================================
# Other standard questions about names, pathes, manual pages
# ==========================================================
#
# The following is a collection of standard questions about
# pathes. They can be used in the main program, if necessary.
#
# Question about something
# ------------------------
# We ask for something, described by an abbreviation.
# If we get no answer, we set a default answer.
# The description should be printed before this procedure.
# Synopsis: ask_for_something abbreviation default
# Result: myresult contains the answer
#
ask_for_something() {
mydefault="$2"
myresult=""
read myresult
if (test ! -n "$myresult") then
myresult="$mydefault"
fi
echo "The $1 is $myresult."
remove_blancs "$myresult"
}
# Question about the name of a generated program
# ----------------------------------------------
# We ask for the name of a program that is generated by make.
# The management of the result is up to the user.
# We allow two lines of description. If these are not used,
# the description nodesc.
# Synopsis: ask_for_name abbreviation descr1 descr2 default
# Result: myresult contains the name
#
ask_for_name() {
mydefault="$4"
echo ""
echo "How the $1 should be called ..."
case "$2" in
nodesc) mydummy="";;
*) echo "$2";;
esac
case "$3" in
nodesc) mydummy="";;
*) echo "$3";;
esac
echo "Please enter the name of the $1 [$mydefault]"
ask_for_something "$1" "$mydefault"
}
# Question about the binary path
# ------------------------------
# We ask for the binary path, i.e. where the executables
# are installed.
# Later, we add the substitute name BINPATHNAME and the
# binary path into the substitute list.
# Synopsis: ask_for_binpath default
# Result: mybinpath contains the binary path
#
ask_for_binpath() {
mydefault="$1"
echo ""
echo "Where the binaries go ..."
echo "Please enter the directory where the executables"
echo "should be placed [$mydefault]:"
ask_for_something "binary path" "$mydefault"
mybinpath="$myresult"
}
# Question about the library path
# -------------------------------
# We ask for the library path, i.e. where the library files
# are installed.
# Later, we add the substitute name LIBPATHNAME and the
# library path into the substitute list.
# Synopsis: ask_for_libpath default
# Result: mylibpath contains the library path
#
ask_for_libpath() {
mydefault="$1"
echo ""
echo "Where the libraries go ..."
echo "Please enter the directory where the library files"
echo "should be placed [$mydefault]:"
ask_for_something "library path" "$mydefault"
mylibpath="$myresult"
}
# Question about the manual path
# ------------------------------
# We ask for the manual path, i.e. where the manual pages
# are installed.
# Later, we add the substitute name MANPATHNAME and the
# manual path into the substitute list.
# Synopsis: ask_for_manpath default
# Result: mymanpath contains the manual path
#
ask_for_manpath() {
mydefault="$1"
echo ""
echo "Where the manual pages go ..."
echo "Please enter the directory where the manual pages"
echo "should be placed [$mydefault]:"
ask_for_something "manual path" "$mydefault"
mymanpath="$myresult"
}
# Question about the manual page extension
# ----------------------------------------
# We ask for the manual page extension, i.e. how the manual page
# should be called.
# Later, we add the substitute name MANEXTNAME and the
# manual path extension into the substitute list.
# Synopsis: ask_for_manext default
# Result: mymanext contains the manual page extension
#
ask_for_manext() {
mydefault="$1"
echo ""
echo "What the manual page extension is ..."
echo "Please enter the extension of the manual pages [$mydefault]:"
ask_for_something "manual page extension" "$mydefault"
mymanext="$myresult"
}
# --------------------------------------------------------------
# ================================================
# Standard questions about flags of the C compiler
# ================================================
# Question about the C flags used to compile
# ------------------------------------------
# We ask for the C flags used to compile to object files.
# Later, we add the substitute name CFLAGSNAME and the
# cflags into the substitute list.
# Synopsis: ask_for_cflags (no argument)
# Result: mycflags contains the C compiler options
ask_for_cflags() {
case "$mysystem" in
ULTRIX) mydefault="-c -O -DULTRIX";;
OSF1) mydefault="-c -O -DOSF";;
AIX) mydefault="-c -O -DAIXCC -DAIX";;
IRIX) mydefault="-c -O -D__STDC__";;
HP-UX) mydefault="-c -O -DHPUX -D_INCLUDE_POSIX_SOURCE";;
*) mydefault="-c -O";;
esac
case "$gccavail" in
yes) mydefault="-c -O -finline-functions -pipe";;
esac
echo ""
echo "Which C compile flags do we use ..."
case "$mysystem" in
ULTRIX)
echo "On ULTRIX systems, please add -DULTRIX"
echo "to the list of flags.";;
HP-UX)
echo "On HP-UX systems, please add -DHPUX for the c89,"
echo "and the cc compiler, but not for the gcc, and add"
echo "-D_INCLUDE_POSIX_SOURCE to the list of flags.";;
OSF1)
echo "On OSF1 compilers please add -DOSF to the"
echo "list of flags.";;
AIX)
echo "On IBM AIX XL C compiler (ANSI C)"
echo "please add -DAIXCC to the list of flags."
echo "For Gnu gcc, it is not necessary."
echo "For both, add -DAIX to the list of flags.";;
IRIX)
echo "On Silicon Graphics MIPS ucode C compiler (ANSI C)"
echo "please add -D__STDC__ to the list of flags."
echo "For Gnu gcc, it is not necessary.";;
*)
echo "For ANSI C compilers, the flag -D__STDC__ might be needed";;
esac
echo "Please enter the flags used to compile"
echo "to object files."
echo "On very small machines, please avoid expensive optimization"
echo "flags like inlining (-finline-functions)."
echo "Enter a dot for no flags [$mydefault]:"
ask_for_something "flags used to compile" "$mydefault"
case "$myresult" in
".") myresult="GSGSPACEGSG";;
esac
mycflags="$myresult"
}
# Question about the C link flags used to link objects together
# -------------------------------------------------------------
# We ask for the C flags used to link the object files into an
# executable binary.
# Later, we add the substitute name CLINKFLAGSNAME and the
# clinkflags into the substitute list.
# Synopsis: ask_for_clinkflags (no argument)
# Result: myclinkflags contains the C compiler options
ask_for_clinkflags() {
case "$gccavail" in
yes) mydefault="-o";;
no) mydefault="-o";;
esac
echo ""
echo "Which C linker flags do we use ..."
echo "Please enter the flags used to link object files"
echo "into an executable. Note: the first argument"
echo "after these flags will be the name of the executable"
echo "we want to produce."
echo "Enter a dot for no flags [$mydefault]:"
ask_for_something "flags used to link" "$mydefault"
case "$myresult" in
".") myresult="GSGSPACEGSG";;
esac
myclinkflags="$myresult"
}
# Question about the INCLUDE path used to compile
# -----------------------------------------------
# We ask for the INCLUDE path used to compile to object files.
# Later, we add the substitute name ADDINCLUDEPATHNAME and the
# cincludes flags into the substitute list.
# Synopsis: ask_for_includepath (no argument)
# Result: mycincludes contains the C compiler options
ask_for_includepath() {
mydefault="-I/usr/local/include/"
echo ""
echo "Which additional INCLUDE path do we use ..."
case "$mywindowsystem" in
"#define X11")
echo "If you are not sure, then look for one of the"
echo "files Xlib.h, Xproto.h, or Xutil.h for X11."
echo "For instance, if you find /usr/X11/include/X11/Xlib.h"
echo "then please use -I/usr/X11/include/";;
"#define SUNVIEW")
echo "If you are not sure, then look for the file sunview.h."
echo "For instance, if you find /usr/mumpf/suntool/sunview.h"
echo "then please use -I/usr/mumpf/";;
esac
echo ""
echo "Please enter the additional include paths flags"
echo "needed to compile."
echo "Enter a dot for no flags [$mydefault]:"
ask_for_something "include path flags used to compile" "$mydefault"
case "$myresult" in
".") myresult="GSGSPACEGSG";;
esac
mycincludes="$myresult"
}
# Question about the library path used to link
# --------------------------------------------
# We ask for the library path used to link the object files
# into a binary.
# Later, we add the substitute name ADDLIBPATHNAME and the
# libpath flags into the substitute list.
# Synopsis: ask_for_addlibpath (no argument)
# Result: myclibpath contains the C linker options
ask_for_addlibpath() {
mydefault="-L/usr/local/lib/"
echo ""
echo "Where are the libraries we use ..."
case "$mywindowsystem" in
"#define X11")
echo "If you are not sure, then look for one of the"
echo "files libX11.a, libX11.so.<version_number>, "
echo "or libXext.a etc."
echo "For instance, if you find /usr/local/X11/lib/X11/libX11.a"
echo "then please use -L/usr/local/X11/lib/";;
"#define SUNVIEW")
echo "If you are not sure, then look for one of the"
echo "Sunview files libsuntool.a, libsunwindow.a"
echo "or libsuntool.so.<version_number>, etc."
echo "For instance, if you find /usr/mumpf/suntool/libsuntool.a"
echo "then please use -L/usr/mumpf/";;
esac
echo ""
echo "Please enter the additional library paths flags"
echo "needed to compile and link."
echo "Enter a dot for no flags [$mydefault]:"
ask_for_something "library path flags used to link" "$mydefault"
case "$myresult" in
".") myresult="GSGSPACEGSG";;
esac
myclibpath="$myresult"
}
# Question about the libraries used to link
# -----------------------------------------
# We ask for the libraries used to link the object files
# into a binary.
# Later, we add the substitute name ADDLIBSNAME and the
# libraryflags into the substitute list.
# Synopsis: ask_for_libs defaultlibs
# Result: myclibs contains the C libraries as options
ask_for_libs() {
if (test -n "$1") then
mydefault="$1"
else
mydefault="-lm"
fi
echo ""
echo "Which libraries do we need ..."
case "$mywindowsystem" in
"#define X11")
mydefault="-lXext -lX11 -lm";;
"#define SUNVIEW")
mydefault="-lsuntool -lsunwindow -lpixrect -lm";;
esac
echo ""
echo "Please enter the flags for additional libraries"
echo "needed e.g. for X11, Sunview, Mathematics."
echo "Enter a dot for no flags [$mydefault]:"
ask_for_something "flags for additional libraries" "$mydefault"
case "$myresult" in
".") myresult="GSGSPACEGSG";;
esac
myclibs="$myresult"
}
# --------------------------------------------------------------
# ==============================================
# Standard questions about very special programs
# ==============================================
# Question about the Makedepend
# -----------------------------
# We ask for the Makedepend program.
# Later, we add the substitute name MAKEDEPENDNAME and the
# makedepend into the substitute list.
# Synopsis: ask_for_makedepend (no argument)
# Result: mymakedepend contains path of the make depend tool
ask_for_makedepend() {
myresult=""
search_tool_at_stdplaces "makedepend"
search_tool_in_path "makedepend"
if (test ! -n "$myresult") then
mydefault="no_default"
else
mydefault="$myresult"
fi
echo ""
echo "Which make depend do we use ..."
echo "To execute make depend, we need a command makedepend"
echo "that understands the -f option."
echo "Example: MakeDepend -f myMakefile creates all dependences"
echo "between the sources listed in the makefile called myMakefile."
echo "If no command makedepend is available, please enter a dummy."
echo "REMARK: To execute make depend is normally not necessary."
echo " Thus it is not fatal, if make depend is not available."
echo ""
echo "Please enter the name (access path) and options"
echo "of a command that creates the dependences of a makefile."
echo "NOTE: The option -f will be added automatically, thus do not"
echo " add this option here [$mydefault]:"
myresult=""
read myresult
if (test ! -n "$myresult") then
myresult="$mydefault"
fi
echo "$myresult found. I take it."
remove_blancs "$myresult"
if (test -n "$myresult") then
mytext=`echo "$myresult" | $mysed -e "s/GSGSPACEGSG/ /g"`
toollist_first $mytext
if (test ! -x "$tool") then
echo "Correction: $mytext not found."
echo "Note: makedepend is not available."
myresult=""
else
echo "Really: $mytext found. I take it."
fi
fi
mymakedepend="$myresult"
}
# Question about an optional executable
# -------------------------------------
# We ask for an optional executable. First, we check whether
# the executable exists with some default name. Then we ask
# for the name. At last we check if the entered executable exists.
# Synopsis: ask_for_optional_executable name_with_flags description
# Result: myresult contains the path and options of the executable
# Note: myresult may be empty, if the executable does not
# exists.
#
ask_for_optional_executable() {
tmpc="$1"
tmpd="$2"
toollist_first $1
shift_toollist $tmpc
myprog="$tool"
myopts="$toollist"
myresult=""
search_tool_at_stdplaces "$myprog"
search_tool_in_path "$myprog"
if (test ! -n "$myresult") then
mydefault="no_default"
else
mydefault="$myresult $myopts"
fi
shift
ask_for_program "$tmpd (optional)" "$mydefault"
if (test -n "$myresult") then
mytext=`echo "$myresult" | $mysed -e "s/GSGSPACEGSG/ /g"`
toollist_first $mytext
if (test ! -x "$tool") then
echo "Correction: $mytext not found."
echo "Note: $tmpd is not available."
myresult=""
else
echo "Really: $mytext found. I take it."
fi
fi
}
# Question about bison
# --------------------
# We ask for the optional parser generator bison.
# Later, we add the substitute name BISONNAME and the
# bison into the substitute list.
# Synopsis: ask_for_bison (no arguments)
# Result: mybison contains the path and options of bison.
# Note: mybison may be empty, if bison does not
# exists.
#
ask_for_bison() {
ask_for_optional_executable "bison -ydt" "the parser generator bison"
mybison="$myresult"
}
# Question about flex
# -------------------
# We ask for the optional scanner generator flex.
# Later, we add the substitute name FLEXNAME and the
# flex into the substitute list.
# Synopsis: ask_for_flex (no arguments)
# Result: myflex contains the path and options of flex.
# Note: myflex may be empty, if flex does not
# exists.
#
ask_for_flex() {
ask_for_optional_executable "flex" "the scanner generator flex"
myflex="$myresult"
}
# Question about install for directories
# --------------------------------------
# We ask for the optional install command of directories.
# Later, we add the substitute name INSTALLDIRNAME and the
# install into the substitute list.
# Synopsis: ask_for_installdir (no arguments)
# Result: mydirinstall contains the path and options.
#
ask_for_installdir() {
echo ""
echo "On some Unix System V, install for directories is "
echo "not necessary. We use the dummy command echo instead."
echo "In any case, it is a good idea if the directories"
echo "already exist where you want to install something."
echo "On SunOS, it depends whether it is Solaris or SunOS 4.1.3."
case "$mysystem" in
HP-UX)
installname="echo";;
OSF1)
installname="echo";;
AIX)
installname="echo";;
IRIX)
installname="echo";;
ULTRIX)
echo "On ULTRIX, try /usr/bin/install."
installname="/usr/bin/install -d -m 755";;
SunOS)
echo "On Solaris, I hope you get /usr/ucb/install."
echo "On SunOs 4.x, I hope you get /bin/install."
installname="install -d -m 755";;
*)
installname="install -d -m 755";;
esac
ask_for_optional_executable "$installname" \
"the installation program for directories"
mydirinstall="$myresult"
if (test ! -n "$mydirinstall") then
echo "WARNING: make install is not possible."
fi
}
# Question about install for binaries
# -----------------------------------
# We ask for the optional install command of binaries.
# Later, we add the substitute name INSTALLBINNAME and the
# install into the substitute list.
# Synopsis: ask_for_installbin (no arguments)
# Result: mybininstall contains the path and options.
#
ask_for_installbin() {
echo ""
myspcbnph=`echo "$mybinpath" | sed -e "s/.*/&GSGENDGSG/" |\
sed -e "s/\/GSGENDGSG/GSGENDGSG/" |\
sed -e "s/GSGENDGSG//" `
echo "Assume that you want to install an executable called dummy."
echo "Insert the command to install dummy."
echo "On Unix System V, use install -s -m 755 -f $myspcbnph dummy."
echo "On other systems, use install -s -m 755 dummy $myspcbnph/dummy."
echo "On SunOS, it depends whether it is Solaris or SunOS 4.1.3."
case "$mysystem" in
AIX)
echo "I hope to get /bin/install"
installname="install -s -S -M 755 -f $myspcbnph dummy";;
OSF1)
echo "I hope to get /usr/bin/install"
installname="install -g bin -u bin -S -m 755 -f $myspcbnph dummy";;
HP-UX)
installname="install -s -m 755 -f $myspcbnph dummy";;
IRIX)
installname="install -s -m 755 -f $myspcbnph dummy";;
ULTRIX)
echo "On ULTRIX, try /usr/bin/install."
installname="/usr/bin/install -s -m 755 dummy $myspcbnph/dummy";;
SunOS)
echo "On Solaris, I hope you get /usr/ucb/install."
echo "On SunOs 4.x, I hope you get /bin/install."
installname="install -s -m 755 dummy $myspcbnph/dummy";;
*)
installname="install -s -m 755 dummy $myspcbnph/dummy";;
esac
ask_for_optional_executable "$installname" \
"the installation program for executable binaries"
mybininstall="$myresult"
if (test ! -n "$myresult") then
echo "WARNING: make install is not possible."
fi
}
# Question about install for manual pages
# ---------------------------------------
# We ask for the optional install command of manual pages.
# Later, we add the substitute name INSTALLMANNAME and the
# install into the substitute list.
# Synopsis: ask_for_installman (no arguments)
# Result: mymaninstall contains the path and options.
#
ask_for_installman() {
echo ""
myspcbnph=`echo "$mymanpath" | sed -e "s/.*/&GSGENDGSG/" |\
sed -e "s/\/GSGENDGSG/GSGENDGSG/" |\
sed -e "s/GSGENDGSG//" `
echo "Assume that you want to install a manual page called dummy."
echo "Insert the command to install dummy."
echo "On Unix System V, use install -m 644 -f $myspcbnph dummy."
echo "On other systems, use install -m 644 dummy $myspcbnph/dummy."
echo "On SunOS, it depends whether it is Solaris or SunOS 4.1.3."
case "$mysystem" in
AIX)
echo "I hope to get /bin/install"
installname="install -s -M 644 -f $myspcbnph dummy";;
OSF1)
echo "I hope to get /usr/bin/install"
installname="install -g bin -u bin -m 644 -f $myspcbnph dummy";;
HP-UX)
installname="install -m 644 -f $myspcbnph dummy";;
IRIX)
installname="install -m 644 -f $myspcbnph dummy";;
ULTRIX)
echo "On ULTRIX, try /usr/bin/install."
installname="/usr/bin/install -s -m 644 dummy $myspcbnph/dummy";;
SunOS)
echo "On Solaris, I hope you get /usr/ucb/install."
echo "On SunOs 4.x, I hope you get /bin/install."
installname="install -m 644 dummy $myspcbnph/dummy";;
*)
installname="install -m 644 dummy $myspcbnph/dummy";;
esac
ask_for_optional_executable "$installname" \
"the installation program for manual pages"
mymaninstall="$myresult"
if (test ! -n "$myresult") then
echo "WARNING: make install is not possible."
fi
}
# Question about install for library files
# ----------------------------------------
# We ask for the optional install command of libaray or data files.
# Later, we add the substitute name INSTALLLIBNAME and the
# install into the substitute list.
# Synopsis: ask_for_installlib (no arguments)
# Result: mylibinstall contains the path and options.
#
ask_for_installlib() {
echo ""
myspcbnph=`echo "$mylibpath" | sed -e "s/.*/&GSGENDGSG/" |\
sed -e "s/\/GSGENDGSG/GSGENDGSG/" |\
sed -e "s/GSGENDGSG//" `
echo "Assume that you want to install a library file called dummy."
echo "Insert the command to install dummy."
echo "On Unix System V, use install -m 644 -f $myspcbnph dummy."
echo "On other systems, use install -m 644 dummy $myspcbnph/dummy."
echo "On SunOS, it depends whether it is Solaris or SunOS 4.1.3."
case "$mysystem" in
AIX)
echo "I hope to get /bin/install"
installname="install -s -M 644 -f $myspcbnph dummy";;
OSF1)
echo "I hope to get /usr/bin/install"
installname="install -g bin -u bin -m 644 -f $myspcbnph dummy";;
IRIX)
installname="install -m 644 -f $myspcbnph dummy";;
HP-UX)
installname="install -m 644 -f $myspcbnph dummy";;
ULTRIX)
echo "On ULTRIX, try /usr/bin/install."
installname="/usr/bin/install -m 644 dummy $myspcbnph/dummy";;
SunOS)
echo "On Solaris, I hope you get /usr/ucb/install."
echo "On SunOs 4.x, I hope you get /bin/install."
installname="install -m 644 dummy $myspcbnph/dummy";;
*)
installname="install -m 644 dummy $myspcbnph/dummy";;
esac
ask_for_optional_executable "$installname" \
"the installation program for library files"
mylibinstall="$myresult"
if (test ! -n "$myresult") then
echo "WARNING: make install is not possible."
fi
}
# --------------------------------------------------------------
# ================================
# Add the other substitute strings
# ================================
#
# Synopsis: add_other_substitutes (no argument)
# Result: no result, but TOOLSUBSTITUTES and TOOLNAMES changed.
#
add_other_subsitutes() {
if (test -n "$mymakedepend") then
add_substitute "$mymakedepend" MAKEDEPENDNAME
fi
if (test -n "$mybison") then
add_substitute "$mybison" BISONNAME
fi
if (test -n "$myflex") then
add_substitute "$myflex" FLEXNAME
fi
if (test -n "$ansidef") then
add_substitute "$ansidef" ANSINAME
fi
if (test -n "$mybinpath") then
add_substitute "$mybinpath" BINPATHNAME
fi
if (test -n "$mylibpath") then
add_substitute "$mylibpath" LIBPATHNAME
fi
if (test -n "$mymanpath") then
add_substitute "$mymanpath" MANPATHNAME
fi
if (test -n "$mymanext") then
add_substitute "$mymanext" MANEXTNAME
fi
if (test -n "$mycflags") then
add_substitute "$mycflags" CFLAGSNAME
fi
if (test -n "$myclinkflags") then
add_substitute "$myclinkflags" CLINKFLAGSNAME
fi
if (test -n "$mycincludes") then
add_substitute "$mycincludes" ADDINCLUDEPATHNAME
fi
if (test -n "$myclibpath") then
add_substitute "$myclibpath" ADDLIBPATHNAME
fi
if (test -n "$myclibs") then
add_substitute "$myclibs" ADDLIBSNAME
fi
if (test -n "$mydirinstall") then
add_substitute "$mydirinstall" INSTALLDIRNAME
fi
if (test -n "$mybininstall") then
add_substitute "$mybininstall" INSTALLBINNAME
fi
if (test -n "$mymaninstall") then
add_substitute "$mymaninstall" INSTALLMANNAME
fi
if (test -n "$mylibinstall") then
add_substitute "$mylibinstall" INSTALLLIBNAME
fi
}
# --------------------------------------------------------------
# Check whether a documentation file is there
# -------------------------------------------
# Synopsis: check_docfile file
# Result: no result, directory stamps are created, if needed.
#
check_docfile () {
if (test -r "doc/$1") then
echo "doc/$1 is there. Okay. "
else
echo "doc/$1 is not there."
echo "We cannot generate the documentation."
$mytouch stamp-doc
$mytouch stamp-shortdoc
fi
}
# Touch a file
# ------------
# Synopsis: touch_a_file file
# Result: no result
#
touch_a_file() {
echo "Touch $1 ..."
if (test -r $1) then
$mychmod 644 $1
$mysync
$mytouch $1
$mysync
$mysync
fi
}
# --------------------------------------------------------------
# ============
# Main Program
# ============
echo "Configuring ..."
# First, initialize myself
# ------------------------
init_tools_needed_by_myself
TOOLNAMES=""
# Ask for VCG name
# ----------------
ask_for_name "VCG tool" \
"For the Sunview version I use the name vcg." \
"For the X11 version I prefer the name xvcg." \
"xvcg"
myvcg="$myresult"
# Different pathes and extensions
# -------------------------------
ask_for_binpath "/usr/local/bin/"
# ask_for_libpath "/usr/local/lib/"
ask_for_manpath "/usr/local/man/manl/"
ask_for_manext "l"
# Special utilities
# -----------------
ask_for_makedepend
# ask_for_bison
#
# ask_for_flex
# How to produce the documentation
# --------------------------------
# mydocfmt=""
# while (test ! -n "$mydocfmt") do
# echo ""
# echo "Please select which documentation do you want ?"
# echo "If you do not have a PostScript printer, you must"
# echo "select 2. However in this case, you need big-latex."
# echo ""
# echo "1 : full documentation (includes PostScript pictures)"
# echo "2 : short documentation (needs a big-latex, uses pictex)"
# read myresult
# case "$myresult" in
# 1) mydocfmt="doc";;
# 2) mydocfmt="shortdoc";;
# *) echo "*** invalid input ***";;
# esac
# done
#
#case "$mydocfmt" in
# doc)
# $mytouch stamp-shortdoc
# ask_for_optional_executable "latex" \
# "the LaTeX text processing system"
# mylatex="$myresult"
# if (test ! -n "$mylatex") then
# echo "WARNING: latex is not available."
# echo " We do not generate the documentation."
# $mytouch stamp-doc
# mydocfmt=""
# fi;;
# shortdoc)
# $mytouch stamp-doc
# ask_for_optional_executable "big-latex" \
# "the BIG LaTeX text processing system"
# mybiglatex="$myresult"
# if (test ! -n "$mybiglatex") then
# echo "WARNING: big-latex is not available."
# echo " We do not generate the documentation."
# $mytouch stamp-shortdoc
# mydocfmt=""
# fi;;
#esac
#
#case "$mydocfmt" in
# doc)
# ask_for_optional_executable "fig2dev" \
# "the Figure to PostScript translator"
# myfigtodev="$myresult"
# if (test ! -n "$myfigtodev") then
# echo "WARNING: fig2dev is not available."
# echo " Hopefully, you have the picture ps files."
# check_docfile "foldpath.ps"
# check_docfile "foldtree.ps"
# check_docfile "hideedge.ps"
# check_docfile "hideedge.ps"
# fi
# ask_for_optional_executable "fig2ps2tex" \
# "the Figure and PostScript to TeX translator"
# myfigtopstotex="$myresult"
# if (test ! -n "$myfigtopstotex") then
# echo "WARNING: fig2ps2tex is not available."
# echo " Hopefully, you have the picture tex files."
# check_docfile "foldpath1.tex"
# check_docfile "foldtree1.tex"
# check_docfile "hideedge1.tex"
# check_docfile "hideedge1.tex"
# fi;;
# shortdoc)
# ask_for_optional_executable "fig2dev" \
# "the Figure to PicTeX translator"
# myfigtodev="$myresult"
# if (test ! -n "$myfigtodev") then
# echo "WARNING: fig2dev is not available."
# echo " Hopefully, you have the picture tex files."
# check_docfile "foldpath2.tex"
# check_docfile "foldtree2.tex"
# check_docfile "hideedge2.tex"
# check_docfile "hideedge2.tex"
# fi;;
#esac
# How to install the stuff
# ------------------------
ask_for_installdir
ask_for_installbin
ask_for_installman
# ask_for_installlib
# Now we look for tools and programs (see TOOLS and PROGRAMS)
# -----------------------------------------------------------
search_tools
search_programs
update_toolnames_needed_by_myself
# Check the Window system
# -----------------------
#mywindowsystem=""
mywindowsystem="#define X11"
while (test ! -n "$mywindowsystem") do
echo ""
echo "Please select the window system."
echo "1 : X11 2 : Sunview "
read myresult
case "$myresult" in
1) mywindowsystem="#define X11";;
2) mywindowsystem="#define SUNVIEW";;
*) echo "*** invalid input ***";;
esac
done
case "$mywindowsystem" in
"#define X11")
echo ""
echo "Which is the default X11 font ... "
echo "Please insert the alias of the default X11 font"
echo "you wish to use. Appropriate fonts should have"
echo "a pointsize of 14-17. Please do not select a "
echo "too large font. [-*-courier-*-*-*--14-*-*-*-*-*-*-*]:"
ask_for_something "font alias" \
"-*-courier-*-*-*--14-*-*-*-*-*-*-*"
myfontalias="$myresult"
echo ""
echo "Which solution do we take for the InputFocus problem ... "
echo "Normally, X11 programs do not take aktively the input"
echo "focus, but some window managers do not work correctly"
echo "on setting the input focus. In this case, the keypresses"
echo "are sometimes ignored by the VCG tool."
echo "The solution is that the VCG tool grabs actively the input"
echo "focus. But this solutions is only appropriate if you really"
echo "want to input something when the VCG tool is called."
echo "Do you wish the VCG tool to grab the input focus ?"
echo "The conservative answer should be no."
echo "Please enter yes or no to answer this [no]:"
ask_for_something "input focussing" "no"
case "$myresult" in
n|no|No|N) myinputgrab="#define NOINPUTFOCUS";;
*) myinputgrab="#undef NOINPUTFOCUS";;
esac
esac
# Any flags for the C compiler
# ----------------------------
ask_for_cflags
ask_for_clinkflags
ask_for_includepath
ask_for_libs "dummy"
ask_for_addlibpath
# Check memory organinsation of our tool
# --------------------------------------
#
echo ""
echo "Memory organisation ..."
echo ""
echo "How structs must be aligned ..."
echo "Structs containing chars, pointers, integers and"
echo "floats must be aligned. Normally, alignment of 8"
echo "is sufficient. It should be a power of 2."
echo "Please enter the alignment required by the compiler [8]:"
ask_for_something "alignment required by the compiler" "8"
myalignment="$myresult"
echo ""
echo "How many bytes should be a block ..."
echo "The memory management allocates blocks of this size,"
echo "and dynamically increases the number of blocks, if more"
echo "memory is necessary. Do not set the blocksize too small."
echo "For instance the tool does not work with blockssize less"
echo "than 1 KB. Propose for good performance: 256 KB minimal."
echo "Please enter the number of bytes per block for the memory"
echo "manager [1048576]:"
ask_for_something "number of bytes per block for the memory manager" "1048576"
myblocksize="$myresult"
# Update the substitute list
# ---------------------------
echo "Wait"
add_substitute "$myvcg" VCGNAME
if (test -n "$mylatex") then
add_substitute "$mylatex" LATEXNAME
fi
if (test -n "$mybiglatex") then
add_substitute "$mybiglatex" BIGLTEXNAME
fi
if (test -n "$myfigtodev") then
add_substitute "$myfigtodev" FIGTODEVNAME
fi
if (test -n "$myfigtopstotex") then
add_substitute "$myfigtopstotex" FIGTOPSTOTEXNAME
fi
if (test -n "$mywindowsystem") then
add_substitute "$mywindowsystem" WINDOWSYSTEMNAME
fi
if (test -n "$myfontalias") then
add_substitute "$myfontalias" FONTALIASNAME
fi
if (test -n "$myinputgrab") then
add_substitute "$myinputgrab" INPUTFOCUSNAME
fi
add_substitute "$myalignment" ALIGNMENTNAME
add_substitute "$myblocksize" BLOCKSIZENAME
add_other_subsitutes
# Final check and configuration
# -----------------------------
final_check_of_substitutes
config_files
touch_files
case "$mydocfmt" in
doc)
if (test ! -n "$myfigtodev") then
touch_a_file doc/foldpath.ps
touch_a_file doc/foldtree.ps
touch_a_file doc/hideedge.ps
touch_a_file doc/window.ps
fi
$mysleep 3
$mysync
$mysync
if (test ! -n "$myfigtopstotex") then
touch_a_file doc/foldpath1.tex
touch_a_file doc/foldtree1.tex
touch_a_file doc/hideedge1.tex
touch_a_file doc/window1.tex
fi;;
shortdoc)
if (test ! -n "$myfigtodev") then
touch_a_file doc/foldpath2.tex
touch_a_file doc/foldtree2.tex
touch_a_file doc/hideedge2.tex
touch_a_file doc/window2.tex
fi;;
esac
abort_successfully
######################## NEVER REACHED ###########################
|