File: configure.in

package info (click to toggle)
squid 2.7.STABLE9-4.1%2Bdeb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,920 kB
  • sloc: ansic: 114,686; sh: 5,581; makefile: 1,362; perl: 1,359; awk: 40; sql: 8
file content (3403 lines) | stat: -rw-r--r-- 92,480 bytes parent folder | download | duplicates (3)
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
dnl
dnl  Configuration input file for Squid
dnl
dnl  $Id: configure.in,v 1.430.2.25 2010/03/14 21:40:46 hno Exp $
dnl
dnl
dnl
AC_INIT(Squid Web Proxy, 2.7.STABLE9, http://bugs.squid-cache.org/, squid)
AC_PREREQ(2.52)
AM_CONFIG_HEADER(include/autoconf.h)
AC_CONFIG_AUX_DIR(cfgaux)
AM_INIT_AUTOMAKE
AC_REVISION($Revision: 1.430.2.25 $)dnl
AC_PREFIX_DEFAULT(/usr/local/squid)
AM_MAINTAINER_MODE

PRESET_CFLAGS="$CFLAGS"
PRESET_LDFLAGS="$LDFLAGS"

dnl Set default LDFLAGS
if test -z "$LDFLAGS"; then
	LDFLAGS="-g"
fi

dnl Check for GNU cc
AC_PROG_CC
AM_PROG_CC_C_O
AC_CANONICAL_HOST


CRYPTLIB=''
REGEXLIB=''	# -lregex
LIBREGEX=''	# libregex.a

dnl Check for pkg-config
AC_PATH_PROG(PKGCONFIG, pkg-config, false)

dnl find out the exe extension for this platform. If it's not empty, use it for CGI's as well.
AC_EXEEXT
AC_OBJEXT

if test -z "$EXEEXT"; then
	CGIEXT=".cgi"
else
	# automake automatically adds .exe when installing binaries
	CGIEXT=""
fi
AC_SUBST(CGIEXT)

dnl this should be expanded to a list of platform sensible support requirements.
dnl (adding an option like --enable-cygwin-support doesn't make sense :]) - R Collins 2001
case "$host_os" in
mingw|mingw32|cygwin|cygwin32)
	AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, true)
	;;
*)
	AM_CONDITIONAL(ENABLE_WIN32SPECIFIC, false)
	;;
esac

case "$host_os" in
mingw|mingw32)
        AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, true)
	AC_PATH_PROG(WIN32_PSAPI, psapi.dll, none)
	CFLAGS="$CFLAGS -mthreads"
	if test "$ac_cv_path_WIN32_PSAPI" = "none"; then
		echo "PSAPI.DLL is recommended to run Squid on Windows Platform"
		echo "Please see PSAPI.DLL section on doc/release-notes/release-2.6.html."
	else
		AC_DEFINE(HAVE_WIN32_PSAPI,1,[Define if you have PSAPI.DLL on Windows systems])
		LIBS="$LIBS -lpsapi"
	fi
	;;
*)
	AM_CONDITIONAL(ENABLE_MINGW32SPECIFIC, false)
	;;
esac

if test -z "$CACHE_HTTP_PORT"; then
	CACHE_HTTP_PORT="3128"
fi
if test -z "$CACHE_ICP_PORT"; then
	CACHE_ICP_PORT="3130"
fi

dnl Substitutions
AC_DEFINE_UNQUOTED(CACHE_HTTP_PORT, $CACHE_HTTP_PORT, [What default TCP port to use for HTTP listening?])
AC_SUBST(CACHE_HTTP_PORT)
AC_DEFINE_UNQUOTED(CACHE_ICP_PORT, $CACHE_ICP_PORT, [What default UDP port to use for ICP listening?])
AC_SUBST(CACHE_ICP_PORT)

AC_DEFINE_UNQUOTED(CONFIG_HOST_TYPE, "$host", [Host type from configure])

AC_DEFINE_UNQUOTED(SQUID_CONFIGURE_OPTIONS, "$ac_configure_args", [configure command line used to configure Squid])

dnl Gerben Wierda <Gerben_Wierda@RnA.nl>
case "$host" in
    mab-next-nextstep3)
	CC="$CC -arch m68k -arch i486 -arch hppa -arch sparc"
	;;
esac

dnl Set Default CFLAGS
if test -z "$PRESET_CFLAGS"; then
    if test "$GCC" = "yes"; then
	case "$host" in
	*-sun-sunos*)
	    # sunos has too many warnings for this to be useful
	    # motorola too
	    ;;
	*m88k*-openbsd*)
	    ;;
	*m88k*)
	    # Motorola cc/ld does not like -02 but is ok on -O
	    CFLAGS=`echo $CFLAGS | sed -e 's/-O[0-9]/-O/'`
	    ;;
	*)
	    CFLAGS="-Wall $CFLAGS"
	    ;;
	esac
    else
	case "$host" in
	*mips-sgi-irix6.*)
	    # suggested by Rafael Seidl <rafaels@cthulhu.engr.sgi.com>
	    CFLAGS="-O3 -OPT:Olimit=0:space=OFF \
		-woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \
		-Wl,-woff,85,-woff,84,-woff,134 \
		-nostdinc -I/usr/include -D_BSD_SIGNALS $CFLAGS"
	    ;;
	alpha-dec-osf4.*)
	    # Mogul says DEC compilers take both -g and -O2
	    CFLAGS=`echo $CFLAGS | sed -e 's/-g/-g3/'`
	    CFLAGS="-O2 $CFLAGS"
	    ;;
	*)
	    ;;
	esac
    fi
fi

dnl Set LDFLAGS
if test -z "$PRESET_LDFLAGS"; then
    if test "$GCC" = "yes"; then
	case "$host" in
	*mips-sgi-irix6.*)
	    # Silence Linker warnings 84, 85 and 134
	    LDFLAGS="-Wl,-woff,85 -Wl,-woff,84 -Wl,-woff,134 $LDFLAGS"
	    ;;
	*)
	    # nothing
	    ;;
	esac
    else
	case "$host" in
	*)
	    # nothing
	    ;;
	esac
    fi
fi

dnl Enable optional modules
AC_ARG_ENABLE(dlmalloc,
[  --enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea],
[
 case "$enableval" in
 'yes')
    use_dlmalloc="yes"
    LIBDLMALLOC="libdlmalloc.a"
    LIB_MALLOC="-L../lib -ldlmalloc"
    echo "dlmalloc enabled"
    ;;
 'no')
    use_dlmalloc="no"
    echo "dlmalloc disabled"
    ;;
 *) use_dlmalloc="yes"
    LIB_MALLOC="$enableval"
    echo "dlmalloc enabled with $LIB_MALLOC"
 esac
])
if test "${use_dlmalloc-unset}" = unset; then
    case "$host" in
	i386-*-solaris2.*)
		echo "Enabling dlmalloc for $host"
		use_dlmalloc="yes"
		LIBDLMALLOC="libdlmalloc.a"
		LIB_MALLOC="-L../lib -ldlmalloc"
		;;
	*-sgi-irix*)
		echo "Enabling dlmalloc for $host"
		use_dlmalloc="yes"
		LIBDLMALLOC="libdlmalloc.a"
		LIB_MALLOC="-L../lib -ldlmalloc"
		;;
    esac
fi
if test "x$ac_cv_enabled_dlmalloc" = "xyes"; then
    # Ok. dlmalloc was enabled before, but state may be changed.
    # we have to test these again
    unset ac_cv_func_mallinfo
    unset ac_cv_func_mallocblksize
    unset ac_cv_func_free
    unset ac_cv_func_realloc
    unset ac_cv_func_memalign
    unset ac_cv_func_valloc
    unset ac_cv_func_pvalloc
    unset ac_cv_func_calloc
    unset ac_cv_func_cfree
    unset ac_cv_func_malloc_trim
    unset ac_cv_func_malloc_usable_size
    unset ac_cv_func_malloc_stats
    unset ac_cv_func_mallinfo
    unset ac_cv_func_mallopt
    unset ac_cv_lib_gnumalloc
    unset ac_cv_header_gnumalloc_h
    unset ac_cv_lib_malloc
    unset ac_cv_enabled_dlmalloc
fi
if test "$use_dlmalloc" = yes; then
    ac_cv_func_mallinfo="yes"
    ac_cv_func_mallocblksize="no"
    ac_cv_func_free="yes"
    ac_cv_func_realloc="yes"
    ac_cv_func_memalign="yes"
    ac_cv_func_valloc="yes"
    ac_cv_func_pvalloc="yes"
    ac_cv_func_calloc="yes"
    ac_cv_func_cfree="yes"
    ac_cv_func_malloc_trim="yes"
    ac_cv_func_malloc_usable_size="yes"
    ac_cv_func_malloc_stats="yes"
    ac_cv_func_mallopt="yes"
    ac_cv_lib_gnumalloc="no"
    ac_cv_header_gnumalloc_h="no"
    ac_cv_lib_malloc="no"
    ac_cv_enabled_dlmalloc="yes"
fi

AC_SUBST(LIBDLMALLOC)
AC_SUBST(LIB_MALLOC)

AC_ARG_ENABLE(gnuregex,
[  --enable-gnuregex       Compile GNUregex.  Unless you have reason to use this
			  option, you should not enable it.  This library file
			  is usually only required on Windows and very old
			  Unix boxes which do not have their own regex library
			  built in.],
[USE_GNUREGEX=$enableval])

dnl This is a developer only option.. developers know how to set defines
dnl
dnl AC_ARG_ENABLE(xmalloc-debug,
dnl [  --enable-xmalloc-debug  Do some simple malloc debugging],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Malloc debugging enabled"
dnl     AC_DEFINE(XMALLOC_DEBUG, 1, [Define to do simple malloc debugging])
dnl   fi
dnl ])

dnl This is a developer only option.. developers know how to set defines
dnl
dnl AC_ARG_ENABLE(xmalloc-debug-trace,
dnl [  --enable-xmalloc-debug-trace
dnl                           Detailed trace of memory allocations],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Malloc debug trace enabled"
dnl     AC_DEFINE(XMALLOC_TRACE, 1, [Define to have a detailed trace of memory allocations])
dnl     AC_DEFINE(XMALLOC_DEBUG, 1, [Define to do simple malloc debugging])
dnl   fi
dnl ])

AC_ARG_WITH(valgrind-debug,
[  --with-valgrind-debug   Include debug instrumentation for use with valgrind],
[ case $withval in
  yes)
	valgrind=1
	;;
  no)
	valgrind=
	;;
  *)
	CPPFLAGS="$CPPFLAGS -I${enableval}/include"
	valgrind=1
	;;
  esac
  if test $valgrind; then
	AC_DEFINE(WITH_VALGRIND, 1, [Valgrind memory debugger support])
	echo "Valgrind debug support enabled"
  fi
])

AC_ARG_ENABLE(mempool-debug,
[  --enable-mempool-debug  Include MemPool debug verifications])
if test "$enable_mempool_debug" = yes; then
	AC_DEFINE(DEBUG_MEMPOOL, 1, [MemPool debug verifications])
	echo "Mempool debug checks enabled"
fi

AC_ARG_ENABLE(xmalloc-statistics,
[  --enable-xmalloc-statistics
			  Show malloc statistics in status page],
[ if test "$enableval" = "yes" ; then
    echo "Malloc statistics enabled"
    AC_DEFINE(XMALLOC_STATISTICS, 1, [Define to have malloc statistics])
  fi
])

USE_CARP=1
AC_ARG_ENABLE(carp,
[  --disable-carp           Disable CARP support],
[ if test "$enableval" = "no" ; then
    echo "CARP disabled"
    USE_CARP=0
  fi
])      
if test $USE_CARP = 1; then
    AC_DEFINE(USE_CARP, 1, [Cache Array Routing Protocol])
fi

AC_ARG_ENABLE(async-io,
[  --enable-async-io[=N_THREADS]
			  Shorthand for
			  --with-aufs-threads=N_THREADS
			  --with-pthreads
			  --enable-storeio=ufs,aufs],
[ case $enableval in
  yes)
	with_pthreads="yes"
	STORE_MODULES="ufs aufs"
    ;;
  no)
    ;;
  *)
	aufs_io_threads=$enableval
	with_pthreads="yes"
	STORE_MODULES="ufs aufs"
    ;;
  esac
])

AC_ARG_WITH(aufs-threads,
[  --with-aufs-threads=N_THREADS
			  Tune the number of worker threads for the aufs object
			  store.],
[ case $withval in
  [[0-9]]*)
    aufs_io_threads=$withval
    ;;
  *)
    echo "ERROR: Invalid --with-aufs-threads argument"
    exit 1
    ;;
  esac
])
if test "$aufs_io_threads"; then
    echo "With $aufs_io_threads aufs threads"
    AC_DEFINE_UNQUOTED(AUFS_IO_THREADS, $aufs_io_threads, [Defines how many threads aufs uses for I/O])
fi

AC_ARG_WITH(pthreads,
[  --with-pthreads         Use POSIX Threads])
if test "$with_pthreads" = "yes"; then
    echo "With pthreads"
fi

AC_ARG_WITH(aio,
[  --with-aio              Use POSIX AIO])
if test "$with_aio" = "yes"; then
    echo "With aio"
fi

AC_ARG_WITH(dl,
[  --with-dl               Use dynamic linking])
if test "$with_dl" = "yes"; then
    echo "With dl"
fi

