summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGeneratorFactory.h
diff options
context:
space:
mode:
authorPatrick Gansterer <paroga@paroga.com>2012-11-19 14:48:33 (GMT)
committerBrad King <brad.king@kitware.com>2012-11-19 17:54:30 (GMT)
commite8f841473bcefc618ddf6712567e624156e88399 (patch)
tree2c77a631bcf9ee7c0cf731354db30c87a1cae312 /Source/cmGlobalGeneratorFactory.h
parent3359d95c00c221328d284e443c1d49e12630be63 (diff)
downloadCMake-e8f841473bcefc618ddf6712567e624156e88399.zip
CMake-e8f841473bcefc618ddf6712567e624156e88399.tar.gz
CMake-e8f841473bcefc618ddf6712567e624156e88399.tar.bz2
Introduce the abstract class cmGlobalGeneratorFactory
This new abstract class allows us move some logic from the cmGlobalGenerator into its own layer in a next step.
Diffstat (limited to 'Source/cmGlobalGeneratorFactory.h')
-rw-r--r--Source/cmGlobalGeneratorFactory.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
new file mode 100644
index 0000000..05c8420
--- /dev/null
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -0,0 +1,51 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmGlobalGeneratorFactory_h
+#define cmGlobalGeneratorFactory_h
+
+#include "cmStandardIncludes.h"
+
+class cmGlobalGenerator;
+struct cmDocumentationEntry;
+
+/** \class cmGlobalGeneratorFactory
+ * \brief Responable for creating cmGlobalGenerator instances
+ *
+ * Subclasses of this class generate instances of cmGlobalGenerator.
+ */
+class cmGlobalGeneratorFactory
+{
+public:
+ virtual ~cmGlobalGeneratorFactory() {}
+
+ /** Create a GlobalGenerator */
+ virtual cmGlobalGenerator* CreateGlobalGenerator() const = 0;
+
+ /** Get the documentation entry for this factory */
+ virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
+};
+
+template<class T>
+class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
+{
+public:
+ /** Create a GlobalGenerator */
+ virtual cmGlobalGenerator* CreateGlobalGenerator() const {
+ return new T; }
+
+ /** Get the documentation entry for this factory */
+ virtual void GetDocumentation(cmDocumentationEntry& entry) const {
+ T().GetDocumentation(entry); }
+};
+
+#endif
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 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843
#!/bin/sh
#############################################################################
##
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation (qt-info@nokia.com)
##
## This file is the build configuration utility of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:LGPL$
## No Commercial Usage
## This file contains pre-release code and may not be distributed.
## You may use this file in accordance with the terms and conditions
## contained in the Technology Preview License Agreement accompanying
## this package.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file.  Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Nokia gives you certain additional
## rights.  These rights are described in the Nokia Qt LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
## If you have questions regarding the use of this file, please contact
## Nokia at qt-info@nokia.com.
##
##
##
##
##
##
##
##
## $QT_END_LICENSE$
##
#############################################################################

#-------------------------------------------------------------------------------
# script initialization
#-------------------------------------------------------------------------------

# the name of this script
relconf=`basename $0`
# the directory of this script is the "source tree"
relpath=`dirname $0`
relpath=`(cd "$relpath"; /bin/pwd)`
# the current directory is the "build tree" or "object tree"
outpath=`/bin/pwd`

#license file location
LICENSE_FILE="$QT_LICENSE_FILE"
[ -z "$LICENSE_FILE" ] && LICENSE_FILE="$HOME/.qt-license"
if [ -f "$LICENSE_FILE" ]; then
    tr -d '\r' <"$LICENSE_FILE" >"${LICENSE_FILE}.tmp"
    diff "${LICENSE_FILE}.tmp" "${LICENSE_FILE}" >/dev/null 2>&1 || LICENSE_FILE="${LICENSE_FILE}.tmp"
fi

# later cache the command line in config.status
OPT_CMDLINE=`echo $@ | sed "s,-v ,,g; s,-v$,,g"`

# initialize global variables
QMAKE_SWITCHES=
QMAKE_VARS=
QMAKE_CONFIG=
QTCONFIG_CONFIG=
QT_CONFIG=
SUPPORTED=
QMAKE_VARS_FILE=.qmake.vars

:> "$QMAKE_VARS_FILE"

#-------------------------------------------------------------------------------
# utility functions
#-------------------------------------------------------------------------------

shellEscape()
{
    echo "$@" | sed 's/ /\ /g'
}

# Adds a new qmake variable to the cache
# Usage: QMakeVar mode varname contents
#   where mode is one of: set, add, del
QMakeVar()
{
    case "$1" in
	set)
	    eq="="
	    ;;
	add)
	    eq="+="
	    ;;
	del)
	    eq="-="
	    ;;
	*)
	    echo >&2 "BUG: wrong command to QMakeVar: $1"
	    ;;
    esac

    echo "$2" "$eq" "$3" >> "$QMAKE_VARS_FILE"
}

# Helper function for getQMakeConf. It parses include statements in
# qmake.conf and prints out the expanded file
getQMakeConf1()
{
    while read line; do case "$line" in
        include*)
	    inc_file=`echo "$line" | sed -n -e "/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p"`
	    current_dir=`dirname "$1"`
	    conf_file="$current_dir/$inc_file"
	    if [ ! -f  "$conf_file" ]; then
                echo "WARNING: Unable to find file $conf_file" >&2
                continue
            fi
            getQMakeConf1 "$conf_file"
        ;;
        *)
            echo "$line"
        ;;
    esac; done < "$1"
}


# relies on $QMAKESPEC being set correctly. parses include statements in
# qmake.conf and prints out the expanded file
getQMakeConf()
{
    tmpSPEC="$QMAKESPEC"
    if [ -n "$1" ]; then
        tmpSPEC="$1"
    fi
    getQMakeConf1 "$tmpSPEC/qmake.conf"
}

# relies on $TEST_COMPILER being set correctly
compilerSupportsFlag()
{
    cat >conftest.cpp <<EOF
int main() { return 0; }
EOF
    "$TEST_COMPILER" "$@" -o conftest.o conftest.cpp
    ret=$?
    rm -f conftest.cpp conftest.o
    return $ret
}

# relies on $TEST_COMPILER being set correctly
linkerSupportsFlag()
{
    lflags=-Wl
    for flag
    do
	safe_flag=`shellEscape "$flag"`
	lflags=$lflags,$safe_flag
    done
    compilerSupportsFlag "$lflags" >/dev/null 2>&1
}

#-------------------------------------------------------------------------------
# operating system detection
#-------------------------------------------------------------------------------

# need that throughout the script
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown

# detect the "echo without newline" style. usage: echo $ECHO_N "<string>$ECHO_C"
if echo '\c' | grep '\c' >/dev/null; then
    ECHO_N=-n
else
    ECHO_C='\c'
fi

#-------------------------------------------------------------------------------
# window system detection
#-------------------------------------------------------------------------------

PLATFORM_X11=no
PLATFORM_MAC=no
PLATFORM_QWS=maybe
PLATFORM_QPA=maybe
BUILD_ON_MAC=no;
[ -d /System/Library/Frameworks/Carbon.framework ] && BUILD_ON_MAC=yes

if [ -f "$relpath"/src/gui/kernel/qapplication_mac.mm ] && [ $BUILD_ON_MAC = "yes" ]; then
    # Qt/Mac
    # ~ the Carbon SDK exists
    # ~ src/gui/base/qapplication_mac.cpp is present
    # ~ this is the internal edition and Qt/Mac sources exist
    PLATFORM_MAC=maybe
elif [ -f "$relpath"/src/gui/kernel/qapplication_qws.cpp ]; then
    # Qt Embedded
    # ~ src/gui/base/qapplication_qws.cpp is present
    # ~ this is the free or commercial edition
    # ~ this is the internal edition and Qt Embedded is explicitly enabled
    if [ -f "$relpath"/src/gui/kernel/qapplication_mac.mm ]; then
        # This is a depot build, or an all-platforms package
        PLATFORM_QWS=maybe
    else
        # This must be the embedded package, since the Qt/Mac source files are not present
	PLATFORM_QWS=yes
    fi
fi

#-----------------------------------------------------------------------------
# Qt version detection
#-----------------------------------------------------------------------------
QT_VERSION=`grep '^# *define *QT_VERSION_STR' "$relpath"/src/corelib/global/qglobal.h`
QT_MAJOR_VERSION=
QT_MINOR_VERSION=0
QT_PATCH_VERSION=0
if [ -n "$QT_VERSION" ]; then
   QT_VERSION=`echo $QT_VERSION | sed 's,^# *define *QT_VERSION_STR *"*\([^ ]*\)"$,\1,'`
   MAJOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'`
   if [ -n "$MAJOR" ]; then
     MINOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'`
      PATCH=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'`
      QT_MAJOR_VERSION="$MAJOR"
      [ -z "$MINOR" ] || QT_MINOR_VERSION="$MINOR"
      [ -z "$PATCH" ] || QT_PATCH_VERSION="$PATCH"
   fi
fi
if [ -z "$QT_MAJOR_VERSION" ]; then
   echo "Cannot process version from qglobal.h: $QT_VERSION"
   echo "Cannot proceed."
   exit 1
fi

QT_PACKAGEDATE=`grep '^# *define *QT_PACKAGEDATE_STR' "$relpath"/src/corelib/global/qglobal.h | sed -e 's,^# *define *QT_PACKAGEDATE_STR *"\([^ ]*\)"$,\1,' -e s,-,,g`
if [ -z "$QT_PACKAGEDATE" ]; then
   echo "Unable to determine package date from qglobal.h: '$QT_PACKAGEDATE'"
   echo "Cannot proceed"
   exit 1
fi

#-------------------------------------------------------------------------------
# check the license
#-------------------------------------------------------------------------------
COMMERCIAL_USER=ask
CFG_DEV=no
CFG_NOKIA=no
CFG_EMBEDDED=no
CFG_RTOS_ENABLED=yes
EditionString=Commercial

earlyArgParse()
{
    # parse the arguments, setting things to "yes" or "no"
    while [ "$#" -gt 0 ]; do
        CURRENT_OPT="$1"
        UNKNOWN_ARG=no
        case "$1" in
        #Autoconf style options
        --enable-*)
            VAR=`echo $1 | sed "s,^--enable-\(.*\),\1,"`
            VAL=yes
            ;;
        --disable-*)
            VAR=`echo $1 | sed "s,^--disable-\(.*\),\1,"`
            VAL=no
            ;;
        --*=*)
            VAR=`echo $1 | sed "s,^--\(.*\)=.*,\1,"`
            VAL=`echo $1 | sed "s,^--.*=\(.*\),\1,"`
            ;;
        --no-*)
            VAR=`echo $1 | sed "s,^--no-\(.*\),\1,"`
            VAL=no
            ;;
        -embedded)
            VAR=embedded
            # this option may or may not be followed by an argument
            if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
                VAL=auto
            else
                shift;
                VAL=$1
            fi
            ;;
        -embedded-lite|-qpa)
            VAR=qpa
            # this option may or may not be followed by an argument
            if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
                VAL=auto
            else
                shift;
                VAL=$1
            fi
            ;;
        -nacl)
            shift;
            VAR=nacl
            VAL=$1
            ;;

        -h|help|--help|-help)
            if [ "$VAL" = "yes" ]; then
                OPT_HELP="$VAL"
                COMMERCIAL_USER="no" #doesn't matter we will display the help
            else
                UNKNOWN_OPT=yes
                COMMERCIAL_USER="no" #doesn't matter we will display the help
            fi
            ;;
        --*)
            VAR=`echo $1 | sed "s,^--\(.*\),\1,"`
            VAL=yes
            ;;
        -*)
            VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
            VAL="unknown"
            ;;
        *)
            UNKNOWN_ARG=yes
            ;;
        esac
        if [ "$UNKNOWN_ARG" = "yes" ]; then
            shift
            continue
        fi
        shift

        UNKNOWN_OPT=no
        case "$VAR" in
        embedded)
            CFG_EMBEDDED="$VAL"
            if [ "$PLATFORM_QWS" != "no" ]; then
                if [ "$PLATFORM_QWS" = "maybe" ]; then
                    PLATFORM_X11=no
                    PLATFORM_MAC=no
                    PLATFORM_QWS=yes
                    PLATFORM_QPA=no
                fi
            else
                echo "No license exists to enable Qt for Embedded Linux. Disabling."
                CFG_EMBEDDED=no
            fi
            ;;
        qpa)
            CFG_EMBEDDED="$VAL"
            if [ "$PLATFORM_QPA" != "no" ]; then
                if [ "$PLATFORM_QPA" = "maybe" ]; then
                    PLATFORM_X11=no
                    PLATFORM_MAC=no
                    PLATFORM_QWS=no
                    PLATFORM_QPA=yes
                fi
            else
                echo "No license exists to enable Qt QPA. Disabling."
                CFG_EMBEDDED=no
            fi
            ;;
        nacl)
            echo "Using NaCl at $VAL."
            PLATFORM_X11=no
            PLATFORM_MAC=no
            PLATFORM_QWS=no
            CFG_NACL_PATH=$VAL
            CFG_EMBEDDED=nacl
            ;;

        developer-build)
            CFG_DEV="yes"
            ;;
        nokia-developer)
            CFG_DEV="yes"
            CFG_NOKIA="yes"
            COMMERCIAL_USER="no"
            ;;
        commercial)
            COMMERCIAL_USER="yes"
            ;;
        opensource)
            COMMERCIAL_USER="no"
            ;;
        *)
            UNKNOWN_OPT=yes
            ;;
        esac
    done
}

earlyArgParse "$@"

if [ "$COMMERCIAL_USER" = "ask" ]; then
    while true; do
        echo "Which edition of Qt do you want to use ?"
        echo
        echo "Type 'c' if you want to use the Commercial Edition."
        echo "Type 'o' if you want to use the Open Source Edition."
        echo
        read commercial
        echo
        if [ "$commercial" = "c" ]; then
            COMMERCIAL_USER="yes"
            break
        elif [ "$commercial" = "o" ]; then
            COMMERCIAL_USER="no"
            break
        fi
    done
fi

if [ "$CFG_NOKIA" = "yes" ]; then
    Licensee="Nokia"
    Edition="NokiaInternalBuild"
    EditionString="Nokia Internal Build"
    QT_EDITION="QT_EDITION_OPENSOURCE"
    [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes
elif [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" ]; then
    # Commercial preview release
    [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes
    Licensee="Preview"
    Edition="Preview"
    QT_EDITION="QT_EDITION_DESKTOP"
    LicenseType="Technology Preview"
elif [ $COMMERCIAL_USER = "yes" ]; then
    # one of commercial editions
    [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes
    [ "$PLATFORM_QPA" = "maybe" ] && PLATFORM_QPA=no
    [ "$PLATFORM_QWS" = "maybe" ] && PLATFORM_QWS=no

    # read in the license file
    if [ -f "$LICENSE_FILE" ]; then
        . "$LICENSE_FILE" >/dev/null 2>&1
        if [ -z "$LicenseKeyExt" ]; then
            echo
            echo "You are using an old license file."
            echo
            echo "Please install the license file supplied by Nokia,"
            echo "or install the Qt Open Source Edition if you intend to"
            echo "develop free software."
            exit 1
        fi
	if [ -z "$Licensee" ]; then
	    echo
	    echo "Invalid license key. Please check the license key."
	    exit 1
	fi
    else
        if [ -z "$LicenseKeyExt" ]; then
            echo
            echo $ECHO_N "Please enter your license key: $ECHO_C"
            read LicenseKeyExt
            Licensee="Unknown user"
        fi
    fi

    # Key verification
    echo "$LicenseKeyExt" | grep ".....*-....*-....*-....*-.....*-.....*-...." >/dev/null 2>&1 \
        && LicenseValid="yes" \
        || LicenseValid="no"
    if [ "$LicenseValid" != "yes" ]; then
        echo
        echo "Invalid license key. Please check the license key."
        exit 1
    fi
    ProductCode=`echo $LicenseKeyExt | cut -f 1 -d - | cut -b 1`
    PlatformCode=`echo $LicenseKeyExt | cut -f 2 -d -`
    LicenseTypeCode=`echo $LicenseKeyExt | cut -f 3 -d -`
    LicenseFeatureCode=`echo $LicenseKeyExt | cut -f 4 -d - | cut -b 1`

    # determine which edition we are licensed to use
    case "$LicenseTypeCode" in
    F4M)
        LicenseType="Commercial"
        case $ProductCode in
        F)
            Edition="Universal"
            QT_EDITION="QT_EDITION_UNIVERSAL"
            ;;
        B)
            Edition="FullFramework"
            EditionString="Full Framework"
            QT_EDITION="QT_EDITION_DESKTOP"
            ;;
        L)
            Edition="GUIFramework"
            EditionString="GUI Framework"
            QT_EDITION="QT_EDITION_DESKTOPLIGHT"
            ;;
        esac
        ;;
    Z4M|R4M|Q4M)
        LicenseType="Evaluation"
        QMakeVar add DEFINES QT_EVAL
        case $ProductCode in
         B)
            Edition="Evaluation"
            QT_EDITION="QT_EDITION_EVALUATION"
            ;;
        esac
        ;;
    esac
    if [ -z "$LicenseType" -o -z "$Edition" -o -z "$QT_EDITION" ]; then
        echo
        echo "Invalid license key. Please check the license key."
        exit 1
    fi

    # verify that we are licensed to use Qt on this platform
    LICENSE_EXTENSION=
    case "$PlatformCode" in
	*L)
	    CFG_RTOS_ENABLED=yes
	    PlatformCode=`echo "$PlatformCode" | sed 'h;y/8NPQRTZ/UCWX9M7/;x;G;s/\(.\)....\(.\)./\1\2/'`
	    ;;
	*)
	    CFG_RTOS_ENABLED=no
	    PlatformCode=`echo "$PlatformCode" | sed 's/.$//'`
	    ;;
    esac
    ### EMBEDDED_QPA logic missing ###
    case "$PlatformCode,$PLATFORM_MAC,$PLATFORM_QWS" in
        X9,* | XC,* | XU,* | XW,* | XM,*)
            # Qt All-OS
            LICENSE_EXTENSION="-ALLOS"
            ;;
        8M,* | KM,* | S9,* | SC,* | SU,* | SW,* | X9,* | XC,* | XU,* | XW,*)
            # Qt for Embedded Linux
            LICENSE_EXTENSION="-EMBEDDED"
            ;;
        6M,*,no | N7,*,no | N9,*,no | NX,*,no)
            # Embedded no-deploy
            LICENSE_EXTENSION="-EMBEDDED"
            ;;
        FM,*,no | LM,yes,* | ZM,no,no)
            # Desktop
            LICENSE_EXTENSION="-DESKTOP"
            ;;
        *)
            Platform=Linux/X11
            [ "$PLATFORM_MAC" = "yes" ] && Platform='Mac OS X'
            [ "$PLATFORM_QWS" = "yes" ] && Platform='Embedded Linux'
            echo
            echo "You are not licensed for the $Platform platform."
            echo
            echo "Please contact qt-info@nokia.com to upgrade your license to"
            echo "include the $Platform platform, or install the Qt Open Source Edition"
            echo "if you intend to develop free software."
            exit 1
            ;;
    esac

    if test -r "$relpath/.LICENSE"; then
	# Generic, non-final license
	LICENSE_EXTENSION=""
	line=`sed 'y/a-z/A-Z/;q' "$relpath"/.LICENSE`
	case "$line" in
	    *BETA*)
		Edition=Beta
		;;
	    *TECHNOLOGY?PREVIEW*)
		Edition=Preview
		;;
	    *EVALUATION*)
		Edition=Evaluation
		;;
	    *)
		echo >&2 "Invalid license files; cannot continue"
		exit 1
		;;
	esac
	Licensee="$Edition"
	EditionString="$Edition"
	QT_EDITION="QT_EDITION_DESKTOP"
    fi

    case "$LicenseFeatureCode" in
    B|G|L|Y)
        # US
        case "$LicenseType" in
        Commercial)
            cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}-US" "$outpath/LICENSE"
            ;;
        Evaluation)
            cp -f "$relpath/.LICENSE-EVALUATION-US" "$outpath/LICENSE"
            ;;
        esac
        ;;
    2|4|5|F)
        # non-US
        case "$LicenseType" in
        Commercial)
            cp -f "$relpath/.LICENSE${LICENSE_EXTENSION}" "$outpath/LICENSE"
            ;;
        Evaluation)
            cp -f "$relpath/.LICENSE-EVALUATION" "$outpath/LICENSE"
            ;;
        esac
        ;;
    *)
        echo
        echo "Invalid license key. Please check the license key."
        exit 1
        ;;
    esac
    case "$LicenseFeatureCode" in
	4|B|F|Y)
	    CFG_RTOS_ENABLED=yes
	    ;;
	2|5|G|L)
	    CFG_RTOS_ENABLED=no
	    ;;
    esac
    if [ '!' -f "$outpath/LICENSE" ]; then
        echo "The LICENSE, LICENSE.GPL3 LICENSE.LGPL file shipped with"
        echo "this software has disappeared."
        echo
        echo "Sorry, you are not licensed to use this software."
        echo "Try re-installing."
        echo
        exit 1
    fi
elif [ $COMMERCIAL_USER = "no" ]; then
    # Open Source edition - may only be used under the terms of the GPL or LGPL.
    [ "$PLATFORM_MAC" = "maybe" ] && PLATFORM_MAC=yes
    Licensee="Open Source"
    Edition="OpenSource"
    EditionString="Open Source"
    QT_EDITION="QT_EDITION_OPENSOURCE"
fi

#-------------------------------------------------------------------------------
# initalize variables
#-------------------------------------------------------------------------------

SYSTEM_VARIABLES="CC CXX CFLAGS CXXFLAGS LDFLAGS"
for varname in $SYSTEM_VARIABLES; do
    qmakevarname="${varname}"
    # use LDFLAGS for autoconf compat, but qmake uses QMAKE_LFLAGS
    if [ "${varname}" = "LDFLAGS" ]; then
        qmakevarname="LFLAGS"
    fi
    cmd=`echo \
'if [ -n "\$'${varname}'" ]; then
    QMakeVar set QMAKE_'${qmakevarname}' "\$'${varname}'"
fi'`
    eval "$cmd"
done
# Use CC/CXX to run config.tests
mkdir -p "$outpath/config.tests"
rm -f "$outpath/config.tests/.qmake.cache"
cp "$QMAKE_VARS_FILE" "$outpath/config.tests/.qmake.cache"

QMakeVar add styles "cde mac motif plastique cleanlooks windows"
QMakeVar add decorations "default windows styled"
QMakeVar add mouse-drivers "pc"
if [ "$UNAME_SYSTEM" = "Linux" ] ; then
    QMakeVar add gfx-drivers "linuxfb"
    QMakeVar add mouse-drivers "linuxtp"
fi
QMakeVar add kbd-drivers "tty"

if [ "$CFG_DEV" = "yes" ]; then
    QMakeVar add kbd-drivers "um"
fi

# QTDIR may be set and point to an old or system-wide Qt installation
unset QTDIR

# the minimum version of libdbus-1 that we require:
MIN_DBUS_1_VERSION=0.93

# initalize internal variables
CFG_CONFIGURE_EXIT_ON_ERROR=yes
CFG_PROFILE=no
CFG_EXCEPTIONS=unspecified
CFG_GUI=auto # (yes|no|auto)
CFG_SCRIPT=auto # (yes|no|auto)
CFG_SCRIPTTOOLS=auto # (yes|no|auto)
CFG_XMLPATTERNS=auto # (yes|no|auto)
CFG_INCREMENTAL=auto
CFG_QCONFIG=full
CFG_DEBUG=auto
CFG_MYSQL_CONFIG=
CFG_DEBUG_RELEASE=no
CFG_SHARED=yes
CFG_SM=auto
CFG_XSHAPE=auto
CFG_XSYNC=auto
CFG_XVIDEO=auto
CFG_XINERAMA=runtime
CFG_XFIXES=runtime
CFG_ZLIB=auto
CFG_SYMBIAN_DEFFILES=auto
CFG_S60=auto
CFG_SQLITE=qt
CFG_GIF=auto
CFG_TIFF=auto
CFG_LIBTIFF=auto
CFG_PNG=yes
CFG_LIBPNG=auto
CFG_JPEG=auto
CFG_LIBJPEG=auto
CFG_MNG=auto
CFG_LIBMNG=auto
CFG_XCURSOR=runtime
CFG_XRANDR=runtime
CFG_XRENDER=auto
CFG_MITSHM=auto
CFG_OPENGL=auto
CFG_OPENVG=no
CFG_OPENVG_LC_INCLUDES=no
CFG_OPENVG_SHIVA=no
CFG_OPENVG_ON_OPENGL=no
CFG_EGL=no
CFG_EGL_GLES_INCLUDES=no
CFG_SSE=auto
CFG_FONTCONFIG=auto
CFG_QWS_FREETYPE=auto
CFG_LIBFREETYPE=auto
CFG_SQL_AVAILABLE=
QT_DEFAULT_BUILD_PARTS="libs tools examples demos docs translations"
CFG_BUILD_PARTS=""
CFG_NOBUILD_PARTS=""
CFG_RELEASE_QMAKE=no
CFG_PHONON=auto
CFG_PHONON_BACKEND=yes
CFG_MULTIMEDIA=auto
CFG_AUDIO_BACKEND=auto
CFG_SVG=auto
CFG_DECLARATIVE=auto
CFG_WEBKIT=auto # (yes|no|auto)
CFG_JAVASCRIPTCORE_JIT=auto

CFG_GFX_AVAILABLE="linuxfb transformed qvfb vnc multiscreen directfb"
CFG_GFX_ON="linuxfb multiscreen"
CFG_GFX_PLUGIN_AVAILABLE=
CFG_GFX_PLUGIN=
CFG_GFX_OFF=
CFG_KBD_AVAILABLE="tty linuxinput qvfb"
CFG_KBD_ON="tty"    #default, see QMakeVar above
CFG_MOUSE_AVAILABLE="pc linuxtp linuxinput tslib qvfb"
CFG_MOUSE_ON="pc linuxtp"   #default, see QMakeVar above

if [ -f "$relpath/src/gui/embedded/qscreenqnx_qws.cpp" ]; then
    CFG_KBD_AVAILABLE="${CFG_KBD_AVAILABLE} qnx"
    CFG_MOUSE_AVAILABLE="${CFG_MOUSE_AVAILABLE} qnx"
    CFG_GFX_AVAILABLE="${CFG_GFX_AVAILABLE} qnx"
fi

CFG_ARCH=
CFG_HOST_ARCH=
CFG_KBD_PLUGIN_AVAILABLE=
CFG_KBD_PLUGIN=
CFG_KBD_OFF=
CFG_MOUSE_PLUGIN_AVAILABLE=
CFG_MOUSE_PLUGIN=
CFG_MOUSE_OFF=
CFG_USE_GNUMAKE=no
CFG_IM=yes
CFG_DECORATION_AVAILABLE="styled windows default"
CFG_DECORATION_ON="${CFG_DECORATION_AVAILABLE}" # all on by default
CFG_DECORATION_PLUGIN_AVAILABLE=
CFG_DECORATION_PLUGIN=
CFG_XINPUT=runtime
CFG_XKB=auto
CFG_NIS=auto
CFG_CUPS=auto
CFG_ICONV=auto
CFG_DBUS=auto
CFG_GLIB=auto
CFG_GSTREAMER=auto
CFG_QGTKSTYLE=auto
CFG_QS60STYLE=auto
CFG_LARGEFILE=auto
CFG_OPENSSL=auto
CFG_PTMALLOC=no
CFG_STL=auto
CFG_PRECOMPILE=auto
CFG_SEPARATE_DEBUG_INFO=no
CFG_SEPARATE_DEBUG_INFO_NOCOPY=no
CFG_REDUCE_EXPORTS=auto
CFG_MMX=auto
CFG_3DNOW=auto
CFG_SSE=auto
CFG_SSE2=auto
CFG_SSE3=auto
CFG_SSSE3=auto
CFG_SSE4_1=auto
CFG_SSE4_2=auto
CFG_AVX=auto
CFG_REDUCE_RELOCATIONS=no
CFG_IPV6=auto
CFG_NAS=no
CFG_QWS_DEPTHS=all
CFG_USER_BUILD_KEY=
CFG_ACCESSIBILITY=auto
CFG_QT3SUPPORT=yes
CFG_ENDIAN=auto
CFG_HOST_ENDIAN=auto
CFG_DOUBLEFORMAT=auto
CFG_ARMFPA=auto
CFG_IWMMXT=no
CFG_NEON=auto
CFG_CLOCK_GETTIME=auto
CFG_CLOCK_MONOTONIC=auto
CFG_MREMAP=auto
CFG_GETADDRINFO=auto
CFG_IPV6IFNAME=auto
CFG_GETIFADDRS=auto
CFG_INOTIFY=auto
CFG_RPATH=yes
CFG_FRAMEWORK=auto
CFG_MAC_ARCHS=
MAC_CONFIG_TEST_COMMANDLINE=  # used to make the configure tests run with the correct arch's and SDK settings
CFG_MAC_DWARF2=auto
CFG_MAC_XARCH=auto
CFG_MAC_CARBON=no
CFG_MAC_COCOA=yes
COMMANDLINE_MAC_CARBON=no
CFG_SXE=no
CFG_PREFIX_INSTALL=yes
CFG_SDK=
D_FLAGS=
I_FLAGS=
L_FLAGS=
RPATH_FLAGS=
l_FLAGS=
QCONFIG_FLAGS=
XPLATFORM=              # This seems to be the QMAKESPEC, like "linux-g++" or "symbian/linux-gcce"
XPLATFORM_MINGW=no      # Whether target platform is MinGW (win32-g++*)
PLATFORM=$QMAKESPEC
QT_CROSS_COMPILE=no
OPT_CONFIRM_LICENSE=no
OPT_SHADOW=maybe
OPT_FAST=auto
OPT_VERBOSE=no
OPT_HELP=
CFG_SILENT=no
CFG_GRAPHICS_SYSTEM=default
CFG_RUNTIME_SYSTEM=
CFG_ALSA=auto
CFG_PULSEAUDIO=auto
CFG_COREWLAN=auto
CFG_ICD=auto

# initalize variables used for installation
QT_INSTALL_PREFIX=
QT_INSTALL_DOCS=
QT_INSTALL_HEADERS=
QT_INSTALL_LIBS=
QT_INSTALL_BINS=
QT_INSTALL_PLUGINS=
QT_INSTALL_IMPORTS=
QT_INSTALL_DATA=
QT_INSTALL_TRANSLATIONS=
QT_INSTALL_SETTINGS=
QT_INSTALL_EXAMPLES=
QT_INSTALL_DEMOS=
QT_HOST_PREFIX=

#flags for SQL drivers
QT_CFLAGS_PSQL=
QT_LFLAGS_PSQL=
QT_CFLAGS_MYSQL=
QT_LFLAGS_MYSQL=
QT_LFLAGS_MYSQL_R=
QT_CFLAGS_SQLITE=
QT_LFLAGS_SQLITE=
QT_LFLAGS_ODBC="-lodbc"
QT_LFLAGS_TDS=

# flags for libdbus-1
QT_CFLAGS_DBUS=
QT_LIBS_DBUS=

# flags for Glib (X11 only)
QT_CFLAGS_GLIB=
QT_LIBS_GLIB=

# flags for GStreamer (X11 only)
QT_CFLAGS_GSTREAMER=
QT_LIBS_GSTREAMER=

# flags for libconnsettings0 (used for Maemo ICD bearer management plugin)
QT_CFLAGS_CONNSETTINGS=
QT_LIBS_CONNSETTINGS=

#-------------------------------------------------------------------------------
# check SQL drivers, mouse drivers and decorations available in this package
#-------------------------------------------------------------------------------

# opensource version removes some drivers, so force them to be off
CFG_SQL_tds=no
CFG_SQL_oci=no
CFG_SQL_db2=no

CFG_SQL_AVAILABLE=
if [ -d "$relpath/src/plugins/sqldrivers" ]; then
  for a in "$relpath/src/plugins/sqldrivers/"*; do
     if [ -d "$a" ]; then
	 base_a=`basename "$a"`
  	 CFG_SQL_AVAILABLE="${CFG_SQL_AVAILABLE} ${base_a}"
	 eval "CFG_SQL_${base_a}=auto"
     fi
  done
fi

CFG_DECORATION_PLUGIN_AVAILABLE=
if [ -d "$relpath/src/plugins/decorations" ]; then
  for a in "$relpath/src/plugins/decorations/"*; do
     if [ -d "$a" ]; then
	 base_a=`basename "$a"`
  	 CFG_DECORATION_PLUGIN_AVAILABLE="${CFG_DECORATION_PLUGIN_AVAILABLE} ${base_a}"
     fi
  done
fi

CFG_KBD_PLUGIN_AVAILABLE=
if [ -d "$relpath/src/plugins/kbddrivers" ]; then
  for a in "$relpath/src/plugins/kbddrivers/"*; do
     if [ -d "$a" ]; then
	 base_a=`basename "$a"`
  	 CFG_KBD_PLUGIN_AVAILABLE="${CFG_KBD_PLUGIN_AVAILABLE} ${base_a}"
     fi
  done
fi

CFG_MOUSE_PLUGIN_AVAILABLE=
if [ -d "$relpath/src/plugins/mousedrivers" ]; then
  for a in "$relpath/src/plugins/mousedrivers/"*; do
     if [ -d "$a" ]; then
	 base_a=`basename "$a"`
  	 CFG_MOUSE_PLUGIN_AVAILABLE="${CFG_MOUSE_PLUGIN_AVAILABLE} ${base_a}"
     fi
  done
fi

CFG_GFX_PLUGIN_AVAILABLE=
if [ -d "$relpath/src/plugins/gfxdrivers" ]; then
  for a in "$relpath/src/plugins/gfxdrivers/"*; do
     if [ -d "$a" ]; then
	 base_a=`basename "$a"`
  	 CFG_GFX_PLUGIN_AVAILABLE="${CFG_GFX_PLUGIN_AVAILABLE} ${base_a}"
     fi
  done
  CFG_GFX_OFF="$CFG_GFX_AVAILABLE" # assume all off
fi

#-------------------------------------------------------------------------------
# Set Default NaCl options
#-------------------------------------------------------------------------------
if [ "$CFG_EMBEDDED" = "nacl" ]; then
    echo "Setting NaCl options:"
    echo "-static"
    CFG_SHARED=no
    echo "-qpa nacl"
    PLATFORM_QPA=yes
    echo "-fast"
    OPT_FAST=yes
    echo "-release"
    CFG_DEBUG=no
    echo "-qconfig minimal-system-dependencies"
    CFG_QCONFIG=minimal-system-dependencies

    if [ `uname` = "Linux" ]; then
        I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/include"
        L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/linux_x86/sdk/nacl-sdk/lib"
    else
        I_FLAGS="$I_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/include"
        L_FLAGS="$L_FLAGS -I${CFG_NACL_PATH}/toolchain/mac_x86/sdk/nacl-sdk/lib"
    fi

    echo "-no-multimedia -no-webkit -no-phonon -no-nultimedia -no-mediaservices -no-xmlpatterns -no-script -no-sql-sqlite -nomake tests"
    CFG_MULTIMEDIA=no
    CFG_WEBKIT=no
    CFG_PHONON=no
    CFG_MULTIMEDIA=no
    CFG_MEDIASERVICES=no
    CFG_XMLPATTERNS=no
    CFG_SCRIPT=no
    CFG_SQLITE=no
    CFG_SQL_sqlite=no
    CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS tests"
    QT_CONFIG="$QT_CONFIG nacl"
fi

#-------------------------------------------------------------------------------
# parse command line arguments
#-------------------------------------------------------------------------------

