File: configure.ac

package info (click to toggle)
gnustep-base 1.31.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,580 kB
  • sloc: objc: 239,446; ansic: 36,519; cpp: 122; sh: 112; makefile: 100; xml: 32
file content (3987 lines) | stat: -rw-r--r-- 154,035 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
# configure.ac for GNU Objective-C library
# Process this file with autoconf to produce a configure script.
#
#   Copyright (C) 1993,1994, 1995, 1996, 1997 Free Software Foundation, Inc.
#
#   Written by:  Andrew Kachites McCallum <mccallum@cs.rochester.edu>
#   Dept. of Computer Science, U. of Rochester, Rochester, NY  14627
#
#   This file is part of the GNU Objective-C library.
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public
#   License as published by the Free Software Foundation; either
#   version 2 of the License, or (at your option) any later version.
#
#   This library is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public
#   License along with this library; if not, write to the Free
#   Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA

#
# DEPENDENCIES POLICY
#
# Generally the aim in the base library is to minimise dependencies on
# external libraries which may not come as standard on all systems, and
# you should not, as a rule, add such dependencies.
#
# However, in some cases there are large areas of functionality where it
# would just be too much effort to implement things ourselves and it makes
# sense to use external software to do the job.
#
# In such cases this configure.ac script should include options to allow
# people to build with the dependency or to disable those parts of the
# base library which require the external dependency and build without it.
# The configure script should support a --disable-xxx option in such a case,
# where 'xxx' is the name of the dependency.
#
# If a major dependency is NOT specifically disabled, the configuration
# process must fail with an error message ... all builds of gnustep-base
# should support all expected functionality unless the person configuring
# and building is very certain they don't want it.
#
# Where a dependency is introduced this script should do this by setting
# HAVE_XXX to 1 or 0 and calling AC_SUBST(XXX) to substitute the information
# into the make files:
#   config.mak.in: used to build the base library itsself
#   base.make.in: the makefile fragment used to build software which uses base
# These files then define GNUSTEP_BASE_HAVE_XXX to 1 or 0 so that the variable
# may be used to control conditional compilation of particular files.
#
# In addition the values should be substituted into the header file
# Headers/GNUstepBase/GSConfig.h.in so that it can define a
# preprocessor constant of the form GS_USE_XXX to 1 or 0, providing a
# standard mechanism for parts of a particular file to compile to make
# use of the external code or not.
# This file is included by all the base library source code, and may also
# be included by code which uses the base library.
#

builtin(include, config/objc-con-autoload.m4)dnl
builtin(include, config/objc-sys-dynamic.m4)dnl
builtin(include, config/procfs-exe-link.m4)dnl
builtin(include, config/procfs.m4)dnl
builtin(include, config/pathxml.m4)dnl
builtin(include, config/pathtls.m4)dnl
builtin(include, config/codeset.m4)dnl
builtin(include, config/addlibrarypath.m4)dnl
builtin(include, config/pkg.m4)dnl

AC_INIT
AC_PREREQ([2.71])
AC_CONFIG_SRCDIR([Source/NSArray.m])

# If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it.
if test -z "$GNUSTEP_MAKEFILES"; then
  GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>&5`
fi

if test -z "$GNUSTEP_MAKEFILES"; then
  AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
fi

# If LIBRARY_COMBO is undefined, try to use gnustep-config to determine it.
if test -z "$LIBRARY_COMBO"; then
  LIBRARY_COMBO=`gnustep-config --variable=LIBRARY_COMBO 2>&5`
fi
OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'`

if test "$OBJC_RUNTIME_LIB" = "ng" -o "$OBJC_RUNTIME_LIB" = "apple"; then
  nonfragile=yes
  BASE_NONFRAGILE_ABI=1
else
  nonfragile=`gnustep-config --objc-flags | grep _NONFRAGILE_ABI 2>&5`
  if test -z "$nonfragile"; then
    nonfragile=no
    BASE_NONFRAGILE_ABI=0
  else
    nonfragile=yes
    BASE_NONFRAGILE_ABI=1
  fi
fi
AC_SUBST(BASE_NONFRAGILE_ABI)

MAKECPPFLAGS=`gnustep-config --variable=CPPFLAGS`
if test "$CPPFLAGS" = ""; then
  CPPFLAGS=$MAKECPPFLAGS
  export CPPFLAGS
else
  if test "$CPPFLAGS" != "$MAKECPPFLAGS"; then
    AC_MSG_WARN([You are running configure with the preprocessor options ($CPPFLAGS) set to a different value from that used by gnustep-make ($MAKECPPFLAGS).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CPPFLAGS=$CPPFLAGS or run the gnustep-base configure again with your CPPFLAGS environment variable set to $MAKECPPFLAGS])
  fi
fi

MAKELDFLAGS=`gnustep-config --variable=LDFLAGS`
if test "$LDFLAGS" = ""; then
  LDFLAGS=$MAKELDFLAGS
  export LDFLAGS
else
  if test "$LDFLAGS" != "$MAKELDFLAGS"; then
    AC_MSG_WARN([You are running configure with the link options ($LDFLAGS) set to a different value from that used by gnustep-make ($MAKELDFLAGS).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use LDFLAGS=$LDFLAGS or run the gnustep-base configure again with your LDFLAGS environment variable set to $MAKELDFLAGS])
  fi
fi

AC_SUBST(BASEFLAGS, `gnustep-config --objc-flags`)
AC_SUBST(BASELIBS, `gnustep-config --base-libs`)

# We shouldn't be loading GNUstep.sh here.  It would load in a lot of
# variables which might get confused with the ones that will be used
# at runtime.  We will load it later once we have determined (and
# saved) the runtime configuration.

# This variable might get temporarily overwritten with the
# GNUSTEP_MAKEFILES of the runtime configuration, make sure we keep
# track of the original one.  CURRENT_GNUSTEP_MAKEFILES is the one
# that we use to locate the actual gnustep-make installation that
# will build the software.
CURRENT_GNUSTEP_MAKEFILES="$GNUSTEP_MAKEFILES"

#--------------------------------------------------------------------
# Use config.guess, config.sub and install-sh provided by gnustep-make
# Evaluation order of the configure script means we can not depend on
# GNUSTEP_MAKEFILES being set for simple variable substitution, so we
# execute a bit of shell code to dynamically get the directory.
#--------------------------------------------------------------------
AC_CONFIG_AUX_DIR([`if test -z "$GNUSTEP_MAKEFILES"; then
  gnustep-config --variable=GNUSTEP_MAKEFILES 2>&5
else
  echo $GNUSTEP_MAKEFILES
fi`])


#--------------------------------------------------------------------
# Use a .h file with #define's, instead of -D command-line switches
#--------------------------------------------------------------------
AC_CONFIG_HEADERS([Headers/GNUstepBase/config.h:Headers/GNUstepBase/config.h.in])

#--------------------------------------------------------------------
# Determine the host, build, and target systems
#--------------------------------------------------------------------
AC_CANONICAL_TARGET([])

#--------------------------------------------------------------------
# Setup cross-compilation-information
#--------------------------------------------------------------------

AC_ARG_WITH(cross-compilation-info,
[  --with-cross-compilation-info=PATH
				Specify path to the configuration file that
				contains information for the configure script in
				case of cross compilation. This information
				replaces those obtained from running programmes
				during the configuration phase.],
  cross_result="$withval",
  cross_result="no"
)
CROSS_CONFIG="$srcdir/cross.config"
if test "$cross_result" != "no"
then
 if test -f "$cross_result" && test -r "$cross_result"
  then
    CROSS_CONFIG="$cross_result"
  else
    AC_MSG_ERROR(["Could not load cross-compilation variables from $cross_result"])
  fi
fi

# import information from the cross-config.
. "$CROSS_CONFIG"

AS_CASE([$host_cpu], [sparc*], [cross_NEED_WORD_ALIGNMENT=1])

#---------------------------------------------------------------------
# Location of the GNUstep.conf config file (--with-config-file)
#---------------------------------------------------------------------
AC_MSG_CHECKING([for GNUstep configuration file to use at runtime])

# This requires gnustep-make > 1.13.0 to work.  For gnustep-make =
# 1.13.0 we would have to parse
# $CURRENT_GNUSTEP_MAKEFILES/$obj_dir/config.make, but $obj_dir is not defined
# yet at this stage in config, not sure if it's worth trying to make
# it work.  For gnustep-make < 1.13.0 we would have to parse
# $CURRENT_GNUSTEP_MAKEFILES/config.make.
GNUSTEP_MAKE_CONFIG=`(grep '^GNUSTEP_CONFIG_FILE *=' $CURRENT_GNUSTEP_MAKEFILES/config-noarch.make | sed -e 's/GNUSTEP_CONFIG_FILE *= *\(.*\)/\1/') 2>&5`

# So, for backwards compatiblity, we try the plain config.make too.
# This should work with gnustep-make < 1.13.0, and with 1.13.0 too if
# they haven't deleted the file.
if test "$GNUSTEP_MAKE_CONFIG"  = ""; then
  GNUSTEP_MAKE_CONFIG=`(grep '^GNUSTEP_CONFIG_FILE *=' $CURRENT_GNUSTEP_MAKEFILES/config.make | sed -e 's/GNUSTEP_CONFIG_FILE *= *\(.*\)/\1/') 2>&5`
fi

AC_ARG_WITH(config-file,
[  --with-config-file=PATH       Specify path to the GNUstep config file.
				This is the location to be used by the base
				library to locate path information at
				application or tool runtime.
				This file might not even exist now; it is
				not read at configure time.  The base library
				will only read it at runtime.
				If unspecified, this uses the same value as
				the GNUstep make package on unix-like systems,
				but uses ./GNUstep.conf on mingw so that
				it is relative to the location of the
				base library DLL.
				If a leading './' is specified, the path
				is taken to be relative to the base library
				linked runtime, not all operating systems
				can support this, so on some platforms you
				may need to specify the location of the
				config file using the GNUSTEP_CONFIG_FILE
				environment variable at runtime.
				If a trailing '/' is specified, the path is
				used for locating domains but no GNUstep
				config file is read at runtime.],
  result="$withval",
  result="no"
)
if test "$result" != "no"
then
  GNUSTEP_TARGET_CONFIG_FILE="$result"
fi
if test x"$GNUSTEP_TARGET_CONFIG_FILE" = x""; then
  case "$target_os" in
    mingw*|windows)
      GNUSTEP_TARGET_CONFIG_FILE=./GNUstep.conf ;;
    *)
      GNUSTEP_TARGET_CONFIG_FILE="$GNUSTEP_MAKE_CONFIG" ;;
  esac
fi
AC_MSG_RESULT($GNUSTEP_TARGET_CONFIG_FILE)

#-----------------------------------------------------------------
# Whether the GNUstep.conf file path can be set in the environment
# By default this is enabled on unix, but disabled on mswindows
# since the normal setup on mswindows is to have the config file
# located with the base library dll for runtime configuration and
# use the environment variable to control the developer config file
# location (used by gnustep-make when building).
#-----------------------------------------------------------------
case "$target_os" in
    mingw*|windows)	enable_env_config=no;;
    *)		enable_env_config=yes;;
esac
AC_MSG_CHECKING([whether the GNUstep.conf file path can be set in the environment])
AC_ARG_ENABLE(environment-config-file,
[  --disable-environment-config-file
                                Disables the use of the GNUSTEP_CONFIG_FILE
				environment variable to specify/override
				the location of the GNUstep config file
				at runtime.  This option is occasionally
				useful to disable the environment variable
				for sites which wish to 'lock down' users
				to always work with a specific system-wide
				configuration.  On unix-like systems the
				default is for this option to be enabled.
				It is disabled by default on windows systems
				so that the base library will not use a
				config file intended for the gnustep-make
				system (and containing unix-style paths
				which cannot be used by windows apps).
				Normally this should be left at its default
				setting.],
  ac_cv_environment_config_file=$enableval,
  ac_cv_environment_config_file=$enable_env_config)
if test "$ac_cv_environment_config_file" = "yes"; then
  AC_DEFINE(OPTION_NO_ENVIRONMENT, 0,
    [Enable GNUSTEP_CONFIG_FILE environment variable])
  AC_MSG_RESULT([yes])
else
  AC_DEFINE(OPTION_NO_ENVIRONMENT, 1,
    [Disable GNUSTEP_CONFIG_FILE environment variable])
  AC_MSG_RESULT([no: disabled from the command-line])
fi

#--------------------------------------------------------------------
# We are now trying to determine the default GNUstep paths to be
# used at runtime.  So all GNUSTEP_xxx variables from now on are to be
# considered as 'runtime' ones.  They refer to paths that might not
# make any sense now, but might make sense once gnustep-base is
# installed in its final location.
#---------------------------------------------------------------------

#
# Set 'standard' defaults for values from configuration file.
#
case "$target_os" in
  *)
    GNUSTEP_SYSTEM_ROOT=/usr/GNUstep/System
    GNUSTEP_LOCAL_ROOT=/usr/GNUstep/Local
    GNUSTEP_NETWORK_ROOT=/usr/GNUstep/Local
    GNUSTEP_USER_DEFAULTS_DIR=GNUstep/Defaults
    GNUSTEP_USER_CONFIG_FILE=.GNUstep.conf
    ;;
esac

#---------------------------------------------------------------------
# Now read/import the existing configuration file, if any
#---------------------------------------------------------------------

# Reading/importing an existing configuration file is good as it means
# the built-in default paths in the code will match those of your
# installation (or of the config file you specify).
# It can be annoying in certain cases though; this option lets you
# turn it off.
AC_MSG_CHECKING([if we should import an existing configuration file now])
AC_ARG_ENABLE(importing-config-file,
[  --disable-importing-config-file
                                Disable importing of an existing GNUstep config
				file and use inbuilt defaults instead.],
  ac_cv_importing_config_file=$enableval,
  ac_cv_importing_config_file="yes")
if test "$ac_cv_importing_config_file" = "no"; then
  AC_MSG_RESULT([no: disabled from the command-line])
else
  AC_MSG_RESULT([yes])
fi