AC_ARG_ENABLE(storeio,
[  --enable-storeio="list of modules"
			  Build support for the list of store I/O modules.
			  The default is only to build the "ufs" module.
			  See src/fs for a list of available modules, or
			  Programmers Guide section <not yet written>
			  for details on how to build your custom store module],
[ case $enableval in
  yes)
	for module in $srcdir/src/fs/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    STORE_MODULES="$STORE_MODULES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)	STORE_MODULES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$STORE_MODULES"; then
    STORE_MODULES="ufs"
  fi
])
echo "Store modules built: $STORE_MODULES"
NEED_DISKD=0
USE_AIOPS_WIN32=0
NEED_COSSDUMP=0
STORE_OBJS="fs/lib`echo $STORE_MODULES|sed -e 's% %.a fs/lib%g'`.a"
AC_SUBST(STORE_OBJS)
STORE_LIBS="`echo $STORE_OBJS|sed -e 's%fs/%%g'`"
AC_SUBST(STORE_LIBS)
dnl some store implementations need additional stuff built like diskd_daemon
STORE_MODULE_SUBDIRS=
for fs in $STORE_MODULES none; do
    case "$fs" in
    diskd)
	NEED_DISKD=1
	;;
    aufs)
	if test -z "$with_pthreads"; then
            case "$host_os" in
            mingw|mingw32)
        	USE_AIOPS_WIN32=1
	        echo "aufs store used, Windows threads support automatically enabled"
                ;;
            *)
	        echo "aufs store used, pthreads support automatically enabled"
	        with_pthreads=yes
                ;;
            esac
	fi
	;;
    coss)
	NEED_COSSDUMP=1
	if test -z "$with_aio"; then
	    echo "coss store used, aio support automatically enabled"
	    with_aio=yes
	fi
	;;
    esac
done
AC_SUBST(STORE_MODULES)
AM_CONDITIONAL([NEED_DISKD], [test "$NEED_DISKD" = 1])
AM_CONDITIONAL([USE_AIOPS_WIN32], [test "$USE_AIOPS_WIN32" = 1])
AM_CONDITIONAL([NEED_COSSDUMP], [test "$NEED_COSSDUMP" = 1])

dnl --enable-heap-replacement compatibility option
AC_ARG_ENABLE(heap-replacement,
[  --enable-heap-replacement
			  Backwards compatibility option. Please use the
			  new --enable-removal-policies directive instead.],
[ if test "$enableval" = "yes" ; then
    echo "--enable-heap-replacement is obsolete. please use the new"
    echo "--enable-removal-policies directive instead"
    sleep 5
    REPL_POLICIES="heap"
  fi
])

AC_ARG_ENABLE(removal-policies,
[  --enable-removal-policies="list of policies"
			  Build support for the list of removal policies.
			  The default is only to build the "lru" module.
			  See src/repl for a list of available modules, or
			  Programmers Guide section 9.9 for details on how
			  to build your custom policy],
[ case $enableval in
  yes)
	for module in $srcdir/src/repl/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    REPL_POLICIES="$REPL_POLICIES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)	REPL_POLICIES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$REPL_POLICIES"; then
    REPL_POLICIES="lru"
  fi
])
echo "Removal policies built: $REPL_POLICIES"
AC_SUBST(REPL_POLICIES)
REPL_OBJS="repl/lib`echo $REPL_POLICIES|sed -e 's% %.a repl/lib%g'`.a"
AC_SUBST(REPL_OBJS)
REPL_LIBS="`echo $REPL_OBJS|sed -e 's%repl/%%g'`"
AC_SUBST(REPL_LIBS)

AM_CONDITIONAL(ENABLE_PINGER, false)
AC_ARG_ENABLE(icmp,
[  --enable-icmp           Enable ICMP pinging],
[ if test "$enableval" = "yes" ; then
    echo "ICMP enabled"
    AC_DEFINE(USE_ICMP, 1, [If you want to use Squid's ICMP features (highly recommended!) then
	define this.  When USE_ICMP is defined, Squid will send ICMP pings
	to origin server sites.  This information is used in numerous ways:
	- Sent in ICP replies so neighbor caches know how close
	  you are to the source.
	- For finding the closest instance of a URN.
	- With the 'test_reachability' option.  Squid will return
	  ICP_OP_MISS_NOFETCH for sites which it cannot ping.])
    AM_CONDITIONAL(ENABLE_PINGER, true)
  fi
])

AM_CONDITIONAL(USE_DELAY_POOLS, false)
AC_ARG_ENABLE(delay-pools,
[  --enable-delay-pools    Enable delay pools to limit bandwidth usage],
[ if test "$enableval" = "yes" ; then
    echo "Delay pools enabled"
    AC_DEFINE(DELAY_POOLS, 1, [Traffic management via "delay pools".])
    AM_CONDITIONAL(USE_DELAY_POOLS, true)
  fi
])

dnl This is a developer only option. Developers know how to set defines
dnl
dnl AC_ARG_ENABLE(mem-gen-trace,
dnl [  --enable-mem-gen-trace  Do trace of memory stuff],
dnl [ if test "$enableval" = "yes" ; then
dnl     echo "Memory trace (to file) enabled"
dnl     AC_DEFINE(MEM_GEN_TRACE, 1, [Define for log file trace of mem alloc/free])
dnl   fi    
dnl ])     

AC_ARG_ENABLE(useragent-log,
[  --enable-useragent-log  Enable logging of User-Agent header],
[ if test "$enableval" = "yes" ; then
    echo "User-Agent logging enabled"
    AC_DEFINE(USE_USERAGENT_LOG, 1, [If you want to log User-Agent request header values, define this.
	By default, they are written to useragent.log in the Squid log directory.])
  fi
])

AC_ARG_ENABLE(referer-log,
[  --enable-referer-log    Enable logging of Referer header],
[ if test "$enableval" = "yes" ; then
    echo "Referer logging enabled"
    AC_DEFINE(USE_REFERER_LOG, 1, [If you want to log Referer request header values, define this.
	By default, they are written to referer.log in the Squid log directory.])
  fi
])

USE_WCCP=1
AC_ARG_ENABLE(wccp,  
[  --disable-wccp          Disable Web Cache Coordination V1 Protocol],
[ if test "$enableval" = "no" ; then
    echo "Web Cache Coordination V1 Protocol disabled"
    USE_WCCP=0
  fi
])      
if test $USE_WCCP = 1; then
    AC_DEFINE(USE_WCCP, 1, [Define to enable WCCP])
fi

USE_WCCPv2=1
AC_ARG_ENABLE(wccpv2,
[  --disable-wccpv2        Disable Web Cache Coordination V2 Protocol],
[ if test "$enableval" = "no" ; then
    echo "Web Cache Coordination V2 Protocol disabled"
    USE_WCCPv2=0
  fi
])
if test $USE_WCCPv2 = 1; then
    AC_DEFINE(USE_WCCPv2, 1, [Define to enable WCCP V2])
fi


AC_ARG_ENABLE(kill-parent-hack,
[  --enable-kill-parent-hack
			  Kill parent on shutdown],
[ if test "$enableval" = "yes" ; then
    echo "Kill parent on shutdown"
    AC_DEFINE(KILL_PARENT_OPT, 1, [A dangerous feature which causes Squid to kill its parent process
	(presumably the RunCache script) upon receipt of SIGTERM or SIGINT.  Use with caution.])
  fi
])

AC_ARG_ENABLE(forward-log,
[  --enable-forward-log    Enable experimental forward_log directive],
[ if test "$enableval" = "yes" ; then
    echo "forward_log enabled"
    AC_DEFINE(WIP_FWD_LOG, 1, [Define to enable experimental forward_log directive])
  fi
])
 
AC_ARG_ENABLE(multicast-miss,
[  --enable-multicast-miss Enable experimental multicast notification of cachemisses],
[ if test "$enableval" = "yes" ; then
    echo "multicast of cache miss URLs enabled"
    AC_DEFINE(MULTICAST_MISS_STREAM, 1, [Define to enable experimental multicast of cache miss URLs])
  fi
])
 
AM_CONDITIONAL(USE_SNMP, false)
AC_ARG_ENABLE(snmp,
[  --enable-snmp           Enable SNMP monitoring],
[ if test "$enableval" = "yes" ; then
    echo "SNMP monitoring enabled"
    AC_DEFINE(SQUID_SNMP, 1, [Define to enable SNMP monitoring of Squid])
    SNMPLIB='../snmplib/libsnmp.a'
    AM_CONDITIONAL(USE_SNMP, true)
    SNMP_MAKEFILE=./snmplib/Makefile
    makesnmplib=snmplib
  fi
])
AC_SUBST(SNMPLIB)
AC_SUBST(makesnmplib)

AC_ARG_ENABLE(cachemgr-hostname,
[  --enable-cachemgr-hostname[=hostname]
			  Make cachemgr.cgi default to this host],
[  case $enableval in
   yes)
       AC_DEFINE(CACHEMGR_HOSTNAME, [getfullhostname()], [If you are upset that the cachemgr.cgi form comes up with the hostname
	field blank, then define this to getfullhostname()])
       echo "Cachemgr default hostname == host where cachemgr runs"
       ;;
   no)
       : # Nothing to do..
       ;;
   *)
       AC_DEFINE_UNQUOTED(CACHEMGR_HOSTNAME, "${enableval}", [If you are upset that the cachemgr.cgi form comes up with the hostname
	field blank, then define this to getfullhostname()])
       echo "Cachemgr default hostname set to ${enableval}"
       ;;
   esac
])

AC_ARG_ENABLE(arp-acl,
[  --enable-arp-acl        Enable use of ARP ACL lists (ether address)],
[  if test "$enableval" = "yes" ; then
     echo "ARP ACL lists enabled (ether address)"
     case "$host" in
	*-linux-*)
	    ;;
	*-solaris*)
	    ;;
	*-freebsd*)
	    ;;
	*-netbsd*)
	    ;;
	*-openbsd*)
	    ;;
	*-cygwin*)
	LIBS="$LIBS -liphlpapi"
	    ;;
	*-mingw*)
	LIBS="$LIBS -liphlpapi"
	    ;;
	*)
	    echo "WARNING: ARP ACL support probably won't work on $host."
	    sleep 10
	    ;;
     esac
     AC_DEFINE(USE_ARP_ACL, 1, [Define this to include code which lets you specify access control
	elements based on ethernet hardware addresses.  This code uses
	functions found in 4.4 BSD derviations (e.g. FreeBSD, ?).])
   fi
])

AM_CONDITIONAL(ENABLE_HTCP, false)
AC_ARG_ENABLE(htcp,
[  --enable-htcp           Enable HTCP protocol],
[ if test "$enableval" = "yes" ; then
    echo "HTCP enabled"
    AC_DEFINE(USE_HTCP, 1, [Define this to include code for the Hypertext Cache Protocol (HTCP)])
    AM_CONDITIONAL(ENABLE_HTCP, true)
  fi
])

dnl SSL is not enabled by default.
AM_CONDITIONAL(ENABLE_SSL, false)

SSLLIB=''
SSLFLAGS=''

dnl Default is to use OpenSSL when available
AC_ARG_ENABLE(ssl,
[  --enable-ssl            Enable ssl gatewaying support using OpenSSL],
[ if test "$enableval" != "no"; then
    echo "SSL gatewaying using OpenSSL enabled"
    AC_DEFINE(USE_SSL, 1, [Define this to include code for SSL encryption.])
    AM_CONDITIONAL(ENABLE_SSL, true)
    case "$host_os" in
    mingw|mingw32)
	SSLLIB='-lssleay32 -leay32 -lgdi32'
	;;
    *)
	SSLLIB='-lssl -lcrypto'
	;;
    esac
    USE_OPENSSL=1
  fi
])

USE_SQUID_MD5=0
AC_ARG_WITH(system-md5,
[  --without-system-md5    Disable the use of any system provided MD5
			  Implementation forcing fallback on the internal
			  implementation shipped with Squid],
[
  case "$enableval" in
  no)
	AC_DEFINE(USE_SQUID_MD5, 1, [Define this to force use of the internal MD5 implementation])
	;;
  esac
])

dnl User may specify OpenSSL is needed from a non-standard location
AC_ARG_WITH(openssl,
[  --with-openssl[=prefix]
			  Compile with the OpenSSL libraries. The path to
			  the OpenSSL development libraries and headers
			  installation can be specified if outside of the
			  system standard directories],
[ 
  case "$with_openssl" in
  yes)
    USE_OPENSSL=1
    ;;
  no)
    USE_OPENSSL=
    ;;
  *)
    PKG_CONFIG_PATH="$with_openssl/lib/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}"
    export PKG_CONFIG_PATH
    SSLLIB="-L$with_openssl/lib -lssl -lcrypto"
    SSLFLAGS="-I$with_openssl/include"
    USE_OPENSSL=1
  esac
])

if test -n "$USE_OPENSSL"; then
  echo "Using OpenSSL MD5 implementation"
  AC_DEFINE(USE_OPENSSL, 1, [Define this to make use of the OpenSSL libraries for
	MD5 calculation rather than Squid's own MD5 implementation
	or if building with SSL encryption (USE_SSL)])
  if test -z "$SSLLIB"; then
    SSLLIB="-lcrypto" # for MD5 routines
  fi
  if $PKGCONFIG --exists openssl; then
    SSLLIB="`$PKGCONFIG --libs openssl`"
    SSLFLAGS="`$PKGCONFIG --cflags openssl`"
  fi
  CPPFLAGS="${SSLFLAGS} $CPPFLAGS"
fi
AC_SUBST(SSLLIB)


AC_ARG_ENABLE(forw-via-db,
[  --enable-forw-via-db    Enable Forw/Via database],
[ if test "$enableval" = "yes" ; then
    echo "FORW-VIA enabled"
    AC_DEFINE(FORW_VIA_DB, 1, [Enable Forw/Via database])
  fi
])