# parse the arguments, setting things to "yes" or "no"
while [ "$#" -gt 0 ]; do
    CURRENT_OPT="$1"
    UNKNOWN_ARG=no
    case "$1" in
    #Autoconf style options
    --enable-*)
        VAR=`echo $1 | sed "s,^--enable-\(.*\),\1,"`
        VAL=yes
        ;;
    --disable-*)
        VAR=`echo $1 | sed "s,^--disable-\(.*\),\1,"`
        VAL=no
        ;;
    --*=*)
        VAR=`echo $1 | sed "s,^--\(.*\)=.*,\1,"`
        VAL=`echo $1 | sed "s,^--.*=\(.*\),\1,"`
        ;;
    --no-*)
        VAR=`echo $1 | sed "s,^--no-\(.*\),\1,"`
        VAL=no
        ;;
    --*)
        VAR=`echo $1 | sed "s,^--\(.*\),\1,"`
        VAL=yes
        ;;
    #Qt plugin options
    -no-*-*|-plugin-*-*|-qt-*-*)
        VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
        VAL=`echo $1 | sed "s,^-\([^-]*\).*,\1,"`
        ;;
    #Qt style no options
    -no-*)
        VAR=`echo $1 | sed "s,^-no-\(.*\),\1,"`
        VAL=no
        ;;
    #Qt style yes options
        -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        VAL=yes
        ;;
    #Qt style options that pass an argument
    -qconfig)
        if [ "$PLATFORM_QWS" != "yes" -a "$PLATFORM_QPA" != "yes" ]; then
            echo
            echo "WARNING: -qconfig is only tested and supported on Qt for Embedded Linux."
            echo
        fi
        CFG_QCONFIG="$VAL"
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        shift
        VAL=$1
        ;;
    -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-demosdir|-depths|-make|-nomake|-platform|-xplatform|-buildkey|-sdk|-arch|-host-arch|-mysql_config)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        shift
        VAL="$1"
        ;;
    #Qt style complex options in one command
    -enable-*|-disable-*)
        VAR=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"`
        VAL=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
        ;;
    #Qt Builtin/System style options
    -no-*|-system-*|-qt-*)
        VAR=`echo $1 | sed "s,^-[^-]*-\(.*\),\1,"`
        VAL=`echo $1 | sed "s,^-\([^-]*\)-.*,\1,"`
        ;;
    #Options that cannot be generalized
    -k|-continue)
        VAR=fatal_error
        VAL=no
        ;;
    -embedded)
        VAR=embedded
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=auto
        else
            shift;
            VAL=$1
        fi
	;;
    -embedded-lite|-qpa)
        VAR=qpa
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=auto
        else
            shift;
            VAL=$1
        fi
	;;
    -nacl)
        VAR=nacl
        shift;
    ;;
    -opengl)
        VAR=opengl
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=yes
        else
            shift;
            VAL=$1
        fi
	;;
    -openvg)
        VAR=openvg
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=yes
        else
            shift;
            VAL=$1
        fi
	;;
    -hostprefix)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=$outpath
        else
            shift;
            VAL=$1
        fi
        ;;
    -host-*-endian)
        VAR=host_endian
        VAL=`echo $1 | sed "s,^-.*-\(.*\)-.*,\1,"`
        ;;
    -*-endian)
        VAR=endian
        VAL=`echo $1 | sed "s,^-\(.*\)-.*,\1,"`
        ;;
    -qtnamespace)
        VAR="qtnamespace"
        shift
        VAL="$1"
        ;;
    -graphicssystem)
	VAR="graphicssystem"
	shift
	VAL=$1
	;;
    -runtimegraphicssystem)
	VAR="runtimegraphicssystem"
	shift
	VAL=$1
	;;
    -qtlibinfix)
        VAR="qtlibinfix"
        shift
        VAL="$1"
        ;;
    -D?*|-D)
        VAR="add_define"
        if [ "$1" = "-D" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-D,,'`
        fi
        ;;
    -I?*|-I)
        VAR="add_ipath"
        if [ "$1" = "-I" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-I,,'`
        fi
        ;;
    -L?*|-L)
        VAR="add_lpath"
        if [ "$1" = "-L" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-L,,'`
        fi
        ;;
    -R?*|-R)
        VAR="add_rpath"
        if [ "$1" = "-R" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-R,,'`
        fi
        ;;
    -l?*)
        VAR="add_link"
        VAL=`echo $1 | sed 's,-l,,'`
        ;;
    -F?*|-F)
        VAR="add_fpath"
        if [ "$1" = "-F" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-F,,'`
        fi
        ;;
    -fw?*|-fw)
        VAR="add_framework"
        if [ "$1" = "-fw" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-fw,,'`
        fi
        ;;
    -*)
        VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
        VAL="unknown"
        ;;
    *)
        UNKNOWN_ARG=yes
        ;;
    esac
    if [ "$UNKNOWN_ARG" = "yes" ]; then
        echo "$1: unknown argument"
        OPT_HELP=yes
        ERROR=yes
        shift
        continue
     fi
    shift

    UNKNOWN_OPT=no
    case "$VAR" in
    qt3support)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_QT3SUPPORT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    accessibility)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ACCESSIBILITY="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    license)
	LICENSE_FILE="$VAL"
	;;
    gnumake)
        CFG_USE_GNUMAKE="$VAL"
        ;;
    mysql_config)
	CFG_MYSQL_CONFIG="$VAL"
	;;
    prefix)
        QT_INSTALL_PREFIX="$VAL"
        ;;
    hostprefix)
	QT_HOST_PREFIX="$VAL"
	;;
    force-pkg-config)
        QT_FORCE_PKGCONFIG=yes
        ;;
    docdir)
        QT_INSTALL_DOCS="$VAL"
        ;;
    headerdir)
        QT_INSTALL_HEADERS="$VAL"
        ;;
    plugindir)
        QT_INSTALL_PLUGINS="$VAL"
        ;;
    importdir)
        QT_INSTALL_IMPORTS="$VAL"
        ;;
    datadir)
        QT_INSTALL_DATA="$VAL"
        ;;
    libdir)
        QT_INSTALL_LIBS="$VAL"
        ;;
    qtnamespace)
        QT_NAMESPACE="$VAL"
        ;;
    qtlibinfix)
        QT_LIBINFIX="$VAL"
        ;;
    translationdir)
        QT_INSTALL_TRANSLATIONS="$VAL"
        ;;
    sysconfdir|settingsdir)
        QT_INSTALL_SETTINGS="$VAL"
        ;;
    examplesdir)
        QT_INSTALL_EXAMPLES="$VAL"
        ;;
    demosdir)
        QT_INSTALL_DEMOS="$VAL"
        ;;
    qconfig)
        CFG_QCONFIG="$VAL"
        ;;
    bindir)
        QT_INSTALL_BINS="$VAL"
        ;;
    buildkey)
        CFG_USER_BUILD_KEY="$VAL"
        ;;
    sxe)
	CFG_SXE="$VAL"
        ;;
    embedded)
        CFG_EMBEDDED="$VAL"
        if [ "$PLATFORM_QWS" != "no" ]; then
            if [ "$PLATFORM_QWS" = "maybe" ]; then
                PLATFORM_X11=no
                PLATFORM_MAC=no
                PLATFORM_QWS=yes
                PLATFORM_QPA=no
            fi
        else
            echo "No license exists to enable Qt for Embedded Linux. Disabling."
            CFG_EMBEDDED=no
        fi
        ;;
    embedded-lite|qpa)
        CFG_EMBEDDED="$VAL"
        if [ "$PLATFORM_QPA" != "no" ]; then
            if [ "$PLATFORM_QPA" = "maybe" ]; then
                PLATFORM_X11=no
                PLATFORM_MAC=no
                PLATFORM_QWS=no
                PLATFORM_QPA=yes
            fi
        else
            echo "No license exists to enable Qt QPA. Disabling."
            CFG_EMBEDDED=no
        fi
        ;;
    nacl)
        ;;
    sse)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SSE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
	;;
    endian)
        if [ "$VAL" = "little" ]; then
            CFG_ENDIAN="Q_LITTLE_ENDIAN"
        elif [ "$VAL" = "big" ]; then
            CFG_ENDIAN="Q_BIG_ENDIAN"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    host_endian)
        if [ "$VAL" = "little" ]; then
            CFG_HOST_ENDIAN="Q_LITTLE_ENDIAN"
        elif [ "$VAL" = "big" ]; then
            CFG_HOST_ENDIAN="Q_BIG_ENDIAN"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    armfpa)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ARMFPA="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    depths)
        CFG_QWS_DEPTHS="$VAL"
        ;;
    opengl)
        if  [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] ||
            [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] ||
            [ "$VAL" = "es1" ] || [ "$VAL" = "es2" ]; then
            CFG_OPENGL="$VAL"
            if  [ "$VAL" = "es1" ] || [ "$VAL" = "es2" ]; then
                CFG_EGL="yes"
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    openvg)
        if [ "$VAL" = "auto" ] || [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_OPENVG="$VAL"
            CFG_EGL="auto"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    graphicssystem)
        if [ "$PLATFORM_QWS" = "yes" ]; then
            echo "Error: Graphics System plugins are not supported on QWS."
            echo "   On QWS, the graphics system API is part of the QScreen plugin architecture "
            echo "   rather than existing as a separate plugin."
            echo ""
            UNKNOWN_OPT=yes
        else
            if  [ "$VAL" = "opengl" ]; then
                CFG_GRAPHICS_SYSTEM="opengl"
            elif [ "$VAL" = "openvg" ]; then
                CFG_GRAPHICS_SYSTEM="openvg"
            elif [ "$VAL" = "raster" ]; then
                CFG_GRAPHICS_SYSTEM="raster"
            elif [ "$VAL" = "runtime" ]; then
                CFG_GRAPHICS_SYSTEM="runtime"
            else
                UNKNOWN_OPT=yes
            fi
        fi
	;;
    runtimegraphicssystem)
        if  [ "$VAL" != "runtime" ]; then
            CFG_RUNTIME_SYSTEM="$VAL"
        fi
	;;

    qvfb) # left for commandline compatibility, not documented
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            if [ "$VAL" = "yes" ]; then
		QMakeVar add gfx-drivers qvfb
		QMakeVar add kbd-drivers qvfb
		QMakeVar add mouse-drivers qvfb
                CFG_GFX_ON="$CFG_GFX_ON qvfb"
                CFG_KBD_ON="$CFG_KBD_ON qvfb"
                CFG_MOUSE_ON="$CFG_MOUSE_ON qvfb"
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    nomake)
	CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS $VAL"
        ;;
    make)
	CFG_BUILD_PARTS="$CFG_BUILD_PARTS $VAL"
        ;;
    x11)
        if [ "$PLATFORM_MAC" = "yes" ]; then
            PLATFORM_MAC=no
        elif [ "$PLATFORM_QWS" = "yes" ]; then
            PLATFORM_QWS=no
        elif [ "$PLATFORM_QPA" = "yes" ]; then
            PLATFORM_QPA=no
        fi
        if [ "$CFG_FRAMEWORK" = "auto" ]; then
            CFG_FRAMEWORK=no
        fi
        PLATFORM_X11=yes
        ;;
    sdk)
        if [ "$PLATFORM_MAC" = "yes" ]; then
            CFG_SDK="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
	;;
     dwarf2)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MAC_DWARF2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
	;;
    arch)
        # if this is a Mac then "windows" probably means
        # we are cross-compiling for MinGW
        if [ "$PLATFORM_MAC" = "yes" ] && [ "$VAL" != "windows" ]; then
            CFG_MAC_ARCHS="$CFG_MAC_ARCHS $VAL"
        else
            CFG_ARCH=$VAL
        fi
        ;;
    host-arch)
        CFG_HOST_ARCH=$VAL
        ;;
    universal)
        if [ "$PLATFORM_MAC" = "yes" ] && [ "$VAL" = "yes" ]; then
            CFG_MAC_ARCHS="$CFG_MAC_ARCHS x86 ppc"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    cocoa)
#       do nothing - Cocoa is the default.
        ;;
    carbon)
        if [ "$PLATFORM_MAC" = "yes" ] && [ "$VAL" = "yes" ]; then
            CFG_MAC_CARBON="$VAL"
            COMMANDLINE_MAC_CARBON="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;

    framework)
        if [ "$PLATFORM_MAC" = "yes" ]; then
            CFG_FRAMEWORK="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    profile)
        if [ "$VAL" = "yes" ]; then
            CFG_PROFILE=yes
	    QMakeVar add QMAKE_CFLAGS -pg
	    QMakeVar add QMAKE_CXXFLAGS -pg
	    QMakeVar add QMAKE_LFLAGS -pg
            QMAKE_VARS="$QMAKE_VARS CONFIG+=nostrip"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    exceptions|g++-exceptions)
        if [ "$VAL" = "no" ]; then
            CFG_EXCEPTIONS=no
        elif [ "$VAL" = "yes" ]; then
            CFG_EXCEPTIONS=yes
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    platform)
        PLATFORM="$VAL"
        # keep compatibility with old platform names
        case $PLATFORM in
        aix-64)
            PLATFORM=aix-xlc-64
            ;;
        hpux-o64)
            PLATFORM=hpux-acc-o64
            ;;
        hpux-n64)
            PLATFORM=hpux-acc-64
            ;;
        hpux-acc-n64)
            PLATFORM=hpux-acc-64
            ;;
        irix-n32)
            PLATFORM=irix-cc
            ;;
        irix-64)
            PLATFORM=irix-cc-64
            ;;
        irix-cc-n64)
            PLATFORM=irix-cc-64
            ;;
        reliant-64)
            PLATFORM=reliant-cds-64
            ;;
        solaris-64)
            PLATFORM=solaris-cc-64
            ;;
        solaris-64)
            PLATFORM=solaris-cc-64
            ;;
        openunix-cc)
            PLATFORM=unixware-cc
            ;;
        openunix-g++)
            PLATFORM=unixware-g++
            ;;
        unixware7-cc)
            PLATFORM=unixware-cc
            ;;
        unixware7-g++)
            PLATFORM=unixware-g++
            ;;
        macx-g++-64)
            PLATFORM=macx-g++
	    NATIVE_64_ARCH=
            case `uname -p` in
            i386) NATIVE_64_ARCH="x86_64" ;;
            powerpc) NATIVE_64_ARCH="ppc64" ;;
            *)   echo "WARNING: Can't detect CPU architecture for macx-g++-64" ;;
            esac
	    if [ ! -z "$NATIVE_64_ARCH" ]; then
		QTCONFIG_CONFIG="$QTCONFIG_CONFIG $NATIVE_64_ARCH"
		CFG_MAC_ARCHS="$CFG_MAC_ARCHS $NATIVE_64_ARCH"
            fi
            ;;
        esac
        ;;
    xplatform)
        XPLATFORM="$VAL"
        case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac
        ;;
    debug-and-release)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_DEBUG_RELEASE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    optimized-qmake)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_RELEASE_QMAKE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    release)
        if [ "$VAL" = "yes" ]; then
            CFG_DEBUG=no
        elif [ "$VAL" = "no" ]; then
            CFG_DEBUG=yes
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    prefix-install)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
	    CFG_PREFIX_INSTALL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
	;;
    debug)
        CFG_DEBUG="$VAL"
        ;;
    developer-build|commercial|opensource|nokia-developer)
        # These switches have been dealt with already
        ;;
    static)
        if [ "$VAL" = "yes" ]; then
            CFG_SHARED=no
        elif [ "$VAL" = "no" ]; then
            CFG_SHARED=yes
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    incremental)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_INCREMENTAL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    fatal_error)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_CONFIGURE_EXIT_ON_ERROR="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    feature-*)
            FEATURE=`echo $VAR | sed "s,^[^-]*-\([^-]*\),\1," | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
            if [ "$VAL" = "no" ]; then
                QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_$FEATURE"
            elif [ "$VAL" = "yes" ] || [ "$VAL" = "unknown" ]; then
                QCONFIG_FLAGS="$QCONFIG_FLAGS QT_$FEATURE"
            else
                UNKNOWN_OPT=yes
            fi
        ;;
    shared)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SHARED="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gif)
        [ "$VAL" = "qt" ] && VAL=auto
        if [ "$VAL" = "auto" ] || [ "$VAL" = "no" ]; then
            CFG_GIF="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sm)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SM="$VAL"
        else
            UNKNOWN_OPT=yes
        fi

        ;;
    xinerama)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then
            CFG_XINERAMA="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xshape)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XSHAPE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xvideo)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XVIDEO="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xsync)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XSYNC="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xinput)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then
            CFG_XINPUT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    egl)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_EGL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    stl)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_STL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    pch)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PRECOMPILE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    separate-debug-info)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SEPARATE_DEBUG_INFO="$VAL"
        elif [ "$VAL" = "nocopy" ] ; then
            CFG_SEPARATE_DEBUG_INFO="yes"
            CFG_SEPARATE_DEBUG_INFO_NOCOPY="yes"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    reduce-exports)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_REDUCE_EXPORTS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    mmx)
        if [ "$VAL" = "no" ]; then
            CFG_MMX="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    3dnow)
        if [ "$VAL" = "no" ]; then
            CFG_3DNOW="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sse)
        if [ "$VAL" = "no" ]; then
            CFG_SSE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sse2)
        if [ "$VAL" = "no" ]; then
            CFG_SSE2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sse3)
        if [ "$VAL" = "no" ]; then
            CFG_SSE3="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    ssse3)
        if [ "$VAL" = "no" ]; then
            CFG_SSSE3="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sse4.1)
        if [ "$VAL" = "no" ]; then
            CFG_SSE4_1="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sse4.2)
        if [ "$VAL" = "no" ]; then
            CFG_SSE4_2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    avx)
        if [ "$VAL" = "no" ]; then
            CFG_AVX="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    iwmmxt)
	CFG_IWMMXT="yes"
	;;
    neon)
        if [ "$VAL" = "no" ]; then
            CFG_NEON="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    reduce-relocations)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_REDUCE_RELOCATIONS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    freetype)
        [ "$VAL" = "qt" ] && VAL=yes
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_QWS_FREETYPE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    zlib)
        [ "$VAL" = "qt" ] && VAL=yes
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_ZLIB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        # No longer supported:
        #[ "$VAL" = "no" ] && CFG_LIBPNG=no
        ;;
    s60)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_S60="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    usedeffiles)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SYMBIAN_DEFFILES="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sqlite)
        if [ "$VAL" = "system" ]; then
            CFG_SQLITE=system
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libpng)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_LIBPNG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libjpeg)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_LIBJPEG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libmng)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_LIBMNG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libtiff)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_LIBTIFF="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    nas-sound)
        if [ "$VAL" = "system" ] || [ "$VAL" = "no" ]; then
            CFG_NAS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xcursor)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then
            CFG_XCURSOR="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xfixes)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then
            CFG_XFIXES="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xrandr)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then
            CFG_XRANDR="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xrender)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XRENDER="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    mitshm)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MITSHM="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    fontconfig)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_FONTCONFIG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xkb)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XKB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    cups)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_CUPS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    iconv)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ICONV="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    glib)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_GLIB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gstreamer)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_GSTREAMER="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gtkstyle)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_QGTKSTYLE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    style-s60)
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ]; then
            CFG_QS60STYLE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gui)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_GUI="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_GUI="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    qdbus|dbus)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "linked" ]; then
            CFG_DBUS="$VAL"
	elif [ "$VAL" = "runtime" ]; then
	    CFG_DBUS="yes"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    dbus-linked)
        if [ "$VAL" = "yes" ]; then
	    CFG_DBUS="linked"
	else
            UNKNOWN_OPT=yes
        fi
        ;;
    nis)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_NIS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    largefile)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LARGEFILE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    openssl)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_OPENSSL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    openssl-linked)
        if [ "$VAL" = "yes" ]; then
            CFG_OPENSSL="linked"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    ptmalloc)
        if [ "$VAL" = "yes" ]; then
            CFG_PTMALLOC="yes"
        else
            UNKNOWN_OPT=yes
        fi
        ;;

    xmlpatterns)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_XMLPATTERNS="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_XMLPATTERNS="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    script)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_SCRIPT="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_SCRIPT="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    scripttools)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_SCRIPTTOOLS="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_SCRIPTTOOLS="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    svg)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_SVG="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_SVG="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    declarative)
        if [ "$VAL" = "yes" ]; then
            CFG_DECLARATIVE="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_DECLARATIVE="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
	;;
    webkit)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_WEBKIT="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_WEBKIT="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    javascript-jit)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ] || [ "$VAL" = "no" ]; then 
            CFG_JAVASCRIPTCORE_JIT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    confirm-license)
        if [ "$VAL" = "yes" ]; then
            OPT_CONFIRM_LICENSE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    h|help)
        if [ "$VAL" = "yes" ]; then
            OPT_HELP="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sql-*|gfx-*|decoration-*|kbd-*|mouse-*)
        # if Qt style options were used, $VAL can be "no", "qt", or "plugin"
        # if autoconf style options were used, $VAL can be "yes" or "no"
        [ "$VAL" = "yes" ] && VAL=qt
        # now $VAL should be "no", "qt", or "plugin"... double-check
        if [ "$VAL" != "no" ] && [ "$VAL" != "qt" ] && [ "$VAL" != "plugin" ]; then
            UNKNOWN_OPT=yes
        fi
        # now $VAL is "no", "qt", or "plugin"
        OPT="$VAL"
        VAL=`echo $VAR | sed "s,^[^-]*-\([^-]*\).*,\1,"`
        VAR=`echo $VAR | sed "s,^\([^-]*\).*,\1,"`

        # Grab the available values
        case "$VAR" in
        sql)
            avail="$CFG_SQL_AVAILABLE"
            ;;
        gfx)
            avail="$CFG_GFX_AVAILABLE"
	    if [ "$OPT" = "plugin" ]; then
		avail="$CFG_GFX_PLUGIN_AVAILABLE"
	    fi
            ;;
        decoration)
            avail="$CFG_DECORATION_AVAILABLE"
	    if [ "$OPT" = "plugin" ]; then
		avail="$CFG_DECORATION_PLUGIN_AVAILABLE"
	    fi
            ;;
        kbd)
            avail="$CFG_KBD_AVAILABLE"
	    if [ "$OPT" = "plugin" ]; then
		avail="$CFG_KBD_PLUGIN_AVAILABLE"
	    fi
            ;;
        mouse)
            avail="$CFG_MOUSE_AVAILABLE"
	    if [ "$OPT" = "plugin" ]; then
		avail="$CFG_MOUSE_PLUGIN_AVAILABLE"
	    fi
            ;;
        *)
            avail=""
            echo "BUG: Unhandled type $VAR used in $CURRENT_OPT"
            ;;
        esac

        # Check that that user's value is available.
        found=no
        for d in $avail; do
            if [ "$VAL" = "$d" ]; then
                found=yes
                break
            fi
        done
        [ "$found" = yes ] || ERROR=yes

        if [ "$VAR" = "sql" ]; then
            # set the CFG_SQL_driver
            eval "CFG_SQL_$VAL=\$OPT"
            continue
        fi

        if [ "$OPT" = "plugin" ] || [ "$OPT" = "qt" ]; then
            if [ "$OPT" = "plugin" ]; then
                [ "$VAR" = "decoration" ] && QMakeVar del "${VAR}s" "$VAL"
                [ "$VAR" = "decoration" ] && CFG_DECORATION_ON=`echo "${CFG_DECORATION_ON} " | sed "s,${VAL} ,,g"` && CFG_DECORATION_PLUGIN="$CFG_DECORATION_PLUGIN ${VAL}"
                [ "$VAR" = "kbd" ] && QMakeVar del "${VAR}s" "$VAL"
                [ "$VAR" = "kbd" ] && CFG_KBD_ON=`echo "${CFG_KBD_ON} " | sed "s,${VAL} ,,g"` && CFG_KBD_PLUGIN="$CFG_KBD_PLUGIN ${VAL}"
                [ "$VAR" = "mouse" ] && QMakeVar del "${VAR}s" "$VAL"
                [ "$VAR" = "mouse" ] && CFG_MOUSE_ON=`echo "${CFG_MOUSE_ON} " | sed "s,${VAL} ,,g"` && CFG_MOUSE_PLUGIN="$CFG_MOUSE_PLUGIN ${VAL}"
                [ "$VAR" = "gfx" ] && QMakeVar del "${VAR}s" "$VAL"
                [ "$VAR" = "gfx" ] && CFG_GFX_ON=`echo "${CFG_GFX_ON} " | sed "s,${VAL} ,,g"` && CFG_GFX_PLUGIN="${CFG_GFX_PLUGIN} ${VAL}"
                VAR="${VAR}-${OPT}"
            else
                if [ "$VAR" = "gfx" ] || [ "$VAR" = "kbd" ] || [ "$VAR" = "decoration" ] || [ "$VAR" = "mouse" ]; then
                    [ "$VAR" = "gfx" ] && CFG_GFX_ON="$CFG_GFX_ON $VAL"
                    [ "$VAR" = "kbd" ] && CFG_KBD_ON="$CFG_KBD_ON $VAL"
		    [ "$VAR" = "decoration" ] && CFG_DECORATION_ON="$CFG_DECORATION_ON $VAL"
                    [ "$VAR" = "mouse" ] && CFG_MOUSE_ON="$CFG_MOUSE_ON $VAL"
                    VAR="${VAR}-driver"
                fi
            fi
	    QMakeVar add "${VAR}s" "${VAL}"
        elif [ "$OPT" = "no" ]; then
            PLUG_VAR="${VAR}-plugin"
            if [ "$VAR" = "gfx" ] || [ "$VAR" = "kbd" ] || [ "$VAR" = "mouse" ]; then
                IN_VAR="${VAR}-driver"
            else
                IN_VAR="${VAR}"
            fi
            [ "$VAR" = "decoration" ] && CFG_DECORATION_ON=`echo "${CFG_DECORATION_ON} " | sed "s,${VAL} ,,g"`
            [ "$VAR" = "gfx" ] && CFG_GFX_ON=`echo "${CFG_GFX_ON} " | sed "s,${VAL} ,,g"`
            [ "$VAR" = "kbd" ] && CFG_KBD_ON=`echo "${CFG_KBD_ON} " | sed "s,${VAL} ,,g"`
            [ "$VAR" = "mouse" ] && CFG_MOUSE_ON=`echo "${CFG_MOUSE_ON} " | sed "s,${VAL} ,,g"`
	    QMakeVar del "${IN_VAR}s" "$VAL"
	    QMakeVar del "${PLUG_VAR}s" "$VAL"
        fi
        if [ "$ERROR" = "yes" ]; then
           echo "$CURRENT_OPT: unknown argument"
           OPT_HELP=yes
        fi
        ;;
    v|verbose)
        if [ "$VAL" = "yes" ]; then
            if [ "$OPT_VERBOSE" = "$VAL" ]; then            # takes two verboses to turn on qmake debugs
                QMAKE_SWITCHES="$QMAKE_SWITCHES -d"
            else
                OPT_VERBOSE=yes
            fi
        elif [ "$VAL" = "no" ]; then
            if [ "$OPT_VERBOSE" = "$VAL" ] && echo "$QMAKE_SWITCHES" | grep ' -d' >/dev/null 2>&1; then
                QMAKE_SWITCHES=`echo $QMAKE_SWITCHES | sed "s, -d,,"`
            else
                OPT_VERBOSE=no
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    fast)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            OPT_FAST="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    rpath)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_RPATH="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    add_define)
        D_FLAGS="$D_FLAGS \"$VAL\""
        ;;
    add_ipath)
        I_FLAGS="$I_FLAGS -I\"${VAL}\""
        ;;
    add_lpath)
        L_FLAGS="$L_FLAGS -L\"${VAL}\""
        ;;
    add_rpath)
        RPATH_FLAGS="$RPATH_FLAGS \"${VAL}\""
        ;;
    add_link)
        l_FLAGS="$l_FLAGS -l\"${VAL}\""
        ;;
    add_fpath)
        if [ "$PLATFORM_MAC" = "yes" ]; then
            L_FLAGS="$L_FLAGS -F\"${VAL}\""
            I_FLAGS="$I_FLAGS -F\"${VAL}\""
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    add_framework)
        if [ "$PLATFORM_MAC" = "yes" ]; then
            l_FLAGS="$l_FLAGS -framework \"${VAL}\""
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    silent)
        CFG_SILENT="$VAL"
        ;;
    phonon)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PHONON="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    phonon-backend)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PHONON_BACKEND="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    multimedia)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MULTIMEDIA="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    audio-backend)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_AUDIO_BACKEND="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    *)
        UNKNOWN_OPT=yes
        ;;
    esac
    if [ "$UNKNOWN_OPT" = "yes" ]; then
        echo "${CURRENT_OPT}: invalid command-line switch"
        OPT_HELP=yes
        ERROR=yes
    fi
done

if [ "$CFG_QCONFIG" != "full" ] && [ "$CFG_QT3SUPPORT" = "yes" ]; then
    echo "Warning: '-qconfig $CFG_QCONFIG' will disable the qt3support library."
    CFG_QT3SUPPORT="no"
fi
if [ "$CFG_GUI" = "no" ]; then
    echo "Warning: -no-gui will disable the qt3support library."
    CFG_QT3SUPPORT="no"
fi

#disable Qt3Support for Lighthouse
if [ "$PLATFORM_QPA" = "yes" ]; then
    CFG_QT3SUPPORT="no"
fi

# update QT_CONFIG to show our current predefined configuration
case "$CFG_QCONFIG" in
minimal|small|medium|large|full)
    # these are a sequence of increasing functionality
    for c in minimal small medium large full; do
        QT_CONFIG="$QT_CONFIG $c-config"
        [ "$CFG_QCONFIG" = $c ] && break
    done
    ;;
*)
    # not known to be sufficient for anything
    if [ '!' -f "$relpath/src/corelib/global/qconfig-${CFG_QCONFIG}.h" ] && [ '!' -f `"$relpath/config.tests/unix/makeabs" "${CFG_QCONFIG}"` ]; then
        echo >&2 "Error: configuration file not found:"
        echo >&2 "  $relpath/src/corelib/global/qconfig-${CFG_QCONFIG}.h"
        echo >&2 "  or"
        echo >&2 "  `"$relpath/config.tests/unix/makeabs" "${CFG_QCONFIG}"`"
        OPT_HELP=yes
    fi
esac

#-------------------------------------------------------------------------------
# build tree initialization
#-------------------------------------------------------------------------------

# where to find which..
unixtests="$relpath/config.tests/unix"
mactests="$relpath/config.tests/mac"
symbiantests="$relpath/config.tests/symbian"
WHICH="$unixtests/which.test"

PERL=`$WHICH perl 2>/dev/null`

# find out which awk we want to use, prefer gawk, then nawk, then regular awk
AWK=
for e in gawk nawk awk; do
    if "$WHICH" $e >/dev/null 2>&1 && ( $e -f /dev/null /dev/null ) >/dev/null 2>&1; then
        AWK=$e
        break
    fi
done

# find perl
PERL="/usr/bin/perl"
if "$WHICH" perl >/dev/null 2>&1 && ( perl /dev/null ) >/dev/null 2>&1; then
    PERL=`$WHICH perl`
fi

### skip this if the user just needs help...
if [ "$OPT_HELP" != "yes" ]; then

# is this a shadow build?
if [ "$OPT_SHADOW" = "maybe" ]; then
    OPT_SHADOW=no
    if [ "$relpath" != "$outpath" ] && [ '!' -f "$outpath/configure" ]; then
        if [ -h "$outpath" ]; then
            [ "$relpath" -ef "$outpath" ] || OPT_SHADOW=yes
        else
            OPT_SHADOW=yes
        fi
    fi
fi
if [ "$OPT_SHADOW" = "yes" ]; then
    if [ -f "$relpath/.qmake.cache" -o -f "$relpath/src/corelib/global/qconfig.h" -o -f "$relpath/src/corelib/global/qconfig.cpp" ]; then
        echo >&2 "You cannot make a shadow build from a source tree containing a previous build."
        echo >&2 "Cannot proceed."
        exit 1
    fi
    [ "$OPT_VERBOSE" = "yes" ] && echo "Performing shadow build..."
fi

if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
    echo
    echo "WARNING: -debug-and-release is not supported anymore on Qt/X11 and Qt for Embedded Linux"
    echo "Qt can be built in release mode with separate debug information, so"
    echo "-debug-and-release is not necessary anymore"
    echo
fi

# detect build style
if [ "$CFG_DEBUG" = "auto" ]; then
    if [ "$PLATFORM_MAC" = "yes" ]; then
        CFG_DEBUG_RELEASE=yes
        CFG_DEBUG=yes
    elif [ "$CFG_DEV" = "yes" ]; then
        CFG_DEBUG_RELEASE=no
        CFG_DEBUG=yes
    else
        CFG_DEBUG_RELEASE=no
        CFG_DEBUG=no
    fi
fi
if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG build_all"
fi

if [ "$CFG_SILENT" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG silent"
fi

# if the source tree is different from the build tree,
# symlink or copy part of the sources
if [ "$OPT_SHADOW" = "yes" ]; then
    echo "Preparing build tree..."

    if [ -z "$PERL" ]; then
        echo
        echo "You need perl in your PATH to make a shadow build."
        echo "Cannot proceed."
        exit 1
    fi

    [ -d "$outpath/bin" ] || mkdir -p "$outpath/bin"

    # symlink the qmake directory
    find "$relpath/qmake" | while read a; do
        my_a=`echo "$a" | sed "s,^${relpath}/,${outpath}/,"`
        if [ '!' -f "$my_a" ]; then
            if [ -d "$a" ]; then
                # directories are created...
                mkdir -p "$my_a"
            else
                a_dir=`dirname "$my_a"`
                [ -d "$a_dir" ] || mkdir -p "$a_dir"
                # ... and files are symlinked
                case `basename "$a"` in
                *.o|*.d|GNUmakefile*|qmake)
                    ;;
                *)
                    rm -f "$my_a"
                    ln -s "$a" "$my_a"
                    ;;
                esac
            fi
        fi
    done

    # make a syncqt script that can be used in the shadow
    rm -f "$outpath/bin/syncqt"
    if [ -x "$relpath/bin/syncqt" ]; then
        mkdir -p "$outpath/bin"
        echo "#!/bin/sh" >"$outpath/bin/syncqt"
        echo "QTDIR=\"$relpath\"; export QTDIR" >>"$outpath/bin/syncqt"
        echo "perl \"$relpath/bin/syncqt\" -outdir \"$outpath\" \"\$@\"" >>"$outpath/bin/syncqt"
        chmod 755 "$outpath/bin/syncqt"
    fi

    for i in elf2e32_qtwrapper createpackage patch_capabilities; do
        rm -f "$outpath/bin/$i"
        if [ -x "$relpath/bin/$i" ]; then
            mkdir -p "$outpath/bin"
            echo "#!/bin/sh" >"$outpath/bin/$i"
            echo "QTDIR=\"$relpath\"; export QTDIR" >>"$outpath/bin/$i"
            echo "\"$relpath/bin/$i\" \"\$@\"" >>"$outpath/bin/$i"
            chmod 755 "$outpath/bin/$i"
        fi
    done

    # symlink the mkspecs directory
    mkdir -p "$outpath/mkspecs"
    rm -rf "$outpath"/mkspecs/*
    ln -s "$relpath"/mkspecs/* "$outpath/mkspecs"
    rm -f "$outpath/mkspecs/default"

    # Special case for mkspecs/features directory.
    # To be able to place .prf files into a shadow build directory,
    # we're creating links for files only. The directory structure is reproduced.
    # A simple "cp -rs" doesn't work on Mac. :(
    rm -rf "$outpath/mkspecs/features"
    find "$relpath/mkspecs/features" -type d | sed "s,^$relpath,$outpath," | xargs mkdir -p
    find "$relpath/mkspecs/features" -type f | sed "s,^$relpath/,," | xargs -n 1 -I % ln -s "$relpath/%" "$outpath/%"

    # symlink the doc directory
    rm -rf "$outpath/doc"
    ln -s "$relpath/doc" "$outpath/doc"

    # make sure q3porting.xml can be found
    mkdir -p "$outpath/tools/porting/src"
    rm -f "$outpath/tools/porting/src/q3porting.xml"
    ln -s "$relpath/tools/porting/src/q3porting.xml" "$outpath/tools/porting/src"
fi

# symlink fonts to be able to run application from build directory
if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then
    if [ "$PLATFORM" = "$XPLATFORM" ]; then
        mkdir -p "${outpath}/lib"
        ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts"
    fi
fi

if [ "$OPT_FAST" = "auto" ]; then
   if [ '!' -z "$AWK" ] && [ "$CFG_DEV" = "yes" ]; then
       OPT_FAST=yes
   else
       OPT_FAST=no
   fi
fi

# find a make command
if [ -z "$MAKE" ]; then
    MAKE=
    for mk in gmake make; do
        if "$WHICH" $mk >/dev/null 2>&1; then
            MAKE=`"$WHICH" $mk`
            break
        fi
    done
    if [ -z "$MAKE" ]; then
        echo >&2 "You don't seem to have 'make' or 'gmake' in your PATH."
        echo >&2 "Cannot proceed."
        exit 1
    fi
    # export MAKE, we need it later in the config.tests
    export MAKE
fi

fi ### help

#-------------------------------------------------------------------------------
# auto-detect all that hasn't been specified in the arguments
#-------------------------------------------------------------------------------

[ "$PLATFORM_QWS" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto
[ "$PLATFORM_QPA" = "yes" -a "$CFG_EMBEDDED" = "no" ] && CFG_EMBEDDED=auto
if [ "$CFG_EMBEDDED" != "no" ]; then
    case "$UNAME_SYSTEM:$UNAME_RELEASE" in
    Darwin:*)
        [ -z "$PLATFORM" ] && PLATFORM=qws/macx-generic-g++
        if [ -z "$XPLATFORM" ]; then
            [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic
            XPLATFORM="qws/macx-$CFG_EMBEDDED-g++"
        fi
        ;;
    FreeBSD:*)
        [ -z "$PLATFORM" ] && PLATFORM=qws/freebsd-generic-g++
        if [ -z "$XPLATFORM" ]; then
            [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic
            XPLATFORM="qws/freebsd-$CFG_EMBEDDED-g++"
        fi
        ;;
    SunOS:5*)
        [ -z "$PLATFORM" ] && PLATFORM=qws/solaris-generic-g++
        if [ -z "$XPLATFORM" ]; then
            [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic
            XPLATFORM="qws/solaris-$CFG_EMBEDDED-g++"
        fi
        ;;
    Linux:*)
        if [ -z "$PLATFORM" ]; then
            case "$UNAME_MACHINE" in
            *86)
                PLATFORM=qws/linux-x86-g++
                ;;
            *86_64)
                PLATFORM=qws/linux-x86_64-g++
                ;;
            *)
                PLATFORM=qws/linux-generic-g++
                ;;
            esac
        fi
        if [ -z "$XPLATFORM" ]; then
            if [ "$CFG_EMBEDDED" = "auto" ]; then
                if [ -n "$CFG_ARCH" ]; then
                    CFG_EMBEDDED=$CFG_ARCH
                else
                    case "$UNAME_MACHINE" in
                    *86)
                        CFG_EMBEDDED=x86
                        ;;
                    *86_64)
                        CFG_EMBEDDED=x86_64
                        ;;
                    *)
                        CFG_EMBEDDED=generic
                        ;;
                    esac
                fi
            fi
            XPLATFORM="qws/linux-$CFG_EMBEDDED-g++"
        fi
        ;;
    QNX:*)
        [ -z "$PLATFORM" ] && PLATFORM=unsupported/qws/qnx-generic-g++
        if [ -z "$XPLATFORM" ]; then
            [ "$CFG_EMBEDDED" = "auto" ] && CFG_EMBEDDED=generic
            XPLATFORM="unsupported/qws/qnx-$CFG_EMBEDDED-g++"
        fi
        ;;
    CYGWIN*:*)
	if [ -z "$XPLATFORM" ]; then
		CFG_EMBEDDED=x86
	fi
	;;
    *)
        echo "Qt for Embedded Linux is not supported on this platform. Disabling."
        CFG_EMBEDDED=no
        PLATFORM_QWS=no
        PLATFORM_QPA=no
        ;;
    esac
fi
if [ -z "$PLATFORM" ]; then
    PLATFORM_NOTES=
    case "$UNAME_SYSTEM:$UNAME_RELEASE" in
     Darwin:*)
        if [ "$PLATFORM_MAC" = "yes" ]; then
          PLATFORM=macx-g++
        # PLATFORM=macx-xcode
        else
          PLATFORM=darwin-g++
        fi
        ;;
     AIX:*)
        #PLATFORM=aix-g++
        #PLATFORM=aix-g++-64
        PLATFORM=aix-xlc
        #PLATFORM=aix-xlc-64
        PLATFORM_NOTES="
            - Also available for AIX: aix-g++ aix-g++-64 aix-xlc-64
        "
        ;;
     GNU:*)
        PLATFORM=hurd-g++
        ;;
     dgux:*)
        PLATFORM=dgux-g++
        ;;
#     DYNIX/ptx:4*)
#       PLATFORM=dynix-g++
#       ;;
     ULTRIX:*)
        PLATFORM=ultrix-g++
        ;;
     FreeBSD:*)
        PLATFORM=freebsd-g++
        PLATFORM_NOTES="
            - Also available for FreeBSD: freebsd-icc
        "
        ;;
     OpenBSD:*)
        PLATFORM=openbsd-g++
        ;;
     NetBSD:*)
        PLATFORM=netbsd-g++
        ;;
     BSD/OS:*|BSD/386:*)
        PLATFORM=bsdi-g++
        ;;
     IRIX*:*)
        #PLATFORM=irix-g++
        PLATFORM=irix-cc
        #PLATFORM=irix-cc-64
        PLATFORM_NOTES="
            - Also available for IRIX: irix-g++ irix-cc-64
        "
        ;;
     HP-UX:*)
        case "$UNAME_MACHINE" in
            ia64)
                #PLATFORM=hpuxi-acc-32
                PLATFORM=hpuxi-acc-64
                PLATFORM_NOTES="
                    - Also available for HP-UXi: hpuxi-acc-32
                "
            ;;
            *)
                #PLATFORM=hpux-g++
                PLATFORM=hpux-acc
                #PLATFORM=hpux-acc-64
                #PLATFORM=hpux-cc
                #PLATFORM=hpux-acc-o64
                PLATFORM_NOTES="
                    - Also available for HP-UX: hpux-g++ hpux-acc-64 hpux-acc-o64
                "
            ;;
        esac
        ;;
     OSF1:*)
        #PLATFORM=tru64-g++
        PLATFORM=tru64-cxx
        PLATFORM_NOTES="
            - Also available for Tru64: tru64-g++
        "
        ;;
     Linux:*)
        case "$UNAME_MACHINE" in
            x86_64|s390x|ppc64)
                PLATFORM=linux-g++-64
                ;;
            *)
                PLATFORM=linux-g++
                ;;
        esac
        PLATFORM_NOTES="
            - Also available for Linux: linux-kcc linux-icc linux-cxx
        "
        ;;
     SunOS:5*)
        if [ "$XPLATFORM_MINGW" = "yes" ]; then
            PLATFORM="solaris-g++"
        else
            #PLATFORM=solaris-g++
            PLATFORM=solaris-cc
            #PLATFORM=solaris-cc64
        fi
        PLATFORM_NOTES="
            - Also available for Solaris: solaris-g++ solaris-cc-64
        "
        ;;
     ReliantUNIX-*:*|SINIX-*:*)
        PLATFORM=reliant-cds
        #PLATFORM=reliant-cds-64
        PLATFORM_NOTES="
            - Also available for Reliant UNIX: reliant-cds-64
        "
        ;;
     CYGWIN*:*)
        PLATFORM=cygwin-g++
        ;;
     LynxOS*:*)
        PLATFORM=lynxos-g++
        ;;
     OpenUNIX:*)
        #PLATFORM=unixware-g++
        PLATFORM=unixware-cc
        PLATFORM_NOTES="
            - Also available for OpenUNIX: unixware-g++
        "
        ;;
     UnixWare:*)
        #PLATFORM=unixware-g++
        PLATFORM=unixware-cc
        PLATFORM_NOTES="
            - Also available for UnixWare: unixware-g++
        "
        ;;
     SCO_SV:*)
        #PLATFORM=sco-g++
        PLATFORM=sco-cc
        PLATFORM_NOTES="
            - Also available for SCO OpenServer: sco-g++
        "
        ;;
     UNIX_SV:*)
        PLATFORM=unixware-g++
        ;;
     QNX:*)
        PLATFORM=unsupported/qnx-g++
        ;;
     *)
        if [ "$OPT_HELP" != "yes" ]; then
            echo
            for p in $PLATFORMS; do
                echo "    $relconf $* -platform $p"
            done
            echo >&2
            echo "   The build script does not currently recognize all" >&2
            echo "   platforms supported by Qt." >&2
            echo "   Rerun this script with a -platform option listed to" >&2
            echo "   set the system/compiler combination you use." >&2
            echo >&2
            exit 2
        fi
    esac
fi

if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    CFG_SM=no
    PLATFORMS=`find "$relpath/mkspecs/qws" | sed "s,$relpath/mkspecs/qws/,,"`
else
    PLATFORMS=`find "$relpath/mkspecs/" -type f | grep -v qws | sed "s,$relpath/mkspecs/qws/,,"`
fi

[ -z "$XPLATFORM" ] && XPLATFORM="$PLATFORM"

case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac

if [ -d "$PLATFORM" ]; then
  QMAKESPEC="$PLATFORM"
else
  QMAKESPEC="$relpath/mkspecs/${PLATFORM}"
fi
if [ -d "$XPLATFORM" ]; then
  XQMAKESPEC="$XPLATFORM"
else
  XQMAKESPEC="$relpath/mkspecs/${XPLATFORM}"
fi
if [ "$PLATFORM" != "$XPLATFORM" ]; then
    QT_CROSS_COMPILE=yes
    QMAKE_CONFIG="$QMAKE_CONFIG cross_compile"
fi

if [ "$PLATFORM_MAC" = "yes" ]; then
   if [ `basename $QMAKESPEC` = "macx-xcode" ] || [ `basename $XQMAKESPEC` = "macx-xcode" ]; then
      echo >&2
      echo "   Platform 'macx-xcode' should not be used when building Qt/Mac." >&2
      echo "   Please build Qt/Mac with 'macx-g++', then if you would like to" >&2
      echo "   use mac-xcode on your application code it can link to a Qt/Mac" >&2
      echo "   built with 'macx-g++'" >&2
      echo >&2
      exit 2
    fi
fi

# check specified platforms are supported
if [ '!' -d "$QMAKESPEC" ]; then
    echo
    echo "   The specified system/compiler is not supported:"
    echo
    echo "      $QMAKESPEC"
    echo
    echo "   Please see the README file for a complete list."
    echo
    exit 2
fi
if [ '!' -d "$XQMAKESPEC" ]; then
    echo
    echo "   The specified system/compiler is not supported:"
    echo
    echo "      $XQMAKESPEC"
    echo
    echo "   Please see the README file for a complete list."
    echo
    exit 2
fi
if [ '!' -f "${XQMAKESPEC}/qplatformdefs.h" ]; then
    echo
    echo "   The specified system/compiler port is not complete:"
    echo
    echo "      $XQMAKESPEC/qplatformdefs.h"
    echo
    echo "   Please contact qt-bugs@trolltech.com."
    echo
    exit 2
fi

# now look at the configs and figure out what platform we are config'd for
[ "$CFG_EMBEDDED" = "no" ] \
  && [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ] \
  && PLATFORM_X11=yes
### echo "$XQMAKESPEC" | grep mkspecs/qws >/dev/null 2>&1 && PLATFORM_QWS=yes

if [ "$UNAME_SYSTEM" = "SunOS" ]; then
    # Solaris 2.5 and 2.6 have libposix4, which was renamed to librt for Solaris 7 and up
    if echo $UNAME_RELEASE | grep "^5\.[5|6]" >/dev/null 2>&1; then
        sed -e "s,-lrt,-lposix4," "$XQMAKESPEC/qmake.conf" > "$XQMAKESPEC/qmake.conf.new"
        mv "$XQMAKESPEC/qmake.conf.new" "$XQMAKESPEC/qmake.conf"
    fi
fi

#-------------------------------------------------------------------------------
# determine the system architecture
#-------------------------------------------------------------------------------
if [ "$OPT_VERBOSE" = "yes" ]; then
    echo "Determining system architecture... ($UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_MACHINE)"
fi

if [ "$CFG_EMBEDDED" != "no" -a "$CFG_EMBEDDED" != "auto" ] && [ -n "$CFG_ARCH" ]; then
    if [ "$CFG_ARCH" != "$CFG_EMBEDDED" ]; then
        echo ""
        echo "You have specified a target architecture with -embedded and -arch."
        echo "The two architectures you have specified are different, so we can"
        echo "not proceed. Either set both to be the same, or only use -embedded."
        echo ""
        exit 1
    fi
fi

if [ "$CFG_RTOS_ENABLED" = "no" ]; then
    case `basename "$XPLATFORM"` in
	qnx-* | vxworks-*)
            echo ""
            echo "You are not licensed for Qt for `basename $XPLATFORM`."
            echo ""
            echo "Please contact qt-info@nokia.com to upgrade your license to"
            echo "include this platform, or install the Qt Open Source Edition"
            echo "if you intend to develop free software."
            exit 1
	    ;;
    esac
fi

if [ -z "${CFG_HOST_ARCH}" ]; then
    case "$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_MACHINE" in
    GNU:*:*)
        CFG_HOST_ARCH=`echo ${UNAME_MACHINE} | sed -e 's,[-/].*$,,'`
        case "$CFG_HOST_ARCH" in
            i?86)
                CFG_HOST_ARCH=i386
                ;;
        esac
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    GNU/Hurd ($CFG_HOST_ARCH)"
        fi
        ;;
    IRIX*:*:*)
        CFG_HOST_ARCH=`uname -p`
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    SGI ($CFG_HOST_ARCH)"
        fi
        ;;
    SunOS:5*:*)
        case "$UNAME_MACHINE" in
	sun4u*|sun4v*)
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo "    Sun SPARC (sparc)"
            fi
            CFG_HOST_ARCH=sparc
            ;;
        i86pc)
	    case "$PLATFORM" in
	    *-64)
                if [ "$OPT_VERBOSE" = "yes" ]; then
	            echo "    64-bit AMD 80x86 (x86_64)"
                fi
                CFG_HOST_ARCH=x86_64
                ;;
	    *)
                if [ "$OPT_VERBOSE" = "yes" ]; then
	            echo "    32-bit Intel 80x86 (i386)"
                fi
                CFG_HOST_ARCH=i386
                ;;
            esac
        esac
        ;;
    Darwin:*:*)
        case "$UNAME_MACHINE" in
            Power?Macintosh)
                if [ "$OPT_VERBOSE" = "yes" ]; then
                    echo "    32-bit Apple PowerPC (powerpc)"
                fi
                ;;
            x86)
                if [ "$OPT_VERBOSE" = "yes" ]; then
                    echo "    32-bit Intel 80x86 (i386)"
                fi
                ;;
        esac
        CFG_HOST_ARCH=macosx
        ;;
    AIX:*:00????????00)
        if [ "$OPT_VERBOSE" = "yes" ]; then
        echo "    64-bit IBM PowerPC (powerpc)"
        fi
        CFG_HOST_ARCH=powerpc
        ;;
    HP-UX:*:9000*)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    HP PA-RISC (parisc)"
        fi
        CFG_HOST_ARCH=parisc
        ;;
    *:*:i?86)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    32-bit Intel 80x86 (i386)"
        fi
        CFG_HOST_ARCH=i386
        ;;
    *:*:x86_64|*:*:amd64)
        if [ "$PLATFORM" = "linux-g++-32" -o "$PLATFORM" = "linux-icc-32" ]; then
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo "    32 bit on 64-bit AMD 80x86 (i386)"
            fi
            CFG_HOST_ARCH=i386
        else
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo "    64-bit AMD 80x86 (x86_64)"
            fi
            CFG_HOST_ARCH=x86_64
        fi
        ;;
    *:*:ppc)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    32-bit PowerPC (powerpc)"
        fi
        CFG_HOST_ARCH=powerpc
        ;;
    *:*:ppc64)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    64-bit PowerPC (powerpc)"
        fi
        CFG_HOST_ARCH=powerpc
        ;;
    *:*:s390*)
    	if [ "$OPT_VERBOSE" = "yes" ]; then
    	    echo "    IBM S/390 (s390)"
    	fi
    	CFG_HOST_ARCH=s390
    	;;
    *:*:arm*)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    ARM (arm)"
        fi
        CFG_HOST_ARCH=arm
        ;;
    Linux:*:sparc*)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    Linux on SPARC"
        fi
        CFG_HOST_ARCH=sparc
        ;;
    QNX:*:*)
        case "$UNAME_MACHINE" in
        x86pc)
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo "    QNX on Intel 80x86 (i386)"
            fi
            CFG_HOST_ARCH=i386
            ;;
        esac
        ;;
    *:*:*)
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    Trying '$UNAME_MACHINE'..."
        fi
        CFG_HOST_ARCH="$UNAME_MACHINE"
        ;;
    esac
fi

if [ "$PLATFORM" != "$XPLATFORM" -a "$CFG_EMBEDDED" != "no" ]; then
    if [ -n "$CFG_ARCH" ]; then
        CFG_EMBEDDED=$CFG_ARCH
    fi

    case "$CFG_EMBEDDED" in
    x86)
        CFG_ARCH=i386
        ;;
    x86_64)
        CFG_ARCH=x86_64
        ;;
    ipaq|sharp)
        CFG_ARCH=arm
        ;;
    dm7000)
        CFG_ARCH=powerpc
        ;;
    dm800)
        CFG_ARCH=mips
        ;;
    sh4al)
        CFG_ARCH=sh4a
        ;;
    *)
        CFG_ARCH="$CFG_EMBEDDED"
        ;;
    esac
elif [ "$XPLATFORM_MINGW" = "yes" ]; then
    [ -z "$CFG_ARCH" ] && CFG_ARCH="windows"
elif echo "$XPLATFORM" | grep symbian > /dev/null; then
    CFG_ARCH=symbian
elif [ "$PLATFORM_MAC" = "yes" ] || [ -z "$CFG_ARCH" ]; then
    CFG_ARCH=$CFG_HOST_ARCH
fi

if [ -d "$relpath/src/corelib/arch/$CFG_ARCH" ]; then
    if [ "$OPT_VERBOSE" = "yes" ]; then
        echo "    '$CFG_ARCH' is supported"
    fi
else
    if [ "$OPT_VERBOSE" = "yes" ]; then
        echo "    '$CFG_ARCH' is unsupported, using 'generic'"
    fi
    CFG_ARCH=generic
fi
if [ "$CFG_HOST_ARCH" != "$CFG_ARCH" ]; then
    if [ -d "$relpath/src/corelib/arch/$CFG_HOST_ARCH" ]; then
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    '$CFG_HOST_ARCH' is supported"
        fi
    else
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "    '$CFG_HOST_ARCH' is unsupported, using 'generic'"
        fi
        CFG_HOST_ARCH=generic
    fi
fi

if [ "$OPT_VERBOSE" = "yes" ]; then
    echo "System architecture: '$CFG_ARCH'"
    if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
	echo "Host architecture: '$CFG_HOST_ARCH'"
    fi
fi

#-------------------------------------------------------------------------------
# tests that don't need qmake (must be run before displaying help)
#-------------------------------------------------------------------------------

if [ -z "$PKG_CONFIG" ]; then
    # See if PKG_CONFIG is set in the mkspec:
    PKG_CONFIG=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%PKG_CONFIG[^_].*=%%p' | tr '\n' ' '`
