summaryrefslogtreecommitdiff
path: root/configure.in
blob: d3e5a075743553f1103dbef0f0abbd84f64df146 (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
dnl /******************************************************************
dnl *     vi:set sw=3 ts=3 et:
dnl *
dnl * Name: configure.in
dnl * Auth: Willem van Dorp, Ross Nicholson, Oisin Boydell - Sun Microsystems Ireland
dnl * Date: $Date: 2008-09-08 07:38:40 $
dnl *
dnl * Desc: This file serves as input for the GNU autoconf package
dnl *       in order to create a configure script.
dnl *       In this stage configure just checks the pre-requisites
dnl *       necessary to build OpenOffice.org
dnl *
dnl *
dnl ******************************************************************/
AC_REVISION( $Revision: 1.290 $ )
AC_PREREQ(2.50)
AC_INIT()
echo "$@" >config.parms
AC_ARG_WITH(gnu-patch,
[  --with-gnu-patch        Specify location of GNU patch on Solaris or FreeBSD
],,)
AC_ARG_WITH(agg,
[  --without-agg           Disable the use of agg altogether
],,with_agg=yes)
AC_ARG_WITH(gnu-cp,
[  --with-gnu-cp           Specify location of GNU cp on Solaris or FreeBSD
],,)
AC_ARG_ENABLE(graphite,
[  --enable-graphite       Enables the compilation of Graphite smart font rendering
],,)
AC_ARG_WITH(system-graphite,
[  --with-system-graphite    use graphite library already installed on system
],,)
AC_ARG_ENABLE(ldap,
[  --disable-ldap          Disables the use of LDAP backend via Netscape/Mozilla
                          or OpenLDAP LDAP SDK
],,)
AC_ARG_WITH(openldap,
[  --with-openldap         Enables the use of the OpenLDAP LDAP SDK instead
                          of the Netscape/Mozilla one
],,)
AC_ARG_ENABLE(lockdown,
[  --enable-lockdown       Enables the gconf integration work in OOo
],,)
AC_ARG_ENABLE(vba,
[  --disable-vba           disables the vba compatibility feature
],,)
AC_ARG_WITH(vba-package-format,
[  --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 optionly 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_ENABLE(pch,
[  --enable-pch            EXPERIMENTAL: Enables precompiled header support for C++.
],,)
AC_ARG_ENABLE(hids,
[  --enable-hids            Enables generation of HelpId lists.
],,)
AC_ARG_ENABLE(mozilla,
[  --disable-mozilla       OO.o usually includes a strangely hacked up mozilla
                          binary for your platform, to build without this
                          version, use this option.
],,enable_mozilla="yes")
AC_ARG_WITH(fonts,
[  --without-fonts         OOo 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,
[  --without-ppds          Removes Postscript Printer definition files from
                          openoffice.org 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,
[  --without-afms          Removes bitmap font files from openoffice.org
                          installation set, for people building for specific
                          distributions where AFM files or TrueType Fonts
                          are known to be available.
],,)
AC_ARG_ENABLE(epm,
[  --disable-epm           OO.o includes self-packaging code, that requires
                          epm, however epm is useless for large scale
                          package building.
],,enable_epm="yes")
AC_ARG_WITH(epm,
[  --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,
[  --with-package-format   specify package format(s) for OOo installsets.
                          Default is "normal" one of the OS/Distribution.

                          Usage: --with-package-format="foo bar"
],,)                   
AC_ARG_ENABLE(odk,
[  --disable-odk           OO.o includes an ODK, office development kit
                          which some packagers may with to build without
],,enable_odk="yes")
AC_ARG_ENABLE(qadevooo,
[  --disable-qadevooo      OO.o includes some qa testsuites which some
                          packagers may wish to build without
],,enable_qadevooo="yes")
AC_ARG_ENABLE(mathmldtd,
[  --disable-mathmldtd     disable mathmldtd
                          (useful for distributions that want to avoid packaging
                          it)
],,enable_mathmldtd="yes")
AC_ARG_ENABLE(evolution2,
[  --enable-evolution2     Allows the built-in evolution 2 addressbook
                          connectivity build to be enabled.
],,)
AC_ARG_WITH(system-stdlibs,
[  --with-system-stdlibs   use libstdc++/libgcc_s already on system
],,checkforstdlibproblems=yes)
AC_ARG_ENABLE(cups,
[  --disable-cups          disable cups support in the psprint project
],,enable_cups=yes)
AC_ARG_ENABLE(fontconfig,
[  --disable-fontconfig    disable support for the fontconfig library
],,enable_fontconfig=yes)
AC_ARG_ENABLE(directx,
[  --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)
],,enable_directx=yes)
AC_ARG_ENABLE(activex,
[  --disable-activex       Disable the use of ActiveX for windows build.
                          This switch is mandatory when using VC++ 2005/2008 Express.
],,)

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

AC_ARG_ENABLE(symbols,
[  --enable-symbols        Include debugging symbols in output.
                          WARNING - a complete build needs 8 Gb of space and
                          takes much longer. (enables -g compiler flag)

                          --enable-symbols=SMALL sets the gcc -g1 setting
                          which is smaller.

                          Enabling symbols disables the stripping of the solver
                          (--disable-strip-solver).
],,)
AC_ARG_ENABLE(strip-solver,
[  --disable-strip-solver  Disable the stripping of the solver.
                          By default the solver is stripped unless a build with
                          debugging symbols (--enable-symbols) is requested.

                          This switch allows to override this setting.
],,)
AC_ARG_ENABLE(werror,
[  --enable-werror         Turn warnings to errors. (Has no effect in modules
                          where the treating of warnings as errors is disabled
                          explicitely)
],,)
AC_ARG_ENABLE(debug,
[  --enable-debug          Include debugging symbols from --enable-symbols
                          plus extra debugging code.  Extra large build!
                          (enables -g compiler flag and dmake debug=true)
],,)
AC_ARG_ENABLE(dbgutil,
[  --enable-dbgutil        Include additional debugging utilities, such as
                          assertions, object counting, etc. Larger build.
                          Independent from --enable-debug
],,)
AC_ARG_ENABLE(crashdump,
[  --enable-crashdump      Enable the crashdump feature code.
],,)
AC_ARG_ENABLE(cl-standard,
[  --enable-cl-standard    For Microsoft C/C++ compiler users, use non-optimizing
                          standard compiler. ( This just disavles optimization
                          options and therefore removes a lot of warnings when
                          using the cheaper standard compiler. )
],,)
AC_ARG_ENABLE(gtk,
[  --disable-gtk           Determines whether to use Gtk+ vclplug on platforms
                          where Gtk+ is available.
],,enable_gtk=yes)
AC_ARG_ENABLE(systray,
[  --disable-systray       Determines whether to build the systray quickstarter.
],,enable_systray=yes)
AC_ARG_ENABLE(cairo,
[  --enable-cairo          Determines whether to use Cairo library on
                          platforms where Cairo is available.
],,enable_cairo=no)
AC_ARG_WITH(system-cairo,
[  --with-system-cairo      Use Cairo libraries already on system
],,)
AC_ARG_ENABLE(opengl,
[  --enable-opengl         Determines whether to build the OpenGL 3D slide 
                          transitions component
],,enable_opengl=no)
AC_ARG_ENABLE(dbus,
[  --enable-dbus           Determines whether to enable presentation mode 
                          screensaver control under GNOME via DBUS 
],,enable_dbus=no)
AC_ARG_ENABLE(gconf,
[  --disable-gconf         Determines whether to use the GConf support
],,enable_gconf=yes)
AC_ARG_ENABLE(gnome-vfs,
[  --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,
[  --enable-gio            Determines whether to use the GIO support
],,enable_gio=no)
AC_ARG_ENABLE(static-gtk,
[  --enable-static-gtk     Modules that are linked against gtk libraries use
                          the static libraries instead of the dynamic ones. 
                          (enables -Bstatic linker flag for gtk libraries)
],,)
AC_ARG_ENABLE(layout,
[  --enable-layout         Enable the compilation and use of layout dialogs
],,)
AC_ARG_ENABLE(build-mozilla,
[  --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_WITH(mozilla-version,
[  --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,
[  --with-mozilla-toolkit  Choose which GUI toolkit to use while building mozilla
                          components. Default: gtk2
],,)
AC_ARG_ENABLE(nss_module,
[  --disable-nss-module    Whether to use provided NSS module     
],,enable_nss_module=yes)
AC_ARG_ENABLE(kde,
[  --enable-kde            Determines whether to use Qt/KDE vclplug on platforms
                          where Qt and KDE are available.
],,)
AC_ARG_ENABLE(kdeab,
[  --disable-kdeab         Disable the KDE address book support
],,if test "$enable_kde" = "yes"; then enable_kdeab=yes; fi)
AC_ARG_ENABLE(kde4,
[  --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(binfilter,
[  --disable-binfilter     Disable legacy binary file formats filters
],,if ! test -d ./binfilter; then enable_binfilter=no; fi)
AC_ARG_ENABLE(rpath,
[  --disable-rpath         Disable the use of relative paths in shared libraries
],,)
AC_ARG_ENABLE(pam,
[  --disable-pam           Disable pam support.
],,)
AC_ARG_ENABLE(pam-link,
[  --enable-pam-link       link with libpam instead of dynamically open it
],,)
AC_ARG_ENABLE(crypt-link,
[  --disable-crypt-link    disable linking with libcrypt instead of dynamically
                          open it (needed for ancient GNU/Linux distributions
                          without crypt()/libcrypt)
],,enable_crypt_link=yes)
AC_ARG_ENABLE(xrender-link,
[  --enable-xrender-link   link with libXrender instead of dynamically open it
],,)
AC_ARG_ENABLE(randr,
[  --disable-randr         disable RandR support in the vcl project
],,enable_randr=yes)
AC_ARG_ENABLE(randr-link,
[  --disable-randr-link    disable linking with libXrandr, instead dynamically 
                           open it at runtime
],,enable_randr_link=yes)
AC_ARG_WITH(myspell-dicts,
[  --without-myspell-dicts Removes myspell dictionaries from openoffice.org
                          installation set, for people building for specific
                          distributions where the myspell dictionaries are
                          installed from other sources
],,)
AC_ARG_WITH(system-dicts,
[  --with-system-dicts    Use dictionaries from system paths- Specify
                         them via --with-{dict,hyph,thes}-path=/path
			 if you want to override the default ones
],,)
AC_ARG_WITH(external-dict-dir,
[  --with-external-dict-dir Specify external dictionary dir
],,)
AC_ARG_WITH(external-hyph-dir,
[  --with-external-hyph-dir Specify external hyphenation pattern dir
],,)
AC_ARG_WITH(external-thes-dir,
[  --with-external-thes-dir Specify external thesaurus dir
],,)
AC_ARG_WITH(system-libs,
[  --with-system-libs      Use libs already on system -- enables all
                          --with-system-* flags except mozilla and
                          odbc/sane/xrender-header(s)
],,)
AC_ARG_WITH(system-headers,
[  --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/xrender-header(s)
],,)
AC_ARG_WITH(system-jars,
[  --without-system-jars   When building with --with-system-libs, also the
                          needed jars are expected on the system. Use this to
                          disable that. 
                          (except for the db case where --with-system-db
                          *has to* imply using the db.jar from there, too)
],,)
AC_ARG_WITH(system-zlib,
[  --with-system-zlib      Use zlib already on system
],,)
AC_ARG_WITH(system-openssl,
[  --with-system-openssl   Use OpenSSL already on system
],,)
AC_ARG_WITH(system-jpeg,
[  --with-system-jpeg      Use jpeg already on system
],,)
AC_ARG_WITH(system-expat,
[  --with-system-expat     Use expat already on system
],,)
AC_ARG_WITH(system-libwpd,
[  --with-system-libwpd    Use libwpd already on system
],,)
AC_ARG_WITH(system-libxml,
[  --with-system-libxml    Use libxml already on system
],,)
AC_ARG_WITH(system-python,
[  --with-system-python    Use python already on system
],,)
AC_ARG_WITH(system-icu,
[  --with-system-icu       Use icu already on system
],,)
AC_ARG_WITH(system-poppler,
[  --with-system-poppler   Use poppler already on system
],,)
AC_ARG_WITH(system-db,
[  --with-system-db        Use berkeley db already on system
],,)
AC_ARG_WITH(system-lucene,
[  --with-system-lucene    Use lucene already on system
],,)
AC_ARG_WITH(lucene-core-jar,
[  --with-lucene-core-jar=JARFILE   Specify path to jarfile manually ],
[ LUCENE_CORE_JAR="$withval"
])
AC_ARG_WITH(lucene-analyzers-jar,
[  --with-lucene-analyzers-jar=JARFILE   Specify path to jarfile manually ],
[ LUCENE_ANALYZERS_JAR="$withval"
])
AC_ARG_ENABLE(mysql-connector,
[  --enable-mysql-connector     enables the build of the MySQL Connector/OOo extension.
                                This requires access to the MySQL Connector/C (aka libmysql) to be given, too, with
                                either the --with-system-mysql or --with-libmysql-path option.
],,)
AC_ARG_WITH(system-mysql,
[  --with-system-mysql          Use MySQL libraries already on system, for building the MySQL Connector/OOo extension.
                                Requires MYSQLCONFIG to point to the mysql_config executable.
],,with_system_mysql="no")
AC_ARG_WITH(libmysql-path,
[  --with-libmysql-path         Use Connector/C (libmysql) installation for building the MySQL Connector/OOo extension.

                                Usage: --with-libmysql-path=<absolute path to your Connector/C installation>
],,)
AC_ARG_WITH(system-mysql-cppconn,
[  --with-system-mysql-cppconn  Use MySQL C++ Connector libraries already on system
],,)
AC_ARG_WITH(system-hsqldb,
[  --with-system-hsqldb    Use hsqldb already on system
],,)
AC_ARG_WITH(hsqldb-jar,
[  --with-hsqldb-jar=JARFILE   Specify path to jarfile manually ],
[ HSQLDB_JAR="$withval"
])
AC_ARG_WITH(system-beanshell,
[  --with-system-beanshell Use beanshell already on system
],,)
AC_ARG_WITH(beanshell-jar,
[  --with-beanshell-jar=JARFILE   Specify path to jarfile manually ],
[ BSH_JAR="$withval"
])
AC_ARG_ENABLE(presenter-extra-ui,
[  --enable-presenter-extra-ui   enables extra functionality during slideshow,
                                 e.g. selecting pen color, erasing drawings etc.
],,enable_presenter_extra_ui=no)
AC_ARG_ENABLE(minimizer,
[  --enable-minimizer          enables the build of the Presentation Minimizer extension
],,)
AC_ARG_ENABLE(presenter-console,
[  --enable-presenter-console          enables the build of the Presenter Console extension
],,)
AC_ARG_ENABLE(pdfimport,
[  --enable-pdfimport          enables the build of the PDF Import extension and xpdf
],,)
AC_ARG_ENABLE(wiki-publisher,
[  --enable-wiki-publisher      enables the build of the Wiki Publisher extension
],,)
AC_ARG_WITH(commons-codec-jar,
[  --with-commons-codec-jar=JARFILE   Specify path to jarfile manually ],
[ COMMONS_CODEC_JAR="$withval"
])
AC_ARG_WITH(commons-lang-jar,
[  --with-commons-lang-jar=JARFILE   Specify path to jarfile manually ],
[ COMMONS_LANG_JAR="$withval"
])
AC_ARG_WITH(commons-httpclient-jar,
[  --with-commons-httpclient-jar=JARFILE   Specify path to jarfile manually ],
[ COMMONS_HTTPCLIENT_JAR="$withval"
])
AC_ARG_WITH(commons-logging-jar,
[  --with-commons-logging-jar=JARFILE   Specify path to jarfile manually ],
[ COMMONS_LOGGING_JAR="$withval"
])
AC_ARG_WITH(servlet-api-jar,
[  --servlet-api-jar=JARFILE   Specify path to jarfile manually ],
[ SERVLETAPI_JAR="$withval"
])
AC_ARG_ENABLE(report-builder,
[  --enable-report-builder  enables the build of the Report Builder extension
],,)
AC_ARG_WITH(system-jfreereport,
[  --with-system-jfreereport      Use JFreeReport already on system
],,)
AC_ARG_WITH(sac-jar,
[  --with-sac-jar=JARFILE   Specify path to jarfile manually ],
[ SAC_JAR="$withval"
])
AC_ARG_WITH(libxml-jar,
[  --with-libxml-jar=JARFILE   Specify path to jarfile manually ],
[ LIBXML_JAR="$withval"
])
AC_ARG_WITH(flute-jar,
[  --with-flute-jar=JARFILE   Specify path to jarfile manually ],
[ FLUTE_JAR="$withval"
])
AC_ARG_WITH(jfreereport-jar,
[  --with-jfreereport-jar=JARFILE   Specify path to jarfile manually ],
[ JFREEREPORT_JAR="$withval"
])
AC_ARG_WITH(liblayout-jar,
[  --with-liblayout-jar=JARFILE   Specify path to jarfile manually ],
[ LIBLAYOUT_JAR="$withval"
])
AC_ARG_WITH(libloader-jar,
[  --with-libloader-jar=JARFILE   Specify path to jarfile manually ],
[ LIBLOADER_JAR="$withval"
])
AC_ARG_WITH(libloader-jar,
[  --with-libloader-jar=JARFILE   Specify path to jarfile manually ],
[ LIBLOADER_JAR="$withval"
])
AC_ARG_WITH(libformula-jar,
[  --with-libformula-jar=JARFILE   Specify path to jarfile manually ],
[ LIBFORMULA_JAR="$withval"
])
AC_ARG_WITH(librepository-jar,
[  --with-librepository-jar=JARFILE   Specify path to jarfile manually ],
[ LIBREPOSITORY_JAR="$withval"
])
AC_ARG_WITH(libfonts-jar,
[  --with-libfonts-jar=JARFILE   Specify path to jarfile manually ],
[ LIBFONTS_JAR="$withval"
])
AC_ARG_WITH(libserializer-jar,
[  --with-libserializer-jar=JARFILE   Specify path to jarfile manually ],
[ LIBSERIALIZER_JAR="$withval"
])
AC_ARG_WITH(libbase-jar,
[  --with-libbase-jar=JARFILE   Specify path to jarfile manually ],
[ LIBBASE_JAR="$withval"
])
AC_ARG_WITH(system-saxon,
[  --with-system-saxon     Use saxon already on system
],,)
AC_ARG_WITH(saxon-jar,
[  --with-saxon-jar=JARFILE   Specify path to jarfile manually ],
[ SAXON_JAR="$withval"
])
AC_ARG_WITH(system-libxslt,
[  --with-system-libxslt   Use libxslt already on system
],,)
AC_ARG_WITH(system-odbc,
[  --with-system-odbc-headers     Use the odbc headers already on system
],,)
AC_ARG_WITH(system-sane,
[  --with-system-sane-header      Use sane.h already on system
],,)
AC_ARG_WITH(system-xrender,
[  --with-system-xrender-headers  Use XRender headers already on system
],,)
AC_ARG_WITH(system-curl,
[  --with-system-curl      Use curl already on system
],,)
AC_ARG_WITH(system-boost,
[  --with-system-boost     Use boost already on system
],,)
AC_ARG_WITH(system-vigra,
[  --with-system-vigra     Use vigra already on system
],,)
AC_ARG_ENABLE(neon,
[  --disable-neon          Disable neon and the compilation of webdav binding
],,)
AC_ARG_ENABLE(Xaw,
[  --disable-Xaw           Disables the use of Xaw for the Netscape/Mozilla
                           plugin
],,)
AC_ARG_WITH(system-neon,
[  --with-system-neon      Use neon already on system
],,)
AC_ARG_WITH(system-agg,
[  --with-system-agg       Use AGG already on system
],,)
AC_ARG_WITH(system-hunspell,
[  --with-system-hunspell   Use libhunspell already on system
],,)
AC_ARG_WITH(system-mythes,
[  --with-system-mythes    Use mythes already on system
],,)
AC_ARG_WITH(system-altlinuxhyph,
[  --with-system-altlinuxhyph    Use ALTLinuxhyph already on system
],,)
AC_ARG_WITH(system-lpsolve,
[  --with-system-lpsolve         Use lpsolve already on system
],,)
AC_ARG_WITH(system-mozilla,
[  --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
], WITH_SYSTEM_MOZILLA=$withval, WITH_SYSTEM_MOZILLA=no)
AC_ARG_WITH(stlport,
[  --with-stlport         The location that STLport is installed in. The STL
                          header files are assumed to be in
                          stlport-home/stlport and the STLPort library in
                          stlport-home/lib.

                          Usage: --with-stlport=<absolute path to stlport home>

                          Warning!!, disabling using --without-stlport or 
                          enabling using --with-stlport on a platform that
                          defaults to the opposite will break ABI compatability
], WITH_STLPORT=$withval , WITH_STLPORT=auto)
AC_ARG_WITH(jdk-home,
[  --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 binary
                          but the location of the entire distribution.
 
                          Usage: --with-jdk-home=<absolute path to JDK home>
],,)
AC_ARG_WITH(gxx_include_path,
[  --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(java,
[  --with-java             Build with[[out]] Java support.  If you use
                          --without-java/--with-java=no then the build will have
                          no support for Java components, applets, accessibility
                          or XML filters. 
], if test "$withval" = "yes"; then WITH_JAVA=java; else WITH_JAVA=$withval; fi, WITH_JAVA=java)
AC_ARG_ENABLE(gcjaot,
[  --enable-gcjaot         Build with[[out]] using Ahead of Time java compilation
                          support to speed up buildsi by compiling the jars also
                          to native code..
                          --enable-gcjaot is only known to work with bytecode
                          created with gcj or ecj
],,)
AC_ARG_WITH(ant-home,
[  --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(perl-home,
[  --with-perl-home        If you have installed the 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=<absolute path to Perl 5 home>
],,)
AC_ARG_WITH(cl-home,
[  --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,
[  --with-mspdb-path       For Microsoft C/C++ compiler users, please supply the
                          path pointing to the mspdb71.dll (.NET 2003).
 
                          Usage: --with-mspdb-path=<absolute path to mspdb71.dll>
],,)
AC_ARG_WITH(midl-path,
[  --with-midl-path        For Microsoft C/C++ .NET compiler users, please supply
                          the path pointing to the midl.exe.
 
                          Usage: --with-midl-path=<absolute path to midl.exe>
],,)
AC_ARG_WITH(csc-path,
[  --with-csc-path         For Microsoft C/C++ .NET compiler users, please supply
                          the path pointing to the csc.exe.
 
                          Usage: --with-csc-path=<absolute path to csc.exe>
],,)
AC_ARG_WITH(nsis-path,
[  --with-nsis-path        For Windows users, please supply the path to the
                          "Nullsoft Scriptable Install System" (NSIS). If NSIS
                          is found in the path or this option is supplied a self
                          contained executable installer for OpenOffice.org will
                          be created.

                          Usage: --with-nsis-path=<absolute path to nsis.exe>
],,)
AC_ARG_WITH(frame-home,
[  --with-frame-home       For Microsoft C/C++ .NET compiler users, please supply
                          the path pointing to lib/mscoree.lib, usually
                          something like:
                          "/cygdrive/c/Program Files/Microsoft Visual Studio .NET/FrameworkSDK"

                          MS Visual Toolkit compiler users, please supply the
                          path pointing to lib/msvcrt.lib, usually something
                          like:
                          "/cygdrive/c/Program Files/Microsoft Visual Studio .NET 2003/Vc7"

                          Usage: --with-frame-home=<absolute path to Framework SDK [[home]]>
],,)
AC_ARG_WITH(psdk-home,
[  --with-psdk-home        For Windows users, please supply the path to the
                          Microsoft Platform SDK.
 
                          Usage: --with-psdk-home=<absolute path to Microsoft Platform SDK>
],,)
AC_ARG_WITH(directx-home,
[  --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,
[  --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(local-solenv,
[  --with-local-solenv     If you have solenv in a location other than ./solenv,
                          please supply the path here.
 
                          Usage: --with-local-solenv=<absolute path to solenv>
],,)
AC_ARG_WITH(local-solver,
[  --with-local-solver     if you have solver in a location other than ./solver,
                          please supply the path here.
 
                          Usage: --with-local-solver=<absolute path to solver>
],,)
AC_ARG_ENABLE(check-only,
[  --enable-check-only     Use this option option if you just want to check your
                          environment.  This option stops the generation of an 
                          ????env.set
 
                          Usage: --enable-check-only=yes
],,)
AC_ARG_ENABLE(ccache-skip,
[[  --enable-ccache-skip    [default=auto] allow the use of --ccache-skip to 
                          escape compiler flags that would otherwise prevent 
                          caching of the result (currently used on Mac only)
                          NOTE: requires patched version because of a bug in
                          ccache (see issue 104567 for details and patch) 
                          explicitly enable if your version of ccache doesn't 
                          identify as version 2.4_OOo
]],,enable_ccache_skip=auto)
AC_ARG_WITH(lang,
[  --with-lang             Use this option to build OpenOffice.org 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"
],,)
AC_ARG_WITH(poor-help-localizations,
[  --with-poor-help-localizations
                           Use this option to specify which languages have
                          unusable help localizations. Separate multiple
                          languages with space.

                          Usage: --with-poor-help-localizations="af ar be-BY ca"
],,)
AC_ARG_WITH(dict,
[  --with-dict             Use this option to build OpenOffice.org with
                          dictionary support. ALL dictionaries are always
                          included by default unless overridden with
                          this option. Separate multiple dictionaries with
                          commas. For all dictionaries, use --with-dict=ALL.

                          Usage: --with-dict=ENGB,ENUS,ITIT
],,)
AC_ARG_WITH(intro-bitmaps,
[  --with-intro-bitmaps    Prefer the specified intro bitmaps over the
                          the default one.  Can be more than one (separated by
                          commas), the order means priority of fallback if the
                          first does not exist (in the installed tree).

                          Usage: --with-intro-bitmaps=/path/my_ooo_intro.bmp
],,)
AC_ARG_WITH(about-bitmaps,
[  --with-about-bitmaps    Similarly to --with-intro-bitmaps, this allows
                          specification of bitmaps for the About box.

                          Usage: --with-about-bitmaps=/path/my_ooo_about.bmp
],,)
AC_ARG_WITH(vendor,
[  --with-vendor           Set vendor of the build.

                          Usage: --with-vendor="John the Builder"
],,)
AC_ARG_WITH(unix-wrapper,
[  --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(asm-home,
[  --with-asm-home         For Windows users, please supply the path for the
                          ml.exe assembler.

                          Usage: --with-asm-home=<path to ml.exe directory>
],,)
AC_ARG_WITH(os-version,
[  --with-os-version       For FreeBSD users, use this option option to override
                          the detected OSVERSION.

                          Usage: --with-os-version=<OSVERSION>
],,)
AC_ARG_WITH(unzip-home,
[  --with-unzip-home       Deprecated: use --with-zip-home instead],,)
AC_ARG_WITH(zip-home,
[  --with-zip-home         If you use a non standard zip, for example windows
                          please supply the path for zip

                          Usage: --with-zip-home=<path to zip executable>
],,)
AC_ARG_WITH(mingwin,
[  --with-mingwin          For Windows users, use the mingwin32 compiler within
                          cygwin environment, this implies --with-use-shell=tcsh

                          Usage: --with-mingwin=yes

                          For !Windows use, use the mingw32 C++ compiler to
                          (re-) build unowinreg.dll. Specify the MinGW C++
                          Compilers name.

                          Usage: --with-mingwin=i586-mingw32msvc-g++
],WITH_MINGWIN=$withval,WITH_MINGWIN=0)
AC_ARG_WITH(use-shell,
[  --with-use-shell        Use this option to override the default shell to be
                          used for the build environment.
                          Supported options:
                            tcsh (default)
                            bash

                          Usage: --with-use-shell=tcsh|bash
],with_use_shell=$withval,with_use_shell="tcsh")
AC_ARG_WITH(build-version,
[  --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,
[  --with-alloc            Define which allocator to build with
			                 (choices are oo, system, tcmalloc)
],,)
AC_ARG_ENABLE(verbose,
[  --enable-verbose        Increase build verbosity.
  --disable-verbose       Decrease build verbosity.
],,)

BUILD_TYPE="OOo"

dnl ===================================================================
dnl Message.
dnl ===================================================================
echo "********************************************************************"
echo "*                                                                  *"
echo "*   OpenOffice.org build configuration.                            *"
echo "*                                                                  *"
echo "*   The configure process checks your platform to see whether      *"
echo "*   you can build OpenOffice.org on it.                            *"
echo "*   This process checks all pre-requisites and generates a file    *"
echo "*   containing the necessary environment variables.                *"
echo "*   Source this file after configure has ended successfully.       *"
echo "*                                                                  *"
echo "*   Any warning that is generated during the configure process     *"
echo "*   must be taken into account since it can be a reason for        *"
echo "*   an unsuccessful build of OpenOffice.org                        *"
echo "*                                                                  *"
echo "********************************************************************"
echo ""
echo "********************************************************************"
echo "*                                                                  *"
echo "*   Checking the platform pre-requisites.                          *"
echo "*                                                                  *"
echo "********************************************************************"
echo ""
dnl ===================================================================
dnl Configure pre-requisites.
dnl ===================================================================
cat /dev/null > warn
AC_PROG_EGREP
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_PROGS(SED, sed )
if test -z "$SED"; then
   AC_MSG_ERROR([install sed to run this script])
fi

AC_MSG_CHECKING([for solenv environment])
if test -z "$with_local_solenv"; then
   LOCAL_SOLENV="DEFAULT"
   AC_MSG_RESULT([default])
else
   LOCAL_SOLENV=$with_local_solenv
   AC_MSG_RESULT([$with_local_solenv])
fi
AC_SUBST(LOCAL_SOLENV)

if test "$LOCAL_SOLENV" = "DEFAULT"; then 
  _solenv="./solenv"
else
  _solenv="$LOCAL_SOLENV"
fi
AC_SUBST(_solenv)

if test -e $_solenv/inc/minor.mk; then
   # Get UPD number from ./solenv/inc/minor.mk
   UPD="`grep RSCVERSION= $_solenv/inc/minor.mk | $AWK -F"=" '{ print $2 }'`"
   AC_SUBST(UPD)
   SOURCEVERSION="`grep SOURCEVERSION= $_solenv/inc/minor.mk | $AWK -F"=" '{ print $2 }'`"
   AC_SUBST(SOURCEVERSION)
else
   AC_MSG_ERROR([$_solenv/inc/minor.mk missing but needed for architecture/os detecion and proper environment script generation...])
fi

dnl ===================================================================
dnl Checks for the operating system and processor.
dnl ===================================================================
AC_CANONICAL_SYSTEM
if test "$build" != "$host" -o "$build" != "$target" \
  -o "$host" != "$target"; then
	AC_MSG_WARN([cross-compiling by any means is not supported (yet)!])
	echo "cross-compiling by any means is not supported (yet)!" >> warn
fi

if echo "$build_os" | grep cygwin; then
   AC_MSG_CHECKING([Cygwin version])
   CygwinVer=`uname -r`
   AC_MSG_RESULT([$CygwinVer])
   if test "`echo $CygwinVer | $AWK -F . '{ print $1$2 }'`" -lt "15"; then
      AC_MSG_ERROR([You need at least Cygwin V1.5.x])
   fi
else
   CygwinVer="false"
fi

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 ===================================================================
case "$build_os" in
	solaris*)
		test_gtk=yes
		test_cairo=yes
		test_kde=yes
		test_cups=yes
        test_randr=yes
		test_freetype=yes
		_os=SunOS
		AC_PATH_PROG( GNUTAR, gtar,,$PATH:/usr/sfw/bin)
		if test -z "$GNUTAR"; then
			AC_MSG_ERROR([gtar (gnu tar) not found but needed. Install it (SUN Freeware package).])
		fi
		AC_SUBST(GNUTAR)

		dnl ===========================================================
		dnl check whether we're using solaris 6,7,8 - sparc or intel.
		dnl ===========================================================
   		AC_MSG_CHECKING([the Solaris operating system release])
   		_os_release=`echo $build_os | $SED -e s/solaris2\.//`
		if test "$_os_release" -lt "6"; then
      			AC_MSG_ERROR([use solaris >= 6 to build OpenOffice.org])
   		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 "$build_cpu" = "sparc" -o "$build_cpu" = "i386"; then
      			AC_MSG_RESULT([ok ($build_cpu)])
   		else
      			AC_MSG_ERROR([only sparc and i386 processors are supported])
   		fi
		;;
	linux-gnu*)
		test_gtk=yes
		test_cairo=yes
		test_kde=yes
		test_kde4=yes
		test_cups=yes
        test_randr=yes
		test_freetype=yes
		_os=Linux
		;;
	gnu)
		test_cups=no
		_os=GNU
		;;
	cygwin*) # Windows
		test_cups=no
		test_cairo=yes
		test_freetype=no
		_os=WINNT
		;;
	darwin*) # Mac OS X
		test_cups=yes
		test_gtk=yes
		test_cairo=yes
        test_randr=no
		test_freetype=no
		_os=Darwin
      if test "$enable_systray" = "yes" && test "$enable_gtk" != "no"; then
         AC_MSG_WARN([Disabling gtk-quickstarter - not supported on Mac. Use --disable-systray])
         echo "Disabling gtk-quickstarter - not supported on Mac. Use --disable-systray" >>warn
         enable_systray=no
      fi
		;;
	os2*)
		test_x=no
		test_cups=no
        test_randr=no
		test_gtk=no
		test_freetype=no
		_os=OS2
		;;
	freebsd*)
		test_gtk=yes
		test_cairo=yes
		test_kde=yes
		test_kde4=yes
		test_cups=yes
        test_randr=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
		;;
	osf)
		test_cups=no
        test_randr=no
		_os=OSF1
		;;
	netbsd)
		test_gtk=yes
		test_cairo=yes
		test_kde=yes
		test_kde4=yes
		test_cups=no
        test_randr=yes
		test_freetype=yes
		PTHREAD_CFLAGS="-pthread"
		PTHREAD_LIBS="-pthread -lpthread"
		_os=NetBSD
		;;
	aix*)
		test_cups=no
        test_randr=no
		test_freetype=yes
	   PTHREAD_LIBS=-pthread
		echo "AIX is an alpha port --- Use at own risk" >> warn
		_os=AIX
		;;
   *)
   AC_MSG_ERROR([$_os operating system is not suitable to build OpenOffice.org!])
   ;;
esac

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

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)

if test "$_os" = "WINNT"; then
   BUILD_TYPE="$BUILD_TYPE TWAIN"
fi

if test "$_os" = "WINNT"; then
   dnl ===================================================================
   dnl Set the VC_STANDARD variable.
   dnl ===================================================================
   AC_MSG_CHECKING([whether to use the standard non-optimizing compiler])
   if test "$enable_cl_standard" = "" -o "$enable_cl_standard" = "no"; then
      VC_STANDARD=""
      AC_MSG_RESULT([no])
   else
      VC_STANDARD="TRUE"
      AC_MSG_RESULT([yes])
   fi
   AC_SUBST(VC_STANDARD)
fi

dnl ===================================================================
dnl Set the ENABLE_WERROR variable. (Activate --enable-werror)
dnl ===================================================================
AC_MSG_CHECKING([whether to turn warnings to errors])
if test -n "$enable_werror" && test "$enable_werror" != "no"; then
   ENABLE_WERROR="TRUE"
   AC_MSG_RESULT([yes])
   AC_MSG_WARN([Turning warnings to errors has no effect in modules or])
   AC_MSG_WARN([on platforms where it has been disabled explicitely])
   echo "Turning warnings to errors has no effect in modules or on platforms where it has been disabled explicitely" >> warn
else
   ENABLE_WERROR="FALSE"
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_WERROR)

dnl ===================================================================
dnl Set the ENABLE_DEBUG variable. (Activate --enable-symbols)
dnl ===================================================================
AC_MSG_CHECKING([whether to do a debug build])
if test -n "$enable_debug" && test "$enable_debug" != "no"; then
   ENABLE_DEBUG="TRUE"
   if test -z "$enable_symbols"; then
      enable_symbols="yes"
   fi
   AC_MSG_RESULT([yes])
else
   ENABLE_DEBUG="FALSE"
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_DEBUG)

dnl ===================================================================
dnl Set the ENABLE_DBGUTIL variable
dnl ===================================================================
AC_MSG_CHECKING([whether to build with additional debug utilities])
if test -n "$enable_dbgutil" && test "$enable_dbgutil" != "no"; then
   PROEXT=""
   PRODUCT=""
   PROFULLSWITCH=""
   AC_MSG_RESULT([yes])
else
   PRODUCT="full"
   PROFULLSWITCH="product=full"
   PROEXT=".pro"
   AC_MSG_RESULT([no, full product build])
fi
AC_SUBST(PRODUCT)
AC_SUBST(PROFULLSWITCH)
AC_SUBST(PROEXT)

dnl ===================================================================
dnl First setting is whether to include symbols into final build.
dnl ===================================================================
AC_MSG_CHECKING([whether to include symbols into final build])
if test -n "$enable_symbols" && test "$enable_symbols" != "no"; then
	if test "$enable_symbols" = "yes" -o "$enable_symbols" = "TRUE"; then
		ENABLE_SYMBOLS="TRUE"
		AC_MSG_RESULT([yes])
	else
		if test "$enable_symbols" = "SMALL" -o "$enable_symbols" = "small"; then
			ENABLE_SYMBOLS="SMALL"
			AC_MSG_RESULT([yes, small ones])
		else if test "$enable_symbols" != "no" ; then
			     echo enable symbols is: $enable_symbols
			     AC_MSG_ERROR([--enable-symbols only accepts yes, TRUE or SMALL as parameter.])
           	     else
              		     ENABLE_SYMBOLS=
		     fi
		fi
	fi
else
   ENABLE_SYMBOLS=
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_SYMBOLS)

dnl ===================================================================
dnl Determine if the solver is to be stripped or not.
dnl ===================================================================
AC_MSG_CHECKING([whether to strip the solver or not.])
if test -n "$enable_strip_solver"; then
   if test "$enable_strip_solver" = "yes"; then
      DISABLE_STRIP=
   else if test "$enable_strip_solver" = "no"; then
           DISABLE_STRIP="TRUE"
        else
           AC_MSG_ERROR([--disable-strip-solver only accepts yes or no as parameter.])
        fi
   fi
else
   if test -n "$ENABLE_SYMBOLS"; then
      DISABLE_STRIP="TRUE"
   else
      DISABLE_STRIP=
   fi
fi
AC_SUBST(DISABLE_STRIP)

dnl ===================================================================
dnl Build options
dnl ===================================================================
AC_MSG_CHECKING([whether to enable native CUPS support])
if test "$test_cups" = "yes" -a \( "$enable_cups" = "yes" -o "$enable_cups" = "TRUE" \) ; then
   ENABLE_CUPS="TRUE"
   AC_MSG_RESULT([yes])
else
   ENABLE_CUPS=""
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_CUPS)

AC_MSG_CHECKING([whether to enable fontconfig support])
if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a \( "$enable_fontconfig" = "yes" -o "$enable_fontconfig" = "TRUE" \); then
   ENABLE_FONTCONFIG="TRUE"
   AC_MSG_RESULT([yes])
else
   ENABLE_FONTCONFIG=""
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_FONTCONFIG)


dnl ===================================================================
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"
   AC_MSG_RESULT([yes])
fi
AC_SUBST(WITH_BINFILTER)

if test "$_os" = "WINNT"; then
   AC_MSG_CHECKING([whether to use DirectX])
   if test "$enable_directx" = "yes" -o "$enable_directx" = "TRUE" -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" -o "$enable_atl" = ""; then
      DISABLE_ATL=""
      AC_MSG_RESULT([yes])
   else
      DISABLE_ATL="TRUE"
      AC_MSG_RESULT([no])
   fi
   AC_SUBST(DISABLE_ATL)

fi

dnl ===================================================================
dnl Disable rpath in shared libraries?
dnl ===================================================================
AC_MSG_CHECKING([whether to use RPATH in shared libraries])
if test "$enable_rpath" = "no"; then
   ENABLE_RPATH="no"
else
   ENABLE_RPATH="yes"
fi
AC_MSG_RESULT([$ENABLE_RPATH])
AC_SUBST(ENABLE_RPATH)

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

if test "$WITH_MYSPELL_DICTS" = "NO"; then
  AC_MSG_CHECKING([whether to use dicts from external paths])
  if test -n "$with_system_dicts" -a "$with_system_dicts" = "yes"; 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
	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
fi
AC_SUBST(SYSTEM_DICTS)
AC_SUBST(DICT_SYSTEM_DIR)
AC_SUBST(HYPH_SYSTEM_DIR)
AC_SUBST(THES_SYSTEM_DIR)

dnl ===================================================================
dnl all O/S use tcsh or bash.
dnl The following sets the with_use_shell variable.
dnl ===================================================================
AC_MSG_CHECKING([which shell to use])
if test $_os = "WINNT"; then
   dnl ===================================================================
   if test "$with_use_shell" != "tcsh" -a "$with_use_shell" != "bash"; then
      AC_MSG_ERROR([only "tcsh" or "bash" are supported options])
   fi
   dnl ===================================================================
   dnl Sanity check! Native windows programs cannot use cygwin symlinks!
   dnl ===================================================================
   dnl As long as awk instead of $AWK is used somewhere in the sources,
   dnl check for $AWK and awk. $AWK is pointing to gawk in cygwin.
      if test -L $AWK -o -L `which awk` -o -L `which tar` -o -L `which gunzip` ; then
         AC_MSG_ERROR([$AWK, awk, tar or gunzip is a cygwin symlink!
Native windows programs cannot use cygwin symlinks. Remove the symbolic
link, and copy the program to the name of the link.])
      fi
   dnl ===================================================================
   dnl Another sanity check! More a band-aid. winenv.* adds guw.exe to
   dnl CC and CXX but the configure checks here assume that guw.exe
   dnl (if needed at all) is not yet present.
   dnl ===================================================================
   CC=`echo $CC | $SED "s/^guw.exe //"`
   CXX=`echo $CXX | $SED "s/^guw.exe //"`
   dnl ===================================================================
   dnl If $CC is set to a MinGW compiler, e.g. "gcc -mno-cygwin" enable
   dnl $WITH_MINGWIN
   dnl ===================================================================
      if test -n "$CC";then
         if test "`$CC -dumpmachine 2>/dev/null | $SED -e 's/^.*-//'`" = "mingw32"; then
            WITH_MINGWIN="yes"
         fi
      fi
   dnl ===================================================================
   dnl If using Mingwin32 then don't use 4NT
   dnl ===================================================================
   if test "$WITH_MINGWIN" = "yes" ; then
      if test "x$with_use_shell" = "x"; then
         with_use_shell="tcsh"
      fi
      if test -z "$CC"; then
         CC="gcc -mno-cygwin"
         CXX="g++ -mno-cygwin"
      fi
   fi
elif test $_os = "OS2"; then
   if test "$with_use_shell" != "tcsh"; then
      AC_MSG_ERROR([only "tcsh" is supported options])
   fi
else 
   dnl ===================================================================
   dnl All other operating systems use tcsh or bash.
   dnl ===================================================================
   if test "$with_use_shell" != "tcsh" -a "$with_use_shell" != "bash"; then
      AC_MSG_ERROR([only "tcsh" or "bash" are supported options])
   fi
fi
USE_SHELL="$with_use_shell"
AC_MSG_RESULT([$USE_SHELL])
AC_SUBST(USE_SHELL)
AC_SUBST(WITH_MINGWIN)

dnl ===================================================================
dnl Extra check for Windows. cygwin builds need gcc to build dmake
dnl and g++ to build guw.exe although MS cl (or MinGW) is used to
dnl build OOo.
dnl ===================================================================
if test "$_os" = "WINNT" ; 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


dnl ===================================================================
dnl Check whether the chosen shell can be used.
dnl ===================================================================
if test "$with_use_shell" = "tcsh"; then
   AC_PATH_PROG(SHELLPATH, tcsh)
   if test -z "$SHELLPATH"; then
      AC_MSG_ERROR([tcsh not found in \$PATH])
   else
      SHELLPATH=`echo $SHELLPATH | $SED -n "s/\/tcsh$//p"`
   fi
elif test "$with_use_shell" = "bash"; then
   AC_PATH_PROG(SHELLPATH, bash)
   if test -z "$SHELLPATH"; then
      AC_MSG_ERROR([bash not found in \$PATH])
   else
      SHELLPATH=`echo $SHELLPATH | $SED -n "s/\/bash$//p"`
   fi
else
   AC_MSG_WARN([Windows/OS/2 4NT builds don't test for the shell])
   SHELLPATH="NO_SHELLPATH_NEEDED"
fi
AC_SUBST(SHELLPATH)

dnl ===================================================================
dnl  Checks for c compiler,
dnl  The check for the c++ compiler is later on.
dnl ===================================================================
AC_MSG_CHECKING([gcc home])
if test -z "$with_gcc_home"; then
	GCC_HOME=`which gcc | $SED -e s,/bin/gcc,,`
else	
	GCC_HOME="$with_gcc_home"
fi
AC_MSG_RESULT($GCC_HOME)
AC_SUBST(GCC_HOME)

if test -n "$with_gcc_home"; then
   if test -z "$CC"; then
      CC="$with_gcc_home/bin/gcc"
   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_MINGWIN" = "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]]\\\$@@"`;
echo $COMPATH
dnl ===================================================================
dnl  Test the gcc version,  3 is OK
dnl ===================================================================
GCCVER=20995
if test \( "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes" \) -a "$GCC" = "yes"; then
    AC_MSG_CHECKING([the GNU gcc compiler version])
   _gcc_version=`$CC -dumpversion`
   _gcc_major=`echo $_gcc_version | $AWK -F. '{ print \$1 }'`
   _gcc_longver=`echo $_gcc_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`
   GCCVER=`echo $_gcc_version | $AWK -F. '{ print \$1*10000+\$2*100+\$3 }'`

   if test "$_gcc_major" -lt "3"; then
      AC_MSG_ERROR([found version "$_gcc_version", use version 3+ of the gcc compiler])
   else
      if test "$GCCVER" -eq "030203"; then
	    if test "$ENABLE_SYMBOLS" = "SMALL"; then
           AC_MSG_ERROR([version "$_gcc_version" gives internal error with small.])
	    fi
      fi
   fi
   AC_MSG_RESULT([checked (gcc $_gcc_version)])
   if test "$_os" = "SunOS"; then
      AC_MSG_CHECKING([gcc linker])
      if $CC -Wl,--version 2>&1 |head -n 1| grep -v GNU > /dev/null;then
          AC_MSG_ERROR([failed (not GNU ld). Use GNU ld instead of Sun ld on Solaris])
      fi
      AC_MSG_RESULT([ok (GNU ld)])
   fi
fi 
AC_SUBST(GCCVER)

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 "z$HAVE_LD_BSYMBOLIC_FUNCTIONS" = "zTRUE"; 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 ===================================================================
dnl Set the ENABLE_PCH variable. (Activate --enable-pch)
dnl ===================================================================
AC_MSG_CHECKING([whether to enable pch feature])
if test -n "$enable_pch" && test "$enable_pch" != "no"; then
   if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
	   ENABLE_PCH="TRUE"
	   AC_MSG_RESULT([yes])
dnl There is no PCH support in GCC versions prior to this
   elif test "$GCC" = "yes" -a "$GCCVER" -gt "030400"; then
	   ENABLE_PCH="TRUE"
	   AC_MSG_RESULT([yes])
   else
	   ENABLE_PCH=""
	   AC_MSG_WARN([Precompiled header not yet supported for your platform/compiler])
   fi
else
   ENABLE_PCH=""
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_PCH)

dnl ===================================================================
dnl Set the NO_HIDS variable. (enable with --enable-hids)
dnl ===================================================================
AC_MSG_CHECKING([whether to enable hid list feature])
if test -n "$enable_hids" && test "$enable_hids" != "no"; then
   NO_HIDS=""
   AC_MSG_RESULT([yes])
else
   NO_HIDS="TRUE"
   AC_MSG_RESULT([no])
fi
AC_SUBST(NO_HIDS)

dnl ===================================================================
dnl Search all the common names for GNU make
dnl ===================================================================
AC_MSG_CHECKING([for GNU make])
for a in "$MAKE" $GNUMAKE make gmake gnumake; do
      $a --version 2> /dev/null | grep GNU  2>&1 > /dev/null
      if test $? -eq 0;  then
           GNUMAKE=$a
           break
      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 | $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 "037901" ; then
   AC_MSG_RESULT([$GNUMAKE $_make_version])
else
   if test "$_os" = "Darwin"; then
       if test "$_make_longver" -ge "037900" ; then
		   AC_MSG_RESULT([$GNUMAKE $_make_version])
       else
           AC_MSG_WARN([failed ($GNUMAKE $_make_version need 3.79.0+)])
       fi
   else
       AC_MSG_ERROR([failed ($GNUMAKE $_make_version need 3.79.1+)])
   fi
fi
AC_SUBST(GNUMAKE)

dnl ===================================================================
dnl Search all the common names for GNU tar
dnl ===================================================================
AC_MSG_CHECKING([for GNU tar])
for a in $GNUTAR gtar gnutar tar; do
      $a --version 2> /dev/null | grep GNU  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 tar.])
fi

AC_SUBST(GNUTAR)

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

if test "$GCC" = "yes"; then
   AC_MSG_CHECKING( for --hash-style=both linker support )
   hash_style_ldflags_save=$LDFLAGS
   LDFLAGS="$LDFLAGS -Wl,--hash-style=both"
   AC_LINK_IFELSE([AC_LANG_PROGRAM([
   #include <stdio.h>
   ],[
    printf ("hello world\n");
   ])], HAVE_LD_HASH_STYLE=TRUE, HAVE_LD_HASH_STYLE=FALSE)
   if test "z$HAVE_LD_HASH_STYLE" = "zTRUE"; then
     AC_MSG_RESULT( found )
   else
     AC_MSG_RESULT( not found )
   fi
   LDFLAGS=$hash_style_ldflags_save
fi
AC_SUBST(HAVE_LD_HASH_STYLE)

dnl ===================================================================
dnl  Test the Compaq compiler for OSF1
dnl ===================================================================
if test "$_os" = "OSF1"; then
   if test "$CC" = "cc"; then
      AC_PATH_PROGS(_cc, cc)
      COMPATH=`echo $_cc | $SED -n "s/\/bin\/cc//p"`
      AC_MSG_WARN([******* $_cc , $COMPATH])
      AC_MSG_CHECKING([the Compaq C compiler version])
      dnl cc -V outputs to standard error!!!!
      _compaqc_version=`$CC -V 2>&1 | $AWK '{ print $3 }'`
      _compaqc_major=`echo $_compaqc_version | $AWK -F. '{ print $1 }'`
      if test "$_compaqc_major" != "T6"; then
         AC_MSG_ERROR([found version "$_compaqc_version", use version 6 of the Compaq C compiler])
      else
         dnl compiler will do
         AC_MSG_RESULT([checked])
      fi
   fi
fi

dnl ===================================================================
dnl Check whether there's a Perl version available.
dnl ===================================================================
if test -z "$with_perl_home"; then
   AC_PATH_PROG(PERL, perl)
else
   if test "$_os" = "WINNT"; then
      with_perl_home=`cygpath -u "$with_perl_home"`
   fi
   _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
AC_SUBST(PERL)

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

dnl ===================================================================
dnl  Check which Microsoft C/C++ or MinGW compiler is used for WINNT
dnl ===================================================================
if test "$_os" = "WINNT"; then
	if test "$WITH_MINGWIN" != "yes"; then
		AC_MSG_CHECKING([for friendly registry keys])
		# VS.Net 2003, VS.Net 2005
		if test -z "$with_cl_home"; then
			vctest=`./oowintool --msvc-productdir`;
			if test -x "$vctest/bin/cl.exe"; then
				with_cl_home=$vctest;
			fi
		else
			with_cl_home=`cygpath -u "$with_cl_home"`
		fi
		AC_MSG_RESULT([done])

		dnl ===========================================================
		dnl  Check for mspdb71.dll/mspdb80.dll
		dnl ===========================================================
		dnl  .NET 2003/5/8 Compiler
		if test -n "$with_mspdb_path";then
			with_mspdb_path=`cygpath -u "$with_mspdb_path"`
		fi
		if test -e "$with_mspdb_path/mspdb71.dll" -o -e "$with_mspdb_path/mspdb80.dll"; then
			MSPDB_PATH="$with_mspdb_path"
		fi
		dnl .NET 2003 case
		if test -z "$MSPDB_PATH" -a -e "$with_cl_home/../Common7/IDE/mspdb71.dll"; then
			MSPDB_PATH="$with_cl_home/../Common7/IDE"
		fi
		dnl .NET 2005/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

		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, mspdb71.dll)
			MSPDB_PATH=`dirname "$MSPDB_PATH"`
		fi

		if test -z "$MSPDB_PATH"; then
			AC_MSG_ERROR([You need a mspdb71.dll/mspdb80.dll, make sure it's 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 -x "$with_cl_home/bin/cl.exe"; then
   			CC="$with_cl_home/bin/cl.exe"
   		else
   			AC_PATH_PROG(CC, cl.exe)
   		fi
  		if test -e "$CC"; then
			# This gives us a posix path with 8.3 filename restrictions
			CC=`cygpath -d "$CC"`
			CC=`cygpath -u "$CC"`
			# Remove /cl.exe from CC case insensitive
			AC_MSG_RESULT([found ($CC)])
			COMPATH=`echo $CC | $SED 's@\/[[Bb]][[Ii]][[Nn]]\/[[cC]][[lL]]\.[[eE]][[xX]][[eE]]@@'`
			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])
dnl      The following find 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]] )
							}
							}"`
			AC_MSG_RESULT([found Compiler version $CCNUMVER.])
			if test "$CCNUMVER" -ge "001500000000"; then
				COMEX=12
				MSVSVER=2008
				AC_MSG_RESULT([found .NET 2008 / VS 9.0.])
			elif test "$CCNUMVER" -ge "001400000000"; then
				COMEX=11
				MSVSVER=2005
				AC_MSG_RESULT([found .NET 2005.])
			elif test "$CCNUMVER" -ge "001300102240"; then
				COMEX=10
				MSVSVER=2003
				AC_MSG_RESULT([found .NET 2003.])
			else
				AC_MSG_ERROR([Compiler too old. Use Microsoft C/C++ .NET 2003/2005 compiler.])
			fi
		else
			AC_MSG_ERROR([Microsoft C/C++ Compiler not found. Use --with-cl-home or set path to cl.exe.])
		fi
	else
		AC_MSG_CHECKING([the Mingwin32 C++ Compiler])
		if test `$CC -dumpmachine | $SED -e 's/^.*-//'` = "mingw32"; then
			AC_MSG_RESULT([found.])
			if $CC -dumpspecs | grep -q "mno-cygwin"; then
				USE_MINGW="cygwin"
			else
				USE_MINGW="pure-mingw"
			fi
		else
			AC_MSG_ERROR([Mingwin32 C++ Compiler not found.])
		fi
	fi
