File: configure.in

package info (click to toggle)
gdal 1.10.1+dfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 84,320 kB
  • ctags: 74,726
  • sloc: cpp: 677,199; ansic: 162,820; python: 13,816; cs: 11,163; sh: 10,446; java: 5,279; perl: 4,429; php: 2,971; xml: 1,500; yacc: 934; makefile: 494; sql: 112
file content (4039 lines) | stat: -rw-r--r-- 131,901 bytes parent folder | download
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
dnl ***************************************************************************
dnl $Id: configure.in 25849 2013-04-03 22:15:46Z rouault $
dnl
dnl Project:  GDAL
dnl Purpose:  Configure source file.
dnl Author:   Frank Warmerdam, warmerdam@pobox.com
dnl
dnl ***************************************************************************
dnl Copyright (c) 2000, Frank Warmerdam
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included
dnl in all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl ***************************************************************************

dnl Disable configure caching ... it causes lots of hassles.
define([AC_CACHE_LOAD], )
define([AC_CACHE_SAVE], )

dnl Process this file with autoconf to produce a configure script.
AC_INIT(GDALmake.opt.in)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_HEADERS([port/cpl_config.h:port/cpl_config.h.in])
AH_BOTTOM([#include "cpl_config_extras.h"])

dnl We require autoconf 2.52+ for libtool support on cygwin/mingw hosts
AC_PREREQ(2.52)

dnl Compute the canonical host-system (the system we are building for)
dnl type variable $host
AC_CANONICAL_HOST

dnl Enable as much warnings as possible
AX_CFLAGS_WARN_ALL(C_WFLAGS)
AX_CXXFLAGS_WARN_ALL(CXX_WFLAGS)
AC_SUBST(CXX_WFLAGS,$CXX_WFLAGS)
AC_SUBST(C_WFLAGS,$C_WFLAGS)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

dnl switch between libtool and native build system
AC_ARG_WITH(libtool, [  --without-libtool     Don't use libtool to build the library],,)

if test "$with_libtool" = "no"; then
AC_PROG_RANLIB

dnl AC_COMPILER_PIC as expanded by autoconf-2.68 doesn't work for the C++ part with clang++ 3.0 that doesn't like compiling .c programs
dnl so we inline the expanded code and fix it at hand.
dnl AC_COMPILER_PIC
	echo 'void f(){}' > conftest.c
	if test -z "`${CC-cc} $CFLAGS -fPIC -c conftest.c 2>&1`"; then
	  CFLAGS="$CFLAGS -fPIC"
	fi
	echo 'void f(){}' > conftest.cpp
	if test -z "`${CXX-g++} $CXXFLAGS -fPIC -c conftest.cpp 2>&1`"; then
	  CXXFLAGS="$CXXFLAGS -fPIC"
	fi
	rm -f conftest*

AC_LD_SHARED
else
with_libtool=yes
fi
AC_SUBST(HAVE_LIBTOOL,$with_libtool)

dnl Checks for libraries.
AC_CHECK_LIB(dl,dlopen,,,)

dnl Needed on Solaris. 
AC_CHECK_LIB(rt,nanosleep,,,)

dnl We don't need to add math library to all targets
case "${host_os}" in
    cygwin* | mingw32* | pw32* | beos* | darwin*)
        ;;
    *)
	AC_CHECK_LIB(m,sin,,,)
        ;;
esac

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(assert.h fcntl.h unistd.h dbmalloc.h dlfcn.h stdint.h limits.h locale.h values.h float.h errno.h direct.h)

AC_C_BIGENDIAN

dnl Check for 64 bit file API
AC_HAVE_LONG_LONG
AC_UNIX_STDIO_64

AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(void*)
dnl Some compilers (IBM VisualAge) has these types defined, so check it here.
dnl These types are used in internal libtiff.
AC_CHECK_TYPES([int8, int16, int32],,,
[
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
])

dnl We need the following lines for libtiff too.
HAVE_IEEEFP=1
AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine])

dnl Check the native cpu bit order (also libtiff stuff).
AC_MSG_CHECKING([native cpu bit order])
case "$host_cpu" in
    i*86*|x86_64*)
        HOST_FILLORDER=FILLORDER_LSB2MSB
	AC_MSG_RESULT([lsb2msb])
	;;
    *)
	HOST_FILLORDER=FILLORDER_MSB2LSB
	AC_MSG_RESULT([msb2lsb])
        ;;
esac
AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])

dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(snprintf vsnprintf)
AC_CHECK_FUNCS(atoll)
AC_CHECK_FUNCS(strtof)
AC_CHECK_FUNCS(getcwd)

dnl Check for declarations
AC_CHECK_DECLS(strtof)

AC_CHECK_FUNCS(readlink)
AC_CHECK_FUNCS(lstat)
AC_CHECK_FUNCS(posix_spawnp)
AC_CHECK_FUNCS(vfork)

dnl Make sure at least these are checked under C++.  Prototypes missing on 
dnl some platforms.

AC_LANG_PUSH(C++)
AC_CHECK_FUNC_CUSTOM(gmtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); gmtime_r( &t, &ltime );])
AC_CHECK_FUNC_CUSTOM(localtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); localtime_r( &t, &ltime );])
AC_LANG_POP(C++)

AC_CHECK_FUNC(setlocale)

OPT_GDAL_FORMATS=
EXTRA_INCLUDES=

dnl ---------------------------------------------------------------------------
dnl Check for --enable-debug
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([to enable debug build])

AC_ARG_ENABLE(debug,
	      AS_HELP_STRING([--enable-debug],
			     [enable debugging (disabled by default)]),
	      [HAVE_DEBUG=$enableval], [HAVE_DEBUG=yes])

if test "x$enable_debug" = "xyes" ; then

  dnl Try to strip out optimization.

  CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-O2 //"` 
  CFLAGS=`echo "$CFLAGS " | sed "s/-O2 //"` 
  CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-O //"` 
  CFLAGS=`echo "$CFLAGS" | sed "s/-O //"` 

  dnl remove existing -g to avoid duplicates. 

  CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-g //"` 
  CFLAGS=`echo "$CFLAGS" | sed "s/-g //"` 

  dnl add -g and -DDEBUG

  CXXFLAGS="$CXXFLAGS -g -DDEBUG"
  CFLAGS="$CFLAGS -g -DDEBUG"

  AC_MSG_RESULT([yes, modified CFLAGS="$CFLAGS"])
else
  AC_MSG_RESULT([no, CFLAGS="$CFLAGS"])
fi

dnl ---------------------------------------------------------------------------
dnl Check if GCC 4.1 atomic builtins are really available
dnl (some GCC versions are broken w.r.t this on some exotic architectures...)
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([whether GCC 4.1 atomic builtins are available])

rm -f atomicbuiltins.c
echo 'int main(int argc, char* argv[]) { int i; __sync_add_and_fetch(&i, 1); __sync_sub_and_fetch(&i, 1); return 0; } ' > atomicbuiltins.c
if test -z "`${CC} atomicbuiltins.c -o atomicbuiltins 2>&1`" ; then
    HAVE_GCC_ATOMIC_BUILTINS=yes
    AC_MSG_RESULT([yes])
    AC_DEFINE_UNQUOTED(HAVE_GCC_ATOMIC_BUILTINS,1, [Define to 1 if GCC atomic builtins are available])
else
    HAVE_GCC_ATOMIC_BUILTINS=no
    AC_MSG_RESULT([no])
fi
rm -f atomicbuiltins.* atomicbuiltins

AC_SUBST(HAVE_GCC_ATOMIC_BUILTINS,$HAVE_GCC_ATOMIC_BUILTINS)

dnl ---------------------------------------------------------------------------
dnl Check SSE availability
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(sse,
[  --with-sse[=ARG]        Detect SSE availability for some optimized routines (ARG=yes(default), no)],,)

AC_MSG_CHECKING([whether SSE is available])

if test "$with_sse" = "yes" -o "$with_sse" = ""; then

    rm -f detectsse.cpp
    echo '#ifdef __SSE__' > detectsse.cpp
    echo '#include <xmmintrin.h>' >> detectsse.cpp
    echo 'void foo() { float fEpsilon = 0.0000000000001f; __m128 xmm_small = _mm_load1_ps(&fEpsilon); } ' >> detectsse.cpp
    echo '#else' >> detectsse.cpp
    echo 'some_error' >> detectsse.cpp
    echo '#endif' >> detectsse.cpp
    if test -z "`${CXX} -c detectsse.cpp 2>&1`" ; then
        AC_MSG_RESULT([yes])
        CFLAGS="$CFLAGS -DHAVE_SSE_AT_COMPILE_TIME"
        CXXFLAGS="$CXXFLAGS -DHAVE_SSE_AT_COMPILE_TIME"
    else
        if test -z "`${CXX} -msse -c detectsse.cpp 2>&1`" ; then
            AC_MSG_RESULT([yes])
            CFLAGS="$CFLAGS -msse -DHAVE_SSE_AT_COMPILE_TIME"
            CXXFLAGS="$CXXFLAGS -msse -DHAVE_SSE_AT_COMPILE_TIME"
        else
            AC_MSG_RESULT([no])
            if test "$with_sse" = "yes"; then
                AC_MSG_ERROR([--with-sse was requested, but SSE is not available])
            fi
        fi
    fi
    rm -f detectsse.*
else
    AC_MSG_RESULT([no])
fi

dnl ---------------------------------------------------------------------------
dnl Check if we need -lws2_32
dnl ---------------------------------------------------------------------------

echo "#include <winsock2.h>" > test_ws2_32.c
echo "#include <ws2tcpip.h>" >> test_ws2_32.c
echo "void foo() {}" >> test_ws2_32.c

if test -z "`${CC} -c test_ws2_32.c 2>&1`" ; then
  LIBS="$LIBS -lws2_32"
fi
rm -f test_ws2_32*

dnl ---------------------------------------------------------------------------
dnl Check if we have getaddrinfo
dnl ---------------------------------------------------------------------------

echo "#include <sys/types.h>" > test_getaddrinfo.c
echo "#include <sys/socket.h>" >> test_getaddrinfo.c
echo "#include <netdb.h>" >> test_getaddrinfo.c
echo "void test() { getaddrinfo(0,0,0,0); }"  >> test_getaddrinfo.c

HAVE_GETADDRINFO=NO
if test -z "`${CC} -c test_getaddrinfo.c 2>&1`" ; then
  AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO,1, [Define to 1 if you have the `getaddrinfo' function.])
fi
rm -f test_getaddrinfo*

dnl ---------------------------------------------------------------------------
dnl Check if user requests hidding internal symbols
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(hide_internal_symbols,[  --with-hide-internal-symbols[=ARG] Try to hide internal symbols (ARG=yes/no)],,)

HAVE_HIDE_INTERNAL_SYMBOLS=no

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

    AC_MSG_CHECKING([whether we should hide internal symbols])

    rm -f hiddensymbols.c
    echo 'int visible() { return 0; } __attribute__ ((visibility("default")))' >> hiddensymbols.c
    echo 'int hidden() { return 0; }' >> hiddensymbols.c
    if test -z "`${CC} -fvisibility=hidden -c hiddensymbols.c 2>&1`" ; then
      HAVE_HIDE_INTERNAL_SYMBOLS=yes
    else
      HAVE_HIDE_INTERNAL_SYMBOLS=no
    fi
    if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes"; then
        AC_MSG_RESULT([yes])
        CFLAGS="$CFLAGS -fvisibility=hidden"
        CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
    else
        AC_MSG_RESULT([no])
    fi
    rm -f hiddensymbols.*
else
  AC_MSG_CHECKING([whether we should hide internal symbols])
  AC_MSG_RESULT([no])
fi

if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes" ; then
  AC_DEFINE_UNQUOTED(USE_GCC_VISIBILITY_FLAG,1, [Define to 1 if you want to use the -fvisibility GCC flag]) 
fi

AC_SUBST(HAVE_HIDE_INTERNAL_SYMBOLS,$HAVE_HIDE_INTERNAL_SYMBOLS)

dnl ---------------------------------------------------------------------------
dnl Check if user requests renaming internal libtiff symbols
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(rename_internal_libtiff_symbols,[  --with-rename-internal-libtiff-symbols[=ARG] Prefix internal libtiff symbols with gdal_ (ARG=yes/no)],,)
if test "$with_rename_internal_libtiff_symbols" = ""; then
    with_rename_internal_libtiff_symbols=no
fi
AC_SUBST(RENAME_INTERNAL_LIBTIFF_SYMBOLS,$with_rename_internal_libtiff_symbols)

dnl ---------------------------------------------------------------------------
dnl Check if user requests renaming internal libgeotiff symbols
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(rename_internal_libgeotiff_symbols,[  --with-rename-internal-libgeotiff-symbols[=ARG] Prefix internal libgeotiff symbols with gdal_ (ARG=yes/no)],,)
if test "$with_rename_internal_libgeotiff_symbols" = ""; then
    with_rename_internal_libgeotiff_symbols=no
fi
AC_SUBST(RENAME_INTERNAL_LIBGEOTIFF_SYMBOLS,$with_rename_internal_libgeotiff_symbols)


dnl ---------------------------------------------------------------------------
dnl Check if user requests /usr/local to be included.
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([for local include/lib path])

AC_ARG_WITH(local,[  --with-local[=dir]      Include /usr/local or other local tree for INCLUDE/LIBS],,)

if test "$with_local" != "no" -a "$with_local" != "" ; then
  
  if test "$with_local" = "yes" ; then
    ADD_PREFIX=/usr/local
  else
    ADD_PREFIX=$with_local
  fi

  AC_MSG_RESULT(adding $ADD_PREFIX)

  LIBS="$LIBS -L$ADD_PREFIX/lib"
  CPPFLAGS="$CPPFLAGS -I$ADD_PREFIX/include"
else
  AC_MSG_RESULT([none])
fi

dnl ---------------------------------------------------------------------
dnl ENABLE THREADS ONLY IF REQUESTED.
dnl ---------------------------------------------------------------------

THREAD_LIB=""
THREAD_FLAG=""
PTHREAD_ENABLED="no"

AC_ARG_WITH(threads,
[  --with-threads[=ARG]    Include thread safe support (ARG=yes(default), no or linkopt)],,)

if test "$with_threads" = "yes" -o "$with_threads" = "" ; then

  AC_CHECK_LIB(pthread,pthread_create,THREAD_FLAG=CPL_MULTIPROC_PTHREAD,,,)

  if test -n "$THREAD_FLAG" ; then
      THREAD_LIB="-lpthread"
  fi

  AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE])

  AC_TRY_COMPILE(
  [
#define _GNU_SOURCE
#include <pthread.h>
  ], [
    return (PTHREAD_MUTEX_RECURSIVE);
  ],
  [
    AC_MSG_RESULT([yes])
    AC_DEFINE_UNQUOTED(HAVE_PTHREAD_MUTEX_RECURSIVE, 1,
          [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE' constant.])
  ], [
    AC_MSG_RESULT([no])
  ])

  PTHREAD_ENABLED="yes"

elif test "$with_threads" != "no" ; then

  THREAD_FLAG=CPL_MULTIPROC_PTHREAD
  THREAD_LIB="$with_threads"  

  AC_CHECKING(whether we should include thread/mutex support...)
  AC_MSG_RESULT([        using threads with link options "$THREAD_LIB".])

  PTHREAD_ENABLED="yes"

else
  AC_CHECKING(whether we should include thread/mutex support...)
  AC_MSG_RESULT([        thread safe support disabled.])
fi

if test "$THREAD_FLAG" = "CPL_MULTIPROC_PTHREAD" ; then
  AC_DEFINE_UNQUOTED(CPL_MULTIPROC_PTHREAD,1, [Define if you want to use pthreads based multiprocessing support])
fi

LIBS="$THREAD_LIB $LIBS" 

dnl ---------------------------------------------------------------------------
dnl Check if libz is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(libz,[  --with-libz[=ARG]       Include libz support (ARG=internal or libz directory)],,)

if test "$with_libz" = "external" -o "$with_libz" = "" -o "$with_libz" = "yes" ; then

  AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,)

  if test "$LIBZ_SETTING" = "external" ; then
    AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,)
    if test "$LIBZ_SETTING" = "external" ; then
        AC_MSG_RESULT([using pre-installed libz])
    else
        AC_MSG_RESULT([using internal libz code as inflateCopy is missing])
    fi
  else
    AC_MSG_RESULT([using internal libz code as deflateInit_ is missing])
  fi

elif test "$with_libz" != "no" -a "$with_libz" != "internal" ; then

  LIBS="-L$with_libz -L$with_libz/lib $LIBS"

  AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
  if test "$LIBZ_SETTING" = "external" ; then
    AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
     if test "$LIBZ_SETTING" = "external" ; then
        AC_MSG_RESULT([using libz library from $with_libz])
    else
        AC_MSG_RESULT([using internal libz code as inflateCopy from $with_libz is missing])
    fi
  else
    AC_MSG_RESULT([using internal libz code as deflateInit_ from $with_libz is missing])
  fi

fi

if test "$LIBZ_SETTING" = "external" ; then
  LIBS="-lz $LIBS"
  if test "$with_libz" != "" -a "$with_libz" != "yes" -a "$with_libz" != "external" ; then
    EXTRA_INCLUDES="-I$with_libz -I$with_libz/include $EXTRA_INCLUDES"
  fi
elif test "$with_libz" = "no" ; then
  LIBZ_SETTING=no
  AC_MSG_RESULT([not using libz at all.])
else
  LIBZ_SETTING=internal
  OPT_GDAL_FORMATS="zlib $OPT_GDAL_FORMATS"
  AC_MSG_RESULT([using internal libz code.])
fi

AC_SUBST(LIBZ_SETTING,$LIBZ_SETTING)

dnl ---------------------------------------------------------------------------
dnl Check for iconv/libiconv.
dnl A rationale for this macro is described in "GNU `gettext' utilities"
dnl manual at
dnl http://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html
dnl ---------------------------------------------------------------------------
AM_ICONV

dnl Extra test needed for GCC 4.5 on Solaris 11, where there is
dnl a different behaviour if the tests are compiled with gcc or g++.
dnl So we introduce a ICONV_CPP_CONST that must be used instead of
dnl ICONV_CONST when used from .cpp files.
if test "$am_func_iconv" = "yes"; then
    rm -f testiconv.*
    echo '#include <iconv.h>' > testiconv.cpp
    echo 'int main(int argc, char** argv) { iconv_t cd; return iconv (cd, (const char **) 0, 0, 0, 0); } ' >> testiconv.cpp
    if test -z "`${CXX} ${CPPFLAGS} testiconv.cpp -c 2>&1`" ; then
        AC_MSG_RESULT([using ICONV_CPP_CONST="const"])
        ICONV_CPP_CONST="const"
    else
        AC_MSG_RESULT([using ICONV_CPP_CONST=""])
        ICONV_CPP_CONST=""
    fi
    rm -f testiconv.*

    AC_DEFINE_UNQUOTED(ICONV_CPP_CONST,$ICONV_CPP_CONST, [For.cpp files, define as const if the declaration of iconv() needs const.])
fi


dnl ---------------------------------------------------------------------------
dnl Check if liblzma is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(liblzma,[  --with-liblzma[=ARG]       Include liblzma support (ARG=yes/no)],,)

if test "$with_liblzma" = "yes" ; then
  AC_CHECK_LIB(lzma,lzma_code,LIBLZMA_SETTING=yes,LIBLZMA_SETTING=no,)

  if test "$LIBLZMA_SETTING" = "yes" ; then
    LIBS="-llzma $LIBS"
  fi
else
    LIBLZMA_SETTING=no
fi

AC_SUBST(LIBLZMA_SETTING,$LIBLZMA_SETTING)

dnl ---------------------------------------------------------------------------
dnl Select an PostgreSQL Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

PG_CONFIG=no

AC_ARG_WITH(pg,
	    AS_HELP_STRING([--with-pg[=ARG]],
	       [Include PostgreSQL GDAL/OGR Support (ARG=path to pg_config)]),,)

if test "x$with_pg" = "xyes" -o "x$with_pg" = "x" ; then
  AC_PATH_PROG(PG_CONFIG, pg_config, no)
else 
  PG_CONFIG=$with_pg
fi

AC_MSG_CHECKING([for PostgreSQL])

if test "x$PG_CONFIG" = "xno" ; then

  HAVE_PG=no
  PG_LIB=
  PG_INC=

  AC_MSG_RESULT([no])

else
  if test -d ${PG_CONFIG} ; then
      AC_MSG_RESULT([no])
      AC_MSG_ERROR([--with-pg argument is a directory.  It should be the path to the pg_config script, often somewhere like /usr/local/pgsql/bin/pg_config.])
  fi

  if test \! -x ${PG_CONFIG} ; then
      AC_MSG_RESULT([no])
      AC_MSG_ERROR([--with-pg argument is a not an executable file.  It should be the path to the pg_config script, often somewhere like /usr/local/pgsql/bin/pg_config.])
  fi

  AC_MSG_RESULT([yes])

  AC_CHECK_LIB(pq,PQconnectdb,HAVE_PG=yes,HAVE_PG=no,-L`$PG_CONFIG --libdir`)
  
  if test "${HAVE_PG}" = "yes" ; then
    LIBS=-L`$PG_CONFIG --libdir`" -lpq $LIBS"
    PG_INC=-I`$PG_CONFIG --includedir`" -I"`$PG_CONFIG --includedir-server`

    PG_EXTRA_DEC=""
    saved_LIBS="$LIBS"
    AC_CHECK_LIB(pq,PQputCopyData,,DEFINE_PG_PRE74=-DPG_PRE74,)
    LIBS="$saved_LIBS"
    if test "$DEFINE_PG_PRE74" != "" ; then
      echo "The PostgreSQL client version is before 7.4. You will not be able to use binary cursors."
    fi

    saved_LIBS="$LIBS"
    AC_CHECK_LIB(pq,PQescapeStringConn,DEFINE_PG_HAS_PQESCAPESTRINGCONN=-DPG_HAS_PQESCAPESTRINGCONN,,)
    LIBS="$saved_LIBS"
    if test "$DEFINE_PG_HAS_PQESCAPESTRINGCONN" = "" ; then
      echo "falling back to using PQescapeString. You should upgrade at least to security releases 8.1.4, 8.0.8, 7.4.13, 7.3.15."
    fi

    PG_INC="${PG_INC} ${DEFINE_PG_PRE74} ${DEFINE_PG_HAS_PQESCAPESTRINGCONN}"
  fi

fi

AC_SUBST(HAVE_PG,$HAVE_PG)
AC_SUBST(PG_INC,$PG_INC)
AC_SUBST(PG_LIB,$PG_LIB)

dnl ---------------------------------------------------------------------------
dnl Check if we should build with GRASS support.
dnl ---------------------------------------------------------------------------

GRASS_SETTING=no
GRASS_INCLUDE=
HAVE_GRASS=no
export GRASS_INCLUDE GRASS_SETTING

AC_ARG_WITH(grass,[  --with-grass[=ARG]      Include GRASS support (GRASS 5.7+, ARG=GRASS install tree dir)],,)

AC_ARG_WITH(libgrass,[  --with-libgrass[=ARG]   Include GRASS support based on libgrass (GRASS 5.0+)],,)

# default use of grass libraries off since we can't easily auto-find them.
if test "$with_grass" = "" ; then
  with_grass=no
fi

# Check for GRASS 5.7.0 or later library use.
# TODO: separate libs for rasters and vectors
if test "$with_grass" != "yes" -a "$with_grass" != "no" ; then

  AC_CHECK_LIB(grass_gis,G_asprintf,GRASS_SETTING=grass57+,GRASS_SETTING=no,-L$with_grass/lib -lgrass_datetime)
   
  if test "$GRASS_SETTING" = "grass57+" ; then   
    G_RASTLIBS="-lgrass_I"
    G_VECTLIBS="-lgrass_vect -lgrass_dig2 -lgrass_dgl -lgrass_rtree -lgrass_linkm -lgrass_dbmiclient -lgrass_dbmibase"
    LIBS="-L$with_grass/lib $G_VECTLIBS $G_RASTLIBS -lgrass_gproj -lgrass_vask -lgrass_gmath -lgrass_gis -lgrass_datetime $LIBS"
    GRASS_INCLUDE="-I$with_grass/include"
    GRASS_GISBASE="$with_grass"
    HAVE_GRASS=yes
  else
    AC_MSG_ERROR([--with-grass=$with_grass requested, but libraries not found!])
  fi

# Check if libgrass is disabled.
elif test "$with_libgrass" = "no" ; then

  echo "GRASS support disabled."

elif test "$with_libgrass" = "yes" -o "$with_libgrass" = "" ; then

  AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,)

  if test "$GRASS_SETTING" = "libgrass" ; then   
    LIBS="-lgrass5 $LIBS"
  fi