fi
if [ -z "$PKG_CONFIG" ]; then
    PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
fi

# Work out if we can use pkg-config
if [ "$QT_CROSS_COMPILE" = "yes" ]; then
    if [ "$QT_FORCE_PKGCONFIG" = "yes" ]; then
        echo >&2 ""
        echo >&2 "You have asked to use pkg-config and are cross-compiling."
        echo >&2 "Please make sure you have a correctly set-up pkg-config"
        echo >&2 "environment!"
        echo >&2 ""
        if [ -z "$PKG_CONFIG_PATH" ]; then
            echo >&2 ""
            echo >&2 "Warning: PKG_CONFIG_PATH has not been set.  This could mean"
            echo >&2 "the host compiler's .pc files will be used. This is probably"
            echo >&2 "not what you want."
            echo >&2 ""
        elif [ -z "$PKG_CONFIG_SYSROOT" ] && [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
            echo >&2 ""
            echo >&2 "Warning: PKG_CONFIG_SYSROOT/PKG_CONFIG_SYSROOT_DIR has not"
            echo >&2 "been set. This means your toolchain's .pc files must contain"
            echo >&2 "the paths to the toolchain's libraries & headers. If configure"
            echo >&2 "tests are failing, please check these files."
            echo >&2 ""
        fi
    else
        echo >&2 ""
        echo >&2 "You have not explicitly asked to use pkg-config and are cross-compiling."
        echo >&2 "pkg-config will not be used to automatically query cflag/lib parameters for"
        echo >&2 "dependencies"
        echo >&2 ""
        PKG_CONFIG=""
    fi
fi

# process CFG_MAC_ARCHS
if [ "$PLATFORM_MAC" = "yes" ]; then
#   check -arch arguments for validity.
    ALLOWED="x86 ppc x86_64 ppc64 i386"
    # Save the list so we can re-write it using only valid values
    CFG_MAC_ARCHS_IN="$CFG_MAC_ARCHS"
    CFG_MAC_ARCHS=
    for i in $CFG_MAC_ARCHS_IN
    do 
        if echo "$ALLOWED" | grep -w -v "$i" > /dev/null 2>&1; then
            echo "Unknown architecture: \"$i\". Supported architectures: x86[i386] ppc x86_64 ppc64";
            exit 2;
        fi
        if [ "$i" = "i386" -o "$i" = "x86" ]; then
            # These are synonymous values
            # CFG_MAC_ARCHS requires x86 while GCC requires i386
            CFG_MAC_ARCHS="$CFG_MAC_ARCHS x86"
            MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -arch i386"
        else
            CFG_MAC_ARCHS="$CFG_MAC_ARCHS $i"
            MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -arch $i"
        fi
    done
fi

# pass on $CFG_SDK to the configure tests.
if [ '!' -z "$CFG_SDK" ]; then
    MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -sdk $CFG_SDK"
fi

# find the default framework value
if [ "$PLATFORM_MAC" = "yes" ] && [ "$PLATFORM" != "macx-xlc" ]; then
    if [ "$CFG_FRAMEWORK" = "auto" ]; then
        CFG_FRAMEWORK="$CFG_SHARED"
    elif [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_SHARED" = "no" ]; then
	echo
	echo "WARNING: Using static linking will disable the use of Mac frameworks."
	echo
        CFG_FRAMEWORK="no"
    fi
else
    CFG_FRAMEWORK=no
fi

QMAKE_CONF_COMPILER=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_CXX[^_A-Z0-9]" | sed "s,.* *= *\(.*\)$,\1," | tail -1`
TEST_COMPILER="$CXX"

[ -z "$TEST_COMPILER" ] && TEST_COMPILER=$QMAKE_CONF_COMPILER
if [ "$XPLATFORM" != "symbian-sbsv2" ]; then
    #for Symbian we don't need this checking
    if [ -z "$TEST_COMPILER" ]; then
        echo "ERROR: Cannot set the compiler for the configuration tests"
        exit 1
    fi
fi

if [ "$CFG_EMBEDDED" = "nacl" ]; then
    TEST_COMPILER="nacl-gcc"
fi

# auto-detect precompiled header support
if [ "$CFG_PRECOMPILE" = "auto" ]; then
    if [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then
       CFG_PRECOMPILE=no
    elif "$unixtests/precomp.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then
       CFG_PRECOMPILE=no
    else
       CFG_PRECOMPILE=yes
    fi
elif [ "$CFG_PRECOMPILE" = "yes" ] && [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then
    echo
    echo "WARNING: Using universal binaries disables precompiled headers."
    echo
    CFG_PRECOMPILE=no
fi

#auto-detect DWARF2 on the mac
if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_DWARF2" = "auto" ]; then
    if "$mactests/dwarf2.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" ; then
        CFG_MAC_DWARF2=no
    else
        CFG_MAC_DWARF2=yes
    fi
fi

# auto-detect support for -Xarch on the mac
if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" = "auto" ]; then
    if "$mactests/xarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" ; then
        CFG_MAC_XARCH=no
    else
        CFG_MAC_XARCH=yes
    fi
fi

# don't autodetect support for separate debug info on objcopy when
# cross-compiling as lots of toolchains seems to have problems with this
if [ "$QT_CROSS_COMPILE" = "yes" ] && [ "$CFG_SEPARATE_DEBUG_INFO" = "auto" ]; then
    CFG_SEPARATE_DEBUG_INFO="no"
fi

# auto-detect support for separate debug info in objcopy
if [ "$CFG_SEPARATE_DEBUG_INFO" != "no" ] && [ "$CFG_SHARED" = "yes" ]; then
    TEST_COMPILER_CFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '`
    TEST_COMPILER_CXXFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CXXFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '`
    TEST_OBJCOPY=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_OBJCOPY" | sed "s%.* *= *\(.*\)$%\1%" | tail -1`
    COMPILER_WITH_FLAGS="$TEST_COMPILER $TEST_COMPILER_CXXFLAGS"
    COMPILER_WITH_FLAGS=`echo "$COMPILER_WITH_FLAGS" | sed -e "s%\\$\\$QMAKE_CFLAGS%$TEST_COMPILER_CFLAGS%g"`
    if "$unixtests/objcopy.test" "$COMPILER_WITH_FLAGS" "$TEST_OBJCOPY" "$OPT_VERBOSE"; then
       CFG_SEPARATE_DEBUG_INFO=no
    else
       case "$PLATFORM" in
       hpux-*)
           # binutils on HP-UX is buggy; default to no.
           CFG_SEPARATE_DEBUG_INFO=no
           ;;
       *)
           CFG_SEPARATE_DEBUG_INFO=yes
           ;;
       esac
    fi
fi

# auto-detect -fvisibility support
if [ "$CFG_REDUCE_EXPORTS" = "auto" ]; then
    if "$unixtests/fvisibility.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then
       CFG_REDUCE_EXPORTS=no
    else
       CFG_REDUCE_EXPORTS=yes
    fi
fi

# detect the availability of the -Bsymbolic-functions linker optimization
if [ "$CFG_REDUCE_RELOCATIONS" != "no" ]; then
    if "$unixtests/bsymbolic_functions.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then
        CFG_REDUCE_RELOCATIONS=no
    else
        CFG_REDUCE_RELOCATIONS=yes
    fi
fi

# auto-detect GNU make support
if [ "$CFG_USE_GNUMAKE" = "auto" ] && "$MAKE" -v | grep "GNU Make" >/dev/null 2>&1; then
   CFG_USE_GNUMAKE=yes
fi

# If -opengl wasn't specified, don't try to auto-detect
if [ "$PLATFORM_QWS" = "yes" ] && [ "$CFG_OPENGL" = "auto" ]; then
        CFG_OPENGL=no
fi

# mac
if [ "$PLATFORM_MAC" = "yes" ]; then
    if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
        CFG_OPENGL=desktop
    fi
fi

# find the default framework value
if [ "$PLATFORM_MAC" = "yes" ] && [ "$PLATFORM" != "macx-xlc" ]; then
    if [ "$CFG_FRAMEWORK" = "auto" ]; then
        CFG_FRAMEWORK="$CFG_SHARED"
    elif [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_SHARED" = "no" ]; then
	echo
	echo "WARNING: Using static linking will disable the use of Mac frameworks."
	echo
        CFG_FRAMEWORK="no"
    fi
else
    CFG_FRAMEWORK=no
fi

# Print a warning if configure was called with the 10.4u SDK option on Snow Leopard
# with the default mkspec. The 10.4u SDK does not support gcc 4.2.
if [ "$PLATFORM_MAC" = "yes" ] && [ '!' -z "$CFG_SDK" ]; then
    # get the darwin version. 10.0.0 and up means snow leopard.
    VERSION=`uname -r | tr '.' ' ' | awk '{print $1}'`
    if [ "$VERSION" -gt 9 ] && [ "$CFG_SDK" == "/Developer/SDKs/MacOSX10.4u.sdk/" ] && [ "$PLATFORM" == "macx-g++" ]; then
        echo
        echo "WARNING: The 10.4u SDK does not support gcc 4.2. Configure with -platform macx-g++40. "
        echo
    fi
fi

# x11 tests are done after qmake is built


#setup the build parts
if [ -z "$CFG_BUILD_PARTS" ]; then
    CFG_BUILD_PARTS="$QT_DEFAULT_BUILD_PARTS"

    # don't build tools by default when cross-compiling
    if [ "$PLATFORM" != "$XPLATFORM" ]; then
	CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed "s, tools,,g"`
    fi
fi
for nobuild in $CFG_NOBUILD_PARTS; do
    CFG_BUILD_PARTS=`echo "$CFG_BUILD_PARTS" | sed "s, $nobuild,,g"`
done
if echo $CFG_BUILD_PARTS | grep -v libs >/dev/null 2>&1; then
#    echo
#    echo "WARNING: libs is a required part of the build."
#    echo
    CFG_BUILD_PARTS="$CFG_BUILD_PARTS libs"
fi

#-------------------------------------------------------------------------------
# post process QT_INSTALL_* variables
#-------------------------------------------------------------------------------

#prefix
if [ -z "$QT_INSTALL_PREFIX" ]; then
    if [ "$CFG_DEV" = "yes" ]; then
        QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default
    elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
        if [ "$PLATFORM_QPA" = "yes" ]; then
	QT_INSTALL_PREFIX="/usr/local/Trolltech/QtLighthouse-${QT_VERSION}"
        else
	QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}"
        fi
        if [ "$PLATFORM" != "$XPLATFORM" ]; then
            QT_INSTALL_PREFIX="${QT_INSTALL_PREFIX}-${CFG_ARCH}"
        fi
    elif [ -d "$EPOCROOT" ]; then
        case "$XPLATFORM" in *symbian*)
            QT_INSTALL_PREFIX="$EPOCROOT/epoc32/"
            QT_INSTALL_LIBS="$EPOCROOT/epoc32/release/armv5/lib/"
            ;;
        esac
    else
        QT_INSTALL_PREFIX="/usr/local/Trolltech/Qt-${QT_VERSION}" # the default install prefix is /usr/local/Trolltech/Qt-$QT_VERSION
    fi
fi
QT_INSTALL_PREFIX=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_PREFIX"`

if echo $XPLATFORM | grep symbian > /dev/null; then
    [ -z "$QT_HOST_PREFIX" ] && QT_HOST_PREFIX="$QT_INSTALL_PREFIX"
    [ -z "$QT_INSTALL_DOCS" ] && QT_INSTALL_DOCS=
    [ -z "$QT_INSTALL_HEADERS" ] && QT_INSTALL_HEADERS=
    [ -z "$QT_INSTALL_LIBS" ] && QT_INSTALL_LIBS=
    [ -z "$QT_INSTALL_BINS" ] && QT_INSTALL_BINS=
    [ -z "$QT_INSTALL_PLUGINS" ] && QT_INSTALL_PLUGINS="\\\\resource\\\\qt$QT_LIBINFIX\\\\plugins"
    [ -z "$QT_INSTALL_IMPORTS" ] && QT_INSTALL_IMPORTS="\\\\resource\\\\qt$QT_LIBINFIX\\\\imports"
    [ -z "$QT_INSTALL_DATA" ] && QT_INSTALL_DATA=
    [ -z "$QT_INSTALL_TRANSLATIONS" ] && QT_INSTALL_TRANSLATIONS="\\\\resource\\\\qt$QT_LIBINFIX\\\\translations"
    [ -z "$QT_INSTALL_SETTINGS" ] && QT_INSTALL_SETTINGS=
    [ -z "$QT_INSTALL_EXAMPLES" ] && QT_INSTALL_EXAMPLES=
    [ -z "$QT_INSTALL_DEMOS" ] && QT_INSTALL_DEMOS=
else
    #docs
    if [ -z "$QT_INSTALL_DOCS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_DOCS="/Developer/Documentation/Qt"
            fi
        fi
        [ -z "$QT_INSTALL_DOCS" ] && QT_INSTALL_DOCS="$QT_INSTALL_PREFIX/doc" #fallback

    fi
    QT_INSTALL_DOCS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_DOCS"`

    #headers
    if [ -z "$QT_INSTALL_HEADERS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        if [ "$CFG_FRAMEWORK" = "yes" ]; then
		    QT_INSTALL_HEADERS=
                fi
            fi
        fi
        [ -z "$QT_INSTALL_HEADERS" ] && QT_INSTALL_HEADERS="$QT_INSTALL_PREFIX/include"

    fi
    QT_INSTALL_HEADERS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_HEADERS"`

    #libs
    if [ -z "$QT_INSTALL_LIBS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        if [ "$CFG_FRAMEWORK" = "yes" ]; then
		    QT_INSTALL_LIBS="/Libraries/Frameworks"
                fi
            fi
        fi
        [ -z "$QT_INSTALL_LIBS" ] && QT_INSTALL_LIBS="$QT_INSTALL_PREFIX/lib" #fallback
    fi
    QT_INSTALL_LIBS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_LIBS"`

    #bins
    if [ -z "$QT_INSTALL_BINS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_BINS="/Developer/Applications/Qt"
            fi
        fi
        [ -z "$QT_INSTALL_BINS" ] && QT_INSTALL_BINS="$QT_INSTALL_PREFIX/bin" #fallback

    fi
    QT_INSTALL_BINS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_BINS"`

    #plugins
    if [ -z "$QT_INSTALL_PLUGINS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_PLUGINS="/Developer/Applications/Qt/plugins"
            fi
        fi
        [ -z "$QT_INSTALL_PLUGINS" ] && QT_INSTALL_PLUGINS="$QT_INSTALL_PREFIX/plugins" #fallback
    fi
    QT_INSTALL_PLUGINS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_PLUGINS"`

    #imports
    if [ -z "$QT_INSTALL_IMPORTS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_IMPORTS="/Developer/Applications/Qt/imports"
            fi
        fi
        [ -z "$QT_INSTALL_IMPORTS" ] && QT_INSTALL_IMPORTS="$QT_INSTALL_PREFIX/imports" #fallback
    fi
    QT_INSTALL_IMPORTS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_IMPORTS"`

    #data
    if [ -z "$QT_INSTALL_DATA" ]; then #default
        QT_INSTALL_DATA="$QT_INSTALL_PREFIX"
    fi
    QT_INSTALL_DATA=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_DATA"`

    #translations
    if [ -z "$QT_INSTALL_TRANSLATIONS" ]; then #default
        QT_INSTALL_TRANSLATIONS="$QT_INSTALL_PREFIX/translations"
    fi
    QT_INSTALL_TRANSLATIONS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_TRANSLATIONS"`

    #settings
    if [ -z "$QT_INSTALL_SETTINGS" ]; then #default
        if [ "$PLATFORM_MAC" = "yes" ]; then
	    QT_INSTALL_SETTINGS=/Library/Preferences/Qt
        else
	    QT_INSTALL_SETTINGS=/etc/xdg
        fi
    fi
    QT_INSTALL_SETTINGS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_SETTINGS"`

    #examples
    if [ -z "$QT_INSTALL_EXAMPLES" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_EXAMPLES="/Developer/Examples/Qt"
            fi
        fi
        [ -z "$QT_INSTALL_EXAMPLES" ] && QT_INSTALL_EXAMPLES="$QT_INSTALL_PREFIX/examples" #fallback
    fi
    QT_INSTALL_EXAMPLES=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_EXAMPLES"`

    #demos
    if [ -z "$QT_INSTALL_DEMOS" ]; then #default
        if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
	    if [ "$PLATFORM_MAC" = "yes" ]; then
	        QT_INSTALL_DEMOS="/Developer/Examples/Qt/Demos"
            fi
        fi
        [ -z "$QT_INSTALL_DEMOS" ] && QT_INSTALL_DEMOS="$QT_INSTALL_PREFIX/demos"
    fi
    QT_INSTALL_DEMOS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_DEMOS"`
fi

#-------------------------------------------------------------------------------
# help - interactive parts of the script _after_ this section please
#-------------------------------------------------------------------------------

# next, emit a usage message if something failed.
if [ "$OPT_HELP" = "yes" ]; then
    [ "x$ERROR" = "xyes" ] && echo
    if [ "$CFG_NIS" = "no" ]; then
        NSY=" "
        NSN="*"
    else
        NSY="*"
        NSN=" "
    fi
    if [ "$CFG_CUPS" = "no" ]; then
        CUY=" "
        CUN="*"
    else
        CUY="*"
        CUN=" "
    fi
    if [ "$CFG_ICONV" = "no" ]; then
        CIY=" "
        CIN="*"
    else
        CIY="*"
        CIN=" "
    fi
    if [ "$CFG_LARGEFILE" = "no" ]; then
        LFSY=" "
        LFSN="*"
    else
        LFSY="*"
        LFSN=" "
    fi
    if [ "$CFG_STL" = "auto" ] || [ "$CFG_STL" = "yes" ]; then
        SHY="*"
        SHN=" "
    else
        SHY=" "
        SHN="*"
    fi
    if [ "$CFG_IPV6" = "auto" ]; then
        I6Y="*"
        I6N=" "
    fi
    if [ "$CFG_PRECOMPILE" = "auto" ] || [ "$CFG_PRECOMPILE" = "no" ]; then
        PHY=" "
        PHN="*"
    else
        PHY="*"
        PHN=" "
    fi

    cat <<EOF
Usage:  $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir <dir>]
        [-docdir <dir>] [-headerdir <dir>] [-plugindir <dir> ] [-importdir <dir>] [-datadir <dir>]
        [-translationdir <dir>] [-sysconfdir <dir>] [-examplesdir <dir>]
        [-demosdir <dir>] [-buildkey <key>] [-release] [-debug]
        [-debug-and-release] [-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
        [-largefile] [-no-exceptions] [-exceptions] [-no-accessibility]
        [-accessibility] [-no-stl] [-stl] [-no-sql-<driver>] [-sql-<driver>]
        [-plugin-sql-<driver>] [-system-sqlite] [-no-qt3support] [-qt3support]
        [-platform] [-D <string>] [-I <string>] [-L <string>] [-help]
        [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libtiff] [-qt-libtiff] [-system-libtiff]
        [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng]
        [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg] [-make <part>]
        [-nomake <part>] [-R <string>]  [-l <string>] [-no-rpath]  [-rpath] [-continue]
        [-verbose] [-v] [-silent] [-no-nis] [-nis] [-no-cups] [-cups] [-no-iconv]
        [-iconv] [-no-pch] [-pch] [-no-dbus] [-dbus] [-dbus-linked] [-no-gui]
        [-no-separate-debug-info] [-no-mmx] [-no-3dnow] [-no-sse] [-no-sse2]
        [-no-sse3] [-no-ssse3] [-no-sse4.1] [-no-sse4.2] [-no-avx]
        [-qtnamespace <namespace>] [-qtlibinfix <infix>] [-separate-debug-info] [-armfpa]
        [-no-optimized-qmake] [-optimized-qmake] [-no-xmlpatterns] [-xmlpatterns]
        [-no-multimedia] [-multimedia] [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend]
        [-no-media-backend] [-media-backend] [-no-audio-backend] [-audio-backend] 
        [-no-openssl] [-openssl] [-openssl-linked]
        [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit]
        [-no-script] [-script] [-no-scripttools] [-scripttools] [-no-declarative] [-declarative]

        [additional platform specific options (see below)]


Installation options:

 These are optional, but you may specify install directories.

    -prefix <dir> ...... This will install everything relative to <dir>
                         (default $QT_INSTALL_PREFIX)
EOF
if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
cat <<EOF

    -hostprefix [dir] .. Tools and libraries needed when developing
                         applications are installed in [dir]. If [dir] is
                         not given, the current build directory will be used.
EOF
fi
cat <<EOF

  * -prefix-install .... Force a sandboxed "local" installation of
                         Qt. This will install into
                         $QT_INSTALL_PREFIX, if this option is
                         disabled then some platforms will attempt a
                         "system" install by placing default values to
                         be placed in a system location other than
                         PREFIX.

 You may use these to separate different parts of the install:

    -bindir <dir> ......... Executables will be installed to <dir>
                            (default PREFIX/bin)
    -libdir <dir> ......... Libraries will be installed to <dir>
                            (default PREFIX/lib)
    -docdir <dir> ......... Documentation will be installed to <dir>
                            (default PREFIX/doc)
    -headerdir <dir> ...... Headers will be installed to <dir>
                            (default PREFIX/include)
    -plugindir <dir> ...... Plugins will be installed to <dir>
                            (default PREFIX/plugins)
    -importdir <dir> ...... Imports for QML will be installed to <dir>
                            (default PREFIX/imports)
    -datadir <dir> ........ Data used by Qt programs will be installed to <dir>
                            (default PREFIX)
    -translationdir <dir> . Translations of Qt programs will be installed to <dir>
                            (default PREFIX/translations)
    -sysconfdir <dir> ..... Settings used by Qt programs will be looked for in <dir>
                            (default PREFIX/etc/settings)
    -examplesdir <dir> .... Examples will be installed to <dir>
                            (default PREFIX/examples)
    -demosdir <dir> ....... Demos will be installed to <dir>
                            (default PREFIX/demos)

 You may use these options to turn on strict plugin loading.

    -buildkey <key> .... Build the Qt library and plugins using the specified
                         <key>.  When the library loads plugins, it will only
                         load those that have a matching key.

Configure options:

 The defaults (*) are usually acceptable. A plus (+) denotes a default value
 that needs to be evaluated. If the evaluation succeeds, the feature is
 included. Here is a short explanation of each option:

 *  -release ........... Compile and link Qt with debugging turned off.
    -debug ............. Compile and link Qt with debugging turned on.
    -debug-and-release . Compile and link two versions of Qt, with and without
                         debugging turned on (Mac only).

    -developer-build ... Compile and link Qt with Qt developer options (including auto-tests exporting)

    -opensource ........ Compile and link the Open-Source Edition of Qt.
    -commercial ........ Compile and link the Commercial Edition of Qt.


 *  -shared ............ Create and use shared Qt libraries.
    -static ............ Create and use static Qt libraries.

 *  -no-fast ........... Configure Qt normally by generating Makefiles for all
                         project files.
    -fast .............. Configure Qt quickly by generating Makefiles only for
                         library and subdirectory targets.  All other Makefiles
                         are created as wrappers, which will in turn run qmake.

    -no-largefile ...... Disables large file support.
 +  -largefile ......... Enables Qt to access files larger than 4 GB.

EOF
if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    EXCN="*"
    EXCY=" "
else
    EXCN=" "
    EXCY="*"
fi
if [ "$CFG_DBUS" = "no" ]; then
    DBY=" "
    DBN="+"
else
    DBY="+"
    DBN=" "
fi

    cat << EOF
 $EXCN  -no-exceptions ..... Disable exceptions on compilers that support it.
 $EXCY  -exceptions ........ Enable exceptions on compilers that support it.

    -no-accessibility .. Do not compile Accessibility support.
 *  -accessibility ..... Compile Accessibility support.

 $SHN  -no-stl ............ Do not compile STL support.
 $SHY  -stl ............... Compile STL support.

    -no-sql-<driver> ... Disable SQL <driver> entirely.
    -qt-sql-<driver> ... Enable a SQL <driver> in the QtSql library, by default
                         none are turned on.
    -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to
                         at run time.

                         Possible values for <driver>:
                         [ $CFG_SQL_AVAILABLE ]

    -system-sqlite ..... Use sqlite from the operating system.

    -no-qt3support ..... Disables the Qt 3 support functionality.
 *  -qt3support ........ Enables the Qt 3 support functionality.

    -no-xmlpatterns .... Do not build the QtXmlPatterns module.
 +  -xmlpatterns ....... Build the QtXmlPatterns module.
                         QtXmlPatterns is built if a decent C++ compiler
                         is used and exceptions are enabled.

    -no-multimedia ..... Do not build the QtMultimedia module.
 +  -multimedia ........ Build the QtMultimedia module.

    -no-audio-backend .. Do not build the platform audio backend into QtMultimedia.
 +  -audio-backend ..... Build the platform audio backend into QtMultimedia if available.

    -no-phonon ......... Do not build the Phonon module.
 +  -phonon ............ Build the Phonon module.
                         Phonon is built if a decent C++ compiler is used.
    -no-phonon-backend.. Do not build the platform phonon plugin.
 +  -phonon-backend..... Build the platform phonon plugin.

    -no-svg ............ Do not build the SVG module.
 +  -svg ............... Build the SVG module.

    -no-webkit ......... Do not build the WebKit module.
 +  -webkit ............ Build the WebKit module.
                         WebKit is built if a decent C++ compiler is used.

    -no-javascript-jit . Do not build the JavaScriptCore JIT compiler.
 +  -javascript-jit .... Build the JavaScriptCore JIT compiler.

    -no-script ......... Do not build the QtScript module.
 +  -script ............ Build the QtScript module.

    -no-scripttools .... Do not build the QtScriptTools module.
 +  -scripttools ....... Build the QtScriptTools module.

 +  -no-declarative .....Do not build the declarative module.
    -declarative ....... Build the declarative module.

    -platform target ... The operating system and compiler you are building
                         on ($PLATFORM).

                         See the README file for a list of supported
                         operating systems and compilers.
EOF
if [ "${PLATFORM_QWS}" != "yes" ]; then
cat << EOF
    -graphicssystem <sys> Sets an alternate graphics system. Available options are:
                           raster - Software rasterizer
                           opengl - Rendering via OpenGL, Experimental!
                           openvg - Rendering via OpenVG, Experimental!

EOF
fi
cat << EOF

    -no-mmx ............ Do not compile with use of MMX instructions.
    -no-3dnow .......... Do not compile with use of 3DNOW instructions.
    -no-sse ............ Do not compile with use of SSE instructions.
    -no-sse2 ........... Do not compile with use of SSE2 instructions.
    -no-sse3 ........... Do not compile with use of SSE3 instructions.
    -no-ssse3 .......... Do not compile with use of SSSE3 instructions.
    -no-sse4.1.......... Do not compile with use of SSE4.1 instructions.
    -no-sse4.2.......... Do not compile with use of SSE4.2 instructions.
    -no-avx ............ Do not compile with use of AVX instructions.

    -qtnamespace <name>  Wraps all Qt library code in 'namespace <name> {...}'.
    -qtlibinfix <infix>  Renames all libQt*.so to libQt*<infix>.so.

    -D <string> ........ Add an explicit define to the preprocessor.
    -I <string> ........ Add an explicit include path.
    -L <string> ........ Add an explicit library path.

    -help, -h .......... Display this information.

Third Party Libraries:

    -qt-zlib ........... Use the zlib bundled with Qt.
 +  -system-zlib ....... Use zlib from the operating system.
                         See http://www.gzip.org/zlib

    -no-gif ............ Do not compile GIF reading support.
 *  -qt-gif ............ Compile GIF reading support.
                         See also src/gui/image/qgifhandler_p.h

    -no-libtiff ........ Do not compile TIFF support.
    -qt-libtiff ........ Use the libtiff bundled with Qt.
 +  -system-libtiff .... Use libtiff from the operating system.
                         See http://www.libtiff.org

    -no-libpng ......... Do not compile PNG support.
    -qt-libpng ......... Use the libpng bundled with Qt.
 +  -system-libpng ..... Use libpng from the operating system.
                         See http://www.libpng.org/pub/png

    -no-libmng ......... Do not compile MNG support.
    -qt-libmng ......... Use the libmng bundled with Qt.
 +  -system-libmng ..... Use libmng from the operating system.
                         See http://www.libmng.com

    -no-libjpeg ........ Do not compile JPEG support.
    -qt-libjpeg ........ Use the libjpeg bundled with Qt.
 +  -system-libjpeg .... Use libjpeg from the operating system.
                         See http://www.ijg.org

    -no-openssl ........ Do not compile support for OpenSSL.
 +  -openssl ........... Enable run-time OpenSSL support.
    -openssl-linked .... Enabled linked OpenSSL support.

    -ptmalloc .......... Override the system memory allocator with ptmalloc.
                         (Experimental.)

Additional options:

    -make <part> ....... Add part to the list of parts to be built at make time.
                         ($QT_DEFAULT_BUILD_PARTS)
    -nomake <part> ..... Exclude part from the list of parts to be built.

    -R <string> ........ Add an explicit runtime library path to the Qt
                         libraries.
    -l <string> ........ Add an explicit library.

    -no-rpath .......... Do not use the library install path as a runtime
                         library path.
 +  -rpath ............. Link Qt libraries and executables using the library
                         install path as a runtime library path. Equivalent
                         to -R install_libpath

    -continue .......... Continue as far as possible if an error occurs.

    -verbose, -v ....... Print verbose information about each step of the
                         configure process.

    -silent ............ Reduce the build output so that warnings and errors
                         can be seen more easily.

 *  -no-optimized-qmake ... Do not build qmake optimized.
    -optimized-qmake ...... Build qmake optimized.

    -no-gui ............ Don't build the Qt GUI library

 $NSN  -no-nis ............ Do not compile NIS support.
 $NSY  -nis ............... Compile NIS support.

 $CUN  -no-cups ........... Do not compile CUPS support.
 $CUY  -cups .............. Compile CUPS support.
                         Requires cups/cups.h and libcups.so.2.

 $CIN  -no-iconv .......... Do not compile support for iconv(3).
 $CIY  -iconv ............. Compile support for iconv(3).

 $PHN  -no-pch ............ Do not use precompiled header support.
 $PHY  -pch ............... Use precompiled header support.

 $DBN  -no-dbus ........... Do not compile the QtDBus module.
 $DBY  -dbus .............. Compile the QtDBus module and dynamically load libdbus-1.
    -dbus-linked ....... Compile the QtDBus module and link to libdbus-1.

    -reduce-relocations ..... Reduce relocations in the libraries through extra
                              linker optimizations (Qt/X11 and Qt for Embedded Linux only;
                              experimental; needs GNU ld >= 2.18).
EOF

if [ "$CFG_SEPARATE_DEBUG_INFO" = "auto" ]; then
    if [ "$QT_CROSS_COMPILE" = "yes" ]; then
        SBY=""
        SBN="*"
    else
        SBY="*"
        SBN=" "
    fi
elif [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
    SBY="*"
    SBN=" "
else
    SBY=" "
    SBN="*"
fi

if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then

    cat << EOF

 $SBN  -no-separate-debug-info . Do not store debug information in a separate file.
 $SBY  -separate-debug-info .... Strip debug information into a separate .debug file.

EOF

fi # X11/QWS

if [ "$PLATFORM_X11" = "yes" ]; then
    if [ "$CFG_SM" = "no" ]; then
        SMY=" "
        SMN="*"
    else
        SMY="*"
        SMN=" "
    fi
    if [ "$CFG_XSHAPE" = "no" ]; then
        SHY=" "
        SHN="*"
    else
        SHY="*"
        SHN=" "
    fi
    if [ "$CFG_XVIDEO" = "no" ]; then
        XVY=" "
        XVN="*"
    else
        XVY="*"
        XVN=" "
    fi
    if [ "$CFG_XINERAMA" = "no" ]; then
        XAY=" "
        XAN="*"
    else
        XAY="*"
        XAN=" "
    fi
    if [ "$CFG_FONTCONFIG" = "no" ]; then
        FCGY=" "
        FCGN="*"
    else
        FCGY="*"
        FCGN=" "
    fi
    if [ "$CFG_XCURSOR" = "no" ]; then
        XCY=" "
        XCN="*"
    else
        XCY="*"
        XCN=" "
    fi
    if [ "$CFG_XFIXES" = "no" ]; then
        XFY=" "
        XFN="*"
    else
        XFY="*"
        XFN=" "
    fi
    if [ "$CFG_XRANDR" = "no" ]; then
        XZY=" "
        XZN="*"
    else
        XZY="*"
        XZN=" "
    fi
    if [ "$CFG_XRENDER" = "no" ]; then
        XRY=" "
        XRN="*"
    else
        XRY="*"
        XRN=" "
    fi
    if [ "$CFG_MITSHM" = "no" ]; then
        XMY=" "
        XMN="*"
    else
        XMY="*"
        XMN=" "
    fi
    if [ "$CFG_XINPUT" = "no" ]; then
        XIY=" "
        XIN="*"
    else
        XIY="*"
        XIN=" "
    fi
    if [ "$CFG_XKB" = "no" ]; then
        XKY=" "
        XKN="*"
    else
        XKY="*"
        XKN=" "
    fi
    if [ "$CFG_IM" = "no" ]; then
        IMY=" "
        IMN="*"
    else
        IMY="*"
        IMN=" "
    fi
    cat << EOF

Qt/X11 only:

    -no-gtkstyle ....... Do not build the GTK theme integration.
 +  -gtkstyle .......... Build the GTK theme integration.

 *  -no-nas-sound ...... Do not compile in NAS sound support.
    -system-nas-sound .. Use NAS libaudio from the operating system.
                         See http://radscan.com/nas.html

    -egl ............... Use EGL instead of GLX to manage contexts.
                         When building for desktop OpenGL, this option will
                         make Qt use EGL to manage contexts rather than the
                         GLX, which is the default. Note: For OpenGL ES, EGL
                         is always used.

    -no-opengl ......... Do not support OpenGL.
 +  -opengl <api> ...... Enable OpenGL support.
                         With no parameter, this will auto-detect the "best"
                         OpenGL API to use. If desktop OpenGL is available, it
                         will be used. Use desktop, es1, or es2 for <api>
                         to force the use of the Desktop (OpenGL 1.x or 2.x),
                         OpenGL ES 1.x Common profile, or 2.x APIs instead.

     -no-openvg ........ Do not support OpenVG.
 +   -openvg ........... Enable OpenVG support.
                         Requires EGL support, typically supplied by an OpenGL
                         or other graphics implementation.

 $SMN  -no-sm ............. Do not support X Session Management.
 $SMY  -sm ................ Support X Session Management, links in -lSM -lICE.

 $SHN  -no-xshape ......... Do not compile XShape support.
 $SHY  -xshape ............ Compile XShape support.
                         Requires X11/extensions/shape.h.

 $XVN  -no-xvideo ......... Do not compile XVideo support.
 $XVY  -xvideo ............ Compile XVideo support.
                         Requires X11/extensions/Xv.h & Xvlib.h.

 $SHN  -no-xsync .......... Do not compile XSync support.
 $SHY  -xsync ............. Compile XSync support.
                         Requires X11/extensions/sync.h.

 $XAN  -no-xinerama ....... Do not compile Xinerama (multihead) support.
 $XAY  -xinerama .......... Compile Xinerama support.
                         Requires X11/extensions/Xinerama.h and libXinerama.
			 By default, Xinerama support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

 $XCN  -no-xcursor ........ Do not compile Xcursor support.
 $XCY  -xcursor ........... Compile Xcursor support.
                         Requires X11/Xcursor/Xcursor.h and libXcursor.
			 By default, Xcursor support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

 $XFN  -no-xfixes ......... Do not compile Xfixes support.
 $XFY  -xfixes ............ Compile Xfixes support.
                         Requires X11/extensions/Xfixes.h and libXfixes.
			 By default, Xfixes support will be compiled if
                         available and the shared libraries are dynamically
                         loaded at runtime.

 $XZN  -no-xrandr ......... Do not compile Xrandr (resize and rotate) support.
 $XZY  -xrandr ............ Compile Xrandr support.
                         Requires X11/extensions/Xrandr.h and libXrandr.

 $XRN  -no-xrender ........ Do not compile Xrender support.
 $XRY  -xrender ........... Compile Xrender support.
                         Requires X11/extensions/Xrender.h and libXrender.

 $XMN  -no-mitshm ......... Do not compile MIT-SHM support.
 $XMY  -mitshm ............ Compile MIT-SHM support.
                         Requires sys/ipc.h, sys/shm.h and X11/extensions/XShm.h

 $FCGN  -no-fontconfig ..... Do not compile FontConfig (anti-aliased font) support.
 $FCGY  -fontconfig ........ Compile FontConfig support.
                         Requires fontconfig/fontconfig.h, libfontconfig,
                         freetype.h and libfreetype.

 $XIN  -no-xinput ......... Do not compile Xinput support.
 $XIY  -xinput ............ Compile Xinput support. This also enabled tablet support
                         which requires IRIX with wacom.h and libXi or
                         XFree86 with X11/extensions/XInput.h and libXi.

 $XKN  -no-xkb ............ Do not compile XKB (X KeyBoard extension) support.
 $XKY  -xkb ............... Compile XKB support.

EOF
fi

if [ "$PLATFORM_MAC" = "yes" ]; then
    cat << EOF

Qt/Mac only:

    -Fstring ........... Add an explicit framework path.
    -fw string ......... Add an explicit framework.

    -cocoa ............. [Deprecated] Cocoa is now enabled by default.

    -carbon .............Build the Carbon version of Qt. 64-bit archs
                         are not supported by carbon and will be built
                         with cocoa

 *  -framework ......... Build Qt as a series of frameworks and
                         link tools against those frameworks.
    -no-framework ...... Do not build Qt as a series of frameworks.

 *  -dwarf2 ............ Enable dwarf2 debugging symbols.
    -no-dwarf2 ......... Disable dwarf2 debugging symbols.

    -universal ......... Equivalent to -arch "ppc x86"

    -arch <arch> ....... Build Qt for <arch>
                         Example values for <arch>: x86 ppc x86_64 ppc64
                         Multiple -arch arguments can be specified.

    -sdk <sdk> ......... Build Qt using Apple provided SDK <sdk>. This option requires gcc 4.
                         To use a different SDK with gcc 3.3, set the SDKROOT environment variable.

EOF
fi

if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    cat << EOF

Qt for Embedded Linux only:

    -xplatform target ... The target platform when cross-compiling.

    -no-feature-<feature> Do not compile in <feature>.
    -feature-<feature> .. Compile in <feature>. The available features
                          are described in src/corelib/global/qfeatures.txt

    -embedded <arch> .... This will enable the embedded build, you must have a
                          proper license for this switch to work.
                          Example values for <arch>: arm mips x86 generic

    -qpa <arch> ......... This will enable the QPA build.
                          Example values for <arch>: arm mips x86 generic
                          QPA is a window system agnostic implementation of Qt.

    -armfpa ............. Target platform uses the ARM-FPA floating point format.
    -no-armfpa .......... Target platform does not use the ARM-FPA floating point format.

                          The floating point format is usually autodetected by configure. Use this
                          to override the detected value.

    -little-endian ...... Target platform is little endian (LSB first).
    -big-endian ......... Target platform is big endian (MSB first).

    -host-little-endian . Host platform is little endian (LSB first).
    -host-big-endian .... Host platform is big endian (MSB first).

                          You only need to specify the endianness when
                          cross-compiling, otherwise the host
                          endianness will be used.

    -no-freetype ........ Do not compile in Freetype2 support.
    -qt-freetype ........ Use the libfreetype bundled with Qt.
 *  -system-freetype .... Use libfreetype from the operating system.
                          See http://www.freetype.org/

    -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the
                          default ($CFG_QCONFIG).

    -depths <list> ...... Comma-separated list of supported bit-per-pixel
                          depths, from: 1, 4, 8, 12, 15, 16, 18, 24, 32 and 'all'.

    -qt-decoration-<style> ....Enable a decoration <style> in the QtGui library,
                               by default all available decorations are on.
			       Possible values for <style>: [ $CFG_DECORATION_AVAILABLE ]
    -plugin-decoration-<style> Enable decoration <style> as a plugin to be
                               linked to at run time.
			       Possible values for <style>: [ $CFG_DECORATION_PLUGIN_AVAILABLE ]
    -no-decoration-<style> ....Disable decoration <style> entirely.
                               Possible values for <style>: [ $CFG_DECORATION_AVAILABLE ]

    -no-opengl .......... Do not support OpenGL.
    -opengl <api> ....... Enable OpenGL ES support
                          With no parameter, this will attempt to auto-detect OpenGL ES 1.x
                          or 2.x. Use es1 or es2 for <api> to override auto-detection.

                          NOTE: A QGLScreen driver for the hardware is required to support
                                OpenGL ES on Qt for Embedded Linux.

    -qt-gfx-<driver> ... Enable a graphics <driver> in the QtGui library.
                         Possible values for <driver>: [ $CFG_GFX_AVAILABLE ]
    -plugin-gfx-<driver> Enable graphics <driver> as a plugin to be
                         linked to at run time.
                         Possible values for <driver>: [ $CFG_GFX_PLUGIN_AVAILABLE ]
    -no-gfx-<driver> ... Disable graphics <driver> entirely.
                         Possible values for <driver>: [ $CFG_GFX_AVAILABLE ]

    -qt-kbd-<driver> ... Enable a keyboard <driver> in the QtGui library.
                         Possible values for <driver>: [ $CFG_KBD_AVAILABLE ]

    -plugin-kbd-<driver> Enable keyboard <driver> as a plugin to be linked to
                         at runtime.
                         Possible values for <driver>: [ $CFG_KBD_PLUGIN_AVAILABLE ]

    -no-kbd-<driver> ... Disable keyboard <driver> entirely.
                         Possible values for <driver>: [ $CFG_KBD_AVAILABLE ]

    -qt-mouse-<driver> ... Enable a mouse <driver> in the QtGui library.
                           Possible values for <driver>: [ $CFG_MOUSE_AVAILABLE ]
    -plugin-mouse-<driver> Enable mouse <driver> as a plugin to be linked to
                           at runtime.
                           Possible values for <driver>: [ $CFG_MOUSE_PLUGIN_AVAILABLE ]
    -no-mouse-<driver> ... Disable mouse <driver> entirely.
                           Possible values for <driver>: [ $CFG_MOUSE_AVAILABLE ]

    -iwmmxt ............ Compile using the iWMMXt instruction set
                         (available on some XScale CPUs).

    -no-neon ........... Do not compile with use of NEON instructions.
EOF
fi


if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" -o "$PLATFORM_X11" = "yes" ]; then
    if [ "$CFG_GLIB" = "no" ]; then
        GBY=" "
        GBN="+"
    else
        GBY="+"
        GBN=" "
    fi
    cat << EOF
 $GBN  -no-glib ........... Do not compile Glib support.
 $GBY  -glib .............. Compile Glib support.

EOF
fi

case "$XPLATFORM" in *symbian*)
    cat << EOF

Qt for Symbian only:
    -no-s60 ............ Do not compile in S60 support.
 +  -s60 ............... Compile with support for the S60 UI Framework.
    -no-style-s60....... Disable s60 style
 +  -qt-style-s60....... Enable s60 style in the Qt Library

    -no-usedeffiles .... Disable the usage of DEF files.
 *  -usedeffiles ....... Enable the usage of DEF files.
EOF
;;
esac

   [ "x$ERROR" = "xyes" ] && exit 1
   exit 0
fi # Help


# -----------------------------------------------------------------------------
# LICENSING, INTERACTIVE PART
# -----------------------------------------------------------------------------

if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    Platform="Qt for Embedded Linux"
elif [ "$PLATFORM_MAC" = "yes" ]; then
    Platform="Qt for Mac OS X"
elif echo "$XPLATFORM" | grep "symbian" > /dev/null ; then
    Platform="Qt for Symbian"
elif [ "$XPLATFORM_MINGW" = "yes" ]; then
    Platform="Qt for Windows"
elif [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ]; then
    PLATFORM_X11=yes
    Platform="Qt for Linux/X11"
fi

echo
echo "This is the $Platform ${EditionString} Edition."
echo

if [ "$Edition" = "NokiaInternalBuild" ]; then
    echo "Detected -nokia-developer option"
    echo "Nokia employees and agents are allowed to use this software under"
    echo "the authority of Nokia Corporation and/or its subsidiary(-ies)"
elif [ "$Edition" = "OpenSource" ]; then
    while true; do
        echo "You are licensed to use this software under the terms of"
        echo "the Lesser GNU General Public License (LGPL) versions 2.1."
        if [ -f "$relpath/LICENSE.GPL3" ]; then
            echo "You are also licensed to use this software under the terms of"
            echo "the GNU General Public License (GPL) versions 3."
            affix="either"
        else
            affix="the"
        fi
        echo
        if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
            echo "You have already accepted the terms of the $LicenseType license."
            acceptance=yes
        else
            if [ -f "$relpath/LICENSE.GPL3" ]; then
                echo "Type '3' to view the GNU General Public License version 3."
            fi
            echo "Type 'L' to view the Lesser GNU General Public License version 2.1."
            echo "Type 'yes' to accept this license offer."
            echo "Type 'no' to decline this license offer."
            echo
            echo $ECHO_N "Do you accept the terms of $affix license? $ECHO_C"
            read acceptance
        fi
        echo
        if [ "$acceptance" = "yes" ] || [ "$acceptance" = "y" ]; then
            break
        elif [ "$acceptance" = "no" ]; then
            echo "You are not licensed to use this software."
            echo
            exit 1
        elif [ "$acceptance" = "3" ]; then
            more "$relpath/LICENSE.GPL3"
        elif [ "$acceptance" = "L" ]; then
            more "$relpath/LICENSE.LGPL"
        fi
    done
elif [ "$Edition" = "Preview" ]; then
    TheLicense=`head -n 1 "$relpath/LICENSE.PREVIEW.COMMERCIAL"`
    while true; do

        if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
            echo "You have already accepted the terms of the $LicenseType license."
            acceptance=yes
        else
            echo "You are licensed to use this software under the terms of"
            echo "the $TheLicense"
            echo
            echo "Type '?' to read the Preview License."
            echo "Type 'yes' to accept this license offer."
            echo "Type 'no' to decline this license offer."
            echo
            echo $ECHO_N "Do you accept the terms of the license? $ECHO_C"
            read acceptance
        fi
        echo
        if [ "$acceptance" = "yes" ]; then
            break
        elif [ "$acceptance" = "no" ] ;then
            echo "You are not licensed to use this software."
            echo
            exit 0
        elif [ "$acceptance" = "?" ]; then
            more "$relpath/LICENSE.PREVIEW.COMMERCIAL"
        fi
    done
elif [ "$Edition" != "OpenSource" ]; then
    if [ -n "$ExpiryDate" ]; then
        ExpiryDate=`echo $ExpiryDate | sed -e "s,-,,g" | tr -d "\n\r"`
        [ -z "$ExpiryDate" ] && ExpiryDate="0"
        Today=`date +%Y%m%d`
        if [ "$Today" -gt "$ExpiryDate" ]; then
            case "$LicenseType" in
            Commercial|Academic|Educational)
                if [ "$QT_PACKAGEDATE" -gt "$ExpiryDate" ]; then
                    echo
                    echo "NOTICE  NOTICE  NOTICE  NOTICE"
                    echo
                    echo "  Your support and upgrade period has expired."
                    echo
                    echo "  You are no longer licensed to use this version of Qt."
                    echo "  Please contact qt-info@nokia.com to renew your support"
                    echo "  and upgrades for this license."
                    echo
                    echo "NOTICE  NOTICE  NOTICE  NOTICE"
                    echo
                    exit 1
                else
                    echo
                    echo "WARNING  WARNING  WARNING  WARNING"
                    echo
                    echo "  Your support and upgrade period has expired."
                    echo
                    echo "  You may continue to use your last licensed release"
                    echo "  of Qt under the terms of your existing license"
                    echo "  agreement. But you are not entitled to technical"
                    echo "  support, nor are you entitled to use any more recent"
                    echo "  Qt releases."
                    echo
                    echo "  Please contact qt-info@nokia.com to renew your"
                    echo "  support and upgrades for this license."
                    echo
                    echo "WARNING  WARNING  WARNING  WARNING"
                    echo
                    sleep 3
                fi
                ;;
            Evaluation|*)
                echo
                echo "NOTICE  NOTICE  NOTICE  NOTICE"
                echo
                echo "  Your Evaluation license has expired."
                echo
                echo "  You are no longer licensed to use this software. Please"
                echo "  contact qt-info@nokia.com to purchase license, or install"
                echo "  the Qt Open Source Edition if you intend to develop free"
                echo "  software."
                echo
                echo "NOTICE  NOTICE  NOTICE  NOTICE"
                echo
                exit 1
                ;;
            esac
        fi
    fi
    TheLicense=`head -n 1 "$outpath/LICENSE"`
    while true; do
        if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
	    echo "You have already accepted the terms of the $TheLicense."
            acceptance=yes
        else
            echo "You are licensed to use this software under the terms of"
            echo "the $TheLicense."
            echo
            echo "Type '?' to view the $TheLicense."
            echo "Type 'yes' to accept this license offer."
            echo "Type 'no' to decline this license offer."
            echo
            echo $ECHO_N "Do you accept the terms of the $TheLicense? $ECHO_C"
            read acceptance
        fi
        echo
        if [ "$acceptance" = "yes" ]; then
            break
        elif [ "$acceptance" = "no" ]; then
            echo "You are not licensed to use this software."
            echo
            exit 1
        else [ "$acceptance" = "?" ]
            more "$outpath/LICENSE"
        fi
    done
fi

# this should be moved somewhere else
case "$PLATFORM" in
aix-*)
    AIX_VERSION=`uname -v`
    if [ "$AIX_VERSION" -lt "5" ]; then
	QMakeVar add QMAKE_LIBS_X11 -lbind
    fi
    ;;
*)
    ;;
esac

#-------------------------------------------------------------------------------
# generate qconfig.cpp
#-------------------------------------------------------------------------------
[ -d "$outpath/src/corelib/global" ] || mkdir -p "$outpath/src/corelib/global"

LICENSE_USER_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_lcnsuser=$Licensee"`
LICENSE_PRODUCTS_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_lcnsprod=$Edition"`
PREFIX_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_prfxpath=$QT_INSTALL_PREFIX"`
DOCUMENTATION_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_docspath=$QT_INSTALL_DOCS"`
HEADERS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_hdrspath=$QT_INSTALL_HEADERS"`
LIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_INSTALL_LIBS"`
BINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_INSTALL_BINS"`
PLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_INSTALL_PLUGINS"`
IMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_INSTALL_IMPORTS"`
DATA_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_datapath=$QT_INSTALL_DATA"`
TRANSLATIONS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_trnspath=$QT_INSTALL_TRANSLATIONS"`
SETTINGS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_stngpath=$QT_INSTALL_SETTINGS"`
EXAMPLES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_xmplpath=$QT_INSTALL_EXAMPLES"`
DEMOS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_demopath=$QT_INSTALL_DEMOS"`

TODAY=`date +%Y-%m-%d`
cat > "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
/* License Info */
static const char qt_configure_licensee_str          [256 + 12] = "$LICENSE_USER_STR";
static const char qt_configure_licensed_products_str [256 + 12] = "$LICENSE_PRODUCTS_STR";

/* Installation date */
static const char qt_configure_installation          [12+11]    = "qt_instdate=$TODAY";
EOF


if [ ! -z "$QT_HOST_PREFIX" ]; then
    HOSTPREFIX_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_prfxpath=$QT_HOST_PREFIX"`
    HOSTDOCUMENTATION_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_docspath=$QT_HOST_PREFIX/doc"`
    HOSTHEADERS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_hdrspath=$QT_HOST_PREFIX/include"`
    HOSTLIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_HOST_PREFIX/lib"`
    HOSTBINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_HOST_PREFIX/bin"`
    HOSTPLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_HOST_PREFIX/plugins"`
    HOSTIMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_HOST_PREFIX/IMPORTS"`
    HOSTDATA_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_datapath=$QT_HOST_PREFIX"`
    HOSTTRANSLATIONS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_trnspath=$QT_HOST_PREFIX/translations"`
    HOSTSETTINGS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_stngpath=$QT_INSTALL_SETTINGS"`
    HOSTEXAMPLES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_xmplpath=$QT_INSTALL_EXAMPLES"`
    HOSTDEMOS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_demopath=$QT_INSTALL_DEMOS"`

    cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF

#if defined(QT_BOOTSTRAPPED) || defined(QT_BUILD_QMAKE)
/* Installation Info */
static const char qt_configure_prefix_path_str       [256 + 12] = "$HOSTPREFIX_PATH_STR";
static const char qt_configure_documentation_path_str[256 + 12] = "$HOSTDOCUMENTATION_PATH_STR";
static const char qt_configure_headers_path_str      [256 + 12] = "$HOSTHEADERS_PATH_STR";
static const char qt_configure_libraries_path_str    [256 + 12] = "$HOSTLIBRARIES_PATH_STR";
static const char qt_configure_binaries_path_str     [256 + 12] = "$HOSTBINARIES_PATH_STR";
static const char qt_configure_plugins_path_str      [256 + 12] = "$HOSTPLUGINS_PATH_STR";
static const char qt_configure_imports_path_str      [256 + 12] = "$HOSTIMPORTS_PATH_STR";
static const char qt_configure_data_path_str         [256 + 12] = "$HOSTDATA_PATH_STR";
static const char qt_configure_translations_path_str [256 + 12] = "$HOSTTRANSLATIONS_PATH_STR";
static const char qt_configure_settings_path_str     [256 + 12] = "$HOSTSETTINGS_PATH_STR";
static const char qt_configure_examples_path_str     [256 + 12] = "$HOSTEXAMPLES_PATH_STR";
static const char qt_configure_demos_path_str        [256 + 12] = "$HOSTDEMOS_PATH_STR";
#else // QT_BOOTSTRAPPED
EOF
fi

cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
/* Installation Info */
static const char qt_configure_prefix_path_str       [256 + 12] = "$PREFIX_PATH_STR";
static const char qt_configure_documentation_path_str[256 + 12] = "$DOCUMENTATION_PATH_STR";
static const char qt_configure_headers_path_str      [256 + 12] = "$HEADERS_PATH_STR";
static const char qt_configure_libraries_path_str    [256 + 12] = "$LIBRARIES_PATH_STR";
static const char qt_configure_binaries_path_str     [256 + 12] = "$BINARIES_PATH_STR";
static const char qt_configure_plugins_path_str      [256 + 12] = "$PLUGINS_PATH_STR";
static const char qt_configure_imports_path_str      [256 + 12] = "$IMPORTS_PATH_STR";
static const char qt_configure_data_path_str         [256 + 12] = "$DATA_PATH_STR";
static const char qt_configure_translations_path_str [256 + 12] = "$TRANSLATIONS_PATH_STR";
static const char qt_configure_settings_path_str     [256 + 12] = "$SETTINGS_PATH_STR";
static const char qt_configure_examples_path_str     [256 + 12] = "$EXAMPLES_PATH_STR";
static const char qt_configure_demos_path_str        [256 + 12] = "$DEMOS_PATH_STR";
EOF

if [ ! -z "$QT_HOST_PREFIX" ]; then
    cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
#endif // QT_BOOTSTRAPPED

EOF
fi

cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
/* strlen( "qt_lcnsxxxx" ) == 12 */
#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;
#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;
#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12;
#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;
#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;
#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;
#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;
#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;
#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;
#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;
#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;
#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;
#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;
#define QT_CONFIGURE_DEMOS_PATH qt_configure_demos_path_str + 12;
EOF

# avoid unecessary rebuilds by copying only if qconfig.cpp has changed
if cmp -s "$outpath/src/corelib/global/qconfig.cpp" "$outpath/src/corelib/global/qconfig.cpp.new"; then
    rm -f "$outpath/src/corelib/global/qconfig.cpp.new"
else
    [ -f "$outpath/src/corelib/global/qconfig.cpp" ] && chmod +w "$outpath/src/corelib/global/qconfig.cpp"
    mv "$outpath/src/corelib/global/qconfig.cpp.new" "$outpath/src/corelib/global/qconfig.cpp"
    chmod -w "$outpath/src/corelib/global/qconfig.cpp"
fi

# -----------------------------------------------------------------------------
if [ "$LicenseType" = "Evaluation" ]; then
    EVALKEY=`"$relpath/config.tests/unix/padstring" 524 "qt_qevalkey=$LicenseKeyExt"`
elif echo "$D_FLAGS" | grep QT_EVAL >/dev/null 2>&1; then
    EVALKEY=`"$relpath/config.tests/unix/padstring" 524 "qt_qevalkey="`
fi

if [ -n "$EVALKEY" ]; then
    rm -f "$outpath/src/corelib/global/qconfig_eval.cpp"
    cat > "$outpath/src/corelib/global/qconfig_eval.cpp" <<EOF
/* Evaluation license key */
static const char qt_eval_key_data                   [512 + 12] = "$EVALKEY";
EOF
    chmod -w "$outpath/src/corelib/global/qconfig_eval.cpp"
fi


# -----------------------------------------------------------------------------
# build qmake
# -----------------------------------------------------------------------------

# symlink includes
if [ -n "$PERL" ] && [ -x "$relpath/bin/syncqt" ]; then
    SYNCQT_OPTS=
    [ "$CFG_DEV" = "yes" ] && SYNCQT_OPTS="$SYNCQT_OPTS -check-includes"
    if [ "$OPT_SHADOW" = "yes" ]; then
        "$outpath/bin/syncqt" $SYNCQT_OPTS
    elif [ "$CFG_DEV" = "yes" ] || [ ! -d $relpath/include ] || [ -d $relpath/.git ]; then
        QTDIR="$relpath" perl "$outpath/bin/syncqt" $SYNCQT_OPTS
    fi
fi

# $1: variable name
# $2: optional transformation
# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter
# is where the resulting variable is written to
setBootstrapVariable()
{
    getQMakeConf | $AWK '/^('"$1"')[^_A-Z0-9]/ { print $0; }' | ( [ -n "$2" ] && sed "$2" ; [ -z "$2" ] && cat ) | $AWK '
{
    varLength = index($0, "=") - 1
    valStart = varLength + 2
    if (substr($0, varLength, 1) == "+") {
        varLength = varLength - 1
        valStart = valStart + 1
    }
    var = substr($0, 0, varLength)
    gsub("[ \t]+", "", var)
    val = substr($0, valStart)
    printf "%s_%s = %s\n", var, NR, val
}
END {
    if (length(var) > 0) {
        printf "%s =", var
        for (i = 1; i <= NR; ++i)
            printf " $(%s_%s)", var, i
        printf "\n"
    }
}' >> "$mkfile"
}

# build qmake
if true; then ###[ '!' -f "$outpath/bin/qmake" ];
    echo "Creating qmake. Please wait..."

    OLD_QCONFIG_H=
    QCONFIG_H="$outpath/src/corelib/global/qconfig.h"
    QMAKE_QCONFIG_H="${QCONFIG_H}.qmake"
    if [ -f "$QCONFIG_H" ]; then
         OLD_QCONFIG_H=$QCONFIG_H
         mv -f "$OLD_QCONFIG_H" "${OLD_QCONFIG_H}.old"
    fi

    # create temporary qconfig.h for compiling qmake, if it doesn't exist
    # when building qmake, we use #defines for the install paths,
    # however they are real functions in the library
    if [ '!' -f "$QMAKE_QCONFIG_H" ]; then
        mkdir -p "$outpath/src/corelib/global"
        [ -f "$QCONFIG_H" ] && chmod +w "$QCONFIG_H"
        echo "/* All features enabled while building qmake */" >"$QMAKE_QCONFIG_H"
    fi

    mv -f "$QMAKE_QCONFIG_H" "$QCONFIG_H"

    #mkspecs/default is used as a (gasp!) default mkspec so QMAKESPEC needn't be set once configured
    rm -rf mkspecs/default
    if echo "$XPLATFORM" | grep "symbian-sbsv2" > /dev/null ; then
#Link is not supported for Symbian build system
        cp -a mkspecs/`echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` mkspecs/default
    else
        ln -s `echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"` mkspecs/default
    fi
    # fix makefiles
    for mkfile in GNUmakefile Makefile; do
        EXTRA_LFLAGS=
        EXTRA_CFLAGS=
        in_mkfile="${mkfile}.in"
        if [ "$mkfile" = "Makefile" ]; then
#           if which qmake >/dev/null 2>&1 && [ -f qmake/qmake.pro ]; then
#               (cd qmake && qmake) >/dev/null 2>&1 && continue
#           fi
            in_mkfile="${mkfile}.unix"
        fi
        in_mkfile="$relpath/qmake/$in_mkfile"
        mkfile="$outpath/qmake/$mkfile"
        if [ -f "$mkfile" ]; then
            [ "$CFG_DEV" = "yes" ] && "$WHICH" chflags >/dev/null 2>&1 && chflags nouchg "$mkfile"
            rm -f "$mkfile"
        fi
        [ -f "$in_mkfile" ] || continue

        echo "########################################################################" > "$mkfile"
        echo "## This file was autogenerated by configure, all changes will be lost ##" >> "$mkfile"
        echo "########################################################################" >> "$mkfile"
        EXTRA_OBJS=
        EXTRA_SRCS=
        EXTRA_CFLAGS="\$(QMAKE_CFLAGS)"
        EXTRA_CXXFLAGS="\$(QMAKE_CXXFLAGS)"
        EXTRA_LFLAGS="\$(QMAKE_LFLAGS)"

        if [ "$PLATFORM" = "irix-cc" ] || [ "$PLATFORM" = "irix-cc-64" ]; then
	    EXTRA_LFLAGS="$EXTRA_LFLAGS -lm"
        fi

	[ -n "$CC" ] && echo "CC = $CC" >> "$mkfile"
	[ -n "$CXX" ] && echo "CXX = $CXX" >> "$mkfile"
        if [ "$CFG_SILENT" = "yes" ]; then
            [ -z "$CC" ] && setBootstrapVariable QMAKE_CC 's,QMAKE_CC.*=,CC=\@,'
            [ -z "$CXX" ] && setBootstrapVariable QMAKE_CXX 's,QMAKE_CXX.*=,CXX=\@,'
        else
            [ -z "$CC" ] && setBootstrapVariable QMAKE_CC 's,QMAKE_CC,CC,'
            [ -z "$CXX" ] && setBootstrapVariable QMAKE_CXX 's,QMAKE_CXX,CXX,'
        fi
        setBootstrapVariable QMAKE_CFLAGS
        setBootstrapVariable QMAKE_CXXFLAGS 's,\$\$QMAKE_CFLAGS,\$(QMAKE_CFLAGS),'
        setBootstrapVariable QMAKE_LFLAGS

        if [ $QT_EDITION = "QT_EDITION_OPENSOURCE" ]; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DQMAKE_OPENSOURCE_EDITION"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -DQMAKE_OPENSOURCE_EDITION"
        fi
        if [ "$CFG_RELEASE_QMAKE" = "yes" ]; then
            setBootstrapVariable QMAKE_CFLAGS_RELEASE
            setBootstrapVariable QMAKE_CXXFLAGS_RELEASE 's,\$\$QMAKE_CFLAGS_RELEASE,\$(QMAKE_CFLAGS_RELEASE),'
            EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_RELEASE)"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_RELEASE)"
        elif [ "$CFG_DEBUG" = "yes" ]; then
            setBootstrapVariable QMAKE_CFLAGS_DEBUG
            setBootstrapVariable QMAKE_CXXFLAGS_DEBUG 's,\$\$QMAKE_CFLAGS_DEBUG,\$(QMAKE_CFLAGS_DEBUG),'
            EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_DEBUG)"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)"
        fi

        if [ '!' -z "$RPATH_FLAGS" ] && [ '!' -z "`getQMakeConf \"$QMAKESPEC\" | $AWK '/QMAKE_(LFLAGS_)?RPATH/ {print $3;}'`" ]; then
            setBootstrapVariable "QMAKE_(LFLAGS_)?RPATH" 's,\$\$LITERAL_WHITESPACE, ,;s,QMAKE_RPATH,QMAKE_LFLAGS_RPATH,'
            for rpath in $RPATH_FLAGS; do
                EXTRA_LFLAGS="\$(QMAKE_LFLAGS_RPATH)\"$rpath\" $EXTRA_LFLAGS"
            done
        fi
        if [ "$BUILD_ON_MAC" = "yes" ]; then
            echo "export MACOSX_DEPLOYMENT_TARGET = 10.4" >> "$mkfile"
            echo "CARBON_LFLAGS =-framework ApplicationServices" >>"$mkfile"
            echo "CARBON_CFLAGS =-fconstant-cfstrings" >>"$mkfile"
            EXTRA_LFLAGS="$EXTRA_LFLAGS \$(CARBON_LFLAGS)"
            EXTRA_CFLAGS="$EXTRA_CFLAGS \$(CARBON_CFLAGS)"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(CARBON_CFLAGS)"
            EXTRA_OBJS="qsettings_mac.o qcore_mac.o"
            EXTRA_SRCS="\"$relpath/src/corelib/io/qsettings_mac.cpp\" \"$relpath/src/corelib/kernel/qcore_mac.cpp\""
	    if echo "$CFG_MAC_ARCHS" | grep x86 > /dev/null 2>&1; then # matches both x86 and x86_64
		X86_CFLAGS="-arch i386"
		X86_LFLAGS="-arch i386"
		EXTRA_CFLAGS="$X86_CFLAGS $EXTRA_CFLAGS"
		EXTRA_CXXFLAGS="$X86_CFLAGS $EXTRA_CXXFLAGS"
                EXTRA_LFLAGS="$EXTRA_LFLAGS $X86_LFLAGS"
            fi
	    if echo "$CFG_MAC_ARCHS" | grep ppc > /dev/null 2>&1; then # matches both ppc and ppc64
		PPC_CFLAGS="-arch ppc"
		PPC_LFLAGS="-arch ppc"
		EXTRA_CFLAGS="$PPC_CFLAGS $EXTRA_CFLAGS"
		EXTRA_CXXFLAGS="$PPC_CFLAGS $EXTRA_CXXFLAGS"
                EXTRA_LFLAGS="$EXTRA_LFLAGS $PPC_LFLAGS"
            fi
	    if [ '!' -z "$CFG_SDK" ]; then
		echo "SDK_LFLAGS =-Wl,-syslibroot,$CFG_SDK" >>"$mkfile"
		echo "SDK_CFLAGS =-isysroot $CFG_SDK" >>"$mkfile"
		EXTRA_CFLAGS="$EXTRA_CFLAGS \$(SDK_CFLAGS)"
		EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(SDK_CFLAGS)"
		EXTRA_LFLAGS="$EXTRA_LFLAGS \$(SDK_LFLAGS)"
            fi
        fi
        [ "$CFG_EMBEDDED" != "no" ] && EXTRA_CFLAGS="$EXTRA_CFLAGS -DQWS"
        if [ '!' -z "$D_FLAGS" ]; then
            for DEF in $D_FLAGS; do
                EXTRA_CFLAGS="$EXTRA_CFLAGS \"-D${DEF}\""
            done
        fi
        QMAKE_BIN_DIR="$QT_INSTALL_BINS"
        [ -z "$QMAKE_BIN_DIR" ] && QMAKE_BIN_DIR="${QT_INSTALL_PREFIX}/bin"
        QMAKE_DATA_DIR="$QT_INSTALL_DATA"
        [ -z "$QMAKE_DATA_DIR" ] && QMAKE_DATA_DIR="${QT_INSTALL_PREFIX}"
        echo >>"$mkfile"
	adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'`
	adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'`
	adjqmakespec=`echo "$QMAKESPEC" | sed 's/ /\\\\\\\\ /g'`
        sed -e "s,@SOURCE_PATH@,$adjrelpath,g" -e "s,@BUILD_PATH@,$adjoutpath,g" \
            -e "s,@QMAKE_CFLAGS@,$EXTRA_CFLAGS,g" -e "s,@QMAKE_LFLAGS@,$EXTRA_LFLAGS,g" \
            -e "s,@QMAKE_CXXFLAGS@,$EXTRA_CXXFLAGS,g" \
            -e "s,@QT_INSTALL_BINS@,\$(INSTALL_ROOT)$QMAKE_BIN_DIR,g" \
            -e "s,@QT_INSTALL_DATA@,\$(INSTALL_ROOT)$QMAKE_DATA_DIR,g" \
            -e "s,@QMAKE_QTOBJS@,$EXTRA_OBJS,g" -e "s,@QMAKE_QTSRCS@,$EXTRA_SRCS,g" \
	    -e "s,@QMAKESPEC@,$adjqmakespec,g" "$in_mkfile" >>"$mkfile"

        if "$WHICH" makedepend >/dev/null 2>&1 && grep 'depend:' "$mkfile" >/dev/null 2>&1; then
            (cd "$outpath/qmake" && "$MAKE" -f "$mkfile" depend) >/dev/null 2>&1
	    sed "s,^.*/\([^/]*.o\):,\1:,g" "$mkfile" >"$mkfile.tmp"
	    sed "s,$outpath,$adjoutpath,g" "$mkfile.tmp" >"$mkfile"
	    rm "$mkfile.tmp"
        fi
    done

    QMAKE_BUILD_ERROR=no
    (cd "$outpath/qmake"; "$MAKE") || QMAKE_BUILD_ERROR=yes
    [ '!' -z "$QCONFIG_H" ] && mv -f "$QCONFIG_H" "$QMAKE_QCONFIG_H" #move qmake's qconfig.h to qconfig.h.qmake
    [ '!' -z "$OLD_QCONFIG_H" ] && mv -f "${OLD_QCONFIG_H}.old" "$OLD_QCONFIG_H" #put back qconfig.h
    [ "$QMAKE_BUILD_ERROR" = "yes" ] && exit 2
fi # Build qmake

#-------------------------------------------------------------------------------
# tests that need qmake
#-------------------------------------------------------------------------------

# detect availability of float math.h functions
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $l_FLAGS; then
    CFG_USE_FLOATMATH=yes
else
    CFG_USE_FLOATMATH=no
fi

# detect mmx support
if [ "${CFG_MMX}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mmx "mmx" $L_FLAGS $I_FLAGS $l_FLAGS "-mmmx"; then
	CFG_MMX=yes
    else
	CFG_MMX=no
    fi
fi

# detect 3dnow support
if [ "${CFG_3DNOW}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/3dnow "3dnow" $L_FLAGS $I_FLAGS $l_FLAGS "-m3dnow"; then
	CFG_3DNOW=yes
    else
	CFG_3DNOW=no
    fi
fi

# detect sse support
if [ "${CFG_SSE}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse "sse" $L_FLAGS $I_FLAGS $l_FLAGS "-msse"; then
	CFG_SSE=yes
    else
	CFG_SSE=no
    fi
fi

# detect sse2 support
if [ "${CFG_SSE2}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse2 "sse2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse2"; then
       CFG_SSE2=yes
    else
       CFG_SSE2=no
    fi
fi

# detect sse3 support
if [ "${CFG_SSE3}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse3 "sse3" $L_FLAGS $I_FLAGS $l_FLAGS "-msse3"; then
       CFG_SSE3=yes
    else
       CFG_SSE3=no
    fi
fi

# detect ssse3 support
if [ "${CFG_SSSE3}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ssse3 "ssse3" $L_FLAGS $I_FLAGS $l_FLAGS "-mssse3"; then
       CFG_SSSE3=yes
    else
       CFG_SSSE3=no
    fi
fi

# detect sse4.1 support
if [ "${CFG_SSE4_1}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse4_1 "sse4_1" $L_FLAGS $I_FLAGS $l_FLAGS "-msse4.1"; then
       CFG_SSE4_1=yes
    else
       CFG_SSE4_1=no
    fi
fi

# detect sse4.2 support
if [ "${CFG_SSE4_2}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sse4_2 "sse4_2" $L_FLAGS $I_FLAGS $l_FLAGS "-msse4.2"; then
       CFG_SSE4_2=yes
    else
       CFG_SSE4_2=no
    fi
fi

# detect avx support
if [ "${CFG_AVX}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/avx "avx" $L_FLAGS $I_FLAGS $l_FLAGS "-mavx"; then
       CFG_AVX=yes
    else
       CFG_AVX=no
    fi
fi

# check iWMMXt support
if [ "$CFG_IWMMXT" = "yes" ]; then
    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iwmmxt "iwmmxt" $L_FLAGS $I_FLAGS $l_FLAGS "-mcpu=iwmmxt"
    if [ $? != "0" ]; then
        echo "The iWMMXt functionality test failed!"
	echo " Please make sure your compiler supports iWMMXt intrinsics!"
	exit 1
    fi
fi

# detect neon support
if ( [ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ] ) && [ "${CFG_NEON}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/neon "neon" $L_FLAGS $I_FLAGS $l_FLAGS "-mfpu=neon"; then
	CFG_NEON=yes
    else
	CFG_NEON=no
    fi
fi

# detect zlib
if [ "$CFG_ZLIB" = "no" ]; then
    # Note: Qt no longer support builds without zlib
    # So we force a "no" to be "auto" here.
    # If you REALLY really need no zlib support, you can still disable
    # it by doing the following:
    #   add "no-zlib" to mkspecs/qconfig.pri
    #   #define QT_NO_COMPRESS (probably by adding to src/corelib/global/qconfig.h)
    #
    # There's no guarantee that Qt will build under those conditions

    CFG_ZLIB=auto
    ZLIB_FORCED=yes
fi
if [ "$CFG_ZLIB" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
       CFG_ZLIB=system
    else
       CFG_ZLIB=yes
    fi
fi

[ "$XPLATFORM_MINGW" = "yes" ] && QMakeVar add styles "windowsxp windowsvista"

case "$XPLATFORM" in *symbian*)
    QMakeVar set styles "windows s60"   #overwrite previous default
    CFG_LIBFREETYPE=no

    if [ "$CFG_LARGEFILE" = auto ]; then
        CFG_LARGEFILE=no
    fi

    if test -z "$EPOCROOT"; then
        echo "Please export EPOCROOT. It should point to the sdk install dir"
        exit 1
    fi
    if test ! -d "$EPOCROOT/epoc32"; then
        echo "Could not find the 'epoc32' dir in your EPOCROOT."
        exit 1
    fi

    if ! echo $XPLATFORM | grep symbian-sbsv2 > /dev/null; then
        # Raptor does not support configure tests.

        # the main commands needed to compile;
        (cd config.tests/symbian
            mkdir -p rcomp
            cd rcomp
            rm -f rcomp_test.rsg
            touch rcomp_test.rpp rcomp_test.rsc rcomp_test.rss
            rcomp -u -m045,046,047 -s./rcomp_test.rpp -o./rcomp_test.rsc -h./rcomp_test.rsg -i./rcomp_test.rss 2>&1 > /dev/null
            if test ! -f rcomp_test.rsg; then
                echo "Finding a working rcomp in your PATH failed."
                echo "Fatal error. Make sure you have the epoc tools working and in your PATH";
                exit 1;
            fi
        )

        # compile a simple main that uses printf
        if ! "$symbiantests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/symbian/simple "simple" $L_FLAGS $I_FLAGS $l_FLAGS
        then
            echo "Testing your compiler failed. Could not compile a simple application."
            echo "Fatal error; Rerun configure with -verbose to get more details."
            exit 1;
        fi
    fi
    ;;
esac

if [ "$CFG_LARGEFILE" = "auto" ]; then
    #Large files should be enabled for all Linux systems
    CFG_LARGEFILE=yes
fi


if [ "$CFG_S60" = "auto" ]; then
    if echo "$XPLATFORM" | grep symbian > /dev/null; then
        CFG_S60=yes
    else
        CFG_S60=no
    fi
fi

if [ "$CFG_QS60STYLE" = "auto" ]; then
    if echo "$XPLATFORM" | grep symbian > /dev/null; then
        CFG_QS60STYLE=qt
    else
        CFG_QS60STYLE=no
    fi
fi

if [ "$CFG_SYMBIAN_DEFFILES" = "auto" ]; then
    if echo "$XPLATFORM" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then
        CFG_SYMBIAN_DEFFILES=yes
    else
        CFG_SYMBIAN_DEFFILES=no
    fi
fi

# detect how jpeg should be built
if [ "$CFG_JPEG" = "auto" ]; then
    if [ "$CFG_SHARED" = "yes" ]; then
        CFG_JPEG=plugin
    else
        CFG_JPEG=yes
    fi
fi
# detect jpeg
if [ "$CFG_LIBJPEG" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
       CFG_LIBJPEG=system
    else
       CFG_LIBJPEG=qt
    fi
fi

# detect how gif should be built
if [ "$CFG_GIF" = "auto" ]; then
    if [ "$CFG_SHARED" = "yes" ]; then
        CFG_GIF=plugin
    else
        CFG_GIF=yes
    fi
fi

# detect how tiff should be built
if [ "$CFG_TIFF" = "auto" ]; then
    if [ "$CFG_SHARED" = "yes" ]; then
        CFG_TIFF=plugin
    else
        CFG_TIFF=yes
    fi
fi

# detect tiff
if [ "$CFG_LIBTIFF" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_LIBTIFF=system
    else
        CFG_LIBTIFF=qt
    fi
fi

# detect how mng should be built
if [ "$CFG_MNG" = "auto" ]; then
    if [ "$CFG_SHARED" = "yes" ]; then
        CFG_MNG=plugin
    else
        CFG_MNG=yes
    fi
fi
# detect mng
if [ "$CFG_LIBMNG" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
       CFG_LIBMNG=system
    else
       CFG_LIBMNG=qt
    fi
fi

# detect png
if [ "$CFG_LIBPNG" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
       CFG_LIBPNG=system
    else
       CFG_LIBPNG=qt
    fi
fi

# detect accessibility
if [ "$CFG_ACCESSIBILITY" = "auto" ]; then
    case "$XPLATFORM" in
    symbian*)
        # accessibility is currently unsupported
        CFG_ACCESSIBILITY=no
    ;;
    *)
        CFG_ACCESSIBILITY=yes
    esac
fi

# auto-detect SQL-modules support
for _SQLDR in $CFG_SQL_AVAILABLE; do
        case $_SQLDR in
        mysql)
            if [ "$CFG_SQL_mysql" != "no" ]; then
		[ -z "$CFG_MYSQL_CONFIG" ] && CFG_MYSQL_CONFIG=`"$WHICH" mysql_config`
                if [ -x "$CFG_MYSQL_CONFIG" ]; then
                    QT_CFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --include 2>/dev/null`
                    QT_LFLAGS_MYSQL_R=`$CFG_MYSQL_CONFIG --libs_r 2>/dev/null`
                    QT_LFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --libs 2>/dev/null`
		    QT_MYSQL_VERSION=`$CFG_MYSQL_CONFIG --version 2>/dev/null`
                    QT_MYSQL_VERSION_MAJOR=`echo $QT_MYSQL_VERSION | cut -d . -f 1`
                fi
                if [ -n "$QT_MYSQL_VERSION" ] && [ "$QT_MYSQL_VERSION_MAJOR" -lt 4 ]; then
                    if [ "$CFG_SQL_mysql" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "This version of MySql is not supported ($QT_MYSQL_VERSION)."
                        echo " You need MySql 4 or higher."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_mysql="no"
			QT_LFLAGS_MYSQL=""
			QT_LFLAGS_MYSQL_R=""
			QT_CFLAGS_MYSQL=""
                    fi
                else
                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                        QMakeVar add CONFIG use_libmysqlclient_r
                        if [ "$CFG_SQL_mysql" = "auto" ]; then
                            CFG_SQL_mysql=plugin
                        fi
                        QT_LFLAGS_MYSQL="$QT_LFLAGS_MYSQL_R"
                    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                        if [ "$CFG_SQL_mysql" = "auto" ]; then
                            CFG_SQL_mysql=plugin
                        fi
                    else
                        if [ "$CFG_SQL_mysql" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                            echo "MySQL support cannot be enabled due to functionality tests!"
                            echo " Turn on verbose messaging (-v) to $0 to see the final report."
                            echo " If you believe this message is in error you may use the continue"
                            echo " switch (-continue) to $0 to continue."
                            exit 101
                        else
                            CFG_SQL_mysql=no
			    QT_LFLAGS_MYSQL=""
			    QT_LFLAGS_MYSQL_R=""
			    QT_CFLAGS_MYSQL=""
                        fi
                    fi
                fi
            fi
            ;;
        psql)
            if [ "$CFG_SQL_psql" != "no" ]; then
                # Be careful not to use native pg_config when cross building.
                if [ "$XPLATFORM_MINGW" != "yes" ] && "$WHICH" pg_config >/dev/null 2>&1; then
                    QT_CFLAGS_PSQL=`pg_config --includedir 2>/dev/null`
                    QT_LFLAGS_PSQL=`pg_config --libdir 2>/dev/null`
                fi
                [ -z "$QT_CFLAGS_PSQL" ] || QT_CFLAGS_PSQL="-I$QT_CFLAGS_PSQL"
                [ -z "$QT_LFLAGS_PSQL" ] || QT_LFLAGS_PSQL="-L$QT_LFLAGS_PSQL"
                # But, respect PSQL_LIBS if set
                [ -z "$PSQL_LIBS" ] || QT_LFLAGS_PSQL="$PSQL_LIBS"
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_psql" = "auto" ]; then
                        CFG_SQL_psql=plugin
                    fi
                else
                    if [ "$CFG_SQL_psql" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "PostgreSQL support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_psql=no
                        QT_CFLAGS_PSQL=""
                        QT_LFLAGS_PSQL=""
                    fi
                fi
            fi
        ;;
        odbc)
            if [ "$CFG_SQL_odbc" != "no" ]; then
                if ( [ "$PLATFORM_MAC" != "yes" ] || [ "$XPLATFORM_MINGW" = "yes" ] ) && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_odbc" = "auto" ]; then
                        CFG_SQL_odbc=plugin
                    fi
                else
                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/iodbc "iODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                        QT_LFLAGS_ODBC="-liodbc"
                        if [ "$CFG_SQL_odbc" = "auto" ]; then
                            CFG_SQL_odbc=plugin
                        fi
                    else
                        if [ "$CFG_SQL_odbc" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                            echo "ODBC support cannot be enabled due to functionality tests!"
                            echo " Turn on verbose messaging (-v) to $0 to see the final report."
                            echo " If you believe this message is in error you may use the continue"
                            echo " switch (-continue) to $0 to continue."
                            exit 101
                        else
                            CFG_SQL_odbc=no
                        fi
                    fi
                fi
            fi
            ;;
        oci)
            if [ "$CFG_SQL_oci" != "no" ]; then
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_oci" = "auto" ]; then
                        CFG_SQL_oci=plugin
                    fi
                else
                    if [ "$CFG_SQL_oci" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "Oracle (OCI) support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_oci=no
                    fi
                fi
            fi
            ;;
        tds)
            if [ "$CFG_SQL_tds" != "no" ]; then
                [ -z "$SYBASE" ] || QT_LFLAGS_TDS="-L$SYBASE/lib"
                [ -z "$SYBASE_LIBS" ] || QT_LFLAGS_TDS="$QT_LFLAGS_TDS $SYBASE_LIBS"
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $QT_LFLAGS_TDS $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_tds" = "auto" ]; then
                        CFG_SQL_tds=plugin
                    fi
                else
                    if [ "$CFG_SQL_tds" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "TDS support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_tds=no
                    fi
                fi
            fi
            ;;
        db2)
            if [ "$CFG_SQL_db2" != "no" ]; then
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_db2" = "auto" ]; then
                        CFG_SQL_db2=plugin
                    fi
                else
                    if [ "$CFG_SQL_db2" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "ODBC support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_db2=no
                    fi
                fi
            fi
            ;;
        ibase)
            if [ "$CFG_SQL_ibase" != "no" ]; then
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_ibase" = "auto" ]; then
                        CFG_SQL_ibase=plugin
                    fi
                else
                    if [ "$CFG_SQL_ibase" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "InterBase support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_ibase=no
                    fi
                fi
            fi
            ;;
        sqlite2)
            if [ "$CFG_SQL_sqlite2" != "no" ]; then
                if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                    if [ "$CFG_SQL_sqlite2" = "auto" ]; then
                        CFG_SQL_sqlite2=plugin
                    fi
                else
                    if [ "$CFG_SQL_sqlite2" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                        echo "SQLite2 support cannot be enabled due to functionality tests!"
                        echo " Turn on verbose messaging (-v) to $0 to see the final report."
                        echo " If you believe this message is in error you may use the continue"
                        echo " switch (-continue) to $0 to continue."
                        exit 101
                    else
                        CFG_SQL_sqlite2=no
                    fi
                fi
            fi
            ;;
        sqlite)
            if [ "$CFG_SQL_sqlite" = "auto" ]; then # the default
                case "$XPLATFORM" in
                    symbian*)
                    # sqlite on symbian is typically not build in Qt but deployed as a pre-existing sis file and should be marked as driver.
                    # Configuration parameters should be set
                    CFG_SQL_sqlite=qt
                    QT_LFLAGS_SQLITE=-lsqlite3
                    QMAKE_CONFIG="$QMAKE_CONFIG system-sqlite"
                    ;;
                esac
            fi
            if [ "$CFG_SQL_sqlite" != "no" ]; then
                SQLITE_AUTODETECT_FAILED="no"
                if [ "$CFG_SQLITE" = "system" ]; then
                    if [ -n "$PKG_CONFIG" ]; then
                        QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null`
                        QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null`
                    fi
                    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
                        if [ "$CFG_SQL_sqlite" = "auto" ]; then
                            CFG_SQL_sqlite=plugin
                        fi
                        QMAKE_CONFIG="$QMAKE_CONFIG system-sqlite"
                    else
                        SQLITE_AUTODETECT_FAILED="yes"
                        CFG_SQL_sqlite=no
                    fi
                elif [ -f "$relpath/src/3rdparty/sqlite/sqlite3.h" ]; then
                    if [ "$CFG_SQL_sqlite" = "auto" ]; then
                            CFG_SQL_sqlite=plugin
                    fi
                else
                    SQLITE_AUTODETECT_FAILED="yes"
                    CFG_SQL_sqlite=no
                fi

                if [ "$SQLITE_AUTODETECT_FAILED" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                    echo "SQLite support cannot be enabled due to functionality tests!"
                    echo " Turn on verbose messaging (-v) to $0 to see the final report."
                    echo " If you believe this message is in error you may use the continue"
                    echo " switch (-continue) to $0 to continue."
                    exit 101
                fi
            fi
            ;;
        *)
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo "unknown SQL driver: $_SQLDR"
            fi
            ;;
        esac
done

# auto-detect NIS support
if [ "$CFG_NIS" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_NIS=yes
    else
        if [ "$CFG_NIS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "NIS support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_NIS=no
        fi
    fi
fi

# auto-detect CUPS support
if [ "$CFG_CUPS" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_CUPS=yes
    else
        if [ "$CFG_CUPS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "Cups support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_CUPS=no
        fi
    fi
fi

# auto-detect iconv(3) support
if [ "$CFG_ICONV" != "no" ]; then
    if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
	CFG_ICONV=no
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_ICONV=yes
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/sun-libiconv" "SUN libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_ICONV=sun
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_ICONV=gnu
    else
        if [ "$CFG_ICONV" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "Iconv support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_ICONV=no
        fi
    fi
fi

# auto-detect libdbus-1 support
if [ "$CFG_DBUS" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --atleast-version="$MIN_DBUS_1_VERSION" dbus-1 2>/dev/null; then
        QT_CFLAGS_DBUS=`$PKG_CONFIG --cflags dbus-1 2>/dev/null`
        QT_LIBS_DBUS=`$PKG_CONFIG --libs dbus-1 2>/dev/null`
    fi
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS $MAC_CONFIG_TEST_COMMANDLINE; then
        [ "$CFG_DBUS" = "auto" ] && CFG_DBUS=yes
        QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS"
        QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS"
    else
        if [ "$CFG_DBUS" = "auto" ]; then
            CFG_DBUS=no
        elif [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            # CFG_DBUS is "yes" or "linked" here

            echo "The QtDBus module cannot be enabled because libdbus-1 version $MIN_DBUS_1_VERSION was not found."
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        fi
    fi
fi

if [ "$CFG_MULTIMEDIA" = "auto" ]; then
    CFG_MULTIMEDIA="$CFG_GUI"
fi

if [ "$CFG_MULTIMEDIA" = "yes" ] && [ "$CFG_GUI" = "no" ]; then
    echo "QtMultimedia requested, but it can't be built without QtGui"
    exit 1
fi

# Generate a CRC of the namespace for using in constants for the Carbon port.
# This should mean that you really *can* load two Qt's and have our custom
# Carbon events work.
if [ "$PLATFORM_MAC" = "yes" -a ! -z "$QT_NAMESPACE" ]; then
    QT_NAMESPACE_MAC_CRC=`"$mactests/crc.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/crc $QT_NAMESPACE $L_FLAGS $I_FLAGS $l_FLAGS`
fi

# X11/QWS/Lighthouse
if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then

    # auto-detect Glib support
    if [ "$CFG_GLIB" != "no" ]; then
        if [ -n "$PKG_CONFIG" ]; then
            QT_CFLAGS_GLIB=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0 2>/dev/null`
            QT_LIBS_GLIB=`$PKG_CONFIG --libs glib-2.0 gthread-2.0 2>/dev/null`
        fi
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/glib "Glib" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GLIB $QT_LIBS_GLIB $X11TESTS_FLAGS ; then
            CFG_GLIB=yes
            QMakeVar set QT_CFLAGS_GLIB "$QT_CFLAGS_GLIB"
            QMakeVar set QT_LIBS_GLIB "$QT_LIBS_GLIB"
        else
            if [ "$CFG_GLIB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                echo "Glib support cannot be enabled due to functionality tests!"
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            else
                CFG_GLIB=no
            fi
        fi
    fi

    if [ "$CFG_GUI" = "no" ]; then
        if [ "$CFG_PHONON" = "auto" ]; then
            CFG_PHONON=no
        fi
        if [ "$CFG_PHONON" != "no" ]; then
            echo "Phonon enabled, but GUI disabled."
            echo " You might need to either enable the GUI or disable Phonon"
            exit 1
        fi
    fi

    # Auto-detect GStreamer support (needed for Phonon)
    if [ "$CFG_PHONON" != "no" ]; then
        if [ "$CFG_GLIB" = "yes" -a "$CFG_GSTREAMER" != "no" ]; then
            if [ -n "$PKG_CONFIG" ]; then
                QT_CFLAGS_GSTREAMER=`$PKG_CONFIG --cflags gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null`
                QT_LIBS_GSTREAMER=`$PKG_CONFIG --libs gstreamer-0.10 gstreamer-plugins-base-0.10 2>/dev/null`
            fi
            if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/gstreamer "GStreamer" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GSTREAMER $QT_LIBS_GSTREAMER $X11TESTS_FLAGS; then
                CFG_GSTREAMER=yes
                QMakeVar set QT_CFLAGS_GSTREAMER "$QT_CFLAGS_GSTREAMER"
                QMakeVar set QT_LIBS_GSTREAMER "$QT_LIBS_GSTREAMER"
            else
                if [ "$CFG_GSTREAMER" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                    echo "Gstreamer support cannot be enabled due to functionality tests!"
                    echo " Turn on verbose messaging (-v) to $0 to see the final report."
                    echo " If you believe this message is in error you may use the continue"
                    echo " switch (-continue) to $0 to continue."
                    exit 101
                else
                    CFG_GSTREAMER=no
                fi
            fi
        elif [ "$CFG_GLIB" = "no" ]; then
            CFG_GSTREAMER=no
        fi
    else
        CFG_GSTREAMER=no
    fi

    if [ "$CFG_PHONON" != "no" ]; then
        if [ "$CFG_PHONON_BACKEND" != "no" ]; then
            if [ "$CFG_GSTREAMER" = "yes" ]; then
                CFG_PHONON=yes
            else
                if [ "$CFG_PHONON" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                    echo "Phonon support cannot be enabled due to functionality tests!"
                    echo " Turn on verbose messaging (-v) to $0 to see the final report."
                    echo " If you believe this message is in error you may use the continue"
                    echo " switch (-continue) to $0 to continue."
                    exit 101
                else
                    CFG_PHONON=no
                fi
            fi
        else
            CFG_PHONON=yes
        fi
    fi

    # auto-detect icd support
    if [ "$CFG_GLIB" = "yes" -a "$CFG_ICD" != "no" ]; then
        if [ -n "$PKG_CONFIG" ]; then
            QT_CFLAGS_CONNSETTINGS=`$PKG_CONFIG --cflags connsettings 2>/dev/null`
            QT_LIBS_CONNSETTINGS=`$PKG_CONFIG --libs connsettings 2>/dev/null`
        fi
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/icd "ICD" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_CONNSETTINGS $QT_LIBS_CONNSETTINGS; then
            [ "$CFG_ICD" = "auto" ] && CFG_ICD=yes
            QMakeVar set QT_CFLAGS_CONNSETTINGS "$QT_CFLAGS_CONNSETTINGS"
            QMakeVar set QT_LIBS_CONNSETTINGS "$QT_LIBS_CONNSETTINGS"
        else
            if [ "$CFG_ICD" = "auto" ]; then
                CFG_ICD=no
            elif [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                # CFG_ICD is "yes"

                echo "The ICD Bearer Management plugin cannot be enabled because connsettings was not found."
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            fi
        fi
    elif [ "$CFG_GLIB" = "no" ]; then
        CFG_ICD=no
    fi

    # Auto-detect PulseAudio support
    if [ "$CFG_PULSEAUDIO" != "no" ]; then
        if [ -n "$PKG_CONFIG" ]; then
            QT_CFLAGS_PULSEAUDIO=`$PKG_CONFIG --cflags libpulse '>=' 0.9.10 libpulse-mainloop-glib 2>/dev/null`
            QT_LIBS_PULSEAUDIO=`$PKG_CONFIG --libs libpulse '>=' 0.9.10 libpulse-mainloop-glib 2>/dev/null`
        fi
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/pulseaudio "PulseAudio" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_PULSEAUDIO $QT_LIBS_PULSEAUDIO $X11TESTS_FLAGS; then
            CFG_PULSEAUDIO=yes
            QMakeVar set QT_CFLAGS_PULSEAUDIO "$QT_CFLAGS_PULSEAUDIO"
            QMakeVar set QT_LIBS_PULSEAUDIO "$QT_LIBS_PULSEAUDIO"
        else
            if [ "$CFG_PULSEAUDIO" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                echo "PulseAudio support cannot be enabled due to functionality tests!"
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            else
		CFG_PULSEAUDIO=no
            fi
        fi
    fi
fi # X11/QWS/Lighthouse

# X11
if [ "$PLATFORM_X11" = "yes" ]; then
    x11tests="$relpath/config.tests/x11"
    X11TESTS_FLAGS=

    # work around broken X11 headers when using GCC 2.95 or later
    NOTYPE=no
    "$x11tests/notype.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" && NOTYPE=yes
    if [ $NOTYPE = "yes" ]; then
	QMakeVar add QMAKE_CXXFLAGS -fpermissive
        X11TESTS_FLAGS="$X11TESTS_FLAGS -fpermissive"
    fi

    # Check we actually have X11 :-)
    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xlib "XLib" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS
    if [ $? != "0" ]; then
        echo "Basic XLib functionality test failed!"
        echo " You might need to modify the include and library search paths by editing"
        echo " QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in ${XQMAKESPEC}."
        exit 1
    fi
fi

# X11/MINGW OpenGL
if [ "$PLATFORM_X11" = "yes" -o "$XPLATFORM_MINGW" = "yes" ]; then
    # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x)
    if [ "$CFG_GUI" = "no" ]; then
        if [ "$CFG_OPENGL" = "auto" ]; then
            CFG_OPENGL=no
        fi
        if [ "$CFG_OPENGL" != "no" ]; then
            echo "OpenGL enabled, but GUI disabled."
            echo " You might need to either enable the GUI or disable OpenGL"
            exit 1
        fi
    fi
    if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
            CFG_OPENGL=desktop
        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es2
            if [ "$CFG_EGL" = "no" ]; then
                CFG_EGL=auto
            fi
        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es1
            if [ "$CFG_EGL" = "no" ]; then
                CFG_EGL=auto
            fi
        else
            if [ "$CFG_OPENGL" = "yes" ]; then
                echo "All the OpenGL functionality tests failed!"
                echo " You might need to modify the include and library search paths by editing"
                echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
                echo " ${XQMAKESPEC}."
                exit 1
            fi
            CFG_OPENGL=no
        fi
        case "$PLATFORM" in
        hpux*)
            # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct.
            if [ "$CFG_OPENGL" = "desktop" ]; then
                "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS
                if [ $? != "0" ]; then
                    QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
                fi
            fi
            ;;
        *)
            ;;
        esac
    elif [ "$CFG_OPENGL" = "es1" ]; then
        # OpenGL ES 1.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 1.x functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL_ES1, QMAKE_LIBDIR_OPENGL_ES1 and QMAKE_LIBS_OPENGL_ES1 in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    elif [ "$CFG_OPENGL" = "es2" ]; then
        #OpenGL ES 2.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 2.0 functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    elif [ "$CFG_OPENGL" = "desktop" ]; then
        # Desktop OpenGL support
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
        case "$PLATFORM" in
        hpux*)
            # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct.
            "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS
            if [ $? != "0" ]; then
                QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
            fi
            ;;
        *)
            ;;
        esac
    fi

    # if opengl is disabled and the user specified graphicssystem gl, disable it...
    if [ "$CFG_GRAPHICS_SYSTEM" = "opengl" ] && [ "$CFG_OPENGL" = "no" ]; then
	echo "OpenGL Graphics System is disabled due to missing OpenGL support..."
	CFG_GRAPHICS_SYSTEM=default
    fi
fi # X11/MINGW OpenGL

# X11
if [ "$PLATFORM_X11" = "yes" ]; then
    # auto-detect Xcursor support
    if [ "$CFG_XCURSOR" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xcursor "Xcursor" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    if [ "$CFG_XCURSOR" != "runtime" ]; then
		CFG_XCURSOR=yes;
	    fi
	else
	    if [ "$CFG_XCURSOR" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Xcursor support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XCURSOR=no
	    fi
	fi
    fi

    # auto-detect Xfixes support
    if [ "$CFG_XFIXES" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xfixes "Xfixes" $L_FLAGS $I_FLAGS $X11TESTS_FLAGS; then
	    if [ "$CFG_XFIXES" != "runtime" ]; then
		CFG_XFIXES=yes;
	    fi
	else
	    if [ "$CFG_XFIXES" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Xfixes support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XFIXES=no
	    fi
	fi
    fi

    # auto-detect Xrandr support (resize and rotate extension)
    if [ "$CFG_XRANDR" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xrandr "Xrandr" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
            if [ "$CFG_XRANDR" != "runtime" ]; then
	    CFG_XRANDR=yes
            fi
	else
	    if [ "$CFG_XRANDR" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Xrandr support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XRANDR=no
	    fi
	fi
    fi

    # auto-detect Xrender support
    if [ "$CFG_XRENDER" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xrender "Xrender" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_XRENDER=yes
	else
	    if [ "$CFG_XRENDER" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Xrender support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XRENDER=no
	    fi
	fi
    fi

    # auto-detect MIT-SHM support
    if [ "$CFG_MITSHM" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/mitshm "mitshm" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_MITSHM=yes
	else
	    if [ "$CFG_MITSHM" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "MITSHM support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_MITSHM=no
	    fi
	fi
    fi

    # auto-detect FontConfig support
    if [ "$CFG_FONTCONFIG" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists fontconfig --exists freetype2 2>/dev/null; then
        QT_CFLAGS_FONTCONFIG=`$PKG_CONFIG --cflags fontconfig --cflags freetype2 2>/dev/null`
        QT_LIBS_FONTCONFIG=`$PKG_CONFIG --libs fontconfig --libs freetype2 2>/dev/null`
    else
        QT_CFLAGS_FONTCONFIG=
        QT_LIBS_FONTCONFIG="-lfreetype -lfontconfig"
    fi
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/fontconfig "FontConfig" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS $QT_CFLAGS_FONTCONFIG $QT_LIBS_FONTCONFIG; then
	    CFG_FONTCONFIG=yes
        QMakeVar set QMAKE_CFLAGS_X11 "$QT_CFLAGS_FONTCONFIG \$\$QMAKE_CFLAGS_X11"
        QMakeVar set QMAKE_LIBS_X11 "$QT_LIBS_FONTCONFIG \$\$QMAKE_LIBS_X11"
	    CFG_LIBFREETYPE=system
	else
	    if [ "$CFG_FONTCONFIG" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "FontConfig support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_FONTCONFIG=no
	    fi
	fi
    fi

    # auto-detect Session Management support
    if [ "$CFG_SM" = "auto" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/sm "Session Management" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_SM=yes
	else
	    if [ "$CFG_SM" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Session Management support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_SM=no
	    fi
	fi
    fi

    # auto-detect SHAPE support
    if [ "$CFG_XSHAPE" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xshape "XShape" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_XSHAPE=yes
	else
	    if [ "$CFG_XSHAPE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "XShape support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XSHAPE=no
	    fi
	fi
    fi

    # auto-detect XVideo support
    if [ "$CFG_XVIDEO" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xvideo "XVideo" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_XVIDEO=yes
	else
	    if [ "$CFG_XVIDEO" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "XVideo support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XVIDEO=no
	    fi
	fi
    fi

    # auto-detect XSync support
    if [ "$CFG_XSYNC" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xsync "XSync" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    CFG_XSYNC=yes
	else
	    if [ "$CFG_XSYNC" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "XSync support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XSYNC=no
	    fi
	fi
    fi

    # auto-detect Xinerama support
    if [ "$CFG_XINERAMA" != "no" ]; then
	if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xinerama "Xinerama" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    if [ "$CFG_XINERAMA" != "runtime" ]; then
		CFG_XINERAMA=yes
	    fi
	else
	    if [ "$CFG_XINERAMA" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
		echo "Xinerama support cannot be enabled due to functionality tests!"
		echo " Turn on verbose messaging (-v) to $0 to see the final report."
		echo " If you believe this message is in error you may use the continue"
		echo " switch (-continue) to $0 to continue."
		exit 101
	    else
		CFG_XINERAMA=no
	    fi
	fi
    fi

    # auto-detect Xinput support
    if [ "$CFG_XINPUT" != "no" ]; then
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xinput "XInput" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
	    if [ "$CFG_XINPUT" != "runtime" ]; then
		CFG_XINPUT=yes
	    fi
        else
            if [ "$CFG_XINPUT" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                echo "Tablet and Xinput support cannot be enabled due to functionality tests!"
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            else
                CFG_XINPUT=no
            fi
        fi
    fi

    # auto-detect XKB support
    if [ "$CFG_XKB" != "no" ]; then
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/xkb "XKB" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
            CFG_XKB=yes
        else
            if [ "$CFG_XKB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                echo "XKB support cannot be enabled due to functionality tests!"
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            else
                CFG_XKB=no
            fi
        fi
    fi

    if [ "$CFG_GLIB" = "yes" -a "$CFG_QGTKSTYLE" != "no" ]; then
        if [ -n "$PKG_CONFIG" ]; then
            QT_CFLAGS_QGTKSTYLE=`$PKG_CONFIG --cflags gtk+-2.0 ">=" 2.10 atk 2>/dev/null`
            QT_LIBS_QGTKSTYLE=`$PKG_CONFIG --libs gobject-2.0 2>/dev/null`
        fi
        if [ -n "$QT_CFLAGS_QGTKSTYLE" ] ; then
            CFG_QGTKSTYLE=yes
            QMakeVar set QT_CFLAGS_QGTKSTYLE "$QT_CFLAGS_QGTKSTYLE"
            QMakeVar set QT_LIBS_QGTKSTYLE "$QT_LIBS_QGTKSTYLE"
        else
            if [ "$CFG_QGTKSTYLE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
                echo "Gtk theme support cannot be enabled due to functionality tests!"
                echo " Turn on verbose messaging (-v) to $0 to see the final report."
                echo " If you believe this message is in error you may use the continue"
                echo " switch (-continue) to $0 to continue."
                exit 101
            else
                CFG_QGTKSTYLE=no
            fi
        fi
    elif [ "$CFG_GLIB" = "no" ]; then
        CFG_QGTKSTYLE=no
    fi
fi # X11


if [ "$PLATFORM_MAC" = "yes" ]; then
    if [ "$CFG_PHONON" != "no" ]; then
        # Always enable Phonon (unless it was explicitly disabled)
        CFG_PHONON=yes
    fi

    if [ "$CFG_COREWLAN" = "auto" ]; then
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/corewlan "CoreWlan" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
            CFG_COREWLAN=yes
        else
            CFG_COREWLAN=no
        fi
    fi
fi


if [ "$PLATFORM_QPA" = "yes" ]; then
    # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x)
    if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS; then
            CFG_OPENGL=desktop
        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es2
        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es1
        else
            if [ "$CFG_OPENGL" = "yes" ]; then
                echo "All the OpenGL functionality tests failed!"
                echo " You might need to modify the include and library search paths by editing"
                echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
                echo " ${XQMAKESPEC}."
                exit 1
            fi
            CFG_OPENGL=no
        fi
    elif [ "$CFG_OPENGL" = "es1" ]; then
        # OpenGL ES 1.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 1.x functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL_ES1, QMAKE_LIBDIR_OPENGL_ES1 and QMAKE_LIBS_OPENGL_ES1 in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    elif [ "$CFG_OPENGL" = "es2" ]; then
        #OpenGL ES 2.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 2.0 functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    elif [ "$CFG_OPENGL" = "desktop" ]; then
        # Desktop OpenGL support
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengldesktop "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    fi
fi


# QWS
if [ "$PLATFORM_QWS" = "yes" ]; then

    # auto-detect OpenGL support (es1 = OpenGL ES 1.x Common, es2 = OpenGL ES 2.x)
    if [ "$CFG_GUI" = "no" ]; then
        if [ "$CFG_OPENGL" = "auto" ]; then
            CFG_OPENGL=no
        fi
        if [ "$CFG_OPENGL" != "no" ]; then
            echo "OpenGL enabled, but GUI disabled."
            echo " You might need to either enable the GUI or disable OpenGL"
            exit 1
        fi
    fi
    if [ "$CFG_OPENGL" = "yes" ]; then
        CFG_EGL=auto
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es2
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then
            CFG_OPENGL=es1
        else
            echo "All the OpenGL ES functionality tests failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
    elif [ "$CFG_OPENGL" = "es1" ]; then
        # OpenGL ES 1.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 1.x functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
        CFG_EGL=yes
    elif [ "$CFG_OPENGL" = "es2" ]; then
        #OpenGL ES 2.x
        "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
            echo "The OpenGL ES 2.0 functionality test failed!"
            echo " You might need to modify the include and library search paths by editing"
            echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in"
            echo " ${XQMAKESPEC}."
            exit 1
        fi
        CFG_EGL=yes
    elif [ "$CFG_OPENGL" = "desktop" ]; then
        # Desktop OpenGL support
        echo "Desktop OpenGL support is not avaliable on Qt for Embedded Linux"
        exit 1
    fi
fi

if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then

    # screen drivers
    for screen in ${CFG_GFX_ON} ${CFG_GFX_PLUGIN}; do
       if [ "${screen}" = "ahi" ] && [ "${CFG_CONFIGURE_EXIT_ON_ERROR}" = "yes" ]; then
           "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qws/ahi "Ahi" $L_FLAGS $I_FLAGS $l_FLAGS
           if [ $? != "0" ]; then
               echo "The Ahi screen driver functionality test failed!"
               echo " You might need to modify the include and library search paths by editing"
               echo " QMAKE_INCDIR and QMAKE_LIBDIR in"
               echo " ${XQMAKESPEC}."
               exit 1
           fi
       fi

       if [ "${screen}" = "svgalib" ] && [ "${CFG_CONFIGURE_EXIT_ON_ERROR}" = "yes" ]; then
           "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qws/svgalib "SVGAlib" $L_FLAGS $I_FLAGS $l_FLAGS
           if [ $? != "0" ]; then
               echo "The SVGAlib screen driver functionality test failed!"
               echo " You might need to modify the include and library search paths by editing"
               echo " QMAKE_INCDIR and QMAKE_LIBDIR in"
               echo " ${XQMAKESPEC}."
               exit 1
           fi
       fi

       if [ "${screen}" = "directfb" ] && [ "${CFG_CONFIGURE_EXIT_ON_ERROR}" = "yes" ]; then
           if test -n "$PKG_CONFIG" && "$PKG_CONFIG" --exists directfb 2>/dev/null; then
               QT_CFLAGS_DIRECTFB=`$PKG_CONFIG --cflags directfb 2>/dev/null`
               QT_LIBS_DIRECTFB=`$PKG_CONFIG --libs directfb 2>/dev/null`
           elif directfb-config --version >/dev/null 2>&1; then
               QT_CFLAGS_DIRECTFB=`directfb-config --cflags 2>/dev/null`
               QT_LIBS_DIRECTFB=`directfb-config --libs 2>/dev/null`
           fi

           # QMake variables set here override those in the mkspec. Therefore we only set the variables here if they are not zero.
           if [ -n "$QT_CFLAGS_DIRECTFB" ] || [ -n "$QT_LIBS_DIRECTFB" ]; then
               QMakeVar set QT_CFLAGS_DIRECTFB "$QT_CFLAGS_DIRECTFB"
               QMakeVar set QT_LIBS_DIRECTFB "$QT_LIBS_DIRECTFB"
           fi
           if [ "$CFG_QT3SUPPORT" = "yes" ]; then
               QMakeVar set QT_DEFINES_DIRECTFB "QT3_SUPPORT"
           fi

           "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qws/directfb "DirectFB" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DIRECTFB $QT_LIBS_DIRECTFB
           if [ $? != "0" ]; then
               echo "The DirectFB screen driver functionality test failed!"
               echo " You might need to modify the include and library search paths by editing"
               echo " QT_CFLAGS_DIRECTFB and QT_LIBS_DIRECTFB in"
               echo " ${XQMAKESPEC}."
               exit 1
           fi
       fi

    done

    # mouse drivers
    for mouse in ${CFG_MOUSE_ON} ${CFG_MOUSE_PLUGIN}; do
	if [ "${mouse}" = "tslib" ] && [ "${CFG_CONFIGURE_EXIT_ON_ERROR}" = "yes" ]; then
	    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tslib "tslib" $L_FLAGS $I_FLAGS $l_FLAGS
            if [ $? != "0" ]; then
               echo "The tslib functionality test failed!"
               echo " You might need to modify the include and library search paths by editing"
               echo " QMAKE_INCDIR and QMAKE_LIBDIR in"
               echo " ${XQMAKESPEC}."
		exit 1
	    fi
	fi
    done

    CFG_QGTKSTYLE=no

    # sound
    "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qws/sound "sound" $L_FLAGS $I_FLAGS $l_FLAGS
    if [ $? != "0" ]; then
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SOUND"
    fi

fi # QWS

# EGL Support
if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then
    if [ "$CFG_EGL" != "no" ]; then
        # detect EGL support
        if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl" "EGL (EGL/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then
            # EGL specified by QMAKE_*_EGL, included with <EGL/egl.h>
            CFG_EGL=yes
            CFG_EGL_GLES_INCLUDES=no
        elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl4gles1" "EGL (GLES/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then
            # EGL specified by QMAKE_*_EGL, included with <GLES/egl.h>
            CFG_EGL=yes
            CFG_EGL_GLES_INCLUDES=yes
        else
            if [ "$CFG_EGL" = "yes" ]; then
                echo "The EGL functionality test failed!"
                echo " EGL is required for OpenGL ES to manage contexts & surfaces."
                echo " You might need to modify the include and library search paths by editing"
                echo " QMAKE_INCDIR_EGL, QMAKE_LIBDIR_EGL and QMAKE_LIBS_EGL in"
                echo " ${XQMAKESPEC}."
                exit 1
            fi
            CFG_EGL=no
            # If QtOpenGL would be built against OpenGL ES, disable it as we can't to that if EGL is missing
            if [ "$CFG_OPENGL" = "es1" -o "$CFG_OPENGL" = "es2" ]; then
                CFG_OPENGL=no
            fi
        fi
    fi
fi

[ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_PHONON" != "no" ] && CFG_PHONON="yes"

# freetype support
[ "x$CFG_EMBEDDED" != "xno" ] && CFG_LIBFREETYPE="$CFG_QWS_FREETYPE"
[ "x$PLATFORM_MAC" = "xyes" ] && CFG_LIBFREETYPE=no
[ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_LIBFREETYPE" = "auto" ] && CFG_LIBFREETYPE=no
if [ "$CFG_LIBFREETYPE" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_LIBFREETYPE=system
    else
        CFG_LIBFREETYPE=yes
    fi
fi

if [ "$CFG_ENDIAN" = "auto" ]; then
    if [ "$XPLATFORM_MINGW" = "yes" ]; then
        CFG_ENDIAN="Q_LITTLE_ENDIAN"
    elif [ "$PLATFORM_MAC" = "yes" ]; then
	true #leave as auto
    elif [ "$XPLATFORM" = "symbian-sbsv2" ]; then
        CFG_ENDIAN="Q_LITTLE_ENDIAN"
    else
        "$unixtests/endian.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
	F="$?"
        if [ "$F" -eq 0 ]; then
            CFG_ENDIAN="Q_LITTLE_ENDIAN"
        elif [ "$F" -eq 1 ]; then
            CFG_ENDIAN="Q_BIG_ENDIAN"
        else
            echo
	    echo "The target system byte order could not be detected!"
	    echo "Turn on verbose messaging (-v) to see the final report."
	    echo "You can use the -little-endian or -big-endian switch to"
	    echo "$0 to continue."
            exit 101
        fi
    fi
fi

if [ "$CFG_HOST_ENDIAN" = "auto" ]; then
    if [ "$PLATFORM_MAC" = "yes" ]; then
	true #leave as auto
    else
        "$unixtests/endian.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
	F="$?"
        if [ "$F" -eq 0 ]; then
            CFG_HOST_ENDIAN="Q_LITTLE_ENDIAN"
        elif [ "$F" -eq 1 ]; then
            CFG_HOST_ENDIAN="Q_BIG_ENDIAN"
        else
            echo
	    echo "The host system byte order could not be detected!"
	    echo "Turn on verbose messaging (-v) to see the final report."
	    echo "You can use the -host-little-endian or -host-big-endian switch to"
	    echo "$0 to continue."
            exit 101
        fi
    fi
fi

if [ "$CFG_ARMFPA" != "auto" ]; then
    if [ "$CFG_ARMFPA" = "yes" ]; then
        if [ "$CFG_ENDIAN" = "Q_LITTLE_ENDIAN" ]; then
            CFG_DOUBLEFORMAT="Q_DOUBLE_LITTLE_SWAPPED"
        else
            CFG_DOUBLEFORMAT="Q_DOUBLE_BIG_SWAPPED"
        fi
    else
        CFG_DOUBLEFORMAT="normal"
    fi
fi


if [ "$CFG_DOUBLEFORMAT" = "auto" ]; then
    if [ "$PLATFORM_QWS" != "yes" -o "$PLATFORM_QPA" = "yes" ]; then
        CFG_DOUBLEFORMAT=normal
    else
        "$unixtests/doubleformat.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
	F="$?"
        if [ "$F" -eq 10 ] && [ "$CFG_ENDIAN" = "Q_LITTLE_ENDIAN" ]; then
            CFG_DOUBLEFORMAT=normal
        elif [ "$F" -eq 11 ] && [ "$CFG_ENDIAN" = "Q_BIG_ENDIAN" ]; then
            CFG_DOUBLEFORMAT=normal
        elif [ "$F" -eq 10 ]; then
            CFG_DOUBLEFORMAT="Q_DOUBLE_LITTLE"
        elif [ "$F" -eq 11 ]; then
            CFG_DOUBLEFORMAT="Q_DOUBLE_BIG"
        elif [ "$F" -eq 12 ]; then
            CFG_DOUBLEFORMAT="Q_DOUBLE_LITTLE_SWAPPED"
            CFG_ARMFPA="yes"
        elif [ "$F" -eq 13 ]; then
            CFG_DOUBLEFORMAT="Q_DOUBLE_BIG_SWAPPED"
            CFG_ARMFPA="yes"
        else
            echo
	    echo "The system floating point format could not be detected."
	    echo "This may cause data to be generated in a wrong format"
	    echo "Turn on verbose messaging (-v) to see the final report."
	    # we do not fail on this since this is a new test, and if it fails,
	    # the old behavior should be correct in most cases
            CFG_DOUBLEFORMAT=normal
        fi
    fi
fi

HAVE_STL=no
if echo "$XPLATFORM" | grep symbian > /dev/null || "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
    HAVE_STL=yes
fi

if [ "$CFG_STL" != "no" ]; then
    if [ "$HAVE_STL" = "yes" ]; then
        CFG_STL=yes
    else
        if [ "$CFG_STL" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "STL support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_STL=no
        fi
    fi
fi

# find if the platform supports IPv6
if [ "$CFG_IPV6" != "no" ]; then
    if [ "$XPLATFORM" = "symbian-sbsv2" ]; then
        #IPV6 should always be enabled for Symbian release
        CFG_IPV6=yes
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        CFG_IPV6=yes
    else
        if [ "$CFG_IPV6" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "IPv6 support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_IPV6=no
        fi
    fi
fi

# detect POSIX clock_gettime()
if [ "$CFG_CLOCK_GETTIME" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/clock-gettime "POSIX clock_gettime()" $L_FLAGS $I_FLAGS $l_FLAGS; then
	CFG_CLOCK_GETTIME=yes
    else
	CFG_CLOCK_GETTIME=no
    fi
fi

# detect POSIX monotonic clocks
if [ "$CFG_CLOCK_GETTIME" = "yes" ] && [ "$CFG_CLOCK_MONOTONIC" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/clock-monotonic "POSIX Monotonic Clock" $L_FLAGS $I_FLAGS $l_FLAGS; then
	CFG_CLOCK_MONOTONIC=yes
    else
	CFG_CLOCK_MONOTONIC=no
    fi
elif [ "$CFG_CLOCK_GETTIME" = "no" ]; then
    CFG_CLOCK_MONOTONIC=no
fi

# detect mremap
if [ "$CFG_MREMAP" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mremap "mremap" $L_FLAGS $I_FLAGS $l_FLAGS; then
	CFG_MREMAP=yes
    else
	CFG_MREMAP=no
    fi
fi

# find if the platform provides getaddrinfo (ipv6 dns lookups)
if [ "$CFG_GETADDRINFO" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/getaddrinfo "getaddrinfo" $L_FLAGS $I_FLAGS $l_FLAGS; then
        CFG_GETADDRINFO=yes
    else
	if [ "$CFG_GETADDRINFO" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "getaddrinfo support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
	else
	    CFG_GETADDRINFO=no
	fi
    fi
fi

# find if the platform provides inotify
if [ "$CFG_INOTIFY" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/inotify "inotify" $L_FLAGS $I_FLAGS $l_FLAGS; then
        CFG_INOTIFY=yes
    else
	if [ "$CFG_INOTIFY" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "inotify support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
	else
	    CFG_INOTIFY=no
	fi
    fi
fi

# find if the platform provides if_nametoindex (ipv6 interface name support)
if [ "$CFG_IPV6IFNAME" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6ifname "IPv6 interface name" $L_FLAGS $I_FLAGS $l_FLAGS; then
        CFG_IPV6IFNAME=yes
    else
        if [ "$CFG_IPV6IFNAME" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "IPv6 interface name support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
	    CFG_IPV6IFNAME=no
	fi
    fi
fi

# find if the platform provides getifaddrs (network interface enumeration)
if [ "$CFG_GETIFADDRS" != "no" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/getifaddrs "getifaddrs" $L_FLAGS $I_FLAGS $l_FLAGS; then
        CFG_GETIFADDRS=yes
    else
        if [ "$CFG_GETIFADDRS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "getifaddrs support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
	    CFG_GETIFADDRS=no
	fi
    fi
fi

# detect OpenSSL
if [ "$CFG_OPENSSL" != "no" ] && [ "$XPLATFORM" != "symbian-sbsv2" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
        if [ "$CFG_OPENSSL" = "auto" ]; then
            CFG_OPENSSL=yes
        fi
    else
        if ( [ "$CFG_OPENSSL" = "yes" ] || [ "$CFG_OPENSSL" = "linked" ] ) && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "OpenSSL support cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_OPENSSL=no
        fi
    fi
else
    if [ "$CFG_OPENSSL" = "auto" ] && [ "$XPLATFORM" = "symbian-sbsv2" ]; then
        #OpenSSl should be enabled for Symbian release
        CFG_OPENSSL=yes
    fi
fi

# detect OpenVG support
if [ "$CFG_OPENVG" != "no" ] && [ "$XPLATFORM" != "symbian-sbsv2" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG openvg_on_opengl" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
        CFG_OPENVG_ON_OPENGL=yes
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG lower_case_includes" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG (lc includes)" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
        CFG_OPENVG_LC_INCLUDES=yes
    elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG openvg_on_opengl lower_case_includes" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG (lc includes)" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
        CFG_OPENVG_LC_INCLUDES=yes
        CFG_OPENVG_ON_OPENGL=yes
    else
        if [ "$CFG_OPENVG" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "$CFG_OPENVG was specified for OpenVG but cannot be enabled due to functionality tests!"
            echo " Turn on verbose messaging (-v) to $0 to see the final report."
            echo " If you believe this message is in error you may use the continue"
            echo " switch (-continue) to $0 to continue."
            exit 101
        else
            CFG_OPENVG=no
        fi
    fi
    if [ "$CFG_OPENVG" = "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/shivavg" "ShivaVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then
        CFG_OPENVG_SHIVA=yes
    fi
fi

# if openvg is disabled and the user specified graphicssystem vg, disable it...
if [ "$CFG_GRAPHICS_SYSTEM" = "openvg" ] && [ "$CFG_OPENVG" = "no" ]; then
    echo "OpenVG Graphics System is disabled due to missing OpenVG support..."
    CFG_GRAPHICS_SYSTEM=default
fi

if [ -n "$CFG_RUNTIME_SYSTEM" -a "$CFG_GRAPHICS_SYSTEM" != "runtime" ] || [ "$CFG_RUNTIME_SYSTEM" = "runtime" ]; then
    echo "Argument to -runtimegraphicssystem is invalid so ignoring..."
    CFG_RUNTIME_SYSTEM=
fi

if [ "$CFG_PTMALLOC" != "no" ]; then
    # build ptmalloc, copy .a file to lib/
    echo "Building ptmalloc. Please wait..."
    (cd "$relpath/src/3rdparty/ptmalloc/"; "$MAKE" "clean" ; "$MAKE" "posix"
     mkdir "$outpath/lib/" ; cp "libptmalloc3.a" "$outpath/lib/")

    QMakeVar add QMAKE_LFLAGS "$outpath/lib/libptmalloc3.a"
fi

if [ "$CFG_ALSA" = "auto" ] && [ "$XPLATFORM" != "symbian-sbsv2" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/alsa "alsa" $L_FLAGS $I_FLAGS $l_FLAGS; then
        CFG_ALSA=yes
    else
        CFG_ALSA=no
    fi
elif [ "$XPLATFORM" = "symbian-sbsv2" ]; then
    # Disabled for Symbian release
    CFG_ALSA=no
fi

if [ "$CFG_JAVASCRIPTCORE_JIT" = "yes" ] || [ "$CFG_JAVASCRIPTCORE_JIT" = "auto" ]; then 
    if [ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ]; then
       "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/javascriptcore-jit "javascriptcore-jit" $L_FLAGS $I_FLAGS $l_FLAGS
        if [ $? != "0" ]; then
           CFG_JAVASCRIPTCORE_JIT=no
        fi
    fi
fi

if [ "$CFG_JAVASCRIPTCORE_JIT" = "yes" ]; then
    QMakeVar set JAVASCRIPTCORE_JIT yes
elif [ "$CFG_JAVASCRIPTCORE_JIT" = "no" ]; then
    QMakeVar set JAVASCRIPTCORE_JIT no
fi

if [ "$CFG_AUDIO_BACKEND" = "auto" ]; then
    if echo "$XPLATFORM" | grep symbian > /dev/null 2>&1; then
         if "$symbiantests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/symbian/audio "audio" $L_FLAGS $I_FLAGS $l_FLAGS ; then
            CFG_AUDIO_BACKEND=yes
         fi
    else
        CFG_AUDIO_BACKEND=yes
    fi
fi

if [ "$CFG_LARGEFILE" != "yes" ] && [ "$XPLATFORM_MINGW" = "yes" ]; then
    echo "Warning: largefile support cannot be disabled for win32."
    CFG_LARGEFILE="yes"
elif [ "$CFG_LARGEFILE" != "no" ] && echo "$XPLATFORM" | grep "symbian" > /dev/null; then
    echo "Warning: largefile support cannot be enabled for symbian."
    CFG_LARGEFILE="no"
fi

#-------------------------------------------------------------------------------
# ask for all that hasn't been auto-detected or specified in the arguments
#-------------------------------------------------------------------------------

### fix this: user input should be validated in a loop
if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    PROMPT_FOR_DEPTHS="yes"
else
    PROMPT_FOR_DEPTHS="no"
fi
if [ "$CFG_QWS_DEPTHS" = "prompted" -a "$PROMPT_FOR_DEPTHS" = "yes" ]; then
    echo
    echo "Choose pixel-depths to support:"
    echo
    echo "   1. 1bpp, black/white"
    echo "   4. 4bpp, grayscale"
    echo "   8. 8bpp, paletted"
    echo "  12. 12bpp, rgb 4-4-4"
    echo "  15. 15bpp, rgb 5-5-5"
    echo "  16. 16bpp, rgb 5-6-5"
    echo "  18. 18bpp, rgb 6-6-6"
    echo "  24. 24bpp, rgb 8-8-8"
    echo "  32. 32bpp, argb 8-8-8-8 and rgb 8-8-8"
    echo " all. All supported depths"
    echo
    echo "Your choices (default 8,16,32):"
    read CFG_QWS_DEPTHS
    if [ -z "$CFG_QWS_DEPTHS" ] || [ "$CFG_QWS_DEPTHS" = "yes" ]; then
        CFG_QWS_DEPTHS=8,16,32
    fi
fi
if [ -n "$CFG_QWS_DEPTHS" -a "$PLATFORM_QWS" = "yes" ]; then
    if [ "$CFG_QWS_DEPTHS" = "all" ]; then
        CFG_QWS_DEPTHS="1 4 8 12 15 16 18 24 32 generic"
    fi
    for D in `echo "$CFG_QWS_DEPTHS" | sed -e 's/,/ /g'`; do
	case $D in
	    1|4|8|12|15|16|18|24|32) QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QWS_DEPTH_$D";;
	    generic) QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QWS_DEPTH_GENERIC";;
	esac
    done
fi

# enable dwarf2 support on Mac
if [ "$CFG_MAC_DWARF2" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG dwarf2"
fi

# Set the default arch if there are no "-arch" arguments on the configure line
# For "-carbon" builds: 32 bit x86/ppc.
# For builds on snow leopard : compiler default (64-bit).
# For builds on leopard : compiler default (32-bit).
if [ "$PLATFORM_MAC" = "yes" ]  && [ "$CFG_MAC_ARCHS" = "" ]; then
    source "$mactests/defaultarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests"

	if [ "$CFG_MAC_CARBON" = "yes" ]; then
		if [ "$QT_MAC_DEFAULT_ARCH" = "x86_64" ]; then
			CFG_MAC_ARCHS=" x86"
		elif [ "$QT_MAC_DEFAULT_ARCH" = "ppc64" ]; then
			CFG_MAC_ARCHS=" ppc"
		else
			CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH"
		fi
	else
		CFG_MAC_ARCHS=" $QT_MAC_DEFAULT_ARCH"
    fi

    [ "$OPT_VERBOSE" = "yes" ] && echo "Setting Mac architechture to$CFG_MAC_ARCHS."
fi

# enable Cocoa and/or Carbon on Mac
#  -carbon on the command line disables Cocoa, except for 64-bit archs
if [ "$CFG_MAC_CARBON" = "yes" ]; then
    CFG_MAC_CARBON="YES"
    CFG_MAC_COCOA="NO"

#    check which archs are in use, enable cocoa if we find a 64-bit one
    if echo "$CFG_MAC_ARCHS" | grep 64 > /dev/null 2>&1; then
        CFG_MAC_COCOA="yes";
        CFG_MAC_CARBON="no";
        if echo "$CFG_MAC_ARCHS" | grep -w ppc > /dev/null 2>&1; then
            CFG_MAC_CARBON="yes";
        fi
        if echo "$CFG_MAC_ARCHS" | grep -w x86 > /dev/null 2>&1; then
            CFG_MAC_CARBON="yes";
        fi
    fi
fi

# select Carbon on 10.4 Tiger.
if [ "$PLATFORM_MAC" = "yes" ]; then
    VERSION=`uname -r | tr '.' ' ' | awk '{print $1}'`
    if [ "$VERSION" == 8 ]; then
        CFG_MAC_COCOA="no";
        CFG_MAC_CARBON="yes";
    fi
fi

# select Carbon when using the 10.4u SDK
if [ "$PLATFORM_MAC" = "yes" ]; then
    if [ "TEST$CFG_SDK" = "TEST/Developer/SDKs/MacOSX10.4u.sdk/" ]; then
        echo "Carbon on";
        CFG_MAC_COCOA="no";
        CFG_MAC_CARBON="yes";
    fi
fi

# but disable Cocoa if cross-building for mingw
[ "$XPLATFORM_MINGW" = "yes" ] && CFG_MAC_COCOA="no"

# set the global Mac deployment target. This is overridden on an arch-by-arch basis
# in some cases, see code further down
case "$PLATFORM,$CFG_MAC_COCOA" in
    macx*,yes)
	# Cocoa
	QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.5
	;;
    macx*,no)
	# gcc, Carbon
	QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.4
	;;
esac

# disable Qt 3 support on VxWorks and Symbian
case "$XPLATFORM" in
    unsupported/vxworks*|symbian*)
	CFG_QT3SUPPORT="no"
    ;;
esac

# enable Qt 3 support functionality
if [ "$CFG_QT3SUPPORT" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG qt3support"
fi

# enable Phonon
if [ "$CFG_PHONON" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG phonon"
    if [ "$CFG_PHONON_BACKEND" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG phonon-backend"
    fi
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_PHONON"
fi

# disable accessibility
if [ "$CFG_ACCESSIBILITY" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ACCESSIBILITY"
else
    QT_CONFIG="$QT_CONFIG accessibility"
fi

# egl stuff does not belong in lighthouse, but rather in plugins
if [ "$PLATFORM_QPA" = "yes" ]; then
    CFG_EGL="no"
fi

# enable egl
if [ "$CFG_EGL" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGL"
else
    QT_CONFIG="$QT_CONFIG egl"
    if [ "$CFG_EGL_GLES_INCLUDES" = "yes" ]; then
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_GLES_EGL"
    fi
fi

# enable openvg
if [ "$CFG_OPENVG" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_OPENVG"
else
    QT_CONFIG="$QT_CONFIG openvg"
    if [ "$CFG_OPENVG_LC_INCLUDES" = "yes" ]; then
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_LOWER_CASE_VG_INCLUDES"
    fi
    if [ "$CFG_OPENVG_ON_OPENGL" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG openvg_on_opengl"
    fi
    if [ "$CFG_OPENVG_SHIVA" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG shivavg"
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_SHIVAVG"
    fi
fi

if [ "$CFG_QS60STYLE" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_S60"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_STYLE_S60"
fi

# Disable OpenGL on Symbian.
case "$XPLATFORM" in
    symbian*)
        CFG_OPENGL="no"
        ;;
esac

# enable opengl
if [ "$CFG_OPENGL" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_OPENGL"
else
    QT_CONFIG="$QT_CONFIG opengl"
fi

if [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es2" ]; then
    if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
	if [ "$PLATFORM_QWS" = "yes" ]; then
	    QCONFIG_FLAGS="$QCONFIG_FLAGS Q_BACKINGSTORE_SUBSURFACES"
	else
	    echo "### Q_BACKINGSTORE_SUBSURFACES disabled, re-enable once it compiles again"
	fi
	QCONFIG_FLAGS="$QCONFIG_FLAGS Q_USE_EGLWINDOWSURFACE"
    fi
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES"
fi

if [ "$CFG_OPENGL" = "es1" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_1"
    QT_CONFIG="$QT_CONFIG opengles1"
fi

if [ "$CFG_OPENGL" = "es2" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_2"
    QT_CONFIG="$QT_CONFIG opengles2"
fi

# safe execution environment
if [ "$CFG_SXE" != "no" ]; then
    QT_CONFIG="$QT_CONFIG sxe"
fi

# build up the variables for output
if [ "$CFG_DEBUG" = "yes" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}debug"
    QMAKE_CONFIG="$QMAKE_CONFIG debug"
elif [ "$CFG_DEBUG" = "no" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}release"
    QMAKE_CONFIG="$QMAKE_CONFIG release"
fi
if [ "$CFG_SHARED" = "yes" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}-shared"
    QMAKE_CONFIG="$QMAKE_CONFIG shared dll"
elif [ "$CFG_SHARED" = "no" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}-static"
    QMAKE_CONFIG="$QMAKE_CONFIG static"
fi
if [ "$PLATFORM_QWS" = "yes" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}-emb-$CFG_EMBEDDED"
    QMAKE_CONFIG="$QMAKE_CONFIG embedded"
    QT_CONFIG="$QT_CONFIG embedded"
    rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes
fi
if [ "$PLATFORM_QPA" = "yes" ]; then
    QMAKE_OUTDIR="${QMAKE_OUTDIR}-emb-$CFG_EMBEDDED"
    QMAKE_CONFIG="$QMAKE_CONFIG qpa"
    QT_CONFIG="$QT_CONFIG qpa"
    rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes
fi

if [ "$CFG_EMBEDDED" = "nacl" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG nacl pepper"
    QT_CONFIG="$QT_CONFIG nacl pepper"
    rm -f "src/.moc/$QMAKE_OUTDIR/allmoc.cpp" # needs remaking if config changes
fi

QMakeVar set PRECOMPILED_DIR ".pch/$QMAKE_OUTDIR"
QMakeVar set OBJECTS_DIR ".obj/$QMAKE_OUTDIR"
QMakeVar set MOC_DIR ".moc/$QMAKE_OUTDIR"
QMakeVar set RCC_DIR ".rcc/$QMAKE_OUTDIR"
QMakeVar set UI_DIR ".uic/$QMAKE_OUTDIR"
if [ "$CFG_LARGEFILE" = "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG largefile"
fi
if [ "$CFG_STL" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STL"
else
    QMAKE_CONFIG="$QMAKE_CONFIG stl"
fi
if [ "$CFG_USE_GNUMAKE" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG GNUmake"
fi
[ "$CFG_REDUCE_EXPORTS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_exports"
[ "$CFG_REDUCE_RELOCATIONS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_relocations"
[ "$CFG_PRECOMPILE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG precompile_header"
if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
    QMakeVar add QMAKE_CFLAGS -g
    QMakeVar add QMAKE_CXXFLAGS -g
    QMAKE_CONFIG="$QMAKE_CONFIG separate_debug_info"
fi
if [ "$CFG_SEPARATE_DEBUG_INFO_NOCOPY" = "yes" ] ; then
    QMAKE_CONFIG="$QMAKE_CONFIG separate_debug_info_nocopy"
fi
[ "$CFG_MMX" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG mmx"
[ "$CFG_3DNOW" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG 3dnow"
[ "$CFG_SSE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse"
[ "$CFG_SSE2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse2"
[ "$CFG_SSE3" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse3"
[ "$CFG_SSSE3" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG ssse3"
[ "$CFG_SSE4_1" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse4_1"
[ "$CFG_SSE4_2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse4_2"
[ "$CFG_AVX" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG avx"
[ "$CFG_IWMMXT" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG iwmmxt"
[ "$CFG_NEON" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG neon"
[ "$PLATFORM_MAC" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG $CFG_MAC_ARCHS"
if [ "$CFG_IPV6" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG ipv6"
fi
if [ "$CFG_CLOCK_GETTIME" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG clock-gettime"
fi
if [ "$CFG_CLOCK_MONOTONIC" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG clock-monotonic"
fi
if [ "$CFG_MREMAP" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG mremap"
fi
if [ "$CFG_GETADDRINFO" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG getaddrinfo"
fi
if [ "$CFG_IPV6IFNAME" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG ipv6ifname"
fi
if [ "$CFG_GETIFADDRS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG getifaddrs"
fi
if [ "$CFG_INOTIFY" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG inotify"
fi
if [ "$CFG_LIBJPEG" = "no" ]; then
    CFG_JPEG="no"
elif [ "$CFG_LIBJPEG" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-jpeg"
fi
if [ "$CFG_JPEG" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-jpeg"
elif [ "$CFG_JPEG" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG jpeg"
fi
if [ "$CFG_LIBMNG" = "no" ]; then
    CFG_MNG="no"
elif [ "$CFG_LIBMNG" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-mng"
fi
if [ "$CFG_MNG" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-mng"
elif [ "$CFG_MNG" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG mng"
fi
if [ "$CFG_LIBPNG" = "no" ]; then
    CFG_PNG="no"
fi
if [ "$CFG_LIBPNG" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-png"
fi
if [ "$CFG_PNG" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-png"
elif [ "$CFG_PNG" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG png"
fi
if [ "$CFG_GIF" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-gif"
elif [ "$CFG_GIF" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG gif"
fi
if [ "$CFG_LIBTIFF" = "no" ]; then
    CFG_TIFF="no"
elif [ "$CFG_LIBTIFF" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-tiff"
fi
if [ "$CFG_TIFF" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-tiff"
elif [ "$CFG_TIFF" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG tiff"
fi
if [ "$CFG_LIBFREETYPE" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-freetype"
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_FREETYPE"
elif [ "$CFG_LIBFREETYPE" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-freetype"
else
    QT_CONFIG="$QT_CONFIG freetype"
fi
if [ "$CFG_GUI" = "auto" ]; then
    CFG_GUI="yes"
fi
if [ "$CFG_GUI" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-gui"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GUI"
fi


if [ "x$PLATFORM_MAC" = "xyes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then
    #On Mac we implicitly link against libz, so we
    #never use the 3rdparty stuff.
    [ "$CFG_ZLIB" = "yes" ] && CFG_ZLIB="system"
fi
if [ "$CFG_ZLIB" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG zlib"
elif [ "$CFG_ZLIB" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-zlib"
fi

if [ "$CFG_S60" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG s60"
fi

if [ "$CFG_SYMBIAN_DEFFILES" = "yes" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG def_files"
else
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG def_files_disabled"
fi

[ "$CFG_NIS" = "yes" ] && QT_CONFIG="$QT_CONFIG nis"
[ "$CFG_CUPS" = "yes" ] && QT_CONFIG="$QT_CONFIG cups"
[ "$CFG_ICONV" = "yes" ] && QT_CONFIG="$QT_CONFIG iconv"
[ "$CFG_ICONV" = "sun" ] && QT_CONFIG="$QT_CONFIG sun-libiconv"
[ "$CFG_ICONV" = "gnu" ] && QT_CONFIG="$QT_CONFIG gnu-libiconv"
[ "$CFG_GLIB" = "yes" ] && QT_CONFIG="$QT_CONFIG glib"
[ "$CFG_GSTREAMER" = "yes" ] && QT_CONFIG="$QT_CONFIG gstreamer"
[ "$CFG_DBUS" = "yes" ] && QT_CONFIG="$QT_CONFIG dbus"
[ "$CFG_DBUS" = "linked" ] && QT_CONFIG="$QT_CONFIG dbus dbus-linked"
[ "$CFG_NAS" = "system" ] && QT_CONFIG="$QT_CONFIG nas"
[ "$CFG_OPENSSL" = "yes" ] && QT_CONFIG="$QT_CONFIG openssl"
[ "$CFG_OPENSSL" = "linked" ] && QT_CONFIG="$QT_CONFIG openssl-linked"

if [ "$PLATFORM_X11" = "yes" ]; then
    [ "$CFG_SM" = "yes" ] && QT_CONFIG="$QT_CONFIG x11sm"

    # for some reason, the following libraries are not always built shared,
    # so *every* program/lib (including Qt) has to link against them
    if [ "$CFG_XSHAPE" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xshape"
    fi
    if [ "$CFG_XVIDEO" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xvideo"
    fi
    if [ "$CFG_XSYNC" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xsync"
    fi
    if [ "$CFG_XINERAMA" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xinerama"
	QMakeVar set QMAKE_LIBS_X11 '-lXinerama $$QMAKE_LIBS_X11'
    fi
    if [ "$CFG_XCURSOR" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xcursor"
	QMakeVar set QMAKE_LIBS_X11 '-lXcursor $$QMAKE_LIBS_X11'
    fi
    if [ "$CFG_XFIXES" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xfixes"
	QMakeVar set QMAKE_LIBS_X11 '-lXfixes $$QMAKE_LIBS_X11'
    fi
    if [ "$CFG_XRANDR" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xrandr"
        if [ "$CFG_XRENDER" != "yes" ]; then
            # libXrandr uses 1 function from libXrender, so we always have to have it :/
	    QMakeVar set QMAKE_LIBS_X11 '-lXrandr -lXrender $$QMAKE_LIBS_X11'
        else
	    QMakeVar set QMAKE_LIBS_X11 '-lXrandr $$QMAKE_LIBS_X11'
        fi
    fi
    if [ "$CFG_XRENDER" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xrender"
	QMakeVar set QMAKE_LIBS_X11 '-lXrender $$QMAKE_LIBS_X11'
    fi
    if [ "$CFG_MITSHM" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG mitshm"
    fi
    if [ "$CFG_FONTCONFIG" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG fontconfig"
    fi
    if [ "$CFG_XINPUT" = "yes" ]; then
	QMakeVar set QMAKE_LIBS_X11 '-lXi $$QMAKE_LIBS_X11'
    fi
    if [ "$CFG_XINPUT" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xinput tablet"
    fi
    if [ "$CFG_XKB" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG xkb"
    fi
fi

[ '!' -z "$D_FLAGS" ] && QMakeVar add DEFINES "$D_FLAGS"
[ '!' -z "$L_FLAGS" ] && QMakeVar add QMAKE_LIBDIR_FLAGS "$L_FLAGS"
[ '!' -z "$l_FLAGS" ] && QMakeVar add LIBS "$l_FLAGS"

if [ "$PLATFORM_MAC" = "yes" ]; then
    if [ "$CFG_RPATH" = "yes" ]; then
       QMAKE_CONFIG="$QMAKE_CONFIG absolute_library_soname"
    fi
elif [ -z "`getQMakeConf \"$XQMAKESPEC\" | $AWK '/QMAKE_(LFLAGS_)?RPATH/ {print $3;}'`" ]; then
    if [ -n "$RPATH_FLAGS" ]; then
        echo
        echo "ERROR: -R cannot be used on this platform as \$QMAKE_LFLAGS_RPATH is"
        echo "       undefined."
        echo
        exit 1
    elif [ "$CFG_RPATH" = "yes" ]; then
        RPATH_MESSAGE="        NOTE: This platform does not support runtime library paths, using -no-rpath."
        CFG_RPATH=no
    fi
else
    if [ "$CFG_RPATH" = "yes" ]; then
        # set the default rpath to the library installation directory
        RPATH_FLAGS="\"$QT_INSTALL_LIBS\" $RPATH_FLAGS"
    fi
    if [ -n "$RPATH_FLAGS" ]; then
        # add the user defined rpaths
	QMakeVar add QMAKE_RPATHDIR "$RPATH_FLAGS"
    fi
fi

if [ '!' -z "$I_FLAGS" ]; then
    # add the user define include paths
    QMakeVar add QMAKE_CFLAGS "$I_FLAGS"
    QMakeVar add QMAKE_CXXFLAGS "$I_FLAGS"
fi

# turn off exceptions for the compilers that support it
if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    COMPILER=`echo $XPLATFORM | cut -f 3- -d-`
elif [ "$XPLATFORM" != "$PLATFORM" ]; then
    COMPILER=`echo $XPLATFORM | cut -f 2- -d-`
else
    COMPILER=`echo $PLATFORM | cut -f 2- -d-`
fi
if [ "$CFG_EXCEPTIONS" = "unspecified" -a "$PLATFORM_QWS" = "yes" ]; then
    CFG_EXCEPTIONS=no
fi

if [ "$CFG_EXCEPTIONS" != "no" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG exceptions"
fi

if [ "$XPLATFORM_MINGW" = "yes" ]; then
    # mkspecs/features/win32/default_pre.prf sets "no-rtti".
    # Follow default behavior of configure.exe by overriding with "rtti".
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG rtti"
fi

if [ "$CFG_ALSA" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG alsa"
fi

if [ "$CFG_PULSEAUDIO" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG pulseaudio"
fi

if [ "$CFG_COREWLAN" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG corewlan"
fi

if [ "$CFG_ICD" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG icd"
fi

#
# Some Qt modules are too advanced in C++ for some old compilers
# Detect here the platforms where they are known to work.
#
# See Qt documentation for more information on which features are
# supported and on which compilers.
#
canBuildQtXmlPatterns="yes"
canBuildWebKit="$HAVE_STL"
canBuildQtConcurrent="yes"

# WebKit requires stdint.h
"$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stdint "Stdint" $L_FLAGS $I_FLAGS $l_FLAGS
if [ $? != "0" ]; then
    canBuildWebKit="no"
fi

case "$XPLATFORM" in
    hpux-g++*)
	# PA-RISC's assembly is too limited
	# gcc 3.4 on that platform can't build QtXmlPatterns
	# the assembly it generates cannot be compiled

	# Check gcc's version
	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
	    4*)
		;;
	    3.4*)
		canBuildQtXmlPatterns="no"
		;;
	    *)
		canBuildWebKit="no"
		canBuildQtXmlPatterns="no"
		;;
	esac
	;;
    unsupported/vxworks-*-g++*)
	canBuildWebKit="no"
	;;
    unsupported/vxworks-*-dcc*)
	canBuildWebKit="no"
	canBuildQtXmlPatterns="no"
	;;
    *-g++*)
	# Check gcc's version
	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
	    4*|3.4*)
		;;
            3.3*)
                canBuildWebKit="no"
                ;;
	    *)
		canBuildWebKit="no"
		canBuildQtXmlPatterns="no"
		;;
	esac
	;;
    solaris-cc*)
        # Check the compiler version
        case `${QMAKE_CONF_COMPILER} -V 2>&1 | awk '{print $4}'` in
            5.[012345678])
                canBuildWebKit="no"
                canBuildQtXmlPatterns="no"
                canBuildQtConcurrent="no"
                ;;
            5.9)
                canBuildWebKit="no"
                canBuildQtConcurrent="no"
                ;;
        esac
        ;;
    hpux-acc*)
	canBuildWebKit="no"
	canBuildQtXmlPatterns="no"
        canBuildQtConcurrent="no"
	;;
    hpuxi-acc*)
	canBuildWebKit="no"
	;;
    aix-xlc*)
        # Get the xlC version
        cat > xlcver.c <<EOF
#include <stdio.h>
int main()
{
    printf("%d.%d\n", __xlC__ >> 8, __xlC__ & 0xFF);
    return 0;
}
EOF
        xlcver=
        if ${QMAKE_CONF_COMPILER} -o xlcver xlcver.c >/dev/null 2>/dev/null; then
            xlcver=`./xlcver 2>/dev/null`
            rm -f ./xlcver
        fi
        if [ "$OPT_VERBOSE" = "yes" ]; then
            if [ -n "$xlcver" ]; then
                echo Found IBM xlC version: $xlcver.
            else
                echo Could not determine IBM xlC version, assuming oldest supported.
            fi
        fi

        case "$xlcver" in
            [123456].*)
                canBuildWebKit="no"
                canBuildQtXmlPatterns="no"
                canBuildQtConcurrent="no"
                ;;
            *)
                canBuildWebKit="no"
                canBuildQtConcurrent="no"
                ;;
        esac
        ;;
    irix-cc*)
        canBuildWebKit="no"
        canBuildQtConcurrent="no"
	;;
    symbian/*-gcce)
        canBuildWebKit="no"
        canBuildQtConcurrent="no"
        ;;
    symbian/*-armcc)
        canBuildQtConcurrent="no"
        ;;
esac

if [ "$CFG_GUI" = "no" ]; then
    # WebKit requires QtGui
    canBuildWebKit="no"
fi

if [ "$CFG_SHARED" = "no" ]; then
    echo
    echo "WARNING: Using static linking will disable the WebKit module."
    echo
    canBuildWebKit="no"
fi

CFG_CONCURRENT="yes"
if [ "$canBuildQtConcurrent" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CONCURRENT"
    CFG_CONCURRENT="no"
fi

if [ "$CFG_XMLPATTERNS" = "yes" -a "$CFG_EXCEPTIONS" = "no" ]; then
    echo "QtXmlPatterns was requested, but it can't be built due to exceptions being disabled."
    exit 1
fi
if [ "$CFG_XMLPATTERNS" = "auto" -a "$CFG_EXCEPTIONS" != "no" ]; then
    CFG_XMLPATTERNS="$canBuildQtXmlPatterns"
elif [ "$CFG_EXCEPTIONS" = "no" ]; then
    CFG_XMLPATTERNS="no"
fi
if [ "$CFG_XMLPATTERNS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG xmlpatterns"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XMLPATTERNS"
fi

if [ "$CFG_MULTIMEDIA" = "no" ]; then
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MULTIMEDIA"
else
    QT_CONFIG="$QT_CONFIG multimedia"
fi

if [ "$CFG_AUDIO_BACKEND" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG audio-backend"
fi

if [ "$CFG_SVG" = "auto" ]; then
    CFG_SVG=$CFG_GUI
fi

if [ "$CFG_SVG" = "yes" ] && [ "$CFG_GUI" = "no" ]; then
    echo "QtSvg requested, but it can't be built without QtGui"
    exit 1
fi

if [ "$CFG_SVG" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG svg"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SVG"
fi

if [ "$CFG_WEBKIT" = "auto" ]; then
    CFG_WEBKIT="$canBuildWebKit"
fi

if [ "$CFG_WEBKIT" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG webkit"
    # The reason we set CFG_WEBKIT, is such that the printed overview of what will be enabled, shows correctly.
    CFG_WEBKIT="yes"
else
    CFG_WEBKIT="no"
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_WEBKIT"
fi

if [ "$CFG_SCRIPT" = "auto" ]; then
    CFG_SCRIPT="yes"
fi

if [ "$CFG_SCRIPT" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG script"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SCRIPT"
fi

if [ "$CFG_SCRIPTTOOLS" = "yes" -a "$CFG_SCRIPT" = "no" ]; then
    echo "QtScriptTools was requested, but it can't be built due to QtScript being disabled."
    exit 1
fi
if [ "$CFG_SCRIPTTOOLS" = "auto" -a "$CFG_SCRIPT" != "no" ]; then
    CFG_SCRIPTTOOLS="yes"
elif [ "$CFG_SCRIPT" = "no" ]; then
    CFG_SCRIPTTOOLS="no"
fi

if [ "$CFG_SCRIPTTOOLS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG scripttools"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SCRIPTTOOLS"
fi


if [ "$CFG_DECLARATIVE" = "yes" ]; then
    if [ "$CFG_SCRIPT" = "no" -o "$CFG_GUI" = "no" ]; then
        echo "Error: QtDeclarative was requested, but it can't be built due to QtScript or QtGui being disabled."
        exit 1
    fi
fi
if [ "$CFG_DECLARATIVE" = "auto" ]; then
    if [ "$CFG_SCRIPT" = "no" -o "$CFG_GUI" = "no" ]; then
            CFG_DECLARATIVE=no
    else
            CFG_DECLARATIVE=yes
    fi
fi

if [ "$CFG_DECLARATIVE" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG declarative"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DECLARATIVE"
fi

if [ "$CFG_EXCEPTIONS" = "no" ]; then
    case "$COMPILER" in
    g++*)
	QMakeVar add QMAKE_CFLAGS -fno-exceptions
	QMakeVar add QMAKE_CXXFLAGS -fno-exceptions
	QMakeVar add QMAKE_LFLAGS -fno-exceptions
        ;;
    cc*)
        case "$PLATFORM" in
        irix-cc*)
	    QMakeVar add QMAKE_CFLAGS -LANG:exceptions=off
	    QMakeVar add QMAKE_CXXFLAGS -LANG:exceptions=off
	    QMakeVar add QMAKE_LFLAGS -LANG:exceptions=off
            ;;
        *) ;;
        esac
        ;;
    *) ;;
    esac
    QMAKE_CONFIG="$QMAKE_CONFIG exceptions_off"
fi

# On Mac, set the minimum deployment target for the different architechtures 
# using the Xarch compiler option when supported (10.5 and up).  On 10.4 the
# deployment version is set to 10.4 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET
# env. variable. 
if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] ; then
    if echo "$CFG_MAC_ARCHS" | grep '\<x86\>' > /dev/null 2>&1; then
        QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_CXXFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_LFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86 "-arch i386 -Xarch_i386 -mmacosx-version-min=10.4"
    fi
    if echo "$CFG_MAC_ARCHS" | grep '\<ppc\>' > /dev/null 2>&1; then
        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC "-arch ppc -Xarch_ppc -mmacosx-version-min=10.4"
    fi
    if echo "$CFG_MAC_ARCHS" | grep '\<x86_64\>' > /dev/null 2>&1; then
        QMakeVar add QMAKE_CFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_CXXFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_LFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5"
    fi
    if echo "$CFG_MAC_ARCHS" | grep '\<ppc64\>' > /dev/null 2>&1; then
        QMakeVar add QMAKE_CFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_LFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
        QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC_64 "-arch ppc64 -Xarch_ppc64 -mmacosx-version-min=10.5"
    fi
fi

#-------------------------------------------------------------------------------
# generate QT_BUILD_KEY
#-------------------------------------------------------------------------------

# some compilers generate binary incompatible code between different versions,
# so we need to generate a build key that is different between these compilers
case "$COMPILER" in
g++*)
    # GNU C++
    COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -dumpversion 2>/dev/null`

    case "$COMPILER_VERSION" in
    *.*.*)
        QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'`
        QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'`
        QT_GCC_PATCH_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'`
        ;;
    *.*)
        QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\1,'`
        QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\2,'`
        QT_GCC_PATCH_VERSION=0
        ;;
    esac

    case "$COMPILER_VERSION" in
    2.95.*)
        COMPILER_VERSION="2.95.*"
        ;;
    3.*)
        COMPILER_VERSION="3.*"
        ;;
    4.*)
        COMPILER_VERSION="4"
        ;;
    *)
        ;;
    esac
    [ '!' -z "$COMPILER_VERSION" ] && COMPILER="g++-${COMPILER_VERSION}"
    ;;
*)
    #
    ;;
esac

# QT_CONFIG can contain the following:
#
# Things that affect the Qt API/ABI:
#
#   Options:
#     minimal-config small-config medium-config large-config full-config
#
#   Different edition modules:
#     gui network canvas table xml opengl sql
#
# Things that do not affect the Qt API/ABI:
#     stl
#     system-jpeg no-jpeg jpeg
#     system-mng no-mng mng
#     system-png no-png png
#     system-zlib no-zlib zlib
#     system-libtiff no-libtiff
#     no-gif gif
#     debug release
#     dll staticlib
#
#     nocrosscompiler
#     GNUmake
#     largefile
#     nis
#     nas
#     tablet
#     ipv6
#
#     X11     : x11sm xinerama xcursor xfixes xrandr xrender mitshm fontconfig xkb
#     Embedded: embedded qpa freetype
#
ALL_OPTIONS=
BUILD_CONFIG=
BUILD_OPTIONS=

# determine the build options
for config_option in $QMAKE_CONFIG $QT_CONFIG; do
    SKIP="yes"
    case "$config_option" in
    *-config)
        # take the last *-config setting.  this is the highest config being used,
        # and is the one that we will use for tagging plugins
        BUILD_CONFIG="$config_option"
        ;;

    *) # skip all other options since they don't affect the Qt API/ABI.
        ;;
    esac

    if [ "$SKIP" = "no" ]; then
        BUILD_OPTIONS="$BUILD_OPTIONS $config_option"
    fi
done

# put the options that we are missing into .options
rm -f .options
for opt in `echo $ALL_OPTIONS`; do
    SKIP="no"
    if echo $BUILD_OPTIONS | grep $opt >/dev/null 2>&1; then
        SKIP="yes"
    fi
    if [ "$SKIP" = "no" ]; then
        echo "$opt" >> .options
    fi
done

# reconstruct BUILD_OPTIONS with a sorted negative feature list
# (ie. only things that are missing are will be put into the build key)
BUILD_OPTIONS=
if [ -f .options ]; then
    for opt in `sort -f .options | uniq`; do
        BUILD_OPTIONS="$BUILD_OPTIONS no-$opt"
    done
fi
rm -f .options

# QT_NO* defines affect the Qt API (and binary compatibility).  they need
# to be included in the build key
for build_option in $D_FLAGS; do
    build_option=`echo $build_option | cut -d \" -f 2 -`
    case "$build_option" in
    QT_NO*)
        echo "$build_option" >> .options
        ;;
    *)
        # skip all other compiler defines
        ;;
    esac
done

# sort the compile time defines (helps ensure that changes in this configure
# script don't affect the QT_BUILD_KEY generation)
if [ -f .options ]; then
    for opt in `sort -f .options | uniq`; do
        BUILD_OPTIONS="$BUILD_OPTIONS $opt"
    done
fi
rm -f .options

BUILD_OPTIONS="$BUILD_CONFIG $BUILD_OPTIONS"
# extract the operating system from the XPLATFORM
TARGET_OPERATING_SYSTEM=`echo $XPLATFORM | cut -f 2- -d/ | cut -f -1 -d-`
case "$XPLATFORM" in
symbian*)
    QT_BUILD_KEY_SYSTEM_PART="Symbian"
    ;;
*)
    QT_BUILD_KEY_SYSTEM_PART="$CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER"
    ;;
esac

# when cross-compiling, don't include build-host information (build key is target specific)
QT_BUILD_KEY="$CFG_USER_BUILD_KEY $QT_BUILD_KEY_SYSTEM_PART $BUILD_OPTIONS"
if [ -n "$QT_NAMESPACE" ]; then
    QT_BUILD_KEY="$QT_BUILD_KEY $QT_NAMESPACE"
fi
MAC_NEED_TWO_BUILD_KEYS="no"
if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then
    QT_BUILD_KEY_CARBON=$QT_BUILD_KEY
    TARGET_OPERATING_SYSTEM="$TARGET_OPERATING_SYSTEM-cocoa"
    QT_BUILD_KEY_COCOA="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS"
    if [ "$CFG_MAC_CARBON" = "no" ]; then
        QT_BUILD_KEY=$QT_BUILD_KEY_COCOA
    else
        MAC_NEED_TWO_BUILD_KEYS="yes"
    fi
fi
# don't break loading plugins build with an older version of Qt
QT_BUILD_KEY_COMPAT=
if [ "$QT_CROSS_COMPILE" = "no" ]; then
    # previous versions of Qt used a build key built from the uname
    QT_BUILD_KEY_COMPAT="$CFG_USER_BUILD_KEY $UNAME_MACHINE $UNAME_SYSTEM $COMPILER $BUILD_OPTIONS"
    if [ -n "$QT_NAMESPACE" ]; then
        QT_BUILD_KEY_COMPAT="$QT_BUILD_KEY_COMPAT $QT_NAMESPACE"
    fi
fi
# strip out leading/trailing/extra whitespace
QT_BUILD_KEY=`echo $QT_BUILD_KEY | sed -e "s,  *, ,g" -e "s,^  *,," -e "s,  *$,,"`
QT_BUILD_KEY_COMPAT=`echo $QT_BUILD_KEY_COMPAT | sed -e "s,  *, ,g" -e "s,^  *,," -e "s,  *$,,"`

#-------------------------------------------------------------------------------
# part of configuration information goes into qconfig.h
#-------------------------------------------------------------------------------

case "$CFG_QCONFIG" in
full)
    echo "/* Everything */" >"$outpath/src/corelib/global/qconfig.h.new"
    ;;
*)
    tmpconfig="$outpath/src/corelib/global/qconfig.h.new"
    echo "#ifndef QT_BOOTSTRAPPED" >"$tmpconfig"
    if [ -f "$relpath/src/corelib/global/qconfig-$CFG_QCONFIG.h" ]; then
        cat "$relpath/src/corelib/global/qconfig-$CFG_QCONFIG.h" >>"$tmpconfig"
    elif [ -f `"$relpath/config.tests/unix/makeabs" "${CFG_QCONFIG}"` ]; then
        cat `"$relpath/config.tests/unix/makeabs" "${CFG_QCONFIG}"` >>"$tmpconfig"
    fi
    echo "#endif" >>"$tmpconfig"
    ;;
esac

cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF

/* Qt Edition */
#ifndef QT_EDITION
#  define QT_EDITION $QT_EDITION
#endif

/* Machine byte-order */
#define Q_BIG_ENDIAN 4321
#define Q_LITTLE_ENDIAN 1234
EOF

if [ "$MAC_NEED_TWO_BUILD_KEYS" = "no" ]; then
    echo "#define QT_BUILD_KEY \"$QT_BUILD_KEY\"" \
        >> "$outpath/src/corelib/global/qconfig.h.new"
else
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF

#define QT_BUILD_KEY_CARBON "$QT_BUILD_KEY_CARBON"
#define QT_BUILD_KEY_COCOA "$QT_BUILD_KEY_COCOA"
EOF
fi

if [ -n "$QT_BUILD_KEY_COMPAT" ]; then
    echo "#define QT_BUILD_KEY_COMPAT \"$QT_BUILD_KEY_COMPAT\"" \
        >> "$outpath/src/corelib/global/qconfig.h.new"
fi
echo "" >>"$outpath/src/corelib/global/qconfig.h.new"

echo "#ifdef QT_BOOTSTRAPPED" >>"$outpath/src/corelib/global/qconfig.h.new"
if [ "$CFG_HOST_ENDIAN" = "auto" ]; then
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#if defined(__BIG_ENDIAN__)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
#elif defined(__LITTLE_ENDIAN__)
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
#else
# error "Unable to determine byte order!"
#endif
EOF
else
    echo "#define Q_BYTE_ORDER $CFG_HOST_ENDIAN" >>"$outpath/src/corelib/global/qconfig.h.new"
fi
echo "#else" >>"$outpath/src/corelib/global/qconfig.h.new"
if [ "$CFG_ENDIAN" = "auto" ]; then
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#if defined(__BIG_ENDIAN__)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
#elif defined(__LITTLE_ENDIAN__)
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
#else
# error "Unable to determine byte order!"
#endif
EOF
else
    echo "#define Q_BYTE_ORDER $CFG_ENDIAN" >>"$outpath/src/corelib/global/qconfig.h.new"
fi
echo "#endif" >>"$outpath/src/corelib/global/qconfig.h.new"

if [ "$CFG_DOUBLEFORMAT" != "normal" ]; then
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
/* Non-IEEE double format */
#define Q_DOUBLE_LITTLE "01234567"
#define Q_DOUBLE_BIG "76543210"
#define Q_DOUBLE_LITTLE_SWAPPED "45670123"
#define Q_DOUBLE_BIG_SWAPPED "32107654"
#define Q_DOUBLE_FORMAT $CFG_DOUBLEFORMAT
EOF
fi
if [ "$CFG_ARMFPA" = "yes" ]; then
    if [ "$CFG_ARCH" != "$CFG_HOST_ARCH" ]; then
	cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#ifndef QT_BOOTSTRAPPED
# define QT_ARMFPA
#endif
EOF
    else
	echo "#define QT_ARMFPA" >>"$outpath/src/corelib/global/qconfig.h.new"
    fi
fi

CFG_ARCH_STR=`echo $CFG_ARCH | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
CFG_HOST_ARCH_STR=`echo $CFG_HOST_ARCH | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
/* Machine Architecture */
#ifndef QT_BOOTSTRAPPED
# define QT_ARCH_${CFG_ARCH_STR}
#else
# define QT_ARCH_${CFG_HOST_ARCH_STR}
#endif
EOF

echo '/* Compile time features */' >>"$outpath/src/corelib/global/qconfig.h.new"
[ '!' -z "$LicenseKeyExt" ] && echo "#define QT_PRODUCT_LICENSEKEY \"$LicenseKeyExt\"" >>"$outpath/src/corelib/global/qconfig.h.new"

if [ "$CFG_LARGEFILE" = "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then
    echo "#define QT_LARGEFILE_SUPPORT 64" >>"$outpath/src/corelib/global/qconfig.h.new"
fi

# if both carbon and cocoa are specified, enable the autodetection code.
if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" -a "$CFG_MAC_CARBON" = "yes" ]; then
    echo "#define QT_AUTODETECT_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new"
elif [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then
    echo "#define QT_MAC_USE_COCOA 1" >>"$outpath/src/corelib/global/qconfig.h.new"
fi

if [ "$CFG_FRAMEWORK" = "yes" ]; then
    echo "#define QT_MAC_FRAMEWORK_BUILD" >>"$outpath/src/corelib/global/qconfig.h.new"
fi

if [ "$PLATFORM_MAC" = "yes" ]; then
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#if defined(__LP64__)
# define QT_POINTER_SIZE 8
#else
# define QT_POINTER_SIZE 4
#endif
EOF
else
    "$unixtests/ptrsize.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
    echo "#define QT_POINTER_SIZE $?" >>"$outpath/src/corelib/global/qconfig.h.new"
fi


echo "" >>"$outpath/src/corelib/global/qconfig.h.new"

if [ "$CFG_DEV" = "yes" ]; then
    echo "#define QT_BUILD_INTERNAL" >>"$outpath/src/corelib/global/qconfig.h.new"
fi

# Embedded compile time options
if [ "$PLATFORM_QWS" = "yes" ]; then
    # Add QWS to config.h
    QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_QWS"

    # Add excluded decorations to $QCONFIG_FLAGS
    decors=`grep '^decorations -= ' "$QMAKE_VARS_FILE" | ${AWK} '{print $3}'`
    for decor in $decors; do
        NODECORATION=`echo $decor | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
        QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_NO_QWS_DECORATION_${NODECORATION}"
    done

    # Figure which embedded drivers which are turned off
    CFG_GFX_OFF="$CFG_GFX_AVAILABLE"
    for ADRIVER in $CFG_GFX_ON; do
        CFG_GFX_OFF=`echo "${CFG_GFX_OFF} " | sed "s,${ADRIVER} ,,g"`
    done

    CFG_KBD_OFF="$CFG_KBD_AVAILABLE"
    # the um driver is currently not in the available list for external builds
    if [ "$CFG_DEV" = "no" ]; then
	CFG_KBD_OFF="$CFG_KBD_OFF um"
    fi
    for ADRIVER in $CFG_KBD_ON; do
        CFG_KBD_OFF=`echo "${CFG_KBD_OFF} " | sed "s,${ADRIVER} ,,g"`
    done

    CFG_MOUSE_OFF="$CFG_MOUSE_AVAILABLE"
    for ADRIVER in $CFG_MOUSE_ON; do
        CFG_MOUSE_OFF=`echo "${CFG_MOUSE_OFF} " | sed "s,${ADRIVER} ,,g"`
    done

    for DRIVER in $CFG_GFX_OFF; do
        NODRIVER=`echo $DRIVER | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_QWS_$NODRIVER"
    done

    for DRIVER in $CFG_KBD_OFF; do
        NODRIVER=`echo $DRIVER | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_QWS_KBD_$NODRIVER"
    done

    for DRIVER in $CFG_MOUSE_OFF; do
        NODRIVER=`echo $DRIVER | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_QWS_MOUSE_$NODRIVER"
    done
fi # QWS

if [ "$PLATFORM_QPA" = "yes" ]; then
    # Add QPA to config.h
    QCONFIG_FLAGS="$QCONFIG_FLAGS Q_WS_QPA QT_NO_QWS_QPF QT_NO_QWS_QPF2"
fi

if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then
    QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_USE_MATH_H_FLOATS"
fi

# Add turned on SQL drivers
for DRIVER in $CFG_SQL_AVAILABLE; do
    eval "VAL=\$CFG_SQL_$DRIVER"
    case "$VAL" in
    qt)
        ONDRIVER=`echo $DRIVER | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_SQL_$ONDRIVER"
        SQL_DRIVERS="$SQL_DRIVERS $DRIVER"
    ;;
    plugin)
        SQL_PLUGINS="$SQL_PLUGINS $DRIVER"
    ;;
    esac
done


QMakeVar set sql-drivers "$SQL_DRIVERS"
QMakeVar set sql-plugins "$SQL_PLUGINS"

# Add other configuration options to the qconfig.h file
[ "$CFG_GIF" = "yes" ]       && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_BUILTIN_GIF_READER=1"
[ "$CFG_TIFF" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_TIFF"
[ "$CFG_PNG" != "yes" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_PNG"
[ "$CFG_JPEG" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_JPEG"
[ "$CFG_MNG" != "yes" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_MNG"
[ "$CFG_ZLIB" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ZLIB"
[ "$CFG_S60" != "yes" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_S60"
[ "$CFG_EXCEPTIONS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EXCEPTIONS"
[ "$CFG_IPV6" = "no" ]       && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IPV6"
[ "$CFG_SXE" = "no" ]        && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SXE"
[ "$CFG_DBUS" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DBUS"

if [ "$PLATFORM_QWS" != "yes" ]; then
    [ "$CFG_GRAPHICS_SYSTEM" = "raster" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_GRAPHICSSYSTEM_RASTER"
    [ "$CFG_GRAPHICS_SYSTEM" = "opengl" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_GRAPHICSSYSTEM_OPENGL"
    [ "$CFG_GRAPHICS_SYSTEM" = "openvg" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_GRAPHICSSYSTEM_OPENVG"
    [ "$CFG_GRAPHICS_SYSTEM" = "runtime" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_GRAPHICSSYSTEM_RUNTIME"
fi

# X11/Unix/Mac only configs
[ "$CFG_CUPS" = "no" ]       && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CUPS"
[ "$CFG_ICONV" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ICONV"
[ "$CFG_GLIB" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GLIB"
[ "$CFG_GSTREAMER" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GSTREAMER"
[ "$CFG_QGTKSTYLE" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_GTK"
[ "$CFG_CLOCK_MONOTONIC" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CLOCK_MONOTONIC"
[ "$CFG_MREMAP" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MREMAP"
[ "$CFG_GETADDRINFO" = "no" ]&& QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GETADDRINFO"
[ "$CFG_IPV6IFNAME" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IPV6IFNAME"
[ "$CFG_GETIFADDRS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GETIFADDRS"
[ "$CFG_INOTIFY" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_INOTIFY"
[ "$CFG_NAS" = "no" ]        && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_NAS"
[ "$CFG_NIS" = "no" ]        && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_NIS"
[ "$CFG_OPENSSL" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_OPENSSL"
[ "$CFG_OPENSSL" = "linked" ]&& QCONFIG_FLAGS="$QCONFIG_FLAGS QT_LINKED_OPENSSL"

[ "$CFG_SM" = "no" ]         && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SESSIONMANAGER"
[ "$CFG_XCURSOR" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XCURSOR"
[ "$CFG_XFIXES" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XFIXES"
[ "$CFG_FONTCONFIG" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_FONTCONFIG"
[ "$CFG_XINERAMA" = "no" ]   && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XINERAMA"
[ "$CFG_XKB" = "no" ]        && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XKB"
[ "$CFG_XRANDR" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XRANDR"
[ "$CFG_XRENDER" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XRENDER"
[ "$CFG_MITSHM" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MITSHM"
[ "$CFG_XSHAPE" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SHAPE"
[ "$CFG_XVIDEO" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XVIDEO"
[ "$CFG_XSYNC" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XSYNC"
[ "$CFG_XINPUT" = "no" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_XINPUT QT_NO_TABLET"

[ "$CFG_XCURSOR" = "runtime" ]   && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XCURSOR"
[ "$CFG_XINERAMA" = "runtime" ]  && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XINERAMA"
[ "$CFG_XFIXES" = "runtime" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XFIXES"
[ "$CFG_XRANDR" = "runtime" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XRANDR"
[ "$CFG_XINPUT" = "runtime" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_RUNTIME_XINPUT"
[ "$CFG_ALSA" = "no" ]           && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ALSA"
[ "$CFG_PULSEAUDIO" = "no" ]          && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_PULSEAUDIO"
[ "$CFG_COREWLAN" = "no" ]       && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_COREWLAN"
[ "$CFG_ICD" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ICD"

# sort QCONFIG_FLAGS for neatness if we can
[ '!' -z "$AWK" ] && QCONFIG_FLAGS=`echo $QCONFIG_FLAGS | $AWK '{ gsub(" ", "\n"); print }' | sort | uniq`
QCONFIG_FLAGS=`echo $QCONFIG_FLAGS`

if echo $XPLATFORM | grep symbian >/dev/null
then
    # Enable Symbian DLLs and export rules.
    # We cannot use Linux's default export rules since they export everything.
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_DLL"
    # Disable non-working features.
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CONCURRENT QT_NO_QFUTURE QT_NO_CRASHHANDLER QT_NO_PRINTER QT_NO_SYSTEMTRAYICON"
fi

if [ -n "$QCONFIG_FLAGS" ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#ifndef QT_BOOTSTRAPPED

EOF
    for cfg in $QCONFIG_FLAGS; do
        cfgd=`echo $cfg | sed 's/=.*$//'` # trim pushed 'Foo=Bar' defines
        cfg=`echo $cfg | sed 's/=/ /'`    # turn first '=' into a space
        # figure out define logic, so we can output the correct
        # ifdefs to override the global defines in a project
        cfgdNeg=
        if [ true ] && echo "$cfgd" | grep 'QT_NO_' >/dev/null 2>&1; then
            # QT_NO_option can be forcefully turned on by QT_option
            cfgdNeg=`echo $cfgd | sed "s,QT_NO_,QT_,"`
        elif [ true ] && echo "$cfgd" | grep 'QT_' >/dev/null 2>&1; then
            # QT_option can be forcefully turned off by QT_NO_option
            cfgdNeg=`echo $cfgd | sed "s,QT_,QT_NO_,"`
        fi

        if [ -z $cfgdNeg ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#ifndef $cfgd
# define $cfg
#endif

EOF
        else
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#if defined($cfgd) && defined($cfgdNeg)
# undef $cfgd
#elif !defined($cfgd) && !defined($cfgdNeg)
# define $cfg
#endif

EOF
        fi
    done
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#endif // QT_BOOTSTRAPPED

EOF
fi

if [ "$CFG_REDUCE_EXPORTS" = "yes" ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#define QT_VISIBILITY_AVAILABLE

EOF
fi

if [ -n "$QT_LIBINFIX" ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#define QT_LIBINFIX "$QT_LIBINFIX"

EOF
fi

if [ -n "$CFG_RUNTIME_SYSTEM" ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" << EOF
#define QT_DEFAULT_RUNTIME_SYSTEM "$CFG_RUNTIME_SYSTEM"

EOF
fi

# avoid unecessary rebuilds by copying only if qconfig.h has changed
if cmp -s "$outpath/src/corelib/global/qconfig.h" "$outpath/src/corelib/global/qconfig.h.new"; then
    rm -f "$outpath/src/corelib/global/qconfig.h.new"
else
    [ -f "$outpath/src/corelib/global/qconfig.h" ] && chmod +w "$outpath/src/corelib/global/qconfig.h"
    mv "$outpath/src/corelib/global/qconfig.h.new" "$outpath/src/corelib/global/qconfig.h"
    chmod -w "$outpath/src/corelib/global/qconfig.h"
    for conf in "$outpath/include/QtCore/qconfig.h" "$outpath/include/Qt/qconfig.h"; do
        if echo "$XPLATFORM" | grep "symbian-sbsv2" > /dev/null 2>&1 ; then
            [ -e "$conf" ] && rm -rf "$conf"
            cp -a "$outpath/src/corelib/global/qconfig.h" "$conf"
        elif [ '!' -f "$conf" ]; then
            ln -s "$outpath/src/corelib/global/qconfig.h" "$conf"
        fi
    done
fi
#-------------------------------------------------------------------------------
# save configuration into qconfig.pri
#-------------------------------------------------------------------------------

QTCONFIG="$outpath/mkspecs/qconfig.pri"
QTCONFIG_CONFIG="$QTCONFIG_CONFIG no_mocdepend"
[ -f "$QTCONFIG.tmp" ] && rm -f "$QTCONFIG.tmp"
if [ "$CFG_DEBUG" = "yes" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG debug"
    if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG release"
    fi
    QT_CONFIG="$QT_CONFIG debug"
elif [ "$CFG_DEBUG" = "no" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG release"
    if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
        QT_CONFIG="$QT_CONFIG debug"
    fi
    QT_CONFIG="$QT_CONFIG release"
fi
if [ "$CFG_STL" = "yes" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG stl"
fi
if [ "$CFG_FRAMEWORK" = "no" ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG qt_no_framework"
else
    QT_CONFIG="$QT_CONFIG qt_framework"
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG qt_framework"
fi
if [ "$PLATFORM_MAC" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG $CFG_MAC_ARCHS"
fi
if [ "$CFG_DEV" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG private_tests"
fi

# Make the application arch follow the Qt arch for single arch builds.
# (for multiple-arch builds, set CONFIG manually in the application .pro file)
if [ `echo "$CFG_MAC_ARCHS" | wc -w` -eq 1 ]; then
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG $CFG_MAC_ARCHS"
fi

cat >>"$QTCONFIG.tmp" <<EOF
#configuration
CONFIG += $QTCONFIG_CONFIG
QT_ARCH = $CFG_ARCH
QT_EDITION = $Edition
QT_CONFIG += $QT_CONFIG

#versioning
QT_VERSION = $QT_VERSION
QT_MAJOR_VERSION = $QT_MAJOR_VERSION
QT_MINOR_VERSION = $QT_MINOR_VERSION
QT_PATCH_VERSION = $QT_PATCH_VERSION

#namespaces
QT_LIBINFIX = $QT_LIBINFIX
QT_NAMESPACE = $QT_NAMESPACE
QT_NAMESPACE_MAC_CRC = $QT_NAMESPACE_MAC_CRC

EOF
if [ "$CFG_RPATH" = "yes" ]; then
    echo "QMAKE_RPATHDIR += \"$QT_INSTALL_LIBS\"" >> "$QTCONFIG.tmp"
fi
if [ -n "$QT_GCC_MAJOR_VERSION" ]; then
    echo "QT_GCC_MAJOR_VERSION = $QT_GCC_MAJOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_GCC_MINOR_VERSION = $QT_GCC_MINOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_GCC_PATCH_VERSION = $QT_GCC_PATCH_VERSION" >> "$QTCONFIG.tmp"
fi
if echo "$XPLATFORM" | grep "symbian-sbsv2" > /dev/null 2>&1; then
    echo "#Qt for symbian FPU settings" >> "$QTCONFIG.tmp"
    echo "MMP_RULES += \"ARMFPU softvfp\"" >> "$QTCONFIG.tmp"
fi
# replace qconfig.pri if it differs from the newly created temp file
if cmp -s "$QTCONFIG.tmp" "$QTCONFIG"; then
    rm -f "$QTCONFIG.tmp"
else
    mv -f "$QTCONFIG.tmp" "$QTCONFIG"
fi

#-------------------------------------------------------------------------------
# save configuration into .qmake.cache
#-------------------------------------------------------------------------------

CACHEFILE="$outpath/.qmake.cache"
[ -f "$CACHEFILE.tmp" ] && rm -f "$CACHEFILE.tmp"
cat >>"$CACHEFILE.tmp" <<EOF
CONFIG += $QMAKE_CONFIG dylib create_prl link_prl depend_includepath fix_output_dirs QTDIR_build
QT_SOURCE_TREE = \$\$quote($relpath)
QT_BUILD_TREE = \$\$quote($outpath)
QT_BUILD_PARTS = $CFG_BUILD_PARTS
QMAKE_ABSOLUTE_SOURCE_ROOT = \$\$QT_SOURCE_TREE
QMAKE_MOC_SRC    = \$\$QT_BUILD_TREE/src/moc

#local paths that cannot be queried from the QT_INSTALL_* properties while building QTDIR
QMAKE_MOC        = \$\$QT_BUILD_TREE/bin/moc
QMAKE_UIC        = \$\$QT_BUILD_TREE/bin/uic
QMAKE_UIC3       = \$\$QT_BUILD_TREE/bin/uic3
QMAKE_RCC        = \$\$QT_BUILD_TREE/bin/rcc
QMAKE_QDBUSXML2CPP = \$\$QT_BUILD_TREE/bin/qdbusxml2cpp
QMAKE_INCDIR_QT  = \$\$QT_BUILD_TREE/include
QMAKE_LIBDIR_QT  = \$\$QT_BUILD_TREE/lib

EOF

# Ensure we can link to uninistalled libraries
if [ "$XPLATFORM_MINGW" != "yes" ] && [ "$CFG_EMBEDDED" != "nacl" ] && linkerSupportsFlag -rpath-link "$outpath/lib"; then
    echo "QMAKE_LFLAGS    = -Wl,-rpath-link,\$\$QT_BUILD_TREE/lib \$\$QMAKE_LFLAGS" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_CFLAGS_PSQL" ]; then
    echo "QT_CFLAGS_PSQL   = $QT_CFLAGS_PSQL" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_PSQL" ]; then
    echo "QT_LFLAGS_PSQL   = $QT_LFLAGS_PSQL" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_CFLAGS_MYSQL" ]; then
    echo "QT_CFLAGS_MYSQL   = $QT_CFLAGS_MYSQL" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_MYSQL" ]; then
    echo "QT_LFLAGS_MYSQL   = $QT_LFLAGS_MYSQL" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_CFLAGS_SQLITE" ]; then
    echo "QT_CFLAGS_SQLITE   = $QT_CFLAGS_SQLITE" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_SQLITE" ]; then
    echo "QT_LFLAGS_SQLITE   = $QT_LFLAGS_SQLITE" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_ODBC" ]; then
    echo "QT_LFLAGS_ODBC   = $QT_LFLAGS_ODBC" >> "$CACHEFILE.tmp"
fi
if [ -n "$QT_LFLAGS_TDS" ]; then
    echo "QT_LFLAGS_TDS   = $QT_LFLAGS_TDS" >> "$CACHEFILE.tmp"
fi

if [ "$QT_EDITION" != "QT_EDITION_OPENSOURCE" ]; then
    echo "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" >> "$CACHEFILE.tmp"
fi

#dump in the OPENSSL_LIBS info
if [ '!' -z "$OPENSSL_LIBS" ]; then
    echo "OPENSSL_LIBS = $OPENSSL_LIBS" >> "$CACHEFILE.tmp"
elif [ "$CFG_OPENSSL" = "linked" ]; then
    echo "OPENSSL_LIBS = -lssl -lcrypto" >> "$CACHEFILE.tmp"
fi

#dump in the SDK info
if [ '!' -z "$CFG_SDK" ]; then
   echo "QMAKE_MAC_SDK = $CFG_SDK" >> "$CACHEFILE.tmp"
fi

# mac gcc -Xarch support
if [ "$CFG_MAC_XARCH" = "no" ]; then
   echo "QMAKE_MAC_XARCH = no" >> "$CACHEFILE.tmp"
fi

#dump the qmake spec
if [ -d "$outpath/mkspecs/$XPLATFORM" ]; then
   echo "QMAKESPEC = \$\$QT_BUILD_TREE/mkspecs/$XPLATFORM" >> "$CACHEFILE.tmp"
else
   echo "QMAKESPEC = $XPLATFORM" >> "$CACHEFILE.tmp"
fi

# cmdline args
cat "$QMAKE_VARS_FILE" >> "$CACHEFILE.tmp"
rm -f "$QMAKE_VARS_FILE" 2>/dev/null

# incrementals
INCREMENTAL=""
[ "$CFG_INCREMENTAL" = "auto" ] && "$WHICH" p4 >/dev/null 2>&1 && [ "$CFG_DEV" = "yes" ] && CFG_INCREMENTAL="yes"
if [ "$CFG_INCREMENTAL" = "yes" ]; then
    find "$relpath" -perm u+w -mtime -3 | grep 'cpp$' | while read f; do
        # don't need to worry about generated files
        [ -r `echo $f | sed "s,cpp$,ui,"` ] && continue
        basename "$f" | grep '^moc_' >/dev/null 2>&1 && continue
        # done
        INCREMENTAL="$INCREMENTAL `basename \"$f\" | sed 's,.cpp,.o,'`"
    done
    [ '!' -z "$INCREMENTAL" ] && echo "QMAKE_INCREMENTAL += $INCREMENTAL" >> "$CACHEFILE.tmp"
    [ -r "$outpath/.qmake.incremental" ] && echo "include($outpath/.qmake.incremental)" >> "$CACHEFILE.tmp"
fi

# replace .qmake.cache if it differs from the newly created temp file
if cmp -s "$CACHEFILE.tmp" "$CACHEFILE"; then
    rm -f "$CACHEFILE.tmp"
else
    mv -f "$CACHEFILE.tmp" "$CACHEFILE"
fi

#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------

case "$COMPILER" in
g++*)
    if [ "$CFG_EXCEPTIONS" != "no" ]; then
        cat <<EOF

        This target is using the GNU C++ compiler ($PLATFORM).

        Recent versions of this compiler automatically include code for
        exceptions, which increase both the size of the Qt libraries and
        the amount of memory taken by your applications.

        You may choose to re-run `basename $0` with the -no-exceptions
        option to compile Qt without exceptions. This is completely binary
        compatible, and existing applications will continue to work.

EOF
    fi
    ;;
cc*)
    case "$PLATFORM" in
    irix-cc*)
        if [ "$CFG_EXCEPTIONS" != "no" ]; then
            cat <<EOF

        This target is using the MIPSpro C++ compiler ($PLATFORM).

        You may choose to re-run `basename $0` with the -no-exceptions
        option to compile Qt without exceptions. This will make the
        size of the Qt library smaller and reduce the amount of memory
        taken by your applications.

EOF
        fi
        ;;
    *) ;;
    esac
    ;;
*) ;;
esac

if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_DWARF2" = "no" ]  && [ "$CFG_WEBKIT" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
    cat <<EOF
        WARNING: DWARF2 debug symbols are not enabled. Linking webkit
        in debug mode will run out of memory on systems with 2GB or less.
        Install Xcode 2.4.1 or higher to enable DWARF2, or configure with
         -no-webkit or -release to skip webkit debug.
EOF
fi

echo
if [ "$XPLATFORM" = "$PLATFORM" ]; then
    echo "Build type:    $PLATFORM"
else
    echo "Building on:   $PLATFORM"
    echo "Building for:  $XPLATFORM"
fi

if [ "$PLATFORM_MAC" = "yes" ]; then
    echo "Architecture:  $CFG_ARCH ($CFG_MAC_ARCHS )"
else
    echo "Architecture:  $CFG_ARCH"
fi

if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
    echo "Host architecture: $CFG_HOST_ARCH"
fi

if [ "$PLATFORM_MAC" = "yes" ]; then
    if [ "$CFG_MAC_COCOA" = "yes" ]; then
        if [ "$CFG_MAC_CARBON" = "yes" ]; then
            echo "Using framework: Carbon for 32-bit, Cocoa for 64-bit"
        else
            echo "Using framework: Cocoa"
        fi
    else
        echo "Using framework: Carbon"
    fi
fi

if [ -n "$PLATFORM_NOTES" ]; then
    echo "Platform notes:"
    echo "$PLATFORM_NOTES"
else
    echo
fi

if [ "$OPT_VERBOSE" = "yes" ]; then
    echo $ECHO_N "qmake vars .......... $ECHO_C"
    cat "$QMAKE_VARS_FILE" | tr '\n' ' '
    echo "qmake switches ......... $QMAKE_SWITCHES"
fi

[ "$CFG_INCREMENTAL" = "yes" ] && [ '!' -z "$INCREMENTAL" ] && echo "Incremental ............ $INCREMENTAL"
echo "Build .................. $CFG_BUILD_PARTS"
echo "Configuration .......... $QMAKE_CONFIG $QT_CONFIG"
if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
   echo "Debug .................. yes (combined)"
   if [ "$CFG_DEBUG" = "yes" ]; then
       echo "Default Link ........... debug"
   else
       echo "Default Link ........... release"
   fi
else
   echo "Debug .................. $CFG_DEBUG"
fi
echo "Qt 3 compatibility ..... $CFG_QT3SUPPORT"
[ "$CFG_DBUS" = "no" ]     && echo "QtDBus module .......... no"
[ "$CFG_DBUS" = "yes" ]    && echo "QtDBus module .......... yes (run-time)"
[ "$CFG_DBUS" = "linked" ] && echo "QtDBus module .......... yes (linked)"
echo "QtConcurrent code ...... $CFG_CONCURRENT"
echo "QtGui module ........... $CFG_GUI"
echo "QtScript module ........ $CFG_SCRIPT"
echo "QtScriptTools module ... $CFG_SCRIPTTOOLS"
echo "QtXmlPatterns module ... $CFG_XMLPATTERNS"
echo "Phonon module .......... $CFG_PHONON"
echo "Multimedia module ...... $CFG_MULTIMEDIA"
echo "SVG module ............. $CFG_SVG"
echo "WebKit module .......... $CFG_WEBKIT"
if [ "$CFG_WEBKIT" = "yes" ]; then 
    if [ "$CFG_JAVASCRIPTCORE_JIT" = "auto" ]; then
        echo "JavaScriptCore JIT ..... To be decided by JavaScriptCore"
    else
        echo "JavaScriptCore JIT ..... $CFG_JAVASCRIPTCORE_JIT"
    fi
fi
echo "Declarative module ..... $CFG_DECLARATIVE"
echo "Support for S60 ........ $CFG_S60"
echo "Symbian DEF files ...... $CFG_SYMBIAN_DEFFILES"
echo "STL support ............ $CFG_STL"
echo "PCH support ............ $CFG_PRECOMPILE"
echo "MMX/3DNOW/SSE/SSE2/SSE3. ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}/${CFG_SSE3}"
echo "SSSE3/SSE4.1/SSE4.2..... ${CFG_SSSE3}/${CFG_SSE4_1}/${CFG_SSE4_2}"
echo "AVX..................... ${CFG_AVX}"
if [ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ]; then
    echo "iWMMXt support ......... ${CFG_IWMMXT}"
    echo "NEON support ........... ${CFG_NEON}"
fi
[ "${PLATFORM_QWS}" != "yes" ] && echo "Graphics System ........ $CFG_GRAPHICS_SYSTEM"
echo "IPv6 support ........... $CFG_IPV6"
echo "IPv6 ifname support .... $CFG_IPV6IFNAME"
echo "getaddrinfo support .... $CFG_GETADDRINFO"
echo "getifaddrs support ..... $CFG_GETIFADDRS"
echo "Accessibility .......... $CFG_ACCESSIBILITY"
echo "NIS support ............ $CFG_NIS"
echo "CUPS support ........... $CFG_CUPS"
echo "Iconv support .......... $CFG_ICONV"
echo "Glib support ........... $CFG_GLIB"
echo "GStreamer support ...... $CFG_GSTREAMER"
echo "PulseAudio support ..... $CFG_PULSEAUDIO"
echo "Large File support ..... $CFG_LARGEFILE"
echo "GIF support ............ $CFG_GIF"
if [ "$CFG_TIFF" = "no" ]; then
    echo "TIFF support ........... $CFG_TIFF"
else
    echo "TIFF support ........... $CFG_TIFF ($CFG_LIBTIFF)"
fi
if [ "$CFG_JPEG" = "no" ]; then
    echo "JPEG support ........... $CFG_JPEG"
else
    echo "JPEG support ........... $CFG_JPEG ($CFG_LIBJPEG)"
fi
if [ "$CFG_PNG" = "no" ]; then
    echo "PNG support ............ $CFG_PNG"
else
    echo "PNG support ............ $CFG_PNG ($CFG_LIBPNG)"
fi
if [ "$CFG_MNG" = "no" ]; then
    echo "MNG support ............ $CFG_MNG"
else
    echo "MNG support ............ $CFG_MNG ($CFG_LIBMNG)"
fi
echo "zlib support ........... $CFG_ZLIB"
echo "Session management ..... $CFG_SM"
if [ "$PLATFORM_QWS" = "yes"  -o "$PLATFORM_QPA" = "yes" ]; then
    echo "Embedded support ....... $CFG_EMBEDDED"
    if [ "$CFG_QWS_FREETYPE" = "auto" ]; then
	echo "Freetype2 support ...... $CFG_QWS_FREETYPE ($CFG_LIBFREETYPE)"
    else
	echo "Freetype2 support ...... $CFG_QWS_FREETYPE"
    fi
    # Normalize the decoration output first
    CFG_GFX_ON=`echo ${CFG_GFX_ON}`
    CFG_GFX_PLUGIN=`echo ${CFG_GFX_PLUGIN}`
    echo "Graphics (qt) .......... ${CFG_GFX_ON}"
    echo "Graphics (plugin) ...... ${CFG_GFX_PLUGIN}"
    CFG_DECORATION_ON=`echo ${CFG_DECORATION_ON}`
    CFG_DECORATION_PLUGIN=`echo ${CFG_DECORATION_PLUGIN}`
    echo "Decorations (qt) ....... $CFG_DECORATION_ON"
    echo "Decorations (plugin) ... $CFG_DECORATION_PLUGIN"
    CFG_KBD_ON=`echo ${CFG_KBD_ON}`
    CFG_KBD_PLUGIN=`echo ${CFG_KBD_PLUGIN}`
    echo "Keyboard driver (qt) ... ${CFG_KBD_ON}"
    echo "Keyboard driver (plugin) .. ${CFG_KBD_PLUGIN}"
    CFG_MOUSE_ON=`echo ${CFG_MOUSE_ON}`
    CFG_MOUSE_PLUGIN=`echo ${CFG_MOUSE_PLUGIN}`
    echo "Mouse driver (qt) ...... $CFG_MOUSE_ON"
    echo "Mouse driver (plugin) .. $CFG_MOUSE_PLUGIN"
fi
if [ "$CFG_OPENGL" = "desktop" ]; then
    echo "OpenGL support ......... yes (Desktop OpenGL)"
elif [ "$CFG_OPENGL" = "es1" ]; then
    echo "OpenGL support ......... yes (OpenGL ES 1.x Common profile)"
elif [ "$CFG_OPENGL" = "es2" ]; then
    echo "OpenGL support ......... yes (OpenGL ES 2.x)"
else
    echo "OpenGL support ......... no"
fi
if [ "$CFG_EGL" != "no" ]; then
    if [ "$CFG_EGL_GLES_INCLUDES" != "no" ]; then
        echo "EGL support ............ yes <GLES/egl.h>"
    else
        echo "EGL support ............ yes <EGL/egl.h>"
    fi
fi
if [ "$CFG_OPENVG" ]; then
    if [ "$CFG_OPENVG_SHIVA" = "yes" ]; then
        echo "OpenVG support ......... ShivaVG"
    else
        echo "OpenVG support ......... $CFG_OPENVG"
    fi
fi
if [ "$PLATFORM_X11" = "yes" ]; then
    echo "NAS sound support ...... $CFG_NAS"
    echo "XShape support ......... $CFG_XSHAPE"
    echo "XVideo support ......... $CFG_XVIDEO"
    echo "XSync support .......... $CFG_XSYNC"
    echo "Xinerama support ....... $CFG_XINERAMA"
    echo "Xcursor support ........ $CFG_XCURSOR"
    echo "Xfixes support ......... $CFG_XFIXES"
    echo "Xrandr support ......... $CFG_XRANDR"
    echo "Xrender support ........ $CFG_XRENDER"
    echo "Xi support ............. $CFG_XINPUT"
    echo "MIT-SHM support ........ $CFG_MITSHM"
    echo "FontConfig support ..... $CFG_FONTCONFIG"
    echo "XKB Support ............ $CFG_XKB"
    echo "immodule support ....... $CFG_IM"
    echo "GTK theme support ...... $CFG_QGTKSTYLE"
fi
[ "$CFG_SQL_mysql" != "no" ] && echo "MySQL support .......... $CFG_SQL_mysql"
[ "$CFG_SQL_psql" != "no" ] && echo "PostgreSQL support ..... $CFG_SQL_psql"
[ "$CFG_SQL_odbc" != "no" ] && echo "ODBC support ........... $CFG_SQL_odbc"
[ "$CFG_SQL_oci" != "no" ] && echo "OCI support ............ $CFG_SQL_oci"
[ "$CFG_SQL_tds" != "no" ] && echo "TDS support ............ $CFG_SQL_tds"
[ "$CFG_SQL_db2" != "no" ] && echo "DB2 support ............ $CFG_SQL_db2"
[ "$CFG_SQL_ibase" != "no" ] && echo "InterBase support ...... $CFG_SQL_ibase"
[ "$CFG_SQL_sqlite2" != "no" ] && echo "SQLite 2 support ....... $CFG_SQL_sqlite2"
[ "$CFG_SQL_sqlite" != "no" ] && echo "SQLite support ......... $CFG_SQL_sqlite ($CFG_SQLITE)"

OPENSSL_LINKAGE=""
if [ "$CFG_OPENSSL" = "yes" ]; then
    OPENSSL_LINKAGE="(run-time)"
elif [ "$CFG_OPENSSL" = "linked" ]; then
    OPENSSL_LINKAGE="(linked)"
fi
echo "OpenSSL support ........ $CFG_OPENSSL $OPENSSL_LINKAGE"
echo "Alsa support ........... $CFG_ALSA"
if [ "$PLATFORM_MAC" = "yes" ]; then
    echo "CoreWlan support ....... $CFG_COREWLAN"
fi
echo "ICD support ............ $CFG_ICD"
echo

[ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........... $CFG_PTMALLOC"

# complain about not being able to use dynamic plugins if we are using a static build
if [ "$CFG_SHARED" = "no" ]; then
    echo
    echo "WARNING: Using static linking will disable the use of dynamically"
    echo "loaded plugins. Make sure to import all needed static plugins,"
    echo "or compile needed modules into the library."
    echo
fi
if [ "$CFG_OPENSSL" = "linked" ] && [ "$OPENSSL_LIBS" = "" ]; then
    echo
    echo "NOTE: When linking against OpenSSL, you can override the default"
    echo "library names through OPENSSL_LIBS."
    echo "For example:"
    echo "    OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked"
    echo
fi
if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "no" ]; then
    echo
    echo "Error: debug-only framework builds are not supported. Configure with -no-framework"
    echo "if you want a pure debug build."
    echo
    exit 1
fi

sepath=`echo "$relpath" | sed -e 's/\\./\\\\./g'`
PROCS=1
EXEC=""


#-------------------------------------------------------------------------------
# build makefiles based on the configuration
#-------------------------------------------------------------------------------

echo "Finding project files. Please wait..."
"$outpath/bin/qmake" -prl -r "${relpath}/projects.pro"
if [ -f "${relpath}/projects.pro" ]; then
    mkfile="${outpath}/Makefile"
    [ -f "$mkfile" ] && chmod +w "$mkfile"
    QTDIR="$outpath" "$outpath/bin/qmake" -spec "$XQMAKESPEC" "${relpath}/projects.pro" -o "$mkfile"
fi

# .projects      -> projects to process
# .projects.1    -> qt and moc
# .projects.2    -> subdirs and libs
# .projects.3    -> the rest
rm -f .projects .projects.1 .projects.2 .projects.3

QMAKE_PROJECTS=`find "$relpath/." -name '*.pro' -print | sed 's-/\./-/-'`
if [ -z "$AWK" ]; then
    for p in `echo $QMAKE_PROJECTS`; do
        echo "$p" >> .projects
    done
else
    cat >projects.awk <<EOF
BEGIN {
    files = 0
    target_file = ""
    input_file = ""

    first = "./.projects.1.tmp"
    second = "./.projects.2.tmp"
    third = "./.projects.3.tmp"
}

FNR == 1 {
    if ( input_file ) {
        if ( ! target_file )
            target_file = third
        print input_file >target_file
    }

    matched_target = 0
    template_lib = 0
    input_file = FILENAME
    target_file = ""
}

/^(TARGET.*=)/ {
    if ( \$3 == "moc" || \$3 ~ /^Qt/ ) {
        target_file = first
        matched_target = 1
    } else if ( \$3 == "lrelease" || \$3 == "qm_phony_target" ) {
        target_file = second
        matched_target = 1
    }
}

matched_target == 0 && /^(TEMPLATE.*=)/ {
    if ( \$3 == "subdirs" )
        target_file = second
    else if ( \$3 == "lib" )
        template_lib = 1
    else
        target_file = third
}

matched_target == 0 && template_lib == 1 && /^(CONFIG.*=)/ {
    if ( \$0 ~ /plugin/ )
        target_file = third
    else
        target_file = second
}

END {
    if ( input_file ) {
        if ( ! target_file )
            target_file = third
        print input_file >>target_file
    }
}

EOF

    rm -f .projects.all
    for p in `echo $QMAKE_PROJECTS`; do
       echo "$p" >> .projects.all
    done

    # if you get errors about the length of the command line to awk, change the -l arg
    # to split below
    split -l 100 .projects.all .projects.all.
    for p in .projects.all.*; do
       "$AWK" -f projects.awk `cat $p`
       [ -f .projects.1.tmp ] && cat .projects.1.tmp >> .projects.1
       [ -f .projects.2.tmp ] && cat .projects.2.tmp >> .projects.2
       [ -f .projects.3.tmp ] && cat .projects.3.tmp >> .projects.3
       rm -f .projects.1.tmp .projects.2.tmp .projects.3.tmp $p
    done
    rm -f .projects.all* projects.awk

    [ -f .projects.1 ] && cat .projects.1 >>.projects
    [ -f .projects.2 ] && cat .projects.2 >>.projects
    rm -f .projects.1 .projects.2
    if [ -f .projects.3 ] && [ "$OPT_FAST" = "no" ]; then
       cat .projects.3 >>.projects
       rm -f .projects.3
    fi
fi
# don't sort Qt and MOC in with the other project files
# also work around a segfaulting uniq(1)
if [ -f .sorted.projects.2 ]; then
    sort .sorted.projects.2 > .sorted.projects.2.new
    mv -f .sorted.projects.2.new .sorted.projects.2
    cat .sorted.projects.2 >> .sorted.projects.1
fi
[ -f .sorted.projects.1 ] && sort .sorted.projects.1 >> .sorted.projects
rm -f .sorted.projects.2 .sorted.projects.1

NORM_PROJECTS=0
FAST_PROJECTS=0
if [ -f .projects ]; then
   uniq .projects >.tmp
   mv -f .tmp .projects
   NORM_PROJECTS=`cat .projects | wc -l | sed -e "s, ,,g"`
fi
if [ -f .projects.3 ]; then
   uniq .projects.3 >.tmp
   mv -f .tmp .projects.3
   FAST_PROJECTS=`cat .projects.3 | wc -l | sed -e "s, ,,g"`
fi
echo "  `expr $NORM_PROJECTS + $FAST_PROJECTS` projects found."
echo

PART_ROOTS=
for part in $CFG_BUILD_PARTS; do
    case "$part" in
    tools) PART_ROOTS="$PART_ROOTS tools" ;;
    libs) PART_ROOTS="$PART_ROOTS src" ;;
    translations) PART_ROOTS="$PART_ROOTS tools/linguist/lrelease translations" ;;
    examples) PART_ROOTS="$PART_ROOTS examples demos" ;;
    *) ;;
    esac