if test "$ac_cv_importing_config_file" = "yes" ;
then
  AC_MSG_CHECKING([for default GNUstep configuration file to use])
  AC_ARG_WITH(default-config,
[  --with-default-config=PATH   Specify path to a GNUstep config file to be
				imported at configure time (now) and used to
				provide default values for the base library
				to use at runtime if no GNUstep config file
				is found at runtime.  If this is not specified
				then the path from the gnustep-make package
				is used.],
    result="$withval",
    result="no"
  )
  if test "$result" != "no"
  then
    GNUSTEP_DEFAULT_CONFIG="$result"
  fi
  if test "$GNUSTEP_DEFAULT_CONFIG" = ""; then
    # No file to import has been specified.  We need to read the paths
    # from somewhere though!  GNUstep.sh might not have been sourced,
    # so at this stage we have no knowledge of what the paths must be.
    # The only place that we can read them from is the gnustep-make
    # GNUstep.conf file.
    # So we fall back to useing the make settings for the built-in ones.
    # However, on mingw these will be msys style paths, and we don't
    # want that ... so later on we convert these to portable relative
    # paths based on the directory in which the base library will be
    # installed.
    GNUSTEP_DEFAULT_CONFIG="$GNUSTEP_MAKE_CONFIG"
  fi
  AC_MSG_RESULT($GNUSTEP_DEFAULT_CONFIG)

  #
  # Only try importing if the default config file has been specified.
  #
  if test "$GNUSTEP_DEFAULT_CONFIG" != ""; then
    # Make sure we have a slash in the path so that '.' will source it
    case $GNUSTEP_DEFAULT_CONFIG in
      /*) ;;
      *) GNUSTEP_DEFAULT_CONFIG="./$GNUSTEP_DEFAULT_CONFIG" ;;
    esac
    #
    # Use the default config file to override standard values.
    #
    if test ! -f "$GNUSTEP_DEFAULT_CONFIG"; then
      AC_MSG_RESULT([fail: file "$GNUSTEP_DEFAULT_CONFIG" does not exist])
      # Ohoh ... things are not going well.  We are asked to import
      # a config file that doesn't exist.  So all paths might be unset
      # and who knows what we'll end up hardcoding into gnustep-base.
      # It looks like we need to make sure the user knows what they
      # are doing, as there is a high chance they don't and might end
      # up with a confused/non-working system.  As far as we know, the
      # system might be already screwed.  If they don't want to import
      # a config file (eg, they don't have one and they don't care about
      # the hardcoded paths) they should just say so. ;-)
      AC_MSG_ERROR([Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option])
      exit 1
    else
      AC_MSG_RESULT([trying to import "$GNUSTEP_DEFAULT_CONFIG"])
      if test -r "$GNUSTEP_DEFAULT_CONFIG"
      then
        AC_MSG_NOTICE([If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option])
        . "$GNUSTEP_DEFAULT_CONFIG"
      else
        AC_MSG_RESULT([fail: file "$GNUSTEP_DEFAULT_CONFIG" is not readable])
	AC_MSG_ERROR([Unable to import configuration file at $GNUSTEP_DEFAULT_CONFIG.  Please run configure again with a revised/corrected --with-default-config= option or with --disable-importing-config-file.])
	exit 1
      fi
    fi
  fi
fi

# If the GNUstep layout is debian-multiarch, expand the multiarch
# triplet, reporting where its value comes from.  This is necessary so
# that the library's hard-coded defaults contain the actual
# directories with the GS_MULTIARCH variable substituted.  Error out
# if something goes wrong.  While gnustep-make's configure script
# bails out if it cannot run dpkg-architecture, this check is a
# safeguard for (admittedly rare) situations when the layout does not
# match reality because the sysadmin has changed the variable's value
# for some reason.
AS_IF([test "x$GNUSTEP_FILESYSTEM_LAYOUT" = "xdebian-multiarch"],
  [AC_MSG_CHECKING([for the value of DEB_HOST_MULTIARCH])
   AS_IF([test "x$DEB_HOST_MULTIARCH" != "x"],
         [TRIPLET=$DEB_HOST_MULTIARCH
          AC_MSG_RESULT([$TRIPLET (from environment)])],
         [AS_IF([TRIPLET=`dpkg-architecture --query DEB_HOST_MULTIARCH`
                 test "x$TRIPLET" != "x"],
                [AC_MSG_RESULT([$TRIPLET (from dpkg-architecture)])],
                [AC_MSG_ERROR([failed to obtain the value of the DEB_HOST_MULTIARCH variable.])])])
AC_DEFINE_UNQUOTED([GS_MULTIARCH], ["$TRIPLET"],
                   [Value of the DEB_HOST_MULTIARCH variable on Debian.])
GNUSTEP_SYSTEM_APPS=`echo $GNUSTEP_SYSTEM_APPS | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`
GNUSTEP_SYSTEM_ADMIN_APPS=`echo $GNUSTEP_SYSTEM_ADMIN_APPS | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`
GNUSTEP_SYSTEM_WEB_APPS=`echo $GNUSTEP_SYSTEM_WEB_APPS | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`
GNUSTEP_SYSTEM_LIBRARY=`echo $GNUSTEP_SYSTEM_LIBRARY | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`
GNUSTEP_SYSTEM_HEADERS=`echo $GNUSTEP_SYSTEM_HEADERS | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`
GNUSTEP_SYSTEM_LIBRARIES=`echo $GNUSTEP_SYSTEM_LIBRARIES | sed -e "s|\\${GS_MULTIARCH}|$TRIPLET|"`],
[])

# Now we have the problem of what to do if some of the paths were not
# set by GNUstep.conf (eg, old gnustep-make), or if no config file was
# read, or if the config file was corrupt.  We decide that the most
# likely case is an old gnustep-make, so by default we configure the
# other paths basing on GNUSTEP_*_ROOT.

# TODO/FIXME: We should really have better checks once the situation
# has stabilized.  This is a reasonable hack for now.

if test x"$GNUSTEP_MAKEFILES" = x""; then GNUSTEP_MAKEFILES=$GNUSTEP_SYSTEM_ROOT/Library/Makefiles; fi

if test x"$GNUSTEP_SYSTEM_USERS_DIR" = x""; then GNUSTEP_SYSTEM_USERS_DIR=/home; fi
if test x"$GNUSTEP_NETWORK_USERS_DIR" = x""; then GNUSTEP_NETWORK_USERS_DIR=/home; fi
if test x"$GNUSTEP_LOCAL_USERS_DIR" = x""; then GNUSTEP_LOCAL_USERS_DIR=/home; fi

if test x"$GNUSTEP_SYSTEM_APPS" = x""; then GNUSTEP_SYSTEM_APPS=$GNUSTEP_SYSTEM_ROOT/Applications; fi
if test x"$GNUSTEP_SYSTEM_ADMIN_APPS" = x""; then GNUSTEP_SYSTEM_ADMIN_APPS=$GNUSTEP_SYSTEM_ROOT/Applications/Admin; fi
if test x"$GNUSTEP_SYSTEM_WEB_APPS" = x""; then GNUSTEP_SYSTEM_WEB_APPS=$GNUSTEP_SYSTEM_ROOT/WebApplications; fi
if test x"$GNUSTEP_SYSTEM_TOOLS" = x""; then GNUSTEP_SYSTEM_TOOLS=$GNUSTEP_SYSTEM_ROOT/Tools; fi
if test x"$GNUSTEP_SYSTEM_ADMIN_TOOLS" = x""; then GNUSTEP_SYSTEM_ADMIN_TOOLS=$GNUSTEP_SYSTEM_ROOT/Tools/Admin; fi
if test x"$GNUSTEP_SYSTEM_LIBRARY" = x""; then GNUSTEP_SYSTEM_LIBRARY=$GNUSTEP_SYSTEM_ROOT/Library; fi
if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then GNUSTEP_SYSTEM_LIBRARIES=$GNUSTEP_SYSTEM_LIBRARY/Libraries; fi
if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then GNUSTEP_SYSTEM_HEADERS=$GNUSTEP_SYSTEM_LIBRARY/Headers; fi
if test x"$GNUSTEP_SYSTEM_DOC" = x""; then GNUSTEP_SYSTEM_DOC=$GNUSTEP_SYSTEM_LIBRARY/Documentation; fi
if test x"$GNUSTEP_SYSTEM_DOC_MAN" = x""; then GNUSTEP_SYSTEM_DOC_MAN=$GNUSTEP_SYSTEM_LIBRARY/Documentation/man; fi
if test x"$GNUSTEP_SYSTEM_DOC_INFO" = x""; then GNUSTEP_SYSTEM_DOC_INFO=$GNUSTEP_SYSTEM_LIBRARY/Documentation/info; fi

if test x"$GNUSTEP_NETWORK_APPS" = x""; then GNUSTEP_NETWORK_APPS=$GNUSTEP_NETWORK_ROOT/Applications; fi
if test x"$GNUSTEP_NETWORK_ADMIN_APPS" = x""; then GNUSTEP_NETWORK_ADMIN_APPS=$GNUSTEP_NETWORK_ROOT/Applications/Admin; fi
if test x"$GNUSTEP_NETWORK_WEB_APPS" = x""; then GNUSTEP_NETWORK_APPS=$GNUSTEP_NETWORK_ROOT/WebApplications; fi
if test x"$GNUSTEP_NETWORK_TOOLS" = x""; then GNUSTEP_NETWORK_TOOLS=$GNUSTEP_NETWORK_ROOT/Tools; fi
if test x"$GNUSTEP_NETWORK_ADMIN_TOOLS" = x""; then GNUSTEP_NETWORK_ADMIN_TOOLS=$GNUSTEP_NETWORK_ROOT/Tools/Admin; fi
if test x"$GNUSTEP_NETWORK_LIBRARY" = x""; then GNUSTEP_NETWORK_LIBRARY=$GNUSTEP_NETWORK_ROOT/Library; fi
if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then GNUSTEP_NETWORK_LIBRARIES=$GNUSTEP_NETWORK_LIBRARY/Libraries; fi
if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then GNUSTEP_NETWORK_HEADERS=$GNUSTEP_NETWORK_LIBRARY/Headers; fi
if test x"$GNUSTEP_NETWORK_DOC" = x""; then GNUSTEP_NETWORK_DOC=$GNUSTEP_NETWORK_LIBRARY/Documentation; fi
if test x"$GNUSTEP_NETWORK_DOC_MAN" = x""; then GNUSTEP_NETWORK_DOC_MAN=$GNUSTEP_NETWORK_LIBRARY/Documentation/man; fi
if test x"$GNUSTEP_NETWORK_DOC_INFO" = x""; then GNUSTEP_NETWORK_DOC_INFO=$GNUSTEP_NETWORK_LIBRARY/Documentation/info; fi

if test x"$GNUSTEP_LOCAL_APPS" = x""; then GNUSTEP_LOCAL_APPS=$GNUSTEP_LOCAL_ROOT/Applications; fi
if test x"$GNUSTEP_LOCAL_ADMIN_APPS" = x""; then GNUSTEP_LOCAL_ADMIN_APPS=$GNUSTEP_LOCAL_ROOT/Applications/Admin; fi
if test x"$GNUSTEP_LOCAL_WEB_APPS" = x""; then GNUSTEP_LOCAL_APPS=$GNUSTEP_LOCAL_ROOT/WebApplications; fi
if test x"$GNUSTEP_LOCAL_TOOLS" = x""; then GNUSTEP_LOCAL_TOOLS=$GNUSTEP_LOCAL_ROOT/Tools; fi
if test x"$GNUSTEP_LOCAL_ADMIN_TOOLS" = x""; then GNUSTEP_LOCAL_ADMIN_TOOLS=$GNUSTEP_LOCAL_ROOT/Tools/Admin; fi
if test x"$GNUSTEP_LOCAL_LIBRARY" = x""; then GNUSTEP_LOCAL_LIBRARY=$GNUSTEP_LOCAL_ROOT/Library; fi
if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then GNUSTEP_LOCAL_LIBRARIES=$GNUSTEP_LOCAL_LIBRARY/Libraries; fi
if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then GNUSTEP_LOCAL_HEADERS=$GNUSTEP_LOCAL_LIBRARY/Headers; fi
if test x"$GNUSTEP_LOCAL_DOC" = x""; then GNUSTEP_LOCAL_DOC=$GNUSTEP_LOCAL_LIBRARY/Documentation; fi
if test x"$GNUSTEP_LOCAL_DOC_MAN" = x""; then GNUSTEP_LOCAL_DOC_MAN=$GNUSTEP_LOCAL_LIBRARY/Documentation/man; fi
if test x"$GNUSTEP_LOCAL_DOC_INFO" = x""; then GNUSTEP_LOCAL_DOC_INFO=$GNUSTEP_LOCAL_LIBRARY/Documentation/info; fi

if test x"$GNUSTEP_USER_DIR_APPS" = x""; then GNUSTEP_USER_DIR_APPS=$GNUSTEP_USER_DIR/Applications; fi
if test x"$GNUSTEP_USER_DIR_ADMIN_APPS" = x""; then GNUSTEP_USER_DIR_ADMIN_APPS=$GNUSTEP_USER_DIR/Applications/Admin; fi
if test x"$GNUSTEP_USER_DIR_WEB_APPS" = x""; then GNUSTEP_USER_DIR_APPS=$GNUSTEP_USER_DIR/WebApplications; fi
if test x"$GNUSTEP_USER_DIR_TOOLS" = x""; then GNUSTEP_USER_DIR_TOOLS=$GNUSTEP_USER_DIR/Tools; fi
if test x"$GNUSTEP_USER_DIR_ADMIN_TOOLS" = x""; then GNUSTEP_USER_DIR_ADMIN_TOOLS=$GNUSTEP_USER_DIR/Tools/Admin; fi
if test x"$GNUSTEP_USER_DIR_LIBRARY" = x""; then GNUSTEP_USER_DIR_LIBRARY=$GNUSTEP_USER_DIR/Library; fi
if test x"$GNUSTEP_USER_DIR_LIBRARIES" = x""; then GNUSTEP_USER_DIR_LIBRARIES=$GNUSTEP_USER_DIR/Libraries; fi
if test x"$GNUSTEP_USER_DIR_HEADERS" = x""; then GNUSTEP_USER_DIR_HEADERS=$GNUSTEP_USER_DIR/Headers; fi
if test x"$GNUSTEP_USER_DIR_DOC" = x""; then GNUSTEP_USER_DIR_DOC=$GNUSTEP_USER_DIR/Documentation; fi
if test x"$GNUSTEP_USER_DIR_DOC_MAN" = x""; then GNUSTEP_USER_DIR_DOC_MAN=$GNUSTEP_USER_DIR/Documentation/man; fi
if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNUSTEP_USER_DIR/Documentation/info; fi

AC_MSG_CHECKING([for GNUstep-base installation domain])
AC_ARG_WITH(installation-domain,
[  --with-installation-domain=DOMAIN
				Specify the domain (SYSTEM, LOCAL,
				NETWORK or USER) into which
				gnustep-base will be installed.
				Whenever relative paths are hardcoded
				into gnustep-base (at the moment, this
				happens only on MinGW) this option
				must be used and must match the domain
				where you will be installing
				gnustep-base.
				If this is not specified, the output of
				gnustep-config --installation-domain-for=gnustep-base
				(which should normally be LOCAL) is used.],
  result="$withval",
  result="no"
)
if test "$result" = "no"
then
  # Check if gnustep-config supports the option
  # --installation-domain-for, and use it if available.  That option
  # will automatically use the shell variable GNUSTEP_INSTALLATION_DOMAIN or
  # the installation-domains.conf files (or the LOCAL default) as appropriate.
  # Otherwise, if that option is not available just fall back to
  # using GNUSTEP_INSTALLATION_DOMAIN or (if that was not defiend) LOCAL.
  if (gnustep-config --help | grep installation-domain) >&5 2>&5
  then
    result=`gnustep-config --installation-domain-for=gnustep-base 2>&5`
  else
    AC_MSG_WARN([The 'gnustep-config' script was not found or out of date.])
    result=$GNUSTEP_INSTALLATION_DOMAIN
    if test "$result" = ""
    then
      # This case was added on December 2008 and is only for backwards
      # compatibility with older versions of gnustep-make.
      result=LOCAL
    fi
  fi
fi
case "$result" in
  SYSTEM)
    AC_MSG_RESULT([SYSTEM])
    GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS";;
  LOCAL)
    AC_MSG_RESULT([LOCAL])
    GNUSTEP_BASE_PATH="$GNUSTEP_LOCAL_TOOLS";;
  NETWORK)
    AC_MSG_RESULT([NETWORK])
    GNUSTEP_BASE_PATH="$GNUSTEP_NETWORK_TOOLS";;
  USER)
    AC_MSG_RESULT([USER])
    GNUSTEP_BASE_PATH="$GNUSTEP_USER_TOOLS";;
  *)
    AC_MSG_ERROR([Unknown installation domain '$result' (it should be SYSTEM, LOCAL, NETWORK or USER).  Please run configure again with the option --with-installation-domain=LOCAL (or whatever domain you want to install into).])
    exit 1;;
esac
# We store GNUSTEP_BASE_DOMAIN in config.mak so that we can check
# at runtime and make sure it is consistent with the
# GNUSTEP_INSTALLATION_DOMAIN that is used at runtime.
GNUSTEP_BASE_DOMAIN=$result
AC_SUBST(GNUSTEP_BASE_DOMAIN)

#
# If we are on mingw, we now want to convert the paths to relative
# paths (relative to libgnustep-base.dll).
#
case "$target_os" in
  mingw*|windows)
    GNUSTEP_SYSTEM_USERS_DIR="C:\Users"
    GNUSTEP_NETWORK_USERS_DIR="C:\Users"
    GNUSTEP_LOCAL_USERS_DIR="C:\Users"

    GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS short`
    GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS short`
    GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS short`
    GNUSTEP_SYSTEM_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_TOOLS short`
    GNUSTEP_SYSTEM_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_TOOLS short`
    GNUSTEP_SYSTEM_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_LIBRARY short`
    GNUSTEP_SYSTEM_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_LIBRARIES short`
    GNUSTEP_SYSTEM_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_HEADERS short`
    GNUSTEP_SYSTEM_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC short`
    GNUSTEP_SYSTEM_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC_MAN short`
    GNUSTEP_SYSTEM_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_DOC_INFO short`

    GNUSTEP_NETWORK_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_APPS short`
    GNUSTEP_NETWORK_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_ADMIN_APPS short`
    GNUSTEP_NETWORK_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_WEB_APPS short`
    GNUSTEP_NETWORK_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_TOOLS short`
    GNUSTEP_NETWORK_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_ADMIN_TOOLS short`
    GNUSTEP_NETWORK_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_LIBRARY short`
    GNUSTEP_NETWORK_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_LIBRARIES short`
    GNUSTEP_NETWORK_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_HEADERS short`
    GNUSTEP_NETWORK_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC short`
    GNUSTEP_NETWORK_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC_MAN short`
    GNUSTEP_NETWORK_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_NETWORK_DOC_INFO short`

    GNUSTEP_LOCAL_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_APPS short`
    GNUSTEP_LOCAL_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_ADMIN_APPS short`
    GNUSTEP_LOCAL_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_WEB_APPS short`
    GNUSTEP_LOCAL_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_TOOLS short`
    GNUSTEP_LOCAL_ADMIN_TOOLS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_ADMIN_TOOLS short`
    GNUSTEP_LOCAL_LIBRARY=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_LIBRARY short`
    GNUSTEP_LOCAL_LIBRARIES=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_LIBRARIES short`
    GNUSTEP_LOCAL_HEADERS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_HEADERS short`
    GNUSTEP_LOCAL_DOC=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC short`
    GNUSTEP_LOCAL_DOC_MAN=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC_MAN short`
    GNUSTEP_LOCAL_DOC_INFO=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_LOCAL_DOC_INFO short`
# It would be nice to now store this stuff into a ./GNUstep.conf file
# installed with gnustep-base.dll.  This would clarify.
    ;;
esac

GNUSTEP_BASE_RELATIVE_PATHS=no

# Now, check if any of the paths is a relative path.
for path in \
 "$GNUSTEP_SYSTEM_APPS" "$GNUSTEP_SYSTEM_ADMIN_APPS" "$GNUSTEP_SYSTEM_WEB_APPS" \
 "$GNUSTEP_SYSTEM_TOOLS" "$GNUSTEP_SYSTEM_ADMIN_TOOLS" \
 "$GNUSTEP_SYSTEM_LIBRARY" "$GNUSTEP_SYSTEM_LIBRARIES" "$GNUSTEP_SYSTEM_HEADERS" \
 "$GNUSTEP_SYSTEM_DOC" "$GNUSTEP_SYSTEM_DOC_MAN" "$GNUSTEP_SYSTEM_DOC_INFO" \
 "$GNUSTEP_NETWORK_APPS" "$GNUSTEP_NETWORK_ADMIN_APPS" "$GNUSTEP_NETWORK_WEB_APPS" \
 "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_NETWORK_ADMIN_TOOLS" \
 "$GNUSTEP_NETWORK_LIBRARY" "$GNUSTEP_NETWORK_LIBRARIES" "$GNUSTEP_NETWORK_HEADERS" \
 "$GNUSTEP_NETWORK_DOC" "$GNUSTEP_NETWORK_DOC_MAN" "$GNUSTEP_NETWORK_DOC_INFO" \
 "$GNUSTEP_LOCAL_APPS" "$GNUSTEP_LOCAL_ADMIN_APPS" "$GNUSTEP_LOCAL_WEB_APPS" \
 "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_LOCAL_ADMIN_TOOLS" \
 "$GNUSTEP_LOCAL_LIBRARY" "$GNUSTEP_LOCAL_LIBRARIES" "$GNUSTEP_LOCAL_HEADERS" \
 "$GNUSTEP_LOCAL_DOC" "$GNUSTEP_LOCAL_DOC_MAN" "$GNUSTEP_LOCAL_DOC_INFO"; do
case "$path" in
  ./*)  GNUSTEP_BASE_RELATIVE_PATHS=yes ;;
  ../*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;;
esac
done

AC_MSG_CHECKING([if we are hardcoding any relative paths in gnustep-base])
AC_MSG_RESULT($GNUSTEP_BASE_RELATIVE_PATHS)
AC_SUBST(GNUSTEP_BASE_RELATIVE_PATHS)

#
# Now, we want to print out the paths that we're going to hardcode
# into gnustep-base.  This is to help users in finding
# misconfigurations.
#
AC_MSG_NOTICE([We store the following filesystem layout into gnustep-base, to be used when no config file is found])
AC_MSG_CHECKING([for Makefiles directory])
AC_MSG_RESULT($GNUSTEP_MAKEFILES)
AC_MSG_CHECKING([for user defaults directory])
AC_MSG_RESULT($GNUSTEP_USER_DEFAULTS_DIR)
AC_MSG_CHECKING([for user config file])
AC_MSG_RESULT($GNUSTEP_USER_CONFIG_FILE)

AC_MSG_CHECKING([for System Applications directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_APPS)
AC_MSG_CHECKING([for System Admin Applications directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_APPS)
AC_MSG_CHECKING([for System Web Applications directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_WEB_APPS)
AC_MSG_CHECKING([for System Tools directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_TOOLS)
AC_MSG_CHECKING([for System Admin Tools directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_ADMIN_TOOLS)
AC_MSG_CHECKING([for System Library directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARY)
AC_MSG_CHECKING([for System Libraries directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_LIBRARIES)
AC_MSG_CHECKING([for System Headers directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_HEADERS)
AC_MSG_CHECKING([for System Documentation directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC)
AC_MSG_CHECKING([for System Info Documentation directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_INFO)
AC_MSG_CHECKING([for System Man Documentation directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_DOC_MAN)

AC_MSG_CHECKING([for Network Applications directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_APPS)
AC_MSG_CHECKING([for Network Admin Applications directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_APPS)
AC_MSG_CHECKING([for Network Web Applications directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_WEB_APPS)
AC_MSG_CHECKING([for Network Tools directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_TOOLS)
AC_MSG_CHECKING([for Network Admin Tools directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_ADMIN_TOOLS)
AC_MSG_CHECKING([for Network Library directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARY)
AC_MSG_CHECKING([for Network Libraries directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_LIBRARIES)
AC_MSG_CHECKING([for Network Headers directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_HEADERS)
AC_MSG_CHECKING([for Network Documentation directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_DOC)
AC_MSG_CHECKING([for Network Info Documentation directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_INFO)
AC_MSG_CHECKING([for Network Man Documentation directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_DOC_MAN)

AC_MSG_CHECKING([for Local Applications directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_APPS)
AC_MSG_CHECKING([for Local Admin Applications directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_APPS)
AC_MSG_CHECKING([for Local Web Applications directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_WEB_APPS)
AC_MSG_CHECKING([for Local Tools directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_TOOLS)
AC_MSG_CHECKING([for Local Admin Tools directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_ADMIN_TOOLS)
AC_MSG_CHECKING([for Local Library directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARY)
AC_MSG_CHECKING([for Local Libraries directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_LIBRARIES)
AC_MSG_CHECKING([for Local Headers directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_HEADERS)
AC_MSG_CHECKING([for Local Documentation directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_DOC)
AC_MSG_CHECKING([for Local Info Documentation directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_INFO)
AC_MSG_CHECKING([for Local Man Documentation directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_DOC_MAN)

AC_MSG_CHECKING([for User Applications directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_APPS)
AC_MSG_CHECKING([for User Admin Applications directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_APPS)
AC_MSG_CHECKING([for User Web Applications directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_WEB_APPS)
AC_MSG_CHECKING([for User Tools directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_TOOLS)
AC_MSG_CHECKING([for User Admin Tools directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_ADMIN_TOOLS)
AC_MSG_CHECKING([for User Library directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARY)
AC_MSG_CHECKING([for User Libraries directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_LIBRARIES)
AC_MSG_CHECKING([for User Headers directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_HEADERS)
AC_MSG_CHECKING([for User Documentation directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC)
AC_MSG_CHECKING([for User Info Documentation directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_INFO)
AC_MSG_CHECKING([for User Man Documentation directory])
AC_MSG_RESULT($GNUSTEP_USER_DIR_DOC_MAN)

AC_MSG_CHECKING([for System User directory])
AC_MSG_RESULT($GNUSTEP_SYSTEM_USERS_DIR)
AC_MSG_CHECKING([for Network User directory])
AC_MSG_RESULT($GNUSTEP_NETWORK_USERS_DIR)
AC_MSG_CHECKING([for Local User directory])
AC_MSG_RESULT($GNUSTEP_LOCAL_USERS_DIR)

#
# Set the default configuration file values in config.h to be hard-coded
# into NSPathUtilities.m
#
GNUSTEP_MAKEFILES=`echo $GNUSTEP_MAKEFILES|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_MAKEFILES,
  "$GNUSTEP_MAKEFILES",
  [Built in default value for GNUstep Makefiles])
GNUSTEP_USER_DEFAULTS_DIR=`echo $GNUSTEP_USER_DEFAULTS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DEFAULTS_DIR,
  "$GNUSTEP_USER_DEFAULTS_DIR",
  [Built in default value for GNUstep user defaults directory])
GNUSTEP_USER_CONFIG_FILE=`echo $GNUSTEP_USER_CONFIG_FILE|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_CONFIG_FILE,
  "$GNUSTEP_USER_CONFIG_FILE",
  [Built in default value for GNUstep user config file])
GNUSTEP_TARGET_CONFIG_FILE=`echo $GNUSTEP_TARGET_CONFIG_FILE|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_CONFIG_FILE,
  "$GNUSTEP_TARGET_CONFIG_FILE",
  [Built in default value for GNUstep config file])

#
# SYSTEM domain paths
#
GNUSTEP_SYSTEM_APPS=`echo $GNUSTEP_SYSTEM_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_APPS,
  "$GNUSTEP_SYSTEM_APPS",
  [Built in default value for GNUstep system apps])

GNUSTEP_SYSTEM_ADMIN_APPS=`echo $GNUSTEP_SYSTEM_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_ADMIN_APPS,
  "$GNUSTEP_SYSTEM_ADMIN_APPS",
  [Built in default value for GNUstep system apps])

GNUSTEP_SYSTEM_WEB_APPS=`echo $GNUSTEP_SYSTEM_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_WEB_APPS,
  "$GNUSTEP_SYSTEM_WEB_APPS",
  [Built in default value for GNUstep web apps])

GNUSTEP_SYSTEM_TOOLS=`echo $GNUSTEP_SYSTEM_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_TOOLS,
  "$GNUSTEP_SYSTEM_TOOLS",
  [Built in default value for GNUstep system tools])

GNUSTEP_SYSTEM_ADMIN_TOOLS=`echo $GNUSTEP_SYSTEM_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_ADMIN_TOOLS,
  "$GNUSTEP_SYSTEM_ADMIN_TOOLS",
  [Built in default value for GNUstep system tools])

GNUSTEP_SYSTEM_LIBRARY=`echo $GNUSTEP_SYSTEM_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_LIBRARY,
  "$GNUSTEP_SYSTEM_LIBRARY",
  [Built in default value for GNUstep system library])

GNUSTEP_SYSTEM_LIBRARIES=`echo $GNUSTEP_SYSTEM_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_LIBRARIES,
  "$GNUSTEP_SYSTEM_LIBRARIES",
  [Built in default value for GNUstep system libraries])

GNUSTEP_SYSTEM_HEADERS=`echo $GNUSTEP_SYSTEM_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_HEADERS,
  "$GNUSTEP_SYSTEM_HEADERS",
  [Built in default value for GNUstep system headers])

GNUSTEP_SYSTEM_DOC=`echo $GNUSTEP_SYSTEM_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC,
  "$GNUSTEP_SYSTEM_DOC",
  [Built in default value for GNUstep system documentation])

GNUSTEP_SYSTEM_DOC_MAN=`echo $GNUSTEP_SYSTEM_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC_MAN,
  "$GNUSTEP_SYSTEM_DOC_MAN",
  [Built in default value for GNUstep system manpages documentation])

GNUSTEP_SYSTEM_DOC_INFO=`echo $GNUSTEP_SYSTEM_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_DOC_INFO,
  "$GNUSTEP_SYSTEM_DOC_INFO",
  [Built in default value for GNUstep system info documentation])

#
# NETWORK domain paths
#
GNUSTEP_NETWORK_APPS=`echo $GNUSTEP_NETWORK_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_APPS,
  "$GNUSTEP_NETWORK_APPS",
  [Built in default value for GNUstep network apps])

GNUSTEP_NETWORK_ADMIN_APPS=`echo $GNUSTEP_NETWORK_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_ADMIN_APPS,
  "$GNUSTEP_NETWORK_ADMIN_APPS",
  [Built in default value for GNUstep network apps])

GNUSTEP_NETWORK_WEB_APPS=`echo $GNUSTEP_NETWORK_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_WEB_APPS,
  "$GNUSTEP_NETWORK_WEB_APPS",
  [Built in default value for GNUstep network web apps])

GNUSTEP_NETWORK_TOOLS=`echo $GNUSTEP_NETWORK_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_TOOLS,
  "$GNUSTEP_NETWORK_TOOLS",
  [Built in default value for GNUstep network tools])

GNUSTEP_NETWORK_ADMIN_TOOLS=`echo $GNUSTEP_NETWORK_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_ADMIN_TOOLS,
  "$GNUSTEP_NETWORK_ADMIN_TOOLS",
  [Built in default value for GNUstep system tools])

GNUSTEP_NETWORK_LIBRARY=`echo $GNUSTEP_NETWORK_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_LIBRARY,
  "$GNUSTEP_NETWORK_LIBRARY",
  [Built in default value for GNUstep network library])

GNUSTEP_NETWORK_LIBRARIES=`echo $GNUSTEP_NETWORK_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_LIBRARIES,
  "$GNUSTEP_NETWORK_LIBRARIES",
  [Built in default value for GNUstep network libraries])

GNUSTEP_NETWORK_HEADERS=`echo $GNUSTEP_NETWORK_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_HEADERS,
  "$GNUSTEP_NETWORK_HEADERS",
  [Built in default value for GNUstep network headers])

GNUSTEP_NETWORK_DOC=`echo $GNUSTEP_NETWORK_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC,
  "$GNUSTEP_NETWORK_DOC",
  [Built in default value for GNUstep network documentation])

GNUSTEP_NETWORK_DOC_MAN=`echo $GNUSTEP_NETWORK_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC_MAN,
  "$GNUSTEP_NETWORK_DOC_MAN",
  [Built in default value for GNUstep network manpages documentation])

GNUSTEP_NETWORK_DOC_INFO=`echo $GNUSTEP_NETWORK_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_DOC_INFO,
  "$GNUSTEP_NETWORK_DOC_INFO",
  [Built in default value for GNUstep network info documentation])

#
# LOCAL domain paths
#
GNUSTEP_LOCAL_APPS=`echo $GNUSTEP_LOCAL_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_APPS,
  "$GNUSTEP_LOCAL_APPS",
  [Built in default value for GNUstep local apps])

GNUSTEP_LOCAL_ADMIN_APPS=`echo $GNUSTEP_LOCAL_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_ADMIN_APPS,
  "$GNUSTEP_LOCAL_ADMIN_APPS",
  [Built in default value for GNUstep local apps])

GNUSTEP_LOCAL_WEB_APPS=`echo $GNUSTEP_LOCAL_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_WEB_APPS,
  "$GNUSTEP_LOCAL_WEB_APPS",
  [Built in default value for GNUstep local web apps])

GNUSTEP_LOCAL_TOOLS=`echo $GNUSTEP_LOCAL_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_TOOLS,
  "$GNUSTEP_LOCAL_TOOLS",
  [Built in default value for GNUstep local tools])

GNUSTEP_LOCAL_ADMIN_TOOLS=`echo $GNUSTEP_LOCAL_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_ADMIN_TOOLS,
  "$GNUSTEP_LOCAL_ADMIN_TOOLS",
  [Built in default value for GNUstep local tools])

GNUSTEP_LOCAL_LIBRARY=`echo $GNUSTEP_LOCAL_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_LIBRARY,
  "$GNUSTEP_LOCAL_LIBRARY",
  [Built in default value for GNUstep local library])

GNUSTEP_LOCAL_LIBRARIES=`echo $GNUSTEP_LOCAL_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_LIBRARIES,
  "$GNUSTEP_LOCAL_LIBRARIES",
  [Built in default value for GNUstep local libraries])

GNUSTEP_LOCAL_HEADERS=`echo $GNUSTEP_LOCAL_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_HEADERS,
  "$GNUSTEP_LOCAL_HEADERS",
  [Built in default value for GNUstep local headers])

GNUSTEP_LOCAL_DOC=`echo $GNUSTEP_LOCAL_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC,
  "$GNUSTEP_LOCAL_DOC",
  [Built in default value for GNUstep local documentation])

GNUSTEP_LOCAL_DOC_MAN=`echo $GNUSTEP_LOCAL_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC_MAN,
  "$GNUSTEP_LOCAL_DOC_MAN",
  [Built in default value for GNUstep local manpages documentation])

GNUSTEP_LOCAL_DOC_INFO=`echo $GNUSTEP_LOCAL_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_DOC_INFO,
  "$GNUSTEP_LOCAL_DOC_INFO",
  [Built in default value for GNUstep local info documentation])

#
# USER_DIR domain paths
#
GNUSTEP_USER_DIR_APPS=`echo $GNUSTEP_USER_DIR_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_APPS,
  "$GNUSTEP_USER_DIR_APPS",
  [Built in default value for GNUstep user_dir apps])

GNUSTEP_USER_DIR_ADMIN_APPS=`echo $GNUSTEP_USER_DIR_ADMIN_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_ADMIN_APPS,
  "$GNUSTEP_USER_DIR_ADMIN_APPS",
  [Built in default value for GNUstep user_dir admin apps])

GNUSTEP_USER_DIR_WEB_APPS=`echo $GNUSTEP_USER_DIR_WEB_APPS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_WEB_APPS,
  "$GNUSTEP_USER_DIR_WEB_APPS",
  [Built in default value for GNUstep user_dir web apps])

GNUSTEP_USER_DIR_TOOLS=`echo $GNUSTEP_USER_DIR_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_TOOLS,
  "$GNUSTEP_USER_DIR_TOOLS",
  [Built in default value for GNUstep user_dir tools])

GNUSTEP_USER_DIR_ADMIN_TOOLS=`echo $GNUSTEP_USER_DIR_ADMIN_TOOLS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_ADMIN_TOOLS,
  "$GNUSTEP_USER_DIR_ADMIN_TOOLS",
  [Built in default value for GNUstep user_dir tools])

GNUSTEP_USER_DIR_LIBRARY=`echo $GNUSTEP_USER_DIR_LIBRARY|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_LIBRARY,
  "$GNUSTEP_USER_DIR_LIBRARY",
  [Built in default value for GNUstep user_dir library])

GNUSTEP_USER_DIR_LIBRARIES=`echo $GNUSTEP_USER_DIR_LIBRARIES|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_LIBRARIES,
  "$GNUSTEP_USER_DIR_LIBRARIES",
  [Built in default value for GNUstep user_dir libraries])

GNUSTEP_USER_DIR_HEADERS=`echo $GNUSTEP_USER_DIR_HEADERS|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_HEADERS,
  "$GNUSTEP_USER_DIR_HEADERS",
  [Built in default value for GNUstep user_dir headers])

GNUSTEP_USER_DIR_DOC=`echo $GNUSTEP_USER_DIR_DOC|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC,
  "$GNUSTEP_USER_DIR_DOC",
  [Built in default value for GNUstep user_dir documentation])

GNUSTEP_USER_DIR_DOC_MAN=`echo $GNUSTEP_USER_DIR_DOC_MAN|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC_MAN,
  "$GNUSTEP_USER_DIR_DOC_MAN",
  [Built in default value for GNUstep user_dir manpages documentation])

GNUSTEP_USER_DIR_DOC_INFO=`echo $GNUSTEP_USER_DIR_DOC_INFO|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR_DOC_INFO,
  "$GNUSTEP_USER_DIR_DOC_INFO",
  [Built in default value for GNUstep user_dir info documentation])

GNUSTEP_TARGET_SYSTEM_USERS_DIR=`echo $GNUSTEP_TARGET_SYSTEM_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_SYSTEM_USERS_DIR,
  "$GNUSTEP_TARGET_SYSTEM_USERS_DIR",
  [Built in default value for GNUstep System Users directory])
GNUSTEP_TARGET_NETWORK_USERS_DIR=`echo $GNUSTEP_TARGET_NETWORK_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_NETWORK_USERS_DIR,
  "$GNUSTEP_TARGET_NETWORK_USERS_DIR",
  [Built in default value for GNUstep Network Users directory])
GNUSTEP_TARGET_LOCAL_USERS_DIR=`echo $GNUSTEP_TARGET_LOCAL_USERS_DIR|sed -e 's/\\\\/\\\\\\\\/g'`
AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_USERS_DIR,
  "$GNUSTEP_TARGET_LOCAL_USERS_DIR",
  [Built in default value for GNUstep Local Users directory])

#
# Now load the values to be used in locating libraries etc used when
# building the base library ... as supplied by the gnustep-make package
#
# It looks like we ought to source the whole GNUstep.sh here, and even
# ask it to output all variables!  That way we have access to (eg)
# GNUSTEP_SYSTEM_HEADERS below.
#
# We need to unset any values that we really need, or existing settings
# would be used by GNUstep.sh
#
unset GNUSTEP_SYSTEM_HEADERS
unset GNUSTEP_SYSTEM_LIBRARIES
unset GNUSTEP_NETWORK_HEADERS
unset GNUSTEP_NETWORK_LIBRARIES
unset GNUSTEP_LOCAL_HEADERS
unset GNUSTEP_LOCAL_LIBRARIES
GNUSTEP_MAKEFILES="$CURRENT_GNUSTEP_MAKEFILES"
GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes
. "$CURRENT_GNUSTEP_MAKEFILES/GNUstep.sh"
unset GNUSTEP_SH_EXPORT_ALL_VARIABLES

# For backwards compatibility, define GNUSTEP_SYSTEM_HEADERS from
# GNUSTEP_SYSTEM_ROOT if not set yet.
if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then
  GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_ROOT/Library/Headers"
fi

if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then
  GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries"
fi

if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then
  GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_ROOT/Library/Headers"
fi

if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then
  GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_ROOT/Library/Libraries"
fi

if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then
  GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers"
fi

if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then
  GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries"
fi

#
# Add standard library and header directories for configure to use to locate
# plain C developer headers/libraries which have been installed in the
# GNUstep hierarchy. These take precedence
#
if test x"$GNUSTEP_IS_FLATTENED" = x"yes"; then
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES"
else
  # FIXME: Cross-compiling should read the target from the configure
  # options and use it.   GNUSTEP_TARGET_* variables do not exist in
  # this context (so "$GNUSTEP_TARGET_CPU" will always be "")
  if test x"$GNUSTEP_TARGET_CPU" = x""; then
    ARCH="$GNUSTEP_HOST_CPU-$GNUSTEP_HOST_OS"
  else
    ARCH=$GNUSTEP_TARGET_CPU-$GNUSTEP_TARGET_OS
  fi
  ALIB="$ARCH/$LIBRARY_COMBO"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS/$ALIB"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS/$ARCH"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_LOCAL_HEADERS"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS/$ALIB"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS/$ARCH"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_NETWORK_HEADERS"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS/$ALIB"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS/$ARCH"
  CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES/$ALIB"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES/$ARCH"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_LOCAL_LIBRARIES"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES/$ALIB"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES/$ARCH"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_NETWORK_LIBRARIES"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES/$ALIB"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES/$ARCH"
  LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES"
fi


#--------------------------------------------------------------------
# Find the compiler
#--------------------------------------------------------------------
MAKECC=`gnustep-config --variable=CC`
MAKECPP=`gnustep-config --variable=CPP`
MAKECXX=`gnustep-config --variable=CXX`
if test "$CC" = ""; then
  CC=$MAKECC
  export CC
else
  if test "$CC" != "$MAKECC"; then
    AC_MSG_WARN([You are running configure with the compiler ($CC) set to a different value from that used by gnustep-make ($MAKECC).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CC=$CC or run the gnustep-base configure again with your CC environment variable set to $MAKECC])
  fi
fi
if test "$CPP" = ""; then
  CPP=$MAKECPP
  export CPP
else
  if test "$CPP" != "$MAKECPP"; then
    AC_MSG_WARN([You are running configure with the preprocessor ($CPP) set to a different value from that used by gnustep-make ($MAKECPP).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CPP=$CPP or run the gnustep-base configure again with your CPP environment variable set to $MAKECPP])
  fi
fi
if test "$CXX" = ""; then
  CXX=$MAKECXX
  export CXX
else
  if test "$CXX" != "$MAKECXX"; then
    AC_MSG_WARN([You are running configure with the compiler ($CXX) set to a different value from that used by gnustep-make ($MAKECXX).  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use CXX=$CXX or run the gnustep-base configure again with your CXX environment variable set to $MAKECXX])
  fi
fi
AC_PROG_CC
AC_PROG_CPP
AC_USE_SYSTEM_EXTENSIONS

AC_MSG_CHECKING(whether the compiler is clang)
# CC may have flags appended to it, so we need to extract the actual
# compiler name.
if "$(echo "${CC}" | awk '{print $1}')" -v 2>&1 | grep -q 'clang version'; then
  CLANG_CC=yes
  AC_MSG_RESULT(yes)
else
  CLANG_CC=no
  AC_MSG_RESULT(no)
fi
AC_SUBST(CLANG_CC)


# Large file support needed by NSData/NSFileHandle.
# These macros must be called after AC_USE_SYSTEM_EXTENSIONS because
# the `fseeko' declaration may be hidden by default on some systems.
AC_FUNC_FSEEKO
AH_BOTTOM([
/* Define `fseeko' to `fseek' if the former is missing.
   Likewise for `ftello'.  */