fi
AC_SUBST(COMEX)
AC_SUBST(MSPDB_PATH)
AC_SUBST(USE_MINGW)

dnl ===================================================================
dnl  .NET needs special treatment
dnl ===================================================================
if test "$_os" = "WINNT"; then
if test "$WITH_MINGWIN" = "yes" || test "$COMEX" -ge "10"; 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
		psdktest=`./oowintool --psdk-home`
		if test -x "$psdktest/Bin/midl.exe" ; then
			MIDL_PATH="$psdktest/Bin"
		fi
	fi
	if test ! -x "$MIDL_PATH/midl.exe"; then
		AC_MSG_ERROR([midl.exe not found. Make sure it's in the 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 Frameworks dir
    dnl For VS2003/2005 $with_frame_home has to point to the directory with lib/mscoree.lib.
       AC_MSG_CHECKING(.NET Framework)
	    if test -n "$with_frame_home"; then
		with_frame_home=`cygpath -u "$with_frame_home"`
	    fi
	    if test -f "$with_frame_home/lib/mscoree.lib"; then
		    FRAME_HOME="$with_frame_home"
	    fi
	    if test -z "$FRAME_HOME" -a -e "$with_cl_home/../SDK/v1.1/lib/mscoree.lib"; then
		    FRAME_HOME="$with_cl_home/../SDK/v1.1"
	    fi
	    if test -z "$FRAME_HOME" ; then
          frametest=`./oowintool --dotnetsdk-dir`
          if test -f "$frametest/lib/mscoree.lib"; then
             FRAME_HOME="$frametest"
          else
             frametest=`./oowintool --psdk-home`
             if test -f "$frametest/lib/mscoree.lib"; then
                FRAME_HOME="$frametest"
             fi
          fi
	    fi
	    if test ! -f "$FRAME_HOME/lib/mscoree.lib"; then
		AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-frame-home])
	    fi
	    AC_MSG_RESULT(found)
	# Convert to posix path with 8.3 filename restrictions ( No spaces )
	FRAME_HOME=`cygpath -d "$FRAME_HOME"`
	FRAME_HOME=`cygpath -u "$FRAME_HOME"`