AC_ARG_ENABLE(cache-digests,
[  --enable-cache-digests  Use Cache Digests
			  see http://www.squid-cache.org/FAQ/FAQ-16.html],
[ if test "$enableval" = "yes" ; then
    echo "USE_CACHE_DIGESTS enabled"
    AC_DEFINE(USE_CACHE_DIGESTS, 1, [Use Cache Digests for locating objects in neighbor caches.  This
	code is still semi-experimental.])
  fi
])

dnl Select Default Error language
AC_ARG_ENABLE(default-err-language,
[  --enable-default-err-language=lang
			  Select default language for Error pages (see
			  errors directory) ],
[
    if test -d $srcdir/errors/$enableval; then
	ERR_DEFAULT_LANGUAGE=$enableval
    else
	echo "ERROR! Unknown language $enableval, see errors/ directory"
	exit 1
    fi
],[ERR_DEFAULT_LANGUAGE="English"])
AC_SUBST(ERR_DEFAULT_LANGUAGE)

dnl Select languages to be installed
AC_ARG_ENABLE(err-languages,
[  --enable-err-languages=\"lang1 lang2..\"
			  Select languages to be installed. (All will be
			  installed by default) ],
[
    for l in $enableval; do
	if test -d $srcdir/errors/$l; then :; else
	    echo "ERROR! Unknown language $$l, see errors/"
	    exit 1
	fi
    done
    ERR_LANGUAGES=$enableval
],[
    ERR_LANGUAGES=
    for l in $srcdir/errors/*; do
	if test -f $l/ERR_ACCESS_DENIED; then
	    ERR_LANGUAGES="$ERR_LANGUAGES `basename $l`"
	fi
    done
])
AC_SUBST(ERR_LANGUAGES)

dnl Size of COSS memory buffer
AC_ARG_WITH(coss-membuf-size,
[  --with-coss-membuf-size COSS membuf size (default 1048576 bytes) ],
[  if test "$with_coss_membuf_size"; then
      echo "Setting COSS membuf size to $with_coss_membuf_size bytes"
      AC_DEFINE_UNQUOTED(COSS_MEMBUF_SZ, $with_coss_membuf_size, [Define if you want to set the COSS membuf size])
   fi
])

dnl COSS I/O method
AC_ARG_ENABLE(coss-aio-ops,
[  --enable-coss-aio-ops   Enable COSS I/O with Posix AIO (default is aufs I/O) ])
if test "$enable_coss_aio_ops" = "yes"; then
      echo "Using Posix AIO method for COSS disk I/O"
      AC_DEFINE(USE_AUFSOPS, 0, [  Define this if you would like to use the aufs I/O method for
	   disk I/O instead of the POSIX AIO method.])
else
      AC_DEFINE(USE_AUFSOPS, 1, [  Define this if you would like to use the aufs I/O method for
	   disk I/O instead of the POSIX AIO method.])
fi

dnl Enable select()
AC_ARG_ENABLE(select,
[  --enable-select         Force the use of select support.
			  Normally configure automatically selects a better
			  alternative if available.
  --disable-select        Disable select support, causing configure to fail
			  if a better alternative is not available],

[
  case "$enableval" in
  yes)
    echo "Forcing select() to be enabled"
    SELECT_TYPE="select"
    ac_cv_func_select='yes'
    ;;
  no)
    echo "Forcing select() to be disabled"
    ac_cv_func_select='no'
    ;;
  esac
])

dnl Enable select()
AC_ARG_ENABLE(select-simple,
[  --enable-select-simple  Force the use of select support (POSIX).
			  Useful if your system only supports the bare minium
			  POSIX select requirements without fds_bits.],
[
  case "$enableval" in
  yes)
    echo "Forcing select() to be enabled in simple POSIX mode"
    SELECT_TYPE="select_simple"
    ac_cv_func_select='yes'
    ;;
  no)
    echo "Forcing select() to be disabled"
    ac_cv_func_select='no'
    ;;
  esac
])

dnl Enable poll()
AC_ARG_ENABLE(poll,
[  --enable-poll           Force the use of poll even if automatic checks
			  indicate poll may be broken on your plaform.
  --disable-poll          Disable the use of poll.],
[ 
  case "$enableval" in
  yes)
    echo "Forcing poll() to be enabled"
    SELECT_TYPE="poll"
    ac_cv_func_poll='yes'
    ;;
  no)
    echo "Forcing poll() to be disabled"
    ac_cv_func_poll='no'
    ;;
  esac
])

dnl Enable epoll()
AC_ARG_ENABLE(epoll,
[  --enable-epoll          Force the use of epoll even if automatic checks
			  indicate epoll may not be supported.
  --disable-epoll         Disable the use of epoll.],
[ 
  case "$enableval" in
  yes)
    echo "Forcing epoll() to be enabled"
    SELECT_TYPE="epoll"
    force_epoll='yes'
    ;;
  no)
    echo "Forcing epoll() to be disabled"
    ac_cv_func_epoll_ctl='no'
    ;;
  esac
])

dnl Enable kqueue
AC_ARG_ENABLE(kqueue,
[  --enable-kqueue         Force the use of kqueue even if automatic checks
			  indicate kqueue may not be supported.
  --disable-kqueue        Disable kqueue support. ],

[
  case "$enableval" in
  yes)
    echo "Forcing kqueue to be enabled"
    SELECT_TYPE="kqueue"
    ac_cv_func_kqueue='yes'
    ;;
  no)
    echo "Forcing kqueue to be disabled"
    ac_cv_func_kqueue='no'
    ;;
  esac
])

dnl Enable devpoll
AC_ARG_ENABLE(devpoll,
[  --enable-devpoll       Use Solaris /dev/poll instead of poll],
[
  case "$enableval" in
  yes)
    echo "Forcing devpoll to be enabled"
    SELECT_TYPE="devpoll"
    ;;
  no)
    echo "Forcing devpoll to be disabled"
    ;;
  esac
])


dnl Disable HTTP violations
HTTP_VIOLATIONS=1
AC_ARG_ENABLE(http-violations,
[  --disable-http-violations
			  This allows you to remove code which is known to
			  violate the HTTP protocol specification.],
[ if test "$enableval" = "no" ; then
    echo "Disabling HTTP Violations"
    HTTP_VIOLATIONS=0
  fi
])
if test $HTTP_VIOLATIONS = 1; then
    AC_DEFINE(HTTP_VIOLATIONS, 1, [By default (for now anyway) Squid includes options which allows the cache administrator to violate the HTTP protocol specification in terms of cache behaviour.  Setting this to '0' will disable such code.])
fi

dnl Enable IP-Filter Transparent Proxy
AC_ARG_ENABLE(ipf-transparent,
[  --enable-ipf-transparent
			  Enable Transparent Proxy support for systems
			  using IP-Filter network address redirection.],
[ if test "$enableval" = "yes" ; then
	echo "IP-Filter Transparent Proxy enabled"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
	IPF_TRANSPARENT="yes"
	dnl On Solaris Ipfilter includes expect that SOLARIS2 is defined with the
	dnl Solaris minor version (8, 9, 10, ...)
	case "$host" in
	*-solaris*)
	    solrev=`uname -r | sh -c 'IFS=. read j n x; echo $n'`
	    CFLAGS="-DSOLARIS2=$solrev $CFLAGS" 
	    ;;
	*)
	    ;;
	esac

  fi
])

dnl Enable PF Transparent Proxy
AC_ARG_ENABLE(pf-transparent,
[  --enable-pf-transparent
			  Enable Transparent Proxy support for systems
			  using PF network address redirection.],
[ if test "$enableval" = "yes" ; then
	echo "PF Transparent Proxy enabled"
	AC_DEFINE(PF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
	PF_TRANSPARENT="yes"
  fi
])

dnl Enable Linux Netfilter Transparent Proxy
AC_ARG_ENABLE(linux-netfilter,
[  --enable-linux-netfilter
			  Enable Transparent Proxy support for Linux 2.4 and later],
[ if test "$enableval" = "yes" ; then
	echo "Linux-Netfilter Transparent Proxy enabled"
	AC_DEFINE(LINUX_NETFILTER, 1, [Enable support for Transparent Proxy on Linux 2.4 and later])
	LINUX_NETFILTER="yes"
  fi
])

dnl Enable Large file support
buildmodel=""
needlargefiles=

AC_ARG_WITH(large-files,
[  --with-large-files      Enable support for large files (logs etc).],
[ if test "$withval" = yes; then
	needlargefiles=1
  fi
])

AC_ARG_ENABLE(large-cache-files,
[  --enable-large-cache-files
			  Enable support for large cache files (>2GB).
			  WARNING: on-disk cache format is changed by this option],
[ if test "$enableval" = "yes" ; then
	echo "Large cache file support enabled"
	AC_DEFINE(LARGE_CACHE_FILES, 1, [Support large cache files > 2GB])
dnl	needlargefiles=1
  fi
])

dnl UNIX Build environment
AC_ARG_WITH(build-environment,
[  --with-build-environment=model
			  The build environment to use. Normally one of
			  POSIX_V6_ILP32_OFF32   32 bits
			  POSIX_V6_ILP32_OFFBIG  32 bits with large file support
			  POSIX_V6_LP64_OFF64    64 bits
			  POSIX_V6_LPBIG_OFFBIG  large pointers and files
			  XBS5_ILP32_OFF32       32 bits (legacy)
			  XBS5_ILP32_OFFBIG      32 bits with large file support (legacy)
			  XBS5_LP64_OFF64        64 bits (legacy)
			  XBS5_LPBIG_OFFBIG      large pointers and files (legacy)
			  default                The default for your OS],
[ case "$withval" in
  yes|no)
	echo "--with-build-environment expects a build environment string as used by getconf"
	exit 1
	;;
  *)
	buildmodel="$withval"
	;;
  esac
])

if test $needlargefiles && test -z "$buildmodel"; then
	for model in POSIX_V6_LPBIG_OFFBIG XBS5_LPBIG_OFFBIG POSIX_V6_LP64_OFF64 XBS5_LP64_OFF64 POSIX_V6_ILP32_OFFBIG XBS5_ILP32_OFFBIG; do
		if test "`getconf _$model 2>/dev/null || true`" = 1 || test "`getconf $model 2>/dev/null || true`" ; then
			buildmodel=$model
			break
		fi
	done
	if test -z "$buildmodel"; then
		echo "WARNING: No suitable build environment found for large files. Trying to use _FILE_OFFSET_BITS=64"
		sleep 1
	fi
fi
case "$buildmodel" in
"default"|"")
	if test $needlargefiles; then
		echo "Enabling -D_FILE_OFFSET_BITS=64 for large file support"
		CFLAGS="-D_FILE_OFFSET_BITS=64 $CFLAGS"
	fi
	;;
*)
	echo "Using $buildmodel build environment"
	if test "`getconf _$buildmodel 2>/dev/null || true`" = 1 || test "`getconf $buildmodel 2>/dev/null || true`" ; then
	    : # All fine
	else
	    echo "ERROR: Build environment $buildmodel not known to getconf."
	    exit 1
	fi
	CFLAGS="`getconf ${buildmodel}_CFLAGS` $CFLAGS"
	LIBS="`getconf ${buildmodel}_LIBS` $LIBS"
	LDFLAGS="`getconf ${buildmodel}_LDFLAGS` $LDFLAGS"
	case "$host" in
dnl
dnl On Solaris getconf returns for CFLAGS -xarch=generic64, -Xa and -Usun options, and
dnl for LDFLAGS -xarch=generic64, but:
dnl   "-Xa" is supported only by Sun cc, so we need to remove it when using gcc
dnl   For gcc "-xarch=generic64" must be replaced with "-m64"
dnl   The 'sun' define is needed by ipfilter includes, so we must remove "-Usun"
	    *-solaris*)
		if test "$GCC" = "yes"; then
		    echo "Removing -Xa for gcc on $host"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-Xa//'`"
		    echo "Replacing -xarch=generic64 with -m64 for gcc on $host"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-xarch=generic64/-m64/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-xarch=generic64//'`"
		fi
		echo "Removing -Usun on $host"
		CFLAGS="`echo $CFLAGS | sed -e 's/-Usun//'`"
		;;
dnl		
dnl On Irix 6.x getconf returns options valid only for the SGI MipsPRO compiler,
dnl so we must adjust something to avoid gcc errors.
dnl On Irix 6.x 32/64 bit we must replace "-n32" with "-mabi=n32" in CFLAGS and
dnl remove "-n32" from LDFLAGS
dnl On Irix 6.x 64 bit we must replace "-64" with "-mabi=64" in CFLAGS and remove
dnl "-64" from LDFLAGS
	    *-sgi-irix6.*)
		if test "$GCC" = "yes"; then
		    CFLAGS="`echo $CFLAGS | sed -e 's/-n32/-mabi=n32/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-n32//'`"
		    CFLAGS="`echo $CFLAGS | sed -e 's/-64/-mabi=64/'`"
		    LDFLAGS="`echo $LDFLAGS | sed -e 's/-64//'`"
		fi
		;;
	    *)
		;;
	esac
	;;
esac

dnl Enable Linux transparent proxy support
AC_ARG_ENABLE(linux-tproxy,
[  --enable-linux-tproxy
			  Enable real Transparent Proxy support for Netfilter TPROXY.],
[ if test "$enableval" = "yes" ; then
	echo "Linux Netfilter/TPROXY enabled"
	AC_DEFINE(LINUX_TPROXY, 1, [Enable real Transparent Proxy support for Netfilter TPROXY.])
	LINUX_TPROXY="yes"
        if test -z "$LINUX_NETFILTER"; then
	    echo "Linux-Netfilter Transparent Proxy automatically enabled"
	    LINUX_NETFILTER="yes"
	fi
  fi
])

AM_CONDITIONAL(MAKE_LEAKFINDER, false)
dnl Enable Leak Finding Functions
AC_ARG_ENABLE(leakfinder,
[  --enable-leakfinder
			  Enable Leak Finding code.  Enabling this alone
			  does nothing; you also have to modify the source
			  code to use the leak finding functions.  Probably
			  Useful for hackers only.],
[ if test "$enableval" = "yes" ; then
	echo "Leak-Finding enabled"
	AC_DEFINE(USE_LEAKFINDER, 1, [Enable code for assiting in finding memory leaks.  Hacker stuff only.])
	USE_LEAKFINDER="yes"
	AM_CONDITIONAL(MAKE_LEAKFINDER, true)
  fi
])

USE_IDENT=1
AC_ARG_ENABLE(ident-lookups,
[  --disable-ident-lookups
			  This allows you to remove code that performs
			  Ident (RFC 931) lookups.],
[ if test "$enableval" = "no" ; then
    echo "Disabling Ident Lookups"
    USE_IDENT=0
  fi
])
if test $USE_IDENT = 1; then
    AC_DEFINE(USE_IDENT, 1, [Compile in support for Ident (RFC 931) lookups?  Enabled by default.])
fi

AM_CONDITIONAL(USE_DNSSERVER, false)
use_dnsserver=
AC_ARG_ENABLE(internal-dns,
[  --disable-internal-dns  This prevents Squid from directly sending and
			  receiving DNS messages, and instead enables the
			  old external 'dnsserver' processes.],
[ if test "$enableval" = "no" ; then
    echo "Disabling Internal DNS queries"
    use_dnsserver="yes"
  fi
])
if test "$use_dnsserver" = "yes"; then
    AC_DEFINE(USE_DNSSERVERS, 1, [If --disable-internal-dns was given to configure, then we'll use
	the dnsserver processes instead.])
    AM_CONDITIONAL(USE_DNSSERVER, true)
    dnl Some platforms need -lresolv when using --disable-internal-dns
     case "$host" in
	*-solaris*)
        LIBS="$LIBS -lresolv"
	    ;;
	*-cygwin*)
        LIBS="$LIBS -lresolv"
        ;;
    esac
fi

AC_ARG_ENABLE(truncate,
[  --enable-truncate       This uses truncate() instead of unlink() when
			  removing cache files.  Truncate gives a little
			  performance improvement, but may cause problems
			  when used with async I/O.  Truncate uses more
			  filesystem inodes than unlink..],
[ if test "$enableval" = "yes" ; then
    echo "Enabling truncate instead of unlink"
    AC_DEFINE(USE_TRUNCATE, 1, [Do we want to use truncate(2) or unlink(2)?])
  fi
])

dnl Select Default hosts file location
AC_ARG_ENABLE(default-hostsfile,
[  --enable-default-hostsfile=path
			  Select default location for hosts file.
			  See hosts_file directive in squid.conf for details],
[
    if test "$enableval" != "none" ; then
	if test -f $enableval; then
	    OPT_DEFAULT_HOSTS=$enableval
	else
	    echo "Warning Unable to find $enableval"
	    sleep 5
	fi
    else
	OPT_DEFAULT_HOSTS="none"    
    fi
    echo "Default hosts file set to: $enableval"
],[OPT_DEFAULT_HOSTS="/etc/hosts"])
AC_SUBST(OPT_DEFAULT_HOSTS)


dnl Enable WIN32 Service compile mode
AC_ARG_ENABLE(win32-service,
[  --enable-win32-service  Compile Squid as a WIN32 Service
			  Works only on Windows NT and Windows 2000 Platforms.],
[ if test "$enableval" = "yes" ; then
    echo "Enabling WIN32 run service mode"
    AC_DEFINE(USE_WIN32_SERVICE,1,[Define Windows NT & Windows 2000 run service mode])
  fi
])

dnl Select auth schemes modules to build
AC_ARG_ENABLE(auth,
[  --enable-auth="list of auth scheme modules"
			  Build support for the list of authentication schemes.
			  The default is to build support for the Basic scheme.
			  See src/auth for a list of available modules, or
			  Programmers Guide section authentication schemes
			  for details on how to build your custom auth scheme
			  module],
[ case $enableval in
  yes)
	for module in $srcdir/src/auth/*; do
	    name="`basename $module`"
	    case $name in
	    CVS) # Ignore
		;;
	    *)
		if test -d $module; then
		    AUTH_MODULES="$AUTH_MODULES $name"
		fi
		;;
	    esac
	done
	;;
  no)
	;;
  *)    AUTH_MODULES="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
	;;
  esac
],
[ if test -z "$AUTH_MODULES"; then
    AUTH_MODULES="basic"
  fi
])
if test -z "$AUTH_MODULES"; then
    echo "Auth scheme modules built: None"
else
    echo "Auth scheme modules built: $AUTH_MODULES"
    AUTH_OBJS="auth/lib`echo $AUTH_MODULES|sed -e 's% %.a auth/lib%g'`.a"
    AUTH_LIBS="`echo $AUTH_OBJS|sed -e 's%auth/%%g'`"
fi
AC_SUBST(AUTH_MODULES)
AC_SUBST(AUTH_OBJS)
AC_SUBST(AUTH_LIBS)

AC_ARG_ENABLE(basic-auth-helpers,
[  --enable-basic-auth-helpers="list of helpers"
			  This option selects which basic scheme proxy_auth
			  helpers to build and install as part of the normal 
			  build process. For a list of available
			  helpers see the helpers/basic_auth directory.],
[ case "$enableval" in
  yes) 
    echo "ERROR: --enable-basic-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    BASIC_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$BASIC_AUTH_HELPERS"; then
    for helper in $BASIC_AUTH_HELPERS; do
	if test -f $srcdir/helpers/basic_auth/$helper/Makefile.in; then
		if test "$helper" = "SASL"; then
			require_sasl=yes
		fi
	else
		echo "ERROR: Basic auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Basic auth helpers built: $BASIC_AUTH_HELPERS"
fi
AC_SUBST(BASIC_AUTH_HELPERS)

dnl Select ntlm auth helpers to build
NTLM_AUTH_HELPERS=
AC_ARG_ENABLE(ntlm-auth-helpers,
[  --enable-ntlm-auth-helpers="list of helpers"
			  This option selects which proxy_auth ntlm helpers
			  to build and install as part of the normal build 
			  process. For a list of available helpers see
			  the helpers/ntlm_auth directory.],
[ case "$enableval" in
  yes) 
    echo "ERROR: --enable-ntlm-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    NTLM_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$NTLM_AUTH_HELPERS"; then
    for helper in $NTLM_AUTH_HELPERS; do
	if test -f $srcdir/helpers/ntlm_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: NTLM auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "NTLM auth helpers built: $NTLM_AUTH_HELPERS"
fi
AC_SUBST(NTLM_AUTH_HELPERS)

dnl Select digest auth scheme helpers to build
DIGEST_AUTH_HELPERS=
AC_ARG_ENABLE(digest-auth-helpers,
[  --enable-digest-auth-helpers="list of helpers"
			  This option selects which digest scheme proxy_auth
			  helpers to build and install as part of the normal
			  build process. For a list of available helpers see the
			  helpers/digest_auth directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-digest-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    DIGEST_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$DIGEST_AUTH_HELPERS"; then
    for helper in $DIGEST_AUTH_HELPERS; do
	if test -f $srcdir/helpers/digest_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: digest auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Digest auth helpers built: $DIGEST_AUTH_HELPERS"
fi
AC_SUBST(DIGEST_AUTH_HELPERS)

dnl Select negotiate auth scheme helpers to build
NEGOTIATE_AUTH_HELPERS=
AC_ARG_ENABLE(negotiate-auth-helpers,
[  --enable-negotiate-auth-helpers="list of helpers"
			  This option selects which negotiate scheme authentication
			  helpers to build and install as part of the normal build
			  process. For a list of available helpers see the
			  helpers/negotiate_auth directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-negotiate-auth-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    NEGOTIATE_AUTH_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$NEGOTIATE_AUTH_HELPERS"; then
    for helper in $NEGOTIATE_AUTH_HELPERS; do
	if test -f $srcdir/helpers/negotiate_auth/$helper/Makefile.in; then
		:
	else
		echo "ERROR: negotiate auth helper $helper does not exists"
		exit 1
	fi
    done
    echo "Negotiate auth helpers built: $NEGOTIATE_AUTH_HELPERS"
fi
AC_SUBST(NEGOTIATE_AUTH_HELPERS)

dnl Enable "NTLM fail open"
AC_ARG_ENABLE(ntlm-fail-open,
[  --enable-ntlm-fail-open Enable NTLM fail open, where a helper that fails one of the
			  Authentication steps can allow squid to still authenticate
			  the user.],
[ if test "$enableval" = "yes" ; then
    AC_DEFINE(NTLM_FAIL_OPEN, 1, [Define if NTLM is allowed to fail gracefully when a helper has problems])
  fi
])

dnl Select external_acl helpers to build
EXTERNAL_ACL_HELPERS=
AC_ARG_ENABLE(external-acl-helpers,
[  --enable-external-acl-helpers="list of helpers"
			  This option selects which external_acl helpers to
			  build and install as part of the normal build
			  process. For a list of available helpers see the
			  helpers/external_acl directory.],
[ case "$enableval" in
  yes)
    echo "ERROR: --enable-external-acl-helpers requires an argument"
    exit 1
    ;;
  no)
    ;;
  *)
    EXTERNAL_ACL_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
  esac
])
if test -n "$EXTERNAL_ACL_HELPERS"; then
    for helper in $EXTERNAL_ACL_HELPERS; do
	if test -f $srcdir/helpers/external_acl/$helper/Makefile.in; then
		:
	else
		echo "ERROR: external acl helper $helper does not exists"
		exit 1
	fi
    done
    echo "External acl helpers built: $EXTERNAL_ACL_HELPERS"
fi
AC_SUBST(EXTERNAL_ACL_HELPERS)


dnl Check for Cyrus SASL
if test "$require_sasl" = "yes"; then
	AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
	if test "$ac_cv_header_sasl_sasl_h" = "yes"; then
		echo "using SASL2"
		LIBSASL="-lsasl2"
	else
		if test "$ac_cv_header_sasl_h" = "yes"; then
			echo "using SASL"
			LIBSASL="-lsasl"
		else
			echo "ERROR: Neither SASL nor SASL2 found"
			exit 1
		fi
	fi
	AC_SUBST(LIBSASL)
fi

dnl Disable "unlinkd" code
AC_ARG_ENABLE(unlinkd,
[  --disable-unlinkd       Do not use unlinkd],
[ if test "$enableval" = "no" ; then
    use_unlinkd=no
  else
    use_unlinkd=yes
  fi
],[
    # Here we should probably use some magic depending on the selected
    # storage models
    use_unlinkd=yes
])
if test "$use_unlinkd" = "yes"; then
    echo "unlinkd enabled"
    AC_DEFINE(USE_UNLINKD, 1, [Define this if unlinkd is required
	(strongly recommended for ufs storage type)])
    AM_CONDITIONAL(ENABLE_UNLINKD, true)
else
    echo "unlinkd disabled"
    AM_CONDITIONAL(ENABLE_UNLINKD, false)
fi

dnl Enable backtraces on fatal errors
AC_ARG_ENABLE(stacktraces,
[  --enable-stacktraces    Enable automatic call backtrace on fatal errors],
[ if test "$enableval" = "yes" ; then
    echo "Enabling automatic stack backtraces on fatal errors"
    AC_DEFINE(PRINT_STACK_TRACE, 1, [Print stacktraces on fatal errors])
    if test "$GCC" = "yes"; then
	LDFLAGS="$LDFLAGS -rdynamic"
    fi
  fi
])

dnl Enable X-Accelerator-Vary for Vary support within an accelerator setup
AC_ARG_ENABLE(x_accelerator_vary,
[  --enable-x-accelerator-vary
			  Enable support for the X-Accelerator-Vary
			  HTTP header. Can be used to indicate
			  variance within an accelerator setup.
			  Typically used together with other code
			  that adds custom HTTP headers to the requests.],
[ if test "$enableval" = "yes" ; then
    echo "Enabling support for X-Accelerator-Vary"
    AC_DEFINE(X_ACCELERATOR_VARY, 1, [Enable support for the X-Accelerator-Vary HTTP header])
  fi
])

AC_ARG_ENABLE(follow-x-forwarded-for,
[  --enable-follow-x-forwarded-for
			  Enable support for following the X-Forwarded-For
			  HTTP header to try to find the IP address of the
			  original or indirect client when a request has
			  been forwarded through other proxies.],
[ if test "$enableval" = "yes" ; then
    echo "follow X-Forwarded-For enabled"
    AC_DEFINE(FOLLOW_X_FORWARDED_FOR, 1, [Enable following X-Forwarded-For headers])
    AC_SEARCH_LIBS(inet_aton, resolv) dnl some systems don't have this in libc
  fi
])

# Force some compilers to use ANSI features
#
case "$host" in
    alpha-dec-osf*)
	if test "$ac_cv_prog_CC" = "cc" ; then
		echo "adding '-std1' to cc args for $host"
		CC="cc -std1";
		ac_cv_prog_CC="$CC"
	fi
	;;
    *-hp-hpux*)
	if test "$ac_cv_prog_CC" = "cc" ; then
		echo "adding '-Ae' to cc args for $host"
		CC="cc -Ae";
		ac_cv_prog_CC="$CC"
	fi
	;;
esac

dnl Check for programs
AC_PROG_EGREP
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PATH_PROG(SH, sh, /bin/sh)
AC_PATH_PROG(FALSE, false, /usr/bin/false)
AC_PATH_PROG(TRUE, true, /usr/bin/true)
AC_PATH_PROG(RM, rm, $FALSE)
AC_PATH_PROG(MV, mv, $FALSE)
AC_PATH_PROG(MKDIR, mkdir, $FALSE)
AC_PATH_PROG(LN, ln, cp)
AC_PATH_PROG(PERL, perl, none)
dnl automake handles this AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUE)
AC_PATH_PROG(AR, ar, $FALSE)

if test "$ac_cv_path_PERL" = "none"; then
	echo "Perl is required to compile Squid"
	echo "Please install Perl and then re-run configure"
	exit 1
fi

case "$host" in
    *-hp-hpux*)
	echo "Disabling 'ranlib' for HP-UX..."
	RANLIB=":"
	;;
esac

dnl set $(AR)
AR_R="$AR r"
case "$host" in
	*-next-nextstep3)
		AR="libtool -o"
		;;
esac
AC_SUBST(AR_R)

dnl Check for headers
AC_HEADER_DIRENT
AC_HEADER_STDC

dnl Check for headers. sys/types.h and stddef.h and limits must be first (see below)
AC_CHECK_HEADERS(
	sys/types.h \
	stddef.h \
	limits.h \
	sys/param.h \
	sys/socket.h \
	netinet/in.h \
	stdio.h \
	stdlib.h \
	arpa/inet.h \
	arpa/nameser.h \
	assert.h \
	bstring.h \
	crypt.h \
	ctype.h \
	errno.h \
	execinfo.h \
	fcntl.h \
	fnmatch.h \
	getopt.h \
	glob.h \
	gnumalloc.h \
	grp.h \
	libc.h \
	linux/netfilter_ipv4.h \
	linux/netfilter_ipv4/ip_tproxy.h \
	malloc.h \
	math.h \
	memory.h \
	mount.h \
	net/if.h \
	net/pfvar.h \
	netdb.h \
	netinet/if_ether.h \
	netinet/tcp.h \
	openssl/err.h \
	openssl/md5.h \
	openssl/ssl.h \
	openssl/engine.h \
	paths.h \
	poll.h \
	pwd.h \
	regex.h \
	resolv.h \
	sched.h \
	signal.h \
	stdarg.h \
	string.h \
	strings.h \
	sys/bitypes.h \
	sys/file.h \
	sys/ioctl.h \
	sys/mount.h \
	md5.h \
	sys/md5.h \
	sys/msg.h \
	sys/prctl.h \
	sys/resource.h \
	sys/poll.h \
	sys/select.h \
	sys/stat.h \
	sys/statfs.h \
	sys/statvfs.h \
	syscall.h \
	sys/syscall.h \
	sys/time.h \
	sys/un.h \
	sys/vfs.h \
	sys/wait.h \
	sys/event.h \
	syslog.h \
	time.h \
	unistd.h \
	utime.h \
	varargs.h \
	byteswap.h \
	glib.h \
	stdint.h \
	inttypes.h \
	grp.h \
	nss_common.h \
	nss.h \
	db.h \
	db_185.h \
	aio.h \
	sys/capability.h \
,,,[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NET_IF_H
#include <net/if.h>
#endif
#if HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#endif
])

dnl Check for IP-Filter headers. These are a bit nasty..
AC_CHECK_HEADERS( \
	ip_compat.h \
	ip_fil_compat.h \
	ip_fil.h \
	ip_nat.h \
	ipl.h \
	netinet/ip_compat.h \
	netinet/ip_fil_compat.h \
	netinet/ip_fil.h \
	netinet/ip_nat.h \
	netinet/ipl.h \
,,,[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NET_IF_H
#include <net/if.h>
#endif
#if HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#endif
#if HAVE_IP_COMPAT_H
#include <ip_compat.h>
#elif HAVE_NETINET_IP_COMPAT_H
#include <netinet/ip_compat.h>
#endif
#if HAVE_IP_FIL_H
#include <ip_fil.h>
#elif HAVE_NETINET_IP_FIL_H
#include <netinet/ip_fil.h>
#endif
])

AC_C_CONST
AC_C_BIGENDIAN
AC_C_INLINE

AC_CACHE_CHECK(if ANSI prototypes work,ac_cv_have_ansi_prototypes, [
  AC_TRY_COMPILE([int foo(char *); int foo (char *bar) {return 1;}],
    [foo("bar")],
    ac_cv_have_ansi_prototypes="yes",
    ac_cv_have_ansi_prototypes="no")
])
if test $ac_cv_have_ansi_prototypes = "yes" ; then
  AC_DEFINE(HAVE_ANSI_PROTOTYPES, 1, [Define if your compiler supports prototyping])
fi

AC_CACHE_CHECK(for tm->tm_gmtoff,ac_cv_have_tm_gmoff, [
  AC_TRY_COMPILE([#include <time.h>
#include <sys/time.h>],
    [struct tm foo;
      foo.tm_gmtoff = 0;],
    ac_cv_have_tm_gmoff="yes",
    ac_cv_have_tm_gmoff="no")
])
if test $ac_cv_have_tm_gmoff = "yes" ; then
  AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if struct tm has tm_gmtoff member])
fi

AC_CACHE_CHECK(for struct mallinfo,ac_cv_have_struct_mallinfo, [
  AC_TRY_COMPILE([#include <sys/types.h>
#if HAVE_MALLOC_H
#include <malloc.h>
#endif],
    [struct mallinfo foo;
    foo.arena = 0;
    foo.ordblks = 0;
    foo.smblks = 0;
    foo.hblks = 0;
    foo.hblkhd = 0;
    foo.uordblks = 0;
    foo.fordblks = 0;
    foo.keepcost = 0;],
    ac_cv_have_struct_mallinfo="yes",
    ac_cv_have_struct_mallinfo="no")
])
if test $ac_cv_have_struct_mallinfo = "yes" ; then
  AC_DEFINE(HAVE_STRUCT_MALLINFO, 1, [we check for the existance of struct mallinfo])
fi

AC_CACHE_CHECK(for extended mallinfo,ac_cv_have_ext_mallinfo, [
  AC_TRY_COMPILE([#include <sys/types.h>
#include <malloc.h>],
    [struct mallinfo foo;
      foo.mxfast = 0;],
    ac_cv_have_ext_mallinfo="yes",
    ac_cv_have_ext_mallinfo="no")
])
if test $ac_cv_have_ext_mallinfo = "yes" ; then
  AC_DEFINE(HAVE_EXT_MALLINFO, 1, [Define if struct mallinfo has mxfast member])
fi

case "$host_os" in
  mingw|mingw32)
    AC_DEFINE(HAVE_STRUCT_RUSAGE)
    ac_cv_func_getrusage='yes'
    echo "Using own rusage on Windows."
    ;;
  *)      
    AC_CACHE_CHECK(for struct rusage,ac_cv_have_struct_rusage, [
      AC_TRY_COMPILE([
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif],
        [struct rusage R;],
        ac_cv_have_struct_rusage="yes",
        ac_cv_have_struct_rusage="no")
])
    if test $ac_cv_have_struct_rusage = "yes" ; then
      AC_DEFINE(HAVE_STRUCT_RUSAGE, 1, [Define if you have struct rusage])
    fi
    ;;
esac

AC_CACHE_CHECK(for ip->ip_hl, ac_cv_have_ip_hl, [
  AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#if defined (__linux__) || defined (__CYGWIN__)
#define ip_hl ihl
#endif
#ifndef __linux__
#ifndef __CYGWIN__
#define iphdr ip
#endif
#endif],
    [struct iphdr ip;
      ip.ip_hl= 0;],
    ac_cv_have_ip_hl="yes",
    ac_cv_have_ip_hl="no")
])
if test $ac_cv_have_ip_hl = "yes" ; then
  AC_DEFINE(HAVE_IP_HL, 1, [Define if struct ip has ip_hl member])
fi

dnl Check for typedefs
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF_SYSTYPE(int8_t)
AC_CHECK_SIZEOF_SYSTYPE(uint8_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int8_t)
AC_CHECK_SIZEOF_SYSTYPE(int16_t)
AC_CHECK_SIZEOF_SYSTYPE(uint16_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int16_t)
AC_CHECK_SIZEOF_SYSTYPE(int32_t)
AC_CHECK_SIZEOF_SYSTYPE(uint32_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int32_t)
AC_CHECK_SIZEOF_SYSTYPE(int64_t)
AC_CHECK_SIZEOF_SYSTYPE(uint64_t)
AC_CHECK_SIZEOF_SYSTYPE(u_int64_t)
AC_CHECK_SIZEOF_SYSTYPE(__int64)

dnl int8_t
if test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(int8_t,char)
fi
dnl u_int8_t
if test "x$ac_cv_sizeof_uint8_t" = "x1"; then
	AC_CHECK_SYSTYPE(u_int8_t,uint8_t)
elif test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(u_int8_t,unsigned char)
fi
dnl uint8_t
if test "x$ac_cv_sizeof_u_int8_t" = "x1"; then
	AC_CHECK_SYSTYPE(uint8_t,u_int8_t)
elif test "x$ac_cv_sizeof_char" = "x1"; then
	AC_CHECK_SYSTYPE(uint8_t,unsigned char)
fi
dnl int16_t
if test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(int16_t,short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(int16_t,int)
fi
dnl u_int16_t
if test "x$ac_cv_sizeof_uint16_t" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,uint16_t)
elif test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,unsigned short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(u_int16_t,unsigned int)
fi
dnl uint16_t
if test "x$ac_cv_sizeof_u_int16_t" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,u_int16_t)
elif test "x$ac_cv_sizeof_short" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,unsigned short)
elif test "x$ac_cv_sizeof_int" = "x2"; then
	AC_CHECK_SYSTYPE(uint16_t,unsigned int)
fi
dnl int32_t
if test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(int32_t,int)
elif "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(int32_t,long)
fi
dnl u_int32_t
if test "x$ac_cv_sizeof_uint32_t" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,uint32_t)
elif test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,unsigned int)
elif test "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(u_int32_t,unsigned long)
fi
dnl uint32_t
if test "x$ac_cv_sizeof_u_int32_t" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,u_int32_t)
elif test "x$ac_cv_sizeof_int" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,unsigned int)
elif test "x$ac_cv_sizeof_long" = "x4"; then
	AC_CHECK_SYSTYPE(uint32_t,unsigned long)
fi
dnl int64_t
if test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(int64_t,__int64)
fi
dnl u_int64_t
if test "x$ac_cv_sizeof_uint64_t" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,uint64_t)
elif test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(u_int64_t,unsigned __int64)
fi
dnl uint64_t
if test "x$ac_cv_sizeof_u_int64_t" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,u_int64_t)
elif test "x$ac_cv_sizeof_long" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned long)
elif test "x$ac_cv_sizeof_long_long" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned long long)
elif test "x$ac_cv_sizeof___int64" = "x8"; then
	AC_CHECK_SYSTYPE(uint64_t,unsigned __int64)
fi

AC_CHECK_SYSTYPE(pid_t, int)
AC_CHECK_SYSTYPE(size_t, unsigned int)
AC_CHECK_SYSTYPE(ssize_t, int)
AC_CHECK_SYSTYPE(off_t, int)
AC_CHECK_SYSTYPE(mode_t, unsigned short)
AC_CHECK_SYSTYPE(fd_mask, int)

AC_CHECK_SIZEOF_SYSTYPE(off_t, 4)
AC_CHECK_SIZEOF_SYSTYPE(size_t, 4)

dnl Check for special functions
AC_FUNC_ALLOCA


dnl Check for type in sys/socket.h
AC_CACHE_CHECK(for socklen_t, ac_cv_type_socklen_t, [
  AC_EGREP_CPP([socklen_t[^a-zA-Z_0-9]], [#include <sys/types.h>
#include <sys/socket.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif],
    ac_cv_type_socklen_t=yes,
    ac_cv_type_socklen_t=no)
])
if test $ac_cv_type_socklen_t = no; then
  AC_DEFINE(socklen_t, int, [This makes warnings go away.  If you have socklen_t defined in your
	/usr/include files, then this should remain undef'd.  Otherwise it
	should be defined to int.])
fi

dnl Check for mtyp_t in some headers
AC_CACHE_CHECK(for mtyp_t, ac_cv_type_mtyp_t, [
  AC_EGREP_CPP([mtyp_t[^a-zA-Z_0-9]], [#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>],
    ac_cv_type_mtyp_t=yes,
    ac_cv_type_mtyp_t=no)
])
if test $ac_cv_type_mtyp_t = no; then
  AC_DEFINE(mtyp_t, long, [message type for message queues])
 fi

use_libcap=auto
AC_ARG_WITH(libcap, AS_HELP_STRING([--without-libcap],[disable usage of Linux capabilities library to control privileges]),
[ if test "x$withval" = "xyes" ; then
    AC_MSG_RESULT(libcap forced enabled)
    use_libcap=yes
  else
    AC_MSG_RESULT(libcap forced disabled)
    use_libcap=no
  fi
])
if test "x$use_libcap" != "xno"; then
  # cap_clear_flag is the most recent libcap function we require
  AC_SEARCH_LIBS(cap_clear_flag, cap)
  AC_CHECK_FUNCS(cap_clear_flag)
  if test "x$ac_cv_func_cap_clear_flag" = xyes; then
    use_libcap=yes
  else
    if test "x$use_libcap" = "xyes"; then
      AC_MSG_ERROR([libcap forced enabled but not available or not usable, requires libcap-2.09 or later])
    fi
    use_libcap=no
  fi
fi
if test "x$use_libcap" = "xyes"; then
  AC_DEFINE(USE_LIBCAP, 1, [use libcap to set capabilities required for TPROXY])
  dnl Check for libcap headader breakage.
  AC_CHECK_HEADERS(sys/capability.h)
  AC_CACHE_CHECK([for operational libcap2 headers], squid_cv_sys_capability_works,
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <stddef.h>
#include <sys/capability.h>
]], [[
capget(NULL, NULL);
capset(NULL, NULL);
                   ]])],[squid_cv_sys_capability_works=yes],[squid_cv_sys_capability_works=no])
  )
  if test x$squid_cv_sys_capability_works != xyes; then
    AC_DEFINE([LIBCAP_BROKEN],1,[if libcap2 headers are broken and clashing with glibc])
  fi
fi

# Check for needed libraries

AX_LIB_SOCKET_NSL

# yp_match is in libnsl on some systems, needed by helpers/basic_auth/YP
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([yp_match], [nsl], [test "$ac_res" = "none required" || NIS_LIBS="$ac_res $NIS_LIBS";LIBS="$saved_LIBS"])
AC_SUBST(NIS_LIBS)

dnl Check for Winsock only on MinGW, on Cygwin we must use emulated BSD socket API
	case "$host_os" in
	mingw|mingw32)
	AC_MSG_CHECKING(for winsock)
	save_LIBS="$LIBS"
	for curlib in ws2_32 wsock32; do
		LIBS="$LIBS -l$curlib"
		AC_TRY_LINK([
				char __attribute__((stdcall)) socket(int,int,int);
				char __attribute__((stdcall)) select(int,int,int,int,int);
				char __attribute__((stdcall)) closesocket(int);
				char __attribute__((stdcall)) gethostname(int,int);
				],
				[
				socket(1,2,3);
				select(1,2,3,4,5);
				closesocket(1);
				gethostname(1,2);
				],
				have_winsock=yes, have_winsock=no)
	
		if test $have_winsock = yes; then
			ac_cv_func_select='yes'
			if test $curlib = ws2_32; then
				have_winsock=winsock2
			fi
			break
		fi
		LIBS="$save_LIBS"
	done
	AC_MSG_RESULT($have_winsock)
	if test $have_winsock = winsock2; then
	       AC_CHECK_HEADERS(winsock2.h)
	else
	       AC_CHECK_HEADERS(winsock.h)
	fi
	;;
esac

dnl Ripped from the Samba sources
AC_CACHE_CHECK([for unix domain sockets],squid_cv_unixsocket, [
    AC_TRY_COMPILE([
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>],
[
  struct sockaddr_un sunaddr; 
  sunaddr.sun_family = AF_UNIX;
],
	squid_cv_unixsocket=yes,squid_cv_unixsocket=no)])
if test x"$squid_cv_unixsocket" = x"yes"; then
   AC_DEFINE(HAVE_UNIXSOCKET, 1, [Do we have unix sockets? (required for the winbind ntlm helper])
fi
dnl end rip

if test "x$ac_cv_enabled_dlmalloc" = "xyes" ; then
  echo "skipping libmalloc check (--enable-dlmalloc specified)"
else
  dnl prefer gnumalloc if available
  AC_CHECK_LIB(gnumalloc, malloc)
  if test "$ac_cv_lib_gnumalloc_main" = "yes"; then
		echo "Disabling extended malloc functions when using gnumalloc"
		ac_cv_func_mallinfo=no
		ac_cv_func_mallocblksize=no
		ac_cv_func_mallopt=no
  else
		case "$host" in
			*-sun-solaris*)
			  echo "skipping libmalloc check for $host"
				;;
			i386-*-freebsd*)
			  echo "skipping libmalloc check for $host"
				;;
			*)
				dnl prefer libmalloc if available
				AC_CHECK_LIB(malloc, malloc)
				;;
		esac
  fi
fi

dnl no idea who requires libbsd, or what function to look for. Been around since day 0
dnl but not needed on any of our main platforms and may contain stuff we do not want
dnl as can be seen below where -lbsd is removed from many systems
dnl AC_CHECK_LIB(bsd, main)

dnl prefer separate regex library if available
AC_CHECK_LIB(regex, regcomp, [REGEXLIB="-lregex"])

case "$host_os" in
mingw|mingw32)
	dnl Is this special case really required, doesn't AC_CHECK_LIB work?
	echo "Use MSVCRT for math functions."
	;;
	*)
	AC_CHECK_LIB(m, rint)
	;;
esac

dnl Check for libcrypt
dnl Some of our helpers use crypt(3) which may be in libc, or in
dnl libcrypt (eg FreeBSD)
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([crypt], [crypt], [test "$ac_res" = "none required" || CRYPTLIB="$ac_res $CRYPTLIB";LIBS="$saved_LIBS"])
AC_SUBST(CRYPTLIB)

dnl Solaris10 provides MD5 natively through libmd5
dnl FreeBSD provides MD5 natively through libmd
AC_SEARCH_LIBS([MD5Init], [md5 md])


dnl Check for libdl, used by auth_modules/PAM
if test "$with_dl" = "yes"; then
    AC_SEARCH_LIBS([dlopen], [dl])
fi

dnl Check for pthreads
dnl We use pthreads when doing ASYNC I/O
if test "$with_pthreads" = "yes"; then
    CFLAGS="$CFLAGS -D_REENTRANT"
    case "$host" in
    i386-unknown-freebsd*)
	if test "$GCC" = "yes" ; then
	    if test -z "$PRESET_LDFLAGS"; then
		LDFLAGS="$LDFLAGS -pthread"
	    fi
	fi
    ;;
    *-solaris2.*)
	if test "$GCC" = "yes" ; then
	    CFLAGS="$CFLAGS -pthreads"
	else
	    CFLAGS="$CFLAGS -mt"
	fi
    ;;
    esac
    AC_CHECK_LIB(pthread, pthread_create)
fi

dnl Check for librt
dnl We use AIO in the coss store
if test "$with_aio" = "yes"; then
    dnl On some systems POSIX AIO functions are in libaio
    AC_SEARCH_LIBS(aio_read, [rt aio])
fi

LIB_EPOLL=''
dnl Check for libepoll
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([epoll_ctl], [epoll], [test "$ac_res" = "none required" || LIB_EPOLL="$ac_res $LIB_EPOLL";LIBS="$saved_LIBS"])
AC_SUBST(LIB_EPOLL)

dnl -lintl is needed on SCO version 3.2v4.2 for strftime()
dnl Robert Side <rside@aiinc.bc.ca>
dnl Mon, 18 Jan 1999 17:48:00 GMT
case "$host" in
	*-pc-sco3.2*)
		AC_SEARCH_LIBS(strftime, intl)
		;;
esac

dnl On MinGW OpenLDAP is not available, so LDAP helpers can be linked 
dnl only with Windows LDAP libraries using -lwldap32
case "$host_os" in
mingw|mingw32)
       LIB_LDAP="-lwldap32"
       ;;
*)
       LIB_LDAP="-lldap"
       dnl LDAP helpers need to know if -llber is needed or not
       dnl unfortunately there is no well defined function API to
       dnl look for so we use AC_CHECK_LIB and just check for some
       dnl C-library function.
       AC_CHECK_LIB(lber, open, [LIB_LDAP="${LIB_LDAP} -llber"])
       ;;
esac
AC_SUBST(LIB_LDAP)

dnl Check for libdb
DBLIB=
dnl 1.85
AC_CACHE_CHECK(if dbopen needs -ldb,ac_cv_dbopen_libdb, [
SAVED_LIBS="$LIBS"; LIBS="$LIBS -ldb"
  AC_TRY_LINK([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#if HAVE_DB_185_H
#include <db_185.h>
#elif HAVE_DB_H
#include <db.h>
#endif],
    [dbopen((void *)0L, 0, 0, DB_HASH, (void *)0L)],
    ac_cv_dbopen_libdb="yes",
    ac_cv_dbopen_libdb="no")
LIBS="$SAVED_LIBS"
])
if test $ac_cv_dbopen_libdb = yes; then
    LIB_DB="-ldb"
fi
AC_SUBST(LIB_DB)

dnl System-specific library modifications
dnl
case "$host" in
	i386-*-solaris2.*)
		if test "$GCC" = "yes"; then
			echo "Removing -O for gcc on $host"
			CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]*//'`"
		fi
		;;
	*-sgi-irix*)
		echo "Removing -lsocket for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lsocket//`
		echo "Removing -lnsl for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lnsl//`
		ac_cv_lib_nsl_main=no
		echo "Removing -lbsd for IRIX..."
		LIBS=`echo $LIBS | sed -e s/-lbsd//`
		;;
dnl From: c0032033@ws.rz.tu-bs.de (Joerg Schumacher)
dnl Date: Thu, 17 Oct 1996 04:09:30 +0200
dnl Please change your configure script.  AIX doesn't need -lbsd.
	*-ibm-aix*)
		echo "Removing -lbsd for AIX..."
		LIBS=`echo $LIBS | sed -e s/-lbsd//`
		case "$host" in
dnl From: mlaster@metavillage.com (Mike Laster)
dnl AIX 4.1.4.x does not have header files for snprintf/vsnprintf
dnl So using the internal versions generates a load of warnings
dnl during compile.
			*-ibm-aix4*)
				echo "disabling snprintf/vsnprintf for $host"
				ac_cv_func_snprintf=no
				ac_cv_func_vsnprintf=no
			;;
		esac
		;;
	*m88k*-openbsd*)
		;;
	*m88k*)
		CFLAGS="$CFLAGS -D_SQUID_MOTOROLA_"
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
	[*-*-solaris2.[0-4]])
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
	[*-sony-newsos[56]*])
		AC_DEFINE(GETTIMEOFDAY_NO_TZP, 1, [If gettimeofday is known to take only one argument])
		;;