else

  AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,-L$with_libgrass/lib)

  if test "$GRASS_SETTING" = "libgrass" ; then   
    LIBS="-L$with_libgrass -L$with_libgrass/lib -lgrass5 $LIBS"
    GRASS_INCLUDE="-I$with_libgrass -I$with_libgrass/include $EXTRA_INCLUDES"
  else
    AC_MSG_ERROR([--with-libgrass=$with_grass requested, but libgrass5 not found!])
  fi
fi

AC_SUBST(GRASS_SETTING,$GRASS_SETTING)
AC_SUBST(GRASS_INCLUDE,$GRASS_INCLUDE)
AC_SUBST(GRASS_GISBASE,$GRASS_GISBASE)
AC_SUBST(HAVE_GRASS)

if test "$GRASS_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="grass $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if cfitsio library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(cfitsio,[  --with-cfitsio[=ARG]    Include FITS support (ARG=no or libcfitsio path)],,)

if test "$with_cfitsio" = "no" ; then

  FITS_SETTING=no

  echo "FITS support disabled."

elif test "$with_cfitsio" = "yes" -o "$with_cfitsio" = "" ; then

  AC_CHECK_LIB(cfitsio,ffopen,FITS_SETTING=external,FITS_SETTING=no,)

  if test "$FITS_SETTING" = "external" ; then   
    LIBS="-lcfitsio $LIBS"
    echo "using pre-installed libcfitsio."
  else
    echo "libcfitsio not found - FITS support disabled"
  fi

dnl Fedora has cfitsio headers in /usr/include/cfitsio
  if test "$FITS_SETTING" = "external" -a -d /usr/include/cfitsio ; then
    EXTRA_INCLUDES="-I/usr/include/cfitsio $EXTRA_INCLUDES"
  fi

else

  FITS_SETTING=external
  LIBS="-L$with_cfitsio -L$with_cfitsio/lib -lcfitsio $LIBS"
  EXTRA_INCLUDES="-I$with_cfitsio -I$with_cfitsio/include $EXTRA_INCLUDES"

  echo "using libcfitsio from $with_cfitsio."
fi

AC_SUBST(FITS_SETTING,$FITS_SETTING)

if test "$FITS_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="fits $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if PCRaster (libcsf) library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(pcraster,[  --with-pcraster[=ARG]   Include PCRaster (libcsf) support (ARG=internal, no or path)],,)

if test "$with_pcraster" = "no" ; then

  PCRASTER_SETTING=no

  echo "PCRaster support disabled."

elif test "$with_pcraster" = "yes" -o "$with_pcraster" = "" ; then

  AC_CHECK_LIB(csf,Mopen,PCRASTER_SETTING=external,PCRASTER_SETTING=internal,$LIBS)
  AC_CHECK_HEADERS(csf.h)

  if test "$PCRASTER_SETTING" = "external" -a "$ac_cv_header_csf_h" = "no" ; then
    PCRASTER_SETTING=internal
  fi

  if test "$PCRASTER_SETTING" = "external" ; then
    LIBS="-lcsf $LIBS"
    echo "using pre-installed libcsf."
  else
    echo "using internal csf code."
  fi

elif test "$with_pcraster" = "internal" ; then

  PCRASTER_SETTING=internal

  echo "using internal csf code."

else

  PCRASTER_SETTING=external
  LIBS="-L$with_pcraster/lib -lcsf $LIBS"
  EXTRA_INCLUDES="-I$with_pcraster/include $EXTRA_INCLUDES"

  echo "using libcsf from $with_pcraster."

fi

AC_SUBST(PCRASTER_SETTING,$PCRASTER_SETTING)

if test "$PCRASTER_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="pcraster $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select a PNG Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([png], [  --with-png[=ARG]        Include PNG support (ARG=internal, no or path)],,)

AC_MSG_CHECKING([for libpng])

if test "$with_png" = "no" ; then

  PNG_SETTING=no

  echo "png support disabled."

elif test "$with_png" = "yes" -o "$with_png" = "" ; then

  AC_CHECK_LIB([png], [png_set_IHDR], [PNG_SETTING=external], [PNG_SETTING=internal], [$LIBS])
  AC_CHECK_HEADERS([png.h])

  if test "$PNG_SETTING" = "external" -a "$ac_cv_header_png_h" = "no" ; then   
    PNG_SETTING=internal
  fi
  if test "$PNG_SETTING" = "external" ; then   
    LIBS="-lpng $LIBS"
    echo "using pre-installed libpng."
  else
    echo "using internal png code."
  fi

elif test "$with_png" = "internal" ; then

  PNG_SETTING=internal

  echo "using internal png code."

else

  PNG_SETTING=external
  LIBS="-L$with_png -L$with_png/lib -lpng $LIBS"
  EXTRA_INCLUDES="-I$with_png -I$with_png/include $EXTRA_INCLUDES"

  echo "using libpng from $with_png."

fi

AC_SUBST([PNG_SETTING], [$PNG_SETTING])

if test "$PNG_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="png $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Enable DDS driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([dds], [  --with-dds[=ARG]        Include DDS support (ARG=no, or path)],,)

AC_MSG_CHECKING([for libcrunch])

if test "$with_dds" = "no" -o "$with_dds" = ""; then

  DDS_SETTING="no"
  CRUNCHDIR=""

  echo "dds support disabled."

else

  DDS_SETTING=yes
  CRUNCHDIR="$with_dds"
  LIBS="-L$with_dds/lib/ -lcrunch $LIBS"
  echo "using libcrunch from $with_dds."

fi

AC_SUBST(CRUNCHDIR,$CRUNCHDIR)
AC_SUBST([DDS_SETTING], [$DDS_SETTING])

if test "$DDS_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="dds $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if GTA library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([gta],[  --with-gta[=ARG]        Include GTA support (ARG=no or libgta tree prefix)],,)

if test "$with_gta" = "no" ; then

  GTA_SETTING=no

  echo "GTA support disabled."

elif test "$with_gta" = "yes" -o "$with_gta" = "" ; then

  AC_CHECK_LIB([gta], [gta_version], [GTA_SETTING=yes], [GTA_SETTING=no],)

  if test "$GTA_SETTING" = "yes" ; then
    LIBS="-lgta $LIBS"
    echo "using pre-installed libgta."
  else
    echo "libgta not found - GTA support disabled"
  fi

else

  GTA_SETTING=yes
  LIBS="-L$with_gta -L$with_gta/lib -lgta $LIBS"
  EXTRA_INCLUDES="-I$with_gta -I$with_gta/include $EXTRA_INCLUDES"

  echo "using libgta from $with_gta."
fi

AC_SUBST([GTA_SETTING], [$GTA_SETTING])

if test "$GTA_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="gta $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select PCIDSK options.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([pcidsk], [  --with-pcidsk[=ARG]     Path to external PCIDSK SDK, or internal (default), or old],,)

AC_MSG_CHECKING([for PCIDSK])

PCIDSK_LIB=
PCIDSK_INCLUDE=

if test "$with_pcidsk" = "old" -o "$with_pcidsk" = "no" ; then

  PCIDSK_SETTING=old

  echo "pcidsk support using pre-PCIDSK SDK (old) implementation."

elif test "$with_pcidsk" = "" -o "$with_pcidsk" = "yes" -o "$with_pcidsk" = "internal" ; then

  PCIDSK_SETTING=internal

  echo "using internal libpcidsk."

else

  PCIDSK_SETTING=external
  PCIDSK_LIB="-L$with_pcidsk/lib -lpcidsk"
  PCIDSK_INCLUDE="-I$with_pcidsk/include -I$with_pcidsk/include/pcidsk"

  echo "using libpcidsk from $with_pcidsk."

fi

AC_SUBST([PCIDSK_SETTING], [$PCIDSK_SETTING])
AC_SUBST([PCIDSK_LIB], [$PCIDSK_LIB])
AC_SUBST([PCIDSK_INCLUDE], [$PCIDSK_INCLUDE])

dnl ---------------------------------------------------------------------------
dnl Select a libtiff library to use.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(libtiff,[  --with-libtiff=ARG    Libtiff library to use (ARG=internal, yes or path)],,)

AC_MSG_CHECKING([for libtiff])

if test "x${with_libtiff}" = "xyes" -o "x${with_libtiff}" = "x" ; then

  dnl Only automatically pick up the external libtiff if it is >= 4.0.
  AC_CHECK_LIB(tiff,TIFFScanlineSize64,TIFF_SETTING=external HAVE_BIGTIFF=yes,TIFF_SETTING=internal HAVE_BIGTIFF=yes,)

  if test "$TIFF_SETTING" = "external" ; then
    dnl Cygwin takes a somewhat restrictive view of what should be exported
    dnl from the dll, so don't use the external library if missing semi-private
    dnl functions.
    AC_CHECK_LIB(tiff,_TIFFsetDoubleArray,TIFF_SETTING=external,TIFF_SETTING=internal,)
  fi

  if test "$TIFF_SETTING" = "external" ; then   
    LIBS="-ltiff $LIBS"
    AC_MSG_RESULT([using pre-installed libtiff.])
  else
    AC_MSG_RESULT([using internal TIFF code.])
  fi

elif test "x${with_libtiff}" = "xinternal" ; then

  TIFF_SETTING=internal
  HAVE_BIGTIFF=yes

  AC_MSG_RESULT([using internal TIFF code.])

else

  TIFF_SETTING=external
  if test -r "$with_libtiff/tiff.h" ; then
    LIBS="-L$with_libtiff -ltiff $LIBS"
    EXTRA_INCLUDES="-I$with_libtiff $EXTRA_INCLUDES"
  else
    LIBS="-L$with_libtiff/lib -ltiff $LIBS"
    EXTRA_INCLUDES="-I$with_libtiff/include $EXTRA_INCLUDES"
  fi

  AC_MSG_RESULT([using libtiff from ${with_libtiff}.])

  dnl Check for the BigTIFF enabled library (libtiff >= 4.0)
  AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,)

fi

if test "${HAVE_BIGTIFF}" = "yes" ; then
  TIFF_OPTS="-DBIGTIFF_SUPPORT"

  LOC_MSG([BigTIFF support enabled.])
fi

AC_SUBST(TIFF_SETTING,${TIFF_SETTING})
AC_SUBST(TIFF_OPTS,${TIFF_OPTS})

dnl ---------------------------------------------------------------------------
dnl Select a libgeotiff library to use.
dnl ---------------------------------------------------------------------------

GEOTIFF_INCLUDE=
AC_ARG_WITH(geotiff,[  --with-geotiff=ARG    Libgeotiff library to use (ARG=internal, yes or path)],,)

if test "$with_geotiff" = "yes" -o "$with_geotiff" = "" ; then

  if test "$TIFF_SETTING" = "internal" ; then
    GEOTIFF_SETTING=internal
  else
    dnl We now require libgeotiff 1.2.1 (for XTIFFClientOpen). 
    AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,GEOTIFF_SETTING=internal)

  fi

  if test "$GEOTIFF_SETTING" = "external" ; then   

    dnl Now search for headers
    if test -r /usr/include/geotiff.h ; then
      GEOTIFF_INCLUDE=
    dnl Debian (at least some versions of it) install in /usr/include/geotiff
    elif test -r /usr/include/geotiff/geotiff.h ; then
      GEOTIFF_INCLUDE="-I/usr/include/geotiff"
    dnl Fedora and OpenSuse in /usr/include/libgeotiff (#4706)
    elif test -r /usr/include/libgeotiff/geotiff.h ; then
      GEOTIFF_INCLUDE="-I/usr/include/libgeotiff"
    else
      AC_CHECK_HEADERS([geotiff.h])
      if test "$ac_cv_header_geotiff_h" = "no" ; then
        AC_MSG_ERROR([cannot find geotiff.h])
      fi
    fi

    LIBS="-lgeotiff $LIBS"
    echo "using pre-installed libgeotiff."

  else

    echo "using internal GeoTIFF code."

  fi

elif test "$with_geotiff" = "internal" ; then

  GEOTIFF_SETTING=internal

  echo "using internal GeoTIFF code."

else

  GEOTIFF_SETTING=external

  dnl We now require libgeotiff 1.2.1 (for XTIFFClientOpen). 
  dnl first check if $with_geotiff/lib has the library:
  AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib)

  if test $GEOTIFF_SETTING = "external" ; then
    LIBS="-L$with_geotiff/lib -lgeotiff $LIBS"
    if test  -d $with_geotiff/include ; then
      EXTRA_INCLUDES="-I$with_geotiff/include $EXTRA_INCLUDES"
    fi
  else
    dnl check if $with_geotiff itself contains the header and library (e.g. as an uninstalled build directory would)
    AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,AC_MSG_ERROR([We require at least GeoTIFF 1.2.1. Consider using the one supplied with GDAL]),-L$with_geotiff)
    if test $GEOTIFF_SETTING = "external" ; then
      LIBS="-L$with_geotiff -lgeotiff $LIBS"
      EXTRA_INCLUDES="-I$with_geotiff $EXTRA_INCLUDES"
    fi
  fi

  echo "using libgeotiff from $with_geotiff."
fi

AC_SUBST(GEOTIFF_SETTING,$GEOTIFF_SETTING)
AC_SUBST(GEOTIFF_INCLUDE,$GEOTIFF_INCLUDE)

dnl ---------------------------------------------------------------------------
dnl Select a JPEG Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(jpeg,[  --with-jpeg[=ARG]       Include JPEG support (ARG=internal, no or path)],,)

if test "$with_jpeg" = "no" ; then

  JPEG_SETTING=no

  echo "jpeg support disabled."

elif test "$with_jpeg" = "yes" -o "$with_jpeg" = "" ; then

  AC_CHECK_LIB(jpeg,jpeg_read_scanlines,JPEG_SETTING=external,JPEG_SETTING=internal,)
  AC_CHECK_HEADERS(jpeglib.h)

  if test "$JPEG_SETTING" = "external" -a "$ac_cv_header_jpeglib_h" = "no" ; then
    JPEG_SETTING=internal
  fi

  if test "$JPEG_SETTING" = "external" -a "$TIFF_SETTING" = "internal" ; then
    AC_MSG_CHECKING([for width_in_blocks in jpeglib.h])

    rm -f conftest.c
    echo '#include <stdio.h>' >> conftest.c
    echo '#include "jpeglib.h"' >> conftest.c
    echo 'int main() { jpeg_component_info *comptr=0; int i; i = comptr->width_in_blocks; }' >> conftest.c
    if test -z "`${CC} -o conftest conftest.c 2>&1`" ; then
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no])
      JPEG_SETTING=internal
    fi
    rm -f conftest*
  fi

  if test "$JPEG_SETTING" = "external" ; then   
    LIBS="-ljpeg $LIBS"
    echo "using pre-installed libjpeg."
  else
    echo "using internal jpeg code."
  fi

elif test "$with_jpeg" = "internal" ; then

  JPEG_SETTING=internal

  echo "using internal jpeg code."

else

  JPEG_SETTING=external
  LIBS="-L$with_jpeg -L$with_jpeg/lib -ljpeg $LIBS"
  EXTRA_INCLUDES="-I$with_jpeg -I$with_jpeg/include $EXTRA_INCLUDES"

  echo "using libjpeg from $with_jpeg."

fi

AC_SUBST(JPEG_SETTING,$JPEG_SETTING)

if test "$JPEG_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="jpeg $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check for BSB in the local tree.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([jpeg12],
	    AS_HELP_STRING([--without-jpeg12],
	       [Disable JPEG 8/12bit TIFF support]),,)