#if !HAVE_FSEEKO
# define fseeko fseek
# define ftello ftell
#endif
])
AC_SYS_LARGEFILE
AC_TYPE_OFF_T

#--------------------------------------------------------------------
# Check how to enable builtins for atomic operations
#--------------------------------------------------------------------

AC_LANG_PUSH(C)
AC_MSG_CHECKING([whether the compiler supports atomic operations]);
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
    [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y + 1);]])],
  have_atomic=yes,
  have_atomic=no);
  if test "$have_atomic" = "yes"; then
    AC_MSG_RESULT([yes]);
    AC_DEFINE(USE_ATOMIC_BUILTINS,1,
      [Define if the compiler provides builtins for atomic operations])
  else
    AC_MSG_RESULT([no]);
    if test "$CC" = "gcc"; then
      saved_CFLAGS="$CFLAGS";
      ATOMIC_CFLAGS="";

      # FIXME: Forcing -march=i568 for any i568 or later CPU is a
      # stop gap measure to make the compiler emit native assembly
      # for atomic operations on i586 or latter processors (GCC by
      # default emits code compatible with the original i386 and
      # requires library functions to emulate atomic operations).
      # When gnustep-make takes care of this kind of target setting,
      # the check can safely be removed.
      case "$target_cpu" in
        i586*|i686*|i786*)
          ATOMIC_CFLAGS="-march=i586"
          CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
          ;;
        x86_64)
          ATOMIC_CFLAGS="-march=x86-64"
          CFLAGS="$saved_CFLAGS $ATOMIC_CFLAGS"
          ;;
      esac
      AC_MSG_CHECKING([whether CC supports atomic operations with -march]);
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
          [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y+1);]])],
        need_march=yes,
      need_march=no);

      if test "$need_march" = "yes"; then
        AC_MSG_RESULT([yes]);
	OBJCFLAGS="$OBJCFLAGS $ATOMIC_CFLAGS";
        AC_DEFINE(USE_ATOMIC_BUILTINS,1,
          [Define if the compiler provides builtins for atomic operations])
      else
        AC_MSG_RESULT([no]);
        saved_LDFLAGS="$LDFLAGS";
        LDFLAGS="$saved_LDFLAGS -lgcc";
        AC_MSG_CHECKING([whether CC supports atomic operations using libgcc]);
          AC_LINK_IFELSE([AC_LANG_PROGRAM([[typedef int atomic;]],
            [[atomic x; atomic y; __sync_bool_compare_and_swap(&x, y, y+1);]])],
          atomic_in_libgcc=yes,
        atomic_in_libgcc=no);
        if test "$atomic_in_libgcc" = "yes"; then
          AC_MSG_RESULT([yes]);
          LIBS="$LIBS -lgcc";
          AC_DEFINE(USE_ATOMIC_BUILTINS,1,
            [Define if the compiler provides builtins for atomic operations])
        else
          LDFLAGS="$saved_LDFLAGS";
          AC_MSG_RESULT([no]);
        fi
      fi
    fi
  fi
AC_LANG_POP(C)


AC_PATH_PROG(WHOAMI, whoami, echo, $PATH:/usr/ucb)
PKG_PROG_PKG_CONFIG
# If the modern mechanism fails we may have an older pkg-config
# so try looking it up the old fashioned way.
if test -z "$PKG_CONFIG"; then
  AC_PATH_PROG(PKG_CONFIG,pkg-config,,)
fi


#--------------------------------------------------------------------
# specific target_os options
#--------------------------------------------------------------------
INCLUDE_FLAGS="$CPPFLAGS"
LDIR_FLAGS="$LDFLAGS"
# This is just for configuring. Later, in config.make, INCLUDE_FLAGS
# goes in CONFIG_SYSTEM_INCL and LIBS goes in CONFIG_SYSTEM_LIBS
case "$target_os" in
  freebsd* | openbsd* )
	        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
		LDFLAGS="$LDFLAGS -L/usr/local/lib";;
  netbsd*)	CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
		LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
  linux-android* )
		# link against libandroid for native application APIs
		LIBS="$LIBS -landroid";;
esac

#--------------------------------------------------------------------
# Set Apple/Darwin/OSX/NeXT information for other tests
#--------------------------------------------------------------------
AC_MSG_CHECKING(the Objective-C runtime)
if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then
  AC_MSG_RESULT(NeXT)
  OBJCFLAGS="$OBJCFLAGS -fnext-runtime -DNeXT_RUNTIME"
elif test "$OBJC_RUNTIME_LIB" = "ng"; then
  AC_MSG_RESULT(Next Gen)
else
  AC_MSG_RESULT(GNU)
  if test "$CLANG_CC" = "yes"; then
    OBJCFLAGS="$OBJCFLAGS -fobjc-runtime=gcc"
  fi
