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 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346
|
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 1997-2018. All Rights Reserved.
dnl
dnl Licensed under the Apache License, Version 2.0 (the "License");
dnl you may not use this file except in compliance with the License.
dnl You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.
dnl
dnl %CopyrightEnd%
dnl The string "FIXME convbreak" means that there is a break of
dnl autoconf convention that should be cleaned up.
AC_INIT(vsn.mk)
AC_PREREQ(2.59)
LM_PRECIOUS_VARS
if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then
# We do not want to use a common cache!
cache_file=/dev/null
fi
dnl How to set srcdir absolute is taken from the GNU Emacs distribution
#### Make srcdir absolute, if it isn't already. It's important to
#### avoid running the path through pwd unnecessary, since pwd can
#### give you automounter prefixes, which can go away.
case "${srcdir}" in
/* ) ;;
. )
## We may be able to use the $PWD environment variable to make this
## absolute. But sometimes PWD is inaccurate.
## Make sure CDPATH doesn't affect cd (in case PWD is relative).
CDPATH=
if test "${PWD}" != "" && test "`(cd ${PWD} ; sh -c pwd)`" = "`pwd`" ;
then
srcdir="$PWD"
else
srcdir="`(cd ${srcdir}; pwd)`"
fi
;;
* ) srcdir="`(cd ${srcdir}; pwd)`" ;;
esac
## Now, make sure that ERL_TOP is set and is the same as srcdir
##
if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
AC_MSG_ERROR(You need to set the environment variable ERL_TOP!)
fi
if test x"${ERL_TOP}/erts" != x"$srcdir"; then
AC_MSG_ERROR([You need to run configure with argument --srcdir=${ERL_TOP}/erts])
fi
erl_top=${ERL_TOP}
# echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# echo X
# echo "X srcdir = $srcdir"
# echo "X ERL_TOP = $ERL_TOP"
# echo X
# echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AC_CONFIG_AUX_DIRS($srcdir/autoconf)
dnl ----------------------------------------------------------------------
dnl Figure out what system we are running on.
dnl ----------------------------------------------------------------------
#
# To configure for free source run ./configure --host=free_source
#
dnl
dnl AC_CANONICAL_HOST does not like free_source as a host specification,
dnl so we make a little special case.
dnl
if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
AC_CANONICAL_HOST
else
host_os=$host
fi
if test "$cross_compiling" = "yes"; then
CROSS_COMPILING=yes
else
CROSS_COMPILING=no
fi
AC_SUBST(CROSS_COMPILING)
ERL_XCOMP_SYSROOT_INIT
AC_ISC_POSIX
AC_CONFIG_HEADER($host/config.h:config.h.in include/internal/$host/ethread_header_config.h:include/internal/ethread_header_config.h.in include/$host/erl_int_sizes_config.h:include/erl_int_sizes_config.h.in)
dnl ----------------------------------------------------------------------
dnl Optional features.
dnl ----------------------------------------------------------------------
ENABLE_ALLOC_TYPE_VARS=
AC_SUBST(ENABLE_ALLOC_TYPE_VARS)
AC_ARG_ENABLE(bootstrap-only,
AS_HELP_STRING([--enable-bootstrap-only],
[enable bootstrap only configuration]),
[ if test "X$enableval" = "Xyes"; then
# Disable stuff not necessary in a bootstrap only system in order
# to speed up things by reducing the amount of stuff needing to be
# built...
with_termcap=no
with_ssl=no
with_ssl_zlib=no
enable_hipe=no
enable_sctp=no
fi
])
AC_ARG_ENABLE(dirty-schedulers-test,
AS_HELP_STRING([--enable-dirty-schedulers-test], [enable dirty scheduler test (for debugging purposes)]),
[ case "$enableval" in
yes) enable_dirty_schedulers_test=yes ;;
*) enable_dirty_schedulers_test=no ;;
esac ], enable_dirty_schedulers_test=no)
AC_ARG_ENABLE(smp-require-native-atomics,
AS_HELP_STRING([--disable-smp-require-native-atomics],
[disable the SMP requirement of a native atomic implementation]),
[ case "$enableval" in
no) smp_require_native_atomics=no ;;
*) smp_require_native_atomics=yes ;;
esac ], smp_require_native_atomics=yes)
AC_ARG_WITH(termcap,
AS_HELP_STRING([--with-termcap], [use termcap (default)])
AS_HELP_STRING([--without-termcap],
[do not use any termcap libraries (ncurses,curses,termcap,termlib)]),
[],
[with_termcap=yes])
AC_ARG_ENABLE(lock-checking,
AS_HELP_STRING([--enable-lock-checking], [enable lock checking]),
[ case "$enableval" in
no) enable_lock_check=no ;;
*) enable_lock_check=yes ;;
esac
],
enable_lock_check=no)
AC_ARG_ENABLE(lock-counter,
AS_HELP_STRING([--enable-lock-counter], [enable lock counters]),
[ case "$enableval" in
no) enable_lock_count=no ;;
*) enable_lock_count=yes ;;
esac ], enable_lock_count=no)
AC_ARG_ENABLE(kernel-poll,
AS_HELP_STRING([--enable-kernel-poll], [enable kernel poll support])
AS_HELP_STRING([--disable-kernel-poll], [disable kernel poll support]),
[ case "$enableval" in
no) enable_kernel_poll=no ;;
*) enable_kernel_poll=yes ;;
esac ], enable_kernel_poll=unknown)
AC_ARG_ENABLE(sctp,
AS_HELP_STRING([--enable-sctp], [enable sctp support (default)
to on demand load the SCTP library in runtime if needed])
AS_HELP_STRING([--enable-sctp=lib], [enable sctp support
to link against the SCTP library])
AS_HELP_STRING([--disable-sctp], [disable sctp support]),
[ case "x$enableval" in
xno|xyes|xlib|x)
;;
x*)
AC_MSG_ERROR("invalid value --enable-sctp=$enableval")
;;
esac ])
AC_ARG_ENABLE(hipe,
AS_HELP_STRING([--enable-hipe], [enable hipe support])
AS_HELP_STRING([--disable-hipe], [disable hipe support]))
AC_ARG_ENABLE(native-libs,
AS_HELP_STRING([--enable-native-libs],
[compile Erlang libraries to native code]))
AC_ARG_ENABLE(fp-exceptions,
AS_HELP_STRING([--enable-fp-exceptions],
[use hardware floating point exceptions (default if hipe enabled)]),
[ case "$enableval" in
no) enable_fp_exceptions=no ;;
*) enable_fp_exceptions=yes ;;
esac
],enable_fp_exceptions=auto)
AC_ARG_ENABLE(m64-build,
AS_HELP_STRING([--enable-m64-build],
[build 64bit binaries using the -m64 flag to (g)cc]),
[ case "$enableval" in
no) enable_m64_build=no ;;
*) enable_m64_build=yes ;;
esac
],enable_m64_build=no)
AC_ARG_ENABLE(m32-build,
AS_HELP_STRING([--enable-m32-build],
[build 32bit binaries using the -m32 flag to (g)cc]),
[ case "$enableval" in
no) enable_m32_build=no ;;
*) enable_m32_build=yes ;;
esac
],enable_m32_build=no)
AC_ARG_WITH(dynamic-trace,
AS_HELP_STRING([--with-dynamic-trace={dtrace|lttng|systemtap}],
[specify use of dynamic trace framework, dtrace, lttng or systemtap])
AS_HELP_STRING([--without-dynamic-trace],
[don't enable any dynamic tracing (default)]))
if test X"$with_dynamic_trace" = X""; then
with_dynamic_trace=no
fi
case "$with_dynamic_trace" in
no) DYNAMIC_TRACE_FRAMEWORK=;;
lttng)
AC_DEFINE(USE_LTTNG,[1],
[Define if you want to use lttng for dynamic tracing])
DYNAMIC_TRACE_FRAMEWORK=lttng;;
dtrace)
AC_DEFINE(USE_DTRACE,[1],
[Define if you want to use dtrace for dynamic tracing])
DYNAMIC_TRACE_FRAMEWORK=dtrace;;
systemtap)
AC_DEFINE(USE_SYSTEMTAP,[1],
[Define if you want to use systemtap for dynamic tracing])
DYNAMIC_TRACE_FRAMEWORK=systemtap;;
*)
AC_MSG_ERROR(Unknown dynamic tracing framework specified with --with-dynamic-trace!);;
esac
if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then
AC_DEFINE(USE_DYNAMIC_TRACE,[1],
[Define if you want to use dynamic tracing])
fi
AC_ARG_ENABLE(vm-probes,
AS_HELP_STRING([--enable-vm-probes],
[add dynamic trace probes to the Beam VM (only possible if --with-dynamic-trace is enabled, and then default)]),
[ case "$enableval" in
no) use_vm_probes=no ;;
*)
if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then
use_vm_probes=yes ;
else
AC_MSG_ERROR(Can not enable VM probes without any dynamic tracing framework!);
fi;;
esac ], if test X"$DYNAMIC_TRACE_FRAMEWORK" != X""; then
use_vm_probes=yes ;
else
use_vm_probes=no
fi)
AC_SUBST(USE_VM_PROBES)
if test X"$DYNAMIC_TRACE_FRAMEWORK" != X"lttng"; then
if test X"$use_vm_probes" = X"yes"; then
USE_VM_PROBES=yes
AC_DEFINE(USE_VM_PROBES,[1],
[Define to enable VM dynamic trace probes])
fi
fi
AC_ARG_WITH(assumed-cache-line-size,
AS_HELP_STRING([--with-assumed-cache-line-size=SIZE],
[specify assumed cache line size in bytes (valid values are powers of two between and including 16 and 8192; default is 64)]))
dnl Require the assumed cache-line size to be a power of two between 16 and 8192
case "$with_assumed_cache_line_size" in
""|no|yes)
with_assumed_cache_line_size=64;;
16|32|64|128|256|512|1024|2048|4096|8192)
;;
*)
AC_MSG_ERROR([Invalid assumed cache-line size of $with_assumed_cache_line_size bytes])
;;
esac
AC_DEFINE_UNQUOTED(ASSUMED_CACHE_LINE_SIZE,
$with_assumed_cache_line_size,
[Assumed cache-line size (in bytes)])
AC_ARG_ENABLE(systemd,
AS_HELP_STRING([--enable-systemd], [enable systemd support in epmd]),
[],
[enable_systemd=no])
AC_ARG_ENABLE(saved-compile-time,
AS_HELP_STRING([--disable-saved-compile-time], [disable saved compile time]),
[ case "$enableval" in
no) save_compile_time=0 ;;
*) save_compile_time=1 ;;
esac ], save_compile_time=1)
AC_DEFINE_UNQUOTED(ERTS_SAVED_COMPILE_TIME, $save_compile_time, [Save compile time?])
AC_ARG_WITH(microstate-accounting,
AS_HELP_STRING([--with-microstate-accounting={yes|extra}],
[enable microstate account, possibly with extra detailed states])
AS_HELP_STRING([--without-microstate-accounting],
[don't enable microstate accounting]),
[],[with_microstate_accounting=yes])
case "$with_microstate_accounting" in
yes) AC_DEFINE(ERTS_ENABLE_MSACC,[1],
[Define as 1 if you want to enable microstate accounting, 2 if you want extra states]) ;;
extra) AC_DEFINE(ERTS_ENABLE_MSACC,[2],
[Define as 1 if you want to enable microstate accounting, 2 if you want extra states]) ;;
*) ;;
esac
dnl Magic test for clearcase.
OTP_RELEASE=
if test "${ERLANG_COMMERCIAL_BUILD}" != ""; then
OTP_EXTRA_FLAGS=-DOTP_RELEASE
OTP_RELEASE=yes
else
OTP_EXTRA_FLAGS=
fi
AC_SUBST(OTP_RELEASE)
AC_MSG_CHECKING([OTP release])
[SYSTEM_VSN=`cat $ERL_TOP/OTP_VERSION | sed "s|\([0-9]*\).*|\1|"`]
AC_MSG_RESULT([$SYSTEM_VSN])
AC_SUBST(SYSTEM_VSN)
AC_MSG_CHECKING([OTP version])
[OTP_VERSION=`cat $ERL_TOP/OTP_VERSION`]
AC_MSG_RESULT([$OTP_VERSION])
AC_SUBST(OTP_VERSION)
if test X${enable_m64_build} = Xyes; then
case $CFLAGS in
*-m64*)
;;
*)
CFLAGS="-m64 $CFLAGS"
;;
esac
else
if test X${enable_m32_build} = Xyes;
then
case $CFLAGS in
*-m32*)
;;
*)
CFLAGS="-m32 $CFLAGS"
;;
esac ;
fi
fi
AC_ARG_ENABLE(static-nifs,
AS_HELP_STRING([--enable-static-nifs], [link nifs statically. If yes then all nifs in all Erlang/OTP applications will be statically linked into the main binary. It is also possible to give a list of nifs that should be linked statically. The list should be a comma separated and contain the absolute path to a .a archive for each nif that is to be statically linked. The name of the .a archive has to be the same as the name of the nif. Note that you have to link any external dependencies that the nifs have to the main binary, so for the crypto nif you want to pass LIBS=-lcrypto to configure.]),
STATIC_NIFS="$enableval",
STATIC_NIFS=no)
AC_SUBST(STATIC_NIFS)
AC_ARG_ENABLE(static-drivers,
AS_HELP_STRING([--enable-static-drivers], [comma separated list of linked-in drivers to link statically with the main binary. The list should contain the absolute path to a .a archive for each driver that is to be statically linked. The name of the .a archive has to be the same as the name of the driver.]),
STATIC_DRIVERS="$enableval",
STATIC_DRIVERS=no)
AC_SUBST(STATIC_DRIVERS)
AC_ARG_WITH(ets-write-concurrency-locks,
AS_HELP_STRING([--with-ets-write-concurrency-locks={8|16|32|64|128|256}],
[specify how many locks the write_concurrency option for ets should use.])
AS_HELP_STRING([--without-ets-write-concurrency-locks],
[use the default number of write_concurrency locks (default)]))
if test X"$with_ets_write_concurrency_locks" != X""; then
AC_DEFINE_UNQUOTED(ERTS_DB_HASH_LOCK_CNT,$with_ets_write_concurrency_locks,
[Define to override the default number of write_concurrency locks])
fi
AC_ARG_WITH(spectre-mitigation,
AS_HELP_STRING([--with-spectre-mitigation={yes|incomplete}],
[enable spectre mitigation, either fully or with mitigations
disabled in a handful places like the interpreter])
AS_HELP_STRING([--without-spectre-mitigation],
[build without spectre mitigation]),
[],[with_spectre_mitigation=no])
case "$with_spectre_mitigation" in
no) ;;
yes) ;;
incomplete) ;;
*) AC_MSG_ERROR([Invalid spectre mitigation setting]) ;;
esac
i_noretpoline_attr=""
if test X"$with_spectre_mitigation" != X"no"; then
CFLAGS="$CFLAGS -mindirect-branch=thunk"
AC_MSG_CHECKING([for spectre mitigation])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([],[return 0;])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([no])])
if test X"$with_spectre_mitigation" = X"incomplete"; then
# gcc and clang support this attribute if they're recent enough. Note
# that we must compile with -Werror to check for actual support as they
# warn rather than error out on unsupported attributes.
i_noretpoline_attr='__attribute__((__indirect_branch__("keep")))'
i_preserve_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_MSG_CHECKING([whether spectre mitigation can be disabled on a per-function basis])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([$i_noretpoline_attr],[return 0;])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([no])])
CFLAGS="$i_preserve_cflags"
fi
fi
AC_DEFINE_UNQUOTED(ERTS_NO_RETPOLINE, $i_noretpoline_attr,
[Per-function attribute for disabling retpoline. This is
*only* defined when --with-spectre-mitigation=incomplete
and has no effects otherwise])
dnl ----------------------------------------------------------------------
dnl Checks for programs.
dnl ----------------------------------------------------------------------
AC_PROG_CC
AC_SUBST(GCC)
dnl ---------------------------------------------------------------------
dnl Special stuff regarding CFLAGS and details in the environment...
dnl ---------------------------------------------------------------------
dnl NOTE: CPPFLAGS will be included in CFLAGS at the end
case $host_os in
linux*|*gnu*) CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE";;
win32)
# The ethread library requires _WIN32_WINNT of at least 0x0403.
# -D_WIN32_WINNT=* from CPPFLAGS is saved in ETHR_DEFS.
CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600 -DWINVER=0x0600"
;;
*)
;;
esac
LM_WINDOWS_ENVIRONMENT
dnl
dnl Flags to the C compiler
dnl
dnl Make sure we find config.h
dnl
extra_flags="-I${ERL_TOP}/erts/$host $OTP_EXTRA_FLAGS"
CFLAGS="$CFLAGS $extra_flags"
DEBUG_CFLAGS="-g $CPPFLAGS $extra_flags $DEBUG_CFLAGS"
DEBUG_FLAGS=-g
dnl
dnl Adjust DEBUG_CFLAGS to match CFLAGS in terms of -m
dnl
case $CFLAGS in
*-m64*)
case $DEBUG_CFLAGS in
*-m64*)
;;
*)
DEBUG_CFLAGS="-m64 $DEBUG_CFLAGS"
;;
esac
;;
*-m32*)
case $DEBUG_CFLAGS in
*-m32*)
;;
*)
DEBUG_CFLAGS="-m32 $DEBUG_CFLAGS"
;;
esac
;;
*)
;;
esac
CFLAG_RUNTIME_LIBRARY_PATH="-Wl,-R"
case $host_os in
darwin*)
CFLAG_RUNTIME_LIBRARY_PATH=
;;
win32)
CFLAG_RUNTIME_LIBRARY_PATH=
;;
osf*)
CFLAG_RUNTIME_LIBRARY_PATH="-Wl,-rpath,"
;;
*)
;;
esac
lfs_conf=ok
lfs_source=none
if test "${LFS_CFLAGS+set}" = "set" || \
test "${LFS_LDFLAGS+set}" = "set" || \
test "${LFS_LIBS+set}" = "set"; then
lfs_source=user
else
LM_CHECK_GETCONF
test "$GETCONF" = "false" || lfs_source=getconf
fi
if test "$lfs_source" = "none"; then
AC_MSG_WARN([Do not know how to check for large file support flags; no getconf is available])
else
for var in CFLAGS LDFLAGS LIBS; do
AC_MSG_CHECKING([for large file support $var])
if test $lfs_source = user; then
eval "lfs_val=\"\$LFS_$var\""
else
eval "lfs_var=LFS_$var"
lfs_val=`$GETCONF $lfs_var 2>/dev/null` || lfs_conf=failed
if test $lfs_conf = failed; then
AC_MSG_RESULT([failed])
break
fi
eval "$lfs_var=\"$lfs_val\""
fi
test "$lfs_val" != "" || lfs_val=none
AC_MSG_RESULT([$lfs_val])
done
if test $lfs_conf = failed; then
AC_MSG_WARN([Check for large file support flags failed; $GETCONF failed])
else
CFLAGS="$CFLAGS $LFS_CFLAGS"
DEBUG_CFLAGS="$DEBUG_CFLAGS $LFS_CFLAGS"
LDFLAGS="$LDFLAGS $LFS_LDFLAGS"
LIBS="$LIBS $LFS_LIBS"
fi
fi
if test "x$GCC" = xyes; then
# Treat certain GCC warnings as errors
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [WERRORFLAGS])
LM_TRY_ENABLE_CFLAG([-Werror=implicit], [WERRORFLAGS])
LM_TRY_ENABLE_CFLAG([-Werror=undef], [WERRORFLAGS])
# until the emulator can handle this, I suggest we turn it off!
#WFLAGS="-Wall -Wshadow -Wcast-qual -Wmissing-declarations"
WFLAGS="-Wall -Wstrict-prototypes"
case "$host_cpu" in
tile*)
# tile-gcc is a bit stricter with -Wmissing-prototypes than other gccs,
# and too strict for our taste.
;;
*)
WFLAGS="$WFLAGS -Wmissing-prototypes";;
esac
saved_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
AC_TRY_COMPILE([],[;], warn_decl_after_st=true, warn_decl_after_st=false)
if test "X$warn_decl_after_st" = "Xtrue"; then
WFLAGS="$WFLAGS -Wdeclaration-after-statement"
fi
CFLAGS=$saved_CFLAGS
else
WFLAGS=""
WERRORFLAGS=""
fi
AC_MSG_CHECKING([CFLAGS for -O switch])
case "$CFLAGS" in
*-O*) AC_MSG_RESULT([yes]) ;;
*)
AC_MSG_ERROR([
CFLAGS must contain a -O flag. If you need to edit the CFLAGS you probably
also want to add the default CFLAGS. The default CFLAGS are "-O2 -g".
If you want to build erts without any optimization, pass -O0 to CFLAGS.]) ;;
esac
dnl DEBUG_FLAGS is obsolete (I hope)
AC_SUBST(DEBUG_FLAGS)
AC_SUBST(DEBUG_CFLAGS)
AC_SUBST(WFLAGS)
AC_SUBST(WERRORFLAGS)
AC_SUBST(CFLAG_RUNTIME_LIBRARY_PATH)
## Check if we can do profile guided optimization of beam_emu
LM_CHECK_ENABLE_CFLAG([-fprofile-generate -Werror],[PROFILE_GENERATE])
LM_CHECK_ENABLE_CFLAG([-fprofile-use -Werror],[PROFILE_USE])
## Check if this is clang
LM_CHECK_ENABLE_CFLAG([-fprofile-instr-generate -Werror],[PROFILE_INSTR_GENERATE])
if test "X$PROFILE_INSTR_GENERATE" = "Xtrue"; then
# It was clang, now we also have to check if we have llvm-profdata and that
# we can link programs with -fprofile-instr-use
saved_CFLAGS=$CFLAGS;
CFLAGS="-fprofile-instr-generate -Werror $saved_CFLAGS"
AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])],
[AC_CHECK_PROGS([LLVM_PROFDATA], [llvm-profdata])
AC_CHECK_PROGS([XCRUN], [xcrun])
if test "X$XCRUN" != "X" -a "X$LLVM_PROFDATA" = "X"; then
AC_MSG_CHECKING([for $XCRUN llvm-profdata])
if $XCRUN llvm-profdata --help 2>& AS_MESSAGE_LOG_FD >& AS_MESSAGE_LOG_FD; then
LLVM_PROFDATA="$XCRUN llvm-profdata"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
AC_SUBST(LLVM_PROFDATA)
if test "X$LLVM_PROFDATA" != "X"; then
CFLAGS="-fprofile-instr-use=default.profdata -Werror $saved_CFLAGS";
$LLVM_PROFDATA merge -output=default.profdata *.profraw;
AC_MSG_CHECKING([whether gcc accepts -fprofile-instr-use=default.profdata -Werror])
AC_COMPILE_IFELSE([],
[AC_MSG_RESULT([yes])
PROFILE_INSTR_USE=true],
[AC_MSG_RESULT([no])
PROFILE_INSTR_USE=false])
rm -f default.profdata
fi],
[],
[AC_MSG_NOTICE([Disabling PGO when cross-compiling])])
rm -f *.profraw
CFLAGS=$saved_CFLAGS;
fi
AC_ARG_ENABLE(pgo,
AS_HELP_STRING([--enable-pgo],
[build erts using PGO (profile guided optimization)]),
[ case "$enableval" in
no) enable_pgo=no ;;
*) enable_pgo=yes ;;
esac
],enable_pgo=default)
LM_CHECK_ENABLE_CFLAG([-fprofile-use -fprofile-correction -Werror],[PROFILE_CORRECTION])
USE_PGO=false
AC_MSG_CHECKING([whether to do PGO of erts])
if test $enable_pgo = no; then
AC_MSG_RESULT([no, disabled by user])
elif test $CROSS_COMPILING = yes; then
if test $enable_pgo = yes; then
AC_MSG_ERROR(cannot use PGO when cross-compiling)
else
AC_MSG_RESULT([no, cross compiling])
fi
elif test "X$host" = "Xwin32"; then
AC_MSG_RESULT([no, not supported in windows])
elif test "X$PROFILE_GENERATE" = "Xtrue" -a "X$PROFILE_USE" = "Xtrue" -a "X$PROFILE_CORRECTION" = "Xtrue"; then
## We need -fprofile-generate and -fprofile-correction support to use PGO with
## gcc as multiple threads run within the executed object files
USE_PGO=true
PROFILE_COMPILER=gcc
AC_MSG_RESULT([yes, using -fprofile-generate -fprofile-correction])
elif test "X$PROFILE_INSTR_GENERATE" = "Xtrue" -a "X$PROFILE_INSTR_USE" = "Xtrue"; then
USE_PGO=true
PROFILE_COMPILER=clang
AC_MSG_RESULT([yes, using -fprofile-instr-generate])
else
if $enable_pgo = yes; then
AC_MSG_ERROR(cannot use PGO with this compiler)
else
AC_MSG_RESULT([no])
fi
fi
AC_SUBST(USE_PGO)
AC_SUBST(PROFILE_COMPILER)
AC_CHECK_SIZEOF(void *) # Needed for ARCH and smp checks below
if test "x$ac_cv_sizeof_void_p" = x8; then
AC_SUBST(EXTERNAL_WORD_SIZE, 64)
else
AC_SUBST(EXTERNAL_WORD_SIZE, 32)
fi
dnl
dnl Figure out operating system and cpu architecture
dnl
if test "x$host_alias" != "x"; then
chk_opsys_=$host_os
else
chk_opsys_=`uname -s`
if test "x$chk_opsys_" = "xSunOS"; then
chk_opsys_=$chk_opsys_`uname -r`
fi
fi
case $chk_opsys_ in
win32) OPSYS=win32;;
solaris2.*|SunOS5.*) OPSYS=sol2;;
linux*|Linux) OPSYS=linux;;
darwin|Darwin) OPSYS=darwin;;
freebsd|FreeBSD) OPSYS=freebsd;;
*) OPSYS=noopsys
esac
AC_SUBST(OPSYS)
LM_HARDWARE_ARCH
dnl Check consistency of os and darwin-switches
dnl Take care of LDFLAGS on darwin, and disable common_test as it
dnl has a build/configure system re rx-lib that is not compatible
dnl First remove common_tests skip file.
dnl Adjust LDFLAGS to allow 64bit linkage on DARWIN
case $ARCH-$OPSYS in
amd64-darwin*)
AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit Darwin])
case $LDFLAGS in
*-m64*)
;;
*)
LDFLAGS="-m64 $LDFLAGS"
;;
esac
;;
*-darwin*)
case $LDFLAGS in
*-m32*)
;;
*)
LDFLAGS="-m32 $LDFLAGS"
;;
esac
;;
*)
if test X${enable_m64_build} = Xyes; then
AC_MSG_NOTICE([Adjusting LDFLAGS to use -m64])
case $LDFLAGS in
*-m64*)
;;
*)
LDFLAGS="-m64 $LDFLAGS"
;;
esac
fi;
if test X${enable_m32_build} = Xyes; then
AC_MSG_NOTICE([Adjusting LDFLAGS to use -m32]) ;
case $LDFLAGS in
*-m32*)
;;
*)
LDFLAGS="-m32 $LDFLAGS"
;;
esac ;
fi
;;
esac
AC_MSG_CHECKING(if VM has to be linked with Carbon framework)
case $ARCH-$OPSYS in
*-darwin*)
LIBCARBON="-framework Carbon -framework Cocoa"
AC_MSG_RESULT([yes])
;;
*)
LIBCARBON=
AC_MSG_RESULT([no])
;;
esac
AC_SUBST(LIBCARBON)
_search_path=/bin:/usr/bin:/usr/local/bin:$PATH
AC_PATH_PROG(RM, rm, false, $_search_path)
if test "$ac_cv_path_RM" = false; then
AC_MSG_ERROR([No 'rm' command found])
fi
AC_PATH_PROG(MKDIR, mkdir, false, $_search_path)
if test "$ac_cv_path_MKDIR" = false; then
AC_MSG_ERROR([No 'mkdir' command found])
fi
AC_PATH_PROG(CP, cp, false, $_search_path)
if test "$ac_cv_path_CP" = false; then
AC_MSG_ERROR([No 'cp' command found])
fi
_search_path=
# Remove old configuration information.
# Next line should be placed after AC_PATH_PROG(RM, ...), but before
# first output to CONN_INFO. So this is just the right place.
$RM -f "$ERL_TOP/erts/CONF_INFO"
dnl Check if we should/can build a sharing-preserving emulator
AC_MSG_CHECKING(if we are building a sharing-preserving emulator)
if test "$enable_sharing_preserving" = "yes"; then
AC_DEFINE(SHCOPY, [1],
[Define if building a sharing-preserving emulator])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
dnl some tests below will call this if we haven't already - and autoconf
dnl can't handle those tests being done conditionally at runtime
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_YACC
LM_PROG_PERL5
if test "$ac_cv_path_PERL" = false; then
AC_MSG_ERROR([Perl version 5 is required to build the emulator!])
fi
AC_PROG_LN_S
AC_CHECK_TOOL([AR], [ar], [false])
if test "$ac_cv_prog_AR" = false; then
AC_MSG_ERROR([No 'ar' command found in PATH])
fi
#
# Get programs needed for building the documentation
#
## Delete previous failed configure results
if test -f doc/CONF_INFO; then
$RM doc/CONF_INFO
fi
AC_CHECK_PROGS(XSLTPROC, xsltproc)
if test -z "$XSLTPROC"; then
echo "xsltproc" >> doc/CONF_INFO
AC_MSG_WARN([No 'xsltproc' command found: the documentation cannot be built])
fi
AC_CHECK_PROGS(FOP, fop)
if test -z "$FOP"; then
FOP="$ERL_TOP/make/fakefop"
echo "fop" >> doc/CONF_INFO
AC_MSG_WARN([No 'fop' command found: going to generate placeholder PDF files])
fi
AC_CHECK_PROGS(XMLLINT, xmllint)
if test -z "$XMLLINT"; then
echo "xmllint" >> doc/CONF_INFO
AC_MSG_WARN([No 'xmllint' command found: can't run the xmllint target for the documentation])
fi
dnl
dnl We can live with Solaris /usr/ucb/install
dnl
case $host in
*-*-solaris*|free_source)
if test -x /usr/ucb/install; then
INSTALL="/usr/ucb/install -c"
fi
;;
*)
;;
esac
AC_PROG_INSTALL
LM_PROG_INSTALL_DIR
case $host_os in
darwin*)
dnl Need to preserve modification time on archives;
dnl otherwise, ranlib has to be run on archives
dnl again after installation.
INSTALL_DATA="$INSTALL_DATA -p";;
*)
;;
esac
dnl
dnl Fix for Tilera install permissions
dnl
case $build in
*tile*)
INSTALL_PROGRAM="$INSTALL_PROGRAM -m755"
INSTALL_SCRIPT="$INSTALL_SCRIPT -m755"
;;
*)
;;
esac
dnl ----------------------------------------------------------------------
dnl Misc. things (some of them should go away)
dnl ----------------------------------------------------------------------
dnl
dnl An attempt to allow cross compiling. This is not the right way,
dnl nor does it work currently. Some makefiles still needs these
dnl variables, so we leave them in for now.
dnl
HCC='$(CC)' AC_SUBST(HCC)
HCFLAGS="" AC_SUBST(HCFLAGS)
HCFLAGS="$HCFLAGS -I${ERL_TOP}/erts/$host"
vxworks_reclaim="" AC_SUBST(vxworks_reclaim)
dnl We want to use $(CC) as linker for the emulator regardless of
dnl what the user say. This might not be the right way to do it, but
dnl for now that is the way we do it.
USER_LD=$LD
USER_LDFLAGS="$LDFLAGS"
LD='$(CC)'
case $host_os in
darwin*)
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
AC_TRY_LINK([],[],
[
LD_MAY_BE_WEAK=no
],
[
LD_MAY_BE_WEAK=yes
LDFLAGS="$saved_LDFLAGS"
]);;
*)
LD_MAY_BE_WEAK=no;;
esac
AC_SUBST(LD)
LDFLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
AC_SUBST(LDFLAG_RUNTIME_LIBRARY_PATH)
dnl Check for cygwin and object/exe files extension
dnl AC_CYGWIN is deprecated
AC_EXEEXT
AC_OBJEXT
dnl This is the os flavour, should be unix, ose, vxworks or win32
case $host in
win32)
ERLANG_OSTYPE=win32 ;;
*)
ERLANG_OSTYPE=unix ;;
esac
AC_SUBST(ERLANG_OSTYPE)
# Check how to export functions from the emulator executable, needed
# when dynamically loaded drivers are loaded (so that they can find
# emulator functions).
# OS'es with ELF executables using the GNU linker (Linux and recent *BSD,
# in rare cases Solaris) typically need '-Wl,-export-dynamic' (i.e. pass
# -export-dynamic to the linker - also known as -rdynamic and some other
# variants); some sysVr4 system(s) instead need(s) '-Wl,-Bexport'.
# AIX 4.x (perhaps only for x>=2) wants -Wl,-bexpall,-brtl and doesn't
# reliably return an error for others, thus we separate it out.
# Otherwise we assume that if the linker accepts the flag, it is needed.
AC_MSG_CHECKING(for extra flags needed to export symbols)
DEXPORT=""
case $host_os in
aix4*)
DEXPORT=-Wl,-bexpall,-brtl
;;
bsdi*)
DEXPORT="-rdynamic "
;;
win32)
DEXPORT=""
;;
*)
save_ldflags="$LDFLAGS"
LDFLAGS=-Wl,-export-dynamic
AC_TRY_LINK(,,[DEXPORT=-Wl,-export-dynamic], [
LDFLAGS=-Wl,-Bexport
AC_TRY_LINK(,,[DEXPORT=-Wl,-Bexport],
AC_MSG_RESULT(none))])
LDFLAGS="$save_ldflags"
;;
esac
AC_SUBST(DEXPORT)
case "x$DEXPORT" in
"x")
AC_MSG_RESULT([none]);;
*)
AC_MSG_RESULT([$DEXPORT]);;
esac
# Check for Solaris/ultrasparc /dev/perfmon interface
# (also needs gcc specific asm instructions)
case "${host}:${GCC}" in
sparc-*-solaris*:yes)
AC_DEFINE(HAVE_SOLARIS_SPARC_PERFMON,[1],
[define if you have the Solaris/ultrasparc /dev/perfmon interface])
;;
*)
;;
esac
dnl ----------------------------------------------------------------------
dnl Checks for libraries.
dnl ----------------------------------------------------------------------
AC_CHECK_LIB(m, sin)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(inet, main)
AC_CHECK_LIB(util, openpty)
dnl Try to find a thread library.
dnl
dnl ETHR_LIB_NAME, ETHR_LIBS, ETHR_X_LIBS, ETHR_THR_LIB_BASE and ETHR_DEFS
dnl are set by ERL_FIND_ETHR_LIB
ERL_FIND_ETHR_LIB
if test "X$ETHR_LIB_NAME" = "X"; then
AC_MSG_ERROR([cannot build emulator since no thread library was found])
fi
TYPES=opt
DIRTY_SCHEDULER_TEST=$enable_dirty_schedulers_test
AC_SUBST(DIRTY_SCHEDULER_TEST)
test $DIRTY_SCHEDULER_TEST != yes || {
test -f "$ERL_TOP/erts/CONF_INFO" || echo "" > "$ERL_TOP/erts/CONF_INFO"
cat >> $ERL_TOP/erts/CONF_INFO <<EOF
WARNING:
Dirty Scheduler Test has been enabled. This
feature is for debugging purposes only.
Poor performance as well as strange system
characteristics is expected!
EOF
}
test "X$smp_require_native_atomics" = "Xyes" &&
AC_DEFINE(ETHR_SMP_REQUIRE_NATIVE_IMPLS, 1, [Define if you want to enable check for native ethread implementations])
case "$ethr_have_native_atomics-$smp_require_native_atomics-$ethr_have_native_spinlock" in
yes-*)
if test "$ethr_native_atomic_implementation" = "gcc_sync"; then
test -f "$ERL_TOP/erts/CONF_INFO" ||
echo "" > "$ERL_TOP/erts/CONF_INFO"
cat >> $ERL_TOP/erts/CONF_INFO <<EOF
WARNING:
Only gcc's __sync_* builtins available for
atomic memory access. This will cause lots
of expensive and unnecessary memory barrier
instructions to be issued which will make
the performance of the runtime system
suffer. You are *strongly* advised to
upgrade to a gcc version that supports the
__atomic_* builtins (at least gcc version
4.7) or build with libatomic_ops. See the
"Atomic Memory Operations and the VM"
chapter of \$ERL_TOP/HOWTO/INSTALL.md for
more information.
EOF
fi
;;
no-yes-*)
AC_MSG_ERROR([No native atomic implementation found. See the \"Atomic Memory Operations and the VM\" chapter of \$ERL_TOP/HOWTO/INSTALL.md for more information.])
;;
no-no-yes)
test -f "$ERL_TOP/erts/CONF_INFO" ||
echo "" > "$ERL_TOP/erts/CONF_INFO"
cat >> $ERL_TOP/erts/CONF_INFO <<EOF
No native atomic implementation available.
Fallbacks implemented using spinlocks will be
used. Note that the performance of the SMP
runtime system will suffer immensely due to
this.
EOF
;;
no-no-no)
test -f "$ERL_TOP/erts/CONF_INFO" ||
echo "" > "$ERL_TOP/erts/CONF_INFO"
cat >> "$ERL_TOP/erts/CONF_INFO" <<EOF
No native atomic implementation, nor no native
spinlock implementation available. Fallbacks
implemented using mutexes will be used. Note
that the performance of the SMP runtime system
will suffer immensely due to this.
EOF
;;
esac
AC_SUBST(TYPES)
AC_CHECK_FUNCS([posix_fadvise closefrom])
AC_CHECK_HEADERS([linux/falloc.h])
dnl * Old glibcs have broken fallocate64(). Make sure not to use it.
AC_CACHE_CHECK([whether fallocate() works],i_cv_fallocate_works,[
AC_TRY_LINK([
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/falloc.h>
],
[
int fd = creat("conftest.temp", 0600);
fallocate(fd, FALLOC_FL_KEEP_SIZE,(off_t) 1024,(off_t) 1024);
], i_cv_fallocate_works=yes, i_cv_fallocate_works=no)
])
if test $i_cv_fallocate_works = yes; then
AC_DEFINE(HAVE_FALLOCATE, 1, Define if you have a working fallocate())
fi
dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
dnl * It may also be broken in AIX.
AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
AC_TRY_RUN([
#if !defined(__sun) && !defined(__sun__)
#define _XOPEN_SOURCE 600
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7))
possibly broken posix_fallocate
#endif
int main() {
int fd = creat("conftest.temp", 0600);
int ret;
if (-1 == fd) {
perror("creat()");
return 2;
}
ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
unlink("conftest.temp");
return ret;
}
], [
i_cv_posix_fallocate_works=yes
], [
i_cv_posix_fallocate_works=no
], [
i_cv_posix_fallocate_works=no
])
])
if test $i_cv_posix_fallocate_works = yes; then
AC_DEFINE(HAVE_POSIX_FALLOCATE,, Define if you have a working posix_fallocate())
fi
#
# EMU_THR_LIB_NAME, EMU_THR_LIBS, EMU_THR_X_LIBS, and EMU_THR_DEFS is
# used by the emulator, and can (but should not) be used by applications
# that only require thread support when the emulator has thread support.
# Other applications should use ETHR_LIB_NAME, ETHR_LIBS, ETHR_X_LIBS,
# and ETHR_DEFS.
#
EMU_THR_LIB_NAME=
EMU_THR_X_LIBS=
EMU_THR_LIBS=
EMU_THR_DEFS=
# Threads enabled for emulator
EMU_THR_LIB_NAME=$ETHR_LIB_NAME
EMU_THR_X_LIBS=$ETHR_X_LIBS
EMU_THR_LIBS=$ETHR_LIBS
EMU_THR_DEFS=$ETHR_DEFS
ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS threads"
AC_MSG_CHECKING(whether lock checking should be enabled)
AC_MSG_RESULT($enable_lock_check)
if test "x$enable_lock_check" != "xno"; then
EMU_THR_DEFS="$EMU_THR_DEFS -DERTS_ENABLE_LOCK_CHECK"
fi
AC_MSG_CHECKING(whether lock counters should be enabled)
AC_MSG_RESULT($enable_lock_count)
if test "x$enable_lock_count" != "xno"; then
TYPES="$TYPES lcnt"
fi
case $host_os in
linux*|*gnu*)
AC_MSG_CHECKING([whether dlopen() needs to be called before first call to dlerror()])
if test "x$ETHR_THR_LIB_BASE_TYPE" != "xposix_nptl"; then
AC_DEFINE(ERTS_NEED_DLOPEN_BEFORE_DLERROR,[1],
[Define if dlopen() needs to be called before first call to dlerror()])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
;;
*)
;;
esac
# Remove -D_WIN32_WINNT*, -DWINVER* and -D_GNU_SOURCE from EMU_THR_DEFS
# (defined in CFLAGS). Note that we want to keep these flags
# in ETHR_DEFS, but not in EMU_THR_DEFS.
new_emu_thr_defs=
for thr_def in $EMU_THR_DEFS; do
case $thr_def in
-D_GNU_SOURCE*|-D_WIN32_WINNT*|-DWINVER*)
;;
*)
new_emu_thr_defs="$new_emu_thr_defs $thr_def"
;;
esac
done
EMU_THR_DEFS=$new_emu_thr_defs
AC_SUBST(EMU_THR_LIB_NAME)
AC_SUBST(EMU_THR_X_LIBS)
AC_SUBST(EMU_THR_LIBS)
AC_SUBST(EMU_THR_DEFS)
if test "x$enable_lock_check" = "xno"; then
EMU_LOCK_CHECKING=no
else
EMU_LOCK_CHECKING=yes
fi
AC_SUBST(EMU_LOCK_CHECKING)
ERL_INTERNAL_LIBS
dnl THR_LIBS and THR_DEFS are only used by odbc
THR_LIBS=$ETHR_X_LIBS
THR_DEFS=$ETHR_DEFS
AC_SUBST(THR_LIBS)
AC_SUBST(THR_DEFS)
dnl ----------------------------------------------------------------------
dnl Try to figure out where to get the termcap functions from.
dnl We use tgetent(), tgetflag(), tgetnum(), tgetstr() and tputs()
dnl ----------------------------------------------------------------------
TERMCAP_LIB=
if test "x$with_termcap" != "xno" &&
test "X$host" != "Xwin32"; then
# try these libs
termcap_libs="tinfo ncurses curses termcap termlib"
for termcap_lib in $termcap_libs; do
AC_CHECK_LIB($termcap_lib, tgetent, TERMCAP_LIB="-l$termcap_lib")
if test "x$TERMCAP_LIB" != "x"; then
break
fi
done
if test "x$TERMCAP_LIB" = "x"; then
AC_MSG_ERROR([No curses library functions found])
fi
fi
AC_SUBST(TERMCAP_LIB)
if test "x$TERMCAP_LIB" != "x"; then
AC_DEFINE(HAVE_TERMCAP, 1, [Define if termcap functions exists])
fi
if test "X$host" != "Xwin32"; then
AC_MSG_CHECKING(for wcwidth)
AC_TRY_LINK([#include <wchar.h>], [wcwidth(0);],
have_wcwidth=yes, have_wcwidth=no)
if test $have_wcwidth = yes; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_WCWIDTH, [1],
[Define to 1 if you have a `wcwidth' function.])
fi
fi
dnl -------------
dnl zlib
dnl -------------
AC_ARG_ENABLE(builtin-zlib,
AS_HELP_STRING([--enable-builtin-zlib],
[force use of our own built-in zlib]),
[ case "$enableval" in
no) enable_builtin_zlib=no ;;
*) enable_builtin_zlib=yes ;;
esac ], enable_builtin_zlib=no)
Z_LIB=
if test "x$enable_builtin_zlib" = "xyes"; then
AC_DEFINE(HAVE_ZLIB_INFLATEGETDICTIONARY, 1,
[Define if your zlib version defines inflateGetDictionary.])
AC_MSG_NOTICE([Using our own built-in zlib source])
else
AC_MSG_CHECKING(for zlib 1.2.5 or higher)
zlib_save_LIBS=$LIBS
LIBS="-lz $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include "zlib.h"
]],[[
#if ZLIB_VERNUM >= 0x1250
Bytef s[1];
s[0] = 0;
(void) adler32((uLong)0, s, 1);
#else
#error "No zlib 1.2.5 or higher found"
error
#endif
]])],
[
Z_LIB="-lz"
AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if you have the `z' library (-lz).])
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
])
if test "$Z_LIB" != ""; then
AC_MSG_CHECKING(for zlib inflateGetDictionary presence)
AC_SEARCH_LIBS(inflateGetDictionary, [z],
AC_DEFINE(HAVE_ZLIB_INFLATEGETDICTIONARY, 1,
[Define if your zlib version defines inflateGetDictionary.]))
fi
LIBS=$zlib_save_LIBS
fi
AC_SUBST(Z_LIB)
dnl
dnl This test kindly borrowed from Tcl
dnl
#--------------------------------------------------------------------
# Check for the existence of the -lsocket and -lnsl libraries.
# The order here is important, so that they end up in the right
# order in the command line generated by make. Here are some
# special considerations:
# 1. Use "connect" and "accept" to check for -lsocket, and
# "gethostbyname" to check for -lnsl.
# 2. Use each function name only once: can't redo a check because
# autoconf caches the results of the last check and won't redo it.
# 3. Use -lnsl and -lsocket only if they supply procedures that
# aren't already present in the normal libraries. This is because
# IRIX 5.2 has libraries, but they aren't needed and they're
# bogus: they goof up name resolution if used.
# 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
# To get around this problem, check for both libraries together
# if -lsocket doesn't work by itself.
#--------------------------------------------------------------------
tk_oldLibs=$LIBS
erl_checkBoth=0
SOCKET_LIBS=""
AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1)
if test "$erl_checkSocket" = 1; then
AC_CHECK_LIB(socket, main, SOCKET_LIBS="-lsocket", erl_checkBoth=1)
fi
if test "$erl_checkBoth" = 1; then
LIBS="$LIBS -lsocket -lnsl"
AC_CHECK_FUNC(accept, SOCKET_LIBS="-lsocket -lnsl")
fi
LIBS="$tk_oldLibs $SOCKET_LIBS"
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [SOCKET_LIBS="$SOCKET_LIBS -lnsl"]))
AC_CHECK_FUNC(gethostbyname_r,have_gethostbyname_r=yes)
LIBS="$tk_oldLibs $SOCKET_LIBS"
AC_SUBST(SOCKET_LIBS)
dnl
dnl These gethostbyname thingies use old style AC_DEFINE for BC with ancient
dnl autoconf...
dnl
if test "$have_gethostbyname_r" = yes; then
# OK, so we have gethostbyname_r() - but do we know how to call it...?
# (if not, HAVE_GETHOSTBYNAME_R will not be defined at all)
case $host_os in
solaris2*)
AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_SOLARIS,
[Define to flavour of gethostbyname_r])
;;
aix4*)
# AIX version also needs "struct hostent_data" defn
AC_TRY_COMPILE([#include <netdb.h>],
[struct hostent_data hd;],
AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_AIX,
[Define to flavour of gethostbyname_r]))
;;
*)
AC_EGREP_CPP(^yes$,[
#include <stdio.h>
#ifdef __GLIBC__
yes
#endif
], AC_DEFINE(HAVE_GETHOSTBYNAME_R, GHBN_R_GLIBC,
[Define to flavour of gethostbyname_r]))
;;
esac
fi
AC_MSG_CHECKING(for working posix_openpt implementation)
AC_TRY_LINK([
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#include <fcntl.h>
],
[
int mfd = posix_openpt(O_RDWR);
ptsname(mfd);
grantpt(mfd);
unlockpt(mfd);
return mfd;
], working_posix_openpt=yes, working_posix_openpt=no)
if test "X$working_posix_openpt" = "Xyes"; then
AC_DEFINE(HAVE_WORKING_POSIX_OPENPT, [1],
[Define if you have a working posix_openpt implementation])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl Check for usage of sockaddr_in in netdb.h
dnl somewhat ugly check, I check for presence of the string and that
dnl compilation works. If either fails I assume it's not needed.
dnl Seems only to be needed on a patched version of solaris2.5.1, with
dnl netdb.h version 1.18.
AC_MSG_CHECKING([if netdb.h requires netinet/in.h to be previously included])
AC_EGREP_CPP(sockaddr_in,
[#include <netdb.h>],
AC_TRY_COMPILE([#include <netinet/in.h>
#include <netdb.h>],
[return 0;],
need_in_h=yes,
need_in_h=no),
need_in_h=no)
if test $need_in_h = yes; then
AC_DEFINE(NETDB_H_NEEDS_IN_H,[1],
[Define if netdb.h needs struct sockaddr_in ans in.h CAN be included before])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl Check for type socklen_t
dnl
AC_MSG_CHECKING([for socklen_t])
AC_TRY_COMPILE( [#include <sys/socket.h>],
[socklen_t test;],
have_socklen_t=yes,
have_socklen_t=no),
if test $have_socklen_t = yes; then
AC_DEFINE(HAVE_SOCKLEN_T,[1],[Define if we have socklen_t])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl h_errno isn't always declared in netdb.h, and with some definitions
dnl (e.g. function call for thread-safe) a simple 'extern int' may conflict
dnl (we do assume that h_errno exists at all...)
AC_CACHE_CHECK([for h_errno declaration in netdb.h],
ac_cv_decl_h_errno,
[AC_TRY_COMPILE([#include <netdb.h>], [int err = h_errno;],
ac_cv_decl_h_errno=yes, ac_cv_decl_h_errno=no)])
if test $ac_cv_decl_h_errno = yes; then
AC_DEFINE(H_ERRNO_DECLARED,[1],
[define if h_errno is declared (in some way) in a system header file])
fi
dnl ----------------------------------------------------------------------
dnl Checks for header files.
dnl ----------------------------------------------------------------------
dnl We sometimes need EMU_THR_DEFS in order to find certain headers.
saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $EMU_THR_DEFS"
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
dnl Interactive UX needs <net/errno.h> for socket related error codes.
dnl Some Linuxes needs <sys/socketio.h> instead of <sys/sockio.h>
dnl
AC_CHECK_HEADERS(fcntl.h limits.h unistd.h syslog.h dlfcn.h ieeefp.h \
sys/types.h sys/stropts.h sys/sysctl.h \
sys/ioctl.h sys/time.h sys/uio.h \
sys/socket.h sys/sockio.h sys/socketio.h \
net/errno.h malloc.h arpa/nameser.h libdlpi.h \
pty.h util.h libutil.h utmp.h langinfo.h poll.h sdkddkver.h)
AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr], [], [],
[#ifdef __WIN32__
#else
#ifdef VXWORKS
#else
#include <net/if.h>
#endif
#endif
])
AC_CHECK_MEMBERS([struct ifreq.ifr_enaddr], [], [],
[#ifdef __WIN32__
#else
#ifdef VXWORKS
#else
#include <net/if.h>
#endif
#endif
])
dnl ----------------------------------------------------------------------
dnl Check the availability of systemd
dnl ----------------------------------------------------------------------
if test x"$enable_systemd" != x"no"; then
systemd_daemon_save_LIBS=$LIBS
LIBS=
AC_SEARCH_LIBS(sd_listen_fds,[systemd systemd-daemon],
[have_sd_listen_fds=yes],[have_sd_listen_fds=no],$systemd_daemon_save_LIBS)
AC_SEARCH_LIBS(sd_notify,[systemd systemd-daemon],
[have_sd_notify=yes],[have_sd_notify=no],$systemd_daemon_save_LIBS)
AC_CHECK_HEADERS(systemd/sd-daemon.h,
[have_systemd_sd_daemon_h=yes],[have_systemd_sd_daemon_h=no])
if test x"$have_sd_listen_fds" = x"yes" && \
test x"$have_sd_notify" = x"yes" && \
test x"$have_systemd_sd_daemon_h" = x"yes"; then
AC_DEFINE([HAVE_SYSTEMD_DAEMON],[1],[Define if you have systemd daemon])
SYSTEMD_DAEMON_LIBS=$LIBS
elif test x"$enable_systemd" = x"yes"; then
AC_MSG_FAILURE([--enable-systemd was given, but test for systemd failed])
fi
LIBS=$systemd_daemon_save_LIBS
fi
AC_SUBST(SYSTEMD_DAEMON_LIBS)
dnl ----------------------------------------------------------------------
dnl Check the availability for libdlpi
dnl ----------------------------------------------------------------------
AC_CHECK_LIB(dlpi, dlpi_open)
if test x"$ac_cv_lib_dlpi_dlpi_open" = x"no"; then
unset -v ac_cv_lib_dlpi_dlpi_open
dnl Try again now with -L/lib (or ditto 64) as argument to linker since
dnl gcc makes /usr/ccs/bin/ld ignore the crle configured linker default paths
dnl typically causing dlpi not being found on Solaris et.al
save_ldflags="$LDFLAGS"
try_dlpi_lib=/lib
if test x"$ac_cv_sizeof_void_p" = x"8"; then
if test -d /lib64; then
try_dlpi_lib=/lib64
elif test -d /lib/64; then
try_dlpi_lib=/lib/64
fi
fi
if test ! -f "$try_dlpi_lib/libdlpi.so" && \
test -f "$try_dlpi_lib/libdlpi.so.1"
then
dnl It looks like there is a missing symlink
dnl - let's be helpful and notify the user
dnl NOTE this help is far from perfect e.g if there would be no
dnl *.so.1 but a *.so.1.123 or *.so.2 this will be no help
AC_MSG_ERROR(
[Your OS installation is missing a symbolic link.
Maybe it lacks some development package(s)...
It can anyhow be fixed with the following command:
# ln -s libdlpi.so.1 $try_dlpi_lib/libdlpi.so
])
fi
LDFLAGS="-L$try_dlpi_lib -R$try_dlpi_lib $LDFLAGS"
unset -v try_dlpi_lib
AC_MSG_NOTICE([Extending the search to include /lib])
AC_CHECK_LIB(dlpi, dlpi_open)
if test x"$ac_cv_lib_dlpi_dlpi_open" = x"no"; then
LDFLAGS="$save_ldflags"
fi
unset -v save_ldflags
fi
AC_CHECK_HEADER(sys/resource.h,
[AC_DEFINE(HAVE_SYS_RESOURCE_H, 1,
[Define to 1 if you have the <sys/resource.h> header file])
AC_CHECK_DECLS([getrlimit, setrlimit, RLIMIT_STACK],
[],[],
[#include <sys/resource.h>])],
[],[])
AC_CHECK_FUNCS([getrusage])
dnl Check if we have kernel poll support
have_kernel_poll=no
AC_CHECK_HEADER(sys/event.h, have_kernel_poll=kqueue)
AC_CHECK_HEADER(sys/epoll.h, have_kernel_poll=epoll)
AC_CHECK_HEADER(sys/devpoll.h, have_kernel_poll=/dev/poll)
dnl Check if we have timerfds to be used for high accuracy
dnl epoll_wait timeouts
AC_CHECK_HEADERS([sys/timerfd.h])
dnl Check for kernel SCTP support
AC_SUBST(LIBSCTP)
if test "x$enable_sctp" != "xno" ; then
AC_CHECK_HEADER(netinet/sctp.h,
[LIBSCTP=libsctp.so.1
AC_DEFINE(HAVE_SCTP_H, [1],
[Define to 1 if you have the <netinet/sctp.h> header file])],
[],
[#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
fi
if test x"$ac_cv_header_netinet_sctp_h" = x"yes"; then
AS_IF([test "x$enable_sctp" = "xlib"],
AC_CHECK_LIB(sctp, sctp_bindx))
AC_CHECK_FUNCS([sctp_bindx sctp_peeloff sctp_getladdrs sctp_freeladdrs sctp_getpaddrs sctp_freepaddrs])
AC_CHECK_DECLS([SCTP_UNORDERED, SCTP_ADDR_OVER, SCTP_ABORT,
SCTP_EOF, SCTP_SENDALL, SCTP_ADDR_CONFIRMED,
SCTP_DELAYED_ACK_TIME,
SCTP_EMPTY, SCTP_UNCONFIRMED,
SCTP_CLOSED, SCTPS_IDLE,
SCTP_BOUND, SCTPS_BOUND,
SCTP_LISTEN, SCTPS_LISTEN,
SCTP_COOKIE_WAIT, SCTPS_COOKIE_WAIT,
SCTP_COOKIE_ECHOED, SCTPS_COOKIE_ECHOED,
SCTP_ESTABLISHED, SCTPS_ESTABLISHED,
SCTP_SHUTDOWN_PENDING, SCTPS_SHUTDOWN_PENDING,
SCTP_SHUTDOWN_SENT, SCTPS_SHUTDOWN_SENT,
SCTP_SHUTDOWN_RECEIVED, SCTPS_SHUTDOWN_RECEIVED,
SCTP_SHUTDOWN_ACK_SENT, SCTPS_SHUTDOWN_ACK_SENT], [], [],
[#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <netinet/sctp.h>
])
AC_CHECK_MEMBERS([struct sctp_paddrparams.spp_pathmtu,
struct sctp_paddrparams.spp_sackdelay,
struct sctp_paddrparams.spp_flags,
struct sctp_remote_error.sre_data,
struct sctp_send_failed.ssf_data], [], [],
[#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <netinet/sctp.h>
])
fi
dnl Check for setns
AC_CHECK_HEADERS(sched.h setns.h)
AC_CHECK_FUNCS([setns])
HAVE_VALGRIND=no
AC_CHECK_HEADER(valgrind/valgrind.h, HAVE_VALGRIND=yes)
AC_SUBST(HAVE_VALGRIND)
LM_DECL_SO_BSDCOMPAT
LM_DECL_INADDR_LOOPBACK
LM_DECL_SYS_ERRLIST
AC_CACHE_CHECK([if windows.h includes winsock2.h],
erts_cv_windows_h_includes_winsock2_h,
AC_TRY_COMPILE([#include <windows.h>
],
[#ifndef _WINSOCK2API_
#error winsock2.h not included
#endif
int i = 1;
],
erts_cv_windows_h_includes_winsock2_h=yes,
erts_cv_windows_h_includes_winsock2_h=no))
if test $erts_cv_windows_h_includes_winsock2_h = yes; then
AC_DEFINE(WINDOWS_H_INCLUDES_WINSOCK2_H, 1, \
[Define if windows.h includes winsock2.h])
fi
dnl restore CPPFLAGS
CPPFLAGS=$saved_cppflags
dnl ----------------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ----------------------------------------------------------------------
AC_C_CONST
AC_TYPE_SIGNAL
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
LM_STRUCT_SOCKADDR_SA_LEN
LM_STRUCT_EXCEPTION
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(time_t)
BITS64=
if test $ac_cv_sizeof_void_p = 8; then
BITS64=yes
fi
AC_SUBST(BITS64)
AC_MSG_CHECKING([for C compiler 'restrict' support])
restrict_keyword=""
for x in restrict __restrict; do
AC_TRY_COMPILE([int * $x foo(int * $x arg);
int * $x foo(int * $x arg)
{ int * $x var=arg; return var;}
],[],
[restrict_keyword=$x],[])
if test "x$restrict_keyword" != "x"; then
break
fi
done
AC_DEFINE_UNQUOTED(ERTS_RESTRICT,[$restrict_keyword],[Type qualifier restrict])
if test "x$restrict_keyword" != "x"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
if test "x$ac_compiler_gnu" = "xyes"; then
AC_MSG_CHECKING([if we should add -fno-tree-copyrename to CFLAGS for computed gotos to work properly])
AC_TRY_COMPILE([],[
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
;
#else
#error old and ok
#endif
],
no_tree_copyrename=yes,
no_tree_copyrename=no)
if test "x$no_tree_copyrename" = "xyes"; then
CFLAGS="$CFLAGS -fno-tree-copyrename"
AC_MSG_RESULT(yes, adjusting CFLAGS)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for broken gcc-4.3.0 compiler])
AC_TRY_RUN([
/* pr36339.c */
extern void abort (void);
typedef unsigned long my_uintptr_t;
int check_a(my_uintptr_t tagged_ptr);
int __attribute__((noinline)) try_a(my_uintptr_t x)
{
my_uintptr_t heap[2];
my_uintptr_t *hp = heap;
hp[0] = x;
hp[1] = 0;
return check_a((my_uintptr_t)(void*)((char*)hp + 1));
}
int __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr)
{
my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1);
if (hp[0] == 42 && hp[1] == 0)
return 0;
return -1;
}
int main(void)
{
if (try_a(42) < 0)
abort ();
return 0;
}
], gcc_4_3_0_bug=no, gcc_4_3_0_bug=yes, gcc_4_3_0_bug=cross)
case $gcc_4_3_0_bug in
yes|no)
gcc_4_3_0_bug_result=$gcc_4_3_0_bug;;
cross)
gcc_dumped_vsn=`$CC -dumpversion 2>/dev/null`
case gcc-$gcc_dumped_vsn in
gcc-4.3.0) gcc_4_3_0_bug=yes;;
*) gcc_4_3_0_bug=no;;
esac
gcc_4_3_0_bug_result="$gcc_4_3_0_bug; could not run test since cross compiling, checked version number ($gcc_dumped_vsn) instead";;
esac
AC_MSG_RESULT([$gcc_4_3_0_bug_result])
if test $gcc_4_3_0_bug = yes; then
AC_MSG_ERROR([This gcc miscompiles the Erlang runtime system; please use a different version])
fi
fi
case X$erl_xcomp_bigendian in
X) ;;
Xyes|Xno) ac_cv_c_bigendian=$erl_xcomp_bigendian;;
*) AC_MSG_ERROR([Bad erl_xcomp_bigendian value: $erl_xcomp_bigendian]);;
esac
AC_C_BIGENDIAN(
[
AC_DEFINE([WORDS_BIGENDIAN], [1], [Define if big-endian])
AC_DEFINE([ERTS_ENDIANNESS], [1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown])
],
[
AC_DEFINE([ERTS_ENDIANNESS], [-1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown])
],
[
case "$erl_xcomp_bigendian" in
yes)
AC_DEFINE([ERTS_ENDIANNESS], [1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);;
no)
AC_DEFINE([ERTS_ENDIANNESS], [-1], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);;
*)
AC_DEFINE([ERTS_ENDIANNESS], [0], [Define > 0 if big-endian < 0 if little-endian, or 0 if unknown]);;
esac
])
AC_C_DOUBLE_MIDDLE_ENDIAN
dnl fdatasync syscall (Unix only)
AC_CHECK_FUNCS([fdatasync])
dnl Find which C libraries are required to use fdatasync
dnl TODO: Remove check once SunOS >= 5.11 is required by erts.
dnl fdatasync requires linking against -lrt on SunOS <= 5.10.
dnl OpenSolaris 2009.06 is SunOS 5.11 and does not require -lrt.
AC_SEARCH_LIBS(fdatasync, [rt])
dnl sendfile syscall
case $host_os in
linux*|freebsd*|dragonfly*|darwin*)
AC_CHECK_FUNCS([sendfile])
;;
solaris*)
AC_SEARCH_LIBS(sendfilev, sendfile,
AC_DEFINE([HAVE_SENDFILEV],[1],
[Define to 1 if you have the `sendfilev' function.]))
;;
win32)
LIBS="$LIBS -lmswsock"
;;
*)
;;
esac
dnl ----------------------------------------------------------------------
dnl Checks for library functions.
dnl ----------------------------------------------------------------------
dnl We may need the thread library and thread flags in order to find right stuff
saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $EMU_THR_DEFS"
saved_libs=$LIBS
LIBS="$LIBS $EMU_THR_X_LIBS"
dnl Check if we have these, in which case we'll try to build
dnl inet_gethost with ipv6 support.
AC_CHECK_HEADERS(windows.h)
AC_CHECK_HEADERS(winsock2.h)
AC_CHECK_HEADERS(ws2tcpip.h,[],[],[
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
])
dnl AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes, have_getaddrinfo=no)
AC_MSG_CHECKING(for getaddrinfo)
AC_TRY_LINK([
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifndef __WIN32__
#include <sys/socket.h>
#include <netdb.h>
#endif
],
[
getaddrinfo("","",NULL,NULL);
],have_getaddrinfo=yes, have_getaddrinfo=no)
if test $have_getaddrinfo = yes; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether getaddrinfo accepts enough flags])
AC_TRY_LINK([
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifndef __WIN32__
#include <sys/socket.h>
#include <netdb.h>
#endif
],
[
struct addrinfo hints, *ai;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_INET6;
if (getaddrinfo("::", NULL, &hints, &ai) == 0) {
freeaddrinfo(ai);
exit(0);
} else {
exit(1);
}
],, have_getaddrinfo=no)
AC_MSG_RESULT($have_getaddrinfo)
case $have_getaddrinfo in
yes)
AC_DEFINE(HAVE_GETADDRINFO, [1],
[Define to 1 if you have a good `getaddrinfo' function.]);;
*) ;;
esac
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING(for getnameinfo)
AC_TRY_LINK([
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifndef __WIN32__
#include <sys/socket.h>
#include <netdb.h>
#endif
],
[
getnameinfo(NULL,0,NULL,0,NULL,0,0);
],have_getnameinfo=yes, have_getnameinfo=no)
if test $have_getnameinfo = yes; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_GETNAMEINFO, [1],
[Define to 1 if you have a good `getnameinfo' function.])
else
AC_MSG_RESULT([no])
fi
AC_CHECK_FUNCS([getipnodebyname getipnodebyaddr gethostbyname2])
AC_CHECK_FUNCS([ieee_handler fpsetmask finite isnan isinf res_gethostbyname dlopen \
pread pwrite memmove strerror strerror_r strncasecmp \
gethrtime localtime_r gmtime_r inet_pton mprotect \
mmap mremap memcpy mallopt sbrk _sbrk __sbrk brk _brk __brk \
flockfile fstat strlcpy strlcat setsid posix2time time2posix \
setlocale nl_langinfo poll mlockall ppoll])
AC_MSG_CHECKING([for isfinite])
AC_TRY_LINK([#include <math.h>],
[isfinite(0);], have_isfinite=yes, have_isfinite=no),
if test $have_isfinite = yes; then
AC_DEFINE(HAVE_ISFINITE,[1],
[Define to 1 if you have the `isfinite' function.])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
case X$erl_xcomp_posix_memalign in
Xno) ;;
Xyes) have_posix_memalign=yes ;;
*)
AC_CHECK_FUNC(
[posix_memalign],
[if test "$cross_compiling" != yes; then
AC_TRY_RUN([
#include <stdlib.h>
int main(void) {
void *ptr = NULL;
int error;
size_t alignment = 0x40000, size = 0x20028;
if ((error = posix_memalign(&ptr, alignment, size)) != 0 || ptr == NULL)
return error;
return 0;
}
],have_posix_memalign=yes
)
else
have_posix_memalign=yes
fi]);;
esac
if test "$have_posix_memalign" = "yes"; then
AC_DEFINE(HAVE_POSIX_MEMALIGN,[1],
[Define to 1 if you have the `posix_memalign' function.])
fi
dnl writev on OS X snow leopard is broken for files > 4GB
case $host_os in
darwin10.8.0)
AC_MSG_CHECKING([for writev])
AC_MSG_RESULT(no, not stable on OS X Snow Leopard) ;;
*)
AC_CHECK_FUNCS([writev]) ;;
esac
AC_CHECK_DECLS([posix2time, time2posix],,,[#include <time.h>])
disable_vfork=false
AC_MSG_CHECKING([if vfork is to be disabled (for HPPA)])
case $host_alias in
hppa*)
AC_MSG_RESULT(yes)
disable_vfork=true;;
*)
AC_MSG_RESULT(no);;
esac
if test "x$EMU_THR_LIB_NAME" != "x"; then
AC_MSG_CHECKING([if vfork is known to hang multithreaded applications])
case $host_os in
osf*)
AC_MSG_RESULT(yes)
disable_vfork=true;;
*)
AC_MSG_RESULT(no);;
esac
fi
if test $disable_vfork = false; then
AC_FUNC_VFORK
if test $ac_cv_func_vfork_works = no; then
disable_vfork=true
fi
fi
if test $disable_vfork = true; then
AC_DEFINE(DISABLE_VFORK, 1, [Define if you want to disable vfork.])
fi
AC_FUNC_VPRINTF
dnl The AC_DEFINEs are necessary for autoheader to work. :-(
dnl for gzio
LM_CHECK_FUNC_DECL(fread, [extern int fread();],,
AC_DEFINE(HAVE_CONFLICTING_FREAD_DECLARATION,[1],[Define if you have a decl of fread that conflicts with int fread]))
dnl Checking with TRY_LINK since putc_unlocked might be (probably is) a macro
AC_CACHE_CHECK([for putc_unlocked],
erts_cv_putc_unlocked,
AC_TRY_LINK([#include <stdio.h>],
[int res = putc_unlocked('x',stdout);],
erts_cv_putc_unlocked=yes,
erts_cv_putc_unlocked=no))
if test $erts_cv_putc_unlocked = yes; then
AC_DEFINE(HAVE_PUTC_UNLOCKED, 1, [Define if you have putc_unlocked])
fi
dnl Checking with TRY_LINK since fwrite_unlocked might be a macro
AC_CACHE_CHECK([for fwrite_unlocked],
erts_cv_fwrite_unlocked,
AC_TRY_LINK([#include <stdio.h>],
[size_t res = fwrite_unlocked(NULL,sizeof(char),0,stdout);],
erts_cv_fwrite_unlocked=yes,
erts_cv_fwrite_unlocked=no))
if test $erts_cv_fwrite_unlocked = yes; then
AC_DEFINE(HAVE_FWRITE_UNLOCKED, 1, [Define if you have fwrite_unlocked])
fi
dnl Need by run_erl.
AC_CHECK_FUNCS([openpty])
AC_CHECK_HEADERS(net/if_dl.h ifaddrs.h netpacket/packet.h sys/un.h)
AC_CHECK_FUNCS([getifaddrs])
dnl Checks for variables in6addr_any and in6addr_loopback,
dnl
dnl They normally declared by netinet/in.h, according to POSIX,
dnl but not on Windows 7 (Windows SDK 7.1). I would have liked
dnl to just write AC_CHECK_DECL([in6addr_any], ...) but if doing so,
dnl the configure check fails erroneously on Linux with the error
dnl "cannot convert to a pointer type", on a line looking like
dnl "char *p = (char *) in6addr_any;", so work around that
dnl with some more code.
AC_CACHE_CHECK(
[whether in6addr_any is declared],
[erts_cv_have_in6addr_any],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
]],
[[printf("%d", in6addr_any.s6_addr[16]);]]
)],
[erts_cv_have_in6addr_any=yes],
[erts_cv_have_in6addr_any=no]
)]
)
case "$erts_cv_have_in6addr_any" in
yes)
AC_DEFINE([HAVE_IN6ADDR_ANY], [1],
[Define to 1 if you have the variable in6addr_any declared.])
esac
AC_CACHE_CHECK(
[whether in6addr_loopback is declared],
[erts_cv_have_in6addr_loopback],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
]],
[[printf("%d", in6addr_loopback.s6_addr[16]);]]
)],
[erts_cv_have_in6addr_loopback=yes],
[erts_cv_have_in6addr_loopback=no]
)]
)
case "$erts_cv_have_in6addr_loopback" in
yes)
AC_DEFINE([HAVE_IN6ADDR_LOOPBACK], [1],
[Define to 1 if you have the variable in6addr_loopback declared.])
esac
AC_CHECK_DECLS([IN6ADDR_ANY_INIT, IN6ADDR_LOOPBACK_INIT, IPV6_V6ONLY], [], [],
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])
dnl ----------------------------------------------------------------------
dnl Checks for features/quirks in the system that affects Erlang.
dnl ----------------------------------------------------------------------
AC_MSG_CHECKING([for sched_getaffinity/sched_setaffinity])
AC_TRY_LINK([#include <sched.h>],
[
#ifndef CPU_SETSIZE
#error no CPU_SETSIZE
#endif
int res;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(1, &cpuset);
res = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
res = sched_getaffinity(0, sizeof(cpu_set_t), &cpuset);
res = CPU_ISSET(1, &cpuset);
CPU_CLR(1, &cpuset);
],
sched_xetaffinity=yes,
sched_xetaffinity=no)
AC_MSG_RESULT([$sched_xetaffinity])
if test $sched_xetaffinity = yes; then
AC_DEFINE(HAVE_SCHED_xETAFFINITY, 1, [Define if you have sched_getaffinity/sched_setaffinity])
fi
AC_MSG_CHECKING([for pset functionality])
AC_TRY_LINK([#include <sys/pset.h>],
[
int res;
psetid_t id = PS_MYID;
int type = PS_PRIVATE;
uint_t numcpus = 1024;
processorid_t cpulist[1024];
res = pset_info(id, &type, &numcpus, &cpulist[0]);
],
pset_functionality=yes,
pset_functionality=no)
AC_MSG_RESULT([$pset_functionality])
if test $pset_functionality = yes; then
AC_DEFINE(HAVE_PSET, 1, [Define if you have pset functionality])
fi
AC_MSG_CHECKING([for processor_bind functionality])
AC_TRY_LINK([
#include <sys/types.h>
#include <sys/processor.h>
#include <sys/procset.h>
],
[
int res = processor_bind(P_LWPID, P_MYID, PBIND_NONE, NULL);
],
processor_bind_functionality=yes,
processor_bind_functionality=no)
AC_MSG_RESULT([$processor_bind_functionality])
if test $processor_bind_functionality = yes; then
AC_DEFINE(HAVE_PROCESSOR_BIND, 1, [Define if you have processor_bind functionality])
fi
AC_MSG_CHECKING([for cpuset_getaffinity/cpuset_setaffinity])
AC_TRY_LINK([
#include <sys/param.h>
#include <sys/cpuset.h>
],
[
int res;
cpuset_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(1, &cpuset);
res = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &cpuset);
res = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), &cpuset);
res = CPU_ISSET(1, &cpuset);
CPU_CLR(1, &cpuset);
],
cpuset_xetaffinity=yes,
cpuset_xetaffinity=no)
AC_MSG_RESULT([$cpuset_xetaffinity])
if test $cpuset_xetaffinity = yes; then
AC_DEFINE(HAVE_CPUSET_xETAFFINITY, 1, [Define if you have cpuset_getaffinity/cpuset_setaffinity])
fi
AC_CACHE_CHECK([for 'end' symbol],
erts_cv_have_end_symbol,
[AC_TRY_LINK([],
[extern char end; {char *x = &end; *x= 0;}],
erts_cv_have_end_symbol=yes,
erts_cv_have_end_symbol=no)])
if test $erts_cv_have_end_symbol = yes; then
AC_DEFINE(HAVE_END_SYMBOL, 1, [Define if you have the 'end' symbol])
fi
AC_CACHE_CHECK([for '_end' symbol],
erts_cv_have__end_symbol,
[AC_TRY_LINK([],
[extern char _end; {char *x = &_end; *x= 0;}],
erts_cv_have__end_symbol=yes,
erts_cv_have__end_symbol=no)])
if test $erts_cv_have__end_symbol = yes; then
AC_DEFINE(HAVE__END_SYMBOL, 1, [Define if you have the '_end' symbol])
fi
AC_CACHE_CHECK([if __after_morecore_hook can track malloc()s core memory use],
erts_cv___after_morecore_hook_can_track_malloc,
[AC_TRY_RUN([
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#if defined(HAVE_END_SYMBOL)
extern char end;
#elif defined(HAVE__END_SYMBOL)
extern char _end;
#endif
#ifdef ETHR_PTHREADS
# ifdef ETHR_HAVE_PTHREAD_H
# include <pthread.h>
# else
# ifdef ETHR_HAVE_MIT_PTHREAD_H
# include <pthread/mit/pthread.h>
# endif
# endif
# define N_THR 5
#else
# define N_THR 1
#endif
static char *heap_start = NULL;
static char *heap_end = NULL;
void update_heap_size(void)
{
heap_end = (char *) sbrk(0);
}
void init_hook(void)
{
#if defined(HAVE_END_SYMBOL)
heap_start = &end;
#elif defined(HAVE__END_SYMBOL)
heap_start = &_end;
#else
heap_start = sbrk(0);
#endif
__after_morecore_hook = update_heap_size;
}
void (*__malloc_initialize_hook) (void) = init_hook;
static int
check_malloc(int size)
{
char *p = (char *) malloc(size);
if (!heap_start || !heap_end) return 0;
if (!p) return 0;
if (p < heap_start || heap_end <= p) return 0;
if (p + size < heap_start || heap_end < p + size) return 0;
return 1;
}
#ifdef ETHR_PTHREADS
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static void *
do_tests(void *vresp)
{
int i, ok = 0;
#ifdef ETHR_PTHREADS
if (pthread_mutex_lock(&mutex) != 0)
return NULL;
#endif
for (i = 0; i < 10; i++)
if (!check_malloc(1000))
goto failed;
for (i = 0; i < 100; i++)
if (!check_malloc(1))
goto failed;
if (!check_malloc(1024*1024+1))
goto failed;
if (!check_malloc(10*1024*1024+1))
goto failed;
ok = 1;
failed:
#ifdef ETHR_PTHREADS
if (pthread_mutex_unlock(&mutex) != 0)
return NULL;
#endif
if (ok)
*((int *) vresp) = 0;
return NULL;
}
int main(void)
{
int res[N_THR], i;
#ifdef ETHR_PTHREADS
pthread_t tid[N_THR];
#endif
#if defined(HAVE_MALLOPT) && defined(M_MMAP_MAX)
(void) mallopt(M_MMAP_MAX, 0);
#endif
for (i = 0; i < N_THR; i++)
res[i] = 1;
#ifdef ETHR_PTHREADS
for (i = 1; i < N_THR; i++)
if (pthread_create(&tid[i], NULL, do_tests, &res[i]) != 0)
return 1;
#endif
(void) do_tests(&res[0]);
#ifdef ETHR_PTHREADS
for (i = 1; i < N_THR; i++)
if (pthread_join(tid[i], NULL) != 0)
return 1;
#endif
for (i = 0; i < N_THR; i++)
if (res[i])
return 1;
return 0;
}
],
erts_cv___after_morecore_hook_can_track_malloc=yes,
erts_cv___after_morecore_hook_can_track_malloc=no,
[
case X$erl_xcomp_after_morecore_hook in
X) erts_cv___after_morecore_hook_can_track_malloc=cross;;
Xyes|Xno) erts_cv___after_morecore_hook_can_track_malloc=$erl_xcomp_after_morecore_hook;;
*) AC_MSG_ERROR([Bad erl_xcomp_after_morecore_hook value: $erl_xcomp_after_morecore_hook]);;
esac
]
)])
case $erts_cv___after_morecore_hook_can_track_malloc in
yes) AC_DEFINE(ERTS___AFTER_MORECORE_HOOK_CAN_TRACK_MALLOC, 1, \
[Define if __after_morecore_hook can track malloc()s core memory use.]);;
cross) AC_MSG_WARN([result no guessed because of cross compilation]);;
*) ;;
esac
if test "x$ac_cv_func_sbrk" = "xyes"; then
AC_CACHE_CHECK([types of sbrk()s return value and argument],
erts_cv_sbrk_ret_arg_types,
[
erts_cv_sbrk_ret_arg_types=unknown
ret_types="void *,char *"
arg_types="intptr_t,ptrdiff_t,int,long"
save_ifs="$IFS"; IFS=","
for rtype in $ret_types; do
for atype in $arg_types; do
IFS=$save_ifs
AC_TRY_LINK([#include <sys/types.h>
#include <unistd.h>],
[$rtype sbrk($atype incr);],
[erts_cv_sbrk_ret_arg_types="$rtype,$atype"])
IFS=","
if test "$erts_cv_sbrk_ret_arg_types" != "unknown"; then
break 2
fi
done
done
IFS=$save_ifs])
if test "$erts_cv_sbrk_ret_arg_types" != "unknown"; then
save_ifs="$IFS"; IFS=","
read ret_type arg_type <<EOF
$erts_cv_sbrk_ret_arg_types
EOF
IFS=$save_ifs
AC_DEFINE_UNQUOTED(SBRK_RET_TYPE, $ret_type, \
[Define the sbrk() return type.])
AC_DEFINE_UNQUOTED(SBRK_ARG_TYPE, $arg_type, \
[Define the sbrk() argument type.])
fi
fi
if test $ac_cv_func_brk = yes; then
AC_CACHE_CHECK([types of brk()s return value and argument],
erts_cv_brk_ret_arg_types,
[
erts_cv_brk_ret_arg_types=unknown
ret_types="int,long,char *,void *"
arg_types="void *,const void *,char *,const char *"
save_ifs="$IFS"; IFS=","
for rtype in $ret_types; do
for atype in $arg_types; do
IFS=$save_ifs
AC_TRY_LINK([#include <sys/types.h>
#include <unistd.h>],
[$rtype brk($atype endds);],
[erts_cv_brk_ret_arg_types="$rtype,$atype"])
IFS=","
if test "$erts_cv_brk_ret_arg_types" != "unknown"; then
break 2
fi
done
done
IFS=$save_ifs])
if test "$erts_cv_brk_ret_arg_types" != "unknown"; then
save_ifs="$IFS"; IFS=","
read ret_type arg_type <<EOF
$erts_cv_brk_ret_arg_types
EOF
IFS=$save_ifs
AC_DEFINE_UNQUOTED(BRK_RET_TYPE, $ret_type, \
[Define the brk() return type.])
AC_DEFINE_UNQUOTED(BRK_ARG_TYPE, $arg_type, \
[Define the brk() argument type.])
fi
fi
if test $ac_cv_func_sbrk = yes; then
AC_CACHE_CHECK([if sbrk()/brk() wrappers can track malloc()s core memory use],
erts_cv_brk_wrappers_can_track_malloc,
[AC_TRY_RUN([
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
/*
* Our implementation requires that we have sbrk(), and 'end' or '_end'.
*/
#if !defined(HAVE_SBRK)
# error no sbrk()
#endif
#if defined(HAVE_END_SYMBOL)
extern char end;
#elif defined(HAVE__END_SYMBOL)
extern char _end;
#else
# error no 'end' nor '_end'
#endif
#ifdef ETHR_PTHREADS
# ifdef ETHR_HAVE_PTHREAD_H
# include <pthread.h>
# else
# ifdef ETHR_HAVE_MIT_PTHREAD_H
# include <pthread/mit/pthread.h>
# endif
# endif
# define N_THR 5
#else
# define N_THR 1
#endif
#define SBRK_IMPL(RET_TYPE, SBRK, ARG_TYPE) \
RET_TYPE SBRK (ARG_TYPE); \
static RET_TYPE (*real_ ## SBRK)(ARG_TYPE) = NULL; \
RET_TYPE \
SBRK (ARG_TYPE arg) \
{ \
RET_TYPE res; \
if (!real_ ## SBRK) real_ ## SBRK = dlsym(RTLD_NEXT, #SBRK); \
res = (*real_ ## SBRK)(arg); \
if (res != (RET_TYPE) -1) heap_end = (char *) (*real_ ## SBRK)(0); \
return res; \
}
#define BRK_IMPL(RET_TYPE, BRK, ARG_TYPE) \
RET_TYPE BRK (ARG_TYPE); \
static RET_TYPE (*real_ ## BRK)(ARG_TYPE) = NULL; \
RET_TYPE \
BRK (ARG_TYPE arg) \
{ \
RET_TYPE res; \
if (!real_ ## BRK) real_ ## BRK = dlsym(RTLD_NEXT, #BRK); \
res = (*real_ ## BRK)(arg); \
if (res != (RET_TYPE) -1) heap_end = (char *) arg; \
return res; \
}
static char *heap_start = NULL;
static char *heap_end = NULL;
SBRK_IMPL(SBRK_RET_TYPE, sbrk, SBRK_ARG_TYPE)
#ifdef HAVE_BRK
BRK_IMPL(BRK_RET_TYPE, brk, BRK_ARG_TYPE)
#endif
#ifdef HAVE__SBRK
SBRK_IMPL(SBRK_RET_TYPE, _sbrk, SBRK_ARG_TYPE)
#endif
#ifdef HAVE__BRK
BRK_IMPL(BRK_RET_TYPE, _brk, BRK_ARG_TYPE)
#endif
#ifdef HAVE___SBRK
SBRK_IMPL(SBRK_RET_TYPE, __sbrk, SBRK_ARG_TYPE)
#endif
#ifdef HAVE___BRK
BRK_IMPL(BRK_RET_TYPE, __brk, BRK_ARG_TYPE)
#endif
static int
check_malloc(int size)
{
char *p = (char *) malloc(size);
if (!heap_start || !heap_end) return 0;
if (!p) return 0;
if (p < heap_start || heap_end <= p) return 0;
if (p + size < heap_start || heap_end < p + size) return 0;
return 1;
}
#ifdef ETHR_PTHREADS
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static void *
do_tests(void *vresp)
{
int i, ok = 0;
#ifdef ETHR_PTHREADS
if (pthread_mutex_lock(&mutex) != 0)
return NULL;
#endif
for (i = 0; i < 10; i++)
if (!check_malloc(1000))
goto failed;
for (i = 0; i < 100; i++)
if (!check_malloc(1))
goto failed;
if (!check_malloc(1024*1024+1))
goto failed;
if (!check_malloc(10*1024*1024+1))
goto failed;
ok = 1;
failed:
#ifdef ETHR_PTHREADS
if (pthread_mutex_unlock(&mutex) != 0)
return NULL;
#endif
if (ok)
*((int *) vresp) = 0;
return NULL;
}
int main(void)
{
int res[N_THR], i;
#ifdef ETHR_PTHREADS
pthread_t tid[N_THR];
#endif
#if defined(HAVE_END_SYMBOL)
heap_start = &end;
#elif defined(HAVE__END_SYMBOL)
heap_start = &_end;
#endif
#if defined(HAVE_MALLOPT) && defined(M_MMAP_MAX)
(void) mallopt(M_MMAP_MAX, 0);
#endif
for (i = 0; i < N_THR; i++)
res[i] = 1;
#ifdef ETHR_PTHREADS
for (i = 1; i < N_THR; i++)
if (pthread_create(&tid[i], NULL, do_tests, &res[i]) != 0)
return 1;
#endif
(void) do_tests(&res[0]);
#ifdef ETHR_PTHREADS
for (i = 1; i < N_THR; i++)
if (pthread_join(tid[i], NULL) != 0)
return 1;
#endif
for (i = 0; i < N_THR; i++)
if (res[i])
return 1;
return 0;
}
],
erts_cv_brk_wrappers_can_track_malloc=yes,
erts_cv_brk_wrappers_can_track_malloc=no,
[
case X$erl_xcomp_dlsym_brk_wrappers in
X) erts_cv_brk_wrappers_can_track_malloc=cross;;
Xyes|Xno) erts_cv_brk_wrappers_can_track_malloc=$erl_xcomp_dlsym_brk_wrappers;;
*) AC_MSG_ERROR([Bad erl_xcomp_dlsym_brk_wrappers value: $erl_xcomp_dlsym_brk_wrappers]);;
esac
])])
case $erts_cv_brk_wrappers_can_track_malloc in
yes)
AC_DEFINE(ERTS_BRK_WRAPPERS_CAN_TRACK_MALLOC, 1, \
[Define if sbrk()/brk() wrappers can track malloc()s core memory use]);;
cross)
AC_MSG_WARN([result no guessed because of cross compilation]);;
*) ;;
esac
fi
dnl Restore LIBS
LIBS=$saved_libs
dnl restore CPPFLAGS
CPPFLAGS=$saved_cppflags
case $ARCH in
x86|amd64)
AC_DEFINE(ERTS_STRUCTURE_ALIGNED_ALLOC, 1, [Define if structure alignment is enough for allocators. If not defined, 64-bit alignment will be forced.]);;
*)
;;
esac
LM_SYS_IPV6
LM_SYS_MULTICAST
ERL_TIME_CORRECTION
AC_CHECK_PROG(M4, m4, m4)
if test X${enable_hipe} != Xno; then
dnl HiPE cannot run without mprotect()
if test X$ac_cv_func_mprotect != Xyes; then
if test X${enable_hipe} = Xyes; then
AC_MSG_ERROR([HiPE needs mprotect() on $ARCH])
else
enable_hipe=no
AC_MSG_WARN([Disable HiPE due to lack of mprotect()])
fi
fi
fi
dnl check to auto-enable hipe here...
if test "$cross_compiling" != "yes" && test X${enable_hipe} != Xno; then
if test -z "$M4"; then
enable_hipe=no
AC_MSG_NOTICE([HiPE disabled as no valid m4 is found in PATH])
else
case "$ARCH-$OPSYS" in
x86-linux|amd64-linux|x86-darwin*|amd64-darwin*|ppc-linux|ppc64-linux|ppc-darwin|arm-linux|amd64-freebsd|x86-freebsd|x86-sol2|amd64-sol2|ultrasparc-linux)
enable_hipe=yes
;;
esac
fi
fi
if test X${enable_hipe} = Xyes; then
case $OPSYS in
linux)
ppcBEAMLDFLAGS="-Wl,-m,elf32ppc"
ppc64BEAMLDFLAGS="-Wl,-m,elf64ppc,-T,hipe/elf64ppc.x"
;;
darwin)
amd64BEAMLDFLAGS="-pagezero_size 0x10000000"
;;
esac
archVarName="${ARCH}BEAMLDFLAGS"
eval HIPEBEAMLDFLAGS=\$$archVarName
fi
AC_SUBST(HIPEBEAMLDFLAGS)
dnl Permanently disable floating point exceptions.
dnl On x86/amd64, floating points exceptions have
dnl unresolved stability issues.
AC_MSG_CHECKING([for unreliable floating point exceptions])
FPE=unreliable
AC_SUBST(FPE)
AC_MSG_RESULT([unreliable])
AC_DEFINE(NO_FPE_SIGNALS,[],[Define if floating points exceptions are non-existing/not reliable])
dnl
dnl Some operating systems allow you to redefine FD_SETSIZE to be able
dnl to select on more than the default number of file descriptors.
dnl We first discovered this in BSD/OS where the default is ridiculously
dnl low (256). But since we use a lot of file descriptors we found the
dnl need to go over the limit in other os's as well. Since FD_SETSIZE
dnl must be defined before pulling in sys/types.h the actual number
dnl of file descriptors is set in acconfig.h and will thus be in config.h
dnl which *always* should be included first.
dnl
AC_MSG_CHECKING([whether to redefine FD_SETSIZE])
case $host_os in
bsdi*)
AC_DEFINE(REDEFINE_FD_SETSIZE,[],[Define if you wish to redefine FD_SETSIZE to be able to select on more fd])
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac
dnl ----------------------------------------------------------------------
dnl Tests related to configurable options given on command line
dnl (using the --disable, --enable and --with switches).
dnl ----------------------------------------------------------------------
#
# Check if we should enable HiPE.
#
HIPE_ENABLED=
HIPE_HELPERS=
dnl if not disabled, autoenable HiPE on known supported platforms
dnl done up where floating point is checked, need to descide there already...
if test X${enable_hipe} = Xyes; then
if test X$ac_cv_sizeof_void_p != X4 -a X$ARCH != Xamd64 -a X$ARCH != Xppc64; then
AC_MSG_WARN([HiPE is not supported in 64-bit builds])
else
HIPE_ENABLED=yes
AC_DEFINE(HIPE,[1],[Define to enable HiPE])
HIPE_HELPERS="xmerl syntax_tools edoc"
ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS hipe"
AC_MSG_NOTICE([Enable exec_alloc for hipe code allocation])
ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS exec_alloc"
fi
fi
AC_SUBST(HIPE_HELPERS)
AC_SUBST(HIPE_ENABLED)
#
# Check if Erlang libraries should be compiled to native code.
#
NATIVE_LIBS_ENABLED=
if test X${enable_native_libs} = Xyes -a X${HIPE_ENABLED} = Xyes; then
NATIVE_LIBS_ENABLED=yes
fi
AC_SUBST(NATIVE_LIBS_ENABLED)
#
# Check for working poll().
#
AC_MSG_CHECKING([for working poll()])
if test "x$ac_cv_header_poll_h" != "xyes" -o "x$ac_cv_func_poll" != "xyes"; then
poll_works=no
else
AC_TRY_RUN([
#include <poll.h>
main()
{
#ifdef _POLL_EMUL_H_
exit(1); /* Implemented using select() -- fail */
#else
struct pollfd fds[1];
int fd;
fd = open("/dev/null", 1);
fds[0].fd = fd;
fds[0].events = POLLIN;
fds[0].revents = 0;
if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
exit(1); /* Does not work for devices -- fail */
}
exit(0);
#endif
}
],
poll_works=yes,
poll_works=no,
[
case X$erl_xcomp_poll in
X) poll_works=cross;;
Xyes|Xno) poll_works=$erl_xcomp_poll;;
*) AC_MSG_ERROR([Bad erl_xcomp_poll value: $erl_xcomp_poll]);;
esac
])
fi
case $poll_works-$host_os in
no-*|cross-darwin*)
#
# The USE_SELECT define is used by the ssl application (should not
# be used by erts).
#
AC_DEFINE(USE_SELECT, 1, [Define if select() should be used instead of poll()])
if test $poll_works = cross; then
AC_MSG_RESULT(cross)
AC_MSG_WARN([result no guessed based on OS ($host_os) because of cross compilation])
else
AC_MSG_RESULT([no; non-existing, broken, or based on select()])
fi
poll_works=no;;
yes-*|cross-*)
AC_DEFINE(ERTS_USE_POLL, 1, [Define if poll() should be used instead of select()])
if test $poll_works = cross; then
AC_MSG_RESULT(cross)
AC_MSG_WARN([result yes guessed based on OS ($host_os) because of cross compilation])
else
AC_MSG_RESULT(yes)
fi
poll_works=yes;;
esac
#
# If kqueue() found
#
if test $have_kernel_poll = kqueue; then
## Some OS X kernel version seems to have bugs in them with regards to kqueue
## Disable kernel poll on those versions
AC_MSG_CHECKING([whether host os has known kqueue bugs])
case $host_os in
# Any OS X version < 16 has known problems with using kqueue
# so we don't use it there. See erl_poll.c for details.
darwin[[0-9]].*|darwin1[[0-5]].*)
AC_MSG_RESULT([yes, disabling kernel poll])
have_kernel_poll=no
;;
*)
AC_MSG_RESULT([no])
;;
esac
fi
#
# If epoll() found, check that it is level triggered.
#
if test $have_kernel_poll = epoll; then
AC_MSG_CHECKING([whether epoll is level triggered])
AC_TRY_LINK([#include <sys/epoll.h>],[
#ifdef EPOLLET
/* Edge triggered option exist, assume level triggered
is default */
;
#else
/* No edge triggered option exist; assume edge
triggered only */
#error No EPOLLET
#endif
],
level_triggered_epoll=yes,
[level_triggered_epoll=no
have_kernel_poll=no])
AC_MSG_RESULT([$level_triggered_epoll])
fi
#
# Check if we should enable kernel poll support
#
AC_MSG_CHECKING(whether kernel poll support should be enabled)
ERTS_ENABLE_KERNEL_POLL=no
ERTS_BUILD_FALLBACK_POLL=no
case $enable_kernel_poll-$have_kernel_poll in
no-*)
AC_MSG_RESULT(no; disabled by user);;
yes-no)
AC_MSG_ERROR(no; kernel poll support requested but not found);;
*-no)
AC_MSG_RESULT(no);;
*)
case $have_kernel_poll in
epoll)
AC_DEFINE(HAVE_SYS_EPOLL_H, 1, [Define if you have the <sys/epoll.h> header file.])
ERTS_BUILD_FALLBACK_POLL=yes
;;
/dev/poll)
AC_DEFINE(HAVE_SYS_DEVPOLL_H, 1, [Define if you have <sys/devpoll.h> header file.])
;;
kqueue)
AC_DEFINE(HAVE_SYS_EVENT_H, 1, [Define if you have <sys/event.h> header file.])
ERTS_BUILD_FALLBACK_POLL=yes
;;
*)
AC_MSG_ERROR(configure.in need to be updated);;
esac
ERTS_ENABLE_KERNEL_POLL=yes
AC_DEFINE(ERTS_ENABLE_KERNEL_POLL, 1, [Define if you have kernel poll and want to use it])
AC_MSG_RESULT([yes; $have_kernel_poll]);;
esac
AC_SUBST(ERTS_BUILD_FALLBACK_POLL)
AC_MSG_CHECKING([whether putenv() stores a copy of the key-value pair])
AC_TRY_RUN([
#include <stdlib.h>
int main(void) {
int i;
char *env;
char buf[10];
for (i = 0; i < 7; i++)
buf[i] = 'X';
buf[i] = '\0';
buf[3] = '=';
if (putenv(buf) != 0)
return 1;
for (i = 4; i < 7; i++)
buf[i] = 'Y';
env = getenv("XXX");
if (!env)
return 2;
for (i = 0; i < 3; i++)
if (env[i] != 'X')
return 3;
for (i = 0; i < 3; i++)
buf[i] = 'Y';
env = getenv("XXX");
if (!env)
return 4;
for (i = 0; i < 3; i++)
if (env[i] != 'X')
return 5;
return 0;
}
],
copying_putenv=yes,
copying_putenv=no,
[
case X$erl_xcomp_putenv_copy in
X) copying_putenv=cross;;
Xyes|Xno) copying_putenv=$erl_xcomp_putenv_copy;;
*) AC_MSG_ERROR([Bad erl_xcomp_putenv_copy value: $erl_xcomp_putenv_copy]);;
esac
])
AC_MSG_RESULT($copying_putenv)
case $copying_putenv in
yes)
AC_DEFINE(HAVE_COPYING_PUTENV,[1],\
[Define if you have a putenv() that stores a copy of the key-value pair]);;
cross)
AC_MSG_WARN([result no guessed because of cross compilation]);;
*) ;;
esac
dnl ----------------------------------------------------------------------
dnl Stuff that should be moved into their respective application
dnl ----------------------------------------------------------------------
dnl crypto
#--------------------------------------------------------------------
# Dynamic Erlang Drivers
#
# Linking to produce dynamic Erlang drivers to be loaded by Erlang's
# Dynamic Driver Loader and Linker (DDLL). Below the prefix DED is an
# abbreviation for `Dynamic Erlang Driver'.
#
# For DED we need something quite sloppy, which allows undefined references
# (notably driver functions) in the resulting shared library.
# Example of Makefile rule (and settings of macros):
#
# LIBS = @LIBS@
# LD = @DED_LD@
# LDFLAGS = @DED_LDFLAGS@
# soname = @ldsoname@
#
# my_drv.so: my_drv.o my_utils.o
# $(LD) $(LDFLAGS) $(soname) $@ -o $@ $^ -lc $(LIBS)
#
#--------------------------------------------------------------------
DED_SYS_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$ERLANG_OSTYPE -I${ERL_TOP}/erts/emulator/sys/common"
if test "X$ETHR_DEFS" = "X"; then
DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
else
DED_THR_DEFS="$ETHR_DEFS"
fi
DED_EMU_THR_DEFS=$EMU_THR_DEFS
DED_CFLAGS="$CFLAGS $CPPFLAGS"
if test "x$GCC" = xyes; then
DED_STATIC_CFLAGS="$DED_CFLAGS"
DED_CFLAGS="$DED_CFLAGS -fPIC"
fi
DED_EXT=so
case $host_os in
win32) DED_EXT=dll;;
darwin*)
DED_CFLAGS="$DED_CFLAGS -fno-common"
DED_STATIC_CFLAGS="$DED_STATIC_CFLAGS -fno-common";;
*)
;;
esac
DED_STATIC_CFLAGS="$DED_STATIC_CFLAGS -DSTATIC_ERLANG_NIF -DSTATIC_ERLANG_DRIVER"
# If DED_LD is set in environment, we expect all DED_LD* variables
# to be specified (cross compiling)
if test "x$DED_LD" = "x"; then
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="-R"
case $host_os in
win32)
DED_LD="ld.sh"
DED_LDFLAGS="-dll"
DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
;;
solaris2*|sysv4*)
DED_LDFLAGS="-G"
if test X${enable_m64_build} = Xyes; then
DED_LDFLAGS="-64 $DED_LDFLAGS"
fi
;;
aix4*)
DED_LDFLAGS="-G -bnoentry -bexpall"
;;
freebsd2*)
# Non-ELF GNU linker
DED_LDFLAGS="-Bshareable"
;;
darwin*)
# Mach-O linker: a shared lib and a loadable
# object file is not the same thing.
DED_LDFLAGS="-bundle -bundle_loader ${ERL_TOP}/bin/$host/beam.smp"
case $ARCH in
amd64)
DED_LDFLAGS="-m64 $DED_LDFLAGS"
;;
*)
;;
esac
DED_LD="$CC"
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
;;
linux*)
DED_LD="$CC"
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
DED_LDFLAGS="-shared -Wl,-Bsymbolic"
if test X${enable_m64_build} = Xyes; then
DED_LDFLAGS="-m64 $DED_LDFLAGS"
fi;
if test X${enable_m32_build} = Xyes; then
DED_LDFLAGS="-m32 $DED_LDFLAGS"
fi
;;
freebsd*)
DED_LD="$CC"
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
DED_LDFLAGS="-shared"
if test X${enable_m64_build} = Xyes; then
DED_LDFLAGS="-m64 $DED_LDFLAGS"
fi;
if test X${enable_m32_build} = Xyes; then
DED_LDFLAGS="-m32 $DED_LDFLAGS"
fi
;;
openbsd*)
DED_LD="$CC"
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
DED_LDFLAGS="-shared"
;;
osf*)
# NOTE! Whitespace after -rpath is important.
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="-rpath "
DED_LDFLAGS="-shared -expect_unresolved '*'"
;;
*)
# assume GNU linker and ELF
DED_LDFLAGS="-shared"
# GNU linker has no option for 64bit build, should not propagate -m64
;;
esac
if test "$DED_LD" = "" && test "$USER_LD" != ""; then
DED_LD="$USER_LD"
DED_LDFLAGS="$USER_LDFLAGS $DED_LDFLAGS"
fi
fi # "x$DED_LD" = "x"
AC_CHECK_TOOL(DED_LD, ld, false)
test "$DED_LD" != "false" || AC_MSG_ERROR([No linker found])
AC_MSG_CHECKING(for compiler flags for loadable drivers)
AC_MSG_RESULT([$DED_CFLAGS])
AC_MSG_CHECKING(for linker for loadable drivers)
AC_MSG_RESULT([$DED_LD])
AC_MSG_CHECKING(for linker flags for loadable drivers)
AC_MSG_RESULT([$DED_LDFLAGS])
AC_MSG_CHECKING(for 'runtime library path' linker flag)
if test "x$DED_LD_FLAG_RUNTIME_LIBRARY_PATH" != "x"; then
AC_MSG_RESULT([$DED_LD_FLAG_RUNTIME_LIBRARY_PATH])
else
AC_MSG_RESULT([not found])
fi
AC_SUBST(DED_EXT)
AC_SUBST(DED_SYS_INCLUDE)
AC_SUBST(DED_CFLAGS)
AC_SUBST(DED_STATIC_CFLAGS)
AC_SUBST(DED_LD)
AC_SUBST(DED_LDFLAGS)
AC_SUBST(DED_LD_FLAG_RUNTIME_LIBRARY_PATH)
AC_SUBST(DED_THR_DEFS)
AC_SUBST(DED_EMU_THR_DEFS)
AC_SUBST(STATIC_CFLAGS)
dnl
dnl We should look for a compiler that handles jump tables, for beam_emu
dnl to be optimized
dnl
LM_FIND_EMU_CC
dnl
dnl Test whether code pointers are always short (32 bits).
dnl
AC_MSG_CHECKING([whether the code model is small])
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $HIPEBEAMLDFLAGS"
AC_TRY_RUN([
#include <stdlib.h>
int main() {
if ((unsigned long long)&main < (1ull << 32)) {
exit(0);
}
exit(1);
}
],
erl_code_model_small=yes,
erl_code_model_small=no,
[case X$erl_xcomp_code_model_small in
X) erl_code_model_small=no;;
Xyes|Xno) erl_code_model_small=$erl_xcomp_code_model_small;;
*) AC_MSG_ERROR([Bad erl_xcomp_code_model_small value: $erl_xcomp_code_model_small]);;
esac])
AC_MSG_RESULT([$erl_code_model_small])
LDFLAGS="$saved_LDFLAGS"
case $erl_code_model_small in
yes)
AC_DEFINE(CODE_MODEL_SMALL,[1],
[Define if the code model is small (code fits below 2Gb)])
CODE_MODEL=small
;;
no)
CODE_MODEL=unknown
;;
esac
AC_SUBST(CODE_MODEL)
dnl
dnl DTrace & LTTNG
dnl
case $DYNAMIC_TRACE_FRAMEWORK in
dtrace|systemtap)
AC_CHECK_TOOL(DTRACE, dtrace, none)
test "$DTRACE" = "none" && AC_MSG_ERROR([No dtrace utility found.]);
enable_lttng_test=no
enable_dtrace_test=yes;;
lttng)
enable_lttng_test=yes
enable_dtrace_test=no;;
*)
enable_lttng_test=no
enable_dtrace_test=no;;
esac
AC_SUBST(DTRACE)
AC_SUBST(DTRACE_CPP)
AC_SUBST(DTRACE_ENABLED)
AC_SUBST(DTRACE_ENABLED_2STEP)
DTRACE_CPP=-C
DTRACE_ENABLED=
DTRACE_ENABLED_2STEP=
DTRACE_2STEP_TEST=./dtrace-test.o
DTRACE_BITS_FLAG=
case $OPSYS in
freebsd)
if test "$BITS64" = "yes" ; then
DTRACE_BITS_FLAG=-64
else
DTRACE_BITS_FLAG=-32
fi
;;
*)
: # Nothing to do
;;
esac
if test "$enable_dtrace_test" = "yes" ; then
if test "$DTRACE" = "dtrace" ; then
AC_CHECK_HEADERS(sys/sdt.h)
AC_MSG_CHECKING([for 1-stage DTrace precompilation])
# The OS X version of dtrace prints a spurious line here.
if ! dtrace -h $DTRACE_CPP -Iemulator/beam -o ./foo-dtrace.h -s emulator/beam/erlang_dtrace.d; then
AC_MSG_ERROR([Could not precompile erlang_dtrace.d: dtrace -h failed])
fi
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for 2-stage DTrace precompilation])
AC_TRY_COMPILE([ #include "foo-dtrace.h" ],
[ERLANG_DIST_PORT_BUSY_ENABLED();],
[$RM -f $DTRACE_2STEP_TEST
dtrace -G $DTRACE_CPP $DTRACE_BITS_FLAG -Iemulator/beam -o $DTRACE_2STEP_TEST -s emulator/beam/erlang_dtrace.d conftest.$OBJEXT 2>&AS_MESSAGE_LOG_FD
if test -f $DTRACE_2STEP_TEST; then
$RM $DTRACE_2STEP_TEST
DTRACE_ENABLED_2STEP=yes
fi],
[])
$RM -f foo-dtrace.h
AS_IF([test "x$DTRACE_ENABLED_2STEP" = "xyes"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
DTRACE_ENABLED=yes
case $OPSYS in
linux)
: # No extra libs to add to LIBS
;;
freebsd)
LIBS="$LIBS -lelf"
;;
*)
LIBS="$LIBS -ldtrace"
;;
esac
else
AC_MSG_ERROR([Dtrace preprocessing test failed.])
fi
fi
if test "$enable_lttng_test" = "yes" ; then
AC_CHECK_HEADERS(lttng/tracepoint.h)
AC_CHECK_HEADERS(lttng/tracepoint-event.h)
dnl The macro tracepoint_enabled is not present in older lttng versions
dnl checking for tracepoint_enabled
AC_MSG_CHECKING([for tracepoint_enabled in lttng/tracepoint.h])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <lttng/tracepoint.h>
#define TRACEPOINT_PROVIDER org_erlang_otp
TRACEPOINT_EVENT(
org_erlang_otp,
dummy,
TP_ARGS(int, my_int),
TP_FIELDS(ctf_integer(int, my_int, my_int)))
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE],
[if(tracepoint_enabled(org_erlang_otp,dummy)) do {} while(0)])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([no (available in lttng-ust v2.7)])])
if test "x$ac_cv_header_lttng_tracepoint_h" = "xyes" \
-a "x$ac_cv_header_lttng_tracepoint_event_h" = "xyes"; then
# No straight forward way to test for liblttng-ust when no public symbol exists,
# just add the lib.
LIBS="$LIBS -llttng-ust -ldl"
else
AC_MSG_ERROR([No LTTng support found.])
fi
fi
dnl
dnl SSL, SSH and CRYPTO need the OpenSSL libraries
dnl
dnl Check flags --with-ssl, --without-ssl --with-ssl=PATH.
dnl If no option is given or --with-ssl is set without a path then we
dnl search for OpenSSL libraries and header files in the standard locations.
dnl If set to --without-ssl we disable the use of SSL, SSH and CRYPTO.
dnl If set to --with-ssl=PATH we use that path as the prefix, i.e. we
dnl use "PATH/include" and "PATH/lib".
AC_SUBST(SSL_INCLUDE)
AC_SUBST(SSL_INCDIR)
AC_SUBST(SSL_LIBDIR)
AC_SUBST(SSL_FLAGS)
AC_SUBST(SSL_CRYPTO_LIBNAME)
AC_SUBST(SSL_SSL_LIBNAME)
AC_SUBST(SSL_CC_RUNTIME_LIBRARY_PATH)
AC_SUBST(SSL_LD_RUNTIME_LIBRARY_PATH)
AC_SUBST(SSL_DED_LD_RUNTIME_LIBRARY_PATH)
AC_SUBST(SSL_DYNAMIC_ONLY)
AC_SUBST(SSL_LINK_WITH_KERBEROS)
AC_SUBST(STATIC_KERBEROS_LIBS)
AC_SUBST(SSL_LINK_WITH_ZLIB)
AC_SUBST(STATIC_ZLIB_LIBS)
std_ssl_locations="/usr/local /usr/sfw /usr /opt/local /usr/pkg /usr/local/openssl /usr/lib/openssl /usr/openssl /usr/local/ssl /usr/lib/ssl /usr/ssl /"
AC_ARG_WITH(ssl-zlib,
AS_HELP_STRING([--with-ssl-zlib=PATH],
[specify location of ZLib to be used by OpenSSL])
AS_HELP_STRING([--with-ssl-zlib],
[link SSL with Zlib (default if found)])
AS_HELP_STRING([--without-ssl-zlib],
[don't link SSL with ZLib]))
if test "x$with_ssl_zlib" = "xno"; then
SSL_LINK_WITH_ZLIB=no
STATIC_ZLIB_LIBS=
elif test "x$with_ssl_zlib" = "xyes" || test "x$with_ssl_zlib" = "x"; then
if test $erl_xcomp_without_sysroot = yes; then
AC_MSG_WARN([Cannot search for zlib; missing cross system root (erl_xcomp_sysroot).])
SSL_LINK_WITH_ZLIB=no
STATIC_ZLIB_LIBS=
elif test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes"; then
SSL_LINK_WITH_ZLIB=no
STATIC_ZLIB_LIBS=
else
SSL_LINK_WITH_ZLIB=no
STATIC_ZLIB_LIBS=
AC_MSG_CHECKING(for static ZLib to be used by SSL in standard locations)
for rdir in $std_ssl_locations; do
dir="$erl_xcomp_sysroot$rdir"
if test "x$ac_cv_sizeof_void_p" = "x8"; then
if test -f "$dir/lib64/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS="$dir/lib64/libz.a"
break
elif test -f "$dir/lib/64/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS="$dir/lib/64/libz.a"
break
fi
fi
if test -f "$dir/lib/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS="$dir/lib/libz.a"
break
fi
done
if test "x$SSL_LINK_WITH_ZLIB" = "xno"; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([$STATIC_ZLIB_LIBS])
fi
fi
else
SSL_LINK_WITH_ZLIB=no
STATIC_ZLIB_LIBS=
if test -f "$with_ssl_zlib/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS=$with_ssl_zlib/libz.a
elif test -f "$with_ssl_zlib/lib/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS=$with_ssl_zlib/lib/libz.a
fi
if test "x$ac_cv_sizeof_void_p" = "x8"; then
if test -f "$with_ssl_zlib/lib64/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS=$with_ssl_zlib/lib64/libz.a
elif test -f "$with_ssl_zlib/lib/64/libz.a"; then
SSL_LINK_WITH_ZLIB=yes
STATIC_ZLIB_LIBS=$with_ssl_zlib/lib/64/libz.a
fi
fi
if test "x$SSL_LINK_WITH_ZLIB" = "xno"; then
AC_MSG_ERROR(Invalid path to option --with-ssl-zlib=PATH)
fi
fi
AC_ARG_WITH(ssl,
AS_HELP_STRING([--with-ssl=PATH], [specify location of OpenSSL include and lib])
AS_HELP_STRING([--with-ssl], [use SSL (default)])
AS_HELP_STRING([--without-ssl], [don't use SSL]))
AC_ARG_WITH(ssl-incl,
AS_HELP_STRING([--with-ssl-incl=PATH], [location of OpenSSL include dir, if different than specified by --with-ssl=PATH]),
[
case X$with_ssl in
X | Xyes | Xno) AC_MSG_ERROR([--with-ssl-incl=PATH set without --with-ssl=PATH]);;
esac
],
[with_ssl_incl=$with_ssl]) #default
AC_ARG_WITH(ssl-rpath,
AS_HELP_STRING([--with-ssl-rpath=yes|no|PATHS],
[runtime library path for OpenSSL. Default is "yes", which equates to a
number of standard locations. If "no", then no runtime
library paths will be used. Anything else should be a
comma separated list of paths.]),
[
case X$with_ssl in
Xno) AC_MSG_ERROR([--with-ssl-rpath set without --with-ssl]);;
esac
],
[with_ssl_rpath=yes]) #default
AC_ARG_ENABLE(dynamic-ssl-lib,
AS_HELP_STRING([--disable-dynamic-ssl-lib],
[disable using dynamic openssl libraries]),
[ case "$enableval" in
no) enable_dynamic_ssl=no ;;
*) enable_dynamic_ssl=yes ;;
esac ], enable_dynamic_ssl=yes)
#----------------------------------------------------------------------
# We actually might do the SSL tests twice due to late discovery of
# kerberos problems with static linking, in case we redo it all trying
# dynamic SSL libraries instead.
#----------------------------------------------------------------------
ssl_done=no
while test "x$ssl_done" != "xyes"; do
ssl_done=yes # Default only one run
# Remove all SKIP files from previous runs
for a in ssl crypto ssh; do
$RM -f $ERL_TOP/lib/$a/SKIP
done
SSL_DYNAMIC_ONLY=$enable_dynamic_ssl
SSL_STATIC_ONLY=no
case "$erl_xcomp_without_sysroot-$with_ssl" in
yes-* | no-no)
SSL_APP=
CRYPTO_APP=
SSH_APP=
if test "$with_ssl" = "no"; then
skip="User gave --without-ssl option"
else
skip="Cannot search for ssl; missing cross system root (erl_xcomp_sysroot)."
fi
for a in ssl crypto ssh; do
echo "$skip" > $ERL_TOP/lib/$a/SKIP
done
;;
no-yes | no- )
# On windows, we could try to find the installation
# of Shining Light OpenSSL, which can be found by poking in
# the uninstall section in the registry, it's worth a try...
extra_dir=""
if test "x$MIXED_CYGWIN" = "xyes"; then
AC_CHECK_PROG(REGTOOL, regtool, regtool, false)
if test "$ac_cv_prog_REGTOOL" != false; then
wrp="/machine/software/microsoft/windows/currentversion/"
if test "x$ARCH" = "xamd64"; then
urp="uninstall/openssl (64-bit)_is1/inno setup: app path"
regtool_subsystem=-w
else
urp="uninstall/openssl (32-bit)_is1/inno setup: app path"
regtool_subsystem=-W
fi
rp="$wrp$urp"
if regtool -q $regtool_subsystem get "$rp" > /dev/null; then
true
else
# Fallback to unspecified wordlength
urp="uninstall/openssl_is1/inno setup: app path"
rp="$wrp$urp"
fi
if regtool -q $regtool_subsystem get "$rp" > /dev/null; then
ssl_install_dir=`regtool -q $regtool_subsystem get "$rp"`
# Try hard to get rid of spaces...
if cygpath -d "$ssl_install_dir" > /dev/null 2>&1; then
ssl_install_dir=`cygpath -d "$ssl_install_dir"`
fi
extra_dir=`cygpath $ssl_install_dir`
fi
fi
elif test "x$MIXED_MSYS" = "xyes"; then
AC_CHECK_PROG(REGTOOL, reg_query.sh, reg_query.sh, false)
if test "$ac_cv_prog_REGTOOL" != false; then
if test "x$ARCH" = "xamd64"; then
rp="HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/OpenSSL (64-bit)_is1"
else
rp="HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/OpenSSL_is1"
fi
key="Inno Setup: App Path"
if "$ac_cv_prog_REGTOOL" "$rp" "$key" > /dev/null; then
ssl_install_dir=`"$ac_cv_prog_REGTOOL" "$rp" "$key"`
extra_dir=`win2msys_path.sh "$ssl_install_dir"`
fi
fi
fi
# We search for OpenSSL in the common OS standard locations.
SSL_APP=ssl
CRYPTO_APP=crypto
SSH_APP=ssh
SSL_CRYPTO_LIBNAME=crypto
SSL_SSL_LIBNAME=ssl
if test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes"; then
if test "x$ARCH" = "xamd64"; then
std_win_ssl_locations="/cygdrive/c/OpenSSL-Win64 /c/OpenSSL-Win64 /opt/local64/pgm/OpenSSL"
else
std_win_ssl_locations="/cygdrive/c/OpenSSL-Win32 /c/OpenSSL-Win32 /cygdrive/c/OpenSSL /c/OpenSSL /opt/local/pgm/OpenSSL"
fi
else
std_win_ssl_locations=""
fi
AC_MSG_CHECKING(for OpenSSL >= 0.9.8c in standard locations)
for rdir in $extra_dir $std_win_ssl_locations $std_ssl_locations; do
dir="$erl_xcomp_sysroot$rdir"
if test -f "$erl_xcomp_isysroot$rdir/include/openssl/opensslv.h"; then
is_real_ssl=yes
SSL_INCDIR="$dir"
if test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes"; then
if test -f "$dir/lib/VC/libeay32.lib"; then
SSL_RUNTIME_LIBDIR="$rdir/lib/VC"
SSL_LIBDIR="$dir/lib/VC"
SSL_CRYPTO_LIBNAME=libeay32
SSL_SSL_LIBNAME=ssleay32
elif test -f "$dir/lib/VC/openssl.lib"; then
SSL_RUNTIME_LIBDIR="$rdir/lib/VC"
SSL_LIBDIR="$dir/lib/VC"
elif test -f $dir/lib/VC/libeay32MD.lib; then
SSL_CRYPTO_LIBNAME=libeay32MD
SSL_SSL_LIBNAME=ssleay32MD
if test "x$enable_dynamic_ssl" = "xno" && \
test -f $dir/lib/VC/static/libeay32MD.lib; then
SSL_RUNTIME_LIBDIR="$rdir/lib/VC/static"
SSL_LIBDIR="$dir/lib/VC/static"
else
SSL_RUNTIME_LIBDIR="$rdir/lib/VC"
SSL_LIBDIR="$dir/lib/VC"
fi
elif test -f "$dir/lib/libeay32.lib"; then
SSL_RUNTIME_LIBDIR="$rdir/lib"
SSL_LIBDIR="$dir/lib"
SSL_CRYPTO_LIBNAME=libeay32
SSL_SSL_LIBNAME=ssleay32
elif test -f "$dir/lib/openssl.lib"; then
SSL_RUNTIME_LIBDIR="$rdir/lib"
SSL_LIBDIR="$dir/lib"
else
is_real_ssl=no
fi
elif test -f "$dir/lib/powerpc/libsslcrypto.a"; then
SSL_CRYPTO_LIBNAME=sslcrypto
SSL_LIBDIR="$dir/lib/powerpc/"
SSL_RUNTIME_LIBDIR="$rdir/lib/powerpc/"
else
if test "x$ac_cv_sizeof_void_p" = "x8"; then
if test -f "$dir/lib64/libcrypto.a"; then
SSL_RUNTIME_LIBDIR="$rdir/lib64"
SSL_LIBDIR="$dir/lib64"
elif test -f "$dir/lib/64/libcrypto.a"; then
SSL_RUNTIME_LIBDIR="$rdir/lib/64"
SSL_LIBDIR="$dir/lib/64"
elif test -f "$dir/lib64/libcrypto.so"; then
SSL_RUNTIME_LIBDIR="$rdir/lib64"
SSL_LIBDIR="$dir/lib64"
elif test -f "$dir/lib/64/libcrypto.so"; then
SSL_RUNTIME_LIBDIR="$rdir/lib/64"
SSL_LIBDIR="$dir/lib/64"
else
SSL_RUNTIME_LIBDIR="$rdir/lib"
SSL_LIBDIR="$dir/lib"
fi
else
SSL_RUNTIME_LIBDIR="$rdir/lib"
SSL_LIBDIR="$dir/lib"
fi
fi
if test '!' -f "$SSL_LIBDIR/lib${SSL_CRYPTO_LIBNAME}.a"; then
SSL_DYNAMIC_ONLY=yes
elif test '!' -f "$SSL_LIBDIR/lib${SSL_CRYPTO_LIBNAME}.so" -a '!' -f "$SSL_LIBDIR/lib${SSL_CRYPTO_LIBNAME}.dylib"; then
SSL_STATIC_ONLY=yes
fi
SSL_BINDIR="$rdir/bin"
if test "x$is_real_ssl" = "xyes" ; then
SSL_INCLUDE="-I$dir/include"
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=$SSL_INCLUDE
AC_EGREP_CPP(^yes$,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090803fL
yes
#endif
],[
ssl_found=yes
],[
SSL_APP=
ssl_found=no
])
CPPFLAGS=$old_CPPFLAGS
if test "x$ssl_found" = "xyes"; then
if test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes"; then
ssl_linkable=yes
elif test "x${SSL_CRYPTO_LIBNAME}" = "xsslcrypto"; then
# This should only be triggered seen OSE
ssl_linkable=yes
else
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$CFLAGS $SSL_INCLUDE"
if test "x$SSL_STATIC_ONLY" = "xyes"; then
LIBS="${SSL_LIBDIR}/lib${SSL_CRYPTO_LIBNAME}.a"
else
LDFLAGS="$LDFLAGS -L$SSL_LIBDIR"
LIBS="$LIBS -l${SSL_CRYPTO_LIBNAME}"
fi
AC_TRY_LINK([
#include <stdio.h>
#include <openssl/hmac.h>],
[
HMAC(0, 0, 0, 0, 0, 0, 0);
],
[ssl_linkable=yes],
[ssl_linkable=no])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
fi
fi
if test "x$ssl_found" = "xyes" && test "x$ssl_linkable" = "xyes"; then
AC_MSG_RESULT([$dir])
break;
fi
fi
fi
done
if test "x$ssl_found" != "xyes" ; then
dnl
dnl If no SSL found above, check whether we are running on OpenBSD.
dnl
case $host_os in
openbsd*)
if test -f "$erl_xcomp_isysroot/usr/include/openssl/opensslv.h"; then
# Trust OpenBSD to have everything the in the correct locations.
ssl_found=yes
ssl_linkable=yes
SSL_INCDIR="$erl_xcomp_sysroot/usr"
AC_MSG_RESULT([$SSL_INCDIR])
SSL_RUNTIME_LIB="/usr/lib"
SSL_LIB="$erl_xcomp_sysroot/usr/lib"
SSL_BINDIR="/usr/sbin"
dnl OpenBSD requires us to link with -L and -l
SSL_DYNAMIC_ONLY="yes"
fi
;;
esac
fi
dnl Now, certain linuxes have a 64bit libcrypto
dnl that cannot build shared libraries (i.e. not PIC)
dnl One could argue that this is wrong, but
dnl so it is - be adoptable
if test "$ssl_found" = "yes" && test "$ssl_linkable" = "yes" && test "$SSL_DYNAMIC_ONLY" != "yes"; then
case $host_os in
linux*)
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$DED_CFLAGS $SSL_INCLUDE"
LDFLAGS="$DED_LDFLAGS"
LIBS="$SSL_LIBDIR/libcrypto.a $STATIC_ZLIB_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include <openssl/hmac.h>],
[
HMAC(0, 0, 0, 0, 0, 0, 0);
],
[ssl_dyn_linkable=yes],
[ssl_dyn_linkable=no])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
if test "x$ssl_dyn_linkable" != "xyes"; then
SSL_DYNAMIC_ONLY=yes
AC_MSG_WARN([SSL will be linked against dynamic lib as static lib is not purely relocatable])
fi
;;
esac
fi
if test "x$ssl_found" != "xyes" || test "x$ssl_linkable" != "xyes"; then
if test "x$ssl_found" = "xyes"; then
AC_MSG_RESULT([found; but not usable])
else
AC_MSG_RESULT([no])
fi
SSL_APP=
CRYPTO_APP=
SSH_APP=
AC_MSG_WARN([No (usable) OpenSSL found, skipping ssl, ssh and crypto applications])
for a in ssl crypto ssh; do
echo "No usable OpenSSL found" > $ERL_TOP/lib/$a/SKIP
done
fi
;;
*)
# Option given with PATH to package
if test ! -d "$with_ssl" ; then
AC_MSG_ERROR(Invalid path to option --with-ssl=PATH)
fi
if test ! -d "$with_ssl_incl" ; then
AC_MSG_ERROR(Invalid path to option --with-ssl-incl=PATH)
fi
SSL_INCDIR="$with_ssl_incl"
SSL_CRYPTO_LIBNAME=crypto
SSL_SSL_LIBNAME=ssl
if test "x$MIXED_CYGWIN" = "xyes" -o "x$MIXED_MSYS" = "xyes" && test -d "$with_ssl/lib/VC"; then
if test -f "$with_ssl/lib/VC/libeay32.lib"; then
SSL_LIBDIR="$with_ssl/lib/VC"
SSL_CRYPTO_LIBNAME=libeay32
SSL_SSL_LIBNAME=ssleay32
elif test -f "$with_ssl/lib/VC/openssl.lib"; then
SSL_LIBDIR="$with_ssl/lib/VC"
elif test -f $with_ssl/lib/VC/libeay32MD.lib; then
SSL_CRYPTO_LIBNAME=libeay32MD
SSL_SSL_LIBNAME=ssleay32MD
if test "x$enable_dynamic_ssl" = "xno" && \
test -f $with_ssl/lib/VC/static/libeay32MD.lib; then
SSL_LIBDIR="$with_ssl/lib/VC/static"
else
SSL_LIBDIR="$with_ssl/lib/VC"
fi
elif test -f "$with_ssl/lib/libeay32.lib"; then
SSL_LIBDIR="$with_ssl/lib"
SSL_CRYPTO_LIBNAME=libeay32
SSL_SSL_LIBNAME=ssleay32
else
# This probably wont work, but that's what the user said, so...
SSL_LIBDIR="$with_ssl/lib"
fi
elif test -f "$dir/lib/powerpc/libsslcrypto.a"; then
SSL_CRYPTO_LIBNAME=sslcrypto
SSL_LIBDIR="$with_ssl/lib/powerpc/"
elif test "x$ac_cv_sizeof_void_p" = "x8"; then
if test -f "$with_ssl/lib64/libcrypto.a"; then
SSL_LIBDIR="$with_ssl/lib64"
elif test -f "$with_ssl/lib/64/libcrypto.a"; then
SSL_LIBDIR="$with_ssl/lib/64"
elif test -f "$with_ssl/lib64/libcrypto.so"; then
SSL_LIBDIR="$with_ssl/lib64"
elif test -f "$with_ssl/lib/64/libcrypto.so"; then
SSL_LIBDIR="$with_ssl/lib/64"
else
SSL_LIBDIR="$with_ssl/lib"
fi
else
SSL_LIBDIR="$with_ssl/lib"
fi
if test '!' -f "${SSL_LIBDIR}/lib${SSL_CRYPTO_LIBNAME}.a"; then
SSL_DYNAMIC_ONLY=yes
elif test '!' -f ${SSL_LIBDIR}/lib${SSL_CRYPTO_LIBNAME}.so -a '!' -f "$SSL_LIBDIR/lib${SSL_CRYPTO_LIBNAME}.dylib"; then
SSL_STATIC_ONLY=yes
fi
SSL_INCLUDE="-I$with_ssl_incl/include"
SSL_APP=ssl
CRYPTO_APP=crypto
SSH_APP=ssh
if test "$cross_compiling" = "yes"; then
SSL_RUNTIME_LIBDIR=`echo "$SSL_LIBDIR" | sed -n "s|^$erl_xcomp_sysroot\(/*\)\(.*\)\$|/\2|p"`
else
SSL_RUNTIME_LIBDIR="$SSL_LIBDIR"
fi
esac
if test "x$SSL_APP" != "x" ; then
dnl We found openssl, now check if we use kerberos 5 support
dnl FIXME: Do we still support platforms that have Kerberos?
AC_MSG_CHECKING(for OpenSSL kerberos 5 support)
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=$SSL_INCLUDE
AC_EGREP_CPP(^yes$,[
#include <openssl/opensslv.h>
#include <openssl/opensslconf.h>
#if OPENSSL_VERSION_NUMBER < 0x1010000fL && !defined(OPENSSL_NO_KRB5)
yes
#endif
],[
AC_MSG_RESULT([yes])
ssl_krb5_enabled=yes
if test "x$SSL_DYNAMIC_ONLY" != "xyes"; then
if test -f "$SSL_LIBDIR/libkrb5.a"; then
SSL_LINK_WITH_KERBEROS=yes
STATIC_KERBEROS_LIBS="$SSL_LIBDIR/libkrb5.a"
if test -f "$SSL_LIBDIR/libkrb5support.a"; then
STATIC_KERBEROS_LIBS="$STATIC_KERBEROS_LIBS $SSL_LIBDIR/libkrb5support.a"
fi
if test -f "$SSL_LIBDIR/libk5crypto.a"; then
STATIC_KERBEROS_LIBS="$STATIC_KERBEROS_LIBS $SSL_LIBDIR/libk5crypto.a"
fi
if test -f "$SSL_LIBDIR/libresolv.a"; then
STATIC_KERBEROS_LIBS="$STATIC_KERBEROS_LIBS $SSL_LIBDIR/libresolv.a"
fi
if test -f "$SSL_LIBDIR/libcom_err.a"; then
STATIC_KERBEROS_LIBS="$STATIC_KERBEROS_LIBS $SSL_LIBDIR/libcom_err.a"
fi
else
AC_MSG_WARN([Kerberos needed but no kerberos static libraries found])
AC_MSG_WARN([Rescanning for dynamic SSL libraries])
enable_dynamic_ssl=yes
ssl_done=no
SSL_LINK_WITH_KERBEROS=no
STATIC_KERBEROS_LIBS=""
ssl_krb5_enabled=no
SSL_WITH_KERBEROS=no
fi
else
SSL_LINK_WITH_KERBEROS=no
STATIC_KERBEROS_LIBS=""
fi
],[
AC_MSG_RESULT([no])
ssl_krb5_enabled=no
SSL_WITH_KERBEROS=no
])
CPPFLAGS=$old_CPPFLAGS
SSL_KRB5_INCLUDE=
if test "x$ssl_krb5_enabled" = "xyes" ; then
AC_MSG_CHECKING(for krb5.h in standard locations)
for dir in $extra_dir "$SSL_INCDIR/include" "$SSL_INCDIR/include/openssl" \
"$SSL_INCDIR/include/kerberos" \
"$erl_xcomp_isysroot/cygdrive/c/kerberos/include" \
"$erl_xcomp_isysroot/usr/local/kerberos/include" \
"$erl_xcomp_isysroot/usr/kerberos/include" \
"$erl_xcomp_isysroot/usr/include"
do
if test -f "$dir/krb5.h" ; then
SSL_KRB5_INCLUDE="$dir"
break
fi
done
if test "x$SSL_KRB5_INCLUDE" = "x" ; then
AC_MSG_RESULT([not found])
SSL_APP=
CRYPTO_APP=
SSH_APP=
AC_MSG_WARN([OpenSSL is configured for kerberos but no krb5.h found])
for a in ssl crypto ssh ; do
echo "OpenSSL is configured for kerberos but no krb5.h found" > $ERL_TOP/lib/$a/SKIP
done
else
AC_MSG_RESULT([found in $SSL_KRB5_INCLUDE])
SSL_INCLUDE="$SSL_INCLUDE -I$SSL_KRB5_INCLUDE"
fi
fi
fi
done # while test ssl_done != yes
SSL_CC_RUNTIME_LIBRARY_PATH=
SSL_LD_RUNTIME_LIBRARY_PATH=
SSL_DED_LD_RUNTIME_LIBRARY_PATH=
cc_rflg="$CFLAG_RUNTIME_LIBRARY_PATH"
ld_rflg="$LDFLAG_RUNTIME_LIBRARY_PATH"
ded_ld_rflg="$DED_LD_FLAG_RUNTIME_LIBRARY_PATH"
case "$with_ssl_rpath" in
yes) # Use standard lib locations for ssl runtime library path
if test "$SSL_APP" != "" && test "$SSL_DYNAMIC_ONLY" = "yes" && \
{ test "$cc_rflg" != "" || test "$ld_rflg" != "" || test "$ded_ld_rflg" != ""; } ; then
AC_MSG_CHECKING(for ssl runtime library path to use)
libdirs="/lib"
if test "$ac_cv_sizeof_void_p" = "8"; then
dir_lib64=no
dir_lib_64=no
case "$SSL_RUNTIME_LIBDIR" in
*/lib/64 | */lib/64/ ) dir_lib_64=yes;;
*/lib64 | */lib64/ ) dir_lib64=yes;;
*) ;;
esac
for dir in $std_ssl_locations; do
test $dir_lib_64 = no &&
test -d "$erl_xcomp_sysroot$dir/lib/64" &&
dir_lib_64=yes
test $dir_lib64 = no &&
test -d "$erl_xcomp_sysroot$dir/lib64" &&
dir_lib64=yes
done
test $dir_lib_64 = yes && libdirs="/lib/64 $libdirs"
test $dir_lib64 = yes && libdirs="/lib64 $libdirs"
fi
for type in std x_std curr; do
cc_rpath="$cc_rflg$SSL_RUNTIME_LIBDIR"
ld_rpath="$ld_rflg$SSL_RUNTIME_LIBDIR"
ded_ld_rpath="$ded_ld_rflg$SSL_RUNTIME_LIBDIR"
rpath="$SSL_RUNTIME_LIBDIR"
if test $type != curr; then
for ldir in $libdirs; do
for dir in $std_ssl_locations; do
test "$SSL_LIBDIR" != "$dir$ldir" || continue
test $type != x_std || test -d "$dir$ldir" || continue
test "$cc_rflg" = "" ||
cc_rpath="$cc_rpath $cc_rflg$dir$ldir"
test "$ld_rflg" = "" ||
ld_rpath="$ld_rpath $ld_rflg$dir$ldir"
test "$ded_ld_rflg" = "" ||
ded_ld_rpath="$ded_ld_rpath $ded_ld_rflg$dir$ldir"
rpath="$rpath:$dir$ldir"
done
done
fi
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$CFLAGS $SSL_INCLUDE"
LDFLAGS="$LDFLAGS $ld_rpath -L$SSL_LIBDIR"
LIBS="-lcrypto"
AC_TRY_LINK([
#include <stdio.h>
#include <openssl/hmac.h>
],
[
HMAC(0, 0, 0, 0, 0, 0, 0);
],
[rpath_success=yes],
[rpath_success=no])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
test "$rpath_success" = "yes" && break
done
test "$rpath_success" = "yes" || { cc_rpath=; ld_rpath=; ded_ld_rpath=; rpath=; }
SSL_CC_RUNTIME_LIBRARY_PATH="$cc_rpath"
SSL_LD_RUNTIME_LIBRARY_PATH="$ld_rpath"
SSL_DED_LD_RUNTIME_LIBRARY_PATH="$ded_ld_rpath"
AC_MSG_RESULT([$rpath])
test "$rpath" != "" || AC_MSG_WARN([Cannot set run path during linking])
fi
;;
no) # Use no ssl runtime library path
SSL_DED_LD_RUNTIME_LIBRARY_PATH=
;;
*) # Use ssl runtime library paths set by --with-ssl-rpath (without any check)
ded_ld_rpath=
delimit=
for dir in `echo $with_ssl_rpath | sed "s/,/ /g"`; do
ded_ld_rpath="$ded_ld_rpath$delimit$ded_ld_rflg$dir"
delimit=" "
done
SSL_DED_LD_RUNTIME_LIBRARY_PATH="$ded_ld_rpath"
;;
esac
AC_ARG_ENABLE(fips,
AS_HELP_STRING([--enable-fips], [enable OpenSSL FIPS mode support])
AS_HELP_STRING([--disable-fips], [disable OpenSSL FIPS mode support (default)]),
[ case "$enableval" in
yes) enable_fips_support=yes ;;
*) enable_fips_support=no ;;
esac ], enable_fips_support=no)
if test "x$enable_fips_support" = "xyes" && test "$CRYPTO_APP" != ""; then
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$CFLAGS $SSL_INCLUDE"
LDFLAGS="$LDFLAGS $SSL_LD_RUNTIME_LIBRARY_PATH -L$SSL_LIBDIR"
LIBS="-lcrypto"
AC_CHECK_FUNC([FIPS_mode_set],
[SSL_FLAGS="-DFIPS_SUPPORT"],
[SSL_FLAGS=])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
else
SSL_FLAGS=
fi
#--------------------------------------------------------------------
# Os mon stuff.
#--------------------------------------------------------------------
AC_SUBST(os_mon_programs)
AC_SUBST(CPU_SUP_LIBS)
AC_CHECK_LIB(kstat, kstat_open, [
use_cpu_sup=yes
CPU_SUP_LIBS="$CPU_SUP_LIBS -lkstat"
])
AC_CHECK_LIB(kvm, kvm_open, [
use_cpu_sup=yes
CPU_SUP_LIBS="$CPU_SUP_LIBS -lkvm"
])
case $host_os in
solaris2*)
os_mon_programs="$os_mon_programs ferrule mod_syslog" ;;
darwin*)
use_cpu_sup=yes ;;
openbsd*)
use_cpu_sup=yes ;;
linux*)
use_cpu_sup=yes ;;
freebsd*)
use_cpu_sup=yes ;;
esac
if test "$use_cpu_sup" = "yes"; then
os_mon_programs="$os_mon_programs cpu_sup"
fi
AC_ARG_WITH(javac,
AS_HELP_STRING([--with-javac=JAVAC], [specify Java compiler to use])
AS_HELP_STRING([--with-javac], [use a Java compiler if found (default)])
AS_HELP_STRING([--without-javac], [don't use any Java compiler]))
dnl
dnl Then there are a number of apps which needs a java compiler...
dnl
need_java="jinterface ic/java_src"
# Remove all SKIP files from previous runs
for a in $need_java ; do
$RM -f $ERL_TOP/lib/$a/SKIP
done
if test "X$with_javac" = "Xno"; then
for a in $need_java ; do
echo "Java compiler disabled by user" > $ERL_TOP/lib/$a/SKIP
done
else # begin - try to find javac
if test "X$with_javac" != "Xyes" -a "X$with_javac" != "X"; then
check_javac=$with_javac
else
check_javac="javac.sh javac guavac gcj jikes bock"
fi
AC_CHECK_PROGS(JAVAC, $check_javac)
if test -n "$JAVAC"; then
dnl Make sure it's at least JDK 1.6
AC_CACHE_CHECK(for JDK version 1.6,
ac_cv_prog_javac_ver_1_6,
[ERL_TRY_LINK_JAVA([], [for (String i : args);
int[] values = {}; String s = new String(values, 0, values.length);],
ac_cv_prog_javac_ver_1_6=yes, ac_cv_prog_javac_ver_1_6=no)])
if test $ac_cv_prog_javac_ver_1_6 = no; then
unset -v JAVAC
fi
fi
if test -z "$JAVAC"; then
if test "X$with_javac" != "X"; then
AC_MSG_ERROR([No java compiler found in PATH (checked for $check_javac)])
fi
AC_MSG_WARN([Could not find any usable java compiler, will skip: jinterface])
for a in $need_java ; do
echo "No Java compiler found" > $ERL_TOP/lib/$a/SKIP
done
fi
fi # end - try to find javac
dnl
dnl Orber has a c++ example, this isn't the right way to check for
dnl it, but....
dnl
AC_SUBST(CXXFLAGS)
dnl this deliberately does not believe that 'gcc' is a C++ compiler
AC_CHECK_TOOLS(CXX, [$CCC c++ g++ CC cxx cc++ cl], false)
# Remove SKIP file from previous run
$RM -f $ERL_TOP/lib/orber/SKIP
if test "$CXX" = false; then
echo "No C++ compiler found" > $ERL_TOP/lib/orber/SKIP
fi
dnl ----------------------------------------------------------------------
dnl Include CPPFLAGS in CFLAGS
dnl ----------------------------------------------------------------------
CFLAGS="$CFLAGS $CPPFLAGS"
#
# Currently if we compile for 64 bits we want to compile
# some external port programs using 32 bits
#
# If not defined we trust the C compiler in $CC to do 32 bits
if test -z "$CC32"; then
CC32="$CC"
fi
if test -z "$CFLAGS32"; then
if test $ac_cv_sizeof_void_p != 4; then
# We are compiling default 64 bits and use -m32 for 32 bit compilations
CFLAGS32="$CFLAGS -m32"
else
CFLAGS32="$CFLAGS"
fi
fi
AC_SUBST(CC32)
AC_SUBST(CFLAGS32)
dnl
dnl ERTS_EMU_CMDLINE_FLAGS will force modification of config.h when
dnl the emulator command line flags are modified by configure, which
dnl in turn will make 'make' detect that files depending on config.h
dnl needs to be rebuilt.
dnl
AC_DEFINE_UNQUOTED(ERTS_EMU_CMDLINE_FLAGS,
"$STATIC_CFLAGS $CFLAGS $DEBUG_CFLAGS $EMU_THR_DEFS $DEFS $WERRORFLAGS $WFLAGS",
[The only reason ERTS_EMU_CMDLINE_FLAGS exists is to force modification of config.h when the emulator command line flags are modified by configure])
dnl ----------------------------------------------------------------------
dnl Directories needed for the build
dnl ----------------------------------------------------------------------
erts=${erl_top}/erts
erts_dirs="
$erts/obj $erts/obj.debug
$erts/obj/$host
$erts/obj.debug/$host
"
for d in ${erl_top}/bin ${erl_top}/bin/$host $erts_dirs ;
do
if test ! -d $d; then
mkdir -p 1>/dev/null 2>&1 $d
fi
done
dnl ---------------------------------------------------------------------
dnl Autoheader macro for adding code at top and bottom of config.h.in
dnl ---------------------------------------------------------------------
AH_TOP([
#define GHBN_R_SOLARIS 2
#define GHBN_R_AIX 3
#define GHBN_R_GLIBC 4
])
AH_BOTTOM([
/* Redefine in6_addr. XXX this should be moved to the files where it's used? */
#ifdef HAVE_IN_ADDR6_STRUCT
#define in6_addr in_addr6
#endif
/* Define a reasonable default for INADDR_LOOPBACK */
/* XXX this should be moved to the files where it's used? */
#ifdef HAVE_NO_INADDR_LOOPBACK
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
#ifdef REDEFINE_FD_SETSIZE
#define FD_SETSIZE 1024
#endif
#ifdef HAVE_GETHRVTIME_PROCFS_IOCTL
#define HAVE_GETHRVTIME
#endif
#if !defined(HAVE_ISFINITE) && !defined(HAVE_FINITE)
# if defined(HAVE_ISINF) && defined(HAVE_ISNAN)
# define USE_ISINF_ISNAN
# endif
#endif
#if defined(DEBUG) && !defined(ERTS_ENABLE_LOCK_CHECK)
#define ERTS_ENABLE_LOCK_CHECK 1
#endif
])
if test "x$GCC" = xyes; then
CFLAGS="$WERRORFLAGS $CFLAGS"
fi
dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------
m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])
dnl ----------------------------------------------------------------------
dnl Check for log2
dnl ----------------------------------------------------------------------
AC_CHECK_FUNCS([log2])
dnl ----------------------------------------------------------------------
dnl Output the result.
dnl ----------------------------------------------------------------------
dnl Note that the output files are relative to $srcdir
AC_CONFIG_FILES([
emulator/$host/Makefile:emulator/Makefile.in
epmd/src/$host/Makefile:epmd/src/Makefile.in
etc/common/$host/Makefile:etc/common/Makefile.in
include/internal/$host/ethread.mk:include/internal/ethread.mk.in
include/internal/$host/erts_internal.mk:include/internal/erts_internal.mk.in
lib_src/$host/Makefile:lib_src/Makefile.in
../make/$host/otp.mk:../make/otp.mk.in
../make/$host/otp_ded.mk:../make/otp_ded.mk.in
])
AC_CONFIG_FILES([../make/make_emakefile:../make/make_emakefile.in],
[chmod +x ../make/make_emakefile])
dnl
dnl The ones below should be moved to their respective lib
dnl
dnl ../lib/ssl/c_src/$host/Makefile:../lib/ssl/c_src/Makefile.in
AC_CONFIG_FILES([
../lib/os_mon/c_src/$host/Makefile:../lib/os_mon/c_src/Makefile.in
../lib/crypto/c_src/$host/Makefile:../lib/crypto/c_src/Makefile.in
../lib/runtime_tools/c_src/$host/Makefile:../lib/runtime_tools/c_src/Makefile.in
../lib/tools/c_src/$host/Makefile:../lib/tools/c_src/Makefile.in
])
AC_OUTPUT
|