summaryrefslogtreecommitdiff
path: root/configure
blob: 75b160435fb26ff1f2487a97c2889a8149ee44a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
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
#!/bin/sh
#############################################################################
##
## Copyright (C) 2015 The Qt Company Ltd.
## Copyright (C) 2013 Intel Corporation.
## Contact: http://www.qt.io/licensing/
##
## This file is the build configuration utility of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:LGPL21$
## Commercial License Usage
## Licensees holding valid commercial Qt licenses may use this file in
## accordance with the commercial license agreement provided with the
## Software or, alternatively, in accordance with the terms contained in
## a written agreement between you and The Qt Company. For licensing terms
## and conditions see http://www.qt.io/terms-conditions. For further
## information use the contact form at http://www.qt.io/contact-us.
##
## 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 or version 3 as published by the Free
## Software Foundation and appearing in the file LICENSE.LGPLv21 and
## LICENSE.LGPLv3 included in the packaging of this file. Please review the
## following information to ensure the GNU Lesser General Public License
## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## As a special exception, The Qt Company gives you certain additional
## rights. These rights are described in The Qt Company LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
## $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`

# where to find which..
unixtests="$relpath/config.tests/unix"
mactests="$relpath/config.tests/mac"
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 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

# do this early so we don't store it in config.status
CFG_TOPLEVEL=
if [ x"$1" = x"-top-level" ]; then
    CFG_TOPLEVEL=yes
    shift
fi

# later cache the command line in config.status
OPT_CMDLINE=
for i in "$@"; do
    if [ "x$i" != "x-v" ]; then
        [ -z "${i##* *}" ] && i="'$i'"
        OPT_CMDLINE="$OPT_CMDLINE $i"
    fi
done

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

:> "$QMAKE_VARS_FILE"
:> "$DEVICE_VARS_FILE"

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

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

shellQuoteLines()
{
    # The call of the outer echo makes the shell word-split the output of
    # the nested pipe, thus effectively converting newlines to spaces.
    echo `echo "$1" | sed 's,^[^ ]* .*$,"&",'`
}

makeabs()
{
    local FILE=$1
    local RES=$FILE
    if [ -z "${FILE##/*}" ]; then
        true
    elif [ "$OSTYPE" = "msys" -a -z "${FILE##[a-zA-Z]:[/\\]*}" ]; then
        true
    else
        RES=$PWD/$FILE
    fi
    RES=$RES/
    while true; do
        nres=`echo "$RES" | sed 's,/[^/][^/]*/\.\./,/,g; s,/\./,/,g'`
        test x"$nres" = x"$RES" && break
        RES=$nres
    done
    echo "$RES" | sed 's,//,/,g; s,/$,,'
}

# 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"
}

shellArgumentListToQMakeListHelper()
{
    local retval
    for arg in "$@"; do retval="$retval \"$arg\""; done
    echo "$retval"
}

# Convert a string usable on a shell command line into word-by-word quoted
# qmake list.
shellArgumentListToQMakeList()
{
    # eval is needed for the shell to interpret the backslash escape sequences
    eval shellArgumentListToQMakeListHelper "$@"
}

# Helper function for getQMakeConf. It parses include statements in
# qmake.conf and prints out the expanded file
expandQMakeConf()
{
    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
            expandQMakeConf "$conf_file"
        ;;
        *load\(device_config\)*)
            conf_file="$DEVICE_VARS_FILE"
            if [ ! -f  "$conf_file" ]; then
                echo "WARNING: Unable to find file $conf_file" >&2
                continue
            fi
            expandQMakeConf "$conf_file"
        ;;
        *)
            echo "$line"
        ;;
    esac; done < "$1"
}

extractQMakeVariables()
{
    LC_ALL=C $AWK '
BEGIN {
    values["LITERAL_WHITESPACE"] = " "
    values["LITERAL_DOLLAR"] = "$"
}
/^!?host_build:/ {
    scopeStart = index($0, ":") + 1
    condition = substr($0, 0, scopeStart - 2)
    if (condition != "'"$1"'") { next }
    $0 = substr($0, scopeStart)
}
/^[_A-Z0-9.]+[ \t]*\+?=/ {
    valStart = index($0, "=") + 1

    append = 0
    if (substr($0, valStart - 2, 1) == "+") {
        append = 1
    }

    variable = substr($0, 0, valStart - 2 - append)
    value = substr($0, valStart)
    gsub("[ \t]+", "", variable)
    gsub("^[ \t]+", "", value)
    gsub("[ \t]+$", "", value)

    ovalue = ""
    while (match(value, /\$\$(\([_A-Z0-9.]+\)|\{[_A-Z0-9.]+\}|[_A-Z0-9.]+)/)) {
        ovalue = ovalue substr(value, 1, RSTART - 1)
        var = substr(value, RSTART + 2, RLENGTH - 2)
        value = substr(value, RSTART + RLENGTH)
        if (var ~ /^\(/) {
            var = substr(var, 2, length(var) - 2)
            ovalue = ovalue ENVIRON[var]
            continue
        }
        if (var ~ /^\{/) {
            var = substr(var, 2, length(var) - 2)
        }
        ovalue = ovalue values[var]
    }
    value = ovalue value

    ovalue = ""
    while (match(value, /\$\$system\(("[^"]*"|[^)]*)\)/)) {
        ovalue = ovalue substr(value, 1, RSTART - 1)
        cmd = substr(value, RSTART + 9, RLENGTH - 10)
        gsub(/^"|"$/, "", cmd)
        value = substr(value, RSTART + RLENGTH)
        while ((cmd | getline line) > 0) {
            ovalue = ovalue line
        }
        close(cmd)
    }
    value = ovalue value

    combinedValue = values[variable]
    if (append == 1 && length(combinedValue) > 0) {
        combinedValue = combinedValue " " value
    } else {
        combinedValue = value
    }
    values[variable] = combinedValue
}
END {
    for (var in values) {
        print var "=" values[var]
    }
}
'
}

getSingleQMakeVariable()
{
    echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }"
}

macSDKify()
{
    # Normally we take care of sysrootifying in sdk.prf, but configure extracts some
    # values before qmake is even built, so we have to duplicate the logic here.

    sdk=$(getSingleQMakeVariable "QMAKE_MAC_SDK" "$1")
    if [ -z "$sdk" ]; then echo "QMAKE_MAC_SDK must be set when building on Mac" >&2; exit 1; fi
    sysroot=$(/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null)
    if [ -z "$sysroot" ]; then echo "Failed to resolve SDK path for '$sdk'" >&2; exit 1; fi

    case "$sdk" in
        macosx*)
            version_min_flag="-mmacosx-version-min=$(getSingleQMakeVariable QMAKE_MACOSX_DEPLOYMENT_TARGET "$1")"
        ;;
        iphoneos*)
            version_min_flag="-miphoneos-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
        ;;
        iphonesimulator*)
            version_min_flag="-mios-simulator-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
        ;;
        *)
        ;;
    esac

    echo "$1" | while read line; do
        case "$line" in
            QMAKE_CC=*|QMAKE_CXX=*|QMAKE_FIX_RPATH=*|QMAKE_AR=*|QMAKE_RANLIB=*|QMAKE_LINK=*|QMAKE_LINK_SHLIB=*)
                # Prefix tool with toolchain path
                var=$(echo "$line" | cut -d '=' -f 1)
                val=$(echo "$line" | cut -d '=' -f 2-)
                sdk_val=$(/usr/bin/xcrun -sdk $sdk -find $(echo $val | cut -d ' ' -f 1))
                val=$(echo $sdk_val $(echo $val | cut -s -d ' ' -f 2-))
                echo "$var=$val"
            ;;
            QMAKE_CFLAGS=*|QMAKE_CXXFLAGS=*|QMAKE_OBJECTIVE_CFLAGS=*)
                echo "$line -isysroot $sysroot $version_min_flag"
            ;;
            QMAKE_LFLAGS=*)
                echo "$line -Wl,-syslibroot,$sysroot $version_min_flag"
            ;;
            *)
                echo "$line"
            ;;
        esac
    done
}

# relies on $QMAKESPEC being set correctly. parses include statements in
# qmake.conf and prints out the expanded file
getQMakeConf()
{
    if [ -z "$specvals" ]; then
        specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" | extractQMakeVariables "host_build"`
        if [ "$BUILD_ON_MAC" = "yes" ]; then specvals=$(macSDKify "$specvals"); fi
    fi
    getSingleQMakeVariable "$1" "$specvals"
}

getXQMakeConf()
{
    if [ -z "$xspecvals" ]; then
        xspecvals=`expandQMakeConf "$XQMAKESPEC/qmake.conf" | extractQMakeVariables "!host_build"`
        if [ "$XPLATFORM_MAC" = "yes" ]; then xspecvals=$(macSDKify "$xspecvals"); fi
    fi
    getSingleQMakeVariable "$1" "$xspecvals"
}

compilerSupportsFlag()
{
    cat >conftest.cpp <<EOF
int main() { return 0; }
EOF
    if [ "$OPT_VERBOSE" = "yes" ]; then
        "$@" -o conftest-out conftest.cpp
    else
        "$@" -o conftest-out conftest.cpp >/dev/null 2>&1
    fi
    ret=$?
    rm -f conftest.cpp conftest-out
    return $ret
}

linkerSupportsFlag()
{
    compiler=$1
    shift
    lflags=-Wl
    for flag
    do
	safe_flag=`shellEscape "$flag"`
	lflags=$lflags,$safe_flag
    done
    if [ $CFG_USE_GOLD_LINKER = yes ]; then
        lflags="-fuse-ld=gold $lflags"
    fi
    compilerSupportsFlag $compiler $lflags
}

# $1: newline-separated list of default paths
# stdin: input path
# stdout: input path or nothing
filterDefaultPaths()
{
    local path
    path=`cat`
    path=`makeabs "$path"`
    echo "$1" | grep "^$path\$" > /dev/null || echo "$path"
}

filterIncludePath()
{
    filterDefaultPaths "$DEFAULT_INCDIRS"
}

filterLibraryPath()
{
    filterDefaultPaths "$DEFAULT_LIBDIRS"
}

filterPathOptionsHelper()
{
    local flag defpaths sep p path
    flag=$1; shift
    defpaths=$1; shift
    sep=
    for p in "$@"; do
        path=${p#$flag}
        if [ "x$path" != "x$p" ]; then
            path=`echo "$path" | filterDefaultPaths "$defpaths"`
            test -z "$path" && continue
        fi
        # Re-quote for shell & qmake
        p=`echo "$p" | sed 's,[^ ]* .*,"&",g'`
        printf "%s%s" "$sep" "$p"
        sep=" "
    done
    echo
}

# $1: flag
# $2: newline-separated list of default paths
# stdin: list of command line options
# sdout: stdin without the options naming default paths
filterPathOptions()
{
    # The eval does escape interpretation for us
    eval filterPathOptionsHelper $1 "\"$2\"" "`cat`"
}

filterIncludeOptions()
{
    filterPathOptions -I "$DEFAULT_INCDIRS"
}

filterLibraryOptions()
{
    filterPathOptions -L "$DEFAULT_LIBDIRS"
}

#-------------------------------------------------------------------------------
# device options
#-------------------------------------------------------------------------------
DeviceVar()
{
    case "$1" in
        set)
            eq="="
            ;;
        *)
            echo >&2 "BUG: wrong command to QMakeVar: $1"
            ;;
    esac

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

resolveDeviceMkspec()
{
    result=$(find "$relpath/mkspecs/devices/" -type d -name "*$1*" | sed "s,^$relpath/mkspecs/,,")
    match_count=$(echo "$result" | wc -w)
    if [ "$match_count" -gt 1 ]; then
        echo >&2 "Error: Multiple matches for device '$1'. Candidates are:"
        tabbed_result=$(echo "$result" | sed 's,^,    ,')
        echo >&2 "$tabbed_result"
        echo "undefined"
    elif [ "$match_count" -eq 0 ]; then
        echo >&2 "Error: No device matching '$1'"
        echo "undefined"
    else
        echo "$result"
    fi
}

#-------------------------------------------------------------------------------
# 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
#-------------------------------------------------------------------------------

BUILD_ON_MAC=no
if [ -d /System/Library/Frameworks/Carbon.framework ]; then
    BUILD_ON_MAC=yes
fi
BUILD_ON_MSYS=no
HOST_DIRLIST_SEP=":"
DEV_NULL=/dev/null
if [ "$OSTYPE" = "msys" ]; then
    HOST_DIRLIST_SEP=";"
    BUILD_ON_MSYS=yes
    DEV_NULL=/tmp/empty-file
    echo "" > $DEV_NULL
    relpath=`(cd "$relpath"; pwd -W)`
    outpath=`pwd -W`
fi

#-------------------------------------------------------------------------------
# Verify Xcode installation on Mac OS
#-------------------------------------------------------------------------------

if [ "$BUILD_ON_MAC" = "yes" ]; then
    if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
        echo >&2
        echo "   No Xcode is selected. Use xcode-select -switch to choose an Xcode" >&2
        echo "   version. See the xcode-select man page for more information." >&2
        echo >&2
        exit 2
    fi

    if ! /usr/bin/xcrun -find xcrun >/dev/null 2>&1; then
        echo >&2
        echo "   Xcode not set up properly. You may need to confirm the license" >&2
        echo "   agreement by running /usr/bin/xcodebuild without arguments." >&2
        echo >&2
        exit 2
    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

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