esac

# Remove optimization for GCC 2.95.[123]
# gcc -O[2] on *BSD and Linux (x86) causes pointers to magically become NULL
if test "$GCC" = "yes"; then
	GCCVER=`$CC -v 2>&1 | awk '$2 ==  "version" {print $3}'`
	case "$GCCVER" in
	[2.95.[123]])
		echo "Removing -O for gcc on $host with GCC $GCCVER"
		CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]*//'`"
		;;
	esac
fi

# Recommended by Balint Nagy Endre <bne@CareNet.hu>
case "$host" in
	*-univel-sysv4.2MP)
		if test `uname -v` = "2.03"; then
			echo "disabling mallinfo for $host"
			ac_cv_func_mallinfo=no
		fi
		;;
esac

dnl This has to be before AC_CHECK_FUNCS
# Disable poll() on certain platforms. Override by setting ac_cv_func_poll
# when running configure.
if test -z "$ac_cv_func_poll"; then
	case "$host" in
		[alpha-dec-osf3.*])
			# John Kay (jkay@nlanr.net) 19970818
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-hp-hpux*.*])
			# Duane Wessels
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-linux-*])
			# Henrik Nordstrom (hno@squid-cache.org) 19980817
			# poll is problematic on Linux.  We disable it
			# by default until Linux gets it right.
			# See also bug #932
			rev=`uname -r | awk -F. '{printf "%03d%03d",$1,$2}'`
			if test $rev -lt 002004; then
			    echo "disabling poll for $host < 2.4..."
			    ac_cv_func_poll='no'
			fi
			;;
		[powerpc-ibm-aix4.1.*])
			# Mike Laster (mlaster@metavillage.com) 19981021
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
		[*-pc-sco3.2*])
			# Robert Side <rside@aiinc.bc.ca>
			# Mon, 18 Jan 1999 17:48:00 GMT
			echo "disabling poll for $host..."
			ac_cv_func_poll='no'
			;;
	esac