fi
AC_SUBST(MIDL_PATH)
AC_SUBST(CSC_PATH)
AC_SUBST(FRAME_HOME)
fi

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

dnl ===================================================================
dnl Find pre-processors.
dnl ===================================================================
if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "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

AC_CHECK_SIZEOF(long)
SIZEOF_LONG=$ac_cv_sizeof_long
AC_SUBST(SIZEOF_LONG)
AC_C_BIGENDIAN
WORDS_BIGENDIAN=$ac_cv_c_bigendian
AC_SUBST(WORDS_BIGENDIAN)

dnl Check for large file support
AC_SYS_LARGEFILE
if test -n "$ac_cv_sys_file_offset_bits"; then
   LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
fi
if test -n "$ac_cv_sys_large_files" && test "$ac_cv_sys_large_files" != "no"; then
   LFS_CFLAGS="$LFS_CFLAGS -D_LARGE_FILES"
fi
AC_SUBST(LFS_CFLAGS)

dnl ===================================================================
dnl Check if we are to enable vba macro interoperability feature
dnl ===================================================================
AC_MSG_CHECKING([whether to disable vba feature])
if test -n "$enable_vba" && test "$enable_vba" = "no"; then
   AC_MSG_RESULT([yes])
   ENABLE_VBA=NO
else
   AC_MSG_RESULT([no])
   ENABLE_VBA=YES
fi
AC_SUBST(ENABLE_VBA)

if test "$ENABLE_VBA" = "YES"; then
   AC_MSG_CHECKING([how to package the vba compatibility api])
   if test -n "$with_vba_package_format"; then
      if test "$with_vba_package_format" = "extn"; then
         VBA_EXTENSION=YES
         AC_MSG_RESULT([uno extension])
         AC_MSG_WARN([--with-vba-package-format=extn can cause problems])
      else if test "$with_vba_package_format" = "builtin"; then
            VBA_EXTENSION=NO
            AC_MSG_RESULT([build into installset])
         else
            AC_MSG_ERROR([unknown packaging method])
         fi
      fi
 
   else
      VBA_EXTENSION=NO
      AC_MSG_RESULT([defaulting to build into installset])
   fi
else
      VBA_EXTENSION=NO
fi
AC_SUBST(VBA_EXTENSION)

dnl ===================================================================
dnl Check the whether vba need to be delivered as an uno package or part
dnl of the install
dnl ===================================================================


dnl ===================================================================
dnl Check if cups/cups.h is available 
dnl ===================================================================
if test "$test_cups" = "yes" -a "$ENABLE_CUPS" = "TRUE" ; then
    AC_CHECK_HEADER(cups/cups.h, [],
                    [AC_MSG_ERROR([cups/cups.h could not be found. libcupsys2-dev or cups???-devel missing?])], [])
fi

dnl ===================================================================
dnl Check if PAM/pam_appl.h is available on Linux or FreeBSD
dnl ===================================================================
if test "$_os" = "Linux" -o "$_os" = "FreeBSD" -o "$_os" = "GNU"; then
  AC_MSG_CHECKING([whether to enable pam support])
  if test -z "$enable_pam" || test "$enable_pam" != "no"; then
    AC_MSG_RESULT([yes])
    PAM=YES
    AC_CHECK_HEADER(security/pam_appl.h, [],
                    [AC_MSG_ERROR([pam_appl.h could not be found. libpam-dev or pam-devel missing?])], [])
    AC_MSG_CHECKING([whether to link to libpam])
    if test -n "$enable_pam_link" -a "$enable_pam_link" != "no"; then
      AC_MSG_RESULT([yes])
      PAM_LINK=YES
      AC_CHECK_LIB(pam, pam_start, [],
          [AC_MSG_ERROR(libpam not found or functional)], [])
    else
      AC_MSG_RESULT([no, dynamically open it])
      PAM_LINK=NO
    fi
  else
    AC_MSG_RESULT([no])
    PAM=NO
    PAM_LINK=NO
    dnl check getspnam_r for needed args (4 or 5)
    AX_FUNC_WHICH_GETSPNAM_R
  fi
fi
AC_SUBST(PAM)
AC_SUBST(NEW_SHADOW_API)
AC_SUBST(PAM_LINK)