SYSTEM_VARIABLES="AR RANLIB STRIP OBJDUMP LD CC CXX CFLAGS CXXFLAGS LDFLAGS"
for varname in $SYSTEM_VARIABLES; do
    qmakevarname="${varname}"
    qmakecmdargs=""
    # use LDFLAGS for autoconf compat, but qmake uses QMAKE_LFLAGS
    if [ "${varname}" = "LDFLAGS" ]; then
        qmakevarname="LFLAGS"
    elif [ "${varname}" = "LD" ]; then
        qmakevarname="LINK"
    elif [ "${varname}" = "AR" ]; then
        # QMAKE_AR needs to be set to "/path/to/ar cqs" but the
        # environment variable will be set to the command only so we
        # need to append " cqs" for autoconf compatibility
        qmakecmdargs=" cqs"
    fi
    cmd=`echo \
'if [ -n "\$'${varname}'" ]; then
    QMakeVar set QMAKE_'${qmakevarname}' "\$'${varname}${qmakecmdargs}'"
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 "mac fusion windows"

# 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=1.2

# initalize internal variables
CFG_CONFIGURE_EXIT_ON_ERROR=yes
CFG_PROFILE=no
CFG_STRIP=yes
CFG_GUI=auto # (yes|no|auto)
CFG_WIDGETS=yes
CFG_QCONFIG=full
CFG_DEBUG=auto
CFG_MYSQL_CONFIG=
CFG_PSQL_CONFIG=
CFG_DEBUG_RELEASE=no
CFG_FORCEDEBUGINFO=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_MTDEV=auto
CFG_JOURNALD=no
CFG_SYSLOG=no
CFG_SQLITE=qt
CFG_GIF=auto
CFG_PNG=yes
CFG_LIBPNG=auto
CFG_JPEG=auto
CFG_LIBJPEG=auto
CFG_XCURSOR=runtime
CFG_XRANDR=runtime
CFG_XRENDER=auto
CFG_MITSHM=auto
CFG_OPENGL=auto
CFG_OPENVG=auto
CFG_OPENVG_LC_INCLUDES=no
CFG_OPENVG_SHIVA=auto
CFG_OPENVG_ON_OPENGL=auto
CFG_EGL=auto
CFG_EGL_X=auto
CFG_FORCE_EGL_X=no
CFG_FONTCONFIG=auto
CFG_FREETYPE=auto
CFG_HARFBUZZ=qt
CFG_SQL_AVAILABLE=
QT_ALL_BUILD_PARTS=" libs tools examples tests "
QT_DEFAULT_BUILD_PARTS="libs tools examples"
CFG_BUILD_PARTS=""
CFG_NOBUILD_PARTS=""
CFG_SKIP_MODULES=""
CFG_COMPILE_EXAMPLES=yes
CFG_RELEASE_QMAKE=no
CFG_AUDIO_BACKEND=auto
CFG_QML_DEBUG=yes
CFG_PKGCONFIG=auto
CFG_STACK_PROTECTOR_STRONG=auto
CFG_SLOG2=auto
CFG_PPS=auto
CFG_QNX_IMF=auto
CFG_LGMON=auto
CFG_SYSTEM_PROXIES=no
CFG_ANDROID_STYLE_ASSETS=yes
CFG_GSTREAMER=auto
CFG_GSTREAMER_VERSION=""

# Target architecture
CFG_ARCH=
CFG_CPUFEATURES=
# Host architecture, same as CFG_ARCH when not cross-compiling
CFG_HOST_ARCH=
CFG_HOST_CPUFEATURES=
# Set when the -arch or -host-arch arguments are used
OPT_OBSOLETE_HOST_ARG=no

CFG_USE_GNUMAKE=no
CFG_XINPUT2=auto
CFG_XINPUT=runtime
CFG_XKB=auto
CFG_XKBCOMMON=yes
CFG_XKBCOMMON_EVDEV=auto
CFG_XKB_CONFIG_ROOT=auto
CFG_XCB=auto
CFG_XCB_XLIB=auto
CFG_XCB_GLX=no
CFG_EGLFS=auto
CFG_EGLFS_BRCM=no
CFG_EGLFS_MALI=no
CFG_EGLFS_VIV=no
CFG_DIRECTFB=auto
CFG_LINUXFB=auto
CFG_KMS=auto
CFG_MIRCLIENT=auto
CFG_LIBUDEV=auto
CFG_LIBINPUT=auto
CFG_OBSOLETE_WAYLAND=no
CFG_EVDEV=auto
CFG_TSLIB=auto
CFG_NIS=auto
CFG_CUPS=auto
CFG_ICONV=auto
CFG_DBUS=auto
CFG_GLIB=auto
CFG_QGTKSTYLE=auto
CFG_LARGEFILE=auto
CFG_OPENSSL=auto
CFG_LIBPROXY=auto
CFG_SECURETRANSPORT=auto
CFG_PRECOMPILE=auto
CFG_SEPARATE_DEBUG_INFO=no
CFG_REDUCE_EXPORTS=auto
CFG_SSE2=auto
CFG_SSE3=auto
CFG_SSSE3=auto
CFG_SSE4_1=auto
CFG_SSE4_2=auto
CFG_AVX=auto
CFG_AVX2=auto
CFG_REDUCE_RELOCATIONS=auto
CFG_ACCESSIBILITY=auto
CFG_ACCESSIBILITY_ATSPI_BRIDGE=no # will be enabled depending on dbus and accessibility being enabled
CFG_NEON=auto
CFG_MIPS_DSP=auto
CFG_MIPS_DSPR2=auto
CFG_CLOCK_GETTIME=auto
CFG_CLOCK_MONOTONIC=auto
CFG_POSIX_FALLOCATE=auto
CFG_MREMAP=auto
CFG_GETADDRINFO=auto
CFG_IPV6IFNAME=auto
CFG_GETIFADDRS=auto
CFG_INOTIFY=auto
CFG_EVENTFD=auto
CFG_CLOEXEC=no
CFG_RPATH=yes
CFG_FRAMEWORK=auto
CFG_USE_GOLD_LINKER=auto
CFG_ENABLE_NEW_DTAGS=auto
DEFINES=
INCLUDES=
D_FLAGS=
I_FLAGS=
L_FLAGS=
RPATH_FLAGS=
W_FLAGS=
QCONFIG_FLAGS=
XPLATFORM=              # This seems to be the QMAKESPEC, like "linux-g++"
XPLATFORM_MAC=no        # Whether target platform is OS X or iOS
XPLATFORM_IOS=no        # Whether target platform is iOS
XPLATFORM_ANDROID=no
XPLATFORM_MINGW=no      # Whether target platform is MinGW (win32-g++*)
XPLATFORM_QNX=no
XPLATFORM_HAIKU=no
XPLATFORM_TIZEN=no
PLATFORM=$QMAKESPEC
QT_CROSS_COMPILE=no
OPT_CONFIRM_LICENSE=no
OPT_SHADOW=maybe
OPT_VERBOSE=no
OPT_HELP=
CFG_SILENT=no
CFG_ALSA=auto
CFG_PULSEAUDIO=auto
CFG_COREWLAN=auto
CFG_ICU=auto
CFG_FORCE_ASSERTS=no
CFG_SANITIZERS=none
CFG_SANITIZE_ADDRESS=no
CFG_SANITIZE_THREAD=no
CFG_SANITIZE_MEMORY=no
CFG_SANITIZE_UNDEFINED=no
CFG_PCRE=auto
QPA_PLATFORM_GUARD=yes
CFG_CXX11=auto
CFG_DIRECTWRITE=no
CFG_WERROR=auto
CFG_HEADERSCLEAN=auto
CFG_QREAL=double
OPT_MAC_SDK=
COMMERCIAL_USER=ask
LICENSE_FILE=
CFG_DEV=no

# initalize variables used for installation
QT_INSTALL_PREFIX=
QT_INSTALL_DOCS=
QT_INSTALL_HEADERS=
QT_INSTALL_LIBS=
QT_INSTALL_BINS=
QT_INSTALL_LIBEXECS=
QT_INSTALL_PLUGINS=
QT_INSTALL_IMPORTS=
QT_INSTALL_QML=
QT_INSTALL_ARCHDATA=
QT_INSTALL_DATA=
QT_INSTALL_TRANSLATIONS=
QT_INSTALL_SETTINGS=
QT_INSTALL_EXAMPLES=
QT_INSTALL_TESTS=
CFG_SYSROOT=
CFG_GCC_SYSROOT="yes"
QT_HOST_PREFIX=
QT_HOST_BINS=
QT_HOST_LIBS=
QT_HOST_DATA=
QT_EXT_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=

# default qpa platform
QT_QPA_DEFAULT_PLATFORM=

# Android vars
CFG_DEFAULT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT
CFG_DEFAULT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT
CFG_DEFAULT_ANDROID_PLATFORM=android-9
CFG_DEFAULT_ANDROID_TARGET_ARCH=armeabi-v7a
CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION=4.9
CFG_DEFAULT_ANDROID_NDK_HOST=$ANDROID_NDK_HOST

#-------------------------------------------------------------------------------
# check SQL drivers 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_IMAGEFORMAT_PLUGIN_AVAILABLE=
if [ -d "$relpath/src/plugins/imageformats" ]; then
    for a in "$relpath/src/plugins/imageformats/"*; do
        if [ -d "$a" ]; then
            base_a=`basename "$a"`
            CFG_IMAGEFORMAT_PLUGIN_AVAILABLE="${CFG_IMAGEFORMAT_PLUGIN_AVAILABLE} ${base_a}"
        fi
    done
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 options that pass an argument
    -prefix| \
    -docdir| \
    -headerdir| \
    -plugindir| \
    -importdir| \
    -qmldir| \
    -archdatadir| \
    -datadir| \
    -libdir| \
    -bindir| \
    -libexecdir| \
    -translationdir| \
    -sysconfdir| \
    -examplesdir| \
    -testsdir| \
    -hostdatadir| \
    -hostbindir| \
    -hostlibdir| \
    -extprefix| \
    -sysroot| \
    -depths| \
    -make| \
    -nomake| \
    -skip| \
    -platform| \
    -xplatform| \
    -device| \
    -device-option| \
    -sdk| \
    -arch| \
    -host-arch| \
    -mysql_config| \
    -psql_config| \
    -qpa| \
    -qconfig| \
    -qreal| \
    -sanitize| \
    -xkb-config-root| \
    -android-sdk| \
    -android-ndk| \
    -android-ndk-platform| \
    -android-ndk-host| \
    -android-arch| \
    -android-toolchain-version)
        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,'`
        ;;
    -system-proxies)
        VAR=system-proxies
        VAL=yes
        ;;
    -no-system-proxies)
        VAR=system-proxies
        VAL=no
        ;;
    #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
        ;;
    -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
        ;;
    -gstreamer)
        VAR=gstreamer
        # 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
        ;;
    -qtnamespace)
        VAR="qtnamespace"
        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
        ;;
    -fpu)
        VAR="fpu"
        # this option may or may not be followed by an argument
        if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
            VAL=no
        else
            shift
            VAL=$1
        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)  # -lfoo is handled differently
        VAR="add_link"
        shift
        VAL="$1"
        ;;
    -F?*|-F)
        VAR="add_fpath"
        if [ "$1" = "-F" ]; then
            shift
            VAL="$1"
        else
            VAL=`echo $1 | sed 's,-F,,'`
        fi
        ;;
    -fw)  # -fwfoo is handled differently
        VAR="add_framework"
        shift
        VAL="$1"
        ;;
    -W*)
        VAR="add_warn"
        VAL="$1"
        ;;
    #General options, including Qt style yes options
    -*)
        VAR=`echo $1 | sed 's,^-\(.*\),\1,'`
        VAL="yes"
        ;;
    *)
        UNKNOWN_ARG=yes
        ;;
    esac
    if [ "$UNKNOWN_ARG" = "yes" ]; then
        echo "$1: unknown argument"
        ERROR=yes
        shift
        continue
     fi
    shift

    UNKNOWN_OPT=no
    case "$VAR" in
    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"
	;;
    psql_config)
        CFG_PSQL_CONFIG="$VAL"
        ;;
    prefix)
        QT_INSTALL_PREFIX="$VAL"
        ;;
    hostprefix)
	QT_HOST_PREFIX="$VAL"
	;;
    hostdatadir)
        QT_HOST_DATA="$VAL"
        ;;
    hostbindir)
        QT_HOST_BINS="$VAL"
        ;;
    hostlibdir)
        QT_HOST_LIBS="$VAL"
        ;;
    extprefix)
        QT_EXT_PREFIX="$VAL"
        ;;
    pkg-config)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PKGCONFIG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    force-pkg-config)
        CFG_PKGCONFIG="yes"
        ;;
    docdir)
        QT_INSTALL_DOCS="$VAL"
        ;;
    headerdir)
        QT_INSTALL_HEADERS="$VAL"
        ;;
    plugindir)
        QT_INSTALL_PLUGINS="$VAL"
        ;;
    importdir)
        QT_INSTALL_IMPORTS="$VAL"
        ;;
    qmldir)
        QT_INSTALL_QML="$VAL"
        ;;
    archdatadir)
        QT_INSTALL_ARCHDATA="$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"
        ;;
    testsdir)
        QT_INSTALL_TESTS="$VAL"
        ;;
    qconfig)
        CFG_QCONFIG="$VAL"
        ;;
    qreal)
        CFG_QREAL="$VAL"
        if [ "$CFG_QREAL" = "float" ]; then
           CFG_QREAL_STRING="\"float\""
        elif [ "$CFG_QREAL" != "double" ]; then
            if [ -z "$PERL" ]; then
                echo "configure needs perl in \$PATH if the -qreal option is used with" >&2
                echo "a value different from \"float\"" >&2
                exit 1
            fi
            CFG_QREAL_STRING=`perl -e '$_ = $ARGV[0];
                                       s/ +/ /g; s/^ +//; s/ +$//;
                                       while (/(.)/g) {
                                           $c = $1;
                                           if ($c =~ /[a-zA-Z0-9]/) { $result .= $c; }
                                           else { $result .= "_" . unpack("H*", $c); }
                                       }
                                       print "\"$result\"";' "$CFG_QREAL"`
        fi
        ;;
    sanitize)
        if [ "$VAL" = "address" ]; then
            CFG_SANITIZE_ADDRESS=yes
        elif [ "$VAL" = "thread" ]; then
            CFG_SANITIZE_THREAD=yes
        elif [ "$VAL" = "memory" ]; then
            CFG_SANITIZE_MEMORY=yes
        elif [ "$VAL" = "undefined" ]; then
            CFG_SANITIZE_UNDEFINED=yes
        else
            echo "Unknown sanitizer: '$VAL'"
            ERROR=true
        fi
        if [ "$CFG_SANITIZERS" = "none" ]; then
            CFG_SANITIZERS=$VAL
        else
            CFG_SANITIZERS="$CFG_SANITIZERS $VAL"
        fi
        ;;
    sysroot)
        CFG_SYSROOT="$VAL"
        ;;
    gcc-sysroot)
        CFG_GCC_SYSROOT="$VAL"
        ;;
    bindir)
        QT_INSTALL_BINS="$VAL"
        ;;
    libexecdir)
        QT_INSTALL_LIBEXECS="$VAL"
        ;;
    opengl)
        if  [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] ||
            [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] ||
            [ "$VAL" = "es2" ]; then
            CFG_OPENGL="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    openvg)
        if [ "$VAL" = "auto" ] || [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_OPENVG="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    nomake)
        if [ -n "${QT_ALL_BUILD_PARTS%%* $VAL *}" ]; then
            echo "Unknown part $VAL passed to -nomake." >&2
            exit 1
        fi
	CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS $VAL"
        ;;
    make)
        if [ "$VAL" = "no" ]; then
            UNKNOWN_OPT=yes
        else
            if [ -n "${QT_ALL_BUILD_PARTS%%* $VAL *}" ]; then
                echo "Unknown part $VAL passed to -make." >&2
                exit 1
            fi
            CFG_BUILD_PARTS="$CFG_BUILD_PARTS $VAL"
        fi
        ;;
    skip)
        VAL=qt${VAL#qt}
        if ! [ -d $relpath/../$VAL ]; then
            echo "Attempting to skip non-existent module $VAL." >&2
            exit 1
        fi
        CFG_SKIP_MODULES="$CFG_SKIP_MODULES $VAL"
        ;;
    compile-examples)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_COMPILE_EXAMPLES="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    sdk)
        if [ "$BUILD_ON_MAC" = "yes" ]; then
            DeviceVar set !host_build:QMAKE_MAC_SDK "$VAL"
            OPT_MAC_SDK="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
	;;
    arch|host-arch)
        OPT_OBSOLETE_HOST_ARG=yes
        ;;
    harfbuzz)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_HARFBUZZ="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;

    framework)
        if [ "$BUILD_ON_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
        ;;
    strip)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_STRIP=$VAL
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    testcocoon)
        if [ "$VAL" = "yes" ]; then
            QTCONFIG_CONFIG="$QTCONFIG_CONFIG testcocoon"
        fi
        ;;
    gcov)
        if [ "$VAL" = "yes" ]; then
            QTCONFIG_CONFIG="$QTCONFIG_CONFIG gcov"
        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
            ;;
        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"
            fi
            ;;
        esac
        ;;
    xplatform)
        XPLATFORM="$VAL"
        case `basename "$XPLATFORM"` in win32-g++*)
            XPLATFORM_MINGW=yes
            CFG_RPATH=no
            CFG_REDUCE_EXPORTS=no
            CFG_ICU=no
            ;;
        esac
        ;;
    device)
        XPLATFORM=`resolveDeviceMkspec $VAL`
        [ "$XPLATFORM" = "undefined" ] && exit 101
        ;;
    device-option)
        DEV_VAR=`echo $VAL | cut -d '=' -f 1`
        DEV_VAL=`echo $VAL | cut -d '=' -f 2-`
        DeviceVar set $DEV_VAR "$DEV_VAL"
        ;;
    qpa)
        QT_QPA_DEFAULT_PLATFORM="$VAL"
        ;;
    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
        ;;
    debug)
        CFG_DEBUG="$VAL"
        ;;
    force-debug-info)
        CFG_FORCEDEBUGINFO="$VAL"
        ;;
    developer-build)
        CFG_DEV="yes"
        ;;
    commercial)
        COMMERCIAL_USER="yes"
        ;;
    opensource)
        COMMERCIAL_USER="no"
        ;;
    static)
        if [ "$VAL" = "yes" ]; then
            CFG_SHARED=no
        elif [ "$VAL" = "no" ]; then
            CFG_SHARED=yes
        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 grep "^Feature: *${FEATURE} *\$" "$relpath"/src/corelib/global/qfeatures.txt >/dev/null 2>&1; then
            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
        else
            echo "ERROR: Unknown feature $FEATURE"
            UNKNOWN_OPT=yes
        fi
        ;;
    shared)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SHARED="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gif)
        if [ "$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
        ;;
     xinput2)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XINPUT2="$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"
            CFG_EGL_X="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    force-eglx)
	if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_FORCE_EGL_X=yes
        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"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    reduce-exports)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_REDUCE_EXPORTS="$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
        ;;
    avx2)
        if [ "$VAL" = "no" ]; then
            CFG_AVX2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    mips_dsp)
        if [ "$VAL" = "no" ]; then
            CFG_MIPS_DSP="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    mips_dspr2)
        if [ "$VAL" = "no" ]; then
            CFG_MIPS_DSPR2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    reduce-relocations)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_REDUCE_RELOCATIONS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    use-gold-linker)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_USE_GOLD_LINKER="$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
        ;;
    mtdev)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MTDEV="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    journald)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_JOURNALD="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    syslog)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SYSLOG="$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
        ;;
    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
        ;;
    freetype)
        [ "$VAL" = "yes" ] && VAL=qt
        if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ]; then
            CFG_FREETYPE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xkb)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XKB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xkbcommon-evdev)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XKBCOMMON_EVDEV="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xkbcommon|xkbcommon-x11)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "qt" ] || [ "$VAL" = "system" ]; then
            CFG_XKBCOMMON="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xcb)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "system" ] || [ "$VAL" = "qt" ]; then
            CFG_XCB="$VAL"
            if [ "$VAL" = "yes" ]; then
                CFG_XCB="system"
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xcb-xlib)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_XCB_XLIB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    wayland)
        CFG_OBSOLETE_WAYLAND=yes
        ;;
    eglfs)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_EGLFS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    directfb)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_DIRECTFB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    linuxfb)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LINUXFB="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    kms)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_KMS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    mirclient)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_MIRCLIENT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libudev)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LIBUDEV="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libinput)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LIBINPUT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    evdev)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_EVDEV="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    tslib)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_TSLIB="$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
        ;;
    slog2)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SLOG2="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    imf)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_QNX_IMF="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    pps)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PPS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    lgmon)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LGMON="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    pulseaudio)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_PULSEAUDIO="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    alsa)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ALSA="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    gstreamer)
        if  [ "$VAL" = "auto" ] || [ "$VAL" = "yes" ] ||
            [ "$VAL" = "0.10" ] || [ "$VAL" = "1.0" ] ||
            [ "$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
        ;;
    gui)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_GUI="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_GUI="no"
            else
                UNKNOWN_OPT=yes
            fi
        fi
        ;;
    widgets)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then
            CFG_WIDGETS="yes"
        elif [ "$VAL" = "no" ]; then
            CFG_WIDGETS="no"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    qpa-platform-guard)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            QPA_PLATFORM_GUARD="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    dbus)
        if [ "$VAL" = "no" ] || [ "$VAL" = "linked" ] || [ "$VAL" = "runtime" ]; then
            CFG_DBUS="$VAL"
        elif [ "$VAL" = "yes" ]; then
            CFG_DBUS="runtime"
        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
        ;;
    securetransport)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SECURETRANSPORT="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    libproxy)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_LIBPROXY="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    qml-debug)
        if [ "$VAL" = "yes" ]; then
            CFG_QML_DEBUG="yes"
        else
            if [ "$VAL" = "no" ]; then
                CFG_QML_DEBUG="no"
            else
                UNKNOWN_OPT=yes
            fi
        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-*|imageformat-*)
        # 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"
            ;;
        imageformat)
            avail="$CFG_IMAGEFORMAT_PLUGIN_AVAILABLE"
            if [ "$OPT" != "plugin" ]; then
                # png is always built in
                avail="$avail png"
            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
        if [ "$found" != "yes" ]; then
            echo "$CURRENT_OPT: unknown argument"
            ERROR=yes
            continue
        fi

        if [ "$VAR" = "sql" ]; then
            # set the CFG_SQL_driver
            eval "CFG_SQL_$VAL=\$OPT"
            continue
        elif [ "$VAR" = "imageformat" ]; then
            [ "$OPT" = "qt" ] && OPT=yes
            VAL="`echo $VAL |tr a-z A-Z`"
            eval "CFG_$VAL=$OPT"
            continue
        fi

        if [ "$OPT" = "plugin" ] || [ "$OPT" = "qt" ]; then
            if [ "$OPT" = "plugin" ]; then
                VAR="${VAR}-${OPT}"
            fi
	    QMakeVar add "${VAR}s" "${VAL}"
        elif [ "$OPT" = "no" ]; then
            PLUG_VAR="${VAR}-plugin"
            IN_VAR="${VAR}"
	    QMakeVar del "${IN_VAR}s" "$VAL"
	    QMakeVar del "${PLUG_VAR}s" "$VAL"
        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
        ;;
    rpath)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_RPATH="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    add_define)
        DEFINES="$DEFINES \"$VAL\""
        D_FLAGS="$D_FLAGS -D\"$VAL\""
        ;;
    add_ipath)
        INCLUDES="$INCLUDES \"$VAL\""
        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 [ "$BUILD_ON_MAC" = "yes" ]; then
            L_FLAGS="$L_FLAGS -F\"${VAL}\""
            I_FLAGS="$I_FLAGS -F\"${VAL}\""
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    add_framework)
        if [ "$BUILD_ON_MAC" = "yes" ]; then
            L_FLAGS="$L_FLAGS -framework \"${VAL}\""
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    add_warn)
        W_FLAGS="$W_FLAGS \"${VAL}\""
        ;;
    silent)
        CFG_SILENT="$VAL"
        ;;
    audio-backend)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_AUDIO_BACKEND="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    icu)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ICU="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    force-asserts)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_FORCE_ASSERTS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    pcre)
        if [ "$VAL" = "qt" ] || [ "$VAL" = "system" ]; then
            CFG_PCRE="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    c++11)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_CXX11="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    system-proxies)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_SYSTEM_PROXIES="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    directwrite)
        if [ "$XPLATFORM_MINGW" = "yes" ] ; then
            if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
                CFG_DIRECTWRITE="$VAL"
            else
                UNKNOWN_OPT=yes
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    warnings-are-errors|Werror)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_WERROR="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    headersclean)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_HEADERSCLEAN="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    xkb-config-root)
        CFG_XKB_CONFIG_ROOT="$VAL"
        ;;
    android-sdk)
        CFG_DEFAULT_ANDROID_SDK_ROOT="$VAL"
        ;;
    android-ndk)
        CFG_DEFAULT_ANDROID_NDK_ROOT="$VAL"
        ;;
    android-ndk-platform)
        CFG_DEFAULT_ANDROID_PLATFORM="$VAL"
        ;;
    android-ndk-host)
        CFG_DEFAULT_ANDROID_NDK_HOST="$VAL"
        ;;
    android-arch)
        CFG_DEFAULT_ANDROID_TARGET_ARCH="$VAL"
        ;;
    android-toolchain-version)
        CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION="$VAL"
        ;;
    android-style-assets)
        if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
            CFG_ANDROID_STYLE_ASSETS="$VAL"
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    l*)  # -lfoo
        if [ "$VAL" = "yes" ]; then
            L_FLAGS="$L_FLAGS -l\"${VAR#l}\""
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    fw*)  # -fwfoo
        if [ "$VAL" = "yes" ]; then
            if [ "$BUILD_ON_MAC" = "yes" ]; then
                L_FLAGS="$L_FLAGS -framework \"${VAR#fw}\""
            else
                UNKNOWN_OPT=yes
            fi
        else
            UNKNOWN_OPT=yes
        fi
        ;;
    *)
        UNKNOWN_OPT=yes
        ;;
    esac
    if [ "$UNKNOWN_OPT" = "yes" ]; then
        echo "${CURRENT_OPT}: invalid command-line switch"
        ERROR=yes
    fi
done
[ "x$ERROR" = "xyes" ] && exit 1

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

if [ "$OPT_HELP" = "yes" ]; then
    cat <<EOF
Usage:  $relconf [options]

Installation options:

 These are optional, but you may specify install directories.

    -prefix <dir> ...... The deployment directory, as seen on the target device.
                         (default /usr/local/Qt-${QT_VERSION}, \$PWD if -developer-build is active)

    -extprefix <dir> ... The installation directory, as seen on the host machine.
                         (default SYSROOT/PREFIX)

    -hostprefix [dir] .. The installation directory for build tools running on the
                         host machine. If [dir] is not given, the current build
                         directory will be used. (default EXTPREFIX)

 You may use these to change the layout of the install. Note that all directories
 except -sysconfdir should be located under -prefix/-hostprefix:

    -bindir <dir> ......... User executables will be installed to <dir>
                            (default PREFIX/bin)
    -headerdir <dir> ...... Headers will be installed to <dir>
                            (default PREFIX/include)
    -libdir <dir> ......... Libraries will be installed to <dir>
                            (default PREFIX/lib)
    -archdatadir <dir> .... Arch-dependent data used by Qt will be installed to <dir>
                            (default PREFIX)
    -plugindir <dir> ...... Plugins will be installed to <dir>
                            (default ARCHDATADIR/plugins)
    -libexecdir <dir> ..... Program executables will be installed to <dir>
                            (default ARCHDATADIR/libexec, ARCHDATADIR/bin for MinGW)
    -importdir <dir> ...... Imports for QML1 will be installed to <dir>
                            (default ARCHDATADIR/imports)
    -qmldir <dir> ......... Imports for QML2 will be installed to <dir>
                            (default ARCHDATADIR/qml)
    -datadir <dir> ........ Arch-independent data used by Qt will be installed to <dir>
                            (default PREFIX)
    -docdir <dir> ......... Documentation will be installed to <dir>
                            (default DATADIR/doc)
    -translationdir <dir> . Translations of Qt programs will be installed to <dir>
                            (default DATADIR/translations)
    -sysconfdir <dir> ..... Settings used by Qt programs will be looked for in <dir>
                            (default PREFIX/etc/xdg)
    -examplesdir <dir> .... Examples will be installed to <dir>
                            (default PREFIX/examples)
    -testsdir <dir> ....... Tests will be installed to <dir>
                            (default PREFIX/tests)

    -hostbindir <dir> .. Host executables will be installed to <dir>
                         (default HOSTPREFIX/bin)
    -hostlibdir <dir> .. Host libraries will be installed to <dir>
                         (default HOSTPREFIX/lib)
    -hostdatadir <dir> . Data used by qmake will be installed to <dir>
                         (default HOSTPREFIX)

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).

    -force-debug-info .. Create symbol files for release builds.

    -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.

    -confirm-license ... Automatically acknowledge the license (use with
                         either -opensource or -commercial)

    -no-c++11 .......... Do not compile Qt with C++11 support enabled.
 +  -c++11 ............. Compile Qt with C++11 support enabled.

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

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

    -no-accessibility .. Do not compile Accessibility support.
                         Disabling accessibility is not recommended, as it will break QStyle
                         and may break other internal parts of Qt.
                         With this switch you create a source incompatible version of Qt,
                         which is unsupported.
 +  -accessibility ..... Compile Accessibility support.

    -no-sql-<driver> ... Disable SQL <driver> entirely.
    -qt-sql-<driver> ... Enable a SQL <driver> in the Qt SQL module, 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-qml-debug ...... Do not build the in-process QML debugging support.
 +  -qml-debug ......... Build the QML debugging support.

    -platform target ... The operating system and compiler you are building
                         on (default detected from host system).

                         See the README file for a list of supported
                         operating systems and compilers.

    -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.
    -no-avx2 ........... Do not compile with use of AVX2 instructions.
    -no-mips_dsp ....... Do not compile with use of MIPS DSP instructions.
    -no-mips_dspr2 ..... Do not compile with use of MIPS DSP rev2 instructions.

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

    -testcocoon ........ Instrument Qt with the TestCocoon code coverage tool.
    -gcov .............. Instrument Qt with the GCov code coverage tool.

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

 +  -pkg-config ........ Use pkg-config to detect include and library paths. By default,
                         configure determines whether to use pkg-config or not with
                         some heuristics such as checking the environment variables.
    -no-pkg-config ..... Disable use of pkg-config.
    -force-pkg-config .. Force usage of pkg-config (skips pkg-config usability
                         detection heuristic).

    -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-mtdev ........... Do not compile mtdev support.
 +  -mtdev .............. Enable mtdev support.

 +  -no-journald ........ Do not send logging output to journald.
    -journald ........... Send logging output to journald.

 +  -no-syslog .......... Do not send logging output to syslog.
    -syslog ............. Send logging output to syslog.

    -no-gif ............. Do not compile GIF reading support.

    -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-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-freetype ........ Do not compile in Freetype2 support.
    -qt-freetype ........ Use the libfreetype bundled with Qt.
 +  -system-freetype..... Use the libfreetype provided by the system (enabled if -fontconfig is active).
                          See http://www.freetype.org

    -no-harfbuzz ........ Do not compile HarfBuzz-NG support.
 *  -qt-harfbuzz ........ Use HarfBuzz-NG bundled with Qt to do text shaping.
                          It can still be disabled by setting
                          the QT_HARFBUZZ environment variable to "old".
    -system-harfbuzz .... Use HarfBuzz-NG from the operating system
                          to do text shaping. It can still be disabled
                          by setting the QT_HARFBUZZ environment variable to "old".
                          See http://www.harfbuzz.org

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

    -no-libproxy ....... Do not compile support for libproxy
 +  -libproxy .......... Use libproxy from the operating system.

    -qt-pcre ............ Use the PCRE library bundled with Qt.
 +  -system-pcre ........ Use the PCRE library from the operating system.

    -qt-xcb ............. Use xcb- libraries bundled with Qt.
                          (libxcb.so will still be used from operating system).
 +  -system-xcb ......... Use xcb- libraries from the operating system.

    -xkb-config-root .... Set default XKB config root. This option is used only together with -qt-xkbcommon-x11.
    -qt-xkbcommon-x11 ... Use the xkbcommon library bundled with Qt in combination with xcb.
 +  -system-xkbcommon-x11 Use the xkbcommon library from the operating system in combination with xcb.

    -no-xkbcommon-evdev . Do not use X-less xkbcommon when compiling libinput support.
 *  -xkbcommon-evdev .... Use X-less xkbcommon when compiling libinput support.

    -no-xinput2 ......... Do not compile XInput2 support.
 *  -xinput2 ............ Compile XInput2 support.

    -no-xcb-xlib......... Do not compile Xcb-Xlib support.
 *  -xcb-xlib............ Compile Xcb-Xlib support.

    -no-glib ............ Do not compile Glib support.
 +  -glib ............... Compile Glib support.

    -no-pulseaudio ...... Do not compile PulseAudio support.
 +  -pulseaudio ......... Compile PulseAudio support.

    -no-alsa ............ Do not compile ALSA support.
 +  -alsa ............... Compile ALSA support.

    -no-gtkstyle ........ Do not compile GTK theme support.
 +  -gtkstyle ........... Compile GTK theme support.