fi

dnl Override statfs detect on MinGW because is emulated in source code
case "$host_os" in
mingw|mingw32)
	ac_cv_func_statfs='yes'
	;;
esac

dnl Check for library functions
AC_CHECK_FUNCS(\
	bcopy \
	backtrace_symbols_fd \
	fchmod \
	getdtablesize \
	getpagesize \
	getpass \
	getrusage \
	getspnam \
	gettimeofday \
	glob \
	kqueue \
	lrand48 \
	mallinfo \
	mallocblksize \
	MD5Init \
	mallopt \
	memcpy \
	memmove \
	memset \
	mkstemp \
	mktime \
	mstats \
	poll \
	prctl \
	pthread_attr_setscope \
	pthread_setschedparam \
	pthread_attr_setschedparam \
	pthread_sigmask \
	putenv \
	random \
	regcomp \
	regexec \
	regfree \
	res_init \
	__res_init \
	rint \
	sbrk \
	select \
	seteuid \
	setgroups \
	setpgrp \
	setrlimit \
	getrlimit \
	setsid \
	sigaction \
	snprintf \
	socketpair \
	srand48 \
	srandom \
	statfs \
	strsep \
	strtoll \
	sysconf \
	syslog \
	timegm \
	vsnprintf \
)

SAVED_LIBS="$LIBS"
LIBS="$LIBS $LIB_EPOLL"
AC_CHECK_FUNCS(epoll_ctl)
LIBS="$SAVED_LIBS"

