/usr/bin/acr-sh is in acr 1.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 | #!/bin/sh
#
# Copyright (C) 2005-2016
# pancake <pancake@nopcode.org>
#
# acr 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.
#
# acr 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 acr; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#===========================================================================
#
# ACR: Auto Conf Replacement
#
# @license: GPLv2
# @author: pancake <pancake@nopcode.org>
# @homepage: http://github.com/radare/acr
# @version: 1.2
#
# acr-sh:
# acr configure script generator.
#
#== How to find things in this large file ==
#
# Just search for the required string:
#
# ##INIT## : All variable initilializations
# ##KEYWORDS## : switch/case with all keywords supported in configure.acr
# ##FI## : Large enumeration of fi's :)
# ##FUNCS## : helpkit functions
# ##LANGS## : LANG_XXX keywords
# ##ENV_LANG## : env_XXX for languages
#
#=============================================================================
#
ACR_VERSION=1.2
CONFIGURE="$2"
: {CONFIGURE:=./configure}
: {STRIP:=0}
if [ -z "$1" ]; then
if [ -f "configure.acr" ]; then
ACRFILE=configure.acr
else
echo "No 'configure.acr' found in current directory." >&2
echo "Give me the file name as argument." >&2
exit 1
fi
else
ACRFILE="$1"
fi
##AWK##
AWK=awk
AWK_STRING="`awk 2>/dev/null`"
if [ -z "${AWK_STRING}" ]; then
Q=`${AWK} 2>&1`
if [ 1 = "$(echo ${Q} | wc -l | awk '{print $1}')" ]; then
AWK_STRING=awk
else
AWK_STRING="`awk -W version 2>&1`"
fi
fi
[ `expr "$AWK_STRING" : "mawk"` -gt 0 ] && AWK="awk -W interactive"
##
## boolean() {
## case "$1" in
## ""|0) echo false ; ;;
## *) echo true ; ;;
## }
##
## {{{ Variable initialization
##INIT##
SET_VAR=""
TMP_VAR=""
STR2=""
STRING=""
H_FILES=""
SH_FILES=""
MODE=""
SCRIPT=": " # The user code script buffer
# Utilities
S="$" # hacky stuff
C="\`"
# Language initialization
LANG=0 # No langs yet defined
LANG_C="" LANG_C_REQUIRED="" LANG_C_ENV="" LANG_CPP_ENV=""
LANC_CXX="" LANG_CXX_REQUIRED="" LANG_CXX_ENV=""
LANG_VALA="" LANG_VALA_REQUIRED="" LANG_VALA_ENV=""
LANG_TCL="" LANG_TCL_REQUIRED="" LANG_TCL_ENV=""
LANG_PERL="" LANG_PERL_REQUIRED="" LANG_PERL_ENV=""
LANG_JAVA="" LANG_JAVA_REQUIRED="" LANG_JAVA_ENV=""
LANG_PYTHON="" LANG_PYTHON_REQUIRED="" LANG_PYTHON_ENV=""
LANG_RUBY="" LANG_RUBY_REQUIRED="" LANG_RUBY_ENV=""
LANG_LUA="" LANG_LUA_REQUIRED="" LANG_LUA_ENV=""
# Defaults
PKGNAME="this package"
VERSION=""
_CONTACT=0
CONTACT_MAIL=""
CONTACT_NAME=""
_AUTHOR=0
AUTHOR_MAIL=""
AUTHOR_NAME=""
# Report
REPORT_REQUIRED="" REPORT_PKGCFG="" REPORT_OPTIONAL=""
REPORT_FLAGS="" REPORT_LANGS="" REPORT_TOOLS=""
# Environment
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR"
ENVWORDS="${ENVWORDS} LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX"
ENVWORDS="${ENVWORDS} TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM"
ENVWORDS="${ENVWORDS} INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA"
ENVWORDS="${ENVWORDS} HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU"
ENVHELP=""
# Checks
CHKUSR_NAME=""
CHKUSR_TARGET=""
# ALL INTERNAL FLAGS #
HAVE_LIBS=0
REPORT=""
_REQUIRED=0
#- pkgconfig -#
_USE_LIBTOOL=0
_USE_LIBTOOL_REQUIRED=0
_USE_PTHREAD=0
_PC_CFLAGS=""
_PC_LDFLAGS=""
#-- ? --#
USE_BACKUP=0
# XXX #_REPORT_DEFINED=0
_REQUIRE_ACR_VERSION=0
NKEYS=0
_EXEC=0
_EXEC_VAR=""
_NOT=0
_USE_DL_USED=0
_CHKVER=0
_SIZEOF=0
_DIE_VAR=""
_DIE_BOOL=0
_IF=0
_IF_VAR=""
_IF_VAR2=""
_IF_OP=""
_IF_BOOL=0
_IF_SETVAR=""
_IF_VALUE=""
_IF_SETVALUE=""
_IF_VALUE_EOF=0
_IFAND=0
_IFEQ=0
_IFEQVAL=0
#_REPORT=0
_CHK_PM=0
_CHK_RU=0
_CHK_PM_NAME=""
#_CHKLIB=0
_CHKLIB_NAME=""
_CHKFUNC=0
_CHKFUNC_NAME=""
_CHKFUNC_LIB=""
_CHKPRG_VAR=""
_CHKPRG_NAME=""
CHECK_VAR=""
CHECK_EOF=""
CHECK_STR=""
ARGUMENT="" # ARGUMENTS #
ARG_VALUE=""
ARG_NAME=""
ARG_FLAG=""
ARG_DESC=""
FLAGHELP=""
FLAGSCRIPT=""
_EQUAL_3=0
EQUAL=""
EQUALSCR=""
_PKGNAME=""
PACKAGE_BUGREPORT=""
S_FILES="" # subst files
S_MKDIR="" # subst directories to be created
SD_FILES=""
INIVARS=""
SUBDIRS=0
SUBCONF=0
SUBCONF_DIRS=""
## }}}
## {{{ print_header
print_header() {
cat <<_EOF_
#!/bin/sh
# This script was automatically generated by ACR v${ACR_VERSION}
# @author: pancake <nopcode.org>
# @url: http://www.nopcode.org
# @repo: git clone https://github.com/radare/acr
do_remove() {
if [ "${S}{ACR_RMFILES}" ]; then
printf "cleaning temporally files... "
rm -f ${S}{ACR_RMFILES}
echo "done"
fi
}
control_c() {
printf "\\n\\n^C control-c : script execution interrupted.\\n"
do_remove
exit 1
}
trap control_c 2
_EOF_
}
## }}}
## {{{ Help Functions
##FUNCS##
add_envword() {
for A in ${ENVWORDS}; do
if [ "${A}" = "$1" ]; then
if [ "${EQUAL}" = 1 ]; then # IFOP='='
echo "`word` < Warning: duplicated export variable '$1'." >&2
fi
return;
fi
done
[ "${DEBUG}" = 1 ] && echo " | env $1" >&2
ENVWORDS="${ENVWORDS} $1"
}
add_lang_envwords() {
for A in `eval echo ${S}LANG_$1_ENV`; do
add_envword ${A}
done
}
word() {
printf "%04d" $WORDS_N
}
reset_vars() {
MODE=""
_IF_OP=""
_IF_VAR=""
_IF_VAR2=""
_IF_SETVAR=""
_IF_SETVAL=""
_IF_VALUE=""
}
get_current_compiler() {
case "${CURRENT_LANG}" in
"c") COMPILER="CC" ; ;;
"c++") COMPILER="CXX" ; ;;
*) echo "No current compiler selected." >&2 ; exit 1 ; ;;
esac
}
concat() {
OLD="$1"
NEW="$2"
[ "${NEW}" = "\;" ] && NEW=";"
if [ -z "${OLD}" ]; then
printf -- "${NEW}"
else
printf -- "${OLD} ${NEW}"
fi
}
check_ifop() {
IFOP=$1
case "${IFOP}" in
"="|"+="|"?=")
;;
"<-")
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
*)
echo "`word` | Invalid operator '${IFOP}' in assignment." >&2
exit 1
;;
esac
}
## }}}
## {{{ Check program path
check_prg() {
_CHKPRG_VAR=$1
_CHKPRG_NAME=$2
_CHKPRG_REQUIRED=$3
add_envword HAVE_${_CHKPRG_VAR}
add_envword ${_CHKPRG_VAR}
# XXX: -x check is also valid for directories
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for ${_CHKPRG_NAME}... "
if [ -x "${S}{${_CHKPRG_VAR}}" ]; then
FIND=${S}{${_CHKPRG_VAR}}
else
FIND=""
IFS=:
for A in ${S}{PATH} ; do
if [ -x "${S}{A}/${_CHKPRG_NAME}" ]; then
FIND="${S}{A}/${_CHKPRG_NAME}"
break;
fi
done
unset IFS
fi
if [ -n "${S}{FIND}" ]; then
echo ${S}{FIND};
HAVE_${_CHKPRG_VAR}=1
${_CHKPRG_VAR}=${S}{FIND}
else
HAVE_${_CHKPRG_VAR}=0
${_CHKPRG_VAR}=${_CHKPRG_NAME}
echo no
EOF
`
if [ "${_CHKPRG_REQUIRED}" = 1 ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
echo "error: This program is required." >&2
exit 1
EOF
`
fi
SCRIPT="${SCRIPT} ; fi"
_CHKPRG_NAME=""
}
## }}}
## {{{ Vala
lang_vala() {
LANG=1
LANG_VALA=1
LANG_VALA_ENV="VALA VAVAC HAVE_LANG_VALA"
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking vala compiler... "
HAVE_LANG_VALA=1
HAVE_VALA=1
HAVE_VALAC=1
VALA_VERSION=""
echo "void main(){}" > .test.vala
${S}{VALAC} .test.vala 2>&1 >/dev/null
if [ ${S}? = 0 ]; then
echo ${S}{VALAC};
VALA_VERSION=${S}(${S}{VALAC} --version | cut -d " " -f 2 | cut -d . -f 1,2);
printf "checking vala... ";
${S}{VALA} .test.vala 2>&1 >/dev/null
if [ ${S}? = 0 ]; then
echo ${S}{VALA};
else
echo no ; HAVE_LANG_VALA=0 ; HAVE_VALA=0
fi
else
echo no ; HAVE_LANG_VALA=0 ; HAVE_VALAC=0
fi
_EOF_
`
if [ "${LANG_VALA_REQUIRED}" = 1 ]; then
SCRIPT="
${SCRIPT}
if [ \"${S}{HAVE_LANG_VALA}\" = 0 ]; then
echo \"ERROR: ${S}{VALAC} cannot create C code\"; exit 1
fi
"
fi
SCRIPT="${SCRIPT} rm -f .test.vala"
}
env_vala() {
[ -n "${LANG_JAVA_ENV}" ] && return
ACR_RMFILES="${ACR_RMFILES} .test.vala .test"
add_lang_envwords "VALA"
REPORT_LANGS="${REPORT_LANGS} vala"
ENVHELP=`cat <<EOF
${ENVHELP}
VALAC Vala compiler to be used.
EOF
`
add_flag with VALA vala "vala" "Manually assign the vala program"
add_flag with VALAC valac "valac" "Manually assign the valac compiler program"
lang_vala
}
## }}}
## {{{ Java
lang_java() {
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking java compiler... "
HAVE_LANG_JAVA=1
echo "class test{public static void main(){}}" > test.java
if [ "${S}{JAVAC}" = "javac" ]; then if [ "${S}{JAVA_HOME}" ]; then
JAVAC="${S}{JAVA_HOME}/bin/javac"
fi;fi
${S}{JAVAC} test.java 2>&1 >/dev/null
if [ ${S}? = 0 ]; then echo ${S}{JAVAC}; else
echo no ; HAVE_LANG_JAVA=0
_EOF_
`
if [ "${LANG_JAVA_REQUIRED}" = 1 ]; then
SCRIPT="
${SCRIPT}
echo \"ERROR: ${S}{JAVAC} cannot create bytecode\"; exit 1"
fi
SCRIPT="${SCRIPT} ; fi"
}
env_java() {
[ -n "${LANG_JAVA_ENV}" ] && return
LANG=1
LANG_JAVA=1
LANG_JAVA_ENV="JAVA JAVAC HAVE_LANG_JAVA JAVA_HOME"
ACR_RMFILES="${ACR_RMFILES} test.java test.class"
add_lang_envwords "JAVA"
REPORT_LANGS="${REPORT_LANGS} java"
ENVHELP=`cat <<EOF
${ENVHELP}
JAVAC Java compiler to be used.
JAVA_HOME Path to the Java SDK prefix.
EOF
`
add_flag with JAVAC javac "javac" "Manually assign the javac program"
add_flag with JAVAC jikes "jikes" "Use jikes instead of javac"
add_flag with JAVAC kjc "kjc" "Use the kaffe compiler"
lang_java
}
use_jni() {
add_envword "JAVA_HOME"
add_envword "JCFLAGS"
REPORT_REQUIRED="${REPORT_REQUIRED} JNI"
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for java native interface (jni)... "
if [ -z "${S}{JAVA_HOME}" ]; then
echo no
echo "ERROR: JAVA_HOME not defined." >&2
exit 1
fi
JCFLAGS="-I${S}{JAVA_HOME}/include -I${S}{JAVA_HOME}/include/linux"
echo "#include <jni.h>" > test.c
eval \\\\${S}${S}{COMPILER} test.c ${S}{JCFLAGS} -c >/dev/null 2>&1
if [ \"${S}?\" = 0 ]; then
echo ok
else
echo no
fi
EOF
`
}
## }}}
## {{{ Flag parsing (--enable-xxx)
add_flag() {
# $1 = type (with,without,enable,disable)
# $2 = affected variable
# $3 = flag name (-static)
# $4 = default value
# $5 = description
# $6 = argument name? ## XXX NOT USED XXX
REPORT_FLAGS="${REPORT_FLAGS} --${1}-${3}"
add_envword ${2}
_TMP_=""
TABS="`echo \"--${1}-${3}\" | ${AWK} '{ len=23-length($1); if (len<1) { print ""; len=25 } ; for (i=0;i<len;i++) { printf " "; } }'`"
if [ -z "${4}" ]; then
case $1 in
"enable"|"with") value=1; echo "${2}=0"; ;;
"disable"|"without") value=0; echo "${2}=1"; ;;
esac
FLAGSCRIPT=`printf "${FLAGSCRIPT}\n\"--${1}-${3}\") $2=\"${value}\"; ;;"`
else
REPORT_FLAGS="${REPORT_FLAGS}=${4}"
echo "[ -z \"${S}{$2}\" ] && ${2}=\"${4}\""
FLAGSCRIPT="`printf \"${FLAGSCRIPT}\n\"--${1}-${3}\") if [ -z \\\"${S}{value}\\\" ]; then $2=\\\"${4}\\\"; else $2=\\\"${S}{value}\\\" ; fi ;;\"`"
_TMP_=" (${2}=${4})"
fi
_TMP_="`printf " --${1}-${3}${6}${TABS}${5}${_TMP_}"`"
FLAGHELP="${FLAGHELP}
${_TMP_}"
}
## }}}
## {{{ Bash
lang_bash() {
LANG=1
REPORT_LANGS="${REPORT_LANGS} bash"
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for bash... "
type bash 2>&1 >/dev/null
if [ ${S}? = 0 ]; then echo yes ;
SH=\`sh -c "command -v bash 2>/dev/null"\`
else echo no ; fi
_EOF_
`
add_envword "SH"
ENVHELP=`cat <<EOF
${ENVHELP}
SH Environment for bash command
EOF
`
}
## }}}
## {{{ Ruby
env_ruby() {
LANG_RUBY=1
if [ "${LANG_RUBY_ENV}" ]; then return ; fi
add_envword "RUBY"
add_envword "RUBY_VERSION"
LANG_RUBY_ENV="RUBY RUBY_VERSION" ## TODO no need to use this now.
ENVHELP=`cat <<EOF
${ENVHELP}
RUBY Ruby interpreter path or binary name.
EOF
`
REPORT_LANGS="${REPORT_LANGS} ruby"
## lang_ruby
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for ruby... "
HAVE_LANG_RUBY=0
for A in \\\`echo ${S}{PATH} | sed -e 's,:, ,g'\\\`; do
RUBY=\\\`ls ${S}{A}/ruby* 2>/dev/null\\\`
if [ "${S}{RUBY}" ]; then
RUBY=\\\`echo ${S}{RUBY} | cut -d\ -f 1\\\`
RUBY_VERSION=\\\`echo ${S}{RUBY} ${S}{A} | ${AWK} '{ print substr(${S}1,length(${S}2)+6) }'\\\`
echo ${S}{RUBY} ; HAVE_LANG_RUBY=1 ; break
fi
done
if [ -z "${S}{RUBY}" ]; then
echo no
_EOF_
`
if [ "${LANG_RUBY_REQUIRED}" ]; then
SCRIPT=`cat <<_EOF_
${SCRIPT}
echo "ERROR: No ruby binaries found in PATH" >&2
exit 1
_EOF
`
fi
SCRIPT="${SCRIPT} ; fi"
}
## }}}
## {{{ | Ruby Modules
check_ru() {
HAVE_LIBS=1
VAR=`echo "HAVE_RU_$1" | \
sed -e 's, ,,g' | \
sed -e 's,/,_,g' | \
${AWK} '{ print toupper($0); }'`
add_envword "${VAR}"
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for ${1} ruby extension... "
if [ -z "${S}{RUBY}" ]; then
false
else
\\\`echo "require '$1'" | ${S}{RUBY} 2> /dev/null\\\`
fi
if [ 0 = ${S}? ]; then
${VAR}=1 ; echo ok
else
${VAR}=0 ; echo no
EOF
`
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
echo "This ruby extension is required."
exit 1
EOF
`
fi
SCRIPT="${SCRIPT} ; fi"
}
## }}}
## {{{ Python
lang_python() {
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for python... "
HAVE_LANG_PYTHON=0
for A in \\\`echo ${S}{PATH} | sed -e 's,:, ,g'\\\` ; do
PYTHON=\\\`ls ${S}{A}/python* 2>/dev/null\\\`
if [ "${S}{PYTHON}" ]; then
PYTHON=\\\`echo ${S}{PYTHON} | ${AWK} '{print ${S}1; }'\\\`
echo ${S}{PYTHON} ; HAVE_LANG_PYTHON=1 ; break ; fi
done
if [ -z "${S}{PYTHON}" ]; then
echo no
_EOF_
`
if [ "${LANG_PYTHON_REQUIRED}" ]; then
SCRIPT=`cat <<_EOF_
${SCRIPT}
echo "ERROR: No python binaries found in PATH" >&2
exit 1
_EOF_
`
fi
SCRIPT="${SCRIPT} ; fi"
}
env_python() {
[ -n "${LANG_PYTHON_ENV}" ] && return
LANG=1
LANG_PYTHON=1
LANG_PYTHON_ENV="PYTHON HAVE_LANG_PYTHON"
add_lang_envwords "PYTHON"
REPORT_LANGS="${REPORT_LANGS} python"
lang_python
}
## }}}
## {{{ - modules
check_py() {
HAVE_LIBS=1
VAR=`echo "HAVE_PY_$1" | sed -e 's, ,,g' | tr '[a-z]' '[A-Z]'`
add_envword "${VAR}"
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for ${1} python module... "
if [ -z "${PYTHON}" ]; then false ; else
\\\`echo import ${1} | ${S}{PYTHON} - 2>&1 >/dev/null\\\` 2>/dev/null
fi
if [ ${S}? = 0 ]; then
${VAR}=1
echo ok
else
${VAR}=0
echo no
EOF
`
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT}
echo \"This python module is required.\"
exit 1"
fi
SCRIPT="${SCRIPT} ; fi"
}
## }}}
## {{{ Lua
lang_lua() {
SCRIPT="${SCRIPT}
printf \"checking for lua... \"
HAVE_LANG_LUA=0
${S}{LUA} -v > /dev/null 2>&1
if [ ${S}? = 0 ]; then
echo ok ; HAVE_LANG_LUA=1 ;
echo \"checking for lua libs... \""
if [ "${LANG_C}" = 1 ]; then
check_lib lua
check_lib lua5.1
SCRIPT="${SCRIPT}
if [ \"${S}{HAVE_LIB_LUA}\" = 1 ]; then
LUA_LIBS=-llua
fi
if [ \"${S}{HAVE_LIB_LUA5_1}\" = 1 ]; then
LUA_LIBS=-llua5.1
fi
"
fi
SCRIPT="${SCRIPT}
else
echo no"
if [ "${LANG_LUA_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT}
echo \"${LINENO}: You need lua.\" >&2
exit 1" ; fi
SCRIPT="${SCRIPT} ; fi"
}
env_lua() {
[ -n "${LANG_LUA_ENV}" ] && return
LANG=1
LANG_LUA=1
LANG_LUA_ENV="LUA HAVE_LANG_LUA LUA_LIBS"
add_lang_envwords "LUA"
REPORT_LANGS="${REPORT_LANGS} lua"
ENVHELP="${ENVHELP}
LUA path to lua interpreter"
lang_lua
}
## }}}
## {{{ Perl
env_perl_threads() {
add_envword "HAVE_LANG_PERL_THREADS"
if [ -z "${LANG_PERL}" ]; then
echo "`word` You must set LANG_PERL before calling USE_PERL_THREADS" >&2
exit 1
fi
SCRIPT="${SCRIPT}
printf \"checking for perl threads... \"
HAVE_LANG_PERL_THREADS=1
${S}{PERL} -e 'use threads;' 2>&1 > /dev/null
if [ ${S}? = 0 ]; then
echo ok; else
echo no ; HAVE_LANG_PERL_THREADS=0
"
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT} echo \"ERROR: You need perl with threads.\" >&2 ; exit 1; fi"
else
SCRIPT="${SCRIPT} fi"
fi
}
lang_perl() {
SCRIPT="${SCRIPT}
printf \"checking for perl... \"
HAVE_LANG_PERL=0
${S}{PERL} -e '' 2>&1 > /dev/null
if [ ${S}? = 0 ]; then
echo ok ; HAVE_LANG_PERL=1 ; else
echo no "
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT}
echo \"${LINENO}: You need perl installed on your system.\" >&2
exit 1"
fi
SCRIPT="${SCRIPT} ; fi"
}
env_perl() {
[ -n "${LANG_PERL_ENV}" ] && return
LANG=1
LANG_PERL=1
LANG_PERL_ENV="PERL HAVE_LANG_PERL"
ACR_RMFILES="${ACR_RMFILES} test.pl"
add_lang_envwords "PERL"
REPORT_LANGS="${REPORT_LANGS} perl"
lang_perl
}
## }}}
## {{{ + modules
check_pm() {
HAVE_LIBS=1
VAR=`echo "HAVE_PM_$1" | sed -e 's, ,,g;s,:,,g' | tr '[a-z]' '[A-Z]'`
add_envword "${VAR}"
SCRIPT="${SCRIPT}
printf \"checking for '${1}' perl module ... \"
perl -m${1} -e '' 2>/dev/null
if [ ${S}? = 0 ]; then
${VAR}=1
echo ok
else
${VAR}=0
echo no
"
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT}
echo 'This perl module is required.'
exit 1
"
fi
SCRIPT="${SCRIPT} fi"
}
## }}}
## {{{ C
lang_c() {
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for c compiler... "
HAVE_LANG_C=1
if [ "${S}{CROSSBUILD}" = 1 ]; then
(command -v ${S}{HOST}-${S}{CC} >/dev/null 2>&1)
if [ ${S}? = 0 ]; then CC="${S}{HOST}-${S}{CC}"; fi
fi
echo "int main(int argc, char **argv){return 0;}" > test.c
(exec ${S}{CC} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{LDFLAGS} test.c >/dev/null 2>&1)
if [ ${S}? = 0 ]; then echo ${S}{CC}; else
echo no ; HAVE_LANG_C=0
_EOF_
`
if [ "${LANG_C_REQUIRED}" = 1 ]; then
SCRIPT="${SCRIPT}
do_remove
echo \"ERROR: ${S}{CC} cannot create executables\" >&2 ;
exit 1"
fi
SCRIPT="${SCRIPT} ; fi"
lang_cpp
}
env_cpp() {
CURRENT_LANG="c"
SCRIPT="${SCRIPT}
COMPILER=CC"
[ -n "${LANG_CPP_ENV}" ] && return
LANG_CPP_ENV="CPPFLAGS CPP"
ENVHELP="${ENVHELP}
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
CPP C preprocessor"
}
env_c() {
[ -n "${LANG_C_ENV}" ] && return
LANG=1
LANG_C=1
LANG_C_ENV="CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C"
ACR_RMFILES="${ACR_RMFILES} test.c a.out a.exe"
REPORT_LANGS="${REPORT_LANGS} c"
add_lang_envwords "C"
ENVHELP="${ENVHELP}
CC C compiler command
CFLAGS C compiler flags
CPPFLAGS C preprocessor flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>"
env_cpp
lang_c
}
lang_cpp() {
LANG=1
if [ "${LANG_CPP_ENV}" ]; then return ; fi
add_envword "CPP"
echo "printf \"checking for cpp... \""
echo "if [ \"${S}{CROSSBUILD}\" = 1 ]; then"
echo "(exec ${S}{HOST}-${S}{CPP} --help >/dev/null 2>&1)"
echo "[ ${S}? = 0 ] && CPP=\"${S}{HOST}-${S}{CPP}\""
echo "fi"
echo "(echo \"int main(int ac, char **av){return 0;}\" | ${S}{CPP} ${CPPFLAGS} >/dev/null 2>&1)"
echo "if [ \$? = 0 ]; then echo ${S}{CPP}; else"
echo "echo \"ERROR: ${S}{CPP} cannot parse sources\"; fi"
echo ""
}
## }}}
## {{{ C++
lang_cxx() {
add_envword "CXX"
SCRIPT="
${SCRIPT}
HAVE_LANG_CXX=1
printf \"checking for c++ compiler... \"
if [ \"${S}{CROSSBUILD}\" = 1 ]; then
(command -v ${S}{HOST}-${S}{CXX} 2>&1 >/dev/null)
if [ \"${S}?\" = 0 ]; then CXX=\"${S}{HOST}-${S}{CXX}\"; fi
fi
echo \"#include <iostream>\" > test.cxx
echo \"int main(){ std::cout << 1; return 0;}\" >> test.cxx
(exec ${S}{CXX} ${S}{CXXFLAGS} ${S}{LDFLAGS} test.cxx -lstdc++ >/dev/null 2>&1)
if [ \$? = 0 ]; then echo ${S}{CXX}; else
HAVE_LANG_CXX=0
echo no
"
if [ "${LANG_CXX_REQUIRED}" = 1 ]; then
SCRIPT="
${SCRIPT}
echo \"ERROR: ${S}{CXX} cannot create executables\" >&2 ;
do_remove
exit 1
"
fi
SCRIPT="${SCRIPT} fi"
lang_cpp
}
env_cxx() {
CURRENT_LANG="c++"
CURRENT_LANG="c"
SCRIPT="${SCRIPT}
COMPILER=CXX"
LANG=1
[ "${LANG_CXX_ENV}" ] && return
LANG_CXX=1
REPORT_LANGS="${REPORT_LANGS} c++"
ACR_RMFILES="${ACR_RMFILES} test.c test.cxx a.out a.exe"
LANG_CXX_ENV="CXX CXXFLAGS LDFLAGS HAVE_LANG_CXX"
add_lang_envwords "CXX"
ENVHELP=`cat <<EOF
${ENVHELP}
CXX C++ compiler command
CXXFLAGS C++ compiler flags
EOF
`
lang_cxx
}
## }}}
## {{{ Objective C
env_objc() {
# The Compiler
[ "${LANG_OBJC_REQUIRED}" = 1 ] && LANG_C_REQUIRED=1
_REQUIRED=1
env_c
check_lib objc
SCRIPT=`cat <<EOF
${SCRIPT}
HAVE_LANG_OBJC=0
[ "${S}{HAVE_LIB_OBJC}${S}{HAVE_LANG_C}" = 11 ] && HAVE_LANG_OBJC=1
EOF
`
}
## }}}
## {{{ | Check Includes
_CHECK_INC=""
check_inc() {
INC=$1
VAR=`echo "HAVE_$1" | sed -e 's,\.,_,g' -e 's,/,_,g' -e 's,+,_,g' | tr "[a-z]" "[A-Z]"`
add_envword "${VAR}"
get_current_compiler
if [ -z "${_CHECK_INC}" ]; then
SCRIPT="
${SCRIPT}
check_include() {
VAR=${S}1
INC=${S}2
_REQUIRED=${S}3
printf \"checking for ${S}2... \"
echo > test.c"
for A in `echo ${S}{INC} | sed -e 's,+, ,g'`; do
SCRIPT="${SCRIPT}
echo \"#include <${A}>\" >>test.c"
done
SCRIPT=`cat <<EOF
${SCRIPT}
echo "int main(int ac, char **av){return 0;}" >>test.c
eval \\\\${S}${S}{COMPILER} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{CXXFLAGS} test.c >/dev/null 2>&1
if [ ${S}? = 0 ]; then
eval ${S}{VAR}=1
echo yes
else
eval ${S}{VAR}=0
echo no
EOF
`
if [ 1 = "${_REQUIRED}" ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
echo "ERROR: required include not found." >&2
do_remove
exit 1
EOF
`
fi
SCRIPT="${SCRIPT} ; fi }"
_CHECK_INC=included
fi
SCRIPT="${SCRIPT}
check_include ${VAR} ${INC} ${_REQUIRED}
"
}
## }}}
## {{{ | Endian
check_endian() {
add_envword "LIL_ENDIAN"
add_envword "BIG_ENDIAN"
add_envword "BYTEORDER"
SCRIPT="
${SCRIPT}
printf \"checking host endianness... \"
LIL_ENDIAN=${S}(printf I|od|awk '{print substr(${S}2,6,1);exit}')
if [ $? != 0 -o \"${S}{LIL_ENDIAN}\" = 1 ]; then
BYTEORDER=1234
BIG_ENDIAN=0
echo little
else
BYTEORDER=4321
BIG_ENDIAN=1
LIL_ENDIAN=0
echo big
fi
"
}
## }}}
## {{{ | Check Libraries
check_lib() {
_CHKLIB_NAME=$1
HAVE_LIBS=1
#_CHKLIB_LIBS="`echo $1 | awk -F + '{ for(i=1;i<=NF;i++) { str=str "-l" $i " " } print str; }'`"
VAR=`echo "HAVE_LIB_$1" | sed -e 's,+,_AND_,g' -e 's,\.,_,g' | awk '{ print toupper($0); }'`
add_envword "${VAR}"
get_current_compiler
if [ -z "${_CHECK_LIB}" ]; then
SCRIPT="
${SCRIPT}
check_library() {
VAR=${S}1
S=\"$\"
_REQUIRED=${S}3
_CHKLIB_NAME=${S}2
_CHKLIB_LIBS=${S}(echo \"-l${S}{_CHKLIB_NAME}\" | sed 's,+, -l,g')
printf \"checking for lib${S}{_CHKLIB_NAME} ... \"
echo \"int main(int ac, char **av){return 0;}\" > test.c
eval ${S}{S}${S}{COMPILER} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{CXXFLAGS} ${S}{LDFLAGS} ${S}{_CHKLIB_LIBS} test.c >/dev/null 2>&1
if [ ${S}? = 0 ]; then
eval ${S}{VAR}=1
echo yes
else
eval ${S}{VAR}=0
echo no "
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
echo "this library is required."
do_remove
exit 1
EOF
`
REPORT_REQUIRED="${REPORT_REQUIRED} lib${_CHKLIB_NAME}"
else
REPORT_OPTIONAL="${REPORT_OPTIONAL} lib${_CHKLIB_NAME}"
fi
SCRIPT="${SCRIPT} ; fi }"
_CHECK_LIB=included
fi
SCRIPT="${SCRIPT}
check_library ${VAR} ${_CHKLIB_NAME} ${_REQUIRED} "
}
## }}}
## {{{ | Check Functions
check_func() {
HAVE_LIBS=1
VAR=`echo "HAVE_$1" | tr '[a-z]' '[A-Z]'`
add_envword "${VAR}"
get_current_compiler
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking function ${_CHKFUNC_NAME}() in ${_CHKFUNC_LIB}... "
echo "int main(int ac, char **av){ ${_CHKFUNC_NAME}(0); return 0; }" > test.c
${S}{${COMPILER}} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{LDFLAGS} -l${_CHKFUNC_LIB} test.c >/dev/null 2>&1
if [ ${S}? = 0 ]; then
echo yes ; ${VAR}=1
else
${VAR}=0 ; echo no
EOF
`
if [ 1 = "${_REQUIRED}" ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
echo "this function is required." >&2
do_remove
exit 1
EOF
`
fi
SCRIPT="${SCRIPT} ; fi"
}
## }}}
## {{{ | Check sizeof
check_sizeof() {
THAT=$1
VAR=`echo "SIZEOF_$1" | sed -e 's,\*,_P,g' | awk '{ gsub(" ","_"); gsub("\\\.","_"); gsub("/","_"); print toupper($0); }'`
add_envword "${VAR}"
## the $(./a.out) XXX this could be not portable
SCRIPT="
${SCRIPT}
printf 'checking size of $1... '
echo '#include <stdio.h>' > test.c
echo 'int main(int ac, char **av){printf(\"##d##\",sizeof($1));return 0;}' >>test.c
eval \\\\${S}${S}{COMPILER} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{CXXFLAGS} -o a.out test.c >/dev/null 2>&1
if [ 0 = ${S}? ]; then
${VAR}=${S}(./a.out)
echo ${S}{${VAR}}
HAVE_${VAR}=1
else
${VAR}=0 ; echo error
"
if [ 1 = "${_REQUIRE}" ]; then
SCRIPT="
${SCRIPT}
do_remove
exit 1
"
else
SCRIPT="
${SCRIPT}
HAVE_${VAR}=0
"
fi
SCRIPT="
${SCRIPT}
fi
"
}
## }}}
## {{{ | Pthreads
use_pthread() {
HAVE_LIBS=1
add_envword "PTHREAD_LIBS"
add_envword "HAVE_PTHREAD"
SCRIPT="${SCRIPT}
printf \"checking for POSIX threads... \"
if [ \"${S}{HOST_OS}\" = \"freebsd\" ]; then
PTHREAD_LIBS=-pthread ; else
PTHREAD_LIBS=-lpthread ; fi
echo '#include <pthread.h>' > test.c
echo 'main(){pthread_testcancel();}' >> test.c
eval \\\\${S}${S}{COMPILER} ${S}{PTHREAD_LIBS} test.c 2>&1 >/dev/null
if [ ! \$? = 0 ]; then
HAVE_PTHREAD=0 ; echo no ; else HAVE_PTHREAD=1; echo yes ; fi
"
if [ "${_REQUIRED}" = 1 ]; then
REPORT_REQUIRED="${REPORT_REQUIRED} libpthread"
SCRIPT="${SCRIPT}
if [ \"${S}{HAVE_PTHREAD}\" = 0 ]; then
echo 'ERROR: You need the pthreads libraries.'
do_remove
exit 1
fi"
else
REPORT_OPTIONAL="${REPORT_OPTIONAL} libpthread"
fi
}
## }}}
## {{{ TCL
lang_tcl() {
LANG=1
SCRIPT=`cat <<_EOF_
printf "checking for tcl... "
HAVE_LANG_TCL=0
for A in ${S}{TCL_LIBDIR} ${S}{SEARCHPATH}; do
if [ -f \"${S}{A}/lib/tclConfig.sh\" ]; then
. ${S}{A}/lib/tclConfig.sh
HAVE_TCL=1
TCL_CFLAGS="${S}{TCL_INCLUDE_SPEC}"
TCL_LDFLAGS="${S}{TCL_LIB_SPEC}"
echo "${S}{TCL_VERSION}"
break
fi
done
if [ "${S}{HAVE_LANG_TCL}" = 0 ]; then echo no
_EOF_
`
[ "${LANG_TCL_REQUIRED}" = 1 ] && \
SCRIPT="${SCRIPT} echo \"ERROR: You need TCL.\" ; exit 1"
SCRIPT="${SCRIPT} ; fi"
}
env_tcl() {
LANG=1
LANG_TCL=1
add_envword "TCL_VERSION"
add_envword "HAVE_LANG_TCL"
add_envword "TCL_LIBS"
add_envword "TCL_CFLAGS"
add_envword "TCL_LDFLAGS"
REPORT_LANGS="${REPORT_LANGS} tcl"
add_flag with TCL_BASEDIR tcl-basedir "=" "Sets the TCL basedir to find [/usr]/lib/tclConfig.sh"
lang_tcl
}
## }}}
## {{{ Libtool
use_libtool() {
_USE_LIBTOOL=1
check_prg "LIBTOOL" "libtool" ${_REQUIRED}
case "${CURRENT_LANG}" in
"c") add_envword "LIBTOOL_CC" ; ;;
"c++") add_envword "LIBTOOL_CXX" ; ;;
*) echo "Libtool depends on c or c++" >&2 ; exit 1 ; ;;
esac
add_envword "LIBTOOL_SHARED"
add_envword "LIBTOOL_STATIC"
add_envword "LIBTOOL_INSTALL"
}
## }}}
## {{{ TK
use_tk() {
echo "printf \"checking for tk... \""
echo "HAVE_TK=0"
echo "for A in ${S}{TK_BASEDIR} ${S}{SEARCHPATH}; do"
echo "if [ -f \"${S}{A}/lib/tkConfig.sh\" ]; then"
echo ". ${S}{A}/lib/tkConfig.sh"
echo " HAVE_TK=1"
echo " TK_LDFLAGS=\"${S}{TK_LIB_SPEC}\""
echo " echo \"${S}{TK_VERSION}\""
echo " break; fi"
echo "done"
echo "if [ \"${S}{HAVE_TK}\" = 0 ]; then echo no; fi"
}
## }}}
## {{{ X11
use_x11() {
add_envword "HAVE_X11"
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for X11... "
CFLAGS="${S}CFLAGS ${S}CPPFLAGS -I${S}{X11BASE}/include"
LDFLAGS="${S}LDFLAGS -L${S}{X11BASE}/lib"
[ "${X_INCLUDES}" ] && CFLAGS="${CFLAGS} -I${X_INCLUDES}"
[ "${X_LIBRARIES}" ] && CFLAGS="${CFLAGS} -L${X_LIBRARIES}"
if [ "${S}{HAVE_X11}" = 1 ]; then
echo "#include <X11/Xlib.h>" > test.c
echo "main(){XrmInitialize();}" >> test.c
${S}{CC} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{LDFLAGS} test.c -lX11 2> /dev/null
if [ 0 = ${S}? ]; then
echo ok ; HAVE_X11=1
else
HAVE_X11=0 ; echo "not found" >&2
fi
else
HAVE_X11=0 ; echo "disabled" >&2
fi
_EOF_
`
}
## }}}
## {{{ GNU make
env_gmake() {
add_envword "MAKE"
add_envword "GMAKE"
REPORT_TOOLS="${REPORT_TOOLS} gmake"
}
use_gmake() {
add_envword "MAKE"
SCRIPT=`cat <<_EOF_
${SCRIPT}
printf "checking for GNU make... "
GMAKE=0
for MAKE in make gmake ; do
if [ -n "\\\`${S}{MAKE} -version 2>&1 | grep GNU\\\`" ]; then
echo yes ; GMAKE=1 ; break
fi
done
if [ "${S}GMAKE" = 0 ]; then
echo no
echo "ERROR: No GNU make found." >&2
exit 1
fi
_EOF_
`
}
## }}}
## {{{ Generate Output file
report_h() {
echo "for A in ${H_FILES}; do"
echo " echo \"creating h ${S}{VPATH}/${S}{A}\""
echo " echo '' > ${S}{VPATH}/${S}{A}"
echo "if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi"
echo " for B in ${S}{ENVWORDS} ; do"
echo " eval \"VAR=\\${S}${S}{B}\""
if [ "${_REPORT_DEFINED}" = 1 ]; then
# echo "if [ ! \"\`echo ${S}{B} | grep -e HAVE -e VER -e PKG -e PACK\`\" = \"\" ]; then"
echo " if [ \"${S}{VAR}\" = 0 ]; then"
echo " echo \"/* #undef ${S}{B} */\" >> ${S}{VPATH}/${S}{A}"
echo " else"
echo " if [ -z \"${S}{VAR}\" ]; then"
echo " echo \"/* #undef ${S}{B} */\" >> ${S}{VPATH}/${S}{A}"
echo " else"
echo " echo \"#define ${S}{B} ${S}{VAR}\" >> ${S}{VPATH}/${S}{A}"
echo " fi"
echo " fi"
# echo "fi"
else
echo " echo \"#define ${S}{B} ${S}{VAR}\" >> ${S}{VPATH}/${S}{A}"
fi
echo " done"
echo "done"
echo ""
}
report_sh() {
echo "for A in ${SH_FILES}; do # SH_FILES"
echo " echo \"creating sh ${S}{VPATH}/${S}{A}\""
echo " echo '# automatically generated by acr' > ${S}{VPATH}/${S}{A}"
echo "if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi"
echo " for B in ${S}{ENVWORDS} ; do"
echo " eval \"VAR=\\${S}${S}{B}\""
echo " echo ${S}{B}=${S}{VAR} >> ${S}{VPATH}/${S}{A}"
echo " done"
echo "done"
echo ""
}
subst_tags() {
# if (crosspathbuild)
# \
# - create target directories (mkdir -p ${XX})
# - target directori is localdir not VPATH
# mkdirs
echo "if [ \"${S}{WODIS}\" = \"crosspath\" ]; then"
if [ "${S_MKDIR}" ]; then
echo " mkdir -p ${S_MKDIR}"
fi
echo " for A in ${S_FILES} ; do"
echo " echo \"filtering ${S}{A}\""
echo " cat ${S}{VPATH}/${S}{A} | eval sed ${S}{SEDFLAGS} > ${S}{A}"
echo "if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi"
echo " done"
echo "else #--"
# move files
echo "for A in ${S_FILES} ; do # SUBST_FILES"
echo " echo \"filtering ${S}{A}\""
echo " if [ -f \"${S}{VPATH}/${S}{A}.orig\" ]; then"
if [ "${USE_BACKUP}" = 1 ]; then
echo " if [ -f \"${S}{VPATH}/${S}{A}.backup\" ]; then"
echo " if [ -f \"${S}{VPATH}/${S}{A}\" ]; then"
echo " if [ \"\`diff ${S}{VPATH}/${S}{A}.backup ${S}{VPATH}/${S}{A}\`\" ]; then"
echo " echo \"It seems that ${S}{VPATH}/${S}{A} has changed. Check .backup first.\""
echo " exit 1 ; fi ; fi ; fi"
echo " rm ${S}{VPATH}/${S}{A}.backup"
fi
echo " mv -f ${S}{VPATH}/${S}{A}.orig ${S}{VPATH}/${S}{A}"
echo " fi"
echo " if [ -f \"${S}{VPATH}/${S}{A}\" ]; then"
echo " mv -f ${S}{VPATH}/${S}{A} ${S}{VPATH}/${S}{A}.orig"
echo " else"
echo " if [ ! -f \"${S}{VPATH}${S}{A}.orig\" ]; then"
echo " echo \"ERROR: Cannot find ${S}{VPATH}/${S}{A}.orig\" >&2"
echo " exit 1"
echo " fi"
echo " fi"
echo " cat ${S}{VPATH}/${S}{A}.orig | eval sed ${S}{SEDFLAGS} > ${S}{VPATH}/${S}{A}"
echo "if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi"
if [ "${USE_BACKUP}" = 1 ]; then
echo " cp ${S}{VPATH}/${S}{A} ${S}{VPATH}/${S}{A}.backup"
echo "if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi"
fi
echo "done"
echo "fi"
echo ""
}
# TODO: too many echo's!
subst_dirs() {
if [ "${SD_FILES}" = "%" ]; then
echo "for A in \`find * | grep Makefile.acr | cut -d . -f 1\` ; do # SUBDIRS"
else
echo "for A in ${SD_FILES} ; do # SUBDIRS"
fi
cat <<EOF
if [ -f "${S}{VPATH}/${S}{A}.acr" ]; then
SD_TARGET=${S}{A}
else
if [ -d "${S}{VPATH}/${S}{A}" ]; then
SD_TARGET=${S}{A}/Makefile
mkdir -p ${S}{A}
else
echo "ERROR: Cannot find ${S}{VPATH}/${S}{A}.acr" >&2
exit 1
fi
fi
echo "creating ${S}{SD_TARGET}"
mkdir -p \$(echo ${S}{A} | sed -e "s,/\`basename ${S}{A}\`\$,,g")
cat ${S}{VPATH}/${S}{SD_TARGET}.acr | \\
eval sed -e "s,@VPATH@,${S}{VPATH}/${S}{A},g" ${S}{SEDFLAGS} > ${S}{SD_TARGET}.tmp
EOF
# Support for ##MARKS##
echo "
for A in ${S}{ENVWORDS}; do
VALUE=\`eval echo \"$\"${S}{A}\`
if [ \"${S}VALUE\" = 0 ]; then ## FALSE
MARK=\"##${S}{A}##\"
if [ -n \"\`grep \\\"${S}{MARK}\\\" ${S}{SD_TARGET}.tmp\`\" ]; then
mv ${S}{SD_TARGET}.tmp ${S}{SD_TARGET}.tmp2
cat ${S}{SD_TARGET}.tmp2 | MARK=${S}MARK awk 'BEGIN{a=0;}{if(${S}1==ENVIRON[\"MARK\"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${S}{SD_TARGET}.tmp
fi
fi
done
mv ${S}{SD_TARGET}.tmp ${S}{SD_TARGET} && rm -f ${S}{SD_TARGET}.tmp2
if [ ! \$? = 0 ]; then echo Cannot write target file ; control_c ; fi
done
"
}
## }}}
## {{{ Body generation
create_body() {
[ "${STRIP}" = 1 ] && return
cat <<EOF
split_host() {
S="$"
while : ; do
ENVWORDS="${S}{ENVWORDS} ${S}1_CPU ${S}1_OS"
STR=\`eval "echo ${S}{S}${S}1"\`
SPLIT_CPU="\`echo "${S}STR" | cut -d - -f 1\`"
SPLIT_OS="\`echo "${S}STR" | awk -F - '{
if (${S}2=="unknown"){
if (NF<3) { print ${S}2; } else { print ${S}3; }
} else {
if (${S}2=="linux") { print ${S}2; } else
if (NF<3) { print ${S}2; } else { print ${S}3; }
}
}'\`"
eval "${S}1_CPU=\"${S}SPLIT_CPU\""
eval "${S}1_OS=\"${S}SPLIT_OS\""
shift
[ -z "${S}1" ] && break
done
}
VPATH=\`dirname ${S}{0}\`
if [ "${S}{VPATH}" = "." ]; then
WODIS=current
else
if [ "${S}{VPATH}" = "${S}{PWD}" ]; then
VPATH=.
WODIS=current
else
WODIS=crosspath
CURDIR=${S}PWD
cd ${S}VPATH
VPATH="${S}{PWD}/"
cd ${S}CURDIR
fi
fi
guess_os() {
if [ -e "${S}{VPATH}/config.guess" ]; then
sh ${S}{VPATH}/config.guess
return
fi
CPU="\`uname -m|sed -e 's, ,,g'|cut -d - -f 1\`"
OS="\`uname -s|tr A-Z a-z\`"
GNU="\`uname --help 2>&1 | grep gnu\`"
[ "${S}{GNU}" ] && OS="${S}{OS}-gnu"
[ "${S}{CPU}" = ppc ] && CPU="powerpc"
echo "${S}{CPU}-unknown-${S}{OS}"
}
SEARCHPATH="/usr /usr/local /usr/pkg /sw"
: ${S}{PREFIX:=/usr/local}
CROSSBUILD=0
BUILD=\`guess_os\`
HOST="${S}{BUILD}"
TARGET="${S}{HOST}"
SYSCONFDIR=""
create_environ() {
: ${S}{EPREFIX:="${S}{PREFIX}"}
: ${S}{SPREFIX:="${S}{PREFIX}"}
: ${S}{BINDIR:="${S}{SPREFIX}/bin"}
: ${S}{SBINDIR:="${S}{PREFIX}/sbin"}
: ${S}{SYSCONFDIR:="${S}{SPREFIX}/etc"}
: ${S}{LIBDIR:="${S}{SPREFIX}/lib"}
: ${S}{LIBEXECDIR:="${S}{SPREFIX}/libexec"}
: ${S}{INCLUDEDIR:="${S}{SPREFIX}/include"}
: ${S}{DATADIR:="${S}{SPREFIX}/share"}
: ${S}{INFODIR:="${S}{DATADIR}/info"}
: ${S}{MANDIR:="${S}{DATADIR}/man"}
: ${S}{DOCDIR:="${S}{DATADIR}/doc/${PKGNAME}"}
: ${S}{LOCALSTATEDIR:="${S}{SPREFIX}/var"}
for A in \`echo ${S}{PATH} | sed -e 's,:, ,g'\` ; do
[ -e "${S}A"/ginstall ] && : ${S}{INSTALL:="${S}A"/ginstall} && break
[ -e "${S}A"/install ] && : ${S}{INSTALL:="${S}A"/install} && break
done
: ${S}{INSTALL_DIR:=${S}{INSTALL} -d}
: ${S}{INSTALL_DATA:=${S}{INSTALL} -m 644}
: ${S}{INSTALL_SCRIPT:=${S}{INSTALL} -m 755}
: ${S}{INSTALL_PROGRAM:=${S}{INSTALL} -m 755}
: ${S}{INSTALL_PROGRAM_STRIP:=${S}{INSTALL} -m 755 -s}
: ${S}{INSTALL_MAN:=${S}{INSTALL} -m 444}
: ${S}{INSTALL_LIB:=${S}{INSTALL} -m 755 -c}
${INIVARS}
}
show_usage() {
`cat <<EOF1
cat <<EOF2
'configure' configures ${PKGNAME}-${VERSION} to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
-r, --report show what libs/programs require to work
-V, --version display version information and exit
Installation directories:
--exec-prefix=EPREFIX install arch-dependent files in EPREFIX [PREFIX]
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--sandbox=SPREFIX sandbox prefix directory: SPREFIX [PREFIX]
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--docdir=DIR documentation directory [DATADIR/doc/${PKGNAME}]
--includedir=DIR C header files [PREFIX/include]
--infodir=DIR info documentation [DATADIR/info]
--libexecdir=DIR program executables [EPREFIX/libexec]
--libdir=DIR object code libraries [EPREFIX/lib]
--libpath=DIR set rpath/libname-path to linker
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--mandir=DIR man documentation [DATADIR/man]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
EOF2
EOF1
`
EOF
[ "${FLAGHELP}" ] && \
echo "printf \"\nOptional Features:${FLAGHELP}\n\""
[ "${ENVHELP}" ] && \
echo "printf \"\nSome influential environment variables:${ENVHELP}\n\""
[ "${AUTHOR_MAIL}" ] && \
echo "printf \"\nAuthor: ${AUTHOR_NAME} <${AUTHOR_MAIL}>\""
[ "${CONTACT_MAIL}" ] && \
echo "printf \"\nReport bugs to: ${CONTACT_NAME} <${CONTACT_MAIL}>\""
cat <<EOF
echo ""
exit 0
}
take_environ() {
: ${S}{SH:=/bin/sh}
EOF
if [ "${LANG_C}" = 1 ]; then
echo ": ${S}{CPP:=cpp}"
echo ": ${S}{CC:=gcc}"
fi
if [ "${LANG_CXX}" = 1 ]; then
echo ": ${S}{CPP:=cpp}"
echo ": ${S}{CXX:=g++}"
fi
if [ "${LANG_JAVA}" = 1 ]; then
echo ": ${S}{JAVAC:=javac}"
fi
if [ "${LANG_VALA}" = 1 ]; then
echo ": ${S}{VALAC:=valac}"
fi
if [ "${LANG_PERL}" = 1 ]; then
echo ": ${S}{PERL:=perl}"
fi
if [ "${LANG_LUA}" = 1 ]; then
echo ": ${S}{LUA:=lua}"
fi
# XXX twice ?
cat <<EOF
: ${S}{PREFIX:=/usr/local/}
}
show_version() {
echo "${PKGNAME}-${VERSION} configuration script done with acr v${ACR_VERSION}.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <nopcode.org>."
exit 0
}
parse_options() {
flag=\`echo \$1| cut -d = -f 1\`
value=\`echo \$1| awk 'BEGIN{FS="=";}{print \$2}'\`
flag2=\`echo \$flag|cut -f2- -d -| sed -e 's,-,_,g' -e 's,^_,,g'|tr '[a-z]' '[A-Z]'\`
if [ "\${TARGET_OS}" = "darwin" ]; then
LIBPATH=-Wl,-install_name,
else
LIBPATH=-Wl,-R
fi
case \$flag in
-h|--help|--hel|--h|--he|-help)
show_usage ; ;;
-V|-version|--version)
show_version ; ;;
-r|--r|--report)
EOF
if [ ! "${PKGNAME}" = "this package" ]; then
echo "echo \"PKGNAME: ${PKGNAME}\""; fi
test "$VERSION" && echo "echo \"VERSION: ${VERSION}\""
if [ "${REPORT_LANGS}" ]; then
echo "echo \"LANGS: ${REPORT_LANGS}\"" ; fi
if [ "${REPORT_REQUIRED}" ]; then
echo "echo \"REQUIRED: ${REPORT_REQUIRED}\"" ; fi
if [ "${REPORT_OPTIONAL}" ]; then
echo "echo \"OPTIONAL: ${REPORT_OPTIONAL}\"" ; fi
if [ "${REPORT_PKGCFG}" ]; then
echo "echo \"PKG-CONFIG: ${REPORT_PKGCFG}\"" ; fi
if [ "${REPORT_FLAGS}" ]; then
echo "echo \"FLAGS: ${REPORT_FLAGS}\"" ; fi
if [ "${REPORT_TOOLS}" ]; then
echo "echo \"TOOLS: ${REPORT_TOOLS}\"" ; fi
# TODO
# We could probably reduce this case/switch because :
# $ ./configure --prefix=/usr # flag=value
# $ ./configure PREFIX=/usr # flag2=value
cat <<EOF
exit 0
;;
--cache-file)
# ignored: acr have no cache
;;
--build)
BUILD="\$value"; split_host BUILD ; ;;
--host)
CROSSBUILD=1 # XXX
HOST="\$value"; split_host HOST ; ;;
--target)
TARGET="\$value"; split_host TARGET ; ;;
--prefix)
PREFIX="\$value"; ;;
--exec-prefix)
EPREFIX="\$value"; ;;
--sandbox|--sprefix)
SPREFIX="\$value"; ;;
--bindir)
BINDIR="\$value"; ;;
--sbindir)
SBINDIR="\$value"; ;;
--libexecdir)
LIBEXECDIR="\$value"; ;;
--docdir)
DOCDIR="\$value"; ;;
--datadir)
DATADIR="\$value"; ;;
--sysconfdir)
SYSCONFDIR="\$value"; ;;
--sharedstatedir)
SHAREDSTATEDIR="\$value"; ;;
--localstatedir)
LOCALSTATEDIR="\$value"; ;;
--libdir)
LIBDIR="\$value"; ;;
--libpath)
LDFLAGS="\${LDFLAGS} \${LIBPATH}\$value"; ;;
--includedir)
INCLUDEDIR="\$value"; CFLAGS="\${CFLAGS} -I\$value"; ;;
--infodir)
INFODIR="\$value"; ;;
--mandir)
MANDIR="\$value"; ;;
${FLAGSCRIPT}
*) if [ "\$value" ]; then eval "\`echo \$flag2=\$value\`" ;
else echo ; echo "WARNING: Unknown flag '\$flag'." >&2 ; echo ; fi ;;
esac
}
# MAIN #
take_environ
split_host BUILD HOST TARGET
[ -z "${S}ACRHOOK" ] && ACRHOOK=./configure.hook
[ -e "${S}ACRHOOK" ] && . ${S}{ACRHOOK}
while : ; do
[ -z "\$1" ] && break
parse_options "\$1"
shift
done
ENVWORDS="${ENVWORDS}"
create_environ
${EQUALSCR}
EOF
}
check_path() {
[ "${SPLIT}" = 1 ] && return
cat <<EOF
[ -n "${S}{prefix}" ] && PREFIX="${S}{prefix}"
echo "checking for working directories... ${S}{WODIS}"
echo "using prefix '${S}{PREFIX}'"
EOF
}
check_os() {
[ "${STRIP}" = 1 ] && return
cat <<EOF
echo "checking build system type... ${S}{BUILD}"
echo "checking host system type... ${S}{HOST}"
echo "checking target system type... ${S}{TARGET}"
[ "${S}{CROSSBUILD}" = 1 ] && echo "using crosscompilation mode."
#split_host BUILD HOST TARGET
EOF
}
## - script output generation - ##
create_script() {
create_body
# checks
check_os
check_path
echo "ACR_RMFILES=\"${ACR_RMFILES}\""
[ "${USE_X11}" = 1 ] && use_x11
[ "${USE_TK}" = 1 ] && use_tk
[ "${USE_GMAKE}" = 1 ] && use_gmake
echo "${SCRIPT}" | sed -e 's,##d##,%d,g'
if [ "${_USE_LIBTOOL}" = 1 ]; then
echo ": ${S}{LIBTOOL_CC:=${S}LIBTOOL --mode=compile ${S}CC -c}"
echo ": ${S}{LIBTOOL_CXX:=${S}LIBTOOL --mode=compile ${S}CXX -c}"
echo ": ${S}{LIBTOOL_SHARED:=${S}LIBTOOL --mode=link ${S}CC -rpath ${S}LIBDIR -release \\\$\{LIB_VERSION\} -o}"
echo ": ${S}{LIBTOOL_STATIC:=${S}LIBTOOL --mode=link ${S}CC -static -rpath ${S}LIBDIR -release \\\$\{LIB_VERSION\} -o}"
echo ": ${S}{LIBTOOL_INSTALL:=${S}LIBTOOL --mode=install ${S}INSTALL_LIB}"
fi
## XXX ([ "${S}{A}" = srcdir ] && continue) is ugly wtf is srcdir?
cat <<EOF
SEDFLAGS="${SEDFLAGS} -e '"
COUNT=0
for A in ${S}{ENVWORDS} ; do
[ "${S}{A}" = VPATH ] && continue
[ "${S}{A}" = srcdir ] && continue
eval "VAR=\\${S}${S}{A}"
VAR="\`echo ${S}{VAR} | sed -e 's/\,/\\\\\,/g'\`"
[ ${S}COUNT = 10 ] && COUNT=0 && SEDFLAGS="${S}{SEDFLAGS}' -e '"
COUNT=${S}((${S}COUNT+1))
SEDFLAGS="${S}{SEDFLAGS}s,@${S}{A}@,${S}{VAR},g;"
done
SEDFLAGS="${S}{SEDFLAGS}'"
EOF
[ "${H_FILES}" ] && report_h ${H_FILES}
[ "${SH_FILES}" ] && report_sh ${SH_FILES}
[ "${S_FILES}" ] && subst_tags ${S_FILES}
[ "${SD_FILES}" ] && subst_dirs ${SD_FILES}
# acr_eof
[ "${LANG}" = 1 ] && echo "do_remove"
# subdirs
[ "${SUBCONF_DIRS}" ] && \
cat <<EOF
for A in ${SUBCONF_DIRS} ; do
if [ -x ${S}{A}/configure ]; then
echo "=> running ./configure in ${S}{A}"
cd ${S}{A}
./configure ${S}@
cd - > /dev/null
else
echo "Cannot find ./configure on directory ${S}{A}."
exit 1
fi
done
EOF
}
## }}}
## {{{ Show report
show_report() {
[ "${REPORT}" ] &&\
cat <<EOF
echo
echo "Final report:"
for A in ${REPORT} ; do # REPORT
eval VAL="\\${S}${S}{A}"
[ -z "${S}{VAL}" ] && VAL="(null)"
echo " - ${S}{A} = ${S}{VAL}"
done
EOF
}
# }}}
is_buggy() {
WORD=$1
[ "${MODE}" != "check" ] && [ "${WORD}" != ";" ] && [ -n "`echo $1 | grep ';'`" ] && \
echo "`word` | Warning: keyword '$1' contains a ';'. Is this fine?" >&2
}
LAST_DOT=0
DOTS=0
show_progress_bar() {
DOTS=`echo $WORDS_N $WORDS_T | awk '{printf ("%.d",$1*70/$2);}'`
if [ "${LAST_DOT}" = "${DOTS}" ]; then return ; fi
PCENT=`echo $WORDS_N $WORDS_T | awk '{printf ("%.d",$1*100/$2);}'`
LAST_DOT=$DOTS
dots=`printf "%.2d" $PCENT`
N=0
BAR=`echo $DOTS | awk '{ str=""; for(i=0;i<$1;i++) { str=str"#"; } print str; }'`
printf " [------------------------------------------------------------------------]\r" >&2
printf " $dots%% [${BAR}\r" >&2
}
is_envword() {
found=""
for A in $ENVWORDS ; do
[ $A = $1 ] && found=1 && break;
done
[ -z "$found" ] && \
echo "`word` | Warning: Variable '$1' not defined." >&2
}
## string mode ##
enter_string_mode() {
[ -n "${STRING}" ] && return 0
MODE_OLD="${MODE}"
MODE="string"
STRING="${1}"
return 1
}
alias wait_string_mode='[ "${MODE}" = "string" ] && continue'
alias leave_string_mode='STRING=""'
enter_mode() {
MODE=$1
STR=$2
_REQUIRED=0
case "${STR}" in
*!) _REQUIRED=1 ; ;;
esac
}
cat_file() {
cat "$1" \
| sed -e 's,/\*,((,g' \
| sed -e 's,\*/,)),g' \
| awk '{ print $0" _n_";}'
}
# MAIN LOOP #
print_header # show /bin/sh stuff
COMMENT=0
WORDS=`cat_file "${ACRFILE}"`
WORDS_N=0 # number of current word (counter)
WORDS_K=0 # keyword word
WORDS_T=`echo ${WORDS} | wc -w ` # total number of words
[ "${DEBUG}" = 1 ] && echo "acr: parsing '${ACRFILE}'" >&2
for STR2 in ${WORDS} NOP ; do
INSIDE_INCLUDE=0
if [ "$MODE" = "include" ]; then
[ "${DEBUG}" = 1 ] && echo "`word` < include $STR2" >&2
if [ -e "@DATADIR@/acr/modules/${STR2}.acr" ]; then
FILE="@DATADIR@/acr/modules/${STR2}.acr";
else FILE="$STR2.acr"; fi
if [ -e "$FILE" ]; then
MODE=""
INSIDE_INCLUDE=1
#WORDS_N=$(($WORDS_N+1))
WORDS2=`cat_file ${FILE}`
else
echo "`word` | ERROR: Cannot include file '$FILE'. File not found." >&2
exit 1
fi
else
WORDS2="${STR2}"
fi
for STR in $WORDS2 ; do
# inner loop for include workaround.
# Progress bar
if [ "${INSIDE_INCLUDE}" = 0 ]; then
[ "${PBAR}" = 1 ] && show_progress_bar
fi
WORDS_N=$(($WORDS_N+1))
IS_KEYWORD=1
is_buggy ${STR}
# XXX <- is deprecated! remove in 0.6
if [ "${STR}" != "<-" ]; then
if [ "`echo ${STR}| cut -c -2`" = "<-" ]; then
VAR="`echo ${STR} | cut -c 3-`"
TMP="${S}${VAR}"
if [ "${DEBUG}" = 1 ]; then
echo "`word` > get value" >&2
fi
STR=${TMP}
fi
fi
# COMMENTS #
[ -z "${STR}" ] && continue ## ???
case ${COMMENT} in
"1")
case "${STR}" in
"##"|"\\\\"|"))")
COMMENT=0
;;
esac
continue
;;
"//")
if [ "${STR}" = "_n_" ]; then
COMMENT=0
else
continue
fi
;;
*)
case "${STR}" in
"##"|"((")
COMMENT=1
continue
;;
"//")
COMMENT="//"
continue
;;
esac
;;
esac
[ "${STR}" = "_n_" ] && continue
# one word comment
[ "`echo $STR | cut -c 1`" = "#" ] && \
echo "`word` | One word comment is deprecated." >&2 && \
continue
# CONDITION FLAGS #
if [ -n "${MODE}" ]; then
if [ "${MODE}" = "string" ]; then
[ "${STR}" = "NOP" ] && STR=";"
if [ "${STR}" = ";" ] ; then
[ "${DEBUG}" = 1 ] && \
echo " | $spaces\"${STRING}\"" >&2
MODE="${MODE_OLD}"
else
STRING="`concat "${STRING}" ${STR}`"
continue
fi
fi
case "${MODE}" in
"chkfunc")
IS_KEYWORD=0
if [ -z "${_CHKFUNC_LIB}" ]; then
_CHKFUNC_LIB="${STR}"
else
MODE=""
_CHKFUNC_NAME=${STR}
check_func $_CHKLIB_LIB ${_CHKFUNC_NAME}
_CHKFUNC=0
_CHKFUNC_LIB=""
_CHKFUNC_NAME=""
fi
;;
"chkcp")
MODE=""
IS_KEYWORD=0
REPORT_REQUIRED="${REPORT_REQUIRED} ${STR}"
VAR=`echo HAVE_CLASSPATH_${STR} | tr '[a-z]' '[A-Z]'| tr '.-' '__'`
SCRIPT="
${SCRIPT}
printf \"checking for classpath ${STR}... \"
echo \"import ${STR}.*;\" > test.java
${S}{JAVAC} test.java 2>&1 > /dev/null
if [ \"${S}?\" = 0 ]; then echo yes
${VAR}=1
else echo no
${VAR}=0
"
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="
${SCRIPT}
echo 'This classpath is required.'
exit 1
"
fi
SCRIPT="${SCRIPT}fi"
;;
"chklib")
IS_KEYWORD=0
check_lib ${STR}
MODE=""
_CHKLIB_NAME=""
;;
"chkpy")
IS_KEYWORD=0
check_py ${STR}
MODE=""
;;
"chkru")
IS_KEYWORD=0
check_ru ${STR}
MODE=""
;;
"chkpm")
IS_KEYWORD=0
check_pm ${STR}
MODE=""
;;
"check_exec")
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=${STR};
elif [ "${STR}" = ";" ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
printf "running ${_IF_VALUE}... "
${_IF_VALUE}
${_IF_VAR}=${S}?
if [ "${S}${_IF_VAR}" = 0 ]; then
${_IF_VAR}=1
echo yes
else
${_IF_VAR}=0
echo no
fi
EOF
`
reset_vars
else
if [ -z "${_IF_VALUE}" ]; then
_IF_VALUE="${STR}"
else
_IF_VALUE="${_IF_VALUE} ${STR}"
fi
fi
;;
"check")
IS_KEYWORD=0
if [ -z "${CHECK_VAR}" ]; then
TMP_VAR=""
SET_VAR=""
CHECK_VAR=${STR};
elif [ -z "${CHECK_EOF}" ]; then
CHECK_EOF=${STR}
elif [ "${STR}" = "${CHECK_EOF}" ]; then
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for ${CHECK_VAR}... "
${TMP_VAR}
if [ "${S}${CHECK_VAR}" = 0 ]; then
${CHECK_VAR}=1
echo yes
else
${CHECK_VAR}=0
echo no
fi
EOF
`
add_envword ${CHECK_VAR}
MODE=""
CHECK_VAR=""
CHECK_EOF=""
TMP_VAR=""
else
if [ "${STR}" = "\\" ]; then
TMP_VAR="${TMP_VAR} ; "
else
TMP_VAR="${TMP_VAR}${STR} "
fi
fi
;;
"chkgrp")
IS_KEYWORD=0;
if [ -z "${CHKUSR_NAME}" ]; then
CHKUSR_NAME=":${STR}"
CHKUSR_VAR="HAVE_GROUP_`echo $STR|tr '[a-z]' '[A-Z]'`"
CHKUSR_TARGET="group"
MODE="chkusr"
fi
;;
"chkusr")
IS_KEYWORD=0;
if [ -z "${CHKUSR_NAME}" ]; then
CHKUSR_NAME=${STR}
CHKUSR_VAR="HAVE_USER_`echo $CHKUSR_NAME|tr '[a-z]' '[A-Z]'`"
else
ACR_RMFILES="${ACR_RMFILES} .usrgrp.tmp"
# HAVE_USER_WWWDATA=0
add_envword ${CHKUSR_VAR}
SCRIPT=`cat <<EOF
${CHKUSR_VAR}=0
printf "checking for ${CHKUSR_TARGET} '${CHKUSR_NAME}'... "
touch .usrgrp.tmp && chown ${CHKUSR_NAME} .usrgrp.tmp 2>/dev/null
if [ \\$? = 0 ]; then echo "ok" ; $CHKUSR_VAR=1; else echo "no"
EOF
`
if [ 1 = "${_REQUIRED}" ]; then
SCRIPT="${SCRIPT} ; echo \"*** This ${CHKUSR_TARGET} is required!.\" ; do_remove ; exit 1"
fi
SCRIPT="${SCRIPT} ; fi"
MODE=""
CHKUSR_NAME=""
CHKUSR_TARGET=""
IS_KEYWORD=1
fi
;;
"chkver")
IS_KEYWORD=0
REPORT_REQUIRED="${REPORT_REQUIRED} lib${_CHKVER_LIB}>=${STR}"
if [ -z "${_CHKVER_LIB}" ]; then
_CHKVER_LIB="${STR}"
else
# HAVE_GLIB_2_0_VERSION_2_18
VAR=`echo HAVE_${_CHKVER_LIB}_VERSION_${STR} | tr '[a-z]' '[A-Z]'| tr '.-' '__'`
add_envword ${VAR}
SCRIPT=`cat <<EOF
${SCRIPT}
${VAR}=0
printf "checking version of library ${_CHKVER_LIB} >= ${STR}... "
${S}{PKGCONFIG} --at least-version=${STR} ${_CHKVER_LIB} >/dev/null 2>&1
if [ ${S}? = 0 ]; then ${VAR}=1 ; echo ok; else
echo "no"
EOF
`
if [ 1 = ${_REQUIRED} ]; then
SCRIPT=`cat <<EOF
echo "ERROR: You need ${_CHKVER_LIB} <= ${STR}." >&2
exit 1; fi
EOF
`
else
SCRIPT="${SCRIPT} ; fi"
fi
_CHKVER=0
_CHKVER_LIB=""
MODE=""
fi
;;
"useiconv")
MODE=""
add_envword "HAVE_LIB_ICONV"
add_envword "ICONV_LIBS"
REPORT_REQUIRED="${REPORT_REQUIRED} libiconv"
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for iconv... "
HAVE_LIB_ICONV=0
ICONV_LIBS=""
for HOST_OS in solaris linux netbsd ; do
HAVE_LIB_ICONV=1
echo libc
break;
done
if [ "${HAVE_LIB_ICONV}" = 0 ]; then
echo 'main(){iconv_open}' > test.c
${S}{CC} ${S}{CFLAGS} ${S}{CPPFLAGS} ${S}{LDFLAGS} test.c 2> /dev/null
if [ ${S}? = 0 ]; then
echo yes
HAVE_LIB_ICONV=1
else
echo no
fi
fi
EOF
`
;;
"exec")
IS_KEYWORD=0
if [ -z "${_EXEC_VAR}" ]; then
_EXEC_VAR="${STR}"
else
enter_string_mode ${STR}
wait_string_mode
add_envword "${_EXEC_VAR}"
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking exec ${STRING}... "
${_EXEC_VAR}="\\\`${STRING} 2>/dev/null\\\`"
if [ ${S}? = 0 ]; then
echo "ok"
else
${_EXEC_VAR}=""
echo "not found"
fi
EOF
`
MODE=""
_EXEC_VAR=""
leave_string_mode
fi
;;
"usedl")
MODE=""
REPORT_REQUIRED="${REPORT_REQUIRED} libdl"
add_envword "HAVE_LIB_DL"
add_envword "DL_LIBS"
# Linux Darwin BeOS Solaris need libdl
SCRIPT=`cat <<EOF
${SCRIPT}
printf "checking for dynamic library... "
HAVE_LIB_DL=0
for OS in gnulinux linux gnu/kfreebsd syllable sunos darwin beos solaris ; do
if [ "${S}{HOST_OS}" = "${S}{OS}" ]; then
HAVE_LIB_DL=1
break;
fi
done
if [ "${S}{HAVE_LIB_DL}" = 1 ]; then
DL_LIBS="-ldl"
echo "required"
else
DL_LIBS=""
echo "libc"
fi
EOF
`
MODE=""
;;
"export")
IS_KEYWORD=0;
if [ "${STR}" = ";" ]; then
MODE=""
else
add_envword $STR
fi
;;
"not")
IS_KEYWORD=0
MODE=""
SCRIPT="${SCRIPT} ; if [ \"${S}{STR}\" = 0 ]; then ${STR}=1 ; else ${STR}=0 ; fi"
_NOT=0
;;
"echo")
IS_KEYWORD=0;
enter_string_mode ${STR}
wait_string_mode
SCRIPT="
${SCRIPT}
echo \" ${STRING}\" >&2 "
MODE=""
leave_string_mode
;;
"die")
IS_KEYWORD=0;
if [ -z "${_DIE_VAR}" ]; then
_DIE_VAR=${STR}
else
enter_string_mode ${STR}
wait_string_mode
if [ "${_DIE_BOOL}" = 0 ]; then
SCRIPT="
${SCRIPT}
case \"${S}${_DIE_VAR}\" in 0|\"\") echo ; echo \"ERROR: ${STRING}\" >&2 ; echo ; exit 1 ;; esac"
else
SCRIPT="
${SCRIPT}
case \"${S}${_DIE_VAR}\" in 0|\"\") ;; *) echo ; echo \"ERROR: ${STRING}\" >&2 ; echo ; exit 1 ; ;; esac"
fi
MODE=""
_DIE_VAR="";
leave_string_mode
fi
;;
"if")
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=${STR}
is_envword "${STR}"
elif [ -z "${_IF_SETVAR}" ]; then
if [ "${STR}" = "{" ]; then
NKEYS=$(($NKEYS+1))
SCRIPT="${SCRIPT}
if [ \"${S}${_IF_VAR}\" = \"${_IF_BOOL}\" ]; then"
MODE=""
_IF_VAR=""
_IF_SETVAR=""
_IF_OP=""
else
_IF_SETVAR=${STR}
is_envword ${STR}
_IF_SETVAL=""
fi
elif [ -z "${_IF_OP}" ]; then
_IF_OP=${STR}
check_ifop ${_IF_OP}
else
enter_string_mode ${STR}
wait_string_mode
add_envword ${_IF_SETVAR}
SCRIPT="
${SCRIPT}
if [ \"${S}${_IF_VAR}\" = \"${_IF_BOOL}\" ]; then"
# check_ifop TODO -> use ifop instead of that.
case ${_IF_OP} in
"=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${_IF_SETVAL}\" ; fi"
;;
"+=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${S}{${_IF_SETVAR}} ${_IF_SETVAL}\" ; fi"
;;
"?=") SCRIPT="${SCRIPT} if [ -z \"${S}${_IF_SETVAR}\" ]; then ${_IF_SETVAR}=\"${_IF_SETVAL}\"; fi"
;;
"<-") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"\`eval 'echo \$${_IF_SETVAL}'\`\"; fi"
# XXX deprecated in 0.6
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
esac
reset_vars
leave_string_mode
fi
;;
"ifeqval")
echo "IFEQVAL: deprecated keyword. Please use IFEQ VAR \$VAR2 ;" >&2
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=$STR
is_envword "${STR}"
elif [ -z "${_IF_VAR2}" ]; then
_IF_VAR2=$STR
elif [ -z "${_IF_SETVAR}" ]; then
if [ "${STR}" = "{" ]; then
NKEYS=$(($NKEYS+1))
if [ "${_IF_BOOL}" = 1 ]; then
SCRIPT="${SCRIPT}
if ["
else
SCRIPT="${SCRIPT}
if [ !"
fi
SCRIPT="${SCRIPT} \\\"${S}${_IF_VAR}\\\" = \\\"${S}${_IF_VAR2}\\\" ]; then"
_IFEQVAL=0
reset_vars
else
_IF_SETVAR=${STR}
fi
elif [ -z "${_IF_OP}" ]; then
_IF_OP=${STR}
check_ifop ${_IF_OP}
elif [ "${STR}" = ";" ]; then
if [ "${_IF_BOOL}" = 1 ]; then
SCRIPT="${SCRIPT}
if ["
else
SCRIPT="${SCRIPT}
if [ !"
fi
SCRIPT="${SCRIPT} \"${S}${_IF_VAR}\" = \"${S}${_IF_VAR2}\" ]; then "
# TODO this must be in a external function
case ${_IF_OP} in
"=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${_IF_SETVAL}\" ; fi"
;;
"+=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${S}{${_IF_SETVAR}} ${_IF_SETVAL}\" ; fi"
;;
"?=") SCRIPT="${SCRIPT} if [ -z \"${S}${_IF_SETVAR}\" ]; then ${_IF_SETVAR}=\"${_IF_SETVAL}\"; fi"
;;
"<-") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"\`eval 'echo \$${_IF_SETVAL}'\`\"; fi"
# XXX this is deprecated
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
esac
MODE=""
_IFEQVAL=0
_IF_BOOL=0
reset_vars
else
_IF_SETVAL="`concat "${_IF_SETVAL}" "${STR}"`"
fi
;;
"ifeq")
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=${STR}
is_envword "${STR}"
elif [ "${_IF_VALUE_EOF}" = 0 ]; then
if [ "${STR}" = ";" ]; then
_IF_VALUE_EOF=1
elif [ "${STR}" = "{" ]; then
echo "`word` | Missing ; in ifeq expression" >&2
exit 1
else
_IF_VALUE="`concat "${_IF_VALUE}" "${STR}"`"
fi
elif [ -z "${_IF_SETVAR}" ]; then
if [ "${STR}" = "{" ]; then
if [ "${_IF_BOOL}" = 1 ]; then
SCRIPT="`printf \"${SCRIPT}\nif [\"`"
else
SCRIPT="`printf \"${SCRIPT}\nif [ !\"`"
fi
SCRIPT="`printf \"${SCRIPT} \\\"${S}${_IF_VAR}\\\" = \\\"${_IF_VALUE}\\\" ]; then\"`"
NKEYS=$(($NKEYS+1))
MODE=""
_IF_VALUE_EOF=0
reset_vars
else
_IF_SETVAR=${STR}
fi
elif [ -z "${_IF_OP}" ]; then
_IF_OP="${STR}"
check_ifop ${_IF_OP}
elif [ "${STR}" = ";" ]; then
# bool
if [ "${_IF_BOOL}" = 1 ]; then
SCRIPT="`echo -n \"${SCRIPT}
if [ \"`"
else
SCRIPT="`echo -n \"${SCRIPT}
if [ ! \"`"
fi
SCRIPT="`echo \"${SCRIPT} \\\"${S}${_IF_VAR}\\\" = \\\"${_IF_VALUE}\\\" ]; then\"`"
# set
# TODO create a new function that concats SCRIPT checking IF_OP
case ${_IF_OP} in
"=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${_IF_SETVAL}\" ; fi ;"
;;
"+=") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"${S}{${_IF_SETVAR}} ${_IF_SETVAL}\" ; fi ;"
;;
"?=") SCRIPT="${SCRIPT} if [ -z \"${S}${_IF_SETVAR}\" ]; then ${_IF_SETVAR}=\"${_IF_SETVAL}\"; fi ; fi ;"
;;
"<-") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"\`eval 'echo \$${_IF_SETVAL}'\`\"; fi"
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
esac
reset_vars
_IFEQ=0
_IF_VALUE_EOF=0
elif [ -z "${_IF_SETVAL}" ]; then
_IF_SETVAL="${STR}"
else
_IF_SETVAL="${_IF_SETVAL} ${STR}"
fi
;;
"ifand")
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=${STR}
is_envword "${STR}"
elif [ -z "${_IF_VAR2}" ]; then
_IF_VAR2="${STR}"
is_envword "${STR}"
elif [ -z "${_IF_SETVAR}" ]; then
if [ "${STR}" = "{" ]; then
NKEYS=$(($NKEYS+1))
[ "${_IF_BOOL}" = 1 ] && OGLE=11 || OGLE=00
SCRIPT="${SCRIPT}
if [ ${OGLE} = \"${S}${_IF_VAR}${S}${_IF_VAR2}\" ]; then
"
_IF_VALUE_EOF=0
reset_vars
else
_IF_SETVAR=${STR}
is_envword ${STR}
fi
elif [ -z "${_IF_OP}" ]; then
_IF_OP="${STR}"
check_ifop ${_IF_OP}
elif [ ! "${STR}" = ";" ]; then
if [ -z "${_IF_SETVAL}" ]; then
_IF_SETVAL="${STR}"
else
_IF_SETVAL="${_IF_SETVAL} ${STR}"
fi
else
[ "${_IF_BOOL}" = 1 ] && OGLE=1 || OGLE=0
case ${_IF_OP} in
"=") STR="${_IF_SETVAR}=\"${_IF_SETVAL}\""
;;
"+=") STR="${_IF_SETVAR}=\"${S}{${_IF_SETVAR}} ${_IF_SETVAL}\""
;;
"?=") STR="if [ -z \"${S}${_IF_SETVAR}\" ]; then ${_IF_SETVAR}=\"${_IF_SETVAL}\"; fi"
;;
"<-") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"\`eval 'echo \$${_IF_SETVAL}'\`\"; fi"
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
esac
SCRIPT="${SCRIPT}
if [ ${OGLE} = \"${S}${_IF_VAR}\" ]; then
if [ ${OGLE} = \"${S}${_IF_VALUE}\" ]; then
${STR} ; fi ; fi"
## TODO XXX this must be other command (IFEQVAR..or something similar
#if [ ${OGLE}"${S}${_IF_VAR}" = "${S}${_IF_VALUE}" ]; then ${_IF_SETVAR}="${STR}" ; fi ;
reset_vars
fi
;;
"ifor")
IS_KEYWORD=0
if [ -z "${_IF_VAR}" ]; then
_IF_VAR=${STR}
is_envword "${STR}"
elif [ -z "${_IF_VAR2}" ]; then
_IF_VAR2="${STR}"
is_envword "${STR}"
elif [ -z "${_IF_SETVAR}" ]; then
if [ "${STR}" = "{" ]; then
NKEYS=$(($NKEYS+1))
SCRIPT="${SCRIPT}
if [ ${_IF_BOOL} = \"${S}${_IF_VAR}\" ] || [ ${_IF_BOOL} = \"${S}${_IF_VAR2}\" ]; then
"
_IF_VALUE_EOF=0
reset_vars
else
_IF_SETVAR=${STR}
is_envword ${STR}
fi
elif [ -z "${_IF_OP}" ]; then
_IF_OP="${STR}"
check_ifop ${_IF_OP}
elif [ ! "${STR}" = ";" ]; then
if [ -z "${_IF_SETVAL}" ]; then
_IF_SETVAL="${STR}"
else
_IF_SETVAL="${_IF_SETVAL} ${STR}"
fi
else
[ "${_IF_BOOL}" = 1 ] && OGLE=1 || OGLE=0
case ${_IF_OP} in
"=") STR="${_IF_SETVAR}=\"${_IF_SETVAL}\""
;;
"+=") STR="${_IF_SETVAR}=\"${S}{${_IF_SETVAR}} ${_IF_SETVAL}\""
;;
"?=") STR="if [ -z \"${S}${_IF_SETVAR}\" ]; then ${_IF_SETVAR}=\"${_IF_SETVAL}\"; fi"
;;
"<-") SCRIPT="${SCRIPT} ${_IF_SETVAR}=\"\`eval 'echo \$${_IF_SETVAL}'\`\"; fi"
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;;
esac
SCRIPT="${SCRIPT}
if [ ${_IF_BOOL} = \"${S}${_IF_VAR}$\" ] || [ ${_IF_BOOL} = \"${S}${_IF_VAR2}\" ]; then
${STR} ; fi"
reset_vars
fi
;;
"valapkg")
IS_KEYWORD=0
TMP_VAR="HAVE_VALAPKG_`echo ${STR}| sed -e 's,\.,_,g' -e 's,-,_,g' -e 's,+,,g' | tr '[a-z]' '[A-Z]'`"
add_envword ${TMP_VAR}
# TODO: Use EOF or F="$F B"
REPORT_PKGCFG="${REPORT_PKGCFG} ${STR}"
SCRIPT="`printf \"${SCRIPT}\nprintf 'checking valac --pkg ${STR}... '\"`"
## - flags - ##
SCRIPT="`printf \"${SCRIPT}\ntmp=\\\`echo 'void main(){}'>.test.vala ; ${S}{VALAC} --pkg ${STR} .test.vala 2>/dev/null\\\`\"`"
SCRIPT="`printf \"${SCRIPT}\nif [ ${S}? != 0 ]; then echo no ; ${TMP_VAR}=0; \"`"
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="`printf \"${SCRIPT}\necho 'This vala package is required'\nexit 1\"`"
fi
SCRIPT="`printf \"${SCRIPT}\nelse \"`"
SCRIPT="`printf \"${SCRIPT}\necho yes; ${TMP_VAR}=1; \";`"
SCRIPT="`printf \"${SCRIPT}\nfi;rm -f .test.vala\"`"
## -eof- ##
_REQUIRED=0
MODE=""
;;
"pkgconfig")
IS_KEYWORD=0
if [ -z "${_PC_CFLAGS}" ]; then
_PC_CFLAGS="${STR}"
elif [ -z "${_PC_LDFLAGS}" ]; then
_PC_LDFLAGS="${STR}"
else
add_envword ${_PC_CFLAGS}
add_envword ${_PC_LDFLAGS}
TMP_VAR="HAVE_PKGCFG_`echo ${STR}| sed -e 's,\.,_,g' -e 's,-,_,g' -e 's,+,,g' | tr '[a-z]' '[A-Z]'`"
add_envword ${TMP_VAR}
# TODO: Use EOF or F="$F B"
REPORT_PKGCFG="${REPORT_PKGCFG} ${STR}"
SCRIPT="`printf \"${SCRIPT}\n[ -z \\\"${S}{PKGCONFIG}\\\" ] && PKGCONFIG=pkg-config\"`"
SCRIPT="`printf \"${SCRIPT}\necho 'Using PKGCONFIG: '${S}{PKGCONFIG}\"`"
SCRIPT="`printf \"${SCRIPT}\nprintf 'checking pkg-config flags for ${STR}... '\"`"
## - flags - ##
SCRIPT="`printf \"${SCRIPT}\ntmp=\\\`${S}{PKGCONFIG} --cflags ${STR} 2>/dev/null\\\`\"`"
SCRIPT="`printf \"${SCRIPT}\nif [ ${S}? != 0 ]; then echo no ; ${TMP_VAR}=0; \"`"
if [ "${_REQUIRED}" = 1 ]; then
SCRIPT="`printf \"${SCRIPT}\necho 'This package is required'\nexit 1\"`"
fi
SCRIPT="`printf \"${SCRIPT}\nelse \"`"
if [ "${_PKGCONFIG_PLUS}" = 1 ]; then
SCRIPT="`printf \"${SCRIPT}\n${_PC_CFLAGS}=\\\"${S}${_PC_CFLAGS} ${S}tmp\\\"; \"`"
else
SCRIPT="`printf \"${SCRIPT}\n${_PC_CFLAGS}=${S}tmp; \"`"
fi
## - libs - ##
SCRIPT="`printf \"${SCRIPT}\ntmp=\\\`${S}{PKGCONFIG} --libs ${STR} 2>/dev/null\\\`\"`"
SCRIPT="`printf \"${SCRIPT}\nif [ ${S}? = 0 ]; then \"`"
SCRIPT="`printf \"${SCRIPT}\necho yes; ${TMP_VAR}=1; \";`"
if [ "${_PKGCONFIG_PLUS}" = 1 ]; then
SCRIPT="`printf \"${SCRIPT}\n${_PC_LDFLAGS}=\\\"${S}${_PC_LDFLAGS} ${S}tmp\\\"; fi; fi\"`"
else
SCRIPT="`printf \"${SCRIPT}\n${_PC_LDFLAGS}=${S}tmp; fi; fi\"`"
fi
## -eof- ##
_PC_CFLAGS=""
_PC_LDFLAGS=""
_REQUIRED=0
MODE=""
fi
;;
"report")
IS_KEYWORD=0
if [ "${STR}" = ";" ]; then
MODE=""
else
REPORT="${REPORT} ${STR}"
fi
;;
"chkinc")
check_inc ${STR}
IS_KEYWORD=0
MODE=""
;;
"subconf")
IS_KEYWORD=0
if [ "${STR}" = ";" ]; then
MODE=""
else
SCRIPT="`printf \"${SCRIPT}\n(cd ${STR} && sh configure )\"`"
# SUBCONF_DIRS="${SUBCONF_DIRS} ${STR}"
fi
;;
"subdirs")
IS_KEYWORD=0
case "${STR}" in
";") MODE="" ; ;;
#"%") SD_FILES="%" ; ;; ## WTF
*) SD_FILES="${SD_FILES}${STR} " ; ;;
esac
;;
"chkprg")
IS_KEYWORD=0
if [ "${STR}" = "NOP" ]; then
echo "ERROR: Expected argument after CHKPRG keyword" >&2
exit 1
fi
if [ -z "${_CHKPRG_VAR}" ]; then
_CHKPRG_VAR=${STR}
else
_CHKPRG_NAME=${STR}
check_prg ${_CHKPRG_VAR} ${_CHKPRG_NAME} ${_REQUIRED}
MODE=""
_CHKPRG_VAR=""
_CHKPRG_NAME=""
fi
;;
"outputh")
if [ "${STR}" = ";" ]; then
MODE=""
else
H_FILES="${H_FILES} ${STR}"
fi
IS_KEYWORD=0
;;
"outputsh")
if [ "${STR}" = ";" ]; then
MODE=""
else
SH_FILES="${SH_FILES} ${STR}"
fi
IS_KEYWORD=0
;;
"argument")
if [ "${STR}" = ";" ]; then
# enable DEBUG debug "="
add_flag ${ARGUMENT} ${ARG_NAME} \
${ARG_FLAG} "${ARG_VALUE}" "${ARG_DESC}"
MODE=""
ARGUMENT=""
ARG_NAME=""
ARG_FLAG=""
ARG_VALUE=""
ARG_DESC=""
else
if [ -z "${ARG_NAME}" ]; then
ARG_NAME=`echo ${STR} | cut -d = -f 1`
ARG_VALUE=`echo ${STR} | awk -F = '{ print $2 }'`
elif [ -z "${ARG_FLAG}" ]; then
ARG_FLAG=${STR}
else
ARG_DESC="${ARG_DESC}${STR} "
fi
fi
IS_KEYWORD=0
;;
"equal")
# TODO: use string mode
if [ "${STR}" = ";" ]; then
for A in 1 2 3 4 ; do
if [ "${A}" = "${EQUAL}" ]; then
echo "`word` | There's a null body assignation to variable ${SET_VAR}. Please type \"\" or ''" >&2
exit 1
IS_KEYWORD=0
fi
done
[ "${DEBUG}" = 1 ] && \
echo " | $spaces\"${STRING}\"" >&2
STRING=""
SCRIPT="${SCRIPT}
${EQUAL}\""
MODE=""
# eval ${EQUAL}\" # XXX ?
EQUAL=""
_EQUAL_3=0
else
if [ -n "${SET_VAR}" ]; then
STRING=${STR}
STR=${SET_VAR}
SET_VAR=""
fi
case "${STRING}" in
"''"|"\"\"")
STRING=""
;;
esac
case "${EQUAL}" in
1) EQUAL="${STR}=\"${STRING}" ;; # =
2) EQUAL="${STR}=\"${S}{${STR}} ${STRING}" ;; # +=
3) EQUAL="[ -z \"${S}{${STR}}\" ] && ${STR}=\"${STRING}" ;; # ?=
4) EQUAL="${STR}=\"${S}${STRING}" ; ;; # <- XXX deprecated!!
*) #STRING=`concat "${STRING}" "${STR}"`
EQUAL=`concat "${EQUAL}" "${STR}"` ; ;; # .concat()
esac
#STRING=""
continue
fi
IS_KEYWORD=0
;;
"pkgname")
add_envword "PKGNAME"
add_envword "VPATH"
INIVARS="${INIVARS} PKGNAME='${STR}' ;"
PKGNAME=${STR}
MODE=""
IS_KEYWORD=0
;;
"version")
if [ "${PKGNAME}" = "this package" ]; then
echo "`word` | PKGNAME must be defined before VERSION" >&2
exit 1
fi
add_envword "VERSION"
INIVARS="${INIVARS} VERSION='${STR}' ;"
VERSION="${STR}"
MODE=""
IS_KEYWORD=0
;;
"contact")
IS_KEYWORD=0
if [ "${_CONTACT}" = 1 ]; then
if [ "${STR}" = ";" ]; then
_CONTACT=2
else
if [ -z "${CONTACT_NAME}" ]; then
CONTACT_NAME="${STR}"
else
CONTACT_NAME="${CONTACT_NAME} ${STR}"
fi
fi
else
CONTACT_MAIL=${STR};
MODE=""
_CONTACT=0 ## XXX ugly hack
add_envword "CONTACT"
add_envword "CONTACT_NAME"
add_envword "CONTACT_MAIL"
INIVARS="${INIVARS} CONTACT_MAIL=\"${CONTACT_MAIL}\" ;"
INIVARS="${INIVARS} CONTACT_NAME=\"${CONTACT_NAME}\" ;"
INIVARS="${INIVARS} CONTACT=\"${CONTACT_NAME} <${CONTACT_MAIL}>\" ;"
fi
;;
"arg_ignore")
FLAGSCRIPT=`printf "${FLAGSCRIPT}\n\"${STR}\") : ; ;;"`
IS_KEYWORD=0
MODE=""
;;
"author")
IS_KEYWORD=0
if [ "${_AUTHOR}" = 1 ]; then
if [ "${STR}" = ";" ]; then
_AUTHOR=2
else
if [ -z "${AUTHOR_NAME}" ]; then
AUTHOR_NAME="${STR}"
else
AUTHOR_NAME="${AUTHOR_NAME} ${STR}"
fi
fi
else
AUTHOR_MAIL=${STR};
MODE=""
_AUTHOR=0 ## XXX ugly hack
add_envword "AUTHOR"
add_envword "AUTHOR_NAME"
add_envword "AUTHOR_MAIL"
INIVARS="${INIVARS} AUTHOR_MAIL=\"${AUTHOR_MAIL}\" ;"
INIVARS="${INIVARS} AUTHOR_NAME=\"${AUTHOR_NAME}\" ;"
INIVARS="${INIVARS} AUTHOR=\"${AUTHOR_NAME} <${AUTHOR_MAIL}>\" ;"
fi
;;
"requireacrversion")
IS_KEYWORD=0
MODE=""
_OK="`echo ${STR} ${ACR_VERSION} | awk '{ if ($1 <= $2) {print "ok";} }'`"
if [ -z "${_OK}" ]; then
echo "`word` | Invalid ACR version. You need at least v${STR}" >&2
exit 1
fi
;;
"sizeof")
enter_string_mode ${STR}
wait_string_mode
check_sizeof "${STRING}"
MODE=""
IS_KEYWORD=0
leave_string_mode
;;
"substfiles")
IS_KEYWORD=0
if [ "${STR}" = ";" ]; then
MODE=""
else
S_FILES="${S_FILES} ${STR}"
# XXX may be buggy on >1 dir. must be checked
DIR="`echo ${STR} | awk -F / '{ print substr($0,0,length($0)-length($NF)) }'`"
S_MKDIR="${S_MKDIR} ${DIR}"
fi
;;
*)
echo "Invalid mode '${MODE}'" >&2
exit 1
;;
esac
fi
##KEYWORDS##
## debug output {{{
if [ "${DEBUG}" = 1 ]; then
spaces="`echo $NKEYS | awk '{ str=""; for(i=0;i<$1;i++) { str=str" "; } print str; }'`"
[ -n "${MODE}" ] && spaces=", ${spaces}"
fi
if [ "${IS_KEYWORD}" = 0 ]; then
if [ "${DEBUG}" = 1 ]; then
if [ ! "${STR}" = ";" ]; then
printf "%04d |$spaces " $WORDS_N >&2
echo "${STR}" >&2
fi
fi
continue
fi
WORDS_K=$WORDS_N
if [ "${DEBUG}" = 1 ]; then
if [ ! "${WORDS_N}" = "${WORDS_T}" ]; then
printf "%04d |$spaces " $WORDS_N >&2
echo "${STR}" >&2
fi
fi
## }}}
if [ -n "${SET_VAR}" ]; then
MODE="equal"
case $STR in
"=") EQUAL=1 ;;
"+=") EQUAL=2 ;;
"?=") EQUAL=3 _EQUAL_3=1 ;;
"<-") EQUAL=4
echo "`word` | The '<-' keyword is deprecated. Use $VAR instead" >&2
;; ### XXX deprecated!!
*)
check_ifop $STR
EQUAL=1 ;; ## will crash in check_ifop :)
esac
continue
fi
# clear required flag
_REQUIRED=0
case $STR in #------------ keyword tokens
";")
echo "`word` < found ';' character out of context." >&2
exit 1
;;
"}{"|"}ELSE{")
if [ $NKEYS -le 0 ]; then
echo "`word` < '}{' unmatching ELSE key." >&2
exit 1
fi
SCRIPT="${SCRIPT}
else"
;;
"}")
if [ $NKEYS -lt 0 ]; then
echo "`word` < unmatching '}' key." >&2
exit 1
fi
NKEYS=$(($NKEYS-1))
SCRIPT="${SCRIPT}; fi"
;;
#------------- segmentation keywords
"LOCAL:")
echo "LOCAL: deprecated keyword." >&2
;;
"GLOBAL:")
echo "GLOBAL: deprecated keyword." >&2
;;
#------------- command keywords
"NOP")
IS_KEYWORD=0 # Do Nothing Keyword
;;
##LANGS##
"LANG_C") env_c ; ;;
"LANG_C!") LANG_C_REQUIRED=1; env_c ; ;;
"LANG_OBJC") env_objc ; ;;
"LANG_OBJC!") LANG_OBJC_REQUIRED=1 ; env_objc ; ;;
"LANG_CC"|"LANG_CXX") env_cxx ; ;;
"LANG_CC!"|"LANG_CXX!") LANG_CXX_REQUIRED=1; env_cxx ; ;;
"LANG_BASH") LANG_BASH=1; lang_bash ; ;;
"LANG_TCL") env_tcl ; ;;
"LANG_TCL!") LANG_TCL_REQUIRED=1 ; env_tcl ; ;;
"LANG_PYTHON") env_python ; ;;
"LANG_PYTHON!") LANG_PYTHON_REQUIRED=1 ; env_python ; ;;
"LANG_JAVA") env_java ; ;;
"LANG_JAVA!") LANG_JAVA_REQUIRED=1 ; env_java ; ;;
"LANG_VALA") env_vala ; ;;
"LANG_VALA!") LANG_VALA_REQUIRED=1 ; env_vala ; ;;
"LANG_LUA") env_lua ; ;;
"LANG_LUA!") LANG_LUA_REQUIRED=1 ; env_lua ; ;;
"LANG_PERL") env_perl ; ;;
"LANG_PERL!") LANG_PERL_REQUIRED=1 ; env_perl ; ;;
"USE_PERL_THREADS") env_perl_threads ; ;;
"USE_PERL_THREADS!") _REQUIRED=1 env_perl_threads ; ;;
"LANG_RUBY") env_ruby ; ;;
"LANG_RUBY!") LANG_RUBY_REQUIRED=1 ; env_ruby ; ;;
"USE_TK")
add_envword "TK_VERSION"
add_envword "HAVE_TK"
add_envword "TK_LIBS"
add_envword "TK_LDFLAGS"
add_flag with TK_BASEDIR tk-basedir "/usr/" "Sets the TK basedir to find [/usr]/lib/tkConfig.sh"
USE_TK=1 ; ;;
"USE_X11")
REPORT_OPTIONAL="${REPORT_OPTIONAL} X11"
add_envword "HAVE_X11"
add_envword "X11BASE"
SCRIPT="${SCRIPT} ; X11BASE=/usr/X11R6/"
add_flag without HAVE_X11 x "" "Disable the X11 window system"
add_flag with X11BASE x11base "=" "Sets the X11BASE directory [/usr/X11R6]"
add_flag x X_INCLUDES includes "=" "X include files are in DIR" "=DIR"
add_flag x X_LIBRARIES libraries "=" "Points to the X11 library directory" "=DIR"
USE_X11=1 ; ;;
"USE_GMAKE") USE_GMAKE=1 ; env_gmake ; ;;
"PKGNAME") MODE="pkgname" ; ;;
"VERSION") MODE="version" ; ;;
"CONTACT") MODE="contact" _CONTACT=1 ; ;;
"AUTHOR") MODE="author" _AUTHOR=1 ; ;;
"ARG_IGNORE") MODE="arg_ignore" ; ;;
"INCLUDE")
if [ "${INSIDE_INCLUDE}" = 1 ]; then
echo "ERROR: Cannot nest includes." >&2
exit 1
fi
MODE="include"
;;
"REQUIRE_ACR_VERSION") MODE="requireacrversion" ; ;;
"CHECK_INCLUDE"|"CHECK_INCLUDE!"|"CHKINC"|"CHKINC!")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | Define LANG_C or LANG_CXX before use CHECK_INC" >&2
exit 1
fi
enter_mode "chkinc" ${STR}
;;
"CHK_CP"|"CHK_CP!"|"CHECK_CLASSPATH"|"CHECK_CLASSPATH!")
if [ -z "${LANG_JAVA}" ]; then
echo "`word` | Define LANG_JAVA before use CHECK_CLASSPATH" >&2
exit 1
fi
enter_mode "chkcp" ${STR}
;;
"CHKFNC"|"CHKFNC!"|"CHECK_FUNCTION"|"CHECK_FUNCTION!")
if [ -z "${LANG_C}" ]; then
echo "`word` | Define LANG_C before use CHECK_FUNC" >&2
exit 1
fi
enter_mode "chkfunc" ${STR}
;;
"CHK_PY"|"CHK_PY!"|"CHECK_PYTHON_MODULE"|"CHECK_PYTHON_MODULE!")
if [ -z "${LANG_PYTHON}" ]; then
echo "`word` | Define LANG_PYTHON before CHECK_PYTHON_MODULE." >&2
exit 1
fi
enter_mode "chkpy" ${STR}
;;
"CHK_RU"|"CHK_RU!"|"CHECK_RUBY_EXTENSION"|"CHECK_RUBY_EXTENSION")
if [ -z "${LANG_RUBY}" ]; then
echo "`word` | Define LANG_RUBY before CHECK_RUBY_EXTENSION." >&2
exit 1
fi
enter_mode "chkru" ${STR}
;;
"CHK_PM"|"CHK_PM!"|"CHECK_PERL_MODULE"|"CHECK_PERL_MODULE!")
if [ -z "${LANG_PERL}" ]; then
echo "`word` | Define LANG_PERL before using CHK_PM directive" >&2
exit 1
fi
enter_mode "chkpm" ${STR}
;;
"CHKLIB"|"CHKLIB!"|"CHECK_LIBRARY"|"CHECK_LIBRARY!")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | Define LANG_C or LANG_CXX before use CHECK_LIB" >&2
exit 1
fi
enter_mode "chklib" ${STR}
;;
"CHKPRG"|"CHKPRG!"|"CHECK_PROGRAM"|"CHECK_PROGRAM!")
enter_mode "chkprg" ${STR}
;;
"CHKUSR"|"CHKUSR!")
enter_mode "chkusr" ${STR}
;;
"CHKGRP"|"CHKGRP!")
enter_mode "chkgrp" ${STR}
;;
"ENDIAN"|"CHECK_ENDIAN")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | Define LANG_C or LANG_CXX before use CHECK_ENDIAN" >&2
exit 1
fi
check_endian
;;
"SIZEOF")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | Define LANG_C or LANG_CXX before use SIZEOF" >&2
exit 1
fi
enter_mode "sizeof" ${STR}
;;
"PKGCONFIG!"|"PKGCFG!")
MODE="pkgconfig"
_PKGCONFIG_PLUS=0
_REQUIRED=1
;;
"PKGCONFIG"|"PKGCFG")
MODE="pkgconfig"
_PKGCONFIG_PLUS=0
;;
"VALAPKG")
MODE="valapkg"
_REQUIRED=0
;;
"VALAPKG!")
MODE="valapkg"
_REQUIRED=1
;;
"PKGCONFIG+"|"PKGCFG+")
MODE="pkgconfig"
_PKGCONFIG_PLUS=1
;;
"USE_LIBTOOL"|"USE_LIBTOOL!")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | USE_LIBTOOL requires LANG_C or LANG_CXX." >&2
exit 1
fi
# TODO: Use mode for libtool
if [ "`echo ${STR}| grep '!'`" ]; then
_REQUIRED=1
else
_REQUIRED=0
fi
use_libtool
;;
"USE_PTHREAD"|"USE_PTHREAD!")
if [ -z "${LANG_C}${LANG_CXX}" ]; then
echo "`word` | USE_PTHREAD requires LANG_C or LANG_CXX." >&2
exit 1
fi
if [ "`echo ${STR}| grep '!'`" ]; then
_REQUIRED=1
else
_REQUIRED=0
fi
use_pthread
;;
"USE_BACKUP")
echo "`word` | USE_BACKUP is deprecated. It may not work on further version." >&2
USE_BACKUP=1
;;
"REPORT_DEFINED"|"RD")
_REPORT_DEFINED=1
;;
"USE_JNI")
if [ -z "${LANG_C}${LANG_CXX}${LANG_JAVA}" ]; then
echo "`word` | USE_JNI requires LANG_C or LANG_CXX and LANG_JAVA" >&2
exit 1
fi
use_jni
;;
"REPORT") MODE="report" ;;
"OUTPUT_H") MODE="outputh" ;;
"OUTPUT_SH") MODE="outputsh" ;;
"SUBCONF") MODE="subconf" ;;
"SUBDIRS") MODE="subdirs" ;;
"EXPORT")
echo "`word` | EXPORT keyword is deprecated. No need to use." >&2
MODE="export" ;;
"SUBST"|"SUBST_FILES")
MODE="substfiles" ;;
"IF")
MODE="if"
_IF_BOOL=1 ;;
"IFNOT")
MODE="if"
_IF_BOOL=0 ;;
"IFNULL")
MODE="if"
_IF_BOOL="" ;;
"ECHO")
MODE="echo" ;;
"IFNOTNULL")
MODE="ifeq"
_IF_BOOL=0
_IF_VALUE=""
_IF_VALUE_EOF=1
;;
"IFEQ")
MODE="ifeq"
_IF_BOOL=1 ;;
"IFNOTEQ")
MODE="ifeq"
_IF_BOOL=0 ;;
"IFEQVAL")
MODE="ifeqval"
_IF_BOOL=1 ;;
"IFNOTEQVAL")
MODE="ifeqval"
_IF_BOOL=0 ;;
"IFAND")
MODE="ifand"
_IF_BOOL=1 ;;
"IFNOTAND")
MODE="ifand"
_IF_BOOL=0 ;;
"IFOR")
MODE="ifor"
_IF_BOOL=1 ;;
"IFNOTOR")
MODE="ifor"
_IF_BOOL=0 ;;
"NOT")
MODE="not"
_NOT=1 ;;
"DIE"|"DIEIF")
MODE="die"
_DIE_BOOL=1 ;;
"DIENOT"|"DIEIFNOT")
MODE="die"
_DIE_BOOL=0 ;;
"DIENOW")
MODE="die"
_DIE_VAR=undefined_variable
_DIE_BOOL=0 ;;
"CHKVER!"|"CHECK_VERSION!"|"CHKVER"|"CHECK_VERSION")
enter_mode "chkver" ${STR} ;;
"USE_DL")
if [ "${_USE_DL_USED}" = 0 ]; then
MODE="usedl"
_USE_DL_USED=`word`
else
echo "`word` | ignored twice USE_DL found at ${_USE_DL_USED}." >&2
fi ;;
"EXEC")
MODE="exec" ;;
"USE_ICONV")
MODE="useiconv" ;;
"ARG_WITH")
MODE="argument"
ARGUMENT=with ;;
"ARG_WITHOUT")
MODE="argument"
ARGUMENT=without ;;
"ARG_ENABLE")
MODE="argument"
ARGUMENT=enable ;;
"ARG_DISABLE")
MODE="argument"
ARGUMENT=disable ;;
"CHECK_EXEC") MODE="check_exec"; ;;
"CHECK") MODE="check"; ;;
"="|"+="|"?="|"<-")
echo "The *old* format <op> <var> <value> is deprecated." >&2
echo "Please use the standard format <var> <op> <value>." >&2
exit 1
;;
*)
add_envword "$STR"
SET_VAR=$STR
;;
esac
done # inner loop
done
if [ "${IS_KEYWORD}" = 1 ]; then
echo "`word` | Unexpected end of file." >&2
exit 1
fi
if [ "${COMMENT}" = 1 ]; then
echo "`word` | Comment tag not closed." >&2
exit 1
fi
# Final stage
if [ "${MAKEFILE}" = 1 ]; then
if [ -f Makefile.acr ]; then
echo "ERROR: Makefile.acr already exists. Remove't manually." >&2
exit 1
fi
if [ -z "${VERSION}" ]; then
echo "ERROR: no VERSION defined." >&2
exit 1
fi
if [ "${PKGNAME}" = "this package" ]; then
echo "ERROR: no PKGNAME defined." >&2
exit 1
fi
if [ $NKEYS -lt 0 ]; then
echo "`word` < unexpected eof: unmatching final '}' key." >&2
exit 1
fi
cat > Makefile.acr <<EOF
.PHONY: all install dist clean mrproper
VPATH=@VPATH@
EOF
echo "PKGNAME=@""PKGNAME@" >> Makefile.acr
echo "VERSION=@""VERSION@" >> Makefile.acr
echo "INSTALL_DATA=@""INSTALL_DATA@" >> Makefile.acr
echo "INSTALL_PROGRAM=@""INSTALL_PROGRAM@" >> Makefile.acr
echo "INSTALL_PROGRAM_STRIP=@""INSTALL_PROGRAM_STRIP@" >> Makefile.acr
if [ "${LANG_JAVA}" = 1 ]; then
cat >> Makefile.acr <<EOF
JAVAC=@JAVAC@
%.class: %.java
${S}{JAVAC} $<
EOF
fi
[ "${LANG_C}" = 1 ] &&\
cat >> Makefile.acr <<EOF
CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
EOF
[ "${LANG_CXX}" = 1 ] &&\
cat >> Makefile.acr <<EOF
CXX=@CXX@
CXXFLAGS=@CXXFLAGS@
EOF
# XXX this will be deprecated!
if [ "${USE_BACKUP}" = 1 ]; then
cat >> Makefile.acr <<EOF
define unsubst
@echo unsubst ${S}{1}
@if [ -f "${S}{1}.backup" ]; then\\
if [ ! -f "${S}{1}" ]; then\\
FOO="";\\
else\\
FOO="\`diff -u ${S}{1} ${S}{1}.backup\`";\\
fi;\\
if [ "${S}{FOO}" ]; then\\
echo "Looks like '${S}{1}' has changed. Check .backup";\\
exit 1;\\
else\\
rm -f ${S}{1}.backup;\\
mv -f ${S}{1}.orig ${S}{1};\\
fi\\
fi
endef
EOF
fi
echo "" >> Makefile.acr
echo "all:" >> Makefile.acr
for A in ${SD_FILES} ; do
if [ ! "${A}" = "." ]; then
printf "\tcd ${A} && ${S}{MAKE}\n" >> Makefile.acr
fi
done
echo "" >> Makefile.acr
echo "install:" >> Makefile.acr
for A in ${SD_FILES} ; do
if [ ! "${A}" = "." ]; then
printf "\tcd ${A} && ${S}{MAKE} install\n" >> Makefile.acr
fi
done
cat >> Makefile.acr << EOF
clean:
EOF
for A in ${SD_FILES} ; do
if [ ! "${A}" = "." ]; then
printf "\tcd ${A} && ${S}{MAKE} clean\n" >> Makefile.acr
fi
done
if [ "${USE_BACKUP}" = 1 ]; then
for A in ${S_FILES}; do
printf "\t${S}(call unsubst,${A})\n" >> Makefile.acr
done
else
for A in ${S_FILES}; do
printf "\tmv -f ${A}.orig ${A}\n" >> Makefile.acr
done
fi
if [ "${H_FILES}" ]; then
printf "\trm -f ${H_FILES}\n" >> Makefile.acr
fi
if [ "${SH_FILES}" ]; then
printf "\trm -f ${SH_FILES}\n" >> Makefile.acr
fi
cat >> Makefile.acr <<EOF
mrproper: clean
rm Makefile
dist: mrproper
cd .. && \\
mv -f ${S}{PKGNAME} ${S}{PKGNAME}-${S}{VERSION} && \\
tar czvf ${S}{PKGNAME}-${S}{VERSION}.tar.gz ${S}{PKGNAME}-${S}{VERSION} && \\
mv -f ${S}{PKGNAME}-${S}{VERSION} ${S}{PKGNAME} && \\
echo "dist done"
EOF
echo "acr: Makefile.acr created successfully." >&2
else
if [ "${PBAR}" = 1 ]; then
echo >&2 ; fi
create_script
if [ $NKEYS -lt 0 ]; then
echo "`word` < unexpected eof: unmatching '}' key." >&2
exit 1
fi
show_report
if [ "${NOPE}" = 0 ]; then
echo "acr: ${CONFIGURE} script created successfully." >&2
fi
fi
makedist_failed(){
echo "ERROR: $1" >&2
exit 1
}
if [ "${MAKEDIST}" = 1 ]; then
if [ -z "$PKGNAME" ]; then
makedist_failed "PKGNAME not defined"
fi
if [ -z "$VERSION" ]; then
VERSION=`date +%Y%m%d`
echo "VERSION not defined. Using current date" >&2
fi
# if ( basename `pwd` != $PKGNAME ) { failed!! }
DIRNAME="`expr $PWD : '.*\/\(.*\)$'`"
if [ ! "$DIRNAME" = "$PKGNAME" ]; then
makedist_failed "Invalid directory name '$DIRNAME' must be '$PKGNAME'." >&2
fi
##
echo "[2/4] Running configure." >&2
./configure 2>&1 | ${AWK} '{ printf "."; }' >&2
echo >&2
if [ ! -e "Makefile.acr" ]; then
makedist_failed "No Makefile.acr found in current directory. Cannot clean"
fi
echo "[3/4] Cleaning (make clean)" >&2
make clean 2>&1 | ${AWK} '{ printf "."; }' >&2
echo >&2
echo "[4/4] Disting project into a tarball." >&2
P=${PKGNAME}-${VERSION}
if [ -d .hg ]; then
rm -rf .tmp >&2
mkdir -p .tmp >&2
hg clone . .tmp/${P} >&2
rm -rf .tmp/${P}/.hg
cd .tmp/
tar czvf ../${P}.tar.gz $P 2>&1 | ${AWK} '{ printf "."; }' >&2
rm -rf .tmp
elif [ -d .git ]; then
rm -rf .tmp >&2
mkdir -p .tmp >&2
git clone . .tmp/${P} >&2
rm -rf .tmp/${P}/.git
cd .tmp/
tar czvf ../${P}.tar.gz $P 2>&1 | ${AWK} '{ printf "."; }' >&2
rm -rf .tmp
elif [ -d .svn ]; then
URL=$(svn info| grep URL|cut -d : -f 2-)
rm -rf .tmp >&2
mkdir -p .tmp >&2
cd .tmp
svn co ${URL} ${P}
rm -rf ${P}/.svn
tar czvf ../${P}.tar.gz $P 2>&1 | ${AWK} '{ printf "."; }' >&2
rm -rf .tmp
else
cd ..
mv $PKGNAME $PKGNAME-$VERSION
tar czvf $PKGNAME-$VERSION.tar.gz $PKGNAME-$VERSION 2>&1 | ${AWK} '{ printf "."; }' >&2
if [ ! $? = 0 ]; then
mv $PKGNAME-$VERSION $PKGNAME
makedist_failed "Cannot create ../$PKGNAME-$VERSION"
fi
mv $PKGNAME-$VERSION $PKGNAME
cd -
mv ../$PKGNAME-$VERSION.tar.gz .
fi
echo >&2
echo "Tarball created successfully at $PKGNAME-$VERSION.tar.gz" >&2
fi
# vim:set foldmethod=marker
|