Additional options:

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

    -skip <module> ..... Exclude an entire module from the build.

    -no-compile-examples ... Install only the sources of examples.

    -no-gui ............ Don't build the Qt GUI module and dependencies.
 +  -gui ............... Build the Qt GUI module and dependencies.

    -no-widgets ........ Don't build the Qt Widgets module and dependencies.
 +  -widgets ........... Build the Qt Widgets module and dependencies.

    -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-nis ............ Do not compile NIS support.
 *  -nis ............... Compile NIS support.

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

    -no-iconv .......... Do not compile support for iconv(3).
 *  -iconv ............. Compile support for iconv(3).

    -no-evdev .......... Do not compile support for evdev.
 *  -evdev ............. Compile support for evdev.

    -no-tslib .......... Do not compile support for tslib.
 *  -tslib ............. Compile support for tslib.

    -no-icu ............ Do not compile support for ICU libraries.
 +  -icu ............... Compile support for ICU libraries.

    -no-fontconfig ..... Do not compile FontConfig support.
 +  -fontconfig ........ Compile FontConfig support.

    -no-strip .......... Do not strip binaries and libraries of unneeded symbols.
 *  -strip ............. Strip binaries and libraries of unneeded symbols when installing.

 *  -no-pch ............ Do not use precompiled header support.
    -pch ............... Use precompiled header support.

    -no-dbus ........... Do not compile the Qt D-Bus module.
 +  -dbus .............. Compile the Qt D-Bus module and dynamically load libdbus-1.
    -dbus-linked ....... Compile the Qt D-Bus 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).

    -no-use-gold-linker ..... Do not link using the GNU gold linker.
 +  -use-gold-linker ........ Link using the GNU gold linker if available.

    -force-asserts ........ Force Q_ASSERT to be enabled even in release builds.

    -sanitize [address|thread|memory|undefined] Enables the specified compiler sanitizer.

    -device <name> ............... Cross-compile for device <name> (experimental)
    -device-option <key=value> ... Add device specific options for the device mkspec
                                   (experimental)

 *  -no-separate-debug-info . Do not store debug information in a separate file.
    -separate-debug-info .... Strip debug information into a separate file.

    -no-xcb ............ Do not compile Xcb (X protocol C-language Binding) support.
 *  -xcb ............... Compile Xcb support.

    -no-eglfs .......... Do not compile EGLFS (EGL Full Screen/Single Surface) support.
 *  -eglfs ............. Compile EGLFS support.

    -no-kms ............ Do not compile EGLFS KMS backend.
 *  -kms ............... Compile EGLFS KMS backend.

    -no-directfb ....... Do not compile DirectFB support.
 *  -directfb .......... Compile DirectFB support.

    -no-linuxfb ........ Do not compile Linux Framebuffer support.
 *  -linuxfb ........... Compile Linux Framebuffer support.

 *  -no-mirclient....... Do not compile Mir client support.
    -mirclient.......... Compile Mir client support.

    -qpa <name> ......... Sets the default QPA platform (e.g xcb, cocoa, windows).

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

    -sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths.
    -no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler

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

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

    -qreal [double|float] typedef qreal to the specified type. The default is double.
                          Note that changing this flag affects binary compatibility.

    -no-opengl .......... Do not support OpenGL.
    -opengl <api> ....... Enable OpenGL support
                          With no parameter, this will attempt to auto-detect
                          OpenGL ES 2.0 and higher, or regular desktop OpenGL.
                          Use es2 for <api> to override auto-detection.

    -no-libinput ........ Do not support libinput.
 *  -libinput ........... Enable libinput support.

    -no-gstreamer ....... Do not support GStreamer.
 +  -gstreamer <version>  Enable GStreamer support
                          With no parameter, this will attempt to auto-detect GStreamer 0.10 and
                          1.0. GStreamer 1.0 is used by default when available.
                          Use 0.10 or 1.0 for <version> to override auto-detection.

 *  -no-system-proxies .. Do not use system network proxies by default.
    -system-proxies ..... Use system network proxies by default.

    -no-warnings-are-errors Make warnings be treated normally
    -warnings-are-errors  Make warnings be treated as errors
                          (enabled if -developer-build is active)

QNX/Blackberry options:

    -no-slog2 .......... Do not compile with slog2 support.
    -slog2 ............. Compile with slog2 support.

    -no-pps ............ Do not compile with pps support.
    -pps ............... Compile with pps support.

    -no-imf ............ Do not compile with imf support.
    -imf ............... Compile with imf support.

    -no-lgmon .......... Do not compile with lgmon support.
    -lgmon ............. Compile with lgmon support.

MacOS/iOS options:

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

 *  -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.

 *  -securetransport ... Use SecureTransport instead of OpenSSL

    -no-securetransport  Do not use SecureTransport, either use OpenSSL or do not use any SSL backend
                         at all (if combined with -no-openssl).

    -sdk <sdk> ......... Build Qt using Apple provided SDK <sdk>. The argument should be
                         one of the available SDKs as listed by 'xcodebuild -showsdks'.
                         Note that the argument applies only to Qt libraries and applications built
                         using the target mkspec - not host tools such as qmake, moc, rcc, etc.

Android options:

    -android-sdk path .............. The Android SDK root path.
                                     (default \$ANDROID_SDK_ROOT)

    -android-ndk path .............. The Android NDK root path.
                                     (default \$ANDROID_NDK_ROOT)

    -android-ndk-platform .......... Sets the android platform
                                     (default $CFG_DEFAULT_ANDROID_PLATFORM)

    -android-ndk-host .............. Sets the android NDK host (linux-x86, linux-x86_64, etc.)
                                     (default \$ANDROID_NDK_HOST)

    -android-arch .................. Sets the android architecture (armeabi, armeabi-v7a, x86, mips,
                                     arm64-v8a, x86_64, mips64)
                                     (default $CFG_DEFAULT_ANDROID_TARGET_ARCH)

    -android-toolchain-version ..... Sets the android toolchain version
                                     (default $CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION)

    -no-android-style-assets ....... Do not compile in the code which automatically extracts
                                     style assets from the run-time device. Setting this will
                                     make the Android style behave incorrectly, but will enable
                                     compatibility with the LGPL2.1 license.
 *  -android-style-assets .......... Compile the code which automatically extracts style assets
                                     from the run-time device. This option will make the
                                     Android platform plugin incompatible with the LGPL2.1.
EOF

   exit 0
fi # Help

#-------------------------------------------------------------------------------
# platform detection
#-------------------------------------------------------------------------------

if [ -z "$PLATFORM" ]; then
    PLATFORM_NOTES=
    case "$UNAME_SYSTEM:$UNAME_RELEASE" in
     Darwin:*)
        # Select compiler. Use g++ unless we find a usable Clang version. Note that
        # we are checking the "Apple" clang/LLVM version number, not the actual
        # clang/LLVM version number that the Apple version was based on. We look
        # for Apple clang version 3.0 or higher, which was branched off LLVM 3.0
        # from SVN, and first included in Xcode 4.2. Also note that we do not care
        # about the OS version, since we're not using the clang version that comes
        # with the system. We use 'xcrun' to check the clang version that's part of
        # the Xcode installation.
        XCRUN=`/usr/bin/xcrun -sdk macosx clang -v 2>&1`
        CLANGVERSION=`echo "$XCRUN" | sed -n 's/.*version \([0-9]\).*/\1/p'`
        expr "$CLANGVERSION" : '[0-9]' > /dev/null || { echo "Unable to determine CLANG version from output of xcrun: $XCRUN" ; exit 2 ; }
        if [ "$CLANGVERSION" -ge 3 ]; then
            PLATFORM=macx-clang

            # Advertise g++ as an alternative on Lion and below
            if [ "$(uname -r | cut -d. -f1)" -le 11 ]; then
                PLATFORM_NOTES="\n    - Also available for Mac OS X: macx-g++\n"
            fi
        else
            PLATFORM=macx-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:*)
        PLATFORM=linux-g++
        PLATFORM_NOTES="
            - Also available for Linux: linux-clang 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++
        ;;
     *)
            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
    esac
fi

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

case "$XPLATFORM" in
    *win32-g++*)
        XPLATFORM_MINGW=yes
        ;;
    *qnx-*|*blackberry-*)
        XPLATFORM_QNX=yes
        ;;
    *haiku-*)
        XPLATFORM_HAIKU=yes
        ;;
    *ios*)
        XPLATFORM_MAC=yes
        XPLATFORM_IOS=yes
        ;;
    *macx*)
        XPLATFORM_MAC=yes
        ;;
    # XPLATFORM_ANDROID should not be set for unsupported/android-g++
    *unsupported*)
        ;;
    *android-g++*)
        XPLATFORM_ANDROID=yes
        ;;
    *tizen*)
        XPLATFORM_TIZEN=yes
        ;;
esac

#-------------------------------------------------------------------------------
# check the license
#-------------------------------------------------------------------------------

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 [ -f "$relpath"/LICENSE.PREVIEW.COMMERCIAL ] && [ $COMMERCIAL_USER = "yes" ]; then
    # Commercial preview release
    Licensee="Preview"
    Edition="Preview"
    EditionString="Technology Preview"
elif [ $COMMERCIAL_USER = "yes" ]; then
    if [ $UNAME_SYSTEM = "Linux" ]; then
        case "$PLATFORM" in
        *-32)
            Licheck=licheck32
            ;;
        *-64)
            Licheck=licheck64
            ;;
        *)
            if file -L /bin/sh | grep -q "64-bit" ; then
                Licheck=licheck64
            else
                Licheck=licheck32
            fi
            ;;
        esac
    elif [ $UNAME_SYSTEM = "Darwin" ]; then
        Licheck=licheck_mac
    else
        echo >&2 "Host operating system not supported by this edition of Qt."
        exit 1
    fi
    if [ -x "$relpath/bin/$Licheck" ]; then
        LicheckOutput=`$relpath/bin/$Licheck $OPT_CONFIRM_LICENSE $relpath $outpath\
                       $PLATFORM $XPLATFORM`
        if [ $? -ne 0 ]; then
            exit 1
        else
            eval "$LicheckOutput"
        fi
    else
        echo
        echo "Error: This is the Open Source version of Qt."
        echo "If you want to use Enterprise features of Qt,"
        echo "use the contact form at http://www.qt.io/contact-us"
        echo "to purchase a license."
        echo
        exit 1
    fi
elif [ $COMMERCIAL_USER = "no" ]; then
    # Open Source edition - may only be used under the terms of the LGPLv3 or LGPLv21.
    Licensee="Open Source"
    Edition="OpenSource"
    EditionString="Open Source"
fi

if [ "$Edition" = "OpenSource" ] || [ "$Edition" = "Preview" ]; then
    echo
    echo "This is the Qt ${EditionString} Edition."
    echo
fi

if [ "$Edition" = "OpenSource" ]; then
    while true; do
        if [ "$CFG_ANDROID_STYLE_ASSETS" = "no" ] || [ "$XPLATFORM_ANDROID" = "no" ]; then
            echo "You are licensed to use this software under the terms of"
            echo "the Lesser GNU General Public License (LGPL) versions 2.1."
            echo "You are also licensed to use this software under the terms of"
            echo "the GNU Lesser General Public License (LGPL) versions 3."
            affix="either"
            showLGPL2="yes"
        else
            echo "You are licensed to use this software under the terms of"
            echo "the GNU Lesser General Public License (LGPL) versions 3."
            showLGPL2="no"
            affix="the"
        fi

        echo
        if [ "$OPT_CONFIRM_LICENSE" = "yes" ]; then
            echo "You have already accepted the terms of the $EditionString license."
            acceptance=yes
        else
            if [ -f "$relpath/LICENSE.LGPLv3" ]; then
                echo "Type '3' to view the GNU Lesser General Public License version 3."
            fi
            if [ "$showLGPL2" = "yes" ]; then
                echo "Type 'L' to view the Lesser GNU General Public License version 2.1."
            fi
            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.LGPLv3"
        elif [ "$acceptance" = "L" ] && [ "$showLGPL2" = "yes" ]; then
            more "$relpath/LICENSE.LGPLv21"
        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 $EditionString 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
fi

#-------------------------------------------------------------------------------
# command line and environment validation
#-------------------------------------------------------------------------------

# update QT_CONFIG to show our current predefined configuration
CFG_QCONFIG_PATH=$relpath/src/corelib/global/qconfig-${CFG_QCONFIG}.h
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
    [ "$CFG_QCONFIG" = full ] && CFG_QCONFIG_PATH=
    ;;
*)
    # not known to be sufficient for anything
    if [ ! -f "$CFG_QCONFIG_PATH" ]; then
        CFG_QCONFIG_PATH=`makeabs "${CFG_QCONFIG}"`
        if [ ! -f "$CFG_QCONFIG_PATH" ]; then
            echo >&2 "Error: configuration file not found:"
            echo >&2 "  $relpath/src/corelib/global/qconfig-${CFG_QCONFIG}.h"
            echo >&2 "  or"
            echo >&2 "  $CFG_QCONFIG_PATH"
            exit 1
        fi
    fi
esac

if [ "$XPLATFORM_MAC" = "no" -a "$CFG_DEBUG_RELEASE" = "yes" ]; then
    echo
    echo "WARNING: -debug-and-release is not supported outside of Mac OS X."
    echo "Qt can be built in release mode with separate debug information, so"
    echo "-debug-and-release is not necessary anymore"
    echo
fi

if ( [ "$CFG_XCB" = "system" ] || [ "$CFG_XCB" = "qt" ] ) && [ "$CFG_XKBCOMMON" = "no" ]; then
    echo "Error: -no-xkbcommon-x11 is not supported on XCB platform plugin."
    exit 101
fi