TIFF_JPEG12_ENABLED=no
AC_MSG_CHECKING([for jpeg12])
if test "$with_jpeg12" = yes ; then
    AC_MSG_RESULT([enabled])
    JPEG12_ENABLED=yes

    echo '#include <stdlib.h>' > check_jpeg_abi.c
    echo '#include <stdio.h>' >> check_jpeg_abi.c
    echo '#include "jpeglib.h"' >> check_jpeg_abi.c
    echo '#if JPEG_LIB_VERSION == 62' >> check_jpeg_abi.c
    echo 'int main() { return 0; }' >> check_jpeg_abi.c
    echo '#else' >> check_jpeg_abi.c
    echo '#error "ABI difference"' >> check_jpeg_abi.c
    echo '#endif' >> check_jpeg_abi.c
    if test -z "`${CC} ${CFLAGS} ${EXTRA_INCLUDES} check_jpeg_abi.c -c -o check_jpeg_abi.o 2>&1`" ; then
      TIFF_JPEG12_ENABLED=yes
    else
      TIFF_JPEG12_ENABLED=no
      AC_MSG_WARN([Internal libjpeg12 has not the same ABI as libjpeg 8 bit. Disabling JPEG-in-TIFF 12 bit])
    fi
    rm -f check_jpeg_abi.*

elif test x"$with_jpeg12" = x ; then
    if test "$JPEG_SETTING" = "internal" -a "$TIFF_SETTING" = "internal" ; then
      AC_MSG_RESULT([enabled])
      JPEG12_ENABLED=yes
      TIFF_JPEG12_ENABLED=yes
    else
      JPEG12_ENABLED=no
      AC_MSG_RESULT([disabled, libjpeg or libtiff not internal])
    fi
else
    JPEG12_ENABLED=no
    AC_MSG_RESULT([disabled by user])
fi

AC_SUBST(JPEG12_ENABLED,$JPEG12_ENABLED)
AC_SUBST(TIFF_JPEG12_ENABLED,$TIFF_JPEG12_ENABLED)

dnl ---------------------------------------------------------------------------
dnl Select a GIF Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(gif,[  --with-gif[=ARG]        Include GIF support (ARG=internal, no or path)],,)

if test "$with_gif" = "no" ; then

  GIF_SETTING=no

  echo "gif support disabled."

elif test "$with_gif" = "yes" -o "$with_gif" = "" ; then

  AC_CHECK_LIB(gif,DGifOpenFileName,GIF_SETTING=external,GIF_SETTING=internal,)
  AC_CHECK_HEADERS(gif_lib.h)

  if test "$GIF_SETTING" = "external" ; then   
    LIBS="-lgif $LIBS"
    echo "using pre-installed libgif."
  else
    echo "using internal gif code."
  fi

elif test "$with_gif" = "internal" ; then

  GIF_SETTING=internal

  echo "using internal gif code."

else

  GIF_SETTING=external
  LIBS="-L$with_gif -L$with_gif/lib -lgif $LIBS"
  EXTRA_INCLUDES="-I$with_gif -I$with_gif/include $EXTRA_INCLUDES"

  echo "using libgif from $with_gif."

fi

AC_SUBST(GIF_SETTING,$GIF_SETTING)

if test "$GIF_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="gif $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select an OGDI Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

OGDI_INCLUDE=
export OGDI_INCLUDE

AC_ARG_WITH(ogdi,[  --with-ogdi[=ARG]       Include OGDI support (ARG=path)],,)

if test "$with_ogdi" = "no" ; then

  HAVE_OGDI=no

  echo "ogdi support disabled."

elif test "$with_ogdi" = "yes" -o "$with_ogdi" = "" ; then

  AC_CHECK_HEADERS(ecs.h)

  if test "$ac_cv_header_ecs_h" = "no" ; then
    if test -f "/usr/include/ogdi/ecs.h"; then
        OGDI_INCLUDE="-I/usr/include/ogdi"
    elif test -f "/usr/local/include/ogdi/ecs.h"; then
        OGDI_INCLUDE="-I/usr/local/include/ogdi"
    elif test -f "/usr/include/ecs.h"; then
        OGDI_INCLUDE="-I/usr/include"
    elif test -f "/usr/local/include/ecs.h"; then
        OGDI_INCLUDE="-I/usr/local/include"
    fi
  fi

  if test "$OGDI_INCLUDE" != "" -o "$ac_cv_header_ecs_h" = "yes"; then
    AC_CHECK_LIB(ogdi,cln_GetLayerCapabilities,HAVE_OGDI=yes,HAVE_OGDI=no,)
    if test "$HAVE_OGDI" = "yes" ; then   
      LIBS="-logdi $LIBS"
    else
      dnl For backward compatibility. Retry with ogdi31 as a name
      AC_CHECK_LIB(ogdi31,cln_GetLayerCapabilities,HAVE_OGDI=yes,HAVE_OGDI=no,)
      if test "$HAVE_OGDI" = "yes" ; then   
        LIBS="-logdi31 $LIBS"
      fi
    fi
  else
    HAVE_OGDI=no
  fi

else

  AC_CHECK_LIB(ogdi,cln_GetLayerCapabilities,HAVE_OGDI=yes,HAVE_OGDI=no,-L$with_ogdi -L$with_ogdi/lib -logdi)
  if test "$HAVE_OGDI" = "yes" ; then
    if test -f "$with_ogdi/ecs.h" -o -f "$with_ogdi/include/ecs.h"; then
        LIBS="-L$with_ogdi -L$with_ogdi/lib -logdi $LIBS"
        OGDI_INCLUDE="-I$with_ogdi -I$with_ogdi/include"

        echo "using libogdi from $with_ogdi."
     else
        HAVE_OGDI=no
        AC_MSG_ERROR([ecs.h not found.])
     fi
  else
    dnl For backward compatibility. Retry with ogdi31 as a name
    AC_CHECK_LIB(ogdi31,cln_GetLayerCapabilities,HAVE_OGDI=yes,HAVE_OGDI=no,-L$with_ogdi -L$with_ogdi/lib -logdi31)
    if test "$HAVE_OGDI" = "yes" ; then
      if test -f "$with_ogdi/ecs.h" -o -f "$with_ogdi/include/ecs.h"; then
        LIBS="-L$with_ogdi -L$with_ogdi/lib -logdi31 $LIBS"
        OGDI_INCLUDE="-I$with_ogdi -I$with_ogdi/include"

        echo "using libogdi31 from $with_ogdi."
      else
        HAVE_OGDI=no
        AC_MSG_ERROR([ecs.h not found.])
      fi
    else
      AC_MSG_ERROR([libogdi not found.])
    fi
  fi

fi

AC_SUBST(HAVE_OGDI,$HAVE_OGDI)
AC_SUBST(OGDI_INCLUDE,$OGDI_INCLUDE)

if test "$HAVE_OGDI" != "no" ; then
  OPT_GDAL_FORMATS="ogdi $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select FME_HOME or disable FME support.
dnl ---------------------------------------------------------------------------

X_FME_HOME=
export X_FME_HOME

AC_ARG_WITH(fme,[  --with-fme[=ARG]        Include FMEObjects support (ARG=FME_HOME path)],,)

AC_MSG_CHECKING([for FMEObjects])

if test "$with_fme" = "no" ; then

  AC_MSG_RESULT([disabled by user])

elif test "$with_fme" = "yes" ; then

  if test "$FME_HOME" = "" ; then
    AC_MSG_ERROR([no, FME_HOME not defined!])
  elif test -f $FME_HOME/fmeobjects/cpp/isession.h ; then 
    AC_MSG_RESULT([yes])
    X_FME_HOME=$FME_HOME
  else
    AC_MSG_ERROR([FME_HOME defined, but $FME_HOME/fmeobjects/cpp/issesion.h not found.])
  fi
    
elif test "$with_fme" = "" ; then

  if test "$FME_HOME" = "" ; then
    AC_MSG_RESULT([no])
  elif test -f $FME_HOME/fmeobjects/cpp/isession.h ; then 
    AC_MSG_RESULT([yes])
    X_FME_HOME=$FME_HOME
  else
    AC_MSG_RESULT([no, FME_HOME defined, but $FME_HOME/fmeobjects/cpp/issesion.h not found.])
  fi
    
else

  if test -f $with_fme/fmeobjects/cpp/isession.h ; then 
    AC_MSG_RESULT([yes])
    X_FME_HOME=$with_fme
  else
    AC_MSG_ERROR([$with_fme/fmeobjects/cpp/issesion.h not found!])
  fi
  
fi

AC_SUBST(X_FME_HOME,$X_FME_HOME)

dnl ---------------------------------------------------------------------------
dnl Select an HDF4 Library to use, or disable driver.
dnl
dnl We assume the user will have libjpeg and libz from other sources when
dnl linking against static HDF4 libraries. 
dnl ---------------------------------------------------------------------------

HDF4_INCLUDE=""

AC_ARG_WITH(hdf4,[  --with-hdf4[=ARG]       Include HDF4 support (ARG=path)],,)

if test x"$with_hdf4" = x"no" ; then

  HAVE_HDF4=no

  echo "hdf4 support disabled."

else

  if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then
dnl Fedora has hdf static libraries in /usr/lib/hdf
    if test -d /usr/lib64/hdf; then
      HDF_LIB_DIR="/usr/lib64/hdf"
    elif test -d /usr/lib/hdf; then
      HDF_LIB_DIR="/usr/lib/hdf"
    else
      HDF_LIB_DIR=""
    fi
  else
    if test -d $with_hdf4/lib ; then
      HDF_LIB_DIR="$with_hdf4/lib"
    else
      HDF_LIB_DIR="$with_hdf4"
    fi
  fi

  ORIG_LIBS="$LIBS"
  if test "$HDF_LIB_DIR" != "" ; then
    LIBS="-L$HDF_LIB_DIR $LIBS"
  fi

dnl Debian supplies the HDF4 library which does not conflict with NetCDF.
dnl Test for Debian flavor first. Hint: install the libhdf4-alt-dev package.
  AC_CHECK_LIB(mfhdfalt,SDreaddata,HDF_LIB_NAME="-lmfhdfalt -ldfalt",HDF_LIB_NAME=missing,-ldfalt)

dnl If it fails, test again for normal libmfhdf/libdf
  if test "$HDF_LIB_NAME" = "missing" ; then
    unset ac_cv_lib_mfhdf_SDreaddata
    AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf",HDF_LIB_NAME=missing,-ldf)
    if test "$HDF_LIB_NAME" = "missing" ; then
      unset ac_cv_lib_mfhdf_SDreaddata
      AC_CHECK_LIB(hdf4,SDreaddata,HDF_LIB_NAME=-lhdf4,HDF_LIB_NAME=missing,)
    fi
  fi

dnl Test again, with -ldf, -ljpeg and -lz this time.
  if test "$HDF_LIB_NAME" = "missing" ; then
    unset ac_cv_lib_mfhdf_SDreaddata
    AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf",HDF_LIB_NAME=missing,-ldf -ljpeg -lz)
  fi

dnl Not found... again, with -lsz.
  if test "$HDF_LIB_NAME" = "missing" ; then
    unset ac_cv_lib_mfhdf_SDreaddata
    AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf -lsz",HDF_LIB_NAME=missing,-ldf -lsz -ljpeg -lz)
  fi

  if test "$HDF_LIB_NAME" != "missing" ; then

    if test "$HDF_LIB_DIR" != "" ; then
      LIBS="-L$HDF_LIB_DIR $HDF_LIB_NAME $ORIG_LIBS"
    else
      LIBS="$HDF_LIB_NAME $ORIG_LIBS"
    fi

  dnl Now search for headers
    if test "$with_hdf4" = "yes" -o "$with_hdf4" = "" -a -r /usr/include/hdf/hdf.h ; then
      HDF4_INCLUDE="-I/usr/include/hdf"
    elif test -r "$with_hdf4/hdf/hdf.h" ; then
      HDF4_INCLUDE="-I$with_hdf4/hdf"
    elif test -r "$with_hdf4/include/hdf/hdf.h" ; then
      HDF4_INCLUDE="-I$with_hdf4/include/hdf"
    elif test -r "$with_hdf4/include/hdf.h" ; then
      HDF4_INCLUDE="-I$with_hdf4/include"
    elif test -r "$with_hdf4/hdf.h" ; then
      HDF4_INCLUDE="-I$with_hdf4"
    fi

    HAVE_HDF4=yes

  else

    if test x"$with_hdf4" != x"" ; then
      AC_MSG_ERROR([HDF4 support requested with arg "$with_hdf4", but neither hdf4 nor mfhdf lib found])
    else
      LIBS="$ORIG_LIBS"
      HAVE_HDF4=no
    fi

  fi

fi

AC_SUBST(HAVE_HDF4,$HAVE_HDF4)
AC_SUBST(HDF4_INCLUDE,$HDF4_INCLUDE)

if test "$HAVE_HDF4" != "no" ; then
  OPT_GDAL_FORMATS="hdf4 $OPT_GDAL_FORMATS"
fi


dnl ---------------------------------------------------------------------------
dnl Select an HDF5 Library to use, or disable driver.
dnl
dnl ---------------------------------------------------------------------------

HDF5_INCLUDE=""

AC_ARG_WITH(hdf5,[  --with-hdf5[=ARG]       Include HDF5 support (ARG=path)],,)

if test "$with_hdf5" = "no" ; then

  HAVE_HDF5=no

  echo "hdf5 support disabled."

elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then

  AC_CHECK_LIB(hdf5,H5Fopen,HAVE_HDF5=yes,HAVE_HDF5=no,)

  if test "$HAVE_HDF5" = "yes" ; then   
    LIBS="-lhdf5 $LIBS"
  fi

dnl Some Linux distros install hdf include files here. 
  if test "$HAVE_HDF5" = "yes" -a -r /usr/include/hdf5.h ; then
    HDF5_INCLUDE="-I/usr/include"
  fi

else

  if test -d $with_hdf5/lib ; then
    HDF5_LIB_DIR=$with_hdf5/lib
  else
    HDF5_LIB_DIR=$with_hdf5
  fi

  ORIG_LIBS="$LIBS"
  LIBS="-L$HDF5_LIB_DIR $LIBS -lhdf5"

  AC_CHECK_LIB(hdf5,H5Fopen,HDF5_LIB_NAME="-lhdf5 ",HDF5_LIB_NAME=missing,-lhdf5)

  if test "$HDF5_LIB_NAME" = "missing" ; then
    AC_MSG_ERROR([HDF5 support requested with arg $with_hdf5, but no hdf5 lib found])
  fi

  LIBS="-L$HDF5_LIB_DIR $HDF5_LIB_NAME $ORIG_LIBS"

  if test -r "$with_hdf5/hdf5/hdf5.h" ; then
    HDF5_INCLUDE="-I$with_hdf5/hdf5"
  elif test -r "$with_hdf5/include/hdf5/hdf5.h" ; then
    HDF5_INCLUDE="-I$with_hdf5/include/hdf5"
  elif test -r "$with_hdf5/include/hdf5.h" ; then
    HDF5_INCLUDE="-I$with_hdf5/include"
  elif test -r "$with_hdf5/hdf.h" ; then
    HDF5_INCLUDE="-I$with_hdf5"
  fi

  HAVE_HDF5=yes
fi

AC_SUBST(HAVE_HDF5,$HAVE_HDF5)
AC_SUBST(HDF5_INCLUDE,$HDF5_INCLUDE)

if test "$HAVE_HDF5" != "no" ; then
  OPT_GDAL_FORMATS="hdf5 $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if netcdf library is available.
dnl ---------------------------------------------------------------------------

NETCDF_SETTING=
NETCDF_ROOT=
NETCDF_HAS_NC4=
NETCDF_HAS_HDF4=
NETCDF_NCCONFIG=

AC_ARG_WITH([netcdf],[  --with-netcdf[=ARG]     Include netCDF support (ARG=no or netCDF tree prefix)],,)

if test "$with_netcdf" = "no" ; then

  NETCDF_SETTING=no

  echo "netCDF support disabled."

else

  dnl find nc-config location
  unset ac_cv_path_NETCDF_NCCONFIG
  if test "$with_netcdf" = "yes" -o "$with_netcdf" = "" ; then
    AC_PATH_PROG(NETCDF_NCCONFIG, nc-config, no)
  else
    tmp_path="$with_netcdf/bin$PATH_SEPARATOR$with_netcdf"
    AC_PATH_PROG(NETCDF_NCCONFIG, nc-config, no, $tmp_path)
  fi

  dnl test nc-config
  if test "$NETCDF_NCCONFIG" = "no" ; then
    echo "        did not find nc-config, some features may be missing"
    echo "        use --with-netcdf=/path/to/netcdf or add nc-config to PATH"
    NETCDF_NCCONFIG=
  elif test "`$NETCDF_NCCONFIG --version`" = "" ; then
    echo "did not get netCDF version from $NETCDF_NCCONFIG ... using fallback"
    NETCDF_NCCONFIG=
  fi
  
  dnl test linking using flags from nc-config
  if test "$NETCDF_NCCONFIG" != "" ; then

    AC_MSG_CHECKING([libnetcdf compiler and linker flags with nc-config])
    NETCDF_VERSION=`$NETCDF_NCCONFIG --version`
    NETCDF_PREFIX=`$NETCDF_NCCONFIG --prefix`
    NETCDF_INCLUDEDIR=`$NETCDF_NCCONFIG --includedir`
    NETCDF_LIBS=`$NETCDF_NCCONFIG --libs` 
    echo ""
    AC_MSG_RESULT([ got version="$NETCDF_VERSION", prefix="$NETCDF_PREFIX", 
 libs="$NETCDF_LIBS", includedir="$NETCDF_INCLUDEDIR"])

    AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no], $NETCDF_LIBS)

    if test "$NETCDF_SETTING" = "yes" ; then
      EXTRA_INCLUDES="-I$NETCDF_INCLUDEDIR $EXTRA_INCLUDES"
      NETCDF_ROOT=$NETCDF_PREFIX
      LIBS="$NETCDF_LIBS $LIBS"
    fi

dnl previous behaviour without nc-config

dnl test linking using default settings
elif test "$with_netcdf" = "yes" -o "$with_netcdf" = "" ; then

  AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no],)

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

    dnl Fedora has netcdf headers in /usr/include/netcdf
    if test -d /usr/include/netcdf ; then
      EXTRA_INCLUDES="-I/usr/include/netcdf $EXTRA_INCLUDES"
      NETCDF_ROOT="/usr"
    dnl RHEL 5 has netcdf headers in /usr/include/netcdf-3
    elif test -d /usr/include/netcdf-3 ; then
      EXTRA_INCLUDES="-I/usr/include/netcdf-3 $EXTRA_INCLUDES"
      NETCDF_ROOT="/usr"
    dnl ubuntu and fedora have netcdf headers in /usr/include
    elif test -f /usr/include/netcdf.h ; then
      NETCDF_ROOT="/usr"
    dnl try /usr/local
    elif test -f /usr/local/include/netcdf.h ; then
      NETCDF_ROOT="/usr/local"
    dnl print warning if include cannot be found
    else
      echo "using pre-installed libnetcdf."
      echo -n "libnetcdf is installed but its location cannot be found, "
      echo "use --with-netcdf=/path_to_netcdf for proper support"
    fi

    LIBS="-lnetcdf $LIBS"
    if test "$NETCDF_ROOT" != "" ; then
      echo "using pre-installed libnetcdf from "$NETCDF_ROOT
    fi

  else
    echo "libnetcdf not found ... netCDF support disabled"
  fi

dnl test linking using --with_netcdf dir
else

  AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no],-L$with_netcdf -L$with_netcdf/lib)

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

    NETCDF_SETTING=yes
    NETCDF_ROOT="$with_netcdf"

    if test -d $with_netcdf/lib ; then
      LIBS="-L$with_netcdf/lib -lnetcdf $LIBS"
      EXTRA_INCLUDES="-I$with_netcdf/include $EXTRA_INCLUDES"
    else
      LIBS="-L$with_netcdf -lnetcdf $LIBS"
      EXTRA_INCLUDES="-I$with_netcdf $EXTRA_INCLUDES"
    fi

    echo "using libnetcdf from $with_netcdf"

  else
    echo "libnetcdf not found in "$with_netcdf" ... netCDF support disabled"
  fi