fi
LIBOBJC=`gnustep-config --objc-libs`
if test "$LIBOBJC" = ""; then
  AC_MSG_ERROR([The command 'gnustep-config --objc-libs' (provided by the gnustep-make package) returned no Objective-C library.  Unable to continue configuring without Objective-C support.])
  exit 1
fi

#--------------------------------------------------------------------
# Miscellaneous flags
#--------------------------------------------------------------------

# Check to see if the libobjc library is in our GNUSTEP_SYSTEM_LIBRARIES.
# If so, there are probably other libraries that we want there also, so
# leave the proper includes in CPPFLAGS and LDFLAGS
AC_MSG_CHECKING(for custom shared objc library)
AC_CACHE_VAL(gs_cv_objc_libdir,
[dnl
gs_cv_objc_libdir=NONE
gs_cv_objc_incdir=NONE
# Try GNUSTEP_SYSTEM_LIBRARIES first
if test "$GNUSTEP_IS_FLATTENED" = yes; then
  GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES"
  GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS"
else
  GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir"
  GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO"
fi

if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/objc.lib"; then
    gs_cv_objc_libdir="$GNUSTEP_LDIR"
    gs_cv_objc_incdir="$GNUSTEP_HDIR"
  fi
fi

# Try GNUSTEP_NETWORK_LIBRARIES second (override GNUSTEP_SYSTEM if
# found)
if test "$GNUSTEP_IS_FLATTENED" = yes; then
  GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES"
  GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS"
else
  GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES/$obj_dir"
  GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO"
fi

if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/objc.lib"; then
    gs_cv_objc_libdir="$GNUSTEP_LDIR"
    gs_cv_objc_incdir="$GNUSTEP_HDIR"
  fi
fi

# Try GNUSTEP_LOCAL_LIBRARIES third (override GNUSTEP_SYSTEM and
# GNUSTEP_NETWORK if found)
if test "$GNUSTEP_IS_FLATTENED" = yes; then
  GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES"
  GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS"
else
  GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES/$obj_dir"
  GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO"
fi

if test -f "$GNUSTEP_HDIR/objc/objc.h"; then
  if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/objc.lib"; then
    gs_cv_objc_libdir="$GNUSTEP_LDIR"
    gs_cv_objc_incdir="$GNUSTEP_HDIR"
  fi
fi
])
AC_MSG_RESULT($gs_cv_objc_libdir)

if test "$gs_cv_objc_libdir" != "NONE"; then
  #
  # The following one is so that headers of custom libraries into
  # $GNUSTEP_HDIR are used before the standard ones
  #
  INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gs_cv_objc_incdir"
  LDIR_FLAGS="$LDIR_FLAGS -L$gs_cv_objc_libdir/$LIBRARY_COMBO -L$gs_cv_objc_libdir"
  CPPFLAGS="$CPPFLAGS -I$gs_cv_objc_incdir"
  LDFLAGS="$LDFLAGS -L$gs_cv_objc_libdir"

  # add to path on Windows for config checks to find DLL at runtime
  case $host_os in
    mingw*|windows) PATH=$PATH:$gs_cv_objc_libdir;;
  esac
fi

#--------------------------------------------------------------------
# Check if Objective-C is installed
#--------------------------------------------------------------------
AC_CHECK_HEADERS(objc/runtime.h)
AC_CHECK_HEADERS(objc/objc.h)
if test $ac_cv_header_objc_objc_h = no; then
  echo "Check to make sure you have the Objective-C runtime library"
  echo "and its headers installed."
  AC_MSG_ERROR(Could not find Objective-C headers)
fi

#--------------------------------------------------------------------
# Check for strange network stuff used by gdomap
#--------------------------------------------------------------------
AC_MSG_NOTICE(for gdomap network details)
AC_MSG_CHECKING(for variable length socket addresses)
AC_LANG(C)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <net/if.h>]],
  [[struct ifreq s; s.ifr_addr.sa_len = 0;]])],
  sa_len=1, sa_len=0)
if test $sa_len = 1; then
  AC_MSG_RESULT([found])
  AC_DEFINE(HAVE_SA_LEN,1,
            [Define if your system has variable length network addresses])
else
  AC_MSG_RESULT([not found])
fi

AC_MSG_CHECKING(for compiler visibility attribute support)
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  #include <stdio.h>
  int foo() __attribute__ ((visibility("internal")));
  int foo(){ return 1; }
  int main(){ return foo(); }])],
  AC_MSG_RESULT([found])
  gs_visibility=1,
  AC_MSG_RESULT([not present])
  gs_visibility=0
)
AC_DEFINE_UNQUOTED(HAVE_VISIBILITY_ATTRIBUTE,$gs_visibility,
  [Says whether the visibility attribute works])
CFLAGS="$saved_CFLAGS"


#--------------------------------------------------------------------
# Check if system has buggy SO_REUSEADDR
#--------------------------------------------------------------------
AC_MSG_CHECKING(whether SO_REUSEADDR is broken)
AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.reuseaddr.c"]])],
	[reuseaddr_ok=1],
	[reuseaddr_ok=0],
	[reuseaddr_ok="$cross_reuseaddr_ok"])
if test $reuseaddr_ok = 0; then
  AC_DEFINE(BROKEN_SO_REUSEADDR,1,
            [Define if SO_REUSEADDR is broken on this system])
  echo
  echo "The SO_REUSEADDR socket option for controlling re-use of network"
  echo "sockets immediately after shutdown appears to be broken on this"
  echo "machine.  Networking code will be built without using this"
  echo "feature."
  echo "The effect of this lack is that when a network service is shut"
  echo "down, it cannot be re-started on the same network port until"
  echo "an operating-system timeout has expired."
  echo "For servers other than gdomap, GNUstep does not normally need"
  echo "a particular network port, so the problem is unlikely to arise."
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

#--------------------------------------------------------------------
# Check for thread flags for libobjc.
#--------------------------------------------------------------------
#
AC_MSG_CHECKING(for objc threading flags)
#
# Get them from gnustep-make which contains the real code to get them
#
objc_threaded=`grep objc_threaded: $CURRENT_GNUSTEP_MAKEFILES/$lobj_dir/config.make | sed -e 's/objc_threaded:=//'`
#
AC_MSG_RESULT($objc_threaded)

#--------------------------------------------------------------------
# Byte order information needed for foundation headers.
#--------------------------------------------------------------------
AC_C_BIGENDIAN
if test $ac_cv_c_bigendian = yes; then
  GS_WORDS_BIGENDIAN=1
else
  GS_WORDS_BIGENDIAN=0
fi
AC_SUBST(GS_WORDS_BIGENDIAN)

#--------------------------------------------------------------------
# Type size information needed for foundation headers.
#--------------------------------------------------------------------
AC_CHECK_SIZEOF(void*)

GS_SINT8="signed char"
GS_UINT8="unsigned char"
AC_SUBST(GS_SINT8)
AC_SUBST(GS_UINT8)

AC_CHECK_SIZEOF(short)
AC_SUBST(ac_cv_sizeof_short)

AC_CHECK_SIZEOF(int)
AC_SUBST(ac_cv_sizeof_int)

AC_CHECK_SIZEOF(long)
AC_SUBST(ac_cv_sizeof_long)

AC_CHECK_SIZEOF(long long)
AC_SUBST(ac_cv_sizeof_long_long)

AC_CHECK_SIZEOF(float)
AC_SUBST(ac_cv_sizeof_float)

AC_CHECK_SIZEOF(double)
AC_SUBST(ac_cv_sizeof_double)

AC_SUBST(ac_cv_sizeof_voidp)
if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_int; then
  GS_SADDR="int"
  GS_UADDR="unsigned int"
else
  if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_long; then
    GS_SADDR="long"
    GS_UADDR="unsigned long"
  else
    if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_long_long; then
      GS_SADDR="long long"
      GS_UADDR="unsigned long long"
    else
      AC_MSG_ERROR([Unable to find integer of same size as void*])
    fi
  fi
fi
AC_SUBST(GS_SADDR)
AC_SUBST(GS_UADDR)

if test $ac_cv_sizeof_short = 2; then
  GS_SINT16="signed short"
  GS_UINT16="unsigned short"
else
  if test $ac_cv_sizeof_int = 2; then
    GS_SINT16="signed int"
    GS_UINT16="unsigned int"
  else
    AC_MSG_ERROR([Unable to determine type for 16-bit integer])
  fi
fi
AC_SUBST(GS_SINT16)
AC_SUBST(GS_UINT16)

if test $ac_cv_sizeof_int = 4; then
  GS_SINT32="signed int"
  GS_UINT32="unsigned int"
else
  if test $ac_cv_sizeof_long = 4; then
    GS_SINT32="signed long"
    GS_UINT32="unsigned long"
  else
    if test $ac_cv_sizeof_short = 4; then
      GS_SINT32="signed short"
      GS_UINT32="unsigned short"
    else
      AC_MSG_ERROR([Unable to determine type for 32-bit integer])
    fi
  fi
fi
AC_SUBST(GS_SINT32)
AC_SUBST(GS_UINT32)

GS_HAVE_I64=1
if test $ac_cv_sizeof_int = 8; then
  GS_SINT64="signed int"
  GS_UINT64="unsigned int"
else
  if test $ac_cv_sizeof_long = 8; then
    GS_SINT64="signed long"
    GS_UINT64="unsigned long"
  else
    if test $ac_cv_sizeof_long_long = 8; then
      GS_SINT64="signed long long"
      GS_UINT64="unsigned long long"
    else
#     64-bit ints not supported - but we need a dummy type for byte-swapping
#     of 64-bit values arriving from another system.
      GS_SINT64="struct { gsu8 a[8]; }"
      GS_UINT64="struct { gsu8 a[8]; }"
      GS_HAVE_I64=0
    fi
  fi
fi
AC_SUBST(GS_SINT64)
AC_SUBST(GS_UINT64)
AC_SUBST(GS_HAVE_I64)

GS_HAVE_I128=1
if test $ac_cv_sizeof_long = 16; then
  GS_SINT128="signed long"
  GS_UINT128="unsigned long"
else
  if test $ac_cv_sizeof_long_long = 16; then
    GS_SINT128="signed long long"
    GS_UINT128="unsigned long long"
  else
#     128-bit ints not supported - but we need a dummy type for byte-swapping
#     of 128-bit values arriving from another system.
    GS_SINT128="struct { gsu8 a[[16]]; }"
    GS_UINT128="struct { gsu8 a[[16]]; }"
    GS_HAVE_I128=0
  fi
fi
AC_SUBST(GS_SINT128)
AC_SUBST(GS_UINT128)
AC_SUBST(GS_HAVE_I128)

if test $ac_cv_sizeof_float = 4; then
  GS_FLT32="float"
else
  AC_MSG_ERROR([Unable to determine type for 32-bit float])
fi
AC_SUBST(GS_FLT32)

if test $ac_cv_sizeof_double = 8; then
  GS_FLT64="double"
else
  AC_MSG_ERROR([Unable to determine type for 64-bit float])
fi
AC_SUBST(GS_FLT64)

#--------------------------------------------------------------------
# Type-size information for encoding into archives using NSArchiver etc.
#--------------------------------------------------------------------
if test $ac_cv_sizeof_short = 2; then
  _GSC_S_SHT=_GSC_I16
else
  _GSC_S_SHT=_GSC_I32
fi
AC_SUBST(_GSC_S_SHT)

if test $ac_cv_sizeof_int = 2; then
  _GSC_S_INT=_GSC_I16
else
  if test $ac_cv_sizeof_int = 4; then
    _GSC_S_INT=_GSC_I32
  else
    if test $ac_cv_sizeof_int = 8; then
      _GSC_S_INT=_GSC_I64
    else
      if test $ac_cv_sizeof_int = 16; then
	_GSC_S_INT=_GSC_I128
      fi
    fi
  fi
fi
AC_SUBST(_GSC_S_INT)

if test $ac_cv_sizeof_long = 4; then
  _GSC_S_LNG=_GSC_I32
else
  if test $ac_cv_sizeof_long = 8; then
    _GSC_S_LNG=_GSC_I64
  else
    if test $ac_cv_sizeof_long = 16; then
      _GSC_S_LNG=_GSC_I128
    fi
  fi
fi
AC_SUBST(_GSC_S_LNG)

if test $ac_cv_sizeof_long_long = 4; then
  _GSC_S_LNG_LNG=_GSC_I32
else
  if test $ac_cv_sizeof_long_long = 8; then
    _GSC_S_LNG_LNG=_GSC_I64
  else
    if test $ac_cv_sizeof_long_long = 16; then
      _GSC_S_LNG_LNG=_GSC_I128
    fi
  fi
fi
AC_SUBST(_GSC_S_LNG_LNG)


#--------------------------------------------------------------------
# Limit information needed for foundation headers.
#--------------------------------------------------------------------
AC_LANG_PUSH(C)
AC_MSG_CHECKING([for working INTPTR_MAX, INTPTR_MIN, UINTPTR_MAX]);
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM([[#include <inttypes.h>]],
    [[int imax = INTPTR_MAX; int imin = INTPTR_MIN; unsigned umax = UINTPTR_MAX;]])],
  have_valid_ptr_limits=yes,
  have_valid_ptr_limits=no);
  if test "$have_valid_ptr_limits" = "yes"; then
    AC_MSG_RESULT([yes]);
    BUGGY_PTR_LIMITS=0
  else
    AC_MSG_RESULT([no]);
    BUGGY_PTR_LIMITS=1
    case "$target_os" in
      solaris*)
        case "$target_cpu" in
          sparc64*|x86_64*)
            GS_INTPTR_MAX="INT64_MAX"
            GS_INTPTR_MIN="INT64_MIN"
            GS_UINTPTR_MAX="UINT64_MAX"
            ;;
          sparc*|i386*|i586*|i686*)
            GS_INTPTR_MAX="INT32_MAX"
            GS_INTPTR_MIN="INT32_MIN"
            GS_UINTPTR_MAX="UINT32_MAX"
            ;;
          *) ;;
        esac ;;
      # support for other OS's with broken macros to be added here (HP-UX, IRIX being known)
      *)
      ;;
    esac
    AC_SUBST(GS_INTPTR_MAX)
    AC_SUBST(GS_INTPTR_MIN)
    AC_SUBST(GS_UINTPTR_MAX)
  fi
AC_SUBST(BUGGY_PTR_LIMITS)
AC_LANG_POP(C)

#--------------------------------------------------------------------
# Check alignment of an object in memory
#--------------------------------------------------------------------
AC_CHECK_ALIGNOF(objc_object,[AC_INCLUDES_DEFAULT
  typedef struct { void *isa; } objc_object;])
if test $ac_cv_alignof_objc_object = 0 ; then
  AC_MSG_ERROR([Unable to find align of object (required).])
fi

#--------------------------------------------------------------------
# Setup dynamic linking
#--------------------------------------------------------------------
OBJC_SYS_DYNAMIC_LINKER()
# NOTE: libdl should be in LIBS now if it's available.
AC_CHECK_FUNCS(dladdr)

AC_CHECK_FUNCS(gethostbyname)
if test "$ac_cv_func_gethostbyname" = "no"; then
  # QNX has gethostbyname and friends in libsocket
  AC_CHECK_LIB(socket, gethostbyname)
fi

AC_CHECK_FUNCS(getaddrinfo)

#--------------------------------------------------------------------
# Windows: check if we have native threading APIs and SRW locks
#--------------------------------------------------------------------
HAVE_WIN32_THREADS_AND_LOCKS=0
if test "$CLANG_CC" = "yes"; then
  case "$target_os" in
    mingw*|windows)
      AC_MSG_CHECKING(for native Windows threads and locks)
      AC_COMPILE_IFELSE(
        [AC_LANG_SOURCE([
          #define GS_USE_WIN32_THREADS_AND_LOCKS 1
          #include "$srcdir/Source/GSPThread.h"
        ])],
        AC_MSG_RESULT([yes])
        HAVE_WIN32_THREADS_AND_LOCKS=1,
        AC_MSG_RESULT([no]))
      ;;
  esac
fi
AC_SUBST(HAVE_WIN32_THREADS_AND_LOCKS)

#--------------------------------------------------------------------
# Check for pthread.h
#--------------------------------------------------------------------
if test $HAVE_WIN32_THREADS_AND_LOCKS = 0; then
  AC_CHECK_HEADERS([pthread.h])
  AC_CHECK_HEADERS([pthread_np.h],[],[],[AC_INCLUDES_DEFAULT
    #ifdef HAVE_PTHREAD_H
    #include <pthread.h>
    #endif
  ])
  if test $ac_cv_header_pthread_h = yes ; then
    AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT
      #include <pthread.h>])
    GS_SIZEOF_MUTEX_T=$ac_cv_sizeof_pthread_mutex_t
    if test $ac_cv_sizeof_pthread_mutex_t = 0 ; then
      AC_MSG_ERROR([Unable to find size of pthread_mutex_t (required).])
    fi
    AC_SUBST(GS_SIZEOF_MUTEX_T)
    GS_SIZEOF_COND_MUTEX_T=$ac_cv_sizeof_pthread_mutex_t
    AC_SUBST(GS_SIZEOF_COND_MUTEX_T)

    # pthread_mutex_t.__data.__owner is non-standard since pthread_mutex_t is
    # nominally an opaque type.  We must not rely on this for anything other
    # than debug output!
    AC_CHECK_MEMBER([pthread_mutex_t.__data.__owner],,,[AC_INCLUDES_DEFAULT
      #include <pthread.h>])
    if test $ac_cv_member_pthread_mutex_t___data___owner = yes ; then
      AC_DEFINE(HAVE_PTHREAD_MUTEX_OWNER, 1,
        [Define if you have pthread_mutex_t.__data.__owner])
    fi

    AC_CHECK_SIZEOF(pthread_cond_t,,[AC_INCLUDES_DEFAULT
      #include <pthread.h>])
    if test $ac_cv_sizeof_pthread_cond_t = 0 ; then
      AC_MSG_ERROR([Unable to find size of pthread_cond_t (required).])
    fi
    GS_SIZEOF_COND_T=$ac_cv_sizeof_pthread_cond_t
    AC_SUBST(GS_SIZEOF_COND_T)

    AC_CHECK_ALIGNOF(pthread_mutex_t,[AC_INCLUDES_DEFAULT
      #include <pthread.h>])
    GS_ALIGNOF_MUTEX_T=$ac_cv_alignof_pthread_mutex_t
    if test $ac_cv_alignof_pthread_mutex_t = 0 ; then
      AC_MSG_ERROR([Unable to find align of pthread_mutex_t (required).])
    fi
    AC_SUBST(GS_ALIGNOF_MUTEX_T)
    GS_ALIGNOF_COND_MUTEX_T=$ac_cv_alignof_pthread_mutex_t
    AC_SUBST(GS_ALIGNOF_COND_MUTEX_T)

    AC_CHECK_ALIGNOF(pthread_cond_t,[AC_INCLUDES_DEFAULT
      #include <pthread.h>])
    if test $ac_cv_alignof_pthread_cond_t = 0 ; then
      AC_MSG_ERROR([Unable to find align of pthread_cond_t (required).])
    fi
    GS_ALIGNOF_COND_T=$ac_cv_alignof_pthread_cond_t
    AC_SUBST(GS_ALIGNOF_COND_T)
  else
    AC_MSG_ERROR([Unable to find pthread.h (needed for thread support).])
  fi
  AC_CHECK_LIB(pthread, pthread_join, pthread_ok=yes, pthread_ok=no)

  if test $pthread_ok = yes ; then
    LIBS="$LIBS -lpthread"
  else
    case "$target_os" in
      mingw*)
        AC_CHECK_LIB(pthreadGC2, pthread_join, pthread_ok=yes, pthread_ok=no)
        if test $pthread_ok = yes ; then
          LIBS="$LIBS -lpthreadGC2"
        fi
        ;;
      windows)
        AC_CHECK_LIB(pthreadVC2, pthread_join, pthread_ok=yes, pthread_ok=no)
        if test $pthread_ok = yes ; then
          LIBS="$LIBS -lpthreadVC2"
        fi
        ;;
      nto*|qnx*|*android*)
        # Android and QNX have pthread in libc instead of libpthread
        AC_CHECK_LIB(c, pthread_join, pthread_ok=yes, pthread_ok=no)
        if test $pthread_ok = yes ; then
           LIBS="$LIBS -lc"
        fi
        ;;
    esac
  fi
  if test $pthread_ok = no ; then
    AC_MSG_ERROR([Unable to find pthread library (needed for thread support).])
  fi

  # Check threading extensions
  AC_CHECK_FUNCS(pthread_getthreadid_np pthread_main_np)

  # Typically need librt on Solaris for sched_yield
  AC_CHECK_LIB(rt, sched_yield)
  
  # Check if we can name pthreads
  AC_CACHE_CHECK([for pthread_setname_np()], gs_cv_pthread_setname_np,
  [AC_LINK_IFELSE(
    [AC_LANG_PROGRAM([#include <pthread.h>],
      [pthread_setname_np("name");])],
    [gs_cv_pthread_setname_np=darwin],
    [AC_LINK_IFELSE(
      [AC_LANG_PROGRAM([#include <pthread.h>],
        [pthread_setname_np(pthread_self(), "name");])],
      [gs_cv_pthread_setname_np=glibc],
      [AC_LINK_IFELSE(
        [AC_LANG_PROGRAM([#include <pthread.h>],
          [pthread_setname_np(pthread_self(), "%s", "name");])],
        [gs_cv_pthread_setname_np=netbsd],
        [gs_cv_pthread_setname_np=none])])])])
  case $gs_cv_pthread_setname_np in
    darwin)
      AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(a),
        [Description: Define set name function for pthread with one arg])
      ;;
    glibc)
      AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),a),
        [Description: Define setname function for pthread with two args])
      ;;
    netbsd)
      AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),"%s",a),
        [Description: Define setname function for pthread with three args])
      ;;
  esac

