1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
|
# This file is part of libmicrohttpd.
# (C) 2006-2021 Christian Grothoff (and other contributing authors)
# (C) 2014-2021 Evgeny Grin (Karlson2k)
#
# libmicrohttpd is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# libmicrohttpd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libmicrohttpd; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
#
# Process this file with autoconf to produce a configure script.
#
#
AC_PREREQ([2.64])
LT_PREREQ([2.4.0])
AC_INIT([GNU Libmicrohttpd],[0.9.75],[libmicrohttpd@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] [silent-rules] [subdir-objects])
AC_CONFIG_HEADERS([MHD_config.h])
AC_CONFIG_MACRO_DIR([m4])
LIB_VERSION_CURRENT=72
LIB_VERSION_REVISION=0
LIB_VERSION_AGE=60
AC_SUBST(LIB_VERSION_CURRENT)
AC_SUBST(LIB_VERSION_REVISION)
AC_SUBST(LIB_VERSION_AGE)
AC_MSG_CHECKING([[whether z/OS special settings are required]])
AS_IF([test `uname -s` = "OS/390"],
[
# configure binaries for z/OS
AS_IF([test -z "$CC"],
[CC=`pwd`"/contrib/xcc"
chmod +x $CC || true])
AS_IF([test -z "$CPP"],
CPP="c89 -E")
AS_IF([test -z "$CXXCPP"],
CXXCPP="c++ -E -+")
AC_MSG_RESULT([[yes]])
# _CCC_CCMODE=1
# _C89_CCMODE=1
],
AC_MSG_RESULT([[no]])
)
# Checks for programs.
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_FGREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CANONICAL_HOST
m4_version_prereq([2.70],
[
# Find C compiler and compiler options to support
# the latest C standard (C11). Fallback to C99 and C89
# if later C versions are not supported.
AC_PROG_CC
],
[
# Find C compiler and compiler options to support
# the latest C standard (C99). Fallback to C89
# if later C versions are not supported.
AC_PROG_CC_STDC
]
)
user_CFLAGS="$CFLAGS"
user_LDFLAGS="$LDFLAGS"
user_CPPFLAGS="$CPPFLAGS"
CFLAGS_ac=""
LDFLAGS_ac=""
CPPFLAGS_ac=""
MHD_SYS_EXT([CPPFLAGS_ac])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
LT_INIT([win32-dll])
LT_LANG([Windows Resource])
# Check for headers that are ALWAYS required
AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [],
[AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers files])], [AC_INCLUDES_DEFAULT])
# Check for basic optional headers
AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for clock-specific optional headers
AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for system information and parameters optional headers
AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \
sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \
sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT])
# Check for network and sockets optional headers
AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in.h arpa/inet.h \
netinet/ip.h netinet/tcp.h net/if.h \
netdb.h sockLib.h inetLib.h], [], [],
[AC_INCLUDES_DEFAULT
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif /* HAVE_NETINET_IP_H */
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif /* HAVE_NETINET_TCP_H */
]]
)
# Check for other optional headers
AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADER([[search.h]],
[
gl_FUNC_TSEARCH
AS_IF([[test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]],
[AC_DEFINE([[HAVE_SEARCH_H]], [[1]],
[Define to 1 if you have the <search.h> header file and your system have properly functioning tsearch(), tfind() and tdelete() functions])])
],
[], [AC_INCLUDES_DEFAULT])
AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
# Optional headers used for tests
AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [],
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif /* HAVE_SYS_SYSCTL_H */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif /* HAVE_NETINET_IP_H */
#ifdef HAVE_NETINET_IP_ICMP_H
#include <netinet/ip_icmp.h>
#endif /* HAVE_NETINET_IP_ICMP_H */
]]
)
# Adam shostack suggests the following for Windows:
# -D_FORTIFY_SOURCE=2 -fstack-protector-all
AC_ARG_ENABLE([gcc-hardening],
[AS_HELP_STRING([--enable-gcc-hardening], [enable compiler security checks])],
[AS_IF([test x$enableval = xyes],[
CFLAGS_ac="${CFLAGS_ac} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all"
CFLAGS_ac="${CFLAGS_ac} -fwrapv -fPIE -Wstack-protector"
CFLAGS_ac="${CFLAGS_ac} --param ssp-buffer-size=1"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS_ac="${LDFLAGS_ac} -pie"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
])])
# Linker hardening options
# Currently these options are ELF specific - you can't use this with MacOSX
AC_ARG_ENABLE([linker-hardening],
[AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])],
[AS_IF([test x$enableval = xyes],
[LDFLAGS_ac="${LDFLAGS_ac} -z relro -z now"])])
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
# Workaround for libgcrypt
AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]])
PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))'
AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]])
AC_SUBST([PACKAGE_VERSION_MAJOR])
AC_SUBST([PACKAGE_VERSION_MINOR])
AC_SUBST([PACKAGE_VERSION_SUBMINOR])
AC_SUBST([MHD_W32_DLL_SUFF])
AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
MHD_LIB_CPPFLAGS=""
MHD_LIB_CFLAGS=""
MHD_LIB_LDFLAGS=""
MHD_LIBDEPS=""
# for pkg-config
MHD_REQ_PRIVATE=''
MHD_LIBDEPS_PKGCFG=''
AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.])
AH_TEMPLATE([[HAVE_REAL_BOOL]], [Define to 1 if you have the real boolean type.])
AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.])
AC_CHECK_HEADER([stdbool.h],
[
AC_CHECK_TYPE([bool],
[
AC_DEFINE([[HAVE_STDBOOL_H]], [[1]])
AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
],
[
AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]])
AC_DEFINE([[bool]], [[int]])
], [
#include <stdbool.h>
]
)
],
[
AC_CHECK_TYPE([bool],
[AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])],
[
AC_CHECK_TYPE([_Bool],
[
AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])
AC_DEFINE([[bool]], [[_Bool]])
],
[
AC_DEFINE([[bool]], [[int]])
], []
)
], []
)
],
[AC_INCLUDES_DEFAULT]
)
AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
]], [[
#if defined(true)
/* dummy */
#else
(void)true;
#endif
]])
], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
])
AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
[AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
]], [[
#if !defined(false)
(void)false;
#else
/* dummy */
#endif
]])
], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
])
AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
[AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
]], [[
int var1[true ? 1 : -1] = { 1 };
int var2[false ? -1 : 1] = { 2 };
int var3[!true ? -1 : 1] = { 3 };
int var4[!false ? 1 : -1] = { 4 };
if (var1[0] == var2[0] || var3[0] == var4[0])
return 1;
]])
], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
])
AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
[AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
[
AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])],
[
AC_MSG_RESULT([[no]])
errattr_CFLAGS=""
], [
AC_MSG_RESULT([[yes]])
errattr_CFLAGS="-Werror=attributes"
])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
],
[[errattr_CFLAGS=""]], [], [])
AC_MSG_CHECKING([[for function inline keywords supported by $CC]])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} $errattr_CFLAGS"
inln_prfx="none"
# Prefer always inline functions
for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline
do
# Try to link to avoid "symbol undefined" problems at build time
AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]],
[
AS_IF([[test "x$errattr_CFLAGS" = "x"]],
[[ # Skip test with attribute as negative result can't be detected
inln_prfx_chk="__forceinline" # use next value
]],[[inln_prfx_chk="inline __attribute__((always_inline))"]])
])
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef __cplusplus
#error This test is only for C.
choke me
#endif
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
static $inln_prfx_chk bool cmpfn(int x, int y)
{ return x > y; }
static $inln_prfx_chk int sumfn(int x, int y)
{ return x + y; }
]],[[
int a = 1, b = 100, c;
if (cmpfn(a, b))
c = sumfn(a, b);
else
c = 0 - sumfn(a, b);
if (c)
return 0;
]])
],
[[ inln_prfx="$inln_prfx_chk" ]])
test "x$inln_prfx" != "xnone" && break
done
AS_IF([[test "x$inln_prfx" != "xnone"]],
[
AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.])
AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $inln_prfx],[Define to prefix which will be used with MHD static inline functions.])
], [
AC_DEFINE([_MHD_static_inline],[static],[Define to prefix which will be used with MHD static inline functions.])
])
AC_MSG_RESULT([[$inln_prfx]])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT])
AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDALIGN_H
#include <stdalign.h>
#endif
]], [[
int var1[(alignof(int) >= 2) ? 1 : -1];
int var2[alignof(unsigned int) - 1];
int var3[(alignof(char) > 0) ? 1 : -1];
int var4[(alignof(long) >= 4) ? 1 : -1];
/* Mute compiler warnings */
var1[0] = var2[0] = var3[0] = 0;
var4[0] = 1;
if (var1[0] + var2[0] + var3[0] == var4[0])
return 1;
]])
], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDALIGN_H
#include <stdalign.h>
#endif
]], [[
/* Should fail if 'alignof()' works */
int var1[alignof(nonexisting_type) - 1];
/* Mute compiler warnings */
var1[0] = 1;
if (var1[0] + 1 == 1)
return 1;
]])
], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']])
], [[mhd_cv_c_alignof='no']])
])
AS_VAR_IF([mhd_cv_c_alignof], ["yes"],
[AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])])
# Check system type
shutdown_trig_select='no'
AC_MSG_CHECKING([[for target host OS]])
AS_CASE(["$host_os"],
[*darwin* | *rhapsody* | *macosx*],
[AC_DEFINE_UNQUOTED(OSX,1,[This is an OS X system])
CFLAGS_ac="-no-cpp-precomp -fno-common $CFLAGS_ac"
mhd_host_os='Darwin'
AC_MSG_RESULT([[$mhd_host_os]])],
[freebsd*],
[AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(FREEBSD,1,[This is a FreeBSD system])
mhd_host_os='FreeBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[openbsd*],
[AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(OPENBSD,1,[This is an OpenBSD system])
mhd_host_os='OpenBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[netbsd*],
[AC_DEFINE_UNQUOTED(SOMEBSD,1,[This is a BSD system])
AC_DEFINE_UNQUOTED(NETBSD,1,[This is a NetBSD system])
mhd_host_os='NetBSD'
AC_MSG_RESULT([[$mhd_host_os]])],
[*solaris*],
[AC_DEFINE_UNQUOTED(SOLARIS,1,[This is a Solaris system])
AC_DEFINE_UNQUOTED(_REENTRANT,1,[Need with solaris or errno does not work])
mhd_host_os='Solaris'
AC_MSG_RESULT([[$mhd_host_os]])
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket])],
[*arm-linux*],
[AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
mhd_host_os='ARM Linux'
AC_MSG_RESULT([[$mhd_host_os]])
CFLAGS_ac="-fPIC -pipe $CFLAGS_ac"],
[*linux*],
[AC_DEFINE_UNQUOTED(LINUX,1,[This is a Linux kernel])
mhd_host_os='Linux'
AC_MSG_RESULT([[$mhd_host_os]])],
[*cygwin*],
[AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
mhd_host_os='Windows/Cygwin'
AC_MSG_RESULT([[$mhd_host_os]])
os_is_windows=yes],
[*mingw*],
[
AC_DEFINE([MINGW],[1],[This is a MinGW system])
AC_DEFINE([WINDOWS],[1],[This is a Windows system])
mhd_host_os='Windows/MinGW'
AC_MSG_RESULT([[$mhd_host_os]])
LIBS="-lws2_32 ${LIBS}"
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT])
AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
[mslibcheck=`lib 2>&1`
AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null],
[ac_cv_use_ms_lib_tool=yes],
[ac_cv_use_ms_lib_tool=no])
])
AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"],
[AC_SUBST([MS_LIB_TOOL], [[lib]])])
AC_SUBST([lt_cv_objdir])
os_is_windows=yes
os_is_native_w32=yes
],
[*openedition*],
[AC_DEFINE_UNQUOTED(OS390,1,[This is a OS/390 system])
mhd_host_os='OS/390'
AC_MSG_RESULT([[$mhd_host_os]])],
[gnu*],
[AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.])
mhd_host_os='GNU Hurd'
AC_MSG_RESULT([[$mhd_host_os]])
],
[
AC_MSG_RESULT([unrecognised OS])
mhd_host_os="${host_os}"
AC_MSG_WARN([Unrecognised OS $host_os])
AC_DEFINE_UNQUOTED(OTHEROS,1,[Some strange OS])
])
AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \
test "x${os_is_native_w32}" != "xyes"]])
AS_VAR_IF([os_is_windows], ["yes"],
[
AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
/* Note: check logic is reversed for easy log reading */
#ifdef WINVER
#error WINVER is defined
choke me now;
#endif
#ifdef _WIN32_WINNT
#error _WIN32_WINNT is defined
choke me now;
#endif
#ifdef NTDDI
#error NTDDI is defined
choke me now;
#endif
]],[[(void)0]])
], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]]
)
AC_MSG_RESULT([[${mhd_w32_ver_preselect}]])
AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT])
AS_VAR_IF([mhd_w32_ver_preselect],["yes"],
[
AC_MSG_CHECKING([[for specified target W32 version]])
AS_UNSET([[mhd_w32_ver]])
AS_UNSET([[mhd_w32_ver_msg]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if _WIN32_WINNT+0 < 0x0501
/* Check before headers inclusion */
#error _WIN32_WINNT is less than 0x0501
choke me now;
#endif
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#if _WIN32_WINNT+0 < 0x0501
#error _WIN32_WINNT is less than 0x0501
choke me now;
#endif
]],[[(void)0]])
], [], [
AC_MSG_RESULT([[pre-WinXP]])
AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]])
]
)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#if _WIN32_WINNT+0 == 0x0501
#error _WIN32_WINNT is 0x0501
choke me now;
#endif
#if _WIN32_WINNT+0 == 0x0502
#error _WIN32_WINNT is 0x0502
choke me now;
#endif
]],[[(void)0]])
], [], [
mhd_w32_ver="WinXP"
mhd_w32_ver_msg="WinXP (selected by precompiler flags)"
]
)
AS_VAR_SET_IF([mhd_w32_ver], [],
[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#if _WIN32_WINNT+0 < 0x0600
#error _WIN32_WINNT is less than 0x0600 but greater than 0x0502
choke me now;
#endif
]],[[(void)0]])
], [], [
AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]])
]
)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#if _WIN32_WINNT+0 == 0x0600
#error _WIN32_WINNT is 0x0600
choke me now;
#endif
]],[[(void)0]])
], [], [
mhd_w32_ver="Vista"
mhd_w32_ver_msg="Vista (selected by precompiler flags)"
]
)
]
)
AS_VAR_SET_IF([mhd_w32_ver], [],
[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#if _WIN32_WINNT+0 > 0x0600
#error _WIN32_WINNT is greater than 0x0600
choke me now;
#endif
]],[[(void)0]])
], [
mhd_w32_ver="unknown"
mhd_w32_ver_msg="unknown (cannot be detected)"
], [
mhd_w32_ver="newer than Vista"
mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)"
]
)
]
)
AC_MSG_RESULT([[${mhd_w32_ver}]])
], [
mhd_w32_ver="Vista"
mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)"
CPPFLAGS_ac="${CPPFLAGS_ac} -D_WIN32_WINNT=0x0600"
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#include <stdio.h>
]],[[(void)0]])
], [
AC_MSG_RESULT([[yes]])
], [
AC_MSG_RESULT([[no]])
AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN])
]
)
]
)
]
)
AS_IF([test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes"],
[
AC_CACHE_CHECK([W32 run-time library type], [mhd_cv_wctr_type],
[
AC_EGREP_CPP([MHDMARKER: UCRT run-time library in use!], [
#include <stdio.h>
#if defined(_UCRT)
#define CRT_STR "MHDMARKER: UCRT run-time library in use!"
#endif
#if defined(__MSVCRT_VERSION__)
#if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000)
#define CRT_STR "MHDMARKER: UCRT run-time library in use!"
#endif
#if (__MSVCRT_VERSION__ > 0x1400)
#define CRT_STR "MHDMARKER: UCRT run-time library in use!"
#endif
#endif
#ifndef CRT_STR
#define CRT_STR "MHDMARKER: MSVCRT run-time library in use!"
#endif
int main(void)
{
printf ("%\n", CRT_STR);
return 0;
}
],
[mhd_cv_wctr_type="ucrt"], [mhd_cv_wctr_type="msvcrt"])
]
)
mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}"
AS_VAR_IF([mhd_cv_wctr_type], ["msvcrt"],
[
# Use CFLAGS here to override user-supplied wrong CPPFLAGS. Durty trick, but choice is limited.
AX_APPEND_COMPILE_FLAGS([-U__USE_MINGW_ANSI_STDIO -D__USE_MINGW_ANSI_STDIO=0], [CFLAGS_ac])
AC_SUBST([W32CRT], [MSVCRT])
], [AC_SUBST([W32CRT], [UCRT])]
)
]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
AC_ARG_WITH([threads],
[AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])],
[], [with_threads='auto'])
AS_CASE([[$with_threads]],
[[win32]], [[with_threads='w32']],
[[pthreads]], [[with_threads='posix']],
[[posix]], [[:]],
[[w32]], [[:]],
[[none]], [[with_threads='none']],
[[no]], [[with_threads='none']],
[[auto]], [[:]],
[AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])]
)
# Check for posix threads support, regardless of configure parameters as
# testsuite uses only posix threads.
AX_PTHREAD(
[
mhd_have_posix_threads='yes'
AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the <pthread.h> header file.])
AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]],
[[mhd_cv_func_pthread_sigmask]], [dnl
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
[[
sigset_t nset, oset;
sigemptyset (&nset);
sigaddset (&nset, SIGPIPE);
if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
]])],
[[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]])
LIBS="${save_LIBS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
])
AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"],
[AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])])
],[[mhd_have_posix_threads='no']])
AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
mhd_have_w32_threads='no'
AS_IF([[test "x$with_threads" = "xauto"]],
[
AS_IF([[test "x$os_is_windows" = "xyes"]],
[
AC_MSG_CHECKING([[for W32 threads]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <windows.h>
]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
, [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']]
)
AC_MSG_RESULT([[$mhd_have_w32_threads]])
])
]
)
AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]])
AS_IF([test "x$with_threads" = "xposix"],
[ # forced posix threads
AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'],
[ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
[ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
[ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
])
])
AS_IF([test "x$with_threads" = "xw32"],
[ # forced w32 threads
AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
[[ USE_THREADS='w32' ]],
[ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
])
AS_IF([test "x$with_threads" = "xauto"],
[# automatic threads lib selection
AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] ,
[[ USE_THREADS='w32' ]] ,
[[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]],
[[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
[ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
)])
AS_IF([test "x$with_threads" = "xnone"],
[USE_THREADS='none'])
AS_IF([test "x$USE_THREADS" = "xposix"],
[CC="$PTHREAD_CC"
AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"],
[AS_IF([test "x$USE_THREADS" = "xw32"],
[AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])])
AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
AM_CONDITIONAL([USE_THREADS], [test "x$USE_THREADS" != "xnone"])
AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"])
AC_MSG_RESULT([$USE_THREADS])
AC_ARG_ENABLE([[thread-names]],
[AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])],
[], [enable_thread_names='auto'])
AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[
# Check for thread name function
HAVE_THREAD_NAME_FUNC="no"
SAVE_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="${CFLAGS_ac} $PTHREAD_CFLAGS ${user_CFLAGS}"
AC_CHECK_HEADERS([pthread_np.h],[],[],
[
AC_INCLUDES_DEFAULT
[
#include <pthread.h>
]
])
# Try to find how to set thread name by thread attributes.
# If pthread_attr_setname_np(3) is not declared, it's not possible to detect
# form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration".
AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]])
AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
[AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[
pthread_attr_t thr_attr;
pthread_attr_init(&thr_attr);
pthread_attr_setname_np(&thr_attr, "name", 0);
pthread_attr_destroy(&thr_attr);
]])],
[AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_attr_setname_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
])
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]],
[AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i or Solaris form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[
pthread_attr_t thr_attr;
pthread_attr_init(&thr_attr);
pthread_attr_setname_np(&thr_attr, "name");
pthread_attr_destroy(&thr_attr);
]])],
[AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
])
# Try to find how to set thread name for started thread - less convenient
# than setting name by attributes.
# If pthread_setname_np(3) is not declared, it's not possible to detect
# form of pthread_setname_np(3) due to C "feature" "implicit declaration".
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
[AC_CHECK_DECL([[pthread_setname_np]],[],[],[[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]])
])
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
[AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res;]])],
[AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
])
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
[AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[int res = pthread_setname_np(pthread_self(), "name"); if (res) return res;]])],
[AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
])
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]],
[AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[int res = pthread_setname_np("name"); if (res) return res;]])],
[AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
])
AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]],
[
AC_CHECK_DECL([[pthread_set_name_np]],
[
AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]], [[pthread_set_name_np(pthread_self(), "name");]])],
[AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.])
HAVE_THREAD_NAME_FUNC="yes"
AC_MSG_RESULT([[yes]])],
[AC_MSG_RESULT([[no]])]
)
],[],[[
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
]]
)
])
LIBS="$SAVE_LIBS"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
])
AS_IF([[test "x$enable_thread_names" != "xno"]],
[
AC_MSG_CHECKING([[whether to enable thread names]])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifdef MHD_NO_THREAD_NAMES
#error Thread names are disabled.
choke me
#endif
/* Keep in sync with mhd_threads.h */
#if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \
defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \
defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) )
(void) 0; /* no-op */
#elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER)
(void) 0; /* no-op */
#else
#error No thread name function is available.
choke me
#endif
]])
], [
enable_thread_names='yes'
], [
AS_IF([[test "x$enable_thread_names" = "xyes"]],
[
AC_MSG_RESULT([[no]])
AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]])
])
enable_thread_names='no'
])
AC_MSG_RESULT([[$enable_thread_names]])
])
AS_IF([[test "x$enable_thread_names" = "xno"]],
[AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])])
AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])
w32_shared_lib_exp=no
AS_IF([test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"],
[
AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"],
[
w32_shared_lib_exp=yes
use_expfile="no"
AS_VAR_IF([ac_cv_use_ms_lib_tool], ["yes"], [use_expfile="yes"],
[
AC_CACHE_CHECK([whether $DLLTOOL supports export file generation], [mhd_cv_dlltool_expfile],
[
AS_IF([AC_RUN_LOG([$DLLTOOL -e conftest.exp >&2 ])],
[
AS_IF([test -f conftest.exp], [mhd_cv_dlltool_expfile="yes"], [mhd_cv_dlltool_expfile="no"])
], [mhd_cv_dlltool_expfile="no"]
)
rm -f conftest.exp
]
)
use_expfile="${mhd_cv_dlltool_expfile}"
]
)
],
[
AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]])
AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]])
]
)
]
)
AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test "x$w32_shared_lib_exp" = "xyes"])
AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"])
AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"])
MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])])
AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"])
# SENDMSG. Should we check for SCM_RIGHTS instead?
# https://lists.x.org/archives/xorg-devel/2013-November/038687.html
AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if your platform supports sendmsg])])
AC_CHECK_FUNCS([writev])
# set GCC options
# use '-fno-strict-aliasing', but only if the compiler
# and linker can take it
AX_CHECK_LINK_FLAG([-fno-strict-aliasing],
[AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [CFLAGS_ac])])
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
AC_C_BIGENDIAN
AC_C_VARARRAYS
AC_CACHE_CHECK([[whether __func__ magic-macro is available]],
[[mhd_cv_macro___func___avail]], [dnl
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __func__ ; if (NULL == funcname) return 1;]])],
[[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]])
])
AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
[AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])],
[
AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]],
[[mhd_cv_macro___function___avail]], [dnl
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]],[[const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1;]])],
[[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]])
])
AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.])
]
)
AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
[[mhd_cv_func___builtin_bswap32_avail]], [dnl
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b;]])],
[[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
])
AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
[AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])])
AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
[[mhd_cv_func___builtin_bswap64_avail]], [dnl
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint32_t b = __builtin_bswap64(a); a = b;]])],
[[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]])
])
AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
[AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])])
AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no])
AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"])
AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no])
AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"])
AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"])
AC_ARG_ENABLE([[doc]],
[AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], ,
[enable_doc=yes])
test "x$enable_doc" = "xno" || enable_doc=yes
AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"])
AC_ARG_ENABLE([[examples]],
[AS_HELP_STRING([[--disable-examples]], [do not build any examples])], ,
[enable_examples=yes])
test "x$enable_examples" = "xno" || enable_examples=yes
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"])
AC_ARG_ENABLE([[heavy-tests]],
[AS_HELP_STRING([[--enable-heavy-tests]], [use heavy tests in test-suite. WARNING:]
[a dedicated host with minimal number of background processes and no network]
[activity is recommended to enable.])], [],
[enable_heavy_tests=no])
AS_VAR_IF([enable_heavy_tests], ["yes"],
[
HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:'
AC_DEFINE([_MHD_HEAVY_TESTS], [1], [Define to 1 to enable "heavy" test paths.])
],
[
enable_heavy_tests=no
HEAVY_TESTS_NOTPARALLEL=" "
]
)
AM_CONDITIONAL([HEAVY_TESTS],[test "x$enable_heavy_tests" = "xyes"])
AC_ARG_ENABLE([[poll]],
[AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])],
[enable_poll=${enableval}],
[enable_poll='auto']
)
AS_IF([test "$enable_poll" != "no"],
[AS_IF([test "$os_is_native_w32" != "yes"],
AC_CHECK_HEADERS([poll.h],
[AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])],
[],
[AC_INCLUDES_DEFAULT]),
[AC_MSG_CHECKING([for WSAPoll()])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <winsock2.h>
]],[[
WSAPOLLFD fda[2];
WSAPoll(fda, 2, 0);]])],
[have_poll='yes'
AC_DEFINE([HAVE_POLL],[1])
],[have_poll='no'])
AC_MSG_RESULT([$have_poll])])
AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
[AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])])
enable_poll="$have_poll"])
AC_ARG_ENABLE([[epoll]],
[AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
[enable_epoll=${enableval}],
[enable_epoll='auto']
)
AS_IF([test "$enable_epoll" != "no"],
[
AX_HAVE_EPOLL
AS_IF([test "${ax_cv_have_epoll}" = "yes"],
[
AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
enable_epoll='yes'
],
[
AS_IF([test "$enable_epoll" = "yes"],
[AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])]
)
enable_epoll='no'
]
)
]
)
AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
AS_IF([test "x$enable_epoll" = "xyes"],
AC_CACHE_CHECK([for epoll_create1()],
[mhd_cv_have_epoll_create1], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/epoll.h>
]], [[
int fd;
fd = epoll_create1(EPOLL_CLOEXEC);]])],
[mhd_cv_have_epoll_create1=yes],
[mhd_cv_have_epoll_create1=no])])
AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])]))
AC_CACHE_CHECK([for suported 'noreturn' keyword], [mhd_cv_decl_noreturn],
[
mhd_cv_decl_noreturn="none"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)'
do
AC_LINK_IFELSE([AC_LANG_SOURCE(
[[
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
${decl_noret} void myexitfunc(int code)
{
#ifdef HAVE_STDLIB_H
exit (code);
#else
(void)code;
#endif
}
int main (int argc, char *const *argv)
{
(void) argv;
if (argc > 2)
myexitfunc (2);
return 0;
}
]]
)], [mhd_cv_decl_noreturn="${decl_noret}"]
)
AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break])
done
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
]
)
AS_VAR_IF([mhd_cv_decl_noreturn], ["none"],
[AC_DEFINE([_MHD_NORETURN], [], [Define to supported 'noreturn' function declaration])],
[AC_DEFINE_UNQUOTED([_MHD_NORETURN], [${mhd_cv_decl_noreturn}], [Define to supported 'noreturn' function declaration])]
)
# Check for types sizes
# Types sizes are used as an indirect indication of maximum allowed values for types
# which is used to exclude by preprocessor some compiler checks for values clips
# Assuming no staffing or uniform staffing for integer types
AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec],
[
AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))],
[[
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
#ifdef HAVE_TIME_H
#include <time.h>
#endif /* HAVE_TIME_H */
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
struct timeval test_var;
]],
[
# The size is used only to exclude additional checks/comparison in code
# to avoid compiler warnings. With larger size MHD code will use
# additional checks which ensure that value will fit but it may produce
# a harmless compiler warning.
AC_MSG_WARN([The size cannot be determined, assuming 8.])
mhd_cv_size_timeval_tv_sec=8
]
)
]
)
AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec],
[The size of `tv_sec' member of `struct timeval', as computed by sizeof])
AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]])
AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]])
AC_CHECK_SIZEOF([size_t], [],
[[
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif /* HAVE_STDDEF_H */
#include <stdio.h>
]]
)
AC_CHECK_SIZEOF([unsigned long long], [], [[#include <stdint.h>]])
AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT])
AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]])
AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT])
AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]])
# Check for generic functions
MHD_CHECK_FUNC([random],
[
AC_INCLUDES_DEFAULT
[#include <stdlib.h>
]],
[[long int r = random(); (void)r;]],
[],
[
MHD_CHECK_FUNC([rand],
[
AC_INCLUDES_DEFAULT
[#include <stdlib.h>
]],
[[int r = rand(); (void)r;]],
)
]
)
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len,
struct sockaddr_storage.ss_len],
[], [],
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
])
MHD_CHECK_FUNC([getsockname],
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
]],
[
struct sockaddr_storage ss;
(void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0);
],
[
AC_CACHE_CHECK([[whether getsockname() is usable]], [[mhd_cv_getsockname_usable]],
[
AC_RUN_IFELSE(
[
AC_LANG_SOURCE(
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
static void zr_mem(void *ptr, socklen_t size)
{ char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
int main(void)
{
const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in);
struct sockaddr_in sa;
socklen_t addr_size;
int ret = 1;
#if !defined(_WIN32) || defined(__CYGWIN__)
int sckt;
const int invld_sckt = -1;
#else
SOCKET sckt;
const SOCKET invld_sckt = INVALID_SOCKET;
WSADATA wsa_data;
if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion)
return 20;
#endif
sckt = socket (PF_INET, SOCK_STREAM, 0);
if (invld_sckt != sckt)
{
zr_mem(&sa, c_addr_size);
sa.sin_family = AF_INET;
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
sa.sin_len = c_addr_size;
#endif
if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size))
{
if (0 == listen (sckt, 1))
{
addr_size = c_addr_size;
if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size))
{
if (c_addr_size >= addr_size)
{
if (0 != ntohs(sa.sin_port))
{ ret = 0;
} else ret = 7;
} else ret = 6;
} else ret = 5;
} else ret = 4;
} else ret = 3;
} else ret = 2;
#if !defined(_WIN32) || defined(__CYGWIN__)
close (sckt);
#else
closesocket (sckt);
WSACleanup();
#endif
return ret;
}
]]
)
],
[[mhd_cv_getsockname_usable='yes']],
[[mhd_cv_getsockname_usable='no']],
[[mhd_cv_getsockname_usable='assuming yes']]
)
]
)
AS_VAR_IF([[mhd_cv_getsockname_usable]], [["no"]], [:],
[AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])])
]
)
AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
[
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef PAGESIZE
#error No PAGESIZE macro defined
choke me now
#endif
]],
[[
long pgsz = PAGESIZE + 0;
if (1 > pgsz) return 1;
]]
)
],
[[mhd_cv_macro_pagesize_usable="yes"]], [[mhd_cv_macro_pagesize_usable="no"]]
)
]
)
AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]],
[
AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro])
AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static],
[
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef PAGESIZE
#error No PAGESIZE macro defined
choke me now
#endif
static long ac_pgsz = PAGESIZE + 0;
]],
[[
if (1 > ac_pgsz) return 1;
]]
)
],
[[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]]
)
]
)
AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]],
[AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])]
)
],
[
AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable],
[
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef PAGE_SIZE
#error No PAGE_SIZE macro defined
choke me now
#endif
]],
[[
long pgsz = PAGE_SIZE + 0;
if (1 > pgsz) return 1;
]]
)
],
[[mhd_cv_macro_page_size_usable="yes"]], [[mhd_cv_macro_page_size_usable="no"]]
)
]
)
AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]],
[
AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro])
AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static],
[
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef PAGE_SIZE
#error No PAGE_SIZE macro defined
choke me now
#endif
static long ac_pgsz = PAGE_SIZE + 0;
]],
[[
if (1 > ac_pgsz) return 1;
]]
)
],
[[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]]
)
]
)
AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]],
[AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])]
)
]
)
]
)
# Check for inter-thread signaling type
AC_ARG_ENABLE([[itc]],
[AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
[[enable_itc='auto']]
)
AS_CASE([[$enable_itc]],
[[pipe]], [[:]],
[[socketpair]], [[:]],
[[eventfd]], [[:]],
[[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
[[eventFD]], [[enable_itc='eventfd']],
[[socket]], [[enable_itc='socketpair']],
[[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
[AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
)
# AS_UNSET([[use_itc]])
AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [
AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
AC_CHECK_HEADERS([sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT])
AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [
AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#include <sys/eventfd.h>
]], [[
int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (ef) return ef - 1;
]])
], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']])
])
])
])
AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [
use_itc='eventfd'
enable_itc="$use_itc"
AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication])
], [
AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
])
])
AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
AC_INCLUDES_DEFAULT
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
], [[
int arr[2];
int res;
res = pipe(arr)
]])
], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
])
])
AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
use_itc='pipe'
enable_itc="$use_itc"
AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
AC_CACHE_CHECK([[whether pipe2(2) is usable]], [[mhd_cv_pipe2_usable]], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
AC_INCLUDES_DEFAULT
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
], [[
int arr[2];
int res;
res = pipe2(arr, O_CLOEXEC | O_NONBLOCK)
]])
], [[mhd_cv_pipe2_usable='yes']], [[mhd_cv_pipe2_usable='no']])
])
AS_VAR_IF([[mhd_cv_pipe2_usable]], [["yes"]],
[AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])])
], [
AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
])
])
AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [
AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [
AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
AC_INCLUDES_DEFAULT
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
], [[
int arr[2];
int res;
#if defined(AF_LOCAL)
res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
#elif defined(AF_UNIX)
res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
#else
#error AF_LOCAL and AF_UNIX are both undefined
choke me now;
#endif
if (res != 0) return 1
]])
], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
])
])
AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
use_itc='socketpair'
enable_itc="$use_itc"
AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication])
], [
AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])])
])
])
AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])])
AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
AC_CHECK_DECL([gmtime_s],
[
AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
AC_LINK_IFELSE(
[ AC_LANG_PROGRAM(
[[
#define __STDC_WANT_LIB_EXT1__ 1
#include <time.h>
#ifdef __cplusplus
extern "C"
#endif
struct tm* gmtime_s(const time_t* time, struct tm* result);
]], [[
struct tm res;
time_t t;
gmtime_s (&t, &res);
]])
],
[
AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.])
AC_MSG_RESULT([[yes]])
],
[
AC_MSG_RESULT([[no]])
AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
AC_LINK_IFELSE(
[ AC_LANG_PROGRAM(
[[
#include <time.h>
#ifdef __cplusplus
extern "C"
#endif
errno_t gmtime_s(struct tm* _tm, const time_t* time);
]], [[
struct tm res;
time_t t;
gmtime_s (&res, &t);
]])
],
[
AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.])
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
])
])
], [],
[[#define __STDC_WANT_LIB_EXT1__ 1
#include <time.h>]])
AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
[[
#if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h>
#endif
#if defined(HAVE_SYS_SOCKET_H)
# include <sys/socket.h>
#elif defined(HAVE_WINSOCK2_H)
# include <winsock2.h>
#endif
]]
)
AC_CHECK_DECL([[clock_gettime]],
[
SAVE_LIBS="$LIBS"
AC_SEARCH_LIBS([clock_gettime], [rt],
[
AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])
AS_VAR_IF([[ac_cv_search_clock_gettime]],[["none required"]], [],
[
MHD_LIBDEPS="$ac_cv_search_clock_gettime $MHD_LIBDEPS"
MHD_LIBDEPS_PKGCFG="$ac_cv_search_clock_gettime $MHD_LIBDEPS_PKGCFG"
])
], [], [$MHD_LIBDEPS])
LIBS="$SAVE_LIBS"
], [], [[
#include <time.h>
]])
AC_MSG_CHECKING([[for clock_get_time]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <mach/clock.h>
#include <mach/mach.h>
]],
[[
clock_serv_t cs;
mach_timespec_t mt;
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
clock_get_time(cs, &mt);
mach_port_deallocate(mach_task_self(), cs);
]])
],
[
AC_DEFINE([HAVE_CLOCK_GET_TIME], [1], [Define to 1 if you have `clock_get_time', `host_get_clock_service' and `mach_port_deallocate' functions.])
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
])
AC_MSG_CHECKING([[for gethrtime]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_SYS_TIME_H
/* Solaris define gethrtime() in sys/time.h */
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
#ifdef HAVE_TIME_H
/* HP-UX define gethrtime() in time.h */
#include <time.h>
#endif /* HAVE_TIME_H */
]], [[hrtime_t hrt = gethrtime(); ]])
],
[
AC_DEFINE([HAVE_GETHRTIME], [1], [Define to 1 if you have `gethrtime' function.])
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
])
AS_VAR_IF([ac_cv_header_time_h], ["yes"],
[
AC_CACHE_CHECK([[for C11 timespec_get()]], [mhd_cv_func_timespec_get],
[
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <time.h>
#ifndef TIME_UTC
#error TIME_UTC must be defined to use timespec_get()
choke me now
#endif
]],
[[
struct timespec ts;
if (TIME_UTC != timespec_get (&ts, TIME_UTC))
return 1;
]]
)
], [[mhd_cv_func_timespec_get="yes"]], [[mhd_cv_func_timespec_get="no"]]
)
]
)
AS_VAR_IF([mhd_cv_func_timespec_get], ["yes"],
[AC_DEFINE([HAVE_TIMESPEC_GET], [1], [Define to 1 if you have C11 `mhd_cv_func_timespec_get' function and TIME_UTC macro.])]
)
]
)
AS_VAR_SET_IF([ac_cv_func_gettimeofday], [mhd_cv_func_gettimeofday="${ac_cv_func_gettimeofday}"])
AC_CACHE_CHECK([[for gettimeofday(2)]], [mhd_cv_func_gettimeofday], [
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
#ifdef HAVE_TIME_H
#include <time.h>
#endif /* HAVE_TIME_H */
]],
[[
struct timeval tv;
if (0 != gettimeofday (&tv, (void*) 0))
return 1;
]]
)
], [[mhd_cv_func_gettimeofday="yes"]], [[mhd_cv_func_gettimeofday="no"]]
)
])
AS_VAR_IF([mhd_cv_func_gettimeofday], ["yes"],
[AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have `gettimeofday' function.])]
)
# IPv6
AC_MSG_CHECKING(for IPv6)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#if HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
]], [[
int af=AF_INET6;
int pf=PF_INET6;
struct sockaddr_in6 sa;
printf("%d %d %p\n", af, pf, &sa);
]])],[
have_inet6=yes;
AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers])
],[
have_inet6=no
])
AC_MSG_RESULT($have_inet6)
MHD_CHECK_FUNC([[sysconf]], [[#include <unistd.h>]], [[long a = sysconf(0); if (a) return 1;]])
MHD_CHECK_FUNC([[sysctl]], [[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
]], [[int mib[2] = {CTL_KERN, KERN_MAXPROC}; if (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;]]
)
MHD_CHECK_FUNC([[sysctlbyname]], [[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]]
)
MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
HIDDEN_VISIBILITY_CFLAGS=""
AS_CASE(["$host"],
[*-*-mingw*],[
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
[defines how to decorate public symbols while building])
HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
],[
dnl on other compilers, check if we can do -fvisibility=hidden
AX_CHECK_LINK_FLAG([-fvisibility=hidden],
[AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
[AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building])
HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"])])
])
AC_SUBST([HIDDEN_VISIBILITY_CFLAGS])
# libcurl (required for testing)
AC_ARG_ENABLE([curl],
[AS_HELP_STRING([--disable-curl],[disable cURL based testcases])],
[enable_curl=${enableval}])
curl=0
AS_IF([test "$enable_curl" != "no"],
[LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes],
[
AS_IF([test "x$enable_curl" = "xyes"],
[AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])])
enable_curl=no
])
])
AS_IF([test "$enable_curl" != "no"],
[
# Lib cURL & cURL - OpenSSL versions
AC_DEFINE([MHD_REQ_CURL_VERSION], ["7.16.4"], [required cURL version to run tests])
AC_DEFINE([MHD_REQ_CURL_OPENSSL_VERSION], ["0.9.8"], [required cURL SSL version to run tests])
AC_DEFINE([MHD_REQ_CURL_GNUTLS_VERSION], ["2.8.6"], [gnuTLS lib version - used in conjunction with cURL])
AC_DEFINE([MHD_REQ_CURL_NSS_VERSION], ["3.12.0"], [NSS lib version - used in conjunction with cURL])
])
AM_CONDITIONAL([HAVE_CURL], [test "x$enable_curl" = "xyes"])
mhd_have_libmagic="no"
SAVE_LIBS="$LIBS"
LIBS="-lmagic $LIBS"
AC_MSG_CHECKING([[for suitable libmagic]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
[
#include <magic.h>
]],
[[
char var_data[256];
const char *var_mime;
magic_t var_magic = magic_open (MAGIC_MIME_TYPE);
(void)magic_load (var_magic, NULL);
var_data[0] = 0;
var_mime = magic_buffer (var_magic, var_data, 1);
magic_close (var_magic);
]]
)
],
[
AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])
mhd_have_libmagic="yes"
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
]
)
LIBS="$SAVE_LIBS"
AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
# large file support (> 4 GB)
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
AC_CHECK_FUNCS([lseek64 pread64 pread])
# check for various sendfile functions
AC_ARG_ENABLE([sendfile],
[AS_HELP_STRING([--disable-sendfile],
[disable usage of sendfile() for HTTP connections [auto]])],
[],
[enable_sendfile="auto"])
AS_CASE([$enable_sendfile],
[[auto | yes]],[[found_sendfile="no"]],
[[no]],[[found_sendfile="disabled"]],
[AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])]
)
AS_VAR_IF([[found_sendfile]], [["no"]],
[
AC_MSG_CHECKING([[for Linux-style sendfile(2)]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/sendfile.h>
static void empty_func(void)
{
/* Check for declaration */
(void)sendfile;
}
/* Declare again to check form match */
ssize_t sendfile(int, int, off_t*, size_t);
]],
[[
int fd1=0, fd2=2;
off_t o = 0;
size_t s = 5;
ssize_t r;
r = sendfile (fd1, fd2, &o, s);
if (r)
empty_func();
]]
)
],
[
AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
found_sendfile="yes, Linux-style"
AC_MSG_RESULT([[yes]])
AC_CHECK_FUNCS([sendfile64])
],
[AC_MSG_RESULT([[no]])
]
)
]
)
AS_VAR_IF([[found_sendfile]], [["no"]],
[
AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
static void empty_func(void)
{
/* Check for declaration */
(void)sendfile;
}
/* Declare again to check form match */
int sendfile(int, int, off_t, size_t,
struct sf_hdtr*, off_t*, int);
]],
[[
int fd1=0, fd2=1;
off_t o = 0;
size_t s = 5;
off_t r1;
int r2;
r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0);
if (r2)
empty_func();
]]
)
],
[
AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).])
found_sendfile="yes, FreeBSD-style"
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
]
)
]
)
AS_VAR_IF([[found_sendfile]], [["no"]],
[
AC_MSG_CHECKING([[for Darwin-style sendfile(2)]])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
static void empty_func(void)
{
/* Check for declaration */
(void)sendfile;
}
/* Declare again to check form match */
int sendfile(int, int, off_t, off_t*,
struct sf_hdtr *, int);
]],
[[
int fd=0, s=1;
off_t o = 0;
off_t l = 5;
int r;
r = sendfile (fd, s, o, &l, (void*)0, 0);
if (r)
empty_func();
]]
)
],
[
AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).])
found_sendfile="yes, Darwin-style"
AC_MSG_RESULT([[yes]])
],
[AC_MSG_RESULT([[no]])
]
)
]
)
AS_VAR_IF([[found_sendfile]], [["no"]],
[
AC_MSG_CHECKING([[for Solaris-style sendfile(3)]])
SAVE_LIBS="$LIBS"
LIBS="-lsendfile $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sendfile.h>
static void empty_func(void)
{
/* Check for declaration */
(void)sendfile;
}
/* Declare again to check form match */
ssize_t sendfile(int out_fd, int in_fd,
off_t *off, size_t len);
]],
[[
int fd1=0, fd2=1;
off_t o = 0;
size_t l = 5;
ssize_t r;
r = sendfile (fd1, fd2, &o, l);
if (r)
empty_func();
]]
)
],
[
AC_DEFINE([HAVE_SOLARIS_SENDFILE], [1], [Define to 1 if you have Solaris-style sendfile(3).])
found_sendfile="yes, Solaris-style"
MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
AC_MSG_RESULT([[yes]])
AC_CHECK_FUNCS([sendfile64])
],
[AC_MSG_RESULT([[no]])
]
)
LIBS="$SAVE_LIBS"
]
)
AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]],
[AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])]
)
# optional: have error messages ?
AC_MSG_CHECKING([[whether to generate error messages]])
AC_ARG_ENABLE([messages],
[AS_HELP_STRING([--disable-messages],
[disable MHD error messages])],
[enable_messages=${enableval}],
[enable_messages=yes])
AS_IF([[test "x$enable_messages" = "xyes"]],
[ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for error messages.]) ],
[[ enable_messages=no ]])
AC_MSG_RESULT([[$enable_messages]])
# optional: have postprocessor?
AC_MSG_CHECKING([[whether to enable postprocessor]])
AC_ARG_ENABLE([postprocessor],
[AS_HELP_STRING([--disable-postprocessor],
[disable MHD PostProcessor functionality])],
[enable_postprocessor=${enableval}],
[enable_postprocessor=yes])
AS_IF([[test "x$enable_postprocessor" != "xno"]],
[ enable_postprocessor=yes
AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ])
AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"])
AC_MSG_RESULT([[$enable_postprocessor]])
# optional: have zzuf, socat?
AC_CHECK_PROG([have_zzuf],[zzuf], [yes], [no])
AC_CHECK_PROG([have_socat],[socat], [yes], [no])
AM_CONDITIONAL([HAVE_ZZUF], [test "x$have_zzuf" = "xyes"])
AM_CONDITIONAL([HAVE_SOCAT], [test "x$have_socat" = "xyes"])
have_gnutls=no
have_gnutls_sni=no
have_gcrypt=no
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
# optional: HTTPS support. Enabled by default
AC_ARG_ENABLE([https],
[AS_HELP_STRING([--enable-https],
[enable HTTPS support (yes, no, auto)[auto]])],
[enable_https=${enableval}])
AS_IF([test "x$enable_https" != "xno"],[
#
# Next block is large unindented block
#
# gnutls
have_gnutls_pkgcfg=no
AC_MSG_CHECKING([[how to find GnuTLS library]])
AC_ARG_WITH([[gnutls]],
[AS_HELP_STRING([[--with-gnutls[=PFX]]],[use GnuTLS for HTTPS support, optional PFX overrides pkg-config data for GnuTLS headers (PFX/include) and libs (PFX/lib)])],
[
AS_CASE([$with_gnutls],
[no],[
AC_MSG_RESULT([[GnuTLS disabled]])
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_CFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
AS_UNSET([GNUTLS_LIBS])
],
[yes],[
AC_MSG_RESULT([[automatically, forced]])
],
[
AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]])
SAVE_LIBS="$LIBS"
LDFLAGS="${LDFLAGS_ac} -L$with_gnutls/lib ${user_LDFLAGS}"
CPPFLAGS="${CPPFLAGS_ac} -I$with_gnutls/include ${user_CPPFLAGS}"
have_gnutls_pkgcfg=no
AC_CHECK_HEADERS([gnutls/gnutls.h],
[AC_CHECK_LIB([gnutls], [gnutls_priority_set],
[
GNUTLS_CPPFLAGS="-I$with_gnutls/include"
GNUTLS_LDFLAGS="-L$with_gnutls/lib"
GNUTLS_LIBS="-lgnutls"
have_gnutls=yes
])], [], [AC_INCLUDES_DEFAULT])
AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
LIBS="$SAVE_LIBS"
])
],
[AC_MSG_RESULT([[automatically]])
])
AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
[
AC_CACHE_CHECK([[whether to add pkg-config special search directories]], [mhd_cv_pkgconf_add_dirs],
[
AS_IF([[test "x$host_os" = "xsolaris2.11" && test "x$cross_compiling" = "xno"]],
[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
char size_chk[7-sizeof(char*)];
#if defined(_LP64) || defined(__LP64__) || defined(__x86_64) || defined(__x86_64__)
#error This is 64-bit target.
choke me now
#endif
#if defined(__amd64) || defined(__amd64__) || defined(__sparcv9) || defined(__sparc_v9__)
#error This is 64-bit target.
choke me now
#endif
]], [[]]
)
],
[
mhd_cv_pkgconf_add_dirs='/usr/lib/pkgconfig/gnutls-3'
],
[
AS_IF([[test "x$host_cpu" = "xx86_64" || test "x$host_cpu" = "xi386"]],
[[mhd_cv_pkgconf_add_dirs='/usr/lib/amd64/pkgconfig/gnutls-3:/usr/lib/amd64/pkgconfig']],
[[test "x$host_cpu" = "xsparc"]],
[[mhd_cv_pkgconf_add_dirs='/usr/lib/sparkv9/pkgconfig/gnutls-3:/usr/lib/sparkv9/pkgconfig']],
[[mhd_cv_pkgconf_add_dirs='/usr/lib/64/pkgconfig/gnutls-3:/usr/lib/64/pkgconfig']]
)
]
)
],
[[ mhd_cv_pkgconf_add_dirs='no' ]]
)
]
)
AS_IF([[test "x$mhd_cv_pkgconf_add_dirs" != "xno"]],
[
test "x$PKG_CONFIG_PATH" = "x" || PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PATH_SEPARATOR}"
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${mhd_cv_pkgconf_add_dirs}"
export PKG_CONFIG_PATH
]
)
PKG_CHECK_MODULES(GNUTLS, [[gnutls]],
[
have_gnutls_pkgcfg='yes'
SAVE_LIBS="$LIBS"
CFLAGS="${CFLAGS_ac} $GNUTLS_CFLAGS ${user_CFLAGS}"
LIBS="$GNUTLS_LIBS $LIBS"
AC_MSG_CHECKING([[whether GnuTLS is usable]])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#include <gnutls/gnutls.h>
]], [[
gnutls_session_t session;
gnutls_priority_t priorities;
gnutls_global_init();
gnutls_priority_init(&priorities, "NORMAL", NULL);
gnutls_init(&session, GNUTLS_SERVER);
gnutls_priority_set(session, priorities);
]])],
[
AC_MSG_RESULT([[yes]])
have_gnutls=yes
# GNUTLS_CFLAGS is actually CPPFLAGS
GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS"
# GNUTLS_LDFLAGS is a combination of LDFLAGS and LIBS
GNUTLS_LDFLAGS="$GNUTLS_LIBS"
],
[
AC_MSG_RESULT([[no]])
have_gnutls=no
])
AS_IF([test "x$have_gnutls" != "xyes"],
[
AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used])
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_CFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
AS_UNSET([GNUTLS_LIBS])
]
)
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
LIBS="$SAVE_LIBS"
],
[
# check for GnuTLS at default paths
have_gnutls_pkgcfg='no'
AC_CHECK_HEADERS([gnutls/gnutls.h],
[AC_CHECK_LIB([gnutls], [gnutls_priority_set],
[
GNUTLS_LIBS="-lgnutls"
have_gnutls=yes
])], [], [AC_INCLUDES_DEFAULT])
])
])
have_gcrypt='unknown'
AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"],
[
AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
AS_IF([[test "x$have_gcrypt" = "xyes"]],
[
SAVE_LIBS="$LIBS"
CFLAGS="${CFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CFLAGS}"
# LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
CPPFLAGS="${CPPFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CPPFLAGS}"
AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
# Check for GnuTLS with gcrypt flags
LDFLAGS="${LDFLAGS_ac} ${LIBGCRYPT_LIBS} ${user_LDFLAGS}"
# A bit of hack: unset cache variable to force recheck
AS_UNSET([ac_cv_header_gnutls_gnutls_h])
AC_CHECK_HEADERS([gnutls/gnutls.h],
[AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck
AC_CHECK_LIB([gnutls], [gnutls_priority_set],
[
GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS"
GNUTLS_LIBS="-lgnutls"
have_gnutls=yes
])], [], [AC_INCLUDES_DEFAULT])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
LIBS="$SAVE_LIBS"
]
)
]
)
AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"],
[AC_MSG_ERROR([[can't find usable libgnutls]])])
AS_IF([test "x$have_gnutls" = "xyes"],
[
SAVE_LIBS="$LIBS"
CPPFLAGS="${CPPFLAGS_ac} ${GNUTLS_CPPFLAGS} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${GNUTLS_LDFLAGS} ${user_LDFLAGS}"
LIBS="$GNUTLS_LIBS $LIBS"
AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#include <gnutls/gnutls.h>
#include <gnutls/abstract.h>
]], [[
gnutls_datum_t data;
gnutls_privkey_t key = 0;
#ifndef gnutls_load_file
(void)gnutls_load_file; /* Check for declaration. */
#endif
#ifndef gnutls_privkey_import_x509_raw
(void)gnutls_privkey_import_x509_raw; /* Check for declaration. */
#endif
gnutls_load_file("key.pem", &data);
gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
gnutls_free(data.data);
]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]])
AC_MSG_RESULT([[$have_gnutls_sni]])
AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisaion]], [mhd_cv_gcrypt_required],
[
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
#include <gnutls/gnutls.h>
],
[
#if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14
#error Old versions of GnuTLS require libgcript initialisaion
choke me now
#endif
]
)
],
[[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']]
)
]
)
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
LIBS="$SAVE_LIBS"
],
[
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
]
)
AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]],
[
AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no])
AS_IF([[test "x$have_gcrypt" = "xyes"]],
[
CFLAGS="${CFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CFLAGS}"
# LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
CPPFLAGS="${CPPFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CPPFLAGS}"
AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT])
CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
]
)
]
)
AS_UNSET([[crypt_missing]])
AS_IF([[test "x$have_gnutls" = "xyes"]],
[
AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]],
[
crypt_missing="required libgcrypt"
AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
enable_https=no
MSG_HTTPS="no (lacking $crypt_missing)"
AS_UNSET([LIBGCRYPT_CFLAGS])
AS_UNSET([LIBGCRYPT_LIBS])
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_CFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
AS_UNSET([GNUTLS_LIBS])
],
[
AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.])
enable_https=yes
AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
[
MSG_HTTPS="yes (using libgnutls and libgcrypt)"
MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS"
MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS"
MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS"
AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt])
],
[
MSG_HTTPS="yes (using libgnutls)"
AS_UNSET([LIBGCRYPT_CFLAGS])
AS_UNSET([LIBGCRYPT_LIBS])
MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS"
MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS"
MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS"
MHD_TLS_LIBDEPS="$GNUTLS_LIBS"
]
)
AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]],
[ # remove GnuTLS from private libs in .pc file as it defined in Requires.private
MHD_REQ_PRIVATE='gnutls'
AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
[[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
)
],
[
MHD_REQ_PRIVATE=''
AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]],
[[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]]
)
MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG"
])
]
)
],
[
crypt_missing="libgnutls"
AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])])
enable_https=no
MSG_HTTPS="no (lacking $crypt_missing)"
AS_UNSET([LIBGCRYPT_CFLAGS])
AS_UNSET([LIBGCRYPT_LIBS])
AS_UNSET([GNUTLS_CPPFLAGS])
AS_UNSET([GNUTLS_CFLAGS])
AS_UNSET([GNUTLS_LDFLAGS])
AS_UNSET([GNUTLS_LIBS])
]
)
],[
MSG_HTTPS="no (disabled)"
])
#
# End of large unindented block
#
AC_MSG_CHECKING(whether to support HTTPS)
AC_MSG_RESULT([$MSG_HTTPS])
AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]])
AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]])
AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"])
AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]])
AC_SUBST([GNUTLS_CPPFLAGS])
AC_SUBST([GNUTLS_CFLAGS])
AC_SUBST([GNUTLS_LDFLAGS])
AC_SUBST([GNUTLS_LIBS])
AS_VAR_IF([have_gnutls], ["yes"],
[
AC_CACHE_CHECK([for GnuTLS quirks], [mhd_cv_gnutls_mthread_broken],
[
mhd_cv_gnutls_mthread_broken="no"
AS_IF([test -r /etc/redhat-release],
[
AS_IF([$FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null],
[mhd_cv_gnutls_mthread_broken="found"],
)
]
)
AS_VAR_IF([mhd_cv_gnutls_mthread_broken], ["no"],
[
AS_IF([command -v rpm >/dev/null],
[
AS_IF([test "r`rpm -E '%{rhel}' 2>/dev/null`" = "r6"],
[mhd_cv_gnutls_mthread_broken="found"],
)
]
)
]
)
]
)
AC_CACHE_CHECK([for gnutls-cli binary], [mhd_cv_gnutls_cli],
[
mhd_cv_gnutls_cli="no"
AS_IF([command -v gnutls-cli >/dev/null 2>&1],
[AS_IF([AC_RUN_LOG([gnutls-cli --version >&2])], [mhd_cv_gnutls_cli="yes"])]
)
]
)
]
)
AM_CONDITIONAL([HAVE_GNUTLS_MTHREAD_BROKEN], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"]])
AM_CONDITIONAL([USE_UPGRADE_TLS_TESTS], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" = "xyes"]])
# optional: HTTP Basic Auth support. Enabled by default
AC_MSG_CHECKING([[whether to support HTTP basic authentication]])
AC_ARG_ENABLE([bauth],
AS_HELP_STRING([--disable-bauth],
[disable HTTP basic Auth support]),
[enable_bauth=${enableval}],
[enable_bauth=yes])
AS_IF([[test "x$enable_bauth" != "xno"]],
[ enable_bauth=yes
AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with basic Auth support.]) ])
AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"])
AC_MSG_RESULT([[$enable_bauth]])
# optional: HTTP Digest Auth support. Enabled by default
AC_MSG_CHECKING([[whether to support HTTP digest authentication]])
AC_ARG_ENABLE([dauth],
AS_HELP_STRING([--disable-dauth],
[disable HTTP basic and digest Auth support]),
[enable_dauth=${enableval}],
[enable_dauth=yes])
AS_IF([[test "x$enable_dauth" != "xno"]],
[ enable_dauth=yes
AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with digest Auth support.]) ])
AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"])
AC_MSG_RESULT([[$enable_dauth]])
# optional: HTTP "Upgrade" support. Enabled by default
AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]])
AC_ARG_ENABLE([[httpupgrade]],
AS_HELP_STRING([[--disable-httpupgrade]],
[disable HTTP "Upgrade" support]),
[AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])],
[[enable_httpupgrade='yes']])
AS_VAR_IF([[enable_httpupgrade]],[["yes"]],
[
AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ])
AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]])
AC_MSG_RESULT([[$enable_httpupgrade]])
AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
]],[[void * ptr = calloc(1, 2); if (ptr) return 1;]])
],
[[mhd_cv_have_func_calloc='yes']],
[[mhd_cv_have_func_calloc='no']]
)
]
)
AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]],
[AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])])
# Some systems have IPv6 disabled in kernel at run-time
AS_IF([[test "x${have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]],
[
AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing],
[
AC_RUN_IFELSE(
[
AC_LANG_SOURCE([[
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
static void zr_mem(void *ptr, socklen_t size)
{ char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
int main(void)
{
int ret = 30;
struct sockaddr_in6 sa;
#if !defined(_WIN32) || defined(__CYGWIN__)
int sckt;
const int invld_sckt = -1;
#else
SOCKET sckt;
const SOCKET invld_sckt = INVALID_SOCKET;
WSADATA wsa_data;
WSAStartup(MAKEWORD(2, 2), &wsa_data);
#endif
zr_mem(&sa, sizeof(sa));
sa.sin6_family = AF_INET6;
sa.sin6_port = 0;
sa.sin6_addr = in6addr_loopback;
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
sa.sin6_len = sizeof(sa);
#endif
sckt = socket (PF_INET6, SOCK_STREAM, 0);
if (invld_sckt != sckt)
{
if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa)))
{
if (0 == listen (sckt, 1))
ret = 0;
else
ret = 1; /* listen() failed */
} else ret = 2; /* bind() failed */
#if !defined(_WIN32) || defined(__CYGWIN__)
close (sckt);
#else
closesocket (sckt);
#endif
} else ret = 3; /* socket() failed */
#if defined(_WIN32) && !defined(__CYGWIN__)
WSACleanup();
#endif
return ret;
}
]])
], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]]
)
]
)
]
)
AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"],
[AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])]
)
# Check for fork() and waitpid(). They are used for tests.
AC_MSG_CHECKING([[for fork()]])
mhd_have_fork_waitpid='no'
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
]], [[
pid_t p = fork ();
if (0 == p)
return 1;
]])
], [
AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.])
AC_MSG_RESULT([[yes]])
AC_MSG_CHECKING([[for waitpid()]])
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <sys/wait.h>
]], [[
pid_t p = fork ();
if (0 == p)
return 1;
waitpid (p, (void*)0, 0)
]])
], [
AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.])
AC_MSG_RESULT([[yes]])
mhd_have_fork_waitpid='yes'
],[
AC_MSG_RESULT([[no]])
])
],[
AC_MSG_RESULT([[no]])
])
AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"])
# gcov compilation
AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
AC_ARG_ENABLE([coverage],
AS_HELP_STRING([--enable-coverage],
[compile the library with code coverage support]),
[use_gcov=${enableval}],
[use_gcov=no])
AC_MSG_RESULT($use_gcov)
AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
AX_COUNT_CPUS
AC_MSG_CHECKING([for number of CPU cores to use in tests])
AS_VAR_IF([enable_heavy_tests], ["yes"],
[
# Enable usage of many core if heavy tests are enabled
AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage
],
[
# Limit usage to just a few cores if heavy tests are not enabled
AS_IF([[test "$CPU_COUNT" -gt "6"]], [[CPU_COUNT="6"]])
AS_IF([[test "$CPU_COUNT" -lt "2"]], [[CPU_COUNT="2"]])
]
)
AC_MSG_RESULT([$CPU_COUNT])
AC_MSG_CHECKING([[whether to enable debug asserts]])
AC_ARG_ENABLE([[asserts]],
AS_HELP_STRING([[--enable-asserts]],
[enable test build with debug asserts]),
[], [[enable_asserts='no']])
AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']])
AC_MSG_RESULT([[$enable_asserts]])
AS_VAR_IF([[enable_asserts]], [["yes"]],
[
AC_DEFINE([[_DEBUG]], [[1]], [Define to use debug asserts.])
[mhd_assert_test_prg="#include <assert.h>
int pos_val(void) {return 5;}
int neg_val(void) {return -5;}
int main(void)
{ int pos_var = pos_val(), neg_var = neg_val();
assert(neg_var > pos_var); /* Must trigger assert. */
(void)pos_var; (void)neg_var;
return 0; }
"]
AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail],
[
AC_LINK_IFELSE([AC_LANG_SOURCE([[$mhd_assert_test_prg]])],
[[mhd_cv_sys_assert_avail='yes']],
[[mhd_cv_sys_assert_avail='no']])
]
)
AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [],
[AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])])
AS_UNSET([mhd_assert_test_prg])
],
[AC_DEFINE([[NDEBUG]], [[1]], [Define to disable usage of debug asserts.])]
)
AS_UNSET([enabled_sanitizers])
AM_TESTS_ENVIRONMENT=""
AM_ASAN_OPTIONS=""
AM_UBSAN_OPTIONS=""
AM_LSAN_OPTIONS=""
AS_UNSET([ASAN_OPTIONS])
AS_UNSET([UBSAN_OPTIONS])
AS_UNSET([LSAN_OPTIONS])
AC_MSG_CHECKING([whether to enable run-time sanitizers])
AC_ARG_ENABLE([sanitizers],
[AS_HELP_STRING([[--enable-sanitizers[=address,undefined,leak,user-poison]]],
[enable run-time sanitizers, specify the list of types of sanitizers to enable or ]
[leave the list empty to enable all suppoted and availabe sanitizers])],
[], [enable_sanitizers=no])
AS_IF([test "x${enable_sanitizers}" = "x"], [enable_sanitizers="auto"])
AS_VAR_IF([enable_sanitizers], ["yes"], [enable_sanitizers="auto"])
AS_IF([test "x${enable_sanitizers}" = "xno"],
[
enable_sanitizers="no"
enable_san_address="no"
enable_san_undef="no"
enable_san_leak="no"
enable_san_upoison="no"
],
[test "x${enable_sanitizers}" = "xauto"],
[
enable_san_address="auto"
enable_san_undef="auto"
enable_san_leak="auto"
enable_san_upoison="auto"
],
[
AS_UNSET([san])
enable_san_address="no"
enable_san_undef="no"
enable_san_leak="no"
enable_san_upoison="no"
for san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '`
do
AS_CASE([$san],
[address], [enable_san_address="yes"],
[undefined], [enable_san_undef="yes"],
[leak], [enable_san_leak="yes"],
[user-poison|user_poison], [enable_san_upoison="yes"],
[no|yes|auto], [AC_MSG_ERROR(["$san" cannot be used with other options for --enable-sanitizers=])],
[AC_MSG_ERROR([Unknown parameter "$san" for --enable-sanitizers=])]
)
done
AS_IF([test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno"],
[AC_MSG_ERROR([User memory poisoning cannot be used without address sanitizer])]
)
enable_sanitizers="selected"
]
)
AS_CASE([${enable_sanitizers}],
[selected], [AC_MSG_RESULT([selected])],
[auto], [AC_MSG_RESULT([yes, detect and use supported sanitizers])],
[AC_MSG_RESULT([no])]
)
AS_VAR_IF([enable_sanitizers], ["no"], [:],
[
AS_UNSET([san_FLAGS]) # the sanitizer flags to be added to both CFLAGS and LDFLAGS
AS_UNSET([san_CFLAGS]) # the sanitizer flags to be added to CFLAGS
AC_CACHE_CHECK([whether '-fsanitize=' works for $CC],
[mhd_cv_cc_sanitizer_works],
[
CFLAGS="${CFLAGS_ac} -fsanitize=wrongFeatureName ${user_CFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"],
[
AS_VAR_IF([enable_san_address], ["no"], [:],
[
AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address],
[
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
[
AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled])
AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address"
AS_VAR_IF([enable_san_leak], ["no"], [:],
[
AC_CACHE_CHECK([whether leak detect is not rejected by address sanitizer], [mhd_cv_cc_sanitizer_address_leak],
[
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${user_CFLAGS}"
ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1"
export ASAN_OPTIONS
AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_address_leak=yes], [mhd_cv_cc_sanitizer_address_leak=no],
[
# Cross-compiling with sanitizers?
mhd_cv_cc_sanitizer_address_leak='assuming no'
]
)
AS_UNSET([ASAN_OPTIONS])
]
)
]
)
AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare],
[
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"],
[
AX_APPEND_FLAG([-fsanitize=pointer-compare], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare"
]
)
AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract],
[
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"],
[
AX_APPEND_FLAG([-fsanitize=pointer-subtract], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract"
]
)
AS_VAR_IF([enable_san_upoison], ["no"], [:],
[
AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT])
AS_IF([test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes"],
[
AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works], [mhd_cv_func_attribute_nosanitize_ptr],
[
ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
export ASAN_OPTIONS
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdlib.h>
__attribute__((no_sanitize("pointer-compare","pointer-subtract")))
int ptr_process(void *ptr1, void *ptr2)
{
if ((char*)ptr1 <= (char*)ptr2)
return (int) ((char*)ptr2 - (char*)ptr1);
return (int) ((char*)ptr1 - (char*)ptr2);
}
]],
[[
int *a = (int*) malloc (sizeof(int)*4);
int *b = (int*) malloc (sizeof(long)*6);
int c = ptr_process(a, b);
if (c)
{
free (b);
free (a);
return 0;
}
free (a);
free (b);
]]
)
],
[mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no],
[
# Cross-compiling with sanitizers??
mhd_cv_func_attribute_nosanitize_ptr='assuming no'
]
)
AS_UNSET([ASAN_OPTIONS])
]
)
AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"],
[AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WOKRS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare","pointer-subtract")))' works])],
[
AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr],
[
ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1"
export ASAN_OPTIONS
CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}"
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdlib.h>
__attribute__((no_sanitize("address")))
int ptr_process(void *ptr1, void *ptr2)
{
if ((char*)ptr1 <= (char*)ptr2)
return (int) ((char*)ptr2 - (char*)ptr1);
return (int) ((char*)ptr1 - (char*)ptr2);
}
]],
[[
int *a = (int*) malloc (sizeof(int)*4);
int *b = (int*) malloc (sizeof(long)*6);
int c = ptr_process(a, b);
if (c)
{
free (b);
free (a);
return 0;
}
free (a);
free (b);
]]
)
],
[mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no],
[
# Cross-compiling with sanitizers??
mhd_cv_func_attribute_nosanitize_addr='assuming no'
]
)
AS_UNSET([ASAN_OPTIONS])
]
)
AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"],
[AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])]
)
]
)
]
)
]
)
]
)
AS_IF([test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes"],
[AC_MSG_ERROR([Address sanitizer cannot be enabled])]
)
enable_san_address="${mhd_cv_cc_sanitizer_address}"
]
)
AS_VAR_IF([enable_san_undef], ["no"], [:],
[
dnl Ensure that '#' will be processed correctly
[
test_undf_prog='
#include <stdio.h>
void func_out_b(char *arr)
{
arr[0] = 0;
arr[16] = 2;
}
unsigned int int_deref(void *ptr)
{
return (*((int*)ptr)) + 2;
}
int func1(void)
{
char chr[16];
func_out_b (chr);
return int_deref(chr + 1) + int_deref(chr + 2);
}
int main(void)
{
unsigned long ulvar;
signed char ch1;
ulvar = -1 * func1();
ch1 = ulvar * 6UL;
printf("%lu\n", ulvar + ch1);
return 0;
}
'
]
AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined],
[
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
[mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"],
[
AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
],
[
AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap],
[
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
[mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"],
[
AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
AX_APPEND_FLAG([-fsanitize-undefined-trap-on-error], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
],
[
AS_IF([test -z "${enabled_sanitizers}"],
[
# Last resort
AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all],
[
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])],
[mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"],
[
AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS])
AX_APPEND_FLAG([-fsanitize-trap=all], [san_FLAGS])
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}"
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined"
AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited])
]
)
]
)
]
)
]
)
AS_CASE(["$enabled_sanitizers"], [*undefined],
[
AS_VAR_IF([mhd_cv_cc_sanitizer_undefined], ["yes"],[],
[
# A workaround for broken clang which is trying to use UBSan lib
# even when instructed to not use it
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
AX_APPEND_LINK_FLAGS([-fsanitize-trap=implicit-conversion],
[san_FLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
]
)
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
AX_APPEND_LINK_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg],
[san_CFLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])])
]
)
AS_UNSET([test_undf_prog])
AS_CASE(["$enabled_sanitizers"],
[*undefined], [enable_san_undef="yes"],
[
AS_VAR_IF([enable_san_undef], [yes], [AC_MSG_ERROR([Undefined behavior sanitizer cannot be enabled])])
enable_san_undef="no"
]
)
]
)
AS_VAR_IF([enable_san_leak], ["no"], [:],
[
AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak],
[
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak ${user_CFLAGS}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no])
]
)
AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"],
[
AX_APPEND_FLAG([-fsanitize=leak], [san_FLAGS])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak"
]
)
AS_IF([test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes"],
[AC_MSG_ERROR([User poison cannot be enabled])]
)
enable_san_leak="${mhd_cv_cc_sanitizer_leak}"
]
)
AS_IF([test -z "${enabled_sanitizers}"],
[AC_MSG_ERROR([cannot find any sanitizer supported by $CC])])
AS_VAR_IF([enable_san_upoison], ["no"], [:],
[
AC_MSG_CHECKING([whether to enable user memory poisoning])
AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_pointer_compare}" = "xyes" && \
test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \
(test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")],
[
AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used])
enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison"
enable_san_upoison="yes"
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no])
AS_VAR_IF([enable_san_upoison], ["yes"],
[AC_MSG_ERROR([User memory poisoning cannot be enabled])])
enable_san_upoison="no"
]
)
]
)
AS_VAR_IF([enable_san_address], ["yes"],
[
AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"],
[
AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS])
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
AX_APPEND_COMPILE_FLAGS([-Wp,-U_FORTIFY_SOURCE], [san_CFLAGS])
],
[AC_MSG_WARN([$CC does not support address sanitizer])]
)
]
)
CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}"
# Always stop on sanitizer error
AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [san_CFLAGS])
# Get a better output for sanitizers error reporting
AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-optimize-sibling-calls],
[san_CFLAGS])
AS_VAR_IF([enable_san_address], ["yes"],
[
AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1"
AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64"
AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3"
AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1"
AS_VAR_IF([enable_san_upoison], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1"])
AS_VAR_IF([enable_san_leak], ["yes"],
[AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"],
[AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"])
], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0"]
)
]
)
AS_VAR_IF([enable_san_undef], [yes],
[AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"])
AS_VAR_IF([enable_san_leak], ["yes"],
[AM_LSAN_OPTIONS="use_unaligned=1"]
)
AM_TESTS_ENVIRONMENT='\
ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \
UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \
LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;'
]
)
CFLAGS_ac="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS}"
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
]
)
AM_CONDITIONAL([USE_SANITIZERS],
[test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"])
AC_SUBST([AM_ASAN_OPTIONS])
AC_SUBST([AM_UBSAN_OPTIONS])
AC_SUBST([AM_LSAN_OPTIONS])
AC_SUBST([AM_TESTS_ENVIRONMENT])
MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS -export-dynamic -no-undefined"
AC_SUBST([CPU_COUNT])
AC_SUBST([HEAVY_TESTS_NOTPARALLEL])
AM_SUBST_NOTMAKE([HEAVY_TESTS_NOTPARALLEL])
AC_SUBST(MHD_LIB_CPPFLAGS)
AC_SUBST(MHD_LIB_CFLAGS)
AC_SUBST(MHD_LIB_LDFLAGS)
AC_SUBST(MHD_LIBDEPS)
AC_SUBST(MHD_TLS_LIB_CPPFLAGS)
AC_SUBST(MHD_TLS_LIB_CFLAGS)
AC_SUBST(MHD_TLS_LIB_LDFLAGS)
AC_SUBST(MHD_TLS_LIBDEPS)
# for pkg-config
AC_SUBST([MHD_REQ_PRIVATE])
AC_SUBST([MHD_LIBDEPS_PKGCFG])
# Restore flags as set by the user
CFLAGS="${user_CFLAGS}"
LDFLAGS="${user_LDFLAGS}"
CPPFLAGS="${user_CPPFLAGS}"
AC_SUBST([CFLAGS])
AC_SUBST([LDFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LIBS])
# Configure-defined flags
AC_SUBST([CFLAGS_ac])
AC_SUBST([LDFLAGS_ac])
AC_SUBST([CPPFLAGS_ac])
# Used for 'po' directory staff
AC_SUBST([ac_configure_args])
AC_SUBST([EMPTY_VAR], [[]])
# We define the paths here, because MinGW/GCC expands paths
# passed through the command line ("-DDIR=..."). This would
# lead to hard-coded paths ("C:\mingw\mingw\bin...") that do
# not contain the actual installation.
AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins])
# should experimental code be compiled (code that may not yet compile)?
AC_MSG_CHECKING(whether to compile experimental code)
AC_ARG_ENABLE([experimental],
[AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])],
[enable_experimental=${enableval}],
[enable_experimental=no])
AC_MSG_RESULT($enable_experimental)
AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
AC_CONFIG_FILES([libmicrohttpd.pc
w32/common/microhttpd_dll_res_vc.rc
Makefile
po/po-configure.ac
contrib/Makefile
doc/Makefile
doc/doxygen/libmicrohttpd.doxy
doc/doxygen/Makefile
doc/examples/Makefile
m4/Makefile
src/Makefile
src/include/Makefile
src/lib/Makefile
src/microhttpd/Makefile
src/microhttpd_ws/Makefile
src/examples/Makefile
src/testcurl/Makefile
src/testcurl/https/Makefile
src/testzzuf/Makefile])
AC_OUTPUT
# Finally: summary
AS_IF([test "x$enable_curl" != "xyes"],
[MSG_CURL="no, many unit tests will not run"],
[MSG_CURL="yes"])
AS_VAR_IF([os_is_windows], ["yes"],
[os_ver_msg="
Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])])
AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
Target directory: ${prefix}
Cross-compiling: ${cross_compiling}
Operating System: ${mhd_host_os}${os_ver_msg}
Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select}
Inter-thread comm: ${use_itc}
poll support: ${enable_poll=no}
epoll support: ${enable_epoll=no}
sendfile used: ${found_sendfile}
HTTPS support: ${MSG_HTTPS}
Threading lib: ${USE_THREADS}
Use thread names: ${enable_thread_names}
Use debug asserts: ${enable_asserts}
Use sanitizers: ${enabled_sanitizers:=no}
Messages: ${enable_messages}
Basic auth.: ${enable_bauth}
Digest auth.: ${enable_dauth}
HTTP "Upgrade": ${enable_httpupgrade}
Postproc: ${enable_postprocessor}
Build docs: ${enable_doc}
Build examples: ${enable_examples}
Test with libcurl: ${MSG_CURL}
])
AS_IF([test "x$enable_https" = "xyes"],
[AC_MSG_NOTICE([HTTPS subsystem configuration:
License : LGPL version 2.1 or any later version
])],
[AC_MSG_NOTICE([
License : LGPLv2.1+ or eCos
])])
AS_IF([test "x$enable_bauth" != "xyes" || \
test "x$enable_dauth" != "xyes" || \
test "x$enable_httpupgrade" != "xyes" || \
test "x$enable_postprocessor" != "xyes"],
[AC_MSG_NOTICE([WARNING: This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems.])])
|