fi

dnl test for NC4 and HDF4 support with nc-config
  if test "$NETCDF_SETTING" = "yes" ; then

    if test "$NETCDF_NCCONFIG" != "" ; then

      AC_MSG_CHECKING([for netcdf-4 (and HDF5) support in libnetcdf])
        if test "x$($NETCDF_NCCONFIG --has-nc4)" = "xyes"; then :
          AC_MSG_RESULT([yes])
          NETCDF_HAS_NC4=yes
        else
          AC_MSG_RESULT([no])
          NETCDF_HAS_NC4=no
        fi

      AC_MSG_CHECKING([for HDF4 support in libnetcdf])
        if test "x$($NETCDF_NCCONFIG --has-hdf4)" = "xyes"; then :
          AC_MSG_RESULT([yes])
          NETCDF_HAS_HDF4=yes
        else
          AC_MSG_RESULT([no])
          NETCDF_HAS_HDF4=no
        fi

    else
      NETCDF_HAS_NC4=no
      NETCDF_HAS_HDF4=no
    fi
fi

fi

dnl export results

AC_SUBST([NETCDF_SETTING], [$NETCDF_SETTING])

if test "$NETCDF_SETTING" != "no" ; then

   AC_SUBST([NETCDF_ROOT], [$NETCDF_ROOT])
   AC_SUBST([NETCDF_HAS_NC4], [$NETCDF_HAS_NC4])
   AC_SUBST([NETCDF_HAS_HDF4], [$NETCDF_HAS_HDF4])

   OPT_GDAL_FORMATS="netcdf $OPT_GDAL_FORMATS"

fi


dnl ---------------------------------------------------------------------------
dnl Select a JasPer Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(jasper,[  --with-jasper[=ARG]     Include JPEG-2000 support via JasPer library (ARG=path)],,)

if test "$with_jasper" = "no" ; then

  HAVE_JASPER=no

  AC_MSG_NOTICE([JasPer (JPEG2000) support disabled.])

elif test "$with_jasper" = "yes" -o "$with_jasper" = "" ; then

  AC_CHECK_LIB(jasper,jpc_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)
  AC_CHECK_LIB(jasper,jp2_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)
  AC_CHECK_LIB(jasper,pgx_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)

  if test "$HAVE_JASPER" = "yes" ; then   
    LIBS="-ljasper $LIBS"
  fi
else

  HAVE_JASPER=yes
  LIBS="-L$with_jasper -L$with_jasper/lib -ljasper $LIBS"
  EXTRA_INCLUDES="-I$with_jasper -I$with_jasper/include $EXTRA_INCLUDES"

  AC_MSG_NOTICE([using JasPer library from $with_jasper.])
fi

if test "$HAVE_JASPER" != "no" ; then
  OPT_GDAL_FORMATS="jpeg2000 $OPT_GDAL_FORMATS"
  
  dnl Test whether we have UUID JasPer hack

  AC_CHECK_LIB(jasper,jp2_encode_uuid,HAVE_JASPER_UUID=yes,HAVE_JASPER_UUID=no,)

  if test "$HAVE_JASPER_UUID" = "yes" ; then
    AC_MSG_NOTICE([hacked JasPer version found (JasPer UUID), GeoJP2 enabled.])
    JASPER_FLAGS=-DHAVE_JASPER_UUID
  else
    AC_MSG_NOTICE([hacked JasPer version not found, GeoJP2 disabled.])
  fi
fi

AC_SUBST([HAVE_JASPER],$HAVE_JASPER)
AC_SUBST([JASPER_FLAGS],$JASPER_FLAGS)


dnl ---------------------------------------------------------------------------
dnl Select a OpenJPEG Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(openjpeg,[  --with-openjpeg[=ARG]     Include JPEG-2000 support via OpenJPEG 2.0 library (ARG=path)],,)

HAVE_OPENJPEG=no

if test "$with_openjpeg" = "no" ; then

  AC_MSG_NOTICE([OpenJPEG (JPEG2000) support disabled.])

elif test "$with_openjpeg" = "yes" -o "$with_openjpeg" = "" ; then

  AC_CHECK_HEADERS([openjpeg-2.0/openjpeg.h])
  if test "$ac_cv_header_openjpeg_2_0_openjpeg_h" = "yes"; then
    AC_CHECK_LIB(openjp2,opj_stream_set_user_data_length,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,)
    if test "$HAVE_OPENJPEG" = "yes"; then
        LIBS="-lopenjp2 $LIBS"
    fi
  fi
else

  HAVE_OPENJPEG=yes
  if test -r $with_openjpeg/include/openjpeg-2.0/openjpeg.h ; then
    EXTRA_INCLUDES="-I$with_openjpeg/include $EXTRA_INCLUDES"
  else
    AC_MSG_ERROR([openjpeg.h not found in $with_openjpeg/include/openjpeg-2.0])
  fi

  AC_CHECK_LIB(openjp2,opj_stream_set_user_data_length,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,-L$with_openjpeg/lib)

  if test "$HAVE_OPENJPEG" = "yes"; then
      LIBS="-L$with_openjpeg/lib -lopenjp2 $LIBS"
      AC_MSG_NOTICE([using OpenJPEG v2 library from $with_openjpeg.])
  fi
fi

if test "$HAVE_OPENJPEG" != "no" ; then
  OPT_GDAL_FORMATS="openjpeg $OPT_GDAL_FORMATS"
fi

AC_SUBST([HAVE_OPENJPEG],$HAVE_OPENJPEG)


dnl ---------------------------------------------------------------------------
dnl Select a FGDB API to use, or disable driver.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(fgdb,[  --with-fgdb[=ARG]        Include ESRI File Geodatabase support (ARG=FGDP API Path, yes or no)],,)

FGDB_ENABLED=no

if test "$with_fgdb" = "no" ; then

  echo "FGDB support disabled."

elif test "$with_fgdb" = "yes" -o "$with_fgdb" = "" ; then

    AC_MSG_CHECKING([for FileGDBAPI])

    rm -f testfgdb.*
    rm -f testfgdb
    echo "#include <FileGDBAPI.h>" > testfgdb.cpp
    echo "using namespace FileGDBAPI;" >> testfgdb.cpp
    echo "int main() { Geodatabase oDB; std::wstring osStr; ::OpenGeodatabase(osStr, oDB); return 0; }" >> testfgdb.cpp
    if test -z "`${CXX} ${CPPFLAGS} testfgdb.cpp -lFileGDBAPI -o testfgdb 2>&1`" ; then
        AC_MSG_RESULT([FileGDBAPI found])
        FGDB_ENABLED="yes"
        FGDB_LIB="-lFileGDBAPI"
    else
        if test "$with_fgdb" = "yes"; then
            AC_MSG_ERROR([FileGDBAPI not found.])
        else
            AC_MSG_RESULT([FileGDBAPI not found.])
        fi
    fi
    rm -f testfgdb.*
    rm -f testfgdb

else

  AC_MSG_CHECKING([for libFileGDBAPI.so in in $with_fgdb/lib])
  FGDB_ENABLED=yes
  if test -r $with_fgdb/lib/libFileGDBAPI.so ; then
    AC_MSG_RESULT([found.])
    FGDB_LIB="-L$with_fgdb/lib -lFileGDBAPI"
  else
    AC_MSG_ERROR([not found.])
  fi

  AC_MSG_CHECKING([for FileGDBAPI.h in $with_fgdb/include])
  if test -r $with_fgdb/include/FileGDBAPI.h ; then  
    AC_MSG_RESULT([found.])
    FGDB_INC="-I$with_fgdb/include"
  else
    AC_MSG_ERROR([not found.])
  fi

fi

AC_SUBST(FGDB_ENABLED, $FGDB_ENABLED)
AC_SUBST(FGDB_LIB, $FGDB_LIB)
AC_SUBST(FGDB_INC, $FGDB_INC)

dnl ---------------------------------------------------------------------------
dnl Select a ECW Library to use, or disable driver.
dnl ---------------------------------------------------------------------------
ECW_FLAGS=
ECW_LIBS=
ECW_INCLUDE=

AC_ARG_WITH(ecw,[  --with-ecw[=ARG]        Include ECW support (ARG=ECW SDK Path, yes or no)],,)

if test ! -z "`uname | grep Darwin`" ; then
  CARBON_FRAMEWORK="-framework Carbon"
else
  CARBON_FRAMEWORK=
fi

if test "$with_ecw" = "no" ; then

  ECW_SETTING=no

  echo "ECW support disabled."

elif test "$with_ecw" = "yes" -o "$with_ecw" = "" ; then

  AC_CHECK_LIB(NCSEcw,NCScbmOpenFileView,ECW_SETTING=yes,ECW_SETTING=no,-lNCSCnet -lNCSUtil)

  if test "$ECW_SETTING" = "yes" ; then   
    ECW_LIBS="-lNCSEcw -lNCSEcwC -lNCSCnet -lNCSUtil"
  fi

  if test "$ECW_SETTING" = "no" ; then
    AC_CHECK_LIB(ecwj2,NCScbmOpenFileView,ECW_SETTING=yes,ECW_SETTING=no,$CARBON_FRAMEWORK)
    if test "$ECW_SETTING" = "yes" ; then   
      ECW_LIBS="-lecwj2 $CARBON_FRAMEWORK"
    fi
  fi

else

  AC_MSG_CHECKING([for libNCSEcw.so or libecwj2])
  ECW_SETTING=yes
  if test -r $with_ecw/lib/libNCSCnet.so -o -r $with_ecw/lib/libNCSCnet.dylib ; then
    ECW_LIBS="-L$with_ecw/lib -lNCSEcw -lNCSEcwC -lNCSCnet -lNCSUtil"
    AC_MSG_RESULT([found in $with_ecw/lib.])
  elif test -r $with_ecw/lib/libNCSCNet.so -o -r $with_ecw/lib/libNCSCNet.dylib ; then
    ECW_LIBS="-L$with_ecw/lib -lNCSEcw -lNCSEcwC -lNCSCNet -lNCSUtil"
    AC_MSG_RESULT([found in $with_ecw/lib.])
  elif test -r $with_ecw/bin/libNCSEcw.so -o -r $with_ecw/bin/libNCSEcw.dylib ; then
    ECW_LIBS="-L$with_ecw/bin -lNCSEcw -lNCSEcwC -lNCSCnet -lNCSUtil"
    AC_MSG_RESULT([found in $with_ecw/bin.])
  elif test -r $with_ecw/lib/libecwj2.dylib ; then
    ECW_LIBS="-L$with_ecw/lib -lecwj2 $CARBON_FRAMEWORK"
    AC_MSG_RESULT([found libecwj2 in $with_ecw/lib.])

  # ECW SDK 5.0 style
  elif test -r $with_ecw/lib/x64/release/libNCSEcw.so ; then
    if test `arch` == "x86_64" ; then
      ECW_LIBDIR=$with_ecw/lib/x64/release
    else
      ECW_LIBDIR=$with_ecw/lib/x86/release
    fi
    ECW_FLAGS="-DLINUX -DX86 -DPOSIX -DHAVE_COMPRESS -DECW_COMPRESS_RW_SDK_VERSION"
    ECW_LIBS="-L$ECW_LIBDIR -lNCSEcw"
    AC_MSG_RESULT([found Intergraph 5.x+ SDK in ${ECW_LIBDIR}.])
  else
    AC_MSG_ERROR([not found in $with_ecw/lib or $with_ecw/bin.])
  fi

  AC_MSG_CHECKING([for NCSECWClient.h in $with_ecw/include])
  if test -r $with_ecw/include/NCSECWClient.h ; then  
    AC_MSG_RESULT([found.])
    ECW_INCLUDE="-I$with_ecw/include"
  else
    AC_MSG_ERROR([not found.])
  fi
  AC_MSG_CHECKING([for ECWJP2BuildNumber.h in $with_ecw/include])
  if test -r $with_ecw/include/ECWJP2BuildNumber.h ; then  
    AC_MSG_RESULT([found.])
    ECW_FLAGS="-DHAVE_ECW_BUILDNUMBER_H $ECW_FLAGS"
  else
    AC_MSG_RESULT([not found.])
  fi
fi

AC_SUBST(ECW_SETTING,$ECW_SETTING)
AC_SUBST(ECW_LIBS,$ECW_LIBS)
AC_SUBST(ECW_FLAGS,$ECW_FLAGS)
AC_SUBST(ECW_INCLUDE,$ECW_INCLUDE)

if test "$ECW_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="ecw $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select Kakadu library or disable driver.
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([for Kakadu JPEG2000 support])

AC_ARG_WITH(kakadu,[  --with-kakadu[=ARG]     Include Kakadu/JPEG2000 support],,)

if test "$with_kakadu" = "no" -o "$with_kakadu" = "" ; then
  KAKDIR=
  AC_MSG_RESULT([not requested.])
  HAVE_KAKADU=no
elif test "$with_kakadu" = "yes" ; then
  AC_MSG_ERROR([
For JPEG2000 support using Kakadu you need provide the path to the Kakadu 
build directory.  Note that Kakadu is *not* free software.])
else
  KAKDIR=$with_kakadu
  OPT_GDAL_FORMATS="jp2kak jpipkak $OPT_GDAL_FORMATS"
  LIBS="$LIBS -L$with_kakadu/lib -lkdu"
  AC_MSG_RESULT([requested.])
  HAVE_KAKADU=yes
fi

AC_SUBST(KAKDIR,$KAKDIR)

dnl ---------------------------------------------------------------------------
dnl Select MrSID library or disable driver.
dnl ---------------------------------------------------------------------------
MRSID_FLAGS=
HAVE_MRSID=no

AC_ARG_WITH(mrsid,[  --with-mrsid[=ARG]      Include MrSID support (ARG=path to MrSID DSDK or no)],,)

AC_ARG_WITH(jp2mrsid,[  --with-jp2mrsid[=ARG]   Enable MrSID JPEG2000 support (ARG=yes/no)],,)

if test "x$with_mrsid" = "xno"  -o "x$with_mrsid" = "x" ; then

  HAVE_MRSID=no

  AC_MSG_NOTICE([MrSID support disabled.])

else

  MRSID_BASE="$with_mrsid/include"

  AC_MSG_CHECKING([for lt_base.h in $MRSID_BASE/support])
  if test -r "$MRSID_BASE/support/lt_base.h" ; then

    AC_MSG_RESULT([found MrSID DSDK version 4.x or newer.])
    HAVE_MRSID=yes
    MRSID_INCLUDE="-I$MRSID_BASE/base -I$MRSID_BASE/metadata -I$MRSID_BASE/mrsid_readers -I$MRSID_BASE/j2k_readers -I$MRSID_BASE/support"

  else

    AC_MSG_RESULT([not found.])

    AC_MSG_CHECKING([for lt_base.h in $MRSID_BASE])
    if test -r "$MRSID_BASE/lt_base.h" ; then

      AC_MSG_RESULT([found MrSID DSDK version 7.x or newer.]);
      HAVE_MRSID=yes
      MRSID_INCLUDE="-I$MRSID_BASE"

    fi

  fi

  if test $HAVE_MRSID = yes ; then

    MRSID_LIBS="-lpthread"

    if test -r "$with_mrsid/lib/libltiesdk.a" ; then # v8+ esdk contains dsdk
      _LIBPART=lib
      MRSID_LIBS="-lltiesdk $MRSID_LIBS"
    elif test -e "$with_mrsid/lib/libltidsdk.a" \
           -o -e "$with_mrsid/lib/libltidsdk.so" \
           -o -e "$with_mrsid/lib/libltidsdk.dylib" ; then
      _LIBPART=lib
      MRSID_LIBS="-lltidsdk $MRSID_LIBS"
    else
      _LIBPART=lib/Release
      MRSID_LIBS="-lltidsdk $MRSID_LIBS"
    fi

    AC_MSG_CHECKING([for MG3ImageWriter.h in $with_mrsid/include/mrsid_writers])
    if test -r "$with_mrsid/include/mrsid_writers/MG3ImageWriter.h" ; then
      AC_MSG_RESULT([found MrSID ESDK version 4.x or newer.])
      MRSID_FLAGS="-DMRSID_ESDK $MRSID_FLAGS"
      MRSID_INCLUDE="-I$with_mrsid/include/mrsid_writers -I$with_mrsid/include/j2k_writers $MRSID_INCLUDE"
      if test -r $with_mrsid/3rd-party/lib/Release/libcryptopp.a ; then
        MRSID_LIBS="-lltiesdk -lcryptopp -lxmlparse $MRSID_LIBS"
      else
        MRSID_LIBS="-lltiesdk -lxmlparse $MRSID_LIBS"
      fi
    else
      AC_MSG_RESULT([no encoding support.])
    fi

    AC_MSG_CHECKING([for MrSID JPEG2000 support])
    if test "x$with_jp2mrsid" = "xyes" -a "$HAVE_KAKADU" = "yes" ; then
      AC_MSG_ERROR([MrSID JPEG2000 support requested, but this is incompatible with use of standalone Kakadu])
    fi

    MRSID_KAKADU_LIB=""
    if test "$HAVE_KAKADU" = "no" ; then
      if test x"$with_jp2mrsid" = x"" -o x"$with_jp2mrsid" = x"yes" ; then
        if test -r "$with_mrsid/3rd-party/$_LIBPART/libltikdu.a" ; then 
          with_jp2mrsid=yes
          MRSID_KAKADU_LIB=-lltikdu
        elif test -r "$with_mrsid/3rd-party/$_LIBPART/liblt_kakadu.a" ; then 
          with_jp2mrsid=yes
          MRSID_KAKADU_LIB=-llt_kakadu
        elif test -e "$with_mrsid/lib/libltidsdk.so" \
               -o -e "$with_mrsid/lib/libltidsdk.dylib"; then # v8+ .so has kdu
          with_jp2mrsid=yes
        elif test x"$with_jp2mrsid" = x"yes" ; then
          AC_MSG_ERROR([MrSID JPEG2000 support requested, but libltikdu.a not found.])
        else
          with_jp2mrsid=no
        fi
      fi
    fi

    if test "x$with_jp2mrsid" = "xyes" ; then
      MRSID_LIBS="$MRSID_LIBS $MRSID_KAKADU_LIB"
      MRSID_FLAGS="-DMRSID_J2K $MRSID_FLAGS"
      AC_MSG_RESULT([enabled])
    else
      AC_MSG_RESULT([disabled])
    fi

    MRSID_LIBS="-L$with_mrsid/$_LIBPART $MRSID_LIBS"
    MRSID_LIBS="-L$with_mrsid/3rd-party/$_LIBPART $MRSID_LIBS"

  else
    HAVE_MRSID=no
    AC_MSG_RESULT([not found.])
    AC_MSG_ERROR([  MrSID requested, but components not found.])
  fi
fi

AC_SUBST(MRSID_INCLUDE,$MRSID_INCLUDE)
AC_SUBST(MRSID_FLAGS,$MRSID_FLAGS)
AC_SUBST(MRSID_LIBS,$MRSID_LIBS)

if test "$HAVE_MRSID" != "no" ; then
  CPPFLAGS="-D_REENTRANT $CPPFLAGS"
  OPT_GDAL_FORMATS="mrsid $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Select MrSID/MG4 Lidar library or disable driver.
dnl ---------------------------------------------------------------------------

MRSID_LIDAR_FLAGS=
HAVE_MRSID_LIDAR=no

AC_ARG_WITH(mrsid_lidar,[  --with-mrsid_lidar[=ARG]      Include MrSID/MG4 LiDAR support (ARG=path to LizardTech LiDAR SDK or no)],,)

if test "x$with_mrsid_lidar" = "xno"  -o "x$with_mrsid_lidar" = "x" ; then
  HAVE_MRSID_LIDAR=no
  AC_MSG_NOTICE([MrSID/MG4 Lidar support disabled.])