# Check if we can get names of pthreads
AC_CACHE_CHECK([for pthread_getname_np()], gs_cv_pthread_getname_np,
[AC_LINK_IFELSE(
  [AC_LANG_PROGRAM([#include <pthread.h>],
    [char name[16]; pthread_getname_np(pthread_self(), name, 16);])],
  [gs_cv_pthread_getname_np=generic])])
case $gs_cv_pthread_getname_np in
  generic)
    AC_DEFINE(PTHREAD_GETNAME(b,c), pthread_getname_np(pthread_self(),b,c),
      [Description: Define getname function for pthread with two args (generic style)])
    ;;
esac

  # Check if we have spinlock support
  AC_CHECK_FUNCS(pthread_spin_lock)
fi

#--------------------------------------------------------------------
# Check Win32 lock sizes
#--------------------------------------------------------------------
if test $HAVE_WIN32_THREADS_AND_LOCKS = 1; then
  AC_CHECK_SIZEOF(gs_mutex_t,,[AC_INCLUDES_DEFAULT
    #define GS_USE_WIN32_THREADS_AND_LOCKS 1
    #include "$srcdir/Source/GSPThread.h"])
  GS_SIZEOF_MUTEX_T=$ac_cv_sizeof_gs_mutex_t
  if test $ac_cv_sizeof_gs_mutex_t = 0 ; then
    AC_MSG_ERROR([Unable to find size of gs_mutex_t (required).])
  fi
  AC_SUBST(GS_SIZEOF_MUTEX_T)
  
  AC_CHECK_ALIGNOF(gs_mutex_t,[AC_INCLUDES_DEFAULT
    #define GS_USE_WIN32_THREADS_AND_LOCKS 1
    #include "$srcdir/Source/GSPThread.h"])
  GS_ALIGNOF_MUTEX_T=$ac_cv_alignof_gs_mutex_t
  if test $ac_cv_alignof_gs_mutex_t = 0 ; then
    AC_MSG_ERROR([Unable to find align of gs_mutex_t (required).])
  fi
  AC_SUBST(GS_ALIGNOF_MUTEX_T)
  
  AC_CHECK_SIZEOF(CONDITION_VARIABLE,,[AC_INCLUDES_DEFAULT
    #include <windows.h>])
  GS_SIZEOF_COND_T=$ac_cv_sizeof_CONDITION_VARIABLE
  if test $ac_cv_sizeof_CONDITION_VARIABLE = 0 ; then
    AC_MSG_ERROR([Unable to find size of CONDITION_VARIABLE (required).])
  fi
  AC_SUBST(GS_SIZEOF_COND_T)
  
  AC_CHECK_ALIGNOF(CONDITION_VARIABLE,[AC_INCLUDES_DEFAULT
    #include <windows.h>])
  GS_ALIGNOF_COND_T=$ac_cv_alignof_CONDITION_VARIABLE
  if test $ac_cv_alignof_CONDITION_VARIABLE = 0 ; then
    AC_MSG_ERROR([Unable to find align of CONDITION_VARIABLE (required).])
  fi
  AC_SUBST(GS_ALIGNOF_COND_T)
  
  AC_CHECK_SIZEOF(SRWLOCK,,[AC_INCLUDES_DEFAULT
    #include <windows.h>])
  GS_SIZEOF_COND_MUTEX_T=$ac_cv_sizeof_SRWLOCK
  if test $ac_cv_sizeof_SRWLOCK = 0 ; then
    AC_MSG_ERROR([Unable to find size of SRWLOCK (required).])
  fi
  AC_SUBST(GS_SIZEOF_COND_MUTEX_T)
  
  AC_CHECK_ALIGNOF(SRWLOCK,[AC_INCLUDES_DEFAULT
    #include <windows.h>])
  GS_ALIGNOF_COND_MUTEX_T=$ac_cv_alignof_SRWLOCK
  if test $ac_cv_alignof_SRWLOCK = 0 ; then
    AC_MSG_ERROR([Unable to find align of SRWLOCK (required).])
  fi
  AC_SUBST(GS_ALIGNOF_COND_MUTEX_T)
fi

#--------------------------------------------------------------------
# One of these function needed by NSThread.m and objc initialize test
#--------------------------------------------------------------------
AC_CHECK_FUNCS(nanosleep usleep Sleep)

AC_MSG_CHECKING(for objc_root_class attribute support)
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror $OBJCFLAGS -x objective-c"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  __attribute__((objc_root_class)) @interface RootObject
  @end
  @implementation RootObject
  @end])],
  AC_MSG_RESULT([found])
  gs_objc_root_class_attr=1,
  AC_MSG_RESULT([not present])
  gs_objc_root_class_attr=0
)

GS_HAVE_OBJC_ROOT_CLASS_ATTR=$gs_objc_root_class_attr
AC_SUBST(GS_HAVE_OBJC_ROOT_CLASS_ATTR)
AC_DEFINE_UNQUOTED(HAVE_OBJC_ROOT_CLASS_ATTRIBUTE,$gs_objc_root_class_attr,
  [Says whether the objc_root_class attribute works])
CFLAGS=$saved_CFLAGS

#--------------------------------------------------------------------
# Check whether we can get the system thread ID
#--------------------------------------------------------------------
AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
[AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
int main(int argc, char **argv) {
pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; }]])],
	[ac_cv_gettid=yes],
	[ac_cv_gettid=no],
	[ac_cv_gettid=no])])
if test "$ac_cv_gettid" = "yes"; then
  AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
fi

#--------------------------------------------------------------------
# Check whether Objective-C /really/ works
#--------------------------------------------------------------------
AC_MSG_CHECKING(whether objc really works)
saved_LIBS="$LIBS"
saved_CPPFLAGS="$CPPFLAGS"
LIBS="$LIBS $LIBOBJC"
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
if test x"$objc_threaded" != x""; then
  LIBS="$LIBS $objc_threaded"
fi
LIBS="$LIBS $extra_LIBS"
AC_CACHE_VAL(gs_cv_objc_works,
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.objc.m"]])],
  	[gs_cv_objc_works=yes],
  	[gs_cv_objc_works=no],
  	[gs_cv_objc_works="$cross_gs_cv_objc_works"])
)
if test $gs_cv_objc_works = yes; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  echo "I don't seem to be able to use your Objective-C compiler to produce"
  echo "working binaries!  Please check your Objective-C compiler installation."
  echo "If you are using gcc-3.x make sure that your compiler's libgcc_s and libobjc"
  echo "can be found by the dynamic linker - usually that requires you to play"
  echo "with LD_LIBRARY_PATH or /etc/ld.so.conf."
  echo "Please refer to your compiler installation instructions for more help."
  AC_MSG_ERROR(The Objective-C compiler does not work or is not installed properly.)
fi

# Don't revert any Objective-C flags as they are used in the next test

#---------------------------------------------------------------------
# See if we are using a compiler which allows us to change the class
# to be used for constant strings by using the -fconstant-string-class
# option.  If that is the case, we change it to NSConstantString.
# Unless we are building for the apple runtime (ie only building base
# additions library and not implementing a constant string class).
#---------------------------------------------------------------------
if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then
  NX_CONST_STRING_OBJCFLAGS=""
  NX_CONST_STRING_CLASS=NXConstantString
else
  strclass_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString"
  AC_MSG_CHECKING(if the compiler supports -fconstant-string-class)
  AC_CACHE_VAL(gs_cv_objc_compiler_supports_constant_string_class,
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE(
	  [[#include "$srcdir/config/config.constant-string-class.m"]])],
    	[gs_cv_objc_compiler_supports_constant_string_class=yes],
    	[gs_cv_objc_compiler_supports_constant_string_class=no],
    	[gs_cv_objc_compiler_supports_constant_string_class="$cross_gs_cv_objc_compiler_supports_constant_string_class"])
  )
  if test $gs_cv_objc_compiler_supports_constant_string_class = yes; then
    NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString"
    NX_CONST_STRING_CLASS=NSConstantString
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
    AC_ARG_ENABLE(nxconstantstring,
        [  --enable-nxconstantstring
	    Enables the use of the NXConstantString class for old compilers.],,
        enable_nxconstantstring=no)
    if test $enable_nxconstantstring = yes; then
      NX_CONST_STRING_OBJCFLAGS=""
      NX_CONST_STRING_CLASS=NXConstantString
      AC_MSG_WARN([You have enabled the use of NXConstantString as the string class in gnustep-base.  The objective-c runtime library typically implements its own class of the same name, so you must either enforce a link order which ensures that the gnustep-base implementation is used, or (better) you must remove the class from the runtime library!])
    else
      AC_MSG_ERROR([Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings.  Please check for a more recent version or consider using --enable-nxconstantstring])
    fi
  fi
  CPPFLAGS="$strclass_CPPFLAGS"
fi

AC_SUBST(NX_CONST_STRING_OBJCFLAGS)
AC_SUBST(NX_CONST_STRING_CLASS)

# Don't revert any Objective-C flags as they are used in the next test

#---------------------------------------------------------------------
# Guess if we are using a compiler which has the (GNU extension) +load
# method which is executed before main.
# Defines HAVE_LOAD_METHOD if +load methods are called before main.
# Needed by NSProcessInfo.m
#---------------------------------------------------------------------
AC_MSG_CHECKING(if +load method is executed before main)
AC_CACHE_VAL(gs_cv_objc_load_method_worked,
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.loadtest.m"]])],
	[gs_cv_objc_load_method_worked=yes],
	[gs_cv_objc_load_method_worked=no],
	[gs_cv_objc_load_method_worked="$cross_gs_cv_objc_load_method_worked"])
)
if test $gs_cv_objc_load_method_worked = yes; then
  AC_DEFINE(HAVE_LOAD_METHOD,1,
            [Define if your Obj-C compiler calls +load methods before main])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

# Don't revert any Objective-C flags as they are used in the next test

#--------------------------------------------------------------------
# Check for thread synchronisation support in runtime
#--------------------------------------------------------------------
if test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
  # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
  # against symbol in discarded section") as the file won't contain any actual
  # ObjC code, so we just assume the function is there.
  AC_MSG_NOTICE([assuming objc_sync_enter() on Windows MSVC])
  OBJCSYNC=1
else
  AC_CHECK_FUNCS(objc_sync_enter)
  if test $ac_cv_func_objc_sync_enter = yes ; then
    OBJCSYNC=1
  else
    OBJCSYNC=0
    if test "$OBJC_RUNTIME_LIB" = "ng"; then
      AC_MSG_ERROR([The objc runtime library does not appear to have synchronisation support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
    fi
  fi
fi
AC_SUBST(OBJCSYNC)

# Don't revert any Objective-C flags as they are used in the next test

#--------------------------------------------------------------------
# Check for ObjC2 support in runtime
#--------------------------------------------------------------------
if test "$cross_compiling" = "yes"; then
  AC_MSG_NOTICE(["Cross compiling! Using predefined OBJC2RUNTIME variable"])
  OBJC2RUNTIME="$cross_objc2_runtime"
elif test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
  # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
  # against symbol in discarded section") as the file won't contain any actual
  # ObjC code, so we just assume the function is there.
  AC_MSG_NOTICE([assuming objc_setProperty() on Windows MSVC])
  OBJC2RUNTIME=1
else
  AC_CHECK_FUNCS(objc_setProperty)
  if test $ac_cv_func_objc_setProperty = yes ; then
    OBJC2RUNTIME=1
  else
    OBJC2RUNTIME=0
    if test "$OBJC_RUNTIME_LIB" = "ng"; then
      AC_MSG_ERROR([The objc runtime library does not appear to have property support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
    fi
  fi
fi
AC_SUBST(OBJC2RUNTIME)

#--------------------------------------------------------------------
# Check for blocks support in runtime
#--------------------------------------------------------------------
if test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
  # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
  # against symbol in discarded section") as the file won't contain any actual
  # ObjC code, so we just assume the function is there.
  AC_MSG_NOTICE([assuming _Block_copy() on Windows MSVC])
  HAVE_BLOCKS=1
else
  AC_CHECK_FUNCS(_Block_copy)
  if test $ac_cv_func__Block_copy = yes ; then
    HAVE_BLOCKS=1
  else
    HAVE_BLOCKS=0
    if test "$OBJC_RUNTIME_LIB" = "ng"; then
      AC_MSG_ERROR([The objc runtime library does not appear to have blocks support.  Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option.])
    fi
  fi
fi
AC_SUBST(HAVE_BLOCKS)

# Don't revert any Objective-C flags as they are used in the next test

GS_NONFRAGILE=0
if test "$nonfragile" = "yes"; then
  if test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
    # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
    # against symbol in discarded section") as the file won't contain any actual
    # ObjC code, so we just assume the function is there.
    AC_MSG_NOTICE([assuming non-fragile-abi support on Windows MSVC])
    GS_NONFRAGILE=1
  else
    saved_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
    AC_MSG_CHECKING(for non-fragile-abi support)
    AC_RUN_IFELSE([AC_LANG_SOURCE(
      [[#include "$srcdir/config/config.non-fragile-ivars.m"]])],
      non_fragile=yes, non_fragile=no,
      non_fragile="$cross_non_fragile")
    CPPFLAGS="$saved_CPPFLAGS"
    if test $non_fragile = yes; then
      GS_NONFRAGILE=1
    fi
    AC_MSG_RESULT($non_fragile)
  fi
fi
AC_SUBST(GS_NONFRAGILE)


# Don't revert any Objective-C flags as they are used in the next test

#--------------------------------------------------------------------
# get_uninstalled_dtable used by behavior.m and objc-load.m
#--------------------------------------------------------------------
AC_EGREP_HEADER(objc_get_uninstalled_dtable, objc/objc-api.h,
	AC_DEFINE(HAVE_OBJC_GET_UNINSTALLED_DTABLE,1,
                  [ Define if objc-api.h defines this function]),)

# Don't revert any Objective-C flags as they are used in the next test


#--------------------------------------------------------------------
# Native Objective-C exceptions
#--------------------------------------------------------------------

if test "$OBJC_RUNTIME_LIB" = "ng"; then
  exceptions=yes
else
  # Determine if native Objective-C exceptions are enabled
  # in gnustep-make.  They are enabled if the compiler supports it; they
  # are disabled if it doesn't.  And, of course, the user may have
  # forced one behaviour or the other.  Note that we go and look at the
  # actual config.make file to be able to know what was configured in
  # gnustep-make regardless of any gnustep-base that is currently
  # installed.  We can't use `gnustep-config --objc-flags` because that
  # may report native exceptions as disabled because the currently
  # installed gnustep-base has them disabled.
  if grep USE_OBJC_EXCEPTIONS $CURRENT_GNUSTEP_MAKEFILES/$lobj_dir/config.make | grep yes >&5 2>&5; then
    exceptions=yes
  else
    exceptions=no
  fi
fi

# At this point, if exceptions=no, then native exceptions are disabled
# and won't be used.  If exceptions=yes, we need to check if they work
# and if the runtime has proper support for them.  If it does, we'll
# happily use them; if it doesn't, we'll automatically disable them
# because they don't work. ;-)

#--------------------------------------------------------------------
# One of these is needed by for handling uncaught exceptions
#--------------------------------------------------------------------

# TODO: These checks are not really needed if native exceptions are
# disabled.  So maybe we should not run them at all in that case.  On
# the other hand, that case is going to become more and more unusual.

AC_MSG_CHECKING(for objc_setUncaughtExceptionHandler() in runtime)
AC_LINK_IFELSE([AC_LANG_SOURCE(
  [[#include "$srcdir/config/config.setUncaughtExceptionHandler.m"]])],
	have_set_uncaught_exception_handler=yes, have_set_uncaught_exception_handler=no)
if test $have_set_uncaught_exception_handler = yes; then
  AC_DEFINE(HAVE_SET_UNCAUGHT_EXCEPTION_HANDLER,1,
	    [Define if libobjc has the objc_setUncaughtExceptionHandler() function])
fi
AC_MSG_RESULT($have_set_uncaught_exception_handler)

# Don't revert any Objective-C flags as they are used in the next test

AC_MSG_CHECKING(for objc_set_unexpected() in runtime)
AC_LINK_IFELSE(
  [AC_LANG_SOURCE([[#include "$srcdir/config/config.set_unexpected.m"]])],
	have_set_unexpected=yes, have_set_unexpected=no)
if test $have_set_unexpected = yes; then
  AC_DEFINE(HAVE_SET_UNEXPECTED,1,
	    [Define if libobjc has the objc_set_unexpected() function])
fi
AC_MSG_RESULT($have_set_unexpected)

# Don't revert any Objective-C flags as they are used in the next test

AC_MSG_CHECKING(for _objc_unexpected_exception in runtime)
if test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
  # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
  # against symbol in discarded section") as the file won't contain any actual
  # ObjC code, so we just assume the function is there.
  AC_MSG_NOTICE([assuming _objc_unexpected_exception() on Windows MSVC])
  have_unexpected=yes
else
  AC_RUN_IFELSE(
    [AC_LANG_SOURCE([[#include "$srcdir/config/config.unexpected.m"]])],
      have_unexpected=yes,
      have_unexpected=no,
      have_unexpected="$cross_have_unexpected")
fi
if test $have_unexpected = yes; then
  AC_DEFINE(HAVE_UNEXPECTED,1,
	    [Define if libobjc has the _objc_unexpected_exception callback])
fi
AC_MSG_RESULT($have_unexpected)

# TODO: It would also be nice to actually test that native Objective-C
# exceptions work.

if test "$exceptions" = "yes"; then
  if test x"$have_set_uncaught_exception_handler" = x"no"; then
    if test x"$have_set_unexpected" = x"no"; then
      if test x"$have_unexpected" = x"no"; then
        AC_MSG_NOTICE([Disabling native Objective-C exceptions because the ObjC runtime])
        AC_MSG_NOTICE([has no way to set an uncaught exception handler.  Please install])
        AC_MSG_NOTICE([a recent Objective-C runtime if you want to use them.])
        exceptions="no";
      fi
    fi
  fi
fi

AC_MSG_CHECKING(whether to enable native Objective-C exceptions)
if test "$exceptions" = "yes"; then
  AC_MSG_RESULT(yes)
  BASE_NATIVE_OBJC_EXCEPTIONS=1
else
  AC_MSG_RESULT(no)
  BASE_NATIVE_OBJC_EXCEPTIONS=0
fi
AC_SUBST(BASE_NATIVE_OBJC_EXCEPTIONS)

# Don't revert any Objective-C flags as they are used in the next test

#--------------------------------------------------------------------
# Function needed by @synchronize directive
#--------------------------------------------------------------------
HAVE_OBJC_SYNC_ENTER=no
if test "$host_os" = windows -a "$OBJC_RUNTIME_LIB" = "ng"; then
  # On Windows MSVC, AC_CHECK_FUNCS() will throw linker errors ("relocation
  # against symbol in discarded section") as the file won't contain any actual
  # ObjC code, so we just assume the function is there.
  AC_MSG_NOTICE([assuming objc_sync_enter() on Windows MSVC])
  HAVE_OBJC_SYNC_ENTER=yes
else
  AC_CHECK_FUNCS(objc_sync_enter)
  if test $ac_cv_func_objc_sync_enter = yes ; then
    HAVE_OBJC_SYNC_ENTER=yes
  fi
fi
AC_SUBST(HAVE_OBJC_SYNC_ENTER)

# Don't revert any Objective-C flags as they are used in the next test

AC_MSG_CHECKING(for thread-safe +initialize in runtime)
AC_RUN_IFELSE(
  [AC_LANG_SOURCE([[#include "$srcdir/config/config.initialize.m"]])],
	safe_initialize=yes, safe_initialize=no, safe_initialize="$cross_safe_initialize")
if test $safe_initialize = yes; then
  AC_DEFINE(HAVE_INITIALIZE,1,
	    [Define if libobjc has thread-safe +initialize support])
else
  AC_MSG_WARN([Your ObjectiveC runtime does not support thread-safe class initialisation.  Please use a different runtime if you intend to use threads.])
fi
AC_MSG_RESULT($safe_initialize)

LIBS="$saved_LIBS"
CPPFLAGS="$saved_CPPFLAGS"

AC_SUBST(OBJCFLAGS)

#--------------------------------------------------------------------
# Generic settings needed by NSZone.m
#--------------------------------------------------------------------
AC_TYPE_SIZE_T
AC_C_INLINE

#--------------------------------------------------------------------
# Following header checks needed for bzero in Storage.m and other places
#--------------------------------------------------------------------

AC_CHECK_HEADERS(string.h memory.h alloca.h)

#--------------------------------------------------------------------
# Following header check needed NSConnection.h
#--------------------------------------------------------------------
AC_CHECK_HEADERS(float.h)

#--------------------------------------------------------------------
# Header files and functions for files and filesystems
#--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h)
AC_CHECK_HEADERS(sys/cdefs.h sys/syslimits.h sys/param.h)
# Twisted header checks for some BSDs with stupid interdependencies
AC_CHECK_HEADERS([sys/syslimits.h], [], [],
  [#if HAVE_SYS_CDEFS_H
   #include <sys/cdefs.h>
   #endif
   #include <sys/syslimits.h>
  ])
AC_CHECK_HEADERS([sys/param.h], [], [],
  [#if HAVE_SYS_CDEFS_H
   #include <sys/cdefs.h>
   #endif
   #if HAVE_SYS_SYSLIMITS_H
   #include <sys/syslimits.h>
   #endif
  ])
AC_CHECK_HEADERS([sys/mount.h], [], [],
  [#if HAVE_SYS_CDEFS_H
   #include <sys/cdefs.h>
   #endif
   #if HAVE_SYS_SYSLIMITS_H
   #include <sys/syslimits.h>
   #endif
   #if HAVE_SYS_PARAM_H
   #include <sys/param.h>
   #endif
  ])
AC_CHECK_HEADERS(sys/types.h windows.h locale.h langinfo.h)
saved_LIBS="$LIBS"
AC_CHECK_LIB(m, main)
AC_CHECK_FUNCS(utimensat statvfs link symlink readlink geteuid getlogin getpwnam getpwnam_r getpwuid getpwuid_r getgrgid getgrgid_r getgrnam getgrnam_r rint getopt malloc_usable_size)
LIBS="$saved_LIBS"

AC_CACHE_CHECK([for pw_gecos field in struct passwd],
		ac_cv_have_pw_gecos_in_struct_passwd, [
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
	[[ struct passwd p; p.pw_gecos = 0; ]])],
	[ ac_cv_have_pw_gecos_in_struct_passwd="yes" ],
	[ ac_cv_have_pw_gecos_in_struct_passwd="no"
	])
])
if test "x$ac_cv_have_pw_gecos_in_struct_passwd" = "xyes" ; then
	AC_DEFINE([HAVE_PW_GECOS_IN_PASSWD], [1],
		[Define if you have pw_gecos field in struct passwd])
fi

AC_CACHE_CHECK([for currency_symbol field in struct lconv],
		ac_cv_have_currency_symbol_in_struct_lconv, [
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <locale.h> ]],
	[[ struct lconv l; l.currency_symbol = NULL; ]])],
	[ ac_cv_have_currency_symbol_in_struct_lconv="yes" ],
	[ ac_cv_have_currency_symbol_in_struct_lconv="no"
	])
])
if test "x$ac_cv_have_currency_symbol_in_struct_lconv" = "xyes" ; then
	AC_DEFINE([HAVE_CURRENCY_SYMBOL_IN_LCONV], [1],
		[Define if you have currency_symbol field in struct lconv])
fi

#--------------------------------------------------------------------
# These two headers (functions) needed by Time.m
#--------------------------------------------------------------------
dnl AC_REPLACE_FUNCS(getrusage gettimeofday)

AC_CHECK_HEADERS(time.h sys/time.h tzfile.h sys/rusage.h ucbinclude/sys/resource.h)
AC_CHECK_FUNCS(time ctime tzset)

#--------------------------------------------------------------------
# These headers/functions needed by GSTcpPort.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/socket.h netinet/in.h)
AC_CHECK_TYPES([socklen_t])

#--------------------------------------------------------------------
# This needed by GSSocketStream.h
#--------------------------------------------------------------------
AC_CHECK_TYPE([struct sockaddr_storage],
  AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
    [if struct sockaddr_storage is defined]), ,[
#undef inline
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#endif
])

dnl AC_REPLACE_FUNCS(recvfrom)

#--------------------------------------------------------------------
# These headers/functions needed for stacktrace in NSException.m
#--------------------------------------------------------------------
AC_ARG_ENABLE(bfd,
  [  --enable-bfd
	Enables the use of libbfd to provide symbolic stack traces.
	Enabling this option provides support for symbolic stack traces
	on platforms where the backtrace_symbols() function is not
	available or does not work properly.
	Enabling this option also has the effect of changing the license
	of gnustep-base from LGPL to GPL since libbfd uses the GPL license],,
  enable_bfd=no)
if test $enable_bfd = yes ; then
  AC_DEFINE(USE_BFD,1, [Define to use bfd library for stack traces])
  AC_MSG_WARN([You enabled bfd, which causes gnustep-base to link with libbfd. This makes the license GPL rather than the normal LGPL.])
fi

AC_CHECK_HEADERS(bfd.h)
AC_CHECK_LIB(intl, libintl_fprintf)
AC_CHECK_LIB(zstd, ZSTD_compress)
AC_CHECK_LIB(iberty, dyn_string_append)
AC_CHECK_LIB(z, gzseek)
AC_SEARCH_LIBS(sframe, sframe_decode)
AC_CHECK_LIB(bfd, bfd_openr)

AC_COMPILE_IFELSE(
	[AC_LANG_PROGRAM([[#include <bfd.h>]],[[bfd_section_vma(0);]])],
	[bfd_section_vma=1],
	[bfd_section_vma=0])
if test $bfd_section_vma = 1; then
  AC_MSG_RESULT([bfd_section_vma found])
  AC_DEFINE([HAVE_BFD_SECTION_VMA], [1], [Have bfd_section_vma])
fi


case "$target_os" in
  mingw*)
    AC_CHECK_HEADERS(dbghelp.h)
    ;;
  *)
    AC_CHECK_HEADERS(execinfo.h)
    AC_CHECK_FUNCS(backtrace)
    ;;
esac

AC_CHECK_FUNCS(__builtin_extract_return_address)

# Enable unwind if found by default
AC_ARG_WITH(unwind,
  AS_HELP_STRING([--without-unwind], [Ignore unwind if found and disable it]))

AS_IF([test "x$with_unwind" != "xno"],
  [AC_CHECK_HEADERS(unwind.h)] [AC_CHECK_FUNCS(_Unwind_GetIP)],
  [have_unwind=no])

AS_IF([test "x$ac_cv_func__Unwind_GetIP" = "xyes"],
  [have_unwind=yes],
  [have_unwind=no])

AS_IF([test "x$have_unwind" = "xyes"],
  [AC_DEFINE([WITH_UNWIND], [1], [Have and use Unwind library])],
  [AS_IF([test "x$with_unwind" = "xyes"],
         [AC_MSG_ERROR([unwind requested but not found])
  ])
])

#--------------------------------------------------------------------
# These headers/functions needed by NSLog.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(syslog.h sys/slog.h sys/slogcodes.h)
AC_CHECK_FUNCS(syslog)
if test "$ac_cv_header_sys_slog_h" = "yes"; then
  oldLibs="$LIBS";
  LIBS="$LIBS -l:libc.a";
  AC_CHECK_FUNCS(slogf)
  if test "$ac_cv_func_slogf" = "no"; then
    LIBS="$oldLibs"
  fi
fi
#--------------------------------------------------------------------
# These headers/functions needed by NSRunLoop.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(poll.h)
AC_CHECK_FUNCS(poll)
have_poll=no
if test $ac_cv_header_poll_h = yes; then
  have_poll=yes
  AC_MSG_CHECKING(for poll emulation)
  AC_EGREP_CPP(emulating_poll, [#include "config/config.poll.c"],
  	have_poll=no,)
  if test $have_poll = yes; then
    AC_MSG_RESULT(no)
    AC_MSG_CHECKING([if poll supports devices])
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.poll-dev.c"]])],
	,
	[have_poll=no],
	[have_poll="$cross_have_poll"])
    if test $have_poll = yes; then
      AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select])
    else
      AC_MSG_RESULT(no)
    fi
  else
    AC_MSG_RESULT(yes)
  fi
fi

#--------------------------------------------------------------------
# This function needed by StdioStream.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(vsprintf vasprintf snprintf vsnprintf)
if test $ac_cv_func_vsprintf = yes ; then
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.vsprintf.c"]])],
	[VSPRINTF_RETURNS_LENGTH=1],
	[VSPRINTF_RETURNS_LENGTH=0],
	[VSPRINTF_RETURNS_LENGTH="$cross_VSPRINTF_RETURNS_LENGTH"])
    AC_DEFINE_UNQUOTED(VSPRINTF_RETURNS_LENGTH, $VSPRINTF_RETURNS_LENGTH,
                       [Define if vsprintf returns the length printed])
fi
if test $ac_cv_func_vasprintf = yes ; then
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.vasprintf.c"]])],
	[VASPRINTF_RETURNS_LENGTH=1],
	[VASPRINTF_RETURNS_LENGTH=0],
	[VASPRINTF_RETURNS_LENGTH="$cross_VASPRINTF_RETURNS_LENGTH"])
    AC_DEFINE_UNQUOTED(VASPRINTF_RETURNS_LENGTH, $VASPRINTF_RETURNS_LENGTH,
                       [Define if vasprintf returns the length printed])
fi

#--------------------------------------------------------------------
# This function needed by NSFileManager.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(getcwd)
AC_HEADER_DIRENT

# Look for file creation and modification date on NetBSD, FreeBSD, Darwin
AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_birthtime, struct stat.st_birthtimespec, struct stat.st_birthtim, struct stat64.st_birthtimespec],
		 ,,[#include <sys/stat.h>])

#--------------------------------------------------------------------
# This function needed by gdomap.c
#--------------------------------------------------------------------
AC_CHECK_HEADERS(getopt.h)

#--------------------------------------------------------------------
# This function needed by NSPage.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(posix_memalign valloc)

#--------------------------------------------------------------------
# This function needed by Time.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(times)

#--------------------------------------------------------------------
# These functions needed by NSData.m and GSFFIInvocation.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(shmctl)
AC_CHECK_FUNCS(mmap)
AC_CHECK_FUNCS(mprotect)
AC_CHECK_HEADERS(sys/mman.h)

#--------------------------------------------------------------------
# These functions needed by NSTask.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(killpg setpgrp setpgid setsid grantpt)
AC_CHECK_FUNCS(closefrom)
if test "x$ac_cv_func_setpgrp" = xyes; then
  AC_FUNC_SETPGRP
fi

HAVE_PTS_STREAM_MODULES=0
case "${target}" in
  *-sysv-*)
    HAVE_PTS_STREAM_MODULES=1
    ;;
esac
AC_DEFINE_UNQUOTED(HAVE_PTS_STREAM_MODULES, $HAVE_PTS_STREAM_MODULES,
                   [Define this if you work on sysv])
AC_SUBST(HAVE_PTS_STREAM_MODULES)

AC_CHECK_HEADERS(dnl
	fcntl.h dnl
	inttypes.h dnl
	libc.h dnl
	limits.h dnl
	malloc.h dnl
	memory.h dnl
	signal.h dnl
	stdint.h dnl
	string.h dnl
	sys/fcntl.h dnl
	sys/file.h dnl
	sys/filio.h dnl
	sys/inttypes.h dnl
	sys/ioctl.h dnl
	sys/signal.h dnl
	sys/stropts.h dnl
	sys/wait.h dnl
	unistd.h dnl
	utime.h dnl
        stdlib.h dnl
        stdbool.h dnl
	)

if test $ac_cv_header_inttypes_h = yes; then
INCLUDE_INTTYPES="#include <inttypes.h>"
elif test $ac_cv_header_sys_inttypes_h = yes; then
INCLUDE_INTTYPES="#include <sys/inttypes.h>"
elif test $ac_cv_header_stdint_h = yes; then
INCLUDE_INTTYPES="#include <stdint.h>"
else
INCLUDE_INTTYPES="no"
fi

if test "$INCLUDE_INTTYPES" = "no"; then
INCLUDE_INTTYPES=""
DEFINE_INT8_T="#define int8_t gss8"
DEFINE_UINT8_T="#define uint8_t gsu8"
DEFINE_INT16_T="#define int16_t gss16"
DEFINE_UINT16_T="#define uint16_t gsu16"
DEFINE_INT32_T="#define int32_t gss32"
DEFINE_UINT32_T="#define uint32_t gsu32"
DEFINE_INT64_T="#define int64_t gss64"
DEFINE_UINT64_T="#define uint64_t gsu64"
DEFINE_INTPTR_T="#define intptr_t gssaddr"
DEFINE_UINTPTR_T="#define uintptr_t gsuaddr"
else
DEFINE_INT8_T=""
DEFINE_UINT8_T=""
DEFINE_INT16_T=""
DEFINE_UINT16_T=""
DEFINE_INT32_T=""
DEFINE_UINT32_T=""
DEFINE_INT64_T=""
DEFINE_UINT64_T=""
DEFINE_INTPTR_T=""
DEFINE_UINTPTR_T=""
fi

AC_SUBST(INCLUDE_INTTYPES)
AC_SUBST(DEFINE_INT8_T)
AC_SUBST(DEFINE_UINT8_T)
AC_SUBST(DEFINE_INT16_T)
AC_SUBST(DEFINE_UINT16_T)
AC_SUBST(DEFINE_INT32_T)
AC_SUBST(DEFINE_UINT32_T)
AC_SUBST(DEFINE_INT64_T)
AC_SUBST(DEFINE_UINT64_T)
AC_SUBST(DEFINE_INTPTR_T)
AC_SUBST(DEFINE_UINTPTR_T)

#--------------------------------------------------------------------
# These used by GSFileHandle.m and distributed objects
# On some systems we need -lnsl ... so check for that case.
#--------------------------------------------------------------------
AC_CHECK_HEADERS(ws2tcpip.h)
AC_SEARCH_LIBS([inet_ntop],[nsl Ws2_32])
AC_CHECK_FUNCS(gethostbyaddr_r inet_aton inet_pton inet_ntop sigaction)

USE_ZLIB=0
AC_CHECK_HEADERS(zlib.h)
if test $ac_cv_header_zlib_h = yes; then
  AC_CHECK_LIB(z, gzseek, zlib_ok=yes, zlib_ok=no)
  if test "$zlib_ok" = yes; then
    LIBS="$LIBS -lz"
    USE_ZLIB=1
  fi
fi
AC_SUBST(USE_ZLIB)

HAVE_INET_PTON=no
if test $ac_cv_func_inet_pton = yes ; then
  HAVE_INET_PTON=yes
fi
AC_SUBST(HAVE_INET_PTON)

HAVE_INET_NTOP=no
if test $ac_cv_func_inet_ntop = yes ; then
  HAVE_INET_NTOP=yes
fi
AC_SUBST(HAVE_INET_NTOP)

#--------------------------------------------------------------------
# For setting thread stack size
#--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_FUNCS(setrlimit)

#--------------------------------------------------------------------
# One of these functions needed by NSDebug.m and NSProcessInfo.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(strerror)
AC_FUNC_STRERROR_R

#--------------------------------------------------------------------
# Needed by NSDebug.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(sigsetjmp)

#--------------------------------------------------------------------
# This type needed by GSFormat
#--------------------------------------------------------------------
AC_CHECK_TYPES([uintmax_t])
AC_CHECK_HEADERS(wchar.h)

#--------------------------------------------------------------------
# Check if short and int values need to be word aligned
#--------------------------------------------------------------------
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -O0"
AC_MSG_CHECKING(short/int needs to be word aligned)
AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.align.c"]])],
	[NEED_WORD_ALIGNMENT=0],
	[NEED_WORD_ALIGNMENT=1],
	[NEED_WORD_ALIGNMENT="$cross_NEED_WORD_ALIGNMENT"])
CFLAGS="$saved_CFLAGS"
AC_DEFINE_UNQUOTED(NEED_WORD_ALIGNMENT, $NEED_WORD_ALIGNMENT,
                   [Define if your system needs to have short/int word aligned])
if test $NEED_WORD_ALIGNMENT = 1; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

#--------------------------------------------------------------------
# This needed by NSString for handling of %@ printf directive.
#--------------------------------------------------------------------
AC_CHECK_FUNCS(register_printf_specifier)
AC_CHECK_FUNC(register_printf_function, register_printf=1,
register_printf=0)
if test $register_printf = 1; then
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.printf.c"]])],
	[working_register_printf=1],
	[working_register_printf=0],
       	[working_register_printf="$cross_working_register_printf"])
  if test $working_register_printf = 1; then
    AC_DEFINE(HAVE_REGISTER_PRINTF_FUNCTION,1,
              [Define if you have the register_printf_function function])
    AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.wprintf.c"]])],
	[wide_register_printf=1],
	[wide_register_printf=0],
	[wide_register_printf="$cross_wide_register_printf"])
    if test $wide_register_printf = 1; then
      AC_DEFINE(HAVE_WIDE_PRINTF_FUNCTION,1,
              [Define if register_printf_function supports wide characters])
    fi
  fi
fi


#--------------------------------------------------------------------
# This function needed by NSString.
#--------------------------------------------------------------------
AC_CHECK_FUNCS(realpath)

#--------------------------------------------------------------------
# Check if the C Library defines extern char *program_invocation_name
# Used in critical cases by NSProcessInfo.m
#--------------------------------------------------------------------
AC_MSG_CHECKING(program_invocation_name in C Library)
AC_CACHE_VAL(gs_cv_program_invocation_name_worked,
[AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[
#include <string.h>
int
main (int argc, char *argv[])
{
  extern char *program_invocation_name;
  return (strcmp (program_invocation_name, argv[0]));
}
]])],
	[gs_cv_program_invocation_name_worked=yes],
	[gs_cv_program_invocation_name_worked=no],
	[gs_cv_program_invocation_name_worked="$cross_gs_cv_program_invocation_name_worked"])])
if test $gs_cv_program_invocation_name_worked = yes; then
  AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME,1,
            [Define if your Lib C defines program_invocation_name])
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

#--------------------------------------------------------------------
# Check for uname header used by NSProcessInfo.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/utsname.h)

#--------------------------------------------------------------------
# Check for sysctlbyname used by NSProcessInfo.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(sys/sysctl.h)
AC_CHECK_FUNCS(sysctlbyname)

#--------------------------------------------------------------------
# Defines HAVE_PROCFS if the kernel supports the /proc filesystem.
# Needed by NSProcessInfo.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(procfs.h)
AC_SYS_PROCFS
AC_SYS_PROCFS_PSINFO
AC_SYS_PROCFS_EXE_LINK

#--------------------------------------------------------------------
# Check if /proc/$$/cmdline terminates the last argument with a nul
#--------------------------------------------------------------------
AC_MSG_CHECKING(/proc/$$/cmdline terminated by nul)
AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.proccmd.c"]])],
	[CMDLINE_TERMINATED=1],
	[CMDLINE_TERMINATED=0],
	[CMDLINE_TERMINATED="$cross_CMDLINE_TERMINATED"])
AC_DEFINE_UNQUOTED(CMDLINE_TERMINATED, $CMDLINE_TERMINATED,
		   [Define if your system terminates the final argument in /proc/$$/cmdline])
if test $CMDLINE_TERMINATED = 1; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

#--------------------------------------------------------------------
# If /proc doesn't work, try kvm (on FreeBSD, for instance)
#--------------------------------------------------------------------
have_kvm_env=0
save_LIBS="$LIBS"
AC_CHECK_LIB(kvm, kvm_getenvv)
if test "$ac_cv_lib_kvm_kvm_getenvv" = yes; then
  AC_MSG_CHECKING(if we can access kernel memory)
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE[[#include "$srcdir/config/config.kvmopen.c"]])],
	[have_kvm_env=1],
	[have_kvm_env=0],
	[have_kvm_env="$cross_have_kvm_env"])
  if test $have_kvm_env = 1; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_KVM_ENV, 1,
    			    [Define if you can access the kernel via kvm_open])
  else
    AC_MSG_RESULT(no)
    # Reset LIBS since we don't need kvm
    LIBS="$save_LIBS"
  fi
fi

#--------------------------------------------------------------------
# Include redefinition of main () only if needed.
# On some systems - force redefinition to be used as the /proc stuff
# doesn't work. Allow NSProcessInfo initialization method also.
#--------------------------------------------------------------------
PASS_ARG=no
case "$target_os" in
  cygwin*)	PASS_ARG=yes;;
esac

AC_MSG_CHECKING(use of pass-through arguments)
AC_ARG_ENABLE(pass-arguments,
  [  --enable-pass-arguments	Force user main call to NSProcessInfo initialize],,
  enable_pass_arguments=$PASS_ARG)

if test "$enable_pass_arguments" = "yes"; then
  GS_PASS_ARGUMENTS=1
else
  GS_PASS_ARGUMENTS=0
fi
AC_SUBST(GS_PASS_ARGUMENTS)
AC_MSG_RESULT($enable_pass_arguments)

AC_MSG_CHECKING(use of fake-main definition)
AC_ARG_ENABLE(fake-main,
  [  --enable-fake-main  		Force redefine of user main function],,
  enable_fake_main=no)

if test "$enable_pass_arguments" = "no"; then
  case "$target_os" in
    freebsd2*)	enable_fake_main=yes;;
    freebsd*)	;;
    kfreebsd*)	enable_fake_main=yes;;
    netbsd*)	enable_fake_main=yes;;
    openbsd*)	enable_fake_main=yes;;
    *sysv*)	enable_fake_main=yes;;
  esac
fi

GS_FAKE_MAIN=0
if test "$enable_fake_main" = "yes"; then
  GS_FAKE_MAIN=1
elif test "$enable_pass_arguments" = "no"; then
  if test "$gs_cv_objc_load_method_worked" = yes -a \( "$ac_cv_sys_procfs" = yes -o "$have_kvm_env" = 1 -o "$ac_cv_sys_procfs_psinfo" = yes \); then
    GS_FAKE_MAIN=0
    if test "$have_kvm_env" = "1"; then
      AC_MSG_WARN([Using libkvm which is known to be buggy on some systems consider configuring with --enable-fake-main instead.])
    fi
  else
    case "$target_os" in
      darwin* ) ;;
      * )
       GS_FAKE_MAIN=1
       enable_fake_main=yes
    esac
  fi
fi
case "$target_os" in
    mingw*|windows)	enable_fake_main=no; GS_FAKE_MAIN=0;;
esac
AC_SUBST(GS_FAKE_MAIN)
AC_MSG_RESULT($enable_fake_main)

#--------------------------------------------------------------------
# Simple way to add a bunch of paths to the flags
#--------------------------------------------------------------------
AC_ARG_WITH(include-flags,
    [  --with-include-flags=FLAGS    Specify all include flags at once],
    include_flags="$withval", include_flags="no")
if test ${include_flags} != "no"; then
    CPPFLAGS="$CPPFLAGS ${include_flags}"
    INCLUDE_FLAGS="$INCLUDE_FLAGS ${include_flags}"
fi

AC_ARG_WITH(library-flags,
    [  --with-library-flags=FLAGS    Specify all library flags at once],
    library_flags="$withval", library_flags="no")
if test ${library_flags} != "no"; then
    LDFLAGS="$LDFLAGS ${library_flags}"
    LDIR_FLAGS="$LDIR_FLAGS ${library_flags}"
fi

#--------------------------------------------------------------------
# Check for FFI interface libraries for invocations
# We enable ffi by default now, as it's the only well supported
# library nowadays.
#--------------------------------------------------------------------
do_broken_libffi=no
do_broken_libffcall=no
do_enable_libffi=yes
do_enable_libffcall=no
case "$target_cpu" in
  sparc64*)
    case "$target_os" in
      solaris*)
        do_broken_libffcall=yes;
        do_enable_libffi=yes;
        do_enable_libffcall=no;;
      *) ;;
    esac ;;
  *) ;;
esac

if test "$exceptions" = "yes"; then
  # ffcall will mess up native exceptions, so we must disable it.
  do_broken_libffcall=yes
  do_enable_libffcall=no
fi

AC_ARG_ENABLE(libffi,
  [  --disable-libffi  		Disable use of libffi library],,
  enable_libffi=$do_enable_libffi)

AC_ARG_ENABLE(ffcall,
  [  --enable-ffcall  		Enable use of the deprecated ffcall library],,
  enable_ffcall=$do_enable_libffcall)

if test $enable_ffcall = yes; then
  AC_MSG_WARN([ffcall has been enabled ... this is deprecated ... please install and use a recent libffi if possible])
fi

AC_ARG_ENABLE(invocations,
  [  --disable-invocations		Build even if invocation-dependencies are not met],,
  enable_invocations=yes)

# DO isn't used on apple-apple-apple
if test $LIBRARY_COMBO = apple-apple-apple; then
  enable_invocations=no
fi

AC_ARG_WITH(ffi-include,
[  --with-ffi-include=PATH       Include path for ffi headers],
    ffi_incdir="$withval", ffi_incdir="no")
if test ${ffi_incdir} != "no"; then
    CPPFLAGS="$CPPFLAGS -I${ffi_incdir}"
    INCLUDE_FLAGS="$INCLUDE_FLAGS -I${ffi_incdir}"
fi

AC_ARG_WITH(ffi-library,
[  --with-ffi-library=PATH       Library path for ffi libs],
    ffi_libdir="$withval", ffi_libdir="no")
if test ${ffi_libdir} != "no"; then
  GS_ADD_LIBRARY_PATH([${ffi_libdir}])
fi

if test "$do_broken_libffi" = "no"; then
  if test -n "$PKG_CONFIG"; then
    if $PKG_CONFIG --exists libffi; then
      pkg_config_libffi=yes
      ffi_CFLAGS=`$PKG_CONFIG --cflags libffi`;
      CPPFLAGS="$CPPFLAGS $ffi_CFLAGS"
      INCLUDE_FLAGS="$INCLUDE_FLAGS $ffi_CFLAGS"
    fi
  fi
  AC_CHECK_HEADER(ffi.h, have_libffi=yes, have_libffi=no)
else
  have_libffi=no
fi
if test "$do_broken_libffcall" = "no"; then
  AC_CHECK_HEADERS(callback.h, have_ffcall=yes, have_ffcall=no)
else
  have_ffcall=no
fi
if test $have_ffcall = no; then
  enable_ffcall=no
  # If we don't have ffcall but do have libffi, use libffi
  if test $have_libffi = yes; then
    enable_libffi=yes
  fi
fi
if test $have_libffi = no; then
  enable_libffi=no
  # If we don't have libffi but do have ffcall, use ffcall
  if test $have_ffcall = yes; then
    if test $enable_ffcall = no; then
      AC_MSG_WARN([ffi support seems to be missing on this system ... please install a recent libffi])
    fi
  fi
fi

have_forward_hook=yes
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
AC_MSG_CHECKING(for forwarding callback in runtime)
AC_COMPILE_IFELSE(
  [AC_LANG_SOURCE([[#include "$srcdir/config/config.forward2.m"]])],
	have_forward_hook=yes, have_forward_hook=no)
if test $have_forward_hook = yes; then
  AC_DEFINE(HAVE_FORWARD2,1,
            [Define if libobjc has the __objc_msg_forward2 function])
else
  AC_COMPILE_IFELSE(
    [AC_LANG_SOURCE([[#include "$srcdir/config/config.forward.m"]])],
	have_forward_hook=yes, have_forward_hook=no)
fi
AC_MSG_RESULT($have_forward_hook)
if test $have_forward_hook = no; then
  enable_libffi=no
  enable_ffcall=no
fi
CPPFLAGS="$saved_CPPFLAGS"

AC_MSG_CHECKING(FFI library usage)
WITH_FFI=none
if test $enable_libffi = yes; then
  AC_DEFINE(USE_LIBFFI,1,
            [Define if using the libffi library for invocations])
  WITH_FFI=libffi
  if test "$pkg_config_libffi" = "yes"; then
    ffi_LIBS=`$PKG_CONFIG --libs libffi`
  else
    ffi_LIBS=-lffi
  fi
  LIBS="$ffi_LIBS $LIBS"
  AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[#include "$srcdir/config/config.ffi.c"]])],
	[ffi_ok="yes"],
	[ffi_ok="no"],
	[ffi_ok="$cross_ffi_ok"])
  if test $ffi_ok = yes; then
    AC_MSG_RESULT(libffi)
    if test $do_broken_libffi = yes; then
      AC_MSG_WARN([ffi may be broken on this system ... try enabling ffcall])
    fi
    AC_CHECK_FUNCS(ffi_prep_closure_loc)
  else
    AC_MSG_ERROR([The ffi library (libffi) does not appear to be working.  Perhaps it's missing or you need a more recent version.  Version 3.0.9 or later should work, and you can find a link to it n the list of packages for download at http://www.gnustep.org/resources/sources.html])
  fi
elif test $enable_ffcall = yes; then
  AC_DEFINE(USE_FFCALL,1,
            [Define if using the ffcall library for invocations])
  WITH_FFI=ffcall
  LIBS="-lcallback -lavcall $LIBS"
  AC_LINK_IFELSE(
	[AC_LANG_PROGRAM([[#include <callback.h>]],)],
	[ffi_ok="yes"],
	[ffi_ok="no"])
  if test $ffi_ok = yes; then
    AC_MSG_RESULT(ffcall)
  fi
  AC_MSG_WARN([ffcall is broken on some systems and is deprecated ... try enabling ffi])
else
  ffi_ok=no
fi

if test $enable_ffcall = yes -a $ffi_ok = yes; then
  AC_MSG_CHECKING(if ffcall trampolines work)
  AC_RUN_IFELSE(
    [AC_LANG_SOURCE([[#include "$srcdir/config/config.trampoline.c"]])],
	  have_working_trampoline=yes, have_working_trampoline=no,
	  have_working_trampoline=yes)
  AC_MSG_RESULT($have_working_trampoline)
fi

if test $ffi_ok = no; then
  AC_MSG_RESULT(none)
  echo
  if test $have_forward_hook = no; then
    echo "You do not have an up-to-date libobjc library installed"
  elif test "$have_working_trampoline" = no; then
    echo "You have ffcall, but it does not work properly. Most likely because"
    echo "your system's security policy is blocking some parts of ffcall"
    echo "we recommend installing libffi instead."
  else
    echo "You do not have either ffcall or libffi installed/enabled, or configure needs"
    echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them,"
    echo "or you have ffcall but gnustep-make is configured to use native exceptions"
    echo "(native exceptions are not compatible with ffcall)."
  fi
  echo "GNUstep requires libffi (or ffcall) and proper libobjc hooks to do"
  echo "invocations and DO."
  echo "(This does not apply on apple-apple-apple systems where DO is"
  echo "not compatible with other GNUstep systems.)"
  if test $enable_invocations = yes; then
    echo
    echo "You most likely do not want to build base without invocation support."
    echo "Many things (including Distributed Objects and undo/redo), won't work"
    echo "at all without invocations."
    echo "If you really want to build -base without invocation support,"
    echo "add --disable-invocations to the configure arguments."
    echo "For more information, read the GNUstep build guide, ffcall section:"
    echo "http://gnustep.made-it.com/BuildGuide/index.html"
    AC_MSG_ERROR([Incomplete support for ffi functionality.])
  fi
  AC_MSG_WARN([Incomplete support for ffi funtionality.])
fi
AC_SUBST(WITH_FFI)


#--------------------------------------------------------------------
# Check for iconv support (for Unicode conversion).
#--------------------------------------------------------------------
# Do this before checking for xml2,  as xml2 may require iconv.
#
# We need to find an iconv library that matches the installed iconv.h header
# (if any). It is important to check header/library compatibility. It's
# fairly common to have iconv support both in libc and from libiconv. In that
# case, a naive check that iconv() is in libc will succeed, but if we use
# libiconv's iconv.h, it will redefine iconv() to functions that exist
# only in libiconv, and we'll get link errors.
#
# Some versions of iconv don't support the '//TRANSLIT' option, which is
# needed for a lossy conversion (where we pick the closest equivalent for
# any character present in the source string which does not exist in the
# destination characterset), so we check for support of that first.

# First, check if there's a working iconv in libc (ie. if the test program
# runs without any extra flags).
AC_ARG_ENABLE(iconv,
  [  --disable-iconv		Build even if iconv is not available],,
  enable_iconv=yes)

if test $enable_iconv = yes; then
AC_MSG_CHECKING(iconv support)
AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
int main(int argc,char **argv)
{ return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
,
  # libc has a working iconv.
  AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
  AC_MSG_RESULT([[yes, in libc]])
  found_iconv=yes
,
  found_iconv=no
,
  found_iconv="$cross_found_iconv_libc";
  if test "$found_iconv" = "yes"; then
    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
    AC_MSG_RESULT([[yes, in libc (via cross.config)]])
  fi
)

if test $found_iconv = no ; then
  # libc doesn't have a working iconv with translit.
  # Try adding -liconv and any user supplied directory.
  AC_ARG_WITH(libiconv-library,
    [  --with-libiconv-library=PATH  Library path for libiconv libraries],
    libiconv_libdir="$withval", libiconv_libdir="no")

  if test "$libiconv_libdir" != "no"; then
    GS_ADD_LIBRARY_PATH([${libiconv_libdir}])
  fi

  AC_ARG_WITH(libiconv-include,
    [  --with-libiconv-include=PATH  Include path for libiconv header],
    libiconv_incdir="$withval", libiconv_incdir="no")
  if test ${libiconv_incdir} != "no"; then
      CPPFLAGS="$CPPFLAGS -I${libiconv_incdir}"
      INCLUDE_FLAGS="$INCLUDE_FLAGS -I${libiconv_incdir}"
  fi

  old_LIBS="$LIBS"
  LIBS="-liconv $LIBS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
  int main(int argc,char **argv)
  { return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
  ,
    # -liconv works.
    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
    AC_MSG_RESULT([[yes, -liconv]])
    found_iconv=yes
  ,
    found_iconv=no
    LIBS="$old_LIBS"
  ,
    found_iconv="$cross_found_iconv_liconv";
    if test "$found_iconv" = "yes"; then
      AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
      AC_MSG_RESULT([[yes, -liconv (via cross.config)]])
    else
      LIBS="$old_LIBS"
    fi
  )
fi

if test $found_iconv = no ; then
  # -liconv with translit didn't work. Try giconv.h and -lgiconv.
  # BSDs install this lib as libgiconv.
  old_LIBS="$LIBS"
  LIBS="-lgiconv $LIBS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <giconv.h>
  int main(int argc,char **argv)
  { return iconv_open("UTF-8//TRANSLIT","ASCII") == -1 ? 1 : 0; }])]
  ,
    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
    AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
    AC_MSG_RESULT([[yes, -lgiconv]])
    found_iconv=yes
  ,
    found_iconv=no
    LIBS="$old_LIBS"
  ,
    found_iconv="$cross_found_iconv_lgiconv";
    if test "$found_iconv" = "yes"; then
      AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
      AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
      AC_MSG_RESULT([[yes, -lgiconv (via cross.config)]])
    else
      LIBS="$old_LIBS"
    fi
  )
fi

AC_ARG_ENABLE(stricticonv,
  [  --enable-stricticonv		Build even if iconv is strict],,
  enable_stricticonv=no)
if test $enable_stricticonv = yes; then
AC_MSG_CHECKING(non-lossy iconv support)
AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
int main(int argc,char **argv)
{ return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
,
  # libc has a working iconv.
  AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
  AC_MSG_RESULT([[yes, in libc]])
  found_iconv=yes
,
  found_iconv=no
)

if test $found_iconv = no ; then
  # libc doesn't have a working iconv. Try adding -liconv and any user
  # supplied directory.
  AC_ARG_WITH(libiconv-library,
    [  --with-libiconv-library=PATH  Library path for libiconv libraries],
    libiconv_libdir="$withval", libiconv_libdir="no")

  if test "$libiconv_libdir" != "no"; then
    GS_ADD_LIBRARY_PATH([${libiconv_libdir}])
  fi

  old_LIBS="$LIBS"
  LIBS="-liconv $LIBS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <iconv.h>
  int main(int argc,char **argv)
  { return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
  ,
    # -liconv works.
    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
    AC_MSG_RESULT([[yes, -liconv]])
    found_iconv=yes
  ,
    found_iconv=no
    LIBS="$old_LIBS"
  )
fi

if test $found_iconv = no ; then
  # -liconv didn't work. Try giconv.h and -lgiconv.
  # BSDs install this lib as libgiconv.
  old_LIBS="$LIBS"
  LIBS="-lgiconv $LIBS"
  AC_RUN_IFELSE([AC_LANG_SOURCE([#include <giconv.h>
  int main(int argc,char **argv)
  { return iconv_open("UTF-8","ASCII") == -1 ? 1 : 0; }])]
  ,
    AC_DEFINE(HAVE_ICONV,1, [Define if you have this function])
    AC_DEFINE(HAVE_GICONV,1, [Define if you have this function])
    AC_MSG_RESULT([[yes, -lgiconv]])
    found_iconv=yes
  ,
    found_iconv=no
    LIBS="$old_LIBS"
  )
fi
fi

if test $found_iconv = no ; then
  AC_MSG_RESULT([[no]])
  echo
  echo "You do not appear to have usable iconv header/library."
  echo "Building without them will disable much characterset support."
  echo "If you really want to build gnustep-base without character conversion"
  echo " support, please add --disable-iconv to the configure arguments."
  AC_MSG_ERROR([Missing support for character conversion functionality.])
fi
fi

#--------------------------------------------------------------------
# Check recent libxml2 for GSXML and NSXMLNode
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------
AC_ARG_ENABLE(xml,
  [  --disable-xml			Build even if XML-dependencies are not met],,
  enable_xml=yes)

HAVE_LIBXML=0

if test $enable_xml = yes; then
  PKG_CHECK_MODULES([XML], [libxml-2.0 >= 2.3.0], [enable_libxml=yes], [
    AM_PATH_XML(2.3.0, enable_libxml=yes, enable_libxml=no)
  ])

  if test $enable_libxml = yes; then
    CPPFLAGS="$CPPFLAGS $XML_CFLAGS"
    INCLUDE_FLAGS="$INCLUDE_FLAGS $XML_CFLAGS"
    LIBS="$XML_LIBS $LIBS"
    HAVE_LIBXML=1
    AC_DEFINE(HAVE_LIBXML,1,[Define if libxml available])
    AC_CHECK_HEADERS(libxml/SAX2.h)

    #--------------------------------------------------------------------
    # Check for (optional) libxslt
    #--------------------------------------------------------------------
    AC_ARG_ENABLE(xslt,
      [  --disable-xslt		Build even if XSLT-dependency is not met],,
      enable_xslt=yes)

    if test $enable_xslt = yes; then
      PKG_CHECK_MODULES([XSLT], [libxslt >= 1.0], [xslt_ok=yes], [xslt_ok=no])
      if test "$xslt_ok" = "yes"; then
        AC_CHECK_HEADERS(libxslt/xslt.h, xslt_ok=yes, xslt_ok=no)
      fi
      if test "$xslt_ok" = "yes"; then
        CPPFLAGS="$CPPFLAGS $XSLT_CFLAGS"
        INCLUDE_FLAGS="$INCLUDE_FLAGS $XSLT_CFLAGS"
        LIBS="$XSLT_LIBS $LIBS"
        HAVE_LIBXSLT=1
        AC_DEFINE(HAVE_LIBXSLT,1,[Define if libxslt available])
      else
        echo
        echo "You do not appear to have usable libxslt headers/library."
        echo "Building without them will disable the XSLT extensions."
        echo "If you really want to build gnustep-base without XSLT support,"
        echo "add --disable-xslt to the configure arguments to avoid warning."
        AC_MSG_WARN([Missing support for XSLT functionality.])
      fi
    else
      HAVE_LIBXSLT=0
      AC_MSG_WARN([Disabled support for XSLT funtionality.])
    fi
    AC_SUBST(HAVE_LIBXSLT)
  else
    echo
    echo "You do not appear to have usable libxml2 headers/library."
    echo "Building without them will disable the GSXML and NSXMLNode."
    echo "If you really want to build gnustep-base without XML DOM support"
    echo " (though NSXMLParser is unaffected),  please"
    echo "add --disable-xml to the configure arguments."
    AC_MSG_ERROR([Missing support for XML DOM functionality.])
  fi
else
  AC_MSG_WARN([XML functionality disabled.])
fi
AC_SUBST(HAVE_LIBXML)

#--------------------------------------------------------------------
# Check recent libgnutls for SSL streams.
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------
AC_ARG_ENABLE(tls,
  [  --disable-tls			Disable use of GNUTLS],,
  enable_tls=yes)

if test $enable_tls = yes; then
  HAVE_GNUTLS=0
  # Save CFLAGS and LIBS as AM_PATH_TLS clobbers these variables regardless
  # of the success of the macro.
  saved_LIBS="$LIBS"
  saved_CFLAGS="$CFLAGS"

  if test -n "$PKG_CONFIG"; then
    if $PKG_CONFIG --exists gnutls; then
      AC_MSG_CHECKING(gnutls support)
      HAVE_GNUTLS=1
      TLS_CFLAGS=`$PKG_CONFIG --cflags gnutls`
      TLS_LIBS=`$PKG_CONFIG --libs gnutls`
    fi
  fi

  if test $HAVE_GNUTLS = 0; then
    #  AM_PATH_TLS(2.0.1, enable_libgnutls=yes, enable_libgnutls=no)
    AM_PATH_TLS(1.4.0, enable_libgnutls=yes, enable_libgnutls=no)
    if test $enable_libgnutls = yes; then
      HAVE_GNUTLS=1
    else
      HAVE_GNUTLS=0
    fi
  fi
  if test $HAVE_GNUTLS = 1; then
    if ! $PKG_CONFIG --atleast-version=2.12 gnutls; then
      AC_CHECK_LIB(gcrypt, gcry_control, have_gcrypt=yes, have_gcrypt=no)
      if test "$have_gcrypt" = "no"; then
        HAVE_GNUTLS=0
      else
        TLS_LIBS="$TLS_LIBS -lgcrypt"
      fi
    fi
  fi
  if test $HAVE_GNUTLS = 0; then
    # Restore the CFLAGS and LIBS because AM_PATH_TLS messes them
    LIBS="$saved_LIBS"
    CFLAGS="$saved_CFLAGS"
    AC_MSG_RESULT(no)
    echo
    echo "You do not appear to have usable libgnutls headers/library."
    echo "Building without them will disable SSL/TLS/HTTPS in NSStream,"
    echo "NSFileHandle, NSURLHandle and NSURLConnection."
    echo "If you really want to build gnustep-base without TLS support,"
    echo "add --disable-tls to the configure arguments."
    AC_MSG_ERROR([Missing support for TLS functionality.])
  else
    AC_MSG_RESULT(yes)
    CPPFLAGS="$CPPFLAGS $TLS_CFLAGS"
    INCLUDE_FLAGS="$INCLUDE_FLAGS $TLS_CFLAGS"
    LIBS="$TLS_LIBS $LIBS"
    AC_CHECK_FUNCS(gnutls_transport_set_errno)
    if test "$ac_cv_func_gnutls_transport_set_errno" = "no"; then
      AC_MSG_WARN([Missing support for thread-safe error handling in GNUTLS.  Please check that you have the most recent version installed (2.0 or later chould be fine).])
    fi
    AC_CHECK_FUNCS(gnutls_x509_privkey_import2)
  fi
else
  AC_MSG_WARN([Disabled support for TLS funtionality.])
  HAVE_GNUTLS=0
fi
if test $HAVE_GNUTLS = 1; then
  AC_DEFINE_UNQUOTED(HAVE_GNUTLS,$HAVE_GNUTLS,[Define if libgnutls available])
fi
AC_SUBST(HAVE_GNUTLS)

#--------------------------------------------------------------------
# Check for NSNetServices
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------
HAVE_MDNS=0
HAVE_AVAHI=0
AC_ARG_ENABLE(zeroconf,
  [  --disable-zeroconf		Disable NSNetServices support],,
  enable_zeroconf=yes)
AC_ARG_WITH(zeroconf-api,
  [  --with-zeroconf-api=API  force use of a specific zeroconf API (mdns or avahi)],
  zeroconf_api="$withval", zeroconf_api="any")
if test $enable_zeroconf = yes; then
  if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "mdns"; then
    AC_CHECK_HEADERS(dns_sd.h, have_mdns=yes, have_mdns=no)
    if test "$have_mdns" = "yes"; then
      AC_CHECK_LIB(dns_sd, DNSServiceBrowse, have_mdns=yes, have_mdns=no)
      if test "$have_mdns" = "yes"; then
        MDNS_LIBS="-ldns_sd"
        HAVE_MDNS=1
      fi
    fi
  fi
  if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "avahi"; then
    AC_CHECK_HEADERS(avahi-client/client.h, have_avahi=yes, have_avahi=no)
    if test "$have_avahi" = "yes"; then
      AC_CHECK_LIB(avahi-client, avahi_client_new, have_avahi=yes, have_avahi=no)
      if test "$have_avahi" = "yes"; then
        AVAHI_LIBS="-lavahi-common -lavahi-client"
        HAVE_AVAHI=1
      fi
    fi
  fi
  # If we have both APIs, prefer Avahi, because the mDNS API
  # is most certainly the compatability one
  if test "$have_avahi" = "yes" && test "$have_mdns" = "yes"; then
    LIBS="$AVAHI_LIBS $LIBS"
    HAVE_MDNS=0
  else
    # One of those will be empty.
    LIBS="$AVAHI_LIBS $MDNS_LIBS $LIBS"
  fi
fi
AC_SUBST(HAVE_MDNS)
AC_SUBST(HAVE_AVAHI)

#--------------------------------------------------------------------
# Check for International Components for Unicode
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------
HAVE_ICU=0
AC_ARG_ENABLE(icu,
  [  --disable-icu			Disable International Components for Unicode],,
  enable_icu=yes)

AS_IF([test "x$enable_icu" = "xyes"], [
  case "$target_os" in
    mingw*|windows)
      # check for ICU bundled with Windows 10
      old_LIBS="$LIBS"
      LIBS="-licu $LIBS"
      AC_CHECK_HEADERS([icu.h],
        AC_RUN_IFELSE([AC_LANG_SOURCE([
          #include <icu.h>
          int main () {
            return udat_countAvailable() > 0 ? 0 : 1;
          }])], HAVE_ICU=1))
      LIBS="$old_LIBS"
      if test $HAVE_ICU = 1; then
        ICU_LIBS=-licu
        AC_MSG_NOTICE([Using system-provided ICU DLL (requires Windows 10 version 1903 or later)])
      fi
    ;;
  esac
  if test $HAVE_ICU = 0; then
    PKG_CHECK_MODULES([ICU], [icu-i18n > 49.0], [
      AC_CHECK_HEADERS([unicode/uloc.h unicode/ulocdata.h unicode/ucol.h unicode/ucurr.h unicode/uregex.h unicode/ucal.h unicode/unorm2.h unicode/unum.h unicode/udat.h unicode/udatpg.h unicode/ustring.h unicode/usearch.h unicode/ucnv.h unicode/utext.h unicode/ubrk.h unicode/utypes.h],
        HAVE_ICU=1)], [HAVE_ICU=0])
  fi
  if test $HAVE_ICU = 0; then
    AC_MSG_ERROR([No useable ICU installation found])
  fi
  LIBS="$LIBS $ICU_LIBS"
])
AC_SUBST(HAVE_ICU)

#--------------------------------------------------------------------
# Check for libdispatch
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------

HAVE_LIBDISPATCH=0
AC_ARG_ENABLE(libdispatch,
  [  --disable-libdispatch		Disable dispatching blocks via libdispatch],
  enable_libdispatch=$enableval,
  enable_libdispatch=yes)

if test $enable_libdispatch = yes; then
  AC_ARG_WITH(dispatch-include,
  [  --with-dispatch-include=PATH       Include path for dispatch header],
      dispatch_incdir="$withval", dispatch_incdir="no")
  if test ${dispatch_incdir} != "no"; then
      CPPFLAGS="$CPPFLAGS -I${dispatch_incdir}"
      INCLUDE_FLAGS="$INCLUDE_FLAGS -I${dispatch_incdir}"
  fi

  AC_ARG_WITH(dispatch-library,
  [  --with-dispatch-library=PATH       Library path for dispatch lib],
      dispatch_libdir="$withval", dispatch_libdir="no")
  if test ${dispatch_libdir} != "no"; then
    GS_ADD_LIBRARY_PATH([${dispatch_libdir}])
  fi

  AC_CHECK_HEADERS(dispatch/dispatch.h, have_dispatch=yes, have_dispatch=no)
  if test "$have_dispatch" = "yes"; then
    # check for private header which includes runloop integration functions in
    # the Swift corelibs libdispatch release
    AC_CHECK_HEADERS(dispatch/private.h)
  else
    AC_CHECK_HEADERS(dispatch.h, have_dispatch=yes, have_dispatch=no)
  fi
  if test "$have_dispatch" = "yes"; then
    AC_CHECK_LIB(dispatch, dispatch_queue_create, have_dispatch=yes, have_dispatch=no)
    if test "$have_dispatch" = "yes"; then
      saveLIBS="$LIBS"
      LIBS="-lobjc -ldispatch";
      # This check is needed because libdispatch might be linked against a
      # version of libBlocksRuntime that defines symbols conflicting with libobjc
      AC_MSG_CHECKING(whether we can link libdispatch and libobjc at the same time)
      AC_LINK_IFELSE(
	[AC_LANG_PROGRAM(,)],
	[have_dispatch=yes],
	[have_dispatch=no])
      if test "$have_dispatch" = "yes"; then
	LIBS="$saveLIBS -ldispatch";
	AC_MSG_RESULT(yes);
	HAVE_LIBDISPATCH=1;
      else
	LIBS="$saveLIBS";
	AC_MSG_RESULT(no);
      fi
    fi
  else
    HAVE_LIBDISPATCH=0;
    # just ignore libdispatch if it's not there
  fi
fi
AC_SUBST(HAVE_LIBDISPATCH)

HAVE_LIBDISPATCH_RUNLOOP=0
if test $HAVE_LIBDISPATCH = 1; then
  # We check whether we have a variant of libdispatch that allows runloop
  # integration
  AC_CHECK_FUNCS(dispatch_main_queue_drain_np dispatch_get_main_queue_handle_np)
  if test "$ac_cv_func_dispatch_main_queue_drain_np" = "yes" && test "$ac_cv_func_dispatch_get_main_queue_handle_np" = "yes"; then
    HAVE_LIBDISPATCH_RUNLOOP=1
  fi
  # Check for "_4CF" variants of runloop integration functions provided by the
  # Swift corelibs libdispatch release
  AC_CHECK_FUNCS(_dispatch_main_queue_callback_4CF _dispatch_get_main_queue_handle_4CF)
  if test "$ac_cv_func__dispatch_main_queue_callback_4CF" = "yes" && test "$ac_cv_func__dispatch_get_main_queue_handle_4CF" = "yes"; then
    HAVE_LIBDISPATCH_RUNLOOP=1
  fi
  # Check for availability of functions in more recent libdispatch versions.
  AC_CHECK_FUNCS(dispatch_cancel)
fi
AC_SUBST(HAVE_LIBDISPATCH_RUNLOOP)


#--------------------------------------------------------------------
# Check for whether the new KVO implementation is enabled (only with
# the NG runtime)
#--------------------------------------------------------------------
HAVE_NEWKVO=0
AC_ARG_ENABLE(newkvo,
  [  --disable-newkvo		Disable new KVO implementation],,[
if test "$OBJC_RUNTIME_LIB" = "ng"; then
  enable_newkvo=yes
else
  enable_newkvo=no
fi])
if test "x$enable_newkvo" = "xyes"
then
  if test "$OBJC_RUNTIME_LIB" = "ng"; then
    HAVE_NEWKVO=1
  else
    echo "You are not using the new runtime ... newkvo not available"
  fi
fi
AC_SUBST(HAVE_NEWKVO)

#--------------------------------------------------------------------
# Check for libcurl
# See DEPENDENCIES POLICY at the start of this file.
#--------------------------------------------------------------------
CURL_CONFIG="curl-config"
AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl=<DIR>],
  [use curl installed in directory <DIR>]))
if test "$with_curl" != ""; then
  CURL_CONFIG="$with_curl/bin/curl-config"
fi

HAVE_LIBCURL=0
SKIP_CURL_CONFIG=0
curl_all=no
AC_MSG_CHECKING([for libcurl])

case "$target_os" in
    windows)	SKIP_CURL_CONFIG=1;;
esac

# When compiling libs-base in an MSYS2 environment on Windows MSVC, compilation may fail:
# Curl is preinstalled on MSYS2 and bundles the curl-config script. The MSYS2 curl library
# and a different (MSVC) curl library might interfere and produce an incorrect configuration.
#
# Skip the curl-config check on Windows.
if eval $CURL_CONFIG --version 2>/dev/null >/dev/null && test "$SKIP_CURL_CONFIG" == "0"; then
  curl_ver=`$CURL_CONFIG --version | sed -e "s/libcurl //g"`
  curl_maj=`echo $curl_ver | sed -e "s/^\(.*\)\.\(.*\)\.\(.*\)$/\1/"`
  curl_min=`echo $curl_ver | sed -e "s/^\(.*\)\.\(.*\)\.\(.*\)$/\2/"`
  if test $curl_maj -lt 7 -o \( $curl_maj -eq 7 -a $curl_min -lt 66 \); then
    AC_MSG_RESULT([FAILED (version too old to use])
  else
    AC_MSG_RESULT(yes ... version $curl_ver)
    AC_CHECK_HEADERS(curl/curl.h, curl_ok=yes, curl_ok=no)
    if test "$curl_ok" = yes; then
      HAVE_LIBCURL=1
      CURLCFLAGS=`$CURL_CONFIG --cflags`
      CURLLIBS=`$CURL_CONFIG --libs`
      CFLAGS="$CFLAGS $CURLCFLAGS"
      LIBS="$LIBS $CURLLIBS"
      curl_all=yes
    fi
  fi
else
  if test -n "$PKG_CONFIG"; then
    if $PKG_CONFIG --exists libcurl; then
      AC_MSG_RESULT(yes ... via pkg-config)
      if $PKG_CONFIG --atleast-version 2.66.0 libcurl; then
        AC_CHECK_HEADERS(curl/curl.h, curl_ok=yes, curl_ok=no)
        if test "$curl_ok" = yes; then
          HAVE_LIBCURL=1
          CURLCFLAGS=`$PKG_CONFIG --cflags libcurl`
          CURLLIBS=`$PKG_CONFIG --libs libcurl`
          CFLAGS="$CFLAGS $CURLCFLAGS"
          LIBS="$LIBS $CURLLIBS"
          curl_all=yes
        fi
        else
          AC_MSG_RESULT([FAILED (version too old to use])
          curl_all=no
      fi
    else
      AC_MSG_RESULT([FAILED (libcurl not found via pkg-config)])
      curl_all=no
    fi
  else
    AC_MSG_RESULT([FAILED (curl-config and pkg-config not found)])
  fi
fi
  
if test "$OBJC_RUNTIME_LIB" = "ng" -a "$HAVE_LIBCURL" = 0; then
AC_MSG_ERROR([libcurl is a hard-dependency when building with the Objective-C 2.0 toolchain])
fi

AC_SUBST(HAVE_LIBCURL)

#--------------------------------------------------------------------
# Check dependencies of NSURLSession API
#--------------------------------------------------------------------
nsurlsessiondefault=no
if test "$OBJC_RUNTIME_LIB" = "ng" -a $HAVE_BLOCKS = 1 -a $HAVE_LIBDISPATCH = 1 -a $HAVE_LIBCURL = 1; then
  nsurlsessiondefault=yes
fi

GS_HAVE_NSURLSESSION=0
AC_ARG_ENABLE(nsurlsession,
  [  --disable-nsurlsession  		Disable support for NSURLSession],,
  enable_nsurlsession=$nsurlsessiondefault)
if test $enable_nsurlsession = yes; then
  if test "$OBJC_RUNTIME_LIB" != "ng"; then
    AC_MSG_ERROR([Missing ng runtime (needed for NSURLSession). To build without NSURLSession support, please run configure again with the --disable-nsurlsession option.])
  fi
  if test $HAVE_BLOCKS = 0; then
    AC_MSG_ERROR([Missing blocks support (needed for NSURLSession).  To build without NSURLSession support, please run configure again with the --disable-nsurlsession option.])
  fi
  if test $HAVE_LIBDISPATCH = 0; then
    AC_MSG_ERROR([Missing libdispatch (needed for NSURLSession).  To build without NSURLSession support, please run configure again with the --disable-nsurlsession option.])
   fi
  # Check for dispatch_queue_create_with_target needed for NSURLSession
  AC_CHECK_FUNCS(dispatch_queue_create_with_target)
  if test $HAVE_LIBCURL = 0; then
    AC_MSG_ERROR([Missing libcurl (needed for NSURLSession). To build without NSURLSession support, please run configure again with the --disable-nsurlsession option.])
  fi
  GS_HAVE_NSURLSESSION=1
fi
AC_SUBST(GS_HAVE_NSURLSESSION)

#--------------------------------------------------------------------
# Check GMP for NSDecimal
#--------------------------------------------------------------------
AC_ARG_WITH(gmp-include,
  [  --with-gmp-include=PATH  include path for gmp headers],
  gmp_incdir="$withval", gmp_incdir="no")

AC_ARG_WITH(gmp-library,
  [  --with-gmp-library=PATH  library path for gmp libraries],
  gmp_libdir="$withval", gmp_libdir="no")

libs_temp=$LIBS

if test "$gmp_incdir" != "no"; then
  CPPFLAGS="$CPPFLAGS -I$gmp_incdir"
  INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gmp_incdir"
fi
if test "$gmp_libdir" != "no"; then
  GS_ADD_LIBRARY_PATH([${gmp_libdir}])
fi

USE_GMP=0
AC_CHECK_HEADERS(gmp.h)
if test $ac_cv_header_gmp_h = yes; then
  AC_CHECK_LIB(gmp, mpf_abs, gmp_ok=yes, gmp_ok=no)
  if test "$gmp_ok" = no; then
    AC_CHECK_LIB(gmp, __gmpf_abs, gmp_ok=yes, gmp_ok=no)
  fi
  if test "$gmp_ok" = yes; then
    LIBS="-lgmp $LIBS"
    USE_GMP=1
  fi
fi

AC_SUBST(USE_GMP)

#--------------------------------------------------------------------
# Check dor 'dot', needed for graphs in autogsdoc output.
#--------------------------------------------------------------------
AC_ARG_VAR([DOT], [The name or full path of the graphviz dot command.])

AC_PATH_PROG([DOT], [dot], [])
AC_SUBST(HAVE_DOT, [$ac_cv_path_DOT])

#--------------------------------------------------------------------
# Check whether nl_langinfo(CODESET) is supported, needed by Unicode.m.
#--------------------------------------------------------------------
AM_LANGINFO_CODESET


AC_SUBST(INCLUDE_FLAGS)
AC_SUBST(LDIR_FLAGS)

#--------------------------------------------------------------------
# Check for -Wdeclaration-after-statement
#--------------------------------------------------------------------
AC_MSG_CHECKING(whether the compiler supports -Wdeclaration-after-statement)

saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],HAS_W_DECL_AFTER_STATEMENT=yes,HAS_W_DECL_AFTER_STATEMENT=no)
CFLAGS="$saved_CFLAGS"

AC_MSG_RESULT($HAS_W_DECL_AFTER_STATEMENT)

if test x"$HAS_W_DECL_AFTER_STATEMENT" = x"yes"; then
  WARN_FLAGS="-Wall -Wdeclaration-after-statement"
else
  WARN_FLAGS=-Wall
fi

AC_SUBST(WARN_FLAGS)

#--------------------------------------------------------------------
# Check if we should use an alternative gdomap port
#--------------------------------------------------------------------
AC_ARG_WITH(gdomap-port,
  [  --with-gdomap-port=PORT  alternative port for gdomap],
  gdomap_port="$withval", gdomap_port="no")

if test "$gdomap_port" = "no"; then
  GNUSTEP_GDOMAP_PORT_OVERRIDE="$gdomap_port"
else
  GNUSTEP_GDOMAP_PORT_OVERRIDE="$gdomap_port"
fi
AC_SUBST(GNUSTEP_GDOMAP_PORT_OVERRIDE)

#--------------------------------------------------------------------
# Check if we should install gdomap as setuid
#--------------------------------------------------------------------
AC_MSG_CHECKING([if we should install gdomap as setuid])
AC_ARG_ENABLE(setuid-gdomap,[
  --enable-setuid-gdomap        Enable installing gdomap as a setuid
                                executable.  By default, it is installed
                                as a normal program intended to be started
				by root at system boot time, but it can
                                also be started up automatically
                                by any user at any time.  Use this
                                option if you are happy having the program
                                started automatically on demand.
],
  ac_cv_setuid_gdomap=$enableval,
  ac_cv_setuid_gdomap="no")

if test "$ac_cv_setuid_gdomap" = "yes"; then
  AC_MSG_RESULT(yes);
  GNUSTEP_INSTALL_GDOMAP_AS_SETUID="yes"
else
  AC_MSG_RESULT(no);
  GNUSTEP_INSTALL_GDOMAP_AS_SETUID="no"
fi

AC_SUBST(GNUSTEP_INSTALL_GDOMAP_AS_SETUID)

#--------------------------------------------------------------------
# Record the version
#--------------------------------------------------------------------
AC_MSG_CHECKING(for the version of gnustep-base we are compiling)
if test -f "Version"; then
  . ./Version
fi
AC_MSG_RESULT($VERSION)
AC_SUBST(VERSION)
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(SUBMINOR_VERSION)
AC_SUBST(GCC_VERSION)

#--------------------------------------------------------------------
# Write the Makefiles
#--------------------------------------------------------------------
AC_CONFIG_FILES([config.mak base.make Source/gnustep-base.pc Headers/GNUstepBase/GSConfig.h])
AC_OUTPUT