done

if [ "$CFG_DEV" = "yes" ]; then
    PART_ROOTS="$PART_ROOTS tests"
fi

echo "Creating makefiles. Please wait..."
for file in .projects .projects.3; do
    [ '!' -f "$file" ] && continue
    for a in `cat $file`; do
        IN_ROOT=no
	for r in $PART_ROOTS; do
	    if echo "$a" | grep "^$r" >/dev/null 2>&1 || echo "$a" | grep "^$relpath/$r" >/dev/null 2>&1; then
		IN_ROOT=yes
		break
            fi
	done
        [ "$IN_ROOT" = "no" ] && continue

        case $a in
        *winmain/winmain.pro)
            [ "$XPLATFORM_MINGW" = "yes" ] || continue
            SPEC=$XQMAKESPEC ;;
        *s60main/s60main.pro) if [ -z "`echo "$XPLATFORM" | grep "symbian" >/dev/null`" ]; then
                continue
            fi;;
        *examples/activeqt/*) continue ;;
        */qmake/qmake.pro) continue ;;
        *tools/bootstrap*|*tools/moc*|*tools/rcc*|*tools/uic*|*linguist/lrelease*) SPEC=$QMAKESPEC ;;
        *) SPEC=$XQMAKESPEC ;;
        esac
        dir=`dirname "$a" | sed -e "s;$sepath;.;g"`
        test -d "$dir" || mkdir -p "$dir"
        OUTDIR="$outpath/$dir"
        if [ -f "${OUTDIR}/Makefile" ] && [ "$OPT_FAST" = "yes" ]; then
            # fast configure - the makefile exists, skip it
            # since the makefile exists, it was generated by qmake, which means we
            # can skip it, since qmake has a rule to regenerate the makefile if the .pro
            # file changes...
            [ "$OPT_VERBOSE" = "yes" ] && echo "  skipping $a"
            continue;
        fi
        QMAKE_SPEC_ARGS="-spec $SPEC"
        echo $ECHO_N "  for $a$ECHO_C"

        QMAKE="$outpath/bin/qmake"
	QMAKE_ARGS="$QMAKE_SWITCHES $QMAKE_SPEC_ARGS"
        if [ "$file" = ".projects.3" ]; then
            echo " (fast)"

            cat >"${OUTDIR}/Makefile" <<EOF
# ${OUTDIR}/Makefile: generated by configure
#
# WARNING: This makefile will be replaced with a real makefile.
# All changes made to this file will be lost.
EOF
            [ "$CFG_DEBUG_RELEASE" = "no" ] && echo "first_target: first" >>${OUTDIR}/Makefile

            cat >>"${OUTDIR}/Makefile" <<EOF
QMAKE = "$QMAKE"
all clean install qmake first Makefile: FORCE
	\$(QMAKE) $QMAKE_ARGS -o "$OUTDIR" "$a"
	cd "$OUTDIR"
	\$(MAKE) \$@

FORCE:

EOF
        else
            if [ "$OPT_VERBOSE" = "yes" ]; then
                echo " (`basename $SPEC`)"
                echo "$QMAKE" $QMAKE_ARGS -o "$OUTDIR" "$a"
	    else
		echo
            fi

            [ -f "${OUTDIR}/Makefile" ] && chmod +w "${OUTDIR}/Makefile"
            QTDIR="$outpath" "$QMAKE" $QMAKE_ARGS -o "$OUTDIR" "$a"
       fi
    done
done
rm -f .projects .projects.3

#-------------------------------------------------------------------------------
# check for platforms that we don't yet know about
#-------------------------------------------------------------------------------
if [ "$CFG_ARCH" = "generic" ]; then
cat <<EOF

        NOTICE: Atomic operations are not yet supported for this
        architecture.

        Qt will use the 'generic' architecture instead, which uses a
        single pthread_mutex_t to protect all atomic operations. This
        implementation is the slow (but safe) fallback implementation
        for architectures Qt does not yet support.