SAVED_LIBS="$LIBS"
LIBS="$LIBS $CRYPTLIB"
AC_CHECK_FUNCS(crypt)
LIBS="$SAVED_LIBS"

dnl Verify that epoll really works
if test $ac_cv_func_epoll_ctl = yes; then
  AC_CACHE_CHECK(if epoll works, ac_cv_epoll_works,
    AC_TRY_RUN([
#include <sys/epoll.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
    int fd = epoll_create(256);
    if (fd < 0) {
	perror("epoll_create:");
	exit(1);
    }
    exit(0);
}
    ], [ac_cv_epoll_works=yes], [ac_cv_epoll_works=no]))
  if test ac_cv_epoll_works = no && test ac_force_epoll = yes; then
	echo "Error - no epoll found";
	echo "Try running 'sh ./scripts/get_epoll-lib.sh'";
	echo "then run configure again";
	exit -1
  fi
fi

dnl Magic which checks whether we are forcing a type of comm loop we
dnl are actually going to (ab)use

dnl Actually do the define magic now
dnl mostly ripped from squid-commloops, thanks to adrian and benno

if test -n "$SELECT_TYPE"; then
	: # Nothing to do
elif test "$ac_cv_epoll_works" = "yes" ; then
	SELECT_TYPE="epoll"