if test "$_os" = "Linux"; then
    AC_MSG_CHECKING([whether to link to libcrypt])
    if test -n "$enable_crypt_link" -a "$enable_crypt_link" != "no"; then
        AC_MSG_RESULT([yes])
        CRYPT_LINK=YES
        AC_CHECK_LIB(crypt, crypt, [],
            [AC_MSG_ERROR(libcrypt not found or functional)], [])
    else
        AC_MSG_RESULT([no, dynamically open it])
        CRYPT_LINK=NO
    fi
fi
AC_SUBST(CRYPT_LINK)

dnl ===================================================================
dnl Testing for c++ compiler and version...
dnl ===================================================================
if test -n "$with_gcc_home"; then
   if test -z "$CXX"; then
      CXX="$with_gcc_home/bin/g++"
   fi
fi

if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
   if test -e "$CC"; then
      CXX="$CC"
   fi
fi

dnl Autoconf 2.53 can do this test for cl.exe, 2.13 can't!
if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
   AC_PROG_CXX
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_major=`echo $_gpp_version | $AWK -F. '{ print \$1 }'`
   _gpp_minor=`echo $_gpp_version | $AWK -F. '{ print \$2 }'`
   
   AC_MSG_RESULT([checked (g++ $_gpp_version)])

   if test "$_gpp_major" = "3"; then
      if test "$_gpp_minor" = "4"; then
         AC_MSG_CHECKING([whether $CXX has the enum bug])
AC_TRY_RUN([
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 OpenOffice.org 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
fi

dnl ===================================================================
dnl Set the gcc/gxx include directories
dnl ===================================================================
# Removed the special FreeBSD treatment. The problem was that with_gxx_include_path
# often contains an i386 which is expanded as a macro. Solved in stlport.
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++ - | $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 test "$WITH_MINGWIN" = "yes"; then
         with_gxx_include_path=`cygpath -d "$with_gxx_include_path"`
         with_gxx_include_path=`cygpath -u "$with_gxx_include_path"`
      fi
      if echo $with_gxx_include_path | grep -q linux; then
         # workaround for Mandriva - issue 100049
         with_gxx_include_path=`cd $with_gxx_include_path && pwd`
      fi
   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([no g++ includes])
else
   AC_MSG_RESULT([$with_gxx_include_path])
fi
GXX_INCLUDE_PATH="$with_gxx_include_path"
AC_SUBST(GXX_INCLUDE_PATH)

dnl ===================================================================
dnl Set the mingw runtime library include directories
dnl ===================================================================
if test "$WITH_MINGWIN" = "yes"; then
   AC_MSG_CHECKING([for mingwin runtime 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 -n "$_mingw_lib_include_path"; then
      _temp=""
      for a in $_mingw_lib_include_path
         do
            a=`cygpath -d "$a"`
            _temp="$_temp "`cygpath -u "$a"`
         done
      _mingw_lib_include_path=$_temp
   fi
   if test -z "$_mingw_lib_include_path"; then
      _mingw_lib_include_path="NO_LIB_INCLUDE"
      AC_MSG_RESULT([no mingwin runtime includes])
   else
      AC_MSG_RESULT([$_mingw_lib_include_path])
   fi
  MINGW_LIB_INCLUDE_PATH="$_mingw_lib_include_path"
  AC_SUBST(MINGW_LIB_INCLUDE_PATH)
dnl mingw gcc 4.4.0 needs backward in include path to use hash_set/hash_map
   AC_MSG_CHECKING([for mingwin c++ backward include path])
   cat >conftest.$ac_ext <<_ACEOF
#include <hash_set>
_ACEOF
   _mingw_backward_include_path=`$CXX -E -xc++ -Wno-deprecated conftest.$ac_ext 2>&5| $SED -n -e '/.*1*"\(.*\)\/hash_set".*/s//\1/p' | sort -u | xargs echo`
   rm conftest.$ac_ext
   if test -n "$_mingw_backward_include_path"; then
      _mingw_backward_include_path=`cygpath -d $_mingw_backward_include_path`
      _mingw_backward_include_path=`cygpath -u $_mingw_backward_include_path`
      AC_MSG_RESULT([$_mingw_backward_include_path])
   else
      _mingw_backward_include_path="NO_BACKWARD_INCLUDE"
      AC_MSG_RESULT([no mingwin c++ backward includes])
   fi
  MINGW_BACKWARD_INCLUDE_PATH="$_mingw_backward_include_path"
  AC_SUBST(MINGW_BACKWARD_INCLUDE_PATH)
  mingw_crtbegin=`$CC -print-file-name=crtbegin.o`
  MINGW_CLIB_DIR=`dirname $mingw_crtbegin`
  AC_MSG_CHECKING([whether to use dynamic libgcc])
  if test -e "$MINGW_CLIB_DIR/libgcc_s.a"; then
    AC_MSG_CHECKING([dynamic libgcc name])
    MINGW_GCCDLL_pattern=`nm $MINGW_CLIB_DIR/libgcc_s.a | sed -ne 's@.* _libgcc\(.*\)_dll_iname@libgcc\1.dll@p' | uniq | sed -e 's@_@?@g'`
    MINGW_GCCDLL=`cd $COMPATH/bin && ls $MINGW_GCCDLL_pattern 2>/dev/null`
    if test -n "$MINGW_GCCDLL"; then
        MINGW_SHARED_GCCLIB=YES
        AC_MSG_RESULT([use $MINGW_GCCDLL])
    else
        AC_MSG_RESULT([no])
    fi
  else
    AC_MSG_RESULT([no])
  fi
  if test -e "$MINGW_CLIB_DIR/libgcc_eh.a"; then
      MINGW_GCCLIB_EH=YES
  fi
  AC_MSG_CHECKING([whether to use dynamic libstdc++])
  if test -e "$MINGW_CLIB_DIR/libstdc++_s.a" ; then
    AC_MSG_CHECKING([dynamic libstdc++ name])
    MINGW_GXXDLL_pattern=`nm $MINGW_CLIB_DIR/libstdc++_s.a | sed -ne 's@.* _libstdc__\(.*\)_dll_iname@libstdc++\1.dll@p' | uniq | sed -e 's@_@?@g'`
    MINGW_GXXDLL=`cd $COMPATH/bin && ls $MINGW_GXXDLL_pattern 2>/dev/null`
    if test -n "$MINGW_GXXDLL"; then
        MINGW_SHARED_GXXLIB=YES
        AC_MSG_RESULT([use $MINGW_GXXDLL])
    else
        AC_MSG_RESULT([no])
    fi
  else
    AC_MSG_RESULT([no])
  fi
  MINGW_CLIB_DIR=`cygpath $MINGW_CLIB_DIR`
  AC_SUBST(MINGW_CLIB_DIR)
  AC_SUBST(MINGW_SHARED_GCCLIB)
  AC_SUBST(MINGW_GCCLIB_EH)
  AC_SUBST(MINGW_SHARED_GXXLIB)
  AC_SUBST(MINGW_GCCDLL)
  AC_SUBST(MINGW_GXXDLL)
fi

dnl ===================================================================
dnl Extra checking for the SUN OS 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 Extra checking for the DARWIN compiler
dnl ===================================================================
if test "$_os" = "Darwin"; then
   dnl c++ packaged with cc (gcc) for Macosx
   if test "$CC" = "cc"; then
      AC_MSG_CHECKING([Macosx c++ Compiler])
      if test "$CXX" != "c++"; then
         AC_MSG_WARN([Macosx C++ was not found])
         echo "Macosx C++ was not found" >> warn
      else
         AC_MSG_RESULT([checked]) 
      fi
   fi 
fi 
dnl ===================================================================
dnl Extra checking for the OSF compiler
dnl ===================================================================
if test "$_os" = "OSF1"; then
   AC_MSG_CHECKING([Compaq C++ compiler version])
   dnl cxx -V outputs to standard error!!!!
   _compaqcxx_version=`$CXX -V 2>&1 | $AWK '{ print $3 }'`
   _compaqcxx_major=`echo $_compaqcxx_version | $AWK -F. '{ print $1 }'`
   if test "$_compaqcxx_major" != "V6"; then
      AC_MSG_WARN([found version "$_compaqc_version", use version 6 of the Compaq C++ compiler])
      echo "found version $_compaqc_version, use version 6 of the Compaq C++ compiler" >> warn
   else
      dnl compiler will do
      AC_MSG_RESULT([checked])
   fi
fi

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

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

	],
	[_Unwind_SjLj_RaiseException() ],
	[exceptions_type="sjlj"],
	[exceptions_type="dwarf2"]
  )
fi

AC_MSG_RESULT($exceptions_type)
AC_LANG_POP([C++])
EXCEPTIONS="$exceptions_type"
AC_SUBST(EXCEPTIONS)

dnl **************************************************************
dnl Testing for required  Solaris and SunStudio compiler patches...
dnl **************************************************************
dnl Check whether the OS is SunOS.
if test "$_os" = "SunOS"; then
   _temp=`showrev -p | $AWK -F" " '{ print $2 }'` 
   if test "$_os_release" = "7"; then
      dnl ***************
      dnl patch 106327-06
      dnl ***************
      AC_MSG_CHECKING([for patch 106327-06 or greater])
      _patch=`echo $_temp | $AWK '/106327-06/ { print "found" }'`
      _patch="false"
      for i in $_temp
      do
         _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
         if test "$_patch_major" = "106327"; then
            _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
            if test "$_patch_rev" -ge "6"; then
               _patch="found"
            fi
        fi
      done
      if test "$_patch" = "found"; then
         AC_MSG_RESULT([found])
      else
         AC_MSG_WARN([patch 106327-06 not found, please install compiler patch 106327-06 or greater])
         echo "patch 106327-06 not found, please install compiler patch 106327-06 or greater" >> warn
      fi
      dnl ***************
      dnl patch 106950-11
      dnl ***************
      AC_MSG_CHECKING([for patch 106950-11 or greater])
      _patch=`echo $_temp | $AWK '/106950-11/ { print "found" }'`
      _patch="false"
      for i in $_temp
      do
         _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
         if test "$_patch_major" = "106950"; then
            _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
            if test "$_patch_rev" -ge "11"; then
               _patch="found"
            fi
         fi
      done
      if test "$_patch" = "found"; then
         AC_MSG_RESULT([found])
      else
         AC_MSG_WARN([patch 106950-11 not found, please install linker patch 106950-11 or greater])
         echo "patch 106950-11 not found, please install linker patch 106950-11 or greater" >> warn
      fi
   else
      if test "$_os_release" = "6"; then
         dnl ***************
         dnl patch 105591-09
         dnl ***************
         AC_MSG_CHECKING([for patch 105591-09 or greater])
         _patch=`echo $_temp | $AWK '/105591-09/ { print "found" }'`
         _patch="false"
         for i in $_temp
         do
            _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
            if test "$_patch_major" = "105591"; then
               _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
               if test "$_patch_rev" -ge "9"; then
                  _patch="found"
               fi
           fi
         done
         if test "$_patch" = "found"; then
            AC_MSG_RESULT([found])
         else
            AC_MSG_WARN([patch 105591-09 not found, please install compiler patch 105591-09 or greater])
            echo "patch 105591-09 not found, please install compiler patch 105591-09 or greater" >> warn
         fi
         dnl ***************
         dnl patch 107733-08
         dnl ***************
         AC_MSG_CHECKING([for patch 107733-08 or greater])
         _patch=`echo $_temp | $AWK '/107733-08/ { print "found" }'`
         _patch="false"
         for i in $_temp
         do
            _patch_major=`echo $i | $AWK -F"-" '{ print $1 }'`
            if test "$_patch_major" = "107733"; then
               _patch_rev=`echo $i | $AWK -F"-" '{ print $2 }'`
               if test "$_patch_rev" -ge "8"; then
                  _patch="found"
               fi
           fi
         done
         if test "$_patch" = "found"; then
            AC_MSG_RESULT([found])
         else
            AC_MSG_WARN([patch 107733-06 not found, please install linker patch 107733-08 or greater])
            echo "patch 107733-06 not found, please install linker patch 107733-08 or greater" >> warn
         fi
      fi
   fi
fi

dnl ===================================================================
dnl Checks for what the default STL should be
dnl ===================================================================
   AC_MSG_CHECKING([what the default STL should be])
   DEFAULT_TO_STLPORT="no"
   if test "$_os" = "Linux"; then
     case "$build_cpu" in
       i?86)
         DEFAULT_TO_STLPORT="yes"
         ;;
       *)
         DEFAULT_TO_STLPORT="no"
         ;;
     esac
   elif test "$_os" = "SunOS"; then
      DEFAULT_TO_STLPORT="yes"
   elif test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
      DEFAULT_TO_STLPORT="yes"
   elif test "$_os" = "OS2"; then
      DEFAULT_TO_STLPORT="yes" 
   elif test "$_os" = "FreeBSD"; then
      DEFAULT_TO_STLPORT="yes"
   fi
   if test "$DEFAULT_TO_STLPORT" = "yes"; then
      AC_MSG_RESULT([stlport])
   else
      AC_MSG_RESULT([system])
   fi
   if test "$WITH_STLPORT" = "auto"; then
      WITH_STLPORT=$DEFAULT_TO_STLPORT
   fi

dnl ===================================================================
dnl Checks for STLPORT
dnl ===================================================================
   AC_MSG_CHECKING([for STL providing headers])
   STLPORT4=""
   USE_SYSTEM_STL=""
   if test "$WITH_STLPORT" = "yes"; then
      AC_MSG_RESULT([using internal stlport.])
      if test "$DEFAULT_TO_STLPORT" != "yes"; then
         AC_MSG_WARN([using stlport. Warning, breaks your ABI compatability!])
         echo "using stlport. Warning, breaks your ABI compatability!" >>warn
      fi
   elif test "$WITH_STLPORT" = "no"; then
      AC_MSG_RESULT([using system STL])
      USE_SYSTEM_STL="YES"
      if test "$DEFAULT_TO_STLPORT" != "no"; then
         AC_MSG_WARN([using system STL. Warning, breaks your ABI compatability!])
         echo "using system STL. Warning, breaks your ABI compatability!" >>warn
      fi
   else
      STLPORT4=$WITH_STLPORT
      if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
         AC_TRY_CPP($STLPORT4/stlport/hash_map, AC_MSG_RESULT([checked.]), AC_MSG_ERROR([STLport headers not found.]))
      else
         dnl AC_TRY_CPP doesn't work for MSVC because C++ preprocessor is not found by autoconf.
         if test -f "$STLPORT4/stlport/hash_map"; then
            AC_MSG_RESULT([checked.])
         else
            AC_MSG_ERROR([STLport headers not found.])
         fi
      fi
      if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
         AC_MSG_CHECKING([for STLport libraries])
         if test "$_os" = "SunOS"; then
		      if test -f "$STLPORT4/lib/libstlport_sunpro.so"; then
			      AC_MSG_RESULT([checked])
		      elif test -f "$STLPORT4/lib/libstlport.so"; then
			      AC_MSG_RESULT([checked])
			      STLPORT_VER=500
		      else
			      AC_MSG_ERROR([STLport libraries not found])
		      fi
	      elif test "$_os" = "Darwin"; then
		      if test -f "$STLPORT4/lib/libstlport_gcc.dylib"; then
			      AC_MSG_RESULT([checked])
		      elif test -f "$STLPORT4/lib/libstlport.dylib"; then
			      AC_MSG_RESULT([checked])
			      STLPORT_VER=500
		      else
			      AC_MSG_ERROR([STLport libraries not found])
		      fi
		   else
			   if test -f "$STLPORT4/lib/libstlport_gcc.so"; then
				   AC_MSG_RESULT([checked])
			   elif test -f "$STLPORT4/lib/libstlport.so"; then
				   AC_MSG_RESULT([checked])
				   STLPORT_VER=500
			   else
				   AC_MSG_ERROR([STLport libraries not found])
			   fi
		   fi
	   fi
      if test "$DEFAULT_TO_STLPORT" != "yes"; then
         AC_MSG_WARN([using stlport. Warning, breaks your ABI compatability!])
         echo "using stlport. Warning, breaks your ABI compatability!" >>warn
      fi
   fi

if test -z "$STLPORT4"; then
  STLPORT4="NO_STLPORT4"
fi
if test -z "$STLPORT_VER"; then
  STLPORT_VER=400
fi
AC_SUBST(STLPORT4)
AC_SUBST(STLPORT_VER)
AC_SUBST(USE_SYSTEM_STL)

dnl ===================================================================
dnl visibility feature
dnl ===================================================================
if test "$GCC" = "yes"; then
   AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
   save_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -fvisibility=hidden"
   AC_TRY_LINK([], [ return 0; ], [ HAVE_GCC_VISIBILITY_FEATURE=TRUE ], [])
   CFLAGS=$save_CFLAGS
   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
      AC_MSG_RESULT([yes])
   else
      AC_MSG_RESULT([no])
   fi
fi

# ===================================================================
# use --ccache-skip?
# ===================================================================
dnl used to escape compiler options for ccache that otherwise prevent 
dnl caching of the results (like "-x objective-c++" for Mac)
AC_MSG_CHECKING([whether we are allowed and able to use --ccache-skip])
if test "$_os" != "Darwin" ; then
   AC_MSG_RESULT([only used on Mac currently, skipping])
elif test "$enable_ccache_skip" = "no" ; then
   AC_MSG_RESULT([no - diabled explicitly])
elif test "$enable_ccache_skip" = "yes" ; then
   AC_MSG_RESULT([yes - enabled explicitly, skipping checks])
   AC_SUBST([USE_CCACHE], [YES])
elif test "$enable_ccache_skip" = "auto" ; then
   # checking for ccache presence/version
   AC_MSG_RESULT([probing...])
   AC_PATH_PROG([CCACHE],[ccache],[not_found])
   if test "$CCACHE" = "not_found" ; then
      AC_MSG_NOTICE([not enabling --ccache-skip (ccache not found)])
   else
      # check ccache version 
      AC_MSG_CHECKING([whether version of ccache is suitable])
      CCACHE_VERSION=`"$CCACHE" -V | "$AWK" '/^ccache version/{print $3}'`
      if test "$CCACHE_VERSION" = "2.4_OOo"; then
         AC_MSG_RESULT([yes])
         AC_MSG_CHECKING([whether ccache is actually used for the build])
         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, will enable --ccache-skip])
            AC_SUBST([USE_CCACHE], [YES])
         else
            AC_MSG_RESULT([no, will not enable --ccache-skip])
         fi
         CXXFLAGS=$save_CXXFLAGS
         AC_LANG_POP([C++])
      else
         AC_MSG_RESULT([no])
         AC_MSG_NOTICE([ccache version $CCACHE_VERSION not accepted. See description for --enable-ccache-skip])
      fi
   fi
else
   AC_MSG_ERROR([invalid option to --enable-ccache-skip. Valid values are "auto", "yes" and "no"])
fi

dnl ===================================================================
dnl system stl sanity tests
dnl ===================================================================
if test "$USE_SYSTEM_STL" = "YES"; then
   AC_MSG_CHECKING([if hash_map will be in __gnu_cxx namespace])
   AC_LANG_PUSH([C++])

   AC_TRY_COMPILE([#include <ext/hash_map>
using namespace __gnu_cxx;
],[hash_map<int, int> t; return 0;],
  ac_cv_cxx_have_ext_hash_map=yes, ac_cv_cxx_have_ext_hash_map=no)

   if test "$ac_cv_cxx_have_ext_hash_map" = "no"; then
      AC_MSG_ERROR([Can't find hash_map. Try with --with-stlport])
   else
      AC_MSG_RESULT([$ac_cv_cxx_have_ext_hash_map])
   fi

   if test "$HAVE_GCC_VISIBILITY_FEATURE" = "TRUE"; then
      AC_MSG_CHECKING([if STL headers are visibility safe])
      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 -fpic -shared"

      AC_MSG_CHECKING([if gcc is -fvisibility-inlines-hidden safe with STL headers])
      AC_TRY_LINK([#include <sstream>
using namespace std;
],[istringstream strm( "test" ); return 0;],
      $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 visibility])
         echo "Your gcc is not -fvisibility-inlines-hidden safe. Disabling visibility" >> warn
         unset HAVE_GCC_VISIBILITY_FEATURE
      fi

      LDFLAGS=$sharedlink_ldflags_save
   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 "$build_cpu" in
            i?86|x86_64)
               if $EGREP -q '@PLT' visibility.s; then
                  gccvisbroken=no
               else 
                  gccvisbroken=yes
               fi
               ;;
            *)
               gccvisbroken=no
               ;;
         esac
      fi
      rm -f visibility.s

      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

   AC_LANG_POP([C++])
fi