if [ "$XPLATFORM_ANDROID" = "yes" ]; then
    if [ "$CFG_DBUS" = "auto" ]; then
        CFG_DBUS="no"
    fi
    if [ -z "$CFG_DEFAULT_ANDROID_NDK_HOST" ]; then
        case $PLATFORM in
        linux-*)
            if [ -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/linux-x86" ]; then
                CFG_DEFAULT_ANDROID_NDK_HOST=linux-x86
            elif [ -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/linux-x86_64" ]; then
                CFG_DEFAULT_ANDROID_NDK_HOST=linux-x86_64
            fi
            ;;
        macx-*)
            CFG_DEFAULT_ANDROID_NDK_HOST=darwin-x86
            if [ ! -z "$NATIVE_64_ARCH" ] && [ -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/darwin-x86_64" ]; then
                CFG_DEFAULT_ANDROID_NDK_HOST=darwin-x86_64
            fi
            ;;
        win32-*)
            CFG_DEFAULT_ANDROID_NDK_HOST=windows
            if [ ! -z "$NATIVE_64_ARCH" ] && [ -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/windows-x86_64" ]; then
                CFG_DEFAULT_ANDROID_NDK_HOST=windows-x86_64
            fi
            ;;
        esac
    fi

        if [ -z "$CFG_DEFAULT_ANDROID_NDK_ROOT" ]; then
            echo
            echo "Can not find Android NDK. Please use -android-ndk option to specify one"
            exit 1
        fi
        if [ -z "$CFG_DEFAULT_ANDROID_SDK_ROOT" ]; then
            echo
            echo "Can not find Android SDK. Please use -android-sdk option to specify one"
            exit 1
        fi
        if [ -z "CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION" ] || [ ! -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt" ]; then
            echo
            echo "Can not detect Android NDK toolchain. Please use -android-toolchain-version to specify"
            exit 1
        fi
        if [ -z "$CFG_DEFAULT_ANDROID_NDK_HOST" ] || [ ! -d "$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/$CFG_DEFAULT_ANDROID_NDK_HOST" ]; then
            echo
            echo "Can not detect the android host. Please use -android-ndk-host option to specify one"
            exit 1
        fi

        QT_QPA_DEFAULT_PLATFORM="android"
        CFG_LARGEFILE="no"

        DeviceVar set DEFAULT_ANDROID_SDK_ROOT "$CFG_DEFAULT_ANDROID_SDK_ROOT"
        DeviceVar set DEFAULT_ANDROID_NDK_ROOT "$CFG_DEFAULT_ANDROID_NDK_ROOT"
        DeviceVar set DEFAULT_ANDROID_PLATFORM "$CFG_DEFAULT_ANDROID_PLATFORM"
        DeviceVar set DEFAULT_ANDROID_NDK_HOST "$CFG_DEFAULT_ANDROID_NDK_HOST"
        DeviceVar set DEFAULT_ANDROID_TARGET_ARCH "$CFG_DEFAULT_ANDROID_TARGET_ARCH"
        DeviceVar set DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION "$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION"
fi

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"
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG cross_compile"
fi

if [ "$BUILD_ON_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-clang' or 'macx-g++', then use" >&2
      echo "   the 'macx-xcode' spec for your application, and it will link to" >&2
      echo "   the Qt/Mac build using the settings of the original mkspec." >&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 information use the contact form at http://www.qt.io/contact-us"
    echo
    exit 2
fi

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

# 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 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..."

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

    mkdir -p "$outpath/mkspecs"
fi

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

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

# detect build style
if [ "$CFG_DEBUG" = "auto" ]; then
    if [ "$XPLATFORM_MAC" = "yes" -o "$XPLATFORM_MINGW" = "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
    QT_CONFIG="$QT_CONFIG build_all debug_and_release"
fi

if [ "$CFG_FORCEDEBUGINFO" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG force_debug_info"
fi

if [ "$XPLATFORM_MAC" = "yes" ]; then
    [ "$CFG_PKGCONFIG" = "auto" ] && CFG_PKGCONFIG="no"
fi

if [ "$XPLATFORM_IOS" = "yes" ]; then
    CFG_RPATH="no"
    CFG_NOBUILD_PARTS="$CFG_NOBUILD_PARTS examples"
    CFG_SHARED="no" # iOS builds should be static to be able to submit to the App Store
    CFG_SKIP_MODULES="$CFG_SKIP_MODULES qtdoc qtmacextras qtserialport qtwebkit qtwebkit-examples"
    CFG_PRECOMPILE="no" # Precompiled headers not supported with multiple -arch arguments

    # If the user passes -sdk on the command line we build a SDK-specific Qt build.
    # Otherwise we build a joined simulator and device build, which is the default.
    if [ -z "$OPT_MAC_SDK" ]; then
         QT_CONFIG="$QT_CONFIG build_all"
         QTCONFIG_CONFIG="$QTCONFIG_CONFIG iphonesimulator_and_iphoneos"
    fi
fi

# disable XCB and GTK support auto-detection on Mac
if [ "$XPLATFORM_MAC" = "yes" ]; then
    [ "$CFG_XCB" = "auto" ] && CFG_XCB=no
    [ "$CFG_QGTKSTYLE" = "auto" ] && CFG_QGTKSTYLE=no
fi

QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`

TEST_COMPILER=$QMAKE_CONF_COMPILER

if [ "$XPLATFORM_ANDROID" = "yes" ] ; then
    ANDROID_NDK_TOOLCHAIN_PREFIX=
    ANDROID_NDK_TOOLS_PREFIX=
    ANDROID_PLATFORM_ARCH=
    case $CFG_DEFAULT_ANDROID_TARGET_ARCH in
        armeabi*)
            ANDROID_NDK_TOOLS_PREFIX=arm-linux-androideabi
            ANDROID_NDK_TOOLCHAIN_PREFIX=arm-linux-androideabi
            ANDROID_PLATFORM_ARCH=arch-arm
            ;;
        x86)
            ANDROID_NDK_TOOLS_PREFIX=i686-linux-android
            ANDROID_NDK_TOOLCHAIN_PREFIX=x86
            ANDROID_PLATFORM_ARCH=arch-x86
            ;;
        mips)
            ANDROID_NDK_TOOLS_PREFIX=mipsel-linux-android
            ANDROID_NDK_TOOLCHAIN_PREFIX=mipsel-linux-android
            ANDROID_PLATFORM_ARCH=arch-mips
            ;;
        arm64-v8a)
            ANDROID_NDK_TOOLS_PREFIX=aarch64-linux-android
            ANDROID_NDK_TOOLCHAIN_PREFIX=aarch64-linux-android
            ANDROID_PLATFORM_ARCH=arch-arm64
            ;;
        mips64)
            ANDROID_NDK_TOOLS_PREFIX=mips64el-linux-android
            ANDROID_NDK_TOOLCHAIN_PREFIX=mips64el-linux-android
            ANDROID_PLATFORM_ARCH=arch-mips64
            ;;
        x86_64)
            ANDROID_NDK_TOOLS_PREFIX=x86_64-linux-android
            ANDROID_NDK_TOOLCHAIN_PREFIX=x86_64
            ANDROID_PLATFORM_ARCH=arch-x86_64
            ;;
        *)
            echo "ERROR: Unknown android arch $CFG_DEFAULT_ANDROID_TARGET_ARCH"
            exit 1
            ;;
    esac
    QMAKE_CONF_COMPILER=$CFG_DEFAULT_ANDROID_NDK_ROOT/toolchains/$ANDROID_NDK_TOOLCHAIN_PREFIX-$CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION/prebuilt/$CFG_DEFAULT_ANDROID_NDK_HOST/bin/$ANDROID_NDK_TOOLS_PREFIX-g++
    TEST_COMPILER="$QMAKE_CONF_COMPILER --sysroot=$CFG_DEFAULT_ANDROID_NDK_ROOT/platforms/$CFG_DEFAULT_ANDROID_PLATFORM/$ANDROID_PLATFORM_ARCH/"
    if [ "$CFG_ANDROID_STYLE_ASSETS" = "yes" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG android-style-assets"
    fi
fi

if [ "$XPLATFORM_SYMBIAN_SBSV2" = "no" ]; then
    if [ -z "$TEST_COMPILER" ]; then
        echo "ERROR: Cannot set the compiler for the configuration tests"
        exit 1
    fi
fi
TEST_COMPILER_CXXFLAGS=`getXQMakeConf QMAKE_CXXFLAGS`

GCC_MACHINE_DUMP=
case "$TEST_COMPILER" in *g++) GCC_MACHINE_DUMP=$($TEST_COMPILER -dumpmachine);; esac
if [ -n "$GCC_MACHINE_DUMP" ]; then
    DeviceVar set GCC_MACHINE_DUMP $($TEST_COMPILER -dumpmachine)
fi

if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then
    SYSROOT_FLAG="--sysroot=$CFG_SYSROOT"
else
    SYSROOT_FLAG=
fi

if [ "$XPLATFORM_TIZEN" = "yes" -a -n "$TIZEN_SYSROOT" ]; then
    SYSROOT_FLAG="--sysroot=$TIZEN_SYSROOT"
fi

export SYSROOT_FLAG    # used by config.tests/unix/{compile.test,arch.test}

# auto-detect precompiled header support
if [ "$CFG_PRECOMPILE" = "auto" ]; then
    if "$unixtests/precomp.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then
       CFG_PRECOMPILE=no
    else
       CFG_PRECOMPILE=yes
    fi
fi

# sanity-check for separate debug info
if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
    if [ "$CFG_SHARED" = "no" ]; then
        echo "ERROR: -separate-debug-info is incompatible with -static"
        exit 1
    fi
    if [ "$CFG_DEBUG" = "no" -a "$CFG_DEBUG_RELEASE" = "no" -a "$CFG_FORCEDEBUGINFO" = "no" ]; then
        echo "ERROR: -separate-debug-info needs -debug, -debug-and-release, or -force-debug-info"
        exit 1
    fi
fi

# auto-detect -fvisibility support
if [ "$CFG_REDUCE_EXPORTS" != "no" ]; then
    if "$unixtests/fvisibility.test" "$TEST_COMPILER" "$OPT_VERBOSE"; then
       if [ "$CFG_REDUCE_EXPORTS" = "yes" ]; then
           echo "-reduce-exports was requested but this compiler does not support it"
           echo "Re-run configure with -v for more information"
           exit 1
       fi
       CFG_REDUCE_EXPORTS=no
    else
       CFG_REDUCE_EXPORTS=yes
    fi
fi

# auto-detect -fuse-ld=gold support
if [ "$CFG_USE_GOLD_LINKER" != "no" ]; then
    if compilerSupportsFlag $TEST_COMPILER -fuse-ld=gold; then
       CFG_USE_GOLD_LINKER=yes
    else
        if [ "$CFG_USE_GOLD_LINKER" = "yes" ]; then
            echo "-use-gold-linker was requested but this compiler does not support it"
            exit 1
        fi
        CFG_USE_GOLD_LINKER=no
    fi
fi

# auto-detect --enable-new-dtags support
if linkerSupportsFlag $TEST_COMPILER --enable-new-dtags; then
    CFG_ENABLE_NEW_DTAGS=yes
else
    CFG_ENABLE_NEW_DTAGS=no
fi

# auto-detect -fstack-protector-strong support (for QNX only currently)
if [ "$XPLATFORM_QNX" = "yes" ]; then
    if compilerSupportsFlag $TEST_COMPILER -fstack-protector-strong; then
       CFG_STACK_PROTECTOR_STRONG=yes
    else
       CFG_STACK_PROTECTOR_STRONG=no
    fi
else
   CFG_STACK_PROTECTOR_STRONG=no
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
       if [ "$CFG_REDUCE_RELOCATIONS" = "yes" ]; then
           echo "-reduce-relocations was requested but this compiler does not support it"
           echo "Re-run configure with -v for more information"
           exit 1
       fi
        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

# find the default framework value
if [ "$XPLATFORM_MAC" = "yes" ]; 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

# Auto-detect default include and library search paths.

# Use intermediate variable to get around backtick/quote nesting problems.
awkprog='
BEGIN { ORS = ""; FS = "="; incs = 0; libs = 0; }

function normalize(dir)
{
    do {
        odir = dir
        sub(/\/[^\/]+\/\.\./, "", dir)
    } while (dir != odir);
    do {
        odir = dir
        gsub(/\/\./, "", dir)
    } while (dir != odir);
    sub("/$", "", dir);
    return dir;
}

# extract include paths from indented lines between
#   #include <...> search starts here:
# and
#   End of search list.
/^\#include </ { yup=1; print "DEFAULT_INCDIRS=\""; next }
/^End of search/ { yup=0; print "\"\n" }
/ \(framework directory\)$/ { next }
yup { print normalize(substr($0, 2)) "\n"; ++incs }

# extract from one line like LIBRARY_PATH=/one/path:/another/path:...
$1 == "LIBRARY_PATH" {
    libs = split($2, library_paths, ":");
    print "DEFAULT_LIBDIRS=\"";
    for (lib in library_paths) {
        dir = normalize(library_paths[lib]);
        if (!(dir in dirs)) {
            print dir "\n";
            dirs[dir] = 1;
        }
    }
    print "\"\n"
}

END {
    if (incs == 0)
        print "DEFAULT_INCDIRS=\"/usr/include\n/usr/local/include\"\n";
    if (libs == 0)
        print "DEFAULT_LIBDIRS=\"/lib\n/usr/lib\"\n";
}'

unset tty
[ "$OPT_VERBOSE" = "yes" ] && tty=/dev/stderr
eval "`LC_ALL=C $TEST_COMPILER $SYSROOT_FLAG $TEST_COMPILER_CXXFLAGS -xc++ -E -v - < /dev/null 2>&1 > /dev/null | $AWK "$awkprog" | tee $tty`"
unset tty

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

    # build tests by default, if a developer build
    if [ "$CFG_DEV" = "yes" ]; then
        CFG_BUILD_PARTS="$CFG_BUILD_PARTS tests"
    fi

    # 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

#-------------------------------------------------------------------------------
# postprocess installation and deployment paths
#-------------------------------------------------------------------------------

if [ -z "$QT_INSTALL_PREFIX" ]; then
    if [ "$CFG_DEV" = "yes" ]; then
        QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default
    else
        QT_INSTALL_PREFIX="/usr/local/Qt-${QT_VERSION}" # the default install prefix is /usr/local/Qt-$QT_VERSION
    fi
fi
QT_INSTALL_PREFIX=`makeabs "$QT_INSTALL_PREFIX"`

if [ -z "$QT_EXT_PREFIX" ]; then
    QT_EXT_PREFIX=$QT_INSTALL_PREFIX
    if [ -n "$CFG_SYSROOT" ]; then
        QMAKE_SYSROOTIFY=true
    else
        QMAKE_SYSROOTIFY=false
    fi
else
    QT_EXT_PREFIX=`makeabs "$QT_EXT_PREFIX"`
    QMAKE_SYSROOTIFY=false
fi

if [ -z "$QT_HOST_PREFIX" ]; then
    if $QMAKE_SYSROOTIFY; then
        QT_HOST_PREFIX=$CFG_SYSROOT$QT_EXT_PREFIX
    else
        QT_HOST_PREFIX=$QT_EXT_PREFIX
    fi
    HAVE_HOST_PATH=false
else
    QT_HOST_PREFIX=`makeabs "$QT_HOST_PREFIX"`
    HAVE_HOST_PATH=true
fi

#------- make the paths relative to the prefixes --------

PREFIX_COMPLAINTS=
PREFIX_REMINDER=false
while read basevar baseoption var option; do
    eval path=\$QT_${basevar}_$var
    [ -z "$path" ] && continue
    path=`makeabs "$path"`
    eval base=\$QT_${basevar}_PREFIX
    rel=${path##$base}
    if [ x"$rel" = x"$path" ]; then
        if [ x"$option" != x"sysconf" ]; then
            PREFIX_COMPLAINTS="$PREFIX_COMPLAINTS
        NOTICE: -${option}dir is not a subdirectory of ${baseoption}prefix."
            eval \$HAVE_${basevar}_PATH || PREFIX_REMINDER=true
        fi
        eval QT_REL_${basevar}_$var=\$rel
    elif [ -z "$rel" ]; then
        eval QT_REL_${basevar}_$var=.
    else
        eval QT_REL_${basevar}_$var=\${rel#/}
    fi
done <<EOF
INSTALL - DOCS doc
INSTALL - HEADERS header
INSTALL - LIBS lib
INSTALL - LIBEXECS libexec
INSTALL - BINS bin
INSTALL - PLUGINS plugin
INSTALL - IMPORTS import
INSTALL - QML qml
INSTALL - ARCHDATA archdata
INSTALL - DATA data
INSTALL - TRANSLATIONS translation
INSTALL - EXAMPLES examples
INSTALL - TESTS tests
INSTALL - SETTINGS sysconf
HOST -host BINS hostbin
HOST -host LIBS hostlib
HOST -host DATA hostdata
EOF
$PREFIX_REMINDER && PREFIX_COMPLAINTS="$PREFIX_COMPLAINTS
        Maybe you forgot to specify -prefix/-hostprefix?"

if [ -z "$QT_REL_INSTALL_HEADERS" ]; then
    QT_REL_INSTALL_HEADERS=include
fi

if [ -z "$QT_REL_INSTALL_LIBS" ]; then
    QT_REL_INSTALL_LIBS=lib
fi

if [ -z "$QT_REL_INSTALL_BINS" ]; then
    QT_REL_INSTALL_BINS=bin
fi

if [ -z "$QT_REL_INSTALL_ARCHDATA" ]; then
    QT_REL_INSTALL_ARCHDATA=.
fi
if [ x"$QT_REL_INSTALL_ARCHDATA" != x. ]; then
    QT_REL_INSTALL_ARCHDATA_PREFIX=$QT_REL_INSTALL_ARCHDATA/
fi

if [ -z "$QT_REL_INSTALL_LIBEXECS" ]; then
    if [ "$XPLATFORM_MINGW" = "yes" ]; then
        QT_REL_INSTALL_LIBEXECS=${QT_REL_INSTALL_ARCHDATA_PREFIX}bin
    else
        QT_REL_INSTALL_LIBEXECS=${QT_REL_INSTALL_ARCHDATA_PREFIX}libexec
    fi
fi

if [ -z "$QT_REL_INSTALL_PLUGINS" ]; then
    QT_REL_INSTALL_PLUGINS=${QT_REL_INSTALL_ARCHDATA_PREFIX}plugins
fi

if [ -z "$QT_REL_INSTALL_IMPORTS" ]; then
    QT_REL_INSTALL_IMPORTS=${QT_REL_INSTALL_ARCHDATA_PREFIX}imports
fi

if [ -z "$QT_REL_INSTALL_QML" ]; then
    QT_REL_INSTALL_QML=${QT_REL_INSTALL_ARCHDATA_PREFIX}qml
fi

if [ -z "$QT_REL_INSTALL_DATA" ]; then
    QT_REL_INSTALL_DATA=.
fi
if [ x"$QT_REL_INSTALL_DATA" != x. ]; then
    QT_REL_INSTALL_DATA_PREFIX=$QT_REL_INSTALL_DATA/
fi

if [ -z "$QT_REL_INSTALL_DOCS" ]; then
    QT_REL_INSTALL_DOCS=${QT_REL_INSTALL_DATA_PREFIX}doc
fi

if [ -z "$QT_REL_INSTALL_TRANSLATIONS" ]; then
    QT_REL_INSTALL_TRANSLATIONS=${QT_REL_INSTALL_DATA_PREFIX}translations
fi

if [ -z "$QT_REL_INSTALL_EXAMPLES" ]; then
    QT_REL_INSTALL_EXAMPLES=examples
fi

if [ -z "$QT_REL_INSTALL_TESTS" ]; then
    QT_REL_INSTALL_TESTS=tests
fi

if [ -z "$QT_REL_INSTALL_SETTINGS" ]; then
    if [ "$XPLATFORM_MAC" = "yes" ]; then
        QT_REL_INSTALL_SETTINGS=/Library/Preferences/Qt
    else
        QT_REL_INSTALL_SETTINGS=etc/xdg
    fi
fi

#------- host paths --------

if [ -z "$QT_REL_HOST_BINS" ]; then
    if $HAVE_HOST_PATH; then
        QT_REL_HOST_BINS=bin
    else
        QT_REL_HOST_BINS=$QT_REL_INSTALL_BINS
    fi
fi

if [ -z "$QT_REL_HOST_LIBS" ]; then
    if $HAVE_HOST_PATH; then
        QT_REL_HOST_LIBS=lib
    else
        QT_REL_HOST_LIBS=$QT_REL_INSTALL_LIBS
    fi
fi

if [ -z "$QT_REL_HOST_DATA" ]; then
    if $HAVE_HOST_PATH; then
        QT_REL_HOST_DATA=.
    else
        QT_REL_HOST_DATA=$QT_REL_INSTALL_ARCHDATA
    fi
fi

if [ "$CFG_COMPILE_EXAMPLES" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG compile_examples"
fi

shortxspec=`echo $XQMAKESPEC | sed "s,^${relpath}/mkspecs/,,"`
shortspec=`echo $QMAKESPEC | sed "s,^${relpath}/mkspecs/,,"`

QT_CONFIGURE_STR_OFF=0

addConfStr()
{
    QT_CONFIGURE_STR_OFFSETS="$QT_CONFIGURE_STR_OFFSETS $QT_CONFIGURE_STR_OFF,"
    QT_CONFIGURE_STRS="$QT_CONFIGURE_STRS    \"$1\\0\"
"
    count=`echo "$1" | wc -c`
    QT_CONFIGURE_STR_OFF=`expr $QT_CONFIGURE_STR_OFF + $count`
}

QT_CONFIGURE_STR_OFFSETS=
QT_CONFIGURE_STRS=
addConfStr "$QT_REL_INSTALL_DOCS"
addConfStr "$QT_REL_INSTALL_HEADERS"
addConfStr "$QT_REL_INSTALL_LIBS"
addConfStr "$QT_REL_INSTALL_LIBEXECS"
addConfStr "$QT_REL_INSTALL_BINS"
addConfStr "$QT_REL_INSTALL_PLUGINS"
addConfStr "$QT_REL_INSTALL_IMPORTS"
addConfStr "$QT_REL_INSTALL_QML"
addConfStr "$QT_REL_INSTALL_ARCHDATA"
addConfStr "$QT_REL_INSTALL_DATA"
addConfStr "$QT_REL_INSTALL_TRANSLATIONS"
addConfStr "$QT_REL_INSTALL_EXAMPLES"
addConfStr "$QT_REL_INSTALL_TESTS"
QT_CONFIGURE_STR_OFFSETS_ALL=$QT_CONFIGURE_STR_OFFSETS
QT_CONFIGURE_STRS_ALL=$QT_CONFIGURE_STRS

QT_CONFIGURE_STR_OFFSETS=
QT_CONFIGURE_STRS=
addConfStr "$CFG_SYSROOT"
addConfStr "$QT_REL_HOST_BINS"
addConfStr "$QT_REL_HOST_LIBS"
addConfStr "$QT_REL_HOST_DATA"
addConfStr "$shortxspec"
addConfStr "$shortspec"

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

cat > "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
/* License Info */
static const char qt_configure_licensee_str          [256 + 12] = "qt_lcnsuser=$Licensee";
static const char qt_configure_licensed_products_str [256 + 12] = "qt_lcnsprod=$Edition";

/* Installation date */
static const char qt_configure_installation          [12+11]    = "qt_instdate=2012-12-20";

/* Installation Info */
static const char qt_configure_prefix_path_str       [256 + 12] = "qt_prfxpath=$QT_INSTALL_PREFIX";
#ifdef QT_BUILD_QMAKE
static const char qt_configure_ext_prefix_path_str   [256 + 12] = "qt_epfxpath=$QT_EXT_PREFIX";
static const char qt_configure_host_prefix_path_str  [256 + 12] = "qt_hpfxpath=$QT_HOST_PREFIX";
#endif

static const short qt_configure_str_offsets[] = {
    $QT_CONFIGURE_STR_OFFSETS_ALL
#ifdef QT_BUILD_QMAKE
    $QT_CONFIGURE_STR_OFFSETS
#endif
};
static const char qt_configure_strs[] =
$QT_CONFIGURE_STRS_ALL#ifdef QT_BUILD_QMAKE
$QT_CONFIGURE_STRS#endif
;

#define QT_CONFIGURE_SETTINGS_PATH "$QT_REL_INSTALL_SETTINGS"

#ifdef QT_BUILD_QMAKE
# define QT_CONFIGURE_SYSROOTIFY_PREFIX $QMAKE_SYSROOTIFY
#endif

/* 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
#ifdef QT_BUILD_QMAKE
# define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12
# define QT_CONFIGURE_HOST_PREFIX_PATH qt_configure_host_prefix_path_str + 12
#endif
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


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

# symlink includes
if [ -e "$relpath/.git" ]; then
    if [ -z "$PERL" ]; then
        echo
        echo "You need perl in your PATH to make a build from GIT."
        echo "Cannot proceed."
        exit 1
    fi

    "$relpath/bin/syncqt.pl" -minimal -module QtCore "$relpath" || exit 1
fi

# $1: input variable name (awk regexp)
# $2: optional output variable name
# $3: optional value transformation (sed command)
# relies on $QMAKESPEC, $COMPILER_CONF and $mkfile being set correctly, as the latter
# is where the resulting variable is written to
setBootstrapVariable()
{
    getQMakeConf "$1" | echo ${2-$1} = `if [ -n "$3" ]; then sed "$3"; else cat; fi` >> "$mkfile"
}

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

    mkdir -p "$outpath/qmake" || exit
    # 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) \$(QMAKE_CFLAGS_SPLIT_SECTIONS)"
        EXTRA_CXXFLAGS="\$(QMAKE_CXXFLAGS) \$(QMAKE_CXXFLAGS_SPLIT_SECTIONS)"
        EXTRA_LFLAGS="\$(QMAKE_LFLAGS) \$(QMAKE_LFLAGS_GCSECTIONS)"

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

        [ "$CFG_SILENT" = "yes" ] && CC_TRANSFORM='s,^,\@,' || CC_TRANSFORM=
        setBootstrapVariable QMAKE_CC CC "$CC_TRANSFORM"
        setBootstrapVariable QMAKE_CXX CXX "$CC_TRANSFORM"
        setBootstrapVariable QMAKE_CFLAGS
        setBootstrapVariable QMAKE_CFLAGS_SPLIT_SECTIONS
        setBootstrapVariable QMAKE_CXXFLAGS
        setBootstrapVariable QMAKE_CXXFLAGS_SPLIT_SECTIONS
        setBootstrapVariable QMAKE_LFLAGS
        setBootstrapVariable QMAKE_LFLAGS_GCSECTIONS

        if [ "$CFG_RELEASE_QMAKE" = "yes" ]; then
            setBootstrapVariable QMAKE_CFLAGS_RELEASE
            setBootstrapVariable QMAKE_CXXFLAGS_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
            EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_DEBUG)"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)"
        fi

        if [ -n "$RPATH_FLAGS" ] && [ -n "`getQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
            setBootstrapVariable "QMAKE_(LFLAGS_)?RPATH" QMAKE_LFLAGS_RPATH
            for rpath in $RPATH_FLAGS; do
                EXTRA_LFLAGS="\$(QMAKE_LFLAGS_RPATH)\"$rpath\" $EXTRA_LFLAGS"
            done
        fi
        if [ "$BUILD_ON_MSYS" = "yes" ]; then
            EXTRA_CFLAGS="-DUNICODE"
            EXTRA_CXXFLAGS="-DUNICODE"
            EXTRA_OBJS="qfilesystemengine_win.o \
                        qfilesystemiterator_win.o \
                        qfsfileengine_win.o \
                        qlocale_win.o \
                        qsettings_win.o \
                        qsystemlibrary.o \
                        registry.o"
            EXTRA_SRCS="\"\$(SOURCE_PATH)/src/corelib/corelib/io/qfilesystemengine_win.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/io/qsettings_win.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp\" \
                        \"\$(SOURCE_PATH)/tools/shared/windows/registry.cpp\""
            EXTRA_LFLAGS="-static -s -lole32 -luuid -ladvapi32 -lkernel32"
            EXEEXT=".exe"
        else
            EXTRA_OBJS="qfilesystemengine_unix.o \
                        qfilesystemiterator_unix.o \
                        qfsfileengine_unix.o \
                        qlocale_unix.o"
            EXTRA_SRCS="\"\$(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/tools/qlocale_unix.cpp\""
            EXEEXT=
        fi
        if [ "$BUILD_ON_MAC" = "yes" ]; then
            echo "COCOA_LFLAGS =-framework Foundation -framework CoreServices" >>"$mkfile"
            echo "CARBON_LFLAGS =-framework ApplicationServices" >>"$mkfile"
            echo "CARBON_CFLAGS =-fconstant-cfstrings" >>"$mkfile"
            EXTRA_LFLAGS="$EXTRA_LFLAGS \$(COCOA_LFLAGS)"
            EXTRA_LFLAGS="$EXTRA_LFLAGS \$(CARBON_LFLAGS)"
            EXTRA_CFLAGS="$EXTRA_CFLAGS \$(CARBON_CFLAGS)"
            EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(CARBON_CFLAGS)"
            EXTRA_OBJS="$EXTRA_OBJS \
                        qsettings_mac.o \
                        qcore_mac.o \
                        qcore_mac_objc.o"
            EXTRA_SRCS="$EXTRA_SRCS \
                        \"\$(SOURCE_PATH)/src/corelib/io/qsettings_mac.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac.cpp\" \
                        \"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac_objc.mm\""
        fi
        if [ '!' -z "$D_FLAGS" ]; then
            EXTRA_CFLAGS="$EXTRA_CFLAGS $D_FLAGS"
        fi
        echo >>"$mkfile"
	adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'`
	adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'`
	adjqmakespec=`echo "$QMAKESPEC" | sed 's/ /\\\\\\\\ /g'`

        echo "BUILD_PATH = .." >> "$mkfile"
        echo "SOURCE_PATH = $adjrelpath" >> "$mkfile"
        if [ -e "$relpath/.git" ]; then
            echo 'INC_PATH = $(BUILD_PATH)/include' >> "$mkfile"
        else
            echo 'INC_PATH = $(SOURCE_PATH)/include' >> "$mkfile"
        fi
        echo "QMAKESPEC = $adjqmakespec" >> "$mkfile"
        echo "QT_VERSION = $QT_VERSION" >> "$mkfile"
        echo "EXTRA_CFLAGS = $EXTRA_CFLAGS" >> "$mkfile"
        echo "EXTRA_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile"
        echo "QTOBJS =" $EXTRA_OBJS >> "$mkfile"
        echo "QTSRCS =" $EXTRA_SRCS >> "$mkfile"
        echo "LFLAGS = $EXTRA_LFLAGS" >> "$mkfile"
        echo "EXEEXT = $EXEEXT" >> "$mkfile"
        echo "RM_F = rm -f" >> "$mkfile"
        echo "RM_RF = rm -rf" >> "$mkfile"

        if [ "$BUILD_ON_MAC" = "yes" ]; then
            echo "EXTRA_CXXFLAGS += -MMD" >> "$mkfile"
            cat "$in_mkfile" >> "$mkfile"
            echo "-include \$(notdir \$(DEPEND_SRC:%.cpp=%.d))" >> "$mkfile"
        else
            cat "$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
        fi
    done

    if [ "$OPT_VERBOSE" = yes ]; then
        # Show the output of make
        (cd "$outpath/qmake"; "$MAKE") || exit 2
    else
        # Hide the output of make
        # Use bash to print dots, if we have it, and stdout is a tty.
        if test -t 1 && $WHICH bash > /dev/null 2>/dev/null; then
            bash -c 'set -o pipefail
                cd "$0/qmake"; "$1" | while read line; do
                    builtin echo -n .
                done' "$outpath" "$MAKE" || exit 2
        else
            (cd "$outpath/qmake"; "$MAKE" -s) || exit 2
        fi
        echo "Done."
    fi
fi # Build qmake

echo "Running configuration tests..."

#-------------------------------------------------------------------------------
# create a qt.conf for the Qt build tree itself
#-------------------------------------------------------------------------------

QTCONFFILE="$outpath/bin/qt.conf"
cat > "$QTCONFFILE" <<EOF
[EffectivePaths]
Prefix=..
EOF
if [ x"$relpath" != x"$outpath" ]; then
    cat >> "$QTCONFFILE" <<EOF
[EffectiveSourcePaths]
Prefix=$relpath
EOF
fi

#-------------------------------------------------------------------------------
# write out device config before we run the test.
#-------------------------------------------------------------------------------
DEVICE_VARS_OUTFILE="$outpath/mkspecs/qdevice.pri"
if cmp -s "$DEVICE_VARS_FILE" "$DEVICE_VARS_OUTFILE"; then
    rm -f "$DEVICE_VARS_FILE"
else
    mv -f $DEVICE_VARS_FILE "$DEVICE_VARS_OUTFILE"
    DEVICE_VARS_FILE="$DEVICE_VARS_OUTFILE"
fi

#-------------------------------------------------------------------------------
# Verify makespec
#-------------------------------------------------------------------------------
QMAKE_OUTPUT=`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "QT=" $DEV_NULL 2>&1`
if [ $? != "0" ]; then
    echo "Failed to process makespec for platform '$XPLATFORM'"
    if [ "$OPT_VERBOSE" = "yes" ]; then
        echo "$QMAKE_OUTPUT"
    else
        echo "Turn on verbose messaging (-v) to see the final report."
    fi
    exit 101
fi

#-------------------------------------------------------------------------------
# Detect pkg-config
#-------------------------------------------------------------------------------
if [ -z "$PKG_CONFIG" ]; then
    # See if PKG_CONFIG is set in the mkspec:
    PKG_CONFIG="`"$outpath/bin/qmake" -E -nocache -spec "$XQMAKESPEC" "CONFIG=" $DEV_NULL 2>&1 | sed -n -e 's,^PKG_CONFIG = \(.*\),\1,p'`"
    [ -n "$PKG_CONFIG" ] && [ "$OPT_VERBOSE" = "yes" ] && echo "Found pkg-config from mkspec: $PKG_CONFIG"
fi
if [ -z "$PKG_CONFIG" ]; then
    PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
    [ -n "$PKG_CONFIG" ] && [ "$OPT_VERBOSE" = "yes" ] && echo "Found pkg-config from \$PATH: $PKG_CONFIG"
fi

if [ "$CFG_PKGCONFIG" = "no" ]; then
    PKG_CONFIG=
    [ "$OPT_VERBOSE" = "yes" ] && echo "pkg-config support disabled."
elif [ -n "$PKG_CONFIG" ]; then
    # found a pkg-config
    if [ "$QT_CROSS_COMPILE" = "yes" ]; then
        # when xcompiling, check environment to see if it's actually usable
        if [ -z "$PKG_CONFIG_LIBDIR" ]; then
            if [ -n "$CFG_SYSROOT" ] && [ -d "$CFG_SYSROOT/usr/lib/pkgconfig" ]; then
                PKG_CONFIG_LIBDIR=$CFG_SYSROOT/usr/lib/pkgconfig:$CFG_SYSROOT/usr/share/pkgconfig
                if [ -n "$GCC_MACHINE_DUMP" ]; then
                    PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:$CFG_SYSROOT/usr/lib/$GCC_MACHINE_DUMP/pkgconfig
                fi
                export PKG_CONFIG_LIBDIR
                echo >&2 "Note: PKG_CONFIG_LIBDIR automatically set to $PKG_CONFIG_LIBDIR"
            elif [ "$CFG_PKGCONFIG" = "auto" ]; then
                PKG_CONFIG=
                echo >&2 "Warning: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and"
                echo >&2 "the host's .pc files would be used (even if you set PKG_CONFIG_PATH)."
                echo >&2 "Set this variable to the directory that contains target .pc files"
                echo >&2 "for pkg-config to function correctly when cross-compiling or"
                echo >&2 "use -pkg-config to override this test."
            fi
        fi
        if [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
            if [ -n "$CFG_SYSROOT" ]; then
                PKG_CONFIG_SYSROOT_DIR=$CFG_SYSROOT
                export PKG_CONFIG_SYSROOT_DIR
                echo >&2 "Note: PKG_CONFIG_SYSROOT_DIR automatically set to $PKG_CONFIG_SYSROOT_DIR"
            elif [ "$CFG_PKGCONFIG" = "auto" ]; then
                PKG_CONFIG=
                echo >&2 "Warning: Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set."
                echo >&2 "Set this variable to your sysroot for pkg-config to function correctly when"
                echo >&2 "cross-compiling or use -pkg-config to override this test."
            fi
        fi
    fi
    if [ -n "$PKG_CONFIG" ]; then
        CFG_PKGCONFIG=yes
    else
        CFG_PKGCONFIG=no
    fi
elif [ "$CFG_PKGCONFIG" = "yes" ]; then
    echo >&2 "Could not detect pkg-config from mkspec or PATH."
    exit 101
fi

if [ -z "$PKG_CONFIG" ]; then
    QT_CONFIG="$QT_CONFIG no-pkg-config"
fi

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

# parameters: path, name, extra args
compileTest()
{
    path=config.tests/$1
    name=$2
    shift 2
    # allow config tests which behave differently depending on the type of
    # library being built (shared/static) e.g. see config.tests/unix/icu
    test_config="$QMAKE_CONFIG shared"
    if [ "$CFG_SHARED" = "no" ]; then
        test_config="$QMAKE_CONFIG static"
    fi
    "$unixtests/compile.test" "$XQMAKESPEC" "$test_config" $OPT_VERBOSE "$relpath" "$outpath" "$path" "$name" $I_FLAGS $D_FLAGS $L_FLAGS "$@"
}

compileTestWithPkgConfig()
{
    if [ $# -lt 4 ]; then
        echo "CompileTestWithPkgConfig requires at least 4 arguments."
        echo "compileTestWithPkgConfig pkg_name configtest configtest_name qmake_postfix + additional arguments to compileTest"
        exit 1
    fi

    local pkg_name=$1
    local configtest=$2
    local configtest_name="$3"
    local qmake_postfix=$4
    shift 4

    local has_used_pkg_config="no"

    local incdir_raw incdir_mod cflags
    local libdir_raw libdir_mod libs
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists $pkg_name 2>/dev/null; then
        incdir_raw=`$PKG_CONFIG --cflags-only-I $pkg_name 2>/dev/null`
        cflags=`$PKG_CONFIG --cflags-only-other $pkg_name 2>/dev/null`
        libdir_raw=`$PKG_CONFIG --libs-only-L $pkg_name 2>/dev/null`
        libs=`$PKG_CONFIG --libs-only-l --libs-only-other $pkg_name 2>/dev/null`
        incdir_mod=`echo $incdir_raw | sed -e 's,^-I,,g' -e 's, -I, ,g'`
        libdir_mod=`echo $libdir_raw | sed -e 's,^-L,,g' -e 's, -L, ,g'`
        has_used_pkg_config="yes"
    fi
    if compileTest $configtest "$configtest_name" $libdir_raw $incdir_raw $libs $cflags "$@"; then
        if [ "$has_used_pkg_config" = "yes" ] && [ -n "$qmake_postfix" ]; then
            QMakeVar set QMAKE_INCDIR_$qmake_postfix "`shellArgumentListToQMakeList $incdir_mod`"
            QMakeVar set QMAKE_LIBDIR_$qmake_postfix "`shellArgumentListToQMakeList $libdir_mod`"
            QMakeVar set QMAKE_LIBS_$qmake_postfix "`shellArgumentListToQMakeList $libs`"
            QMakeVar set QMAKE_CFLAGS_$qmake_postfix "`shellArgumentListToQMakeList $cflags`"
        fi
        return 0
    else
        return 1
    fi
}

#-------------------------------------------------------------------------------
# determine the target and host architectures
#-------------------------------------------------------------------------------

# Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is
OUTFILE=$outpath/arch.result
"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $I_FLAGS $D_FLAGS $L_FLAGS
if [ $? -eq 0 ]; then
    eval `cat "$OUTFILE"`
else
    echo
    echo "Could not determine the target architecture!"
    echo "Turn on verbose messaging (-v) to see the final report."
fi
rm -f "$OUTFILE" 2>/dev/null
[ -z "$CFG_ARCH" ] && CFG_ARCH="unknown"

if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then
    # Do the same test again, using the host compiler
    SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $I_FLAGS $D_FLAGS $L_FLAGS
    if [ $? -eq 0 ]; then
        eval `cat "$OUTFILE"`
    else
        echo
        echo "Could not determine the host architecture!"
        echo "Turn on verbose messaging (-v) to see the final report."
    fi
    rm -f "$OUTFILE" 2>/dev/null
    [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown"
else
    # not cross compiling, host == target
    CFG_HOST_ARCH="$CFG_ARCH"
    CFG_HOST_CPUFEATURES="$CFG_CPUFEATURES"
fi
unset OUTFILE

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

#-------------------------------------------------------------------------------
# functionality tests
#-------------------------------------------------------------------------------

# Detect objcopy support
if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
    if ! compileTest unix/objcopy "objcopy"; then
        echo "ERROR: -separate-debug-info was requested but this binutils does not support it."
        echo "Re-run configure with -v for more information"
        exit 1
    fi
fi

# Detect C++11 support
if [ "$CFG_CXX11" != "no" ]; then
    # Configure detects compiler features based on cross compiler, so we need
    # to explicitly disable C++11 on Mac to avoid breaking builds where the
    # host compiler does not support it.
    if [ "$BUILD_ON_MAC" = "yes" ] && [ "$XPLATFORM_ANDROID" = "yes" ]; then
        CFG_CXX11="no"
    elif compileTest common/c++11 "C++11"; then
        CFG_CXX11="yes"
    elif [ "$CFG_CXX11" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
        echo "C++11 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_CXX11="no"
    fi
fi

# Detect which edition of the C++ standard the compiler defaults to
CFG_STDCXX_DEFAULT=199711
if compileTest common/c++default "default C++ standard edition"; then
    if [ -e "$outpath/config.tests/common/c++default/c++default.ii" ]; then
        CFG_STDCXX_DEFAULT=`sed -n '/^[0-9]/s/L//p' "$outpath/config.tests/common/c++default/c++default.ii"`
    else
        if [ "$OPT_VERBOSE" = "yes" ]; then
            echo "Failed to run the preprocessor, something is wrong with your compiler"
        fi
        if [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            exit 101
        fi
    fi
fi

# detect sse2 support
if [ "${CFG_SSE2}" = "auto" ]; then
    if compileTest common/sse2 "sse2"; then
       CFG_SSE2=yes
    else
       CFG_SSE2=no
    fi
fi

# detect sse3 support
if [ "${CFG_SSE2}" = "no" ]; then
    CFG_SSE3=no
fi
if [ "${CFG_SSE3}" = "auto" ]; then
    if compileTest common/sse3 "sse3"; then
       CFG_SSE3=yes
    else
       CFG_SSE3=no
    fi
fi

# detect ssse3 support
if [ "${CFG_SSE3}" = "no" ]; then
    CFG_SSSE3=no
fi
if [ "${CFG_SSSE3}" = "auto" ]; then
    if compileTest common/ssse3 "ssse3"; then
       CFG_SSSE3=yes
    else
       CFG_SSSE3=no
    fi
fi

# detect sse4.1 support
if [ "${CFG_SSSE3}" = "no" ]; then
    CFG_SSE4_1=no
fi
if [ "${CFG_SSE4_1}" = "auto" ]; then
    if compileTest common/sse4_1 "sse4_1"; then
       CFG_SSE4_1=yes
    else
       CFG_SSE4_1=no
    fi
fi

# detect sse4.2 support
if [ "${CFG_SSE4_1}" = "no" ]; then
    CFG_SSE4_2=no
fi
if [ "${CFG_SSE4_2}" = "auto" ]; then
    if compileTest common/sse4_2 "sse4_2"; then
       CFG_SSE4_2=yes
    else
       CFG_SSE4_2=no
    fi
fi

# detect avx support
if [ "${CFG_SSE4_2}" = "no" ]; then
    CFG_AVX=no
fi
if [ "${CFG_AVX}" = "auto" ]; then
    if compileTest common/avx "avx"; then
       case "$XQMAKESPEC" in
           *g++*|*-clang*)
               # Some clang versions produce internal compiler errors compiling Qt AVX code
               case `$TEST_COMPILER --version` in
                   Apple\ clang\ version\ [23]*)
                       CFG_AVX=no
                       if [ "$OPT_VERBOSE" = "yes" ]; then
                           echo 'AVX support disabled for blacklisted clang compiler'
                       fi
                       ;;
                   *)
                       CFG_AVX=yes
                       ;;
               esac
               ;;
           *)
               CFG_AVX=yes
               ;;
       esac
    else
       CFG_AVX=no
    fi
fi

# detect avx2 support
if [ "${CFG_AVX}" = "no" ]; then
    CFG_AVX2=no
fi
if [ "${CFG_AVX2}" = "auto" ]; then
    if compileTest common/avx2 "avx2"; then
       CFG_AVX2=yes
    else
       CFG_AVX2=no
    fi
fi

# check Neon support
if [ "$CFG_NEON" = "auto" ]; then
    # no compile test, just check what the compiler has
    case "$CFG_CPUFEATURES" in
        *neon*)
            CFG_NEON=yes
            ;;
        *)
            CFG_NEON=no
            ;;
    esac
fi

# detect mips_dsp support
if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSP}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dsp "mips_dsp" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
        CFG_MIPS_DSP=yes
    else
        CFG_MIPS_DSP=no
    fi
elif [ "$CFG_ARCH" != "mips" ]; then
    CFG_MIPS_DSP=no
fi

# detect mips_dspr2 support
if [ "$CFG_ARCH" = "mips" ] && [ "${CFG_MIPS_DSPR2}" = "auto" ]; then
    if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mips_dspr2 "mips_dspr2" $L_FLAGS $I_FLAGS $D_FLAGS $l_FLAGS; then
        CFG_MIPS_DSPR2=yes
    else
        CFG_MIPS_DSPR2=no
    fi
elif [ "$CFG_ARCH" != "mips" ]; then
    CFG_MIPS_DSPR2=no
fi

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

# check IPC support
if ! compileTest unix/ipc_sysv "ipc_sysv" ; then
    # SYSV IPC is not supported - check POSIX IPC
    if compileTest unix/ipc_posix "ipc_posix" ; then
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_POSIX_IPC"
    else
        if [ "$XPLATFORM_ANDROID" = "no" ] ; then
            QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SYSTEMSEMAPHORE QT_NO_SHAREDMEMORY"
        fi
    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 [ "$XPLATFORM_QNX" = "yes" ]; then
    if [ "$CFG_SLOG2" != "no" ]; then
        if compileTest unix/slog2 "slog2"; then
            CFG_SLOG2=yes
            QMAKE_CONFIG="$QMAKE_CONFIG slog2"
        else
            CFG_SLOG2=no
        fi
    fi
    if [ "$CFG_QNX_IMF" != "no" ]; then
        if compileTest unix/qqnx_imf "qqnx_imf"; then
            CFG_QNX_IMF=yes
            QMAKE_CONFIG="$QMAKE_CONFIG qqnx_imf"
        else
            CFG_QNX_IMF=no
        fi
    fi
    if [ "$CFG_PPS" != "no" ]; then
        if compileTest unix/pps "pps"; then
            CFG_PPS=yes
            QMAKE_CONFIG="$QMAKE_CONFIG qqnx_pps"
        else
            CFG_PPS=no
        fi
    fi

    if [ "$CFG_LGMON" != "no" ]; then
        if compileTest unix/lgmon "lgmon"; then
            CFG_LGMON=yes
            QMAKE_CONFIG="$QMAKE_CONFIG lgmon"
        else
            CFG_LGMON=no
        fi
    fi
fi

if [ "$CFG_ZLIB" = "auto" ]; then
    if compileTest unix/zlib "zlib"; then
       CFG_ZLIB=system
    else
       CFG_ZLIB=yes
    fi
fi

if [ "$CFG_MTDEV" != "no" ]; then
    if compileTest unix/mtdev "mtdev"; then
        CFG_MTDEV=yes
    else
        CFG_MTDEV=no
    fi
fi
if [ "$CFG_MTDEV" = "no" ]; then
    QMakeVar add DEFINES QT_NO_MTDEV
fi

if [ "$CFG_JOURNALD" != "no" ]; then
    if compileTest unix/journald "journald"; then
        CFG_JOURNALD=yes
        QMAKE_CONFIG="$QMAKE_CONFIG journald"
    else
        if [ "$CFG_JOURNALD" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "journald 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_JOURNALD=no
        fi
    fi
fi

if [ "$CFG_SYSLOG" != "no" ]; then
    if compileTest unix/syslog "syslog"; then
        CFG_SYSLOG=yes
        QMAKE_CONFIG="$QMAKE_CONFIG syslog"
    else
        if [ "$CFG_SYSLOG" != "auto" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "syslog 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_SYSLOG=no
        fi
    fi
fi

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

if [ "$CFG_GUI" = "no" ]; then
    QPA_PLATFORM_GUARD=no
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 compileTest unix/libjpeg "libjpeg"; 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 png
if [ "$CFG_LIBPNG" = "auto" ]; then
    if compileTest unix/libpng "libpng"; then
       CFG_LIBPNG=system
    else
       CFG_LIBPNG=qt
    fi
fi

if [ "$CFG_EGLFS" = "yes" ]; then
    if [ "$CFG_EGL" = "no" ]; then
        echo "The EGLFS plugin requires EGL support and cannot be built"
        exit 101
    fi
    CFG_EGL=yes
fi

if [ "$CFG_KMS" = "yes" ]; then
    if [ "$CFG_EGL" = "no" ]; then
        echo "The KMS plugin requires EGL support and cannot be built"
        exit 101
    fi
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 | filterIncludeOptions`
                    QT_LFLAGS_MYSQL_R=`$CFG_MYSQL_CONFIG --libs_r 2>/dev/null | filterLibraryOptions`
                    QT_LFLAGS_MYSQL=`$CFG_MYSQL_CONFIG --libs 2>/dev/null | filterLibraryOptions`
		    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 compileTest unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $QT_CFLAGS_MYSQL; 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 compileTest unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $QT_CFLAGS_MYSQL; 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
                [ -z "$CFG_PSQL_CONFIG" ] && CFG_PSQL_CONFIG=`"$WHICH" pg_config`
                # Be careful not to use native pg_config when cross building.
                if [ "$XPLATFORM_MINGW" != "yes" ] && [ -x "$CFG_PSQL_CONFIG" ]; then
                    QT_CFLAGS_PSQL=`$CFG_PSQL_CONFIG --includedir 2>/dev/null | filterIncludePath`
                    QT_LFLAGS_PSQL=`$CFG_PSQL_CONFIG --libdir 2>/dev/null | filterLibraryPath`
                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 compileTest unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $QT_CFLAGS_PSQL; 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 [ "$XPLATFORM_MAC" != "yes" ] && compileTest unix/odbc "ODBC"; then
                    if [ "$CFG_SQL_odbc" = "auto" ]; then
                        CFG_SQL_odbc=plugin
                    fi
                else
                    if compileTest unix/iodbc "iODBC"; 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 compileTest unix/oci "OCI"; 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 compileTest unix/tds "TDS" $QT_LFLAGS_TDS; 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 compileTest unix/db2 "DB2"; 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 compileTest unix/ibase "InterBase"; 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 compileTest unix/sqlite2 "SQLite2"; 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" != "no" ]; then
                SQLITE_AUTODETECT_FAILED="no"
                if [ "$CFG_SQLITE" = "system" ]; then
                    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists sqlite3 2>/dev/null; then
                        QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null`
                        QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null`
                    else
                        QT_CFLAGS_SQLITE=
                        QT_LFLAGS_SQLITE="-lsqlite3 -lz"
                    fi
                    if compileTest unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $QT_CFLAGS_SQLITE; 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 compileTest unix/nis "NIS"; 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 compileTest unix/cups "Cups"; 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 [ "$XPLATFORM_MINGW" = "yes" ]; then
        CFG_ICONV=no
    elif compileTest unix/iconv "POSIX iconv"; then
        CFG_ICONV=yes
    elif compileTest unix/sun-libiconv "SUN libiconv"; then
        CFG_ICONV=sun
    elif compileTest unix/gnu-libiconv "GNU libiconv"; 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" = "auto" ]; then
    CFG_DBUS="runtime"
fi
if [ "$CFG_DBUS" = "linked" ]; 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`
    else
        QT_LIBS_DBUS="-ldbus-1"
    fi
    if compileTest unix/dbus "D-Bus" $QT_CFLAGS_DBUS $QT_LIBS_DBUS; then
        QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS"
        QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS"
        # Try find correct host configuration for dbus tools when cross-compiling
        if [ "$QT_CROSS_COMPILE" = "yes" ] && env -i PATH="$PATH" \
                pkg-config --atleast-version="$MIN_DBUS_1_VERSION" dbus-1 2>/dev/null; then
            QT_CFLAGS_DBUS=`env -i PATH="$PATH" pkg-config --cflags dbus-1 2>/dev/null`
        fi
        QMakeVar set QT_HOST_CFLAGS_DBUS "$QT_CFLAGS_DBUS"
    else
        if [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "The Qt D-Bus module cannot be enabled because libdbus-1 version $MIN_DBUS_1_VERSION was not found."
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            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

# auto-detect libproxy support
if [ "$CFG_LIBPROXY" != "no" ]; then
    if compileTest common/libproxy "libproxy"; then
        CFG_LIBPROXY=yes
    else
        if [ "$CFG_LIBPROXY" = "auto" ]; then
            CFG_LIBPROXY=no
        elif [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            # CFG_LIBPROXY is "yes" here
            echo "The libproxy support cannot be enabled because libproxy 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

# 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 compileTest unix/glib "Glib" $QT_CFLAGS_GLIB $QT_LIBS_GLIB; 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!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            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

# auto-detect GTK style support
if [ "$CFG_GLIB" = "yes" -a "$CFG_QGTKSTYLE" != "no" ]; then
    if [ -n "$PKG_CONFIG" ]; then
        QT_CFLAGS_QGTK2=`$PKG_CONFIG --cflags gtk+-2.0 ">=" 2.18 atk 2>/dev/null`
        QT_LIBS_QGTK2=`$PKG_CONFIG --libs gtk+-2.0 2>/dev/null`
        QT_LIBS_QGOBJECT=`$PKG_CONFIG --libs gobject-2.0 2>/dev/null`
    fi
    if [ -n "$QT_CFLAGS_QGTK2" ] ; then
        CFG_QGTKSTYLE=yes
        QT_CONFIG="$QT_CONFIG gtk2 gtkstyle"
        QMakeVar set QT_CFLAGS_QGTKSTYLE "$QT_CFLAGS_QGTK2"
        QMakeVar set QT_LIBS_QGTKSTYLE "$QT_LIBS_QGOBJECT"
        QMakeVar set QT_CFLAGS_QGTK2 "$QT_CFLAGS_QGTK2"
        QMakeVar set QT_LIBS_QGTK2 "$QT_LIBS_QGTK2"
    else
        if [ "$CFG_QGTKSTYLE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "GTK theme support cannot be enabled due to functionality tests!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            echo " Turn on verbose messaging (-v) to $0 to see the fin  al 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

# auto-detect libicu support
if [ "$CFG_ICU" != "no" ]; then
    if compileTest unix/icu "ICU"; then
        [ "$CFG_ICU" = "auto" ] && CFG_ICU=yes
    else
        if [ "$CFG_ICU" = "auto" ]; then
            CFG_ICU=no
        elif [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            # CFG_ICU is "yes"

            echo "The ICU library support cannot be enabled."
            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

# 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 compileTest unix/pulseaudio "PulseAudio" $QT_CFLAGS_PULSEAUDIO $QT_LIBS_PULSEAUDIO; 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!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            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

# X11/MINGW OpenGL
if [ "$XPLATFORM_MINGW" = "yes" ]; then
    # auto-detect OpenGL support (es2 = OpenGL ES 2.0 or higher)
    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 compileTest x11/opengl "OpenGL"; then
            CFG_OPENGL=desktop
        elif compileTest unix/opengles2 "OpenGL ES 2.0"; then
            CFG_OPENGL=es2
        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
                compileTest x11/glxfbconfig "OpenGL"
                if [ $? != "0" ]; then
                    QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
                fi
            fi
            ;;
        *)
            ;;
        esac
    elif [ "$CFG_OPENGL" = "es2" ]; then
        #OpenGL ES 2.0
        compileTest unix/opengles2 "OpenGL ES 2.0"
        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
        compileTest x11/opengl "OpenGL"
        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.
            compileTest x11/glxfbconfig "OpenGL"
            if [ $? != "0" ]; then
                QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT
            fi
            ;;
        *)
            ;;
        esac
    fi
fi # X11/MINGW OpenGL

if [ "$XPLATFORM_MAC" = "yes" ]; then
    if [ "$CFG_COREWLAN" = "auto" ]; then
        if compileTest mac/corewlan "CoreWlan"; then
            CFG_COREWLAN=yes
        else
            CFG_COREWLAN=no
        fi
    fi
fi

# auto-detect OpenGL support (es2 = OpenGL ES 2.0 or higher)
if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
    if compileTestWithPkgConfig gl unix/opengldesktop "OpenGL" OPENGL; then
        CFG_OPENGL=desktop
    elif compileTestWithPkgConfig glesv2 unix/opengles2 "OpenGL ES 2.0" OPENGL_ES2; then
        CFG_OPENGL=es2
    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" = "es2" ]; then
    #OpenGL ES 2.0

    compileTestWithPkgConfig glesv2 unix/opengles2 "OpenGL ES 2.0" OPENGL_ES2
    if [ $? != "0" ]; then
        echo "The OpenGL ES 2.0 functionality test failed!"
        [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
        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
    compileTestWithPkgConfig gl unix/opengldesktop "OpenGL" OPENGL
    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

# If OpenGL ES 2.0 is enabled, check for 3.0 and higher. This is used to allow
# compile-time differentiation and including the version specific (but backwards
# compatible) ES headers (for example, GLES3/gl31.h). Other than that, there is
# no difference in the configuration, even the library is the same.
if [ "$CFG_OPENGL" = "es2" ]; then
    if compileTestWithPkgConfig glesv2 unix/opengles3 "OpenGL ES 3.0" ""; then
        # Add a define for ES3, in addition to ES and ES2.
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_3"
    fi
    if compileTestWithPkgConfig glesv2 unix/opengles31 "OpenGL ES 3.1" ""; then
        # Add a define for ES31.
        QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_3_1"
    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 compileTest unix/fontconfig "FontConfig" $QT_CFLAGS_FONTCONFIG $QT_LIBS_FONTCONFIG; then
        QT_CONFIG="$QT_CONFIG fontconfig"
        QMakeVar set QMAKE_CFLAGS_FONTCONFIG "$QT_CFLAGS_FONTCONFIG"
        QMakeVar set QMAKE_LIBS_FONTCONFIG "$QT_LIBS_FONTCONFIG"
        CFG_FONTCONFIG=yes
        CFG_FREETYPE=system
    else
        CFG_FONTCONFIG=no
    fi

fi

# Save these for a check later
ORIG_CFG_XCB="$CFG_XCB"
ORIG_CFG_EGLFS="$CFG_EGLFS"
ORIG_CFG_DIRECTFB="$CFG_DIRECTFB"
ORIG_CFG_LINUXFB="$CFG_LINUXFB"
ORIG_CFG_KMS="$CFG_KMS"
ORIG_CFG_MIRCLIENT="$CFG_MIRCLIENT"

if [ "$CFG_LIBUDEV" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists libudev 2>/dev/null; then
        QMAKE_INCDIR_LIBUDEV=`$PKG_CONFIG --cflags-only-I libudev 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
        QMAKE_LIBS_LIBUDEV=`$PKG_CONFIG --libs libudev 2>/dev/null`
        QMAKE_CFLAGS_LIBUDEV=`$PKG_CONFIG --cflags libudev 2>/dev/null`
        QMakeVar set QMAKE_INCDIR_LIBUDEV "$QMAKE_INCDIR_LIBUDEV"
        QMakeVar set QMAKE_LIBS_LIBUDEV "$QMAKE_LIBS_LIBUDEV"
    fi
    if compileTest unix/libudev "libudev" $QMAKE_CFLAGS_LIBUDEV $QMAKE_LIBS_LIBUDEV; then
        CFG_LIBUDEV=yes
        QT_CONFIG="$QT_CONFIG libudev"
    elif [ "$CFG_LIBUDEV" = "yes" ]; then
        echo "The libudev functionality test failed!"
        [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
        exit 1
    else
        CFG_LIBUDEV=no
    fi
fi
if [ "$CFG_LIBUDEV" = "no" ]; then
    QMakeVar add DEFINES QT_NO_LIBUDEV
fi

if [ "$CFG_EVDEV" != "no" ]; then
    if compileTest unix/evdev "evdev"; then
        CFG_EVDEV=yes
        QT_CONFIG="$QT_CONFIG evdev"
    elif [ "$CFG_EVDEV" = "yes" ]; then
        echo "The evdev functionality test failed!"
        exit 1
    else
        CFG_EVDEV=no
    fi
fi
if [ "$CFG_EVDEV" = "no" ]; then
    QMakeVar add DEFINES QT_NO_EVDEV
fi

if [ "$CFG_TSLIB" != "no" ]; then
    if compileTest unix/tslib "tslib"; then
        CFG_TSLIB=yes
        QT_CONFIG="$QT_CONFIG tslib"
    elif [ "$CFG_TSLIB" = "yes" ]; then
        echo "The tslib functionality test failed!"
        exit 1
    else
        CFG_TSLIB=no
    fi
fi
if [ "$CFG_TSLIB" = "no" ]; then
    QMakeVar add DEFINES QT_NO_TSLIB
fi

if [ "$CFG_XKBCOMMON_EVDEV" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists xkbcommon 2>/dev/null; then
        QMAKE_INCDIR_XKBCOMMON_EVDEV=`$PKG_CONFIG --cflags-only-I xkbcommon 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
        QMAKE_LIBS_XKBCOMMON_EVDEV=`$PKG_CONFIG --libs xkbcommon 2>/dev/null`
        QMAKE_CFLAGS_XKBCOMMON_EVDEV=`$PKG_CONFIG --cflags xkbcommon 2>/dev/null`
        QMakeVar set QMAKE_INCDIR_XKBCOMMON_EVDEV "$QMAKE_INCDIR_XKBCOMMON_EVDEV"
        QMakeVar set QMAKE_LIBS_XKBCOMMON_EVDEV "$QMAKE_LIBS_XKBCOMMON_EVDEV"
    fi
    if compileTest unix/xkbcommon "xkbcommon" $QMAKE_CFLAGS_XKBCOMMON_EVDEV $QMAKE_LIBS_XKBCOMMON_EVDEV; then
        CFG_XKBCOMMON_EVDEV=yes
        QT_CONFIG="$QT_CONFIG xkbcommon-evdev"
    elif [ "$CFG_XKBCOMMON_EVDEV" = "yes" ]; then
        echo "The xkbcommon-evdev functionality test failed!"
        exit 1
    else
        CFG_XKBCOMMON_EVDEV=no
    fi
fi

if [ "$CFG_LIBINPUT" != "no" ] && [ "$CFG_LIBUDEV" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists libinput 2>/dev/null; then
        QMAKE_INCDIR_LIBINPUT=`$PKG_CONFIG --cflags-only-I libinput 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
        QMAKE_LIBS_LIBINPUT=`$PKG_CONFIG --libs libinput 2>/dev/null`
        QMAKE_CFLAGS_LIBINPUT=`$PKG_CONFIG --cflags libinput 2>/dev/null`
        QMAKE_LIBINPUT_VERSION_MAJOR=`$PKG_CONFIG --modversion libinput 2>/dev/null | cut -d . -f 1`
        QMAKE_LIBINPUT_VERSION_MINOR=`$PKG_CONFIG --modversion libinput 2>/dev/null | cut -d . -f 2`
        QMakeVar set QMAKE_LIBINPUT_VERSION_MAJOR "$QMAKE_LIBINPUT_VERSION_MAJOR"
        QMakeVar set QMAKE_LIBINPUT_VERSION_MINOR "$QMAKE_LIBINPUT_VERSION_MINOR"
        QMakeVar set QMAKE_INCDIR_LIBINPUT "$QMAKE_INCDIR_LIBINPUT"
        QMakeVar set QMAKE_LIBS_LIBINPUT "$QMAKE_LIBS_LIBINPUT"
    fi
    if compileTest unix/libinput "libinput" $QMAKE_CFLAGS_LIBINPUT $QMAKE_LIBS_LIBINPUT; then
        CFG_LIBINPUT=yes
        QT_CONFIG="$QT_CONFIG libinput"
    elif [ "$CFG_LIBINPUT" = "yes" ]; then
        echo "The libinput functionality test failed!"
        exit 1
    else
        CFG_LIBINPUT=no
    fi
else
    CFG_LIBINPUT=no
fi
if [ "$CFG_LIBINPUT" = "no" ]; then
    QMakeVar add DEFINES QT_NO_LIBINPUT
fi

# Check we actually have X11 :-)
if compileTest x11/xlib "XLib"; then
    QT_CONFIG="$QT_CONFIG xlib"
fi

# auto-detect Xrender support
if [ "$CFG_XRENDER" != "no" ]; then
    if compileTest x11/xrender "Xrender"; then
        CFG_XRENDER=yes
        QT_CONFIG="$QT_CONFIG xrender"
    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 XInput2 support
if [ "$CFG_XINPUT2" != "no" ]; then
    if compileTest x11/xinput2 "XInput2"; then
        if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists xi 2>/dev/null; then
            QMAKE_LIBXI_VERSION_MAJOR=`$PKG_CONFIG --modversion xi 2>/dev/null | cut -d . -f 1`
            QMAKE_LIBXI_VERSION_MINOR=`$PKG_CONFIG --modversion xi 2>/dev/null | cut -d . -f 2`
            QMAKE_LIBXI_VERSION_PATCH=`$PKG_CONFIG --modversion xi 2>/dev/null | cut -d . -f 3`
            QMakeVar set QMAKE_LIBXI_VERSION_MAJOR "$QMAKE_LIBXI_VERSION_MAJOR"
            QMakeVar set QMAKE_LIBXI_VERSION_MINOR "$QMAKE_LIBXI_VERSION_MINOR"
            QMakeVar set QMAKE_LIBXI_VERSION_PATCH "$QMAKE_LIBXI_VERSION_PATCH"
        fi
        CFG_XINPUT2=yes
        CFG_XINPUT=no
    else
        if [ "$CFG_XINPUT2" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "XInput2 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_XINPUT2=no
        fi
    fi
fi

if [ "$CFG_XCB" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xcb >= 1.5" 2>/dev/null; then
        QMAKE_CFLAGS_XCB="`$PKG_CONFIG --cflags xcb 2>/dev/null`"
        QMAKE_LIBS_XCB="`$PKG_CONFIG --libs xcb 2>/dev/null`"
    fi
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "x11" 2> /dev/null; then
        QMAKE_X11_PREFIX="`$PKG_CONFIG --variable=prefix x11`"
    else
        # default to LSB prefix
        QMAKE_X11_PREFIX="/usr"
    fi
    QMakeVar set QMAKE_X11_PREFIX "$QMAKE_X11_PREFIX"

    if [ "$CFG_XKBCOMMON" != no ] && compileTest qpa/xcb "xcb" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
        QT_CONFIG="$QT_CONFIG xcb-plugin"

        if [ "$CFG_XCB" = "qt" ]; then
            QT_CONFIG="$QT_CONFIG xcb-qt"
        else
            CFG_XCB="system"
            if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xcb >= 1.5" 2>/dev/null; then
                XCB_PACKAGES="xcb xcb-shm xcb-sync xcb-xfixes xcb-randr xcb-image xcb-keysyms xcb-icccm xcb-shape"
                QMAKE_CFLAGS_XCB="`$PKG_CONFIG --cflags $XCB_PACKAGES 2>/dev/null`"
                QMAKE_LIBS_XCB="`$PKG_CONFIG --libs $XCB_PACKAGES 2>/dev/null`"
            fi

            # libxcb version 1.10 was the first version that enables xcb-xkb by default,
            # therefore the minimal xcb-xkb version we support is 1.10
            CFG_XKB=no
            if $PKG_CONFIG --exists "xcb-xkb >= 1.10" 2>/dev/null; then
                QMAKE_CFLAGS_XKB="`$PKG_CONFIG --cflags xcb xcb-xkb 2>/dev/null`"
                QMAKE_LIBS_XKB="`$PKG_CONFIG --libs xcb xcb-xkb 2>/dev/null`"
                if compileTest qpa/xcb-xkb "xcb-xkb" $QMAKE_CFLAGS_XKB $QMAKE_LIBS_XKB; then
                    CFG_XKB=yes
                fi
            fi
            if [ "$CFG_XKB" = "no" ]; then
                QMakeVar add DEFINES QT_NO_XKB
            fi

            if compileTest qpa/xcb-syslibs "xcb-syslibs" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
                if compileTest qpa/xcb-render "xcb-render" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
                    QT_CONFIG="$QT_CONFIG xcb-render"
                fi

                if compileTest qpa/xcb-glx "xcb-glx" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
                    CFG_XCB_GLX=yes
                    QT_CONFIG="$QT_CONFIG xcb-glx"
                fi
            else
                echo "The test for linking against libxcb and support libraries failed!"
                echo " You might need to install dependency packages, or pass -qt-xcb."
                echo " See src/plugins/platforms/xcb/README."
                exit 1
            fi
        fi

        if [ "$CFG_XCB_XLIB" != "no" ]; then
            if compileTest qpa/xcb-xlib "xcb-xlib" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then
                QT_CONFIG="$QT_CONFIG xcb-xlib"
                CFG_XCB_XLIB=yes
            else
                CFG_XCB_XLIB=no
            fi
        fi

        if [ "$CFG_SM" != "no" ] && [ -n "$PKG_CONFIG" ]; then
            if $PKG_CONFIG --exists "sm" 2>/dev/null && $PKG_CONFIG --exists "ice" 2>/dev/null; then
                QT_CONFIG="$QT_CONFIG xcb-sm"
            fi
        fi
    else
        if [ "$CFG_XCB" != "auto" ]; then
            echo "The test for linking against libxcb failed!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            echo " You might need to install dependency packages for libxcb."
            echo " See src/plugins/platforms/xcb/README."
            exit 1
        fi
        CFG_XCB=no
    fi
fi

if [ "$CFG_DIRECTFB" != "no" ]; then
    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists directfb 2>/dev/null; then
        QMAKE_CFLAGS_DIRECTFB=`$PKG_CONFIG --cflags directfb 2>/dev/null`
        QMAKE_LIBS_DIRECTFB=`$PKG_CONFIG --libs directfb 2>/dev/null`
        if compileTest qpa/directfb "DirectFB" $QMAKE_CFLAGS_DIRECTFB $QMAKE_LIBS_DIRECTFB; then
            CFG_DIRECTFB=yes
        elif [ "$CFG_DIRECTFB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo " DirectFB support cannot be enabled due to functionality tests!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            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_DIRECTFB=no
        fi
    else
        CFG_DIRECTFB=no
    fi
fi

if [ "$CFG_LINUXFB" != "no" ]; then
    if compileTest qpa/linuxfb "LinuxFB"; then
        CFG_LINUXFB=yes
    elif [ "$CFG_LINUXFB" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
        echo " Linux Framebuffer 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_LINUXFB=no
    fi
fi

if [ "$CFG_KMS" != "no" ]; then
    if compileTest qpa/kms "KMS"; then
        CFG_KMS=yes
    elif [ "$CFG_KMS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
        echo " KMS 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_KMS=no
    fi
fi

if [ "$CFG_MIRCLIENT" != "no" ]; then
    if compileTest qpa/mirclient "Mir client"; then
        CFG_MIRCLIENT=yes
    elif [ "$CFG_MIRCLIENT" = "yes" ]; then
        echo " Mir client 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_MIRCLIENT=no
    fi
fi

# Detect libxkbcommon
MIN_REQ_XKBCOMMON="0.4.1"
# currently only xcb platform plugin supports building xkbcommon
if [ "$CFG_XCB" != "no" ]; then
    if [ "$CFG_XKBCOMMON" != "no" ] && [ "$CFG_XKBCOMMON" != "qt" ]; then
        # Check if there is a suitable system-wide xkbcommon
        if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xkbcommon xkbcommon-x11 >= $MIN_REQ_XKBCOMMON" 2>/dev/null; then
            QMAKE_CFLAGS_XKBCOMMON="`$PKG_CONFIG --cflags xkbcommon xkbcommon-x11 2>/dev/null`"
            QMAKE_LIBS_XKBCOMMON="`$PKG_CONFIG --libs xkbcommon xkbcommon-x11 2>/dev/null`"

            QMakeVar set QMAKE_CFLAGS_XKBCOMMON "$QMAKE_CFLAGS_XKBCOMMON"
            QMakeVar set QMAKE_LIBS_XKBCOMMON "$QMAKE_LIBS_XKBCOMMON"
            CFG_XKBCOMMON=system
        elif [ "$CFG_XKBCOMMON" = "system" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo " xkbcommon support cannot be enabled because either xkbcommon or "
            echo " xkbcommon-x11 >= $MIN_REQ_XKBCOMMON was not found via pkg-config!"
            [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
            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
            # use the bundled version instead
            CFG_XKBCOMMON=qt
        fi
    fi
    if [ "$CFG_XKBCOMMON" = "qt" ]; then
        QT_CONFIG="$QT_CONFIG xkbcommon-qt"
        # detect XKB config root
        if [ "$CFG_XKB_CONFIG_ROOT" = "auto" ]; then
            if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xkeyboard-config" 2> /dev/null; then
                CFG_XKB_CONFIG_ROOT="`$PKG_CONFIG --variable=xkb_base xkeyboard-config`"
            else
                # search for xkb configs in most probable locations
                if [ -d "/usr/share/X11/xkb" ]; then
                    # Linux
                    CFG_XKB_CONFIG_ROOT="/usr/share/X11/xkb"
                elif [ -d "/usr/local/share/X11/xkb" ]; then
                    # BSD UNIX
                    CFG_XKB_CONFIG_ROOT="/usr/local/share/X11/xkb"
                fi
            fi
        fi
        QMakeVar set QMAKE_XKB_CONFIG_ROOT "$CFG_XKB_CONFIG_ROOT"
        if [ "$CFG_XKB_CONFIG_ROOT" = "auto" ]; then
            CFG_XKB_CONFIG_ROOT="not found"
        fi
    fi
else
    CFG_XKBCOMMON=no
fi

# EGL Support
if [ "$CFG_EGL" != "no" ]; then
    if [ "$CFG_EGL" = "yes" ] && [ "$CFG_OPENGL" = "no" ]; then
        echo "EGL support was requested but OpenGL support is disabled."
        echo "Either disable EGL support or enable OpenGL support."
        exit 101
    fi

    if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists egl 2>/dev/null; then
        QMAKE_INCDIR_EGL=`$PKG_CONFIG --cflags-only-I egl 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
        QMAKE_LIBS_EGL=`$PKG_CONFIG --libs egl 2>/dev/null`
        QMAKE_CFLAGS_EGL=`$PKG_CONFIG --cflags egl 2>/dev/null`
        QMakeVar set QMAKE_INCDIR_EGL "$QMAKE_INCDIR_EGL"
        QMakeVar set QMAKE_LIBS_EGL "$QMAKE_LIBS_EGL"
        QMakeVar set QMAKE_CFLAGS_EGL "`echo " $QMAKE_CFLAGS_EGL " | sed -e 's, -I[^ ]* , ,g;s,^ ,,;s, $,,'`"
    fi       # detect EGL support
    if compileTest qpa/egl "EGL" $QMAKE_CFLAGS_EGL $QMAKE_LIBS_EGL; then
        CFG_EGL=yes
        if compileTest qpa/egl-x11 "EGL-X11" $QMAKE_CFLAGS_EGL $QMAKE_LIBS_EGL || [ "$CFG_FORCE_EGL_X" = "yes" ]; then
            CFG_EGL_X=yes
        else
            CFG_EGL_X=no
        fi
    elif [ "$CFG_EGL" = "yes" ]; then
        echo " The EGL functionality test failed; EGL is required by some QPA plugins to manage contexts & surfaces."
        [ -z "$PKG_CONFIG" ] && echo " Use of pkg-config is not enabled, maybe you want to pass -pkg-config?"
        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 ${XQMAKESPEC}."
        exit 1
    else
        CFG_EGL=no
        CFG_EGL_X=no
    fi
fi

if [ "$CFG_EGLFS" != "no" ]; then
    if [ "$XPLATFORM_QNX" = "no" ] && [ "$CFG_OPENGL" != "no" ]; then
        CFG_EGLFS="$CFG_EGL"
        # Detect eglfs backends.
        if compileTest qpa/eglfs-brcm "eglfs-brcm"; then
            CFG_EGLFS_BRCM=yes
        else
            CFG_EGLFS_BRCM=no
        fi
        if compileTest qpa/eglfs-mali "eglfs-mali"; then
            CFG_EGLFS_MALI=yes
        else
            CFG_EGLFS_MALI=no
        fi
        if compileTest qpa/eglfs-viv "eglfs-viv"; then
            CFG_EGLFS_VIV=yes
        else
            CFG_EGLFS_VIV=no
        fi
    else
        CFG_EGLFS="no"
    fi
fi

if [ "$CFG_KMS" = "yes" ]; then
    if [ "$CFG_EGL" = "yes" ]; then
        CFG_KMS="yes"
    else
        CFG_KMS="no"
    fi
fi

# Detect accessibility support
if [ "$CFG_ACCESSIBILITY" = "no" ]; then
    echo >&2 "Warning: Disabling Accessibility. This version of Qt is unsupported."
else
    CFG_ACCESSIBILITY=yes

    # linux/xcb accessibility bridge needs dbus
    if [ "$CFG_XCB" != "no" ]; then
        if [ "$CFG_DBUS" != "no" ]; then
            CFG_ACCESSIBILITY_ATSPI_BRIDGE=yes
            QT_CONFIG="$QT_CONFIG accessibility-atspi-bridge"
        else
            echo >&2 "Warning: Disabling Linux Accessibility Bridge: DBus is missing."
            QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ACCESSIBILITY_ATSPI_BRIDGE"
        fi
    fi
fi

# Determine the default QPA platform
if [ -z "$QT_QPA_DEFAULT_PLATFORM" ]; then
    # check the mkspec
    QT_QPA_DEFAULT_PLATFORM=`getXQMakeConf QT_QPA_DEFAULT_PLATFORM`
    if [ -z "$QT_QPA_DEFAULT_PLATFORM" ]; then
        if [ "$XPLATFORM_MINGW" = "yes" ]; then
            QT_QPA_DEFAULT_PLATFORM="windows"
        elif [ "$XPLATFORM_MAC" = "yes" ]; then
            QT_QPA_DEFAULT_PLATFORM="cocoa"
        elif [ "$UNAME_SYSTEM" = "QNX" ]; then
            QT_QPA_DEFAULT_PLATFORM="qnx"
        else
            QT_QPA_DEFAULT_PLATFORM="xcb"
        fi
    fi
fi

if [ -n "$QMAKE_CFLAGS_XCB" ] || [ -n "$QMAKE_LIBS_XCB" ]; then
    QMakeVar set QMAKE_CFLAGS_XCB "$QMAKE_CFLAGS_XCB"
    QMakeVar set QMAKE_LIBS_XCB "$QMAKE_LIBS_XCB"
fi

if [ "$CFG_DIRECTFB" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG directfb"
    QMakeVar set QMAKE_CFLAGS_DIRECTFB "$QMAKE_CFLAGS_DIRECTFB"
    QMakeVar set QMAKE_LIBS_DIRECTFB "$QMAKE_LIBS_DIRECTFB"
fi
if [ "$CFG_LINUXFB" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG linuxfb"
fi
if [ "$CFG_KMS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG kms"
fi
if [ "$CFG_MIRCLIENT" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG mirclient"
fi

if [ "$XPLATFORM_MAC" = "no" ] && [ "$XPLATFORM_MINGW" = "no" ] && [ "$XPLATFORM_QNX" = "no" ] && [ "$XPLATFORM_ANDROID" = "no" ] && [ "$XPLATFORM_HAIKU" = "no" ]; then
    if [ "$CFG_XCB" = "no" ] && [ "$CFG_EGLFS" = "no" ] && [ "$CFG_DIRECTFB" = "no" ] && [ "$CFG_LINUXFB" = "no" ] && [ "$CFG_KMS" = "no" ]  && [ "$CFG_MIRCLIENT" = "no" ]; then
        if [ "$QPA_PLATFORM_GUARD" = "yes" ] &&
            ( [ "$ORIG_CFG_XCB" = "auto" ] || [ "$ORIG_CFG_EGLFS" = "auto" ] || [ "$ORIG_CFG_DIRECTFB" = "auto" ] || [ "$ORIG_CFG_LINUXFB" = "auto" ] || [ "$ORIG_CFG_KMS" = "auto" ]  || [ "$ORIG_CFG_MIRCLIENT" = "auto" ] ); then
        echo "No QPA platform plugin enabled!"
        echo " If you really want to build without a QPA platform plugin you must pass"
        echo " -no-qpa-platform-guard to configure. Doing this will"
        echo " produce a Qt that can not run GUI applications."
        echo " The dependencies needed for xcb to build are listed in"
        echo " src/plugins/platforms/xcb/README"
        exit 1
    fi
fi
    fi

# freetype support
[ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_FREETYPE" = "auto" ] && CFG_FREETYPE=no
if [ "$CFG_FREETYPE" = "auto" ]; then
    if compileTest unix/freetype "FreeType"; then
        CFG_FREETYPE=system
    else
        CFG_FREETYPE=yes
    fi
fi

# harfbuzz support
if [ "$CFG_HARFBUZZ" = "system" ]; then
    if ! compileTest unix/harfbuzz "HarfBuzz"; then
        if [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo " HarfBuzz system library 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_HARFBUZZ=qt
        fi
    fi
fi
if [ "$XPLATFORM_MAC" = "yes" -a "$CFG_HARFBUZZ" != "qt" ]; then
    echo
    echo "WARNING: On OS X, AAT is supported only with -qt-harfbuzz."
    echo
fi

if ! compileTest unix/stl "STL" &&
    [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
    echo "STL functionality check failed! Cannot build Qt with this STL library."
    echo " Turn on verbose messaging (-v) to $0 to see the final report."
    exit 101
fi


# detect POSIX clock_gettime()
if [ "$CFG_CLOCK_GETTIME" = "auto" ]; then
    if compileTest unix/clock-gettime "POSIX clock_gettime()"; 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 compileTest unix/clock-monotonic "POSIX Monotonic Clock"; then
	CFG_CLOCK_MONOTONIC=yes
    else
	CFG_CLOCK_MONOTONIC=no
    fi
elif [ "$CFG_CLOCK_GETTIME" = "no" ]; then
    CFG_CLOCK_MONOTONIC=no
fi

# detect posix_fallocate
if [ "$CFG_POSIX_FALLOCATE" = "auto" ]; then
    if compileTest unix/posix_fallocate "posix_fallocate"; then
        CFG_POSIX_FALLOCATE=yes
    else
        CFG_POSIX_FALLOCATE=no
    fi
fi

# detect mremap
if [ "$CFG_MREMAP" = "auto" ]; then
    if compileTest unix/mremap "mremap"; 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 compileTest unix/getaddrinfo "getaddrinfo"; 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 compileTest unix/inotify "inotify"; 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 eventfd
if [ "$CFG_EVENTFD" != "no" ]; then
    if compileTest unix/eventfd "eventfd"; then
        CFG_EVENTFD=yes
    else
        if [ "$CFG_EVENTFD" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "eventfd 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_EVENTFD=no
        fi
    fi
fi

# find if the platform provides if_nametoindex (ipv6 interface name support)
if [ "$CFG_IPV6IFNAME" != "no" ]; then
    if compileTest unix/ipv6ifname "IPv6 interface name"; 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 compileTest unix/getifaddrs "getifaddrs"; 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

# find if the platform provides thread-safe CLOEXEC support
if compileTest unix/cloexec "cloexec"; then
    CFG_CLOEXEC=yes
fi

if [ "$XPLATFORM_MAC" = "yes" ] && [ "$CFG_SECURETRANSPORT" != "no" ] && ([ "$CFG_OPENSSL" = "no" ] || [ "$CFG_OPENSSL" = "auto" ]); then
    CFG_SECURETRANSPORT=yes
    CFG_OPENSSL=no
else
    CFG_SECURETRANSPORT=no
fi

# detect OpenSSL
if [ "$CFG_OPENSSL" != "no" ]; then
    if compileTest unix/openssl "OpenSSL"; 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
fi


# detect PCRE
if [ "$CFG_PCRE" != "qt" ]; then
    if compileTest unix/pcre "PCRE"; then
        CFG_PCRE=system
    else
        if [ "$CFG_PCRE" = "system" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
            echo "PCRE 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_PCRE=qt
        fi
    fi
fi

# detect OpenVG support
if [ "$CFG_OPENVG" != "no" ]; then
    if compileTest unix/openvg "OpenVG"; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
    elif compileTest unix/openvg "OpenVG" -config openvg_on_opengl; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
        CFG_OPENVG_ON_OPENGL=yes
    elif compileTest unix/openvg "OpenVG (lc includes)" -config lower_case_includes; then
        if [ "$CFG_OPENVG" = "auto" ]; then
            CFG_OPENVG=yes
        fi
        CFG_OPENVG_LC_INCLUDES=yes
    elif compileTest unix/openvg "OpenVG (lc includes)" -config "openvg_on_opengl lower_case_includes"; 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" ] && compileTest unix/shivavg "ShivaVG"; then
        CFG_OPENVG_SHIVA=yes
    fi
fi

if [ "$CFG_ALSA" = "auto" ]; then
    if compileTest unix/alsa "alsa"; then
        CFG_ALSA=yes
    else
        CFG_ALSA=no
    fi
fi

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

# detect GStreamer support
if [ "$CFG_GSTREAMER" = "auto" ] || [ "$CFG_GSTREAMER" = "yes" ]; then
    if compileTest unix/gstreamer "GStreamer 1.0" -config gst-1.0; then
        CFG_GSTREAMER=yes
        CFG_GSTREAMER_VERSION=1.0
    elif compileTest unix/gstreamer "GStreamer 0.10" -config gst-0.10; then
        CFG_GSTREAMER=yes
        CFG_GSTREAMER_VERSION=0.10
    else
        if [ "$CFG_GSTREAMER" = "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."
            exit 1
        fi
        CFG_GSTREAMER=no
    fi
elif [ "$CFG_GSTREAMER" = "0.10" ]; then
    if compileTest unix/gstreamer "GStreamer 0.10" -config gst-0.10; then
        CFG_GSTREAMER=yes
        CFG_GSTREAMER_VERSION=0.10
    else
        echo "The GStreamer 0.10 functionality test failed!"
        echo " Turn on verbose messaging (-v) to $0 to see the final report."
        exit 1
    fi
elif [ "$CFG_GSTREAMER" = "1.0" ]; then
    if compileTest unix/gstreamer "GStreamer 1.0" -config gst-1.0; then
        CFG_GSTREAMER=yes
        CFG_GSTREAMER_VERSION=1.0
    else
        echo "The GStreamer 1.0 functionality test failed!"
        echo " Turn on verbose messaging (-v) to $0 to see the final report."
        exit 1
    fi
fi

if [ "$CFG_LARGEFILE" != "yes" ] && [ "$XPLATFORM_MINGW" = "yes" ]; then
    echo "Warning: largefile support cannot be disabled for win32."
    CFG_LARGEFILE="yes"
fi

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

[ "$CFG_CXX11" = "yes" ] && QT_CONFIG="$QT_CONFIG c++11"

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

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

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

# enable egl on X
if [ "$CFG_EGL_X" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG egl_x11"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGL_X11"
fi

# enable eglfs
if [ "$CFG_EGLFS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG eglfs"
else
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGLFS"
fi
# eglfs backends
if [ "$CFG_EGLFS_BRCM" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG eglfs_brcm"
fi
if [ "$CFG_EGLFS_MALI" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG eglfs_mali"
fi
if [ "$CFG_EGLFS_VIV" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG eglfs_viv"
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

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

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

if [ "$CFG_SHARED" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG shared"
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG shared"
elif [ "$CFG_SHARED" = "no" ]; then
    QT_CONFIG="$QT_CONFIG static"
    QTCONFIG_CONFIG="$QTCONFIG_CONFIG static"
fi

#FIXME: qpa is implicit this should all be removed
QMAKE_CONFIG="$QMAKE_CONFIG qpa"
QT_CONFIG="$QT_CONFIG qpa"
QTCONFIG_CONFIG="$QTCONFIG_CONFIG qpa"

if [ "$CFG_LARGEFILE" = "yes" ] && [ "$XPLATFORM_MINGW" != "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG largefile"
fi
if [ "$CFG_USE_GNUMAKE" = "yes" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG GNUmake"
fi
[ "$CFG_REDUCE_EXPORTS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_exports"
[ "$CFG_STACK_PROTECTOR_STRONG" = "yes" ] && QT_CONFIG="$QT_CONFIG stack-protector-strong"
[ "$CFG_REDUCE_RELOCATIONS" = "yes" ] && QT_CONFIG="$QT_CONFIG reduce_relocations"
[ "$CFG_STRIP" = "no" ] && QMAKE_CONFIG="$QMAKE_CONFIG nostrip"
[ "$CFG_PRECOMPILE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG precompile_header"
[ "$CFG_USE_GOLD_LINKER" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG use_gold_linker"
[ "$CFG_ENABLE_NEW_DTAGS" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG enable_new_dtags"
if [ "$CFG_SEPARATE_DEBUG_INFO" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG separate_debug_info"
fi
[ "$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_AVX2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG avx2"
[ "$CFG_NEON" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG neon"
if [ "$CFG_ARCH" = "mips" ]; then
    [ "$CFG_MIPS_DSP" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG mips_dsp"
    [ "$CFG_MIPS_DSPR2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG mips_dspr2"
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_POSIX_FALLOCATE" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG posix_fallocate"
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_EVENTFD" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG eventfd"
fi
if [ "$CFG_CLOEXEC" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG threadsafe-cloexec"
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_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_FREETYPE" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-freetype"
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_FREETYPE"
elif [ "$CFG_FREETYPE" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-freetype"
else
    QT_CONFIG="$QT_CONFIG freetype"
fi
if [ "$CFG_HARFBUZZ" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-harfbuzz"
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_HARFBUZZ"
elif [ "$CFG_HARFBUZZ" = "system" ]; then
    QT_CONFIG="$QT_CONFIG system-harfbuzz"
else
    QT_CONFIG="$QT_CONFIG harfbuzz"
fi
if [ "$CFG_GUI" = "auto" ]; then
    CFG_GUI="yes"
fi
if [ "$CFG_GUI" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-gui"
    CFG_WIDGETS="no"
fi
if [ "$CFG_WIDGETS" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-widgets"
    QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_WIDGETS"
fi

if [ "$XPLATFORM_MAC" = "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

[ "$CFG_MTDEV" = "yes" ] && QT_CONFIG="$QT_CONFIG mtdev"
[ "$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_DBUS" != "no" ] && QT_CONFIG="$QT_CONFIG dbus"
[ "$CFG_DBUS" = "linked" ] && QT_CONFIG="$QT_CONFIG dbus-linked"
[ "$CFG_OPENSSL" = "yes" ] && QT_CONFIG="$QT_CONFIG openssl"
[ "$CFG_OPENSSL" = "linked" ] && QT_CONFIG="$QT_CONFIG openssl-linked"
[ "$CFG_SECURETRANSPORT" = "yes" ] && QT_CONFIG="$QT_CONFIG ssl securetransport"
[ "$CFG_LIBPROXY" = "yes" ] && QT_CONFIG="$QT_CONFIG libproxy"
[ "$CFG_XCB" != "no" ] && QT_CONFIG="$QT_CONFIG xcb"
[ "$CFG_XINPUT2" = "yes" ] && QT_CONFIG="$QT_CONFIG xinput2"
[ "$CFG_SYSTEM_PROXIES" = "yes" ] && QT_CONFIG="$QT_CONFIG system-proxies"
[ "$CFG_DIRECTWRITE" = "yes" ] && QT_CONFIG="$QT_CONFIG directwrite"

[ '!' -z "$DEFINES" ] && QMakeVar add DEFINES "$DEFINES"
[ '!' -z "$INCLUDES" ] && QMakeVar add INCLUDEPATH "$INCLUDES"
[ '!' -z "$L_FLAGS" ] && QMakeVar add LIBS "$L_FLAGS"

if [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; 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 [ -n "$RPATH_FLAGS" ]; then
        # add the user defined rpaths
	QMakeVar add QMAKE_RPATHDIR "$RPATH_FLAGS"
    fi
fi
if [ "$CFG_RPATH" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG rpath"
fi

if [ '!' -z "$W_FLAGS" ]; then
    # add the user defined warning flags
    QMakeVar add QMAKE_CFLAGS_WARN_ON "$W_FLAGS"
    QMakeVar add QMAKE_CXXFLAGS_WARN_ON "$W_FLAGS"
    QMakeVar add QMAKE_OBJECTIVE_CFLAGS_WARN_ON "$W_FLAGS"
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

[ "$CFG_GSTREAMER_VERSION" = "0.10" ] && QT_CONFIG="$QT_CONFIG gstreamer-0.10"
[ "$CFG_GSTREAMER_VERSION" = "1.0" ] && QT_CONFIG="$QT_CONFIG gstreamer-1.0"

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

if [ "$CFG_ICU" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG icu"
fi

if [ "$CFG_FORCE_ASSERTS" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG force_asserts"
fi

if [ "$CFG_SANITIZERS" != "none" ]; then

    QTCONFIG_CONFIG="$QTCONFIG_CONFIG sanitizer"

    if [ "$CFG_SANITIZE_ADDRESS" = "yes" ]; then
        QTCONFIG_CONFIG="$QTCONFIG_CONFIG sanitize_address"
    fi

    if [ "$CFG_SANITIZE_THREAD" = "yes" ]; then
        QTCONFIG_CONFIG="$QTCONFIG_CONFIG sanitize_thread"
    fi

    if [ "$CFG_SANITIZE_MEMORY" = "yes" ]; then
        QTCONFIG_CONFIG="$QTCONFIG_CONFIG sanitize_memory"
    fi

    if [ "$CFG_SANITIZE_UNDEFINED" = "yes" ]; then
        QTCONFIG_CONFIG="$QTCONFIG_CONFIG sanitize_undefined"
    fi
fi

if [ "$CFG_PCRE" = "qt" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG pcre"
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.
#
canBuildQtConcurrent="yes"

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.*)
                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"
	;;
esac

if [ "$CFG_GUI" = "no" ]; then
    # WebKit requires Qt GUI
    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"
else
    QT_CONFIG="$QT_CONFIG concurrent"
fi

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

# ### Vestige
if [ "$CFG_WEBKIT" = "debug" ]; then
    QMAKE_CONFIG="$QMAKE_CONFIG webkit-debug"
fi

# ### Vestige
if [ "$CFG_QML_DEBUG" = "no" ]; then
    QT_CONFIG="$QT_CONFIG no-qml-debug"
fi

case "$QMAKE_CONF_COMPILER" in
*clang*)
    # Clang
    COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -v 2>&1 | sed -n -E '
/^Apple (clang|LLVM) version /{s///; s/^([0-9]*)\.([0-9]*).*$/QT_APPLE_CLANG_MAJOR_VERSION=\1; QT_APPLE_CLANG_MINOR_VERSION=\2/;p;q;}
/^clang version /{s///; s/^([0-9]*)\.([0-9]*).*$/QT_CLANG_MAJOR_VERSION=\1; QT_CLANG_MINOR_VERSION=\2/;p;q;}'`
    eval "$COMPILER_VERSION"
    ;;
*icpc)
    # Intel CC
    COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -v 2>&1 | sed -n '
s/icpc version \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\) .*$/QT_ICC_MAJOR_VERSION=\1; QT_ICC_MINOR_VERSION=\2; QT_ICC_PATCH_VERSION=\3/p'`
    eval "$COMPILER_VERSION"
    ;;
*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
        ;;
    *)
        QT_GCC_MAJOR_VERSION=$COMPILER_VERSION
        QT_GCC_MINOR_VERSION=0
        QT_GCC_PATCH_VERSION=0
    esac

    ;;
*)
    #
    ;;
esac

#-------------------------------------------------------------------------------
# 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"
    cat "$CFG_QCONFIG_PATH" >>"$tmpconfig"
    echo "#endif" >>"$tmpconfig"
    ;;
esac

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_SHARED" = "no" ]; then
    cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
/* Qt was configured for a static build */
#if !defined(QT_SHARED) && !defined(QT_STATIC)
# define QT_STATIC
#endif

EOF
fi

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

if [ "$CFG_QREAL" != double ]; then
    echo "#define QT_COORD_TYPE $CFG_QREAL" >>"$outpath/src/corelib/global/qconfig.h.new"
    echo "#define QT_COORD_TYPE_STRING $CFG_QREAL_STRING" >>"$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 [ "$XPLATFORM_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

#REDUCE_RELOCATIONS is a elf/unix only thing, so not in windows configure.exe
if [ "$CFG_REDUCE_RELOCATIONS" = "yes" ]; then
    echo "#define QT_REDUCE_RELOCATIONS" >>"$outpath/src/corelib/global/qconfig.h.new"
fi

# Add compiler sub-architecture support
echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
echo "// Compiler sub-arch support" >>"$outpath/src/corelib/global/qconfig.h.new"
for SUBARCH in SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX AVX2 \
    MIPS_DSP MIPS_DSPR2; do
    eval "VAL=\$CFG_$SUBARCH"
    case "$VAL" in
        yes)
            echo "#define QT_COMPILER_SUPPORTS_$SUBARCH 1" \
                >>"$outpath/src/corelib/global/qconfig.h.new"
            ;;
    esac
done

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

# Add QPA to config.h
QCONFIG_FLAGS="$QCONFIG_FLAGS"

# 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_PNG" != "yes" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_PNG"
[ "$CFG_JPEG" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_JPEG"
[ "$CFG_ZLIB" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ZLIB"
[ "$CFG_DBUS" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DBUS"
[ "$CFG_LIBPROXY" = "no" ]   && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_LIBPROXY"

# 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_EVDEV" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EVDEV"
[ "$CFG_GLIB" != "yes" ]     && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GLIB"
[ "$CFG_QGTKSTYLE" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_GTK"
[ "$CFG_CLOCK_MONOTONIC" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CLOCK_MONOTONIC"
[ "$CFG_POSIX_FALLOCATE" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_POSIX_FALLOCATE"
[ "$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_EVENTFD" = "no" ]    && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EVENTFD"
[ "$CFG_CLOEXEC" = "yes" ]   && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_THREADSAFE_CLOEXEC=1"
[ "$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_OPENSSL" = "no" ] && [ "$CFG_SECURETRANSPORT" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SSL"
[ "$CFG_SECURETRANSPORT" = "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_SECURETRANSPORT"

[ "$CFG_SM" = "no" ]         && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SESSIONMANAGER"
[ "$CFG_TSLIB" = "no" ]      && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_TSLIB"
[ "$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"

# 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 [ -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

echo "#define QT_QPA_DEFAULT_PLATFORM_NAME \"$QT_QPA_DEFAULT_PLATFORM\"" >>"$outpath/src/corelib/global/qconfig.h.new"

# 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
    mv -f "$outpath/src/corelib/global/qconfig.h.new" "$outpath/src/corelib/global/qconfig.h"
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_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 [ "$CFG_DEV" = "yes" ]; then
    QT_CONFIG="$QT_CONFIG private_tests"
    if [ "$CFG_WERROR" != "no" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG warnings_are_errors"
    fi
    if [ "$CFG_HEADERSCLEAN" != "no" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG headersclean"
    fi
else
    if [ "$CFG_WERROR" = "yes" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG warnings_are_errors"
    fi
    if [ "$CFG_HEADERSCLEAN" = "yes" ]; then
        QMAKE_CONFIG="$QMAKE_CONFIG headersclean"
    fi
fi

cat >>"$QTCONFIG.tmp" <<EOF
#configuration
CONFIG += $QTCONFIG_CONFIG
host_build {
    QT_ARCH = $CFG_HOST_ARCH
    QT_TARGET_ARCH = $CFG_ARCH
} else {
    QT_ARCH = $CFG_ARCH
    QMAKE_DEFAULT_LIBDIRS = `shellQuoteLines "$DEFAULT_LIBDIRS"`
    QMAKE_DEFAULT_INCDIRS = `shellQuoteLines "$DEFAULT_INCDIRS"`
}
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_EDITION = $Edition
EOF

if [ "$Edition" != "OpenSource" ] && [ "$Edition" != "Preview" ]; then
    echo "QT_LICHECK = $Licheck" >> "$QTCONFIG.tmp"
    echo "QT_RELEASE_DATE = $ReleaseDate" >> "$QTCONFIG.tmp"
fi
echo >> "$QTCONFIG.tmp"

if [ "$CFG_SHARED" = "no" ]; then
    echo "QT_DEFAULT_QPA_PLUGIN = q$QT_QPA_DEFAULT_PLATFORM" >> "$QTCONFIG.tmp"
    echo >> "$QTCONFIG.tmp"
fi

if [ -n "$PKG_CONFIG_SYSROOT_DIR" ] || [ -n "$PKG_CONFIG_LIBDIR" ]; then
    echo "# pkgconfig" >> "$QTCONFIG.tmp"
    echo "PKG_CONFIG_SYSROOT_DIR = $PKG_CONFIG_SYSROOT_DIR" >> "$QTCONFIG.tmp"
    echo "PKG_CONFIG_LIBDIR = $PKG_CONFIG_LIBDIR" >> "$QTCONFIG.tmp"
    echo >> "$QTCONFIG.tmp"
fi

if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then
    echo "# sysroot" >>"$QTCONFIG.tmp"
    echo "!host_build {" >>"$QTCONFIG.tmp"
    echo "    QMAKE_CFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
    echo "    QMAKE_CXXFLAGS  += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
    echo "    QMAKE_LFLAGS    += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp"
    echo "}" >> "$QTCONFIG.tmp"
    echo >> "$QTCONFIG.tmp"
fi
if [ -n "$RPATH_FLAGS" ]; then
    echo "QMAKE_RPATHDIR += $RPATH_FLAGS" >> "$QTCONFIG.tmp"
fi
echo "QT_COMPILER_STDCXX = $CFG_STDCXX_DEFAULT" >> "$QTCONFIG.tmp"
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 [ -n "$QT_ICC_MAJOR_VERSION" ]; then
    echo "QT_ICC_MAJOR_VERSION = $QT_ICC_MAJOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_ICC_MINOR_VERSION = $QT_ICC_MINOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_ICC_PATCH_VERSION = $QT_ICC_PATCH_VERSION" >> "$QTCONFIG.tmp"
fi
if [ -n "$QT_CLANG_MAJOR_VERSION" ]; then
    echo "QT_CLANG_MAJOR_VERSION = $QT_CLANG_MAJOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_CLANG_MINOR_VERSION = $QT_CLANG_MINOR_VERSION" >> "$QTCONFIG.tmp"
fi
if [ -n "$QT_APPLE_CLANG_MAJOR_VERSION" ]; then
    echo "QT_APPLE_CLANG_MAJOR_VERSION = $QT_APPLE_CLANG_MAJOR_VERSION" >> "$QTCONFIG.tmp"
    echo "QT_APPLE_CLANG_MINOR_VERSION = $QT_APPLE_CLANG_MINOR_VERSION" >> "$QTCONFIG.tmp"
fi

if [ -n "$QMAKE_INCDIR_OPENGL_ES2" ]; then
    echo "#Qt opengl include path" >> "$QTCONFIG.tmp"
    echo "QMAKE_INCDIR_OPENGL_ES2 = `shellArgumentListToQMakeList "$QMAKE_INCDIR_OPENGL_ES2"`" >> "$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 qmodule.pri
#-------------------------------------------------------------------------------
QTMODULE="$outpath/mkspecs/qmodule.pri"

echo "CONFIG += $QMAKE_CONFIG" >> "$QTMODULE.tmp"
echo "QT_BUILD_PARTS += $CFG_BUILD_PARTS" >> "$QTMODULE.tmp"
if [ -n "$CFG_SKIP_MODULES" ]; then
    echo "QT_SKIP_MODULES += $CFG_SKIP_MODULES" >> "$QTMODULE.tmp"
fi
DISABLED_FEATURES=
for cfg in $QCONFIG_FLAGS; do
    ncfg=${cfg#QT_NO_}
    if [ x$ncfg != x$cfg ]; then
        DISABLED_FEATURES="$DISABLED_FEATURES $ncfg"
    fi
done
if [ -n "$DISABLED_FEATURES" ]; then
    echo "QT_NO_DEFINES = $DISABLED_FEATURES" >> "$QTMODULE.tmp"
fi
echo "QT_QCONFIG_PATH = ${CFG_QCONFIG_PATH#$relpath/src/corelib/global/}" >> "$QTMODULE.tmp"

cat >>"$QTMODULE.tmp" <<EOF
host_build {
    QT_CPU_FEATURES.$CFG_HOST_ARCH = $CFG_HOST_CPUFEATURES
} else {
    QT_CPU_FEATURES.$CFG_ARCH = $CFG_CPUFEATURES
}
EOF
echo "QT_COORD_TYPE = $CFG_QREAL" >> "$QTMODULE.tmp"

if [ -n "$QT_CFLAGS_PSQL" ]; then
    echo "QT_CFLAGS_PSQL   = $QT_CFLAGS_PSQL" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_LFLAGS_PSQL" ]; then
    echo "QT_LFLAGS_PSQL   = $QT_LFLAGS_PSQL" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_CFLAGS_MYSQL" ]; then
    echo "QT_CFLAGS_MYSQL   = $QT_CFLAGS_MYSQL" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_LFLAGS_MYSQL" ]; then
    echo "QT_LFLAGS_MYSQL   = $QT_LFLAGS_MYSQL" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_CFLAGS_SQLITE" ]; then
    echo "QT_CFLAGS_SQLITE   = $QT_CFLAGS_SQLITE" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_LFLAGS_SQLITE" ]; then
    echo "QT_LFLAGS_SQLITE   = $QT_LFLAGS_SQLITE" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_LFLAGS_ODBC" ]; then
    echo "QT_LFLAGS_ODBC   = $QT_LFLAGS_ODBC" >> "$QTMODULE.tmp"
fi
if [ -n "$QT_LFLAGS_TDS" ]; then
    echo "QT_LFLAGS_TDS   = $QT_LFLAGS_TDS" >> "$QTMODULE.tmp"
fi

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

# cmdline args
cat "$QMAKE_VARS_FILE" >> "$QTMODULE.tmp"
# QMAKE_VARS_FILE will be still needed for a status message.

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

#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------
exec 3>&1 1>$outpath/config.summary # redirect output temporarily to config.summary

report_support()
{
    case "$#,$2" in
        2,auto)
            # 2 arguments and the result is "auto", so just say "yes"
            # this is usually an error in the configure script, but oh well..
            echo "$1 yes"
            return
            ;;
        [012],* | *,no*)
            # 0, 1 or 2 arguments, or anything starting with "no"
            # print just the first part of the argument (before the dash)
            echo "$1 ${2%%-*}"
            return
            :;
    esac
    heading=$1
    shift

    value=$1
    shift

    while [ $# -gt 0 ]; do
        if [ "$value" = "$1" ]; then
            echo "$heading yes ($2)"
            return
        fi
        shift
        shift
    done
    echo "$heading $value"
}

report_support_plugin()
{
    report_support "$1" "$2-$3" \
        yes-qt "in $4, using bundled copy" \
        yes-system "in $4, using system library" \
        plugin-qt "plugin, using bundled copy" \
        plugin-system "plugin, using system library"
}

echo
echo "   Configure summary"
echo
if [ "$XPLATFORM" = "$PLATFORM" ]; then
    # the missing space before $CFG_FEATURES is intentional
    echo "Build type:    $PLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES:- none detected})"
else
    echo "Building on:   $PLATFORM ($CFG_HOST_ARCH, CPU features:${CFG_HOST_CPUFEATURES:- none detected})"
    echo "Building for:  $XPLATFORM ($CFG_ARCH, CPU features:${CFG_CPUFEATURES:- none detected})"
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"
    echo
fi

# Build configuration
echo "Build options:"
echo $ECHO_N "  Configuration .......... $ECHO_C"
echo $QMAKE_CONFIG $QT_CONFIG | tr ' ' '\n' | sort | tr '\n' ' '
echo
echo "  Build parts ............ $CFG_BUILD_PARTS"
release="release"
[ "$CFG_FORCEDEBUGINFO" = "yes" ] && release="release (with debug info)"
[ "$CFG_DEBUG" = "yes" ] && build_mode="debug" || build_mode=$release
if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
   echo "  Mode ................... debug and $release; default link: $build_mode"
else
   echo "  Mode ................... $build_mode"
fi
unset build_mode release
echo "  Using sanitizer(s)...... $CFG_SANITIZERS"
echo "  Using C++11 ............ $CFG_CXX11"
echo "  Using gold linker....... $CFG_USE_GOLD_LINKER"
echo "  Using new DTAGS ........ $CFG_ENABLE_NEW_DTAGS"
echo "  Using PCH .............. $CFG_PRECOMPILE"
echo "  Target compiler supports:"
if [ "$CFG_ARCH" = "i386" -o "$CFG_ARCH" = "x86_64" ]; then
    echo "    SSE2/SSE3/SSSE3 ...... ${CFG_SSE2}/${CFG_SSE3}/${CFG_SSSE3}"
    echo "    SSE4.1/SSE4.2 ........ ${CFG_SSE4_1}/${CFG_SSE4_2}"
    echo "    AVX/AVX2 ............. ${CFG_AVX}/${CFG_AVX2}"
elif [ "$CFG_ARCH" = "arm" ]; then
    echo "    Neon ................. ${CFG_NEON}"
elif [ "$CFG_ARCH" = "mips" ]; then
    echo "    DSP/DSPr2 ............ ${CFG_MIPS_DSP}/${CFG_MIPS_DSPR2}"
fi

# Qt modules
echo
echo "Qt modules and options:"
report_support "  Qt D-Bus ..............." "$CFG_DBUS" runtime "loading dbus-1 at runtime" linked "linked to dbus-1"
report_support "  Qt Concurrent .........." "$CFG_CONCURRENT"
report_support "  Qt GUI ................." "$CFG_GUI"
report_support "  Qt Widgets ............." "$CFG_WIDGETS"
report_support "  Large File ............." "$CFG_LARGEFILE"
report_support "  QML debugging .........." "$CFG_QML_DEBUG"
report_support "  Use system proxies ....." "$CFG_SYSTEM_PROXIES"

# Other things
# Please keep sorted and properly grouped! The output is quite long, so it's
# hard to find something you're searching for if it's not sorted.
echo
echo "Support enabled for:"
report_support "  Accessibility .........." "$CFG_ACCESSIBILITY"
report_support "  ALSA ..................." "$CFG_ALSA"
report_support "  CUPS ..................." "$CFG_CUPS"
[ "$XPLATFORM_MINGW" = "yes" ] && \
    report_support "  DirectWrite ............" "$CFG_DIRECTWRITE"
report_support "  Evdev .................." "$CFG_EVDEV"
report_support "  FontConfig ............." "$CFG_FONTCONFIG"
report_support "  FreeType ..............." "$CFG_FREETYPE" system "system library" yes "bundled copy"
report_support "  Glib ..................." "$CFG_GLIB"
report_support "  GStreamer .............." "$CFG_GSTREAMER" yes "$CFG_GSTREAMER_VERSION"
report_support "  GTK theme .............." "$CFG_QGTKSTYLE"
report_support "  HarfBuzz ..............." "$CFG_HARFBUZZ" system "system library" qt "bundled copy"
report_support "  Iconv .................." "$CFG_ICONV"
report_support "  ICU ...................." "$CFG_ICU"
report_support "  Image formats:"
report_support_plugin "    GIF .................." "$CFG_GIF" qt QtGui
report_support_plugin "    JPEG ................." "$CFG_JPEG" "$CFG_LIBJPEG" QtGui
report_support_plugin "    PNG .................." "$CFG_PNG" "$CFG_LIBPNG" QtGui
report_support "  libinput................" "$CFG_LIBINPUT"
report_support "  Logging backends:"
report_support "    journald ..............." "$CFG_JOURNALD"
report_support "    syslog   ..............." "$CFG_SYSLOG"
report_support "  mtdev .................." "$CFG_MTDEV" yes "system library"
report_support "  Networking:"
[ "$XPLATFORM_MAC" = "yes" ] && \
    report_support "    CoreWlan ............." "$CFG_COREWLAN"
report_support "    getaddrinfo .........." "$CFG_GETADDRINFO"
report_support "    getifaddrs ..........." "$CFG_GETIFADDRS"
report_support "    IPv6 ifname .........." "$CFG_IPV6IFNAME"
report_support "    libproxy.............." "$CFG_LIBPROXY"
report_support "    OpenSSL .............." "$CFG_OPENSSL" yes "loading libraries at run-time" linked "linked to the libraries"
[ "$XPLATFORM_MAC" = "yes" ] && \
    report_support "    SecureTransport ......" "$CFG_SECURETRANSPORT"
report_support "  NIS ...................." "$CFG_NIS"
report_support "  OpenGL / OpenVG:"
report_support "    EGL .................." "$CFG_EGL"
report_support "    OpenGL ..............." "$CFG_OPENGL" yes "Desktop OpenGL" es2 "OpenGL ES 2.0+"
report_support "    OpenVG ..............." "$CFG_OPENVG-$CFG_OPENVG_SHIVA" yes-yes "ShivaVG" yes-no "native"
report_support "  PCRE ..................." "$CFG_PCRE" yes "system library" qt "bundled copy"
if [ -n "$PKG_CONFIG" ]; then
    report_support "  pkg-config ............. yes"
else
    report_support "  pkg-config ............. no"
fi
report_support "  PulseAudio ............." "$CFG_PULSEAUDIO"
report_support "  QPA backends:"
report_support "    DirectFB ............." "$CFG_DIRECTFB"
report_support "    EGLFS ................" "$CFG_EGLFS"
report_support "      EGLFS i.MX6....... ." "$CFG_EGLFS_VIV"
report_support "      EGLFS KMS .........." "$CFG_KMS"
report_support "      EGLFS Mali ........." "$CFG_EGLFS_MALI"
report_support "      EGLFS Raspberry Pi ." "$CFG_EGLFS_BRCM"
report_support "      EGLFS X11 .........." "$CFG_EGL_X"
report_support "    LinuxFB .............." "$CFG_LINUXFB"
report_support "    Mir client............" "$CFG_MIRCLIENT"
report_support "    XCB .................." "$CFG_XCB" system "system library" qt "bundled copy"
if [ "$CFG_XCB" != "no" ]; then
    report_support "      EGL on X ..........." "$CFG_EGL_X"
    report_support "      GLX ................" "$CFG_XCB_GLX"
    report_support "      MIT-SHM ............" "$CFG_MITSHM"
    report_support "      Xcb-Xlib ..........." "$CFG_XCB_XLIB"
    report_support "      Xcursor ............" "$CFG_XCURSOR" runtime "loaded at runtime"
    report_support "      Xfixes ............." "$CFG_XFIXES" runtime "loaded at runtime"
    report_support "      Xi ................." "$CFG_XINPUT" runtime "loaded at runtime"
    report_support "      Xi2 ................" "$CFG_XINPUT2" runtime "loaded at runtime"
    report_support "      Xinerama ..........." "$CFG_XINERAMA" runtime "loaded at runtime"
    report_support "      Xrandr ............." "$CFG_XRANDR" runtime "loaded at runtime"
    report_support "      Xrender ............" "$CFG_XRENDER"
    report_support "      XKB ................" "$CFG_XKB"
    report_support "      XShape ............." "$CFG_XSHAPE"
    report_support "      XSync .............." "$CFG_XSYNC"
    report_support "      XVideo ............." "$CFG_XVIDEO"
fi
report_support "  Session management ....." "$CFG_SM"
if [ "$XPLATFORM_QNX" = "yes" ]; then
    report_support "  SLOG2 .................." "$CFG_SLOG2"
    report_support "  IMF ...................." "$CFG_QNX_IMF"
    report_support "  PPS ...................." "$CFG_PPS"
    report_support "  LGMON .................." "$CFG_LGMON"
fi
report_support "  SQL drivers:"
report_support "    DB2 .................." "$CFG_SQL_db2" plugin "plugin" yes "built into QtSql"
report_support "    InterBase ............" "$CFG_SQL_ibase" plugin "plugin" yes "built into QtSql"
report_support "    MySQL ................" "$CFG_SQL_mysql" plugin "plugin" yes "built into QtSql"
report_support "    OCI .................." "$CFG_SQL_oci" plugin "plugin" yes "built into QtSql"
report_support "    ODBC ................." "$CFG_SQL_odbc" plugin "plugin" yes "built into QtSql"
report_support "    PostgreSQL ..........." "$CFG_SQL_psql" plugin "plugin" yes "built into QtSql"
report_support "    SQLite 2 ............." "$CFG_SQL_sqlite2" plugin "plugin" yes "built into QtSql"
report_support_plugin "    SQLite ..............." "$CFG_SQL_sqlite" "$CFG_SQLITE" QtSql
report_support "    TDS .................." "$CFG_SQL_tds" plugin "plugin" yes "built into QtSql"
report_support "  tslib .................." "$CFG_TSLIB"
report_support "  udev ..................." "$CFG_LIBUDEV"
report_support "  xkbcommon-x11..........." "$CFG_XKBCOMMON" system "system library" qt "bundled copy, XKB config root: $CFG_XKB_CONFIG_ROOT"
report_support "  xkbcommon-evdev........." "$CFG_XKBCOMMON_EVDEV"
report_support "  zlib ..................." "$CFG_ZLIB" system "system library" yes "bundled copy"

echo

# 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."
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"
fi
if [ "$CFG_JOURNALD" = "yes" ] || [ "$CFG_SYSLOG" = "yes" ] || [ "$CFG_SLOG2" = "yes" ]; then
    echo
    echo "NOTE: journald, syslog or slog2 integration is enabled."
    echo "If your users intend on developing applications against this build,"
    echo "ensure that the IDEs they use either set QT_LOGGING_TO_CONSOLE to 1"
    echo "or the IDE is able to read the logged output from journald, syslog or slog2."
fi
if [ "$CFG_XKBCOMMON" = "qt" ] && [ "$CFG_XKB_CONFIG_ROOT" = "not found" ]; then
    echo
    echo "WARNING: Could not find XKB config root, use -xkb-config-root to set a path to "
    echo "XKB configuration data. This is required for keyboard input support."
fi
if [ "$CFG_QREAL" = double ] && [ "$CFG_ARCH" = arm ]; then
    echo
    echo "NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1."
    echo "Configure with '-qreal float' to create a build that is binary compatible with 5.1."
fi

exec 1>&3 3>&- # restore stdout
cat $outpath/config.summary # display config feedback to user

if [ "$XPLATFORM_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=""

rm -f "$QMAKE_VARS_FILE" 2>/dev/null

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

(   # fork to make the cd stay local

    relpathMangled=$relpath
    if [ -n "$CFG_TOPLEVEL" ]; then
        relpathMangled=`dirname "$relpath"`
        cd ..
    fi

    "$outpath/bin/qmake" "$relpathMangled"

) || exit

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

        NOTICE: configure was unable to determine the architecture
        for the $XQMAKESPEC target.

        Qt will not use a specialized implementation for any atomic
        operations. Instead a generic implemention based on either GCC
        intrinsics or C++11 std::atomic<T> will be used (when
        available). The generic implementations are generally as fast
        as and always as safe as a specialized implementation.

        If no generic implementation is available, Qt will use a
        fallback UNIX implementation 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

#-------------------------------------------------------------------------------
# check if the user passed the obsoleted -wayland or -no-wayland flag
#-------------------------------------------------------------------------------
if [ "$CFG_OBSOLETE_WAYLAND" = "yes" ]; then
cat <<EOF

        NOTICE: The -wayland and -no-wayland flags are now obsolete

        All configuring of QtWayland plugin and QtCompositor happens in the module
EOF
fi

#-------------------------------------------------------------------------------
# check if the user passed the obsoleted -arch or -host-arch options
#-------------------------------------------------------------------------------
if [ "$OPT_OBSOLETE_HOST_ARG" = "yes" ]; then
cat <<EOF

        NOTICE: The -arch and -host-arch options are obsolete.

        Qt now detects the target and host architectures based on compiler
        output. Qt will be built using $CFG_ARCH for the target architecture
        and $CFG_HOST_ARCH for the host architecture (note that these two
        will be the same unless you are cross-compiling).
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"
    [ -n "$PKG_CONFIG_SYSROOT_DIR" ] && \
        echo "export PKG_CONFIG_SYSROOT_DIR=$PKG_CONFIG_SYSROOT_DIR" >> "$outpath/config.status"
    [ -n "$PKG_CONFIG_LIBDIR" ] && \
        echo "export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR" >> "$outpath/config.status"
    echo "$CONFIG_STATUS \"\$@\"" >> "$outpath/config.status"
    chmod +x "$outpath/config.status"
fi

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

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

MAKE=`basename "$MAKE"`
echo
echo Qt is now configured for building. Just run \'$MAKE\'.
if [ "$outpath" = "$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 Prior to reconfiguration, make sure you remove any leftovers from
echo the previous build.
echo