elif test "$ac_cv_func_kqueue" = "yes" ; then
	SELECT_TYPE="kqueue"
elif test "$ac_cv_func_poll" = "yes" ; then
	SELECT_TYPE="poll"
elif test "$ac_cv_func_select" = "yes" ; then
	case "$host_os" in
	mingw|mingw32)
		SELECT_TYPE="select_win32"
		;;
	*)
		SELECT_TYPE="select"
		;;
	esac
else
	echo "Eep!  Can't find poll, epoll, kqueue or select!"
	echo "I'll try select and hope for the best."
	SELECT_TYPE="select"
fi

echo "Using ${SELECT_TYPE} for the IO loop."
AM_CONDITIONAL([USE_POLL], [test $SELECT_TYPE = poll])
AM_CONDITIONAL([USE_EPOLL], [test $SELECT_TYPE = epoll])
AM_CONDITIONAL([USE_SELECT], [test $SELECT_TYPE = select])
AM_CONDITIONAL([USE_SELECT_SIMPLE], [test $SELECT_TYPE = select_simple])
AM_CONDITIONAL([USE_SELECT_WIN32], [test $SELECT_TYPE = select_win32])
AM_CONDITIONAL([USE_KQUEUE], [test $SELECT_TYPE = kqueue])
AM_CONDITIONAL([USE_DEVPOLL], [test $SELECT_TYPE = devpoll])


dnl Hmm.. some OS:es (i.e. FreeBSD) can't handle large AF_UNIX dgram packets.
dnl Verify that at least 16K is supported, if not fall back on using
dnl IP dgram sockets for IPC.
AC_CACHE_CHECK(if AF_UNIX dgram sockets support large packets, ac_cv_af_unix_large_dgram,
  AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#else
#include <sys/time.h>
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#define BUFSIZE 16384
  void consumer(int s, int p)
  {
      fd_set fds;
      char buf[[BUFSIZE]];
      int len;
      int nfds = p > s ? p + 1 : s + 1;
      int rc;
      FD_ZERO(&fds);
      FD_SET(s, &fds);
      FD_SET(p, &fds);
      rc = select(nfds, &fds, NULL, NULL, NULL);
      if (rc < 0)
	    exit(1);
      if (FD_ISSET(s, &fds))
	  len = recv(s, buf, sizeof(buf), 0);
  }

  void sender(int s, int p)
  {
      char buf[[BUFSIZE]];
      int len = sizeof(buf);
      int rc = send(s, buf, len, 0);
      if (rc < 0) {
	  perror("send");
	  exit(1);
      }
      if (rc != len) {
	  fprintf(stderr, "Short send %d of %d\n", rc, len);
	  exit(1);
      }
  }

  int main(int argc, char **argv)
  {
      int s[[2]];
      int p[[2]];
      pid_t pid;
      socketpair(AF_UNIX, SOCK_DGRAM, 0, s);
      pipe(p);
      pid = fork();
      if (pid < 0) {
	  perror("fork");
	  exit(0);
      }
      if (pid == 0) {
	  close(s[[0]]);
	  close(p[[0]]);
	  consumer(s[[1]],p[[1]]);
      } else {
	  close(s[[1]]);
	  close(p[[1]]);
	  sender(s[[0]],p[[0]]);
      }
      return 0;
  }
  ], ac_cv_af_unix_large_dgram="yes",ac_cv_af_unix_large_dgram="no")
)
if test "$ac_cv_af_unix_large_dgram" = "yes" ; then
    AC_DEFINE(SUPPORTS_LARGE_AF_UNIX_DGRAM, 1, [Supports large dgram sockets over AF_UNIX sockets])
fi

dnl Yay!  Another Linux brokenness.  Its not good enough
dnl to know that setresuid() exists, because RedHat 5.0 declares
dnl setresuid() but doesn't implement it.
dnl
AC_CACHE_CHECK(if setresuid is implemented, ac_cv_func_setresuid,
  AC_TRY_RUN([
#include <stdlib.h>
  int main() {
    if(setresuid(-1,-1,-1)) {
      perror("setresuid:");
      exit(1);
    }
    exit(0);
  }
  ],ac_cv_func_setresuid="yes",ac_cv_func_setresuid="no")
)
if test "$ac_cv_func_setresuid" = "yes" ; then
  AC_DEFINE(HAVE_SETRESUID, 1, [Yay! Another Linux brokenness.  Its not good enough to know that
	setresuid() exists, because RedHat 5.0 declare setresuid() but
	doesn't implement it.])
fi

AM_CONDITIONAL(NEED_OWN_SNPRINTF, false)
if test "$ac_cv_func_snprintf" = "no" || test "$ac_cv_func_vsnprintf" = "no" ; then
  AM_CONDITIONAL(NEED_OWN_SNPRINTF, true)
fi

AM_CONDITIONAL(NEED_OWN_STRSEP, false)
if test "$ac_cv_func_strsep" = "no" ; then
  AM_CONDITIONAL(NEED_OWN_STRSEP, true)
fi

dnl
dnl Test for va_copy
dnl
AC_CACHE_CHECK(if va_copy is implemented, ac_cv_func_va_copy,
  AC_TRY_RUN([
      #include <stdarg.h>
      void f (int i, ...) {
	 va_list args1, args2;
	 va_start (args1, i);
	 va_copy (args2, args1);
	 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	    exit (1);
	 va_end (args1); va_end (args2);
      }
      int main() {
	 f (0, 42);
	 return 0;
      }
      ],ac_cv_func_va_copy="yes",ac_cv_func_va_copy="no")
)
if test "$ac_cv_func_va_copy" = "yes" ; then
  AC_DEFINE(HAVE_VA_COPY, 1, [Some systems dont have va_copy])
fi

dnl
dnl Some systems support __va_copy
dnl
AC_CACHE_CHECK(if __va_copy is implemented, ac_cv_func___va_copy,
  AC_TRY_RUN([
      #include <stdarg.h>
      void f (int i, ...) {
	 va_list args1, args2;
	 va_start (args1, i);
	 __va_copy (args2, args1);
	 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	    exit (1);
	 va_end (args1); va_end (args2);
      }
      int main() {
	 f (0, 42);
	 return 0;
      }
      ],ac_cv_func___va_copy="yes",ac_cv_func___va_copy="no")
)
if test "$ac_cv_func___va_copy" = "yes" ; then
  AC_DEFINE(HAVE___VA_COPY, 1, [Some systems support __va_copy])
fi

dnl IP-Filter support requires ipf header files. These aren't
dnl installed by default, so we need to check for them
if test "$IPF_TRANSPARENT" ; then
    AC_MSG_CHECKING(if IP-Filter header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_ip_compat_h" = "yes" ||
	test "$ac_cv_header_ip_fil_compat_h" = "yes" ||
	test "$ac_cv_header_netinet_ip_compat_h" = "yes" ||
	test "$ac_cv_header_netinet_ip_fil_compat_h" = "yes" ; then
	have_ipfilter_compat_header="yes"
     fi
     if test "x$have_ipfilter_compat_header" = "xyes" &&
       test "$ac_cv_header_ip_fil_h" = "yes" &&
       test "$ac_cv_header_ip_nat_h" = "yes" ; then
	IPF_TRANSPARENT="yes"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    elif test "$have_ipfilter_compat_header" = "yes" &&
	 test "$ac_cv_header_netinet_ip_fil_h" = "yes" &&
	 test "$ac_cv_header_netinet_ip_nat_h" = "yes" ; then
	IPF_TRANSPARENT="yes"
	AC_DEFINE(IPF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    else
	IPF_TRANSPARENT="no"
	AC_DEFINE(IPF_TRANSPARENT, 0, [Enable support for Transparent Proxy on systems using IP-Filter
	address redirection. This provides "masquerading" support for non
	Linux system.])
    fi
    AC_MSG_RESULT($IPF_TRANSPARENT)
fi 
if test "$IPF_TRANSPARENT" = "no" ; then
    echo "WARNING: Cannot find necessary IP-Filter header files"
    echo "         Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl PF support requires a header file.
if test "$PF_TRANSPARENT" ; then
    AC_MSG_CHECKING(if PF header file is installed)
    # hold on to your hats...
    if test "$ac_cv_header_net_pfvar_h" = "yes"; then
	PF_TRANSPARENT="yes"
	AC_DEFINE(PF_TRANSPARENT, 1, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
    else
	PF_TRANSPARENT="no"
	AC_DEFINE(PF_TRANSPARENT, 0, [Enable support for Transparent Proxy on systems using PF address
	redirection. This provides "masquerading" support for OpenBSD.])
    fi
    AC_MSG_RESULT($PF_TRANSPARENT)
fi
if test "$PF_TRANSPARENT" = "no" ; then
    echo "WARNING: Cannot find necessary PF header file"
    echo "         Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl Linux-Netfilter support requires Linux 2.4 or newer kernel header files.
dnl Shamelessly copied from above
if test "$LINUX_NETFILTER" = "yes"; then
    AC_MSG_CHECKING(if Linux 2.4 or newer kernel header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_linux_netfilter_ipv4_h" = "yes"; then
	LINUX_NETFILTER="yes"
	AC_DEFINE(LINUX_NETFILTER, 1, [Enable support for Transparent Proxy on Linux (Netfilter) systems])
    else
	LINUX_NETFILTER="no"
	AC_DEFINE(LINUX_NETFILTER, 0, [Enable support for Transparent Proxy on Linux (Netfilter) systems])
    fi
    AC_MSG_RESULT($LINUX_NETFILTER)
fi 
if test "$LINUX_NETFILTER" = "no" ; then
    echo "WARNING: Cannot find necessary Linux kernel header files"
    echo "         Linux Netfilter Transparent Proxy support WILL NOT be enabled"
    sleep 10
fi

dnl Linux Netfilter/TPROXY support requires some specific header files and libcap
dnl Shamelessly copied from shamelessly copied from above
if test "$LINUX_TPROXY"; then
    AC_MSG_CHECKING(if TPROXY header files are installed)
    # hold on to your hats...
    if test "$ac_cv_header_linux_netfilter_ipv4_ip_tproxy_h" = "yes" && test "$LINUX_NETFILTER" = "yes"; then
	LINUX_TPROXY="yes"
	AC_DEFINE(LINUX_TPROXY, 1, [Enable real Transparent Proxy support for Netfilter TPROXY.])
    else
	LINUX_TPROXY="no"
	AC_DEFINE(LINUX_TPROXY, 0, [Enable real Transparent Proxy support for Netfilter TPROXY.])
    fi
    AC_MSG_RESULT($LINUX_TPROXY)
    if test "$use_libcap" != "yes"; then
       AC_MSG_WARN([Missing needed capabilities (libcap or libcap2) for TPROXY])
       LINUX_TPROXY="no"
       sleep 10
    fi
fi
if test "$LINUX_TPROXY" = "no" && test "$LINUX_NETFILTER" = "yes"; then
    echo "WARNING: Cannot find TPROXY headers, you need to patch your kernel with the"
    echo "tproxy package from:"
    echo " - lynx http://www.balabit.com/downloads/files/tproxy/"
    sleep 10
fi

if test -z "$USE_GNUREGEX" ; then
    case "$host" in
    *-sun-solaris2.[[0-4]])
	  USE_GNUREGEX="yes"
	  ;;
    *-next-nextstep*)
	  USE_GNUREGEX="yes"
	  ;;
    esac
fi
AC_MSG_CHECKING(if GNUregex needs to be compiled)
if test -z "$USE_GNUREGEX"; then
if test "$ac_cv_func_regcomp" = "no" || test "$USE_GNUREGEX" = "yes" ; then
	USE_GNUREGEX="yes"
else
	AC_TRY_COMPILE([#include <sys/types.h>
#include <regex.h>],[regex_t t; regcomp(&t,"",0);],
		USE_GNUREGEX="no",
		USE_GNUREGEX="yes")
fi
fi
AC_MSG_RESULT($USE_GNUREGEX)
if test "$USE_GNUREGEX" = "yes"; then
	REGEXLIB="-lregex"
	LIBREGEX="libregex.a"
	AC_DEFINE(USE_GNUREGEX, 1, [Define if we should use GNU regex])
fi
AC_SUBST(REGEXLIB)
AC_SUBST(LIBREGEX)

AC_REPLACE_FUNCS(\
	drand48 \
	tempnam \
	strerror \
	initgroups
)

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default FD_SETSIZE value)
AC_TRY_RUN([
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main() {
	FILE *fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", FD_SETSIZE);
	exit(0);
}
],
DEFAULT_FD_SETSIZE=`cat conftestval`,
DEFAULT_FD_SETSIZE=256,
DEFAULT_FD_SETSIZE=256)
AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, [Default FD_SETSIZE value])

AC_ARG_WITH(maxfd,
[  --with-maxfd=N          Override maximum number of filedescriptors. Useful
			  if you build as another user who is not privileged
			  to use the number of filedescriptors you want the
			  resulting binary to support],
[ case $withval in
  [[0-9]]*)
    SQUID_MAXFD=$withval
    echo "Maximum filedescriptors set to $SQUID_MAXFD"
    ;;
  *)
    echo "ERROR: Invalid --with-maxfd argument"
    exit 1
    ;;
  esac
])
if test -z "$SQUID_MAXFD"; then

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Maximum number of filedescriptors we can open)
dnl damn! FreeBSD's pthreads breaks dup2().
TLDFLAGS="$LDFLAGS"
case $host in
i386-unknown-freebsd*)
    if echo "$LDFLAGS" | grep -q pthread; then
	LDFLAGS=`echo $LDFLAGS | sed -e "s/-pthread//"`
    fi