AC_SUBST(HAVE_GCC_VISIBILITY_FEATURE)

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 $build_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" = "internal" -o -z "$with_alloc"; then
   AC_MSG_RESULT([internal])
fi
AC_SUBST(ALLOC)

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

AC_MSG_CHECKING([whether to add custom build version])
if test "z$with_build_version" != "z"; 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
   AC_MSG_RESULT([yes])
   SOLAR_JAVA="TRUE"
else
   AC_MSG_RESULT([no])
   SOLAR_JAVA=""

   AC_MSG_WARN([building without java will mean some features will not be available])
   echo "building without java will mean some features will not be available" >>warn
fi
AC_SUBST(SOLAR_JAVA)

if test "$_os" = "Linux" && test "$build_cpu" = "powerpc"; then
   # IBMs JDK needs this...
   JITC_PROCESSOR_TYPE=6
   export JITC_PROCESSOR_TYPE
fi

if test "$_os" = "WINNT"; then
   if test -z "$with_jdk_home"; then
      _jdk_home=`./oowintool --jdk-home`
       if test -d "$_jdk_home"; then
          with_jdk_home="$_jdk_home"
       fi
   else
      with_jdk_home=`cygpath -u "$with_jdk_home"`
   fi
fi

dnl ===================================================================
dnl Checks for java
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
   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 set with_jdk_home])
      fi
   fi
   if test "$_os" = "WINNT"; then
      if test x`echo "$JAVAINTERPRETER" | grep -i '\.exe$'` = x; then
          JAVAINTERPRETER="${JAVAINTERPRETER}.exe"
      fi
      JAVAINTERPRETER=`cygpath -d "$JAVAINTERPRETER"`
      JAVAINTERPRETER=`cygpath -u "$JAVAINTERPRETER"`
   fi
fi

dnl ===================================================================
dnl Checks for JDK.
dnl ===================================================================
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])
#        dnl Kaffe specific tests
#        KAFFE_VER=`$JAVAINTERPRETER -version 2>&1 | $EGREP "  Version:" | $SED -r "s/.*  Version: ([[0-9\.]]*).*/\1/"`
#        if test -z "$KAFFE_VER"; then
#          AC_MSG_ERROR([looks like Kaffe but version detection failed])
#        fi
#        _kaffe_ver=`echo "$KAFFE_VER" | $AWK -F. '{ print (($1 * 100) + $2) * 100 + $3;}'`
#        if test "$_kaffe_ver" -lt 10100; then
#           AC_MSG_ERROR([Kaffe is too old ($KAFFE_VER - $_kaffe_ver), you need at least 1.1.0])
#        fi
#        JDK=kaffe
#        
#        dnl TODO: define some project exclusion variables
#        
#        AC_MSG_RESULT([checked (Kaffe $KAFFE_VER)])
#        AC_MSG_WARN([EXPERIMENTAL: Kaffe is not a full JDK replacement - some projects will fail to compile])
#        echo "EXPERIMENTAL: Kaffe is not a full JDK replacement - some projects will fail to compile" >>warn
#        JAVA_HOME=`echo $JAVAINTERPRETER | $SED -n "s,//*bin//*java,,p"`
      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])
#        JDK=bea
#
#        dnl BEA 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 BEA JDK 1.5.0])
#        fi
#
#        AC_MSG_RESULT([checked (BEA JDK $_jdk)])
#
#        if test "$with_jdk_home" = ""; then
#             AC_MSG_ERROR([In order to successfully build OpenOffice.org using the BEA JDK,
#you must use the "--with-jdk-home" configure option explicitly])
#        fi
#
#        AC_MSG_WARN([A bug in certain BEA JREs can prevent you from successfully compiling some modules])
#        echo "A bug in certain BEA JREs can prevent you from successfully compiling some modules" >>warn
#
#        JAVA_HOME=$with_jdk_home
#
      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 OpenOffice.org 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
        if test "$_os" = "OS2"; 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

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 "$_os" = "OS2"; then
      if test x`echo "$javacompiler" | grep -i '\.exe$'` = x; then
          javacompiler="${javacompiler}.exe"
      fi
    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 "$_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 "$_os" = "OS2"; then
       if test x`echo "$JAVACOMPILER" | grep -i '\.exe$'` = x; then
          JAVACOMPILER="${JAVACOMPILER}.exe"
       fi
    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)

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"
        if test "$_os" = "OS2"; then
          if test x`echo "$_javadoc_path" | grep -i '\.exe$'` = x; then
              _javadoc_path="${_javadoc_path}.exe"
          fi
        fi
        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 "$_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
    if test "$_os" = "OS2"; then
        if test x`echo "$JAVADOC" | grep -i '\.exe$'` = x; then
            JAVADOC="${JAVADOC}.exe"
        fi
    fi
fi

if test "$SOLAR_JAVA" != ""; then
    dnl first check if we have been asked to autodetect JAVA_HOME with a recent gij
    if test "$JDK" == "gcj" -a -z "$JAVA_HOME"; then
      if test "x$with_jdk_home" = "x" -a "$_gij_longver" -ge "40200"; 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 && test -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 && test "$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
      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
      # 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)
         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"; 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
      # now check if $JAVA_HOME is really valid
      if test "$_os" = "Darwin"; 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
#         if test "$JDK" == "gcj"; then
#             echo "e.g. install java-1.4.2-gcj-compat-devel and use --with-jdk-home=/usr/lib/jvm/java-1.4.2-gcj" >> warn
#         fi
      fi
    fi
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

dnl ===================================================================
dnl Check for optional gcj for AOT
dnl ===================================================================
if test "$SOLAR_JAVA" != ""; then
  AC_MSG_CHECKING([whether to enable gcj aot compilation])
  if test -n "$enable_gcjaot" && test "$enable_gcjaot" != "no"; then
     AC_MSG_RESULT([yes])
     if test `echo $WITH_JAVA | grep -c "gij"` -eq 0; then
        gcjaot="gcj"
     else
        gcjaot=`echo $WITH_JAVA | $SED -e "s/gij/gcj/g"`
     fi
     AC_MSG_RESULT([$gcjaot])
     if test -n "$with_jdk_home"; then
        _javac_path="$with_jdk_home/bin/$gcjaot"
        dnl Check if there is a gcj at all.
        if test -x "$_javac_path"; then
           JAVAAOTCOMPILER=$_javac_path
        fi
     fi
     if test -z "$JAVAAOTCOMPILER"; then
        AC_PATH_PROG(JAVAAOTCOMPILER, $gcjaot)
     fi
     if test -z "$JAVAAOTCOMPILER"; then
        AC_MSG_WARN([$gcjaot not found, set with_jdk_home])
     fi
  else
     AC_MSG_RESULT([no])
  fi
fi

AC_SUBST(JAVA_HOME)
AC_SUBST(JDK)
AC_SUBST(JAVAFLAGS)
AC_SUBST(JAVAINTERPRETER)
AC_SUBST(JAVACOMPILER)
AC_SUBST(JAVAAOTCOMPILER)
AC_SUBST(JAVADOC)

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])
if test "$_os" != "WINNT" -a \( "z$enable_epm" = "z" -o "$enable_epm" != "no" \) ; 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" || test "$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])
   # epm supports the following formats:
   # aix - AIX software distribution
   # bsd - FreeBSD, NetBSD, or OpenBSD software distribution
   # depot or swinstall - HP-UX 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

   # defaults
   case "$_os" in
	OS2)
		PKGFORMAT=native
		;;
	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=aix
		;;
	*BSD)
		PKGFORMAT=bsd
		;;
	OSF1)
		PKGFORMAT=setld
		;;
	# 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) 
			;;
		*)
			AC_MSG_ERROR([unsupported format $i. Supported by EPM are:
aix - AIX software distribution
bsd - FreeBSD, NetBSD, or OpenBSD software distribution
depot or swinstall - HP-UX 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
			]) 
			;;
		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])
       else
	  RPM_PATH=`which $RPM`
          AC_MSG_RESULT([$RPM_PATH])
       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" && test "$EPM" != "internal"; then
           if test "`echo $EPM_VERSION | cut -d'.' -f1`" -lt "4"; then
               AC_MSG_CHECKING([whether epm is patched for OOos needs])
               if grep "Patched for OpenOffice.org" $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(BUILD_EPM)
   AC_SUBST(PKGFORMAT)
   AC_SUBST(RPM)
   AC_SUBST(DPKG)
   AC_SUBST(PKGMK)
else
   AC_MSG_RESULT([no])
   EPM=NO
fi
AC_SUBST(EPM)

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

dnl ===================================================================
dnl Check for building ODK
dnl ===================================================================
AC_MSG_CHECKING([whether to build the ODK])
if test "z$enable_odk" = "z" -o "$enable_odk" != "no"; then
   AC_MSG_RESULT([yes])
   if test "$WITH_JAVA" != "no"; then
   AC_MSG_CHECKING([for external/unowinreg/unowinreg.dll])
   if ! test -f "./external/unowinreg/unowinreg.dll"; then
      HAVE_UNOWINREG_DLL=no
   else
      HAVE_UNOWINREG_DLL=yes
   fi
   if test "$HAVE_UNOWINREG_DLL" = "yes"; then
      AC_MSG_RESULT([found])
      BUILD_UNOWINREG=NO
   else
      if test "$_os" = "WINNT"; then
         AC_MSG_RESULT([not found, will be built])
      else
         AC_MSG_WARN([not found, will be cross-built using mingw32])
      fi
      BUILD_UNOWINREG=YES
   fi
   if test "$_os" != "WINNT" && test "$BUILD_UNOWINREG" = "YES"; then
      if test -z "$WITH_MINGWIN" || test "$WITH_MINGWIN" = "0"; then
         AC_MSG_ERROR([for rebuilding unowinreg.dll you need the mingw32 C++ compiler.
         Specify mingw32 g++ executable name with --with-mingwin.
         Or use prebuilt one from http://tools.openoffice.org/unowinreg_prebuild/680/ and
         put it into external/unowinreg])
      fi
      if echo "$WITH_MINGWIN" | $EGREP -q "/"; then
         if ! test -x "$WITH_MINGWIN"; then MINGWCXX=false; else MINGWCXX=`basename $WITH_MINGWIN`; fi
      else
         AC_CHECK_TOOL(MINGWCXX, $WITH_MINGWIN, false)
      fi
      if test "$MINGWCXX" = "false"; then
         AC_MSG_ERROR(specified MinGW32 C++ cross-compiler not found. Install it or correct name.)
      fi
      AC_MSG_CHECKING(whether we are using the MinGW32 cross C++ compiler)
      if ! echo "`$MINGWCXX -dumpmachine`" | grep -q mingw32; then
         AC_MSG_ERROR(no)
      else
         AC_MSG_RESULT(yes)
      fi
      if echo "$WITH_MINGWIN" | $EGREP -q "/"; then
         if ! test -x "`echo $WITH_MINGWIN | $SED -e s/g++/strip/`"; then MINGSTRIP=false; else MINGWSTRIP=$(basename $(echo $WITH_MINGWIN | $SED -e s/g++/strip/)); fi
      else
         AC_CHECK_TOOL(MINGWSTRIP, `echo $WITH_MINGWIN | $SED -e s/g++/strip/`, false)
      fi
      if test "$MINGWSTRIP" = "false"; then
         AC_MSG_ERROR(MinGW32 binutils needed. Install them.)
      fi
      AC_LANG_PUSH([C++])
      save_CXX=$CXX
      save_CXXCPP=$CXXCPP
      CXX=$MINGWCXX
      CXXCPP="$MINGWCXX -E"
      save_CXXFLAGS=$CXXFLAGS
      save_CPPFLAGS=$CPPFLAGS
      CXXFLAGS="$CXXFLAGS -I$JAVA_HOME/include"
      CPPFLAGS="$CPPFLAGS -I$JAVA_HOME/include"
      # LIBS contains -lcrypt etc due to teh AC_CHECK_LIBS which obviously
      # do not make sense here (and 'd make the check fail)
      save_LIBS=$LIBS
      LIBS=""
      AC_HAVE_LIBRARY(kernel32)
      AC_HAVE_LIBRARY(advapi32)
      AC_CHECK_HEADER(windows.h, [], [AC_MSG_ERROR([windows.h missing])])
      CXXFLAGS=$save_CXXFLAGS
      CPPFLAGS=$save_CPPFLAGS
      CXX=$save_CXX
      CXXCPP=$save_CXXCPP
      LIBS=$save_LIBS
      AC_LANG_POP([C++])
      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 building qadevOOo
dnl ===================================================================
AC_MSG_CHECKING([whether to build qadevOOo])
if test "z$enable_qadevooo" = "z" -o "$enable_qadevooo" != "no"; then
   AC_MSG_RESULT([yes])
   BUILD_QADEVOOO="YES"
   BUILD_TYPE="$BUILD_TYPE QADEVOOO"
else
   BUILD_QADEVOOO="NO"
   AC_MSG_RESULT([no])
fi
AC_SUBST(BUILD_QADEVOOO)

dnl ===================================================================
dnl Check for prelinked libgcc_s.so.1
dnl ===================================================================
if test "$_os" = "Linux" -a -z "$with_system_stdlibs" -a -z "$with_system_libs"; then
  if test -n "$checkforstdlibproblems"; then
    if test -f /etc/rpm/macros.prelink; then
      with_system_stdlibs=yes
      AC_MSG_WARN([prelinked libgcc_s.so.1, enabling --with-system-stdlibs, use --without-system-stdlibs to override])
      echo "prelinked libgcc_s.so.1, enabling --with-system-stdlibs, use --without-system-stdlibs to override" >> warn
    elif test "$GCC" = "yes" -a ! -e `$CC -print-file-name=libgcc_s.so.1`; then
      with_system_stdlibs=yes
      AC_MSG_WARN([platform doesn't have a libgcc_s.so.1, enabling --with-system-stdlibs, use --without-system-stdlibs to override])
      echo "platform doesn't have a libgcc_s.so.1, enabling --with-system-stdlibs, use --without-system-stdlibs to override" >> warn
    fi
  fi
fi

dnl ===================================================================
dnl Check for system stdlibs
dnl ===================================================================
AC_MSG_CHECKING([whether to provide libstdc++/libgcc_s in the installset])
if test -n "$with_system_stdlibs" -o -n "$with_system_libs" && \
   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 "$_os" = "Darwin" && test "$with_system_zlib" != "no"; then
   with_system_zlib=yes
fi
AC_MSG_CHECKING([which zlib to use])
if test -n "$with_system_zlib" -o -n "$with_system_libs" && \
	test "$with_system_zlib" != "no"; 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)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_ZLIB=NO
    BUILD_TYPE="$BUILD_TYPE ZLIB"
fi
AC_SUBST(SYSTEM_ZLIB)

dnl ===================================================================
dnl Check for system jpeg
dnl ===================================================================
AC_MSG_CHECKING([which jpeg to use])
if test -n "$with_system_jpeg" -o -n "$with_system_libs" && \
	test "$with_system_jpeg" != "no"; 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)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_JPEG=NO
    BUILD_TYPE="$BUILD_TYPE JPEG"
fi
AC_SUBST(SYSTEM_JPEG)

dnl ===================================================================
dnl Check for system expat
dnl ===================================================================
AC_MSG_CHECKING([which expat to use])
if test -n "$with_system_expat" -o -n "$with_system_libs" && \
	test "$with_system_expat" != "no"; 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.)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_EXPAT=NO
    BUILD_TYPE="$BUILD_TYPE EXPAT"
fi
AC_SUBST(SYSTEM_EXPAT)

dnl ===================================================================
dnl Check for system libwpd
dnl ===================================================================
AC_MSG_CHECKING([which libwpd to use])
if test -n "$with_system_libwpd" -o -n "$with_system_libs" && \
        test "$with_system_libwpd" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBWPD=YES
    PKG_CHECK_MODULES( LIBWPD, libwpd-0.8 )
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBWPD=NO
    BUILD_TYPE="$BUILD_TYPE LIBWPD"
fi
AC_SUBST(SYSTEM_LIBWPD)
AC_SUBST(LIBWPD_CFLAGS)
AC_SUBST(LIBWPD_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 )
fi
AC_SUBST(FREETYPE_CFLAGS)
AC_SUBST(FREETYPE_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)

if test -n "$with_system_libxslt" -o -n "$with_system_libs" && \
   test "$with_system_libxslt" != "no"; then
    if test -z "$with_system_libxml" -a -z "$with_system_libs" || \
      test "$with_system_libxml" == "no"; then
      # somehow AC_MSG_WARN won't work...
       echo "to prevent incompatibilities between internal libxml2 and libxslt, the office will be build with system-libxml"
       echo "to prevent incompatibilities between internal libxml2 and libxslt, the office will be build with system-libxml" >> warn
       with_system_libxml=yes
    fi
fi
if test -n "$with_system_libxml" -o -n "$with_system_libs" && \
   test "$with_system_libxml" != "no"; then
    if test -z "$with_system_libxslt" -a -z "$with_system_libs" || \
      test "$with_system_libxslt" == "no"; then
      # somehow AC_MSG_WARN won't work...
       echo "to prevent incompatibilities between internal libxslt and libxml2, the office will be build with system-libxslt"
       echo "to prevent incompatibilities between internal libxslt and libxml2, the office will be build with system-libxslt" >> warn
       with_system_libxslt=yes
    fi
fi

dnl ===================================================================
dnl Check for system libxslt
dnl ===================================================================
AC_MSG_CHECKING([which libxslt to use])
if test -n "$with_system_libxslt" -o -n "$with_system_libs" -o \
       "$_os" = "Darwin" && \
   test "$with_system_libxslt" != "no"; then
   AC_MSG_RESULT([external])
   SYSTEM_LIBXSLT=YES

   PKG_CHECK_MODULES_MACHACK(LIBXSLT, xslt-config, libxslt)

   dnl Check for xsltproc
   AC_PATH_PROG(XSLTPROC, xsltproc, no)
   if test "$XSLTPROC" = "no"; then
      AC_MSG_ERROR([xsltproc is required])
   fi
else
   AC_MSG_RESULT([internal])
   SYSTEM_LIBXSLT=NO
   BUILD_TYPE="$BUILD_TYPE LIBXSLT"
fi
AC_SUBST(SYSTEM_LIBXSLT)
AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_LIBS)


dnl ===================================================================
dnl Check for system libxml
dnl ===================================================================
AC_MSG_CHECKING([which libxml to use])
if test -n "$with_system_libxml" -o -n "$with_system_libs" -o \
            "$_os" = "Darwin" && \
	test "$with_system_libxml" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_LIBXML=YES
    PKG_CHECK_MODULES_MACHACK(LIBXML, xml2-config, libxml-2.0 >= 2.0)
    BUILD_TYPE="$BUILD_TYPE LIBXMLSEC"
else
    AC_MSG_RESULT([internal])
    SYSTEM_LIBXML=NO
    BUILD_TYPE="$BUILD_TYPE LIBXML2 LIBXMLSEC"
fi
AC_SUBST(SYSTEM_LIBXML)
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_LIBS)

dnl ===================================================================
dnl Check for system python
dnl ===================================================================
if test "$_os" = "Darwin" && test "$with_system_python" != "no"; then
   with_system_python=yes
fi
AC_MSG_CHECKING([which python to use])
if test -n "$with_system_python" -o -n "$with_system_libs" && \
	test "$with_system_python" != "no"; then
   SYSTEM_PYTHON=YES
   AC_MSG_RESULT([external])
   AM_PATH_PYTHON([2.2])

   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_CFLAGS="-I$python_include"

   if test "$_os" = "Darwin"; then
      PYTHON_LIBS="-framework Python"
   else
      PYTHON_LIBS="-lpython$python_version"
   fi
   
   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)], [])
   CPPFLAGS="$save_CPPFLAGS"
else
   SYSTEM_PYTHON=NO
   BUILD_TYPE="$BUILD_TYPE PYTHON"
   AC_MSG_RESULT([internal])
   # Embedded python dies without Home set
   if test "z$HOME" = "z"; 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
fi
AC_SUBST(SYSTEM_PYTHON)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
HOME=`echo $HOME | sed 's:\\\\:/:g'`
AC_SUBST(HOME)

dnl ===================================================================
dnl Check for system berkley db
dnl ===================================================================
AC_MSG_CHECKING([which db to use])
if test -n "$with_system_db" -o -n "$with_system_libs" && \
	test "$with_system_db" != "no"; then
    SYSTEM_DB=YES
    AC_MSG_RESULT([external])
    AC_CHECK_HEADER(db.h, [ DB_INCLUDES=/usr/include ],
        [
             CFLAGS=-I/usr/include/db4
             AC_CHECK_HEADER(db4/db.h,
             [ DB_INCLUDES=/usr/include/db4 ],
             [ AC_MSG_ERROR(no. install the db4 libraries) ], []+             )
        ], []
    )
    AC_MSG_CHECKING([whether db is at least 4.1])
    AC_TRY_RUN([
#include <db.h>

int main(int argc, char **argv) {
       if(DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)) return 0;
       else return 1;
}
    ], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no. you need at least db 4.1])])
    AC_HAVE_LIBRARY(db, [],
      [AC_MSG_ERROR([db not installed or functional])], [])
    SCPDEFS="$SCPDEFS -DSYSTEM_DB"
