summaryrefslogtreecommitdiff
path: root/configure.in
blob: 5015915341dde11ab28e4641479ad8b3f937a9ea (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
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil -*-
dnl configure.in serves as input for the GNU autoconf package
dnl in order to create a configure script.

AC_INIT([LibreOffice],[3.6],[],[],[http://documentfoundation.org/])
AC_PREREQ([2.59])

save_CC=$CC
save_CXX=$CXX

BUILD_TYPE="LibO"
SCPDEFS=""
GIT_REPO_NAMES=""
LO_PATH= # used by path_munge to construct a PATH variable

PathFormat()
{
    formatted_path="$1"
    if test "$build_os" = "cygwin"; then
        pf_part1=
        pf_conv_to_dos=
        for pf_part in $formatted_path; do
            if test -z "$pf_part1"; then
                pf_part1="$pf_part"
            else
                pf_conv_to_dos="yes"
            fi
        done
        if test "$pf_conv_to_dos" = "yes"; then
            formatted_path=`cygpath -d "$formatted_path"`
            if test $? -ne 0;  then
                AC_MSG_ERROR([path conversion failed for "$1".])
            fi
        fi
        fp_count_colon=`echo "$formatted_path" | $GREP -c "[:]"`
        fp_count_slash=`echo "$formatted_path" | $GREP -c "[/]"`
        if test "$fp_count_slash$fp_count_colon" != "00"; then
            if test "$fp_count_colon" = "0"; then
                formatted_path=`realpath "$formatted_path"`
                if test $? -ne 0;  then
                    AC_MSG_ERROR([realpath failed for "$1".])
                fi
            fi
            formatted_path=`cygpath -m "$formatted_path"`
            if test $? -ne 0;  then
                AC_MSG_ERROR([path conversion failed for "$1".])
            fi
        fi
    fi
}

echo "********************************************************************"
echo "*"
echo "*   Running ${PACKAGE_NAME} build configuration."
echo "*"
echo "********************************************************************"
echo ""

dnl ===================================================================
dnl checks build and host OSes
dnl do this before argument processing to allow for platform dependent defaults
dnl ===================================================================
AC_CANONICAL_HOST

if test "$cross_compiling" = "yes"; then
    CROSS_COMPILING=YES
else
    CROSS_COMPILING=
    BUILD_TYPE="$BUILD_TYPE NATIVE"
fi
AC_SUBST(CROSS_COMPILING)

AC_PROG_EGREP
# AC_PROG_EGREP doesn't set GREP on all systems as well
AC_PATH_PROG(GREP, grep)

if test "$build_os" = "cygwin"; then
    EXEEXT_FOR_BUILD=.exe
    SRC_ROOT=`pwd`
    PathFormat "$SRC_ROOT"
    SRC_ROOT="$formatted_path"
    x_Cygwin=
else
    EXEEXT_FOR_BUILD=
    SRC_ROOT=`pwd`
    x_Cygwin=[\#]
fi

AC_SUBST(SRC_ROOT)
AC_SUBST(EXEEXT_FOR_BUILD)
AC_SUBST(x_Cygwin)

cat /dev/null > warn

if test "z$EUID" = "z0" -a "`uname -o 2>/dev/null`" = "Cygwin"; then
    AC_MSG_ERROR([You must build LibreOffice as a normal user - not using an administrative account])
fi

# need sed in os checks...
AC_PATH_PROGS(SED, sed)
if test -z "$SED"; then
    AC_MSG_ERROR([install sed to run this script])
fi

dnl ===================================================================
dnl When building for Android the --with-android-ndk is mandatory
dnl ===================================================================
ANDROID_NDK_HOME=
if test -n "$with_android_ndk"; then
   ANDROID_NDK_HOME=$with_android_ndk
   # Set up a lot of pre-canned defaults
   # What if the NDK at some point starts including several toolchains for different
   # gcc versions (like some 3rd-party improved NDK builds already do)?
   # Then the use of a wildcard below will break.
   ANDROID_ABI_PREBUILT_BIN=`echo $ANDROID_NDK_HOME/toolchains/arm-linux*/prebuilt/*/bin`

   test -z "$SYSBASE" && export SYSBASE=$ANDROID_NDK_HOME/platforms/android-9/arch-arm
   test -z "$AR" && AR=$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-ar
   test -z "$NM" && NM=$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-nm
   test -z "$OBJDUMP" && OBJDUMP=$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-objdump
   test -z "$RANLIB" && RANLIB=$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-ranlib
   test -z "$STRIP" && STRIP=$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-strip

   ANDROIDCFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8 --sysroot $ANDROID_NDK_HOME/platforms/android-9/arch-arm -L$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a"

   test -z "$CC" && CC="$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-gcc $ANDROIDCFLAGS"
   test -z "$CXX" && CXX="$ANDROID_ABI_PREBUILT_BIN/arm-linux-androideabi-g++ $ANDROIDCFLAGS -I $ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/include -I$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include"
fi
AC_SUBST(ANDROID_NDK_HOME)

dnl ===================================================================
dnl Also --with-android-sdk is mandatory
dnl ===================================================================
ANDROID_SDK_HOME=
if test -n "$with_android_sdk"; then
   ANDROID_SDK_HOME=$with_android_sdk
   PATH="$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/tools:$PATH"
fi
AC_SUBST(ANDROID_SDK_HOME)

dnl ===================================================================
dnl The following is a list of supported systems.
dnl Sequential to keep the logic very simple
dnl These values may be checked and reset later.
dnl ===================================================================
#defaults unless the os test overrides this:
test_randr=yes
test_xrender=yes
test_cups=yes
test_fontconfig=yes

# Default values, as such probably valid just for Linux, set
# differently below just for Mac OS X,but at least better than
# hardcoding these as we used to do. Much of this is duplicated also
# in solenv for old build system and for gbuild, ideally we should
# perhaps define stuff like this only here in configure.in?

LINKFLAGSSHL="-shared"
PICSWITCH="-fpic"
DLLPOST=".so"

LINKFLAGSNOUNDEFS="-Wl,-z,defs"

case "$host_os" in

solaris*)
    test_gtk=yes
    build_gstreamer=yes
    test_tde=yes
    test_kde=yes
    test_freetype=yes
    test_gstreamer=yes
    _os=SunOS

    dnl ===========================================================
    dnl Check whether we're using Solaris 10 - SPARC or Intel.
    dnl ===========================================================
    AC_MSG_CHECKING([the Solaris operating system release])
    _os_release=`echo $host_os | $SED -e s/solaris2\.//`
    if test "$_os_release" -lt "10"; then
        AC_MSG_ERROR([use Solaris >= 10 to build LibreOffice])
    else
        AC_MSG_RESULT([ok ($_os_release)])
    fi

    dnl Check whether we're using a SPARC or i386 processor
    AC_MSG_CHECKING([the processor type])
    if test "$host_cpu" = "sparc" -o "$host_cpu" = "i386"; then
        AC_MSG_RESULT([ok ($host_cpu)])
    else
        AC_MSG_ERROR([only SPARC and i386 processors are supported])
    fi
    ;;

linux-gnu*|k*bsd*-gnu*)
    test_gtk=yes
    build_gstreamer=yes
    test_tde=yes
    test_kde=yes
    test_kde4=yes
    test_freetype=yes
    test_unix_quickstarter=yes
    _os=Linux
    ;;

gnu)
    test_randr=no
    test_xrender=no
    _os=GNU
     ;;

cygwin*|interix*|mingw32*)

    # When building on Windows normally with MSVC under Cygwin,
    # configure thinks that the host platform (the platform the
    # built code will run on) is Cygwin, even if it obviously is
    # Windows, which in Autoconf terminology is called
    # "mingw32". (Which is misleading as MinGW is the name of the
    # tool-chain, not an operating system.)

    # Somewhat confusing, yes. But this configure script doesn't
    # look at $host etc that much, it mostly uses its own $_os
    # variable, set here in this case statement.

    # When cross-compiling to Windows from Unix, the host platform
    # is "mingw32" (because in that case it is the MinGW
    # tool-chain that is used).

    test_cups=no
    test_randr=no
    test_xrender=no
    test_freetype=no
    test_fontconfig=no
    _os=WINNT
    use_shl_version="TRUE"
    DYNAMIC_CRT="TRUE"
    # If the host OS matches "mingw32*", that means we are using the
    # MinGW cross-compiler, because we don't see the point in building
    # LibreOffice using MinGW on Windows. If you want to build on
    # Windows, use MSVC. If you want to use MinGW, surely you want to
    # cross-compile (from Linux or some other Unix).

    case "$host_os" in
    mingw32*)
        WITH_MINGW=yes
        if test -z "$CC"; then
            CC="$host_cpu-$host_vendor-$host_os-gcc"
        fi
        if test -z "$CXX"; then
            CXX="$host_cpu-$host_vendor-$host_os-g++"
        fi
        ;;
    esac
    ;;

darwin*) # Mac OS X or iOS
    test_gtk=yes
    test_randr=no
    test_xrender=no
    test_freetype=no
    test_fontconfig=no
    if test "$host_cpu" = "arm"; then
        _os=iOS
        test_gtk=no
        test_cups=no
    else
        _os=Darwin
    fi
    enable_systray=no
    # See comment above the case "$host_os"
    LINKFLAGSSHL="-dynamiclib -single_module"

    # -fPIC is default
    PICSWITCH=""

    DLLPOST=".dylib"

    # -undefined error is the default
    LINKFLAGSNOUNDEFS=""
;;

freebsd*)
    test_gtk=yes
    build_gstreamer=yes
    test_tde=yes
    test_kde=yes
    test_kde4=yes
    test_freetype=yes
    AC_MSG_CHECKING([the FreeBSD operating system release])
    if test -n "$with_os_version"; then
        OSVERSION="$with_os_version"
    else
        OSVERSION=`/sbin/sysctl -n kern.osreldate`
    fi
    AC_MSG_RESULT([found OSVERSION=$OSVERSION])
    AC_MSG_CHECKING([which thread library to use])
    if test "$OSVERSION" -lt "500016"; then
        PTHREAD_CFLAGS="-D_THREAD_SAFE"
        PTHREAD_LIBS="-pthread"
    elif test "$OSVERSION" -lt "502102"; then
        PTHREAD_CFLAGS="-D_THREAD_SAFE"
        PTHREAD_LIBS="-lc_r"
    else
        PTHREAD_CFLAGS=""
        PTHREAD_LIBS="-pthread"
    fi
    AC_MSG_RESULT([$PTHREAD_LIBS])
    _os=FreeBSD
    ;;

*netbsd*)
    test_gtk=yes
    build_gstreamer=yes
    test_tde=no
    test_kde=no
    test_kde4=yes
    test_freetype=yes
    PTHREAD_LIBS="-pthread -lpthread"
    _os=NetBSD
    ;;

aix*)
    test_randr=no
    test_freetype=yes
    PTHREAD_LIBS=-pthread
    _os=AIX
    ;;

openbsd*)
    test_gtk=yes
    test_tde=yes
    test_kde=yes
    test_freetype=yes
    PTHREAD_CFLAGS="-D_THREAD_SAFE"
    PTHREAD_LIBS="-pthread"
    _os=OpenBSD
    ;;

dragonfly*)
    test_gtk=yes
    build_gstreamer=yes
    test_tde=yes
    test_kde=yes
    test_kde4=yes
    test_freetype=yes
    PTHREAD_LIBS="-pthread"
    _os=DragonFly
    ;;

linux-androideabi*)
    build_gstreamer=no
    test_cups=no
    test_fontconfig=no
    test_freetype=no
    test_gtk=no
    test_tde=no
    test_kde=no
    test_kde4=no
    test_randr=no
    test_xrender=no
    test_unix_quickstarter=no
    _os=Android

    if test -z "$with_android_ndk"; then
        AC_MSG_ERROR([the --with-android-ndk option is mandatory])
    fi

    if test -z "$with_android_sdk"; then
        AC_MSG_ERROR([the --with-android-sdk option is mandatory])
    fi

    # Verify that the NDK and SDK options are proper
    if test ! -f "$ANDROID_NDK_HOME/platforms/android-9/arch-arm/usr/lib/libc.a"; then
        AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK])
    fi

    if test ! -f "$ANDROID_SDK_HOME/platforms/android-14/android.jar"; then
        AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
    fi

    BUILD_TYPE="$BUILD_TYPE FONTCONFIG FREETYPE"
    FREETYPE_TARBALL=dbf2caca1d3afd410a29217a9809d397-freetype-2.4.8.tar.bz2
    FONTCONFIG_TARBALL=77e15a92006ddc2adbb06f840d591c0e-fontconfig-2.8.0.tar.gz
    ;;

*)
    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
    ;;
esac

if test "$_os" = "AIX"; then
    AC_PATH_PROG(GAWK, gawk)
    if test -z "$GAWK"; then
        AC_MSG_ERROR([gawk not found in \$PATH])
    fi
fi

AC_SUBST(use_shl_version)
AC_SUBST(DYNAMIC_CRT)

AC_SUBST(WITH_MINGW)
AC_SUBST(OSVERSION)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)

AC_SUBST(FREETYPE_TARBALL)
AC_SUBST(FONTCONFIG_TARBALL)

###############################################################################
# Extensions switches --enable/--disable
###############################################################################
# By default these should be enabled unless having extra dependencies.
# If there is extra dependency over configure options then the enable should
# be automagic based on wether the requiring feature is enabled or not.
# All this options change anything only with --enable-extension-integration.

# The name of this option and its help string makes it sound as if
# extensions are built anyway, just not integrated in the installer,
# if you use --disable-extension-integration. Is that really the
# case?

AC_ARG_ENABLE(extension-integration,
    AS_HELP_STRING([--disable-extension-integration],
        [Disable integration of the built extensions in the installer of the
         product. Use this switch to disable the integration.])
)

AC_ARG_ENABLE(ext-barcode,
    AS_HELP_STRING([--enable-ext-barcode],
        [Enable the Barcode extension.])
)

AC_ARG_ENABLE(database-connectivity,
    AS_HELP_STRING([--disable-database-connectivity],
        [Disable various database connectivity. Work in progress, use only if you are hacking on it.])
)

# This doesn't mean not building (or "integrating") extensions
# (although it probably should; i.e. it should imply
# --disable-extension-integration I guess), it means not supporting
# any extension mechanism at all
AC_ARG_ENABLE(extensions,
    AS_HELP_STRING([--disable-extensions],
        [Disable all add-on extension functionality. Work in progress, use only if you are hacking on it.])
)

AC_ARG_ENABLE(scripting,
    AS_HELP_STRING([--disable-scripting],
        [Disable BASIC, Java and Python. Work in progress, use only if you are hacking on it.])
)

# This is mainly for iOS, but could potentially be used in some
# special case otherwise, too, so factored out as a separate setting
AC_ARG_ENABLE(dynamic-loading,
    AS_HELP_STRING([--disable-dynamic-loading],
        [Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
)

AC_ARG_ENABLE(ext-diagram,
    AS_HELP_STRING([--enable-ext-diagram],
        [Enable the SmART Gallery (Diagram) extension.])
)

AC_ARG_ENABLE(ext-google-docs,
    AS_HELP_STRING([--enable-ext-google-docs],
        [Enable the Google Documents extension.])
)

AC_ARG_ENABLE(ext-hunart,
    AS_HELP_STRING([--enable-ext-hunart],
        [Enable the Hungarian Cross-reference Toolbar extension.])
)

AC_ARG_ENABLE(ext-languagetool,
    AS_HELP_STRING([--enable-ext-languagetool],
        [Enable the LanguageTool extension.])
)

AC_ARG_ENABLE(ext-mysql-connector,
    AS_HELP_STRING([--enable-ext-mysql-connector],
        [Enable the build of the MySQL Connector extension.])
)

AC_ARG_ENABLE(ext-nlpsolver,
    AS_HELP_STRING([--enable-ext-nlpsolver],
        [Enable the NLPSolver extension.])
)

AC_ARG_ENABLE(ext-ct2n,
    AS_HELP_STRING([--enable-ext-ct2n],
        [Enable the ConvertTextToNumber extension.])
)

AC_ARG_ENABLE(ext-numbertext,
    AS_HELP_STRING([--enable-ext-numbertext],
        [Enable the Numbertext extension.])
)

AC_ARG_ENABLE(ext-oooblogger,
    AS_HELP_STRING([--enable-ext-oooblogger],
        [Enable the OOo Blogger extension.])
)

AC_ARG_ENABLE(ext-pdfimport,
    AS_HELP_STRING([--disable-ext-pdfimport],
        [Disable the PDF Import extension.])
)

AC_ARG_ENABLE(ext-presenter-console,
    AS_HELP_STRING([--disable-ext-presenter-console],
        [Disable the Presenter Console extension.])
)

AC_ARG_ENABLE(ext-presenter-minimizer,
    AS_HELP_STRING([--disable-ext-presenter-minimizer],
        [Disable the Presentation Minimizer extension.])
)

AC_ARG_ENABLE(ext-report-builder,
    AS_HELP_STRING([--disable-ext-report-builder],
        [Disable the Report Builder extension.])
)

AC_ARG_ENABLE(ext-scripting-beanshell,
    AS_HELP_STRING([--enable-ext-scripting-beanshell],
        [Enable support for scripts in BeanShell.])
)

AC_ARG_ENABLE(ext-scripting-javascript,
    AS_HELP_STRING([--enable-ext-scripting-javascript],
        [Enable support for scripts in JavaScript.])
)

AC_ARG_ENABLE(ext-typo,
    AS_HELP_STRING([--enable-ext-typo],
        [Enable the Typography Toolbar extension.])
)

AC_ARG_ENABLE(ext-validator,
    AS_HELP_STRING([--enable-ext-validator],
        [Enable the Validator extension.])
)

AC_ARG_ENABLE(ext-watch-window,
    AS_HELP_STRING([--enable-ext-watch-window],
        [Enable the Watch Window extension to Calc.])
)

AC_ARG_ENABLE(ext-wiki-publisher,
    AS_HELP_STRING([--enable-ext-wiki-publisher],
        [Enable the Wiki Publisher extension.])
)
###############################################################################

dnl ---------- *** ----------

AC_ARG_ENABLE(mergelibs,
    AS_HELP_STRING([--enable-mergelibs],
        [Enables linking of big merged library used for better performance.])
)

AC_ARG_ENABLE(graphite,
    AS_HELP_STRING([--enable-graphite],
        [Enables the compilation of Graphite smart font rendering.])
)

AC_ARG_ENABLE(ldap,
    AS_HELP_STRING([--disable-ldap],
        [Disables the use of LDAP backend via Netscape/Mozilla or OpenLDAP LDAP SDK])
)

AC_ARG_ENABLE(fetch-external,
    AS_HELP_STRING([--disable-fetch-external],
        [Disables fetching external tarballs from web sources.])
)

AC_ARG_ENABLE(lockdown,
    AS_HELP_STRING([--disable-lockdown],
        [Disables the gconf integration work in LibreOffice.]),
)

AC_ARG_ENABLE(vba,
    AS_HELP_STRING([--disable-vba],
        [Disables the vba compatibility feature.])
)

AC_ARG_ENABLE(pch,
    AS_HELP_STRING([--enable-pch],
        [DEPRECATED : is ignored])
)

AC_ARG_ENABLE(mozilla,
    AS_HELP_STRING([--disable-mozilla],
        [LibreOffice usually includes a strangely hacked up Mozilla binary for your
         platform, to build without this version, use this option.])
)

AC_ARG_ENABLE(epm,
    AS_HELP_STRING([--enable-epm],
        [LibreOffice includes self-packaging code, that requires epm, however epm is
         useless for large scale package building.])
)

AC_ARG_ENABLE(activex_component,
    AS_HELP_STRING([--disable-activex-component],
        [Remove support for ActiveX embedding of LibreOffice.])
)

AC_ARG_ENABLE(odk,
    AS_HELP_STRING([--disable-odk],
        [LibreOffice includes an ODK, office development kit which some packagers may
         wish to build without.])
)

AC_ARG_ENABLE(mathmldtd,
    AS_HELP_STRING([--disable-mathmldtd],
        [Disable mathmldtd (useful for distributions that want to avoid
         packaging it).])
)

AC_ARG_ENABLE(evolution2,
    AS_HELP_STRING([--enable-evolution2],
        [Allows the built-in evolution 2 addressbook connectivity build to be
         enabled.])
)

AC_ARG_ENABLE(directx,
    AS_HELP_STRING([--disable-directx],
        [Remove DirectX implementation for the new XCanvas interface.
         The DirectX support requires more stuff installed on Windows to
         compile. (DirectX SDK, GDI+ libs)])
)

AC_ARG_ENABLE(activex,
    AS_HELP_STRING([--disable-activex],
        [Disable the use of ActiveX for a Windows build.
        This switch is mandatory when using VC++ 2008 Express.])
)

AC_ARG_ENABLE(atl,
    AS_HELP_STRING([--disable-atl],
        [Disable the use of ATL for a Windows build.])
    [
                          This switch is mandatory when using VC++ 2008 Express.
    ],
,)

AC_ARG_ENABLE(symbols,
    AS_HELP_STRING([--enable-symbols],
        [Include debugging symbols in output. WARNING - a complete build needs
         a lot of space (roughly 10 GiB) and takes much longer (enables -g
         compiler flag for GCC or equivalent).]),
,)

AC_ARG_ENABLE(werror,
    AS_HELP_STRING([--enable-werror],
        [Turn warnings to errors. (Has no effect in modules where the treating
         of warnings as errors is disabled explicitly.)]),
,)

AC_ARG_ENABLE(debug,
    AS_HELP_STRING([--enable-debug],
        [Include debugging symbols like with --enable-symbols, disable compiler
         optimization and inlining plus extra debugging code like assertions.
         Extra large build! (enables -g compiler flag and dmake debug=true)
         If you need even more verbose output, build a module with
         "build -- debug=true dbglevel=2".
         You can also use this switch as follows:
         --enable-debug="all -sw/ -Library_sc" to enable symbols only for
         the specified gbuild-build targets (all means everything, - prepended
         means not to enable, / appended means everything in the directory,
         there is no ordering, more specific overrides more general, and
         disabling takes precedence).]))

AC_ARG_ENABLE(dbgutil,
    AS_HELP_STRING([--enable-dbgutil],
        [Include additional debugging utilities, such as assertions, object
         counting, etc. Larger build. Independent from --enable-debug.
         Note that this option makes the build ABI incompatible:
         It is not possible to mix object files or libraries from a
         --enable-dbgutil and a --disable-dbgutil build.]))

AC_ARG_ENABLE(linkoo,
    AS_HELP_STRING([--disable-linkoo],
        [Disable linkoo for the smoketest installation.]))

AC_ARG_ENABLE(lto,
    AS_HELP_STRING([--enable-lto],
        [Enable link-time optimization. Suitable for product builds.
         Building takes longer but libraries are optimized for speed.
         (possible only with gcc-4.5 or later,
          better to use gcc-4.6 and 'gold' as linker)]))

AC_ARG_ENABLE(crashdump,
    AS_HELP_STRING([--enable-crashdump],
        [Enable the crashdump feature.]))

AC_ARG_ENABLE(python,
    AS_HELP_STRING([--enable-python=<no/auto/system/internal>],
        [Enables or disables Python support at run-time and build-time.
         Also specifies what Python to use. 'auto' is the
         default. Note that Python can be disabled with
         --disable-python or --enable-python=no only if no
         translations are required.]))

AC_ARG_ENABLE(gtk,
    AS_HELP_STRING([--disable-gtk],
        [Determines whether to use Gtk+ vclplug on platforms where Gtk+ is available.]),
,enable_gtk=yes)

AC_ARG_ENABLE(gtk3,
    AS_HELP_STRING([--disable-gtk3],
        [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
,enable_gtk3=no)

AC_ARG_ENABLE(systray,
    AS_HELP_STRING([--disable-systray],
        [Determines whether to build the systray quickstarter.]),
,enable_systray=yes)

AC_ARG_ENABLE(split-app-modules,
    AS_HELP_STRING([--enable-split-app-modules],
        [Split file lists for app modules, e.g. base, calc.
         Has effect only with make distro-pack-install]),
,)

AC_ARG_ENABLE(split-opt-features,
    AS_HELP_STRING([--enable-split-opt-features],
        [Split file lists for some optional features, .e.g. pyuno, testtool.
         Has effect only with make distro-pack-install]),
,)

AC_ARG_ENABLE(cairo-canvas,
[  --disable-cairo-canvas  Determines whether to build the Cairo canvas on
                          platforms where Cairo is available.
])

AC_ARG_ENABLE(librsvg,
    AS_HELP_STRING([--enable-librsvg=<no/auto/system/internal/fully-internal>],
        [Enables or disables use of librsvg to render SVG at run-time.
         Also specificed what librsvg to use. 'auto' is the default.
         'fully-internal' also forces internal versions of libraries (only)
         librsvg depends on (currently GLib, gdk-pixbuf, libcroco, libgsf,
         pango).]))

AC_ARG_ENABLE(opengl,
    AS_HELP_STRING([--disable-opengl],
        [Determines whether to build the OpenGL 3D slide transitions component.]),
,enable_opengl=yes)

AC_ARG_ENABLE(dbus,
    AS_HELP_STRING([--enable-dbus],
        [Determines whether to enable presentation mode screensaver control
         under GNOME via DBUS.]),
,enable_dbus=no)

AC_ARG_ENABLE(gconf,
    AS_HELP_STRING([--disable-gconf],
        [Determines whether to use the GConf support.]),
,enable_gconf=yes)

AC_ARG_ENABLE(gnome-vfs,
    AS_HELP_STRING([--disable-gnome-vfs],
        [Determines whether to use the Gnome Virtual Filing System on platforms
         where that VFS is available.]),
,enable_gnome_vfs=yes)

AC_ARG_ENABLE(gio,
    AS_HELP_STRING([--enable-gio],
        [Determines whether to use the GIO support.]),
,enable_gio=no)

AC_ARG_ENABLE(build-mozilla,
    AS_HELP_STRING([--disable-build-mozilla],
        [Use this option if you do not want to build the Mozilla components from
         the Mozilla source code but take precompiled zips.]),
,)

AC_ARG_ENABLE(xmlsec,
    AS_HELP_STRING([--disable-xmlsec],
        [Whether to enable XMLsec for open document signing.]),
)

AC_ARG_ENABLE(tde,
    AS_HELP_STRING([--enable-tde],
        [Determines whether to use TQt/TDE vclplug on platforms where TQt and
         TDE are available.]),
,)

AC_ARG_ENABLE(tdeab,
    AS_HELP_STRING([--disable-tdeab],
        [Disable the TDE address book support.]),
,
    if test "$enable_tde" = "yes"; then
        enable_tdeab=yes;
    fi
)

AC_ARG_ENABLE(kde,
    AS_HELP_STRING([--enable-kde],
        [Determines whether to use Qt3/KDE3 vclplug on platforms where Qt3 and
         KDE3 are available.]),
,)

AC_ARG_ENABLE(kdeab,
    AS_HELP_STRING([--disable-kdeab],
        [Disable the KDE3 address book support.]),
,
    if test "$enable_kde" = "yes"; then
        enable_kdeab=yes;
    fi
)

AC_ARG_ENABLE(kde4,
    AS_HELP_STRING([--enable-kde4],
        [Determines whether to use Qt4/KDE4 vclplug on platforms where Qt4 and
         KDE4 are available. May be used with --enable-kde if you want to support
         both KDE3 and KDE4.]),
,)

AC_ARG_ENABLE(headless,
    AS_HELP_STRING([--enable-headless],
        [Disable building of GUIs to reduce dependencies. Useful for
        server usage. Work in progress, use only if you are hacking on
        it. Not related to the --headless option.]), ,)

AC_ARG_ENABLE(unix-qstart-libpng,
    AS_HELP_STRING([--disable-unix-qstart-libpng],
        [On UNIX systems, we have a faster splash app, that can use libpng to
         render its splash, if we can safely link to the system libpng then
         enabling this is a good idea (ie. for Linux Distro packaging).]),
,enable_unix_qstart_libpng=yes)

AC_ARG_ENABLE(binfilter,
    AS_HELP_STRING([--enable-binfilter],
        [Enable legacy binary file formats filters build.]),
,enable_binfilter=no
)

AC_ARG_ENABLE(rpath,
    AS_HELP_STRING([--disable-rpath],
        [Disable the use of relative paths in shared libraries.]),
,)

AC_ARG_ENABLE(randr,
    AS_HELP_STRING([--disable-randr],
        [Disable RandR support in the vcl project.]),
,enable_randr=yes)

AC_ARG_ENABLE(randr-link,
    AS_HELP_STRING([--disable-randr-link],
        [Disable linking with libXrandr, instead dynamically open it at runtime.]),
,enable_randr_link=yes)

AC_ARG_ENABLE(gstreamer,
    AS_HELP_STRING([--disable-gstreamer],
        [Disable building the gstreamer avmedia backend.]),
,enable_gstreamer=yes)

AC_ARG_ENABLE(neon,
    AS_HELP_STRING([--disable-neon],
        [Disable neon and the compilation of webdav binding.]),
,)

AC_ARG_ENABLE(build-unowinreg,
    AS_HELP_STRING([--enable-build-unowinreg],
        [Do not use the prebuilt unowinreg.dll. Build it instead. The MinGW C++
         compiler is needed on Linux.])
    [
                          Usage:     --enable-build-unowinreg
    ],
,)

AC_ARG_ENABLE(verbose,
    AS_HELP_STRING([--enable-verbose],
        [Increase build verbosity.])[
  --disable-verbose       Decrease build verbosity.],
,)

AC_ARG_ENABLE(dependency-tracking,
    AS_HELP_STRING([--enable-dependency-tracking],
        [Do not reject slow dependency extractors.])[
  --disable-dependency-tracking
                          Disables generation of dependency information.
                          Speed up one-time builds.],
,)

AC_ARG_ENABLE(icecream,
    AS_HELP_STRING([--enable-icecream],
        [Use the 'icecream' distributed compiling tool to speedup the compilation.
         It defaults to /opt/icecream for the location of the icecream gcc/g++
         wrappers, you can override that using --with-gcc-home=/the/path switch.]),
,)

AC_ARG_ENABLE(zenity,
    AS_HELP_STRING([--disable-zenity],
        [Do not display a build icon in the notification area (on unix) during build.]),
,enable_zenity=yes)

AC_ARG_ENABLE(nsplugin,
    AS_HELP_STRING([--disable-nsplugin],
        [Do not build nsplugin extension for browser embedding.])
)

AC_ARG_ENABLE(cups,
    AS_HELP_STRING([--disable-cups],
        [Do not build cups support.])
)

AC_ARG_ENABLE(ccache,
    AS_HELP_STRING([--disable-ccache],
        [Do not try to use ccache automatically.
         By default, we will try to detect if ccache is available; in that case if
         CC/CXX are not yet set, and --enable-icecream is not given, we
         attempt to use ccache. --disable-ccache disables ccache completely.
]),
,)

AC_ARG_ENABLE(cl-x64,
    AS_HELP_STRING([--enable-cl-x64],
        [Build a 64-bit LibreOffice using the Microsoft C/C++ x64
        compiler. Incomplete and doesn't work, use only if you are
        hacking on it.]), ,)

AC_ARG_ENABLE(extra-gallery,
    AS_HELP_STRING([--enable-extra-gallery],
        [Add extra gallery content.]),
,)

AC_ARG_ENABLE(extra-template,
    AS_HELP_STRING([--enable-extra-template],
        [Add extra template content.]),
,)

AC_ARG_ENABLE(extra-sample,
    AS_HELP_STRING([--enable-extra-sample],
        [Add extra sample content.]),
,)

AC_ARG_ENABLE(extra-font,
    AS_HELP_STRING([--enable-extra-font],
        [Add extra font content.]),
,)

AC_ARG_ENABLE(oxygenoffice,
    AS_HELP_STRING([--enable-oxygenoffice],
        [Download OxygenOffice branding and set custom settings.]),
,)

AC_ARG_ENABLE(lomenubar,
    AS_HELP_STRING([--enable-lomenubar],
        [Enable global menu support.]),
,)

AC_ARG_ENABLE(online-update,
    AS_HELP_STRING([--enable-online-update],
        [Enable the online update service that will check for new versions of
         LibreOffice. By default, it is on on Windows and Mac, and off on Linux.]),
,)

AC_ARG_ENABLE(release-build,
    AS_HELP_STRING([--enable-release-build],
        [Enable release build.
         See http://wiki.documentfoundation.org/DevBuild]),
,)

AC_ARG_ENABLE(silent-msi,
    AS_HELP_STRING([--enable-silent-msi],
        [Enable MSI with LIMITUI=1 (silent install).]),
,)

AC_ARG_ENABLE(postgresql-sdbc,
    AS_HELP_STRING([--disable-postgresql-sdbc],
        [Disable the build of the PostgreSQL-SDBC driver.])
)

dnl ===================================================================
dnl Optional Packages (--with/without-)
dnl ===================================================================
AC_ARG_WITH(android-ndk,
    AS_HELP_STRING([--with-android-ndk],
        [Specify location of the Android Native Development Kit. Mandatory when building for Android.]),
,)

AC_ARG_WITH(android-sdk,
    AS_HELP_STRING([--with-android-sdk],
        [Specify location of the Android SDK. Mandatory when building for Android.]),
,)

AC_ARG_WITH(gnu-patch,
    AS_HELP_STRING([--with-gnu-patch],
        [Specify location of GNU patch on Solaris or FreeBSD.]),
,)

AC_ARG_WITH(build-platform-configure-options,
        [Specify options for the configure script run for the *build* platform in a cross-compilation])

AC_ARG_WITH(gnu-cp,
    AS_HELP_STRING([--with-gnu-cp],
        [Specify location of GNU cp on Solaris or FreeBSD.]),
,)

AC_ARG_WITH(external-tar,
    AS_HELP_STRING([--with-external-tar=<TARFILE PATH>],
        [Specify path to tarfiles manually.]),
    TARFILE_LOCATION=$withval ,
)

AC_ARG_WITH(solver-and-workdir-root,
    AS_HELP_STRING([--with-solver-and-workdir-root=<PATH>],
        [Specify path that contains SOLARVER and WORKDIR directories manually.])
)

AC_ARG_WITH(linked-git,
    AS_HELP_STRING([--with-linked-git=<OTHER_CLONE_DIR>],
        [Specify another checkout's clonedir to re-use. This makes use of
                 git-new-workdir, and saves a lot of diskspace when having multiple
                 trees side-by-side.]),
    GIT_LINK_SRC=$withval ,
)

AC_ARG_WITH(openldap,
    AS_HELP_STRING([--with-openldap],
        [Enables the use of the OpenLDAP LDAP SDK instead of the Netscape/Mozilla one.]),
,)

AC_ARG_WITH(vba-package-format,
    AS_HELP_STRING([--with-vba-package-format],
        [Specify package format for vba compatibility api. Specifying  "builtin"
         means the api component and associated type library are  part of the
         installation set. Specifying "extn" creates an uno extension that is
         part of the installation set (located in the program directory) that
         MUST be optionally registered using either the unopkg executeable or the
         extension manager gui.])
    [
                          Note: "builtin" is the default, "extn" can cause
                          problems.

                          Usage:     --with-vba-package-format="builtin" or
                                     --with-vba-package-format="extn"
    ],
,)

AC_ARG_WITH(theme,
    AS_HELP_STRING([--with-theme="theme1 theme2..."],
        [Choose which themes to include. By default those themes with an '*' are included.
         Possible choices: *crystal, *default (galaxy), *hicontrast, human, industrial, *oxygen, *tango.]),
,)

AC_ARG_WITH(helppack-integration,
[
  --without-helppack-integration      It will not integrate the helppacks to the installer
                          of the product.
                          Please use this switch to use the online help or separate help packages.],
,)

AC_ARG_WITH(fonts,
    AS_HELP_STRING([--without-fonts],
        [LibreOffice includes some third-party fonts to provide a reliable basis for
         help content, templates, samples, etc. When these fonts are already
         known to be available on the system then you should use this option.]),
,)

AC_ARG_WITH(ppds,
    AS_HELP_STRING([--without-ppds],
        [Removes Postscript Printer definition files from LibreOffice
         installation set, for people building for specific distributions where
         PPDs are known to be already available (every recent distro with CUPS backend).]),
,)

AC_ARG_WITH(afms,
    AS_HELP_STRING([--without-afms],
        [Removes bitmap font files from LibreOffice installation set, for people
         building for specific distributions where AFM files or TrueType Fonts
         are known to be available.]),
,)

AC_ARG_WITH(agfa-monotype-fonts,
     AS_HELP_STRING([--with-agfa-monotype-fonts],
          [This switch should only be enabled for those who have the right
           to use or distribute the proprietary Agfa Monotype
           fonts.])
,)

AC_ARG_WITH(epm,
    AS_HELP_STRING([--with-epm],
        [Decides which epm to use. Default is to use the one from the system if
         one is built. When either this is not there or you say =internal epm
         will be built.]),
,)

AC_ARG_WITH(package-format,
    AS_HELP_STRING([--with-package-format],
        [Specify package format(s) for LibreOffice installsets. Default is the
         "normal" one of the OS/Distribution. Possible values: aix, bsd, deb,
         inst, tardist, osx, pkg, rpm, setld, native, portable, archive, dmg,
          installed, msi. Example: --with-package-format="deb dmg"]),
,)

AC_ARG_WITH(system-libs,
    AS_HELP_STRING([--with-system-libs],
        [Use libraries already on system -- enables all --with-system-* flags except
         mozilla.]),
,)

AC_ARG_WITH(system-headers,
    AS_HELP_STRING([--with-system-headers],
        [Use headers already on system -- enables all --with-system-* flags for
         external packages whose headers are the only entities used i.e.
         boost/vigra/odbc/sane-header(s).]),,
    [with_system_headers="$with_system_libs"])

AC_ARG_WITH(system-jars,
    AS_HELP_STRING([--without-system-jars],
        [When building with --with-system-libs, also the needed jars are expected
         on the system. Use this to disable that]),,
    [with_system_jars="$with_system_libs"])

AC_ARG_WITH(system-stdlibs,
    AS_HELP_STRING([--without-system-stdlibs],
        [Bundle the used libstdc++/libgcc_s into the installation set.]),,
    [with_system_stdlibs="$with_system_libs"])

AC_ARG_WITH(system-cairo,
    AS_HELP_STRING([--with-system-cairo],
        [Use Cairo libraries already on system.]),,
    [with_system_cairo="$with_system_libs"])

AC_ARG_WITH(system-graphite,
    AS_HELP_STRING([--with-system-graphite],
        [Use graphite library already installed on system.]),,
    [with_system_graphite="$with_system_libs"])

AC_ARG_WITH(system-nss,
    AS_HELP_STRING([--with-system-nss],
        [Use NSS/nspr libraries already on system.]),,
    [with_system_nss="$with_system_libs"])

AC_ARG_WITH(system-sampleicc,
    AS_HELP_STRING([--with-system-sampleicc],
        [Use SampleICC libraries already on system (used only during build).]),,
    [with_system_sampleicc="$with_system_libs"])

AC_ARG_WITH(mozilla-version,
    AS_HELP_STRING([--with-mozilla-version],
        [Choose which version of Mozilla to use while building Mozilla.
         (default=1.7.5) Note that not all versions are supported.]),
,)

AC_ARG_WITH(mozilla-toolkit,
    AS_HELP_STRING([--with-mozilla-toolkit],
        [Choose which GUI toolkit to use while building Mozilla components. (default=gtk2)]),
,)

AC_ARG_WITH(myspell-dicts,
    AS_HELP_STRING([--without-myspell-dicts],
        [Removes myspell dictionaries from LibreOffice installation set, for
         people building for specific distributions where the myspell dictionaries
         are installed from other sources.]),
,)

AC_ARG_WITH(system-dicts,
    AS_HELP_STRING([--without-system-dicts],
        [Do not use dictionaries from system paths.]),
,)

AC_ARG_WITH(external-dict-dir,
    AS_HELP_STRING([--with-external-dict-dir],
        [Specify external dictionary dir.]),
,)

AC_ARG_WITH(external-hyph-dir,
    AS_HELP_STRING([--with-external-hyph-dir],
        [Specify external hyphenation pattern dir.]),
,)

AC_ARG_WITH(external-thes-dir,
    AS_HELP_STRING([--with-external-thes-dir],
        [Specify external thesaurus dir.]),
,)

AC_ARG_WITH(system-zlib,
    AS_HELP_STRING([--with-system-zlib],
        [Use zlib already on system.]),,
    [with_system_zlib=auto])

AC_ARG_WITH(system-openssl,
    AS_HELP_STRING([--with-system-openssl],
        [Use OpenSSL already on system.]),,
    [with_system_openssl="$with_system_libs"])

AC_ARG_WITH(system-jpeg,
    AS_HELP_STRING([--with-system-jpeg],
        [Use jpeg already on system.]),,
    [with_system_jpeg=auto])

AC_ARG_WITH(system-clucene,
    AS_HELP_STRING([--with-system-clucene],
        [Use clucene already on system.]),,
    [with_system_clucene="$with_system_libs"])

AC_ARG_WITH(system-expat,
    AS_HELP_STRING([--with-system-expat],
        [Use expat already on system.]),,
    [with_system_expat="$with_system_libs"])

AC_ARG_WITH(system-libcmis,
    AS_HELP_STRING([--with-system-libcmis],
        [Use libcmis already on system.]),,
    [with_system_libcmis="$with_system_libs"])

AC_ARG_WITH(system-lcms2,
    AS_HELP_STRING([--with-system-lcms2],
        [Use littlecms v2 already on system.]),,
    [with_system_lcms2="$with_system_libs"])

AC_ARG_WITH(system-libcdr,
    AS_HELP_STRING([--with-system-libcdr],
        [Use libcdr already on system.]),,
    [with_system_libcdr="$with_system_libs"])

AC_ARG_WITH(system-libvisio,
    AS_HELP_STRING([--with-system-libvisio],
        [Use libvisio already on system.]),,
    [with_system_libvisio="$with_system_libs"])

AC_ARG_WITH(system-libwpd,
    AS_HELP_STRING([--with-system-libwpd],
        [Use libwpd already on system.]),,
    [with_system_libwpd="$with_system_libs"])

AC_ARG_WITH(system-libwps,
    AS_HELP_STRING([--with-system-libwps],
        [Use libwps already on system.]),,
    [with_system_libwps="$with_system_libs"])

AC_ARG_WITH(system-libwpg,
    AS_HELP_STRING([--with-system-libwpg],
        [Use libwpg already on system.]),,
    [with_system_libwpg="$with_system_libs"])

AC_ARG_WITH(system-libxml,
    AS_HELP_STRING([--with-system-libxml],
        [Use libxml/libxslt already on system.]),,
    [with_system_libxml=auto])

AC_ARG_WITH(system-icu,
    AS_HELP_STRING([--with-system-icu],
        [Use icu already on system.]),,
    [with_system_icu="$with_system_libs"])

AC_ARG_WITH(system-poppler,
    AS_HELP_STRING([--with-system-poppler],
        [Use system poppler. (only needed for pdfimport extension)]),,
    [with_system_poppler="$with_system_libs"])

AC_ARG_WITH(system-db,
    AS_HELP_STRING([--with-system-db],
        [Use Berkeley db already on system.]),,
    [with_system_db="$with_system_libs"])

AC_ARG_WITH(system-apache-commons,
    AS_HELP_STRING([--with-system-apache-commons],
        [Use Apache commons libraries already on system.]),,
    [with_system_apache_commons="$with_system_jars"])

AC_ARG_WITH(system-mysql,
    AS_HELP_STRING([--with-system-mysql],
        [Use MySQL libraries already on system, for building the MySQL Connector/LibreOffice
         extension. If the the mysql_config executable is not in PATH, use MYSQLCONFIG to
         point to it.]),,
    [with_system_mysql="$with_system_libs"])

AC_ARG_WITH(libmysql-path,
    AS_HELP_STRING([--with-libmysql-path],
        [Use Connector/C (libmysql) installation for building the MySQL
         Connector/LibreOffice extension.])
    [
                          Usage:     --with-libmysql-path=<absolute path to
                                                  your Connector/C installation>
    ],
,)

AC_ARG_WITH(system-mysql-cppconn,
    AS_HELP_STRING([--with-system-mysql-cppconn],
        [Use MySQL C++ Connector libraries already on system.]),,
    [with_system_mysql_cppconn="$with_system_libs"])

AC_ARG_WITH(system-postgresql,
    AS_HELP_STRING([--with-system-postgresql],
        [Use PostgreSQL libraries already on system, for building the PostgreSQL-SDBC
         driver. If pg_config is not in PATH, use PGCONFIG to point to it.]),,
    [with_system_postgresql="$with_system_libs"])

AC_ARG_WITH(libpq-path,
    AS_HELP_STRING([--with-libpq-path],
        [Use this PostgreSQL C interface (libpq) installation for building
         the PostgreSQL-SDBC extension.])
    [
                          Usage:     --with-libpq-path=<absolute path to
                                                  your libq installation>
    ],
,)

AC_ARG_WITH(system-hsqldb,
    AS_HELP_STRING([--with-system-hsqldb],
        [Use hsqldb already on system.]),,
    [with_system_hsqldb="$with_system_jars"])

AC_ARG_WITH(hsqldb-jar,
    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
        [Specify path to jarfile manually.]),
    HSQLDB_JAR=$withval)

AC_ARG_WITH(system-beanshell,
    AS_HELP_STRING([--with-system-beanshell],
        [Use beanshell already on system.]),,
    [with_system_beanshell="$with_system_jars"])

AC_ARG_WITH(beanshell-jar,
    AS_HELP_STRING([--with-beanshell-jar=JARFILE],
        [Specify path to jarfile manually.]),
    BSH_JAR=$withval)

AC_ARG_WITH(system-rhino,
    AS_HELP_STRING([--with-system-rhino],
        [Use rhino already on system.]),,)
#    [with_system_rhino="$with_system_jars"])
# Above is not used as we have different debug interface
# patched into internal rhino. This code needs to be fixed
# before we can enable it by default.

AC_ARG_WITH(rhino-jar,
    AS_HELP_STRING([--with-rhino-jar=JARFILE],
        [Specify path to jarfile manually.]),
    RHINO_JAR=$withval)

AC_ARG_WITH(commons-codec-jar,
    AS_HELP_STRING([--with-commons-codec-jar=JARFILE],
        [Specify path to jarfile manually.]),
    COMMONS_CODEC_JAR=$withval)

AC_ARG_WITH(commons-lang-jar,
    AS_HELP_STRING([--with-commons-lang-jar=JARFILE],
        [Specify path to jarfile manually.]),
    COMMONS_LANG_JAR=$withval)

AC_ARG_WITH(commons-httpclient-jar,
    AS_HELP_STRING([--with-commons-httpclient-jar=JARFILE],
        [Specify path to jarfile manually.]),
    COMMONS_HTTPCLIENT_JAR=$withval)

AC_ARG_WITH(commons-logging-jar,
    AS_HELP_STRING([--with-commons-logging-jar=JARFILE],
        [Specify path to jarfile manually.]),
    COMMONS_LOGGING_JAR=$withval)

AC_ARG_WITH(system-servlet-api,
    AS_HELP_STRING([--with-system-servlet-api],
        [Use servlet-api already on system.]),,
    [with_system_servlet_api="$with_system_jars"])

AC_ARG_WITH(servlet-api-jar,
    AS_HELP_STRING([--with-servlet-api-jar=JARFILE],
        [Specify path to jarfile manually.]),
    SERVLETAPI_JAR=$withval)

AC_ARG_WITH(system-jfreereport,
    AS_HELP_STRING([--with-system-jfreereport],
        [Use JFreeReport already on system.]),,
    [with_system_jfreereport="$with_system_jars"])

AC_ARG_WITH(sac-jar,
    AS_HELP_STRING([--with-sac-jar=JARFILE],
        [Specify path to jarfile manually.]),
    SAC_JAR=$withval)

AC_ARG_WITH(libxml-jar,
    AS_HELP_STRING([--with-libxml-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBXML_JAR=$withval)

AC_ARG_WITH(flute-jar,
    AS_HELP_STRING([--with-flute-jar=JARFILE],
        [Specify path to jarfile manually.]),
    FLUTE_JAR=$withval)

AC_ARG_WITH(jfreereport-jar,
    AS_HELP_STRING([--with-jfreereport-jar=JARFILE],
        [Specify path to jarfile manually.]),
    JFREEREPORT_JAR=$withval)

AC_ARG_WITH(liblayout-jar,
    AS_HELP_STRING([--with-liblayout-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBLAYOUT_JAR=$withval)

AC_ARG_WITH(libloader-jar,
    AS_HELP_STRING([--with-libloader-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBLOADER_JAR=$withval)

AC_ARG_WITH(libloader-jar,
    AS_HELP_STRING([--with-libloader-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBLOADER_JAR=$withval)

AC_ARG_WITH(libformula-jar,
    AS_HELP_STRING([--with-libformula-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBFORMULA_JAR=$withval)

AC_ARG_WITH(librepository-jar,
    AS_HELP_STRING([--with-librepository-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBREPOSITORY_JAR=$withval)

AC_ARG_WITH(libfonts-jar,
    AS_HELP_STRING([--with-libfonts-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBFONTS_JAR=$withval)

AC_ARG_WITH(libserializer-jar,
    AS_HELP_STRING([--with-libserializer-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBSERIALIZER_JAR=$withval)

AC_ARG_WITH(libbase-jar,
    AS_HELP_STRING([--with-libbase-jar=JARFILE],
        [Specify path to jarfile manually.]),
    LIBBASE_JAR=$withval)

AC_ARG_WITH(system-saxon,
    AS_HELP_STRING([--with-system-saxon],
        [Use saxon already on system.]),,
    [with_system_saxon="$with_system_jars"])

AC_ARG_WITH(saxon-jar,
    AS_HELP_STRING([--with-saxon-jar=JARFILE],
        [Specify path to jarfile manually.]),
    SAXON_JAR=$withval)

AC_ARG_WITH(system-odbc,
    AS_HELP_STRING([--with-system-odbc],
        [Use the odbc headers already on system.]),,
    [with_system_odbc="$with_system_headers"])

AC_ARG_WITH(system-sane,
    AS_HELP_STRING([--with-system-sane],
        [Use sane.h already on system.]),,
    [with_system_sane="$with_system_headers"])

AC_ARG_WITH(system-xextensions-headers,
    AS_HELP_STRING([--with-system-xextensions-headers],
        [To build without system X11 extensions headers, use
         --without-system-xextensions-headers. This is possibly
         useful on legacy unix systems which ship with the libs
         but without the headers.]))

AC_ARG_WITH(system-mesa-headers,
    AS_HELP_STRING([--with-system-mesa-headers],
        [Use Mesa headers already on system.]),,
    [with_system_mesa_headers="$with_system_headers"])

AC_ARG_WITH(system-curl,
    AS_HELP_STRING([--with-system-curl],
        [Use curl already on system.]),,
    [with_system_curl=auto])

AC_ARG_WITH(system-boost,
    AS_HELP_STRING([--with-system-boost],
        [Use boost already on system.]),,
    [with_system_boost="$with_system_headers"])

AC_ARG_WITH(system-mdds,
    AS_HELP_STRING([--with-system-mdds],
        [Use mdds already on system.]),,
    [with_system_mdds="$with_system_headers"])

AC_ARG_WITH(system-vigra,
    AS_HELP_STRING([--with-system-vigra],
        [Use vigra already on system.]),,
    [with_system_vigra="$with_system_headers"])

AC_ARG_WITH(system-neon,
    AS_HELP_STRING([--with-system-neon],
        [Use neon already on system.]),,
    [with_system_neon="$with_system_libs"])

AC_ARG_WITH(system-hunspell,
    AS_HELP_STRING([--with-system-hunspell],
        [Use libhunspell already on system.]),,
    [with_system_hunspell="$with_system_libs"])

AC_ARG_WITH(system-mythes,
    AS_HELP_STRING([--with-system-mythes],
        [Use mythes already on system.]),,
    [with_system_mythes="$with_system_libs"])

AC_ARG_WITH(system-altlinuxhyph,
    AS_HELP_STRING([--with-system-altlinuxhyph],
        [Use ALTLinuxhyph already on system.]),,
    [with_system_altlinuxhyph="$with_system_libs"])

AC_ARG_WITH(system-lpsolve,
    AS_HELP_STRING([--with-system-lpsolve],
        [Use lpsolve already on system.]),,
    [with_system_lpsolve="$with_system_libs"])

AC_ARG_WITH(system-libexttextcat,
    AS_HELP_STRING([--with-system-libexttextcat],
        [Use libexttextcat already on system.]),,
    [with_system_libexttextcat="$with_system_libs"])

AC_ARG_WITH(system-cppunit,
    AS_HELP_STRING([--with-system-cppunit],
        [Use cppunit already on system.]),,
    [with_system_cppunit="$with_system_libs"])

AC_ARG_WITH(system-redland,
    AS_HELP_STRING([--with-system-redland],
        [Use redland library already on system.]),,
    [with_system_redland="$with_system_libs"])

AC_ARG_WITH(system-mozilla,
    AS_HELP_STRING([--with-system-mozilla],
        [Use Mozilla already on system. Note that some components cannot be built
         against a contemporary Mozilla. The flavour used can be specified by
         --with-system-mozilla=<flavour>. Supported are: libxul (default),
         xulrunner, firefox, seamonkey, mozilla, iceape.]),
    WITH_SYSTEM_MOZILLA=$withval ,
WITH_SYSTEM_MOZILLA=no)

AC_ARG_WITH(system-mozilla-headers,
    AS_HELP_STRING([--with-system-mozilla-headers],
        [Use mozilla headers provided by system instead of bundled ones. Used in
         nsplugin]),,
    [with_system_mozilla_headers="$with_system_headers"]
)

AC_ARG_WITH(system-gettext,
    AS_HELP_STRING([--with-system-gettext],
        [Use gettext runtime library already on system.]),,
    [with_system_gettext="$with_system_libs"])

AC_ARG_WITH(system-libpng,
    AS_HELP_STRING([--with-system-libpng],
        [Use libpng already on system.]),,
    [with_system_libpng=auto])

AC_ARG_WITH(linker-hash-style,
    AS_HELP_STRING([--with-linker-hash-style],
        [Use linker with --hash-style=<style> when linking shared objects.
         Possible values: "sysv", "gnu", "both". The default value is "gnu"
         if supported on the build system, and "sysv" otherwise.]))

AC_ARG_WITH(stlport,
    AS_HELP_STRING([--with-stlport],
        [Build the STLPort library for compatibility with old extensions for
         architectures where STLPort used to be used.]),
    with_stlport=$withval ,
with_stlport=auto)

AC_ARG_WITH(jdk-home,
    AS_HELP_STRING([--with-jdk-home],
        [If you have installed JDK 1.3 or later on your system please supply the
         path here. Note that this is not the location of the java command but the
         location of the entire distribution.])
    [
                          Usage:     --with-jdk-home=<absolute path to JDK home>
    ],
,)

AC_ARG_WITH(gxx_include_path,
    AS_HELP_STRING([--with-gxx-include-path],
        [If you want to override the autodetected g++ include path.])
    [
                          Usage:     --with-gxx-include-path=<absolute path to
                                                                g++ include dir>
    ],
,)

AC_ARG_WITH(help,
    AS_HELP_STRING([--with-help],
        [Enable the build of help.

         To build without help, use --without-help.]))

AC_ARG_WITH(java,
    AS_HELP_STRING([--with-java],
        [Specify the name of the Java interpreter command. Typically "java"
         which is the default.

         To build without support for Java components, applets, accessibility
         or the XML filters written in Java, use --without-java or --with-java=no.])
    [
                          Usage:     --with-java==<java command>
                                     --without-java
    ],
    [ test -z "$with_java" -o "$with_java" = "yes" && with_java=java ],
    [ with_java=java ]
)

AC_ARG_WITH(java_target_version,
    AS_HELP_STRING([--with-java-target-version],
        [Generate class files that will work on JVMs with the specified version.
         For example, use --with-java-target-version=1.4 to make sure that the
         application will work with JVM 1.4 even when compiled with JDK 1.5.])
    [
                          This option is ignored when you compile with gcj/gij.

                          Usage:     --with-java-target-version=<jvm version>
    ],
,)

AC_ARG_WITH(jvm-path,
    AS_HELP_STRING([--with-jvm-path],
        [Use a specific JVM search path at runtime.])
    [
                          Usage:     --with-jvm-path=<absolute path to parent of jvm home>

                          e. g.: --with-jvm-path=/usr/lib/
                                 to find JRE/JDK in /usr/lib/jvm/
    ],
,)

AC_ARG_WITH(ant-home,
    AS_HELP_STRING([--with-ant-home],
        [If you have installed Jakarta Ant on your system, please supply the path here.
         Note that this is not the location of the Ant binary but the location
         of the entire distribution.])
    [
                          Usage:     --with-ant-home=<absolute path to Ant home>
    ],
,)

AC_ARG_WITH(junit,
    AS_HELP_STRING([--with-junit],
        [Specifies the JUnit 4 jar file to use for JUnit-based tests.
         --without-junit disables those tests. Not relevant in the --without-java case.])
    [
                          Usage:     --with-junit=<absolute path to JUnit 4 jar>
    ],
,with_junit=yes)

AC_ARG_WITH(perl-home,
    AS_HELP_STRING([--with-perl-home],
        [If you have installed Perl 5 Distribution, on your system, please
         supply the path here. Note that this is not the location of the Perl
         binary but the location of the entire distribution.])
    [
                          Usage:     --with-perl-home=<abs. path to Perl 5 home>
    ],
,)

AC_ARG_WITH(
    [doxygen],
    AS_HELP_STRING(
        [--with-doxygen],
        [Specifies the doxygen executable to use when generating ODK C/C++
         documentation. --without-doxygen disables generation of ODK C/C++
         documentation. Not relevant in the --disable-odk case.])
    [
                          Usage:     --with-doxygen=<absolute path to doxygen executable>
    ],,
    [with_doxygen=yes])

AC_ARG_WITH(cl-home,
    AS_HELP_STRING([--with-cl-home],
        [For Windows NT users, please supply the path for the Microsoft C/C++
         compiler. Note that this is not the location of the compiler binary but
         the location of the entire distribution.])
    [
                          Usage:     --with-cl-home=<absolute path to Microsoft
                                                            C/C++ compiler home>
    ],
,)

AC_ARG_WITH(mspdb-path,
    AS_HELP_STRING([--with-mspdb-path],
        [For Microsoft C/C++ compiler users, please supply the path pointing to
         the mspdb80.dll (if using Visual Studio 2008) or mspdb100.dll (if using
         Visual Studio 2010).])
    [
                          Usage:     --with-mspdb-path=<path to
                                                       mspdb80.dll/mspdb100.dll>
    ],
,)

AC_ARG_WITH(midl-path,
    AS_HELP_STRING([--with-midl-path],
        [For Microsoft compiler users, please supply the path pointing to the midl.exe.])
    [
                          Usage:     --with-midl-path=<abs. path to midl.exe>
    ],
,)

AC_ARG_WITH(csc-path,
    AS_HELP_STRING([--with-csc-path],
        [For Windows builds, please supply the path pointing to the csc.exe.
         Usually found automatically when building on Windows.])
    [
                          Usage:     --with-csc-path=<abs. path to csc.exe>
    ],
,)

AC_ARG_WITH(dotnet-framework-home,
    AS_HELP_STRING([--with-dotnet-framework-home],
        [For Microsoft compiler users, please supply the path pointing to
         lib/mscoree.lib, usually something like:
         "/cygdrive/c/Program Files/Windows SDKs/Windows/v7.0"])
    [
                          Note that in most cases it will be automatically
                          found, though.

                          Usage:     --with-dotnet-framework-home=<absolute path to .NET
                                                          Framework>
    ],
,)

AC_ARG_WITH(windows-sdk-home,
    AS_HELP_STRING([--with-windows-sdk-home],
        [For Windows builds, please supply the path to the Windows SDK.
         Usually found automatically when building on Windows.])
    [
                          Usage:     --with-windows-sdk-home=<absolute path to Windows SDK>
    ],
,)

AC_ARG_WITH(directx-home,
    AS_HELP_STRING([--with-directx-home],
        [For Windows users, please supply the path to the Microsoft DirectX SDK.])
    [
                          Usage:     --with-directx-home=<absolute path to
                                                          Microsoft DirectX SDK>
    ],
,)

AC_ARG_WITH(mozilla-build,
    AS_HELP_STRING([--with-mozilla-build],
        [For Windows users, please supply the path to the Mozilla build tools.])
    [
                          Usage:     --with-mozilla-build=<absolute path to
                                                          Mozilla build tools>

                          At the moment of this writing, an installer for the
                          mozilla build tools can be obtained from http://ftp.
                          mozilla.org/pub/mozilla.org/mozilla/libraries/win32.
    ],
    MOZILLABUILD=$withval ,
)

AC_ARG_WITH(lang,
    AS_HELP_STRING([--with-lang],
        [Use this option to build LibreOffice with additional language support.
         English (US) is always included by default.
         Separate multiple languages with space.
         For all languages, use --with-lang=ALL.])
    [
                          Usage:     --with-lang="es sw tu cs sk"
    ],
,)

# Kerberos and GSSAPI used only by PostgreSQL as of LibO 3.5
AC_ARG_WITH(krb5,
    AS_HELP_STRING([--with-krb5],
        [Enable MIT Kerberos 5 support in modules that support it.
         By default automatically enabled on platforms
         where a good system Kerberos 5 is available.]),
,)

AC_ARG_WITH(gssapi,
    AS_HELP_STRING([--with-gssapi],
        [Enable GSSAPI support in modules that support it.
         By default automatically enabled on platforms
         where a good system GSSAPI is available.]),
,)

dnl ===================================================================
dnl Branding
dnl ===================================================================

AC_ARG_WITH(branding,
[  --with-branding        Use given path to retrieve all branding images.
                          Expects /path/intro.png ...
                          /path/backing_rtl_right.png to be there. Individual
                          images can be overridden via --with-intro-bitmap ...
                          --with-startcenter-rtl-left-bitmap switches.

                          Usage:     --with-branding=/path/to/images
],,)

AC_ARG_WITH(intro-bitmap,
[  --with-intro-bitmap    Prefer the specified intro bitmap over the
                          the default one.

                          Usage:     --with-intro-bitmap=/path/my_ooo_intro.png
],,)

AC_ARG_WITH(intro-progressbar-color,
[  --with-intro-progressbar-color    Set color of progress bar on intro screen.
                                     Comma separated RGB values in decimal format.

                          Usage: --with-intro-progressbar-color=126,170,23
],,)

AC_ARG_WITH(intro-progressbar-size,
[  --with-intro-progressbar-size     Set size of progress bar on intro screen.
                                     Comma separated values in decimal format.

                          Usage: --with-intro-progressbar-size=319,10
],,)

AC_ARG_WITH(intro-progressbar-position,
[  --with-intro-progressbar-position Set position of progress bar on intro screen.
                                     Comma separated values in decimal format.

                          Usage: --with-intro-progressbar-position=164,225
],,)

AC_ARG_WITH(intro-progressbar-frame-color,
[  --with-intro-progressbar-frame-color    Set color of progress bar frame on intro screen.
                                           Comma separated RGB values in decimal format.

                          Usage: --with-intro-progressbar-frame-color=207,208,211
],,)

AC_ARG_WITH(flat-logo-svg,
[  --with-flat-logo-svg    Allows specification of the flat Logo SVG.

                          Usage:     --with-flat-logo-svg=/path/my_flat_logo.svg
],,)

AC_ARG_WITH(about-background-svg,
[  --with-about-background-svg    Allows specification of the background SVG for the About dialog.

                          Usage:     --with-about-background-svg=/path/my_libo_about.svg
],,)

AC_ARG_WITH(startcenter-left-bitmap,
[  --with-startcenter-left-bitmap    Similarly to --with-intro-bitmap, this allows
                                     specification of bitmap for the Start center.

                          Usage: --with-startcenter-left-bitmap=/path/my_backing_left.png
],,)

AC_ARG_WITH(startcenter-right-bitmap,
[  --with-startcenter-right-bitmap    Similarly to --with-intro-bitmap, this allows
                                      specification of bitmap for the Start center.

                          Usage: --with-startcenter-right-bitmap=/path/my_backing_right.png
],,)

AC_ARG_WITH(startcenter-rtl-left-bitmap,
[  --with-startcenter-rtl-left-bitmap    Similarly to --with-intro-bitmap, this allows
                                         specification of bitmap for the Start center.

                          Usage: --with-startcenter-rtl-left-bitmap=/path/my_backing_rtl_left.png
],,)

AC_ARG_WITH(startcenter-rtl-right-bitmap,
[  --with-startcenter-rtl-right-bitmap    Similarly to --with-intro-bitmap, this allows
                                          specification of bitmap for the Start center.

                          Usage: --with-startcenter-rtl-right-bitmap=/path/my_backing_rtl_right.png
],,)

AC_ARG_WITH(startcenter-space-bitmap,
[  --with-startcenter-space-bitmap    Similarly to --with-intro-bitmap, this allows
                                      specification of bitmap for the Start center.

                          Usage: --with-startcenter-space-bitmap=/path/my_backing_space.png
],,)

AC_ARG_WITH(vendor,
    AS_HELP_STRING([--with-vendor],
        [Set vendor of the build.])
    [
                          Usage:     --with-vendor="John the Builder"
    ],
,)

AC_ARG_WITH(unix-wrapper,
    AS_HELP_STRING([--with-unix-wrapper],
        [Redefines the name of the UNIX wrapper that will be used in the desktop
         files and in the desktop-integration RPMs.])
    [
                          Usage:     --with-unix-wrapper=ooffice
    ],
,)

AC_ARG_WITH(compat-oowrappers,
    AS_HELP_STRING([--with-compat-oowrappers],
        [Install oo* wrappers in parallel with
         lo* ones to keep backward compatibility.
         Has effect only with make distro-pack-install]),
,)

AC_ARG_WITH(asm-home,
    AS_HELP_STRING([--with-asm-home],
        [For Windows, please supply the path for the ml.exe or ml64.exe assembler.])
    [
                          Usage:     --with-asm-home=<path to assembler directory>
    ],
,)

AC_ARG_WITH(os-version,
    AS_HELP_STRING([--with-os-version],
        [For FreeBSD users, use this option option to override the detected OSVERSION.])
    [
                          Usage:     --with-os-version=<OSVERSION>
    ],
,)

AC_ARG_WITH(mingw-cross-compiler,
    AS_HELP_STRING([--with-mingw-cross-compiler],
        [Specify the MinGW cross-compiler to use.])
    [
                          Usage:     --with-mingw-cross-compiler=<mingw32-g++ command>

                          When building on the ODK on Unix and building unowinreg.dll,
                          specify the MinGW C++ cross-compiler.
    ],
,)

AC_ARG_WITH(build-version,
    AS_HELP_STRING([--with-build-version],
        [Allows the builder to add a custom version tag that will appear in the
         Help/About box for QA purposes.])
    [
                          Usage:     --with-build-version="Built by Jim"
    ],
    with_build_version=$withval ,
)

AC_ARG_WITH(alloc,
    AS_HELP_STRING([--with-alloc],
        [Define which allocator to build with (choices are oo, system, tcmalloc, jemalloc).
         Note that on FreeBSD/NetBSD system==jemalloc]),
,)

AC_ARG_WITH(sun-templates,
    AS_HELP_STRING([--with-sun-templates],
        [Integrate Sun template packages.]),
,)

AC_ARG_WITH(num-cpus,
    AS_HELP_STRING([--with-num-cpus],
        [Number of build processes/cpus to use (number of projects that will build at the same time).
         Multi-process/multi-cpu builds can save a lot of time on multi-cpu machines.
         Defaults to the number of CPUs on the machine.]),
,)

AC_ARG_WITH(max-jobs,
    AS_HELP_STRING([--with-max-jobs],
        [Maximum number of jobs that will be issued at the same time per dmake or gbuild subproject.
         The real number of the jobs is affected by the --with-num-cpus too, it can get up to CPUS*max_jobs.
         Defaults to 1, unless you configure --enable-icecream - then to 10.]),
,)

dnl ===================================================================
dnl MacOSX build and runtime environment options
dnl ===================================================================

AC_ARG_WITH(macosx-sdk,
    AS_HELP_STRING([--with-macosx-sdk],
        [Use a specific SDK for building.])
    [
                          Usage:     --with-macosx-sdk=<version>

                          e. g.: --with-macosx-sdk=10.4

                          there are 3 options to controle the MacOSX build:
                          --with-macosx-sdk (refered as 'sdl' below)
                          --with-macosx-version-min-required (refered as 'min' below)
                          --with-macosx-version-max-allowed (refered as 'max' below)

                          the connection between these value and the default they take is as follow:
                          ( ? means not specified on the command line, constraint: x <= y <= z)

                          ==========================================
                           command line      || config result
                          ==========================================
                          min  | max  | sdk  || min  | max  | sdk  |
                          ?    | ?    | ?    || 10.4 | 10.4 | 10.4 |
                          ?    | ?    | 10.x || 10.4 | 10.4 | 10.x |
                          ?    | 10.x | ?    || 10.4 | 10.x | 10.x |
                          ?    | 10.x | 10.y || 10.4 | 10.x | 10.y |
                          10.x | ?    | ?    || 10.x | 10.x | 10.x |
                          10.x | ?    | 10.y || 10.x | 10.x | 10.y |
                          10.x | 10.y | ?    || 10.x | 10.y | 10.y |
                          10.x | 10.y | 10.z || 10.x | 10.y | 10.z |


                          see: http://developer.apple.com/library/mac/#technotes/tn2064/_index.html
                          for a detailled technical explanation of these variables

                          Note: MACOSX_DEPLOYMENT_TARGET will be set to the value of 'min'.

    ],
,)

AC_ARG_WITH(macosx-version-min-required,
    AS_HELP_STRING([--with-macosx-version-min-required],
        [set the minimum OS version needed to run the built LibreOffice])
    [
                          Usage:     --with-macosx-version-min-required=<version>

                          e. g.: --with-macos-version-min-required=10.4
                          see --with-macosx-sdk for more info
    ],
,)

AC_ARG_WITH(macosx-version-max-allowed,
    AS_HELP_STRING([--with-macosx-version-max-allowed],
        [set the maximum allowed OS version the LibreOffice compilation can use APIs from])
    [
                          Usage:     --with-macosx-version-max-allowed=<version>

                          e. g.: --with-macos-version-max-allowed=10.6
                          see --with-macosx-sdk for more info
    ],
,)


dnl ===================================================================
dnl options for stuff used during cross-compilation build
dnl These are superseded by --with-build-platform-configure-options
dnl ===================================================================

AC_ARG_WITH(system-boost-for-build,
    AS_HELP_STRING([--with-system-boost-for-build],
        [Use boost already on system for build tools (cross-compilation only).]))

AC_ARG_WITH(system-cppunit-for-build,
    AS_HELP_STRING([--with-system-cppunit-for-build],
        [Use cppunit already on system for build tools (cross-compilation only).]))

AC_ARG_WITH(system-db-for-build,
    AS_HELP_STRING([--with-system-db-for-build],
        [Use db already on system for build tools (cross-compilation only).]))

AC_ARG_WITH(system-expat-for-build,
    AS_HELP_STRING([--with-system-expat-for-build],
        [Use expat already on system for build tools (cross-compilation only).]))

AC_ARG_WITH(system-icu-for-build,
    AS_HELP_STRING([--with-system-icu-for-build=yes/no/force],
        [Use icu already on system for build tools (cross-compilation only).]))

AC_ARG_WITH(system-libxml-for-build,
    AS_HELP_STRING([--with-system-libxml-for-build],
        [Use libxml/libxslt already on system for build tools (cross-compilation only).]))


dnl ===================================================================
dnl check for required programs (grep, awk, sed, bash)
dnl ===================================================================

pathmunge ()
{
    if test -n "$1"; then
        if test "$build_os" = "cygwin"; then
            PathFormat "$1"
            new_path=`cygpath -u "$formatted_path"`
        else
            new_path="$1"
        fi
        if ! echo "$LO_PATH" | $EGREP -q "(^|:)$1($|:)"; then
            if test "$2" = "after"; then
                LO_PATH="$LO_PATH:$new_path"
            else
                LO_PATH="$new_path:$LO_PATH"
            fi
        fi
        unset new_path
    fi
}

AC_PROG_AWK
AC_PATH_PROG( AWK, $AWK)
if test -z "$AWK"; then
    AC_MSG_ERROR([install awk to run this script])
fi

AC_PATH_PROG(BASH, bash)
if test -z "$BASH"; then
    AC_MSG_ERROR([bash not found in \$PATH])
fi
AC_SUBST(BASH)

AC_MSG_CHECKING([for GNU or BSD tar])
for a in $GNUTAR gtar gnutar tar /usr/sfw/bin/gtar; do
    $a --version 2> /dev/null | egrep "GNU|bsdtar"  2>&1 > /dev/null
    if test $? -eq 0;  then
        GNUTAR=$a
        break
    fi
done
AC_MSG_RESULT($GNUTAR)
if test -z "$GNUTAR"; then
    AC_MSG_ERROR([not found. install GNU or BSD tar.])
fi
AC_SUBST(GNUTAR)

AC_MSG_CHECKING([for tar's option to strip components])
$GNUTAR --help 2> /dev/null | egrep "strip-components" 2>&1 >/dev/null
if test $? -eq 0; then
    STRIP_COMPONENTS="--strip-components"
else
    $GNUTAR --help 2> /dev/null | egrep "strip-path" 2>&1 >/dev/null
	if test $? -eq 0; then
	    STRIP_COMPONENTS="--strip-path"
	else
		STRIP_COMPONENTS="unsupported"
	fi
fi
AC_MSG_RESULT($STRIP_COMPONENTS)
if test x$STRIP_COMPONENTS == xunsupported; then
	AC_MSG_ERROR([you need a tar that is able to strip components.])
fi
AC_SUBST(STRIP_COMPONENTS)

dnl It is useful to have a BUILD_TYPE keyword to distinguish "normal"
dnl desktop OSes from "mobile" ones.

dnl We assume that a non-DESKTOP build type is also a non-NATIVE one.
dnl In other words, that when building for an OS that is not a
dnl "desktop" one but a "mobile" one, we are always cross-compiling.

dnl Note the direction of the implication; there is no assumption that
dnl cross-compiling would imply a non-desktop OS.

if test $_os != iOS -a $_os != Android; then
    BUILD_TYPE="$BUILD_TYPE DESKTOP"
fi

dnl Decide whether to build database connectivity stuff (including
dnl Base) or not. We probably don't want to on non-desktop OSes.

if test -z "$enable_database_connectivity"; then
    # Do enable database connectivity for Android for now as otherwise
    # we presumably will get linking errors... We are not as far in
    # the work for iOS, so we might as well disable it for iOS already.
    if test $_os != iOS; then
        enable_database_connectivity=yes
    fi
fi

DISABLE_DBCONNECTIVITY=''
if test "$enable_database_connectivity" = yes; then
    BUILD_TYPE="$BUILD_TYPE DBCONNECTIVITY"
else
    DISABLE_DBCONNECTIVITY='TRUE'
    SCPDEFS="$SCPDEFS -DDISABLE_DBCONNECTIVITY"
fi
AC_SUBST(DISABLE_DBCONNECTIVITY)

if test -z "$enable_extensions"; then
    # For iOS disable extensions unless specifically overridden with
    # --enable-extensions.
    if test $_os != iOS; then
        enable_extensions=yes
    fi
fi

DISABLE_EXTENSIONS=''
if test "$enable_extensions" = yes; then
    BUILD_TYPE="$BUILD_TYPE EXTENSIONS"
else
    DISABLE_EXTENSIONS='TRUE'
fi
AC_SUBST(DISABLE_EXTENSIONS)

if test -z "$enable_scripting"; then
    # Disable scripting for iOS unless specifically overridden
    # with --enable-scripting.
    if test $_os != iOS; then
        enable_scripting=yes
    fi
fi

DISABLE_SCRIPTING=''
if test "$enable_scripting" = yes; then
    BUILD_TYPE="$BUILD_TYPE SCRIPTING"
else
    DISABLE_SCRIPTING='TRUE'
    SCPDEFS="$SCPDEFS -DDISABLE_SCRIPTING"
fi
AC_SUBST(DISABLE_SCRIPTING)

if test $_os = iOS; then
    # Disable dynamic_loading always for iOS
    enable_dynamic_loading=no
elif test -z "$enable_dynamic_loading"; then
    # Otherwise enable it unless speficically disabled
    enable_dynamic_loading=yes
fi

DISABLE_DYNLOADING=''
if test "$enable_dynamic_loading" = yes; then
    BUILD_TYPE="$BUILD_TYPE DYNLOADING"
else
    DISABLE_DYNLOADING='TRUE'
    SCPDEFS="$SCPDEFS -DDISABLE_DYNLOADING"
fi
AC_SUBST(DISABLE_DYNLOADING)

if test -n "${with_solver_and_workdir_root}"; then
    if ! test -d ${with_solver_and_workdir_root}; then
      AC_MSG_ERROR([directory does not exist: ${with_solver_and_workdir_root}])
    fi
    PathFormat "${with_solver_and_workdir_root}"
    # IsValidFilePath in /sal/osl/w32/file_url.cxx rejects "X:\\" breaking idlc
    if echo ${formatted_path} | $GREP -q '/$'; then
        SOLARVER=${formatted_path}solver
    else
        SOLARVER=${formatted_path}/solver
    fi
else
    SOLARVER=${SRC_ROOT}/solver
fi

dnl ===================================================================
dnl Extra check for Windows. Cygwin builds need gcc to build dmake
dnl although MSVC is used to build other build-time tools and
dnl LibreOffice itself.
dnl ===================================================================
if test "$build_os" = "cygwin"; then
    AC_MSG_CHECKING([for Cygwin gcc/g++])
    if which gcc > /dev/null && which g++ > /dev/null; then
        AC_MSG_RESULT([found])
    else
        AC_MSG_ERROR([Cygwin gcc and g++ are needed, please install them.])
    fi
fi

# remenber SYSBASE value
AC_SUBST(SYSBASE)

dnl ===================================================================
dnl  Checks if ccache is available
dnl ===================================================================
if test "$enable_ccache" = "yes" -o \( "$enable_ccache" = "" -a "$enable_icecream" != "yes" -a "$build_os" != "cygwin" \); then
    case "%$CC%$CXX%" in
    # If $CC and/or $CXX already contain "ccache" (possibly suffixed with some verison number etc),
    # assume that's good then
    *%ccache[[-_' ']]*|*/ccache[[-_' ']]*)
        AC_MSG_NOTICE([ccache seems to be included in a pre-defined CC and/or CXX])
        ;;
    *)
        AC_PATH_PROG([CCACHE],[ccache],[not found])
        if test "$CCACHE" = "not found"; then
            CCACHE=""
        else
            # Need to check for ccache version: otherwise prevents
            # caching of the results (like "-x objective-c++" for Mac)
            if test $_os = Darwin -o $_os = iOS; then
                # Check ccache version
                AC_MSG_CHECKING([whether version of ccache is suitable])
                CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
                CCACHE_NUMVER=`echo $CCACHE_VERSION | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
                if test "$CCACHE_VERSION" = "2.4_OOo" -o "$CCACHE_NUMVER" -ge "030100"; then
                    AC_MSG_RESULT([yes, $CCACHE_VERSION])
                else
                    AC_MSG_RESULT([no, $CCACHE_VERSION])
                    CCACHE=""
                fi
            fi
        fi
        ;;
    esac
else
    CCACHE=""
fi

if test "$CCACHE" != ""; then
    ccache_size_msg=$([ccache -s | tail -n 1 | sed 's/^[^0-9]*//' | sed -e 's/\.[0-9]*//'])
    ccache_size=$(echo "$ccache_size_msg" | grep "G" | sed -e 's/G.*$//')
    if test "$ccache_size" = ""; then
        ccache_size=$(echo "$ccache_size_msg" | grep "M" | sed -e 's/\ M.*$//')
        if test "$ccache_size" = ""; then
            ccache_size=0
        fi
        # we could not determine the size or it was less than 1GB -> disable auto-ccache
        if test $ccache_size -lt 1024; then
            CCACHE=""
            AC_MSG_WARN([ccache's cache size is less than 1GB using it is counter-producive: Disabling auto-ccache detection])
            echo "ccache's cache size is less than 1GB using it is counter-producive: auto-ccache detection disabled" >> warn
        else
            # warn that ccache may be too small for debug build
            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-producive for debug or symbol-enabled build])
            echo "ccache's cache size is less than 5GB using it may be counter-producive for debug or symbol-enabled build" >> warn
        fi
    else
        if test $ccache_size -lt 5; then
            #warn that ccache may be too small for debug build
            AC_MSG_WARN([ccache's cache size is less than 5GB using it may be counter-producive for debug or symbol-enabled build])
            echo "ccache's cache size is less than 5GB using it may be counter-producive for debug or symbol-enabled build" >> warn
        fi
    fi
fi

dnl ===================================================================
dnl  Checks for C compiler,
dnl  The check for the C++ compiler is later on.
dnl ===================================================================
GCC_HOME_SET="true"
AC_MSG_CHECKING([gcc home])
if test -z "$with_gcc_home"; then
    if test "$enable_icecream" = "yes"; then
        if test -d "/usr/lib/icecc/bin"; then
            GCC_HOME="/usr/lib/icecc/"
        else
            GCC_HOME="/opt/icecream/"
        fi
    else
        GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
        GCC_HOME_SET="false"
    fi
else
    GCC_HOME="$with_gcc_home"
fi
AC_MSG_RESULT($GCC_HOME)
AC_SUBST(GCC_HOME)

if test "$GCC_HOME_SET" = "true"; then
    if test -z "$CC"; then
        CC="$GCC_HOME/bin/gcc"
    fi
    if test -z "$CXX"; then
        CXX="$GCC_HOME/bin/g++"
    fi
fi

dnl The following checks for gcc, cc and then cl (if it weren't guarded for win32)
if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    AC_PROG_CC
fi

COMPATH=`dirname "$CC"`
if test "$COMPATH" = "."; then
    AC_PATH_PROGS(COMPATH, $CC)
    dnl double square bracket to get single because of M4 quote...
    COMPATH=`echo $COMPATH | $SED "s@/[[^/:]]*\\\$@@"`;
fi
COMPATH=`echo $COMPATH | $SED "s@/[[Bb]][[Ii]][[Nn]]\\\$@@"`;

dnl ===================================================================
dnl  Test the Solaris compiler version
dnl ===================================================================
if test "$_os" = "SunOS"; then
    if test "$CC" = "cc"; then
        AC_PATH_PROGS(_cc, cc)
        COMPATH=`echo $_cc | $SED -n "s/\/bin\/cc//p"`
        AC_MSG_CHECKING([the SunStudio C/C++ compiler version])
        dnl cc -V outputs to standard error!!!!
        _sunstudio_string=`$CC -V 2>&1 | grep '^cc' | $SED -e 's/.* C //'`
        _sunstudio_version=`echo $_sunstudio_string | $AWK '{ print $1 }'`
        _sunstudio_major=`echo $_sunstudio_version | $AWK -F. '{ print $1 }'`
        if test "$_sunstudio_major" != "5"; then
            AC_MSG_ERROR([found version "$_sunstudio_version", use version 5.5, 5.7, 5.8 or 5.9 of the SunStudio C/C++ compiler])
        else
            _sunstudio_minor=`echo $_sunstudio_version | $AWK -F. '{ if ($2 == 5) print "true"; else if ($2 == 7) print "true"; else if ($2 == 8) print "true"; else if ($2 == 9) print "true"; else print "false" }'`
            if test "$_sunstudio_minor" = "false"; then
                AC_MSG_ERROR([found version "$_sunstudio_version", use version 5.5, 5.7, 5.8 or 5.9 of the SunStudio C/C++ compiler])
            else
                dnl compiler will do
                AC_MSG_RESULT([checked])
            fi
        fi
    fi
fi


dnl ===================================================================
dnl  Test MacOSX sdk and version requirement
dnl ===================================================================
if test "$_os" = "Darwin"; then

    if test "$with_macosx_version_min_required" = ""; then
        with_macosx_version_min_required="10.4"
    fi

    if test "$with_macosx_version_max_allowed" = ""; then
        with_macosx_version_max_allowed="$with_macosx_version_min_required"
    fi

    if test "$with_macosx_sdk" = ""; then
        with_macosx_sdk="$with_macosx_version_max_allowed"
    fi

    case "$with_macosx_sdk" in

    10.4)
        MACOSX_SDK_PATH="/Developer/SDKs/MacOSX10.4u.sdk"
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH="/Developer-old/SDKs/MacOSX10.4u.sdk"
        fi
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH="/Xcode3/SDKs/MacOSX10.4u.sdk"
        fi
        macosx_sdk_value="1040"
        ;;
    10.5)
        MACOSX_SDK_PATH="/Developer/SDKs/MacOSX10.5.sdk"
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH="/Developer-old/SDKs/MacOSX10.5.sdk"
        fi
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH="/Xcode3/SDKs/MacOSX10.5.sdk"
        fi
        macosx_sdk_value="1050"
        AC_MSG_WARN([Building with a SDK > 10.4 is experimental])
        echo "Building with a SDK > 10.4 is experimental" >> warn
        ;;
    10.6)
        MACOSX_SDK_PATH="/Developer/SDKs/MacOSX10.6.sdk"
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
        fi
        macosx_sdk_value="1060"
        AC_MSG_WARN([Building with a SDK > 10.4 is experimental])
        echo "Building with a SDK > 10.4 is experimental" >> warn
        ;;
    10.7)
        MACOSX_SDK_PATH="/Developer/SDKs/MacOSX10.7.sdk"
        if test ! -d "$MACOSX_SDK_PATH"; then
            MACOSX_SDK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
        fi
        macosx_sdk_value="1070"
        AC_MSG_WARN([Building with SDK 10.7 is known to fail in vcl])
        echo "Building with SDK 10.7 is known to fail in vcl" >> warn
        ;;
    *)
        AC_MSG_ERROR([$with_macosx_sdk is not a supported SDK value, supported value are 10.4, 10.5, 10.6 and 10.7])
        ;;
    esac
    AC_MSG_CHECKING([the presence of the SDK $with_macosx_sdk])
    if test -d "$MACOSX_SDK_PATH"; then
        AC_MSG_RESULT([$MACOSX_SDK_PATH ok])
    else
        AC_MSG_ERROR([$MACOSX_SDK_PATH not found])
    fi
    FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks";
    MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"

    case "$with_macosx_version_min_required" in

    10.4)
        MAC_OS_X_VERSION_MIN_REQUIRED="1040"
        ;;
    10.5)
        MAC_OS_X_VERSION_MIN_REQUIRED="1050"
        AC_MSG_WARN([Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build])
        echo "Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build" >>warn
        if test -z "$save_CC"; then
            CC="gcc-4.2 -m32"
            CXX="g++-4.2 -m32"
        fi
        ;;
    10.6)
        MAC_OS_X_VERSION_MIN_REQUIRED="1060"
        AC_MSG_WARN([Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build])
        echo "Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build" >>warn
        if test -z "$save_CC"; then
            CC="gcc-4.2 -m32"
            CXX="g++-4.2 -m32"
        fi
        ;;
    10.7)
        MAC_OS_X_VERSION_MIN_REQUIRED="1070"
        AC_MSG_WARN([Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build])
        echo "Building with a minimum version requirement > 10.4 break 10.4 compatibility. do not use for deliverable build" >>warn
        if test -z "$save_CC"; then
            CC="gcc-4.2 -m32"
            CXX="g++-4.2 -m32"
        fi
        ;;
    *)
        AC_MSG_ERROR([with-macosx-version-min-required $with_macosx_version_min_required is not a supported value, supported value are 10.4, 10.5, 10.6 and 10.7])
        ;;
    esac

    case "$with_macosx_version_max_allowed" in

    10.4)
        MAC_OS_X_VERSION_MAX_ALLOWED="1040"
        ;;
    10.5)
        MAC_OS_X_VERSION_MAX_ALLOWED="1050"
        ;;
    10.6)
        MAC_OS_X_VERSION_MAX_ALLOWED="1060"
        ;;
    10.7)
        MAC_OS_X_VERSION_MAX_ALLOWED="1070"
        ;;
    *)
        AC_MSG_ERROR([with-macosx-version-max-allowed $with_macosx_version_max_allowed is not a supported value, supported value are 10.4, 10.5, 10.6 and 10.7])
        ;;
    esac

    AC_MSG_CHECKING([that macosx-version-min-required is coherent with macosx-version-max-allowed])
    if test $MAC_OS_X_VERSION_MIN_REQUIRED -gt $MAC_OS_X_VERSION_MAX_ALLOWED; then
        AC_MSG_ERROR([the version minimumn required must be inferior or equal to the version maximum allowed])
    else
        AC_MSG_RESULT([ok])
    fi

    AC_MSG_CHECKING([that macosx-version-max-allowed is coherent macos-with-sdk])
    if test $MAC_OS_X_VERSION_MAX_ALLOWED -gt $macosx_sdk_value; then
        AC_MSG_ERROR([the version maximum allowed cannot be greater thatn the sdk level])
    else
        AC_MSG_RESULT([ok])
    fi
    AC_MSG_NOTICE([MAC_OS_X_VERSION_MIN_REQUIRED=$MAC_OS_X_VERSION_MIN_REQUIRED])
    AC_MSG_NOTICE([MAC_OS_X_VERSION_MAX_ALLOWED=$MAC_OS_X_VERSION_MAX_ALLOWED])
fi
AC_SUBST(FRAMEWORKSHOME)
AC_SUBST(MACOSX_SDK_PATH)
AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
AC_SUBST(MAC_OS_X_VERSION_MIN_REQUIRED)
AC_SUBST(MAC_OS_X_VERSION_MAX_ALLOWED)

dnl ===================================================================
dnl Windows specific tests and stuff
dnl ===================================================================
if test "$_os" = "WINNT"; then

    dnl Include twain scanners
    BUILD_TYPE="$BUILD_TYPE TWAIN"

    dnl Set the CL_X64 variable if we are building a 64-bit LibreOffice.
    AC_MSG_CHECKING([whether to build a 64-bit LibreOffice])
    if test "$enable_cl_x64" = "" -o "$enable_cl_x64" = "no"; then
        CL_X64=""
        AC_MSG_RESULT([no])
    else
        CL_X64="TRUE"
        AC_MSG_RESULT([yes])
    fi
    AC_SUBST(CL_X64)

    AC_MSG_CHECKING([whether to use DirectX])
    if test "$enable_directx" = "yes" -o "$enable_directx" = ""; then
        ENABLE_DIRECTX="TRUE"
        AC_MSG_RESULT([yes])
    else
        ENABLE_DIRECTX=""
        AC_MSG_RESULT([no])
    fi
    AC_SUBST(ENABLE_DIRECTX)

    AC_MSG_CHECKING([whether to use ActiveX])
    if test "$enable_activex" = "yes" -o "$enable_activex" = "TRUE" -o "$enable_activex" = ""; then
        DISABLE_ACTIVEX=""
        AC_MSG_RESULT([yes])
    else
        DISABLE_ACTIVEX="TRUE"
        AC_MSG_RESULT([no])
    fi
    AC_SUBST(DISABLE_ACTIVEX)

    AC_MSG_CHECKING([whether to use ATL])
    if test "$enable_atl" = "yes" -o "$enable_atl" = "TRUE"; then
        DISABLE_ATL=""
        AC_MSG_RESULT([yes])
    elif test "$enable_atl" = ""; then
        if test "$WITH_MINGW" = "yes"; then
            DISABLE_ATL="TRUE"
            AC_MSG_RESULT([no])
        else
            DISABLE_ATL=""
            AC_MSG_RESULT([yes])
        fi
    else
        DISABLE_ATL="TRUE"
        AC_MSG_RESULT([no])
    fi
    AC_SUBST(DISABLE_ATL)
fi

dnl ===================================================================
dnl  Test the gcc version
dnl ===================================================================
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING([the GCC version])
    _gcc_version=`$CC -dumpversion`
    _gcc_major=`echo $_gcc_version | $AWK -F. '{ print \$1 }'`
    GCCVER=`echo $_gcc_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`

    if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.4" -a "$GCCVER" -ge "040100"; then
        if test -z "$save_CC" -a -x "$GCC_HOME/bin/gcc-4.0"; then
            export CC="$GCC_HOME/bin/gcc-4.0"
            #  export CC to have it available in set_soenv -> config.guess
            GCCVER2=`$CC -dumpversion | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
            if test "$GCCVER2" -ge "040000" -a "$GCCVER2" -lt "040100"; then
                GCCVER=$GCCVER2
            fi
        fi
        if test "$GCCVER" -ge "040100"; then
            AC_MSG_ERROR([You need to use the gcc-4.0 compiler (gcc $_gcc_version won't work with the MacOSX10.4u.sdk) - set CC accordingly])
        else
            AC_MSG_RESULT([implicitly using CC=$CC])
        fi
    else
        AC_MSG_RESULT([gcc $_gcc_version])
    fi
fi

dnl ===================================================================
dnl  Is GCC actually Clang?
dnl ===================================================================

COM_GCC_IS_CLANG=
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING([whether GCC is actually Clang])
    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
        #ifndef __clang__
        you lose
        #endif
        int foo=42;
        ]])],
        [AC_MSG_RESULT([yes])
         COM_GCC_IS_CLANG=TRUE],
        [AC_MSG_RESULT([no])])

    if test "$COM_GCC_IS_CLANG" = TRUE; then
        AC_MSG_CHECKING([the Clang version])
        clang_version=`echo __clang_major__.__clang_minor__.__clang_patchlevel__ | $CC -E -P -`
        CLANG_FULL_VERSION=`echo __clang_version__ | $CC -E -P -`
        CLANGVER=`echo $clang_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
        AC_MSG_RESULT([Clang $CLANG_FULL_VERSION, $CLANGVER])
    fi
fi
AC_SUBST(COM_GCC_IS_CLANG)

# ===================================================================
# check various GCC options that Clang does not support now but maybe
# will somewhen in the future, check them even for GCC, so that the
# flags are set
# ===================================================================

HAVE_GCC_GGDB2=
HAVE_GCC_FINLINE_LIMIT=
HAVE_GCC_FNO_INLINE=
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING([whether $CC supports -ggdb2])
    if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
        # Option just ignored and silly warning that isn't a real
        # warning printed
        :
    else
        save_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS -Werror -ggdb2"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_GGDB2=TRUE ],[])
        CFLAGS=$save_CFLAGS
    fi
    if test "$HAVE_GCC_GGDB2" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CC supports -finline-limit=0])
    if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
        # As above
        :
    else
        save_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS -Werror -finline-limit=0"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FINLINE_LIMIT=TRUE ],[])
        CFLAGS=$save_CFLAGS
    fi
    if test "$HAVE_GCC_FINLINE_LIMIT" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CC supports -fno-inline])
    if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
        # Ditto
        :
    else
        save_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS -Werror -fno-inline"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_INLINE=TRUE ],[])
        CFLAGS=$save_CFLAGS
    fi
    if test "$HAVE_GCC_FNO_INLINE" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi
fi
AC_SUBST(HAVE_GCC_GGDB2)
AC_SUBST(HAVE_GCC_FINLINE_LIMIT)
AC_SUBST(HAVE_GCC_FNO_INLINE)

HAVE_LD_BSYMBOLIC_FUNCTIONS=
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING( for -Bsymbolic-functions linker support )
    bsymbolic_functions_ldflags_save=$LDFLAGS
    LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <stdio.h>
        ],[
printf ("hello world\n");
        ])], HAVE_LD_BSYMBOLIC_FUNCTIONS=TRUE, [])
    if test "$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "TRUE"; then
        AC_MSG_RESULT( found )
    else
        AC_MSG_RESULT( not found )
    fi
    LDFLAGS=$bsymbolic_functions_ldflags_save
fi
AC_SUBST(HAVE_LD_BSYMBOLIC_FUNCTIONS)

dnl Set the ENABLE_DBGUTIL variable
dnl ===================================================================
AC_MSG_CHECKING([whether to build with additional debug utilities])
if test -n "$enable_dbgutil" -a "$enable_dbgutil" != "no"; then
    PROEXT=""
    PRODUCT=""

    AC_MSG_RESULT([yes])
    # cppunit and graphite expose STL in public headers
    if test "$with_system_cppunit" = "yes"; then
        AC_MSG_ERROR([--with-system-cppunit conflicts with DBG_UTIL build])
    else
        with_system_cppunit=no
    fi
    if test "$with_system_graphite" = "yes"; then
        AC_MSG_ERROR([--with-system-graphite conflicts with DBG_UTIL build])
    else
        with_system_graphite=no
    fi
    if test "$with_system_mysql_cppconn" = "yes"; then
        AC_MSG_ERROR([--with-system-mysql-cppconn conflicts with DBG_UTIL build])
    else
        with_system_mysql_cppconn=no
    fi
    if test $_os = WINNT -a \
            \( "$enable_mozilla" != no -o \
               "$enable_build_mozilla" != no \); then
        # We can't build against the Mozilla stuff if using _DEBUG, will get linking errors
        # See connectivity/drivers/mozab
        AC_MSG_WARN([Also disabling Mozilla stuff then])
        enable_mozilla=no
        enable_build_mozilla=no
    fi
else
    PRODUCT="full"
    PROEXT=".pro"
    AC_MSG_RESULT([no, full product build])
fi
AC_SUBST(PRODUCT)
AC_SUBST(PROEXT)

dnl ===================================================================
dnl  Check which Microsoft C/C++ or MinGW compiler is used for WINNT
dnl ===================================================================
SHOWINCLUDES_PREFIX=
if test "$_os" = "WINNT"; then
    if test "$WITH_MINGW" != "yes"; then
        AC_MSG_CHECKING([for a friendly Microsoft C/C++ compiler installation path])
        if test -z "$with_cl_home"; then
            vctest=`./oowintool --msvc-productdir`;
            if test "$CL_X64" = ""; then
                if test -x "$vctest/bin/cl.exe"; then
                    with_cl_home=$vctest;
                fi
            else
                if test -x "$vctest/bin/amd64/cl.exe"; then
                    with_cl_home=$vctest;
                fi
            fi
        else
            with_cl_home=`cygpath -u "$with_cl_home"`
        fi
        with_cl_home=`cygpath -d "$with_cl_home"`
        with_cl_home=`cygpath -u "$with_cl_home"`
        AC_MSG_RESULT([$with_cl_home])

        dnl ===========================================================
        dnl  Check for mspdb80.dll/mspdb100.dll
        dnl ===========================================================
        dnl MSVS 2008/10 Compiler
        if test -n "$with_mspdb_path";then
            with_mspdb_path=`cygpath -u "$with_mspdb_path"`
        fi
        if test -e "$with_mspdb_path/mspdb80.dll" -o -e "$with_mspdb_path/mspdb100.dll"; then
            MSPDB_PATH="$with_mspdb_path"
        fi
        dnl MSVS 2008 case
        if test -z "$MSPDB_PATH" -a -e "$with_cl_home/../Common7/IDE/mspdb80.dll"; then
            MSPDB_PATH="$with_cl_home/../Common7/IDE"
        fi
        dnl Windows SDK 6.0 case
        if test -z "$MSPDB_PATH" -a -e "$with_cl_home/bin/mspdb80.dll"; then
            MSPDB_PATH="$with_cl_home/bin"
        fi
        dnl MSVS 2010 case
        if test -z "$MSPDB_PATH" -a -e "$with_cl_home/../Common7/IDE/mspdb100.dll"; then
            MSPDB_PATH="$with_cl_home/../Common7/IDE"
        fi

        if test -z "$MSPDB_PATH";then
            dnl AC_PATH_PROG only checks if MSPDB_PATH is still empty
            AC_PATH_PROG(MSPDB_PATH, mspdb80.dll)
            AC_PATH_PROG(MSPDB_PATH, mspdb100.dll)
            MSPDB_PATH=`dirname "$MSPDB_PATH"`
        fi

        if test -z "$MSPDB_PATH"; then
            AC_MSG_ERROR([You need a mspdb80.dllor mspdb100.dll, make sure it is in the path or use --with-mspdb-path])
        fi
        MSPDB_PATH=`cygpath -d "$MSPDB_PATH"`
        MSPDB_PATH=`cygpath -u "$MSPDB_PATH"`
        dnl The path needs to be added before cl is called
        PATH="$MSPDB_PATH:$PATH"

        AC_MSG_CHECKING([the Microsoft C/C++ Compiler])
        if test -z "$CC"; then
            if test "$CL_X64" = ""; then
                if test -x "$with_cl_home/bin/cl.exe"; then
                    CC="$with_cl_home/bin/cl.exe"
                fi
            else
                if test -x "$with_cl_home/bin/amd64/cl.exe"; then
                    CC="$with_cl_home/bin/amd64/cl.exe"
                fi
            fi
            if test -z "$CC"; then
                AC_PATH_PROG(CC, cl.exe)
            fi
            # This gives us a posix path with 8.3 filename restrictions
            CC=`cygpath -d "$CC"`
            CC=`cygpath -u "$CC"`
        fi

        if test -n "$CC"; then
            # Remove /cl.exe from CC case insensitive
            AC_MSG_RESULT([found ($CC)])
            if test "$CL_X64" = ""; then
                COMPATH=`echo $CC | $SED -e 's@\/[[Bb]][[Ii]][[Nn]]\/[[cC]][[lL]]\.[[eE]][[xX]][[eE]].*@@' -e 's@^.* @@'`
            else
                if test -n "$with_cl_home"; then
                    COMPATH=`echo $with_cl_home`
                fi
            fi
            export INCLUDE=`cygpath -d "$COMPATH/Include"`
            dnl  Check which Microsoft C/C++ compiler is found
            AC_MSG_CHECKING([the Version of Microsoft C/C++ Compiler])
            # The following finds Microsoft, matches nn.nn.nnnn then pulls numbers out.
            CCNUMVER=`$CC 2>&1 | $AWK "/Microsoft/ && /..\\...\\...../ {
                            x = match( \\\$0, /..\\...\\...../ )
                            CCversion = substr( \\\$0, RSTART, RLENGTH)
                            tokencount = split (CCversion,vertoken,\".\")
                            for ( i = 1 ; i <= tokencount ; i++ ) {
                                printf (\"%04d\",vertoken[[i]] )
                            }
                            }"`
            if test "$CCNUMVER" -ge "001600000000"; then
                COMEX=13
                MSVSVER=2010
            elif test "$CCNUMVER" -ge "001500000000"; then
                COMEX=12
                MSVSVER=2008
            else
                AC_MSG_ERROR([Compiler too old. Use Microsoft Visual Studio 2008 or 2010.])
            fi
            PathFormat "$COMPATH"
            COMPATH="$formatted_path"

            AC_MSG_RESULT([found compiler version $CCNUMVER (MSVS $MSVSVER).])
        else
            AC_MSG_ERROR([Microsoft C/C++ Compiler not found. Use --with-cl-home or set path to cl.exe.])
        fi

        dnl We need to guess the prefix of the -showIncludes output, it can be
        dnl localized
        AC_MSG_CHECKING([the dependency generation prefix (cl.exe -showIncludes)])
        echo "#include <stdlib.h>" > conftest.c
        SHOWINCLUDES_PREFIX=`$CC -c -showIncludes conftest.c 2>/dev/null | \
            grep 'stdlib\.h' | head -n1 | sed 's/ [[[:alpha:]]]:.*//'`
        rm -f conftest.c conftest.obj
        if test -z "$SHOWINCLUDES_PREFIX"; then
            AC_MSG_ERROR([cannot determine the -showIncludes prefix])
        else
            AC_MSG_RESULT(["$SHOWINCLUDES_PREFIX"])
        fi

        # Check for 64-bit (cross-)compiler to use to build the 64-bit
        # version of the Explorer extension (and maybe other small
        # bits, too) needed when installing a 32-bit LibreOffice on a
        # 64-bit OS. The 64-bit Explorer extension is a feature that
        # has been present since long in OOo. Don't confuse it with
        # building LibreOffice itself as 64-bit code, which is
        # unfished work and highly experimental.

        BUILD_X64=
        CXX_X64_BINARY=
        LINK_X64_BINARY=
        LIBMGR_X64_BINARY=

        AC_MSG_CHECKING([for a x64 compiler and libraries for 64bit ActiveX component])
        if test "$CL_X64" = "" -a -f "$with_cl_home/atlmfc/lib/amd64/atls.lib"; then
            # Prefer native x64 compiler to cross-compiler, in case we are running
            # the build on a 64-bit OS.
            if "$with_cl_home/bin/amd64/cl.exe" -? </dev/null >/dev/null 2>&1; then
                BUILD_X64=TRUE
                CXX_X64_BINARY="$with_cl_home/bin/amd64/cl.exe"
                LINK_X64_BINARY="$with_cl_home/bin/amd64/link.exe"
                LIBMGR_X64_BINARY="$with_cl_home/bin/amd64/lib.exe"
            elif "$with_cl_home/bin/x86_amd64/cl.exe" -? </dev/null >/dev/null 2>&1; then
                BUILD_X64=TRUE
                CXX_X64_BINARY="$with_cl_home/bin/x86_amd64/cl.exe"
                LINK_X64_BINARY="$with_cl_home/bin/x86_amd64/link.exe"
                LIBMGR_X64_BINARY="$with_cl_home/bin/x86_amd64/lib.exe"
            fi
        fi
        if test "$BUILD_X64" = TRUE; then
            AC_MSG_RESULT([found])
        else
            AC_MSG_RESULT([not found])
            AC_MSG_WARN([Installation set will not contain the 64-bit Explorer extension])
        fi
        AC_SUBST(BUILD_X64)

        # These are passed to the environment through set_soenv.in as usual, and then
        # used in set_wntx64.mk
        AC_SUBST(CXX_X64_BINARY)
        AC_SUBST(LINK_X64_BINARY)
        AC_SUBST(LIBMGR_X64_BINARY)

    else
        AC_MSG_CHECKING([the compiler is MinGW])
        MACHINE_PREFIX=`$CC -dumpmachine`
        if echo $MACHINE_PREFIX | $GREP -q mingw32; then
            COMPATH=`echo "$COMPATH" | sed -e 's,/bin$,,'`
            AC_MSG_RESULT([yes])
        else
            AC_MSG_ERROR([Compiler is not MinGW.])
        fi
    fi
fi
AC_SUBST(COMEX)
PathFormat "$MSPDB_PATH"
MSPDB_PATH="$formatted_path"
AC_SUBST(SHOWINCLUDES_PREFIX)

#
# prefix C with ccache if needed
#
if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    if test "$CCACHE" != ""; then
        AC_MSG_CHECKING([whether $CC is already ccached])

        AC_LANG_PUSH([C])
        save_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS --ccache-skip -O2"
        dnl an empty program will do, we're checking the compiler flags
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
                          [use_ccache=yes], [use_ccache=no])
        if test $use_ccache = yes; then
            AC_MSG_RESULT([yes])
        else
            CC="$CCACHE $CC"
            AC_MSG_RESULT([no])
        fi
        CFLAGS=$save_CFLAGS
        AC_LANG_POP([C])
    fi

fi

#
# determine CPU, CPUNAME, GUI, GUIBASE, ...
#
LIB64="lib"
SOLARINC=

case "$host_os" in

aix*)
    COM=GCC
    CPU=P
    CPUNAME=POWERPC
    GUI=UNX
    GUIBASE=unx
    OS=AIX
    RTL_OS=AIX
    RTL_ARCH=PowerPC
    OUTPATH=unxaigppc
    P_SEP=:
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

cygwin*)
    COM=MSC
    GUI=WNT
    GUIBASE=WIN
    OS=WNT
    RTL_OS=Windows
    P_SEP=";"

    case "$host_cpu" in
    i*86|x86_64)
        if test "$CL_X64" != ""; then
            CPU=X
            CPUNAME=X86_64
            RTL_ARCH=X86_64
            LIB64="lib/x64"
            OUTPATH=wntmscx$COMEX
        else
            CPU=I
            CPUNAME=INTEL
            RTL_ARCH=x86
            OUTPATH=wntmsci$COMEX
        fi
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SCPDEFS="$SCPDEFS -D_MSC_VER"
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    ;;

darwin*)
    COM=GCC
    GUI=UNX
    # Not sure if "Aqua" is the right term to use?
    GUIBASE="aqua"
    OS=MACOSX
    RTL_OS=MacOSX
    P_SEP=:

    case "$host_cpu" in
    arm*)
        CPU=R
        CPUNAME=ARM
        RTL_ARCH=ARM_EABI
        GUIBASE=cocoatouch
        OUTPATH=unxiosr
        OS=IOS;
        ;;
    powerpc*)
        CPU=P
        CPUNAME=POWERPC
        RTL_ARCH=PowerPC
        OUTPATH=unxmacxp
        ;;
    i*86|x86_64)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        OUTPATH=unxmacxi
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    ;;

dragonfly*)
    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=DRAGONFLY
    RTL_OS=DragonFly
    OUTPATH=unxdfly
    P_SEP=:

    case "$host_cpu" in
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

freebsd*)
    COM=GCC
    GUI=UNX
    GUIBASE=unx
    RTL_OS=FreeBSD
    OS=FREEBSD
    OUTPATH=unxfbsd
    P_SEP=:

    case "$host_cpu" in
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        OUTPATH=unxfbsdi
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

kfreebsd*)
    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=LINUX
    RTL_OS=kFreeBSD
    case "$host_cpu" in

    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        OUTPATH=unxkfgi6
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        LIB64="lib64"
        OUTPATH=unxkfgx6
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

linux-gnu*)
    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=LINUX
    RTL_OS=Linux
    P_SEP=:

    case "$host_cpu" in

    alpha)
        CPU=L
        CPUNAME=AXP
        RTL_ARCH=ALPHA
        OUTPATH=unxlngaxp
        ;;
    arm*)
        CPU=R
        CPUNAME=ARM
        EPM_FLAGS="-a arm"
        OUTPATH=unxlngr
        RTL_ARCH=ARM_EABI
        case "$host_cpu" in
        arm*-linux)
            RTL_ARCH=ARM_OABI
            ;;
        esac
        ;;
    hppa)
        CPU=H
        CPUNAME=HPPA
        RTL_ARCH=HPPA
        EPM_FLAGS="-a hppa"
        OUTPATH=unxlnghppa
        ;;
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        OUTPATH=unxlngi6
        ;;
    ia64)
        CPU=A
        CPUNAME=IA64
        RTL_ARCH=IA64
        OUTPATH=unxlnga
        ;;
    mips)
        CPU=M
        CPUNAME=GODSON
        RTL_ARCH=MIPS_EB
        EPM_FLAGS="-a mips"
        OUTPATH=unxlngmips
        ;;
    mips64)
        CPU=M
        CPUNAME=GODSON
        RTL_ARCH=MIPS_EB
        EPM_FLAGS="-a mips64"
        OUTPATH=unxlngmips
        ;;
    mips64el)
        CPU=M
        CPUNAME=GODSON
        RTL_ARCH=MIPS_EL
        EPM_FLAGS="-a mips64el"
        OUTPATH=unxlngmips
        ;;
    mipsel)
        CPU=M
        CPUNAME=GODSON
        RTL_ARCH=MIPS_EL
        EPM_FLAGS="-a mipsel"
        OUTPATH=unxlngmips
        ;;
    m68k)
        CPU=6
        CPUNAME=M68K
        RTL_ARCH=M68K
        OUTPATH=unxlngm68k
        ;;
    powerpc)
        CPU=P
        CPUNAME=POWERPC
        RTL_ARCH=PowerPC
        OUTPATH=unxlngppc
        ;;
    powerpc64)
        CPU=P
        CPUNAME=POWERPC64
        RTL_ARCH=PowerPC_64
        LIB64="lib64"
        OUTPATH=unxlngppc64
        ;;
    sparc)
        CPU=S
        CPUNAME=SPARC
        RTL_ARCH=SPARC
        OUTPATH=unxlngs
        ;;
    s390)
        CPU=3
        CPUNAME=S390
        RTL_ARCH=S390
        OUTPATH=unxlngs390
        ;;
    s390x)
        CPU=3
        CPUNAME=S390x
        RTL_ARCH=S390x
        LIB64="lib64"
        OUTPATH=unxlngs390x
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        LIB64="lib64"
        OUTPATH=unxlngx6
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

linux-androideabi*)
    COM=GCC
    GUI=UNX
    GUIBASE=android
    OS=ANDROID
    RTL_OS=Android
    P_SEP=:

    case "$host_cpu" in

    arm|armel)
        CPU=R
        CPUNAME=ARM
        RTL_ARCH=ARM_EABI
        OUTPATH=unxandr
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARINC="$SOLARINC -I$SRC_ROOT/solenv/inc/$OUTPATH"
    SOLARLIB="-L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    ;;

mingw*)
    COM=GCC
    GUI=WNT
    GUIBASE=WIN
    OS=WNT
    RTL_OS=Windows
    P_SEP=:

    case "$host_cpu" in
    i*86|x86_64)
        if test "$CL_X64" != ""; then
            CPU=X
            CPUNAME=X86_64
            RTL_ARCH=X86_84
            OUTPATH=wntgccx$COMEX
        else
            CPU=I
            CPUNAME=INTEL
            RTL_ARCH=x86
            OUTPATH=wntgcci$COMEX
        fi
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARINC="$SOLARINC -I$SRC_ROOT/solenv/inc/win32 -I$SRC_ROOT/solenv/inc/$OUTPATH"
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    ;;

*netbsd*)

    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=NETBSD
    RTL_OS=NetBSD
    OUTPATH=unxnbsd
    P_SEP=:

    case "$host_cpu" in
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        ;;
    powerpc)
        CPU=P
        CPUNAME=POWERPC
        RTL_ARCH=PowerPC
        ;;
    sparc)
        CPU=S
        CPUNAME=SPARC
        RTL_ARCH=SPARC
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    ;;

openbsd*)
    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=OPENBSD
    RTL_OS=OpenBSD
    OUTPATH=unxobsd
    P_SEP=:

    case "$host_cpu" in
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        ;;
    x86_64)
        CPU=X
        CPUNAME=X86_64
        RTL_ARCH=X86_64
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARINC="$SOLARINC -I/usr/local/include"
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L/usr/local/lib"

    ;;

solaris*)

    COM=GCC
    GUI=UNX
    GUIBASE=unx
    OS=SOLARIS
    RTL_OS=Solaris
    P_SEP=:

    case "$host_cpu" in
    i*86)
        CPU=I
        CPUNAME=INTEL
        RTL_ARCH=x86
        OUTPATH=unxsogi
        ;;
    sparc)
        CPU=S
        CPUNAME=SPARC
        RTL_ARCH=SPARC
        OUTPATH=unxsogs
        ;;
    *)
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
        ;;
    esac
    SOLARINC="$SOLARINC -I/usr/local/include"
    SOLARLIB="-L../lib -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L${SOLARVER}/${OUTPATH}${PROEXT}/lib"
    SOLARLIB="$SOLARLIB -L$SRC_ROOT/solenv/$OUTPATH/lib"
    SOLARLIB="$SOLARLIB -L$COMPATH/lib"
    SOLARLIB="$SOLARLIB -L/usr/local/bin -L/usr/dt/lib -L/usr/openwin/lib"
    ;;

*)
    AC_MSG_ERROR([$host_os operating system is not suitable to build LibreOffice for!])
    ;;
esac

if test "$enable_headless" = "yes"; then
    GUIBASE=headless
fi

INPATH="${OUTPATH}${PROEXT}"
if test -n "${with_solver_and_workdir_root}"; then
    PathFormat "${with_solver_and_workdir_root}"
    # IsValidFilePath in /sal/osl/w32/file_url.cxx rejects "X:\\" breaking idlc
    if echo ${formatted_path} | $GREP -q '/$'; then
        WORKDIR=${formatted_path}workdir/${INPATH}
    else
        WORKDIR=${formatted_path}/workdir/${INPATH}
    fi
else
    WORKDIR=${SRC_ROOT}/workdir/${INPATH}
fi
OUTDIR="${SOLARVER}/${INPATH}"
SOLARINC="-I. -I${SOLARVER}/$INPATH/inc/external -I${SOLARVER}/$INPATH/inc -I$SRC_ROOT/solenv/inc $SOLARINC"
AC_SUBST(COM)
AC_SUBST(CPU)
AC_SUBST(CPUNAME)
AC_SUBST(RTL_OS)
AC_SUBST(RTL_ARCH)
AC_SUBST(EPM_FLAGS)
AC_SUBST(GUI)
AC_SUBST(GUIBASE)
AC_SUBST(INPATH)
AC_SUBST(OS)
AC_SUBST(OUTDIR)
AC_SUBST(OUTPATH)
AC_SUBST(P_SEP)
AC_SUBST(SOLARVER)
AC_SUBST(WORKDIR)

dnl ===================================================================
dnl Set up a different compiler to produce tools to run on the build
dnl machine when doing cross-compilation
dnl ===================================================================

m4_pattern_allow([PKG_CONFIG_FOR_BUILD])
if test "$cross_compiling" = "yes"; then
    AC_MSG_CHECKING([for BUILD platform configuration])
    echo
    rm -rf CONF-FOR-BUILD config_build.mk
    mkdir CONF-FOR-BUILD
    tar cf - \
        bin/repo-list.in \
        config.guess \
        config_host.mk.in \
        configure \
        ooo.lst.in \
        oowintool \
        post_download.in \
        solenv/inc/langlist.mk \
        solenv/inc/postset.mk \
    | (cd CONF-FOR-BUILD && tar xf -)
    (
    unset COM GUI GUIBASE OS CPU CPUNAME
    unset CC CXX SYSBASE CFLAGS
    unset PYTHON_CFLAGS PYTHON_LIBS
    unset AR NM OBJDUMP PKG_CONFIG RANLIB STRIP
    unset CPPUNIT_CFLAGS CPPUNIT_LIBS
    unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
    test -n "$CC_FOR_BUILD" && export CC="$CC_FOR_BUILD"
    test -n "$CXX_FOR_BUILD" && export CXX="$CXX_FOR_BUILD"
    test -n "$PKG_CONFIG_FOR_BUILD" && export PKG_CONFIG="$PKG_CONFIG_FOR_BUILD"
    cd CONF-FOR-BUILD
    sub_conf_opts=""
    test -n "$enable_ccache" && sub_conf_opts="$sub_conf_opts --enable-ccache=$enable_ccache"
    test -n "$with_ant_home" && sub_conf_opts="$sub_conf_opts --with-ant-home=$with_ant_home"
    test $with_java = no && sub_conf_opts="$sub_conf_opts --without-java"
    test $with_junit = no && sub_conf_opts="$sub_conf_opts --without-junit"
    test -n "$TARFILE_LOCATION" && sub_conf_opts="$sub_conf_opts --with-external-tar=$TARFILE_LOCATION"
    test -n "${with_solver_and_workdir_root}" && sub_conf_opts="$sub_conf_opts --with-solver-and-workdir-root=${with_solver_and_workdir_root}"
    test -n "$with_system_boost_for_build" && sub_conf_opts="$sub_conf_opts --with-system-boost"
    test -n "$with_system_cppunit_for_build" && sub_conf_opts="$sub_conf_opts --with-system-cppunit"
    test -n "$with_system_db_for_build" && sub_conf_opts="$sub_conf_opts --with-system-db"
    test -n "$with_system_expat_for_build" && sub_conf_opts="$sub_conf_opts --with-system-expat"
    test "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" && sub_conf_opts="$sub_conf_opts --with-system-icu"
    test -n "$with_system_libxml_for_build" && sub_conf_opts="$sub_conf_opts --with-system-libxml"
    sub_conf_opts="$sub_conf_opts $with_build_platform_configure_options"
    ./configure \
        --disable-mozilla \
        --disable-build-mozilla \
        --disable-zenity \
        --with-num-cpus="$with_num_cpus" \
        --with-max-jobs="$with_max_jobs" \
        --without-doxygen \
        $sub_conf_opts \
        2>&1 | sed -e 's/^/    /'
    test -f ./config_host.mk 2>/dev/null || exit
    cp config_host.mk ../config_build.mk
    cp config.log ../config.Build.log
    sed -e 's,=\(.*\),="\1",' < config_host.mk > config_host.sh
    . ./config_host.sh
    for V in COM GUI GUIBASE OS CPU CPUNAME CC CXX GXX_INCLUDE_PATH MACOSX_DEPLOYMENT_TARGET INPATH OUTPATH \
             SYSTEM_LIBXSLT; do
        VV='$'$V
        VV=`eval "echo $VV"`
        if test -n "$VV"; then
            line=${V}_FOR_BUILD='${'${V}_FOR_BUILD:-$VV'}'
            echo "$line" >>build-config
        fi
    done

    for V in OUTDIR LO_PATH SOLARINC SOLARLIB WORKDIR; do
        VV='$'$V
        VV=`eval "echo $VV"`
        VV=`echo $VV | sed -e 's,/CONF-FOR-BUILD,,g'`
        if test -n "$VV"; then
            line="${V}_FOR_BUILD='$VV'"
            echo "$line" >>build-config
        fi
    done
    )
    test -f CONF-FOR-BUILD/build-config || AC_MSG_ERROR([Running configure script for BUILD system failed, see CONF-FOR-BUILD/config.log])
    test -f config_build.mk || AC_MSG_ERROR([A file called config_build.mk was supposed to have been copied here, but it isn't found])
    perl -pi -e 's,/CONF-FOR-BUILD,,g' config_build.mk
    eval `cat CONF-FOR-BUILD/build-config`
    AC_MSG_RESULT([checking for BUILD platform configuration... done])
    rm -rf CONF-FOR-BUILD
else
    CC_FOR_BUILD="$CC"
    CXX_FOR_BUILD="$CXX"
    CC_FOR_BUILD="$CC"
    COM_FOR_BUILD="$COM"
    CPUNAME_FOR_BUILD="$CPUNAME"
    CPU_FOR_BUILD="$CPU"
    CXX_FOR_BUILD="$CXX"
    GUIBASE_FOR_BUILD="$GUIBASE"
    GUI_FOR_BUILD="$GUI"
    INPATH_FOR_BUILD="$INPATH"
    MACOSX_DEPLOYMENT_TARGET_FOR_BUILD="$MACOSX_DEPLOYMENT_TARGET"
    OS_FOR_BUILD="$OS"
    OUTDIR_FOR_BUILD="$OUTDIR"
    OUTPATH_FOR_BUILD="$OUTPATH"
    WORKDIR_FOR_BUILD="$WORKDIR"
fi
AC_SUBST(COM_FOR_BUILD)
AC_SUBST(GUI_FOR_BUILD)
AC_SUBST(GUIBASE_FOR_BUILD)
AC_SUBST(OS_FOR_BUILD)
AC_SUBST(CPU_FOR_BUILD)
AC_SUBST(CPUNAME_FOR_BUILD)
AC_SUBST(CC_FOR_BUILD)
AC_SUBST(CXX_FOR_BUILD)
AC_SUBST(INPATH_FOR_BUILD)
AC_SUBST(OUTPATH_FOR_BUILD)
AC_SUBST(MACOSX_DEPLOYMENT_TARGET_FOR_BUILD)

AC_SUBST(OUTDIR_FOR_BUILD)
AC_SUBST(WORKDIR_FOR_BUILD)

UPD="`echo AC_PACKAGE_VERSION | sed "s/\.//"`0"
SOURCEVERSION="OOO$UPD"
AC_SUBST(UPD)
AC_SUBST(SOURCEVERSION)

dnl ===================================================================
dnl Set the ENABLE_CRASHDUMP variable.
dnl ===================================================================
AC_MSG_CHECKING([whether to enable crashdump feature])
if test "$enable_crashdump" = "yes"; then
    ENABLE_CRASHDUMP="TRUE"
    BUILD_TYPE="$BUILD_TYPE CRASHREP"
    AC_MSG_RESULT([yes])
else
    ENABLE_CRASHDUMP=""
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_CRASHDUMP)


dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
dnl ===================================================================
AC_MSG_CHECKING([whether to turn warnings to errors])
if test -n "$enable_werror" -a "$enable_werror" != "no"; then
    EXTERNAL_WARNINGS_NOT_ERRORS="FALSE"
    AC_MSG_RESULT([yes])
else
    EXTERNAL_WARNINGS_NOT_ERRORS="TRUE"
    AC_MSG_RESULT([no])
fi
AC_SUBST(EXTERNAL_WARNINGS_NOT_ERRORS)

dnl Set the ENABLE_DEBUG variable.
dnl ===================================================================
AC_MSG_CHECKING([whether to do a debug build])
if test -n "$enable_debug" && test "$enable_debug" != "no"; then
    if test "$enable_debug" = "y" || test "$enable_debug" = "yes"; then
        ENABLE_DEBUG="TRUE"
        ENABLE_DEBUG_FOR=all
        AC_MSG_RESULT([yes])
    else
        ENABLE_DEBUG=""
        ENABLE_DEBUG_FOR="$enable_debug"
        AC_MSG_RESULT([for $enable_debug])
    fi
else
    ENABLE_DEBUG=""
    ENABLE_DEBUG_FOR=""
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_DEBUG)
AC_SUBST(ENABLE_DEBUG_FOR)


dnl Determine whether to use linkoo for the smoketest installation
dnl ===================================================================
AC_MSG_CHECKING([whether to use linkoo for the smoketest installation])
if test "$enable_linkoo" = "no"; then
    DISABLE_LINKOO="TRUE"
    AC_MSG_RESULT([no])
else
    DISABLE_LINKOO=
    AC_MSG_RESULT([yes])
fi
AC_SUBST(DISABLE_LINKOO)

# Set the ENABLE_LTO variable
# ===================================================================
AC_MSG_CHECKING([whether to use link-time optimization])
if test -n "$enable_lto" -a "$enable_lto" != "no"; then
    ENABLE_LTO="TRUE"
    AC_MSG_RESULT([yes])
else
    ENABLE_LTO=""
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_LTO)

dnl whether to include symbols into final build.
dnl ===================================================================
AC_MSG_CHECKING([whether to include symbols])
if test -n "$enable_symbols" -a "$enable_symbols" != "no"; then
    ENABLE_SYMBOLS="TRUE"
    AC_MSG_RESULT([yes])
else
    ENABLE_SYMBOLS=
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_SYMBOLS)

if test "$enable_headless" = "yes"; then
    # be sure to do not mess with uneeded stuff
    test_randr=no
    test_xrender=no
    test_cups=no
    test_fontconfig=yes
    test_gtk=no
    build_gstreamer=no
    test_tde=no
    test_kde=no
    test_kde4=no
    test_unix_quickstarter=no
fi

dnl check for cups support
dnl ===================================================================
if test "$enable_cups" = "no"; then
    test_cups=no
    ENABLE_CUPS="NO"
elif test "$enable_cups" = "yes"; then
    if test $_os = iOS -o $_os = Android; then
        AC_MSG_ERROR([CUPS makes no sense for $_os])
    fi
    ENABLE_CUPS="YES"
elif test $_os = iOS -o $_os = Android; then
    ENABLE_CUPS=NO
else
    ENABLE_CUPS="YES"
fi
AC_SUBST(ENABLE_CUPS)

if test "$test_cups" = "yes"; then
    AC_MSG_CHECKING([whether cups support is present])
    AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
    AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
    if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -a "$ac_cv_header_cups_cups_h" != "yes"; then
        AC_MSG_ERROR([Could not find CUPS. Install libcupsys2-dev or cups???-devel.])
    fi
fi


# fontconfig checks
if test "$test_fontconfig" = "yes"; then
    PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
else
    case "$BUILD_TYPE" in
    *FONTCONFIG*)
        FONTCONFIG_LIBS="-lfontconfig"
        ;;
    esac
fi
AC_SUBST(FONTCONFIG_CFLAGS)
AC_SUBST(FONTCONFIG_LIBS)

dnl whether to find & fetch external tarballs?
dnl ===================================================================
if test -z "$TARFILE_LOCATION"; then
    TARFILE_LOCATION="$SRC_ROOT/src"
fi
AC_SUBST(TARFILE_LOCATION)

AC_MSG_CHECKING([whether we want to fetch tarballs])
if test "$enable_fetch_external" != "no"; then
    AC_MSG_RESULT([yes])
    DO_FETCH_TARBALLS="YES"
else
    AC_MSG_RESULT([no])
    DO_FETCH_TARBALLS="NO"
fi
AC_SUBST(DO_FETCH_TARBALLS)


dnl Disable legacy binary file formats filters
dnl ===================================================================
AC_MSG_CHECKING([whether to enable filters for legacy binary file formats (StarOffice 5.2)])
if test "$enable_binfilter" = "no"; then
    WITH_BINFILTER="NO"
    AC_MSG_RESULT([no])
else
    WITH_BINFILTER="YES"
    BUILD_TYPE="$BUILD_TYPE BINFILTER"
    GIT_REPO_NAMES="$GIT_REPO_NAMES binfilter"
    AC_MSG_RESULT([yes])
fi
AC_SUBST(WITH_BINFILTER)

AC_MSG_CHECKING([whether to build help])
if test "$with_help" != "no" -a $_os != iOS -a $_os != Android; then
    AC_MSG_RESULT([yes])
    BUILD_TYPE="$BUILD_TYPE HELP"
    SCPDEFS="$SCPDEFS -DWITH_HELP"
    GIT_REPO_NAMES="$GIT_REPO_NAMES help"
else
    AC_MSG_RESULT([no])
fi

dnl Test whether to include MySpell dictionaries
dnl ===================================================================
AC_MSG_CHECKING([whether to include MySpell dictionaries])
if test -z "$with_myspell_dicts" -o "$with_myspell_dicts" = "yes"; then
    AC_MSG_RESULT([yes])
    WITH_MYSPELL_DICTS=YES
    BUILD_TYPE="$BUILD_TYPE DICTIONARIES"
    GIT_REPO_NAMES="$GIT_REPO_NAMES dictionaries"
else
    AC_MSG_RESULT([no])
    WITH_MYSPELL_DICTS=NO
fi
AC_SUBST(WITH_MYSPELL_DICTS)

AC_MSG_CHECKING([whether to use dicts from external paths])
if test -z "$with_system_dicts" -o "$with_system_dicts" != "no"; then
    AC_MSG_RESULT([yes])
    SYSTEM_DICTS=YES
    AC_MSG_CHECKING([for spelling dictionary directory])
    if test -n "$with_external_dict_dir"; then
        DICT_SYSTEM_DIR=file://$with_external_dict_dir
    else
        DICT_SYSTEM_DIR=file:///usr/share/hunspell
        if test ! -d /usr/share/hunspell -a -d /usr/share/myspell; then
            DICT_SYSTEM_DIR=file:///usr/share/myspell
        fi
    fi
    AC_MSG_RESULT([$DICT_SYSTEM_DIR])
    AC_MSG_CHECKING([for hyphenation patterns directory])
    if test -n "$with_external_hyph_dir"; then
        HYPH_SYSTEM_DIR=file://$with_external_hyph_dir
    else
        HYPH_SYSTEM_DIR=file:///usr/share/hyphen
    fi
    AC_MSG_RESULT([$HYPH_SYSTEM_DIR])
    AC_MSG_CHECKING([for thesaurus directory])
    if test -n "$with_external_thes_dir"; then
        THES_SYSTEM_DIR=file://$with_external_thes_dir
    else
        THES_SYSTEM_DIR=file:///usr/share/mythes
    fi
    AC_MSG_RESULT([$THES_SYSTEM_DIR])
else
    AC_MSG_RESULT([no])
    SYSTEM_DICTS=NO
fi
AC_SUBST(SYSTEM_DICTS)
AC_SUBST(DICT_SYSTEM_DIR)
AC_SUBST(HYPH_SYSTEM_DIR)
AC_SUBST(THES_SYSTEM_DIR)

dnl ===================================================================
dnl ENABLE_PCH i now a no-op
dnl ===================================================================
AC_MSG_CHECKING([whether to enable pch feature])
AC_MSG_RESULT([no, obsolete])

dnl ===================================================================
dnl Search all the common names for GNU make
dnl ===================================================================
AC_MSG_CHECKING([for GNU make])

# try to use our own make if it is available and GNUMAKE was not already defined
if test -z "$GNUMAKE"; then
    if test -x "/opt/lo/bin/make"; then
        GNUMAKE="/opt/lo/bin/make"
    fi
fi

for a in "$MAKE" "$GNUMAKE" make gmake gnumake; do
    if test -n "$a"; then
        $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
        if test $? -eq 0;  then
            GNUMAKE=$a
            break
        fi
    fi
done
AC_MSG_RESULT($GNUMAKE)
if test -z "$GNUMAKE"; then
    AC_MSG_ERROR([not found. install GNU make.])
fi

AC_MSG_CHECKING([the GNU make version])
_make_version=`$GNUMAKE --version | grep GNU | $GREP -v GPL | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
_make_longver=`echo $_make_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
if test "$_make_longver" -ge "038200"; then
    AC_MSG_RESULT([$GNUMAKE $_make_version])

elif test "$_make_longver" -ge "038100"; then
    if test "$build_os" = "cygwin"; then
        AC_MSG_ERROR([failed ($GNUMAKE version >= 3.82 needed])
    fi
    AC_MSG_RESULT([$GNUMAKE $_make_version])

    dnl ===================================================================
    dnl Search all the common names for sha1sum
    dnl ===================================================================
    AC_PATH_PROGS(SHA1SUM, sha1sum sha1 shasum)
    if test -z "$SHA1SUM"; then
        AC_MSG_ERROR([install the approproate SHA-1 checksumming program for this OS])
    fi
    AC_MSG_CHECKING([for GNU make bug 20033])
    TESTGMAKEBUG20033=`mktemp -d tmp.XXXXXX`
    cat > $TESTGMAKEBUG20033/Makefile << EOF
A := \$(wildcard *.a)

.PHONY: all
all: \$(A:.a=.b)
	@echo survived bug20033. #dont kill these tabs, you will break the Makefile!!!!

.PHONY: setup
setup:
	@touch 1.a 2.a 3.a 4.a 5.a 6.a

define d1
@echo lala \$(1)
@sleep 1
endef

define d2
@echo tyty \$(1)
@sleep 1
endef

%.b : %.a
	\$(eval CHECKSUM := \$(word 1,\$(shell cat \$^ | $SHA1SUM))) \$(if \$(wildcard \$(CACHEDIR)/\$(CHECKSUM)),\
	\$(call d1,\$(CHECKSUM)),\
	\$(call d2,\$(CHECKSUM)))
EOF
    if test -z "`(cd $TESTGMAKEBUG20033 && $GNUMAKE setup && $GNUMAKE -j)|grep survived`"; then
        no_parallelism_make="YES"
        AC_MSG_RESULT([yes, disable parallelism])
    else
        AC_MSG_RESULT([no, keep parallelism enabled])
    fi
    rm -rf $TESTGMAKEBUG20033
else
    AC_MSG_ERROR([failed ($GNUMAKE version >= 3.81 needed])
fi

# find if gnumake support file function
AC_MSG_CHECKING([for GNU support for (file function])
TESTGMAKEFILEFUNC="`mktemp -d -t tst.XXXXXX`"
cat > $TESTGMAKEFILEFUNC/Makefile << EOF
\$(file >test.txt,Success )

.PHONY: all
all:
	@cat test.txt

EOF
$GNUMAKE -C $TESTGMAKEFILEFUNC 2>/dev/null 1>&2
if test -f $TESTGMAKEFILEFUNC/test.txt ; then
    HAVE_GNUMAKE_FILE_FUNC="YES"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
rm -rf $TESTGMAKEFILEFUNC
AC_SUBST(HAVE_GNUMAKE_FILE_FUNC)
AC_SUBST(GNUMAKE)

_make_ver_check=`$GNUMAKE --version | grep LibreOffice`;
STALE_MAKE=
make_warning=
if test "$_make_ver_check" = ""; then
   STALE_MAKE=TRUE
fi

HAVE_LD_HASH_STYLE=FALSE
WITH_LINKER_HASH_STYLE=
AC_MSG_CHECKING( for --hash-style gcc linker support )
if test "$GCC" = "yes"; then
    if test -z "$with_linker_hash_style" -o "$with_linker_hash_style" = "yes"; then
        hash_styles="gnu sysv"
    elif test "$with_linker_hash_style" = "no"; then
        hash_styles=
    else
        hash_styles="$with_linker_hash_style"
    fi

    for hash_style in $hash_styles; do
        test "$HAVE_LD_HASH_STYLE" = "TRUE" && continue
        hash_style_ldflags_save=$LDFLAGS
        LDFLAGS="$LDFLAGS -Wl,--hash-style=$hash_style"

        AC_LINK_IFELSE([AC_LANG_PROGRAM(
            [
#include <stdio.h>
            ],[
printf ("");
            ])],
            [ if ./conftest$EXEEXT; then
                  HAVE_LD_HASH_STYLE=TRUE
                  WITH_LINKER_HASH_STYLE=$hash_style
              fi],
            [HAVE_LD_HASH_STYLE=FALSE])
        LDFLAGS=$hash_style_ldflags_save
    done

    if test "$HAVE_LD_HASH_STYLE" = "TRUE"; then
        AC_MSG_RESULT( $WITH_LINKER_HASH_STYLE )
    else
        AC_MSG_RESULT( no )
    fi
    LDFLAGS=$hash_style_ldflags_save
else
    AC_MSG_RESULT( no )
fi
AC_SUBST(HAVE_LD_HASH_STYLE)
AC_SUBST(WITH_LINKER_HASH_STYLE)

dnl ===================================================================
dnl Check whether there's a Perl version available.
dnl ===================================================================
if test -z "$with_perl_home"; then
    AC_PATH_PROG(PERL, perl)
else
    test "$build_os" = "cygwin" && with_perl_home=`cygpath -u "$with_perl_home"`
    _perl_path="$with_perl_home/bin/perl"
    if test -x "$_perl_path"; then
        PERL=$_perl_path
    else
        AC_MSG_ERROR([$_perl_path not found])
    fi
fi

dnl ===================================================================
dnl Testing for Perl version 5 or greater.
dnl $] is the Perl version variable, it is returned as an integer
dnl ===================================================================
if test "$PERL"; then
    AC_MSG_CHECKING([the Perl version])
    ${PERL} -e "exit($]);"
    _perl_version=$?
    if test "$_perl_version" -lt 5; then
        AC_MSG_ERROR([found Perl version "$_perl_version", use version 5 of Perl])
    fi
    AC_MSG_RESULT([checked (perl $_perl_version)])
else
    AC_MSG_ERROR([Perl not found, install version 5 of Perl])
fi

dnl ===================================================================
dnl Testing for required Perl modules
dnl ===================================================================

AC_MSG_CHECKING([for required Perl modules])
if `$PERL -e 'use Archive::Zip; use Cwd;'`; then
    AC_MSG_RESULT([all modules found])
else
    AC_MSG_ERROR([Failed to find some modules])
fi


dnl ===================================================================
dnl Check for pkg-config
dnl ===================================================================
if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    PKG_PROG_PKG_CONFIG
fi

if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then

    # If you use CC=/path/to/compiler/foo-gcc or even CC="ccache
    # /path/to/compiler/foo-gcc" you need to set the AR etc env vars
    # explicitly. Or put /path/to/compiler in PATH yourself.

    AC_CHECK_TOOL(AR,ar)
    AC_CHECK_TOOL(NM,nm)
    AC_CHECK_TOOL(OBJDUMP,objdump)
    AC_CHECK_TOOL(RANLIB,ranlib)
    AC_CHECK_TOOL(STRIP,strip)
    if test "$_os" = "WINNT"; then
        AC_CHECK_TOOL(DLLTOOL,dlltool)
        AC_CHECK_TOOL(WINDRES,windres)
    fi
fi
AC_SUBST(AR)
AC_SUBST(DLLTOOL)
AC_SUBST(NM)
AC_SUBST(OBJDUMP)
AC_SUBST(PKG_CONFIG)
AC_SUBST(RANLIB)
AC_SUBST(STRIP)
AC_SUBST(WINDRES)

dnl ===================================================================
dnl pkg-config checks on Mac OS X
dnl ===================================================================

if test $_os = Darwin; then
    AC_MSG_CHECKING([for bogus pkg-config])
    if test -n "$PKG_CONFIG"; then
        if test "$PKG_CONFIG" = /usr/bin/pkg-config && ls -l /usr/bin/pkg-config | $GREP -q Mono.framework; then
            AC_MSG_RESULT([yes, from Mono])
        else
            AC_MSG_RESULT([yes, from unknown origin])
        fi
        AC_MSG_WARN([This might have unexpected consequences, please consider hiding $PKG_CONFIG])
        echo "Having a $PKG_CONFIG might have unexpected consequences, please consider hiding it" >>warn
    else
        AC_MSG_RESULT([no])
    fi
fi

dnl ===================================================================
dnl  .NET needs special treatment
dnl (does the above comment really mean .NET, or is it misusing
dnl that to mean Visual Studio .NET 2003 ? And does this also
dnl in fact apply equally to what we actually support, i.e.
dnl Visual Studio 2008 and 2010?)
dnl ===================================================================
if test "$build_os" = "cygwin"; then
    dnl Check midl.exe
    AC_PATH_PROG(MIDL_PATH, midl.exe)
    if test -n "$MIDL_PATH";then
        MIDL_PATH=`dirname "$MIDL_PATH"`
    fi
    if test -n "$with_midl_path";then
        with_midl_path=`cygpath -u "$with_midl_path"`
    fi
    if test -x "$with_midl_path/midl.exe"; then
        MIDL_PATH="$with_midl_path"
    fi
    if test -z "$MIDL_PATH" -a -e "$with_cl_home/../Common7/Tools/Bin/midl.exe"; then
        MIDL_PATH="$with_cl_home/../Common7/Tools/Bin"
    fi
    if test -z "$MIDL_PATH"; then
        vstest=`./oowintool --msvs-productdir`;
        if test -x "$vstest/Common7/Tools/Bin/midl.exe"; then
            MIDL_PATH="$vstest/Common7/Tools/Bin"
        fi
    fi
    if test -z "$MIDL_PATH"; then
        winsdktest=`./oowintool --windows-sdk-home`
        if test -x "$winsdktest/Bin/midl.exe"; then
            MIDL_PATH="$winsdktest/Bin"
        fi
    fi
    if test ! -x "$MIDL_PATH/midl.exe"; then
        AC_MSG_ERROR([midl.exe not found. Make sure it's in PATH or use --with-midl-path])
    fi
    # Convert to posix path with 8.3 filename restrictions ( No spaces )
    MIDL_PATH=`cygpath -d "$MIDL_PATH"`
    MIDL_PATH=`cygpath -u "$MIDL_PATH"`

    dnl Check csc.exe
    AC_PATH_PROG(CSC_PATH, csc.exe)
    if test -n "$CSC_PATH";then
        CSC_PATH=`dirname "$CSC_PATH"`
    fi
    if test -n "$with_csc_path";then
        with_csc_path=`cygpath -u "$with_csc_path"`
    fi
    if test -x "$with_csc_path/csc.exe"; then
        CSC_PATH="$with_csc_path"
    else
       csctest=`./oowintool --csc-compilerdir`;
       if test -x "$csctest/csc.exe"; then
           CSC_PATH="$csctest"
       fi
    fi
    if test ! -x "$CSC_PATH/csc.exe"; then
        AC_MSG_ERROR([csc.exe not found. Make sure it's in the path or use --with-csc-path])
    fi
    # Convert to posix path with 8.3 filename restrictions ( No spaces )
    CSC_PATH=`cygpath -d "$CSC_PATH"`
    CSC_PATH=`cygpath -u "$CSC_PATH"`

    dnl Check mscoree.lib / .NET Framework dir
    AC_MSG_CHECKING(.NET Framework)
    if test -n "$with_dotnet_framework_home"; then
        with_dotnet_framework_home=`cygpath -u "$with_dotnet_framework_home"`
    fi
    if test -f "$with_dotnet_framework_home/lib/mscoree.lib"; then
        DOTNET_FRAMEWORK_HOME="$with_dotnet_framework_home"
    fi
    if test -z "$DOTNET_FRAMEWORK_HOME"; then
        frametest=`./oowintool --dotnetsdk-dir`
        if test -f "$frametest/lib/mscoree.lib"; then
            DOTNET_FRAMEWORK_HOME="$frametest"
        else
            frametest=`./oowintool --windows-sdk-home`
            if test -f "$frametest/lib/mscoree.lib"; then
                DOTNET_FRAMEWORK_HOME="$frametest"
            fi
        fi
    fi
    if test ! -f "$DOTNET_FRAMEWORK_HOME/lib/mscoree.lib"; then
        AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-dotnet-framework-home])
    fi
    AC_MSG_RESULT(found)

    PathFormat "$MIDL_PATH"
    MIDL_PATH="$formatted_path"

    PathFormat "$DOTNET_FRAMEWORK_HOME"
    DOTNET_FRAMEWORK_HOME="$formatted_path"

    PathFormat "$CSC_PATH"
    CSC_PATH="$formatted_path"

fi

dnl ===================================================================
dnl Check if stdc headers are available excluding MSVC.
dnl ===================================================================
if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    AC_HEADER_STDC
fi

dnl ===================================================================
dnl Testing for C++ compiler and version...
dnl ===================================================================

if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    AC_PROG_CXX
else
    if test -n "$CC" -a -z "$CXX"; then
        CXX="$CC"
    fi
fi

dnl check if we are using a buggy version of g++ (currently 3.4.0, 3.4.1 and trunk)
if test "$GXX" = "yes"; then
    AC_MSG_CHECKING([the GNU C++ compiler version])

    _gpp_version=`$CXX -dumpversion`
    _gpp_majmin=`echo $_gpp_version | $AWK -F. '{ print \$1*100+\$2 }'`

    if test "$_os" = "Darwin" -a "$with_macosx_sdk" = "10.4" -a "$_gpp_majmin" -ge "401"; then
        if test -z "$save_CXX" -a -x "$GCC_HOME/bin/g++-4.0"; then
            export CXX="$GCC_HOME/bin/g++-4.0"
            _gpp_majmin_2=`$CXX -dumpversion | $AWK -F. '{ print \$1*100+\$2 }'`
            if test "$_gpp_majmin_2" -ge "400" -a "$_gpp_majmin_2" -lt "401"; then
                _gpp_majmin=$_gpp_majmin_2
            fi
        fi
        if test "$_gpp_majmin" -ge "401"; then
            AC_MSG_ERROR([You need to use the g++-4.0 compiler (g++ $_gpp_version won't work with the MacOSX10.4u.sdk) - set CXX accordingly])
        else
            AC_MSG_RESULT([implicitly using CXX=$CXX])
        fi
    else
        AC_MSG_RESULT([checked (g++ $_gpp_version)])
    fi

    if test "$_gpp_majmin" = "304"; then
        AC_MSG_CHECKING([whether $CXX has the enum bug])
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
            extern "C" void abort (void);
            extern "C" void exit (int status);

            enum E { E0, E1, E2, E3, E4, E5 };

            void test (enum E e)
            {
                if (e == E2 || e == E3 || e == E1)
                    exit (1);
            }

            int main (void)
            {
                test (E4);
                test (E5);
                test (E0);
                return 0;
            }
            ]])],[AC_MSG_ERROR([your version of the GNU C++ compile has a bug which prevents LibreOffice from being compiled correctly - please check http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00968.html for details.])],[AC_MSG_RESULT([no])],[])
    fi
fi

#
# prefx CXX with ccache if needed
#
if test "$CCACHE" != ""; then
    AC_MSG_CHECKING([whether $CXX is already ccached])
    AC_LANG_PUSH([C++])
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS --ccache-skip -O2"
    dnl an empty program will do, we're checking the compiler flags
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
                      [use_ccache=yes], [use_ccache=no])
    if test $use_ccache = yes; then
        AC_MSG_RESULT([yes])
    else
        CXX="$CCACHE $CXX"
        AC_MSG_RESULT([no])
    fi
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])
fi

dnl ===================================================================
dnl Find pre-processors.(should do that _after_ messing with CC/CXX)
dnl ===================================================================

if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then
    AC_PROG_CXXCPP

    dnl Check whether there's a C pre-processor.
    dnl ===================================================================
    dnl When using SunStudio compiler, there is a bug with the cc
    dnl preprocessor, so use CC preprocessor as the cc preprocessor
    dnl See Issuezilla #445.
    dnl ===================================================================
    if test "$_os" = "SunOS"; then
        CPP=$CXXCPP
    else
        AC_PROG_CPP
    fi
fi


dnl ===================================================================
dnl Find integral type sizes and alignments
dnl ===================================================================

if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then

    AC_CHECK_SIZEOF(long)
    AC_CHECK_SIZEOF(short)
    AC_CHECK_SIZEOF(int)
    AC_CHECK_SIZEOF(long long)
    AC_CHECK_SIZEOF(double)
    AC_CHECK_SIZEOF(void*)

    SIZEOF_SHORT=$ac_cv_sizeof_short
    SIZEOF_INT=$ac_cv_sizeof_int
    SIZEOF_LONG=$ac_cv_sizeof_long
    SIZEOF_LONGLONG=$ac_cv_sizeof_long_long
    SIZEOF_DOUBLE=$ac_cv_sizeof_double
    SIZEOF_POINTER=$ac_cv_sizeof_voidp

    dnl Allow build without AC_CHECK_ALIGNOF, grrr
    m4_pattern_allow([AC_CHECK_ALIGNOF])
    m4_ifdef([AC_CHECK_ALIGNOF],
        [
            AC_CHECK_ALIGNOF(short,[#include <stddef.h>])
            AC_CHECK_ALIGNOF(int,[#include <stddef.h>])
            AC_CHECK_ALIGNOF(long,[#include <stddef.h>])
            AC_CHECK_ALIGNOF(double,[#include <stddef.h>])
        ],
        [
            case "$_os-$host_cpu" in
            Darwin-powerpc)
                test -z "$ac_cv_alignof_short" && ac_cv_alignof_short=1
                test -z "$ac_cv_alignof_int" && ac_cv_alignof_int=1
                test -z "$ac_cv_alignof_long" && ac_cv_alignof_long=1
                test -z "$ac_cv_alignof_double" && ac_cv_alignof_double=1
                ;;
            *)
                if test -z "$ac_cv_alignof_short" -o \
                        -z "$ac_cv_alignof_int" -o \
                        -z "$ac_cv_alignof_long" -o \
                        -z "$ac_cv_alignof_double"; then
                   AC_MSG_ERROR([Your Autoconf doesn't have [AC_][CHECK_ALIGNOF]. You need to set the environment variables ac_cv_alignof_short, ac_cv_alignof_int, ac_cv_alignof_long and ac_cv_alignof_double.])
                fi
                ;;
            esac
        ])

    ALIGNOF_SHORT=$ac_cv_alignof_short
    ALIGNOF_INT=$ac_cv_alignof_int
    ALIGNOF_LONG=$ac_cv_alignof_long
    ALIGNOF_DOUBLE=$ac_cv_alignof_double

    AC_C_BIGENDIAN
    WORDS_BIGENDIAN=$ac_cv_c_bigendian

    dnl Check for large file support
    AC_SYS_LARGEFILE
    if test -n "$ac_cv_sys_file_offset_bits" -a "$ac_cv_sys_file_offset_bits" != "no"; then
        LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
    fi
    if test -n "$ac_cv_sys_large_files" -a "$ac_cv_sys_large_files" != "no"; then
        LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
    fi
else
    # Hardcode for MSVC
    SIZEOF_SHORT=2
    SIZEOF_INT=4
    SIZEOF_LONG=4
    SIZEOF_LONGLONG=8
    if test "$CL_X64" = ""; then
        SIZEOF_POINTER=4
    else
        SIZEOF_POINTER=8
    fi
    ALIGNOF_SHORT=2
    ALIGNOF_INT=4
    ALIGNOF_LONG=4
    ALIGNOF_DOUBLE=8
    WORDS_BIGENDIAN=no
    LFS_CFLAGS=''
fi
AC_SUBST(WORDS_BIGENDIAN)
AC_SUBST(LFS_CFLAGS)

AC_SUBST(SIZEOF_SHORT)
AC_SUBST(SIZEOF_INT)
AC_SUBST(SIZEOF_LONG)
AC_SUBST(SIZEOF_LONGLONG)
AC_SUBST(SIZEOF_DOUBLE)
AC_SUBST(SIZEOF_POINTER)
AC_SUBST(ALIGNOF_SHORT)
AC_SUBST(ALIGNOF_INT)
AC_SUBST(ALIGNOF_LONG)
AC_SUBST(ALIGNOF_DOUBLE)

dnl ===================================================================
dnl Check if valgrind.h is available
dnl ===================================================================
if test "$cross_compiling" != "yes" -a "$enable_dbgutil" != "no" -a \
        -z "$VALGRIND_CFLAGS"; then
    dnl Test $prefix (currently only testing for /usr and /usr/local)
    dnl so that VALGRIND_CFLAGS = -I$prefix/include/valgrind
    prev_cppflags=$CPPFLAGS
    CPPFLAGS="-I/usr/include/valgrind"
    AC_CHECK_HEADER([valgrind.h], [VALGRIND_CFLAGS=$CPPFLAGS], [unset ac_cv_header_valgrind_h])
    if test -z "$VALGRIND_CFLAGS"; then
        CPPFLAGS="-I/usr/local/include/valgrind"
        AC_CHECK_HEADER([valgrind.h], [VALGRIND_CFLAGS=$CPPFLAGS], [])
    fi
    if test -n "$VALGRIND_CFLAGS"; then
        CPPFLAGS=$VALGRIND_CFLAGS
        AC_CHECK_HEADER([memcheck.h], [], [VALGRIND_CFLAGS=""])
    fi
    CPPFLAGS=$prev_cppflags
fi
AC_SUBST([VALGRIND_CFLAGS])

dnl ===================================================================
dnl Set the MinGW include directories
dnl ===================================================================
if test "$WITH_MINGW" = "yes"; then
    AC_MSG_CHECKING([for MinGW include path])
    cat >conftest.$ac_ext <<_ACEOF
#include <stddef.h>
#include <bits/c++config.h>
_ACEOF
    _mingw_lib_include_path=`$CXX -E -xc++ conftest.$ac_ext | $SED -n -e '/.*1*"\(.*\)\/stddef.h".*/s//\1/p' -e '/.*1*"\(.*\)\/bits\/c++config.h".*/s//\1/p' | sort -u | xargs echo`
    rm conftest.$ac_ext
    if test -z "$_mingw_lib_include_path"; then
        _mingw_lib_include_path="NO_LIB_INCLUDE"
        AC_MSG_RESULT([no MinGW include path])
    else
        AC_MSG_RESULT([$_mingw_lib_include_path])
    fi
    MINGW_LIB_INCLUDE_PATH="$_mingw_lib_include_path"
    AC_SUBST(MINGW_LIB_INCLUDE_PATH)

    mingw_crtbegin=`$CC -print-file-name=crtbegin.o`
    MINGW_CLIB_DIR=`dirname $mingw_crtbegin`

    AC_LANG_PUSH([C++])

    AC_MSG_CHECKING([for dynamic libgcc])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <iostream>
using namespace std;
]], [[ try { throw 42; } catch (int e) { cout << "Yep, " << e << endl; } ]])],[   
            MINGW_GCCDLL=`$OBJDUMP -p conftest.exe | grep 'DLL Name: libgcc' | $SED -e 's@.*DLL Name: @@'`
            if test -n "$MINGW_GCCDLL"; then
                MINGW_SHARED_GCCLIB=YES
                AC_MSG_RESULT([ $MINGW_GCCDLL])
            else
                MINGW_SHARED_GCCLIB=NO
                AC_MSG_RESULT([no])
            fi
       ],[ AC_MSG_RESULT([no])
       
    ])

    AC_MSG_CHECKING([for dynamic libstdc++])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <iostream>
using namespace std;
]], [[ cout << "Hello there." << endl; ]])],[   
            MINGW_GXXDLL=`$OBJDUMP -p conftest.exe | grep 'DLL Name: libstdc++' | $SED -e 's@.*DLL Name: @@'`
            if test -n "$MINGW_GXXDLL"; then
                mingw_gxxdll_root=${MINGW_GXXDLL%.dll}
                mingw_gxxdll_root=${mingw_gxxdll_root#lib}
                MINGW_SHARED_LIBSTDCPP=-l$mingw_gxxdll_root
                MINGW_SHARED_GXXLIB=YES
                AC_MSG_RESULT([$MINGW_GXXDLL])
            else
                MINGW_SHARED_GXXLIB=NO
                AC_MSG_RESULT([no])
            fi
       ],[ AC_MSG_RESULT([no])
       
    ])

    AC_LANG_POP([C++])

    AC_SUBST(MINGW_CLIB_DIR)
    AC_SUBST(MINGW_SHARED_GCCLIB)
    AC_SUBST(MINGW_SHARED_GXXLIB)
    AC_SUBST(MINGW_SHARED_LIBSTDCPP)
    AC_SUBST(MINGW_GCCDLL)
    AC_SUBST(MINGW_GXXDLL)
fi

dnl ===================================================================
dnl Extra checking for the SunOS compiler
dnl ===================================================================
if test "$_os" = "SunOS"; then
    dnl SunStudio C++ compiler packaged with SunStudio C compiler
    if test "$CC" = "cc"; then
    AC_MSG_CHECKING([SunStudio C++ Compiler])
        if test "$CXX" != "CC"; then
            AC_MSG_WARN([SunStudio C++ was not found])
            echo "SunStudio C++ was not found" >> warn
        else
            AC_MSG_RESULT([checked])
        fi
    fi
fi

dnl *************************************************************
dnl Testing for exception handling - dwarf2 or sjlj exceptions...
dnl *************************************************************
if test "$WITH_MINGW" = "yes"; then
    AC_MSG_CHECKING([exception type])
    AC_LANG_PUSH([C++])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iostream>

        extern "C" void _Unwind_SjLj_RaiseException(void) __attribute__ ((__noreturn__));

        ]], [[_Unwind_SjLj_RaiseException() ]])],[exceptions_type="sjlj"],[exceptions_type="dwarf2"
    ])
    AC_MSG_RESULT($exceptions_type)
    AC_LANG_POP([C++])
fi

EXCEPTIONS="$exceptions_type"
AC_SUBST(EXCEPTIONS)

dnl ===================================================================
dnl Checks for what the default STL should be
dnl ===================================================================
AC_MSG_CHECKING([Whether building STLPort library makes sense])
BUILD_STLPORT="no"
if test "$_os" = "Linux"; then
    case "$host_cpu" in
    i?86)
        case "$host_os" in
        k*bsd*-gnu*)
            BUILD_STLPORT="no"
            ;;
        *)
            BUILD_STLPORT="yes"
            ;;
        esac
        ;;
    *)
        BUILD_STLPORT="no"
        ;;
    esac
elif test "$_os" = "SunOS"; then
    BUILD_STLPORT="yes"
elif test "$_os" = "WINNT" -a "$WITH_MINGW" != "yes"; then
    BUILD_STLPORT="yes"
elif test "$_os" = "FreeBSD"; then
    BUILD_STLPORT="yes"
fi
if test "$BUILD_STLPORT" = "yes"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi

AC_MSG_CHECKING([Whether STLPort library will be actually built])
if test "$with_stlport" = "auto" -o "$BUILD_STLPORT" = "no"; then
    with_stlport=$BUILD_STLPORT
fi
if test "$with_stlport" = "yes"; then
    AC_MSG_RESULT([yes])
    WITH_STLPORT=YES
    SCPDEFS="$SCPDEFS -DWITH_STLPORT"
    BUILD_TYPE="$BUILD_TYPE STLPORT"
else
    WITH_STLPORT=NO
    AC_MSG_RESULT([no])
fi

AC_SUBST(WITH_STLPORT)

dnl ===================================================================
dnl gxx include directories needed by STLPort
dnl ===================================================================
# Removed the special FreeBSD treatment. The problem was that with_gxx_include_path
# often contains an i386 which is expanded as a macro.
if test "$GXX" = "yes"; then
    AC_MSG_CHECKING([for g++ include path])
    if test -z "$with_gxx_include_path"; then
        with_gxx_include_path=`echo "#include <cstring>" | $CXX -E -xc++ - 2>/dev/null | $SED -n '/.*1*"\(.*\)\/cstring".*/s//\1/p' | head -n 1`
        if test "$with_gxx_include_path" = "/usr/libexec/(null)/include"; then
            with_gxx_include_path="/usr/include"
        fi
        if echo $with_gxx_include_path | $GREP -q linux; then
            # workaround for Mandriva - issue 100049
            with_gxx_include_path=`cd -P $with_gxx_include_path && pwd`
        fi
    fi
    dnl This is the original code...
    dnl with_gxx_include_path=`$CXX -print-search-dirs | grep instal |$AWK '{ print \$2 }'`/include
    if test -z "$with_gxx_include_path"; then
        with_gxx_include_path="NO_GXX_INCLUDE"
        AC_MSG_RESULT([none])
    else
        PathFormat "$with_gxx_include_path"
        with_gxx_include_path="$formatted_path"
        AC_MSG_RESULT([$with_gxx_include_path])
    fi
else
    with_gxx_include_path="NO_GXX_INCLUDE"
fi
GXX_INCLUDE_PATH="$with_gxx_include_path"
AC_SUBST(GXX_INCLUDE_PATH)

dnl ===================================================================
dnl thread-safe statics
dnl ===================================================================
AC_MSG_CHECKING([whether $CXX supports thread safe statics])
unset HAVE_THREADSAFE_STATICS
if test "$GCC" = "yes"; then
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS -fthreadsafe-statics"
    AC_LANG_PUSH([C++])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)],[HAVE_THREADSAFE_STATICS=TRUE],[])
    AC_LANG_POP([C++])
    CXXFLAGS=$save_CXXFLAGS
    if test "$HAVE_THREADSAFE_STATICS" = "TRUE"; then
        dnl Some C++ runtimes use a single lock for all static variables, which
        dnl can cause deadlock in multi-threaded applications.  This is not
        dnl easily tested here; for POSIX-based systems, if executing the
        dnl following C++ program does not terminate then the tool chain
        dnl apparently has this problem:
        dnl
        dnl   #include <pthread.h>
        dnl   int h() { return 0; }
        dnl   void * g(void * unused) {
        dnl     static int n = h();
        dnl     return &n;
        dnl   }
        dnl   int f() {
        dnl     pthread_t t;
        dnl     pthread_create(&t, 0, g, 0);
        dnl     pthread_join(t, 0);
        dnl     return 0;
        dnl   }
        dnl   int main() {
        dnl     static int n = f();
        dnl     return n;
        dnl   }
        dnl
        dnl Mac OS X up to at least 10.7.1 is known to have this problem, as is
        dnl at least one instance of GCC 4.2.4 (used on a "Linux
        dnl ooobuild1.osuosl.org 2.6.9-101.plus.c4smp #1 SMP Thu Jul 21 19:08:15
        dnl EDT 2011 i686 i686 i386 GNU/Linux" machine); see the definition of
        dnl __cxa_guard_acquire in GCC's libstdc++-v3/libsupc++/guard.cc for
        dnl what #ifdefs actually make a difference there.  Conservative advice
        dnl from Jakub Jelinek is to assume it working in GCC >= 4.3:
        if test "$_os" = "Darwin" -o "${GCCVER?}" -lt 040300; then
            unset HAVE_THREADSAFE_STATICS
            AC_MSG_RESULT([broken (i.e., no)])
        else
            AC_MSG_RESULT([yes])
        fi
    else
        AC_MSG_RESULT([no])
    fi
else
    AC_MSG_RESULT([unknown (assuming no)])
fi
AC_SUBST(HAVE_THREADSAFE_STATICS)

dnl ===================================================================
dnl visibility and c++0x features
dnl ===================================================================
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
    save_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_VISIBILITY_FEATURE=TRUE ],[])
    CFLAGS=$save_CFLAGS

    if test "$COM_GCC_IS_CLANG" = TRUE -a $_os = Darwin; then
        # It seems that with Apple's Clang, visibility doesn't work as
        # we would want at least in the connectivity and dbaccess
        # modules. This might be because of something peculiar in
        # those modules? Whatever.
        HAVE_GCC_VISIBILITY_FEATURE=
    fi

    if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CC supports -Wno-long-double])
    save_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS -Werror -Wno-long-double"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_NO_LONG_DOUBLE=TRUE ],[])
    CFLAGS=$save_CFLAGS
    if test "$HAVE_GCC_NO_LONG_DOUBLE" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CC supports -mno-avx])
    save_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS -Werror -mno-avx"
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_AVX=TRUE ],[])
    CFLAGS=$save_CFLAGS
    if test "$HAVE_GCC_AVX" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CC supports -std=gnu++0x without Language Defect 757])
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
    AC_LANG_PUSH([C++])

    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stddef.h>

template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];

namespace
{
        struct b
        {
                int i;
                int j;
        };
}
]], [[
struct a
{
        int i;
        int j;
};
a thinga[]={{0,0}, {1,1}};
b thingb[]={{0,0}, {1,1}};
size_t i = sizeof(sal_n_array_size(thinga));
size_t j = sizeof(sal_n_array_size(thingb));
return !(i != 0 && j != 0);
]])],[HAVE_CXX0X=TRUE],[])

    AC_LANG_POP([C++])
    CXXFLAGS=$save_CXXFLAGS
    if test "$HAVE_CXX0X" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi
fi

AC_SUBST(HAVE_CXX0X)
AC_SUBST(HAVE_GCC_NO_LONG_DOUBLE)
AC_SUBST(HAVE_GCC_AVX)

dnl ===================================================================
dnl system stl sanity tests
dnl ===================================================================
HAVE_GCC_VISIBILITY_BROKEN=
if test \( "$_os" != "WINNT" -o "$WITH_MINGW" = "yes" \); then

    AC_LANG_PUSH([C++])

    save_CPPFLAGS="$CPPFLAGS"
    if test -n "$MACOSX_SDK_PATH"; then
        CPPFLAGS="-isysroot $MACOSX_SDK_PATH $CPPFLAGS"
    fi

    if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
        dnl gcc#19664, gcc#22482, rhbz#162935
        AC_MSG_CHECKING([if STL headers are visibility safe (GCC bug 22482)])
        AC_EGREP_HEADER(visibility push, string, stlvisok=yes, stlvisok=no)
        AC_MSG_RESULT([$stlvisok])
        if test "$stlvisok" = "no"; then
            AC_MSG_WARN([Your gcc STL headers are not visibility safe. Disabling visibility])
            echo "Your gcc STL headers are not visibility safe. Disabling visibility" >> warn
            unset HAVE_GCC_VISIBILITY_FEATURE
        fi
    fi

    if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
        sharedlink_ldflags_save=$LDFLAGS
        LDFLAGS="$LDFLAGS -fvisibility-inlines-hidden $PICSWITCH $LINKFLAGSSHL"

        AC_MSG_CHECKING([if gcc is -fvisibility-inlines-hidden safe with STL headers])
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sstream>
using namespace std;
            ]], [[
istringstream strm( "test" ); return 0;
            ]])],
            # Ugh, surely bad to assume an error message will contain
            # the word "unresolvable", a problem with
            # -fvisibility-inlines-hidden and STL headers might cause
            # some more obscure message on some platform, and anway,
            # the error message could be localised.
            [$EGREP -q unresolvable conftest.err;
            if test $? -eq 0; then gccvisok=no; else gccvisok=yes; fi],[gccvisok=no
        ])
        AC_MSG_RESULT([$gccvisok])
        if test "$gccvisok" = "no"; then
            AC_MSG_WARN([Your gcc is not -fvisibility-inlines-hidden safe, disabling that.])
            echo "Your gcc is not -fvisibility-inlines-hidden safe, disabling that." >> warn
            HAVE_GCC_VISIBILITY_BROKEN="TRUE"
        fi

        LDFLAGS=$sharedlink_ldflags_save
    fi

    if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE" -a "$HAVE_GCC_VISIBILITY_BROKEN" != "TRUE"; then
        AC_MSG_CHECKING([if gcc is -fvisibility-inlines-hidden safe (Clang bug 11250)])
        cat > conftestlib1.cc <<_ACEOF
template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
struct S2: S1<int> { virtual ~S2(); };
S2::~S2() {}
_ACEOF
        cat > conftestlib2.cc <<_ACEOF
template<typename T> struct S1 { virtual ~S1() {} virtual void f() {} };
struct S2: S1<int> { virtual ~S2(); };
struct S3: S2 { virtual ~S3(); }; S3::~S3() {}
_ACEOF
        gccvisinlineshiddenok=yes
        if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib1.cc -o libconftest1$DLLPOST >/dev/null 2>&5; then
            gccvisinlineshiddenok=no
        else
            if ! $CXX $CXXFLAGS $CPPFLAGS $LINKFLAGSSHL -fPIC -fvisibility-inlines-hidden conftestlib2.cc -L. -lconftest1 $LINKFLAGSNOUNDEFS -o libconftest2$DLLPOST >/dev/null 2>&5; then
                gccvisinlineshiddenok=no
            fi
        fi
        
        rm -f libconftest1$DLLPOST libconftest2$DLLPOST
        AC_MSG_RESULT([$gccvisinlineshiddenok])
        if test "$gccvisinlineshiddenok" = "no"; then
            AC_MSG_WARN([Your gcc/clang is not -fvisibility-inlines-hidden safe, disabling that.])
            echo "Your gcc/clang is not -fvisibility-inlines-hidden safe, disabling that." >> warn
            HAVE_GCC_VISIBILITY_BROKEN="TRUE"
        fi
    fi

    if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
        AC_MSG_CHECKING([if gcc has a visibility bug with class-level attributes (GCC bug 26905)])
        cat >visibility.cxx <<_ACEOF
#pragma GCC visibility push(hidden)
struct __attribute__ ((visibility ("default"))) TestStruct {
  static void Init();
};
__attribute__ ((visibility ("default"))) void TestFunc() {
  TestStruct::Init();
}
_ACEOF
        if ! $CXX $CXXFLAGS $CPPFLAGS -fpic -S visibility.cxx 2>/dev/null > /dev/null; then
            gccvisbroken=yes
        else
            case "$host_cpu" in
            i?86|x86_64)
                if test "$_os" = "Darwin"; then
                    gccvisbroken=no
                else
                    if $EGREP -q '@PLT|@GOT' visibility.s; then
                        gccvisbroken=no
                    else
                        gccvisbroken=yes
                    fi
                fi
                ;;
            *)
                gccvisbroken=no
                ;;
            esac
        fi
        rm -f visibility.s visibility.cxx

        AC_MSG_RESULT([$gccvisbroken])
        if test "$gccvisbroken" = "yes"; then
            AC_MSG_WARN([Your gcc is not -fvisibility=hidden safe. Disabling visibility])
            echo "Your gcc is not -fvisibility=hidden safe. Disabling visibility" >> warn
            unset HAVE_GCC_VISIBILITY_FEATURE
        fi
    fi

    CPPFLAGS="$save_CPPFLAGS"

    AC_LANG_POP([C++])
fi

AC_SUBST(HAVE_GCC_VISIBILITY_FEATURE)
AC_SUBST(HAVE_GCC_VISIBILITY_BROKEN)

dnl ===================================================================
dnl SFINAE test
dnl Pre-C++11 does not allow types without linkage as template arguments.
dnl Substitution Failure Is Not An Error is an idiom that disables
dnl template instances that would cause an error, without actually
dnl causing an error. Old gcc (pre-4.0.2) however causes a real error.
dnl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21514
dnl ===================================================================
HAVE_SFINAE_ANONYMOUS_BROKEN=
if test \( "$_os" != "WINNT" -o "$WITH_MINGW" = "yes" \); then

    AC_LANG_PUSH([C++])
    AC_MSG_CHECKING([if SFINAE is broken with anonymous types])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
enum { AnonymousEnumValue };
template< typename T > class TestPredicate {};
template<> class TestPredicate< int > { public: typedef bool Type; };
template< typename T >
bool test( const T&, typename TestPredicate< T >::Type = false )
    { return true; };
void test( ... );
            ]], [[
    test( 10 );
    test( AnonymousEnumValue );
            ]])],[sfinae_anonymous_broken=no],[sfinae_anonymous_broken=yes
        ])
        AC_MSG_RESULT([$sfinae_anonymous_broken])
        if test "$sfinae_anonymous_broken" = "yes"; then
            HAVE_SFINAE_ANONYMOUS_BROKEN="TRUE"
        fi
    AC_LANG_POP([C++])
fi

AC_SUBST(HAVE_SFINAE_ANONYMOUS_BROKEN)

dnl ===================================================================
dnl  Clang++ tests
dnl ===================================================================

HAVE_GCC_FNO_DEFAULT_INLINE=
HAVE_GCC_FNO_ENFORCE_EH_SPECS=
if test "$GCC" = "yes"; then
    AC_MSG_CHECKING([whether $CXX supports -fno-default-inline])
    if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
        # Option just ignored and silly warning that isn't a real
        # warning printed
        :
    else
        AC_LANG_PUSH([C++])
        save_CXXFLAGS=$CXXFLAGS
        CXXFLAGS="$CFLAGS -Werror -fno-default-inline"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_DEFAULT_INLINE=TRUE ],[])
        CXXFLAGS=$save_CXXFLAGS
        AC_LANG_POP([C++])
    fi
    if test "$HAVE_GCC_FNO_DEFAULT_INLINE" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi

    AC_MSG_CHECKING([whether $CXX supports -fno-enforce-eh-specs])
    if test -n "$CLANGVER" -a 0"$CLANGVER" -le 30100; then
        # As above
        :
    else
        AC_LANG_PUSH([C++])
        save_CXXFLAGS=$CXXFLAGS
        CXXFLAGS="$CFLAGS -Werror -fno-enforce-eh-specs"
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_FNO_ENFORCE_EH_SPECS=TRUE ],[])
        CXXFLAGS=$save_CXXFLAGS
        AC_LANG_POP([C++])
    fi
    if test "$HAVE_GCC_FNO_ENFORCE_EH_SPECS" = "TRUE"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
    fi
fi
AC_SUBST(HAVE_GCC_FNO_DEFAULT_INLINE)
AC_SUBST(HAVE_GCC_FNO_ENFORCE_EH_SPECS)


dnl ===================================================================
dnl allocator
dnl ===================================================================
AC_MSG_CHECKING([which memory allocator to use])
if test "$with_alloc" = "system"; then
    AC_MSG_RESULT([system])
    ALLOC="SYS_ALLOC";
    AC_CHECK_FUNCS([malloc realloc calloc free])
fi
if test "$with_alloc" = "tcmalloc"; then
    AC_MSG_RESULT(tcmalloc)
    if ! echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
        AC_MSG_ERROR([tcmalloc only available/usable on ix86])
    fi
    AC_CHECK_LIB([tcmalloc], [malloc], [:],
        [AC_MSG_ERROR(tcmalloc not found or functional. Install the Google Profiling Tools)], [])
    ALLOC="TCMALLOC";
fi
if test "$with_alloc" = "jemalloc"; then
    if test "$_os" != "FreeBSD" -o "$_os" != "NetBSD"; then
        AC_MSG_RESULT(jemalloc)
        save_CFLAGS=$CFLAGS
        CFLAGS="$CFLAGS -pthread"
        AC_CHECK_LIB([jemalloc], [malloc], [:],
            [AC_MSG_ERROR(jemalloc not found or functional. Install the jemalloc allocator.)], [])
        ALLOC="JEMALLOC";
        CFLAGS=$save_CFLAGS
    else
        AC_MSG_RESULT([system])
        ALLOC="SYS_ALLOC";
        AC_CHECK_FUNCS([malloc realloc calloc free])
    fi
fi
if test "$with_alloc" = "internal" -o -z "$with_alloc"; then
    AC_MSG_RESULT([internal])
fi
AC_CHECK_FUNCS(posix_fallocate, HAVE_POSIX_FALLOCATE=YES, [HAVE_POSIX_FALLOCATE=NO])
AC_SUBST(HAVE_POSIX_FALLOCATE)
AC_SUBST(ALLOC)

dnl ===================================================================
dnl Custom build version
dnl ===================================================================

AC_MSG_CHECKING([whether to add custom build version])
if test "$with_build_version" != ""; then
    BUILD_VER_STRING=$with_build_version
    AC_MSG_RESULT([yes, $BUILD_VER_STRING])
else
    BUILD_VER_STRING=
    AC_MSG_RESULT([no])
fi
AC_SUBST(BUILD_VER_STRING)

dnl ===================================================================
dnl Java support enable
dnl ===================================================================
AC_MSG_CHECKING([whether to build with Java support])
if test "$with_java" != "no"; then
    if test "$DISABLE_SCRIPTING" = TRUE; then
        AC_MSG_RESULT([no, overridden by --disable-scripting])
        SOLAR_JAVA=""
        with_java=no
    else
        AC_MSG_RESULT([yes])
        SOLAR_JAVA="TRUE"
    fi
else
    AC_MSG_RESULT([no])
    SOLAR_JAVA=""
fi

AC_SUBST(SOLAR_JAVA)

dnl SOLAR_JAVA="YES" (yes, silly name, should rename) indicates whether we
dnl want there to be *run-time* (and build-time) support for Java extensions in the
dnl built LibreOffice.

dnl SOLAR_JAVA="BUILD" is claimed to indicate build-time only support
dnl (no runtime support). It doesn't seem to ever be set to this
dnl value, though, and everywhere SOLAR_JAVA is only checked for being
dnl empty or non-empty.

dnl SOLAR_JAVA="" indicate no java support at all

JITC_PROCESSOR_TYPE=""
if test "$_os" = "Linux" -a "$host_cpu" = "powerpc"; then
    # IBMs JDK needs this...
    JITC_PROCESSOR_TYPE=6
    export JITC_PROCESSOR_TYPE
fi
AC_SUBST([JITC_PROCESSOR_TYPE])

if test $_os = "WINNT"; then
    SCPDEFS="$SCPDEFS -DWITH_VC_REDIST"
fi
AC_SUBST(WITH_VC_REDIST)

dnl ===================================================================
dnl Checks for Java
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then

    # Windows-specific tests
    if test "$build_os" = "cygwin" -a "$_os" = "WINNT"; then
        if test "$CL_X64" != ""; then
            bitness="64-bit"
            otherbitness="32-bit"
        else
            bitness="32-bit"
            otherbitness="64-bit"
        fi

        if test -z "$with_jdk_home"; then

            # Unfortunately apparently no way to find, if needed, the 64-bit
            # JDK in the Registry from the 32-bit Perl oowintool

            _jdk_home=`./oowintool --jdk-home`
            if test -f "$_jdk_home/lib/jvm.lib" -a -f "$_jdk_home/bin/java.exe"; then
                with_jdk_home="$_jdk_home"
                howfound="found by oowintool"
            else
                AC_MSG_ERROR([No JDK found by oowintool, pass the --with-jdk-home option pointing to a $bitness JDK])
            fi
        else
            test "$build_os" = "cygwin" && with_jdk_home=`cygpath -u "$with_jdk_home"`
            howfound="you passed"
        fi
    fi

    JAVA_HOME=; export JAVA_HOME
    if test -z "$with_jdk_home"; then
        AC_PATH_PROG(JAVAINTERPRETER, $with_java)
    else
        _java_path="$with_jdk_home/bin/$with_java"
        dnl Check if there is a Java interpreter at all.
        if test -x "$_java_path"; then
            JAVAINTERPRETER=$_java_path
        else
            AC_MSG_ERROR([$_java_path not found, pass --with-jdk-home])
        fi
    fi

    if test "$build_os" = "cygwin" -a "$_os" = "WINNT"; then
        # Check that the JDK found is correct architecture
        # Why is this necessary, we don't link with any library from the JDK I think,

        shortjdkhome=`cygpath -d "$with_jdk_home"`
        if test "$CL_X64" != "" -a -f "$with_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" = "" >/dev/null; then
            AC_MSG_WARN([You are building 64-bit binaries but the JDK $howfound is 32-bit])
            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a 64-bit JDK])
        elif test "$CL_X64" = "" -a -f "$_jdk_home/bin/java.exe" -a "`$shortjdkhome/bin/java.exe -version 2>&1 | $GREP -i 64-bit`" != ""  >/dev/null; then
            AC_MSG_WARN([You are building 32-bit binaries but the JDK $howfound is 64-bit])
            AC_MSG_ERROR([You should pass the --with-jdk-home option pointing to a (32-bit) JDK])
        fi

        if test x`echo "$JAVAINTERPRETER" | $GREP -i '\.exe$'` = x; then
            JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
        fi
        JAVAINTERPRETER=`cygpath -d "$JAVAINTERPRETER"`
        JAVAINTERPRETER=`cygpath -u "$JAVAINTERPRETER"`
    elif test "$_os" = "Darwin"; then
        dnl HACK:  There currently is only a 32 bit version of LibreOffice for Mac OS X,
        dnl and Tiger Java complains about -d32 while Snow Leopard Java needs it
        dnl to run in 32 bit mode and be able to load LibreOffice jnilibs:
        AC_MSG_CHECKING([whether to pass -d32 to Java interpreter])
        if "$JAVAINTERPRETER" -d32 >&5 2>&5; then
            AC_MSG_RESULT([yes])
            JAVAIFLAGS=-d32
        else
            AC_MSG_RESULT([no])
        fi
    fi
fi

dnl ===================================================================
dnl Checks for JDK.
dnl ===================================================================

# Note that JAVA_HOME as for now always means the *build* platform's
# JAVA_HOME. Whether all the complexity here actually is needed any
# more or not, no idea.

if test "$SOLAR_JAVA" != ""; then
    _gij_longver=0
    AC_MSG_CHECKING([the installed JDK])
    if test -n "$JAVAINTERPRETER"; then
        dnl java -version sends output to stderr!
        if test `$JAVAINTERPRETER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.in])
        elif test `$JAVAINTERPRETER --version 2>&1 | $GREP -c "GNU libgcj"` -gt 0; then
            JDK=gcj
            AC_MSG_RESULT([checked (gcj)])
            _gij_version=`$JAVAINTERPRETER --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
            _gij_longver=`echo $_gij_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`

        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "BEA"` -gt 0; then
            AC_MSG_ERROR([No valid check available. Please check the block for your desired java in configure.in])
        elif test `$JAVAINTERPRETER -version 2>&1 | $AWK '{ print }' | $GREP -c "IBM"` -gt 0; then
            JDK=ibm

            dnl IBM JDK specific tests
            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`

            if test "$_jdk_ver" -lt 10500; then
                AC_MSG_ERROR([IBM JDK is too old, you need at least 1.5])
            fi

            AC_MSG_RESULT([checked (IBM JDK $_jdk)])

            if test "$with_jdk_home" = ""; then
                AC_MSG_ERROR([In order to successfully build LibreOffice using the IBM JDK,
you must use the "--with-jdk-home" configure option explicitly])
            fi

           JAVA_HOME=$with_jdk_home

        else
            JDK=sun

            dnl Sun JDK specific tests
            _jdk=`$JAVAINTERPRETER -version 2>&1 | $AWK -F'"' '{ print \$2 }' | $SED s/[[-A-Za-z]]*//`
            _jdk_ver=`echo "$_jdk" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`

            if test "$_jdk_ver" -lt 10500; then
                AC_MSG_ERROR([JDK is too old, you need at least 1.5])
            fi
            AC_MSG_RESULT([checked (JDK $_jdk)])
            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
            if test "$_os" = "WINNT"; then
                JAVA_HOME=`echo $JAVA_HOME | $SED "s,\.[[eE]][[xX]][[eE]]$,,"`
            fi
        fi
    else
        AC_MSG_ERROR([Java not found. You need at least jdk-1.5, or gcj-4])
    fi
else
    dnl Java disabled
    JAVA_HOME=NO_JAVA_HOME ; export JAVA_HOME
fi

_java_target_ver="1.5"
dnl ===================================================================
dnl Check for target Java bytecode version
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    AC_MSG_CHECKING([for target Java bytecode version])
    if test "$JDK" = "gcj" -o "$JDK" = "kaffe"; then
    AC_MSG_RESULT([default by $JDK])
    if test -n "$with_java_target_version" -a "$with_java_target_version" != "no"; then
        AC_MSG_WARN([Value defined by --with-java-target-version is ignored!])
    fi
    else
    if test -n "$with_java_target_version" -a "$with_java_target_version" != "no"; then
        _java_target_ver="$with_java_target_version"
        AC_MSG_RESULT([$_java_target_ver])
    elif test $_jdk_ver -gt 10000; then
        _java_target_ver=`echo "$_jdk_ver" | $AWK '{ maj=substr($0,1,1); min=substr($0,2,2); print int(maj)"."int(min) }'`
        AC_MSG_RESULT([$_java_target_ver])
    else
        AC_MSG_ERROR([Unable to guess Java bytecode version from Java version!])
    fi
    fi

    JAVA_SOURCE_VER="$_java_target_ver"
    JAVA_TARGET_VER="$_java_target_ver"
fi

dnl ===================================================================
dnl Checks for javac
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    if test "$JDK" = "gcj"; then
        javacompiler=`echo $with_java | $SED -e "s/gij/gcj/g" | $SED -e "s/java/javac/g"`
    else
        javacompiler="javac"
    fi
    if test -z "$with_jdk_home"; then
        AC_PATH_PROG(JAVACOMPILER, $javacompiler)
    else
        _javac_path="$with_jdk_home/bin/$javacompiler"
        dnl Check if there is a Java compiler at all.
        if test -x "$_javac_path"; then
            JAVACOMPILER=$_javac_path
        fi
    fi
    if test -z "$JAVACOMPILER"; then
        AC_MSG_ERROR([$javacompiler not found set with_jdk_home])
    fi
    if test "$build_os" = "cygwin" -a "$_os" = "WINNT"; then
        if test x`echo "$JAVACOMPILER" | $GREP -i '\.exe$'` = x; then
            JAVACOMPILER="${JAVACOMPILER}.exe"
        fi
        JAVACOMPILER=`cygpath -d "$JAVACOMPILER"`
        JAVACOMPILER=`cygpath -u "$JAVACOMPILER"`
    fi

    if test `$JAVACOMPILER -version 2>&1 | $GREP -c "Eclipse Java Compiler"` -gt 0; then
        AC_MSG_CHECKING([re-checking JDK])
        JDK=gcj
        AC_MSG_RESULT([checked (ecj)])
        #TODO: what's to do here? some switch to do 1.5 compiling?
        JAVAFLAGS="-source 1.5 -target 1.5"
        _gij_longver="40200"
    fi
fi

JAVACISGCJ=""
dnl ===================================================================
dnl Checks that javac is gcj
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    if test `$JAVACOMPILER --version 2>&1 | $GREP -c "GCC"` -gt 0; then
        JAVACISGCJ="yes"
    fi
fi
AC_SUBST(JAVACISGCJ)

JAVACISKAFFE=""
dnl ===================================================================
dnl Checks that javac is kaffe
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    if test `$JAVACOMPILER -version 2>&1 | $GREP -c "Kaffe"` -gt 0; then
        JAVACISKAFFE="yes"
    fi
fi
AC_SUBST(JAVACISKAFFE)

dnl ===================================================================
dnl Checks for javadoc
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    if test -z "$with_jdk_home"; then
        AC_PATH_PROG(JAVADOC, javadoc)
    else
        _javadoc_path="$with_jdk_home/bin/javadoc"
        dnl Check if there is a javadoc at all.
        if test -x "$_javadoc_path"; then
            JAVADOC=$_javadoc_path
        else
            AC_PATH_PROG(JAVADOC, javadoc)
        fi
    fi
    if test -z "$JAVADOC"; then
        AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home])
    fi
    if test "$build_os" = "cygwin" -a "$_os" = "WINNT"; then
        if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then
            JAVADOC="${JAVADOC}.exe"
        fi
        JAVADOC=`cygpath -d "$JAVADOC"`
        JAVADOC=`cygpath -u "$JAVADOC"`
    fi
fi

if test "$SOLAR_JAVA" != ""; then
    # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr
    if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then
        if basename $(readlink $(readlink $JAVACOMPILER)) >/dev/null 2>/dev/null; then
           # try to recover first by looking whether we have a alternatives
           # system as in Debian or newer SuSEs where following /usr/bin/javac
           # over /etc/alternatives/javac leads to the right bindir where we
           # just need to strip a bit away to get a valid JAVA_HOME
           JAVA_HOME=$(readlink $(readlink $JAVACOMPILER))
        elif readlink $JAVACOMPILER >/dev/null 2>/dev/null; then
            # maybe only one level of symlink (e.g. on Mac)
            JAVA_HOME=$(readlink $JAVACOMPILER)
            if test "$(dirname $JAVA_HOME)" = "."; then
                # we've got no path to trim back
                JAVA_HOME=""
            fi
        else
            # else warn
            AC_MSG_WARN([JAVA_HOME is set to /usr - this is very likely to be incorrect])
            AC_MSG_WARN([if this is the case, please inform the correct JAVA_HOME with --with-jdk-home])
            echo "JAVA_HOME is set to /usr - this is very likely to be incorrect" >> warn
            echo "if this is the case, please inform the correct JAVA_HOME with --with-jdk-home" >> warn
        fi
        dnl now that we have the path to the real javac, make a JAVA_HOME out of it..
        if test "$JAVA_HOME" != "/usr"; then
            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
                dnl Leopard returns a non-suitable path with readlink - points to "Current" only
                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/Current/Commands/javac$,/CurrentJDK/Home,)
                dnl Tiger already returns a JDK path..
                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
            else
                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
            fi
        fi
    fi
    # as we drop out of this, JAVA_HOME may have been set to the empty string by readlink

    dnl now if JAVA_HOME has been set to empty, then call findhome to find it
    if test -z "$JAVA_HOME"; then
        if test "x$with_jdk_home" = "x"; then
            cat > findhome.java <<_ACEOF
[import java.io.File;

class findhome
{
    public static void main(String args[])
    {
        String jrelocation = System.getProperty("java.home");
        File jre = new File(jrelocation);
        System.out.println(jre.getParent());
    }
}]
_ACEOF
            AC_MSG_CHECKING([if javac works])
            javac_cmd="$JAVACOMPILER findhome.java 1>&2"
            AC_TRY_EVAL(javac_cmd)
            if test $? = 0 -a -f ./findhome.class; then
                AC_MSG_RESULT([javac works])
            else
                echo "configure: javac test failed" >&5
                cat findhome.java >&5
                AC_MSG_ERROR([javac does not work - java projects will not build!])
            fi
            AC_MSG_CHECKING([if gij knows its java.home])
            JAVA_HOME=`$JAVAINTERPRETER findhome`
            if test $? = 0 -a "$JAVA_HOME" != ""; then
                AC_MSG_RESULT([$JAVA_HOME])
            else
                echo "configure: java test failed" >&5
                cat findhome.java >&5
                AC_MSG_ERROR([gij does not know its java.home - use --with-jdk-home])
            fi
            # clean-up after ourselves
            rm -f ./findhome.java ./findhome.class
        else
            JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*$with_java,,p"`
        fi
    fi

    dnl second sanity check JAVA_HOME if possible
    if test "$JDK" != "gcj" -o "$_gij_longver" -ge "40200"; then
        # now check if $JAVA_HOME is really valid
        if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
            if test ! -f "$JAVA_HOME/lib/jvm.cfg" -a "x$with_jdk_home" = "x"; then
                JAVA_HOME_OK="NO"
            fi
        elif test ! -d "$JAVA_HOME/jre" -a "x$with_jdk_home" = "x"; then
            JAVA_HOME_OK="NO"
        fi
        if test "$JAVA_HOME_OK" = "NO"; then
            AC_MSG_WARN([JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script])
            AC_MSG_WARN([attempted to find JAVA_HOME automatically, but apparently it failed])
            AC_MSG_WARN([in case JAVA_HOME is incorrectly set, some projects with not be built correctly])
            echo "JAVA_HOME was not explicitly informed with --with-jdk-home. the configure script" >> warn
            echo "attempted to find JAVA_HOME automatically, but apparently it failed" >> warn
            echo "in case JAVA_HOME is incorrectly set, some projects with not be built correctly" >> warn
        fi
    fi
    PathFormat "$JAVA_HOME"
    JAVA_HOME="$formatted_path"
fi

AWTLIB=

if test "$SOLAR_JAVA" != ""; then
    AC_MSG_CHECKING([for jawt lib name])
    if test "$JDK" = "gcj"; then
        save_CFLAGS=$CFLAGS
        save_LDFLAGS=$LDFLAGS
        CFLAGS="$CFLAGS -I$JAVA_HOME/include"
        LDFLAGS="$LDFLAGS -L$JAVA_HOME/lib -lgcj"
        exec 6>/dev/null # no output
        AC_CHECK_HEADER(jni.h, [],
                    [AC_MSG_ERROR([jni.h could not be found. Mismatch between gcc and libgcj or libgcj-devel missing?])], [])
        AC_CHECK_LIB(gcjawt, JAWT_GetAWT, [ AWTLIB="-lgcjawt -lgcj"] )
        exec 6>&1 # output on again
        CFLAGS=$save_CFLAGS
        LDFLAGS=$save_LDFLAGS
    fi
    # IBM SDK 1.5.0-sr5 includes libjawt.so with unresolved symbols.
    # A workaround is to link also against libpmawt.so
    if test "$JDK" = "ibm"; then
        save_CFLAGS=$CFLAGS
        save_LDFLAGS=$LDFLAGS
        save_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
        CFLAGS="$CFLAGS -I$JAVA_HOME/include"
        LDFLAGS="$LDFLAGS -L$JAVA_HOME/jre/bin"
        LD_LIBRARY_PATH=$JAVA_HOME/jre/bin:$JAVA_HOME/jre/bin/classic:$JAVA_HOME/jre/bin/xawt:$LD_LIBRARY_PATH
        export LD_LIBRARY_PATH
        exec 6>/dev/null # no output
        AC_CHECK_HEADER(jni.h, [],
                    [AC_MSG_ERROR([jni.h could not be found.])], [])
        AC_CHECK_LIB(jawt, JAWT_GetAWT, [ AWTLIB="-ljawt"] )
        if test -z "$AWTLIB"; then
            LDFLAGS="$LDFLAGS -L$JAVA_HOME/jre/bin/xawt -ljawt"
            AC_CHECK_LIB(mawt, JAWT_GetAWT, [ AWTLIB="-L$JAVA_HOME/jre/bin/xawt -ljawt -lmawt"])
        fi
        exec 6>&1 # output on again
        CFLAGS=$save_CFLAGS
        LDFLAGS=$save_LDFLAGS
        LD_LIBRARY_PATH=$save_LD_LIBRARY_PATH
    fi
    if test -z "$AWTLIB"; then
        AWTLIB=-ljawt
    fi
    AC_MSG_RESULT([$AWTLIB])
    AC_SUBST(AWTLIB)
fi


if test "$SOLAR_JAVA" != ""; then
#
# Determine JAVALIB
# If your platform follow the common pattern
# just define JAVA_ARCH and JAVA_TOOLKIT for it
# if not, leave JAVA_ARCH empty and define JAVALIB manually
# if you don't want JAVALIB to be exported at all
# define x_JAVALIB=[\#]
#
    JAVA_ARCH=
    JAVA_TOOLKIT=
    x_JAVALIB=
    x_JDKLIB=[\#]

    case "$host_os" in

    aix*)
        JAVA_ARCH="ppc"
        JAVA_TOOLKIT="classic"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/aix"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    cygwin*)
        x_JDKLIB=
        JDKLIB="$JAVA_HOME/lib"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/win32"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        ;;

    darwin*)
        x_JAVALIB=[\#]
        SOLARINC="$SOLARINC -I$FRAMEWORKSHOME/JavaVM.framework/Versions/Current/Headers -I$FRAMEWORKSHOME/JavaVM/Headers"
        ;;

    dragonfly*)
        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            JAVA_TOOLKIT="client"
            ;;
        x86_64)
            JAVA_ARCH="amd64"
            JAVA_TOOLKIT="server"
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    freebsd*)
        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            JAVA_TOOLKIT="client"
            ;;
        x86_64)
            if test "`echo $JAVA_HOME | sed -e 's,.*/,,'`" = "linux"; then
                JAVA_ARCH="i386"
                JAVA_TOOLKIT="client"
            else
                JAVA_ARCH="amd64"
                JAVA_TOOLKIT="server"
            fi
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/freebsd"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/bsd"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/linux"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    k*bsd*-gnu*)
        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            JAVA_TOOLKIT="client"
            ;;
        x86_64)
            JAVA_ARCH="amd64"
            JAVA_TOOLKIT="server"
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    linux-gnu*)

        case "$host_cpu" in

        alpha)
            JAVA_ARCH="alpha"
            JAVA_TOOLKIT="server"
            ;;
        arm*)
            JAVA_ARCH="arm"
            JAVA_TOOLKIT="server"
            ;;
        hppa)
            JAVA_ARCH="hppa"
            JAVA_TOOLKIT="server"
            ;;
        i*86)
            JAVA_ARCH="i386"
            case "$JDK" in
            [Ii][Bb][Mm]*)
                JAVA_ARCH=
                JRE_BASE_DIR="$JAVA_HOME/jre/bin"
                JAVALIB="-L$JAVA_HOME/$LIB64 -L$JRE_BASE_DIR -L$JRE_BASE_DIR/classic -L$JRE_BASE_DIR/native_thread"
                ;;
            [Bb][Ee][Aa]*)
                JAVA_TOOLKIT="jrockit";
                ;;
            *)
                JAVA_TOOLKIT="client";
                ;;
            esac
            ;;
        ia64)
            JAVA_ARCH="ia64"
            JAVA_TOOLKIT="server"
            ;;
        m68k)
            JAVA_ARCH="mk68"
            JAVA_TOOLKIT="server"
            ;;
        mips|mips64|mipsel|mips64el)
            JAVA_ARCH="$host_cpu"
            JAVA_TOOLKIT="server"
            ;;
        mips32)
            JAVA_ARCH="$host_cpu"
            JAVA_TOOLKIT="client"
            ;;
        powerpc)
            JAVA_ARCH="ppc"
            case "$JDK" in
            [Ii][Bb][Mm]*)
                JAVA_TOOLKIT="classic"
                ;;
            gcj)
                JAVA_TOOLKIT="client"
                ;;
            *)
                JAVA_TOOLKIT="server"
                ;;
            esac
            ;;
        powerpc64)
            JAVA_ARCH="ppc64"
            if test "$JDK" = "gcj"; then
                JAVA_TOOLKIT="client"
            else
                JAVA_TOOLKIT="server"
            fi
            ;;
        sparc)
            JAVA_ARCH="sparc"
            JAVA_TOOLKIT="server"
            ;;
        s390)
            JAVA_ARCH="s390"
            JAVA_TOOLKIT="server"
            ;;
        s390x)
            JAVA_ARCH="s390x"
            JAVA_TOOLKIT="server"
            ;;
        x86_64)
            JAVA_ARCH="amd64"
            JAVA_TOOLKIT="server"
            ;;
        *)
            AC_MSG_ERROR([No JAVALIB definition host_cpu $host_cpu for host_os $host_os])
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/linux"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    linux-androideabi*)

        case "$host_cpu" in

    arm|armel)
            JAVA_ARCH="arm"
            JAVA_TOOLKIT="server"
            ;;
        esac
        ;;

    mingw*)
        x_JAVALIB=[\#]
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        ;;

    *netbsd*)

        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            JAVA_TOOLKIT="client"
            ;;
        powerpc)
            JAVA_ARCH="pcc"
            JAVA_TOOLKIT="classic"
            ;;
        sparc)
            JAVA_ARCH="sparc"
            JAVA_TOOLKIT="client"
            ;;
        x86_64)
            JAVA_ARCH="amd64"
            JAVA_TOOLKIT="client"
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/netbsd"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
       ;;

    openbsd*)
        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            JAVA_TOOLKIT="client"
            ;;
        x86_64)
            JAVA_ARCH="amd64"
            JAVA_TOOLKIT="server"
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/openbsd"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;

    solaris*)

        JAVA_TOOLKIT="xawt"
        case "$host_cpu" in
        i*86)
            JAVA_ARCH="i386"
            ;;
        sparc)
            JAVA_ARCH="sparc"
            ;;
        esac
        SOLARINC="$SOLARINC -I$JAVA_HOME/include"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/solaris"
        SOLARINC="$SOLARINC -I$JAVA_HOME/include/native_threads/include"
        ;;
    esac

    if test -n "$JAVA_ARCH"; then
        JRE_BASE_DIR="$JAVA_HOME/jre/lib/$JAVA_ARCH"
        JAVALIB="-L$JAVA_HOME/$LIB64"
        test -d "$JRE_BASE_DIR" && JAVALIB="$JAVALIB -L$JRE_BASE_DIR"
        test -d "$JRE_BASE_DIR/$JAVA_TOOLKIT" && JAVALIB="$JAVALIB -L$JRE_BASE_DIR/$JAVA_TOOLKIT"
        test -d "$JRE_BASE_DIR/native_thread" && JAVALIB="$JAVALIB -L$JRE_BASE_DIR/native_thread"
    fi

    CLASSPATH=
    if test "$JDK"!="gcj"; then
        if test -f "$JAVA_HOME/jre/lib/rt.jar"; then
            CLASSPATH="${JAVA_HOME}/jre/lib/rt.jar${P_SEP}."
        fi
    fi
    XCLASSPATH="$CLASSPATH"
else
    x_JAVALIB=[\#]
    x_JDKLIB=[\#]
fi

AC_SUBST(CLASSPATH)
AC_SUBST(JAVALIB)
AC_SUBST(JAVACOMPILER)
AC_SUBST(JAVADOC)
AC_SUBST(JAVAFLAGS)
AC_SUBST(JAVAINTERPRETER)
AC_SUBST(JAVAIFLAGS)
AC_SUBST(JAVA_HOME)
AC_SUBST(JAVA_SOURCE_VER)
AC_SUBST(JAVA_TARGET_VER)
AC_SUBST(JDK)
AC_SUBST(JDKLIB)
AC_SUBST(XCLASSPATH)
AC_SUBST(x_JAVALIB)
AC_SUBST(x_JDKLIB)

dnl ===================================================================
dnl Checks for specific files.
dnl ===================================================================

dnl ===================================================================
dnl Checks for programs.
dnl ===================================================================

dnl ===================================================================
dnl Check whether we already have dmake
dnl ===================================================================
AC_PATH_PROG(DMAKE, dmake, no)
if test "$DMAKE" = "no"; then
    BUILD_DMAKE=YES
    echo "dmake will be built on ./bootstrap"
else
    AC_MSG_CHECKING([whether the found dmake is the right dmake])
    # we need to find out whether that dmake we found is "our" dmake
    # or the dmake from Sun's SunStudio Compiler which is something
    # different
    # This test _should_ work because the one accepts -V (ours) and one
    # (the other) not...
    $DMAKE -V 2>/dev/null | grep 'dmake .* Version .*' >/dev/null
    if test $? -eq 0; then
        BUILD_DMAKE=NO
        AC_MSG_RESULT([yes])
        AC_MSG_CHECKING([the dmake version])
        DMAKE_VERSION=`$DMAKE -V | $AWK '$3 == "Version" {print $4}'`
        if test "`echo $DMAKE_VERSION | cut -d'.' -f1`" -gt "4"; then
            AC_MSG_RESULT([OK, >= 4.11])
        elif test "`echo $DMAKE_VERSION | cut -d'.' -f1`" = "4" && \
            test "`echo $DMAKE_VERSION | cut -d'.' -f2`" -ge "11"; then
            AC_MSG_RESULT([OK, >= 4.11])
        else
            AC_MSG_RESULT([too old. >= 4.11 is needed])
            echo "A newer dmake will be built on ./bootstrap"
            BUILD_DMAKE=YES
        fi
    else
        AC_MSG_RESULT([no])
        echo "dmake will be built on ./bootstrap"
        BUILD_DMAKE=YES
    fi
fi
AC_SUBST(BUILD_DMAKE)

AC_MSG_CHECKING([whether to enable EPM for packing])
BUILD_EPM=NO
if test "$enable_epm" = "yes"; then
    AC_MSG_RESULT([yes])
    dnl ===================================================================
    dnl Check for epm - not needed for Windows
    dnl ===================================================================
    if test "$_os" != "WINNT"; then
        if test -n "$with_epm"; then
            EPM=$with_epm
        else
            AC_PATH_PROG(EPM, epm, no)
        fi
        if test "$EPM" = "no" -o "$EPM" = "internal"; then
            echo "EPM will be built."
            BUILD_EPM=YES
            BUILD_TYPE="$BUILD_TYPE EPM"
        else
            # Gentoo has some epm which is something different...
            AC_MSG_CHECKING([whether the found epm is the right epm])
            if $EPM | grep "ESP Package Manager" >/dev/null 2>/dev/null; then
                AC_MSG_RESULT([yes])
            else
                AC_MSG_ERROR([no. Install ESP Package Manager (www.easysw.com/epm) and/or specify the path to the right epm])
            fi
            AC_MSG_CHECKING([epm version])
            EPM_VERSION=`$EPM | grep 'ESP Package Manager' | cut -d' ' -f4 | $SED -e s/v//`
            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -gt "3" || \
               test "`echo $EPM_VERSION | cut -d'.' -f1`" -eq "3" -a "`echo $EPM_VERSION | cut -d'.' -f2`" -ge "7"; then
                AC_MSG_RESULT([OK, >= 3.7])
                BUILD_EPM=NO
                if test "$_os" = "Darwin"; then
                    AC_MSG_CHECKING([which PackageMaker EPM thinks to use])
                    _pm=`strings $EPM | grep PackageMaker | cut -d" " -f1`
                    if test "$_pm" = "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; then
                        AC_MSG_ERROR([$_pm; PackageMaker expected in wrong path. Either patch your epm with the right path (/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker) or use internal patched epm (--with-epm=internal)])
                    elif test "$_pm" = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"; then
                        AC_MSG_RESULT([$_pm, ok])
                    else # we never should get here, but go safe
                        AC_MSG_ERROR([$_pm; PackageMaker expected in unknown path. Either patch your epm with the right path (/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker) or use internal patched epm (--with-epm=internal)])
                    fi
                fi
            else
                AC_MSG_RESULT([too old. epm >= 3.7 is required.])
                echo "EPM will be built."
                BUILD_EPM=YES
                BUILD_TYPE="$BUILD_TYPE EPM"
            fi
        fi
    fi

    # test which package format to use
    AC_MSG_CHECKING([which package format to use])

    # defaults
    case "$_os" in
    Darwin)
        PKGFORMAT=dmg
        ;;
    SunOS)
        PKGFORMAT=pkg
        ;;
    Linux)
        # if building on Debian, default should be deb...
        if test -e /etc/debian_version; then
            PKGFORMAT=deb
        else
            PKGFORMAT=rpm
        fi
        ;;
    AIX)
        PKGFORMAT=rpm
        ;;
    OpenBSD|DragonFly)
        PKGFORMAT=portable
        ;;
    *BSD)
        PKGFORMAT=bsd
        ;;
    WINNT)
        PKGFORMAT=msi
        ;;
    # we never should get here since we check the arciecture/os at the beginning,
    # but go sure...
    *)
        AC_MSG_ERROR([unknown system])
    esac
    if test -n "$with_package_format"; then
        for i in $with_package_format; do
            case "$i" in
            aix | bsd | deb | inst | tardist | osx | pkg | rpm | setld | native | portable | archive | dmg | installed | msi)
                ;;
            *)
                AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
aix - AIX software distribution
bsd - FreeBSD, NetBSD, or OpenBSD software distribution
deb - Debian software distribution
inst or tardist - IRIX software distribution
osx - MacOS X software distribution
pkg - Solaris software distribution
rpm - RedHat software distribution
setld - Tru64 (setld) software distribution
native - "Native" software distribution for the platform
portable - Portable software distribution
LibreOffice additionally supports:
archive - .tar.gz or .zip
dmg - Mac OS X .dmg
installed - installation tree
msi - Windows .msi
            ])
                ;;
            esac
        done
        PKGFORMAT="$with_package_format"
    fi
    AC_MSG_RESULT([$PKGFORMAT])
    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null; then
        AC_MSG_CHECKING([for rpm])
        for a in "$RPM" rpmbuild rpm; do
            $a --usage >/dev/null 2> /dev/null
            if test $? -eq 0; then
                RPM=$a
                break
            else
                $a --version >/dev/null 2> /dev/null
                if test $? -eq 0; then
                    RPM=$a
                    break
                fi
            fi
        done
        if test -z "$RPM"; then
            AC_MSG_ERROR([not found])
        elif "$RPM" --help 2>&1 | $EGREP buildroot >/dev/null; then
            RPM_PATH=`which $RPM`
            AC_MSG_RESULT([$RPM_PATH])
        else
            AC_MSG_ERROR([cannot build packages. Try installing rpmbuild.])
        fi
    fi
    if echo "$PKGFORMAT" | $EGREP deb 2>&1 >/dev/null; then
        AC_PATH_PROG(DPKG, dpkg, no)
        if test "$DPKG" = "no"; then
            AC_MSG_ERROR([dpkg needed for deb creation. Install dpkg.])
        fi
    fi
    if echo "PKGFORMAT" | $EGREP osx 2>&1 >/dev/null; then
        if test "$_os" = "Darwin"; then
            AC_MSG_CHECKING([for PackageMaker availability])
            if ! test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker; then
                AC_MSG_ERROR([not installed. Please install Apples Dev Tools])
            else
                AC_MSG_RESULT([ok])
            fi
        else
            AC_MSG_ERROR([PackageMaker needed to build OSX packages and you are not on OSX...])
        fi
    fi
    if echo "$PKGFORMAT" | $EGREP rpm 2>&1 >/dev/null || \
       echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
        if test "$EPM" != "no" -a "$EPM" != "internal"; then
            if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
                AC_MSG_CHECKING([whether epm is patched for LibreOffice's needs])
                if grep "Patched for LibreOffice" $EPM >/dev/null 2>/dev/null; then
                    AC_MSG_RESULT([yes])
                else
                    AC_MSG_RESULT([no])
                    if echo "$PKGFORMAT" | $GREP -q rpm; then
                        _pt="rpm"
                        AC_MSG_WARN([the rpms will need to be installed with --nodeps])
                        echo "the rpms will need to be installed with --nodeps" >> warn
                    else
                        _pt="pkg"
                    fi
                    AC_MSG_WARN([the ${_pt}s will not be relocateable])
                    echo "the ${_pt}s will not be relocateable" >> warn
                    AC_MSG_WARN([if you want to make sure installation without --nodeps and
                                 relocation will work, you need to patch your epm with the
                                 patch in epm/epm-3.7.patch or build with
                                 --with-epm=internal which will build a suitable epm])
                fi
            fi
        fi
    fi
    if echo "$PKGFORMAT" | $EGREP pkg 2>&1 >/dev/null; then
        AC_PATH_PROG(PKGMK, pkgmk, no)
        if test "$PKGMK" = "no"; then
            AC_MSG_ERROR([pkgmk needed for Solaris pkg creation. Install it.])
        fi
    fi
    AC_SUBST(RPM)
    AC_SUBST(DPKG)
    AC_SUBST(PKGMK)
else
    AC_MSG_RESULT([no])
    EPM=NO
    PKGFORMAT=native
fi
AC_SUBST(EPM)
AC_SUBST(BUILD_EPM)
AC_SUBST(PKGFORMAT)

dnl ===================================================================
dnl Check for gperf
dnl ===================================================================
AC_PATH_PROG(GPERF, gperf)
if test -z "$GPERF"; then
    AC_MSG_ERROR([gperf not found but needed. Install it.])
fi
AC_MSG_CHECKING([gperf version])
if test "`$GPERF --version | $EGREP ^GNU\ gperf | $AWK '{ print $3 }' | cut -d. -f1`" -ge "3"; then
    AC_MSG_RESULT([OK])
else
    AC_MSG_ERROR([too old, you need at least 3.0.0])
fi
AC_SUBST(GPERF)

dnl ===================================================================
dnl Check for building ODK
dnl ===================================================================
AC_MSG_CHECKING([whether to build the ODK])
if test "$enable_odk" = "" -o "$enable_odk" != "no"; then
    AC_MSG_RESULT([yes])

    if test "$with_java" != "no"; then
        AC_MSG_CHECKING([whether to build unowinreg.dll])
        if test "$_os" = "WINNT" -a "$enable_build_unowinreg" = ""; then
            # build on Win by default
            enable_build_unowinreg=yes
        fi
        if test "$enable_build_unowinreg" = "" -o "$enable_build_unowinreg" = "no"; then
            AC_MSG_RESULT([no])
            BUILD_UNOWINREG=NO
        else
            AC_MSG_RESULT([yes])
            BUILD_UNOWINREG=YES
        fi
        if test "$_os" != "WINNT" -a "$BUILD_UNOWINREG" = "YES"; then
            if test -z "$with_mingw_cross_compiler"; then
                dnl Guess...
                AC_CHECK_PROGS(MINGWCXX,i386-mingw32msvc-g++ i586-pc-mingw32-g++ i686-pc-mingw32-g++ i686-w64-mingw32-g++,false)
            elif test -x "$with_mingw_cross_compiler"; then
                 MINGWCXX="$with_mingw_cross_compiler"
            else
                AC_CHECK_TOOL(MINGWCXX, "$with_mingw_cross_compiler", false)
            fi

            if test "$MINGWCXX" = "false"; then
                AC_MSG_ERROR([MinGW32 C++ cross-compiler not found.])
            fi

            mingwstrip_test="`echo $MINGWCXX | $SED -e s/g++/strip/`"
            if test -x "$mingwstrip_test"; then
                MINGWSTRIP="$mingwstrip_test"
            else
                AC_CHECK_TOOL(MINGWSTRIP, "$mingwstrip_test", false)
            fi

            if test "$MINGWSTRIP" = "false"; then
                AC_MSG_ERROR(MinGW32 binutils not found.)
            fi
        fi
    fi
    BUILD_TYPE="$BUILD_TYPE ODK"
else
    AC_MSG_RESULT([no])
    BUILD_UNOWINREG=NO
fi
AC_SUBST(BUILD_UNOWINREG)
AC_SUBST(MINGWCXX)
AC_SUBST(MINGWSTRIP)

dnl ===================================================================
dnl Check for system stdlibs
dnl ===================================================================
AC_MSG_CHECKING([whether to provide libstdc++/libgcc_s in the installset])
if test "$with_system_stdlibs" != "no"; then
    AC_MSG_RESULT([no])
    SYSTEM_STDLIBS=YES
else
    AC_MSG_RESULT([yes])
    SYSTEM_STDLIBS=NO
fi
AC_SUBST(SYSTEM_STDLIBS)

dnl ===================================================================
dnl Check for system zlib
dnl ===================================================================
if test "$with_system_zlib" = "auto"; then
    case "$_os" in
    WINNT)
        with_system_zlib="$with_system_libs"
        ;;
    *)
        with_system_zlib=yes
        ;;
    esac
fi

AC_MSG_CHECKING([which zlib to use])
if test "$with_system_zlib" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_ZLIB=YES
    AC_CHECK_HEADER(zlib.h, [],
        [AC_MSG_ERROR(zlib.h not found. install zlib)], [])
    AC_CHECK_LIB(z, deflate, [ ZLIB=-lz ],
        [AC_MSG_ERROR(zlib not found or functional)], [])
    if test "$WITH_MINGW" = "yes"; then
        # we need minizip too
        PKG_CHECK_MODULES([MINIZIP], [minizip])
        libo_MINGW_CHECK_DLL([MINIZIP], [libminizip])
        SYSTEM_MINIZIP=YES
    fi
else
    AC_MSG_RESULT([internal])
    SYSTEM_ZLIB=NO
    SYSTEM_MINIZIP=NO
    BUILD_TYPE="$BUILD_TYPE ZLIB"
fi
AC_SUBST(SYSTEM_ZLIB)
AC_SUBST([SYSTEM_MINIZIP])
AC_SUBST([MINGW_MINIZIP_DLL])

dnl ===================================================================
dnl Check for system jpeg
dnl ===================================================================
AC_MSG_CHECKING([which jpeg to use])
if test "$with_system_jpeg" = "auto"; then
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        with_system_jpeg="$with_system_libs"
        ;;
    *)
        with_system_jpeg=yes
        ;;
    esac
fi

if test "$with_system_jpeg" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_JPEG=YES
    AC_CHECK_HEADER(jpeglib.h, [],
        [AC_MSG_ERROR(jpeg.h not found. install libjpeg)], [])
    AC_CHECK_LIB(jpeg, jpeg_resync_to_restart, [ JPEG3RDLIB=-ljpeg ],
    [AC_MSG_CHECKING(jpeg library not found or fuctional)], [])
    libo_MINGW_CHECK_DLL([JPEG], [libjpeg])
else
    AC_MSG_RESULT([internal])
    SYSTEM_JPEG=NO
    BUILD_TYPE="$BUILD_TYPE JPEG"
fi
AC_SUBST(SYSTEM_JPEG)
AC_SUBST([MINGW_JPEG_DLL])

dnl ===================================================================
dnl Check for system clucene
dnl ===================================================================
AC_MSG_CHECKING([which clucene to use])
if test "$with_system_clucene" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_CLUCENE=YES
    PKG_CHECK_MODULES(CLUCENE, libclucene-core)

    AC_LANG_PUSH([C++])
    save_CXXFLAGS=$CXXFLAGS
    save_CPPFLAGS=$CPPFLAGS
    CXXFLAGS="$CXXFLAGS $CLUCENE_CFLAGS"
    CPPFLAGS="$CPPFLAGS $CLUCENE_CFLAGS"
    dnl http://sourceforge.net/tracker/index.php?func=detail&aid=3392466&group_id=80013&atid=558446
    dnl https://bugzilla.redhat.com/show_bug.cgi?id=794795
    AC_CHECK_HEADER([CLucene/analysis/cjk/CJKAnalyzer.h], [],
                 [AC_MSG_ERROR([Your version of libclucene has contribs-lib missing.])], [#include <CLucene.h>])
    CXXFLAGS=$save_CXXFLAGS
    CPPFLAGS=$save_CPPFLAGS
    AC_LANG_POP([C++])

    CLUCENE_LIBS="$CLUCENE_LIBS -lclucene-contribs-lib"
else
    AC_MSG_RESULT([internal])
    SYSTEM_CLUCENE=NO
    BUILD_TYPE="$BUILD_TYPE CLUCENE"
fi
AC_SUBST(SYSTEM_CLUCENE)
AC_SUBST(CLUCENE_CFLAGS)
AC_SUBST(CLUCENE_LIBS)

dnl ===================================================================
dnl Check for system expat
dnl ===================================================================
AC_MSG_CHECKING([which expat to use])
if test "$with_system_expat" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_EXPAT=YES
    AC_CHECK_HEADER(expat.h, [],
        [AC_MSG_ERROR(expat.h not found. install expat)], [])
    AC_CHECK_LIB([expat], [XML_ParserCreate], [:],
    [AC_MSG_RESULT(expat library not found or functional.)], [])
    libo_MINGW_CHECK_DLL([EXPAT], [libexpat])
else
    AC_MSG_RESULT([internal])
    SYSTEM_EXPAT=NO
    BUILD_TYPE="$BUILD_TYPE EXPAT"
fi
AC_SUBST(SYSTEM_EXPAT)
AC_SUBST([MINGW_EXPAT_DLL])

dnl ===================================================================
dnl Check for system libcdr
dnl ===================================================================
AC_MSG_CHECKING([which libcdr to use])
if test "$with_system_libcdr" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBCDR=YES
    PKG_CHECK_MODULES( CDR, libcdr-0.0 >= 0.0.5 )
elif test $_os = iOS; then
    # libcdr depends on libwpd and libwpg and those are LGPL
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBCDR=NO
    BUILD_TYPE="$BUILD_TYPE LIBCDR"
fi
AC_SUBST(SYSTEM_LIBCDR)
AC_SUBST(CDR_CFLAGS)
AC_SUBST(CDR_LIBS)

dnl ===================================================================
dnl Check for system libvisio
dnl ===================================================================
AC_MSG_CHECKING([which libvisio to use])
if test "$with_system_libvisio" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBVISIO=YES
    PKG_CHECK_MODULES( VISIO, libvisio-0.0 )
elif test $_os = iOS; then
    # libvisio depends on libwpd and libwpg and those are LGPL
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBVISIO=NO
    BUILD_TYPE="$BUILD_TYPE LIBVISIO"
fi
AC_SUBST(SYSTEM_LIBVISIO)
AC_SUBST(VISIO_CFLAGS)
AC_SUBST(VISIO_LIBS)

dnl ===================================================================
dnl Check for system libcmis
dnl ===================================================================
AC_MSG_CHECKING([which libcmis to use])
if test "$with_system_libcmis" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBCMIS=YES
    PKG_CHECK_MODULES( LIBCMIS, libcmis-0.2 )
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBCMIS=NO
    BUILD_TYPE="$BUILD_TYPE LIBCMIS"
fi
AC_SUBST(SYSTEM_LIBCMIS)
AC_SUBST(LIBCMIS_CFLAGS)
AC_SUBST(LIBCMIS_LIBS)


dnl ===================================================================
dnl Check for system libwpd
dnl ===================================================================
AC_MSG_CHECKING([which libwpd to use])
if test "$with_system_libwpd" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBWPD=YES
    PKG_CHECK_MODULES( WPD, libwpd-0.9 libwpd-stream-0.9 )
elif test $_os = iOS; then
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBWPD=NO
    BUILD_TYPE="$BUILD_TYPE LIBWPD"
fi
AC_SUBST(SYSTEM_LIBWPD)
AC_SUBST(WPD_CFLAGS)
AC_SUBST(WPD_LIBS)

dnl ===================================================================
dnl Check for system lcms2
dnl ===================================================================
AC_MSG_CHECKING([which littlecms v2 to use])
if test "$with_system_lcms2" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LCMS2=YES
    PKG_CHECK_MODULES( LCMS2, lcms2 )
    libo_MINGW_CHECK_DLL([LCMS2], [liblcms2])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LCMS2=NO
    BUILD_TYPE="$BUILD_TYPE LCMS2"
fi
AC_SUBST(SYSTEM_LCMS2)
AC_SUBST(LCMS2_CFLAGS)
AC_SUBST(LCMS2_LIBS)
AC_SUBST([MINGW_LCMS2_DLL])

dnl ===================================================================
dnl Check for system cppunit
dnl ===================================================================
AC_MSG_CHECKING([which cppunit to use])
if test "$with_system_cppunit" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_CPPUNIT=YES
    # might work for earlier, too but go sure:
    PKG_CHECK_MODULES( CPPUNIT, cppunit >= 1.12.0 )
else
    AC_MSG_RESULT([internal])
    SYSTEM_CPPUNIT=NO
    BUILD_TYPE="$BUILD_TYPE CPPUNIT"
fi
AC_SUBST(SYSTEM_CPPUNIT)
AC_SUBST(CPPUNIT_CFLAGS)
AC_SUBST(CPPUNIT_LIBS)

dnl ===================================================================
dnl Check whether freetype is available
dnl ===================================================================
if test  "$test_freetype" = "yes"; then
    AC_MSG_CHECKING([whether freetype is available])
    PKG_CHECK_MODULES( FREETYPE, freetype2 >= 2.0 )
else
    case "$BUILD_TYPE" in
    *FREETYPE*)
        FREETYPE_LIBS="-lfreetype"
        ;;
    esac
fi
AC_SUBST(FREETYPE_CFLAGS)
AC_SUBST(FREETYPE_LIBS)

dnl ===================================================================
dnl Check for system libwps
dnl ===================================================================
AC_MSG_CHECKING([which libwps to use])
if test "$with_system_libwps" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBWPS=YES
    PKG_CHECK_MODULES( WPS, libwps-0.2 )
elif test $_os = iOS; then
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBWPS=NO
    BUILD_TYPE="$BUILD_TYPE LIBWPS"
fi
AC_SUBST(SYSTEM_LIBWPS)
AC_SUBST(WPS_CFLAGS)
AC_SUBST(WPS_LIBS)

dnl ===================================================================
dnl Check for system libwpg
dnl ===================================================================
AC_MSG_CHECKING([which libwpg to use])
if test "$with_system_libwpg" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBWPG=YES
    PKG_CHECK_MODULES( WPG, libwpg-0.2 )
elif test $_os = iOS; then
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBWPG=NO
    BUILD_TYPE="$BUILD_TYPE LIBWPG"
fi
AC_SUBST(SYSTEM_LIBWPG)
AC_SUBST(WPG_CFLAGS)
AC_SUBST(WPG_LIBS)

dnl ===================================================================
dnl Check whether freetype2 supports emboldening
dnl ===================================================================
if test  "$test_freetype" = "yes"; then
    save_CPPFLAGS="$CPPFLAGS"
    save_LDFLAGS="$LDFLAGS"
    save_LIBS="$LIBS"
    CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
    LDFLAGS="$LDFLAGS $FREETYPE_LIBS"
    AC_CHECK_LIB(freetype, FT_GlyphSlot_Embolden,
                 [USE_FT_EMBOLDEN="YES"], [USE_FT_EMBOLDEN="NO"], [])
    LDFLAGS="$save_LDFLAGS"
    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"
fi
AC_SUBST(USE_FT_EMBOLDEN)

# ===================================================================
# Check for system libxslt
# to prevent incompatibilities between internal libxml2 and external libxslt,
# or vice versa, use with_system_libxml here
# ===================================================================
if test "$with_system_libxml" = "auto"; then
    case "$_os" in
    WINNT|iOS|Android)
        with_system_libxml="$with_system_libs"
        ;;
    *)
        with_system_libxml=yes
        ;;
    esac
fi

AC_MSG_CHECKING([which libxslt to use])
if test "$with_system_libxml" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBXSLT=YES
    if test "$_os" = "Darwin"; then
        dnl make sure to use SDK path
        LIBXSLT_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
        dnl omit -L/usr/lib
        LIBXSLT_LIBS="-lxslt -lxml2 -lz -lpthread -liconv -lm"
    else
        PKG_CHECK_MODULES(LIBXSLT, libxslt)
    fi

    dnl Check for xsltproc
    AC_PATH_PROG(XSLTPROC, xsltproc, no)
    if test "$XSLTPROC" = "no"; then
        AC_MSG_ERROR([xsltproc is required])
    fi

    libo_MINGW_CHECK_DLL([LIBXSLT], [libxslt])
    libo_MINGW_TRY_DLL([ICONV], [iconv])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBXSLT=NO
    BUILD_TYPE="$BUILD_TYPE LIBXSLT"

    if test "$cross_compiling" = "yes"; then
        AC_PATH_PROG(XSLTPROC, xsltproc, no)
        if test "$XSLTPROC" = "no"; then
            AC_MSG_ERROR([xsltproc is required])
        fi
    fi
fi
AC_SUBST(SYSTEM_LIBXSLT)
if test -z "$SYSTEM_LIBXSLT_FOR_BUILD"; then
    SYSTEM_LIBXSLT_FOR_BUILD="$SYSTEM_LIBXSLT"
fi
AC_SUBST(SYSTEM_LIBXSLT_FOR_BUILD)

AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_LIBS)
AC_SUBST(XSLTPROC)
AC_SUBST([MINGW_LIBXSLT_DLL])
AC_SUBST([MINGW_ICONV_DLL])

# ===================================================================
# Check for system libxml
# ===================================================================
AC_MSG_CHECKING([which libxml to use])
if test "$with_system_libxml" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBXML=YES
    if test "$_os" = "Darwin"; then
        dnl make sure to use SDK path
        LIBXML_CFLAGS="-I$MACOSX_SDK_PATH/usr/include/libxml2"
        dnl omit -L/usr/lib
        LIBXML_LIBS="-lxml2 -lz -lpthread -liconv -lm"
    elif test $_os = iOS; then
        dnl make sure to use SDK path
        usr=`echo '#include <stdlib.h>' | $CC -E -MD - | grep usr/include/stdlib.h | head -1 | sed -e 's,# 1 ",,' -e 's,/usr/include/.*,/usr,'`
        LIBXML_CFLAGS="-I$usr/include/libxml2"
        LIBXML_LIBS="-L$usr/lib -lxml2 -liconv"
    else
        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.0)
    fi

    dnl Check for xmllint
    AC_PATH_PROG(XMLLINT, xmllint, no)
    if test "$XMLLINT" = "no"; then
        AC_MSG_ERROR([xmllint is required])
    fi

    libo_MINGW_CHECK_DLL([LIBXML],[libxml2])
    libo_MINGW_TRY_DLL([ZLIB],[zlib1])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBXML=NO
    BUILD_TYPE="$BUILD_TYPE LIBXML2"
fi
AC_SUBST(SYSTEM_LIBXML)
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_LIBS)
AC_SUBST(XMLLINT)
AC_SUBST([MINGW_LIBXML_DLL])
AC_SUBST([MINGW_ZLIB_DLL])
dnl ===================================================================
dnl Checks for Python
dnl ===================================================================

AC_MSG_CHECKING([which Python to use])

case "$enable_python" in
no|disable)
    enable_python=no
    AC_MSG_RESULT([none])
    DISABLE_PYTHON=TRUE
    ;;
""|yes|auto)
    if test "$DISABLE_SCRIPTING" = TRUE; then
        AC_MSG_RESULT([no, overridden by --disable-scripting])
        enable_python=no
        DISABLE_PYTHON=TRUE
    elif test $build_os = cygwin; then
        dnl When building on Windows we don't attempt to use any installed
        dnl "system"  Python.
        dnl
        dnl (When cross-compiling to Windows from Linux using the mingw32-cross
        dnl compiler from OBS, use mingw32-python from OBS, and ditto for other
        dnl MinGW cross-compilation setups.)
        AC_MSG_RESULT([internal])
        enable_python=internal
    elif test $_os = Darwin -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \); then
        AC_MSG_RESULT([internal, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno])
        enable_python=internal
    else
        AC_MSG_RESULT([checking below])
        enable_python=auto
    fi
    ;;
internal)
    AC_MSG_RESULT([internal])
    ;;
system)
    if test $_os = Darwin -a -z "$PYTHON" -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \); then
        AC_MSG_ERROR([Cannot use "system" Python, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno])
    fi
    AC_MSG_RESULT([system])
    ;;
*)
    AC_MSG_ERROR([Incorrect --enable-python option])
    ;;
esac

AC_SUBST(DISABLE_PYTHON)

if test $_os = WINNT -a "$WITH_MINGW" != yes -a $enable_python = system; then
    AC_MSG_ERROR([Must use internal Python when building with MSVC])
fi

if test $enable_python != no; then
    BUILD_TYPE="$BUILD_TYPE PYUNO"
fi

if test "$cross_compiling" = yes; then
    if test $enable_python = auto; then
        enable_python=system
    fi
else
    if test $enable_python = system -a -z "$PYTHON"; then
        if test $_os = Darwin; then
            # We already have logic above to make sure the system Python
            # is used only when building against SDK 10.6 or newer.

            # Make sure we use the 2.6 Python when building against the
            # 10.6 SDK.
            case $with_macosx_sdk in
            10.6)
                python_version=2.6;;
            10.7)
                python_version=2.7;;
            *)
                # ???
                python_version=2.7;;
            esac
            PYTHON=python$python_version
            PYTHON_CFLAGS="-I/Developer/SDKs/MacOSX${with_macosx_sdk}.sdk/System/Library/Frameworks/Python.framework/Versions/${python_version}/include/python${python_version}"
            PYTHON_LIBS="-framework Python"
        else
            # This causes an error if no python command is found
            AM_PATH_PYTHON([2.6])
        fi
    elif test $enable_python = auto; then
        dnl This allows lack of system Python
        AM_PATH_PYTHON([2.6],, [:])

        if test "$PYTHON" = :; then
            enable_python=internal
        else
            enable_python=system
        fi
    fi
fi

if test $enable_python = system; then
    if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
        # Fallback: Accept these in the environment, or as set above
        # for MacOSX.
        :
    elif test "$cross_compiling" != yes; then
        python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
        python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
        python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
        python_libdir=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBDIR'));"`
        if test -z "$PKG_CONFIG"; then
            PYTHON_CFLAGS="-I$python_include"
            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
        elif $PKG_CONFIG --exists python-$python_version; then
            PYTHON_CFLAGS="`$PKG_CONFIG --cflags python-$python_version`"
            PYTHON_LIBS="`$PKG_CONFIG --libs python-$python_version` $python_libs"
        else
            PYTHON_CFLAGS="-I$python_include"
            PYTHON_LIBS="-L$python_libdir -lpython$python_version $python_libs"
        fi
    else
        dnl How to find out the cross-compilation Python installation path?
        dnl Let's hardocode what we know for different distributions for now...

        for python_sysroot in /usr/i686-w64-mingw32/sys-root/mingw; do
            for python_version in 2.6; do
                if test -f ${python_sysroot}/include/python${python_version}/Python.h; then
                    PYTHON_CFLAGS="-I${python_sysroot}/include/python$python_version"
                    PYTHON_LIBS="-L${python_sysroot}lib -lpython$python_version $python_libs"
                    break
                fi
            done
            test -n "$PYTHON_CFLAGS" && break
        done
    fi
fi

dnl By now enable_python should be "system", "internal" or "no"
case $enable_python in
system)
    SYSTEM_PYTHON=YES

    dnl Check if the headers really work
    save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
    AC_CHECK_HEADER(Python.h, [],
       [AC_MSG_ERROR([Python headers not found. You probably want to set both the PYTHON_CFLAGS and PYTHON_LIBS environment variables.])],
       [])
    CPPFLAGS="$save_CPPFLAGS"

    dnl FIXME Check if the Python library can be linked with, too?
    ;;

internal)
    SYSTEM_PYTHON=NO
    BUILD_TYPE="$BUILD_TYPE PYTHON"
    # Embedded Python dies without Home set
    if test "$HOME" = ""; then
        export HOME="";
    fi
    # bz2 tarball and bzip2 is not standard
    if test -z "$BZIP2"; then
        AC_PATH_PROG( BZIP2, bzip2)
        if test -z "$BZIP2"; then
            AC_MSG_ERROR([the internal Python module has a .tar.bz2. You need bzip2])
        fi
    fi
    ;;
no)
    SYSTEM_PYTHON=NO
    ;;
*)
    AC_MSG_ERROR([Internal configure script error, invalid enable_python value "$enable_python"])
    ;;
esac

AC_SUBST(SYSTEM_PYTHON)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)

dnl ===================================================================
dnl Check for system Berkeley db
dnl ===================================================================
AC_MSG_CHECKING([which db to use])
if test "$with_system_db" = "yes"; then
    SYSTEM_DB=YES
    AC_MSG_RESULT([external])

    db_header=
    for dbver in 5.3 5.1 5.0 5 4.8 4.7 4; do
        for dash in - ''; do
            AC_CHECK_HEADER([db$dash$dbver/db.h],
                [ db_header="db$dash$dbver/db.h"; break 2 ])
        done
    done

    if test -z "$db_header"; then
        AC_CHECK_HEADER([db/db.h], [db_header='db/db.h'; dbver=''])
    fi

    if test -z "$db_header"; then
       AC_CHECK_HEADER(db.h, [ db_header='db.h'; dbver='' ])
    fi

    if test -z "$db_header"; then
        AC_MSG_ERROR([db.h not found. Use the correct -I flag, or install the Berkeley db development package.])
    fi

    AC_MSG_CHECKING([whether db is at least 4.1])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <$db_header>]], [[int array[(DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1))-1];]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no. you need at least db 4.1])])

    SYSTEM_DB_CFLAGS="-DSYSTEM_DB_HEADER='<$db_header>'"

    DB_LIB=
    dnl At least on OpenBSD dbver is not appended to the library
    if test "$_os" = "OpenBSD"; then
        dbver=''
    fi
    for dash in - ''; do
        AC_CHECK_LIB(db$dash$dbver, dbopen,
            [ DB_LIB="db$dash$dbver"; DB_CPPLIB="db_cxx$dash$dbver"; break ])
        AC_CHECK_LIB(db$dash$dbver, __db185_open,
            [ DB_LIB="db$dash$dbver"; DB_CPPLIB="db_cxx$dash$dbver"; break ])
    done

    if test -z "$DB_LIB"; then
        AC_MSG_ERROR([db library not found. Use the correct -L flag,
or install the Berkeley db development package.])
    fi

    SCPDEFS="$SCPDEFS -DSYSTEM_DB"
    libo_MINGW_CHECK_DLL([DB], [libdb])
elif test $_os != iOS -a $_os != Android; then
    AC_MSG_RESULT([internal])
    SYSTEM_DB=NO
    BUILD_TYPE="$BUILD_TYPE BERKELEYDB"
else
   AC_MSG_RESULT([none])
fi
AC_SUBST(SYSTEM_DB)
AC_SUBST(SYSTEM_DB_CFLAGS)
AC_SUBST(DB_LIB)
AC_SUBST(DB_CPPLIB)
AC_SUBST([MINGW_DB_DLL])

AC_MSG_CHECKING([whether to build the MySQL Connector extension])
if test "x$enable_ext_mysql_connector" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    AC_MSG_RESULT([yes])
    ENABLE_MYSQLC=YES
    BUILD_TYPE="$BUILD_TYPE MYSQLC"
else
    AC_MSG_RESULT([no])
    ENABLE_MYSQLC=NO
fi
AC_SUBST(ENABLE_MYSQLC)

if test "$ENABLE_MYSQLC" = "YES"; then

    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_MYSQLC"

    dnl ===================================================================
    dnl Check for system MySQL
    dnl ===================================================================
    AC_MSG_CHECKING([for MySQL prerequisites])
    if test "$with_system_mysql" = "yes"; then
        AC_MSG_RESULT([external MySQL])
        SYSTEM_MYSQL=YES
        AC_PATH_PROG( MYSQLCONFIG, mysql_config)
        AC_MSG_CHECKING([MySQL version])
        MYSQL_VERSION=`$MYSQLCONFIG --version`
        MYSQL_MAJOR=`$MYSQLCONFIG --version | cut -d"." -f1`
        if test "$MYSQL_MAJOR" -ge "5"; then
            AC_MSG_RESULT([OK])
        else
            AC_MSG_ERROR([too old, use 5.0.x or 5.1.x])
        fi
        AC_MSG_CHECKING([for MySQL Client library])
        MYSQL_INC=`$MYSQLCONFIG --include`
        MYSQL_LIB=`$MYSQLCONFIG --libs`
        MYSQL_DEFINES=`$MYSQLCONFIG --cflags | $SED -e s,$MYSQL_INC,,`
        AC_MSG_RESULT([includes $MYSQL_INC, libraries $MYSQL_LIB])
    else
        SYSTEM_MYSQL=NO
        if test -n "$with_libmysql_path"; then
            AC_MSG_RESULT([external Connector/C (libmysql)])
            LIBMYSQL=libmysql.so
            if test "$_os" = "Darwin"; then
                LIBMYSQL=libmysql.dylib
            elif test "$_os" = "WINNT"; then
                LIBMYSQL=libmysql.dll
            fi
            AC_MSG_CHECKING([for $LIBMYSQL])
            if test -e "$with_libmysql_path/lib/$LIBMYSQL"; then
                AC_MSG_RESULT([found.])
                LIBMYSQL_PATH=$with_libmysql_path
            else
                AC_MSG_ERROR([not found. Please specify proper path in --with-libmysql-path.])
            fi
        else
            AC_MSG_ERROR([not given. Please specify either --with-system-mysql or --with-libmysql-path])
        fi
    fi
    AC_SUBST(SYSTEM_MYSQL)
    AC_SUBST(MYSQL_INC)
    AC_SUBST(MYSQL_LIB)
    AC_SUBST(MYSQL_DEFINES)
    AC_SUBST(LIBMYSQL_PATH)

    AC_LANG_PUSH([C++])
    dnl ===================================================================
    dnl Check for system MySQL C++ Connector
    dnl ===================================================================
    # FIXME!
    # who thought this too-generic cppconn dir was a good idea?
    AC_MSG_CHECKING([MySQL Connector/C++])
    if test "$with_system_mysql_cppconn" = "yes"; then
        AC_MSG_RESULT([external])
        SYSTEM_MYSQL_CPPCONN=YES
        AC_LANG_PUSH([C++])
        AC_CHECK_HEADER(mysql_driver.h, [],
                    [AC_MSG_ERROR(mysql_driver.h not found. install MySQL C++ Connectivity)], [])
        AC_CHECK_LIB([mysqlcppconn], [main], [:],
                    [AC_MSG_ERROR(MySQL C++ Connectivity lib not found or functional)], [])
        save_LDFLAGS=$LDFLAGS
        LDFLAGS="$LDFLAGS -lmysqlcppconn"
        AC_MSG_CHECKING([version])
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <mysql_driver.h>

int main(int argc, char **argv) {
    sql::Driver *driver;
    driver = get_driver_instance();
    if (driver->getMajorVersion() > 1 || \
       (driver->getMajorVersion() == 1 && driver->getMinorVersion() > 0) || \
       (driver->getMajorVersion() == 1 && driver->getMinorVersion() == 0 && driver->getPatchVersion() >= 6))
        return 0;
      else
        return 1;
}
      ]])],[AC_MSG_RESULT(OK)],[AC_MSG_ERROR([not suitable, we need >= 1.0.6])],[])

        AC_LANG_POP([C++])
        LDFLAGS=$save_LDFLAGS
    else
        AC_MSG_RESULT([internal])
        AC_MSG_CHECKING([for mysqlcppconn module])
        if test -d mysqlcppconn; then
            AC_MSG_RESULT([OK])
        else
            AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
        fi
        BUILD_TYPE="$BUILD_TYPE MYSQLCPPCONN"
        SYSTEM_MYSQL_CPPCONN=NO
    fi
    AC_LANG_POP([C++])
    AC_SUBST(SYSTEM_MYSQL_CPPCONN)
fi

dnl ===================================================================
dnl Check for system hsqldb
dnl ===================================================================
if test "$with_java" != "no"; then
AC_MSG_CHECKING([which hsqldb to use])
if test "$with_system_hsqldb" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_HSQLDB=YES
    if test -z $HSQLDB_JAR; then
        HSQLDB_JAR=/usr/share/java/hsqldb.jar
    fi
    AC_CHECK_FILE($HSQLDB_JAR, [],
               [AC_MSG_ERROR(hsqldb.jar not found.)], [])
    AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
    export HSQLDB_JAR
    if $PERL -e 'use Archive::Zip;
            my $file = "$ENV{'HSQLDB_JAR'}";
            my $zip = Archive::Zip->new( $file );
            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
            if ( $mf =~ m/Specification-Version: 1.8.*/ ) {
               push @l, split(/\n/, $mf);
               foreach my $line (@l) {
                  if ($line =~ m/Specification-Version:/) {
                      ($t, $version) = split (/:/,$line);
                      $version =~ s/^\s//;
                      ($a, $b, $c, $d) = split (/\./,$version);
                      if ($c == "0" && $d > "8")  {
                          exit 0;
                      } else {
                          exit 1;
                      }
                  }
               }
            } else {
                exit 1;
            }'; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
    fi
else
    AC_MSG_RESULT([internal])
    SYSTEM_HSQLDB=NO
    BUILD_TYPE="$BUILD_TYPE HSQLDB"
fi
AC_SUBST(SYSTEM_HSQLDB)
AC_SUBST(HSQLDB_JAR)
fi

dnl ===================================================================
dnl Check for PostgreSQL stuff
dnl ===================================================================
if test "x$enable_postgresql_sdbc" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_POSTGRESQL_SDBC"

    # if/when anything else than PostgreSQL uses Kerberos,
    # move this out of `test "x$enable_postgresql_sdbc" != "xno"'
    WITH_KRB5=NO
    WITH_GSSAPI=no
    case "$_os" in
    Darwin)
        # MacOS X has system MIT Kerberos 5 since 10.4
        if test "$with_krb5" != "no"; then
            WITH_KRB5=YES
            save_LIBS=$LIBS
            AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
            LIBS=$save_LIBS
            AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
            LIBS=$save_LIBS
        fi
        if test "$with_gssapi" != "no"; then
          WITH_GSSAPI=YES
          save_LIBS=$LIBS
          AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
                [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
          LIBS=$save_LIBS
        fi
        ;;
    WINNT)
        if test "$with_krb5" = "yes" -o "$with_gssapi" = "yes"; then
            AC_MSG_ERROR([Refusing to enable MIT Kerberos 5 or GSSAPI on Windows.])
        fi
        ;;
    Linux|GNU|*BSD|DragonFly)
        if test "$with_krb5" != "no"; then
            WITH_KRB5=YES
            save_LIBS=$LIBS
            AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
            LIBS=$save_LIBS
            AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
            LIBS=$save_LIBS
        fi
        if test "$with_gssapi" != "no"; then
            WITH_GSSAPI=YES
            save_LIBS=$LIBS
            AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
                [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
            LIBS=$save_LIBS
        fi
        ;;
    *)
        if test "$with_krb5" = "yes"; then
            WITH_KRB5=YES
            save_LIBS=$LIBS
            AC_SEARCH_LIBS(com_err, [com_err 'com_err -lssl -lcrypto' krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'com_err' required for Kerberos 5])])
            LIBS=$save_LIBS
            AC_SEARCH_LIBS(krb5_sendauth, [krb5 'krb5 -lcrypto -ldes -lasn1 -lroken'], [],
                [AC_MSG_ERROR([could not find function 'krb5_sendauth' required for Kerberos 5])])
            LIBS=$save_LIBS
        fi
        if test "$with_gssapi" = "yes"; then
            WITH_GSSAPI=YES
            save_LIBS=$LIBS
            AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
                [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
            LIBS=$save_LIBS
        fi
    esac

    AC_MSG_CHECKING([PostgreSQL C interface])
    if test "$with_system_postgresql" = "yes"; then
        AC_MSG_RESULT([external PostgreSQL])
        SYSTEM_POSTGRESQL=YES
        if test "$_os" = Darwin; then
            supp_path=''
            for d in /Library/PostgreSQL/9.*/bin /sw/opt/postgresql/9.*/bin /opt/local/lib/postgresql9*/bin; do
                pg_supp_path="$P_SEP$d$pg_supp_path"
            done
        fi
        AC_PATH_PROG(PGCONFIG, pg_config, ,$PATH$pg_supp_path)
        if test -z "$PGCONFIG"; then
            AC_MSG_ERROR([pg_config needed; set PGCONFIG if not in PATH])
        fi
        POSTGRESQL_INC=-I$(${PGCONFIG} --includedir)
        POSTGRESQL_LIB="-L$(${PGCONFIG} --libdir)"
    else
        if test -n "$with_libpq_path"; then
            SYSTEM_POSTGRESQL=YES
            AC_MSG_RESULT([external libpq])
            POSTGRESQL_LIB="-L${with_libpq_path}/lib/"
            POSTGRESQL_INC=-I"${with_libpq_path}/include/"
        else
            SYSTEM_POSTGRESQL=NO
            AC_MSG_RESULT([internal])
            POSTGRESQL_LIB=""
            POSTGRESQL_INC="%OVERRIDE_ME%"
            BUILD_TYPE="$BUILD_TYPE POSTGRESQL"
        fi
    fi
    if test "${SYSTEM_POSTGRESQL}" = "YES"; then
        AC_MSG_NOTICE([checking system PostgreSQL prerequisites])
        save_CFLAGS=$CFLAGS
        save_CPPFLAGS=$CPPFLAGS
        save_LIBS=$LIBS
        CPPFLAGS="${CPPFLAGS} ${POSTGRESQL_INC}"
        LIBS="${LIBS} ${POSTGRESQL_LIB}"
        AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([libpq-fe.h is needed])], [])
        AC_CHECK_LIB([pq], [PQconnectdbParams], [:],
            [AC_MSG_ERROR(libpq not found or too old. Need >= 9.0)], [])
        CFLAGS=$save_CFLAGS
        CPPFLAGS=$save_CPPFLAGS
        LIBS=$save_LIBS
    fi
    BUILD_POSTGRESQL_SDBC=YES
fi
AC_SUBST(WITH_KRB5)
AC_SUBST(WITH_GSSAPI)
AC_SUBST(BUILD_POSTGRESQL_SDBC)
AC_SUBST(SYSTEM_POSTGRESQL)
AC_SUBST(POSTGRESQL_INC)
AC_SUBST(POSTGRESQL_LIB)


dnl ===================================================================
dnl Check for system saxon
dnl ===================================================================
if test "$with_java" != "no"; then
AC_MSG_CHECKING([which saxon to use])
if test "$with_system_saxon" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_SAXON=YES
    if test -z $SAXON_JAR; then
        AC_CHECK_FILE(/usr/share/java/saxon9.jar,
            [ SAXON_JAR=/usr/share/java/saxon9.jar ],
            [
              AC_CHECK_FILE(/usr/share/java/saxon.jar,
                [ SAXON_JAR=/usr/share/java/saxon.jar ],
                [ AC_CHECK_FILE(/usr/share/java/saxon9.jar,
                    [ SAXON_JAR=/usr/share/java/saxon9.jar ],
                    [ AC_MSG_ERROR(saxon.jar replacement not found)]
                  )
                ]
              )
            ]
          )
    else
        AC_CHECK_FILE($SAXON_JAR, [],
               [AC_MSG_ERROR(saxon.jar replacement not found.)], [])
    fi
    if test -n "$SERIALIZER_JAR"; then
        AC_CHECK_FILE($SERIALIZER_JAR, [],
               [AC_MSG_ERROR(serializer.jar not found.)], [])
        AC_SUBST(SERIALIZER_JAR)
    fi

    dnl Saxon comes in two practically available versions, the out-of-date saxonb which
    dnl supports the Java extensions that LibreOffice uses, and the up-to-date saxon he
    dnl "home edition" version, which is crippled to not support those Java extensions.
    dnl And as an aside the he one also needs to be tweaked to include
    dnl a META-INF/services to broadcast that it supports the jaxp transform factory

    AC_MSG_CHECKING([if saxon works])
    cat > saxontest.java <<_ACEOF
[import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import java.io.*;

import net.sf.saxon.FeatureKeys;

class saxontest {
    public static void main(String[] args) {
      System.setProperty("javax.xml.transform.TransformerFactory",
        "net.sf.saxon.TransformerFactoryImpl");
      try {
        TransformerFactory tfactory = TransformerFactory.newInstance();
    // some external saxons (Debian, Ubuntu, ...) have this disabled
    // per default
    tfactory.setAttribute(FeatureKeys.ALLOW_EXTERNAL_FUNCTIONS, new Boolean(true));
        System.out.println("TransformerFactory is" +
          tfactory.getClass().getName());
        Transformer transformer = tfactory.newTransformer(
          new StreamSource(new File(args[0])));
      } catch(Exception e){
        e.printStackTrace(System.err);
        System.exit(-1);
      }
      System.exit(0);
    }
}
]
_ACEOF

    cat > saxontest.xsl<<_ACEOF
[<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
  <xsl:value-of select="math:sqrt(1)" xmlns:math="java:java.lang.Math"/>
 </xsl:template>
</xsl:stylesheet>
]
_ACEOF

    javac_cmd="$JAVACOMPILER -cp $SAXON_JAR saxontest.java 1>&2"
    AC_TRY_EVAL(javac_cmd)
    if test $? = 0 -a -f ./saxontest.class; then
        java_cmd="$JAVAINTERPRETER -cp $SAXON_JAR:. saxontest saxontest.xsl 1>&2"
        AC_TRY_EVAL(java_cmd)
        if test $? = 0; then
            AC_MSG_RESULT([yes])
        else
            cat saxontest.java >&5
            AC_MSG_RESULT([no])
            AC_MSG_ERROR([Non-functional saxon jar, e.g. crippled saxon-he instead of saxonb])
        fi
    else
        AC_MSG_RESULT([no])
        cat saxontest.java >&5
        AC_MSG_ERROR([saxontest could not be compiled, non-functional saxon jar])
    fi
else
    AC_MSG_RESULT([internal])
    SYSTEM_SAXON=NO
    NEED_SAXON=TRUE
fi
fi
AC_SUBST(SYSTEM_SAXON)
AC_SUBST(SAXON_JAR)

if test -n "$NEED_SAXON"; then
    BUILD_TYPE="$BUILD_TYPE SAXON"
fi

# ===================================================================
# Check whether to build stax
# ===================================================================
AC_MSG_CHECKING([whether building the stax is required])
BUILD_STAX=NO
if test -z "$SOLAR_JAVA"; then
    AC_MSG_RESULT([no (java disabled)])
elif test "$SYSTEM_SAXON" = "YES"; then
    AC_MSG_RESULT([no (already provided by system saxon)])
elif test -f "./stax/download/jsr173_1.0_api.jar"; then
    AC_MSG_RESULT([no (will use the prebuilt stax/download/jsr173_1.0_api.jar)])
else
    BUILD_STAX=YES
    AC_MSG_RESULT([yes (no system saxon and no prebuilt copy)])
fi
AC_SUBST(BUILD_STAX)

dnl ===================================================================
dnl Check for system curl
dnl ===================================================================
AC_MSG_CHECKING([which libcurl to use])
if test "$with_system_curl" = "auto"; then
    case "$_os" in
    Darwin)
        with_system_curl=yes
        ;;
    *)
        with_system_curl="$with_system_libs"
        ;;
    esac
fi

if test "$with_system_curl" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_CURL=YES

    curl_version=""
    if test "$cross_compiling" = "yes"; then
        dnl At least the OBS mingw32-libcurl-devel package
        dnl comes with a proper .pc file
        PKG_CHECK_MODULES(CURL, libcurl,, [:])
        if test -n "$CURL_PKG_ERRORS"; then
            AC_MSG_RESULT([no])
        else
            curl_version=`$PKG_CONFIG --modversion libcurl`
        fi
    fi
    if test -z "$curl_version"; then
        AC_PATH_PROG(CURLCONFIG, curl-config)
        if test -z "$CURLCONFIG"; then
            AC_MSG_ERROR([install the libcurl development package])
        fi
        CURL_LIBS=`$CURLCONFIG --libs`
        CURL_CFLAGS=`$CURLCONFIG --cflags`
        curl_version=`$CURLCONFIG --version | $SED -e 's/^libcurl //'`
    fi

    AC_MSG_CHECKING([whether libcurl is >= 7.13.1])

    case $curl_version in
    dnl brackets doubled below because Autoconf uses them as m4 quote characters,
    dnl so they need to be doubled to end up in the configure script
    7.13.1|7.1[[4-9]].*|7.[[2-9]]?.*|7.???.*|[[8-9]].*|[[1-9]][[0-9]].*)
        AC_MSG_RESULT([yes, you have $curl_version])
        ;;
    *)
        AC_MSG_ERROR([no, you have $curl_version])
        ;;
    esac

    libo_MINGW_CHECK_DLL([CURL], [libcurl])
    libo_MINGW_TRY_DLL([INTL], [libintl])
    libo_MINGW_TRY_DLL([IDN], [libidn])
    libo_MINGW_TRY_DLL([NSPR4], [libnspr4])
    libo_MINGW_TRY_DLL([NSSUTIL3], [nssutil3])
    libo_MINGW_TRY_DLL([PLC4], [libplc4])
    libo_MINGW_TRY_DLL([PLDS4], [libplds4])
    libo_MINGW_TRY_DLL([NSS3], [nss3])
    libo_MINGW_TRY_DLL([SSL3], [ssl3])
    libo_MINGW_TRY_DLL([GPG_ERROR], [libgpg-error])
    libo_MINGW_TRY_DLL([GCRYPT], [libgcrypt])
    libo_MINGW_TRY_DLL([SSH2], [libssh2])
else
    AC_MSG_RESULT([internal])
    SYSTEM_CURL=NO
    BUILD_TYPE="$BUILD_TYPE CURL"
fi
AC_SUBST(SYSTEM_CURL)
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
AC_SUBST([MINGW_CURL_DLL])
AC_SUBST([MINGW_GCRYPT_DLL])
AC_SUBST([MINGW_GPG_ERROR_DLL])
AC_SUBST([MINGW_IDN_DLL])
AC_SUBST([MINGW_INTL_DLL])
AC_SUBST([MINGW_NSPR4_DLL])
AC_SUBST([MINGW_NSS3_DLL])
AC_SUBST([MINGW_NSSUTIL3_DLL])
AC_SUBST([MINGW_PLC4_DLL])
AC_SUBST([MINGW_PLDS4_DLL])
AC_SUBST([MINGW_SSH2_DLL])
AC_SUBST([MINGW_SSL3_DLL])

dnl ===================================================================
dnl Check for system boost
dnl ===================================================================
AC_MSG_CHECKING([which boost to use])
if test "$with_system_boost" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_BOOST=YES
    AC_LANG_PUSH([C++])
    AC_CHECK_HEADER(boost/shared_ptr.hpp, [],
       [AC_MSG_ERROR(boost/shared_ptr.hpp not found. install boost)], [])
    AC_CHECK_HEADER(boost/spirit/include/classic_core.hpp, [],
       [AC_MSG_ERROR(boost/spirit/include/classic_core.hpp not found. install boost >= 1.36)], [])
    AC_CHECK_HEADER(boost/function.hpp, [],
       [AC_MSG_ERROR(boost/function.hpp not found. install boost)], [])
    AC_CHECK_HEADER([boost/unordered_map.hpp], [HAVE_BOOST_UNORDERED_MAP=TRUE],
                   [AC_MSG_WARN([boost/unordered_map.hpp not found])], [])

    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS -fno-exceptions"
    AC_MSG_CHECKING([whether boost/function.hpp compiles with -fno-exceptions])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <boost/function.hpp>
]], [[]])],[ac_cv_cxx_boost_no_exceptions_broken=no],[ac_cv_cxx_boost_no_exceptions_broken=yes])

    if test "$ac_cv_cxx_boost_no_exceptions_broken" = "yes"; then
        AC_MSG_ERROR([no, see https://bugzilla.redhat.com/show_bug.cgi?id=477131])
    else
        AC_MSG_RESULT([yes])
    fi
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])
else
    AC_MSG_RESULT([internal])
    BUILD_TYPE="$BUILD_TYPE BOOST"
    SYSTEM_BOOST=NO
    HAVE_BOOST_UNORDERED_MAP=TRUE
fi
AC_SUBST([HAVE_BOOST_UNORDERED_MAP])
AC_SUBST(SYSTEM_BOOST)

dnl ===================================================================
dnl Check for system mdds
dnl ===================================================================
AC_MSG_CHECKING([which mdds to use])
if test "$with_system_mdds" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_MDDS=YES

    dnl ===================================================================
    dnl Determine which hash container mdds shall use
    dnl ===================================================================
    AC_MSG_CHECKING([which hash container mdds shall use])
    if test "x$HAVE_CXX0X" = "xTRUE"; then
        MDDS_CPPFLAGS="-std=gnu++0x"
        AC_MSG_RESULT([std::unordered_map])
    else
        MDDS_CPPFLAGS="-DMDDS_HASH_CONTAINER_BOOST"
        AC_MSG_RESULT([boost::unordered_map])
    fi

    AC_LANG_PUSH([C++])
    save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $MDDS_CPPFLAGS"
    AC_CHECK_HEADER(mdds/flat_segment_tree.hpp, [],
        [AC_MSG_ERROR(mdds/flat_segment_tree.hpp not found. install mdds)], [])
    AC_CHECK_HEADER(mdds/mixed_type_matrix.hpp, [],
        [AC_MSG_ERROR(mdds/mixed_type_matrix.hpp not found. install mdds >= 0.4.0)], [])
    CPPFLAGS="$save_CPPFLAGS"
    save_CXXFLAGS="$CXXFLAGS"
    CXXFLAGS="$CXXFLAGS $MDDS_CPPFLAGS"
    AC_MSG_CHECKING([for correct signature of ::mdds::flat_segment_tree])
    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <mdds/flat_segment_tree.hpp>

    int main(int argc, char **argv) {
        ::mdds::flat_segment_tree<long, short> db(0, 100, 0);
        short val;
        if (!db.search(5, val).second)
            return 1;
        return 0;
    }
]])],[ac_cv_cxx_mdds_flat_segment_tree_correct=yes],[ac_cv_cxx_mdds_flat_segment_tree_correct=no],[])

    if test "$ac_cv_cxx_mdds_flat_segment_tree_correct" = "yes"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_ERROR([no, install mdds >= 0.5.0])
    fi
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])
else
    AC_MSG_RESULT([internal])
    BUILD_TYPE="$BUILD_TYPE MDDS"
    SYSTEM_MDDS=NO

    dnl ===================================================================
    dnl Determine which hash container mdds shall use
    dnl ===================================================================
    AC_MSG_CHECKING([which hash container mdds shall use])
    MDDS_CPPFLAGS="-DMDDS_HASH_CONTAINER_BOOST"
    AC_MSG_RESULT([boost::unordered_map])
fi
AC_SUBST(SYSTEM_MDDS)
AC_SUBST([MDDS_CPPFLAGS])

dnl ===================================================================
dnl Check for system vigra
dnl ===================================================================
AC_MSG_CHECKING([which vigra to use])
if test "$with_system_vigra" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_VIGRA=YES
    AC_LANG_PUSH([C++])
    AC_CHECK_HEADER(vigra/copyimage.hxx, [],
       [AC_MSG_ERROR(vigra/copyimage.hxx not found. install vigra)], [])
    AC_LANG_POP([C++])
else
    AC_MSG_RESULT([internal])
    BUILD_TYPE="$BUILD_TYPE VIGRA"
    SYSTEM_VIGRA=NO
fi
AC_SUBST(SYSTEM_VIGRA)

dnl ===================================================================
dnl Check for system odbc
dnl ===================================================================
AC_MSG_CHECKING([which odbc headers to use])
if test "$with_system_odbc" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_ODBC_HEADERS=YES

    AC_CHECK_HEADER(sqlext.h, [],
      [AC_MSG_ERROR(odbc not found. install odbc)], [])
elif test "$enable_database_connectivity" != yes; then
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([internal])
    SYSTEM_ODBC_HEADERS=NO
fi
AC_SUBST(SYSTEM_ODBC_HEADERS)

AC_MSG_CHECKING([whether to enable build of Mozilla])
if test "$enable_mozilla" = "no"; then
    AC_MSG_RESULT([no])
    WITH_MOZILLA=NO
else
    AC_MSG_RESULT([yes])
    WITH_MOZILLA=YES
fi
AC_SUBST(WITH_MOZILLA)

AC_MSG_CHECKING([whether to build Mozilla addressbook connectivity])
if test "$enable_mozilla" = "no"; then
    AC_MSG_RESULT([no])
elif test "$with_system_mozilla" = "yes"; then
    AC_MSG_RESULT([no, not possible with system-mozilla])
else
    AC_MSG_RESULT([yes])
fi

AC_MSG_CHECKING([whether to build XML Security support])
if test "$enable_xmlsec" = "no"; then
    AC_MSG_RESULT([no])
    ENABLE_XMLSEC=
else
    ENABLE_XMLSEC="YES"
    BUILD_TYPE="$BUILD_TYPE LIBXMLSEC"
    AC_MSG_RESULT([yes])
fi
AC_SUBST(ENABLE_XMLSEC)

AC_MSG_CHECKING([whether to build LDAP configuration backend])
if test "$enable_ldap" != "no"; then
    WITH_OPENLDAP=NO
    WITH_LDAP=NO
    if test "$with_openldap" = "yes"; then
        WITH_LDAP=YES
        AC_MSG_RESULT([OpenLDAP])
        WITH_OPENLDAP=YES
        AC_CHECK_HEADERS(ldap.h, [],
            [AC_MSG_ERROR(ldap.h not found. install openldap libs)], [])
	AC_CHECK_LIB([ldap], [ldap_simple_bind_s], [:],
	    [AC_MSG_ERROR(openldap lib not found or functional)], [])
	AC_CHECK_LIB([ldap], [ldap_set_option], [:],
	    [AC_MSG_ERROR(openldap lib not found or functional)], [])
    elif test "$enable_mozilla" != "no"; then
        AC_MSG_RESULT([Mozilla])
        WITH_LDAP=YES
        WITH_OPENLDAP=NO
    else
        AC_MSG_RESULT([no. Either Mozilla or OpenLDAP required])
    fi
else
    AC_MSG_RESULT([no])
    WITH_LDAP=NO
fi
AC_SUBST(WITH_LDAP)
AC_SUBST(WITH_OPENLDAP)

dnl ===================================================================
dnl Check for system mozilla
dnl ===================================================================

AC_MSG_CHECKING([which Mozilla to use])
if test -n "$with_system_mozilla" -a "$with_system_mozilla" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_MOZILLA=YES
    AC_MSG_CHECKING([which Mozilla flavour to use])
    if test -n "$with_system_mozilla" -a "$with_system_mozilla" = "libxul"; then
        MOZ_FLAVOUR=libxul
    elif test -n "$with_system_mozilla" -a "$with_system_mozilla" = "xulrunner"; then
        MOZ_FLAVOUR=xulrunner
    elif test -n "$with_system_mozilla" -a "$with_system_mozilla" = "seamonkey"; then
        MOZ_FLAVOUR=seamonkey
    elif test -n "$with_system_mozilla" -a "$with_system_mozilla" = "iceape"; then
        MOZ_FLAVOUR=iceape
    elif test -n "$with_system_mozilla" -a "$with_system_mozilla" = "firefox"; then
        MOZ_FLAVOUR=firefox
    elif test -n "$with_system_mozilla" -a "$with_system_mozilla" = "mozilla"; then
        MOZ_FLAVOUR=mozilla
    else
        MOZ_FLAVOUR=libxul
    fi
    tmp=`echo $MOZ_FLAVOUR | $PERL -e 'print ucfirst(<STDIN>);'`
    AC_MSG_RESULT($tmp)

    if test "$MOZ_FLAVOUR" != "libxul"; then
        PKG_CHECK_MODULES( MOZILLAXPCOM, $MOZ_FLAVOUR-xpcom, HASXPCOM="TRUE", HASXPCOM="" )
        MOZ_INC=`$PKG_CONFIG --variable=includedir $MOZ_FLAVOUR-xpcom`
        MOZ_LIB=`$PKG_CONFIG --variable=libdir $MOZ_FLAVOUR-xpcom`
    fi

    if test -z "$HASXPCOM"; then
        PKG_CHECK_MODULES( MOZILLAXPCOM, libxul )
        MOZ_INC=`$PKG_CONFIG --variable=includedir libxul`
        MOZ_LIB=`$PKG_CONFIG --variable=libdir libxul`
        if ! test -e "$MOZ_LIB/libxul.so"; then
            MOZ_LIB=`$PKG_CONFIG --variable=sdkdir libxul`
            if test -e "$MOZ_LIB/sdk/lib/libxul.so"; then
                MOZ_LIB="$MOZ_LIB/sdk/lib"
            fi
        fi
    fi

    MOZ_LIB_XPCOM=$MOZILLAXPCOM_LIBS
    if test "$WITH_LDAP" != "NO" -a "$WITH_OPENLDAP" != "YES"; then
        AC_MSG_CHECKING([whether $tmp was compiled with --enable-ldap])
        if test -d "$MOZ_INC/ldap"; then
            AC_MSG_RESULT([yes])
            MOZ_LDAP_CFLAGS="-I$MOZ_INC"
        else
            AC_MSG_ERROR([no.
Could not find LDAP header include files in $MOZ_INC/ldap.
Please recompile $tmp with --enable-ldap or use --with-openldap.])
        fi
    fi

    #e.g. http://fedoraproject.org/wiki/Releases/FeatureXULRunnerAPIChanges
    #the plugin pkg-config etc. reverts to "mozilla-plugin" with libxul
    if test "$MOZ_FLAVOUR" = "libxul"; then
        MOZ_FLAVOUR="mozilla"
    fi

elif test "$enable_mozilla" = "no"; then
    AC_MSG_RESULT([none])
    WITH_MOZILLA=NO
else
    AC_MSG_RESULT([internal])
    SYSTEM_MOZILLA=NO
    BUILD_TYPE="$BUILD_TYPE MOZ"
    if test -z "$with_mozilla_version"; then
        MOZILLA_VERSION=
    else
        AC_MSG_CHECKING([which Mozilla version to build])
        MOZILLA_VERSION=$with_mozilla_version
        enable_build_mozilla=1
        AC_MSG_RESULT([$MOZILLA_VERSION])
    fi

    AC_SUBST(MOZILLA_VERSION)

    AC_MSG_CHECKING([for toolkit Mozilla should use])
    if test -z "$with_mozilla_toolkit"; then
        if test "$_os" != "WINNT"; then
            if test "$_os" = "Darwin"; then
                MOZILLA_TOOLKIT=mac
                AC_MSG_RESULT([mac])
            else
                MOZILLA_TOOLKIT=gtk2
                AC_MSG_RESULT([gtk2])
            fi
        fi
    else
        MOZILLA_TOOLKIT=$with_mozilla_toolkit
        enable_build_mozilla=1
        AC_MSG_RESULT([$MOZILLA_TOOLKIT])
    fi

    AC_SUBST(MOZILLA_TOOLKIT)

    # default to enabling build mozilla
    if test "$enable_build_mozilla" != "no"; then
        enable_build_mozilla=yes
    else
        enable_build_mozilla=
    fi

    AC_MSG_CHECKING([whether to build Mozilla/SeaMonkey])
    if test -n "$enable_build_mozilla"; then
        BUILD_MOZAB="TRUE"
        AC_MSG_RESULT([yes])
    else
        BUILD_MOZAB=""
        AC_MSG_RESULT([no])
    fi

    if test "$BUILD_MOZAB" = "TRUE"; then
        if test "$_os" = "WINNT"; then
            if test "$WITH_MINGW" != "yes"; then
                # compiling with MSVC. Only supported platform here is MSVS2005 at the moment.
                if test "$MSVSVER" != "2005"; then
                    AC_MSG_ERROR([Building SeaMonkey is supported with Microsoft Visual Studio 2005 only.])
                fi
            else
                AC_MSG_WARN([Building SeaMonkey with MinGW is not tested, and likely to break.])
                echo "Building SeaMonkey with MinGW is not tested, and likely to break." >> warn
            fi
        fi

        if test -z "$MOZILLA_VERSION"; then
            MOZILLA_VERSION=1.1.14
        fi
        MOZILLA_SOURCE_VERSION="seamonkey-${MOZILLA_VERSION}.source"
        MOZILLA_FETCH_FILE=`grep $MOZILLA_SOURCE_VERSION ooo.lst.in`
        AC_MSG_CHECKING([for Mozilla sources])
        if test -z "$MOZILLA_FETCH_FILE"; then
            AC_MSG_RESULT([not found])
            HAVE_MOZILLA_TARBALL=n
        else
            AC_MSG_CHECKING([for $MOZILLA_FETCH_FILE])
            if test ! -e "$TARFILE_LOCATION/$MOZILLA_FETCH_FILE"; then
                if test -z "$DO_FETCH"; then
                    AC_MSG_RESULT([will be fetched])
                    HAVE_MOZILLA_TARBALL=y
                else
                    AC_MSG_RESULT([not found])
                    HAVE_MOZILLA_TARBALL=n
                fi
            else
                AC_MSG_RESULT([found])
                HAVE_MOZILLA_TARBALL=y
            fi
        fi
        if test "$HAVE_MOZILLA_TARBALL" != "y"; then
            AC_MSG_ERROR([Mozilla/SeaMonkey source archive not found.
Use "./download" to download.])
        fi
        if test "$_os" = "WINNT"; then
            AC_MSG_CHECKING([for moztools binaries])
            if test ! -e "$TARFILE_LOCATION/vc8-moztools.zip"; then
                AC_MSG_ERROR([The following file is missing in $TARFILE_LOCATION: vc8-moztools.zip
(from ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/historic/vc8/)])
            else
                AC_MSG_RESULT([ok])
            fi
        elif test "$_os" = "Darwin"; then
            PKG_CHECK_MODULES(MOZLIBREQ, libIDL-2.0 >= 0.6.3,  MOZIDL="TRUE", MOZIDL="")
            if test -z "$MOZIDL"; then
                AC_MSG_ERROR([libIDL 0.6.3 or newer is needed to build Mozilla with Mac toolkit.])
            fi
        else
            # Generic Unix/Linux section
            if test "$MOZILLA_TOOLKIT" = "gtk2"; then
                PKG_CHECK_MODULES(MOZLIBREQ, gtk+-2.0, MOZGTK="TRUE", MOZGTK="")
                if test -z "$MOZGTK"; then
                    AC_MSG_ERROR([GTK2 is needed to build Mozilla.])
                fi
                PKG_CHECK_MODULES(MOZLIBREQ, libIDL-2.0 >= 0.8.0, MOZIDL="TRUE", MOZIDL="")
                if test -z "$MOZIDL"; then
                    AC_MSG_ERROR([libIDL >= 0.8.0 is needed when using GTK2 to build Mozilla.])
                fi
            else
                PKG_CHECK_MODULES(MOZLIBREQ, gtk+ >= 1.2.3, MOZGTK="TRUE", MOZGTK="")
                if test -z "$MOZGTK"; then
                    AC_MSG_ERROR([GTK+ 1.2 is needed when not using GTK2 to build Mozilla.])
                fi
                PKG_CHECK_MODULES(MOZLIBREQ, libidl >= 0.6.3 libidl <= 0.6.8, MOZIDL="TRUE", MOZIDL="")
                if test -z "$MOZIDL"; then
                    AC_MSG_ERROR([libIDL 0.6.3 - 0.6.8 is needed when not using GTK2 to build Mozilla.])
                fi
            fi
        fi
    else
        AC_MSG_CHECKING([which pre-built Mozilla module in moz/zipped])
        if test -e "$SRC_ROOT/moz/zipped/${OS}${COM}${CPU}inc.zip" -a \
                -e "$SRC_ROOT/moz/zipped/${OS}${COM}${CPU}lib.zip" -a \
                -e "$SRC_ROOT/moz/zipped/${OS}${COM}${CPU}runtime.zip"; then
            AC_MSG_RESULT([Found])
            PREBUILD_MOZAB="YES"
            if test "$_os" = "WINNT"; then
                AC_MSG_CHECKING([for MSVC 2005 runtime needed for prebuilt Mozilla])
                if test -e "$SRC_ROOT/external/msvcp80/Microsoft.VC80.CRT.manifest" -a \
                        -e "$SRC_ROOT/external/msvcp80/msvcp80.dll" -a \
                        -e "$SRC_ROOT/external/msvcp80/msvcr80.dll"; then
                    AC_MSG_RESULT([Found])
                else
                    AC_MSG_RESULT([Not Found])
                    AC_MSG_ERROR([For the pre-built Mozilla libraries, you need MSVC 2005 runtime files
Microsoft.VC80.CRT.manifest, msvcp80.dll, and msvcr80.dll
in external/msvcp80.

You can get them by installing:
<http://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.EXE>
and copying the abovementioned files from:
c:/windows/winsxs/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989/
and
c:/windows/winsxs/manifests/x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989.manifest
])
                fi
            fi
        else
            AC_MSG_RESULT([Not Found])
            AC_MSG_ERROR([If you don't use system mozilla and also disable the build of internal mozilla, you must provided the appropriate libraries yourself.
You need to copy $OS$COM$CPU{inc,lib,runtime}.zip into moz/zipped.
These files can be found at <http://dev-www.libreoffice.org/mozilla/>
])
        fi
    fi
fi

if test "$SYSTEM_MOZILLA" = "YES"; then
    SOLARLIB="$SOLARLIB -L$MOZ_LIB"
fi

AC_SUBST(BUILD_MOZAB)
AC_SUBST(PREBUILD_MOZAB)
AC_SUBST(MOZILLABUILD)
AC_SUBST(SYSTEM_MOZILLA)
AC_SUBST(MOZ_FLAVOUR)
AC_SUBST(MOZ_INC)
AC_SUBST(MOZ_LIB)
AC_SUBST(MOZ_LIB_XPCOM)
AC_SUBST(MOZ_LDAP_CFLAGS)

dnl ===================================================================
dnl Check for system NSS only with xmlsec or mozilla build enabled
dnl ===================================================================
if test "x$enable_xmlsec" != "xno" -o "x$enable_mozilla" != "xno"; then
AC_MSG_CHECKING([which NSS to use])
if test "$with_system_nss" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_NSS="YES"
    PKG_CHECK_MODULES(NSS, nss >= 3.9.3 nspr >= 4.8)
else
    SYSTEM_NSS="NO"
    BUILD_TYPE="$BUILD_TYPE NSS"
    AC_MSG_RESULT([internal])
    if test "$build_os" = "cygwin"; then
        AC_MSG_CHECKING([for Mozilla build tooling. Required for nss and/or mozilla])
        if test -z "$MOZILLABUILD"; then
            AC_MSG_ERROR([Mozilla build tooling not found.
Use the --with-mozilla-build option after installing the tools obtained
from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32])
        else
            if test \( "$WITH_MINGW" = "yes" \); then
                if test ! -d "$MOZILLABUILD"; then
                    AC_MSG_ERROR([Mozilla build tooling incomplete!])
                else
                    AC_MSG_RESULT([ok])
                fi
            else
                if test ! -d "$MOZILLABUILD/moztools" \
                        -o ! -d "$MOZILLABUILD/msys"; then
                    AC_MSG_ERROR([Mozilla build tooling incomplete!])
                else
                    AC_MSG_RESULT([ok])
                fi
            fi
        fi
    fi
fi # system nss
fi # enable xmlsec || enable mozilla
AC_SUBST(SYSTEM_NSS)
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LIBS)

dnl ===================================================================
dnl Check for system mozilla headers
dnl ===================================================================
HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION=
AC_MSG_CHECKING([which mozilla headers to use])
if test "$with_system_mozilla_headers" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_MOZILLA_HEADERS=YES
    # First try npapi-sdk:
    PKG_CHECK_MODULES(MOZILLA_HEADERS, npapi-sdk, [LOCATED=yes], [LOCATED=no])
    # Then go with libxul:
    if test "x$LOCATED" != "xyes"; then
        PKG_CHECK_MODULES(MOZILLA_HEADERS, libxul, [LOCATED=yes], [LOCATED=no])
    fi
    if test "x$LOCATED" != "xyes"; then
        PKG_CHECK_MODULES(MOZILLA_HEADERS, mozilla-plugin, [LOCATED=yes], [LOCATED=no])
    fi
    # if still not found bail out
    if test "x$LOCATED" != "xyes"; then
        AC_MSG_ERROR([npapi.h header file not found])
    fi

    AC_LANG_PUSH([C])
    save_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS $MOZILLA_HEADERS_CFLAGS"
    AC_MSG_CHECKING([for NPP_GetMIMEDescription return type])
    AC_COMPILE_IFELSE(
        [AC_LANG_SOURCE([[
            #define XP_UNIX
            #include <npapi.h>
            const char* NPP_GetMIMEDescription(void) { return "foo"; }
            ]])],
        [AC_MSG_RESULT([const char*])],
        [
        AC_MSG_RESULT([char*])
        HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION=TRUE
        ])
    CFLAGS=$save_CFLAGS
    AC_LANG_POP([C])
else
    AC_MSG_RESULT([internal])
    SYSTEM_MOZILLA_HEADERS=NO
fi
AC_SUBST(MOZILLA_HEADERS_CFLAGS)
AC_SUBST(SYSTEM_MOZILLA_HEADERS)
AC_SUBST(HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION)

dnl ===================================================================
dnl Check for system sane
dnl ===================================================================
AC_MSG_CHECKING([which sane header to use])
if test "$with_system_sane" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_SANE_HEADER=YES
    AC_CHECK_HEADER(sane/sane.h, [],
      [AC_MSG_ERROR(sane not found. install sane)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_SANE_HEADER=NO
    BUILD_TYPE="$BUILD_TYPE SANE"
fi
AC_SUBST(SYSTEM_SANE_HEADER)

dnl ===================================================================
dnl Check for system icu
dnl ===================================================================
SYSTEM_GENBRK=
SYSTEM_GENCCODE=
SYSTEM_GENCMN=

ICU_MAJOR=49
ICU_MINOR=1
ICU_MICRO=1
ICU_RECLASSIFIED_CLOSE_PARENTHESIS="YES"
ICU_RECLASSIFIED_PREPEND_SET_EMPTY="YES"
ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="YES"
ICU_RECLASSIFIED_HEBREW_LETTER="YES"
AC_MSG_CHECKING([which icu to use])
if test "$with_system_icu" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_ICU=YES
    AC_LANG_PUSH([C++])
    AC_MSG_CHECKING([for unicode/rbbi.h])
    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[unicode/rbbi.h]])],[AC_MSG_RESULT(checked.)],[AC_MSG_ERROR(icu headers not found.)])
    AC_LANG_POP([C++])

    ICUPATH="$PATH"
    if test "$WITH_MINGW" = "yes"; then
        ICUPATH=`$CC -print-sysroot`/mingw/bin:"$ICUPATH"
    fi
    AC_PATH_PROG(ICUCONFIG,icu-config,,[$ICUPATH])

    AC_MSG_CHECKING([ICU version])
    ICU_VERSION=`$ICUCONFIG --noverify --version 2>/dev/null || $ICUCONFIG --version`
    ICU_MAJOR=`echo $ICU_VERSION | cut -d"." -f1`
    ICU_MINOR=`echo $ICU_VERSION | cut -d"." -f2`
    ICU_MICRO=`echo $ICU_VERSION | cut -d"." -f3`

    if test "$ICU_MAJOR" -ge "4"; then
        AC_MSG_RESULT([OK, $ICU_VERSION])
    else
        AC_MSG_ERROR([not suitable, only >= 4.0 supported currently])
    fi

    if test "$cross_compiling" = "yes" -a \( "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force" \); then
        AC_PATH_PROG([ICUCONFIG_FOR_BUILD], [icu-config], [], [$PATH:/usr/sbin:/sbin])
        ICU_VERSION_FOR_BUILD=`$ICUCONFIG_FOR_BUILD --noverify --version 2>/dev/null || $ICUCONFIG_FOR_BUILD --version`
        ICU_MAJOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f1`
        ICU_MINOR_FOR_BUILD=`echo $ICU_VERSION_FOR_BUILD | cut -d"." -f2`
        AC_MSG_CHECKING([if MinGW and system versions of ICU are compatible])
        if test "$ICU_MAJOR" -eq "$ICU_MAJOR_FOR_BUILD" -a "$ICU_MINOR" -eq "$ICU_MINOR_FOR_BUILD"; then
            AC_MSG_RESULT([yes])
        else
            AC_MSG_RESULT([no])
            if test "$with_system_icu_for_build" != "force"; then
                AC_MSG_ERROR([System ICU is not version-compatible with MinGW ICU.
You can use --with-system-icu-for-build=force to use it anyway.])
            fi
        fi
    fi

    if test "$cross_compiling" != "yes" -o "$with_system_icu_for_build" = "yes" -o "$with_system_icu_for_build" = "force"; then
        # using the system icu tools can lead to version confusion, use the
        # ones from the build environment when cross-compiling
        AC_PATH_PROG(SYSTEM_GENBRK, genbrk, [], [$PATH:/usr/sbin:/sbin])
        if test -z "$SYSTEM_GENBRK"; then
            AC_MSG_ERROR([\'genbrk\' not found in \$PATH, install the icu development tool \'genbrk\'])
        fi
        AC_PATH_PROG(SYSTEM_GENCCODE, genccode, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
        if test -z "$SYSTEM_GENCCODE"; then
            AC_MSG_ERROR([\'genccode\' not found in \$PATH, install the icu development tool \'genccode\'])
        fi
        AC_PATH_PROG(SYSTEM_GENCMN, gencmn, [], [$PATH:/usr/sbin:/sbin:/usr/local/sbin])
        if test -z "$SYSTEM_GENCMN"; then
            AC_MSG_ERROR([\'gencmn\' not found in \$PATH, install the icu development tool \'gencmn\'])
        fi
        if test "$ICU_MAJOR" -ge "5" -o "$ICU_MAJOR" = "4" -a "$ICU_MINOR" -ge "4"; then
            ICU_RECLASSIFIED_CLOSE_PARENTHESIS="YES"
        else
            ICU_RECLASSIFIED_CLOSE_PARENTHESIS="NO"
        fi
        if test "$ICU_MAJOR" -ge "5" -o "$ICU_MAJOR" = "4" -a "$ICU_MINOR" -ge "9"; then
            ICU_RECLASSIFIED_PREPEND_SET_EMPTY="YES"
        else
            ICU_RECLASSIFIED_PREPEND_SET_EMPTY="NO"
        fi
        if test "$ICU_MAJOR" -le 4; then
            ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER="NO"
            ICU_RECLASSIFIED_HEBREW_LETTER="NO"
        fi
    fi

    libo_MINGW_CHECK_DLL([ICUDATA], [icudata][$ICU_MAJOR][$ICU_MINOR])
    libo_MINGW_CHECK_DLL([ICUI18N], [icui18n][$ICU_MAJOR][$ICU_MINOR])
    libo_MINGW_CHECK_DLL([ICUUC], [icuuc][$ICU_MAJOR][$ICU_MINOR])
else
    AC_MSG_RESULT([internal])
    SYSTEM_ICU="NO"
    BUILD_TYPE="$BUILD_TYPE ICU"
fi

AC_SUBST(SYSTEM_ICU)
AC_SUBST(SYSTEM_GENBRK)
AC_SUBST(SYSTEM_GENCCODE)
AC_SUBST(SYSTEM_GENCMN)
AC_SUBST(ICU_MAJOR)
AC_SUBST(ICU_MINOR)
AC_SUBST(ICU_MICRO)
AC_SUBST(ICU_RECLASSIFIED_CLOSE_PARENTHESIS)
AC_SUBST([ICU_RECLASSIFIED_CONDITIONAL_JAPANESE_STARTER])
AC_SUBST([ICU_RECLASSIFIED_HEBREW_LETTER])
AC_SUBST(ICU_RECLASSIFIED_PREPEND_SET_EMPTY)
AC_SUBST([MINGW_ICUDATA_DLL])
AC_SUBST([MINGW_ICUI18N_DLL])
AC_SUBST([MINGW_ICUUC_DLL])

dnl ===================================================================
dnl Graphite
dnl ===================================================================

AC_MSG_CHECKING([whether to enable graphite support])
if test "$_os" = "WINNT" -o "$_os" = "Linux" && test "$enable_graphite" = "" -o "$enable_graphite" != "no"; then
    AC_MSG_RESULT([yes])
    ENABLE_GRAPHITE="TRUE"
    AC_MSG_CHECKING([which graphite to use])
    if test "$with_system_graphite" = "yes"; then
        AC_MSG_RESULT([external])
        SYSTEM_GRAPHITE=YES
        PKG_CHECK_MODULES( GRAPHITE, graphite2 >= 0.9.3 )
        libo_MINGW_CHECK_DLL([GRAPHITE2], [libgraphite2])
    else
        AC_MSG_RESULT([internal])
        SYSTEM_GRAPHITE=NO
        BUILD_TYPE="$BUILD_TYPE GRAPHITE"
    fi
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_GRAPHITE)
AC_SUBST(SYSTEM_GRAPHITE)
AC_SUBST(GRAPHITE_LIBS)
AC_SUBST(GRAPHITE_CFLAGS)
AC_SUBST([MINGW_GRAPHITE2_DLL])

dnl ===================================================================
dnl SampleICC
dnl ===================================================================
AC_MSG_CHECKING([whether to use system SampleICC])
if test "$with_system_sampleicc" = "yes"; then
    AC_MSG_RESULT([yes])
    SYSTEM_SAMPLEICC=YES
    PKG_CHECK_MODULES(SAMPLEICC, sampleicc)
else
    AC_MSG_RESULT([no])
    SYSTEM_SAMPLEICC=NO
fi
AC_SUBST(SYSTEM_SAMPLEICC)
AC_SUBST(SAMPLEICC_LIBS)
AC_SUBST(SAMPLEICC_CFLAGS)

if test $_os = Darwin -o $_os = iOS -o $_os = Android; then
    enable_gtk=no
fi

dnl ===================================================================
dnl Check for nsplugin
dnl ===================================================================
AC_MSG_CHECKING([whether to build nsplugin extension])
ENABLE_NSPLUGIN=NO
if test "$enable_nsplugin" != "no"; then
    if test "$enable_gtk" != "no"; then
        AC_MSG_RESULT([yes])
        ENABLE_NSPLUGIN=YES
    else
        AC_MSG_RESULT([no, disabled gtk2])
    fi
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_NSPLUGIN)

AC_MSG_CHECKING([whether to use X11])
dnl ***************************************
dnl testing for X libraries and includes...
dnl ***************************************
WANT_X11="no"
if test $_os != Darwin -a $_os != WINNT -a $_os != Android -a $_os != iOS -a "$enable_headless" != "yes"; then
    WANT_X11="yes"
fi
AC_MSG_RESULT([$WANT_X11])

if test "$WANT_X11" = "yes"; then
    AC_PATH_X
    AC_PATH_XTRA
    CPPFLAGS="$CPPFLAGS $X_CFLAGS"

    if test "x$x_includes" = "x"; then
        x_includes="default_x_includes"
    fi
    if test "x$x_libraries" = "x"; then
        x_libraries="default_x_libraries"
    fi
    dnl The variables $x_libraries and $x_includes are set.
    if test -z "$x_libraries"; then
        AC_MSG_ERROR([No X libraries found]) # Exit
    fi
    if test -z "$x_includes"; then
        AC_MSG_ERROR([No X includes found]) # Exit
    fi
    CFLAGS="$CFLAGS $X_CFLAGS"
    LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
    AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
else
    x_includes="no_x_includes"
    x_libraries="no_x_libraries"
fi
if test -z "$x_includes"; then
    x_includes="no_x_includes"
fi
if test -z "$x_libraries"; then
    x_libraries="no_x_libraries"
fi
if test "$x_includes" = "default_x_includes"; then
    XINC="/usr/include"
else
    XINC="$x_includes"
fi
AC_SUBST(XINC)
if test "$x_libraries" = "default_x_libraries"; then
    XLIB=`$PKG_CONFIG --variable=libdir x11`
    if test "x$XLIB" = x; then
        XLIB="/usr/lib"
    fi
else
    XLIB="$x_libraries"
fi
if test "$XLIB" != "no_x_libraries" -a "$XLIB" != "/usr/lib" -a "$XLIB" != "/usr/lib64"; then
    SOLARLIB="$SOLARLIB -L$XLIB"
fi
if test "$XINC" != "no_x_includes" -a "$XINC" != "/usr/include"; then
    SOLARINC="$SOLARINC -I$XINC"
fi
AC_SUBST(XLIB)

if test "$WANT_X11" = "yes"; then
    dnl ===================================================================
    dnl Check for Composite.h for Mozilla plugin
    dnl ===================================================================
    AC_CHECK_HEADERS(X11/Composite.h,[],[AC_MSG_ERROR([Xt headers not found])],
     [#include <X11/Intrinsic.h>])
fi

AC_MSG_CHECKING([whether to use internal X11 extensions headers])
if test "$with_system_xextensions_headers" != "no"; then
    AC_MSG_RESULT([no])
else
    AC_MSG_RESULT([yes])
    AC_CHECK_HEADERS(X11/extensions/shape.h,[],[AC_MSG_ERROR([libXext headers not found])],
     [#include <X11/extensions/shape.h>])
    BUILD_TYPE="$BUILD_TYPE X11_EXTENSIONS"
fi

dnl ===================================================================
dnl Check for system Xrender
dnl ===================================================================
AC_MSG_CHECKING([whether to use Xrender])
if test "$WANT_X11" = "yes" -a  "$test_xrender" = "yes"; then
    AC_MSG_RESULT([yes])
    AC_CHECK_LIB([Xrender], [XRenderQueryVersion], [:],
      [AC_MSG_ERROR(libXrender not found or functional)], [])
    AC_MSG_CHECKING([which Xrender headers to use])
    if test "$with_system_xextensions_headers" != "no"; then
        AC_MSG_RESULT([external])
        AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
          [AC_MSG_ERROR(Xrender not found. install X)], [])
    else
        AC_MSG_RESULT([internal])
    fi
else
    AC_MSG_RESULT([no])
fi

dnl ===================================================================
dnl Check for XRandr
dnl ===================================================================
AC_MSG_CHECKING([whether to enable RandR support])
if test "$WANT_X11" = "yes" -a "$test_randr" = "yes" -a \( "$enable_randr" = "yes" -o "$enable_randr" = "TRUE" \); then
    if test -z "$enable_randr_link" -o "$enable_randr_link" = "no"; then
        XRANDR_DLOPEN="TRUE"
        AC_MSG_RESULT([configured to dlopen libXrandr at runtime])
    else
        AC_MSG_RESULT([yes])
        XRANDR_DLOPEN="FALSE"
        PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2, ENABLE_RANDR="TRUE", ENABLE_RANDR="")
        if test "$ENABLE_RANDR" != "TRUE"; then
            AC_CHECK_HEADER(X11/extensions/Xrandr.h, [],
                        [AC_MSG_ERROR([X11/extensions/Xrandr.h could not be found. X11 dev missing?])], [])
            XRANDR_CFLAGS=" "
            AC_CHECK_LIB([Xrandr], [XRRQueryExtension], [:],
              [ AC_MSG_ERROR(libXrandr not found or functional) ], [])
            XRANDR_LIBS="-lXrandr "
            ENABLE_RANDR="TRUE"
        fi
    fi
else
    ENABLE_RANDR=""
    AC_MSG_RESULT([no])
fi
AC_SUBST(XRANDR_DLOPEN)
AC_SUBST(XRANDR_CFLAGS)
AC_SUBST(XRANDR_LIBS)
AC_SUBST(ENABLE_RANDR)

dnl ===================================================================
dnl Check for building neon
dnl ===================================================================
AC_MSG_CHECKING([whether to use neon])
if test "$enable_neon" = "no"; then
    AC_MSG_RESULT([no])
    DISABLE_NEON=TRUE
    AC_SUBST(DISABLE_NEON)
else
    AC_MSG_RESULT([yes])
dnl ===================================================================
dnl Check for system neon
dnl ===================================================================
AC_MSG_CHECKING([which neon to use])
if test "$with_system_neon" = "yes"; then
    AC_MSG_RESULT([external])
    PKG_CHECK_MODULES(NEON, neon >= 0.26.0, , AC_MSG_ERROR([you need neon >= 0.26.x for system-neon]))
    NEON_VERSION="`$PKG_CONFIG --modversion neon | $SED 's/\.//g'`"
    NEON_CFLAGS="$NEON_CFLAGS -DSYSTEM_NEON -DUSE_DAV_LOCKS=1"
    SYSTEM_NEON=YES
    libo_MINGW_CHECK_DLL([NEON], [libneon])
    libo_MINGW_TRY_DLL([TASN1], [libtasn1])
    libo_MINGW_TRY_DLL([GNUTLS], [libgnutls])
else
    AC_MSG_RESULT([internal])
    SYSTEM_NEON=NO
    NEON_LIBS=-lneon
    NEON_CFLAGS=
    BUILD_TYPE="$BUILD_TYPE NEON"
fi
AC_SUBST(SYSTEM_NEON)
AC_SUBST(NEON_VERSION)
AC_SUBST(NEON_LIBS)
AC_SUBST(NEON_CFLAGS)
AC_SUBST([MINGW_GNUTLS_DLL])
AC_SUBST([MINGW_NEON_DLL])
AC_SUBST([MINGW_TASN1_DLL])
fi

dnl ===================================================================
dnl Check for system openssl
dnl ===================================================================
if test "$_os" = "Darwin" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o \
        "$_os" = "DragonFly" && test "$with_system_openssl" != "no"; then
    with_system_openssl=yes
fi
AC_MSG_CHECKING([which libssl to use])
if test "$with_system_openssl" = "yes"; then
    AC_MSG_RESULT([external])
    # Mac OS builds should get out without extra stuff is the Mac porters'
    # wish. And pkg-config is although Xcode ships a .pc for openssl
    if test "$_os" = "Darwin" -o "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o \
            "$_os" = "DragonFly"; then
        OPENSSL_CFLAGS=
        OPENSSL_LIBS="-lssl -lcrypto"
    else
        PKG_CHECK_MODULES( OPENSSL, openssl )
    fi
    SYSTEM_OPENSSL=YES
    libo_MINGW_CHECK_DLL([SSL], [libssl])
    libo_MINGW_CHECK_DLL([CRYPTO], [libcrypto])
else
    AC_MSG_RESULT([internal])
    SYSTEM_OPENSSL=NO
    BUILD_TYPE="$BUILD_TYPE OPENSSL"
fi
AC_SUBST(SYSTEM_OPENSSL)
AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LIBS)
AC_SUBST([MINGW_SSL_DLL])
AC_SUBST([MINGW_CRYPTO_DLL])

dnl ===================================================================
dnl Check for system redland
dnl ===================================================================
AC_MSG_CHECKING([which redland library to use])
if test "$with_system_redland" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_REDLAND=YES
    dnl versions before 1.0.8 write RDF/XML that is useless for ODF (@xml:base)
    PKG_CHECK_MODULES(REDLAND, redland >= 1.0.8)
    libo_MINGW_CHECK_DLL([REDLAND], [librdf])
    libo_MINGW_TRY_DLL([RAPTOR], [libraptor])
    libo_MINGW_TRY_DLL([RASQAL], [librasqal])
    libo_MINGW_TRY_DLL([SQLITE3], [libsqlite3])
else
    AC_MSG_RESULT([internal])
    BUILD_TYPE="$BUILD_TYPE REDLAND"
    SYSTEM_REDLAND=NO
fi
AC_SUBST(SYSTEM_REDLAND)
AC_SUBST(REDLAND_CFLAGS)
AC_SUBST(REDLAND_LIBS)
AC_SUBST([MINGW_RAPTOR_DLL])
AC_SUBST([MINGW_RASQAL_DLL])
AC_SUBST([MINGW_REDLAND_DLL])
AC_SUBST([MINGW_SQLITE3_DLL])

dnl ===================================================================
dnl Check for system hunspell
dnl ===================================================================
AC_MSG_CHECKING([which libhunspell to use])
if test "$with_system_hunspell" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_HUNSPELL=YES
    AC_LANG_PUSH([C++])
    PKG_CHECK_MODULES(HUNSPELL, hunspell, HUNSPELL_PC="TRUE", HUNSPELL_PC="" )
    if test "$HUNSPELL_PC" != "TRUE"; then
        AC_CHECK_HEADER(hunspell.hxx, [],
            [
            AC_CHECK_HEADER(hunspell/hunspell.hxx, [ HUNSPELL_CFLAGS=-I/usr/include/hunspell ],
            [AC_MSG_ERROR(hunspell headers not found.)], [])
            ], [])
        AC_CHECK_LIB([hunspell], [main], [:],
           [ AC_MSG_ERROR(hunspell library not found.) ], [])
        HUNSPELL_LIBS=-lhunspell
    fi
    AC_LANG_POP([C++])
    libo_MINGW_CHECK_DLL([HUNSPELL], [libhunspell-1.3])
else
    AC_MSG_RESULT([internal])
    SYSTEM_HUNSPELL=NO
    BUILD_TYPE="$BUILD_TYPE HUNSPELL"
fi
AC_SUBST(SYSTEM_HUNSPELL)
AC_SUBST(HUNSPELL_CFLAGS)
AC_SUBST(HUNSPELL_LIBS)
AC_SUBST([MINGW_HUNSPELL_DLL])

dnl ===================================================================
dnl Checking for altlinuxhyph
dnl ===================================================================
AC_MSG_CHECKING([which altlinuxhyph to use])
if test "$with_system_altlinuxhyph" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_HYPH=YES
    AC_CHECK_HEADER(hyphen.h, [],
       [ AC_MSG_ERROR(altlinuxhyph headers not found.)], [])
    AC_CHECK_MEMBER(struct _HyphenDict.cset, [],
       [ AC_MSG_ERROR(no. You are sure you have altlinuyhyph headers?)],
       [#include <hyphen.h>])
    AC_CHECK_LIB(hyphen, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyphen],
        [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
    if test -z "$HYPHEN_LIB"; then
        AC_CHECK_LIB(hyph, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhyph],
           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
    fi
    if test -z "$HYPHEN_LIB"; then
        AC_CHECK_LIB(hnj, hnj_hyphen_hyphenate2, [HYPHEN_LIB=-lhnj],
           [ AC_MSG_ERROR(altlinuxhyph library not found or too old.)], [])
    fi
    libo_MINGW_CHECK_DLL([HYPHEN], [libhyphen])
else
    AC_MSG_RESULT([internal])
    SYSTEM_HYPH=NO
    BUILD_TYPE="$BUILD_TYPE HYPHEN"
fi
AC_SUBST(SYSTEM_HYPH)
AC_SUBST(HYPHEN_LIB)
AC_SUBST([MINGW_HYPHEN_DLL])

dnl ===================================================================
dnl Checking for mythes
dnl ===================================================================
AC_MSG_CHECKING([which mythes to use])
if test "$with_system_mythes" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_MYTHES=YES
    AC_LANG_PUSH([C++])
    PKG_CHECK_MODULES(MYTHES, mythes, MYTHES_PKGCONFIG=yes, MYTHES_PKGCONFIG=no)
    if test "$MYTHES_PKGCONFIG" = "no"; then
        AC_CHECK_HEADER(mythes.hxx, [],
            [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
        AC_CHECK_LIB([mythes-1.2], [main], [:],
            [ MYTHES_FOUND=no], [])
    if test "$MYTHES_FOUND" = "no"; then
        AC_CHECK_LIB(mythes, main, [MYTHES_FOUND=yes],
                [ MYTHES_FOUND=no], [])
    fi
    if test "$MYTHES_FOUND" = "no"; then
        AC_MSG_ERROR([mythes library not found!.])
    fi
    fi
    AC_LANG_POP([C++])
    libo_MINGW_CHECK_DLL([MYTHES], [libmythes-1.2])
else
    AC_MSG_RESULT([internal])
    SYSTEM_MYTHES=NO
    BUILD_TYPE="$BUILD_TYPE MYTHES"
fi
AC_SUBST(SYSTEM_MYTHES)
AC_SUBST(MYTHES_CFLAGS)
AC_SUBST(MYTHES_LIBS)
AC_SUBST([MINGW_MYTHES_DLL])

dnl ===================================================================
dnl Checking for lpsolve
dnl ===================================================================
AC_MSG_CHECKING([which lpsolve to use])
if test "$with_system_lpsolve" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LPSOLVE=YES
    AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
       [ AC_MSG_ERROR(lpsolve headers not found.)], [])
    save_LIBS=$LIBS
    # some systems need this. Like Ubuntu....
    AC_CHECK_LIB(m, floor)
    AC_CHECK_LIB(dl, dlopen)
    AC_CHECK_LIB([lpsolve55], [make_lp], [:],
        [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
    LIBS=$save_LIBS
    libo_MINGW_CHECK_DLL([LPSOLVE], [lpsolve55])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LPSOLVE=NO
    BUILD_TYPE="$BUILD_TYPE LPSOLVE"
fi
AC_SUBST(SYSTEM_LPSOLVE)
AC_SUBST([MINGW_LPSOLVE_DLL])

dnl ===================================================================
dnl Checking for libexttextcat
dnl ===================================================================
AC_MSG_CHECKING([which libexttextcat to use])
if test "$with_system_libexttextcat" = "yes"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBEXTTEXTCAT=YES
    PKG_CHECK_MODULES([LIBEXTTEXTCAT], [libexttextcat >= 3.1.1])
    SYSTEM_LIBEXTTEXTCAT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libexttextcat`
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBEXTTEXTCAT=NO
    BUILD_TYPE="$BUILD_TYPE LIBEXTTEXTCAT"
fi
AC_SUBST(SYSTEM_LIBEXTTEXTCAT)
AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
AC_SUBST(LIBEXTTEXTCAT_CFLAGS)
AC_SUBST(LIBEXTTEXTCAT_LIBS)

dnl ***************************************
dnl testing libc version for Linux...
dnl ***************************************
if test "$_os" = "Linux"; then
    AC_MSG_CHECKING([whether libc is >= 2.1.1])
    exec 6>/dev/null # no output
    AC_CHECK_LIB(c, gnu_get_libc_version, HAVE_LIBC=yes; export HAVE_LIBC)
    exec 6>&1 # output on again
    if test "$HAVE_LIBC"; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_ERROR([no, upgrade libc])
    fi
fi

if test "$_os" != "WINNT"; then
    AC_CHECK_FUNCS(getopt, HAVE_GETOPT=YES, [HAVE_GETOPT=NO])
    AC_CHECK_FUNCS(readdir_r, HAVE_READDIR_R=YES, [HAVE_READDIR_R=NO])
    if test "$HAVE_GETOPT" = "YES" -a "$HAVE_READDIR_R" = "YES"; then
        SYSTEM_LIBC=YES
    fi
else
    HAVE_GETOPT=NO
    HAVE_READDIR_R=NO
    SYSTEM_LIBC=YES
fi
AC_SUBST(HAVE_GETOPT)
AC_SUBST(HAVE_READDIR_R)
AC_SUBST(SYSTEM_LIBC)

dnl =========================================
dnl Check for the Windows  SDK.
dnl =========================================
dnl FIXME: I don't know yet if the Windows SDK works with MinGW, keep it until I know better,
dnl and add "-a \( "$WITH_MINGW" != "yes" \)" then
if test "$_os" = "WINNT"; then
    AC_MSG_CHECKING([for Windows SDK])
    if test "$build_os" = "cygwin"; then
        if test -z "$with_windows_sdk_home"; then
            # This first line will detect a February 2003 Microsoft Platform SDK
            WINDOWS_SDK_HOME=`./oowintool --windows-sdk-home`
            # But there might be also an April 2005 PSDK, unfortunately MS changed
            # the registry entry. (we prefer the old version!?)
            if test -z "$WINDOWS_SDK_HOME"; then
                WINDOWS_SDK_HOME=`cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/MicrosoftSDK/InstalledSDKs/*/Install\ Dir 2> /dev/null | tr '\000' '\n' | head -n 1`
            fi
            # normalize if found
            if test -n "$WINDOWS_SDK_HOME"; then
                WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
                WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`

                #If this sdk is incomplete, lets see if the one
                #recommended to be installed is available
                if test ! -x "$WINDOWS_SDK_HOME/bin/msiinfo.exe"; then
                    WINDOWS_SDK7_HOME=`cat "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows/v7.1/InstallationFolder" 2> /dev/null | tr '\000' '\n' | head -n 1`
                    if test -n "$WINDOWS_SDK7_HOME"; then
                        WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK7_HOME"`
                        WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
                    fi
                fi
            fi
        else
            WINDOWS_SDK_HOME=`cygpath -u "$with_windows_sdk_home"`
        fi
    fi
    if test -n "$WINDOWS_SDK_HOME"; then
        # Remove a possible trailing backslash
        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`
        # Problem with current PSDK (iz 49865)
        # (What "current" does that mean?)
        if test -f "$WINDOWS_SDK_HOME/Lib/libcp.lib"; then
            AC_MSG_ERROR([
Some modules do not build correctly with MS Platform SDK - April 2005
Edition if the library ($WINDOWS_SDK_HOME/Lib/libcp.lib) is found.
Remove/rename/backup that file and restart configure. Details about this
problem can be found in issue 49856.])
        fi

        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
            HAVE_PSDK_H="yes"
        else
            HAVE_PSDK_H="no"
        fi
        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
            HAVE_PSDK_LIB="yes"
        else
            HAVE_PSDK_LIB="no"
        fi

        if test "$HAVE_PSDK_H" = "no" -o "$HAVE_PSDK_LIB" = "no"; then
            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
the  Windows SDK are installed.])
        fi

        if test ! -x "$WINDOWS_SDK_HOME/bin/msiinfo.exe" \
             -o ! -x "$WINDOWS_SDK_HOME/bin/msidb.exe" \
             -o ! -x "$WINDOWS_SDK_HOME/bin/uuidgen.exe" \
             -o ! -x "$WINDOWS_SDK_HOME/bin/msitran.exe"; then
            AC_MSG_ERROR([Some (all) files of the Windows Installer SDK are missing, please install.])
        fi
    fi

    if test -z "$WINDOWS_SDK_HOME"; then
        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway])
    elif echo $WINDOWS_SDK_HOME | grep "v6.1" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([found Windows SDK 6.1 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "v6.0" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([found Windows SDK 6.0 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "v7" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([found Windows SDK 7 ($WINDOWS_SDK_HOME)])
    else
        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
    fi
    PathFormat "$WINDOWS_SDK_HOME"
    WINDOWS_SDK_HOME="$formatted_path"
    if test "$build_os" = "cygwin"; then
        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/include"
    fi
fi
AC_SUBST(WINDOWS_SDK_HOME)

dnl =========================================
dnl Check for uuidgen
dnl =========================================
if test "$_os" = "WINNT"; then
    if test "$WITH_MINGW" = "yes"; then
        AC_PATH_PROG([UUIDGEN], [uuid])
        if test -z "$UUIDGEN"; then
            AC_MSG_WARN([uuid is needed for dev-install])
        fi
    else
        # presence is already tested above in the WINDOWS_SDK_HOME check
        UUIDGEN=uuidgen.exe
        AC_SUBST(UUIDGEN)
    fi
fi

dnl =========================================
dnl Check for the Microsoft DirectX SDK.
dnl =========================================
if test -n "$ENABLE_DIRECTX" -a "$_os" = "WINNT"; then
    AC_MSG_CHECKING([for DirectX SDK])
    if test "$build_os" = "cygwin"; then
        if test -z "$with_directx_home"; then
            dnl A standard installation of the DirectX SDK sets $DXSDK_DIR
            if test -n "$DXSDK_DIR"; then
                DIRECTXSDK_HOME=`cygpath -d "$DXSDK_DIR"`
                DIRECTXSDK_HOME=`cygpath -u "$DIRECTXSDK_HOME"`
            fi
            # At this point $DIRECTXSDK_HOME might still be undefined. This will lead to
            # the "DirectX SDK not found" error later
        else
            DIRECTXSDK_HOME=`cygpath -u "$with_directx_home"`
        fi
        # Remove a possible trailing backslash
        DIRECTXSDK_HOME=`echo $DIRECTXSDK_HOME | $SED 's/\/$//'`
    elif test -n "$with_directx_home"; then
        DIRECTXSDK_HOME="$with_directx_home"
    fi

    if test -f "$DIRECTXSDK_HOME/Include/ddraw.h" -o -f "$DIRECTXSDK_HOME/Include/d3d9.h"; then
        HAVE_DIRECTXSDK_H="yes"
    else
        HAVE_DIRECTXSDK_H="no"
    fi

    # MS changed the location of the libraries with Dec 2004 DirectX SDK
    if test -d "$DIRECTXSDK_HOME/lib/x86"; then
        DIRECTXSDK_LIB="$DIRECTXSDK_HOME/lib/x86"
    else
        DIRECTXSDK_LIB="$DIRECTXSDK_HOME/lib"
    fi
    PathFormat "$DIRECTXSDK_LIB"
    DIRECTXSDK_LIB="$formatted_path"

    if test -f "$DIRECTXSDK_LIB/ddraw.lib" -o -f "$DIRECTXSDK_LIB/d3d9.lib"; then
        HAVE_DIRECTXSDK_LIB="yes"
    else
        HAVE_DIRECTXSDK_LIB="no"
    fi

    if test "$HAVE_DIRECTXSDK_H" = "yes" -a "$HAVE_DIRECTXSDK_LIB" = "yes"; then
        AC_MSG_RESULT([found])
    else
        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway])
    fi
    PathFormat "$DIRECTXSDK_HOME"
    DIRECTXSDK_HOME="$formatted_path"
    SOLARINC="$SOLARINC -I$DIRECTXSDK_HOME/include"
fi
AC_SUBST(DIRECTXSDK_HOME)
AC_SUBST(DIRECTXSDK_LIB)

dnl ***************************************
dnl Checking for bison and flex
dnl ***************************************
AC_PATH_PROG(BISON, bison)
ANCIENT_BISON="NO"
if test -z "$BISON"; then
    AC_MSG_ERROR([no bison found in \$PATH, install it])
else
    AC_MSG_CHECKING([the bison version])
    _bison_version=`$BISON --version | grep GNU | $SED -e 's@^[[^0-9]]*@@' -e 's@ .*@@' -e 's@,.*@@'`;
    _bison_longver=`echo $_bison_version | $AWK -F. '{ print \$1*1000+\$2}'`
    # Accept newer than 1.875 or older(equal) than 1.75
    if test "$_bison_longver" -ge 1875 -o "$_bison_longver" -le 1075; then
        if test "$_bison_version" = "1.875"; then
            AC_MSG_WARN([suspect ($BISON $_bison_version)])
            echo "Suspect ($BISON $_bison_version) suggest upgrade" >> warn
        else
            AC_MSG_RESULT([checked ($BISON $_bison_version)])
        fi
    else
        AC_MSG_ERROR([failed ($BISON $_bison_version need 1.875+ (or 1.75 and older))])
    fi
    if test "$_bison_longver" -lt 2000; then
        ANCIENT_BISON="YES"
    fi
fi
AC_SUBST(ANCIENT_BISON)

AC_PATH_PROG(FLEX, flex)
if test -z "$FLEX"; then
    AC_MSG_ERROR([no flex found in \$PATH, install it])
fi
AC_SUBST([FLEX])
dnl ***************************************
dnl Checking for patch
dnl ***************************************
AC_PATH_PROG(PATCH, patch)
if test -z "$PATCH"; then
    AC_MSG_ERROR([\"patch\" not found in \$PATH, install it])
fi

dnl On Solaris, FreeBSD or MacOS X, check if --with-gnu-patch was used
if test "$_os" = "SunOS" -o "$_os" = "FreeBSD" -o "$_os" = "Darwin"; then
    if test -z "$with_gnu_patch"; then
        GNUPATCH=$PATCH
    else
        if test -x "$with_gnu_patch"; then
            GNUPATCH=$with_gnu_patch
        else
            AC_MSG_ERROR([--with-gnu-patch did not point to an executable])
        fi
    fi

    AC_MSG_CHECKING([whether $GNUPATCH is GNU patch])
    if $GNUPATCH --version | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_ERROR([no, GNU patch needed. install or specify with --with-gnu-patch=/path/to/it])
    fi
else
    GNUPATCH=$PATCH
fi

dnl We also need to check for --with-gnu-cp

if test -z "$with_gnu_cp"; then
    # check the place where the good stuff is hidden on Solaris...
    if test -x /usr/gnu/bin/cp; then
        GNUCP=/usr/gnu/bin/cp
    else
        AC_PATH_PROGS(GNUCP, gnucp cp)
    fi
    if test -z $GNUCP; then
        AC_MSG_ERROR([Neither gnucp nor cp found. Install GNU cp and/or specify --with-gnu-cp=/path/to/it])
    fi
else
    if test -x "$with_gnu_cp"; then
        GNUCP=$with_gnu_cp
    else
        AC_MSG_ERROR([--with-gnu-cp did not point to an executable])
    fi
fi

AC_MSG_CHECKING([whether $GNUCP is GNU cp from coreutils with preserve= support])
if $GNUCP --version 2>/dev/null | grep "coreutils" >/dev/null 2>/dev/null; then
    AC_MSG_RESULT([yes])
elif $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
    AC_MSG_RESULT([yes])
else
    case "$build_os" in
    darwin*|netbsd*|openbsd*|freebsd*|dragonfly*|aix*)
        x_GNUCP=[\#]
        GNUCP=''
        AC_MSG_RESULT([no gnucp found - using the system's cp command])
        ;;
    *)
        AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
        ;;
    esac
fi

AC_SUBST(GNUPATCH)
AC_SUBST(GNUCP)
AC_SUBST(x_GNUCP)

dnl ***************************************
dnl testing assembler path
dnl ***************************************
ML_EXE=""
if test "$_os" = "WINNT" -a "$WITH_MINGW" != "yes"; then
    if test "$CL_X64" = ""; then
        assembler=ml.exe
        assembler_bin=bin
    else
        assembler=ml64.exe
        assembler_bin=bin/amd64
    fi
    if test -n "$with_asm_home"; then
        with_asm_home=`cygpath -u "$with_asm_home"`
    fi
    if test -x "$with_asm_home/$assembler"; then
        AC_MSG_CHECKING([$assembler assembler path])
        AC_MSG_RESULT([$with_asm_home/$assembler])
        ML_EXE="$with_asm_home/$assembler"
    else
        AC_PATH_PROG(ML_EXE, $assembler)
        if test -z "$ML_EXE"; then
            AC_MSG_CHECKING([$with_cl_home/$assembler_bin/$assembler])
            if test -x "$with_cl_home/$assembler_bin/$assembler"; then
                with_asm_home=$with_cl_home/$assembler_bin
                AC_MSG_RESULT([found])
                ML_EXE="$with_cl_home/$assembler_bin/$assembler"
            else
                AC_MSG_ERROR([Configure did not find $assembler assembler.])
            fi
        else
            with_asm_home="ASM_IN_PATH"
            ML_EXE="$assembler"
        fi
    fi
    PathFormat "$with_asm_home"
    ASM_HOME="$formatted_path"
else
    ASM_HOME=""
fi

AC_SUBST(ML_EXE)

dnl ===================================================================
dnl We need zip and unzip
dnl ===================================================================
AC_PATH_PROG(ZIP, zip)
test -z "$ZIP" && AC_MSG_ERROR([zip is required])
if ! "$ZIP" --filesync < /dev/null 2>/dev/null > /dev/null; then
    AC_MSG_ERROR([Zip version 3.0 or newer is required to build, please install or use --with-zip-home],,)
fi

AC_PATH_PROG(UNZIP, unzip)
test -z "$UNZIP" && AC_MSG_ERROR([unzip is required])

dnl ===================================================================
dnl Zip must be a specific type for different build types.
dnl ===================================================================
if test $build_os = cygwin; then
    if test -n "`$ZIP -h | $GREP -i WinNT`"; then
        AC_MSG_ERROR([$ZIP is not the required Cygwin version of Info-ZIP's zip.exe.])
    fi
fi

dnl ===================================================================
dnl Test which vclplugs have to be built.
dnl ===================================================================
R=""
GTK3_CFLAGS=""
GTK3_LIBS=""
ENABLE_GTK3=""
if test "x$enable_gtk3" = "xyes"; then
    if test "$with_system_cairo" != yes; then
        echo "System cairo required for gtk3 support, please use --with-system-cairo"
    fi
    PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.2 gtk+-unix-print-3.0 cairo, ENABLE_GTK3="TRUE", ENABLE_GTK3="")
    if test "x$ENABLE_GTK3" = "xTRUE"; then
        R="gtk3"
    else
        AC_MSG_ERROR([gtk3 libraries of the correct versions, not found])
    fi
fi
AC_SUBST(GTK3_LIBS)
AC_SUBST(GTK3_CFLAGS)
AC_SUBST(ENABLE_GTK3)

AC_MSG_CHECKING([which VCLplugs shall be built])
ENABLE_GTK=""
if test "x$enable_gtk" = "xyes"; then
    ENABLE_GTK="TRUE"
    R="gtk $R"
fi
AC_SUBST(ENABLE_GTK)

ENABLE_TDE=""
if test "x$enable_tde" = "xyes"; then
    # Libs kab and tdeab in connectivity and kdeab and tdeab in shell
    # are built from the same sources. So we only allow one of them.
    if test "x$enable_kde" = "xyes"; then
        AC_MSG_ERROR([enabling both KDE and TDE is not supported])
    fi
    ENABLE_TDE="TRUE"
    R="$R tde"
fi
AC_SUBST(ENABLE_TDE)

ENABLE_KDE=""
if test "x$enable_kde" = "xyes"; then
    ENABLE_KDE="TRUE"
    R="$R kde"
fi
AC_SUBST(ENABLE_KDE)

ENABLE_KDE4=""
if test "x$enable_kde4" = "xyes"; then
    ENABLE_KDE4="TRUE"
    R="$R kde4"
fi
AC_SUBST(ENABLE_KDE4)

ENABLE_HEADLESS=""
if test "x$enable_headless" = "xyes"; then
    ENABLE_HEADLESS="TRUE"
    SCPDEFS="$SCPDEFS -DLIBO_HEADLESS"
    R="headless"
fi
AC_SUBST(ENABLE_HEADLESS)

if test -z "$R"; then
    AC_MSG_RESULT([none])
else
    AC_MSG_RESULT([$R])
fi

dnl ===================================================================
dnl GCONF check
dnl ===================================================================

ENABLE_GCONF=""
AC_MSG_CHECKING([whether to enable GConf support])
if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gconf" = "yes"; then
    ENABLE_GCONF="TRUE"
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES( GCONF, gconf-2.0 ORBit-2.0 )
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(GCONF_LIBS)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(ENABLE_GCONF)

dnl ===================================================================
dnl Gnome VFS check
dnl ===================================================================

ENABLE_GNOMEVFS=""
AC_MSG_CHECKING([whether to enable GNOME VFS support])
if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gnome_vfs" = "yes" -a "$enable_gconf" = "yes"; then
    ENABLE_GNOMEVFS="TRUE"
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES( GNOMEVFS, gnome-vfs-2.0 >= 2.6.0 )
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(GNOMEVFS_LIBS)
AC_SUBST(GNOMEVFS_CFLAGS)
AC_SUBST(ENABLE_GNOMEVFS)

dnl ===================================================================
dnl Check whether the gtk 2.0 libraries are available.
dnl ===================================================================

GTK_CFLAGS=""
GTK_LIBS=""
ENABLE_SYSTRAY_GTK=""
ENABLE_DBUS=""
DBUS_CFLAGS=""
DBUS_LIBS=""
if test  "$test_gtk" = "yes"; then

    if test "$ENABLE_GTK" = "TRUE"; then
        PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4 gdk-pixbuf-xlib-2.0 >= 2.2 ,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
        PKG_CHECK_MODULES(GTHREAD, gthread-2.0,,AC_MSG_ERROR([requirements to build the gtk-plugin not met. Use --disable-gtk or install the missing packages]))
        BUILD_TYPE="$BUILD_TYPE GTK"

        if test "x$enable_systray" = "xyes"; then
            PKG_CHECK_MODULES( GTK210, gtk+-2.0 >= 2.10.0,
                            [ ENABLE_SYSTRAY_GTK="TRUE" ],
                            [ ENABLE_SYSTRAY_GTK="" ])
        fi

        AC_MSG_CHECKING([whether to enable Gtk print dialog support])
        PKG_CHECK_MODULES([GTK_PRINT], [gtk+-unix-print-2.0 >= 2.10.0],
                          [ENABLE_GTK_PRINT="TRUE"],
                          [ENABLE_GTK_PRINT=""])

        AC_MSG_CHECKING([whether to enable DBUS support])
        if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_dbus" = "yes"; then
            ENABLE_DBUS="TRUE"
            AC_MSG_RESULT([yes])
            PKG_CHECK_MODULES( DBUS, dbus-glib-1 >= 0.70 )
        else
            AC_MSG_RESULT([no])
        fi

        AC_MSG_CHECKING([whether to enable GIO support])
        if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
            if test "$ENABLE_GNOMEVFS" = "TRUE"; then
                AC_MSG_ERROR([please use --enable-gio only together with --disable-gnome-vfs.])
            fi
            ENABLE_GIO="TRUE"
            AC_MSG_RESULT([yes])
            PKG_CHECK_MODULES( GIO, gio-2.0 )
        else
            AC_MSG_RESULT([no])
        fi
    fi
fi
AC_SUBST(ENABLE_GIO)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
AC_SUBST(ENABLE_DBUS)
AC_SUBST(ENABLE_SYSTRAY_GTK)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
AC_SUBST(GTHREAD_CFLAGS)
AC_SUBST(GTHREAD_LIBS)
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
AC_SUBST([ENABLE_GTK_PRINT])
AC_SUBST([GTK_PRINT_CFLAGS])
AC_SUBST([GTK_PRINT_LIBS])

PKG_CHECK_MODULES( LIBPNG, libpng, ENABLE_QUICKSTART_LIBPNG="TRUE", ENABLE_QUICKSTART_LIBPNG="" )
AC_SUBST(LIBPNG_LIBS)
AC_SUBST(LIBPNG_CFLAGS)

AC_MSG_CHECKING([whether to enable libpng linking in quickstarter])
if test "x$enable_unix_qstart_libpng" != "xno"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
    ENABLE_QUICKSTART_LIBPNG=""
fi
AC_SUBST(ENABLE_QUICKSTART_LIBPNG)

SPLIT_APP_MODULES=""
if test "$enable_split_app_modules" = "yes"; then
    SPLIT_APP_MODULES="YES"
fi
AC_SUBST(SPLIT_APP_MODULES)

SPLIT_OPT_FEATURES=""
if test "$enable_split_opt_features" = "yes"; then
    SPLIT_OPT_FEATURES="YES"
fi
AC_SUBST(SPLIT_OPT_FEATURES)

if test $_os = Darwin -o $_os = WINNT; then
    if test "$enable_cairo_canvas" = yes; then
        AC_MSG_ERROR([The cairo canvas should not be used for this platform])
    fi
    enable_cairo_canvas=no
elif test -z "$enable_cairo_canvas"; then
    enable_cairo_canvas=yes
fi

ENABLE_CAIRO_CANVAS=""
if test "$enable_cairo_canvas" = "yes"; then
    ENABLE_CAIRO_CANVAS="TRUE"
fi
AC_SUBST(ENABLE_CAIRO_CANVAS)

dnl ===================================================================
dnl Check whether the GStreamer libraries are available.
dnl ===================================================================

ENABLE_GSTREAMER=""

if test  "$build_gstreamer" = "yes"; then

    AC_MSG_CHECKING([whether to enable the GStreamer avmedia backend])
    if test "x$enable_gstreamer" != "xno"; then
        ENABLE_GSTREAMER="TRUE"
        AC_MSG_RESULT([yes])
        PKG_CHECK_MODULES( GSTREAMER, gstreamer-0.10 gstreamer-plugins-base-0.10 )
    else
        AC_MSG_RESULT([no])
    fi
fi

AC_SUBST(ENABLE_GSTREAMER)

dnl ===================================================================
dnl Check whether the OpenGL libraries are available
dnl ===================================================================

AC_MSG_CHECKING([whether to build the OpenGL Transitions component])
ENABLE_OPENGL=

if test "$_os" = "Darwin"; then
    # We use frameworks on Mac OS X, no need for detail checks
    ENABLE_OPENGL=TRUE
    SYSTEM_MESA_HEADERS=YES
    AC_MSG_RESULT([yes])
else
    if test "x$enable_opengl" != "xno"; then
        if test "$_os" != "WINNT"; then
            save_LDFLAGS=$LDFLAGS
            LDFLAGS="$LDFLAGS -lm"
            AC_MSG_RESULT([yes])
            AC_CHECK_LIB([GL], [main], [:],
                      [AC_MSG_ERROR(libGL not installed or functional)], [])
            AC_CHECK_LIB([GLU], [main], [:],
                      [AC_MSG_ERROR(libGLU not installed or functional)], [])
            ENABLE_OPENGL=TRUE
            LDFLAGS=$save_LDFLAGS

            dnl ===================================================================
            dnl Check for system Mesa
            dnl ===================================================================
            AC_MSG_CHECKING([which Mesa headers to use])
            if test "$with_system_mesa_headers" = "yes"; then
                AC_MSG_RESULT([external])
                SYSTEM_MESA_HEADERS=YES
                AC_LANG_PUSH(C)
                AC_CHECK_HEADER(GL/glxext.h, [],
                   [ AC_MSG_ERROR(mesa headers not found.)], [#include <GL/glx.h>])
                AC_MSG_CHECKING([whether GL/glxext.h defines PFNGLXBINDTEXIMAGEEXTPROC])
                AC_EGREP_HEADER(PFNGLXBINDTEXIMAGEEXTPROC, GL/glxext.h, [AC_MSG_RESULT([yes])], AC_MSG_ERROR(no))
                AC_LANG_POP(C)
            else
                AC_MSG_RESULT([internal])
                SYSTEM_MESA_HEADERS=NO
                BUILD_TYPE="$BUILD_TYPE MESA"
            fi
        else
            AC_MSG_RESULT([not on Windows])
        fi
    else
       AC_MSG_RESULT([no])
    fi
fi

AC_SUBST(SYSTEM_MESA_HEADERS)
AC_SUBST(ENABLE_OPENGL)

# presenter minimizer extension?
AC_MSG_CHECKING([whether to build the Presentation Minimizer extension])
if test "x$enable_ext_presenter_minimizer" != "xno" -a "x$enable_extension_integration" != "xno"; then
   AC_MSG_RESULT([yes])
   ENABLE_MINIMIZER=YES
else
   AC_MSG_RESULT([no])
   ENABLE_MINIMIZER=NO
   SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MINIMIZER"
fi
AC_SUBST(ENABLE_MINIMIZER)

# presenter console extension?
AC_MSG_CHECKING([whether to build the Presenter Console extension])
if test "x$enable_ext_presenter_console" != "xno" -a "x$enable_extension_integration" != "xno"; then
   AC_MSG_RESULT([yes])
   ENABLE_PRESENTER_SCREEN=YES
else
   AC_MSG_RESULT([no])
   ENABLE_PRESENTER_SCREEN=NO
   SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_PRESENTER_SCREEN"
fi
AC_SUBST(ENABLE_PRESENTER_SCREEN)

# pdf import extension?
AC_MSG_CHECKING([whether to build the PDF Import extension])
if test "x$enable_ext_pdfimport" != "xno" -a "x$enable_extension_integration" != "xno"; then
  AC_MSG_RESULT([yes])
  ENABLE_PDFIMPORT=YES

  dnl ===================================================================
  dnl Check for system poppler
  dnl ===================================================================
  AC_MSG_CHECKING([which pdf backend to use])
  if test "$with_system_poppler" = "yes"; then
      AC_MSG_RESULT([external])
      SYSTEM_POPPLER=YES
      PKG_CHECK_MODULES( POPPLER, poppler >= 0.8.0 )
      AC_LANG_PUSH([C++])
      save_CXXFLAGS=$CXXFLAGS
      save_CPPFLAGS=$CPPFLAGS
      CXXFLAGS="$CXXFLAGS $POPPLER_CFLAGS"
      CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
      AC_CHECK_HEADER([cpp/poppler-version.h], [],
                   [AC_MSG_ERROR([cpp/poppler-version.h not found. Install poppler])], [])
      CXXFLAGS=$save_CXXFLAGS
      CPPFLAGS=$save_CPPFLAGS
      AC_LANG_POP([C++])
  else
      AC_MSG_RESULT([internal])
      SYSTEM_POPPLER=NO
      BUILD_TYPE="$BUILD_TYPE XPDF"
  fi
else
  AC_MSG_RESULT([no])
  ENABLE_PDFIMPORT=NO
  SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_PDFIMPORT"
fi
AC_SUBST(ENABLE_PDFIMPORT)
AC_SUBST(SYSTEM_POPPLER)
AC_SUBST(POPPLER_CFLAGS)
AC_SUBST(POPPLER_LIBS)


if test "$ENABLE_PRESENTER_SCREEN" = "YES" -o "$ENABLE_MINIMIZER" = "YES" -o "$ENABLE_PDFIMPORT" = "YES"; then
   AC_MSG_CHECKING([for sdext module])
   BUILD_TYPE="$BUILD_TYPE SDEXT"
fi

AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
  AC_MSG_RESULT([yes])
  AC_MSG_CHECKING([for swext module])
  ENABLE_MEDIAWIKI=YES
  BUILD_TYPE="$BUILD_TYPE SWEXT"
  if test  "x$with_java" = "xno"; then
    AC_MSG_ERROR([Wiki Publisher requires Java! Enable Java if you want to build it.])
  fi
else
  AC_MSG_RESULT([no])
  ENABLE_MEDIAWIKI=NO
  SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_MEDIAWIKI"
fi
AC_SUBST(ENABLE_MEDIAWIKI)

if test "$ENABLE_MEDIAWIKI" = "YES"; then
    AC_MSG_CHECKING([which Servlet API Jar to use])
    if test "$with_system_servlet_api" = "yes"; then
        AC_MSG_RESULT([external])
        SYSTEM_SERVLETAPI=YES
        if test -z "$SERVLETAPI_JAR"; then
            SERVLETAPI_JAR=/usr/share/java/servlet-api.jar
        fi
        AC_CHECK_FILE($SERVLETAPI_JAR, [],
              [AC_MSG_ERROR(servlet-api.jar not found.)], [])
    else
        AC_MSG_RESULT([internal])
        SYSTEM_SERVLETAPI=NO
        BUILD_TYPE="$BUILD_TYPE TOMCAT"
    fi
fi
AC_SUBST(SYSTEM_SERVLETAPI)
AC_SUBST(SERVLETAPI_JAR)

AC_MSG_CHECKING([whether to build the Report Builder extension])
if test "$enable_ext_report_builder" != "no" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
    AC_MSG_RESULT([yes])
    ENABLE_REPORTBUILDER=YES
    AC_MSG_CHECKING([for reportbuilder module])
    AC_MSG_CHECKING([which jfreereport libs to use])
    if test "$with_system_jfreereport" = "yes"; then
        SYSTEM_JFREEREPORT=YES
        AC_MSG_RESULT([external])
        if test -z $SAC_JAR; then
            SAC_JAR=/usr/share/java/sac.jar
        fi
        AC_CHECK_FILE($SAC_JAR, [],
             [AC_MSG_ERROR(sac.jar not found.)], [])

        if test -z $LIBXML_JAR; then
            AC_CHECK_FILE(/usr/share/java/libxml-1.0.0.jar,
                [ LIBXML_JAR=/usr/share/java/libxml-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/libxml.jar,
                       [ LIBXML_JAR=/usr/share/java/libxml.jar ],
                       [AC_MSG_ERROR(libxml.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBXML_JAR, [],
                 [AC_MSG_ERROR(libxml.jar not found.)], [])
        fi

        if test -z $FLUTE_JAR; then
            AC_CHECK_FILE(/usr/share/java/flute-1.3.0.jar,
                [ FLUTE_JAR=/usr/share/java/flute-1.3.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/flute.jar,
                        [ FLUTE_JAR=/usr/share/java/flute.jar ],
                        [ AC_MSG_ERROR(flute-1.3.0.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($FLUTE_JAR, [],
                 [AC_MSG_ERROR(flute-1.3.0.jar not found.)], [])
        fi

        if test -z $JFREEREPORT_JAR; then
            AC_CHECK_FILE(/usr/share/java/flow-engine-0.9.2.jar,
                [ JFREEREPORT_JAR=/usr/share/java/flow-engine-0.9.2.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/flow-engine.jar,
                        [ JFREEREPORT_JAR=/usr/share/java/flow-engine.jar ],
                        [AC_MSG_ERROR(jfreereport.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($JFREEREPORT_JAR, [],
                 [AC_MSG_ERROR(jfreereport.jar not found.)], [])
        fi

        if test -z $LIBLAYOUT_JAR; then
            AC_CHECK_FILE(/usr/share/java/liblayout-0.2.9.jar,
                [ LIBLAYOUT_JAR=/usr/share/java/liblayout-0.2.9.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/liblayout.jar,
                        [ LIBLAYOUT_JAR=/usr/share/java/liblayout.jar ],
                        [AC_MSG_ERROR(liblayout.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBLAYOUT_JAR, [],
                 [AC_MSG_ERROR(liblayout.jar not found.)], [])
        fi

        if test -z $LIBLOADER_JAR; then
            AC_CHECK_FILE(/usr/share/java/libloader-1.0.0.jar,
                [ LIBLOADER_JAR=/usr/share/java/libloader-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/libloader.jar,
                       [ LIBLOADER_JAR=/usr/share/java/libloader.jar ],
                       [AC_MSG_ERROR(libloader.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBLOADER_JAR, [],
                [AC_MSG_ERROR(libloader.jar not found.)], [])
        fi

        if test -z $LIBFORMULA_JAR; then
            AC_CHECK_FILE(/usr/share/java/libformula-0.2.0.jar,
                 [ LIBFORMULA_JAR=/usr/share/java/libformula-0.2.0.jar ],
                 [
                     AC_CHECK_FILE(/usr/share/java/libformula.jar,
                         [ LIBFORMULA_JAR=/usr/share/java/libformula.jar ],
                         [AC_MSG_ERROR(libformula.jar replacement not found.)]
                     )
                 ]
            )
        else
            AC_CHECK_FILE($LIBFORMULA_JAR, [],
                [AC_MSG_ERROR(libformula.jar not found.)], [])
        fi

        if test -z $LIBREPOSITORY_JAR; then
            AC_CHECK_FILE(/usr/share/java/librepository-1.0.0.jar,
                [ LIBREPOSITORY_JAR=/usr/share/java/librepository-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/librepository.jar,
                        [ LIBREPOSITORY_JAR=/usr/share/java/librepository.jar ],
                        [AC_MSG_ERROR(librepository.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBREPOSITORY_JAR, [],
                [AC_MSG_ERROR(librepository.jar not found.)], [])
        fi

        if test -z $LIBFONTS_JAR; then
            AC_CHECK_FILE(/usr/share/java/libfonts-1.0.0.jar,
                [ LIBFONTS_JAR=/usr/share/java/libfonts-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/libfonts.jar,
                        [ LIBFONTS_JAR=/usr/share/java/libfonts.jar ],
                        [AC_MSG_ERROR(libfonts.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBFONTS_JAR, [],
                [AC_MSG_ERROR(libfonts.jar not found.)], [])
        fi

        if test -z $LIBSERIALIZER_JAR; then
            AC_CHECK_FILE(/usr/share/java/libserializer-1.0.0.jar,
                [ LIBSERIALIZER_JAR=/usr/share/java/libserializer-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/libserializer.jar,
                        [ LIBSERIALIZER_JAR=/usr/share/java/libserializer.jar ],
                        [AC_MSG_ERROR(libserializer.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBSERIALIZER_JAR, [],
                [AC_MSG_ERROR(libserializer.jar not found.)], [])
        fi

        if test -z $LIBBASE_JAR; then
            AC_CHECK_FILE(/usr/share/java/libbase-1.0.0.jar,
                [ LIBBASE_JAR=/usr/share/java/libbase-1.0.0.jar ],
                [
                    AC_CHECK_FILE(/usr/share/java/libbase.jar,
                        [ LIBBASE_JAR=/usr/share/java/libbase.jar ],
                        [AC_MSG_ERROR(libbase.jar replacement not found.)]
                    )
                ]
            )
        else
            AC_CHECK_FILE($LIBBASE_JAR, [],
                [AC_MSG_ERROR(libbase.jar not found.)], [])
        fi

    else
        AC_MSG_RESULT([internal])
        AC_MSG_CHECKING([for jfreereport module])
        SYSTEM_JFREEREPORT=NO
        BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
    fi
    BUILD_TYPE="$BUILD_TYPE REPORTBUILDER"
else
    AC_MSG_RESULT([no])
    ENABLE_REPORTBUILDER=NO
    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_REPORTDESIGN"
    SYSTEM_JFREEREPORT=NO
fi
AC_SUBST(ENABLE_REPORTBUILDER)
AC_SUBST(SYSTEM_JFREEREPORT)
AC_SUBST(SAC_JAR)
AC_SUBST(LIBXML_JAR)
AC_SUBST(FLUTE_JAR)
AC_SUBST(JFREEREPORT_JAR)
AC_SUBST(LIBBASE_JAR)
AC_SUBST(LIBLAYOUT_JAR)
AC_SUBST(LIBLOADER_JAR)
AC_SUBST(LIBFORMULA_JAR)
AC_SUBST(LIBREPOSITORY_JAR)
AC_SUBST(LIBFONTS_JAR)
AC_SUBST(LIBSERIALIZER_JAR)

# this has to be here because both the Wiki Publisher and the SRB use
# commons-logging
if test "$ENABLE_MEDIAWIKI" = "YES" -o "$ENABLE_REPORTBUILDER" = "YES"; then
    AC_MSG_CHECKING([which Apache commons-* libs to use])
    if test "$with_system_apache_commons" = "yes"; then
        SYSTEM_APACHE_COMMONS=YES
        AC_MSG_RESULT([external])
        if test "$ENABLE_MEDIAWIKI" = "YES"; then
            if test -z $COMMONS_CODEC_JAR; then
                AC_CHECK_FILE(/usr/share/java/commons-codec-1.3.jar,
                    [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec-1.3.jar ],
                    [
                        AC_CHECK_FILE(/usr/share/java/commons-codec.jar,
                            [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec.jar ],
                            [AC_MSG_ERROR(commons-codec.jar replacement not found.)]
                        )
                    ]
                )
            else
                AC_CHECK_FILE($COMMONS_CODEC_JAR, [],
                    [AC_MSG_ERROR(commons-codec.jar not found.)], [])
            fi

            if test -z $COMMONS_LANG_JAR; then
                AC_CHECK_FILE(/usr/share/java/commons-lang-2.3.jar,
                    [ COMMONS_LANG_JAR=/usr/share/java/commons-lang-2.3.jar ],
                    [
                        AC_CHECK_FILE(/usr/share/java/commons-lang.jar,
                            [ COMMONS_LANG_JAR=/usr/share/java/commons-lang.jar ],
                            [AC_MSG_ERROR(commons-lang.jar replacement not found.)]
                            )
                    ]
                )
            else
                AC_CHECK_FILE($COMMONS_LANG_JAR, [],
                    [AC_MSG_ERROR(commons-lang.jar not found.)], [])
            fi

            if test -z $COMMONS_HTTPCLIENT_JAR; then
                AC_CHECK_FILE(/usr/share/java/commons-httpclient-3.1.jar,
                    [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient-3.1.jar ],
                    [
                        AC_CHECK_FILE(/usr/share/java/commons-httpclient.jar,
                            [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient.jar ],
                            [AC_MSG_ERROR(commons-httpclient.jar replacement not found.)]
                        )
                    ]
                )
            else
                AC_CHECK_FILE($COMMONS_HTTPCLIENT_JAR, [],
                    [AC_MSG_ERROR(commons-httpclient.jar not found.)], [])
            fi
        fi
        if test "$ENABLE_MEDIAWIKI" = "YES" -o "$ENABLE_REPORTBUILDER" = "YES"; then
            if test -z $COMMONS_LOGGING_JAR; then
                AC_CHECK_FILE(/usr/share/java/commons-logging-1.1.1.jar,
                   [ COMMONS_LOGGING_JAR=/usr/share/java/commons-logging-1.1.1.jar ],
                   [
                        AC_CHECK_FILE(/usr/share/java/commons-logging.jar,
                            [ COMMONS_LOGGING_JAR=/usr/share/java/commons-logging.jar ],
                            [AC_MSG_ERROR(commons-logging.jar replacement not found.)]
                        )
                    ]
                )
            else
                AC_CHECK_FILE($COMMONS_LOGGING_JAR, [],
                    [AC_MSG_ERROR(commons-logging.jar not found.)], [])
            fi
        fi
    else
        AC_MSG_RESULT([internal])
        SYSTEM_APACHE_COMMONS=NO
        BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS TOMCAT"
    fi
fi
AC_SUBST(SYSTEM_APACHE_COMMONS)
AC_SUBST(COMMONS_CODEC_JAR)
AC_SUBST(COMMONS_LANG_JAR)
AC_SUBST(COMMONS_HTTPCLIENT_JAR)
AC_SUBST(COMMONS_LOGGING_JAR)

# scripting provider for BeanShell extension?
AC_MSG_CHECKING([whether to build extension for support of scripts in BeanShell])
if test "x$enable_ext_scripting_beanshell" = "xyes" -a "x$enable_extension_integration" != "xno" -a "x$with_java" != "xno"; then
   AC_MSG_RESULT([yes])
   ENABLE_SCRIPTING_BEANSHELL=YES

   dnl ===================================================================
   dnl Check for system beanshell
   dnl ===================================================================
   AC_MSG_CHECKING([which beanshell to use])
   if test "$with_system_beanshell" = "yes"; then
       AC_MSG_RESULT([external])
       SYSTEM_BSH=YES
       if test -z $BSH_JAR; then
           BSH_JAR=/usr/share/java/bsh.jar
       fi
       AC_CHECK_FILE($BSH_JAR, [],
                  [AC_MSG_ERROR(bsh.jar not found.)], [])
   else
       AC_MSG_RESULT([internal])
       SYSTEM_BSH=NO
       BUILD_TYPE="$BUILD_TYPE BSH"
   fi
else
   AC_MSG_RESULT([no])
   ENABLE_SCRIPTING_BEANSHELL=NO
   SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_SCRIPTING_BEANSHELL"
fi
AC_SUBST(ENABLE_SCRIPTING_BEANSHELL)
AC_SUBST(SYSTEM_BSH)
AC_SUBST(BSH_JAR)

# scripting provider for JavaScript extension?
AC_MSG_CHECKING([whether to build extension for support of scripts in JavaScript])
if test "x$enable_ext_scripting_javascript" = "xyes" -a "x$enable_extension_integration" != "xno" -a "x$with_java" != "xno"; then
   AC_MSG_RESULT([yes])
   ENABLE_SCRIPTING_JAVASCRIPT=YES

   dnl ===================================================================
   dnl Check for system rhino
   dnl ===================================================================
   AC_MSG_CHECKING([which rhino to use])
   if test "$with_system_rhino" = "yes"; then
       AC_MSG_RESULT([external])
       SYSTEM_RHINO=YES
       if test -z $RHINO_JAR; then
           RHINO_JAR=/usr/share/java/js.jar
       fi
       AC_CHECK_FILE($RHINO_JAR, [],
                  [AC_MSG_ERROR(js.jar not found.)], [])
   else
       AC_MSG_RESULT([internal])
       SYSTEM_RHINO=NO
       BUILD_TYPE="$BUILD_TYPE RHINO"
   fi
else
   AC_MSG_RESULT([no])
   ENABLE_SCRIPTING_JAVASCRIPT=NO
   SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_SCRIPTING_JAVASCRIPT"
fi
AC_SUBST(ENABLE_SCRIPTING_JAVASCRIPT)
AC_SUBST(SYSTEM_RHINO)
AC_SUBST(RHINO_JAR)

dnl Scripting provider for Python extension?
dnl We always provide this unless we have disabled Python completely
if test $enable_python = no; then
    ENABLE_SCRIPTING_PYTHON=NO
    SCPDEFS="$SCPDEFS -DWITHOUT_EXTENSION_SCRIPTING_PYTHON"
else
    ENABLE_SCRIPTING_PYTHON=YES
fi
AC_SUBST(ENABLE_SCRIPTING_PYTHON)

supports_multilib=
case "$host_cpu" in
x86_64 | powerpc64 | s390x)
    if test "$SIZEOF_LONG" = "8"; then
        supports_multilib="yes"
    fi
    ;;
*)
    ;;
esac

dnl ===================================================================
dnl Check whether the TQt and TDE libraries are available.
dnl ===================================================================

TDE_CFLAGS=""
TDE_LIBS=""
if test "$_os" != "OpenBSD"; then
    MOC="moc"
fi
if test "$test_tde" = "yes" -a "$ENABLE_TDE" = "TRUE"; then
    dnl Search paths for TQt and TDE
    if test -z "$supports_multilib"; then
        tqt_incdirs="$QTINC /usr/local/tqt3/include /usr/include/tqt3 /usr/include /usr/X11R6/include/X11/tqt3 /usr/X11R6/include/tqt3 /usr/lib/tqt3/include /usr/lib/tqt3/include /usr/share/tqt3/include /usr/local/include/X11/tqt3 $x_includes"
        tqt_libdirs="$QTLIB /usr/local/tqt3/lib /usr/lib/tqt3 /usr/lib /usr/X11R6/lib/X11/tqt3 /usr/X11R6/lib/tqt3 /usr/lib/tqt3/lib /usr/lib/tqt3/lib /usr/share/tqt3/lib /usr/local/lib/tqt3 $x_libraries"
    else
        tqt_incdirs="$QTINC /usr/local/tqt3/include /usr/include/tqt3 /usr/include /usr/X11R6/include/X11/tqt3 /usr/X11R6/include/tqt3 /usr/lib64/tqt3/include /usr/lib64/tqt3/include /usr/share/tqt3/include /usr/lib/tqt3/include /usr/lib/tqt3/include /usr/local/include/X11/tqt3 $x_includes"
        tqt_libdirs="$QTLIB /usr/local/tqt3/lib64 /usr/lib64/tqt3 /usr/lib64 /usr/X11R6/lib64/X11/tqt3 /usr/X11R6/lib64/tqt3 /usr/lib64/tqt3/lib64 /usr/lib64/tqt3/lib64 /usr/share/tqt3/lib64 /usr/local/tqt3/lib /usr/lib/tqt3 /usr/lib /usr/X11R6/lib/X11/tqt3 /usr/X11R6/lib/tqt3 /usr/lib/tqt3/lib /usr/lib/tqt3/lib /usr/share/tqt3/lib /usr/local/lib/tqt3 $x_libraries"
    fi
    if test -n "$TQTDIR"; then
        tqt_incdirs="$TQTDIR/include $tqt_incdirs"
        if test -z "$supports_multilib"; then
            tqt_libdirs="$TQTDIR/lib $tqt_libdirs"
        else
            tqt_libdirs="$TQTDIR/lib64 $TQTDIR/lib $tqt_libdirs"
        fi
    fi
    if test -z "$supports_multilib"; then
        tde_incdirs="/usr/lib/trinity/include /usr/local/trinity/include /usr/local/include /usr/trinity/include /usr/include/trinity /opt/trinity/include /opt/trinity/include $x_includes"
        tde_libdirs="/usr/lib/trinity/lib /usr/local/trinity/lib /usr/trinity/lib /usr/lib/trinity /usr/lib/trinity /usr/X11R6/lib /usr/local/lib /opt/trinity/lib /opt/trinity/lib /usr/X11R6/trinity/lib /usr/lib $x_libraries"
    else
        tde_incdirs="/usr/lib64/trinity/include /usr/lib/trinity/include /usr/local/trinity/include /usr/local/include /usr/trinity/include /usr/include/trinity /opt/trinity/include /opt/trinity/include $x_includes"
        tde_libdirs="/usr/lib64/trinity/lib64 /usr/local/trinity/lib64 /usr/trinity/lib64 /usr/lib64/trinity /usr/lib64/trinity /usr/X11R6/lib64 /usr/local/lib64 /opt/trinity/lib64 /opt/trinity/lib64 /usr/X11R6/trinity/lib64 /usr/lib/trinity/lib /usr/local/trinity/lib /usr/trinity/lib /usr/lib/trinity /usr/lib/trinity /usr/lib /usr/X11R6/lib /usr/local/lib /opt/trinity/lib /opt/trinity/lib /usr/X11R6/trinity/lib /usr/lib64 $x_libraries"
    fi
    if test -n "$TDEDIR"; then
        tde_incdirs="$TDEDIR/include $tde_incdirs"
        if test -z "$supports_multilib"; then
            tde_libdirs="$TDEDIR/lib $tde_libdirs"
        else
            tde_libdirs="$TDEDIR/lib64 $TDEDIR/lib $tde_libdirs"
        fi
    fi

    dnl What to test
    tqt_test_include="ntqstyle.h"
    tde_test_include="kapp.h"

    if test "$_os" != "OpenBSD"; then
        tqt_test_library="libtqt-mt.so"
        tde_test_library="libDCOP.so"
    else
        tqt_test_library="libtqt-mt.so*"
        tde_test_library="libDCOP.so*"
    fi

    dnl Check for TQt headers
    AC_MSG_CHECKING([for TQt headers])
    tqt_incdir="no"
    for tde_check in $tqt_incdirs; do
        if test -r "$tde_check/$tqt_test_include"; then
            tqt_incdir="$tde_check"
            break
        fi
    done
    AC_MSG_RESULT([$tqt_incdir])
    if test "x$tqt_incdir" = "xno"; then
        AC_MSG_ERROR([TQt headers not found.  Please specify the root of
your TQt installation by exporting TQTDIR before running "configure".])
    fi

    dnl Check for TQt libraries
    AC_MSG_CHECKING([for TQt libraries])
    tqt_libdir="no"
    for tqt_check in $tqt_libdirs; do
        if test -r "`ls $tqt_check/$tqt_test_library 2>/dev/null | head -1`"; then
            tqt_libdir="$tqt_check"
            break
        fi
    done
    AC_MSG_RESULT([$tqt_libdir])
    if test "x$tqt_libdir" = "xno"; then
        AC_MSG_ERROR([TQt libraries not found.  Please specify the root of
your TQt installation by exporting TQTDIR before running "configure".])
    fi

    dnl Check for Meta Object Compiler
    AC_PATH_PROG( MOC, moc, no, [`dirname $tqt_libdir`/bin:$TQTDIR/bin:$PATH] )
    if test "$MOC" = "no"; then
        AC_MSG_ERROR([TQt Meta Object Compiler not found.  Please specify
the root of your TQt installation by exporting TQTDIR before running "configure".])
    fi

    dnl Check for TDE headers
    AC_MSG_CHECKING([for TDE headers])
    tde_incdir="no"
    for tde_check in $tde_incdirs; do
        if test -r "$tde_check/$tde_test_include"; then
            tde_incdir="$tde_check"
            break
        fi
    done
    AC_MSG_RESULT([$tde_incdir])
    if test "x$tde_incdir" = "xno"; then
        AC_MSG_ERROR([TDE headers not found.  Please specify the root of
your TDE installation by exporting TDEDIR before running "configure".])
    fi

    dnl Check for TDE libraries
    AC_MSG_CHECKING([for TDE libraries])
    tde_libdir="no"
    for tde_check in $tde_libdirs; do
        if test -r "`ls $tde_check/$tde_test_library 2>/dev/null | head -1`"; then
            tde_libdir="$tde_check"
            break
        fi
    done
    AC_MSG_RESULT([$tde_libdir])
    if test "x$tde_libdir" = "xno"; then
        AC_MSG_ERROR([TDE libraries not found.  Please specify the root of
your TDE installation by exporting TDEDIR before running "configure".])
    fi

    dnl Set the variables
    TDE_CFLAGS="-I$tqt_incdir -I$tde_incdir -I/usr/include/tqt -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
    TDE_LIBS="-L$tde_libdir -L$tqt_libdir -ltdeui -ltdecore -ltqt -ltqt-mt"
fi
AC_SUBST(TDE_CFLAGS)
AC_SUBST(TDE_LIBS)
AC_SUBST(MOC)

dnl ===================================================================
dnl Check whether the Qt3 and KDE3 libraries are available.
dnl ===================================================================

KDE_CFLAGS=""
KDE_LIBS=""
if test "$_os" != "OpenBSD"; then
    MOC="moc"
fi
if test "$test_kde" = "yes" -a "$ENABLE_KDE" = "TRUE"; then
    dnl Search paths for Qt3 and KDE3
    if test -z "$supports_multilib"; then
        qt_incdirs="$QTINC /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/lib/qt3/include /usr/lib/qt/include /usr/share/qt3/include /usr/local/include/X11/qt3 $x_includes"
        qt_libdirs="$QTLIB /usr/local/qt/lib /usr/lib/qt /usr/lib /usr/X11R6/lib/X11/qt /usr/X11R6/lib/qt /usr/lib/qt3/lib /usr/lib/qt/lib /usr/share/qt3/lib /usr/local/lib/qt3 $x_libraries"
    else
        qt_incdirs="$QTINC /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/lib64/qt3/include /usr/lib64/qt/include /usr/share/qt3/include /usr/lib/qt3/include /usr/lib/qt/include /usr/local/include/X11/qt3 $x_includes"
        qt_libdirs="$QTLIB /usr/local/qt/lib64 /usr/lib64/qt /usr/lib64 /usr/X11R6/lib64/X11/qt /usr/X11R6/lib64/qt /usr/lib64/qt3/lib64 /usr/lib64/qt/lib64 /usr/share/qt3/lib64 /usr/local/qt/lib /usr/lib/qt /usr/lib /usr/X11R6/lib/X11/qt /usr/X11R6/lib/qt /usr/lib/qt3/lib /usr/lib/qt/lib /usr/share/qt3/lib /usr/local/lib/qt3 $x_libraries"
    fi
    if test -n "$QTDIR"; then
        qt_incdirs="$QTDIR/include $qt_incdirs"
        if test -z "$supports_multilib"; then
            qt_libdirs="$QTDIR/lib $qt_libdirs"
        else
            qt_libdirs="$QTDIR/lib64 $QTDIR/lib $qt_libdirs"
        fi
    fi
    if test -z "$supports_multilib"; then
        kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /opt/kde3/include /opt/kde/include $x_includes"
        kde_libdirs="/usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib/kde3 /usr/X11R6/lib /usr/local/lib /opt/kde3/lib /opt/kde/lib /usr/X11R6/kde/lib /usr/lib $x_libraries"
    else
        kde_incdirs="/usr/lib64/kde/include /usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /opt/kde3/include /opt/kde/include $x_includes"
        kde_libdirs="/usr/lib64/kde/lib64 /usr/local/kde/lib64 /usr/kde/lib64 /usr/lib64/kde /usr/lib64/kde3 /usr/X11R6/lib64 /usr/local/lib64 /opt/kde3/lib64 /opt/kde/lib64 /usr/X11R6/kde/lib64 /usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib/kde3 /usr/lib /usr/X11R6/lib /usr/local/lib /opt/kde3/lib /opt/kde/lib /usr/X11R6/kde/lib /usr/lib64 $x_libraries"
    fi
    if test -n "$KDEDIR"; then
        kde_incdirs="$KDEDIR/include $kde_incdirs"
        if test -z "$supports_multilib"; then
            kde_libdirs="$KDEDIR/lib $kde_libdirs"
        else
            kde_libdirs="$KDEDIR/lib64 $KDEDIR/lib $kde_libdirs"
        fi
    fi

    dnl What to test
    qt_test_include="qstyle.h"
    kde_test_include="kapp.h"

    if test "$_os" != "OpenBSD"; then
        qt_test_library="libqt-mt.so"
        kde_test_library="libDCOP.so"
    else
        qt_test_library="libqt-mt.so*"
        kde_test_library="libDCOP.so*"
    fi

    dnl Check for Qt3 headers
    AC_MSG_CHECKING([for Qt3 headers])
    qt_incdir="no"
    for kde_check in $qt_incdirs; do
        if test -r "$kde_check/$qt_test_include"; then
            qt_incdir="$kde_check"
            break
        fi
    done
    AC_MSG_RESULT([$qt_incdir])
    if test "x$qt_incdir" = "xno"; then
        AC_MSG_ERROR([Qt3 headers not found.  Please specify the root of
your Qt3 installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for Qt3 libraries
    AC_MSG_CHECKING([for Qt3 libraries])
    qt_libdir="no"
    for qt_check in $qt_libdirs; do
        if test -r "`ls $qt_check/$qt_test_library 2>/dev/null | head -1`"; then
            qt_libdir="$qt_check"
            break
        fi
    done
    AC_MSG_RESULT([$qt_libdir])
    if test "x$qt_libdir" = "xno"; then
        AC_MSG_ERROR([Qt3 libraries not found.  Please specify the root of
your Qt3 installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for Meta Object Compiler
    AC_PATH_PROG( MOC, moc, no, [`dirname $qt_libdir`/bin:$QTDIR/bin:$PATH] )
    if test "$MOC" = "no"; then
        AC_MSG_ERROR([Qt3 Meta Object Compiler not found.  Please specify
the root of your Qt3 installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for KDE3 headers
    AC_MSG_CHECKING([for KDE3 headers])
    kde_incdir="no"
    for kde_check in $kde_incdirs; do
        if test -r "$kde_check/$kde_test_include"; then
            kde_incdir="$kde_check"
            break
        fi
    done
    AC_MSG_RESULT([$kde_incdir])
    if test "x$kde_incdir" = "xno"; then
        AC_MSG_ERROR([KDE3 headers not found.  Please specify the root of
your KDE3 installation by exporting KDEDIR before running "configure".])
    fi

    dnl Check for KDE3 libraries
    AC_MSG_CHECKING([for KDE3 libraries])
    kde_libdir="no"
    for kde_check in $kde_libdirs; do
        if test -r "`ls $kde_check/$kde_test_library 2>/dev/null | head -1`"; then
            kde_libdir="$kde_check"
            break
        fi
    done
    AC_MSG_RESULT([$kde_libdir])
    if test "x$kde_libdir" = "xno"; then
        AC_MSG_ERROR([KDE3 libraries not found.  Please specify the root of
your KDE3 installation by exporting KDEDIR before running "configure".])
    fi

    dnl Set the variables
    KDE_CFLAGS="-I$qt_incdir -I$kde_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
    KDE_LIBS="-L$kde_libdir -L$qt_libdir -lkdeui -lkdecore -lqt-mt"
fi
AC_SUBST(KDE_CFLAGS)
AC_SUBST(KDE_LIBS)
AC_SUBST(MOC)

dnl ===================================================================
dnl KDE4 Integration
dnl ===================================================================

KDE4_CFLAGS=""
KDE4_LIBS=""
QMAKE4="qmake"
MOC4="moc"
KDE_GLIB_CFLAGS=""
KDE_GLIB_LIBS=""
KDE_HAVE_GLIB=""
if test "$test_kde4" = "yes" -a "$ENABLE_KDE4" = "TRUE"; then
    qt_incdirs="$QT4INC /usr/include/qt4 /usr/include $x_includes"
    qt_libdirs="$QT4LIB /usr/lib/qt4 /usr/lib $x_libraries"

    kde_incdirs="/usr/include /usr/include/kde4 $x_includes"
    kde_libdirs="/usr/lib /usr/lib/kde4 /usr/lib/kde4/devel $x_libraries"

    if test -n "$supports_multilib"; then
        qt_libdirs="$qt_libdirs /usr/lib64/qt4 /usr/lib64/qt /usr/lib64"
        kde_libdirs="$kde_libdirs /usr/lib64 /usr/lib64/kde4 /usr/lib64/kde4/devel"
    fi

    if test -n "$QTDIR"; then
        qt_incdirs="$QTDIR/include $qt_incdirs"
        if test -z "$supports_multilib"; then
            qt_libdirs="$QTDIR/lib $qt_libdirs"
        else
            qt_libdirs="$QTDIR/lib64 $QTDIR/lib $qt_libdirs"
        fi
    fi
    if test -n "$QT4DIR"; then
        qt_incdirs="$QT4DIR/include $qt_incdirs"
        if test -z "$supports_multilib"; then
            qt_libdirs="$QT4DIR/lib $qt_libdirs"
        else
            qt_libdirs="$QT4DIR/lib64 $QT4DIR/lib $qt_libdirs"
        fi
    fi

    if test -n "$KDEDIR"; then
        kde_incdirs="$KDEDIR/include $kde_incdirs"
        if test -z "$supports_multilib"; then
            kde_libdirs="$KDEDIR/lib $kde_libdirs"
        else
            kde_libdirs="$KDEDIR/lib64 $KDEDIR/lib $kde_libdirs"
        fi
    fi
    if test -n "$KDE4DIR"; then
        kde_incdirs="$KDE4DIR/include $KDE4DIR/include/kde4 $kde_incdirs"
        if test -z "$supports_multilib"; then
            kde_libdirs="$KDE4DIR/lib $kde_libdirs"
        else
            kde_libdirs="$KDE4DIR/lib64 $KDE4DIR/lib $kde_libdirs"
        fi
    fi

    qt_test_include="Qt/qobject.h"
    qt_test_library="libQtCore.so"
    kde_test_include="kwindowsystem.h"
    kde_test_library="libsolid.so"

    AC_MSG_CHECKING([for Qt4 headers])
    qt_header_dir="no"
    for inc_dir in $qt_incdirs; do
        if test -r "$inc_dir/$qt_test_include"; then
            qt_header_dir="$inc_dir"
            break
        fi
    done

    AC_MSG_RESULT([$qt_header_dir])
    if test "x$qt_header_dir" = "xno"; then
        AC_MSG_ERROR([Qt4 headers not found.  Please specify the root of your Qt4 installation by exporting QT4DIR before running "configure".])
    fi

    dnl Check for qmake
    AC_PATH_PROG( QMAKEQT4, qmake-qt4, no, [`dirname $qt_header_dir`/bin:$QT4DIR/bin:$PATH] )
    QMAKE4="$QMAKEQT4"
    if test "$QMAKE4" = "no" ; then
        AC_PATH_PROG( QMAKE4, qmake, no, [`dirname $qt_header_dir`/bin:$QT4DIR/bin:$PATH] )
        if test "$QMAKE4" = "no" ; then
            AC_MSG_ERROR([Qmake not found.  Please specify
the root of your Qt installation by exporting QT4DIR before running "configure".])
        fi
    fi

    qt_libdirs="`$QMAKE4 -query QT_INSTALL_LIBS` $qt_libdirs"
    AC_MSG_CHECKING([for Qt4 libraries])
    qt_lib_dir="no"
    for lib_dir in $qt_libdirs; do
        if test -r "$lib_dir/$qt_test_library"; then
            qt_lib_dir="$lib_dir"
            PKG_CONFIG_PATH="$qt_lib_dir"/pkgconfig:$PKG_CONFIG_PATH
            break
        fi
    done

    AC_MSG_RESULT([$qt_lib_dir])

    if test "x$qt_lib_dir" = "xno"; then
        AC_MSG_ERROR([Qt4 libraries not found.  Please specify the root of your Qt4 installation by exporting QT4DIR before running "configure".])
    fi

    dnl Check for Meta Object Compiler

    AC_PATH_PROG( MOCQT4, moc-qt4, no, [`dirname $qt_lib_dir`/bin:$QT4DIR/bin:$PATH] )
    MOC4="$MOCQT4"
    if test "$MOC4" = "no"; then
        AC_PATH_PROG( MOC4, moc, no, [`dirname $qt_lib_dir`/bin:$QT4DIR/bin:$PATH] )
        if test "$MOC4" = "no"; then
            AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
the root of your Qt installation by exporting QT4DIR before running "configure".])
        fi
    fi

    dnl Check for KDE4 headers
    AC_MSG_CHECKING([for KDE4 headers])
    kde_incdir="no"
    for kde_check in $kde_incdirs; do
        if test -r "$kde_check/$kde_test_include"; then
            kde_incdir="$kde_check"
            break
        fi
    done
    AC_MSG_RESULT([$kde_incdir])
    if test "x$kde_incdir" = "xno"; then
        AC_MSG_ERROR([KDE4 headers not found.  Please specify the root of your KDE4 installation by exporting KDE4DIR before running "configure".])
    fi

    dnl Check for KDE4 libraries
    AC_MSG_CHECKING([for KDE4 libraries])
    kde_libdir="no"
    for kde_check in $kde_libdirs; do
        if test -r "$kde_check/$kde_test_library"; then
            kde_libdir="$kde_check"
            break
        fi
    done

    AC_MSG_RESULT([$kde_libdir])
    if test "x$kde_libdir" = "xno"; then
        AC_MSG_ERROR([KDE4 libraries not found.  Please specify the root of your KDE4 installation by exporting KDE4DIR before running "configure".])
    fi

    KDE4_CFLAGS="`pkg-config --cflags QtCore` `pkg-config --cflags QtGui` -I$kde_incdir -DQT_CLEAN_NAMESPACE -DQT_THREAD_SUPPORT"
    KDE4_LIBS="-L$kde_libdir -L$qt_lib_dir -lkio -lkfile -lkdeui -lkdecore -lQtCore -lQtGui"

    AC_LANG_PUSH([C++])
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS $KDE4_CFLAGS"
    AC_MSG_CHECKING([whether KDE is >= 4.2])
       AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <kdeversion.h>

int main(int argc, char **argv) {
       if (KDE_VERSION_MAJOR == 4 && KDE_VERSION_MINOR >= 2) return 0;
       else return 1;
}
       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old])],[])
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])

   # Glib is needed for properly handling Qt event loop with Qt's Glib integration enabled
    PKG_CHECK_MODULES(KDE_GLIB,[glib-2.0 >= 2.4],
        [KDE_HAVE_GLIB=1],
        AC_MSG_WARN([[No Glib found, KDE4 support will not integrate with Qt's Glib event loop support]]))
fi
AC_SUBST(KDE4_CFLAGS)
AC_SUBST(KDE4_LIBS)
AC_SUBST(MOC4)
AC_SUBST(KDE_GLIB_CFLAGS)
AC_SUBST(KDE_GLIB_LIBS)
AC_SUBST(KDE_HAVE_GLIB)

dnl ===================================================================
dnl Test for the enabling the lockdown pieces
dnl ===================================================================
AC_MSG_CHECKING([whether to enable the lockdown pieces])
ENABLE_LOCKDOWN=""
if test -n "$enable_lockdown" -a "$enable_lockdown" != "no"; then
    ENABLE_LOCKDOWN=YES
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_LOCKDOWN)

dnl ===================================================================
dnl Test whether to include Evolution 2 support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable evolution 2 support])
if test "$enable_evolution2" = "yes" -o "$enable_evolution2" = "TRUE"; then
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES(GOBJECT, gobject-2.0)
    ENABLE_EVOAB2="TRUE"
else
    ENABLE_EVOAB2=""
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_EVOAB2)
AC_SUBST(GOBJECT_CFLAGS)
AC_SUBST(GOBJECT_LIBS)

dnl ===================================================================
dnl Test whether to include TDE AB support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable TDE address book support])
if test "$enable_tdeab" = "yes" -a "$enable_tde" = "yes"; then
    AC_MSG_RESULT([yes])
    AC_LANG_PUSH([C++])
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS $TDE_CFLAGS"
    AC_MSG_CHECKING([whether TDE is at least R14.0])
       AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <tdeversion.h>

int main(int argc, char **argv) {
       if (TDE_VERSION_MAJOR >= 14) return 0;
       else return 1;
}
       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([TDE version too old or too recent, please use another version of TDE or disable TDE address book support])],[])
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])
    ENABLE_TDEAB=TRUE
else
    AC_MSG_RESULT([no])
    ENABLE_TDEAB=
fi
AC_SUBST(ENABLE_TDEAB)

dnl ===================================================================
dnl Test whether to include KDE AB support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable KDE address book support])
if test "$enable_kdeab" = "yes" -a "$enable_kde" = "yes"; then
    AC_MSG_RESULT([yes])
    AC_LANG_PUSH([C++])
    save_CXXFLAGS=$CXXFLAGS
    CXXFLAGS="$CXXFLAGS $KDE_CFLAGS"
    AC_MSG_CHECKING([whether KDE is between 3.2 and 3.6])
       AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <kdeversion.h>

int main(int argc, char **argv) {
       if (KDE_VERSION_MAJOR == 3 && 2 <= KDE_VERSION_MINOR && KDE_VERSION_MINOR <= 6) return 0;
       else return 1;
}
       ]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([KDE version too old or too recent, please use another version of KDE or disable KDE address book support])],[])
    CXXFLAGS=$save_CXXFLAGS
    AC_LANG_POP([C++])
    ENABLE_KAB=TRUE
else
    AC_MSG_RESULT([no])
    ENABLE_KAB=
fi
AC_SUBST(ENABLE_KAB)

dnl ===================================================================
dnl Test whether to include MathMLDTD
dnl ===================================================================
AC_MSG_CHECKING([whether to include MathMLDTD])
if test -n "$enable_mathmldtd"; then
    if test "$enable_mathmldtd" = "no"; then
        AC_MSG_RESULT([no])
        SCPDEFS="$SCPDEFS -DWITHOUT_MATHMLDTD"
    else
        AC_MSG_RESULT([yes])
        BUILD_TYPE="$BUILD_TYPE MATHMLDTD"
    fi
else
    AC_MSG_RESULT([no])
    SCPDEFS="$SCPDEFS -DWITHOUT_MATHMLDTD"
fi

dnl ===================================================================
dnl Test which themes to include
dnl ===================================================================
AC_MSG_CHECKING([which themes to include])
# if none given use default subset of available themes
if test "x$with_theme" = "x" -o "x$with_theme" = "xyes"; then
    with_theme="crystal default hicontrast oxygen tango"
fi

WITH_THEMES=""
for theme in $with_theme; do
    case $theme in
        crystal|default|galaxy|hicontrast|human|industrial|oxygen|tango) : ;;
        *) AC_MSG_ERROR([Unknown value for --with-theme: $theme]) ;;
    esac
    WITH_THEMES="$WITH_THEMES $theme"
    SCPDEFS="$SCPDEFS -DTHEME_`echo $theme|tr '[[:lower:]]' '[[:upper:]]'`"
done
AC_MSG_RESULT([$WITH_THEMES])
AC_SUBST([WITH_THEMES])

dnl ===================================================================
dnl Test whether to integrate helppacks into the product's installer
dnl ===================================================================
AC_MSG_CHECKING([for helppack integration])
if test "$with_helppack_integration" = "no"; then
    WITH_HELPPACK_INTEGRATION=NO
    AC_MSG_RESULT([no integration])
else
    WITH_HELPPACK_INTEGRATION=YES
    SCPDEFS="$SCPDEFS -DWITH_HELPPACK_INTEGRATION"
    AC_MSG_RESULT([integration])
fi
AC_SUBST(WITH_HELPPACK_INTEGRATION)

###############################################################################
# Extensions checking
###############################################################################
dnl ===================================================================
dnl Test whether to integrate extensions into the product's installer
dnl ===================================================================
AC_MSG_CHECKING([for extensions integration])
if test "x$enable_extension_integration" != "xno"; then
    WITH_EXTENSION_INTEGRATION=YES
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_INTEGRATION"
    AC_MSG_RESULT([yes, use integration])
else
    WITH_EXTENSION_INTEGRATION=NO
    AC_MSG_RESULT([no, do not integrate])
fi
AC_SUBST(WITH_EXTENSION_INTEGRATION)

dnl ===================================================================
dnl Test whether to include Watch Window extension
dnl ===================================================================
AC_MSG_CHECKING([for Watch Window extension integration])
WATCH_WINDOW_EXTENSION_PACK=
if test "x$enable_ext_watch_window" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_WATCH_WINDOW"
    WATCH_WINDOW_EXTENSION_PACK="23bd75552206dfcd8fd4e29137dcac84-WatchWindow_1.2.0.0.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(WATCH_WINDOW_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include SmART Gallery (Diagram) extension
dnl ===================================================================
AC_MSG_CHECKING([for SmART Gallery (Diagram) extension integration])
DIAGRAM_EXTENSION_PACK=
if test "x$enable_ext_diagram" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_DIAGRAM"
    DIAGRAM_EXTENSION_PACK="8d74685d41f8bffe8c3e71fe8deac09d-SmART_0.9.5.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(DIAGRAM_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Validator extension
dnl ===================================================================
AC_MSG_CHECKING([for Validator extension integration])
VALIDATOR_EXTENSION_PACK=
if test "x$enable_ext_validator" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_VALIDATOR"
    VALIDATOR_EXTENSION_PACK="bbdd5639ada63e3130761daaecae1a10-Validator_1.1.0.0.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(VALIDATOR_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Barcode extension
dnl ===================================================================
AC_MSG_CHECKING([for Barcode extension integration])
BARCODE_EXTENSION_PACK=
if test "x$enable_ext_barcode" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_BARCODE"
    BARCODE_EXTENSION_PACK="3ed18025a766f1e955707b969c8113a5-Barcode_1.3.5.0.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST([BARCODE_EXTENSION_PACK])

dnl ===================================================================
dnl Test whether to include ConvertTextToNumber extension
dnl ===================================================================
AC_MSG_CHECKING([for ConvertTextToNumber extension integration])
CT2N_EXTENSION_PACK=
if test "x$enable_ext_ct2n" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    BUILD_TYPE="$BUILD_TYPE CT2N"
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_CT2N"
    CT2N_EXTENSION_PACK="451ccf439a36a568653b024534669971-ConvertTextToNumber_1.3.2.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(CT2N_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Numbertext extension
dnl ===================================================================
AC_MSG_CHECKING([for Numbertext extension integration])
NUMBERTEXT_EXTENSION_PACK=
if test "x$enable_ext_numbertext" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_NUMBERTEXT"
    NUMBERTEXT_EXTENSION_PACK="b8cbca7b3363e6ca2d02bc0ba2b63904-numbertext_0.9.4.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(NUMBERTEXT_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Hungarian Cross-reference Toolbar extension
dnl ===================================================================
AC_MSG_CHECKING([for Hungarian Cross-reference Toolbar extension integration])
HUNART_EXTENSION_PACK=
if test "x$enable_ext_hunart" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_HUNART"
    HUNART_EXTENSION_PACK="b632bdd25649cc4067bcb410bae23d2b-hunart_0.3.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(HUNART_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Typography Toolbar extension
dnl ===================================================================
AC_MSG_CHECKING([for Typography Toolbar extension integration])
TYPO_EXTENSION_PACK=
if test "x$enable_ext_typo" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_TYPO"
    TYPO_EXTENSION_PACK="9d60b6cfa3ef1926848710bbcd11115b-typo_0.4.2.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(TYPO_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include Google Docs extension
dnl ===================================================================
AC_MSG_CHECKING([for Google Docs extension integration])
GOOGLE_DOCS_EXTENSION_PACK=
if test "x$enable_ext_google_docs" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_GOOGLE_DOCS"
    GOOGLE_DOCS_EXTENSION_PACK="cea0f63d5985ba4fcbd882031df44346-gdocs_3.0.0_modified.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(GOOGLE_DOCS_EXTENSION_PACK)

dnl ===================================================================
dnl Test whether to include NLPSolver extension
dnl ===================================================================
AC_MSG_CHECKING([for NLPSolver extension integration])
if test "x$enable_ext_nlpsolver" = "xyes" -a "x$enable_extension_integration" != "xno" -a "x$with_java" != "xno"; then
    BUILD_TYPE="$BUILD_TYPE NLPSOLVER"
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_NLPSOLVER"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi

dnl ===================================================================
dnl Test whether to include LanguageTool extension
dnl ===================================================================
AC_MSG_CHECKING([for LanguageTool extension integration])
if test "x$enable_ext_languagetool" = "xyes" -a "x$enable_extension_integration" != "xno" -a "x$with_java" != "xno"; then
    BUILD_TYPE="$BUILD_TYPE LANGUAGETOOL"
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_LANGUAGETOOL"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi

dnl ===================================================================
dnl Test whether to include oooblogger extension
dnl ===================================================================
AC_MSG_CHECKING([for oooblogger extension integration])
OOOBLOGGER_EXTENSION_PACK=
if test "x$enable_ext_oooblogger" = "xyes" -a "x$enable_extension_integration" != "xno"; then
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_OOOBLOGGER"
    OOOBLOGGER_EXTENSION_PACK="b7b2d0e04e142f26dd96119c80757d1f-oooblogger_0.1.oxt"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(OOOBLOGGER_EXTENSION_PACK)
###############################################################################

dnl ===================================================================
dnl Test whether to include Sun Professional Template Pack
dnl ===================================================================
AC_MSG_CHECKING([for Sun Professional Template Pack integration (only supported languages displayed)])
if test "$with_sun_templates" = "" -o "$with_sun_templates" = "no"; then
    AC_MSG_RESULT([no integration])
else
    SCPDEFS="$SCPDEFS -DWITH_EXTENSION_SUN_TEMPLATE_PACK"
    sun_supported_langs="en-US de it fr es hu"
    if test "$with_sun_templates" = "yes"; then
        wanted_sun_templates="$sun_supported_langs"
    else
        # check whether the langs are supported by Sun
        wanted_sun_templates=
        for lang in $with_sun_templates; do
            if test -n "`echo $sun_supported_langs | grep "$lang"`"; then
                wanted_sun_templates="$wanted_sun_templates $lang"
            fi
        done
    fi
    SUNTEMPLATES_LANG=
    SUNTEMPLATES_DE_PACK=
    SUNTEMPLATES_EN_US_PACK=
    SUNTEMPLATES_ES_PACK=
    SUNTEMPLATES_FR_PACK=
    SUNTEMPLATES_HU_PACK=
    SUNTEMPLATES_IT_PACK=
    # check whether the langs are requested at all
    for lang in $wanted_sun_templates; do
    if test "$with_lang" = "ALL" -o -n "`echo $with_lang | grep "$lang"`"; then
        SUNTEMPLATES_LANG="$SUNTEMPLATES_LANG $lang"
        case $lang in
        "de") SUNTEMPLATES_DE_PACK="53ca5e56ccd4cab3693ad32c6bd13343-Sun-ODF-Template-Pack-de_1.0.0.oxt";;
        "en-US") SUNTEMPLATES_EN_US_PACK="472ffb92d82cf502be039203c606643d-Sun-ODF-Template-Pack-en-US_1.0.0.oxt";;
        "es") SUNTEMPLATES_ES_PACK="4ad003e7bbda5715f5f38fde1f707af2-Sun-ODF-Template-Pack-es_1.0.0.oxt";;
        "fr") SUNTEMPLATES_FR_PACK="a53080dc876edcddb26eb4c3c7537469-Sun-ODF-Template-Pack-fr_1.0.0.oxt";;
        "hu") SUNTEMPLATES_HU_PACK="09ec2dac030e1dcd5ef7fa1692691dc0-Sun-ODF-Template-Pack-hu_1.0.0.oxt";;
        "it") SUNTEMPLATES_IT_PACK="b33775feda3bcf823cad7ac361fd49a6-Sun-ODF-Template-Pack-it_1.0.0.oxt";;
        esac
    fi
    done
    AC_MSG_RESULT([$SUNTEMPLATES_LANG])
fi
AC_SUBST(SUNTEMPLATES_DE_PACK)
AC_SUBST(SUNTEMPLATES_EN_US_PACK)
AC_SUBST(SUNTEMPLATES_ES_PACK)
AC_SUBST(SUNTEMPLATES_FR_PACK)
AC_SUBST(SUNTEMPLATES_HU_PACK)
AC_SUBST(SUNTEMPLATES_IT_PACK)

dnl ===================================================================
dnl Test whether to include fonts
dnl ===================================================================
AC_MSG_CHECKING([whether to include third-party fonts])
if test "$with_fonts" != "no"; then
    AC_MSG_RESULT([yes])
    WITH_FONTS=YES
    BUILD_TYPE="$BUILD_TYPE MORE_FONTS"
else
    AC_MSG_RESULT([no])
    WITH_FONTS=NO
    SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
fi
AC_SUBST(WITH_FONTS)

AC_MSG_CHECKING([whether to include Agfa Monotype fonts])
if test "$with_agfa_monotype_fonts" = "yes"; then
    AC_MSG_RESULT([yes])
    WITH_AGFA_MONOTYPE_FONTS=YES
    SCPDEFS="$SCPDEFS -DWITH_AGFA_MONOTYPE_FONTS"
    BUILD_TYPE="$BUILD_TYPE AGFA_MONOTYPE_FONTS"
else
    AC_MSG_RESULT([no])
    WITH_AGFA_MONOTYPE_FONTS=NO
fi
AC_SUBST(WITH_AGFA_MONOTYPE_FONTS)

dnl ===================================================================
dnl Test whether to include ppds
dnl ===================================================================
AC_MSG_CHECKING([whether to include PPDs])
if test "$with_ppds" != "no"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
    WITHOUT_PPDS=YES
    SCPDEFS="$SCPDEFS -DWITHOUT_PPDS"
fi
AC_SUBST(WITHOUT_PPDS)

dnl ===================================================================
dnl Test whether to include afms
dnl ===================================================================
AC_MSG_CHECKING([whether to include AFMs])
if test "$with_afms" != "no"; then
    AC_MSG_RESULT([yes])
    BUILD_TYPE="$BUILD_TYPE AFMS"
else
    AC_MSG_RESULT([no])
    WITHOUT_AFMS=YES
    SCPDEFS="$SCPDEFS -DWITHOUT_AFMS"
fi
AC_SUBST(WITHOUT_AFMS)

dnl ===================================================================
dnl Test whether to include extra galleries
dnl ===================================================================
AC_MSG_CHECKING([whether to include extra galleries])
if test "$enable_extra_gallery" = "" -o "$enable_extra_gallery" = "no"; then
    AC_MSG_RESULT([no])
    WITH_EXTRA_GALLERY=NO
    OOOP_GALLERY_PACK=""
else
    AC_MSG_RESULT([yes])
    WITH_EXTRA_GALLERY=YES
    BUILD_TYPE="$BUILD_TYPE EXTRA_GALLERY"
    SCPDEFS="$SCPDEFS -DWITH_EXTRA_GALLERY"
    OOOP_GALLERY_PACK="af9314c5972d95a5d6da23ffad818f68-OOOP-gallery-pack-2.8.0.0.zip"
fi
AC_SUBST(WITH_EXTRA_GALLERY)
AC_SUBST(OOOP_GALLERY_PACK)

dnl ===================================================================
dnl Test whether to include extra templates
dnl ===================================================================
AC_MSG_CHECKING([whether to include extra templates])
if test "$enable_extra_template" = "" -o "$enable_extra_template" = "no"; then
    AC_MSG_RESULT([no])
    WITH_EXTRA_TEMPLATE=NO
    OOOP_TEMPLATES_PACK=""
else
    AC_MSG_RESULT([yes])
    WITH_EXTRA_TEMPLATE=YES
    BUILD_TYPE="$BUILD_TYPE EXTRA_TEMPLATE"
    SCPDEFS="$SCPDEFS -DWITH_EXTRA_TEMPLATE"
    OOOP_TEMPLATES_PACK="1be202fbbbc13f10592a98f70a4a87fb-OOOP-templates-pack-2.9.0.0.zip"
fi
AC_SUBST(WITH_EXTRA_TEMPLATE)
AC_SUBST(OOOP_TEMPLATES_PACK)

dnl ===================================================================
dnl Test whether to include extra samples
dnl ===================================================================
AC_MSG_CHECKING([whether to include extra samples])
if test "$enable_extra_sample" = "" -o "$enable_extra_sample" = "no"; then
    AC_MSG_RESULT([no])
    WITH_EXTRA_SAMPLE=NO
    OOOP_SAMPLES_PACK=""
else
    AC_MSG_RESULT([yes])
    WITH_EXTRA_SAMPLE=YES
    BUILD_TYPE="$BUILD_TYPE EXTRA_SAMPLE"
    SCPDEFS="$SCPDEFS -DWITH_EXTRA_SAMPLE"
    OOOP_SAMPLES_PACK="a6bccacf44914969e6e7b2f8faf4132c-OOOP-samples-pack-2.7.0.0.zip"
fi
AC_SUBST(WITH_EXTRA_SAMPLE)
AC_SUBST(OOOP_SAMPLES_PACK)

dnl ===================================================================
dnl Test whether to include extra fonts
dnl ===================================================================
AC_MSG_CHECKING([whether to include extra fonts])
if test "$enable_extra_font" = "" -o "$enable_extra_font" = "no"; then
    AC_MSG_RESULT([no])
    WITH_EXTRA_FONT=NO
    OOOP_FONTS_PACK=""
else
    AC_MSG_RESULT([yes])
    WITH_EXTRA_FONT=YES
    BUILD_TYPE="$BUILD_TYPE EXTRA_FONT"
    SCPDEFS="$SCPDEFS -DWITH_EXTRA_FONT"
    OOOP_FONTS_PACK="a10aa597411643326e27d7fc128af12d-OOOP-fonts-pack-2.9.0.0.zip"
fi
AC_SUBST(WITH_EXTRA_FONT)
AC_SUBST(OOOP_FONTS_PACK)

dnl ===================================================================
dnl Test whether to download OxygenOffice branding and set custom settings
dnl ===================================================================
AC_MSG_CHECKING([whether to download OxygenOffice branding and set custom settings])
if test "$enable_oxygenoffice" = "" -o "$enable_oxygenoffice" = "no"; then
    AC_MSG_RESULT([no])
    ENABLE_OXYGENOFFICE=NO
else
    AC_MSG_RESULT([yes])
    ENABLE_OXYGENOFFICE=YES
    OXYGENOFFICE_PACK="18bf204479ff641d99a88cd71f6f25f7-oxygenoffice-001.zip"
    BUILD_TYPE="$BUILD_TYPE OXYGENOFFICE"
fi
AC_SUBST(ENABLE_OXYGENOFFICE)
AC_SUBST(OXYGENOFFICE_PACK)

dnl ===================================================================
dnl Test whether to build global menu support
dnl ===================================================================
AC_MSG_CHECKING([whether to build global menu support])
if test "$enable_lomenubar" = "" -o "$enable_lomenubar" = "no"; then
    AC_MSG_RESULT([no])
    ENABLE_LOMENUBAR="FALSE"
else
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES(DBUSMENUGTK, dbusmenu-gtk-0.4,, AC_MSG_ERROR([requirements to build lo-menubar not met. Use --disable-lomenubar or install the missing packages]))
    ENABLE_LOMENUBAR="TRUE"
fi
AC_SUBST(ENABLE_LOMENUBAR)

dnl ===================================================================
dnl Test whether to enable online update service
dnl ===================================================================
AC_MSG_CHECKING([whether to enable online update])
ENABLE_ONLINE_UPDATE=
if test "$enable_online_update" = ""; then
    if test "$_os" = "WINNT" -o "$_os" = "Darwin"; then
        AC_MSG_RESULT([yes])
        ENABLE_ONLINE_UPDATE="TRUE"
    else
        AC_MSG_RESULT([no])
    fi
else
    if test "$enable_online_update" = "yes"; then
        AC_MSG_RESULT([yes])
        ENABLE_ONLINE_UPDATE="TRUE"
    else
        AC_MSG_RESULT([no])
    fi
fi
AC_SUBST(ENABLE_ONLINE_UPDATE)

dnl ===================================================================
dnl Test whether build target is Release Build
dnl ===================================================================
AC_MSG_CHECKING([whether build target is Release Build])
if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
    AC_MSG_RESULT([no])
    ENABLE_RELEASE_BUILD="FALSE"
else
    AC_MSG_RESULT([yes])
    ENABLE_RELEASE_BUILD="TRUE"
fi
AC_SUBST(ENABLE_RELEASE_BUILD)

dnl ===================================================================
dnl Test whether to create MSI with LIMITUI=1 (silent install)
dnl ===================================================================
AC_MSG_CHECKING([whether to create MSI with LIMITUI=1 (silent install)])
if test "$enable_silent_msi" = "" -o "$enable_silent_msi" = "no"; then
    AC_MSG_RESULT([no])
    ENABLE_SILENT_MSI="FALSE"
else
    AC_MSG_RESULT([yes])
    ENABLE_SILENT_MSI="TRUE"
    SCPDEFS="$SCPDEFS -DENABLE_SILENT_MSI"
fi
AC_SUBST(ENABLE_SILENT_MSI)

dnl ===================================================================
dnl Test whether to enable ActiveX embedding
dnl ===================================================================
if test "$_os" = "WINNT" -a "$WITH_MINGW" != yes; then
    AC_MSG_CHECKING([whether to enable ActiveX embedding of LibreOffice components])
    if test "$enable_activex_component" = "yes" -o "$enable_activex_component" = "TRUE" -o "$enable_activex_component" = ""; then
        ENABLE_ACTIVEX_COMPONENT="TRUE"
        AC_MSG_RESULT([yes])
        SCPDEFS="$SCPDEFS -DWITH_ACTIVEX_COMPONENT"
    else
        ENABLE_ACTIVEX_COMPONENT=""
        AC_MSG_RESULT([no])
    fi
    AC_SUBST(ENABLE_ACTIVEX_COMPONENT)
    AC_SUBST(SCPDEFS)
fi

AC_MSG_CHECKING([whether and how to use Xinerama])
if test "$_os" = "Darwin"; then
    USE_XINERAMA=YES
    XINERAMA_LINK=dynamic
    AC_MSG_RESULT([yes])
elif test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
    if test "$x_libraries" = "default_x_libraries"; then
        XINERAMALIB=`$PKG_CONFIG --variable=libdir xinerama`
        if test "x$XINERAMALIB" = x; then
           XINERAMALIB="/usr/lib"
        fi
    else
        XINERAMALIB="$x_libraries"
    fi
    if test -e "$XINERAMALIB/libXinerama.so" -a -e "$XINERAMALIB/libXinerama.a"; then
        # we have both versions, let the user decide but use the dynamic one
        # per default
        USE_XINERAMA=YES
        if test -z "$with_static_xinerama" -o -n "$with_system_libs"; then
            XINERAMA_LINK=dynamic
        else
            XINERAMA_LINK=static
        fi
    elif test -e "$XINERAMALIB/libXinerama.so" -a ! -e "$XINERAMALIB/libXinerama.a"; then
        # we have only the dynamic version
        USE_XINERAMA=YES
        XINERAMA_LINK=dynamic
    elif test -e "$XINERAMALIB/libXinerama.a"; then
        # static version
        if echo $host_cpu | $GREP -E 'i[[3456]]86' 2>/dev/null >/dev/null; then
            USE_XINERAMA=YES
            XINERAMA_LINK=static
        else
            USE_XINERAMA=NO
            XINERAMA_LINK=none
        fi
    else
        # no Xinerama
        USE_XINERAMA=NO
        XINERAMA_LINK=none
    fi
    if test "$USE_XINERAMA" = "YES"; then
        AC_MSG_RESULT([yes, with $XINERAMA_LINK linking])
        AC_CHECK_HEADER(X11/extensions/Xinerama.h, [],
            [AC_MSG_ERROR(Xinerama header not found.)], [])
        XEXTLIBS=`$PKG_CONFIG --variable=libs xext`
        if test "x$XEXTLIB" = x; then
           XEXTLIBS="-L$XLIB -L$XINERAMALIB -lXext"
        fi
        XINERAMA_EXTRA_LIBS="$XEXTLIBS"
        if test "$_os" = "FreeBSD"; then
            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -lXt"
        fi
        if test "$_os" = "Linux"; then
            XINERAMA_EXTRA_LIBS="$XINERAMA_EXTRA_LIBS -ldl"
        fi
        AC_CHECK_LIB([Xinerama], [XineramaIsActive], [:],
            [AC_MSG_ERROR(Xinerama not functional?)], [$XINERAMA_EXTRA_LIBS])
    else
        AC_MSG_RESULT([no, libXinerama not found or wrong architecture.])
    fi
else
    USE_XINERAMA=NO
    XINERAMA_LINK=none
    AC_MSG_RESULT([no])
fi
AC_SUBST(USE_XINERAMA)
AC_SUBST(XINERAMA_LINK)

dnl ===================================================================
dnl Checks for librsvg
dnl ===================================================================

dnl ENABLE_LIBRSVG is set to "" (for NO), SYSTEM or INTERNAL. The
dnl SYSTEM_LIBRSVG, SYSTEM_GDKPIXBUF etc are redundant.

ENABLE_LIBRSVG=""
LIBRSVG_CFLAGS=""
LIBRSVG_LIBS=""

AC_MSG_CHECKING([what librsvg to use])

case "$enable_librsvg" in
no|disable)
    AC_MSG_RESULT([none])
    enable_librsvg=no
    ;;

""|yes|auto)
    if test $build_os = cygwin -o \
           $_os = Darwin; then
        dnl When building on/for these OSes always use the internal one,
        dnl if at all. Add more OSes above as needed.
        AC_MSG_RESULT([internal])
        enable_librsvg=internal
    elif test  $_os = iOS -o $_os = Android; then
        AC_MSG_RESULT([none])
        enable_librsvg=no
    else
        if test "$with_system_libs" = yes; then
            AC_MSG_RESULT([system])
            PKG_CHECK_MODULES(LIBRSVG, librsvg-2.0 >= 2.14)
            enable_librsvg=system
        elif test "$with_system_libs" = no; then
            AC_MSG_RESULT([internal])
            enable_librsvg=internal
        else
            AC_MSG_RESULT([checking further])
            PKG_CHECK_MODULES(LIBRSVG, librsvg-2.0 >= 2.14,, [:])
            if test -z "$LIBRSVG_PKG_ERRORS"; then
                enable_librsvg=system
            else
                enable_librsvg=internal
            fi
        fi
    fi
    ;;

internal)
    AC_MSG_RESULT([internal])
    ;;

fully-internal)
    AC_MSG_RESULT([fully internal])
    ;;

system)
    if test $_os = WINNT -a "$WITH_MINGW" != yes; then
        AC_MSG_ERROR([Must use internal librsvg when building with MSVC])
    fi
    AC_MSG_RESULT([system])
    PKG_CHECK_MODULES(LIBRSVG, librsvg-2.0 >= 2.14)
    ;;

*)
    AC_MSG_ERROR([Incorrect --enable-librsvg option])
    ;;
esac

dnl By now enable_librsvg should be "system", "internal", "fully-internal", or
dnl "no":
case $enable_librsvg in
system)
    ENABLE_LIBRSVG=SYSTEM
    SYSTEM_LIBRSVG=YES
    ;;

internal|fully-internal)
    ENABLE_LIBRSVG=INTERNAL
    SYSTEM_LIBRSVG=NO
    BUILD_TYPE="$BUILD_TYPE LIBRSVG"
    ;;

no)
    ENABLE_LIBRSVG=NO
    SYSTEM_LIBRSVG=NO
    ;;

*)
    AC_MSG_ERROR([Internal configure script error, invalid enable_librsvg value "$enable_librsvg"])
    ;;
esac

AC_SUBST(ENABLE_LIBRSVG)
AC_SUBST(LIBRSVG_CFLAGS)
AC_SUBST(LIBRSVG_LIBS)
AC_SUBST(SYSTEM_LIBRSVG)

dnl ===================================================================
dnl Test whether to build cairo or rely on the system version
dnl ===================================================================


SYSTEM_CAIRO=""

AC_MSG_CHECKING([whether to use the system cairo])

if test "$with_system_cairo" = "yes"; then
    SYSTEM_CAIRO=YES
    AC_MSG_RESULT([yes])

    PKG_CHECK_MODULES( CAIRO, cairo >= 1.0.2 )

    if test "$test_xrender" = "yes"; then
        if test "$with_system_xextensions_headers" != "no"; then
            AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
            AC_LANG_PUSH([C])
            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],[[
#ifdef PictStandardA8
#else
      return fail;
#endif
]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, X headers too old.])])

            AC_LANG_POP([C])
        fi
    fi
    libo_MINGW_CHECK_DLL([CAIRO], [libcairo])
    libo_MINGW_TRY_DLL([FONTCONFIG], [libfontconfig])
    libo_MINGW_TRY_DLL([FREETYPE], [libfreetype])
    libo_MINGW_TRY_DLL([PIXMAN], [libpixman])
    libo_MINGW_TRY_DLL([PNG15], [libpng15])
else
    AC_MSG_RESULT([no])

    if test $_os = WINNT; then
        dnl We only need cairo for Windows if we
        dnl build librsvg or directx disabled
        if test "$ENABLE_LIBRSVG" != NO -o -z "$ENABLE_DIRECTX"; then
            BUILD_TYPE="$BUILD_TYPE CAIRO"
        fi
    else
        if test "$enable_cairo_canvas" = "yes"; then
            BUILD_TYPE="$BUILD_TYPE CAIRO"
        else
            if test "$with_system_cairo" != "yes"; then
                if test "$ENABLE_LIBRSVG" != NO; then
                    BUILD_TYPE="$BUILD_TYPE CAIRO"
                fi
            fi
        fi
    fi
fi

AC_SUBST(SYSTEM_CAIRO)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(CAIRO_LIBS)
AC_SUBST([MINGW_CAIRO_DLL])
AC_SUBST([MINGW_FONTCONFIG_DLL])
AC_SUBST([MINGW_FREETYPE_DLL])
AC_SUBST([MINGW_PIXMAN_DLL])
AC_SUBST([MINGW_PNG15_DLL])


dnl ===================================================================
dnl Test whether to build gdk-pixbuf or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system gdk-pixbuf])

dnl As long as the only thing we need gdk-pixbuf for is below
dnl librsvg, use the same --enable-librsvg (possibly implied
dnl by --with-system-libs) to override this.

if test "$SYSTEM_LIBRSVG" = YES; then
    SYSTEM_GDKPIXBUF=YES
    AC_MSG_RESULT([yes])
elif test "$enable_librsvg" = fully-internal; then
    SYSTEM_GDKPIXBUF=NO
    AC_MSG_RESULT([no])
else
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        SYSTEM_GDKPIXBUF=NO
        AC_MSG_RESULT([no])
        ;;
    *)
        SYSTEM_GDKPIXBUF=YES
        AC_MSG_RESULT([yes])
        ;;
    esac
fi
AC_SUBST(SYSTEM_GDKPIXBUF)

dnl ===================================================================
dnl Test whether to build GLib or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system GLib])

dnl As long as the only thing we need GLib for is below
dnl librsvg, use the same --enable-librsvg (possibly implied
dnl by --with-system-libs) to override this.

if test "$SYSTEM_LIBRSVG" = YES; then
    SYSTEM_GLIB=YES
    AC_MSG_RESULT([yes])
elif test "$enable_librsvg" = fully-internal; then
    SYSTEM_GLIB=NO
    AC_MSG_RESULT([no])
else
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        SYSTEM_GLIB=NO
        AC_MSG_RESULT([no])
        ;;
    *)
        SYSTEM_GLIB=YES
        AC_MSG_RESULT([yes])
        ;;
    esac
fi
AC_SUBST(SYSTEM_GLIB)

dnl ===================================================================
dnl Test whether to build gettext runtime (libintl) or rely on the
dnl system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system gettext runtime])

if test -z "$with_system_gettext"; then
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        with_system_gettext=no
        ;;
    *)
        with_system_gettext=yes
        ;;
    esac
fi
if test "$with_system_gettext" = yes; then
    SYSTEM_GETTEXT=YES
    AC_MSG_RESULT([yes])
elif test "$with_system_gettext" = no; then
    SYSTEM_GETTEXT=NO
    AC_MSG_RESULT([yes])
else
    AC_MSG_ERROR([bad --with-system-gettext=$with_system_gettext])
fi
AC_SUBST(SYSTEM_GETTEXT)

dnl ===================================================================
dnl Test whether to build libcroco or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system libcroco])

dnl As long as the only thing we need libcroco for is below
dnl librsvg, use the same --enable-librsvg (possibly implied
dnl by --with-system-libs) to override this.

if test "$SYSTEM_LIBRSVG" = YES; then
    SYSTEM_LIBCROCO=YES
    AC_MSG_RESULT([yes])
elif test "$enable_librsvg" = fully-internal; then
    SYSTEM_LIBCROCO=NO
    AC_MSG_RESULT([no])
else
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        SYSTEM_LIBCROCO=NO
        AC_MSG_RESULT([no])
        ;;
    *)
        SYSTEM_LIBCROCO=YES
        AC_MSG_RESULT([yes])
        ;;
    esac
fi
AC_SUBST(SYSTEM_LIBCROCO)

dnl ===================================================================
dnl Test whether to build Pango or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system pango])

dnl As long as the only thing we need Pango for is below
dnl librsvg, use the same --enable-librsvg (possibly implied
dnl by --with-system-libs) to override this.

if test "$SYSTEM_LIBRSVG" = YES; then
    SYSTEM_PANGO=YES
    AC_MSG_RESULT([yes])
elif test "$enable_librsvg" = fully-internal; then
    SYSTEM_PANGO=NO
    AC_MSG_RESULT([no])
else
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        SYSTEM_PANGO=NO
        AC_MSG_RESULT([no])
        ;;
    *)
        SYSTEM_PANGO=YES
        AC_MSG_RESULT([yes])
        ;;
    esac
fi
AC_SUBST(SYSTEM_PANGO)

dnl ===================================================================
dnl Test whether to build libgsf or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system libgsf])

dnl As long as the only thing we need libgsf for is below librsvg (is
dnl it?), use the same --enable-librsvg (possibly implied by
dnl --with-system-libs) to override this.

if test "$SYSTEM_LIBRSVG" = YES; then
    SYSTEM_LIBGSF=YES
    AC_MSG_RESULT([yes])
elif test "$enable_librsvg" = fully-internal; then
    SYSTEM_LIBGSF=NO
    AC_MSG_RESULT([no])
else
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        SYSTEM_LIBGSF=NO
        AC_MSG_RESULT([no])
        ;;
    *)
        SYSTEM_LIBGSF=YES
        AC_MSG_RESULT([yes])
        ;;
    esac
fi
AC_SUBST(SYSTEM_LIBGSF)

dnl ===================================================================
dnl Test whether to build libpng or rely on the system version
dnl ===================================================================

AC_MSG_CHECKING([whether to use the system libpng])

dnl How should and does this interact with the checks for libpng
dnl related to use of libpng in the quickstarter above? This needs to
dnl be unified.

if test "$with_system_libpng" = "auto"; then
    case "$_os" in
    WINNT|Darwin|iOS|Android)
        with_system_libpng="$with_system_libs"
        ;;
    *)
        with_system_libpng=yes
        ;;
    esac
fi

if test "$with_system_libpng" = yes; then
    SYSTEM_LIBPNG=YES
    AC_MSG_RESULT([yes])
else
    SYSTEM_LIBPNG=NO
    BUILD_TYPE="$BUILD_TYPE LIBPNG"
    AC_MSG_RESULT([no])
fi
AC_SUBST(SYSTEM_LIBPNG)

dnl ===================================================================
dnl Check for runtime JVM search path
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
    AC_MSG_CHECKING([whether to use specific JVM search path at runtime])
    if test -n "$with_jvm_path" -a "$with_jvm_path" != "no"; then
        AC_MSG_RESULT([yes])
        if ! test -d "$with_jvm_path"; then
            AC_MSG_ERROR(["$with_jvm_path" not a directory])
        fi
        if ! test -d "$with_jvm_path"jvm; then
            AC_MSG_ERROR(["$with_jvm_path"jvm not found, point with_jvm_path to \[/path/to/\]jvm])
        fi
        JVM_ONE_PATH_CHECK="$with_jvm_path"
        AC_SUBST(JVM_ONE_PATH_CHECK)
    else
        AC_MSG_RESULT([no])
    fi
fi

dnl ===================================================================
dnl Test for the presence of Ant and that it works
dnl ===================================================================

if test "$SOLAR_JAVA" != ""; then
    ANT_HOME=; export ANT_HOME
    WITH_ANT_HOME=; export WITH_ANT_HOME
    if test -z "$with_ant_home"; then
        AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat ant.cmd])
    else
        if test "$_os" = "WINNT"; then
            with_ant_home=`cygpath -u "$with_ant_home"`
        fi
        AC_PATH_PROGS(ANT, [jakarta-ant ant ant.sh ant.bat ant.cmd],,$with_ant_home/bin:$PATH)
        WITH_ANT_HOME=$with_ant_home
        ANT_HOME=$with_ant_home
    fi

    if test -z "$ANT"; then
        AC_MSG_ERROR([Ant not found - Make sure it's in the path or use --with-ant-home])
    else
        # resolve relative or absolute symlink
        while test -h "$ANT"; do
            a_cwd=`pwd`
            a_basename=`basename "$ANT"`
            a_script=`ls -l "$ANT" | $SED "s/.*${a_basename} -> //g"`
            cd "`dirname "$ANT"`"
            cd "`dirname "$a_script"`"
            ANT="`pwd`"/"`basename "$a_script"`"
            cd "$a_cwd"
        done

        AC_MSG_CHECKING([if $ANT works])
        cat > conftest.java << EOF
        public class conftest {
            int testmethod(int a, int b) {
                    return a + b;
            }
        }
EOF

        cat > conftest.xml << EOF
        <project name="conftest" default="conftest">
        <target name="conftest">
            <javac srcdir="." includes="conftest.java">
            </javac>
        </target>
        </project>
EOF

        oldJAVA_HOME=$JAVA_HOME
        if test "$JAVACISGCJ" = "yes"; then
            JAVA_HOME=; export JAVA_HOME
            ant_cmd="$ANT -Dbuild.compiler=gcj -buildfile conftest.xml 1>&2"
        else
            ant_cmd="$ANT -buildfile conftest.xml 1>&2"
        fi
        AC_TRY_EVAL(ant_cmd)
        if test $? = 0 -a -f ./conftest.class; then
            AC_MSG_RESULT([Ant works])
            if test -z "$WITH_ANT_HOME"; then
                ANT_HOME=`$ANT -diagnostics | $EGREP "ant.home :" | $SED -e "s#ant.home : ##g"`
                if test -z "$ANT_HOME"; then
                    ANT_HOME=`echo $ANT | $SED -n "s/\/bin\/ant.*\$//p"`
                fi
            else
                ANT_HOME="$WITH_ANT_HOME"
            fi
        else
            echo "configure: Ant test failed" >&5
            cat conftest.java >&5
            cat conftest.xml >&5
            AC_MSG_WARN([Ant does not work - Some Java projects will not build!])
            ANT_HOME=""
            echo "Ant does not work - Some Java projects will not build!" >>warn
        fi
        JAVA_HOME=$oldJAVA_HOME
        rm -f conftest* core core.* *.core
    fi
    if test -z "$ANT_HOME"; then
        ANT_HOME="NO_ANT_HOME"
    else
        PathFormat "$ANT_HOME"
        ANT_HOME="$formatted_path"
        PathFormat "$ANT"
        ANT="$ANT"
    fi
    AC_SUBST(ANT_HOME)
    AC_SUBST(ANT)

    dnl Checking for ant.jar
    if test "$ANT_HOME" != "NO_ANT_HOME"; then
        AC_MSG_CHECKING([Ant lib directory])
        if test -f $ANT_HOME/lib/ant.jar; then
            ANT_LIB="$ANT_HOME/lib"
        else
            if test -f $ANT_HOME/ant.jar; then
                ANT_LIB="$ANT_HOME"
            else
                if test -f /usr/share/java/ant.jar; then
                    ANT_LIB=/usr/share/java
                else
                    if test -f /usr/share/ant-core/lib/ant.jar; then
                        ANT_LIB=/usr/share/ant-core/lib
                    else
                        if test -f $ANT_HOME/lib/ant/ant.jar; then
                            ANT_LIB="$ANT_HOME/lib/ant"
                        else
                            if test -f /usr/share/lib/ant/ant.jar; then
                                ANT_LIB=/usr/share/lib/ant
                            else
                                AC_MSG_ERROR([Ant libraries not found!])
                            fi
                        fi
                    fi
                fi
            fi
        fi
        PathFormat "$ANT_LIB"
        ANT_LIB="$formatted_path"
        AC_MSG_RESULT([Ant lib directory found.])
    fi
    AC_SUBST(ANT_LIB)

    ant_minver=1.6.0
    ant_minminor1=`echo $ant_minver | cut -d"." -f2`

    AC_MSG_CHECKING([whether Ant is >= $ant_minver])
    ant_version=`$ANT -version | $AWK '{ print $4; }'`
    ant_version_major=`echo $ant_version | cut -d. -f1`
    ant_version_minor=`echo $ant_version | cut -d. -f2`
    echo "configure: ant_version $ant_version " >&5
    echo "configure: ant_version_major $ant_version_major " >&5
    echo "configure: ant_version_minor $ant_version_minor " >&5
    if test "$ant_version_major" -ge "2"; then
        AC_MSG_RESULT([yes, $ant_version])
    elif test "$ant_version_major" = "1" -a "$ant_version_minor" -ge "$ant_minminor1"; then
        AC_MSG_RESULT([yes, $ant_version])
    else
        AC_MSG_ERROR([no, you need at least Ant >= $ant_minver])
    fi

    if test "$ENABLE_MEDIAWIKI" = "YES"; then
        AC_MSG_CHECKING([whether Ant supports mapper type="regexp"])
        rm -rf confdir
        mkdir confdir
        cat > conftest.java << EOF
            public class conftest {
                int testmethod(int a, int b) {
                    return a + b;
                }
            }
EOF

        cat > conftest.xml << EOF
            <project name="conftest" default="conftest">
            <target name="conftest" depends="copytest">
                <javac srcdir="." includes="conftest.java">
                </javac>
            </target>
            <target name="copytest">
                 <copy todir="confdir">
                 <fileset dir="confdir" includes="**/*.abc" casesensitive="yes"/>
                 <filterset/>
                 <mapper type="regexp" from="^(.*[/\\])foo([/\\].*)" to="\1baa\2"/>
                 </copy>
            </target>
            </project>
EOF

        if test "$JAVACISGCJ" = "yes"; then
            JAVA_HOME=; export JAVA_HOME
            ant_cmd="$ANT -Dbuild.compiler=gcj -buildfile conftest.xml 1>&2"
        else
            ant_cmd="$ANT -buildfile conftest.xml 1>&2"
        fi
        AC_TRY_EVAL(ant_cmd)
        if test $? = 0 -a -f ./conftest.class; then
            AC_MSG_RESULT([yes])
            rm -rf confdir
        else
            echo "configure: Ant test failed" >&5
            cat conftest.java >&5
            cat conftest.xml >&5
            rm -rf confdir
            AC_MSG_ERROR([no. Did you install ant-apache-regexp?])
        fi
    fi
    rm -f conftest* core core.* *.core
fi

OOO_JUNIT_JAR=
if test "$SOLAR_JAVA" != "" -a "$with_junit" != "no"; then
    AC_MSG_CHECKING([for JUnit 4])
    if test "$with_junit" = "yes"; then
        if test -e /usr/share/java/junit4.jar; then
            OOO_JUNIT_JAR=/usr/share/java/junit4.jar
        else
           if test -e /usr/share/lib/java/junit.jar; then
              OOO_JUNIT_JAR=/usr/share/lib/java/junit.jar
           else
              OOO_JUNIT_JAR=/usr/share/java/junit.jar
           fi
        fi
    else
        OOO_JUNIT_JAR=$with_junit
    fi
    if test "$_os" = "WINNT"; then
        OOO_JUNIT_JAR=`cygpath -m "$OOO_JUNIT_JAR"`
    fi
    "$JAVA_HOME/bin/jar" tf "$OOO_JUNIT_JAR" 2>&5 | \
        grep org/junit/Before.class > /dev/null 2>&5
    if test $? -eq 0; then
        # check if either class-path entry is available for hamcrest or
        # it's bundled
        if "$JAVA_HOME/bin/jar" tf "$OOO_JUNIT_JAR" |$GREP -q hamcrest || \
            "$UNZIP" -c "$OOO_JUNIT_JAR" META-INF/MANIFEST.MF |$GREP 'Class-Path:' | $GREP -q 'hamcrest'; then
            AC_MSG_RESULT([$OOO_JUNIT_JAR])
        else
            AC_MSG_ERROR([your junit jar neither sets a classpath nor includes hamcrest; please
provide a full junit jar or use --without-junit])
        fi
    else
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([cannot find JUnit 4 jar; please install one in the default
location (/usr/share/java), specify its pathname via
--with-junit=..., or disable it via --without-junit])
    fi
    if test $OOO_JUNIT_JAR != ""; then
	BUILD_TYPE="$BUILD_TYPE QADEVOOO"
    fi
fi
AC_SUBST(OOO_JUNIT_JAR)

if test "$enable_odk" = no; then
    unset DOXYGEN
else
    if test "$with_doxygen" = no; then
        AC_MSG_CHECKING([for doxygen])
        unset DOXYGEN
        AC_MSG_RESULT([no])
    else
        if test "$with_doxygen" = yes; then
            AC_PATH_PROG([DOXYGEN], [doxygen])
            if test -z "$DOXYGEN"; then
                AC_MSG_RESULT([no])
                AC_MSG_ERROR([doxygen not found in \$PATH; specify its pathname via --with-doxygen=..., or disable its use via --without-doxygen])
            fi
        else
            AC_MSG_CHECKING([for doxygen])
            DOXYGEN=$with_doxygen
            AC_MSG_RESULT([$DOXYGEN])
        fi
    fi
fi
AC_SUBST([DOXYGEN])

dnl ===================================================================
dnl Product version
dnl ===================================================================
AC_MSG_CHECKING([for product version])
PRODUCTVERSION=AC_PACKAGE_VERSION
AC_MSG_RESULT([$PRODUCTVERSION])
AC_SUBST(PRODUCTVERSION)

dnl ===================================================================
dnl Dealing with l10n options
dnl ===================================================================
AC_MSG_CHECKING([which languages to be built])
# get list of all languages
# generate shell variable from completelangiso= from solenv/inc/langlist.mk
# the sed command does the following:
#   + if a line ends with a backslash, append the next line to it
#   + adds " on the beginning of the value (after =)
#   + adds " at the end of the value
#   + removes en-US; we want to put it on the beginning
#   + prints just the section starting with 'completelangiso=' and ending with the " at the end of line
[eval $(sed -e :a -e '/\\$/N; s/\\\n//; ta' -n -e 's/=/="/;s/\([^\\]\)$/\1"/;s/en-US//;/^completelangiso/p' solenv/inc/langlist.mk)]
ALL_LANGS="en-US $completelangiso"
# check the configured localizations
WITH_LANG="$with_lang"
if test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US"; then
    AC_MSG_RESULT([en-US])
else
    AC_MSG_RESULT([$WITH_LANG])
    GIT_REPO_NAMES="$GIT_REPO_NAMES translations"
fi
# check that the list is valid
for lang in $WITH_LANG; do
    test "$lang" = "ALL" && continue;
    # need to check for the exact string, so add space before and after the list of all languages
    for vl in $ALL_LANGS; do
        if test "$vl" = "$lang"; then
           break;
        fi
    done
    if test "$vl" != "$lang"; then
        AC_MSG_ERROR([invalid language: $lang; supported languages are: $ALL_LANGS])
    fi
done
# list with substituted ALL
WITH_LANG_LIST=`echo $WITH_LANG | sed "s/ALL/$ALL_LANGS/"`
# this variable is used only by bin/distro-install-* helper scripts
# they need a real list of languages
test -z "$WITH_LANG_LIST" && WITH_LANG_LIST="en-US"
test -z "$WITH_LANG" -o "$WITH_LANG" = "en-US" || BUILD_TYPE="$BUILD_TYPE TRANSLATIONS"
AC_SUBST(ALL_LANGS)
AC_SUBST(WITH_LANG)
AC_SUBST(WITH_LANG_LIST)
AC_SUBST(GIT_REPO_NAMES)


PathFormat "$SRC_ROOT/translations"
L10N_MODULE="$formatted_path"
WITH_POOR_HELP_LOCALIZATIONS=
if test -d "./translations"; then
    for l in `ls -1 translations/source`; do
        if test ! -d translations/source/$l/helpcontent2; then
            WITH_POOR_HELP_LOCALIZATIONS="$WITH_POOR_HELP_LOCALIZATIONS $l"
        fi
    done
fi
AC_SUBST(L10N_MODULE)
AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)

dnl git-new-workdir
dnl ===================================================================
if test -n "${GIT_LINK_SRC}"; then
    for repo in ${GIT_REPO_NAMES}; do
        if ! test -d "${GIT_LINK_SRC}"/${repo}; then
            AC_MSG_ERROR([linked git: required repository does not exist: ${GIT_LINK_SRC}/${repo}])
        fi
    done
fi
AC_SUBST(GIT_LINK_SRC)

AC_MSG_CHECKING([for custom 'intro' progress bar color])
PROGRESSBARCOLOR=
if test -z "$with_intro_progressbar_color"; then
   PROGRESSBARCOLOR="126,170,23"
   AC_MSG_RESULT([none])
else
   PROGRESSBARCOLOR="$with_intro_progressbar_color"
   AC_MSG_RESULT([$PROGRESSBARCOLOR])
fi
AC_SUBST(PROGRESSBARCOLOR)

AC_MSG_CHECKING([for custom 'intro' progress bar size])
PROGRESSSIZE=
if test -z "$with_intro_progressbar_size"; then
   PROGRESSSIZE="319,10"
   AC_MSG_RESULT([none])
else
   PROGRESSSIZE="$with_intro_progressbar_size"
   AC_MSG_RESULT([$PROGRESSSIZE])
fi
AC_SUBST(PROGRESSSIZE)

AC_MSG_CHECKING([for custom 'intro' progress bar position])
PROGRESSPOSITION=
if test -z "$with_intro_progressbar_position"; then
   PROGRESSPOSITION="164,225"
   AC_MSG_RESULT([none])
else
   PROGRESSPOSITION="$with_intro_progressbar_position"
   AC_MSG_RESULT([$PROGRESSPOSITION])
fi
AC_SUBST(PROGRESSPOSITION)

AC_MSG_CHECKING([for custom 'intro' progress bar frame color])
PROGRESSFRAMECOLOR=
if test -z "$with_intro_progressbar_frame_color"; then
   PROGRESSFRAMECOLOR="207,208,211"
   AC_MSG_RESULT([none])
else
   PROGRESSFRAMECOLOR="$with_intro_progressbar_frame_color"
   AC_MSG_RESULT([$PROGRESSFRAMECOLOR])
fi
AC_SUBST(PROGRESSFRAMECOLOR)

AC_MSG_CHECKING([for alternative branding images directory])
INTRO_BITMAP=
ABOUT_BACKGROUND_SVG=
FLAT_LOGO_SVG=
STARTCENTER_LEFT_BITMAP=
STARTCENTER_RIGHT_BITMAP=
STARTCENTER_RTL_LEFT_BITMAP=
STARTCENTER_RTL_RIGHT_BITMAP=
STARTCENTER_SPACE_BITMAP=
if test -z "$with_branding" -o "$with_branding" = "no"; then
    AC_MSG_RESULT([none])
else
    INTRO_BITMAP="$with_branding/intro.png"
    ABOUT_BACKGROUND_SVG="$with_branding/about.svg"
    FLAT_LOGO_SVG="$with_branding/flat_logo.svg"
    STARTCENTER_LEFT_BITMAP="$with_branding/backing_left.png"
    STARTCENTER_RIGHT_BITMAP="$with_branding/backing_right.png"
    STARTCENTER_RTL_LEFT_BITMAP="$with_branding/backing_rtl_left.png"
    STARTCENTER_RTL_RIGHT_BITMAP="$with_branding/backing_rtl_right.png"
    STARTCENTER_SPACE_BITMAP="$with_branding/backing_space.png"
    for i in $INTRO_BITMAP \
             $ABOUT_BACKGROUND_SVG \
             $FLAT_LOGO_SVG \
             $STARTCENTER_LEFT_BITMAP \
             $STARTCENTER_RIGHT_BITMAP \
             $STARTCENTER_RTL_LEFT_BITMAP \
             $STARTCENTER_RTL_RIGHT_BITMAP \
             $STARTCENTER_SPACE_BITMAP; do
        if test ! -f $i; then
            AC_MSG_WARN([Required file $i does not exist!])
        fi
    done
    AC_MSG_RESULT([$with_branding])
fi

AC_MSG_CHECKING([for yet another 'intro' bitmap])
if test -z "$with_intro_bitmap" -o "$with_intro_bitmap" = "no"; then
    if test "$with_intro_bitmap" = "no"; then
        INTRO_BITMAP=
    fi
    AC_MSG_RESULT([none])
else
    case "$with_intro_bitmap" in
    *.png) INTRO_BITMAP="$with_intro_bitmap" ;;
    *)     AC_MSG_WARN([Intro bitmap should be a .png file!]) ;;
    esac
    AC_MSG_RESULT([$INTRO_BITMAP])
fi
AC_SUBST(INTRO_BITMAP)

AC_MSG_CHECKING([for yet another 'about' svg])
if test -z "$with_about_background_svg" -o "$with_about_background_svg" = "no" ; then
    if test "$with_about_background_svg" = "no" ; then
        ABOUT_BACKGROUND_SVG=
    fi
    AC_MSG_RESULT([none])
else
   case "$with_about_background_svg" in
   *.svg) ABOUT_BACKGROUND_SVG="$with_about_background_svg" ;;
   *)     AC_MSG_WARN([About background SVG should be a .svg file!]) ;;
   esac
   AC_MSG_RESULT([$ABOUT_BACKGROUND_SVG])
fi
AC_SUBST(ABOUT_BACKGROUND_SVG)

AC_MSG_CHECKING([for yet another 'flat_logo' svg])
if test -z "$with_flat_logo_svg" -o "$with_flat_logo_svg" = "no" ; then
    if test "$with_flat_logo_svg" = "no" ; then
        FLAT_LOGO_SVG=
    fi
    AC_MSG_RESULT([none])
else
   case "$with_flat_logo_svg" in
   *.svg) FLAT_LOGO_SVG="$with_flat_logo_svg" ;;
   *)     AC_MSG_WARN([Flat logo SVG should be a .svg file!]) ;;
   esac
   AC_MSG_RESULT([$ABOUT_BITMAP])
fi
AC_SUBST(FLAT_LOGO_SVG)

AC_MSG_CHECKING([for yet another 'start center left' bitmap])
if test -z "$with_startcenter_left_bitmap" -o "$with_startcenter_left_bitmap" = "no"; then
   if test "$with_startcenter_left_bitmap" = "no"; then
      STARTCENTER_LEFT_BITMAP=
   fi
   AC_MSG_RESULT([none])
else
   case "$with_startcenter_left_bitmap" in
      *.png) STARTCENTER_LEFT_BITMAP="$with_startcenter_left_bitmap" ;;
      *)     AC_MSG_WARN([Startcenter left bitmap should be a .png file!]) ;;
   esac
   AC_MSG_RESULT([$STARTCENTER_LEFT_BITMAP])
fi
AC_SUBST(STARTCENTER_LEFT_BITMAP)

AC_MSG_CHECKING([for yet another 'start center right' bitmap])
if test -z "$with_startcenter_right_bitmap" -o "$with_startcenter_right_bitmap" = "no"; then
   if test "$with_startcenter_right_bitmap" = "no"; then
      STARTCENTER_RIGHT_BITMAP=
   fi
   AC_MSG_RESULT([none])
else
   case "$with_startcenter_right_bitmap" in
      *.png) STARTCENTER_RIGHT_BITMAP="$with_startcenter_right_bitmap" ;;
      *)     AC_MSG_WARN([Startcenter right bitmap should be a .png file!]) ;;
   esac
   AC_MSG_RESULT([$STARTCENTER_RIGHT_BITMAP])
fi
AC_SUBST(STARTCENTER_RIGHT_BITMAP)

AC_MSG_CHECKING([for yet another 'start center rtl left' bitmap])
if test -z "$with_startcenter_rtl_left_bitmap" -o "$with_startcenter_rtl_left_bitmap" = "no"; then
   if test "$with_startcenter_rtl_left_bitmap" = "no"; then
      STARTCENTER_RTL_LEFT_BITMAP=
   fi
   AC_MSG_RESULT([none])
else
   case "$with_startcenter_rtl_left_bitmap" in
      *.png) STARTCENTER_RTL_LEFT_BITMAP="$with_startcenter_rtl_left_bitmap" ;;
      *)     AC_MSG_WARN([Startcenter rtl left bitmap should be a .png file!]) ;;
   esac
   AC_MSG_RESULT([$STARTCENTER_RTL_LEFT_BITMAP])
fi
AC_SUBST(STARTCENTER_RTL_LEFT_BITMAP)

AC_MSG_CHECKING([for yet another 'start center rtl right' bitmap])
if test -z "$with_startcenter_rtl_right_bitmap" -o "$with_startcenter_rtl_right_bitmap" = "no"; then
   if test "$with_startcenter_rtl_right_bitmap" = "no"; then
      STARTCENTER_RTL_RIGHT_BITMAP=
   fi
   AC_MSG_RESULT([none])
else
   case "$with_startcenter_rtl_right_bitmap" in
      *.png) STARTCENTER_RTL_RIGHT_BITMAP="$with_startcenter_rtl_right_bitmap" ;;
      *)     AC_MSG_WARN([Startcenter rtl right bitmap should be a .png file!]) ;;
   esac
   AC_MSG_RESULT([$STARTCENTER_RTL_RIGHT_BITMAP])
fi
AC_SUBST(STARTCENTER_RTL_RIGHT_BITMAP)

AC_MSG_CHECKING([for yet another 'start center space' bitmap])
if test -z "$with_startcenter_space_bitmap" -o "$with_startcenter_space_bitmap" = "no"; then
   if test "$with_startcenter_space_bitmap" = "no"; then
      STARTCENTER_SPACE_BITMAP=
   fi
   AC_MSG_RESULT([none])
else
   case "$with_startcenter_space_bitmap" in
      *.png) STARTCENTER_SPACE_BITMAP="$with_startcenter_space_bitmap" ;;
      *)     AC_MSG_WARN([Startcenter left bitmap should be a .png file!]) ;;
   esac
   AC_MSG_RESULT([$STARTCENTER_SPACE_BITMAP])
fi
AC_SUBST(STARTCENTER_SPACE_BITMAP)

OOO_VENDOR=
AC_MSG_CHECKING([for vendor])
if test -z "$with_vendor" -o "$with_vendor" = "no"; then
    AC_MSG_RESULT([not set])
else
    OOO_VENDOR="$with_vendor"
    AC_MSG_RESULT([$OOO_VENDOR])
fi
AC_SUBST(OOO_VENDOR)

UNIXWRAPPERNAME=
AC_MSG_CHECKING([for UNIX wrapper name])
if test -z "$with_unix_wrapper" -o "$with_unix_wrapper" = "no"  -o "$with_unix_wrapper" = "yes"; then
    AC_MSG_RESULT([not set])
else
    UNIXWRAPPERNAME="$with_unix_wrapper"
    AC_MSG_RESULT([$UNIXWRAPPERNAME])
fi
AC_SUBST(UNIXWRAPPERNAME)

AC_MSG_CHECKING([whether to install the compat oo* wrappers])
if test "$with_compat_oowrappers" = "yes"; then
    WITH_COMPAT_OOWRAPPERS=YES
    AC_MSG_RESULT(yes)
else
    WITH_COMPAT_OOWRAPPERS=
    AC_MSG_RESULT(no)
fi
AC_SUBST(WITH_COMPAT_OOWRAPPERS)

AC_MSG_CHECKING([for product name])
PRODUCTNAME=AC_PACKAGE_NAME
AC_MSG_RESULT([$PRODUCTNAME])
AC_SUBST(PRODUCTNAME)

INSTALLDIRNAME=`echo AC_PACKAGE_NAME | tr '[[:upper:]]' '[[:lower:]]'`
AC_MSG_CHECKING([for install dirname])
if test -n "$with_install_dirname" -a "$with_install_dirname" != "no" -a "$with_install_dirname" != "yes"; then
   INSTALLDIRNAME="$with_install_dirname"
fi
AC_MSG_RESULT([$INSTALLDIRNAME])
AC_SUBST(INSTALLDIRNAME)

AC_MSG_CHECKING([for prefix])
test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix=$prefix
PREFIXDIR="$prefix"
AC_MSG_RESULT([$PREFIXDIR])
AC_SUBST(PREFIXDIR)

AC_MSG_CHECKING([for libdir])
LIBDIR=[$(eval echo $(eval echo $libdir))]
AC_MSG_RESULT([$LIBDIR])
AC_SUBST(LIBDIR)

AC_MSG_CHECKING([for data dir])
DATADIR=[$(eval echo $(eval echo $datadir))]
AC_MSG_RESULT([$DATADIR])
AC_SUBST(DATADIR)

AC_MSG_CHECKING([for man dir])
MANDIR=[$(eval echo $(eval echo $mandir))]
AC_MSG_RESULT([$MANDIR])
AC_SUBST(MANDIR)

AC_MSG_CHECKING([for doc dir])
DOCDIR=[$(eval echo $(eval echo $docdir))]
AC_MSG_RESULT([$DOCDIR])
AC_SUBST(DOCDIR)

AC_MSG_CHECKING([for install dir])
INSTALLDIR="$LIBDIR/$INSTALLDIRNAME"
AC_MSG_RESULT([$INSTALLDIR])
AC_SUBST(INSTALLDIR)

AC_MSG_CHECKING([for dev-install dir])
DEVINSTALLDIR="$OUTDIR/installation"
AC_MSG_RESULT([$DEVINSTALLDIR])
AC_SUBST(DEVINSTALLDIR)

# ===================================================================
# De- or increase default verbosity of build process
# ===================================================================
AC_MSG_CHECKING([build verbosity])
if test -n "$enable_verbose"; then
    if test "$enable_verbose" = "yes"; then
        VERBOSE="TRUE"
        AC_MSG_RESULT([high])
    fi
    if test "$enable_verbose" = "no"; then
        VERBOSE="FALSE"
        AC_MSG_RESULT([low])
    fi
else
    AC_MSG_RESULT([not set])
fi
AC_SUBST(VERBOSE)

dnl ===================================================================
dnl Use zenity during build
dnl ===================================================================
AC_MSG_CHECKING([whether to use zenity during build])
if test "$enable_zenity" = "yes"; then
    AC_MSG_RESULT([yes])
    AC_PATH_PROGS( ZNTY, zenity )
    if test -z "$ZNTY"; then
        ENABLE_ZENITY=FALSE
    else
        ENABLE_ZENITY=TRUE
    fi
else
    ENABLE_ZENITY=FALSE
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_ZENITY)


dnl ===================================================================
dnl Hook up LibreOffice's nodep environmental variable to automake's equivalent
dnl --enable-dependency-tracking configure option
dnl ===================================================================
AC_MSG_CHECKING([whether to enable dependency tracking])
if test "$enable_dependency_tracking" = "no"; then
    nodep=TRUE
    AC_MSG_RESULT([no])
else
    AC_MSG_RESULT([yes])
fi
AC_SUBST(nodep)

dnl ===================================================================
dnl Number of CPUs to use during the build
dnl ===================================================================
AC_MSG_CHECKING([for number of processors to use])
if test -n "$with_num_cpus"; then
    BUILD_NCPUS=$with_num_cpus
else
    case `uname -s` in

    Darwin|FreeBSD|NetBSD|OpenBSD)
        BUILD_NCPUS=`sysctl -n hw.ncpu`
        ;;

    Linux)
	BUILD_NCPUS=`getconf _NPROCESSORS_ONLN`
	;;
    # what else than above does profit here *and* has /proc?
    *)
        BUILD_NCPUS=`grep $'^processor\t*:' /proc/cpuinfo | wc -l`
        ;;
    esac

    # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an
    # unexpected format, 'wc -l' will have returned 0.
    if test "$BUILD_NCPUS" -eq 0; then
        BUILD_NCPUS=1
    fi
fi
AC_MSG_RESULT([$BUILD_NCPUS])
AC_SUBST(BUILD_NCPUS)

#
# Set up ILIB for MSVC build
#
if test "$build_os" = "cygwin"; then
    ILIB=".;${SOLARVER}/$INPATH/lib"
    if test -n "$JAVA_HOME" -a "$JAVA_HOME" != "NO_JAVA_HOME"; then
        ILIB="$ILIB;$JAVA_HOME/lib"
    fi
    if test "$CL_X64" = "TRUE"; then
        ILIB="$ILIB;$COMPATH/lib/amd64"
        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib64"
    else
        ILIB="$ILIB;$COMPATH/lib"
        ILIB="$ILIB;$WINDOWS_SDK_HOME/lib"
    fi
    ILIB="$ILIB;$DOTNET_FRAMEWORK_HOME/lib"

    if test "$ENABLE_DIRECTX" = "TRUE"; then
        ILIB="$ILIB;$DIRECTXSDK_LIB"
    fi
    AC_SUBST(ILIB)
fi


# ===================================================================
# Creating bigger shared library to link against
# ===================================================================
AC_MSG_CHECKING([whether to create a big library for better performance])
MERGELIBS=
if test "$enable_mergelibs" = "yes"; then
    MERGELIBS="TRUE"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(MERGELIBS)

dnl ===================================================================
dnl Number of parallel jobs to be executed by dmake
dnl ===================================================================
AC_MSG_CHECKING([for maximum of jobs per processor])
BUILD_MAX_JOBS="1"
if test "$with_max_jobs" != ""; then
    BUILD_MAX_JOBS="$with_max_jobs"
else
    if test "$enable_icecream" = "yes"; then
        BUILD_MAX_JOBS="10"
    fi
fi
AC_MSG_RESULT([$BUILD_MAX_JOBS])
AC_SUBST(BUILD_MAX_JOBS)

# =====================================================================
# determine the parallelism for gnu make
# =====================================================================
AC_MSG_CHECKING([for maximum parallelism for gmake])
if test $BUILD_MAX_JOBS -gt $BUILD_NCPUS; then
    GMAKE_PARALLELISM="$BUILD_MAX_JOBS"
else
    GMAKE_PARALLELISM="$BUILD_NCPUS"
fi
GMAKE_MODULE_PARALLELISM="$BUILD_MAX_JOBS"
if test "$no_parallelism_make" = "YES"; then
    if test -z "$with_num_cpus"; then
        GMAKE_PARALLELISM="1";
        if test $GMAKE_MODULE_PARALLELISM -gt 1; then
            AC_MSG_WARN([gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this.])
            if test -z "$with_num_cpus"; then
                echo "gmake 3.81 crashes with parallelism > 1, reducing it to 1. upgrade to 3.82 to avoid this." >> warn
            fi
            GMAKE_MODULE_PARALLELISM="1"
        fi
    else
        GMAKE_PARALLELISM="$BUILD_NCPUS";
        echo "make 3.81 is prone to crashes with parallelism > 1. Since --with-num-cpus was explicitly given, it is honored, but do not complain when make segfault on you." >> warn
    fi
fi

# GMAKE_PARALLELISM is used in tail_build
# GMAKE_MODULE_PARALLELISM is used when building individual gbuildified module
AC_MSG_RESULT([per module:$GMAKE_MODULE_PARALLELISM, for tail_build:$GMAKE_PARALLELISM])
AC_SUBST(GMAKE_PARALLELISM)
AC_SUBST(GMAKE_MODULE_PARALLELISM)

dnl ===================================================================
dnl Setting up the environment.
dnl ===================================================================
echo "setting up the build environment variables..."

if test -z "$COMPATH"; then
    AC_MSG_ERROR([No compiler found.])
fi
AC_SUBST(COMPATH)

if test "$build_os" = "cygwin"; then
    if test "$DISABLE_ACTIVEX" = "YES"; then
        ATL_LIB="$WINDOWS_SDK_HOME/lib"; # Doesn't exist for VSE
        ATL_INCLUDE="$WINDOWS_SDK_HOME/include".$ds."atl";
        MFC_LIB="$WINDOWS_SDK_HOME/lib"; # Doesn't exist for VSE
        MFC_INCLUDE="$WINDOWS_SDK_HOME/include/mfc";
    else
        ATL_LIB="$COMPATH/atlmfc/lib";
        ATL_INCLUDE="$COMPATH/atlmfc/include";
        MFC_LIB="$COMPATH/atlmfc/lib";
        MFC_INCLUDE="$WINDOWS_SDK_HOME/include/mfc";
    fi
    if test "$CL_X64" = "YES"; then
        ATL_LIB="$ATL_LIB/amd64"
        MFC_LIB="$MFC_LIB/amd64"
    fi
    PathFormat "/usr/bin/grep.exe"
    WIN_GREP="$formatted_path"
    PathFormat "/usr/bin/find.exe"
    WIN_FIND="$formatted_path"
    PathFormat "/usr/bin/ls.exe"
    WIN_LS="$formatted_path"
    PathFormat "/usr/bin/touch.exe"
    WIN_TOUCH="$formatted_path"
fi

AC_SUBST(ATL_INCLUDE)
AC_SUBST(ATL_LIB)
AC_SUBST(MFC_INCLUDE)
AC_SUBST(MFC_LIB)
AC_SUBST(WIN_FIND)
AC_SUBST(WIN_GREP)
AC_SUBST(WIN_LS)
AC_SUBST(WIN_TOUCH)

AC_SUBST(BUILD_TYPE)

AC_SUBST(SOLARINC)
AC_SUBST(SOLARLIB)

if test -z "$SOLARINC_FOR_BUILD"; then
    SOLARINC_FOR_BUILD="$SOLARINC"
fi
AC_SUBST(SOLARINC_FOR_BUILD)

if test -z "$SOLARLIB_FOR_BUILD"; then
    SOLARLIB_FOR_BUILD="$SOLARLIB"
fi
AC_SUBST(SOLARLIB_FOR_BUILD)

PathFormat "$PERL"
PERL="$formatted_path"
AC_SUBST(PERL)

if test "$build_os" = "cygwin"; then
    TEMP_DIRECTORY=`cygpath -m "/tmp"`
    if test -n "$TMP"; then
        TMP_DIRECTORY="$TMP"
    else
        TMP_DIRECTORY="$TEMP_DIRECTORY"
    fi
else
    if test -n "$TMPDIR"; then
        TEMP_DIRECTORY="$TMPDIR"
    else
        TEMP_DIRECTORY="/tmp"
    fi
fi
AC_SUBST(TEMP_DIRECTORY)
AC_SUBST(TMP_DIRECTORY)

# setup the PATH for the environment
if test -n "$LO_PATH_FOR_BUILD"; then
    LO_PATH="$LO_PATH_FOR_BUILD"
else
    LO_PATH="$PATH"

    case "$host_os" in

    aix*|dragonfly*|freebsd*|linux-gnu*|*netbsd*|openbsd*)
        if test "$SOLAR_JAVA" != "" -a "$JDK"!="gcj"; then
            pathmunge "$JAVA_HOME/bin" "after"
        fi
        ;;

    cygwin*)
        pathmunge "$DOTNET_FRAMEWORK_HOME/bin" "before"
        pathmunge "$ASM_HOME" "before"
        pathmunge "$WINDOWS_SDK_HOME/bin" "before"
        pathmunge "$CSC_PATH" "before"
        pathmunge "$MIDL_PATH" "before"
        pathmunge "$MSPDB_PATH" "before"
        if test "$CL_X64" = "TRUE"; then
            pathmunge "$COMPATH/bin/amd64" "before"
        else
            pathmunge "$COMPATH/bin" "before"
        fi
        if test "$SOLAR_JAVA" != "" -a "$JDK"!="gcj"; then
            if test -d "$JAVA_HOME/jre/bin/client"; then
                pathmunge "$JAVA_HOME/jre/bin/client" "before"
            fi
            if test -d "$JAVA_HOME/jre/bin/hotspot"; then
                pathmunge "$JAVA_HOME/jre/bin/hotspot" "before"
            fi
            pathmunge "$JAVA_HOME/bin" "before"
        fi
        ;;

    solaris*)
        pathmunge "/usr/css/bin" "before"
        if test "$SOLAR_JAVA" != "" -a "$JDK"!="gcj"; then
            pathmunge "$JAVA_HOME/bin" "after"
        fi
        ;;
    esac

    pathmunge "$SRC_ROOT/solenv/$OUTPATH/bin" "before"
    pathmunge "$SRC_ROOT/solenv/bin" "before"
    pathmunge "." "before"
fi

AC_SUBST(LO_PATH)

# make sure config.guess is +x; we execute config.guess, so it has to be so;
chmod +x ./config.guess

dnl Setting up the post_download check script
dnl Using autoconf here, so that the migration from the previous state
dnl (checks for the additional Windows downloads were directly in
dnl configure.in) is as easy as possible
echo "setting up the post_download check script"
autoconf post_download.in > post_download
chmod +x post_download

# Generate a configuration timestamp we can use for deps
if test -f config_host.mk; then
    mv -f config_host.mk config_host.mk.last
else
    echo > config_host.mk.last
fi

AC_CONFIG_FILES([config_host.mk ooo.lst bin/repo-list])
AC_OUTPUT

# touch the config timestamp file set_soenv.stamp
if test ! -f set_soenv.stamp; then
    echo > set_soenv.stamp
elif diff config_host.mk config_host.mk.last >/dev/null 2>&1; then
    echo "Configuration unchanged - avoiding scp2 stamp update"
else
    echo > set_soenv.stamp
fi


if test "$STALE_MAKE" = "TRUE" -a "$build_os" = "cygwin"; then
cat << _EOS
****************************************************************************
WARNING:
Your make version is known to be horribly slow, and hard to debug
problems with. To get a reasonably functional make please do:

to install a pre-compiled binary make for cygwin

mkdir -p /opt/lo/bin
cd /opt/lo/bin
wget http://dev-www.libreoffice.org/bin/cygwin/make
chmod +x make

to install from source:
place yourself in a working directory of you choice.

git clone git://anongit.freedesktop.org/libreoffice/contrib/dev-tools
cd dev-tools/make-3.82-gbuild
./configure --prefix=/opt/lo
make
sudo make install

Then re-run autogen.sh

Note: autogen.sh will try to use /opt/lo/bin/make if the environment variable GNUMAKE is not already defined.
Alternatively, you can install the 'new' make where ever you want and make sure that `which make` finds it.

_EOS
fi

cat << _EOF
****************************************************************************
To build, issue:
$GNUMAKE

To install when the build is finished, issue:
$GNUMAKE install

If you want to develop LibreOffice, you might prefer:
$GNUMAKE dev-install

If you want to run the smoketest, issue:
$GNUMAKE check

ATTENTION: Env.Host.sh and Env.Build.sh are no more.
The environment is now in config_host.mk and config_build.mk (for cross-compile)
You do not need to source them, even for partial build.
run: make help
for details

_EOF

dnl vim:set shiftwidth=4 softtabstop=4 expandtab: