summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/src/Configure
blob: d4345035318746aa6c6a1cb7d1440903c71b7e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
#!/bin/sh
# $OpenBSD: Configure,v 1.23 2003/11/17 18:57:05 henning Exp $
## ====================================================================
## The Apache Software License, Version 1.1
##
## Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
## reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
##
## 1. Redistributions of source code must retain the above copyright
##    notice, this list of conditions and the following disclaimer.
##
## 2. Redistributions in binary form must reproduce the above copyright
##    notice, this list of conditions and the following disclaimer in
##    the documentation and/or other materials provided with the
##    distribution.
##
## 3. The end-user documentation included with the redistribution,
##    if any, must include the following acknowledgment:
##       "This product includes software developed by the
##        Apache Software Foundation (http://www.apache.org/)."
##    Alternately, this acknowledgment may appear in the software itself,
##    if and wherever such third-party acknowledgments normally appear.
##
## 4. The names "Apache" and "Apache Software Foundation" must
##    not be used to endorse or promote products derived from this
##    software without prior written permission. For written
##    permission, please contact apache@apache.org.
##
## 5. Products derived from this software may not be called "Apache",
##    nor may "Apache" appear in their name, without prior written
##    permission of the Apache Software Foundation.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
## OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
## DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
## ====================================================================
##
## This software consists of voluntary contributions made by many
## individuals on behalf of the Apache Software Foundation.  For more
## information on the Apache Software Foundation, please see
## <http://www.apache.org/>.
##
## Portions of this software are based upon public domain software
## originally written at the National Center for Supercomputing Applications,
## University of Illinois, Urbana-Champaign.
##



# Uses 6 supplemental scripts located in ./helpers:
#	CutRule: Determines the value for a specified Rule
#	GuessOS: Uses uname to determine OS/platform
#	PrintPath: generic "type" or "whence" replacement
#	TestCompile: Can check for libs and if $(CC) is ANSI
#	 (i.e., a simple "sanity check")
#	mfhead:
#	fp2rp:
#	slo.sh:

LANG=C; export LANG
exitcode=0
trap 'rm -f $tmpfile $tmpfile2 $tmpfile3 $tmpconfig $awkfile; exit $exitcode' 0 1 2 3 15

####################################################################
## Set up some defaults
##
file=Configuration
tmpfile=htconf.$$
tmpfile2=$tmpfile.2
tmpfile3=$tmpfile.3
awkfile=$tmpfile.4
tmpconfig=$tmpfile.5
SUBDIRS="ap main"
APLIBDIRS=""
SHELL=/bin/sh

####################################################################
## Now handle any arguments, which, for now, is -file
## to select an alternate Configuration file and -v
## to turn on verbose mode
##
while [ "x$1" != "x" ]; do
  if [ "x$1" = "x-v" ] ; then
    shift 1;
    vflag="-v";
  fi
  if [ "x$1" = "x-file" ] ; then
    shift 1; file=$1; shift 1
    if [ ! -r $file ]; then
      echo "$file does not exist or is not readable."
      exitcode=1
      exit 1
    fi
  else
    echo "ERROR: Bad command line option '$1'"
    echo "  Please read the file INSTALL."
    exit 1
  fi
done
if [ ! -r $file ]; then
  echo "Can't see or read \"$file\""
  echo "Please copy Configuration.tmpl to $file, edit it for your platform,"
  echo "and re-run $0 again."
  exitcode=1
  exit 1
fi

####################################################################
## Now see if Configuration.tmpl is more recent than $file. If
## so, then we complain and bail out
##
if ls -lt $file Configuration.tmpl | head -1 | \
  grep 'Configuration.tmpl' > /dev/null
then
  echo "Configuration.tmpl is more recent than $file;"
  echo "Make sure that $file is valid and, if it is, simply"
  echo "'touch $file' and re-run $0 again."
  exitcode=1
  exit 1
fi

echo "Using config file: $file"

####################################################################
## From the Configuration file, create a "cleaned-up" version
## that's easy to scan
##

# Strip comments and blank lines, remove whitespace around
# "=" assignments, change Rules to comments and then remove whitespace
# before Module declarations
sed 's/#.*//' $file | \
 sed '/^[ 	]*$/d' | \
 sed 's/[ 	]*$//' | \
 sed 's/[ 	]*=[ 	]*/=/' | \
 sed '/^Rule[ 	]*/d' | \
 sed 's/^[ 	]*AddModule/AddModule/' | \
 sed 's/^[ 	]*%AddModule/%AddModule/' | \
 sed 's/^[ 	]*SharedModule/SharedModule/' | \
 sed 's/^[ 	]*Module/Module/' | \
 sed 's/^[ 	]*%Module/%Module/' > $tmpfile

# Determine if shared objects are used
using_shlib=`grep  '^SharedModule' $tmpfile >/dev/null && echo 1`

# But perhaps later via apxs when just mod_so is compiled in!
if [ "x$using_shlib" = "x" ]; then
    using_shlib=`grep  '^AddModule modules/standard/mod_so.o' $tmpfile >/dev/null && echo 1`
fi

# Only "assignment" ("=") statements and Module lines
# should be left at this point. If there is other stuff
# we bail out
if egrep -v '^%?Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile \
 | egrep -v '^%?AddModule[ 	]+[^ 	]+$' \
 | egrep -v '^SharedModule[ 	]+[^ 	]+$' \
 | grep -v = > /dev/null
then
  echo "Syntax error --- The configuration file is used only to"
  echo "define the list of included modules or to set Makefile"
  echo "options or Configure rules, and I don't see that at all:"
  egrep -v '^%?Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile \
   | egrep -v '^%?AddModule[ 	]+[^ 	]+$'  \
   | egrep -v '^%?SharedModule[ 	]+[^ 	]+$'  \
   | grep -v =
  exitcode=1
  exit 1
fi

####################################################################
## If we find the directory /usr/local/etc/httpd and there is
## no HTTPD_ROOT flag set in the Configuration file we assume
## that the user was using the old default root directory
## and issue a notice about it.
##
if [ "x$file" != "xConfiguration.apaci" ]
then
  if [ -d /usr/local/etc/httpd/ ]
  then
    if egrep '^EXTRA_CFLAGS.*HTTPD_ROOT' $file >/dev/null
    then
      :
    else
      echo " | Please note that the default httpd root directory has changed"
      echo " | from '/usr/local/etc/httpd/' to '/usr/local/apache/.'"
      echo " | You may add '-DHTTPD_ROOT=\\\"/usr/local/etc/httpd\\\"' to EXTRA_CFLAGS"
      echo " | in your Configuration file (and re-run Configure) or start"
      echo " | httpd with the option '-d /usr/local/etc/httpd' if you still"
      echo " | want to use the old root directory for your server."
    fi
  fi
fi

####################################################################
## Start creating the Makefile. We add some comments and
## then fold in the modules that were included in Configuration
##
echo "Creating Makefile"
${SHELL} helpers/mfhead . $file > Makefile

####################################################################
## Now we create a stub file, called Makefile.config, which
## just includes those assignments (eg: CC=gcc) in Configuration
##
awk >Makefile.config <$tmpfile '
    BEGIN {
	print "##"
	print "##  Inherited Makefile options from Configure script"
	print "##  (Begin of automatically generated section)"
	print "##"
	print "SRCDIR=."
    } 
    /\=/ { print } 
    '

####################################################################
## Extract the rules.
##
RULE_WANTHSREGEX=`${SHELL} helpers/CutRule WANTHSREGEX $file`
RULE_STATUS=`${SHELL} helpers/CutRule STATUS $file`
RULE_SOCKS4=`${SHELL} helpers/CutRule SOCKS4 $file`
RULE_SOCKS5=`${SHELL} helpers/CutRule SOCKS5 $file`
RULE_IRIXNIS=`${SHELL} helpers/CutRule IRIXNIS $file`
RULE_IRIXN32=`${SHELL} helpers/CutRule IRIXN32 $file`
RULE_PARANOID=`${SHELL} helpers/CutRule PARANOID $file`
RULE_EXPAT=`${SHELL} helpers/CutRule EXPAT $file`
RULE_CYGWIN_WINSOCK=`${SHELL} helpers/CutRule CYGWIN_WINSOCK $file` 
RULE_SHARED_CORE=`${SHELL} helpers/CutRule SHARED_CORE $file`
RULE_SHARED_CHAIN=`${SHELL} helpers/CutRule SHARED_CHAIN $file`

####################################################################
## Rule SHARED_CORE implies required DSO support
##
if [ "x$RULE_SHARED_CORE" = "xyes" ]; then
	using_shlib=1
fi

####################################################################
## Preset some "constants";
## can be overridden on a per-platform basis below.
##
DBM_LIB="-ldbm"
DB_LIB="-ldb"
SHELL="/bin/sh"
SUBTARGET="target_static"
SHLIB_SUFFIX_NAME=""
SHLIB_SUFFIX_LIST=""
CAT="cat"

####################################################################
## Now we determine the OS/Platform automagically, thanks to
## GuessOS, a home-brewed OS-determiner ala config.guess
##
## We adjust CFLAGS, LIBS, LDFLAGS and INCLUDES (and other Makefile
## options) as required. Setting CC and OPTIM here has no effect
## if they were set in Configure.
##
## Also, we set DEF_WANTHSREGEX and to the appropriate
## value for each platform.
##
## As more PLATFORMs are added to Configuration.tmpl, be sure to
## add the required lines below.
##
SHELL="/bin/sh"
PLAT=`${SHELL} helpers/GuessOS`
OSDIR="os/unix"

case "$PLAT" in
    *mint)
	OS="MiNT"
	CFLAGS="-DMINT"
	LIBS="$LIBS -lportlib -lsocket"
	DEF_WANTHSREGEX=yes
	;;
    *MPE/iX*)
	export OS='MPE/iX'
	OSDIR='os/mpeix'
	CFLAGS="$CFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE"
	LIBS="$LIBS -lsocket -lsvipc -lcurses"
	LDFLAGS="$LDFLAGS -Xlinker \"-WL,cap=ia,ba,ph;nmstack=1024000\""
	CAT="/bin/cat" # built-in cat is badly broken for stdin redirection
	;;
    *-apple-aux3*)
	OS='A/UX 3.1.x'
	CFLAGS="$CFLAGS -DAUX3 -D_POSIX_SOURCE"
	LIBS="$LIBS -lposix -lbsd"
	LDFLAGS="$LDFLAGS -s"
	DEF_WANTHSREGEX=no
	;;
    i386-ibm-aix*)
	OS='IBM AIX PS/2'
	CFLAGS="$CFLAGS -DAIX=100 -U__STR__ -DUSEBCOPY"
	DEF_WANTHSREGEX=no
	;;
    ia64-ibm-aix*)
       OS='IBM AIX IA64'
       CFLAGS="$CFLAGS -DAIXIA64 -U__STR__"
       LDFLAGS="$LDFLAGS -lm"
       RULE_SHARED_CORE=no
       DEF_SHARED_CORE=no
       ;;
    *-ibm-aix[1-2].*)
	OS='IBM AIX 1.x/2.x'
	CFLAGS="$CFLAGS -DAIX=100 -DNEED_RLIM_T -U__STR__"
	;;
    *-ibm-aix3.*)
	OS='IBM AIX 3.x'
	CFLAGS="$CFLAGS -DAIX=300 -DNEED_RLIM_T -U__STR__"
	;;
    *-ibm-aix[45678].*)
        PLATOSVERS=`echo $PLAT | sed 's/^.*ibm-aix//'`
        OS="AIX $PLATOSVERS"
        PLATOSVERSNUM=`echo $PLATOSVERS | sed 's/\.//'`
        if test $PLATOSVERSNUM -ge 43; then
            PLATOSVERSNUM=`oslevel | sed 's/\.//g' | sed 's/.$//'`
        else
            PLATOSVERSNUM="$PLATOSVERSNUM"0
        fi
        # PLATOSVERSNUM is a three digit number at this point
        CFLAGS="$CFLAGS -DAIX=$PLATOSVERSNUM -U__STR__"
        if test $PLATOSVERSNUM -lt 420; then
            CFLAGS="$CFLAGS -DNEED_RLIM_T"
        fi
        if test $PLATOSVERSNUM -ge 420; then
            LDFLAGS="$LDFLAGS -lm"
        fi
        if test $PLATOSVERSNUM -ge 430; then
            LDFLAGS="$LDFLAGS -lpthread"
            RULE_SHARED_CORE=no
            DEF_SHARED_CORE=no
        fi
        ;;
    *-ibm-aix*)
	OS='IBM AIX'
	CFLAGS="$CFLAGS -DAIX=100 -U__STR__"
	LDFLAGS="$LDFLAGS -lm"
	;;
    *-apollo-*)
	OS='Apollo Domain'
	CFLAGS="$CFLAGS -DAPOLLO"
	;;
    *-dg-dgux*)
	OS='DG/UX 5.4'
	CFLAGS="$CFLAGS -DDGUX"
	DEF_WANTHSREGEX=yes
	;;
    *OS/2*)
	OSDIR="os/os2"
	DEF_WANTHSREGEX=yes
	OS='EMX OS/2'
	CFLAGS="$CFLAGS -DOS2 -DTCPIPV4 -g -Zmt"
	LDFLAGS="$LDFLAGS -Zexe -Zmtd -Zsysv-signals -Zbin-files"
	LIBS="$LIBS -lsocket -lufc -lbsd"
	DBM_LIB="-lgdbm"
	SHELL=sh
	;;
    *-hi-hiux)
	OS='HI-UX'
	CFLAGS="$CFLAGS -DHIUX"
	;;
    *-hp*-hpux11.*)
	OS='HP-UX 11'
	CFLAGS="$CFLAGS -DHPUX11"
	RANLIB="/bin/true"
	LIBS="$LIBS -lm -lpthread"
	DEF_WANTHSREGEX=yes
	;;
    *-hp*-hpux10.*)
	OS='HP-UX 10'
	CFLAGS="$CFLAGS -DHPUX10"
	RANLIB="/bin/true"
 	case "$PLAT" in
 	  *-hp-hpux10.01)
	       # We know this is a problem in 10.01.
	       # Not a problem in 10.20.  Otherwise, who knows?
	       CFLAGS="$CFLAGS -DSELECT_NEEDS_CAST"
	       ;;	     
 	esac
	DEF_WANTHSREGEX=yes
	;;
    *-hp*-hpux*)
	OS='HP-UX'
	CFLAGS="$CFLAGS -DHPUX"
	RANLIB="/bin/true"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lm"
	;;
    *-sgi-irix64)
	# Note: We'd like to see patches to compile 64-bit, but for now...
	echo "You are running 64-bit Irix. For now, we will compile 32-bit"
	echo "but if you would care to port to 64-bit, send us the patches."
	DEF_WANTHSREGEX=yes
	DBM_LIB=""
	if [ "x$RULE_IRIXNIS" = "xyes" ]; then
	    OS='SGI IRIX-64 w/NIS'
	    CFLAGS="$CFLAGS -DIRIX"
	    LIBS="$LIBS -lsun"
	else
	    OS='SGI IRIX-64'
	    CFLAGS="$CFLAGS -DIRIX"
	fi
	;;
    *-sgi-irix32)
	DEF_WANTHSREGEX=yes
	DBM_LIB=""
	if [ "x$RULE_IRIXN32" = "xyes" ]; then
	    if [ "x$RULE_IRIXNIS" = "xyes" ]; then
		OS='SGI IRIX-32 w/NIS'
	    else
		OS='SGI IRIX-32'
	    fi
	else
	    if [ "x$RULE_IRIXNIS" = "xyes" ]; then
		OS='SGI IRIX w/NIS'
	    else
		OS='SGI IRIX'
	    fi
	fi
	CC='cc'
	CFLAGS="$CFLAGS -DIRIX"
	;;
    *-sgi-irix)
	DEF_WANTHSREGEX=yes
	DBM_LIB=""
	if [ "x$RULE_IRIXNIS" = "xyes" ]; then
	    OS='SGI IRIX w/NIS'
	    CFLAGS="$CFLAGS -DIRIX"
	    LIBS="$LIBS -lsun"
	else
	    OS='SGI IRIX'
	    CFLAGS="$CFLAGS -DIRIX"
	fi
	;;
    *-linux20)
	DEF_WANTHSREGEX=yes
	OS='Linux'
	CFLAGS="$CFLAGS -DLINUX=20"
	LIBS="$LIBS -lm"
	;;
    *-linux22)
        # This handles linux 2.2 and above (2.4, ...)
	DEF_WANTHSREGEX=yes
	OS='Linux'
	CFLAGS="$CFLAGS -DLINUX=22"
	LIBS="$LIBS -lm"
	;;
    *-GNU*)
	DEF_WANTHSREGEX=yes
	OS='GNU/Hurd'
	CFLAGS="$CFLAGS -DHURD"
	LIBS="$LIBS -lm -lcrypt"
	;;
    *-linux1)
	DEF_WANTHSREGEX=yes
	OS='Linux'
	CFLAGS="$CFLAGS -DLINUX=1"
	;;
    *-lynx-lynxos)
	OS='LynxOS 2.x'
	CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__ -DLYNXOS"
	LIBS="$LIBS -lbsd -lcrypt"
	DEF_WANTHSREGEX=yes
	;;
    *486-*-bsdi*)
	OS='BSDI w/486'
	CFLAGS="$CFLAGS -m486"
	DBM_LIB=""
	DB_LIB=""
	;;
    *-bsdi3)
        if [ "x$using_shlib" = "x1" ] ; then
            CC="shlicc2"
        fi
        ;;
    *-bsdi*)
	OS='BSDI'
	DBM_LIB=""
	DB_LIB=""
	;;
    *-netbsd*)
	OS='NetBSD'
	CFLAGS="$CFLAGS -DNETBSD"
	LIBS="$LIBS -lcrypt"
	DBM_LIB=""
	DB_LIB=""
	DEF_WANTHSREGEX=no
	;;
    *-freebsd*)
    	PLATOSVERS=`echo $PLAT | sed 's/^.*freebsd//'`
	OS="FreeBSD $PLATOSVERS"
	case "$PLATOSVERS" in
	    [2345]*)
		DEF_WANTHSREGEX=no
		CFLAGS="$CFLAGS -funsigned-char"
		;;
	esac
	LIBS="$LIBS -lcrypt"
	DBM_LIB=""
	DB_LIB=""
	;;
    *-openbsd*)
	OS='OpenBSD'
	DBM_LIB=""
	DB_LIB=""
	DEF_WANTHSREGEX=no
	;;
    *-next-nextstep*)
	OS='NeXTStep'
	OPTIM='-O'
	CFLAGS="$CFLAGS -DNEXT"
	DEF_WANTHSREGEX=yes
	;;
    *-next-openstep*)
	OS='OpenStep/Mach'
	CC='cc'
	OPTIM='-O'
	CFLAGS="$CFLAGS -DNEXT"
	DEF_WANTHSREGEX=yes
	;;
    *-apple-rhapsody*)
	OS='Mac OS X Server'
	CFLAGS="$CFLAGS -DDARWIN -DMAC_OS_X_SERVER"
	DEF_WANTHSREGEX=yes
	;;
    *-apple-darwin*)
	OS='Darwin'
	CFLAGS="$CFLAGS -DDARWIN"
	DEF_WANTHSREGEX=yes
	;;
    *-dec-osf*)
	OS='DEC OSF/1'
	CFLAGS="$CFLAGS -DOSF1"
	LIBS="$LIBS -lm"
	;;
    *-qnx)
	OS='QNX'
	CFLAGS="$CFLAGS -DQNX"
	LIBS="$LIBS -N128k -lsocket -lunix"
	DEF_WANTHSREGEX=yes
	;;
    *-qnx32)
        CC='cc -F'
	OS='QNX32'
	CFLAGS="$CFLAGS -DQNX -mf -3"
	LIBS="$LIBS -N128k -lsocket -lunix"
	DEF_WANTHSREGEX=yes
	;;
    *-isc4*)
	OS='ISC 4'
	CC='gcc'
	CFLAGS="$CFLAGS -posix -DISC"
	LDFLAGS="$LDFLAGS -posix"
	LIBS="$LIBS -linet"
	DEF_WANTHSREGEX=yes
	;;
    *-sco3*)
	OS='SCO 3'
	CFLAGS="$CFLAGS -DSCO -Oacgiltz"
	LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
	DEF_WANTHSREGEX=yes
	;;
    *-sco5*)
	OS='SCO 5'
	CFLAGS="$CFLAGS -DSCO5"
	LIBS="$LIBS -lsocket -lmalloc -lprot -ltinfo -lx -lm"
	DEF_WANTHSREGEX=no
	;;
    *-sco_sv*|*-SCO_SV*)
	OS='SCO SV'
	CFLAGS="$CFLAGS -DSCO"
	LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
	DEF_WANTHSREGEX=yes
	;;
    *-solaris2*)
    	PLATOSVERS=`echo $PLAT | sed 's/^.*solaris2.//'`
	OS="Solaris $PLATOSVERS"
	CFLAGS="$CFLAGS -DSOLARIS2=$PLATOSVERS"
	LIBS="$LIBS -lsocket -lnsl -lpthread"
	DBM_LIB=""
	case "$PLATOSVERS" in
	    2[01234]*)
		DEF_WANTHSREGEX=yes
		;;
	    *)
		DEF_WANTHSREGEX=no
		;;
	esac
	;;
    *-sunos4*)
	OS='SunOS 4'
	CFLAGS="$CFLAGS -DSUNOS4 -DUSEBCOPY"
	DEF_WANTHSREGEX=yes
	;;
    *-unixware1)
	DEF_WANTHSREGEX=yes
	OS='UnixWare 1.x'
	CFLAGS="$CFLAGS -DUW=100"
	LIBS="$LIBS -lsocket -lnsl -lcrypt"
	;;
    *-unixware2)
	DEF_WANTHSREGEX=yes
	OS='UnixWare 2.x'
	CFLAGS="$CFLAGS -DUW=200"
	LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
	;;
    *-unixware211)
	OS='UnixWare 2.1.1'
	CFLAGS="$CFLAGS -DUW=211"
	LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
	;;
    *-unixware212)
	OS='UnixWare 2.1.2'
	CFLAGS="$CFLAGS -DUW=212"
	LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
	DBM_LIB=""
	;;
    *-unixware7)
	OS='UnixWare 7'
	CFLAGS="$CFLAGS -DUW=700"
	LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen -lresolv"
	DBM_LIB=""
	;;
    *-OpenUNIX)
	OS='OpenUNIX'
	CFLAGS="$CFLAGS -DUW=800"
	LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen -lresolv"
	DBM_LIB=""
	;;
    maxion-*-sysv4*)
    	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lc -lgen"
	;;
    *-*-powermax*)
	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lgen"
	LD_SHLIB='cc'
	LDFLAGS_SHLIB="-Zlink=so"
	LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
	CFLAGS_SHLIB='-Zpic'
	;;
    TPF)
       OS='TPF'
       OSDIR='os/tpf'
       CC='c89'
       CFLAGS="$CFLAGS -DTPF -DCHARSET_EBCDIC -D_POSIX_SOURCE"
       DEF_WANTHSREGEX=yes
       LIBS="$LIBS"
       SUBTARGET="target_compile_only"
       ;;
    BS2000*-siemens-sysv4*)
	OS='BS2000'
	OSDIR='os/bs2000'
	# If you are using a CPP before V3.0, delete the -Kno_integer_overflow flag
	CC='c89 -XLLML -XLLMK -XL -Kno_integer_overflow'
	CFLAGS="$CFLAGS -DCHARSET_EBCDIC -DSVR4 -D_XPG_IV"
	DEF_WANTHSREGEX=yes
	DBM_LIB=""
	;;
    *-siemens-sysv4*)
	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DNEED_UNION_SEMUN"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lc"
	DBM_LIB=""
	;;
    pyramid-pyramid-svr4)
	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4 -DNO_LONG_DOUBLE"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    DS/90\ 7000-*-sysv4*)
	OS='UXP/DS'
	CFLAGS="$CFLAGS -DUXPDS"
	LIBS="$LIBS -lsocket -lnsl"
	DEF_WANTHSREGEX=yes
	;;
    *-tandem-sysv4*)
	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4"
	LIBS="$LIBS -lsocket -lnsl"
	DEF_WANTHSREGEX=yes
	;;
    *-ncr-sysv4)
	OS='NCR MP/RAS'
	CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
	LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
	DEF_WANTHSREGEX=yes
	;;
    *-sysv4*)
	OS='SVR4'
	CFLAGS="$CFLAGS -DSVR4"
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    88k-encore-sysv4)
	OS='Encore UMAX V'
	CFLAGS="$CFLAGS -DSVR4 -DENCORE"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lPW"
	;;
    *-uts*)
	PLATOSVERS=`echo $PLAT | sed 's/^.*,//'`
	OS='Amdahl UTS $PLATOSVERS'
	case "$PLATOSVERS" in
	    2*) CFLAGS="$CFLAGS -Xa -eft -DUTS21 -DUSEBCOPY"
	        LIBS="$LIBS -lsocket -lbsd -la"
	        DEF_WANTHSREGEX=yes
	        ;;
	    *)  CFLAGS="$CFLAGS -Xa -DSVR4"
	        LIBS="$LIBS -lsocket -lnsl"
	        ;;
	esac
	;;
    *-ultrix)
	OS='ULTRIX'
	CFLAGS="-DULTRIX"
	DEF_WANTHSREGEX=yes
	SHELL="/bin/sh5"
	;;
    *powerpc-tenon-machten*)
	OS='MachTen PPC'
	LDFLAGS="$LDFLAGS -Xlstack=0x14000 -Xldelcsect"
	;;
    *-machten*)
	OS='MachTen 68K'
	LDFLAGS="$LDFLAGS -stack 0x14000"
	DEF_WANTHSREGEX=yes
	;;
    *convex-v11*)
	OS='CONVEXOS11'
	CFLAGS="$CFLAGS -ext -DCONVEXOS11"
	OPTIM="-O1" # scalar optimization only
	CC='cc'
	DEF_WANTHSREGEX=yes
	;;
    i860-intel-osf1)
	DEF_WANTHSREGEX=yes
	OS='Paragon OSF/1'
	CFLAGS="$CFLAGS -DPARAGON"
	;;
    *-sequent-ptx2.*.*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v2.*.*'
	CFLAGS="$CFLAGS -DSEQUENT=20 -Wc,-pw"
	LIBS="$LIBS -lsocket -linet -lnsl -lc -lseq"
	;;
    *-sequent-ptx4.0.*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v4.0.*'
	CFLAGS="$CFLAGS -DSEQUENT=40 -Wc,-pw"
	LIBS="$LIBS -lsocket -linet -lnsl -lc"
	;;
    *-sequent-ptx4.[123].*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v4.1.*/v4.2.*'
	CFLAGS="$CFLAGS -DSEQUENT=41 -Wc,-pw"
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    *-sequent-ptx4.4.*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v4.4.*'
	CFLAGS="$CFLAGS -DSEQUENT=44 -Wc,-pw"
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    *-sequent-ptx4.5.*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v4.5.*'
	CFLAGS="$CFLAGS -DSEQUENT=45 -Wc,-pw"
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    *-sequent-ptx5.0.*)
	DEF_WANTHSREGEX=yes
	OS='SEQUENT DYNIX/ptx v5.0.*'
	CFLAGS="$CFLAGS -DSEQUENT=50 -Wc,-pw"
	LIBS="$LIBS -lsocket -lnsl -lc"
	;;
    *NEWS-OS*)
	DEF_WANTHSREGEX=yes
	OS='SONY NEWS-OS'
	CFLAGS="$CFLAGS -DNEWSOS"
	;;
    *-riscix)
	OS='Acorn RISCix'
	CFLAGS="$CFLAGS -DRISCIX"
	OPTIM="-O"
	MAKE="make"
	DEF_WANTHSREGEX=yes
	;;
    *-BeOS*)
	PLATOSVER=`uname -r`
        case "$PLATOSVER" in
            5.0.4*)
                OS="BeOS BONE"
                LIBS="-lbind -lsocket -lbe -lroot"
                CFLAGS="$CFLAGS -DBONE"
                ;;
            *)
                OS='BeOS';
	        CFLAGS="$CFLAGS -DBEOS"
                ;;
        esac
	DEF_WANTHSREGEX=yes
	;;
    4850-*.*)
	OS='NCR MP/RAS'
	CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
	;;
    drs6000*)
	OS='DRS6000'
	CFLAGS="$CFLAGS -DSVR4"
	DEF_WANTHSREGEX=yes
	LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
	;;
    m88k-*-CX/SX|CYBER)
	OS='Cyberguard CX/SX'
	CFLAGS="$CFLAGS -D_CX_SX -Xa"
	DEF_WANTHSREGEX=yes
	CC='cc'
	RANLIB='true'
	;;
    *-tandem-oss)
	OS='Tandem OSS'
	CFLAGS="-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
	CC='c89'
	;;
    *-IBM-OS390*)
       OS='OS390'
       OSDIR='os/os390'
       CC='c89'
       CFLAGS="$CFLAGS -DOS390 -DCHARSET_EBCDIC -D_ALL_SOURCE"
       DEF_WANTHSREGEX=yes
       LIBS="$LIBS"
       ;;
    *-cygwin*)
	OS='Cygwin'
	OSDIR="os/cygwin"
	CFLAGS="$CFLAGS -DCYGWIN"
	DEF_WANTHSREGEX=yes
	DBM_LIB="-lgdbm"
	LIBS="$LIBS -lcrypt $DBM_LIB"
	if [ "x$RULE_CYGWIN_WINSOCK" = "xyes" ]; then 
	    CFLAGS="$CFLAGS -DCYGWIN_WINSOCK" 
	    LIBS="$LIBS -lwsock32" 
	fi 

	;;
    *atheos*)
	DEF_WANTSREGEX=yes
	OS='AtheOS'
	CFLAGS="$CFLAGS -DATHEOS"
	LIBS="$LIBS -lcrypt"
	;;
    *) # default: Catch systems we don't know about
	OS='Unknown and unsupported OS'
    	echo Sorry, but we cannot grok \"$PLAT\"
	echo uname -m
	uname -m
	echo uname -r
	uname -r
	echo uname -s
	uname -s
	echo uname -v
	uname -v
	echo uname -X
	uname -X
	echo Ideally, read the file PORTING, do what it says, and send the
	echo resulting patches to The Apache Group by filling out a report
	echo form at http://bugs.apache.org/.  If you don\'t 
	echo wish to do the port yourself, please submit this output rather 
	echo than the patches. Thank you.
	echo
	echo Pressing on with the build process, but all bets are off.
	echo Do not be surprised if it fails. If it works, and even
	echo if it does not, please contact the above address.
	echo
	;;
esac

####################################################################
## set this if we haven't
##
if [ "x${MAKE}" = "x" ]; then
    MAKE='make'; export MAKE
fi

####################################################################
## Show user what OS we came up with
##
echo " + configured for $OS platform"
SUBDIRS="$OSDIR $SUBDIRS"

####################################################################
# Continue building the stub file
# Set variables as soon as possible so that TestCompile can use them
##
echo >>Makefile.config "OSDIR=\$(SRCDIR)/$OSDIR"
echo >>Makefile.config "INCDIR=\$(SRCDIR)/include"
echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR)"
echo >>Makefile.config "SHELL=$SHELL"
echo >>Makefile.config "OS=$OS"

####################################################################
## And adjust/override WANTHSREGEX as needed
##
if [ "x$RULE_WANTHSREGEX" = "xdefault" ]; then
	if [ "x$DEF_WANTHSREGEX" = "x" ]; then
		RULE_WANTHSREGEX=yes
	else
		RULE_WANTHSREGEX=$DEF_WANTHSREGEX
	fi
fi

####################################################################
## Now we determine the C-compiler and optimization level
## to use. Settings of CC and OPTIM in Configuration have
## the highest precedence; next comes any settings from
## the above "OS-specific" section. If still unset,
## then we look for a known compiler somewhere in PATH
##

# First, look for a CC=<whatever> setting in Configuration (recall, we
# copied these to Makefile.config)
#
# If $TCC is null, then no such line exists in Configuration
#
TCC=`egrep '^CC=' Makefile.config | tail -1 | awk -F= '{print $2}'`
if [ "x$TCC" = "x" ]; then
    if [ "x$CC" = "x" ]; then
	# At this point, CC is not set in Configuration or above, so we
	# try to find one
	for compilers in "gcc" "cc" "acc" "c89"
	do
	    lookedfor="$lookedfor $compilers"
	    if ${SHELL} helpers/PrintPath -s $compilers; then
		COMPILER="$compilers"
		break
	    fi
	done
	if [ "x$COMPILER" = "x" ]; then
	    echo "Error: could not find any of these C compilers"
	    echo " anywhere in your PATH: $lookedfor"
	    echo "Configure terminated"
	    exitcode=1
	    exit 1
	fi
	CC=$COMPILER
    fi
    echo " + setting C compiler to $CC"
fi

####################################################################
## Write the value of $CC to Makefile.config... We only do this
## is not done already (ie: a 'CC=' line was in Configuration).
## If there was an entry for it, then set $CC for our own internal
## use.
##
if [ "x$TCC" = "x" ]; then
    echo "CC=$CC" >> Makefile.config
else
    CC=$TCC
fi

####################################################################
## Now check how we can _directly_ run the C pre-processor
##
TCPP=`egrep '^CPP=' Makefile.config | tail -1 | awk -F= '{print $2}'`
if [ "x$TCPP" != "x" ]; then
    CPP=`CPP="$TCPP"; export CPP CC; ${SHELL} ./helpers/findcpp.sh`
else
    CPP=`export CC; ${SHELL} ./helpers/findcpp.sh`
fi
if [ "x$TCPP" = "x" ]; then
    echo "CPP=$CPP" >> Makefile.config
fi 
echo " + setting C pre-processor to $CPP"

####################################################################
## Now check for existance of non-standard system header files
## and start generation of the ap_config_auto.h header
##
AP_CONFIG_AUTO_H="include/ap_config_auto.h"
echo "/*" >$AP_CONFIG_AUTO_H
echo " *  ap_config_auto.h -- Automatically determined configuration stuff" >>$AP_CONFIG_AUTO_H
echo " *  THIS FILE WAS AUTOMATICALLY GENERATED - DO NOT EDIT!" >>$AP_CONFIG_AUTO_H
echo " */" >>$AP_CONFIG_AUTO_H
echo "" >>$AP_CONFIG_AUTO_H
echo "#ifndef AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H
echo "#define AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H

for uppercase in "tr [a-z] [A-Z]" "tr [:lower:] [:upper:]" "sed y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/"
do
  case `echo Apache | $uppercase` in
    APACHE) break;;
  esac
done
echo " + using \"$uppercase\" to uppercase"
echo " + checking for system header files"
CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h sys/resource.h sys/select.h sys/processor.h sys/param.h"
(
export CPP
for header in $CHECK_FOR_HEADERS; do
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* check: #include <$header> */" >>$AP_CONFIG_AUTO_H
    name="`echo $header | sed -e 's:/:_:g' -e 's:\.:_:g' | $uppercase`"
    ${SHELL} ./helpers/checkheader.sh $header
    if [ $? -eq 0 ]; then
	echo "#ifndef HAVE_${name}" >>$AP_CONFIG_AUTO_H
	echo "#define HAVE_${name} 1" >>$AP_CONFIG_AUTO_H
	echo "#endif" >>$AP_CONFIG_AUTO_H
    else
	echo "#ifdef HAVE_${name}" >>$AP_CONFIG_AUTO_H
	echo "#undef HAVE_${name}" >>$AP_CONFIG_AUTO_H
	echo "#endif" >>$AP_CONFIG_AUTO_H
    fi
done
)

####################################################################
# Special AIX 4.x support: need to check for sys/processor.h
# to decide whether the Processor Binding can be used or not
case "$PLAT" in
    *-ibm-aix*)
	CPP=$CPP ${SHELL} helpers/checkheader.sh sys/processor.h
	if [ $? -eq 0 ]; then
	    CFLAGS="$CFLAGS -DAIX_BIND_PROCESSOR"
	fi
	;;
esac

####################################################################
## Look for OPTIM and save for later
##
TOPTIM=`egrep '^OPTIM=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TRANLIB=`egrep '^RANLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TTARGET=`egrep '^TARGET=' Makefile.config | tail -1 | awk -F= '{print $2}'`

####################################################################
## Check for user provided flags for shared object support
##
TLD_SHLIB=`egrep '^LD_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TLDFLAGS_SHLIB=`egrep '^LDFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TLDFLAGS_MOD_SHLIB=`egrep '^LDFLAGS_MOD_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TLDFLAGS_SHLIB_EXPORT=`egrep '^LDFLAGS_SHLIB_EXPORT=' Makefile.config | tail -1 | awk -F= '{print $2}'`
TCFLAGS_SHLIB=`egrep '^CFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`

####################################################################
## Handle TARGET name
##
if [ "x$TTARGET" = "x" ]; then
    TARGET=httpd
    echo "TARGET=$TARGET" >> Makefile.config
else
    TARGET=$TTARGET
fi
if [ "x$TARGET" != "xhttpd" ]; then
    echo " + using custom target name: $TARGET"
    CFLAGS="$CFLAGS -DTARGET=\\\"$TARGET\\\""
fi

####################################################################
## We adjust now CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT as
## required.  For more platforms just add the required lines below.
##
if [ "x$using_shlib" = "x1" ] ; then
    LD_SHLIB="ld"
    DEF_SHARED_CORE=no
    DEF_SHARED_CHAIN=no
    SHLIB_SUFFIX_NAME=so
    SHMOD_SUFFIX_NAME=so
    SHLIB_SUFFIX_DEPTH=all
    SHLIB_EXPORT_FILES=no
    SHARED_CORE_EP='lib$(TARGET).ep'
    SHCORE_IMPLIB=''
    case "$PLAT" in
	*MPE/iX*)
	    LD_SHLIB=ld	
	    LDFLAGS_SHLIB='-b -a archive'
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    ;;
	*-linux1)
	    CFLAGS_SHLIB="-fpic"
	    LDFLAGS_SHLIB="-Bshareable"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-rdynamic"
	    ;;
	*-linux2*)
		LD_SHLIB="gcc"
	    CFLAGS_SHLIB="-fpic"
	    LDFLAGS_SHLIB="-shared"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-rdynamic"
	    SHLIB_SUFFIX_DEPTH=0
	    ;;
	*-freebsd2*)
		LD_SHLIB="gcc"
	    CFLAGS_SHLIB="-fpic"
	    LDFLAGS_SHLIB="-shared"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=2
	    ;;
	*-freebsd[3-9]*)
		LD_SHLIB="gcc"
	    CFLAGS_SHLIB="-fpic"
	    LDFLAGS_SHLIB="-shared"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` 
	    if [ "x$OBJFORMAT" = "xelf" ]; then
		LDFLAGS_SHLIB_EXPORT="-Wl,-E"
		SHLIB_SUFFIX_DEPTH=0
	    else
		LDFLAGS_SHLIB_EXPORT=""
		SHLIB_SUFFIX_DEPTH=2
	    fi  
	    ;;
	*-openbsd*)
	    PLATOSVERS=`echo $PLAT | sed 's/^.*openbsd//'`
	    CFLAGS_SHLIB="-fPIC"
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=2
	    case "$PLATOSVERS" in
		[01].*|2.[0-7]|2.[0-7].*)
		   LDFLAGS_SHLIB="-Bshareable"
		;;
		*)
		   LD_SHLIB="gcc"
		   LDFLAGS_SHLIB="-shared \$(CFLAGS_SHLIB)"
		   if [ -z "`echo __ELF__ | ${CC} -E - | grep __ELF__`" ]; then
		     LDFLAGS_SHLIB_EXPORT="-Wl,-E"
		   fi
		;;
	    esac
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    ;;
	*-netbsd*)
	    CFLAGS_SHLIB="-fPIC -DPIC"
	    if echo __ELF__ | ${CC} -E - | grep -q __ELF__; then
		LDFLAGS_SHLIB="-Bshareable"
		LDFLAGS_SHLIB_EXPORT=""
	    else
		LDFLAGS_SHLIB="-shared"
		LDFLAGS_SHLIB_EXPORT="-Wl,-E"
	    fi
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    SHLIB_SUFFIX_DEPTH=2
	    ;;
	*-bsdi3)
	    LD_SHLIB="shlicc2"
	    LDFLAGS_SHLIB="-r"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    ;;
	*-bsdi)
	    CFLAGS_SHLIB="-fPIC"
	    LDFLAGS_SHLIB="-shared"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-rdynamic"
	    ;;
 	*-next-openstep*)
 	    LD_SHLIB='cc'
 	    CFLAGS_SHLIB='-dynamic -fno-common'
 	    LDFLAGS_SHLIB='-bundle -undefined warning'
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
 	    LDFLAGS_SHLIB_EXPORT=''
 	    SHLIB_SUFFIX_DEPTH=0
 	    ;;
	*-apple-rhapsody* | *-apple-darwin* )
	    LD_SHLIB="cc"
	    CFLAGS_SHLIB=""
	    case "$PLAT" in
		*-apple-rhapsody* | *-apple-darwin1.[0-3]* )
		    LDFLAGS_SHLIB='$(EXTRA_LDFLAGS) -bundle -undefined suppress'
		    ;;
		* )
		    LDFLAGS_SHLIB='$(EXTRA_LDFLAGS) -bundle -undefined suppress -flat_namespace'
		    ;;
	    esac
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=0
	    ;;
	*-solaris2*)
	    if [ "x`$CC -v 2>&1 | grep gcc`" != "x" ]; then
	        CFLAGS_SHLIB="-fPIC"
	    else
	        CFLAGS_SHLIB="-KPIC"
	    fi
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=1
	    ;;
	*-sunos4*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fPIC" ;;
		*/acc|acc ) CFLAGS_SHLIB="-pic" ;;
	    esac
	    LDFLAGS_SHLIB="-assert pure-text"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    ;;
	*-sgi-irix32)
	    case $CC in
		*/gcc|gcc )
		    CFLAGS_SHLIB="-fpic"
		    N32FLAG=""
		    ;;
		*/cc|cc )
		    CFLAGS_SHLIB="-KPIC"
		    N32FLAG="-n32"
		    ;;
	    esac
	    if [ "x$RULE_IRIXN32" = "xyes" ]; then
		LDFLAGS_SHLIB="$N32FLAG -shared"
	    else
		LDFLAGS_SHLIB="-shared"
	    fi
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    ;;
	*-sgi-irix64)
	    case $CC in
		*/gcc|gcc )
		    CFLAGS_SHLIB="-fpic"
		    N32FLAG=""
		    ;;
		*/cc|cc )
		    CFLAGS_SHLIB="-KPIC"
		    N32FLAG="-n32"
		    ;;
	    esac
	    if [ "x$RULE_IRIXN32" = "xyes" ]; then
		LDFLAGS_SHLIB="$N32FLAG -shared"
	    else
		LDFLAGS_SHLIB="-shared"
	    fi
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    ;;
	*-sgi-irix)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-shared"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    ;;
	*-dec-osf*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="" ;;
	    esac
	    LDFLAGS_SHLIB='-shared -expect_unresolved "*" -s'
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    ;;
	*-unixware*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-Bdynamic -G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
	    ;;
	*-OpenUNIX*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-Bdynamic -G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
	    LD_SHLIB=$CC
	    ;;
	 *-sco5*)
	     case $CC in
		 */gcc*|gcc* ) CFLAGS_SHLIB="-fpic" ;;
		 */cc*|cc*   ) CFLAGS_SHLIB="-KPIC" ;;
	     esac
	     LDFLAGS_SHLIB="-G"
	     LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	     SHLIB_SUFFIX_DEPTH=1
	     ;;
	*-sequent-ptx*)
	    case $PLAT in
	       *-sequent-ptx2*)
	           ;;
	       *-sequent-ptx4.0*)
	           ;;
	       *-sequent-ptx*)
	           CFLAGS_SHLIB="-KPIC"
	           LDFLAGS_SHLIB="-G"
	           LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
	           LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	           ;;
	    esac
	    ;;
	RM*-siemens-sysv4*)
	    # MIPS hosts can take advantage of the LDFLAGS_SHLIB_EXPORT switch
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Wl,-Blargedynsym"
	    ;;
	BS2000-siemens-sysv4*)
	    CFLAGS_SHLIB="-K PIC"
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=0
	    DEF_SHARED_CORE=no
	    ;;
	*-siemens-sysv4*)
	    # Older SINIX machines must be linked as "shared core"-Apache
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*)          CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    SHLIB_SUFFIX_DEPTH=0
	    DEF_SHARED_CORE=yes
	    ;;
	*-sysv4*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
	    esac
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
	    DEF_SHARED_CORE=yes
	    ;;
	*-hp-hpux9.*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="+z" ;;
	    esac
	    LDFLAGS_SHLIB="-b"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred"
	    SHLIB_SUFFIX_NAME=sl
	    ;;
	*-hp-hpux10.*|*-hp-hpux11.*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="+z" ;;
	    esac
	    LDFLAGS_SHLIB="-b"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred -Wl,+s"
	    SHLIB_SUFFIX_NAME=sl
	    ;;
       ia64-ibm-aix*)
           case $CC in
               */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
               */cc|cc   ) CFLAGS_SHLIB="" ;;
           esac
           LDFLAGS_SHLIB=" -L /usr/lib/ia64l32 -G "
           LDFLAGS_MOD_SHLIB="$LDFLAGS_SHLIB -bI:@libexecdir@/httpd.exp -lc"
           LDFLAGS_SHLIB="$LDFLAGS_SHLIB -Bexport:\`echo \$@|sed -e 's:\.so\$\$:.exp:'\`"
           LDFLAGS_SHLIB="$LDFLAGS_SHLIB -lc"
           LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport:\$(SRCDIR)/support/httpd.exp"
           SHLIB_EXPORT_FILES=yes
           ;;
	*-ibm-aix*)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
		*/cc|cc   ) CFLAGS_SHLIB="" ;;
	    esac
	    case $PLAT in
		*-ibm-aix[45678]*)
		    LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -bnoentry"
		    ;;
		*-ibm-aix*)
		    LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -e _nostart"
		    ;;
	    esac
	    LDFLAGS_MOD_SHLIB="$LDFLAGS_SHLIB -bI:@libexecdir@/httpd.exp -lc"
	    LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bI:\$(SRCDIR)/support/httpd.exp "
	    LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bE:\`echo \$@|sed -e 's:\.so\$\$:.exp:'\`"
	    LDFLAGS_SHLIB="$LDFLAGS_SHLIB -lc"
	    LDFLAGS_SHLIB_EXPORT="-Wl,-bE:\$(SRCDIR)/support/httpd.exp"
	    SHLIB_EXPORT_FILES=yes
	    ;;
	*-*-powermax*)
	    LD_SHLIB='cc'
	    LDFLAGS_SHLIB="-Zlink=so"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
	    CFLAGS_SHLIB='-Zpic'
	    ;;
	*-OS/2*)
	    DEF_SHARED_CORE=yes
	    LDFLAGS_SHLIB="`echo $LDFLAGS|sed -e s/-Zexe//` -Zdll"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    SHLIB_SUFFIX_NAME=dll
	    SHMOD_SUFFIX_NAME=dll
	    SHLIB_SUFFIX_DEPTH=0
	    LD_SHLIB=$CC
	    LD_SHCORE_DEF="ApacheCoreOS2.def"
	    LD_SHCORE_LIBS="$LIBS"
	    LIBS_SHLIB='$(SRCDIR)/ApacheCoreOS2.a -lsocket -lbsd $(EXTRA_LIBS)'
	    SHARED_CORE_EP=''
	    SHCORE_IMPLIB='ApacheCoreOS2.a'
	    OS_MODULE_INCLUDE='Makefile.OS2'
	    ;;
	*-dgux)
	    case $CC in
		*/gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
	    esac
	    DEF_SHARED_CORE=yes
	    LDFLAGS_SHLIB="-G"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    LDFLAGS_SHLIB_EXPORT=""
            ;;
	*-cygwin*)
	    DEF_SHARED_CORE=yes
	    LDFLAGS_SHLIB="--export-all"
	    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
	    SHLIB_SUFFIX_NAME=dll
	    SHMOD_SUFFIX_NAME=dll
	    SHLIB_SUFFIX_DEPTH=0
	    LD_SHLIB='dllwrap'
	    LD_SHCORE_DEF=''
	    LD_SHCORE_LIBS="$LIBS"
	    LIBS_SHLIB='$(EXTRA_LIBS)'
	    SHARED_CORE_EP='lib$(TARGET).ep'
	    SHCORE_IMPLIB='lib$(TARGET).dll'
	    OS_MODULE_INCLUDE='$(SRCDIR)/modules/standard/Makefile.Cygwin'
	    ;;
	*)
	    ##  ok, no known explict support for shared objects
	    ##  on this platform, but we give not up immediately.
	    ##  We take a second chance by guessing the compiler
	    ##  and linker flags from the Perl installation
	    ##  if it exists.
	    PERL=
	    for dir in `echo $PATH | sed -e 's/:/ /g'`
	    do
		if [ -f "$dir/perl5" ]; then
		    PERL="$dir/perl5"
		    break
		fi
		if [ -f "$dir/perl" ]; then
		    PERL="$dir/perl"
		    break
		fi
	    done
	    if [ "x$PERL" != "x" ]; then
		#   cool, Perl is installed on this platform...
		if [ "x`$PERL -V:dlsrc 2>/dev/null | grep dlopen`" != "x" ]; then
		    #   ...and actually uses the dlopen-style interface,
		    #   so we can guess the flags from its knowledge
		    CFLAGS_SHLIB="`$PERL -V:cccdlflags | cut -d\' -f2`"
		    LDFLAGS_SHLIB="`$PERL -V:lddlflags | cut -d\' -f2`"
		    LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
		    LDFLAGS_SHLIB_EXPORT="`$PERL -V:ccdlflags | cut -d\' -f2`"
		    #   but additionally we have to inform the
		    #   user that we are just guessing the flags
		    echo ""
		    echo "** WARNING: We have no explicit knowledge about shared object"
		    echo "** support for your particular platform. But perhaps you have"
		    echo "** luck: We were able to guess the compiler and linker flags"
		    echo "** for creating shared objects from your Perl installation."
		    echo "** If they actually work, please send the following information"
		    echo "** for inclusion into later releases to new-httpd@apache.org or make"
		    echo "** a suggestion report at http://bugs.apache.org/:"
		    echo "**     PLATFORM=$PLAT"
		    echo "**     CFLAGS_SHLIB=$CFLAGS_SHLIB"
		    echo "**     LDFLAGS_SHLIB=$LDFLAGS_SHLIB"
		    echo "**     LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT"
		    echo ""
		fi
	    fi
	    ;;
    esac
fi

####################################################################
## Check if we really have some information to compile
## the shared objects if SharedModule was used.
##
if [ "x$using_shlib" = "x1" ] ; then
    if [ "x$TCFLAGS_SHLIB"  = "x" -a "x$CFLAGS_SHLIB"  = "x"  -a \
	 "x$TLDFLAGS_SHLIB" = "x" -a "x$LDFLAGS_SHLIB" = "x" ]; then
	echo ""
	echo "** FAILURE: Sorry, no shared object support available."
	echo "** Either compile all modules statically (use AddModule instead"
	echo "** of SharedModule in the Configuration file) or at least provide"
	echo "** us with the appropriate compiler and linker flags via the"
	echo "** CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT entries"
	echo "** in the Configuration file."
	echo ""
	exit 1
    fi
fi

####################################################################
## Now we do some OS specific adjustments... for some OSs, we need
## to adjust CFLAGS and/or OPTIM depending on which compiler we
## are going to use. This is easy, since this can be gleamed from
## Makefile.config
##
case "$OS" in
    'ULTRIX')
	case "$CC" in
	    */cc|cc ) CFLAGS="$CFLAGS -std" ;;
	esac
	;;
    'SCO 5')
	case "$CC" in
	    */cc|cc ) CFLAGS="$CFLAGS -K noinline" ;;
	esac
	;;
    'HI-UX')
	case "$CC" in
	    */cc|cc )
		CFLAGS="$CFLAGS -Aa -Ae -D_HIUX_SOURCE"
		OPTIM=" "
		TOPTIM=""
	    ;;
	esac
	;;
    'HP-UX'|'HP-UX 10'|'HP-UX 11')
	case "$CC" in
	    */cc|cc )
		CFLAGS="$CFLAGS -Aa -Ae -D_HPUX_SOURCE"
		OPTIM=" "
		TOPTIM=""
	    ;;
	esac
	;;
    *IRIX-64*)
	if [ "x$RULE_IRIXN32" = "xyes" ]; then
	    case "$CC" in
		*/cc|cc )
		    CFLAGS="$CFLAGS -n32"
		    LDFLAGS="$LDFLAGS -n32"
		;;
	    esac
	fi
	;;
    *IRIX-32*)
	if [ "x$RULE_IRIXN32" = "xyes" ]; then
	    case "$CC" in
		*/cc|cc )
		    CFLAGS="$CFLAGS -n32"
		    LDFLAGS="$LDFLAGS -n32"
		;;
	    esac
	fi
	;;
    IBM?AIX?4.[123])
	case $CC in
	    */cc|cc ) 
		CFLAGS="$CFLAGS -qnogenpcomp -qnousepcomp"
	    ;;
	esac
	;;
    'IBM AIX IA64')
       case $CC in
           */cc|cc )
               CFLAGS="$CFLAGS -qnogenpcomp -qnousepcomp"
           ;;
       esac
       ;;
esac

####################################################################
## OK, now we can write OPTIM
##
if [ "x$TOPTIM" = "x" ]; then
    echo "OPTIM=$OPTIM" >> Makefile.config
fi

####################################################################
## OK, now handle RANLIB
##
if [ "x$RANLIB" = "x" ]; then
    if [ "x$TRANLIB" != "x" ]; then
	RANLIB=$TRANLIB
    else
	if ${SHELL} helpers/PrintPath -s ranlib; then
	    RANLIB="ranlib"
	else
	    RANLIB="true"
	fi
    fi
fi

####################################################################
## Now we do some general checks and some intelligent Configuration
## control.

# Use TestCompile to look for various LIBS
case "$PLAT" in
    *-linux*)
	# newer systems using glibc 2.x need -lcrypt
	if ${SHELL} helpers/TestCompile lib crypt; then
	    LIBS="$LIBS -lcrypt"
	fi
	;;

    *-dg-dgux*)
	# R4.11MU02 requires -lsocket -lnsl ... no idea if it's earlier or
	# later than what we already knew about.  PR#732
	if ${SHELL} helpers/TestCompile lib nsl; then
	    LIBS="$LIBS -lnsl"
	    TLIB='-lnsl'
	fi
	if TLIB=$TLIB ${SHELL} helpers/TestCompile lib socket; then
	    LIBS="-lsocket $LIBS"
	fi
	;;
    BS2000*-siemens-sysv4*)
	# Activate RISC compilation if this is a SR2000 machine
	# (test written by Thomas Dorner <Thomas.Dorner@start.de>
	# for perl5 port):
	ISSR2000="`bs2cmd SHOW-SYSTEM-INFO | grep 'HSI-ATT'`"
	case "$ISSR2000" in
	    *TYPE*SR*)
	        CFLAGS="$CFLAGS -Krisc_4000"
	        ;;
	esac
	# Depending on the BS2000 OS and compiler/crte release,
	# -lnsl may be available (or may be not).
	# In standard SVR4 systems, -lsocket relies on some symbols
	# from -lnsl, so the test for -lnsl must appear first.
	if ${SHELL} helpers/TestCompile lib nsl; then
	    LIBS="$LIBS -lnsl"
	    TLIB='-lnsl'
	fi
	if TLIB=$TLIB ${SHELL} helpers/TestCompile lib socket; then
	    LIBS="-lsocket $LIBS"
	fi
	# Auto-detect presence of libdl for dynamic loading
	if ${SHELL} ./helpers/TestCompile lib dl; then
	    if ${SHELL} ./helpers/TestCompile func dlopen; then
		LIBS="$LIBS -ldl"
		TLIB='-ldl'
    	   fi
	fi
	# Test for the presence of the "union semun":
	if TCADDINCL='#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>' ./helpers/TestCompile sizeof "union semun"; then
            : Okay, union semun is defined
	else
	    CFLAGS="$CFLAGS -DNEED_UNION_SEMUN"
	fi
	# Test for the presence of the _rini_struct typedef:
	if TCADDINCL='#include <pwd.h>' ${SHELL} ./helpers/TestCompile sizeof _rini_struct; then
	    CFLAGS="$CFLAGS -DHAVE_RINI_STRUCT"
	fi
	# Test whether initgroups() must be emulated:
	if ${SHELL} helpers/TestCompile func initgroups; then
	    :
	else
	    CFLAGS="$CFLAGS -DNEED_INITGROUPS"
	fi
	;;
esac

# SOCKS4 support:
# We assume that if they are using SOCKS4, then they've
# adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
# otherwise we assume "-L/usr/local/lib -lsocks"
if [ "x$RULE_SOCKS4" = "xyes" ]; then
    echo " + enabling SOCKS4 support"
    CFLAGS="$CFLAGS -DSOCKS -DSOCKS4"
    CFLAGS="$CFLAGS -Dconnect=Rconnect -Dselect=Rselect"
    CFLAGS="$CFLAGS -Dgethostbyname=Rgethostbyname"
    if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks`" = "x" ]; then
	LIBS="$LIBS -L/usr/local/lib -lsocks"
    fi
    case $PLAT in
	*-solaris2* )
	    LIBS="$LIBS -lresolv"
	    ;;
    esac
fi

# SOCKS5 support:
# We assume that if they are using SOCKS5, then they've
# adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
# otherwise we assume "-L/usr/local/lib -lsocks5"
if [ "x$RULE_SOCKS5" = "xyes" ]; then
    echo " + enabling SOCKS5 support"
    CFLAGS="$CFLAGS -DSOCKS -DSOCKS5"
    CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dselect=SOCKSselect"
    CFLAGS="$CFLAGS -Dgethostbyname=SOCKSgethostbyname -Dclose=SOCKSclose"
    if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks5`" = "x" ]; then
	LIBS="$LIBS -L/usr/local/lib -lsocks5"
    fi
    case $PLAT in
	*-solaris2* )
	    LIBS="$LIBS -lresolv"
	    ;;
    esac
fi

####################################################################
## Find out what modules we want and try and configure things for them
## Module lines can look like this:
##
##  Module  name_module    some/path/mod_name[.[oa]]
##  AddModule              some/path/mod_name[.[oa]]
##
## In both cases, the some/path can either be an arbitrary path (including
## an absolute path), or a path like "modules/DIR", in which case we _might_
## auto-generate a Makefile in modules/DIR (see later).
##
## The first case is the original style, where we give the module's
## name as well as it's binary file location - either a .o or .a.
##
## The second format is new, and means we do not repeat the module
## name, which is already part of the module source or definition.
## The way we find the module name (and other optional information about
## the module) is like this:
##
##  1 If extension is not given or is .c, assume .o was given and goto 3
##  2 If extension is .module, go to D1
##  3 If extension is .o, look for a corresponding .c file and if
##      found, go to C1
##  4 If no .c file was found, look for a .module file (Apache module
##      definition file). If found, go to D1
##  5 Assume module name is the "name" part of "mod_name", as in
##      name_module.
##
## If a C file is found:
##
## C1 Look for module name given by an MODULE: line (e.g. MODULE: name_module)
##      If found assume module contains a definition, and go to D1
## C2 If not found, look for a module name given on the declaration of the
##      module structure (e.g. module name_module).
## C3 If neither given, go to 4 above.
##
## If a definition file is found, or a .c file includes a module definition:
##
## D1 Get the module name from the MODULE: name= line
## D2 Get other module options (libraries etc). To be done later.
##
##
## For now, we will convert the AddModule lines into Module format
## lines, so the rest of Configure can do its stuff without too much
## additional hackery. It would be nice to reduce the number of times
## we have to awk the $tmpfile, though.

## MODFILES contains a list of module filenames (could be .c, .o, .so, .a
##    or .module files) from AddModule lines only
## MODDIRS contains a list of subdirectories under 'modules' which
##    contain modules we want to build from both AddModule and Module
##    lines

echo " + adding selected modules"

MODFILES=`awk <$tmpfile '($1 == "AddModule" || $1 == "SharedModule") { printf "%s ", $2 }'`
MODDIRS=`awk < $tmpfile '
	($1 == "Module" && $3 ~ /^modules\//) {
	    split ($3, pp, "/")
	    if (! SEEN[pp[2]]) {
		printf "%s ", pp[2]
		SEEN[pp[2]] = 1
	    }
    	}
	(($1 == "AddModule" || $1 == "SharedModule") && $2 ~ /^modules\//) { 
	    split ($2, pp, "/")
	    if (! SEEN[pp[2]]) {
		printf "%s ", pp[2]
		SEEN[pp[2]] = 1
	    } 
    	}'`
MODDIRS_NO_SO=`awk < $tmpfile '
	($1 == "Module" && $3 ~ /^modules\//) {
	    split ($3, pp, "/")
	    if (! SEEN[pp[2]]) {
		printf "%s ", pp[2]
		SEEN[pp[2]] = 1
	    }
    	}
	(($1 == "AddModule") && $2 ~ /^modules\//) { 
	    split ($2, pp, "/")
	    if (! SEEN[pp[2]]) {
		printf "%s ", pp[2]
		SEEN[pp[2]] = 1
	    } 
    	}'`

# Now autoconfigure each of the modules specified by AddModule.
# Use tmpfile2 for the module definition file, and tmpfile3 for the
# shell commands to be executed for this module.

for modfile in $MODFILES ; do
	rm -f $tmpfile2 $tmpfile3
	modname=''

	ext=`echo $modfile | sed 's/^.*\.//'`
	modbase=`echo $modfile | sed 's/\.[^.]*$//'`
	if [ "x$ext" = "x$modfile" ]; then ext=o; modbase=$modfile; modfile=$modbase.o; fi
	if [ "x$ext" = "x" ] ; then ext=o; modbase=$modfile; fi
	if [ "x$ext" = "xc" ] ; then ext=o; fi

	# modbase is the path+filename without extension, ext is the
	# extension given, or if none, o
	if [ -r $modbase.module ] ; then
		$CAT $modbase.module > $tmpfile2
	else
	    if [ -f $modbase.c ] ; then
		# Guess module structure name in case there is no
		# module definition in this file
		modname=`egrep '^module .*;' $modbase.c | head -1 |\
			sed 's/^module.*[ 	][ 	]*//' | \
			sed 's/[ 	]*;[ 	]*$//'`
		# Get any module definition part
		if grep "MODULE-DEFINITION-" $modbase.c > /dev/null; then
		$CAT $modbase.c | \
		sed '1,/MODULE-DEFINITION-START/d;/MODULE-DEFINITION-END/,$d' \
			> $tmpfile2
		fi
	    fi
	fi		
	if [ -r $tmpfile2 ] ; then
		# Read a module definition from .module or .c
		modname=`grep "Name:" $tmpfile2 | sed 's/^.*Name:[ 	]*//'`
		if grep "ConfigStart" $tmpfile2 > /dev/null \
		 && grep "ConfigEnd" $tmpfile2 > /dev/null; then
		    sed '1,/ConfigStart/d;/ConfigEnd/,$d' $tmpfile2 > \
		     $tmpfile3
		    echo "    o $modname uses ConfigStart/End"
		    if [ "x$RULE_PARANOID" = "xyes" ]; then
			sed 's/^/>> /' $tmpfile3
		    fi
		    . ./$tmpfile3
		fi
		if grep "Libs:" $tmpfile2 > /dev/null; then
		    modlibs1=`grep Libs: $tmpfile2 | sed 's/^.*Libs:[ 	]*//'`
		    echo "    o $modbase adds libraries: $modlibs1"
		    modlibs="$modlibs $modlibs1"
		fi
		rm -f $tmpfile2 $tmpfile3
		if [ "x$ext" != "x$SHMOD_SUFFIX_NAME" ]; then
		    ext=o
		fi
	fi
	if [ "x$modname" = "x" ] ; then
		modname=`echo $modbase | sed 's/^.*\///' | \
			sed 's/^mod_//' | sed 's/^lib//' | sed 's/$/_module/'`
	fi
	if [ "x$ext" != "x$SHMOD_SUFFIX_NAME" ]; then
		echo "Module $modname $modbase.$ext" >>$tmpfile
	fi
	#   optionally generate export file for some linkers 
	if [ "x$ext" = "x$SHMOD_SUFFIX_NAME" -a "x$SHLIB_EXPORT_FILES" = "xyes" ]; then
		echo "$modname" >$modbase.exp
	fi
done
# $tmpfile now contains Module lines for all the modules we want

####################################################################
## Now HS's POSIX regex implementation if needed/wanted. We do it
## now since AddModule may have changed it
##
if [ "x$RULE_WANTHSREGEX" = "xyes" ]; then
    REGLIB="regex/libregex.a"
    SUBDIRS="regex $SUBDIRS"
    CFLAGS="$CFLAGS -DUSE_HSREGEX"
fi

####################################################################
## Extended API (EAPI) support:
##
if [ "x$RULE_EAPI" = "x" ]; then
    RULE_EAPI=`${SHELL} helpers/CutRule EAPI $file`
fi
if [ "x$RULE_EAPI" = "xyes" ]; then
    echo " + enabling Extended API (EAPI)"
    CFLAGS="$CFLAGS -DEAPI"
    #   some vendor compilers are too restrictive
    #   for our ap_hook and ap_ctx sources.
    case "$OS:$CC" in
        *IRIX-32*:*/cc|*IRIX-32*:cc )
            CFLAGS="$CFLAGS -woff 1048,1110,1164"
            ;;
    esac
    #   MM Shared Memory Library support for EAPI
    if [ "x$EAPI_MM" = "x" ]; then
        EAPI_MM=`egrep '^EAPI_MM=' $file | sed -n -e '$p' | awk -F= '{print $2}'`
    fi
    if [ "x$EAPI_MM" != "x" ]; then
        case $EAPI_MM in
            SYSTEM|/* ) ;;
            * ) for p in . .. ../..; do
                    if [ -d "$p/$EAPI_MM" ]; then
                        EAPI_MM="`echo $p/$EAPI_MM | sed -e 's;/\./;/;g'`" 
                        break
                    fi
                done
                ;;
        esac
        if [ "x$EAPI_MM" = "xSYSTEM" ]; then
            echo "   using MM library for EAPI: (system-wide)"
            CFLAGS="$CFLAGS -DEAPI_MM"
            __INCLUDES="`mm-config --cflags`"
            if [ "x$__INCLUDES" != "x-I/usr/include" ]; then
                INCLUDES="$INCLUDES $__INCLUDES"
            fi
            LDFLAGS="$LDFLAGS `mm-config --ldflags`"
            LIBS="$LIBS `mm-config --libs`"
        else
            if [ -f "$EAPI_MM/.libs/libmm.a" -a -f "$EAPI_MM/mm.h" ]; then
                echo "   using MM library: $EAPI_MM (source-tree only)"
                case $EAPI_MM in
                    /* ) ;;
                    *  ) EAPI_MM="\$(SRCDIR)/$EAPI_MM" ;;
                esac
                CFLAGS="$CFLAGS -DEAPI_MM"
                INCLUDES="$INCLUDES -I$EAPI_MM"
                LDFLAGS="$LDFLAGS -L$EAPI_MM/.libs"
                LIBS="$LIBS -lmm"
            elif [ -f "$EAPI_MM/bin/mm-config" ]; then
                echo "   using MM library: $EAPI_MM (installed)"
                CFLAGS="$CFLAGS -DEAPI_MM"
                INCLUDES="$INCLUDES `$EAPI_MM/bin/mm-config --cflags`"
                LDFLAGS="$LDFLAGS `$EAPI_MM/bin/mm-config --ldflags`"
                LIBS="$LIBS `$EAPI_MM/bin/mm-config --libs`"
            else
                echo "Configure:Error: Cannot find MM library under $EAPI_MM" 1>&2
                exit 1
            fi
        fi
    fi
fi


####################################################################
## Add in the Expat library if needed/wanted.
##

# set the default, based on whether expat-lite is bundled. if it is present,
# then we can always include expat.
if [ "x$RULE_EXPAT" = "xdefault" ]; then
    if [ -d ./lib/expat-lite/ ]; then
        RULE_EXPAT=yes
    else
        RULE_EXPAT=no
    fi
fi

if [ "x$RULE_EXPAT" = "xyes" ]; then
    if ${SHELL} ./helpers/TestCompile lib expat; then
        echo " + using system Expat"
        LIBS="$LIBS -lexpat"
    else
        if [ ! -d ./lib/expat-lite/ ]; then
            echo "ERROR: RULE_EXPAT set to \"yes\" but is not available."
	    exit 1
        fi
        echo " + using builtin Expat"
        EXPATLIB="lib/expat-lite/libexpat.a"
        APLIBDIRS="expat-lite $APLIBDIRS"
        CFLAGS="$CFLAGS -DUSE_EXPAT -I\$(SRCDIR)/lib/expat-lite"
    fi
fi

####################################################################
## Now the SHARED_CHAIN stuff
##
if [ "x$using_shlib" = "x1" ] ; then
    if [ "x$RULE_SHARED_CHAIN" = "xdefault" ] ; then
	RULE_SHARED_CHAIN=$DEF_SHARED_CHAIN
    fi
    if [ "x$RULE_SHARED_CHAIN" = "xyes" ]; then
	echo " + enabling DSO files to be linked against others"
	#   determine libraries which can be safely linked
	#   to our DSO files, i.e. PIC libraries and shared libraries
	extra_ldflags="`grep EXTRA_LDFLAGS= Makefile.config`"
	extra_libs="`grep EXTRA_LIBS= Makefile.config`"
	eval "`${SHELL} helpers/slo.sh $LDFLAGS $LIBS $extra_ldflags $extra_libs`"
	LIBS_SHLIB="$SLO_DIRS_PIC $SLO_LIBS_PIC $SLO_DIRS_DSO $SLO_LIBS_DSO"
    fi
fi

####################################################################
## Now the SHARED_CORE stuff
##
if [ "x$using_shlib" = "x1" ] ; then
    if [ "x$RULE_SHARED_CORE" = "xdefault" ] ; then
	RULE_SHARED_CORE=$DEF_SHARED_CORE
    fi
    if [ "x$RULE_SHARED_CORE" = "xyes" ]; then
	DSO_STRING="DSO"
	if [ "$OS" = "Cygwin" ]; then
	    DSO_STRING="DLL"
	fi
	echo " + enabling generation of Apache core as $DSO_STRING"
	#    shuffle compiler flags from shlib variant to standard
	CFLAGS="$CFLAGS $CFLAGS_SHLIB"
	CFLAGS_SHLIB=""
	#    indicate that Rule SHARED_CORE is active
	CFLAGS="$CFLAGS -DSHARED_CORE"
	#    select the special subtarget for shared core generation
	SUBTARGET=target_shared
	#    determine additional suffixes for libhttpd.so
	V=1 R=3 P=29
	if [ "x$SHLIB_SUFFIX_DEPTH" = "x0" ]; then
	    SHLIB_SUFFIX_LIST=""
	fi
	if [ "x$SHLIB_SUFFIX_DEPTH" = "x1" ]; then
	    SHLIB_SUFFIX_LIST="$V"
	fi
	if [ "x$SHLIB_SUFFIX_DEPTH" = "x2" ]; then
	    SHLIB_SUFFIX_LIST="$V.$R"
	fi
	if [ "x$SHLIB_SUFFIX_DEPTH" = "x3" ]; then
	    SHLIB_SUFFIX_LIST="$V.$R.$P"
	fi
	if [ "x$SHLIB_SUFFIX_DEPTH" = "xall" ]; then
	    SHLIB_SUFFIX_LIST="$V $V.$R $V.$R.$P"
	fi
    fi
fi

####################################################################
## Don't force DL emulation, if not necessary. Currently only used
## by os/unix/os.c. 
##
if [ "x$using_shlib" != "x1" ] ; then
    CFLAGS="$CFLAGS -DNO_DL_NEEDED"
fi

####################################################################
## Set the value of the shared libary flags, if they aren't explicitly
## set in the configuration file
##
if [ "x$using_shlib" = "x1" ] ; then
    if [ "x$TCFLAGS_SHLIB" = "x" ]; then
	echo "CFLAGS_SHLIB=$CFLAGS_SHLIB -DSHARED_MODULE" >> Makefile.config
    fi
    if [ "x$TLD_SHLIB" = "x" ]; then
	echo "LD_SHLIB=$LD_SHLIB" >> Makefile.config
    fi
    if [ "x$TLDFLAGS_SHLIB" = "x" ]; then
	echo "EXTRA_LDFLAGS_SHLIB=$EXTRA_LDFLAGS_SHLIB" >> Makefile.config
	echo "LDFLAGS_SHLIB=$LDFLAGS_SHLIB $EXTRA_LDFLAGS_SHLIB" >> Makefile.config
    fi
    if [ "x$TLDFLAGS_SHLIB_EXPORT" = "x" ]; then
	echo "LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT" >> Makefile.config
    fi
    if [ "x$TLDFLAGS_MOD_SHLIB" = "x" ]; then
	echo "LDFLAGS_MOD_SHLIB=$LDFLAGS_MOD_SHLIB" >> Makefile.config
    fi
    echo "LD_SHCORE_DEF=$LD_SHCORE_DEF" >> Makefile.config
    echo "LD_SHCORE_LIBS=$LD_SHCORE_LIBS" >> Makefile.config
    echo "SHARED_CORE_EP=$SHARED_CORE_EP" >> Makefile.config
    echo "SHCORE_IMPLIB=$SHCORE_IMPLIB" >> Makefile.config
fi

####################################################################
## Now create modules.c
##
$CAT > $awkfile <<'EOFM'
    BEGIN {
	modules[n++] = "core"
	pmodules[pn++] = "core"
    } 
    /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } 
    /^%Module/ { pmodules[pn++] = $2 } 
    END {
	print "/*"
	print " * modules.c --- automatically generated by Apache"
	print " * configuration script.  DO NOT HAND EDIT!!!!!"
	print " */"
	print ""
	print "#include \"httpd.h\""
	print "#include \"http_config.h\""
	print ""
	for (i = 0; i < pn; ++i) {
	    printf ("extern module %s_module;\n", pmodules[i])
	}
	print ""
	print "/*"
	print " *  Modules which implicitly form the"
	print " *  list of activated modules on startup,"
	print " *  i.e. these are the modules which are"
	print " *  initially linked into the Apache processing"
	print " *  [extendable under run-time via AddModule]"
	print " */"
	print "module *ap_prelinked_modules[] = {"
	for (i = 0; i < n; ++i) {
	    printf "  &%s_module,\n", modules[i]
	}
	print "  NULL"
	print "};"
	print ""
	print "/*"
	print " *  Modules which initially form the"
	print " *  list of available modules on startup,"
	print " *  i.e. these are the modules which are"
	print " *  initially loaded into the Apache process"
	print " *  [extendable under run-time via LoadModule]"
	print " */"
	print "module *ap_preloaded_modules[] = {"
	for (i = 0; i < pn; ++i) {
	    printf "  &%s_module,\n", pmodules[i]
	}
	print "  NULL"
	print "};"
	print ""
    }
EOFM
$CAT $tmpfile | sed 's/_module//' | awk -f $awkfile > modules.c 

####################################################################
## figure out which module dir require use to autocreate a Makefile.
## for these dirs we must not list the object files from the AddModule
## lines individually since the auto-generated Makefile will create
## a library called libMODDIR.a for it (MODDIR is the module dir
## name). We create two variable here:
##
##   AUTODIRS   Space separated list of module directories, relative to
##              src
##   AUTOLIBS   Space separated list of auto-generated library files
##
for moddir in $MODDIRS 
do
	if [ -f modules/$moddir/Makefile.tmpl ] ; then
		AUTODIRS="$AUTODIRS modules/$moddir"
	fi
done
for moddir in $MODDIRS_NO_SO
do
	if [ -f modules/$moddir/Makefile.tmpl ] ; then
		AUTOLIBS="$AUTOLIBS modules/$moddir/lib$moddir.a"
	fi
done

####################################################################
## Add the module targets to the Makefile. Do not add individual object
## targets for auto-generated directories.
##
$CAT > $awkfile <<EOF1
    BEGIN {
	split ("$AUTODIRS", tmp, " ")
EOF1
$CAT >> $awkfile <<'EOF2'
	for ( key in tmp ) {
	    autodirs[tmp[key]] = 1
	}
     }
    /^Module/ { modules[n++] = $3 }
    /^%Module/ { modules[n++] = $3 }
    END {
	print "MODULES= \\"
	for (i = 0; i < n; ++i) {
	    split (modules[i], pp, "/")
	    dir = pp[1] "/" pp[2] 
	    inthere = 0
	    for ( tdir in autodirs ) {
		if (tdir == dir) 
		    inthere = 1
	    }
	    if (inthere == 1)
		continue
	    else
		printf ("  %s \\\n", modules[i])
	}
    }
EOF2
awk -f $awkfile >>Makefile <$tmpfile

####################################################################
## Now add the auto-generated library targets.  Need to use awk so we
## don't hang a continuation on the last line.
##
$CAT > $awkfile <<'EOF4'
    {
	z = 0
	split ($0, libs)
	for ( lib in libs ) {
	    if (z != 0)
		printf (" \\\n")
	    z++
	    printf ("  %s", libs[lib])
	}
    }
    END {
	printf ("\n")
    }
EOF4
echo "$AUTOLIBS" | awk -f $awkfile >>Makefile
echo "" >>Makefile

####################################################################
## Now add the target for the main Makefile
##
echo "SUBDIRS=$SUBDIRS lib modules" >> Makefile
echo "SUBTARGET=$SUBTARGET" >> Makefile
echo "SHLIB_SUFFIX_NAME=$SHLIB_SUFFIX_NAME" >> Makefile
echo "SHMOD_SUFFIX_NAME=$SHMOD_SUFFIX_NAME" >> Makefile
echo "SHLIB_SUFFIX_LIST=$SHLIB_SUFFIX_LIST" >> Makefile
echo "SHLIB_EXPORT_FILES=$SHLIB_EXPORT_FILES" >> Makefile
echo "" >> Makefile

####################################################################
## Determine GNU Make variant because
## it uses ugly looking built-in directory walk messages
## while we are already using our own messages
##
if [ "x`${MAKE} -v 2>/dev/null | grep 'GNU Make'`" = "x" ]; then
	MFLAGS_STATIC=
else
	MFLAGS_STATIC=--no-print-directory
fi

####################################################################
## Continue building Makefile.config. Fill in all entries except
## for $LIBS at this point. This implies that anything below
## can only alter $LIBS
##
echo "CFLAGS1=$CFLAGS" >>Makefile.config
echo "INCLUDES1=$INCLUDES" >>Makefile.config
echo "LIBS_SHLIB=$LIBS_SHLIB" >>Makefile.config
echo "LDFLAGS1=$LDFLAGS" >>Makefile.config
echo "MFLAGS_STATIC=$MFLAGS_STATIC" >>Makefile.config
echo "REGLIB=$REGLIB" >>Makefile.config
echo "EXPATLIB=$EXPATLIB" >>Makefile.config
echo "RANLIB=$RANLIB" >>Makefile.config

####################################################################
## Some OS-related stuff for the DSO mechanism:
## Finding the vendor DSO functions
##
if [ "x$using_shlib" = "x1" ] ; then
    DL_LIB=""
    case $PLAT in
       ia64-ibm-aix* )
           DL_LIB="-ldl"
           ;;
	*-ibm-aix* )
	    DL_LIB="-lld"
	    ;;
	*-sequent-ptx* )
	    case $PLAT in
	        *-sequent-ptx2*)
	            ;;
	        *-sequent-ptx4.0*)
	            ;;
	        *-sequent-ptx*)
	            DL_LIB="-ldl"
	            ;;
	    esac
	    ;;
	*-hp-hpux*)
	    if ${SHELL} helpers/TestCompile func shl_load; then
		:
	    else
		if ${SHELL} helpers/TestCompile lib dld; then
		    DL_LIB="-ldld"
		fi
	    fi
	    ;;
	* )
	    if ${SHELL} helpers/TestCompile func dlopen; then
		:
	    else
		if ${SHELL} helpers/TestCompile lib dl; then
		    DL_LIB="-ldl"
		fi
	    fi
	    ;;
    esac
    if [ "x$DL_LIB" != "x" ]; then
	LIBS="$LIBS $DL_LIB"
	echo " + using $DL_LIB for vendor DSO support"
    fi
fi

####################################################################
## More building ap_config_auto.h
##
## We check the sizeof various data types
##
echo " + checking sizeof various data types"
AP_TYPE_QUAD=`${SHELL} helpers/TestCompile -r sizeof 'long long'`
if [ "x$AP_TYPE_QUAD" = "x" ]; then
    AP_TYPE_QUAD="unknown_quad"
    AP_LONGEST_LONG="long"
else
    AP_LONGEST_LONG="long long"
fi

echo "" >>$AP_CONFIG_AUTO_H
echo "/* determine: longest possible integer type */" >>$AP_CONFIG_AUTO_H
echo "#ifndef AP_LONGEST_LONG" >>$AP_CONFIG_AUTO_H
echo "#define AP_LONGEST_LONG $AP_LONGEST_LONG" >>$AP_CONFIG_AUTO_H
echo "#endif" >>$AP_CONFIG_AUTO_H

####################################################################
## More building ap_config_auto.h
##
## Check for availability of isinf() and isnan()
##
if ${SHELL} ./helpers/TestCompile func isinf ; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: isinf() found in libc */ " >>$AP_CONFIG_AUTO_H
    echo "#ifndef HAVE_ISINF" >>$AP_CONFIG_AUTO_H
    echo "#define HAVE_ISINF 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
elif ${SHELL} ./helpers/TestCompile lib m isinf ; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: isinf() found in libm */ " >>$AP_CONFIG_AUTO_H
    echo "#ifndef HAVE_ISINF" >>$AP_CONFIG_AUTO_H
    echo "#define HAVE_ISINF 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
    LIBS="$LIBS -lm"
    ADDED_LM="yes"
fi

if ${SHELL} ./helpers/TestCompile func isnan ; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: isnan() found in libc */ " >>$AP_CONFIG_AUTO_H
    echo "#ifndef HAVE_ISNAN" >>$AP_CONFIG_AUTO_H
    echo "#define HAVE_ISNAN 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
elif ${SHELL} ./helpers/TestCompile lib m isnan ; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: isnan() found in libm */ " >>$AP_CONFIG_AUTO_H
    echo "#ifndef HAVE_ISNAN" >>$AP_CONFIG_AUTO_H
    echo "#define HAVE_ISNAN 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
    if [ "x$ADDED_LM" != "xyes" ]; then
        LIBS="$LIBS -lm"
    fi
fi

## We check for the endianess of the machine
##
AP_BYTE_ORDER=`${SHELL} helpers/TestCompile -r byteorder`
if [ "x$AP_BYTE_ORDER" = "x21" ]; then
    AP_BYTE_ORDER="21" # big endian
else
    AP_BYTE_ORDER="12" # little endian
fi

echo "" >>$AP_CONFIG_AUTO_H
echo "/* determine: byte order of machine (12: little endian, 21: big endian) */" >>$AP_CONFIG_AUTO_H
echo "#ifndef AP_BYTE_ORDER" >>$AP_CONFIG_AUTO_H
echo "#define AP_BYTE_ORDER $AP_BYTE_ORDER" >>$AP_CONFIG_AUTO_H
echo "#endif" >>$AP_CONFIG_AUTO_H

##
## Now compare the sizes of off_t to long
##
AP_TYPE_OFF_T=`${SHELL} helpers/TestCompile -r sizeof off_t`
if [ "x$AP_TYPE_OFF_T" = "x" ]; then
    AP_TYPE_OFF_T="unknown_off_t"
fi

AP_TYPE_LONG=`${SHELL} helpers/TestCompile -r sizeof long`
if [ "x$AP_TYPE_LONG" = "x" ]; then
    AP_TYPE_LONG="unknown_long"
fi

if [ "x$AP_TYPE_OFF_T" != "x$AP_TYPE_LONG" ]; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: is off_t a quad */" >>$AP_CONFIG_AUTO_H
    echo "#ifndef AP_OFF_T_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#define AP_OFF_T_IS_QUAD 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
else
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: is off_t a quad */" >>$AP_CONFIG_AUTO_H
    echo "#ifdef AP_OFF_T_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#undef AP_OFF_T_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
fi

##
## Now see of void * is as big as a quad (long long)
##
AP_TYPE_VOID_P=`${SHELL} helpers/TestCompile -r sizeof 'void *'`
if [ "x$AP_TYPE_VOID_P" = "x" ]; then
    AP_TYPE_VOID_P="unknown_void_p"
fi

if [ "x$AP_TYPE_VOID_P" = "x$AP_TYPE_QUAD" ]; then
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: is void * a quad */" >>$AP_CONFIG_AUTO_H
    echo "#ifndef AP_VOID_P_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#define AP_VOID_P_IS_QUAD 1" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
else
    echo "" >>$AP_CONFIG_AUTO_H
    echo "/* determine: is void * a quad */" >>$AP_CONFIG_AUTO_H
    echo "#ifdef AP_VOID_P_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#undef AP_VOID_P_IS_QUAD" >>$AP_CONFIG_AUTO_H
    echo "#endif" >>$AP_CONFIG_AUTO_H
fi

####################################################################
## Finish building ap_config_auto.h
##
## We pick out all -D's from CFLAGS and insert them as defines into
## ap_config_auto.h so they are available to external modules needing to
## include Apache header files.
##
TEXTRA_CFLAGS=`egrep '^EXTRA_CFLAGS=' Makefile.config | tail -1 |\
	       sed -e 's;^EXTRA_CFLAGS=;;' -e 's;\`.*\`;;'`
tmpstr=`echo $CFLAGS $TEXTRA_CFLAGS |\
	sed -e 's;[ 	]\([+-]\);!\1;g' -e 's/\([^\\\]\)"/\1/g' -e 's/\\\"/\"/g'`
OIFS="$IFS"
IFS='!'
for cflag in $tmpstr; do
    echo "$cflag" >>$tmpconfig
done
IFS="$OIFS"
awk >>$AP_CONFIG_AUTO_H <$tmpconfig '
    /^-D.*/ {
	i = index($0, "=")
	if (i > 0) {
	    define = substr($0, 3, i-3)
	    value  = substr($0, i+1, length($0)-i)
	}
	else {
	    define = substr($0, 3, length($0)-2)
	    value  = "1";
	}
	printf ("\n/* build flag: %s */\n", $0)
	printf ("#ifndef %s\n#define %s %s\n#endif\n", define, define, value)
    }
'

# finish header file
echo "" >>$AP_CONFIG_AUTO_H
echo "#endif /* AP_CONFIG_AUTO_H */" >>$AP_CONFIG_AUTO_H

####################################################################
## Finish creating the Makefile.config file
##
echo "LIBS1=$modlibs $LIBS">> Makefile.config
echo "##" >> Makefile.config
echo "##  (End of automatically generated section)">> Makefile.config
echo "##" >> Makefile.config
echo "" >> Makefile.config

####################################################################
## Use TestCompile to see if $(CC) is ANSI and as a "final" sanity
## check
##

if [ "x$OS" = "xTPF" ] ; then
    :
else
   echo " + doing sanity check on compiler and options"
   if ${SHELL} ./helpers/TestCompile $vflag sanity; then
      :
   else
      if [ "x$vflag" = "x-v" ] ; then
         WHEREERR="above"
      else
         WHEREERR="below"
      fi
      echo "** A test compilation with your Makefile configuration"
      echo "** failed.  The $WHEREERR error output from the compilation"
      echo "** test will give you an idea what is failing. Note that"
      echo "** Apache requires an ANSI C Compiler, such as gcc. "
      echo ""
      echo "======== Error Output for sanity check ========"
      (${SHELL} ./helpers/TestCompile -v sanity) 2>&1
      echo "============= End of Error Report ============="
      echo ""
      echo " Aborting!"
      exitcode=1
      exit 1
   fi
fi

####################################################################
## Now (finish) creating the makefiles
##

# ./Makefile
$CAT Makefile.config >> Makefile
sed -e "s#@@Configuration@@#$file#" "Makefile.tmpl" >>Makefile

# xxx/Makefile
MAKEDIRS="support $SUBDIRS"
for dir in $MAKEDIRS ; do
	echo Creating Makefile in $dir
	${SHELL} helpers/mfhead $dir $file > $dir/Makefile
	$CAT Makefile.config $dir/Makefile.tmpl |\
	sed -e "s:^SRCDIR=.*:SRCDIR=`${SHELL} helpers/fp2rp $dir`:" >> $dir/Makefile
done

####################################################################
## Now create the lib/Makefile
##
${SHELL} helpers/mfhead modules $file > lib/Makefile
$CAT Makefile.config | sed -e 's:^SRCDIR=.*:SRCDIR=..:' >> lib/Makefile

$CAT << EOF >> lib/Makefile
APLIBS=$APLIBDIRS
CFLAGS=\$(OPTIM) \$(CFLAGS1) \$(EXTRA_CFLAGS)

default: all

all clean distclean depend :: 
	@for i in \$(APLIBS) ""; do \\
	  if [ "x\$\$i" != "x" ]; then \\
	    echo "===> \$(SDP)lib/\$\$i"; \\
		(cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)' CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1; \\
		echo "<=== \$(SDP)lib/\$\$i"; \\
	  fi; \\
	done

EOF

####################################################################
## Now create the lib/xxx/Makefile
##

for dir in $APLIBDIRS ; do
	echo Creating Makefile in lib/$dir
	${SHELL} helpers/mfhead lib/$dir $file > lib/$dir/Makefile
	$CAT Makefile.config lib/$dir/Makefile.tmpl |\
	sed -e "s:^SRCDIR=.*:SRCDIR=`${SHELL} helpers/fp2rp lib/$dir`:" >> lib/$dir/Makefile
done

####################################################################
## Now create the modules/Makefile
##
${SHELL} helpers/mfhead modules $file > modules/Makefile
$CAT Makefile.config | sed -e 's:^SRCDIR=.*:SRCDIR=..:' >> modules/Makefile

$CAT << EOF >> modules/Makefile
MODULES=$MODDIRS
CFLAGS=\$(OPTIM) \$(CFLAGS1) \$(EXTRA_CFLAGS)

default: all

all clean distclean depend :: 
	@for i in \$(MODULES) ""; do \\
	  if [ "x\$\$i" != "x" ]; then \\
	    echo "===> \$(SDP)modules/\$\$i"; \\
		case "x\$(OS)" in \\
		  xOS390 | xTPF) (cd \$\$i && \$(MAKE) SDP='\$(SDP)' OPTIM='\$(OPTIM)' \$@) || exit 1;; \\
		              *) (cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)' CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' OPTIM='\$(OPTIM)' \$@) || exit 1;; \\
		esac; \\
		echo "<=== \$(SDP)modules/\$\$i"; \\
	  fi; \\
	done

EOF

####################################################################
## Now create modules/xxx/Makefile
##
for moddir in $AUTODIRS ; do
	echo "Creating Makefile in $moddir"

    ${SHELL} helpers/mfhead $moddir $file > $moddir/Makefile
	$CAT Makefile.config |\
	sed -e "s:^SRCDIR=.*:SRCDIR=`${SHELL} helpers/fp2rp $moddir`:" >> $moddir/Makefile
	$CAT << 'EOF' >> $moddir/Makefile
##
##  Default Makefile options from Configure script
##  (Begin of automatically generated section)
##
CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
LIBS=$(EXTRA_LIBS) $(LIBS1)
INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
INCDIR=$(SRCDIR)/include
EOF
	if [ -f $moddir/Makefile.libdir ]; then
	    basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
	    awk >> $moddir/Makefile < $tmpfile '
		($2 ~ /^modules\/'$basedir'\//) {
		    split($2, pp, "/");
		    split(pp[3], parts, ".");
		    libext=parts[2];
		}
		END { 
		    printf "LIBEXT=%s\n", libext;
		}'
	    # it's responsible for the rest of its Makefile...
	else
	    basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
	    OBJS=`awk < $tmpfile '
		($1 == "Module" && $3 ~ /^modules\/'$basedir'\//) { 
		    split ($3, pp, "/")
		    printf "%s ", pp[3] 
		} 
		'`
	    echo "OBJS=$OBJS" >> $moddir/Makefile
	    if [ "x$OBJS" != "x" ]; then
		echo "LIB=lib$basedir.a" >> $moddir/Makefile
	    else
		#   essential!
		echo "LIB=" >> $moddir/Makefile
	    fi
	    awk >> $moddir/Makefile < $tmpfile '
	    ($1 == "SharedModule" && $2 ~ /^modules\/'$basedir'\//) {
		split($2, pp, "/")
		shlibs=shlibs " " pp[3]
		so=pp[3]
		split(pp[3], parts, ".")
		base=parts[1]
		objspic=objspic " " base ".lo"
	    }
	    END { 
		printf "SHLIBS=%s\n", shlibs;
		printf "OBJS_PIC=%s\n", objspic;
	    }'

	    $CAT << 'EOF' >> $moddir/Makefile

all: lib shlib

lib:	$(LIB) 

shlib:	$(SHLIBS)

dummy $(LIB): $(OBJS)
	rm -f $@
	ar cr $@ $(OBJS)
	$(RANLIB) $@

.SUFFIXES: .o .so .dll

.c.o:
	$(CC) -c $(INCLUDES) $(CFLAGS) $<

.c.so:
	$(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo
	$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $*.lo $(LIBS_SHLIB)

clean:
	rm -f $(LIB) $(OBJS) $(SHLIBS) $(OBJS_PIC)

distclean: clean
	rm -f Makefile

#   NOT FOR END USERS!
depend:
	cp Makefile.tmpl Makefile.tmpl.bak \
	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
		   -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
		> Makefile.tmpl \
	    && rm Makefile.new

EOF
	fi

	if [ "x$OS_MODULE_INCLUDE" != "x" ]; then
		echo "include $OS_MODULE_INCLUDE" >> $moddir/Makefile
	fi

	$CAT << 'EOF' >> $moddir/Makefile
##
##  (End of automatically generated section)
##
EOF
    $CAT >> $moddir/Makefile < $moddir/Makefile.tmpl

done