else
    AC_MSG_RESULT([internal])
    SYSTEM_DB=NO
    BUILD_TYPE="$BUILD_TYPE BERKELEYDB"
fi
AC_SUBST(SYSTEM_DB)
AC_SUBST(DB_VERSION)
AC_SUBST(DB_INCLUDES)
AC_SUBST(DB_JAR)

dnl ===================================================================
dnl Check for system lucene
dnl ===================================================================
AC_MSG_CHECKING([which lucene to use])
if test -n "$with_system_lucene" -o -n "$with_system_libs" && \
       test "$with_system_lucene" != "no" && test "$with_system_jars" != "no"; then
        AC_MSG_RESULT([external])
        SYSTEM_LUCENE=YES
        if test -z $LUCENE_CORE_JAR; then
          AC_CHECK_FILE(/usr/share/java/lucene-core-2.3.jar, 
            [ LUCENE_CORE_JAR=/usr/share/java/lucene-core-2.3.jar ],
            [
              AC_CHECK_FILE(/usr/share/java/lucene.jar, 
                [ LUCENE_CORE_JAR=/usr/share/java/lucene.jar ],
                [ AC_MSG_ERROR(lucene-core.jar replacement not found)]
              )
            ]
          )
        else
          AC_CHECK_FILE($LUCENE_CORE_JAR, [],
               [AC_MSG_ERROR(lucene-core.jar not found.)], [])
        fi

        if test -z $LUCENE_ANALYZERS_JAR; then
          AC_CHECK_FILE(/usr/share/java/lucene-analyzers-2.3.jar, 
            [ LUCENE_ANALYZERS_JAR=/usr/share/java/lucene-analyzers-2.3.jar ],
            [
              AC_CHECK_FILE(/usr/share/java/lucene-contrib/lucene-analyzers.jar, 
                [ LUCENE_ANALYZERS_JAR=/usr/share/java/lucene-contrib/lucene-analyzers.jar ],
                [ AC_MSG_ERROR(lucene-analyzers.jar replacement not found.)]
              )
            ]
          )
        else
          AC_CHECK_FILE($LUCENE_CORE_JAR, [],
               [ AC_MSG_ERROR(lucene-analyzers.jar not found.)], [])
        fi
else
    AC_MSG_RESULT([internal])
    SYSTEM_LUCENE=NO
    BUILD_TYPE="$BUILD_TYPE LUCENE"
fi
AC_SUBST(SYSTEM_LUCENE)
AC_SUBST(LUCENE_CORE_JAR)
AC_SUBST(LUCENE_ANALYZERS_JAR)

AC_MSG_CHECKING([whether to build the MySQL Connector extension])
if test -n "$enable_mysql_connector" -a "$enable_mysql_connector" != "no"; then
  AC_MSG_RESULT([yes])
  ENABLE_MYSQLC=YES
  AC_MSG_CHECKING([for mysqlc module])
  if test -d mysqlc; then
   AC_MSG_RESULT([OK])
  else
   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
  fi
  BUILD_TYPE="$BUILD_TYPE MYSQLC"
else
  AC_MSG_RESULT([no])
  ENABLE_MYSQLC=NO
fi
AC_SUBST(ENABLE_MYSQLC)

if test "$ENABLE_MYSQLC" = "YES"; then
dnl ===================================================================
dnl Check for system MySQL
dnl ===================================================================
AC_MSG_CHECKING([for mysql pre-requisites])
if test -n "$with_system_mysql" -o -n "$with_system_libs" && \
       test "$with_system_mysql" != "no" && test "$with_system_libs" != "no"; 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 -n "$with_system_mysql_cppconn" -o -n "$with_system_libs" && \
		test "$with_system_mysql_cppconn" != "no" && test "$with_system_libs" != "no"; 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)], [])
   AC_MSG_CHECKING([version])
      AC_TRY_RUN([
#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++])

	AC_MSG_CHECKING([STL compatibility])
	if test "$WITH_STLPORT" != "no"; then
		AC_MSG_ERROR([to use system mysqlcppconn you need to use --without-stlport])
	else
		AC_MSG_RESULT([OK])	
	fi

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 ===================================================================
AC_MSG_CHECKING([which hsqldb to use])
if test -n "$with_system_hsqldb" -o -n "$with_system_libs" && \
       test "$with_system_hsqldb" != "no" && test "$with_system_jars" != "no"; 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.9])
        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") || $c > 0)  {
		            exit 0;
		        } else {
		            exit 1;
		        }
		    }
		}
	    } else {
	        exit 1;
            }'; then
            AC_MSG_RESULT([yes])
         else
            AC_MSG_ERROR([no, hsqldb >= 1.8.0.9 is needed])
         fi
else
    AC_MSG_RESULT([internal])
    SYSTEM_HSQLDB=NO
    BUILD_TYPE="$BUILD_TYPE HSQLDB"
fi
AC_SUBST(SYSTEM_HSQLDB)
AC_SUBST(HSQLDB_JAR)

dnl ===================================================================
dnl Check for system beanshell
dnl ===================================================================
AC_MSG_CHECKING([which beanshell to use])
if test -n "$with_system_beanshell" -o -n "$with_system_libs" && \
       test "$with_system_beanshell" != "no" && test "$with_system_jars" != "no"; 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
AC_SUBST(SYSTEM_BSH)
AC_SUBST(BSH_JAR)


dnl ===================================================================
dnl Check for system saxon
dnl ===================================================================
AC_MSG_CHECKING([which saxon to use])
if test -n "$with_system_saxon" -o -n "$with_system_libs" && \
       test "$with_system_saxon" != "no" && test "$with_system_jars" != "no"; 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
else
    AC_MSG_RESULT([internal])
    SYSTEM_SAXON=NO
    NEED_SAXON=TRUE
fi
AC_SUBST(SYSTEM_SAXON)
AC_SUBST(SAXON_JAR)

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

dnl ===================================================================
dnl Check for system curl
dnl ===================================================================
if test "$_os" = "Darwin" && test "$with_system_curl" != "no"; then
   with_system_curl=yes
fi
AC_MSG_CHECKING([which curl to use])
if test -n "$with_system_curl" -o -n "$with_system_libs" && \
	test "$with_system_curl" != "no"; then
   AC_MSG_RESULT([external])
   SYSTEM_CURL=YES

   AC_PATH_PROG( CURLCONFIG, curl-config)
   if test -z "$CURLCONFIG"; then
      AC_MSG_ERROR([install curl to run this script])
   fi

   # check curl version
   AC_MSG_CHECKING([whether curl is >= 7.13.1])
   if test "`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $1 }'`" -gt "7" -a \
	"`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $2 }'`" -gt "13" -a \
	"`$CURLCONFIG --version | $AWK -F' ' '{print $2}' | $AWK -F. '{ print $3 }'`" -gt "1"; then 
      AC_MSG_ERROR([no, you need at least curl 7.13,1])
   else
      AC_MSG_RESULT([yes])
   fi
   CURL_LIBS=`$CURLCONFIG --libs`
   CURL_CFLAGS=`$CURLCONFIG --cflags`
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)

dnl ===================================================================
dnl Check for system boost
dnl ===================================================================
AC_MSG_CHECKING([which boost to use])
if test -n "$with_system_boost" -o -n "$with_system_headers" && \
	test "$with_system_boost" != "no"; 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.38)], [])
   AC_CHECK_HEADER(boost/function.hpp, [],
       [AC_MSG_ERROR(boost/function.hpp not found. install boost)], [])

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

   if test "$ac_cv_cxx_boost_no_exceptons_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
fi
AC_SUBST(SYSTEM_BOOST)

dnl ===================================================================
dnl Check for system vigra
dnl ===================================================================
AC_MSG_CHECKING([which vigra to use])
if test -n "$with_system_vigra" -o -n "$with_system_headers" && \
	test "$with_system_vigra" != "no"; 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 -n "$with_system_odbc_headers" -o -n "$with_system_headers" && \
	test "$with_system_odbc_headers" != "no"; then
   AC_MSG_RESULT([external])
   SYSTEM_ODBC_HEADERS=YES

   AC_CHECK_HEADER(sqlext.h, [],
      [AC_MSG_ERROR(odbc not found. install odbc)], [])
else
   AC_MSG_RESULT([internal])
   SYSTEM_ODBC_HEADERS=NO
   BUILD_TYPE="$BUILD_TYPE UNIXODBC"
fi
AC_SUBST(SYSTEM_ODBC_HEADERS)

AC_MSG_CHECKING([whether to enable build of Mozilla/Mozilla NSS-using components])
if test "$enable_mozilla" = "no"; then
   AC_MSG_RESULT([no])
   WITH_MOZILLA=NO
   ENABLE_NSS_MODULE=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_mozilla" = "no"; then
   AC_MSG_RESULT([no, since Mozilla (NSS) disabled but needed])
else
   AC_MSG_RESULT([yes])
fi

AC_MSG_CHECKING([whether to build LDAP configuration backend])
if test -z "$enable_ldap" || test "$enable_ldap" = "yes"; then
   if test "$enable_mozilla" = "yes" || test "$with_openldap" = "yes"; then
      AC_MSG_RESULT([yes])
      WITH_LDAP=YES
   else
      AC_MSG_RESULT([no. Either Mozilla or OpenLDAP needed])
      WITH_LDAP=NO
   fi
else
   AC_MSG_RESULT([no])
   WITH_LDAP=NO
fi

if test "$WITH_LDAP" = "YES"; then
   dnl ===================================================================
   dnl Test whether we want to use the Mozilla or the OpenLDAP LDAP SDK
   dnl ===================================================================
   AC_MSG_CHECKING([which LDAP SDK to use])
   if test -n "$with_openldap" && test "$with_openldap" != "no"; then
  	   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)], [])
	   # rumours say that OpenLDAP doesn't have that function. I looked and
	   # it has it. Test for it to be sure
         AC_CHECK_LIB(ldap, ldap_set_option, [],
                [AC_MSG_ERROR(openldap lib not found or functional)], [])
   else
	   AC_MSG_RESULT([Netscape/Mozilla])
	   # TODO. Actually do a sanity check and check for
	   # LDAP_OPT_SIZELIMIT and LDAP_X_OPT_CONNECT_TIMEOUT 
	   WITH_OPENLDAP=NO
   fi
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" && test "$with_system_mozilla" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_MOZILLA=YES
    ENABLE_NSS_MODULE=NO
    enable_nss_module=no
    AC_MSG_CHECKING([which Mozilla flavour to use])
    if test -n "$with_system_mozilla" && test "$with_system_mozilla" = "libxul"; then
      MOZ_FLAVOUR=libxul
    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "xulrunner"; then
      MOZ_FLAVOUR=xulrunner
    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "seamonkey"; then
      MOZ_FLAVOUR=seamonkey
    elif test -n "$with_system_mozilla" && test "$with_system_mozilla" = "firefox"; then
      MOZ_FLAVOUR=firefox
    elif test -n "$with_system_mozilla" && test "$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)

    PKG_CHECK_MODULES( MOZ_NSS, nss, STANDALONENSS="TRUE", STANDALONENSS="" )
    if test -z "$STANDALONENSS"; then
        PKG_CHECK_MODULES( MOZ_NSS, $MOZ_FLAVOUR-nss )
    else
        NSS_LIB="-L`$PKG_CONFIG --variable=libdir nss`"
        AC_SUBST(NSS_LIB)
    fi

    if $PKG_CONFIG --exists nspr ; then
      PKG_CHECK_MODULES( MOZ_NSPR, nspr )
      NSPR_LIB="-L`$PKG_CONFIG --variable=libdir nspr`"
      AC_SUBST(NSPR_LIB)
    else
      PKG_CHECK_MODULES( MOZ_NSPR, $MOZ_FLAVOUR-nspr )
    fi

    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

    save_CPPFLAGS="$CPPFLAGS"
    save_LDFLAGS="$LDFLAGS"
    save_LIBS="$LIBS"
    CPPFLAGS="$CPPFLAGS $MOZ_NSS_CFLAGS"
    LDFLAGS="$LDFLAGS $MOZ_NSS_LIBS"
    AC_CHECK_LIB(nss3, PK11_GetCertFromPrivateKey, [], 
      [AC_MSG_ERROR(PK11_GetCertFromPrivateKey missing but needed.
See https://bugzilla.mozilla.org/show_bug.cgi?id=262274.
Fixed since nss 3.9.3 (contained by e.g. mozilla >= 1.7.5))], [])
    LDFLAGS="$save_LDFLAGS"
    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"

    MOZ_LIB_XPCOM=$MOZILLAXPCOM_LIBS
    if test "$WITH_LDAP" != "NO" && test "$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
    ENABLE_NSS_MODULE=NO
    enable_nss_module=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
#if test "$_os" = "Darwin" && test "$MOZILLA_TOOLKIT" != "gtk2"; then
#   #only gtk2 toolkit supported - xlib or cocoa nees glib1 and libIDL1 - the latter is not
#   #available using fink, mac (carbon) doesn't work because xcode installs conflicting headers
#   AC_MSG_ERROR([Only gtk2 toolkit supported on Mac, sorry.])
#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

AC_MSG_CHECKING([whether to build provided NSS module])
if test "$enable_nss_module" != "no"; then
   ENABLE_NSS_MODULE="YES"
   BUILD_TYPE="$BUILD_TYPE NSS"
   AC_MSG_RESULT([yes])
   if test "$_os" = "WINNT"; then
      AC_MSG_CHECKING([for Mozilla build tooling])
      if test -z "$MOZILLABUILD" ; then
AC_MSG_ERROR([Mozilla build tooling not found.
Use the --with-mozilla-build option after installling the tools obtained
from http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32])
      else
         if test \( "$WITH_MINGWIN" = "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
else
   ENABLE_NSS_MODULE="NO"
   AC_MSG_RESULT([no])
fi

if test "$BUILD_MOZAB" = "TRUE"; then
  if test "$_os" = "WINNT"; then
    if test "$WITH_MINGWIN" != "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 .NET 2005 only.])
      fi
    else
      AC_MSG_WARN([Building SeaMonkey with mingwin is not tested, and likely to break.])
      echo "Building SeaMonkey with mingwin 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"
   for e in gz bz2; do
      AC_MSG_CHECKING([for $MOZILLA_SOURCE_VERSION.tar.$e])
      if test ! -e "moz/download/$MOZILLA_SOURCE_VERSION.tar.$e" && test "$HAVE_MOZILLA_TARBALL" != "y"; then
         AC_MSG_RESULT([not found])
         HAVE_MOZILLA_TARBALL=n
      else
         AC_MSG_RESULT([found])
         HAVE_MOZILLA_TARBALL=y
      fi
   done
   if test "$HAVE_MOZILLA_TARBALL" != "y"; then
         AC_MSG_ERROR([Mozilla/SeaMonkey source archive not found.
Please copy $MOZILLA_SOURCE_VERSION.tar.bz2 or $MOZILLA_SOURCE_VERSION.tar.gz to moz/download/.
The archives can be found here:
ftp://ftp.mozilla.org/pub/mozilla.org/seamonkey/releases/$MOZILLA_VERSION/])
   fi
   if test "$_os" = "WINNT"; then
      AC_MSG_CHECKING([for moztools binaries])
      if test ! -e "moz/download/vc8-moztools.zip" ; then
        AC_MSG_ERROR([The following file is missing in moz/download: 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
      if test "$MOZILLA_TOOLKIT" = "gtk2"; then
         AC_MSG_NOTICE([checking whether mozilla can be built...])
         PKG_CHECK_MODULES(MOZGTK2, gtk+-2.0 >= 2.4 libIDL-2.0 >= 0.8, AC_MSG_NOTICE([OK - can build mozilla]), AC_MSG_ERROR([Prerequisites to build mozilla not met. Either use the precompiled mozilla binaries or install the missing packages]))
      else
         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
      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
fi

AC_SUBST(BUILD_MOZAB)

fi
AC_SUBST(ENABLE_NSS_MODULE)
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_NSPR_CFLAGS)
AC_SUBST(MOZ_NSS_CFLAGS)
AC_SUBST(MOZ_LDAP_CFLAGS)

dnl ===================================================================
dnl Check for system sane
dnl ===================================================================
AC_MSG_CHECKING([which sane header to use])
if test -n "$with_system_sane_header" -o -n "$with_system_headers" && \
	test "$with_system_sane_header" != "no"; 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 ===================================================================
AC_MSG_CHECKING([which icu to use])
if test -n "$with_system_icu" -o -n "$with_system_libs" && \
	test "$with_system_icu" != "no"; then
   AC_MSG_RESULT([external])
   SYSTEM_ICU=YES
   AC_LANG_PUSH([C++])
   AC_MSG_CHECKING([for unicode/rbbi.h])
   AC_TRY_CPP(unicode/rbbi.h, AC_MSG_RESULT([checked.]), AC_MSG_ERROR([icu headers not found.]))
   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])
   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])
   if test -z "$SYSTEM_GENCMN"; then
      AC_MSG_ERROR([\"gencmn\" not found in \$PATH, install the icu development tool \"gencmn"\])
   fi
   AC_MSG_CHECKING([ICU version])
      AC_TRY_RUN([
#include <unicode/uversion.h>

int main(int argc, char **argv) {
      if(U_ICU_VERSION_MAJOR_NUM < 4)
        return 1;
      else
        return 0;
}
      ], [AC_MSG_RESULT(OK)], [AC_MSG_ERROR([not suitable, only >= 4.0 supported currently])])
      AC_LANG_POP([C++])
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)

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

AC_MSG_CHECKING([whether to enable graphite support])
if test "$_os" = "WINNT" -o "$_os" = "Linux" && test "z$enable_graphite" == "z" -o "$enable_graphite" != "no" ; then
    AC_MSG_RESULT([yes])
    ENABLE_GRAPHITE="TRUE"
    AC_MSG_CHECKING([which graphite to use])
    if test -n "$with_system_graphite" -o -n "$with_system_libs" && \
        test "$with_system_graphite" != "no"; then
        AC_MSG_RESULT([external])
        SYSTEM_GRAPHITE=YES
        PKG_CHECK_MODULES( GRAPHITE, silgraphite )
    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)

dnl ===================================================================
dnl Checks for libraries.
dnl ===================================================================
dnl Check for Mac OS X native GUI, which may is now required; the X11 build is no longer supported
dnl See if we have the AppKit framework for building with Quartz graphics.

if test  "$_os" = "Darwin"; then
   if test "x$with_x" = "xyes"; then
      AC_MSG_ERROR([X11 build is no longer supported on MacOSX, please use the native aqua build])
   else
      AC_MSG_CHECKING([for /System/Library/Frameworks/AppKit.framework])
      if test -d "/System/Library/Frameworks/AppKit.framework/"; then
         AC_MSG_RESULT([yes])
         x_includes="no_x_includes"
         x_libraries="no_x_libraries"
         dnl disable some things used on other Unix versions but not on the aqua build
         enable_gtk=no
         enable_cups=no
         ENABLE_CUPS=""
         AC_SUBST(ENABLE_CUPS)
      else
         AC_MSG_ERROR([No AppKit.framewrok found])
      fi
   fi
fi

dnl ***************************************
dnl testing for X libraries and includes...
dnl ***************************************
if test "$_os" = "Darwin" -a "x$x_includes" = "xno_x_includes"; then
   echo "Do Nothing for _os = Darwin"
   dnl Mac OS X using Aqua graphics. Don't check for X11.
   :
elif test "$_os" = "OS2" ; then
   echo "Do Nothing for _os = OS2. Don't check for X11."
   dnl OS/2 uses native graphics. Don't check for X11.
   :
elif test "$_os" != "WINNT" ; 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=$X_CFLAGS
   LDFLAGS="$X_LDFLAGS $X_LIBS"
   AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", [AC_MSG_ERROR([X Development libraries not found])])
   dnl Check if the XauDisposeAuth symbol is provided by libXau.
   AC_CHECK_LIB(Xau, XauDisposeAuth, XAU_LIBS="-lXau", [])
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
AC_SUBST(XLIB)
AC_SUBST(XAU_LIBS)