EOF
fi

#-------------------------------------------------------------------------------
# check if the user passed the -no-zlib option, which is no longer supported
#-------------------------------------------------------------------------------
if [ -n "$ZLIB_FORCED" ]; then
    which_zlib="supplied"
    if [ "$CFG_ZLIB" = "system" ]; then
	which_zlib="system"
    fi

cat <<EOF

        NOTICE: The -no-zlib option was supplied but is no longer
        supported.

        Qt now requires zlib support in all builds, so the -no-zlib
        option was ignored. Qt will be built using the $which_zlib
        zlib.
EOF
fi

#-------------------------------------------------------------------------------
# finally save the executed command to another script
#-------------------------------------------------------------------------------
if [ `basename $0` != "config.status" ]; then
    CONFIG_STATUS="$relpath/$relconf $OPT_CMDLINE"

    # add the system variables
    for varname in $SYSTEM_VARIABLES; do
        cmd=`echo \
'if [ -n "\$'${varname}'" ]; then
    CONFIG_STATUS="'${varname}'='"'\\\$${varname}'"' \$CONFIG_STATUS"
fi'`
	eval "$cmd"
    done

    echo "$CONFIG_STATUS" | grep '\-confirm\-license' >/dev/null 2>&1 || CONFIG_STATUS="$CONFIG_STATUS -confirm-license"

    [ -f "$outpath/config.status" ] && rm -f "$outpath/config.status"
    echo "#!/bin/sh" > "$outpath/config.status"
    echo "if [ \"\$#\" -gt 0 ]; then" >> "$outpath/config.status"
    echo "  $CONFIG_STATUS \"\$@\"" >> "$outpath/config.status"
    echo "else" >> "$outpath/config.status"
    echo "  $CONFIG_STATUS" >> "$outpath/config.status"
    echo "fi" >> "$outpath/config.status"
    chmod +x "$outpath/config.status"
fi

if [ -n "$RPATH_MESSAGE" ]; then
    echo
    echo "$RPATH_MESSAGE"
fi

MAKE=`basename "$MAKE"`
echo
echo Qt is now configured for building. Just run \'$MAKE\'.
if [ "$relpath" = "$QT_INSTALL_PREFIX" ]; then
    echo Once everything is built, Qt is installed.
    echo You should not run \'$MAKE install\'.
else
    echo Once everything is built, you must run \'$MAKE install\'.
    echo Qt will be installed into $QT_INSTALL_PREFIX
fi
echo
echo To reconfigure, run \'$MAKE confclean\' and \'configure\'.
echo