else
  MRSID_LIDAR_BASE="$with_mrsid_lidar"

  if test -r "$MRSID_LIDAR_BASE/include/lidar/Version.h" ; then
    AC_MSG_RESULT([found LizardTech LiDAR SDK 1.1 or newer.])
    HAVE_MRSID_LIDAR=yes
  else
    HAVE_MRSID_LIDAR=no
    AC_MSG_RESULT([not found.])
    AC_MSG_ERROR([  MrSID/MG4 Lidar requested, but components not found.])
  fi

  if test $HAVE_MRSID_LIDAR = yes ; then
    if test -e "$MRSID_LIDAR_BASE/lib/liblti_lidar_dsdk.so" \
         -o -e "$MRSID_LIDAR_BASE/lib/liblti_lidar_dsdk.dylib"; then
      MRSID_LIDAR_LIBS="-L$MRSID_LIDAR_BASE/lib -llti_lidar_dsdk"
      MRSID_LIDAR_INCLUDE="-I$MRSID_LIDAR_BASE/include"
    else
      MRSID_LIDAR_LIBS="-L$MRSID_LIDAR_BASE/lib/Release -llti_lidar_dsdk"
      MRSID_LIDAR_INCLUDE="-I$MRSID_LIDAR_BASE/include"
    fi
  fi
fi

AC_SUBST(MRSID_LIDAR_INCLUDE,$MRSID_LIDAR_INCLUDE)
AC_SUBST(MRSID_LIDAR_LIBS,$MRSID_LIDAR_LIBS)

if test "$HAVE_MRSID_LIDAR" != "no" ; then
  OPT_GDAL_FORMATS="mrsid_lidar $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Enable MSG format if EUMETSAT Wavelet Transform Software
dnl available in the local tree
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([msg],
	    AS_HELP_STRING([--with-msg[=ARG]],
	       [Enable MSG driver (ARG=yes or no)]),,)

HAVE_MSG=no
HAVE_EUMETSATWT=no

if test "x$with_msg" = "xyes" ; then 
    AC_MSG_CHECKING([for EUMETSAT Wavelet Transformation Software])

    if test -d "frmts/msg/PublicDecompWT" -a \
        -f "frmts/msg/PublicDecompWT/COMP/Inc/CImage.h"; then
        HAVE_EUMETSATWT=yes
    else
        HAVE_EUMETSATWT=no
    fi
    AC_MSG_RESULT([$HAVE_EUMETSATWT])
fi

AC_MSG_CHECKING([for MSG])

if test "x$with_msg" = "xyes" -o "x$with_msg" = "x" \
    -a "x$HAVE_EUMETSATWT" = "xyes"; then 
    OPT_GDAL_FORMATS="msg $OPT_GDAL_FORMATS"
    HAVE_MSG=yes
    AC_MSG_RESULT([enabled])
else
    HAVE_MSG=no
    AC_MSG_RESULT([not requested])
fi


dnl ---------------------------------------------------------------------------
dnl Check for BSB in the local tree.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([bsb],
	    AS_HELP_STRING([--without-bsb],
	       [Disable BSB driver (legal issues pending]),,)

AC_MSG_CHECKING([for BSB])
if test "$with_bsb" = yes -o x"$with_bsb" = x ; then
    OPT_GDAL_FORMATS="bsb $OPT_GDAL_FORMATS"
    AC_MSG_RESULT([enabled])
else
    AC_MSG_RESULT([disabled by user])
fi

dnl ---------------------------------------------------------------------------
dnl Check for GeoRaster in the local tree.
dnl ---------------------------------------------------------------------------

ORACLE_OCI_REQ_VERSION="10.0.1"
AX_LIB_ORACLE_OCI($ORACLE_OCI_REQ_VERSION)

if test "$HAVE_ORACLE_OCI" = "yes"; then
    OPT_GDAL_FORMATS="georaster $OPT_GDAL_FORMATS"
    HAVE_GEORASTER=yes
else
    HAVE_GEORASTER=no
fi

dnl ---------------------------------------------------------------------------
dnl Check for GRIB in the local tree.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH([grib],
	    AS_HELP_STRING([--without-grib],
	       [Disable GRIB driver]),,)

AC_MSG_CHECKING([for GRIB])
if test "$with_grib" = yes -o x"$with_grib" = x ; then
    OPT_GDAL_FORMATS="grib $OPT_GDAL_FORMATS"
    HAVE_GRIB=yes
    AC_MSG_RESULT([enabled])
else
    HAVE_GRIB=no
    AC_MSG_RESULT([disabled by user])
fi


dnl ---------------------------------------------------------------------------

AC_SUBST([OPT_GDAL_FORMATS], [$OPT_GDAL_FORMATS])

dnl ---------------------------------------------------------------------------

AC_ARG_WITH(ogr,[  --without-ogr         Don't build OGR into shared library],,)

if test "$with_ogr" = yes -o x"$with_ogr" = x ; then
  echo checking for OGR ... enabled
  OGR_ENABLED=yes
else
  echo checking for OGR ... disabled by user
  OGR_ENABLED=no
fi
AC_SUBST(OGR_ENABLED,$OGR_ENABLED)

dnl ---------------------------------------------------------------------------
dnl Select an MySQL Library to use, or disable driver.
dnl ---------------------------------------------------------------------------

MYSQL_CONFIG=no

AC_ARG_WITH(mysql,[  --with-mysql[=ARG]      Include MySQL (ARG=path to mysql_config) [[default=no]]],,)

if test "$with_mysql" = "yes" ; then
  AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no)
else
    if test "x$with_mysql" != "x" ; then
      MYSQL_CONFIG=$with_mysql
    fi
fi

AC_MSG_CHECKING([for MySQL])

if test "$MYSQL_CONFIG" = "no" ; then

  HAVE_MYSQL=no
  MYSQL_LIB=
  MYSQL_INC=

  AC_MSG_RESULT([no])

else
  if test -d $MYSQL_CONFIG ; then
      AC_MSG_RESULT([no])
      AC_MSG_ERROR([--with-mysql argument is a directory.  It should be the path to the mysql_config script, often somewhere like /usr/local/bin/mysql_config.])
  fi

  if test \! -x $MYSQL_CONFIG ; then
      AC_MSG_RESULT([no])
      AC_MSG_ERROR([--with-mysql argument is a not an executable file.  It should be the path to the mysql_config script, often somewhere like /usr/local/bin/mysql_config.])
  fi

  MYSQL_VERSION="`$MYSQL_CONFIG --version`"

  case ${MYSQL_VERSION} in 
    [[0-3]*]) 
      HAVE_MYSQL=no
      AC_MSG_RESULT([no, mysql is pre-4.x])
	;;
    *)
      HAVE_MYSQL=yes
      MYSQL_LIB="`$MYSQL_CONFIG --libs`"
      MYSQL_INC="`$MYSQL_CONFIG --include`"
      AC_MSG_RESULT([yes])
	;;
  esac
fi

AC_SUBST(HAVE_MYSQL,$HAVE_MYSQL)
AC_SUBST(MYSQL_INC,$MYSQL_INC)
AC_SUBST(MYSQL_LIB,$MYSQL_LIB)

dnl ---------------------------------------------------------------------------
dnl INGRES support.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(ingres,[  --with-ingres=ARG     Include Ingres (ARG=$II_SYSTEM)],,)

AC_MSG_CHECKING([for Ingres])

if test "$with_ingres" = "no" -o "x$with_ingres" = "x" ; then
  HAVE_INGRES=no
  II_SYSTEM=
  INGRES_LIB=
  INGRES_INC=
  AC_MSG_RESULT([no])
elif test "$with_ingres" = "yes" ; then
  AC_MSG_ERROR([--with-ingres requires a path argument ($II_SYSTEM)])
else
  HAVE_INGRES=yes
  II_SYSTEM=$with_ingres
  INGRES_LIB="-L$II_SYSTEM/ingres/lib \
	$II_SYSTEM/ingres/lib/iiclsadt.o \
	$II_SYSTEM/ingres/lib/iiuseradt.o \
	-liiapi.1 -lcompat.1 -lq.1 -lframe.1" 
  INGRES_INC=-I$II_SYSTEM/ingres/files
fi

AC_SUBST(HAVE_INGRES,$HAVE_INGRES)
AC_SUBST(II_SYSTEM,$II_SYSTEM)
AC_SUBST(INGRES_LIB,$INGRES_LIB)
AC_SUBST(INGRES_INC,$INGRES_INC)

dnl ---------------------------------------------------------------------------
dnl Check for Xerces C++ Parser support.
dnl ---------------------------------------------------------------------------

XERCES_REQ_VERSION="2.7.0"
AX_LIB_XERCES($XERCES_REQ_VERSION)

if test "$HAVE_XERCES" = "yes"; then
    LIBS="$XERCES_LDFLAGS $LIBS"
fi

AC_SUBST([HAVE_XERCES], $HAVE_XERCES)
AC_SUBST([XERCES_INCLUDE], $XERCES_CFLAGS)
  
dnl ---------------------------------------------------------------------------
dnl Enable NAS if we have Xerces.
dnl ---------------------------------------------------------------------------

if test "$HAVE_XERCES" = "yes" ; then
  HAVE_NAS=yes
else
  HAVE_NAS=no
fi
AC_SUBST([HAVE_NAS], $HAVE_NAS)

dnl ---------------------------------------------------------------------------
dnl Check for Expat configuration.
dnl ---------------------------------------------------------------------------

dnl Expat 1.95.0 released in 2000-09-28
EXPAT_REQ_VERSION="1.95.0"
AX_LIB_EXPAT($EXPAT_REQ_VERSION)

if test "$HAVE_EXPAT" = "yes"; then
    LIBS="$EXPAT_LDFLAGS $LIBS"
fi

AC_SUBST([HAVE_EXPAT], $HAVE_EXPAT)
AC_SUBST([EXPAT_INCLUDE], $EXPAT_CFLAGS)

dnl ---------------------------------------------------------------------------
dnl Check for Google libkml support.
dnl ---------------------------------------------------------------------------

LIBKML_REQ_VERSION="1.3.0"
AX_LIB_LIBKML($LIBKML_REQ_VERSION)

if test "$HAVE_LIBKML" = "yes"; then
    LIBS="$LIBKML_LDFLAGS $LIBS"
fi

AC_SUBST([HAVE_LIBKML], $HAVE_LIBKML)
AC_SUBST([LIBKML_INCLUDE], $LIBKML_CFLAGS)
  
dnl ---------------------------------------------------------------------------
dnl Check for ODBC support.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(odbc,[  --with-odbc[=ARG]       Include ODBC support (ARG=no or path)],,)

if test "$with_odbc" = "no" ; then

  ODBC_SETTING=no

  echo "ODBC support disabled."

elif test "$with_odbc" = "yes" -o "$with_odbc" = "" ; then

  AC_CHECK_LIB(odbc,SQLConnect,ODBC_SETTING=yes,ODBC_SETTING=no,)
  AC_CHECK_LIB(odbcinst,SQLInstallDriverEx,ODBC_SETTING=yes,ODBC_SETTING=no,)

  if test "$ODBC_SETTING" = "yes" ; then
    if test -f /usr/local/include/sql.h -o -f /usr/include/sql.h ; then
      ODBC_SETTING=yes
    else
      echo "odbc library found, but sql.h missing, ODBC support disabled." 
      ODBC_SETTING=no
    fi
  fi

  if test "$ODBC_SETTING" = "yes"  ; then   
    LIBS="-lodbc -lodbcinst $LIBS"
  fi

else

  ODBC_SETTING=yes
  LIBS="-L$with_odbc -L$with_odbc/lib -lodbc -lodbcinst $LIBS"
  EXTRA_INCLUDES="-I$with_odbc -I$with_odbc/include $EXTRA_INCLUDES"

  echo "using odbc library from $with_odbc."
fi

AC_SUBST(ODBC_SETTING,$ODBC_SETTING)

dnl ---------------------------------------------------------------------------
dnl Check for OCI support.
dnl ---------------------------------------------------------------------------

ORACLE_OCI_REQ_VERSION="8.1.7"
AX_LIB_ORACLE_OCI($ORACLE_OCI_REQ_VERSION)

if test "$HAVE_ORACLE_OCI" = "yes"; then
    OCI_INCLUDE="$ORACLE_OCI_CFLAGS"
    LIBS="$ORACLE_OCI_LDFLAGS $LIBS"
fi

AC_SUBST([HAVE_OCI], [$HAVE_ORACLE_OCI])
AC_SUBST([OCI_INCLUDE], $[OCI_INCLUDE])

dnl ---------------------------------------------------------------------------
dnl Check for DODS.
dnl ---------------------------------------------------------------------------

HAVE_DODS=no

AC_MSG_CHECKING(Checking for DODS)
AC_ARG_WITH(dods_root,
    [  --with-dods-root[=ARG]  Include DODS support (ARG=no or absolute path)],
    ,,)

if test -z "$with_dods_root" -o "$with_dods_root" = "no"; then
    AC_MSG_RESULT(disabled)
elif test "$with_dods_root" = "yes" ; then
    AC_MSG_ERROR([--with-dods-root requires path to dods root as argument])