if test "$_os" != "WINNT" -a "$_os" != "OS2" -a "$_os" != "Darwin"; then
   dnl ===================================================================
   dnl Check for using Xaw
   dnl ===================================================================
   AC_MSG_CHECKING([whether to use Xaw])
   if test "$enable_Xaw" = "no"; then
       DISABLE_XAW=TRUE
       AC_MSG_RESULT([no])
       AC_CHECK_HEADERS(X11/Composite.h,[],[AC_MSG_ERROR([Xt include headers not found])],
         [#include <X11/Intrinsic.h>])
   else
       AC_MSG_RESULT([yes])
       AC_CHECK_HEADERS(X11/Xaw/Label.h,[],[AC_MSG_ERROR([Xaw include headers not found])],
         [#include <X11/Intrinsic.h>])
       AC_CHECK_LIB(Xaw, main, [],
           [AC_MSG_ERROR(Xaw library not found or functional)], [])
   fi
fi
AC_SUBST(DISABLE_XAW)



dnl ===================================================================
dnl Check if fontconfig/fontconfig.h is available 
dnl ===================================================================
if test "$ENABLE_FONTCONFIG" = "TRUE" ; then
    AC_CHECK_HEADER(fontconfig/fontconfig.h, [],
                    [AC_MSG_ERROR([fontconfig/fontconfig.h could not be found. libfontconfig1-dev or fontconfig???-devel missing?])], [])
    AC_MSG_CHECKING([whether fontconfig is >= 2.2.0])
    AC_TRY_RUN([
#include <fontconfig/fontconfig.h>

int main(int argc, char **argv) {
	if(FC_MAJOR > 2 || (FC_MAJOR == 2 && FC_MINOR >= 2)) return 0;
	else return 1;
}
], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, fontconfig >= 2.2.0 needed])])
fi

dnl ===================================================================
dnl Check for system Xrender
dnl ===================================================================
AC_MSG_CHECKING([whether to link to Xrender])
if test -n "$enable_xrender_link" -a "$enable_xrender_link" != "no"; then
   AC_MSG_RESULT([yes])
   XRENDER_LINK=YES
   with_system_xrender_headers=yes
else
   AC_MSG_RESULT([no, dynamically open it])
   XRENDER_LINK=NO
fi
AC_MSG_CHECKING([which Xrender headers to use])
if test -n "$with_system_xrender_headers" -o -n "$with_system_headers" && \
	test "$with_system_xrender_headers" != "no"; then
   AC_MSG_RESULT([external])
   SYSTEM_XRENDER_HEADERS=YES
   AC_CHECK_HEADER(X11/extensions/Xrender.h, [],
      [AC_MSG_ERROR(Xrender not found. install X)], [])
else
   AC_MSG_RESULT([internal])
   SYSTEM_XRENDER_HEADERS=NO
   BUILD_TYPE="$BUILD_TYPE X11_EXTENSIONS"
fi
if test "$XRENDER_LINK" = "YES"; then
   AC_CHECK_LIB(Xrender, XRenderQueryVersion, [],
      [AC_MSG_ERROR(libXrender not found or functional)], [])
fi
AC_SUBST(SYSTEM_XRENDER_HEADERS)
AC_SUBST(XRENDER_LINK)

dnl ===================================================================
dnl Check for XRandr
dnl ===================================================================
AC_MSG_CHECKING([whether to enable RandR support])
if test "$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([resorting to dlopen libXrandr at runtime])
   else
	  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"
	     AC_MSG_RESULT([enabling RandR support])
      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 -n "$with_system_neon" -o -n "$with_system_libs" && \
	test "$with_system_neon" != "no"; then
        AC_MSG_RESULT([external])
        PKG_CHECK_MODULES(NEON, neon >= 0.24.0, , AC_MSG_ERROR([you need neon >= 0.24.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
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)
fi

dnl ===================================================================
dnl Check for system openssl
dnl ===================================================================
if test "$_os" = "Darwin" && test "$with_system_openssl" != "no"; then
   with_system_openssl=yes
fi
AC_MSG_CHECKING([which libssl to use])
if test -n "$with_system_openssl" -o -n "$with_system_libs" && \
        test "$with_system_openssl" != "no"; 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"; then
        OPENSSL_CFLAGS=
        OPENSSL_LIBS="-lssl -lcrypto"
    else
    	PKG_CHECK_MODULES( OPENSSL, openssl )
    fi
    SYSTEM_OPENSSL=YES
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)

dnl ===================================================================
dnl Test for disabling agg
dnl ===================================================================
AC_MSG_CHECKING([whether to enable agg])
if test "$with_agg" = "no"; then
  AC_MSG_RESULT([no])
else
  AC_MSG_RESULT([yes])
  ENABLE_AGG=YES
  AC_SUBST(ENABLE_AGG)

  dnl ===================================================================
  dnl Check for system AGG
  dnl ===================================================================
  AC_MSG_CHECKING([which AGG to use])
  if test -n "$with_system_agg" -o -n "$with_system_libs" && \
     test "$with_system_agg" != "no"; then
         AC_MSG_RESULT([external])
         PKG_CHECK_MODULES(AGG, libagg >= 2.3)
         AC_MSG_CHECKING([agg version])
         # workaround; if AGG_CFLAGS is empty (broken libagg.pc in 2.3), add /usr/include/agg2 anyway
         # (/usr/include gets stripped from pkg-config output)
         if test -z "$AGG_CFLAGS" || test "$AGG_CFLAGS" = " "; then
            AGG_INCDIR="`$PKG_CONFIG --variable includedir libagg`/agg2"
         else
            AGG_INCDIR="`echo $AGG_CFLAGS | $SED -e s/-I//`"
         fi
	 if $PKG_CONFIG --modversion libagg | grep -q 2.3 || \
	 	$PKG_CONFIG --modversion libagg | grep -q 2.4; then
            # 2.4's libagg.pc.in still contains 2.3 :/
            if $EGREP -q "Version 2.4" `echo $AGG_INCDIR`/agg_basics.h; then
               AC_MSG_RESULT([2.4])
               AGG_VERSION=2400
            else
               AC_MSG_RESULT([2.3])
               AGG_VERSION=2300
            fi
            SYSTEM_AGG=YES
	 else
	    AC_MSG_ERROR([only agg 2.3 and 2.4 are supported])
	 fi
  else
         AC_MSG_RESULT([internal])
         SYSTEM_AGG=NO
         AGG_VERSION=2300
         BUILD_TYPE="$BUILD_TYPE AGG"
  fi
  AC_SUBST(SYSTEM_AGG)
  AC_SUBST(AGG_VERSION)
fi

dnl ===================================================================
dnl Check for system redland
dnl ===================================================================
AC_MSG_CHECKING([which redland library to use])
dnl if test -n "$with_system_redland" -o -n "$with_system_libs" && \
dnl	test "$with_system_redland" != "no"; then
dnl mst: NOTE: right now we need patches against redland
dnl            so we only enable system redland if explicitly requested
dnl            if next version includes patches, insert version check here
if test -n "$with_system_redland" && \
	test "$with_system_redland" != "no"; then
	AC_MSG_RESULT([external])
	SYSTEM_REDLAND=YES
	PKG_CHECK_MODULES(REDLAND, redland)
else
	AC_MSG_RESULT([internal])
	BUILD_TYPE="$BUILD_TYPE REDLAND"
	SYSTEM_REDLAND=NO
fi
AC_SUBST(SYSTEM_REDLAND)
AC_SUBST(REDLAND_LIBS)

dnl ===================================================================
dnl Check for system hunspell
dnl ===================================================================
AC_MSG_CHECKING([which libhunspell to use])
if test -n "$with_system_hunspell" -o -n "$with_system_libs" && \
	test "$with_system_hunspell" != "no"; 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++])
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)

dnl ===================================================================
dnl Checking for altlinuxhyph
dnl ===================================================================
AC_MSG_CHECKING([which altlinuxhyph to use])
if test -n "$with_system_altlinuxhyph" -o -n "$with_system_libs" && \
	test "$with_system_altlinuxhyph" != "no"; 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
else
    AC_MSG_RESULT([internal])
    SYSTEM_HYPH=NO
    BUILD_TYPE="$BUILD_TYPE HYPHEN"
fi
AC_SUBST(SYSTEM_HYPH)
AC_SUBST(HYPHEN_LIB)

dnl ===================================================================
dnl Checking for mythes
dnl ===================================================================
AC_MSG_CHECKING([which mythes to use])
if test -n "$with_system_mythes" && test "$with_system_mythes" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_MYTHES=YES
    AC_CHECK_HEADER(mythes.hxx, [],
       [ AC_MSG_ERROR(mythes.hxx headers not found.)], [])
    AC_CHECK_LIB(mythes, main, [],
        [ AC_MSG_ERROR(mythes library not found.)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_MYTHES=NO
fi
AC_SUBST(SYSTEM_MYTHES)

dnl ===================================================================
dnl Checking for lpsolve
dnl ===================================================================
AC_MSG_CHECKING([which lpsolve to use])
if test -n "$with_system_lpsolve" -o -n "$with_system_libs" && \
	test "$with_system_lpsolve" != "no"; then
    AC_MSG_RESULT([external])
    SYSTEM_LPSOLVE=YES
    AC_CHECK_HEADER(lpsolve/lp_lib.h, [],
       [ AC_MSG_ERROR(lpsolve headers not found.)], [])
    AC_CHECK_LIB(lpsolve55, make_lp, ,
        [ AC_MSG_ERROR(lpsolve library not found or too old.)], [])
else
    AC_MSG_RESULT([internal])
    SYSTEM_LPSOLVE=NO
    BUILD_TYPE="$BUILD_TYPE LPSOLVE"
fi
AC_SUBST(SYSTEM_LPSOLVE)

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

dnl =========================================
dnl Check for the Microsoft Platform SDK.
dnl =========================================
dnl FIXME: I don't know yet if PSDK works with MinGW, keep it until I know better,
dnl and add "-a \( "$WITH_MINGWIN" != "yes" \)" then
if test \( "$_os" = "WINNT" \) ; then
	AC_MSG_CHECKING([for PSDK files])
	if test -z "$with_psdk_home"; then
		# This first line will detect a February 2003 Microsoft Platform SDK
		PSDK_HOME=`./oowintool --psdk-home`
        # But there might be also an April 2005 PSDK, unfortunately MS changed
        # the registry entry. (we prefer the old version!?)
        if test -z "$PSDK_HOME"; then
          PSDK_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 "$PSDK_HOME"; then
              PSDK_HOME=`cygpath -d "$PSDK_HOME"`
              PSDK_HOME=`cygpath -u "$PSDK_HOME"`
           fi
	else
           PSDK_HOME=`cygpath -u "$with_psdk_home"`
	fi
        # Remove a possible trailing backslash
        PSDK_HOME=`echo $PSDK_HOME | $SED 's/\/$//'`
    # Problem with current PSDK (iz 49865)
    if test -f "$PSDK_HOME/Lib/libcp.lib"; then
        AC_MSG_ERROR([

Some modules do not build correctly with MS Platform SDK - April 2005
Edition if the library ($PSDK_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
# WIndows SDK has different headers
	if test \( -f "$PSDK_HOME/Include/adoint.h" \) \
		 -a \( -f "$PSDK_HOME/Include/SqlUcode.h" \) \
		 -a \( -f "$PSDK_HOME/Include/usp10.h" \); then
		HAVE_PSDK_H="yes"
	else
		HAVE_PSDK_H="no"
	fi
	if test -f "$PSDK_HOME/lib/unicows.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?) PSDK files not found, please check if all needed Platform SDKs
are installed or use --with-psdk-home .])
    fi
    if test ! -x "$PSDK_HOME/bin/msiinfo.exe" \
         -o ! -x "$PSDK_HOME/bin/msidb.exe" \
         -o ! -x "$PSDK_HOME/bin/uuidgen.exe" \
         -o ! -x "$PSDK_HOME/bin/msitran.exe" ; then
        AC_MSG_ERROR([Some (all) files of the Windows Installer SDK are missing, please install.])
    fi
    AC_MSG_RESULT([SDK files found ...)])
dnl Check if this is the right SDK.
    if echo $PSDK_HOME | grep "v6.1" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([Found Windows SDK 6.1 ($PSDK_HOME)])
        WINDOWS_VISTA_PSDK=TRUE
    elif echo $PSDK_HOME | grep "v6.0" >/dev/null 2>/dev/null; then
        AC_MSG_RESULT([Found Windows SDK 6.0 ($PSDK_HOME)])
        WINDOWS_VISTA_PSDK=TRUE
    else
        AC_MSG_RESULT([Found Legacy Windows Platform SDK ($PSDK_HOME)])
    fi
fi
AC_SUBST(PSDK_HOME)
AC_SUBST(WINDOWS_VISTA_PSDK)

dnl =========================================
dnl Check for the Microsoft DirectX SDK.
dnl =========================================
if test \( "$_os" = "WINNT" \) ; then
    AC_MSG_CHECKING([for DirectX SDK files])
    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 files 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/\/$//'`

    if test -f "$DIRECTXSDK_HOME/Include/ddraw.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
    if test -f "$DIRECTXSDK_LIB/ddraw.lib" ; then
        HAVE_DIRECTXSDK_LIB="yes"
    else
        HAVE_DIRECTXSDK_LIB="no"
    fi
    if test -n "$ENABLE_DIRECTX"; then
	    if test "$HAVE_DIRECTXSDK_H" = "yes" -a "$HAVE_DIRECTXSDK_LIB" = "yes"; then
		    AC_MSG_RESULT([found])
	    else
		    AC_MSG_ERROR([DirectX SDK files not found, please use --with-directx-home or -disable-directx.])
	    fi
    else
		DIRECTXSDK_HOME=""
		AC_MSG_RESULT([disabled])
    fi
fi
AC_SUBST(DIRECTXSDK_HOME)
AC_SUBST(DIRECTXSDK_LIB)

dnl ============================================
dnl Check for Nullsoft Scriptable Install System
dnl ============================================
NSIS_PATH=""
if test "$_os" = "WINNT" ; then
    AC_MSG_CHECKING([for NSIS])
    AC_PATH_PROG(NSIS_PATH, nsis.exe)
    if test -n "$NSIS_PATH"; then
        NSIS_PATH=`dirname "$NSIS_PATH"`
    fi
    if test -n "$with_nsis_path"; then
        with_nsis_path=`cygpath -u "$with_nsis_path"`
    fi
    if test -e "$with_nsis_path/nsis.exe"; then
        NSIS_PATH="$with_nsis_path"
    fi
    nsistest=`./oowintool --nsis-dir`;
    if test -x "$nsistest/nsis.exe"; then
        NSIS_PATH="$nsistest"
    fi
    if test -z "$NSIS_PATH"; then
        AC_MSG_WARN([NSIS not found, no self contained installer will be build.])
        echo "NSIS not found, no self contained installer will be build." >> warn
    else
        NSIS_PATH=`cygpath -d "$NSIS_PATH"`
        NSIS_PATH=`cygpath -u "$NSIS_PATH"`
        AC_MSG_RESULT([found ($NSIS_PATH)])
    fi
fi
AC_SUBST(NSIS_PATH)

dnl ***************************************
dnl testing bison and flex exist
dnl ***************************************
AC_PATH_PROG(BISON, bison)
if test -z "$BISON"; then
   AC_MSG_ERROR([no bison found in \$PATH, install bison])
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
fi
AC_PATH_PROG(FLEX, flex)
if test -z "$FLEX"; then
   AC_MSG_ERROR([no flex found in \$PATH, install flex])
fi
dnl ***************************************
dnl testing that patch exists
dnl ***************************************
AC_PATH_PROG(PATCH, patch)
if test -z "$PATCH"; then
   AC_MSG_ERROR([\"patch\" not found in \$PATH, install the development tool named\"patch"\])
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

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

  if test -z "$with_gnu_cp"; then
    AC_PATH_PROGS(GNUCP, gnucp cp)
    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])
  if $GNUCP --version 2>/dev/null | grep "Free Software Foundation" >/dev/null 2>/dev/null; then
	AC_MSG_RESULT([yes])
  else
   if $GNUCP --version 2>/dev/null | grep "GNU fileutils" >/dev/null 2>/dev/null; then
	AC_MSG_RESULT([yes])
   else
      if test "$_os" = "Darwin"; then
         GNUCP=''
         AC_MSG_RESULT([no gnucp found - using the system's cp command])
      else      
         AC_MSG_ERROR([no, GNU cp needed. install or specify with --with-gnu-cp=/path/to/it])
      fi
   fi
  fi	

fi
AC_SUBST(GNUPATCH)
AC_SUBST(GNUCP)

dnl ***************************************
dnl testing bash tools path on Windows
dnl ***************************************
if test "$_os" = "WINNT"; then
    CYGWIN_PATH=""
    AC_PATH_PROG(CYGWIN_PATH, bash)
    CYGWIN_PATH=`dirname "$CYGWIN_PATH"`
fi
if test -z "$CYGWIN_PATH"; then
   CYGWIN_PATH="NO_CYGWIN"
fi
AC_SUBST(CYGWIN_PATH)

dnl ***************************************
dnl testing ml.exe assembler path
dnl ***************************************
if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
  AC_MSG_CHECKING([ml.exe assembler path])
  if test -n "$with_asm_home"; then
    with_asm_home=`cygpath -u "$with_asm_home"`
  fi
  if test ! -x "$with_asm_home/ml.exe"; then
    AC_PATH_PROG(ML_EXE, ml.exe)
    if test -z "$ML_EXE"; then
      if test -x "$with_cl_home/bin/ml.exe"; then
        with_asm_home=$with_cl_home/bin
        AC_MSG_RESULT([found ($with_asm_home)])
      else
        AC_MSG_ERROR([Configure did not find ml.exe assembler.])
      fi
    else
       with_asm_home="ASM_IN_PATH"
    fi
  fi
else
	with_asm_home="NO_ASM_HOME"
fi
ASM_HOME="$with_asm_home"
if test -n "$ASM_HOME"; then
  AC_MSG_RESULT([$ASM_HOME])
fi
AC_SUBST(ASM_HOME)
 
dnl ===================================================================
dnl testing handle deprecated unzip switch
dnl ===================================================================
if test -z "$with_zip_home"; then
	with_zip_home="$with_unzip_home"
fi
dnl ===================================================================
dnl Zip will be found where you tell me to find it
dnl ===================================================================
if test -n "$with_zip_home" ; then
    if test "$_os" = "WINNT"; then
        with_zip_home=`cygpath -u "$with_zip_home"`
    fi
    ZIP="$with_zip_home/zip"
    UNZIP="$with_zip_home/unzip"
    ZIP_HOME="$with_zip_home"
else
    AC_PATH_PROG(ZIP, zip)
    AC_PATH_PROG(UNZIP, unzip)
    ZIP_HOME=`dirname "$ZIP"`
fi
dnl ===================================================================
dnl Zip must be available or else it is an error, all platforms
dnl ===================================================================
if test -z "$ZIP" -o -z "$UNZIP"; then
    AC_MSG_ERROR([Zip/Unzip are required to build, please install or use --with-zip-home],,)
fi

dnl ===================================================================
dnl Zip must be a specific type for different build types.
dnl ===================================================================
if test "$_os" = "WINNT"; then
    if test -n "`$ZIP -h | grep -i WinNT`" ; then
AC_MSG_ERROR([$ZIP found in the path is not the required cygwin version of Info-ZIPs zip.exe.])
    fi
fi
AC_SUBST(ZIP_HOME)

dnl ===================================================================
dnl Windows builds need unicows.dll in external/unicows/
dnl ===================================================================
if test "$_os" = "WINNT"; then
   AC_MSG_CHECKING([for unicows.dll])
   if test -x ./external/unicows/unicows.dll; then
      AC_MSG_RESULT([found])
   else
      AC_MSG_ERROR([The Microsoft Layer for Unicode (unicows.dll) is missing in external/unicows/.
Get it from the Microsoft site and put it into external/unicows.
(Note: Microsoft seems to enjoy changing the exact location of this file. You
may have to search Microsoft's website.) Last time it was seen at:
<http://download.microsoft.com/download/b/7/5/b75eace3-00e2-4aa0-9a6f-0b6882c71642/unicows.exe>.])
   fi
fi

dnl ===================================================================
dnl Windows builds need dbghelp.dll in external/dbghelp/
dnl ===================================================================
if test "$_os" = "WINNT"; then
   AC_MSG_CHECKING([for dbghelp.dll])
   if test -x ./external/dbghelp/dbghelp.dll; then
      AC_MSG_RESULT([found])
   else
      AC_MSG_ERROR([dbghelp.dll is missing in external/dbghelp/.
Get it from the Microsoft site and put it into external/dbghelp.
(Note: Microsoft seems to enjoy changing the exact location of this file. You
may have to search Microsoft's website.) Last time it was seen at:
<http://www.microsoft.com/downloads/release.asp?releaseid=30682>.])
   fi
fi

dnl ===================================================================
dnl Windows builds - use oowintool to copy CRT dlls and manifest
dnl ===================================================================
if test "$_os" = "WINNT" -a "$WITH_MINGWIN" != "yes"; then
       if ./oowintool --msvc-copy-dlls ./external/msvcp ; then
          :
       else
          AC_MSG_ERROR([oowintool failed to copy CRT])
       fi
fi

dnl ===================================================================
dnl Windows builds need gdiplus.dll in external/gdiplus/
dnl ===================================================================
if test "$_os" = "WINNT"; then
   AC_MSG_CHECKING([for gdiplus.dll])
   if test -x ./external/gdiplus/gdiplus.dll; then
      AC_MSG_RESULT([found])
   else
      AC_MSG_ERROR([gdiplus.dll is missing in external/gdiplus/.
Get it from the Microsoft site and put it into external/gdiplus.
You may have to search Microsoft's website. Last time it was seen at:
<http://www.microsoft.com/downloads/details.aspx?familyid=6A63AB9C-DF12-4D41-933C-BE590FEAA05A&displaylang=en>.])
   fi
fi

dnl ===================================================================
dnl Windows builds - attempt to auto-copy required instmsiX.exe into external/
dnl ===================================================================
if test "$_os" = "WINNT"; then
       ./oowintool --msvc-copy-instmsi ./external/msi
fi

dnl ===================================================================
dnl Windows builds with VS 2003/2005/2008 need instmsia.exe and instmsiw.exe in external/msi
dnl ===================================================================
if test "$_os" = "WINNT"; then
   if test  "$WITH_MINGWIN" = "yes" || test "$COMEX" -ge "10"; then
   AC_MSG_CHECKING([for instmsia.exe/instmsiw.exe])
   if test -x ./external/msi/instmsia.exe -a -x ./external/msi/instmsiw.exe; then
      AC_MSG_RESULT([found])
   else
      MSIAPATH=`/bin/find "$COMPATH/.." -iname instmsia.exe | head -n 1`
      MSIWPATH=`/bin/find "$COMPATH/.." -iname instmsiw.exe | head -n 1`
      if test -n "$MSIAPATH" -a -n "$MSIWPATH"; then
         cp "$MSIAPATH" ./external/msi/ && chmod +x ./external/msi/instmsia.exe && MSIACOPY="OK"
         cp "$MSIWPATH" ./external/msi/ && chmod +x ./external/msi/instmsiw.exe && MSIWCOPY="OK"
      fi
      if test -z "$MSIACOPY" -o -z "$MSIWCOPY"; then
         AC_MSG_ERROR([instmsia.exe and/or instmsiw.exe are/is missing in the default location.
These programs are part of the Visual Studio installation and should be found in a
directory similar to:
"c:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools\\Deployment\\MsiRedist\\"
As the automatic detection fails please copy the files to external/msi/.])
      else
         AC_MSG_RESULT([found and copied])
      fi
   fi
fi
fi

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

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)

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 "$_os" != "OS2" -a "$enable_gconf" = "yes"; then
    ENABLE_GCONF="TRUE"
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES( GCONF, gconf-2.0 )
else
    AC_MSG_RESULT([no])
fi
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"; then
    ENABLE_GNOMEVFS="TRUE"
    AC_MSG_RESULT([yes])
    PKG_CHECK_MODULES( GNOMEVFS, gnome-vfs-2.0 >= 2.6.0 )
    if test "$ENABLE_GCONF" != "TRUE"; then
        PKG_CHECK_MODULES( GCONF, gconf-2.0 )
    fi
else
    AC_MSG_RESULT([no])
fi
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=""
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]))
      BUILD_TYPE="$BUILD_TYPE GTK"

      if test "x$enable_systray" = "xyes"; then
         ENABLE_SYSTRAY_GTK="TRUE"
         BUILD_TYPE="$BUILD_TYPE SYSTRAY_GTK"
      fi

      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(ENABLE_DBUS)
AC_SUBST(ENABLE_SYSTRAY_GTK)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

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

ENABLE_CAIRO=""
BUILD_PIXMAN=""
SYSTEM_CAIRO=""

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

    AC_MSG_CHECKING([whether to use cairo])
    if test "x$enable_cairo" != "xno" ; then
        ENABLE_CAIRO="TRUE"
	AC_MSG_RESULT([yes])
        AC_MSG_CHECKING([which cairo to use])
        if test -n "$with_system_cairo" -o -n "$with_system_libs" && \
           test "$with_system_cairo" != "no"; then
           AC_MSG_RESULT([external])
           SYSTEM_CAIRO=YES
	   
           PKG_CHECK_MODULES( CAIRO, cairo >= 1.0.2 )
	   if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$ENABLE_FONTCONFIG" != "TRUE" ; then
	      AC_MSG_ERROR([Cairo library requires fontconfig.])
	   fi
           if test "$with_system_xrender_headers" = "yes"; then
              AC_MSG_CHECKING([whether Xrender.h defines PictStandardA8])
              AC_TRY_RUN([
#include <X11/extensions/Xrender.h>

int main(int argc, char **argv) {
#ifdef PictStandardA8
      return 0;
#else
      return 1;
#endif
}
               ], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no, X headers too old.])])
           fi
        else
           BUILD_TYPE="$BUILD_TYPE CAIRO"
	   dnl === compiler fails on pixman with 64bit architectures...===
	   if test "$build_cpu" != "x86_64"; then
	      BUILD_PIXMAN=YES
	   fi
           AC_MSG_RESULT([internal])	   
        fi
    else
	   AC_MSG_RESULT([no])
    fi
fi

AC_SUBST(ENABLE_CAIRO)
AC_SUBST(BUILD_PIXMAN)
AC_SUBST(SYSTEM_CAIRO)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(CAIRO_LIBS)

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

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

if test "x$enable_opengl" != "xno" ; then
   AC_MSG_RESULT([yes])
   AC_CHECK_HEADER(GL/gl.h, [],
                   [AC_MSG_ERROR([OpenGL headers not found])], [])
   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
else
   AC_MSG_RESULT([no])
fi

AC_SUBST(ENABLE_OPENGL)

AC_MSG_CHECKING([whether to build extra presenter ui])
if test -n "$enable_presenter_extra_ui" -a "$enable_presenter_extra_ui" != "no"; then
   AC_MSG_RESULT([yes])
   ENABLE_PRESENTER_EXTRA_UI=YES
else
   AC_MSG_RESULT([no])
   ENABLE_PRESENTER_EXTRA_UI=NO
fi
AC_SUBST(ENABLE_PRESENTER_EXTRA_UI)

AC_MSG_CHECKING([whether to build the Presentation Minimizer extension])
if test -n "$enable_minimizer" -a "$enable_minimizer" != "no"; then
   AC_MSG_RESULT([yes])
   ENABLE_MINIMIZER=YES
else
   AC_MSG_RESULT([no])
   ENABLE_MINIMIZER=NO
fi
AC_SUBST(ENABLE_MINIMIZER)

AC_MSG_CHECKING([whether to build the Presenter Screen extension])
if test -n "$enable_presenter_console" -a "$enable_presenter_screen" != "no"; then
   AC_MSG_RESULT([yes])
   ENABLE_PRESENTER_SCREEN=YES
else
   AC_MSG_RESULT([no])
   ENABLE_PRESENTER_SCREEN=NO
fi
AC_SUBST(ENABLE_PRESENTER_SCREEN)

AC_MSG_CHECKING([whether to build the PDF Import extension])
if test -n "$enable_pdfimport" -a "$enable_pdfimport" != "no"; 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 -n "$with_system_poppler" -o -n "$with_system_libs" && \
       test "$with_system_poppler" != "no"; then
      AC_MSG_RESULT([external])
      SYSTEM_POPPLER=YES
      PKG_CHECK_MODULES( POPPLER, poppler >= 0.8.0 )
  else
      AC_MSG_RESULT([internal])
      SYSTEM_POPPLER=NO
      BUILD_TYPE="$BUILD_TYPE XPDF"
      AC_MSG_CHECKING([for xpdf module])
      if test -d ./xpdf; then
       AC_MSG_RESULT([OK])
      else
        AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
      fi
  fi
else
   AC_MSG_RESULT([no])
   ENABLE_PDFIMPORT=NO
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])
  if test -d ./sdext; then
   AC_MSG_RESULT([OK])
  else
   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
  fi
  BUILD_TYPE="$BUILD_TYPE SDEXT"
fi

AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
if test -n "$enable_wiki_publisher" -a "$enable_wiki_publisher" != "no" && test  "$WITH_JAVA" != "no"; then
  AC_MSG_RESULT([yes])
  AC_MSG_CHECKING([for swext module])
  if test -d ./swext; then
   AC_MSG_RESULT([OK])
  else
   AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
  fi
  ENABLE_MEDIAWIKI=YES
  BUILD_TYPE="$BUILD_TYPE SWEXT"
else
  AC_MSG_RESULT([no])
  ENABLE_MEDIAWIKI=NO
fi
AC_SUBST(ENABLE_MEDIAWIKI)

if test "$ENABLE_MEDIAWIKI" == "YES"; then
  AC_MSG_CHECKING([which Servlet API Jar to use])
  if test -n "$with_system_servlet_api"; 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 -n "$enable_report_builder" -a "$enable_report_builder" != "no" && test "$WITH_JAVA" != "no"; then
  AC_MSG_RESULT([yes])
  ENABLE_REPORTBUILDER=YES
  AC_MSG_CHECKING([for reportbuilder module])
  if test -d ./reportbuilder; then
    AC_MSG_RESULT([OK])
  else
    AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
  fi
  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])
     if test -d ./jfreereport; then
      AC_MSG_RESULT([OK]) 
     else
      AC_MSG_ERROR([not existing. get it (did you get the -extensions tarball?)])
     fi
     SYSTEM_JFREEREPORT=NO
     BUILD_TYPE="$BUILD_TYPE JFREEREPORT"
  fi
  BUILD_TYPE="$BUILD_TYPE REPORTBUILDER"