esac
AC_TRY_RUN([
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>	/* needed on FreeBSD */
#include <sys/param.h>
#include <sys/resource.h>
main() {
	FILE *fp;
	int i,j;
#if defined(__CYGWIN32__) || defined (__CYGWIN__)
    /* getrlimit and sysconf returns bogous values on cygwin32.
     * Number of fds is virtually unlimited in cygwin (sys/param.h)
     * __CYGWIN32__ is deprecated.
     */
    i = NOFILE;
#else
#if HAVE_SETRLIMIT
    struct rlimit rl;
#if defined(RLIMIT_NOFILE)
    if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
	perror("getrlimit: RLIMIT_NOFILE");
    } else {
	rl.rlim_cur = rl.rlim_max;      /* set it to the max */
	if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
	    perror("setrlimit: RLIMIT_NOFILE");
	}
    }
#elif defined(RLIMIT_OFILE)
    if (getrlimit(RLIMIT_OFILE, &rl) < 0) {
	perror("getrlimit: RLIMIT_OFILE");
    } else {
	rl.rlim_cur = rl.rlim_max;      /* set it to the max */
	if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
	    perror("setrlimit: RLIMIT_OFILE");
	}
    }
#endif /* RLIMIT_NOFILE */
#endif /* HAVE_SETRLIMIT */
	/* by starting at 2^14, we will never get higher
	than 2^15 for SQUID_MAXFD */
	i = j = 1<<14;
	while (j) {
		j >>= 1;
		if (dup2(0, i) < 0) { 
			i -= j;
		} else {
			close(i);
			i += j;
		}
	}
	i++;
#endif /* IF !DEF CYGWIN */
	fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", i & ~0x3F);
	exit(0);
}
],
SQUID_MAXFD=`cat conftestval`,
SQUID_MAXFD=256,
SQUID_MAXFD=256)
dnl Microsoft MSVCRT.DLL supports 2048 maximum FDs
case "$host_os" in
mingw|mingw32)
  SQUID_MAXFD="2048"
  ;;
esac
AC_MSG_RESULT($SQUID_MAXFD)
fi # --with-maxfd SQUID_MAXFD
AC_DEFINE_UNQUOTED(SQUID_MAXFD, $SQUID_MAXFD, [Maximum number of open filedescriptors])
if test "$SQUID_MAXFD" -lt 512 ; then
    echo "WARNING: $SQUID_MAXFD may not be enough filedescriptors if your"
    echo "         cache will be very busy.  Please see the FAQ page"
    echo "         http://www.squid-cache.org/FAQ/FAQ-11.html#filedescriptors"
    echo "         on how to increase your filedescriptor limit"
    sleep 10
fi
LDFLAGS="$TLDFLAGS"

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default UDP send buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val<=0) exit(1);
	fp = fopen("conftestval", "w");
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_UDP_SO_SNDBUF=`cat conftestval`,
SQUID_UDP_SO_SNDBUF=16384,
SQUID_UDP_SO_SNDBUF=16384)
AC_MSG_RESULT($SQUID_UDP_SO_SNDBUF)
AC_DEFINE_UNQUOTED(SQUID_UDP_SO_SNDBUF, $SQUID_UDP_SO_SNDBUF, [UDP send buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default UDP receive buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_UDP_SO_RCVBUF=`cat conftestval`,
SQUID_UDP_SO_RCVBUF=16384,
SQUID_UDP_SO_RCVBUF=16384)
AC_MSG_RESULT($SQUID_UDP_SO_RCVBUF)
AC_DEFINE_UNQUOTED(SQUID_UDP_SO_RCVBUF, $SQUID_UDP_SO_RCVBUF, [UDP receive buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default TCP send buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_TCP_SO_SNDBUF=`cat conftestval`,
SQUID_TCP_SO_SNDBUF=16384,
SQUID_TCP_SO_SNDBUF=16384)
AC_MSG_RESULT($SQUID_TCP_SO_SNDBUF)
if test $SQUID_TCP_SO_SNDBUF -gt 32768; then
    echo "Limiting send buffer size to 32K"
    SQUID_TCP_SO_SNDBUF=32768
fi
AC_DEFINE_UNQUOTED(SQUID_TCP_SO_SNDBUF, $SQUID_TCP_SO_SNDBUF, [TCP send buffer size])

dnl Not cached since people are likely to tune this
AC_MSG_CHECKING(Default TCP receive buffer size)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_WINSOCK_H
#include <winsock.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
main ()
{
	FILE *fp;
	int fd,val=0,len=sizeof(int);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSADATA wsaData;
	WSAStartup(2, &wsaData);
#endif
	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) exit(1);
	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) exit(1);
#if (defined(WIN32) || defined(__WIN32__) || defined(__WIN32)) && !(defined(__CYGWIN32__) || defined(__CYGWIN__))
	WSACleanup();
#endif
	if (val <= 0) exit(1);
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%d\n", val);
	exit(0);
}
],
SQUID_TCP_SO_RCVBUF=`cat conftestval`,
SQUID_TCP_SO_RCVBUF=16384,
SQUID_TCP_SO_RCVBUF=16384)
AC_MSG_RESULT($SQUID_TCP_SO_RCVBUF)
if test $SQUID_TCP_SO_RCVBUF -gt 65535; then
    echo "Limiting receive buffer size to 64K"
    SQUID_TCP_SO_RCVBUF=65535
fi
AC_DEFINE_UNQUOTED(SQUID_TCP_SO_RCVBUF, $SQUID_TCP_SO_RCVBUF, [TCP receive buffer size])
AC_CACHE_CHECK(if sys_errlist is already defined, ac_cv_needs_sys_errlist,
  AC_TRY_COMPILE([#include <stdio.h>],[char *s = sys_errlist;],
    ac_cv_needs_sys_errlist="no",
    ac_cv_needs_sys_errlist="yes")
)
if test "$ac_cv_needs_sys_errlist" = "yes" ; then
  AC_DEFINE(NEED_SYS_ERRLIST, 1, [If we need to declare sys_errlist[] as external])
fi

AC_MSG_CHECKING(if inet_ntoa() actually works)
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main ()
{
	FILE *fp;
	struct in_addr in;
	in.s_addr = inet_addr("1.2.3.4");
	fp = fopen("conftestval", "w"); 
	fprintf (fp, "%s\n", inet_ntoa(in));
	exit(0);
}
],
INET_NTOA_RESULT=`cat conftestval`,
INET_NTOA_RESULT="broken",
INET_NTOA_RESULT="broken")
if test "$INET_NTOA_RESULT" = "1.2.3.4" ; then
	AC_MSG_RESULT("yes")
else
	AC_MSG_RESULT("no")
	case "$host_os" in
	mingw|mingw32)
	    echo "Using Win32 resolver instead."
	    ;;
	    *)      
	    echo "Will use our own inet_ntoa()."
	    # autoconf-2.13 needs the lines below switched
#	    LIBOBJS="$LIBOBJS inet_ntoa.o"
	    AC_LIBOBJ(inet_ntoa)
#	    echo "WARNING: This looks bad, and probably prevents Squid from working."
#	    echo "         If you're on IRIX and using GCC 2.8, you probably need"
#	    echo "         to use the IRIX C compiler instead."
#	    sleep 10
	;;
	esac
fi

if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then
AC_MSG_CHECKING(for working statvfs() interface)
AC_TRY_COMPILE([
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/statvfs.h>
],
[
struct statvfs sfs;
fsblkcnt_t blocks;
fsfilcnt_t files;
blocks = sfs.f_blocks = sfs.f_bfree = sfs.f_frsize = 0;
files = sfs.f_files = sfs.f_ffree = 0;
statvfs("/tmp", &sfs);
],
  ac_cv_func_statvfs=yes,
  ac_cv_func_statvfs=no)
AC_MSG_RESULT($ac_cv_func_statvfs)
if test "$ac_cv_func_statvfs" = "yes" ; then
  AC_DEFINE(HAVE_STATVFS, 1, [If your system has statvfs(), and if it actually works!])
fi
fi

AC_CACHE_CHECK(for _res.nsaddr_list, ac_cv_have_res_nsaddr_list,
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#if HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[_res.nsaddr_list[[0]];],
ac_cv_have_res_nsaddr_list="yes",
ac_cv_have_res_nsaddr_list="no"))
if test $ac_cv_have_res_nsaddr_list = "yes" ; then
  AC_DEFINE(HAVE_RES_NSADDR_LIST, 1, [If _res structure has nsaddr_list member])
fi

if test $ac_cv_have_res_nsaddr_list = "no" ; then
AC_CACHE_CHECK(for _res.ns_list, ac_cv_have_res_ns_list,
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#if HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#if HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[_res.ns_list[[0]].addr;],
ac_cv_have_res_ns_list="yes",
ac_cv_have_res_ns_list="no"))
if test $ac_cv_have_res_ns_list = "yes" ; then
  AC_DEFINE(HAVE_RES_NS_LIST, 1, [If _res structure has ns_list member])
fi
fi

dnl Need the debugging version of malloc if available
XTRA_OBJS=''
if test "$ac_cv_lib_malloc_main" = "yes" ; then
	if test -r /usr/lib/debug/malloc.o ; then
		XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/malloc.o"
	fi
	if test -r /usr/lib/debug/mallocmap.o ; then
		XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/mallocmap.o"
	fi
fi

AC_SUBST(XTRA_OBJS)

if test -z "$XTRA_LIBS"; then
	XTRA_LIBS="$LIBS"
	dnl minor cleanup
	XTRA_LIBS=`echo $XTRA_LIBS | sed -e "s/  */ /g"`
	LIBS=''
fi
AC_SUBST(XTRA_LIBS)

dnl Clean up after OSF/1 core dump bug
rm -f core 

dnl FS_MAKEFILES=""
dnl for fs in $STORE_MODULES none; do
dnl 	if test $fs != none; then
dnl	    FS_MAKEFILES="$FS_MAKEFILES ./src/fs/$fs/Makefile"
dnl 	fi
dnl done
dnl REPL_MAKEFILES=""
dnl for repl in $REPL_POLICIES none; do
dnl 	if test $repl != none; then
dnl 	    REPL_MAKEFILES="$REPL_MAKEFILES ./src/repl/$repl/Makefile"
dnl 	fi
dnl done

dnl This could actually be used to find all the Makefiles..
dnl One of Automake's limitations is that it needs to know all the created makefiles.
dnl AUTH_MAKEFILES=""
dnl for auth in `find $srcdir/src/auth -type d -print`; do
dnl 	if test -f $auth/Makefile.in; then
dnl	    dir=`echo $auth | sed -e "s|^$srcdir/||"`
dnl            AUTH_MAKEFILES="$AUTH_MAKEFILES ./$dir/Makefile"
dnl	fi
dnl done


AC_OUTPUT([\
	Makefile \
	lib/Makefile \
	scripts/Makefile \
	scripts/RunCache \
	src/Makefile \
	src/fs/Makefile \
	src/repl/Makefile \
	src/auth/Makefile \
	contrib/Makefile \
	snmplib/Makefile \
	icons/Makefile \
	errors/Makefile \
	doc/Makefile \
	helpers/Makefile \
	helpers/basic_auth/Makefile \
	helpers/basic_auth/LDAP/Makefile \
	helpers/basic_auth/MSNT/Makefile \
	helpers/basic_auth/NCSA/Makefile \
	helpers/basic_auth/PAM/Makefile \
	helpers/basic_auth/SMB/Makefile \
	helpers/basic_auth/YP/Makefile \
	helpers/basic_auth/getpwnam/Makefile \
	helpers/basic_auth/mswin_sspi/Makefile \
	helpers/basic_auth/multi-domain-NTLM/Makefile \
	helpers/basic_auth/SASL/Makefile \
	helpers/basic_auth/POP3/Makefile \
	helpers/basic_auth/DB/Makefile \
	helpers/basic_auth/squid_radius_auth/Makefile \
	helpers/digest_auth/Makefile \
	helpers/digest_auth/password/Makefile \
	helpers/digest_auth/ldap/Makefile \
	helpers/digest_auth/eDirectory/Makefile \
	helpers/ntlm_auth/Makefile \
	helpers/ntlm_auth/fakeauth/Makefile \
	helpers/ntlm_auth/mswin_sspi/Makefile \
	helpers/ntlm_auth/no_check/Makefile \
	helpers/ntlm_auth/SMB/Makefile \
	helpers/ntlm_auth/SMB/smbval/Makefile \
	helpers/negotiate_auth/Makefile \
	helpers/negotiate_auth/mswin_sspi/Makefile \
	helpers/negotiate_auth/squid_kerb_auth/Makefile \
	helpers/external_acl/Makefile \
	helpers/external_acl/ip_user/Makefile \
	helpers/external_acl/ldap_group/Makefile \
	helpers/external_acl/mswin_ad_group/Makefile \
	helpers/external_acl/mswin_lm_group/Makefile \
	helpers/external_acl/session/Makefile \
	helpers/external_acl/unix_group/Makefile \
	helpers/external_acl/wbinfo_group/Makefile \
	tools/Makefile \
])