else
    DODS_LIB=$with_dods_root/lib
    DODS_INC="-I$with_dods_root/include -I$with_dods_root/include/libdap -I$with_dods_root/include/dap"
    DODS_BIN=$with_dods_root/bin

    dnl Check libdap version the sane way (if possible through dap-config)
    if test -x $DODS_BIN/dap-config ; then
        LIBDAP_VER=`${DODS_BIN}/dap-config --version |awk '{print \$2}'`
        LIBDAP_CFLAGS=`${DODS_BIN}/dap-config --cflags`
        dnl The dods driver needs LIBDAP_320 and LIBDAP_39 defined to include the right headers
        DODS_INC="$DODS_INC $LIBDAP_CFLAGS -DLIBDAP_310 -DLIBDAP_39"
        dnl libs from dap-config gets added further down
        AC_MSG_RESULT([libdap $LIBDAP_VER])
    else
        dnl Check the version by compiling test programs 

        dnl Test if we have libdap >= 3.10
        dnl From libdap 3.10, AISConnect.h has been renamed as Connect.h
        rm -f islibdappost310.*
        echo '#include "Connect.h"' > islibdappost310.cpp
        echo 'int main(int argc, char** argv) { return 0; } ' >> islibdappost310.cpp
        if test -z "`${CXX} islibdappost310.cpp -c ${DODS_INC} ${CPPFLAGS} 2>&1`" ; then
        dnl yes, libdap >= 3.10
            DODS_INC="$DODS_INC -DLIBDAP_310 -DLIBDAP_39"
            AC_MSG_RESULT([libdap >= 3.10])
        else
            AC_MSG_RESULT([libdap < 3.10])

            dnl Test if we have libdap < 3.9
            dnl Before libdap < 3.9, DAS derived from AttrTable class
            dnl I wish they had defines with version numbers instead of this test !
            rm -f islibdappre39.*
            echo '#include "DAS.h"' > islibdappre39.cpp
            echo '#include "AttrTable.h"' >> islibdappre39.cpp
            echo 'using namespace libdap;' >> islibdappre39.cpp
            echo 'int main(int argc, char** argv) { DAS oDAS; AttrTable& oAttrTable = oDAS; } ' >> islibdappre39.cpp
            if test -z "`${CXX} islibdappre39.cpp -c ${DODS_INC} 2>&1`" ; then
            dnl yes, libdap < 3.9
                AC_MSG_RESULT([libdap < 3.9])
            else
                DODS_INC="$DODS_INC -DLIBDAP_39"
                AC_MSG_RESULT([libdap >= 3.9])
            fi
            rm -f islibdappre39.*

        fi
        rm -f islibdappost310.*
    fi


    dnl Add the DODS libraries to LIBS
    if test -x $DODS_BIN/opendap-config ; then 
      dnl OPeNDAP 3.4 and earlier lack opendap-config, but use it if avail.
      LIBS="$LIBS `$DODS_BIN/opendap-config --libs`"
    elif test -x $DODS_BIN/dap-config ; then 
      dnl OPeNDAP 3.4 and earlier lack opendap-config, but use it if avail.
      LIBS="$LIBS `$DODS_BIN/dap-config --libs`"
    else
      dnl Otherwise try to put things together in a more primitive way.
      LIBS="$LIBS -L$DODS_LIB -ldap++ -lpthread -lrx"
    
      dnl Add curl to LIBS; it might be local to DODS or generally installed
      if test -x $DODS_BIN/curl-config; then
          LIBS="$LIBS  `$DODS_BIN/curl-config --libs`"
      elif which curl-config > /dev/null 2>&1; then
          LIBS="$LIBS  `curl-config --libs`"
      else
          AC_MSG_ERROR([You gave a dods root, but I can't find curl!])
      fi

      if test -x $DODS_BIN/xml2-config; then
          LIBS="$LIBS `$DODS_BIN/xml2-config --libs`"
      elif which xml2-config > /dev/null 2>&1; then
          LIBS="$LIBS  `xml2-config --libs`"
      else
          AC_MSG_ERROR([You gave a dods root, but I can't find xml2!])
      fi 
    fi

    OPT_GDAL_FORMATS="dods $OPT_GDAL_FORMATS"
    DODSDEF=-DFRMT_dods
    AC_MSG_RESULT(setting DODS root directory to $with_dods_root)
    HAVE_DODS=yes
fi

dnl This is used by the GNUmakefile in frmts/dods (via GDALmake.opt)
AC_SUBST(DODS_INC)

dnl ---------------------------------------------------------------------------
dnl Check for curl (ie. for wcs).
dnl ---------------------------------------------------------------------------
CURL_SETTING=no
CURL_INC=
CURL_LIB=

AC_ARG_WITH(curl,
    [  --with-curl[=ARG]       Include curl (ARG=path to curl-config.)],,,)

dnl Clear some cache variables
unset ac_cv_path_LIBCURL

if test "`basename xx/$with_curl`" = "curl-config" ; then
  LIBCURL_CONFIG="$with_curl"
elif test "$with_curl" = "no" ; then
  LIBCURL_CONFIG=no
else
  AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no)
fi

if test "$LIBCURL_CONFIG" != "no" ; then

  CURL_VERNUM=`$LIBCURL_CONFIG --vernum`
  CURL_VER=`$LIBCURL_CONFIG --version | awk '{print $2}'`

  AC_MSG_RESULT([        found libcurl version $CURL_VER])
  
  AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`)

fi

if test "$CURL_SETTING" = "yes" ; then
  
  CURL_INC=`$LIBCURL_CONFIG --cflags`
  CURL_LIB=`$LIBCURL_CONFIG --libs`
  OPT_GDAL_FORMATS="wcs wms $OPT_GDAL_FORMATS"

fi

AC_SUBST(CURL_SETTING,$CURL_SETTING)
AC_SUBST(CURL_INC,    $CURL_INC)
AC_SUBST(CURL_LIB,    $CURL_LIB)

dnl ---------------------------------------------------------------------------
dnl Check for libxml2.
dnl ---------------------------------------------------------------------------

HAVE_LIBXML2=no
LIBXML2_INC=
LIBXML2_LIB=

AC_ARG_WITH(xml2,
    [  --with-xml2[=ARG]       Include libxml2 (ARG=path to xml2-config.)],,,)

if test "`basename xx/$with_xml2`" = "xml2-config" ; then
  LIBXML2_CONFIG="$with_xml2"
elif test "$with_xml2" = "no" ; then
  LIBXML2_CONFIG=no
else
  AC_PATH_PROG(LIBXML2_CONFIG, xml2-config, no)
fi

if test "$LIBXML2_CONFIG" != "no" ; then

  AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no,`$LIBXML2_CONFIG --libs`)

fi

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

  LIBXML2_INC=`$LIBXML2_CONFIG --cflags`
  LIBXML2_LIB=`$LIBXML2_CONFIG --libs`

fi

AC_SUBST(HAVE_LIBXML2,$HAVE_LIBXML2)
AC_SUBST(LIBXML2_INC, $LIBXML2_INC)
AC_SUBST(LIBXML2_LIB, $LIBXML2_LIB)

dnl ---------------------------------------------------------------------------
dnl Check for SpatiaLite.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(spatialite,
    [  --with-spatialite=ARG Include SpatiaLite support (ARG=no(default), yes or path)],
    ,,)

HAVE_SPATIALITE=no
SPATIALITE_AMALGAMATION=no

if test -z "$with_spatialite" -o "$with_spatialite" = "no"; then
    AC_MSG_RESULT(disabled)
elif test "$with_spatialite" = "yes"; then
    AC_CHECK_HEADERS(sqlite3.h)
    if test "$ac_cv_header_sqlite3_h" = "yes"; then
        AC_MSG_CHECKING([for spatialite.h in /usr/include or /usr/local/include])
        if test -f "/usr/include/spatialite.h" -o -f "/usr/local/include/spatialite.h"; then
            AC_MSG_RESULT(found)
            AC_CHECK_LIB(spatialite,spatialite_init,SPATIALITE_INIT_FOUND=yes,SPATIALITE_INIT_FOUND=no,)
            if test "$SPATIALITE_INIT_FOUND" = "yes"; then
                HAVE_SPATIALITE=yes
                LIBS="$LIBS -lspatialite"
                HAVE_SQLITE3=yes
            fi
        else
            AC_MSG_RESULT(not found : spatialite support disabled)
        fi
    fi
else
    AC_CHECK_LIB(spatialite,spatialite_init,SPATIALITE_INIT_FOUND=yes,SPATIALITE_INIT_FOUND=no,-L$with_spatialite/lib -lspatialite)
    if test -f "$with_spatialite/include/spatialite.h" -a \
        -f "$with_spatialite/include/spatialite/sqlite3.h" -a \
        "$SPATIALITE_INIT_FOUND" = "yes"; then

        AC_MSG_RESULT(enabled)
        HAVE_SPATIALITE=yes
        SPATIALITE_AMALGAMATION=yes

        # SpatiaLite amalgamation availability implies SQLite availability
        # Caution : don't include the include/spatialite subdir in the include dir
        # as there's a spatialite.h file in it, which we don't want to include.
        # We want to include include/spatialite.h instead !
        SQLITE3_CFLAGS="-I$with_spatialite/include"
        LIBS="$LIBS -L$with_spatialite/lib -lspatialite"
        HAVE_SQLITE3=yes

    elif test -f "$with_spatialite/include/spatialite.h" -a \
        "$SPATIALITE_INIT_FOUND" = "yes"; then
        AC_CHECK_HEADERS(sqlite3.h)
        if test "$ac_cv_header_sqlite3_h" = "yes"; then
            AC_MSG_RESULT(enabled)
            SPATIALITE_INC="-I$with_spatialite/include"
            HAVE_SPATIALITE=yes
            LIBS="$LIBS -L$with_spatialite/lib -lspatialite"
            HAVE_SQLITE3=yes
        fi
    else
        AC_MSG_RESULT(disabled)
    fi
fi

AC_SUBST([HAVE_SPATIALITE], $HAVE_SPATIALITE)
AC_SUBST([SPATIALITE_INC], $SPATIALITE_INC)
AC_SUBST([SPATIALITE_AMALGAMATION], $SPATIALITE_AMALGAMATION)

dnl ---------------------------------------------------------------------------
dnl Check for SQLite (only if SpatiaLite is not detected)
dnl ---------------------------------------------------------------------------

if test "${HAVE_SPATIALITE}" = "no" ; then
    SQLITE3_REQ_VERSION="3.0.0"
    AX_LIB_SQLITE3($SQLITE3_REQ_VERSION)

    if test "$HAVE_SQLITE3" = "yes"; then
        LIBS="$SQLITE3_LDFLAGS $LIBS"
    fi
fi

if test "$HAVE_SQLITE3" = "yes"; then
    AC_CHECK_LIB(sqlite3,sqlite3_column_table_name,SQLITE_HAS_COLUMN_METADATA=yes,SQLITE_HAS_COLUMN_METADATA=no,$LIBS)
fi

AC_SUBST([SQLITE_INC], $SQLITE3_CFLAGS)
AC_SUBST([HAVE_SQLITE], $HAVE_SQLITE3)
AC_SUBST([SQLITE_HAS_COLUMN_METADATA], $SQLITE_HAS_COLUMN_METADATA)
HAVE_SQLITE=$HAVE_SQLITE3

dnl ---------------------------------------------------------------------------
dnl Check for PCRE.
dnl ---------------------------------------------------------------------------

HAVE_PCRE=no

AC_ARG_WITH(pcre,
    [  --with-pcre             Include libpcre support (REGEXP support for SQLite)],
    ,,)

if test "$with_pcre" = "no"; then
    AC_MSG_RESULT(disabled)
    HAVE_PCRE=no
else
    AC_CHECK_HEADERS([pcre.h])
    if test "$ac_cv_header_pcre_h" = "no" ; then
        if test "$with_pcre" = "yes"; then
            AC_MSG_ERROR([cannot find pcre.h])
        fi
    else
        AC_CHECK_LIB(pcre,pcre_compile,HAVE_PCRE=yes,HAVE_PCRE=no,)
        if test "$HAVE_PCRE" = "yes" ; then
            HAVE_PCRE=yes
            LIBS="$LIBS -lpcre"
        else
            if test "$with_pcre" = "yes"; then
                AC_MSG_ERROR([cannot find libpcre])
            fi
        fi
    fi
fi

AC_SUBST(HAVE_PCRE)

dnl ---------------------------------------------------------------------------
dnl Check for DWGdirect.
dnl ---------------------------------------------------------------------------

DWGDIRECT=
DWG_PLT=

AC_MSG_CHECKING(Checking for DWGdirect)
AC_ARG_WITH(dwgdirect,
    [  --with-dwgdirect[=path] Include DWG direct support],
    ,,)
    
if test -z "$with_dwgdirect" -o "$with_dwgdirect" = "no"; then
    AC_MSG_RESULT(disabled)
    HAVE_DWGDIRECT=no
else
    AC_MSG_RESULT(enabled)

    AC_ARG_WITH(dwgdirect,
      [  --with-dwg-plt[=platform] DWGdirect Platform, defaults to lnxX86],
      ,,)
    if test "x$with_dwg_plt" != "x" ; then
        DWG_PLT=$with_dwg_plt
    else
        DWG_PLT=lnxX86
    fi
    DWGDIRECT=$with_dwgdirect
    HAVE_DWGDIRECT=yes
fi

dnl This is used by the GNUmakefile in frmts/dods (via GDALmake.opt)
AC_SUBST(DWG_PLT)
AC_SUBST(DWGDIRECT)

dnl ---------------------------------------------------------------------------
dnl Select Informix DataBlade support
dnl ---------------------------------------------------------------------------

HAVE_IDB=no

AC_ARG_WITH(idb,[  --with-idb=DIR        Include Informix DataBlade support (DIR points to Informix root)],,)

if test x"${with_idb}" = x"no" ; then
  AC_MSG_NOTICE(["IBM Informix DataBlade support disabled."])
else
  if test x"${with_idb}" = x ; then
    with_idb=$INFORMIXDIR
  fi

  if test -e "${with_idb}/incl/c++/it.h" ; then

    LIBS_DIRS="-L${with_idb}/lib/ -L${with_idb}/lib/esql"
    LIBS_ESQL="-lifsql -lifasf -lifgen -lifos -lifgls -lifglx ${with_idb}/lib/esql/checkapi.o"
    LIBS_LIBMI="-L${with_idb}/lib/dmi -lifdmi"
    LIBS_CPPIF="-L${with_idb}/lib/c++ -lifc++"

    IDB_INC="-I${with_idb}/incl/ -I${with_idb}/incl/dmi -I${with_idb}/incl/c++"
    IDB_LIB="${LIBS_DIRS} ${LIBS_ESQL} ${LIBS_LIBMI} ${LIBS_CPPIF}"

    ax_save_LIBS="${LIBS}"
    LIBS="${IDB_LIB} -ldl -lcrypt"
    AC_CHECK_LIB(ifsql,ifx_srvinfo,HAVE_IDB=yes,HAVE_IDB=no,)
    LIBS="${ax_save_LIBS}"

  fi

  if test "${HAVE_IDB}" = "yes" ; then
    AC_MSG_NOTICE([using Informix C++ client library from $with_idb.])
  else
    AC_MSG_NOTICE([IBM Informix DataBlade not supported.])
  fi

fi

AC_SUBST(HAVE_IDB,${HAVE_IDB})
AC_SUBST(IDB_INC,${IDB_INC})
AC_SUBST(IDB_LIB,${IDB_LIB})

dnl ---------------------------------------------------------------------
dnl Find ESRI SDE ONLY IF REQUESTED.
dnl ---------------------------------------------------------------------

SDE_ENABLED=no

AC_CHECKING(whether we should include ESRI SDE support)
AC_ARG_WITH(sde,
[  --with-sde[=DIR]        Include ESRI SDE support (DIR is SDE's install dir).],,)

AC_ARG_WITH(sde-version,
[  --with-sde-version[=VERSION NUMBER]  Set ESRI SDE version number (Default is 80).],SDE_VERSION=$with_sde_version,SDE_VERSION=80)

if test -z "$SDE_VERSION" -o `expr "$SDE_VERSION" \>\= 92` = 1; then
SDE_VERSION=""
fi
if test "$with_sde" = "yes" ; then

  AC_CHECK_LIB(sde$SDE_VERSION,SE_connection_create,SDE_ENABLED=yes,,,)

  if test -n "$SDE_ENABLED" ; then
      SDE_LIB="-lsde$SDE_VERSION -lpe$SDE_VERSION -lsg$SDE_VERSION"
      AC_CHECK_LIB(pthread, main, SDE_LIB="$SDE_LIB -lpthread",,)
      AC_CHECK_LIB(socket, main, SDE_LIB="$SDE_LIB -lsocket",,)
      AC_CHECK_LIB(dl, main, SDE_LIB="$SDE_LIB -ldl",,)
      AC_MSG_RESULT([        using ESRI SDE from system libs.])
  else
      AC_MSG_WARN([        ESRI SDE not found in system libs... use --with-sde=DIR.])
  fi

elif test -n "$with_sde" -a "$with_sde" != "no" ; then

  SDE_DIR=$with_sde

  test -f $SDE_DIR/arcsde/coverages/include/sdetype.h && SDE_INCDIR="$SDE_DIR/arcsde/coverages/include"
  test -f $SDE_DIR/include/sdetype.h && SDE_INCDIR="$SDE_DIR/include"
  test -f $SDE_DIR/sdetype.h && SDE_INCDIR="$SDE_DIR"

  test -f $SDE_DIR/lib/libsde$SDE_VERSION.a && SDE_LIBDIR="$SDE_DIR/lib"
  test -f $SDE_DIR/lib64/libsde$SDE_VERSION.a && SDE_LIBDIR="$SDE_DIR/lib64"
  test -f $SDE_DIR/libsde$SDE_VERSION.a && SDE_LIBDIR="$SDE_DIR"

  test -f $SDE_DIR/lib/libsde$SDE_VERSION.so -o -f $SDE_DIR/lib/libsde$SDE_VERSION.sl && SDE_LIBDIR="$SDE_DIR/lib"
  test -f $SDE_DIR/lib64/libsde$SDE_VERSION.so -o -f $SDE_DIR/lib64/libsde$SDE_VERSION.sl && SDE_LIBDIR="$SDE_DIR/lib64"
  test -f $SDE_DIR/libsde$SDE_VERSION.so -o -f $SDE_DIR/libsde$SDE_VERSION.sl && SDE_LIBDIR="$SDE_DIR"

  if test -n "$SDE_INCDIR" -a -n "$SDE_LIBDIR" ; then
      SDE_INC=-I$SDE_INCDIR
      SDE_LIB="-L$SDE_LIBDIR -lsde$SDE_VERSION -lpe$SDE_VERSION -lsg$SDE_VERSION"
      AC_CHECK_LIB(pthread, main, SDE_LIB="$SDE_LIB -lpthread",,)
      AC_CHECK_LIB(socket, main, SDE_LIB="$SDE_LIB -lsocket",,)
      AC_CHECK_LIB(dl, main, SDE_LIB="$SDE_LIB -ldl",,)
  else
      AC_MSG_ERROR("Could not find sdetype.h or libsde$SDE_VERSION.a/libsde$SDE_VERSION.so in $SDE_DIR.")
  fi

  if test "`arch`" = "x86_64" ; then
    AC_MSG_RESULT([        Adding -DSDE64 for 64bit platform.])
    SDE_INC="$SDE_INC -DSDE64"
  fi

  SDE_ENABLED=yes
  OPT_GDAL_FORMATS="sde $OPT_GDAL_FORMATS"
  AC_MSG_RESULT([        using ESRI SDE from $SDE_DIR.])

else

  AC_MSG_RESULT([        ESRI SDE support not requested.])
fi

AC_SUBST(SDE_ENABLED,$SDE_ENABLED)
AC_SUBST(SDE_INC,    $SDE_INC)
AC_SUBST(SDE_LIB,    $SDE_LIB)

dnl ---------------------------------------------------------------------------
dnl Check if epsilon library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(epsilon,[  --with-epsilon[=ARG]    Include EPSILON support (ARG=no, yes or libepsilon install root path)],,)

EPSILON_SETTING=no

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

  AC_CHECK_LIB(epsilon,eps_read_block_header,EPSILON_SETTING=yes,EPSILON_SETTING=no,)

  if test "$EPSILON_SETTING" = "yes" ; then   
    LIBS="-lepsilon $LIBS"
  else
    echo "libepsilon not found - EPSILON support disabled"
  fi

elif test "$with_epsilon" != "no" -a "$with_epsilon" != ""; then

  AC_CHECK_LIB(epsilon,eps_read_block_header,EPSILON_SETTING=yes,EPSILON_SETTING=no,-L$with_epsilon/lib -lepsilon)

  if test "$EPSILON_SETTING" = "yes" ; then   
    LIBS="-L$with_epsilon/lib -lepsilon $LIBS"
    EXTRA_INCLUDES="-I$with_epsilon/include $EXTRA_INCLUDES"
  else
    echo "libepsilon not found - EPSILON support disabled"
  fi

fi

if test "$EPSILON_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="epsilon $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if webp library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(webp,[  --with-webp[=ARG]    Include WEBP support (ARG=no, yes or libwebp install root path)],,)

WEBP_SETTING=no

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

  AC_CHECK_LIB(webp,WebPDecodeRGB,WEBP_SETTING=yes,WEBP_SETTING=no,)

  if test "$WEBP_SETTING" = "yes" ; then
    LIBS="-lwebp $LIBS"
  else
    echo "libwebp not found - WEBP support disabled"
  fi

elif test "$with_webp" != "no" -a "$with_webp" != ""; then

  AC_CHECK_LIB(webp,WebPDecodeRGB,WEBP_SETTING=yes,WEBP_SETTING=no,-L$with_webp/lib -lwebp)

  if test "$WEBP_SETTING" = "yes" ; then
    LIBS="-L$with_webp/lib -lwebp $LIBS"
    EXTRA_INCLUDES="-I$with_webp/include $EXTRA_INCLUDES"
  else
    echo "libwebp not found - WEBP support disabled"
  fi

fi

if test "$WEBP_SETTING" != "no" ; then
  OPT_GDAL_FORMATS="webp $OPT_GDAL_FORMATS"
fi

dnl ---------------------------------------------------------------------------
dnl Check if geos library is available.
dnl ---------------------------------------------------------------------------

GEOS_INIT(2.2.0)
HAVE_GEOS_RESULT="no"
if test "${HAVE_GEOS}" = "yes" ; then

  AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION])
  LIBS="${GEOS_LIBS} ${LIBS}"
  HAVE_GEOS_RESULT="yes"
fi

dnl ---------------------------------------------------------------------------
dnl Check if opencl library is available.
dnl ---------------------------------------------------------------------------

OPENCL_SETTING=no
OPENCL_FLAGS=
OPENCL_LIB=

AC_ARG_WITH(opencl,
    [  --with-opencl[=ARG]       Include OpenCL (GPU) support],,,)

AC_MSG_CHECKING([for OpenCL support])

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

  AC_ARG_WITH(opencl-include,
      [  --with-opencl-include=ARG OpenCL Include directory (with a CL subdirectory)],,,)

  OPENCL_SETTING=yes

  if test "x$with_opencl_include" = "x" ; then
    OPENCL_FLAGS=-DHAVE_OPENCL
    if test -z "`uname | grep Darwin`" ; then
        AC_CHECK_HEADERS([CL/opencl.h])
        if test "$ac_cv_header_CL_opencl_h" = "no" ; then
            AC_MSG_ERROR([cannot find CL/opencl.h])
        fi
    fi
  else
    OPENCL_FLAGS="-I$with_opencl_include -DHAVE_OPENCL"
  fi
    
  AC_ARG_WITH(opencl-lib,
      [  --with-opencl-lib=ARG   OpenCL Link Flags (ie. -L/xxx -lOpenCL)],,,)
     
  if test "x$with_opencl_lib" = "x" ; then
    if test ! -z "`uname | grep Darwin`" ; then
      OPENCL_LIB="-framework OpenCL"
    else
      AC_CHECK_LIB(OpenCL,clGetPlatformIDs,OPENCL_LIB=-lOpenCL,OPENCL_LIB=missing)
      if test "$OPENCL_LIB" = "missing"; then
        AC_MSG_ERROR([--with-opencl requested, but libraries not found!])
      fi
    fi
  else
    OPENCL_LIB="$with_opencl_lib"
  fi

fi

AC_MSG_RESULT([$OPENCL_SETTING])

AC_SUBST(OPENCL_FLAGS,  $OPENCL_FLAGS)
AC_SUBST(OPENCL_LIB,    $OPENCL_LIB)


dnl ---------------------------------------------------------------------------
dnl Check if FreeXL library is available.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(freexl,[  --with-freexl[=ARG]    Include freexl support (ARG=no, yes (default) or libfreexl install path)],,)

AC_MSG_CHECKING([for FreeXL support])

HAVE_FREEXL=no
FREEXL_INCLUDE=

if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then
  AC_CHECK_HEADERS(freexl.h)
  AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing)

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl -lm",FREEXL_LIBS=missing,-lm)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl -liconv",FREEXL_LIBS=missing,-liconv)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl -liconv -lm",FREEXL_LIBS=missing,-liconv -lm)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl -liconv -lcharset",FREEXL_LIBS=missing,-liconv -lcharset)
  fi

  if test "$FREEXL_LIBS" != "missing" -a "$ac_cv_header_freexl_h" = "yes" ; then

    # Check that freexl is recent enough
    rm -f testrlist.*
    echo '#include <freexl.h>' > testfreexl.c
    echo 'int main(int argc, char** argv) { FreeXL_CellValue s; freexl_get_cell_value (0,0,0,&s); return 0; } ' >> testfreexl.c
    if test -z "`${CC} testfreexl.c -c 2>&1`" ; then
        HAVE_FREEXL=yes
        LIBS="$FREEXL_LIBS $LIBS"
    else
        HAVE_FREEXL=no
        AC_MSG_RESULT([freexl too old. Needs freexl >= 1.0])
    fi
    rm -f testfreexl.*

  else
    HAVE_FREEXL=no
    echo "libfreexl not found - FreeXL support disabled"
  fi

elif test "$with_freexl" != "no"; then

  AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-L$with_freexl/lib -lfreexl",FREEXL_LIBS=missing,-L$with_freexl/lib)

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-L$with_freexl/lib -lfreexl -lm",FREEXL_LIBS=missing,-L$with_freexl/lib -lm)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-L$with_freexl/lib -lfreexl -liconv",FREEXL_LIBS=missing,-L$with_freexl/lib -liconv)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-L$with_freexl/lib -lfreexl -liconv -lm",FREEXL_LIBS=missing,-L$with_freexl/lib -liconv -lm)
  fi

  if test "$FREEXL_LIBS" = "missing"; then
    unset ac_cv_lib_freexl_freexl_open
    AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-L$with_freexl/lib -lfreexl -liconv -lcharset",FREEXL_LIBS=missing,-L$with_freexl/lib -liconv -lcharset)
  fi

  if test "FREEXL_LIBS" != "missing" -a -f "$with_freexl/include/freexl.h" ; then

    # Check that freexl is recent enough
    rm -f testrlist.*
    echo '#include <freexl.h>' > testfreexl.c
    echo 'int main(int argc, char** argv) { FreeXL_CellValue s; freexl_get_cell_value (0,0,0,&s); return 0; } ' >> testfreexl.c
    if test -z "`${CC} -I$with_freexl/include testfreexl.c -c 2>&1`" ; then
        HAVE_FREEXL=yes
        LIBS="$FREEXL_LIBS $LIBS"
        FREEXL_INCLUDE="-I$with_freexl/include"
    else
        HAVE_FREEXL=no
        AC_MSG_RESULT([freexl too old. Needs freexl >= 1.0])
    fi
    rm -f testfreexl.*

  else
    HAVE_FREEXL=no
    echo "libfreexl not found - FreeXL support disabled"
  fi

fi

AC_SUBST(HAVE_FREEXL,  $HAVE_FREEXL)
AC_SUBST(FREEXL_INCLUDE,  $FREEXL_INCLUDE)

dnl ---------------------------------------------------------------------------
dnl Check if we must enable PAM
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([whether to enable PAM])

AC_ARG_WITH(pam,[  --without-pam         Disable PAM (.aux.xml) support],,)

export PAM_SETTING=

if test "x$with_pam" = "xno" ; then
  AC_MSG_RESULT([no])
else
  AC_MSG_RESULT([yes])
  PAM_SETTING=-DPAM_ENABLED
fi

AC_SUBST(PAM_SETTING, $PAM_SETTING)

dnl ---------------------------------------------------------------------------
dnl Check if libpoppler is available
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(poppler,[  --with-poppler[=ARG]    Include poppler(for PDF) support (ARG=no(default), yes or poppler install path)],,)

HAVE_POPPLER=no
POPPLER_HAS_OPTCONTENT=no
POPPLER_BASE_STREAM_HAS_TWO_ARGS=no
POPPLER_0_20_OR_LATER=no

AC_MSG_CHECKING([for poppler])

if test "$with_poppler" != "no" -a "$with_poppler" != ""; then

    if test "$with_poppler" = "yes" ; then
        TEST_POPPLER_INC="-I/usr/include -I/usr/include/poppler"
        TEST_POPPLER_LIB="-lpoppler"
    else
        TEST_POPPLER_INC="-I$with_poppler/include -I$with_poppler/include/poppler"
        TEST_POPPLER_LIB="-L$with_poppler/lib -lpoppler"
    fi

    # Check that we can accept Page::pageObj private member
    rm -f testpoppler.*
    echo '#define private public' > testpoppler.cpp
    echo '#include <poppler/Page.h>' >> testpoppler.cpp
    echo '#include <poppler/splash/SplashBitmap.h>' >> testpoppler.cpp
    echo 'int main(int argc, char** argv) { return &(((Page*)0x8000)->pageObj) == 0; } ' >> testpoppler.cpp
    if test -z "`${CXX} testpoppler.cpp -o testpoppler ${TEST_POPPLER_INC} ${TEST_POPPLER_LIB} 2>&1`" ; then
        HAVE_POPPLER=yes
        LIBS="${TEST_POPPLER_LIB} ${LIBS}"
        AC_MSG_RESULT([yes])
        POPPLER_INC=$TEST_POPPLER_INC

        # And now try another dirty thing, but this one is
        # optional.
        AC_MSG_CHECKING([if Catalog::optContent exists])
        rm -f testpoppler.*
        echo '#define private public' > testpoppler.cpp
        echo '#include <poppler/Object.h>' >> testpoppler.cpp
        echo '#include <poppler/Catalog.h>' >> testpoppler.cpp
        echo 'int main(int argc, char** argv) { return &(((Catalog*)0x8000)->optContent) == 0; }' >> testpoppler.cpp
        if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
            POPPLER_HAS_OPTCONTENT=yes
            AC_MSG_RESULT([yes])
        else
            AC_MSG_RESULT([no])
        fi

        # And now we check if we have Poppler >= 0.16.0
        AC_MSG_CHECKING([if BaseStream constructor needs 2 arguments])
        rm -f testpoppler.*
        echo '#include <poppler/Object.h>' > testpoppler.cpp
        echo '#include <poppler/Stream.h>' >> testpoppler.cpp
        echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
        echo 'public:' >> testpoppler.cpp
        echo '  TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
        echo '};' >> testpoppler.cpp
        echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
        if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
            POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
            AC_MSG_RESULT([yes])

            # And now we check if we have Poppler >= 0.20.0
            AC_MSG_CHECKING([if we have Poppler >= 0.20.0])
            rm -f testpoppler.*
            echo '#include <poppler/Error.h>' > testpoppler.cpp
            echo 'int main(int argc, char** argv) { setErrorCallback(0,0); return 0; }' >> testpoppler.cpp
            if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
                POPPLER_0_20_OR_LATER=yes
                AC_MSG_RESULT([yes])

                # And now we check if we have Poppler >= 0.23.0
                AC_MSG_CHECKING([if we have Poppler >= 0.23.0])
                rm -f testpoppler.*
                echo '#include <poppler/Object.h>' > testpoppler.cpp
                echo '#include <poppler/Stream.h>' >> testpoppler.cpp
                echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
                echo 'public:' >> testpoppler.cpp
                echo '  TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
                echo '  ~TestStream() {}' >> testpoppler.cpp
                echo '  virtual BaseStream *copy() { return BaseStream::copy(); }' >> testpoppler.cpp
                echo '};' >> testpoppler.cpp
                echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
                if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
                    POPPLER_0_23_OR_LATER=yes
                    AC_MSG_RESULT([yes])
                else
                    AC_MSG_RESULT([no])
                fi

            else
                AC_MSG_RESULT([no])
            fi

        else
            AC_MSG_RESULT([no])
        fi
    else
        AC_MSG_RESULT([no])
    fi
    rm -f testpoppler.*
    rm -f testpoppler
else
    AC_MSG_RESULT([disabled])
fi

AC_SUBST(HAVE_POPPLER, $HAVE_POPPLER)
AC_SUBST(POPPLER_HAS_OPTCONTENT, $POPPLER_HAS_OPTCONTENT)
AC_SUBST(POPPLER_BASE_STREAM_HAS_TWO_ARGS, $POPPLER_BASE_STREAM_HAS_TWO_ARGS)
AC_SUBST(POPPLER_0_20_OR_LATER, $POPPLER_0_20_OR_LATER)
AC_SUBST(POPPLER_0_23_OR_LATER, $POPPLER_0_23_OR_LATER)
AC_SUBST(POPPLER_INC, $POPPLER_INC)

dnl ---------------------------------------------------------------------------
dnl Check if libpodofo is available
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(podofo,[  --with-podofo[=ARG]    Include podofo(for PDF) support (ARG=no(default), yes or podofo install path)],,)

HAVE_PODOFO=no

AC_MSG_CHECKING([for podofo])

if test "$with_podofo" != "no" -a "$with_podofo" != ""; then

    AC_ARG_WITH(podofo-lib,
      [  --with-podofo-lib=ARG   podofo Link Flags (ie. -L/xxx -lpodofo ...). Mainly for static libpodofo],,,)

    if test "$with_podofo" = "yes" ; then
        TEST_PODOFO_INC="-I/usr/include -I/usr/include/podofo"
        PODOFO_LIB="-lpodofo"
    else
        TEST_PODOFO_INC="-I$with_podofo/include -I$with_podofo/include/podofo"
        PODOFO_LIB="-L$with_podofo/lib -lpodofo"
    fi

    if test "x$with_podofo_lib" = "x" ; then
        rm -f testpodofo.*
        echo '#include <podofo.h>' > testpodofo.cpp
        echo 'int main(int argc, char** argv) { PoDoFo::PdfError::EnableDebug( 0 ); return 0; } ' >> testpodofo.cpp
        if test -z "`${CXX} testpodofo.cpp -o testpodofo ${TEST_PODOFO_INC} ${PODOFO_LIB}  2>&1`" ; then
            HAVE_PODOFO=yes
            LIBS="${PODOFO_LIB} ${LIBS}"
            PODOFO_INC=$TEST_PODOFO_INC
            AC_MSG_RESULT([yes])
        fi
        rm -f testpodofo.*
        rm -f testpodofo
    fi

    if test "$HAVE_PODOFO" = "no"; then
        if test "x$with_podofo_lib" != "x" ; then
            PODOFO_LIB="$with_podofo_lib"
        else
            # This may be a static libpodofo.a, so add dependant libraries
            PODOFO_LIB="$PODOFO_LIB -lfreetype -lfontconfig -lpthread"
        fi

        AC_ARG_WITH(podofo-extra-lib-for-test,
          [  --with-podofo-extra-lib-for-test=ARG   Additional libraries to pass the detection test, but not used for libgdal linking (ie. -ljpeg ...). Mainly for static libpodofo],,,)

        if test "x$with_podofo_extra_lib_for_test" = "x" ; then
            TEST_PODOFO_LIB="$PODOFO_LIB"
        else
            TEST_PODOFO_LIB="$PODOFO_LIB $with_podofo_extra_lib_for_test"
        fi

        rm -f testpodofo.*
        echo '#include <podofo.h>' > testpodofo.cpp
        echo 'int main(int argc, char** argv) { PoDoFo::PdfError::EnableDebug( 0 ); return 0; } ' >> testpodofo.cpp
        if test -z "`${CXX} testpodofo.cpp -o testpodofo ${TEST_PODOFO_INC} ${TEST_PODOFO_LIB} 2>&1`" ; then
            HAVE_PODOFO=yes
            LIBS="${PODOFO_LIB} ${LIBS}"
            PODOFO_INC=$TEST_PODOFO_INC
            AC_MSG_RESULT([yes])
        else
            AC_MSG_RESULT([no])
        fi
        rm -f testpodofo.*
        rm -f testpodofo
    fi
else
    AC_MSG_RESULT([disabled])
fi

AC_SUBST(HAVE_PODOFO, $HAVE_PODOFO)
AC_SUBST(PODOFO_INC, $PODOFO_INC)

dnl ---------------------------------------------------------------------------
dnl PROJ.4 related stuff.
dnl ---------------------------------------------------------------------------

AC_MSG_CHECKING([how to link PROJ.4 library])

AC_ARG_WITH(static_proj4,[  --with-static-proj4=ARG Compile with PROJ.4 statically (ARG=no or path)],,)

if test "x$with_static_proj4" = "xno" -o "x$with_static_proj4" = "x"; then

  PROJ_STATIC=no
  AC_MSG_RESULT([link dynamically.])

else

  PROJ_STATIC=yes
  AC_MSG_RESULT([link statically.])

  ORIG_LIBS="$LIBS"
  PROJ_LIB="-lproj"

  if test "x$with_static_proj4" = "xyes" ; then
    LIBS="$PROJ_LIB $ORIG_LIBS"
    AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)
  else
  
    LIBS="-L$with_static_proj4/lib $PROJ_LIB $ORIG_LIBS"
    AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)

    if test "$PROJ_STATIC" = "no"; then
      dnl Disable previous value cached by the previous AC_CHECK_LIB test :
      dnl AC_CHECK_LIB caches the result value for a couple (function, library)
      dnl in a variable named "ac_cv_lib_<library name>_<function name>".
      dnl In order to try to locate the library in different locations, using
      dnl different values of LIBS, we have to 'unset' this variable after
      dnl each negative test.

      unset ac_cv_lib_proj_pj_init

      LIBS="-L$with_static_proj4/src $PROJ_LIB $ORIG_LIBS"
      AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)
    fi

    if test "$PROJ_STATIC" = "no"; then
      unset ac_cv_lib_proj_pj_init
      LIBS="-L$with_static_proj4/src/.libs $PROJ_LIB $ORIG_LIBS"
      AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)
    fi

    if test "$PROJ_STATIC" = "no"; then
      unset ac_cv_lib_proj_pj_init
      LIBS="-L$with_static_proj4 $PROJ_LIB $ORIG_LIBS"
      AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)
    fi

    if test "$PROJ_STATIC" = "no"; then
      unset ac_cv_lib_proj_pj_init
      LIBS="$PROJ_LIB $ORIG_LIBS"
      AC_CHECK_LIB(proj,pj_init,PROJ_STATIC=yes,PROJ_STATIC=no,)
    fi

  fi

  if test "$PROJ_STATIC" = "no"; then
    LIBS="$ORIG_LIBS"
  fi

  if test -r "$with_static_proj4/src/proj_api.h" ; then
    PROJ_INCLUDE="-I$with_static_proj4/src"
  elif test -r "$with_static_proj4/include/proj_api.h" ; then
    PROJ_INCLUDE="-I$with_static_proj4/include"
  elif test -r "$with_static_proj4/proj_api.h" ; then
    PROJ_INCLUDE="-I$with_static_proj4"
  fi
  
fi

AC_SUBST(PROJ_STATIC)
AC_SUBST(PROJ_INCLUDE)

dnl ---------------------------------------------------------------------------
dnl Get/override version.
dnl ---------------------------------------------------------------------------


AC_ARG_WITH(gdal-ver,[  --with-gdal-ver=ARG   Override GDAL version ],,)
GDAL_VERSION_MAJOR=`grep "#*define.GDAL_VERSION_MAJOR.*" gcore/gdal_version.h | awk '{print $4}'`
GDAL_VERSION_MINOR=`grep "#*define.GDAL_VERSION_MINOR.*" gcore/gdal_version.h | awk '{print $4}'`
GDAL_VERSION_REV=`grep "#*define.GDAL_VERSION_REV.*" gcore/gdal_version.h | awk '{print $4}'`

AC_MSG_RESULT([checking GDAL version information from gdal_version.h: $GDAL_VERSION_MAJOR.$GDAL_VERSION_MINOR.$GDAL_VERSION_REV])

AC_SUBST(GDAL_VERSION_MAJOR,    "$GDAL_VERSION_MAJOR")
AC_SUBST(GDAL_VERSION_MINOR,    "$GDAL_VERSION_MINOR")
AC_SUBST(GDAL_VERSION_REV,    "$GDAL_VERSION_REV")

if test "x$with_gdal_ver" != "x"; then

  GDAL_VER=$with_gdal_ver
  AC_MSG_RESULT([  overridden GDAL version: $GDAL_VER])
else

  GDAL_VER=$GDAL_VERSION_MAJOR.$GDAL_VERSION_MINOR.$GDAL_VERSION_REV

fi

AC_SUBST(GDAL_VER, $GDAL_VER)
echo $GDAL_VER > VERSION

dnl ---------------------------------------------------------------------------
dnl MacOS X Framework Build

if test ! -z "`uname | grep Darwin`" ; then

  CXXFLAGS="$ARCHFLAGS $CXXFLAGS"
  CFLAGS="$ARCHFLAGS $CFLAGS"
  LIBS="$ARCHFLAGS $LIBS"

  MACOSX_FRAMEWORK=no
  AC_ARG_WITH(,[  --with-macosx-framework         Build and install GDAL as a Mac OS X Framework],,)
  AC_MSG_CHECKING([for Mac OS X Framework build])
  if test "$with_macosx_framework" = yes ; then
    MACOSX_FRAMEWORK=yes
    AC_MSG_RESULT([enabled])
    AC_DEFINE_UNQUOTED(MACOSX_FRAMEWORK,1, [Define for Mac OSX Framework build])
    prefix="/Library/Frameworks/GDAL.framework/Versions/${GDAL_VERSION_MAJOR}.${GDAL_VERSION_MINOR}"
    exec_prefix='${prefix}'
    includedir='${prefix}/Headers'
    datadir='${prefix}/Resources/gdal'
    libdir='${exec_prefix}'
    bindir='${exec_prefix}/Programs'
    docdir='${prefix}/Resources/doc'
    mandir='${prefix}/Resources/man'
  else
    AC_MSG_RESULT([disabled])
  fi
  AC_SUBST(MACOSX_FRAMEWORK, $MACOSX_FRAMEWORK)
fi

AC_SUBST(EXTRA_INCLUDES,$EXTRA_INCLUDES)

dnl ---------------------------------------------------------------------------
dnl Check whether we need to add specific suffix for executables (.EXE when
dnl building for Windows). This test should work for the case of
dnl cross-compilation too.
dnl ---------------------------------------------------------------------------
case "${host_os}" in
    cygwin* | mingw32* | pw32*)
      EXE_EXT=.exe
      SO_EXT=dll
      ;;
    *)
      EXE_EXT=
      ;;
esac

AC_SUBST(EXE_EXT)
AC_SUBST(SO_EXT)

dnl ---------------------------------------------------------------------------
dnl Which "true" program should we use? 
dnl ---------------------------------------------------------------------------
BINTRUE=/bin/true

if test -f /bin/true.exe ; then
  BINTRUE=/bin/true.exe
fi
if test -f /usr/bin/true ; then
  BINTRUE=/usr/bin/true
fi

export BINTRUE

AC_SUBST(BINTRUE,$BINTRUE)

dnl ---------------------------------------------------------------------------
dnl If datadir is set to @prefix@/share, the modify it to be 
dnl @prefix@/share/gdal.  I wish we could default this.
dnl ---------------------------------------------------------------------------
if test "$datadir" = '${prefix}/share' ; then
  datadir='${prefix}/share/gdal'
fi

if test "$datadir" = '${datarootdir}' \
     -a "$datarootdir" = '${prefix}/share' ; then
  datarootdir='${prefix}/share/gdal'
fi

dnl ---------------------------------------------------------------------------
dnl By default mandir is $datarootdir/man which would be
dnl /usr/local/share/gdal/man but we want man pages in /usr/local/man. 
dnl ---------------------------------------------------------------------------
mandir='${prefix}/man'

dnl ---------------------------------------------------------------------------
dnl Capture GDAL_PREFIX for the cpl_config.h include file. 
dnl ---------------------------------------------------------------------------

if test "$prefix" = "NONE" ; then 
  GDAL_PREFIX=/usr/local
else
  GDAL_PREFIX=${prefix}
fi

export GDAL_PREFIX
AC_DEFINE_UNQUOTED(GDAL_PREFIX,["]$GDAL_PREFIX["], [--prefix directory for GDAL install])

dnl ---------------------------------------------------------------------------
dnl Perl bindings.
dnl ---------------------------------------------------------------------------

BINDINGS=

AC_ARG_WITH(perl,[  --with-perl           Enable perl bindings],,)

AC_MSG_CHECKING([for perl bindings])
if test "$with_perl" = "yes" ; then
  BINDINGS="perl $BINDINGS"
  AC_MSG_RESULT([enabled])
else
  AC_MSG_RESULT([disabled])
fi

dnl ---------------------------------------------------------------------------
dnl PHP bindings.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(php,[  --with-php            Enable php bindings],,)

AC_MSG_CHECKING([for php bindings])
if test "$with_php" = "yes" ; then
  BINDINGS="php $BINDINGS"
  AC_MSG_RESULT([enabled])
else
  AC_MSG_RESULT([disabled])
fi

dnl ---------------------------------------------------------------------------
dnl Ruby bindings.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(ruby,[  --with-ruby           Enable Ruby bindings],,)

AC_MSG_CHECKING([for ruby bindings])
if test "$with_ruby" = "yes" ; then
  BINDINGS="ruby $BINDINGS"
  AC_MSG_RESULT([enabled])
else
  AC_MSG_RESULT([disabled])
fi

dnl ---------------------------------------------------------------------------
dnl NG Python bindings.
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(python,[  --with-python=ARG   Enable python bindings (ARG=yes, no, or path to python binary)],,)

AC_MSG_CHECKING([for python bindings])
if test "$with_python" = "yes" ; then
  dnl
  dnl Check for Python executable in PATH
  dnl
  AC_CHECK_PROGS([PYTHON], [python python3 python2])
  if test "x$PYTHON" = "x"; then
    AC_MSG_ERROR([--with-python requested, but Python not found!])
  fi
elif test "x$with_python" != "x" -a "$with_python" != "no" ; then
  PYTHON="$with_python"
  if test "`$PYTHON -c 'print(1)'`" != "1"; then
    AC_MSG_ERROR([--with-python requested, but Python not found!])
  fi
  AC_MSG_RESULT([enabled])
else
  AC_MSG_RESULT([disabled])
fi

if test "x$PYTHON" != "x"; then
  BINDINGS="python $BINDINGS"

  AC_MSG_CHECKING([for python setuptools])
  SETUPTEST='try:
  import setuptools
  print(1)
except ImportError:
  pass'
  PY_HAVE_SETUPTOOLS=`$PYTHON -c "$SETUPTEST"`
  if test "$PY_HAVE_SETUPTOOLS" = "1"; then
    AC_MSG_RESULT([found])
  else
    AC_MSG_RESULT([not found])
  fi
fi

AC_SUBST([PY_HAVE_SETUPTOOLS])
AC_SUBST([BINDINGS])

dnl ---------------------------------------------------------------------------
dnl Java support
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(java,[  --with-java       Include Java support (ARG=yes, no or JDK home path)  [[default=no]]],,)

AC_MSG_CHECKING([whether we should include Java support])

JAVA_HOME=""
JAVA_INC=""

if test "x$with_java" = "xyes"; then

dnl Ubuntu
    JAVA_6_TEST_DIR=
    JAVA_7_TEST_DIR=
    case "$host_cpu" in
        i*86*)
            JAVA_6_TEST_DIR=/usr/lib/jvm/java-6-openjdk-i386
            JAVA_7_TEST_DIR=/usr/lib/jvm/java-7-openjdk-i386
            ;;
        x86_64*)
            JAVA_6_TEST_DIR=/usr/lib/jvm/java-6-openjdk-amd64
            JAVA_7_TEST_DIR=/usr/lib/jvm/java-7-openjdk-amd64
            ;;
        *)
            ;;
    esac

    if test "x$JAVA_7_TEST_DIR" != "x" -a -d "$JAVA_7_TEST_DIR/include"; then
        with_java="$JAVA_7_TEST_DIR"

    elif test "x$JAVA_6_TEST_DIR" != "x" -a -d "$JAVA_6_TEST_DIR/include"; then
        with_java="$JAVA_6_TEST_DIR"

    elif test -d /usr/lib/jvm/java-6-openjdk; then
        with_java="/usr/lib/jvm/java-6-openjdk"

dnl RHEL6
    elif test -d /usr/lib/jvm/java-openjdk; then
        with_java="/usr/lib/jvm/java-openjdk"

dnl    elif test -d /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers; then
dnl        JAVA_INC="-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"

dnl OpenSolaris
    elif test -d /usr/java; then
        with_java="/usr/java"
    else
        AC_MSG_ERROR("cannot find JDK root directory.")
    fi

    if test \! -d "$with_java/include" ; then
        AC_MSG_ERROR("$with_java is not a valid JDK.")
    fi
fi

if test "x$JAVA_INC" != "x"; then
    AC_MSG_RESULT([yes])
elif test "x$with_java" != "x" -a "x$with_java" != "xno"; then

    if test -d "$with_java/include"; then
        if test -d "$with_java/include/linux"; then
            JAVA_HOME="$with_java"
            JAVA_INC="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
            AC_MSG_RESULT([yes])
        elif test -d "$with_java/include/solaris"; then
            JAVA_HOME="$with_java"
            JAVA_INC="-I$JAVA_HOME/include -I$JAVA_HOME/include/solaris"
            AC_MSG_RESULT([yes])
        elif test -d "$with_java/include/freebsd"; then
            JAVA_HOME="$with_java"
            JAVA_INC="-I$JAVA_HOME/include -I$JAVA_HOME/include/freebsd"
            AC_MSG_RESULT([yes])
        else
            AC_MSG_ERROR("Cannot find $with_java/include/linux or solaris or freebsd directory.")
        fi
    else
        AC_MSG_ERROR("Cannot find $with_java/include directory.")
    fi

else
    AC_MSG_RESULT([no])
fi

AC_SUBST(JAVA_HOME,$JAVA_HOME)
AC_SUBST(JAVA_INC,$JAVA_INC)

dnl ---------------------------------------------------------------------------
dnl MDB driver
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(mdb,[  --with-mdb       Include MDB driver],,)

AC_MSG_CHECKING([whether we should include MDB support])

MDB_ENABLED=no
JVM_LIB=""

if test "$with_mdb" = "yes" ; then
    if test "x$JAVA_INC" = "x"; then
        AC_MSG_ERROR("--with-java must be specified.")
    fi

    AC_ARG_WITH(jvm-lib,          [  --with-jvm-lib=[ARG]        ARG points to Java libjvm path],,)

    AC_ARG_WITH(jvm-lib-add-rpath,[  --with-jvm-lib-add-rpath    Add the libjvm path to the RPATH (no by default)],,)

    if test "x$with_jvm_lib" != "x"; then
        if test -d "$with_jvm_lib"; then
            saved_LDFLAGS="$LDFLAGS"
            LDFLAGS="$LDFLAGS -L$with_jvm_lib"
            AC_CHECK_LIB(jvm,JNI_CreateJavaVM,HAS_LIB_JVM=yes,HAS_LIB_JVM=no,)
            LDFLAGS="$saved_LDFLAGS"
            if test "$HAS_LIB_JVM" = "yes"; then
                JVM_LIB="-L$with_jvm_lib -ljvm"
                if test "x$with_jvm_lib_add_rpath" = "xyes"; then
                    JVM_LIB="-Wl,-rpath=$with_jvm_lib $JVM_LIB"
                fi
            else
                AC_MSG_ERROR("--with-jvm-lib must point to a directory with a libjvm.")
            fi
        else
            AC_MSG_ERROR("--with-jvm-lib must point to a directory.")
        fi
    elif test "x$JAVA_HOME" != "x"; then
        TEST_DIR="$JAVA_HOME/jre/lib/amd64/server"
        if test "x$JVM_LIB" = "x" -a -d "$TEST_DIR"; then
            unset ac_cv_lib_jvm_JNI_CreateJavaVM
            saved_LDFLAGS="$LDFLAGS"
            LDFLAGS="$LDFLAGS -L$TEST_DIR"
            AC_CHECK_LIB(jvm,JNI_CreateJavaVM,HAS_LIB_JVM=yes,HAS_LIB_JVM=no,)
            LDFLAGS="$saved_LDFLAGS"
            if test "$HAS_LIB_JVM" = "yes"; then
                JVM_LIB="-L$TEST_DIR -ljvm"
                if test "x$with_jvm_lib_add_rpath" = "xyes"; then
                    JVM_LIB="-Wl,-rpath=$TEST_DIR $JVM_LIB"
                fi
            fi
        fi

        TEST_DIR="$JAVA_HOME/jre/lib/i386/server"
        if test "x$JVM_LIB" = "x" -a -d "$TEST_DIR"; then
            unset ac_cv_lib_jvm_JNI_CreateJavaVM
            saved_LDFLAGS="$LDFLAGS"
            LDFLAGS="$LDFLAGS -L$TEST_DIR"
            AC_CHECK_LIB(jvm,JNI_CreateJavaVM,HAS_LIB_JVM=yes,HAS_LIB_JVM=no,)
            LDFLAGS="$saved_LDFLAGS"
            if test "$HAS_LIB_JVM" = "yes"; then
                JVM_LIB="-L$TEST_DIR -ljvm"
                if test "x$with_jvm_lib_add_rpath" = "xyes"; then
                    JVM_LIB="-Wl,-rpath=$TEST_DIR $JVM_LIB"
                fi
            fi
        fi

        if test "x$JVM_LIB" = "x"; then
            AC_MSG_ERROR("--with-jvm-lib must be specified.")
        fi
dnl    elif test -f /System/Library/Frameworks/JavaVM.framework/Versions/Current/JavaVM; then
dnl        JVM_LIB="-framework /System/Library/Frameworks/JavaVM.framework/Versions/Current/JavaVM"
    else
        AC_MSG_ERROR("--with-jvm-lib must be specified.")
    fi

    MDB_ENABLED=yes
    AC_MSG_RESULT([yes])

else
    AC_MSG_RESULT([no])
fi

AC_SUBST(MDB_ENABLED,$MDB_ENABLED)
AC_SUBST(JVM_LIB,$JVM_LIB)


dnl ---------------------------------------------------------------------------
dnl Select Rasdaman or disable driver.
dnl ---------------------------------------------------------------------------

RASDAMAN_ENABLED=no

AC_CHECKING(whether we should include rasdaman support)
AC_ARG_WITH(rasdaman,
[  --with-rasdaman[=DIR]        Include rasdaman support (DIR is rasdaman's install dir).],,)

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

  AC_CHECK_LIB(raslib,main,RASDAMAN_ENABLED=yes,,,)

  if test -n "$RASDAMAN_ENABLED" ; then
      RASDAMAN_LIB="-lrasodmg -lclientcomm -lcompression -lnetwork -lraslib"
      OPT_GDAL_FORMATS="rasdaman $OPT_GDAL_FORMATS"
      AC_MSG_RESULT([        using rasdaman from system libs.])
  else
      AC_MSG_WARN([        rasdaman not found in system libs... use --with-rasdaman=DIR.])
  fi

elif test -n "$with_rasdaman" -a "$with_rasdaman" != "no" ; then

  RASDAMAN_DIR=$with_rasdaman

  if test -f $RASDAMAN_DIR/include/rasdaman.hh -a -d$RASDAMAN_DIR/lib ; then
      RASDAMAN_INC=-I$RASDAMAN_DIR/include
      RASDAMAN_LIB="-L$RASDAMAN_DIR/lib -lrasodmg -lclientcomm -lcompression -lnetwork -lraslib"
  else
      AC_MSG_ERROR("Could not find rasdaman.hh or libraslib.a in $RASDAMAN_DIR.")
  fi

  RASDAMAN_ENABLED=yes
  OPT_GDAL_FORMATS="rasdaman $OPT_GDAL_FORMATS"
  AC_MSG_RESULT([        using rasdaman from $RASDAMAN_DIR.])

else

  AC_MSG_RESULT([        rasdaman support not requested.])
fi

AC_SUBST(RASDAMAN_ENABLED,$RASDAMAN_ENABLED)
AC_SUBST(RASDAMAN_INC,    $RASDAMAN_INC)
AC_SUBST(RASDAMAN_LIB,    $RASDAMAN_LIB)

dnl ---------------------------------------------------------------------------
dnl Armadillo support
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(armadillo,[  --with-armadillo=ARG       Include Armadillo support for faster TPS transform computation (ARG=yes/no/path to armadillo install root) [[default=no]]],,)

AC_MSG_CHECKING([whether we should include Armadillo support])

HAVE_ARMADILLO=no

if test "$with_armadillo" = "yes" ; then
    rm -f testarmadillo.*
    rm -f testarmadillo
    echo '#include <armadillo>' > testarmadillo.cpp
    echo 'int main(int argc, char** argv) { arma::mat matInput(2,2); const arma::mat& matInv = arma::inv(matInput); return 0; } ' >> testarmadillo.cpp
    if test -z "`${CXX} ${CPPFLAGS} testarmadillo.cpp -o testarmadillo -larmadillo ${LIBS} 2>&1`" ; then
        HAVE_ARMADILLO=yes
        LIBS="-larmadillo ${LIBS}"
        AC_MSG_RESULT([yes])
    else
        dnl Try adding -llapack (#4923)
        if test -z "`${CXX} ${CPPFLAGS} testarmadillo.cpp -o testarmadillo -larmadillo -llapack ${LIBS} 2>&1`" ; then
            HAVE_ARMADILLO=yes
            LIBS="-larmadillo -llapack ${LIBS}"
            AC_MSG_RESULT([yes])
        else
            AC_MSG_RESULT([no])
        fi
    fi
    rm -f testarmadillo.*
    rm -f testarmadillo

elif test -n "$with_armadillo" -a "$with_armadillo" != "no" ; then

    rm -f testarmadillo.*
    rm -f testarmadillo
    echo '#include <armadillo>' > testarmadillo.cpp
    echo 'int main(int argc, char** argv) { arma::mat matInput(2,2); const arma::mat& matInv = arma::inv(matInput); return 0; } ' >> testarmadillo.cpp
    if test -z "`${CXX} ${CPPFLAGS} -I$with_armadillo/include testarmadillo.cpp -o testarmadillo -L$with_armadillo/lib -larmadillo ${LIBS} 2>&1`" ; then
        HAVE_ARMADILLO=yes
        LIBS="-L$with_armadillo/lib -larmadillo ${LIBS}"
        EXTRA_INCLUDES="-I$with_armadillo/include $EXTRA_INCLUDES"
        AC_MSG_RESULT([yes])
    else
        dnl Try adding -llapack (#4923)
        if test -z "`${CXX} ${CPPFLAGS} -I$with_armadillo/include testarmadillo.cpp -o testarmadillo -L$with_armadillo/lib -larmadillo -llapack ${LIBS} 2>&1`" ; then
            HAVE_ARMADILLO=yes
            LIBS="-L$with_armadillo/lib -larmadillo -llapack ${LIBS}"
            EXTRA_INCLUDES="-I$with_armadillo/include $EXTRA_INCLUDES"
            AC_MSG_RESULT([yes])
        else
            AC_MSG_RESULT([no])
        fi
    fi
    rm -f testarmadillo.*
    rm -f testarmadillo

else
    AC_MSG_RESULT([no])
fi

AC_SUBST(HAVE_ARMADILLO,$HAVE_ARMADILLO)


AC_OUTPUT(GDALmake.opt)

dnl ---------------------------------------------------------------------------
dnl Display configuration status
dnl ---------------------------------------------------------------------------

LOC_MSG()
LOC_MSG([GDAL is now configured for ${host}])
LOC_MSG()
LOC_MSG([  Installation directory:    ${prefix}])
LOC_MSG([  C compiler:                ${CC} ${CFLAGS}])
LOC_MSG([  C++ compiler:              ${CXX} ${CXXFLAGS}])
LOC_MSG()
LOC_MSG([  LIBTOOL support:           ${with_libtool}])
LOC_MSG()
LOC_MSG([  LIBZ support:              ${LIBZ_SETTING}])
LOC_MSG([  LIBLZMA support:           ${LIBLZMA_SETTING}])
LOC_MSG([  GRASS support:             ${GRASS_SETTING}])
LOC_MSG([  CFITSIO support:           ${FITS_SETTING}])
LOC_MSG([  PCRaster support:          ${PCRASTER_SETTING}])
LOC_MSG([  LIBPNG support:            ${PNG_SETTING}])
LOC_MSG([  DDS support:               ${DDS_SETTING}])
LOC_MSG([  GTA support:               ${GTA_SETTING}]) 
LOC_MSG([  LIBTIFF support:           ${TIFF_SETTING} (BigTIFF=${HAVE_BIGTIFF})])
LOC_MSG([  LIBGEOTIFF support:        ${GEOTIFF_SETTING}])
LOC_MSG([  LIBJPEG support:           ${JPEG_SETTING}])
LOC_MSG([  12 bit JPEG:               ${JPEG12_ENABLED}])
LOC_MSG([  12 bit JPEG-in-TIFF:       ${TIFF_JPEG12_ENABLED}])
LOC_MSG([  LIBGIF support:            ${GIF_SETTING}])
LOC_MSG([  OGDI support:              ${HAVE_OGDI}])
LOC_MSG([  HDF4 support:              ${HAVE_HDF4}])
LOC_MSG([  HDF5 support:              ${HAVE_HDF5}])
LOC_MSG([  NetCDF support:            ${NETCDF_SETTING}])
LOC_MSG([  Kakadu support:            ${HAVE_KAKADU}])
if test "x$HAVE_JASPER_UUID" != "x" ; then
  LOC_MSG([  JasPer support:            ${HAVE_JASPER} (GeoJP2=${HAVE_JASPER_UUID})])
else
  LOC_MSG([  JasPer support:            ${HAVE_JASPER}])
fi
LOC_MSG([  OpenJPEG support:          ${HAVE_OPENJPEG}])
LOC_MSG([  ECW support:               ${ECW_SETTING}])
LOC_MSG([  MrSID support:             ${HAVE_MRSID}])
LOC_MSG([  MrSID/MG4 Lidar support:   ${HAVE_MRSID_LIDAR}])
LOC_MSG([  MSG support:               ${HAVE_MSG}])
LOC_MSG([  GRIB support:              ${HAVE_GRIB}])
LOC_MSG([  EPSILON support:           ${EPSILON_SETTING}])
LOC_MSG([  WebP support:              ${WEBP_SETTING}])
LOC_MSG([  cURL support (wms/wcs/...):${CURL_SETTING}])
LOC_MSG([  PostgreSQL support:        ${HAVE_PG}])
LOC_MSG([  MySQL support:             ${HAVE_MYSQL}])
LOC_MSG([  Ingres support:            ${HAVE_INGRES}])
LOC_MSG([  Xerces-C support:          ${HAVE_XERCES}])
LOC_MSG([  NAS support:               ${HAVE_NAS}])
LOC_MSG([  Expat support:             ${HAVE_EXPAT}])
LOC_MSG([  libxml2 support:           ${HAVE_LIBXML2}])
LOC_MSG([  Google libkml support:     ${HAVE_LIBKML}])
LOC_MSG([  ODBC support:              ${ODBC_SETTING}])
LOC_MSG([  PGeo support:              ${ODBC_SETTING}])
LOC_MSG([  FGDB support:              ${FGDB_ENABLED}])
LOC_MSG([  MDB support:               ${MDB_ENABLED}])
LOC_MSG([  PCIDSK support:            ${PCIDSK_SETTING}])
LOC_MSG([  OCI support:               ${HAVE_OCI}])
LOC_MSG([  GEORASTER support:         ${HAVE_GEORASTER}])
LOC_MSG([  SDE support:               ${SDE_ENABLED}])
LOC_MSG([  Rasdaman support:          ${RASDAMAN_ENABLED}])
LOC_MSG([  DODS support:              ${HAVE_DODS}])
LOC_MSG([  SQLite support:            ${HAVE_SQLITE}])
LOC_MSG([  PCRE support:              ${HAVE_PCRE}])
LOC_MSG([  SpatiaLite support:        ${HAVE_SPATIALITE}])
LOC_MSG([  DWGdirect support          ${HAVE_DWGDIRECT}])
LOC_MSG([  INFORMIX DataBlade support:${HAVE_IDB}])
LOC_MSG([  GEOS support:              ${HAVE_GEOS_RESULT}])
LOC_MSG([  Poppler support:           ${HAVE_POPPLER}])
LOC_MSG([  Podofo support:            ${HAVE_PODOFO}])
LOC_MSG([  OpenCL support:            ${OPENCL_SETTING}])
LOC_MSG([  Armadillo support:         ${HAVE_ARMADILLO}])
LOC_MSG([  FreeXL support:            ${HAVE_FREEXL}])
LOC_MSG()
if test ! -z "`uname | grep Darwin`" ; then
  LOC_MSG([  Mac OS X Framework :       ${MACOSX_FRAMEWORK}])
fi
LOC_MSG()
if test -z "$BINDINGS"; then
    WHAT_BINDINGS="no"
else
    WHAT_BINDINGS="$BINDINGS"
fi
LOC_MSG([  SWIG Bindings:             ${WHAT_BINDINGS}])
LOC_MSG()
LOC_MSG([  Statically link PROJ.4:    ${PROJ_STATIC}])
LOC_MSG([  enable OGR building:       ${OGR_ENABLED}])
LOC_MSG([  enable pthread support:    ${PTHREAD_ENABLED}])
LOC_MSG([  enable POSIX iconv support:${am_cv_func_iconv}])
LOC_MSG([  hide internal symbols:     ${HAVE_HIDE_INTERNAL_SYMBOLS}])
LOC_MSG()

if test "$HAVE_PODOFO" = "yes" -a "$HAVE_POPPLER" = "yes" ; then
    AC_MSG_WARN([--with-podofo and --with-poppler are both available. This is unusual setup, but will work. Poppler will be used by default...])
fi
if test "$HAVE_LIBXML2" = "yes" -a "$FGDB_ENABLED" = "yes"; then
    AC_MSG_WARN([--with-libxml2 and --with-fgdb are both available. There might be some incompatibility between system libxml2 and the embedded copy within libFileGDBAPI])
fi