else
  AC_MSG_RESULT([no])
  ENABLE_REPORTBUILDER=NO
  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-codecs.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)

dnl ===================================================================
dnl Check whether the Qt and KDE libraries are available.
dnl ===================================================================

KDE_CFLAGS=""
KDE_LIBS=""
MOC="moc"
if test "$test_kde" = "yes" -a "$ENABLE_KDE" = "TRUE" ; then
    dnl Search paths for Qt and KDE
    if test "$build_cpu" != "x86_64" ; 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 $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 $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 $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 $x_libraries"
    fi
    if test -n "$QTDIR" ; then
        qt_incdirs="$QTDIR/include $qt_incdirs"
        if test "$build_cpu" != "x86_64" ; then
            qt_libdirs="$QTDIR/lib $qt_libdirs"
        else
            qt_libdirs="$QTDIR/lib64 $QTDIR/lib $qt_libdirs"
        fi
    fi
    if test "$build_cpu" != "x86_64" ; 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 "$build_cpu" != "x86_64" ; 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"
    qt_test_library="libqt-mt.so"
    kde_test_include="ksharedptr.h"
    kde_test_library="libkdeui.so"

    dnl Check for Qt headers
    AC_MSG_CHECKING([for Qt 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([Qt headers not found.  Please specify the root of
your Qt installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for Qt libraries
    AC_MSG_CHECKING([for Qt libraries])
    qt_libdir="no"
    for qt_check in $qt_libdirs ; do
        if test -r "$qt_check/$qt_test_library" ; then
            qt_libdir="$qt_check"
            break
        fi
    done
    AC_MSG_RESULT([$qt_libdir])
    if test "x$qt_libdir" = "xno" ; then
        AC_MSG_ERROR([Qt libraries not found.  Please specify the root of
your Qt installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for Meta Object Compiler
    AC_PATH_PROG( MOC, moc, no, [$QTDIR/bin:$PATH] )
    if test "$MOC" = "no" ; then
        AC_MSG_ERROR([Qt Meta Object Compiler not found.  Please specify
the root of your Qt installation by exporting QTDIR before running "configure".])
    fi

    dnl Check for KDE headers
    AC_MSG_CHECKING([for KDE 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([KDE headers not found.  Please specify the root of
your KDE installation by exporting KDEDIR before running "configure".])
    fi

    dnl Check for KDE libraries
    AC_MSG_CHECKING([for KDE 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([KDE libraries not found.  Please specify the root of
your KDE 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=""
MOC4="moc"
if test "$test_kde4" = "yes" -a "$ENABLE_KDE4" = "TRUE" ; then
   qt_incdirs="$QT4INC $QT4DIR /usr/include/qt4 /usr/include $x_includes"
   qt_libdirs="$QT4LIB /usr/lib $x_libraries"
   
   kde_incdirs="/usr/include $x_includes"
   kde_libdirs="/usr/lib $x_libraries"
   
   if test "$build_cpu" == "x86_64" ; then
      qt_libdirs="$qt_libdirs /usr/lib64/qt4 /usr/lib64/qt /usr/lib64"
      kde_libdirs="$kde_libdirs /usr/lib64 /usr/lib64/kde4"
   fi

   if test -n "$KDE4DIR" ; then
      kde_incdirs="$KDE4DIR/include $kde_incdirs"
      if test "$build_cpu" != "x86_64" ; 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="ksharedptr.h"
   kde_test_library="libkdeui.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
   
   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"
         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( MOC4, moc, no, [$PATH:$QT4DIR/bin] )
   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

   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 -lkdeui -lkdecore -lQtCore -lQtGui"
fi
AC_SUBST(KDE4_CFLAGS)
AC_SUBST(KDE4_LIBS)
AC_SUBST(MOC4)

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" && test "$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 KDE AB support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable KDE address book support])
if test "$enable_kdeab" = "yes" && test "$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_TRY_RUN([
#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 whether to include fonts
dnl ===================================================================
AC_MSG_CHECKING([whether to include Bitstream Vera fonts])
if test "$with_fonts" != "no" ; then
  AC_MSG_RESULT([yes])
  WITH_FONTS=YES
  BUILD_TYPE="$BUILD_TYPE BITSTREAM_VERA_FONTS"
else
  AC_MSG_RESULT([no])
  WITH_FONTS=NO
  SCPDEFS="$SCPDEFS -DWITHOUT_FONTS"
fi
AC_SUBST(WITH_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])
else
  AC_MSG_RESULT([no])
  WITHOUT_AFMS=YES
  SCPDEFS="$SCPDEFS -DWITHOUT_AFMS"
fi
AC_SUBST(WITHOUT_AFMS)

AC_SUBST(SCPDEFS)

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 -e "$XLIB/libXinerama.so" -a -e "$XLIB/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 "$XLIB/libXinerama.so" -a ! -e "$XLIB/libXinerama.a"; then
      # we have only the dynamic version
      USE_XINERAMA=YES
      XINERAMA_LINK=dynamic
   elif test -e "$XLIB/libXinerama.a"; then
      # static version
      if echo $build_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.)], [])
      XINERAMA_EXTRA_LIBS="-L$XLIB -lXext"
      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
   AC_MSG_RESULT([no])
fi
AC_SUBST(USE_XINERAMA)
AC_SUBST(XINERAMA_LINK)

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

  if test "$_os" = "OS2"; then
    ANT_HOME=`echo $ANT | $SED -n "s/\/bin\/ant.*\$//p"`
    export ANT_HOME
  fi

  ant_minver=1.6.0
  # update for more extensions...
  if test "$ENABLE_MEDIAWIKI" = "YES"; then
    ant_minver=1.7.0
  fi
  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" && test "$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
  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 && test -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"
fi
AC_SUBST(ANT_HOME)

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
                    AC_MSG_ERROR([Ant libraries not found!])
                fi  
             fi
          fi
      fi
   fi
   AC_MSG_RESULT([Ant lib directory found.])
fi
AC_SUBST(ANT_LIB)
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 && test -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

AC_MSG_CHECKING([which languages to be built])
WITH_LANG="$with_lang"
if test -z "$WITH_LANG"; then
   AC_MSG_RESULT([en-US])
else
   AC_MSG_RESULT([$WITH_LANG])
fi
AC_SUBST(WITH_LANG)

AC_MSG_CHECKING([which languages have poor help localizations])
WITH_POOR_HELP_LOCALIZATIONS="$with_poor_help_localizations"
if test -z "$WITH_POOR_HELP_LOCALIZATIONS"; then
   AC_MSG_RESULT([none])
else
   AC_MSG_RESULT([$WITH_POOR_HELP_LOCALIZATIONS])
fi
AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)

AC_MSG_CHECKING([which dictionaries to include])
if test -z "$with_dict"; then
   WITH_DICT=,ALL,
   AC_MSG_RESULT([ALL])
else
   WITH_DICT=","$with_dict","
   AC_MSG_RESULT([$with_dict])
fi
AC_SUBST(WITH_DICT)

AC_MSG_CHECKING([for additional 'intro' bitmaps])
INTRO_BITMAPS=
if test -z "$with_intro_bitmaps" -o "$with_intro_bitmaps" = "no" ; then
   INTRO_BITMAPS=
   AC_MSG_RESULT([none])
else
   for bitmap in `echo $with_intro_bitmaps | tr ',' ' '` ; do
      case "$bitmap" in
         *.bmp) ;;
         *)     bitmap= ; AC_MSG_WARN([Intro bitmaps should be .bmp files!]) ;;
      esac
      if test -n "$bitmap" ; then
         INTRO_BITMAPS="$INTRO_BITMAPS $bitmap"
      fi
   done
   AC_MSG_RESULT([$INTRO_BITMAPS])
fi
AC_SUBST(INTRO_BITMAPS)

AC_MSG_CHECKING([for additional 'about' bitmaps])
ABOUT_BITMAPS=
if test -z "$with_about_bitmaps" -o "$with_about_bitmaps" = "no" ; then
   ABOUT_BITMAPS=
   AC_MSG_RESULT([none])
else
   for bitmap in `echo $with_about_bitmaps | tr ',' ' '` ; do
      case "$bitmap" in
         *.bmp) ;;
         *)     bitmap= ; AC_MSG_WARN([About bitmaps should be .bmp files!]) ;;
      esac
      if test -n "$bitmap" ; then
         ABOUT_BITMAPS="$ABOUT_BITMAPS $bitmap"
      fi
   done
   AC_MSG_RESULT([$ABOUT_BITMAPS])
fi
AC_SUBST(ABOUT_BITMAPS)

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 statically link to Gtk])
if test -n "$enable_static_gtk" && test "$enable_static_gtk" != "no"; then
   ENABLE_STATIC_GTK="TRUE"
   AC_MSG_RESULT([yes])
else
   ENABLE_STATIC_GTK="FALSE"	
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_STATIC_GTK)

AC_MSG_CHECKING([whether to use layout dialogs])
if test -n "$enable_layout" && test "$enable_layout" != "no"; then
   ENABLE_LAYOUT="TRUE"
   AC_MSG_RESULT([yes])
else
   ENABLE_LAYOUT="FALSE"	
   AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_LAYOUT)

# ===================================================================
# 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 Setting up the environment.
dnl ===================================================================
echo "********************************************************************"
echo "*                                                                  *"
echo "*   Setting up the build environment variables.                    *"
echo "*                                                                  *"
echo "********************************************************************"

if test -z "$COMPATH"; then
   AC_MSG_ERROR([No compiler found.])
fi
AC_SUBST(COMPATH)

AC_MSG_CHECKING([solver path])
if test -z "$with_local_solver"; then
   LOCAL_SOLVER="DEFAULT"
   AC_MSG_RESULT([default])
else
   LOCAL_SOLVER=$with_local_solver
   AC_MSG_RESULT([$with_local_solver])
fi
AC_SUBST(LOCAL_SOLVER)

AC_SUBST(BUILD_TYPE)

# make sure config.guess is +x; we execute config.guess, so it has to be so; 
chmod +x ./config.guess

AC_OUTPUT([set_soenv Makefile])

dnl Executing the set_soenv script to setup the environment variables.
chmod a+x set_soenv
if test -z "$enable_check_only"; then
   './set_soenv'
else
   echo
   echo Test Complete
   echo No environment file will be generated
   echo
   num_warnings=`wc -l warn`
   _num=`echo $num_warnings | $AWK '{ print $1 }'`
   if test $_num -gt 0; then
      echo The following warning\(s\) were generated by configure
      echo ----------------------------------------------------
      echo
      cat warn
      echo
   else
      echo There were no warnings
   fi
   echo
fi