aboutsummaryrefslogtreecommitdiffstats
path: root/main/collectd/configure.ac
blob: 88125495b25fd5fa5e58361c84f8d20d442cc2d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
dnl Process this file with autoconf to produce a configure script.
AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
AC_CONFIG_SRCDIR(src/)
AC_CONFIG_HEADERS(src/config.h)
AC_CONFIG_AUX_DIR([libltdl/config])

m4_ifdef([LT_PACKAGE_VERSION],
	# libtool >= 2.2
	[
	 LT_CONFIG_LTDL_DIR([libltdl])
	 LT_INIT([dlopen])
	 LTDL_INIT([convenience])
	 AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
	]
,
	# libtool <= 1.5
	[
	 AC_LIBLTDL_CONVENIENCE
	 AC_SUBST(LTDLINCL)
	 AC_SUBST(LIBLTDL)
	 AC_LIBTOOL_DLOPEN
	 AC_CONFIG_SUBDIRS(libltdl)
	 AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
	]
)

AM_INIT_AUTOMAKE([tar-pax dist-bzip2 foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_LANG(C)

AC_PREFIX_DEFAULT("/opt/collectd")

AC_SYS_LARGEFILE

#
# Checks for programs.
#
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_CC_C_O
AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")

AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_LEX
AC_PROG_YACC
PKG_PROG_PKG_CONFIG

AC_CHECK_PROG([have_protoc_c], [protoc-c], [yes], [no])
AC_CHECK_HEADERS([google/protobuf-c/protobuf-c.h],
                 [have_protobuf_c_h="yes"],
                 [have_protobuf_c_h="no"])
if test "x$have_protoc_c" = "xyes" && test "x$have_protobuf_c_h" != "xyes"
then
	have_protoc_c="no (unable to find <google/protobuf-c/protobuf-c.h>)"
fi
AM_CONDITIONAL(HAVE_PROTOC_C, test "x$have_protoc_c" = "xyes")

AC_MSG_CHECKING([for kernel type ($host_os)])
case $host_os in
	*linux*)
	AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
	ac_system="Linux"
	;;
	*solaris*)
	AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
	ac_system="Solaris"
	;;
	*darwin*)
	AC_DEFINE([KERNEL_DARWIN], 1, [True if program is to be compiled for a Darwin kernel])
	ac_system="Darwin"
	;;
	*openbsd*)
	AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
	ac_system="OpenBSD"
	;;
	*aix*)
	AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
	ac_system="AIX"
	;;
	*freebsd*)
	AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel])
	ac_system="FreeBSD"
	;;
	*)
	ac_system="unknown"
esac
AC_MSG_RESULT([$ac_system])

AM_CONDITIONAL([BUILD_LINUX],[test "x$x$ac_system" = "xLinux"])
AM_CONDITIONAL([BUILD_SOLARIS],[test "x$x$ac_system" = "xSolaris"])
AM_CONDITIONAL([BUILD_DARWIN],[test "x$x$ac_system" = "xDarwin"])
AM_CONDITIONAL([BUILD_OPENBSD],[test "x$x$ac_system" = "xOpenBSD"])
AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"])
AM_CONDITIONAL([BUILD_FREEBSD],[test "x$x$ac_system" = "xFreeBSD"])

if test "x$ac_system" = "xLinux"
then
	AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
	if test -z "$KERNEL_DIR"
	then
		KERNEL_DIR="/lib/modules/`uname -r`/source"
	fi

	KERNEL_CFLAGS="-I$KERNEL_DIR/include"
	AC_SUBST(KERNEL_CFLAGS)
fi

if test "x$ac_system" = "xSolaris"
then
	AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
	AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
fi
if test "x$ac_system" = "xAIX"
then
	AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
fi

# Where to install .pc files.
pkgconfigdir="${libdir}/pkgconfig"
AC_SUBST(pkgconfigdir)

# Check for standards compliance mode
AC_ARG_ENABLE(standards,
	      AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
	      [enable_standards="$enableval"],
	      [enable_standards="no"])
if test "x$enable_standards" = "xyes"
then
	AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
	AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
	AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
	AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
	if test "x$GCC" = "xyes"
	then
		CFLAGS="$CFLAGS -std=c99"
	fi
fi
AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")

#
# Checks for header files.
#
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_DIRENT
AC_HEADER_STDBOOL

AC_CHECK_HEADERS(stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h fnmatch.h libgen.h)

# For ping library
AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
])
AC_CHECK_HEADERS(netinet/in.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
])
AC_CHECK_HEADERS(netinet/ip.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
])
AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
])
AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
])
AC_CHECK_HEADERS(netinet/ip6.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
])
AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP6_H
# include <netinet/ip6.h>
#endif
])
AC_CHECK_HEADERS(netinet/tcp.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
])
AC_CHECK_HEADERS(netinet/udp.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
])

# For cpu modules
AC_CHECK_HEADERS(sys/dkstat.h)
if test "x$ac_system" = "xDarwin"
then
	AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
	AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
	# For the battery plugin
	AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
[
#if HAVE_IOKIT_IOKITLIB_H
#  include <IOKit/IOKitLib.h>
#endif
#if HAVE_IOKIT_IOTYPES_H
#  include <IOKit/IOTypes.h>
#endif
])

fi

AC_CHECK_HEADERS(sys/sysctl.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
])

AC_MSG_CHECKING([for sysctl kern.cp_times])
if test -x /sbin/sysctl
then
	/sbin/sysctl kern.cp_times 2>/dev/null
	if test $? -eq 0
	then
		AC_MSG_RESULT([yes])
		AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
		[Define if sysctl supports kern.cp_times])
	else
		AC_MSG_RESULT([no])
	fi
else
	AC_MSG_RESULT([no])
fi

# For hddtemp module
AC_CHECK_HEADERS(linux/major.h)

# For md module (Linux only)
if test "x$ac_system" = "xLinux"
then
	AC_CHECK_HEADERS(linux/raid/md_u.h,
			 [have_linux_raid_md_u_h="yes"],
			 [have_linux_raid_md_u_h="no"],
[
#include <sys/ioctl.h>
#include <linux/major.h>
#include <linux/types.h>
])
else
	have_linux_raid_md_u_h="no"
fi

# For the swap module
have_linux_wireless_h="no"
if test "x$ac_system" = "xLinux"
then
  AC_CHECK_HEADERS(linux/wireless.h,
		   [have_linux_wireless_h="yes"],
		   [have_linux_wireless_h="no"],
[
#include <dirent.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
])
fi

# For the swap module
have_sys_swap_h="yes"
AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
[
#undef _FILE_OFFSET_BITS
#undef _LARGEFILE64_SOURCE
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
])

if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
then
	hint_64=""
	if test "x$GCC" = "xyes"
	then
		hint_64="CFLAGS='-m64'"
	else
		hint_64="CFLAGS='-xarch=v9'"
	fi
	AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
fi

# For load module
# For the processes plugin
# For users module
AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)

# For interface plugin
AC_CHECK_HEADERS(ifaddrs.h)
AC_CHECK_HEADERS(net/if.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
])
AC_CHECK_HEADERS(linux/if.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
])
AC_CHECK_HEADERS(linux/inet_diag.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
#if HAVE_LINUX_INET_DIAG_H
# include <linux/inet_diag.h>
#endif
])
AC_CHECK_HEADERS(linux/netdevice.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
#if HAVE_LINUX_IF_H
# include <linux/if.h>
#endif
])

# For ethstat module
AC_CHECK_HEADERS(linux/sockios.h,
    [have_linux_sockios_h="yes"],
    [have_linux_sockios_h="no"],
    [
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
    ])
AC_CHECK_HEADERS(linux/ethtool.h,
    [have_linux_ethtool_h="yes"],
    [have_linux_ethtool_h="no"],
    [
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
#if HAVE_LINUX_SOCKIOS_H
# include <linux/sockios.h>
#endif
    ])

# For ipvs module
have_linux_ip_vs_h="no"
have_net_ip_vs_h="no"
have_ip_vs_h="no"
ip_vs_h_needs_kernel_cflags="no"
if test "x$ac_system" = "xLinux"
then
	AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
	AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
	AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])

	if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR"
	then
		SAVE_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS $KERNEL_CFLAGS"

		AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])

		AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
		AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
		AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])

		if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
		then
			ip_vs_h_needs_kernel_cflags="yes"
		fi

		CFLAGS="$SAVE_CFLAGS"
	fi
fi
AM_CONDITIONAL(IP_VS_H_NEEDS_KERNEL_CFLAGS, test "x$ip_vs_h_needs_kernel_cflags" = "xyes")

# For quota module
AC_CHECK_HEADERS(sys/ucred.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
])

# For mount interface
AC_CHECK_HEADERS(sys/mount.h, [], [],
[
#if HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
])

# For the email plugin
AC_CHECK_HEADERS(linux/un.h, [], [],
[
#if HAVE_SYS_SOCKET_H
#	include <sys/socket.h>
#endif
])

AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h sys/vmmeter.h kvm.h wordexp.h locale.h)

# For the dns plugin
AC_CHECK_HEADERS(arpa/nameser.h)
AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
[
#if HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
])

AC_CHECK_HEADERS(net/if_arp.h, [], [],
[#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
AC_CHECK_HEADERS(net/ppp_defs.h)
AC_CHECK_HEADERS(net/if_ppp.h, [], [],
[#if HAVE_NET_PPP_DEFS_H
# include <net/ppp_defs.h>
#endif
])
AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
[#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
])

AC_CHECK_HEADERS(netinet/ip_compat.h)

have_net_pfvar_h="no"
AC_CHECK_HEADERS(net/pfvar.h,
               [have_net_pfvar_h="yes"],
               [have_net_pfvar_h="no"],
[
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
])

# For the multimeter plugin
have_termios_h="no"
AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])

# For the turbostat plugin
have_asm_msrindex_h="no"
AC_CHECK_HEADERS(asm/msr-index.h, [have_asm_msrindex_h="yes"])

if test "x$have_asm_msrindex_h" = "xyes"
then
  AC_CACHE_CHECK([whether asm/msr-index.h has MSR_CORE_C3_RESIDENCY],
                 [c_cv_have_usable_asm_msrindex_h],
                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#include<asm/msr-index.h>
]]],
[[[
int y = MSR_CORE_C3_RESIDENCY;
return(y);
]]]
  )],
                 [c_cv_have_usable_asm_msrindex_h="yes"],
                 [c_cv_have_usable_asm_msrindex_h="no"],
                                  )
                 )
fi

have_cpuid_h="no"
AC_CHECK_HEADERS(cpuid.h, [have_cpuid_h="yes"])

AC_CHECK_HEADERS(sys/capability.h)
#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT32_T
AC_HEADER_TIME

#
# Checks for library functions.
#
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname setlocale)

AC_FUNC_STRERROR_R

SAVE_CFLAGS="$CFLAGS"
# Emulate behavior of src/Makefile.am
if test "x$GCC" = "xyes"
then
	CFLAGS="$CFLAGS -Wall -Werror"
fi

AC_CACHE_CHECK([for strtok_r],
  [c_cv_have_strtok_r_default],
  AC_LINK_IFELSE(
    [AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
]]],
[[[
      char buffer[] = "foo,bar,baz";
      char *token;
      char *dummy;
      char *saveptr;

      dummy = buffer;
      saveptr = NULL;
      while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
      {
        dummy = NULL;
        printf ("token = %s;\n", token);
      }
]]]
    )],
    [c_cv_have_strtok_r_default="yes"],
    [c_cv_have_strtok_r_default="no"]
  )
)

if test "x$c_cv_have_strtok_r_default" = "xno"
then
  CFLAGS="$CFLAGS -D_REENTRANT=1"

  AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
    [c_cv_have_strtok_r_reentrant],
    AC_LINK_IFELSE(
      [AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
]]],
[[[
        char buffer[] = "foo,bar,baz";
        char *token;
        char *dummy;
        char *saveptr;

        dummy = buffer;
        saveptr = NULL;
        while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
        {
          dummy = NULL;
          printf ("token = %s;\n", token);
        }
]]]
      )],
      [c_cv_have_strtok_r_reentrant="yes"],
      [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
    )
  )
fi

CFLAGS="$SAVE_CFLAGS"
if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
then
	CFLAGS="$CFLAGS -D_REENTRANT=1"
fi

AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)

socket_needs_socket="no"
AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")

clock_gettime_needs_rt="no"
clock_gettime_needs_posix4="no"
have_clock_gettime="no"
AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
if test "x$have_clock_gettime" = "xno"
then
	AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
					 have_clock_gettime="yes"])
fi
if test "x$have_clock_gettime" = "xno"
then
	AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
					     have_clock_gettime="yes"])
fi
if test "x$have_clock_gettime" = "xyes"
then
	AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
else
	AC_MSG_WARN(cannot find clock_gettime)
fi

nanosleep_needs_rt="no"
nanosleep_needs_posix4="no"
AC_CHECK_FUNCS(nanosleep,
    [],
    AC_CHECK_LIB(rt, nanosleep,
        [nanosleep_needs_rt="yes"],
        AC_CHECK_LIB(posix4, nanosleep,
            [nanosleep_needs_posix4="yes"],
            AC_MSG_ERROR(cannot find nanosleep))))

AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")

AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])

# Check for strptime {{{
if test "x$GCC" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS -Wall -Wextra -Werror"
fi

AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
if test "x$have_strptime" = "xyes"
then
	AC_CACHE_CHECK([whether strptime is exported by default],
		       [c_cv_have_strptime_default],
		       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#include <time.h>
]]],
[[[
 struct tm stm;
 (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
]]]
		       )],
		       [c_cv_have_strptime_default="yes"],
		       [c_cv_have_strptime_default="no"]))
fi
if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
then
	AC_CACHE_CHECK([whether strptime needs standards mode],
		       [c_cv_have_strptime_standards],
		       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#ifndef _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
#endif
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif
#ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 500
#endif
#include <time.h>
]]],
[[[
 struct tm stm;
 (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
]]]
		       )],
		       [c_cv_have_strptime_standards="yes"],
		       [c_cv_have_strptime_standards="no"]))

	if test "x$c_cv_have_strptime_standards" = "xyes"
	then
		AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
	else
		have_strptime="no"
	fi
fi

if test "x$GCC" = "xyes"
then
	CFLAGS="$SAVE_CFLAGS"
fi
# }}} Check for strptime

AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
if test "x$have_swapctl" = "xyes"; then
        AC_CACHE_CHECK([whether swapctl takes two arguments],
                [c_cv_have_swapctl_two_args],
                AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
#  undef _FILE_OFFSET_BITS
#  undef _LARGEFILE64_SOURCE
#endif
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/swap.h>
#include <unistd.h>
]]],
[[[
int num = swapctl(0, NULL);
]]]
                        )],
                        [c_cv_have_swapctl_two_args="yes"],
                        [c_cv_have_swapctl_two_args="no"]
                )
        )
        AC_CACHE_CHECK([whether swapctl takes three arguments],
                [c_cv_have_swapctl_three_args],
                AC_COMPILE_IFELSE(
                        [AC_LANG_PROGRAM(
[[[
#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
#  undef _FILE_OFFSET_BITS
#  undef _LARGEFILE64_SOURCE
#endif
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/swap.h>
#include <unistd.h>
]]],
[[[
int num = swapctl(0, NULL, 0);
]]]
                        )],
                        [c_cv_have_swapctl_three_args="yes"],
                        [c_cv_have_swapctl_three_args="no"]
                )
        )
fi
# Check for different versions of `swapctl' here..
if test "x$have_swapctl" = "xyes"; then
        if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
                AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
                          [Define if the function swapctl exists and takes two arguments.])
        fi
        if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
                AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
                          [Define if the function swapctl exists and takes three arguments.])
        fi
fi

# Check for NAN
AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
[
 if test "x$withval" = "xno"; then
	 nan_type="none"
 else if test "x$withval" = "xyes"; then
	 nan_type="zero"
 else
	 nan_type="$withval"
 fi; fi
],
[nan_type="none"])
if test "x$nan_type" = "xnone"; then
  AC_CACHE_CHECK([whether NAN is defined by default],
    [c_cv_have_nan_default],
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <math.h>
static double foo = NAN;
]]],
[[[
       if (isnan (foo))
        return 0;
       else
	return 1;
]]]
      )],
      [c_cv_have_nan_default="yes"],
      [c_cv_have_nan_default="no"]
    )
  )
  if test "x$c_cv_have_nan_default" = "xyes"
  then
    nan_type="default"
  fi
fi
if test "x$nan_type" = "xnone"; then
  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
    [c_cv_have_nan_isoc],
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#define __USE_ISOC99 1
#include <math.h>
static double foo = NAN;
]]],
[[[
       if (isnan (foo))
        return 0;
       else
	return 1;
]]]
      )],
      [c_cv_have_nan_isoc="yes"],
      [c_cv_have_nan_isoc="no"]
    )
  )
  if test "x$c_cv_have_nan_isoc" = "xyes"
  then
    nan_type="isoc99"
  fi
fi
if test "x$nan_type" = "xnone"; then
  SAVE_LDFLAGS=$LDFLAGS
  LDFLAGS="$LDFLAGS -lm"
  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
    [c_cv_have_nan_zero],
    AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <math.h>
#ifdef NAN
# undef NAN
#endif
#define NAN (0.0 / 0.0)
#ifndef isnan
# define isnan(f) ((f) != (f))
#endif
static double foo = NAN;
]]],
[[[
       if (isnan (foo))
        return 0;
       else
	return 1;
]]]
      )],
      [c_cv_have_nan_zero="yes"],
      [c_cv_have_nan_zero="no"]
    )
  )
  LDFLAGS=$SAVE_LDFLAGS
  if test "x$c_cv_have_nan_zero" = "xyes"
  then
    nan_type="zero"
  fi
fi

if test "x$nan_type" = "xdefault"; then
  AC_DEFINE(NAN_STATIC_DEFAULT, 1,
    [Define if NAN is defined by default and can initialize static variables.])
else if test "x$nan_type" = "xisoc99"; then
  AC_DEFINE(NAN_STATIC_ISOC, 1,
    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
else if test "x$nan_type" = "xzero"; then
  AC_DEFINE(NAN_ZERO_ZERO, 1,
    [Define if NAN can be defined as (0.0 / 0.0)])
else
  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
fi; fi; fi

AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
[
 if test "x$withval" = "xnothing"; then
 	fp_layout_type="nothing"
 else if test "x$withval" = "xendianflip"; then
 	fp_layout_type="endianflip"
 else if test "x$withval" = "xintswap"; then
 	fp_layout_type="intswap"
 else
 	AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
fi; fi; fi
],
[fp_layout_type="unknown"])

if test "x$fp_layout_type" = "xunknown"; then
  AC_CACHE_CHECK([if doubles are stored in x86 representation],
    [c_cv_fp_layout_need_nothing],
    AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDBOOL_H
# include <stdbool.h>
#endif
]]],
[[[
	uint64_t i0;
	uint64_t i1;
	uint8_t c[8];
	double d;

	d = 8.642135e130;
	memcpy ((void *) &i0, (void *) &d, 8);

	i1 = i0;
	memcpy ((void *) c, (void *) &i1, 8);

	if ((c[0] == 0x2f) && (c[1] == 0x25)
			&& (c[2] == 0xc0) && (c[3] == 0xc7)
			&& (c[4] == 0x43) && (c[5] == 0x2b)
			&& (c[6] == 0x1f) && (c[7] == 0x5b))
		return (0);
	else
		return (1);
]]]
      )],
      [c_cv_fp_layout_need_nothing="yes"],
      [c_cv_fp_layout_need_nothing="no"]
    )
  )
  if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
    fp_layout_type="nothing"
  fi
fi
if test "x$fp_layout_type" = "xunknown"; then
  AC_CACHE_CHECK([if endianflip converts to x86 representation],
    [c_cv_fp_layout_need_endianflip],
    AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDBOOL_H
# include <stdbool.h>
#endif
#define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
                       (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
                       (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
                       (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
                       (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
                       (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
                       (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
                       (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
]]],
[[[
	uint64_t i0;
	uint64_t i1;
	uint8_t c[8];
	double d;

	d = 8.642135e130;
	memcpy ((void *) &i0, (void *) &d, 8);

	i1 = endianflip (i0);
	memcpy ((void *) c, (void *) &i1, 8);

	if ((c[0] == 0x2f) && (c[1] == 0x25)
			&& (c[2] == 0xc0) && (c[3] == 0xc7)
			&& (c[4] == 0x43) && (c[5] == 0x2b)
			&& (c[6] == 0x1f) && (c[7] == 0x5b))
		return (0);
	else
		return (1);
]]]
      )],
      [c_cv_fp_layout_need_endianflip="yes"],
      [c_cv_fp_layout_need_endianflip="no"]
    )
  )
  if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
    fp_layout_type="endianflip"
  fi
fi
if test "x$fp_layout_type" = "xunknown"; then
  AC_CACHE_CHECK([if intswap converts to x86 representation],
    [c_cv_fp_layout_need_intswap],
    AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDBOOL_H
# include <stdbool.h>
#endif
#define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
                       (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
]]],
[[[
	uint64_t i0;
	uint64_t i1;
	uint8_t c[8];
	double d;

	d = 8.642135e130;
	memcpy ((void *) &i0, (void *) &d, 8);

	i1 = intswap (i0);
	memcpy ((void *) c, (void *) &i1, 8);

	if ((c[0] == 0x2f) && (c[1] == 0x25)
			&& (c[2] == 0xc0) && (c[3] == 0xc7)
			&& (c[4] == 0x43) && (c[5] == 0x2b)
			&& (c[6] == 0x1f) && (c[7] == 0x5b))
		return (0);
	else
		return (1);
]]]
      )],
      [c_cv_fp_layout_need_intswap="yes"],
      [c_cv_fp_layout_need_intswap="no"]
    )
  )
  if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
    fp_layout_type="intswap"
  fi
fi

if test "x$fp_layout_type" = "xnothing"; then
  AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
  [Define if doubles are stored in x86 representation.])
else if test "x$fp_layout_type" = "xendianflip"; then
  AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
  [Define if endianflip is needed to convert to x86 representation.])
else if test "x$fp_layout_type" = "xintswap"; then
  AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
  [Define if intswap is needed to convert to x86 representation.])
else
  AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
fi; fi; fi

# --with-useragent {{{
AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
[
    if test "x$withval" != "xno" && test "x$withval" != "xyes"
    then
        AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
    fi
])

# }}}

have_getfsstat="no"
AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
have_getvfsstat="no"
AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
have_listmntent="no"
AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])

have_getmntent="no"
AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
if test "x$have_getmntent" = "xno"; then
	AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
fi
if test "x$have_getmntent" = "xno"; then
	AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
fi
if test "x$have_getmntent" = "xno"; then
	AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
fi

if test "x$have_getmntent" = "xc"; then
	AC_CACHE_CHECK([whether getmntent takes one argument],
		[c_cv_have_one_getmntent],
		AC_COMPILE_IFELSE(
			[AC_LANG_PROGRAM(
[[[
#include "$srcdir/src/utils_mount.h"
]]],
[[[
FILE *fh;
struct mntent *me;
fh = setmntent ("/etc/mtab", "r");
me = getmntent (fh);
return(me->mnt_passno);
]]]
			)],
			[c_cv_have_one_getmntent="yes"],
			[c_cv_have_one_getmntent="no"]
		)
	)
	AC_CACHE_CHECK([whether getmntent takes two arguments],
		[c_cv_have_two_getmntent],
		AC_COMPILE_IFELSE(
			[AC_LANG_PROGRAM(
[[[
#include "$srcdir/src/utils_mount.h"
]]],
[[[
				 FILE *fh;
				 struct mnttab mt;
				 int status;
				 fh = fopen ("/etc/mnttab", "r");
				 status = getmntent (fh, &mt);
				 return(status);
]]]
			)],
			[c_cv_have_two_getmntent="yes"],
			[c_cv_have_two_getmntent="no"]
		)
	)
fi

# Check for different versions of `getmntent' here..

if test "x$have_getmntent" = "xc"; then
	if test "x$c_cv_have_one_getmntent" = "xyes"; then
		AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
			  [Define if the function getmntent exists and takes one argument.])
	fi
	if test "x$c_cv_have_two_getmntent" = "xyes"; then
		AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
			  [Define if the function getmntent exists and takes two arguments.])
	fi
fi
if test "x$have_getmntent" = "xsun"; then
	AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
		  [Define if the function getmntent exists. It's the version from libsun.])
fi
if test "x$have_getmntent" = "xseq"; then
	AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
		  [Define if the function getmntent exists. It's the version from libseq.])
fi
if test "x$have_getmntent" = "xgen"; then
	AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
		  [Define if the function getmntent exists. It's the version from libgen.])
fi

# Check for htonll
AC_CACHE_CHECK([if have htonll defined],
                  [c_cv_have_htonll],
                  AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#include <sys/types.h>
#include <netinet/in.h>
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
]]],
[[[
          return htonll(0);
]]]
    )],
    [c_cv_have_htonll="yes"],
    [c_cv_have_htonll="no"]
  )
)
if test "x$c_cv_have_htonll" = "xyes"
then
    AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
fi

# Check for structures
AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
	[AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
	[],
	[
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <net/if.h>
	])
AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
	[AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
	[],
	[
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <linux/if.h>
	#include <linux/netdevice.h>
	])
AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
	[AC_DEFINE(HAVE_STRUCT_LINUX_INET_DIAG_REQ, 1, [Define if struct inet_diag_req exists and is usable.])],
	[],
	[
	#include <linux/inet_diag.h>
	])


AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
	[],
	[
	#include <netinet/in.h>
	#include <net/if.h>
	])

AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
	[
		AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
			[Define if struct kinfo_proc exists in the FreeBSD variant.])
		have_struct_kinfo_proc_freebsd="yes"
	],
	[
		have_struct_kinfo_proc_freebsd="no"
	],
	[
#include <kvm.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
	])

AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
	[
		AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
			[Define if struct kinfo_proc exists in the OpenBSD variant.])
		have_struct_kinfo_proc_openbsd="yes"
	],
	[
		have_struct_kinfo_proc_openbsd="no"
	],
	[
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
	])

AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
[#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
#if HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
])
AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
[#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
#if HAVE_NETINET_UDP_H
# include <netinet/udp.h>
#endif
])

AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
	[],
	[],
	[
#if HAVE_KSTAT_H
# include <kstat.h>
#endif
	])
AC_CHECK_MEMBERS([struct shm_info.used_ids], [],
[
	AC_CHECK_MEMBERS([struct shm_info.__used_ids], [], [],
	[#include <sys/shm.h>
	])
],
[#include <sys/shm.h>
])

#
# Checks for libraries begin here
#

with_libresolv="yes"
AC_CHECK_LIB(resolv, res_search,
[
	AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
],
[with_libresolv="no"])
AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")

dnl Check for HAL (hardware abstraction library)
with_libhal="yes"
AC_CHECK_LIB(hal,libhal_device_property_exists,
	     [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
	     [with_libhal="no"])
if test "x$with_libhal" = "xyes"; then
	if test "x$PKG_CONFIG" != "x"; then
		BUILD_WITH_LIBHAL_CFLAGS="`$PKG_CONFIG --cflags hal`"
		BUILD_WITH_LIBHAL_LIBS="`$PKG_CONFIG --libs hal`"
		AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
		AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
	fi
fi

m4_divert_once([HELP_WITH], [
collectd additional packages:])

if test "x$ac_system" = "xAIX"
then
	with_perfstat="yes"
	with_procinfo="yes"
else
	with_perfstat="no (AIX only)"
	with_procinfo="no (AIX only)"
fi

if test "x$with_perfstat" = "xyes"
then
	AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
#	AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
fi
if test "x$with_perfstat" = "xyes"
then
	 AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
	 # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
	 AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
	 if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
	 then
		AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
	 fi
fi
AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")

# Processes plugin under AIX.
if test "x$with_procinfo" = "xyes"
then
	AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
fi
if test "x$with_procinfo" = "xyes"
then
	 AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
fi

if test "x$ac_system" = "xSolaris"
then
	with_kstat="yes"
	with_devinfo="yes"
else
	with_kstat="no (Solaris only)"
	with_devinfo="no (Solaris only)"
fi

if test "x$with_kstat" = "xyes"
then
	AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
fi
if test "x$with_kstat" = "xyes"
then
	AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
	AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
fi
if test "x$with_kstat" = "xyes"
then
	AC_DEFINE(HAVE_LIBKSTAT, 1,
		  [Define to 1 if you have the 'kstat' library (-lkstat)])
fi
AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")

with_libiokit="no"
if test "x$ac_system" = "xDarwin"
then
	with_libiokit="yes"
else
	with_libiokit="no"
fi
AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")

with_libkvm="no"
AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
if test "x$with_kvm_getprocs" = "xyes"
then
	AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
		  [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
	with_libkvm="yes"
fi
AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")

AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
if test "x$with_kvm_getswapinfo" = "xyes"
then
	AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
		  [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
	with_libkvm="yes"
fi
AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")

AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
if test "x$with_kvm_nlist" = "xyes"
then
	AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
	AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
		  [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
	with_libkvm="yes"
fi
AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")

AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
if test "x$with_kvm_openfiles" = "xyes"
then
	AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
		  [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
	with_libkvm="yes"
fi
AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")

# --with-libaquaero5 {{{
AC_ARG_WITH(libaquaero5, [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
[
 if test "x$withval" = "xyes"
 then
	 with_libaquaero5="yes"
 else if test "x$withval" = "xno"
 then
	 with_libaquaero5="no"
 else
	 with_libaquaero5="yes"
	 LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
	 LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
 fi; fi
],
[with_libaquaero5="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"

if test "x$with_libaquaero5" = "xyes"
then
	if test "x$LIBAQUAERO5_CFLAGS" != "x"
	then
		AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
	fi
	AC_CHECK_HEADERS(libaquaero5.h,
	[with_libaquaero5="yes"],
	[with_libaquaero5="no (libaquaero5.h not found)"])
fi
if test "x$with_libaquaero5" = "xyes"
then
	if test "x$LIBAQUAERO5_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
	fi
	AC_CHECK_LIB(aquaero5, libaquaero5_poll,
	[with_libaquaero5="yes"],
	[with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libaquaero5" = "xyes"
then
	BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
	BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBAQUAERO5_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
# }}}

# --with-libhiredis {{{
AC_ARG_WITH(libhiredis, [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@],
      [Path to libhiredis.])],
[
 if test "x$withval" = "xyes"
 then
	 with_libhiredis="yes"
 else if test "x$withval" = "xno"
 then
	 with_libhiredis="no"
 else
	 with_libhiredis="yes"
	 LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
	 LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
 fi; fi
],
[with_libhiredis="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"

if test "x$with_libhiredis" = "xyes"
then
	if test "x$LIBHIREDIS_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(hiredis/hiredis.h,
	[with_libhiredis="yes"],
	[with_libhiredis="no (hiredis.h not found)"])
fi
if test "x$with_libhiredis" = "xyes"
then
	if test "x$LIBHIREDIS_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
	fi
	AC_CHECK_LIB(hiredis, redisCommand,
	[with_libhiredis="yes"],
	[with_libhiredis="no (symbol 'redisCommand' not found)"])

fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libhiredis" = "xyes"
then
	BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
	BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBHIREDIS_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBHIREDIS, test "x$with_libhiredis" = "xyes")
# }}}

# --with-libcurl {{{
with_curl_config="curl-config"
with_curl_cflags=""
with_curl_libs=""
AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
[
	if test "x$withval" = "xno"
	then
		with_libcurl="no"
	else if test "x$withval" = "xyes"
	then
		with_libcurl="yes"
	else
		if test -f "$withval" && test -x "$withval"
		then
			with_curl_config="$withval"
			with_libcurl="yes"
		else if test -x "$withval/bin/curl-config"
		then
			with_curl_config="$withval/bin/curl-config"
			with_libcurl="yes"
		fi; fi
		with_libcurl="yes"
	fi; fi
],
[
	with_libcurl="yes"
])
if test "x$with_libcurl" = "xyes"
then
	with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
	curl_config_status=$?

	if test $curl_config_status -ne 0
	then
		with_libcurl="no ($with_curl_config failed)"
	else
		SAVE_CPPFLAGS="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $with_curl_cflags"

		AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])

		CPPFLAGS="$SAVE_CPPFLAGS"
	fi
fi
if test "x$with_libcurl" = "xyes"
then
	with_curl_libs=`$with_curl_config --libs 2>/dev/null`
	curl_config_status=$?

	if test $curl_config_status -ne 0
	then
		with_libcurl="no ($with_curl_config failed)"
	else
		AC_CHECK_LIB(curl, curl_easy_init,
		 [with_libcurl="yes"],
		 [with_libcurl="no (symbol 'curl_easy_init' not found)"],
		 [$with_curl_libs])
		AC_CHECK_DECL(CURLOPT_USERNAME,
		 [have_curlopt_username="yes"],
		 [have_curlopt_username="no"],
		 [[#include <curl/curl.h>]])
		AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
		 [have_curlopt_timeout="yes"],
		 [have_curlopt_timeout="no"],
		 [[#include <curl/curl.h>]])
	fi
fi
if test "x$with_libcurl" = "xyes"
then
	BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
	BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
	AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBCURL_LIBS)

	if test "x$have_curlopt_username" = "xyes"
	then
		AC_DEFINE(HAVE_CURLOPT_USERNAME, 1, [Define if libcurl supports CURLOPT_USERNAME option.])
	fi

	if test "x$have_curlopt_timeout" = "xyes"
	then
		AC_DEFINE(HAVE_CURLOPT_TIMEOUT_MS, 1, [Define if libcurl supports CURLOPT_TIMEOUT_MS option.])
	fi
fi
AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
# }}}

# --with-libdbi {{{
with_libdbi_cppflags=""
with_libdbi_ldflags=""
AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_libdbi_cppflags="-I$withval/include"
		with_libdbi_ldflags="-L$withval/lib"
		with_libdbi="yes"
	else
		with_libdbi="$withval"
	fi
],
[
	with_libdbi="yes"
])
if test "x$with_libdbi" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"

	AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libdbi" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
	LDFLAGS="$LDFLAGS $with_libdbi_ldflags"

	AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libdbi" = "xyes"
then
	BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
	BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
	BUILD_WITH_LIBDBI_LIBS="-ldbi"
	AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
# }}}

# --with-libesmtp {{{
AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		LDFLAGS="$LDFLAGS -L$withval/lib"
		CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
		with_libesmtp="yes"
	else
		with_libesmtp="$withval"
	fi
],
[
	with_libesmtp="yes"
])
if test "x$with_libesmtp" = "xyes"
then
	AC_CHECK_LIB(esmtp, smtp_create_session,
	[
		AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
	], [with_libesmtp="no (libesmtp not found)"])
fi
if test "x$with_libesmtp" = "xyes"
then
	AC_CHECK_HEADERS(libesmtp.h,
	[
		AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
	], [with_libesmtp="no (libesmtp.h not found)"])
fi
if test "x$with_libesmtp" = "xyes"
then
	collect_libesmtp=1
else
	collect_libesmtp=0
fi
AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
	[Wether or not to use the esmtp library])
AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
# }}}

# --with-libganglia {{{
AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
[
 if test -f "$withval" && test -x "$withval"
 then
	 with_libganglia_config="$withval"
	 with_libganglia="yes"
 else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
 then
	 with_libganglia_config="$withval/bin/ganglia-config"
	 with_libganglia="yes"
 else if test -d "$withval"
 then
	 GANGLIA_CPPFLAGS="-I$withval/include"
	 GANGLIA_LDFLAGS="-L$withval/lib"
	 with_libganglia="yes"
 else
	 with_libganglia_config="ganglia-config"
	 with_libganglia="$withval"
 fi; fi; fi
],
[
 with_libganglia_config="ganglia-config"
 with_libganglia="yes"
])

if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
then
	if test "x$GANGLIA_CPPFLAGS" = "x"
	then
		GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
	fi

	if test "x$GANGLIA_LDFLAGS" = "x"
	then
		GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
	fi

	if test "x$GANGLIA_LIBS" = "x"
	then
		GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
	fi
fi

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"

if test "x$with_libganglia" = "xyes"
then
	AC_CHECK_HEADERS(gm_protocol.h,
	[
		AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
			  [Define to 1 if you have the <gm_protocol.h> header file.])
	], [with_libganglia="no (gm_protocol.h not found)"])
fi

if test "x$with_libganglia" = "xyes"
then
	AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
	[
		AC_DEFINE(HAVE_LIBGANGLIA, 1,
			  [Define to 1 if you have the ganglia library (-lganglia).])
	], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

AC_SUBST(GANGLIA_CPPFLAGS)
AC_SUBST(GANGLIA_LDFLAGS)
AC_SUBST(GANGLIA_LIBS)
AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
# }}}

# --with-libgcrypt {{{
GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
GCRYPT_LIBS="$GCRYPT_LIBS"
AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
[
 if test -f "$withval" && test -x "$withval"
 then
	 with_libgcrypt_config="$withval"
	 with_libgcrypt="yes"
 else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
 then
	 with_libgcrypt_config="$withval/bin/gcrypt-config"
	 with_libgcrypt="yes"
 else if test -d "$withval"
 then
	 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
	 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
	 with_libgcrypt="yes"
 else
	 with_libgcrypt_config="gcrypt-config"
	 with_libgcrypt="$withval"
 fi; fi; fi
],
[
 with_libgcrypt_config="libgcrypt-config"
 with_libgcrypt="yes"
])

if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
then
	if test "x$GCRYPT_CPPFLAGS" = "x"
	then
		GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
	fi

	if test "x$GCRYPT_LDFLAGS" = "x"
	then
		gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
		GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
	fi

	if test "x$GCRYPT_LIBS" = "x"
	then
		GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
	fi
fi

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"

if test "x$with_libgcrypt" = "xyes"
then
	if test "x$GCRYPT_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(gcrypt.h,
		[with_libgcrypt="yes"],
		[with_libgcrypt="no (gcrypt.h not found)"])
fi

if test "x$with_libgcrypt" = "xyes"
then
	if test "x$GCRYPT_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
	fi
	AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
		[with_libgcrypt="yes"],
		[with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])

	if test "$with_libgcrypt" != "no"; then
		m4_ifdef([AM_PATH_LIBGCRYPT],[AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")])
		GCRYPT_CPPFLAGS="$LIBGCRYPT_CPPFLAGS $LIBGCRYPT_CFLAGS"
		GCRYPT_LIBS="$LIBGCRYPT_LIBS"
	fi
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libgcrypt" = "xyes"
then
	AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
fi

AC_SUBST(GCRYPT_CPPFLAGS)
AC_SUBST(GCRYPT_LDFLAGS)
AC_SUBST(GCRYPT_LIBS)
AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
# }}}

# --with-libiptc {{{
AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
[
	if test "x$withval" = "xyes"
	then
		with_libiptc="pkgconfig"
	else if test "x$withval" = "xno"
	then
		with_libiptc="no"
	else
		with_libiptc="yes"
		with_libiptc_cflags="-I$withval/include"
		with_libiptc_libs="-L$withval/lib"
	fi; fi
],
[
	if test "x$ac_system" = "xLinux"
	then
		with_libiptc="pkgconfig"
	else
		with_libiptc="no (Linux only)"
	fi
])

if test "x$with_libiptc" = "xpkgconfig" && test "x$PKG_CONFIG" = "x"
then
	with_libiptc="no (Don't have pkg-config)"
fi

if test "x$with_libiptc" = "xpkgconfig"
then
	$PKG_CONFIG --exists 'libiptc' 2>/dev/null
	if test $? -ne 0
	then
		with_libiptc="no (pkg-config doesn't know libiptc)"
	fi
fi
if test "x$with_libiptc" = "xpkgconfig"
then
	with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
	if test $? -ne 0
	then
		with_libiptc="no ($PKG_CONFIG failed)"
	fi
	with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
	if test $? -ne 0
	then
		with_libiptc="no ($PKG_CONFIG failed)"
	fi
fi

SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"

# check whether the header file for libiptc is available.
if test "x$with_libiptc" = "xpkgconfig"
then
	AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
			[with_libiptc="no (header file missing)"])
fi
# If the header file is available, check for the required type declaractions.
# They may be missing in old versions of libiptc. In that case, they will be
# declared in the iptables plugin.
if test "x$with_libiptc" = "xpkgconfig"
then
	AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
fi
# Check for the iptc_init symbol in the library.
# This could be in iptc or ip4tc
if test "x$with_libiptc" = "xpkgconfig"
then
	SAVE_LIBS="$LIBS"
	AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
			[with_libiptc="pkgconfig"],
			[with_libiptc="no"],
			[$with_libiptc_libs])
	LIBS="$SAVE_LIBS"
fi
if test "x$with_libiptc" = "xpkgconfig"
then
	with_libiptc="yes"
fi

CPPFLAGS="$SAVE_CPPFLAGS"

AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
if test "x$with_libiptc" = "xyes"
then
	BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
	BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
	AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
fi
# }}}

# --with-java {{{
with_java_home="$JAVA_HOME"
if test "x$with_java_home" = "x"
then
	with_java_home="/usr/lib/jvm"
fi
with_java_vmtype="client"
with_java_cflags=""
with_java_libs=""
JAVAC="$JAVAC"
JAR="$JAR"
AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
[
	if test "x$withval" = "xno"
	then
		with_java="no"
	else if test "x$withval" = "xyes"
	then
		with_java="yes"
	else
		with_java_home="$withval"
		with_java="yes"
	fi; fi
],
[with_java="yes"])
if test "x$with_java" = "xyes"
then
	if test -d "$with_java_home"
	then
		AC_MSG_CHECKING([for jni.h])
		TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
		if test "x$TMPVAR" != "x"
		then
			AC_MSG_RESULT([found in $TMPVAR])
			JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
		else
			AC_MSG_RESULT([not found])
		fi

		AC_MSG_CHECKING([for jni_md.h])
		TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
		if test "x$TMPVAR" != "x"
		then
			AC_MSG_RESULT([found in $TMPVAR])
			JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
		else
			AC_MSG_RESULT([not found])
		fi

		AC_MSG_CHECKING([for libjvm.so])
		TMPVAR=`find -L "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' 2>/dev/null | head -n 1`
		if test "x$TMPVAR" != "x"
		then
			AC_MSG_RESULT([found in $TMPVAR])
			JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
		else
			AC_MSG_RESULT([not found])
		fi

		if test "x$JAVAC" = "x"
		then
			AC_MSG_CHECKING([for javac])
			TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | head -n 1`
			if test "x$TMPVAR" != "x"
			then
				JAVAC="$TMPVAR"
				AC_MSG_RESULT([$JAVAC])
			else
				AC_MSG_RESULT([not found])
			fi
		fi
		if test "x$JAR" = "x"
		then
			AC_MSG_CHECKING([for jar])
			TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | head -n 1`
			if test "x$TMPVAR" != "x"
			then
				JAR="$TMPVAR"
				AC_MSG_RESULT([$JAR])
			else
				AC_MSG_RESULT([not found])
			fi
		fi
	else if test "x$with_java_home" != "x"
	then
		AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
	fi; fi
fi

if test "x$JAVA_CPPFLAGS" != "x"
then
	AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
fi
if test "x$JAVA_CFLAGS" != "x"
then
	AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
fi
if test "x$JAVA_LDFLAGS" != "x"
then
	AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
fi
if test "x$JAVAC" = "x"
then
	with_javac_path="$PATH"
	if test "x$with_java_home" != "x"
	then
		with_javac_path="$with_java_home:with_javac_path"
		if test -d "$with_java_home/bin"
		then
			with_javac_path="$with_java_home/bin:with_javac_path"
		fi
	fi

	AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
fi
if test "x$JAVAC" = "x"
then
	with_java="no (javac not found)"
fi
if test "x$JAR" = "x"
then
	with_jar_path="$PATH"
	if test "x$with_java_home" != "x"
	then
		with_jar_path="$with_java_home:$with_jar_path"
		if test -d "$with_java_home/bin"
		then
			with_jar_path="$with_java_home/bin:$with_jar_path"
		fi
	fi

	AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
fi
if test "x$JAR" = "x"
then
	with_java="no (jar not found)"
fi

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_CFLAGS="$CFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
CFLAGS="$CFLAGS $JAVA_CFLAGS"
LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"

if test "x$with_java" = "xyes"
then
	AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
fi
if test "x$with_java" = "xyes"
then
	AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
	[with_java="yes"],
	[with_java="no (libjvm not found)"],
	[$JAVA_LIBS])
fi
if test "x$with_java" = "xyes"
then
	JAVA_LIBS="$JAVA_LIBS -ljvm"
	AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
CFLAGS="$SAVE_CFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

AC_SUBST(JAVA_CPPFLAGS)
AC_SUBST(JAVA_CFLAGS)
AC_SUBST(JAVA_LDFLAGS)
AC_SUBST(JAVA_LIBS)
AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
# }}}

# --with-libldap {{{
AC_ARG_WITH(libldap, [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
[
 if test "x$withval" = "xyes"
 then
	 with_libldap="yes"
 else if test "x$withval" = "xno"
 then
	 with_libldap="no"
 else
	 with_libldap="yes"
	 LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
	 LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
 fi; fi
],
[with_libldap="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"

if test "x$with_libldap" = "xyes"
then
	if test "x$LIBLDAP_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(ldap.h,
	[with_libldap="yes"],
	[with_libldap="no ('ldap.h' not found)"])
fi
if test "x$with_libldap" = "xyes"
then
	if test "x$LIBLDAP_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
	fi
	AC_CHECK_LIB(ldap, ldap_initialize,
	[with_libldap="yes"],
	[with_libldap="no (symbol 'ldap_initialize' not found)"])

fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libldap" = "xyes"
then
	BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
	BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBLDAP_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBLDAP_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBLDAP, test "x$with_libldap" = "xyes")
# }}}

# --with-liblvm2app {{{
with_liblvm2app_cppflags=""
with_liblvm2app_ldflags=""
AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
[
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
                with_liblvm2app_cppflags="-I$withval/include"
                with_liblvm2app_ldflags="-L$withval/lib"
                with_liblvm2app="yes"
        else
                with_liblvm2app="$withval"
        fi
],
[
        with_liblvm2app="yes"
])
if test "x$with_liblvm2app" = "xyes"
then
        SAVE_CPPFLAGS="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"

        AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])

        CPPFLAGS="$SAVE_CPPFLAGS"
fi

if test "x$with_liblvm2app" = "xyes"
then
        SAVE_CPPFLAGS="$CPPFLAGS"
        SAVE_LDFLAGS="$LDFLAGS"
        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
        LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"

        AC_CHECK_LIB(lvm2app, lvm_lv_get_property, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"])

        CPPFLAGS="$SAVE_CPPFLAGS"
        LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_liblvm2app" = "xyes"
then
        BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
        BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
        BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
        AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
        AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
        AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
        AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
fi
AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
# }}}

# --with-libmemcached {{{
with_libmemcached_cppflags=""
with_libmemcached_ldflags=""
AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_libmemcached_cppflags="-I$withval/include"
		with_libmemcached_ldflags="-L$withval/lib"
		with_libmemcached="yes"
	else
		with_libmemcached="$withval"
	fi
],
[
	with_libmemcached="yes"
])
if test "x$with_libmemcached" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"

	AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libmemcached" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
	LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"

	AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libmemcached" = "xyes"
then
	BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
	BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
	BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
	AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
	AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
fi
AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
# }}}

# --with-libmodbus {{{
with_libmodbus_config=""
with_libmodbus_cflags=""
with_libmodbus_libs=""
AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
[
	if test "x$withval" = "xno"
	then
		with_libmodbus="no"
	else if test "x$withval" = "xyes"
	then
		with_libmodbus="use_pkgconfig"
	else if test -d "$with_libmodbus/lib"
	then
		AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
		with_libmodbus_cflags="-I$withval/include"
		with_libmodbus_libs="-L$withval/lib -lmodbus"
		with_libmodbus="yes"
	fi; fi; fi
],
[with_libmodbus="use_pkgconfig"])

# configure using pkg-config
if test "x$with_libmodbus" = "xuse_pkgconfig"
then
	if test "x$PKG_CONFIG" = "x"
	then
		with_libmodbus="no (Don't have pkg-config)"
	fi
fi
if test "x$with_libmodbus" = "xuse_pkgconfig"
then
	AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
	$PKG_CONFIG --exists 'libmodbus' 2>/dev/null
	if test $? -ne 0
	then
		with_libmodbus="no (pkg-config doesn't know libmodbus)"
	fi
fi
if test "x$with_libmodbus" = "xuse_pkgconfig"
then
	with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
	if test $? -ne 0
	then
		with_libmodbus="no ($PKG_CONFIG failed)"
	fi
	with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
	if test $? -ne 0
	then
		with_libmodbus="no ($PKG_CONFIG failed)"
	fi
fi
if test "x$with_libmodbus" = "xuse_pkgconfig"
then
	with_libmodbus="yes"
fi

# with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
# the actual checks.
if test "x$with_libmodbus" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"

	AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libmodbus" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
	LDFLAGS="$LDFLAGS $with_libmodbus_libs"

	AC_CHECK_LIB(modbus, modbus_connect,
		     [with_libmodbus="yes"],
		     [with_libmodbus="no (symbol modbus_connect not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libmodbus" = "xyes"
then
	BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
	BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
	AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
fi
# }}}

# --with-libmongoc {{{
AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
[
 if test "x$withval" = "xyes"
 then
	 with_libmongoc="yes"
 else if test "x$withval" = "xno"
 then
	 with_libmongoc="no"
 else
	 with_libmongoc="yes"
	 LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
	 LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
 fi; fi
],
[with_libmongoc="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"

if test "x$with_libmongoc" = "xyes"
then
	if test "x$LIBMONGOC_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(mongo.h,
	[with_libmongoc="yes"],
	[with_libmongoc="no ('mongo.h' not found)"],
[#if HAVE_STDINT_H
# define MONGO_HAVE_STDINT 1
#else
# define MONGO_USE_LONG_LONG_INT 1
#endif
])
fi
if test "x$with_libmongoc" = "xyes"
then
	if test "x$LIBMONGOC_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
	fi
	AC_CHECK_LIB(mongoc, mongo_run_command,
	[with_libmongoc="yes"],
	[with_libmongoc="no (symbol 'mongo_run_command' not found)"])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libmongoc" = "xyes"
then
	BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
	BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
# }}}

# --with-libmysql {{{
with_mysql_config="mysql_config"
with_mysql_cflags=""
with_mysql_libs=""
AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
[
	if test "x$withval" = "xno"
	then
		with_libmysql="no"
	else if test "x$withval" = "xyes"
	then
		with_libmysql="yes"
	else
		if test -f "$withval" && test -x "$withval";
		then
			with_mysql_config="$withval"
		else if test -x "$withval/bin/mysql_config"
		then
			with_mysql_config="$withval/bin/mysql_config"
		fi; fi
		with_libmysql="yes"
	fi; fi
],
[
	with_libmysql="yes"
])
if test "x$with_libmysql" = "xyes"
then
	with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
	mysql_config_status=$?

	if test $mysql_config_status -ne 0
	then
		with_libmysql="no ($with_mysql_config failed)"
	else
		SAVE_CPPFLAGS="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $with_mysql_cflags"

		have_mysql_h="no"
		have_mysql_mysql_h="no"
		AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])

		if test "x$have_mysql_h" = "xno"
		then
			AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
		fi

		if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
		then
			with_libmysql="no (mysql.h not found)"
		fi

		CPPFLAGS="$SAVE_CPPFLAGS"
	fi
fi
if test "x$with_libmysql" = "xyes"
then
	with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
	mysql_config_status=$?

	if test $mysql_config_status -ne 0
	then
		with_libmysql="no ($with_mysql_config failed)"
	else
		AC_CHECK_LIB(mysqlclient, mysql_init,
		 [with_libmysql="yes"],
		 [with_libmysql="no (symbol 'mysql_init' not found)"],
		 [$with_mysql_libs])

		AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
		 [with_libmysql="yes"],
		 [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
		 [$with_mysql_libs])
	fi
fi
if test "x$with_libmysql" = "xyes"
then
	BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
	BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
	AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
# }}}

# --with-libmnl {{{
with_libmnl_cflags=""
with_libmnl_libs=""
AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
[
 echo "libmnl: withval = $withval"
 if test "x$withval" = "xyes"
 then
	 with_libmnl="yes"
 else if test "x$withval" = "xno"
 then
	 with_libmnl="no"
 else
	 if test -d "$withval/include"
	 then
		 with_libmnl_cflags="-I$withval/include"
		 with_libmnl_libs="-L$withval/lib -lmnl"
		 with_libmnl="yes"
	 else
		 AC_MSG_ERROR("no such directory: $withval/include")
	 fi
 fi; fi
],
[
 if test "x$ac_system" = "xLinux"
 then
	 with_libmnl="yes"
 else
	 with_libmnl="no (Linux only library)"
 fi
])
if test "x$PKG_CONFIG" = "x"
then
	with_libmnl="no (Don't have pkg-config)"
fi
if test "x$with_libmnl" = "xyes"
then
	if $PKG_CONFIG --exists libmnl 2>/dev/null; then
	  with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
	  with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
	fi

	AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
	[
	 with_libmnl="yes"
	 break
	], [],
[#include <stdio.h>
#include <sys/types.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>])
	AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
[#include <stdio.h>
#include <sys/types.h>
#include <asm/types.h>
#include <sys/socket.h>])

        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <sys/types.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
]],
[[
int retval = TCA_STATS2;
return (retval);
]]
	)],
	[AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])

	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <sys/types.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
]],
[[
int retval = TCA_STATS;
return (retval);
]]
	)],
	[AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
fi
if test "x$with_libmnl" = "xyes"
then
	AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
	[AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
	[],
	[
	#include <linux/if_link.h>
	])
fi
if test "x$with_libmnl" = "xyes"
then
	AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
		     [with_libmnl="yes"],
		     [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
		     [$with_libmnl_libs])
fi
if test "x$with_libmnl" = "xyes"
then
	AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
	BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
	BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
	AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
# }}}

# --with-libnetapp {{{
AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
[
 if test -d "$withval"
 then
	 LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
	 LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
	 with_libnetapp="yes"
 else
	 with_libnetapp="$withval"
 fi
],
[
 with_libnetapp="yes"
])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"

if test "x$with_libnetapp" = "xyes"
then
	if test "x$LIBNETAPP_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(netapp_api.h,
		[with_libnetapp="yes"],
		[with_libnetapp="no (netapp_api.h not found)"])
fi

if test "x$with_libnetapp" = "xyes"
then
	if test "x$LIBNETAPP_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
	fi

	if test "x$LIBNETAPP_LIBS" = "x"
	then
		LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
	fi
	AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])

	AC_CHECK_LIB(netapp, na_server_invoke_elem,
		[with_libnetapp="yes"],
		[with_libnetapp="no (symbol na_server_invoke_elem not found)"],
		[$LIBNETAPP_LIBS])
	LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libnetapp" = "xyes"
then
	AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
fi

AC_SUBST(LIBNETAPP_CPPFLAGS)
AC_SUBST(LIBNETAPP_LDFLAGS)
AC_SUBST(LIBNETAPP_LIBS)
AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
# }}}

# --with-libnetsnmp {{{
with_snmp_config="net-snmp-config"
with_snmp_cflags=""
with_snmp_libs=""
AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
[
	if test "x$withval" = "xno"
	then
		with_libnetsnmp="no"
	else if test "x$withval" = "xyes"
	then
		with_libnetsnmp="yes"
	else
		if test -x "$withval"
		then
			with_snmp_config="$withval"
			with_libnetsnmp="yes"
		else
			with_snmp_config="$withval/bin/net-snmp-config"
			with_libnetsnmp="yes"
		fi
	fi; fi
],
[with_libnetsnmp="yes"])
if test "x$with_libnetsnmp" = "xyes"
then
	with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
	snmp_config_status=$?

	if test $snmp_config_status -ne 0
	then
		with_libnetsnmp="no ($with_snmp_config failed)"
	else
		SAVE_CPPFLAGS="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $with_snmp_cflags"

		AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])

		CPPFLAGS="$SAVE_CPPFLAGS"
	fi
fi
if test "x$with_libnetsnmp" = "xyes"
then
	with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
	snmp_config_status=$?

	if test $snmp_config_status -ne 0
	then
		with_libnetsnmp="no ($with_snmp_config failed)"
	else
		AC_CHECK_LIB(netsnmp, init_snmp,
		[with_libnetsnmp="yes"],
		[with_libnetsnmp="no (libnetsnmp not found)"],
		[$with_snmp_libs])
	fi
fi
if test "x$with_libnetsnmp" = "xyes"
then
	BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
	BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
	AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
# }}}

# --with-liboconfig {{{
with_own_liboconfig="no"
liboconfig_LDFLAGS="$LDFLAGS"
liboconfig_CPPFLAGS="$CPPFLAGS"
AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		if test -d "$withval/lib"
		then
			liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
		fi
		if test -d "$withval/include"
		then
			liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
		fi
	fi
	if test "x$withval" = "xno"
	then
		AC_MSG_ERROR("liboconfig is required")
	fi
],
[
	with_liboconfig="yes"
])

save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
LDFLAGS="$liboconfig_LDFLAGS"
CPPFLAGS="$liboconfig_CPPFLAGS"
AC_CHECK_LIB(oconfig, oconfig_parse_fh,
[
	with_liboconfig="yes"
	with_own_liboconfig="no"
],
[
	with_liboconfig="yes"
	with_own_liboconfig="yes"
	LDFLAGS="$save_LDFLAGS"
	CPPFLAGS="$save_CPPFLAGS"
])

AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
if test "x$with_own_liboconfig" = "xyes"
then
	with_liboconfig="yes (shipped version)"
fi
# }}}

# --with-liboping {{{
AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
[
 if test "x$withval" = "xyes"
 then
	 with_liboping="yes"
 else if test "x$withval" = "xno"
 then
	 with_liboping="no"
 else
	 with_liboping="yes"
	 LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
	 LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
 fi; fi
],
[with_liboping="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"

if test "x$with_liboping" = "xyes"
then
	if test "x$LIBOPING_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(oping.h,
	[with_liboping="yes"],
	[with_liboping="no (oping.h not found)"])
fi
if test "x$with_liboping" = "xyes"
then
	if test "x$LIBOPING_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
	fi
	AC_CHECK_LIB(oping, ping_construct,
	[with_liboping="yes"],
	[with_liboping="no (symbol 'ping_construct' not found)"])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_liboping" = "xyes"
then
	BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
	BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
# }}}

# --with-oracle {{{
with_oracle_cppflags=""
with_oracle_libs=""
AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
[
	if test "x$withval" = "xyes"
	then
		if test "x$ORACLE_HOME" = "x"
		then
			AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
		fi
		with_oracle="yes"
	else if test "x$withval" = "xno"
	then
		with_oracle="no"
	else
		with_oracle="yes"
		ORACLE_HOME="$withval"
	fi; fi
],
[
	if test "x$ORACLE_HOME" = "x"
	then
		with_oracle="no (ORACLE_HOME is not set)"
	else
		with_oracle="yes"
	fi
])
if test "x$ORACLE_HOME" != "x"
then
	with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"

	if test -e "$ORACLE_HOME/lib/ldflags"
	then
		with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
	fi
	#with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
	with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
fi
if test "x$with_oracle" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"

	AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_oracle" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LIBS="$LIBS"
	CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
	LIBS="$LIBS $with_oracle_libs"

	AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LIBS="$SAVE_LIBS"
fi
if test "x$with_oracle" = "xyes"
then
	BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
	BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
	AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
	AC_SUBST(BUILD_WITH_ORACLE_LIBS)
fi
# }}}

# --with-libowcapi {{{
with_libowcapi_cppflags=""
with_libowcapi_libs="-lowcapi"
AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_libowcapi_cppflags="-I$withval/include"
		with_libowcapi_libs="-L$withval/lib -lowcapi"
		with_libowcapi="yes"
	else
		with_libowcapi="$withval"
	fi
],
[
	with_libowcapi="yes"
])
if test "x$with_libowcapi" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$with_libowcapi_cppflags"

	AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libowcapi" = "xyes"
then
	SAVE_LDFLAGS="$LDFLAGS"
	SAVE_CPPFLAGS="$CPPFLAGS"
	LDFLAGS="$with_libowcapi_libs"
	CPPFLAGS="$with_libowcapi_cppflags"

	AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])

	LDFLAGS="$SAVE_LDFLAGS"
	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libowcapi" = "xyes"
then
	BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
	BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
	AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
fi
# }}}

# --with-libpcap {{{
AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		LDFLAGS="$LDFLAGS -L$withval/lib"
		CPPFLAGS="$CPPFLAGS -I$withval/include"
		with_libpcap="yes"
	else
		with_libpcap="$withval"
	fi
],
[
	with_libpcap="yes"
])
if test "x$with_libpcap" = "xyes"
then
	AC_CHECK_LIB(pcap, pcap_open_live,
	[
		AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
	], [with_libpcap="no (libpcap not found)"])
fi
if test "x$with_libpcap" = "xyes"
then
	AC_CHECK_HEADERS(pcap.h,,
			 [with_libpcap="no (pcap.h not found)"])
fi
if test "x$with_libpcap" = "xyes"
then
	AC_CHECK_HEADERS(pcap-bpf.h,,
			 [with_libpcap="no (pcap-bpf.h not found)"])
fi
if test "x$with_libpcap" = "xyes"
then
	AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
		       [c_cv_libpcap_have_pcap_error_iface_not_up],
		       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[[
#include <pcap.h>
]]],
[[[
  int val = PCAP_ERROR_IFACE_NOT_UP;
  return(val);
]]]
		       )],
		       [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
		       [c_cv_libpcap_have_pcap_error_iface_not_up="no"]))
fi
if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"
then
		with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
fi
AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
# }}}

# --with-libperl {{{
perl_interpreter="perl"
AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
[
	if test -f "$withval" && test -x "$withval"
	then
		perl_interpreter="$withval"
		with_libperl="yes"
	else if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		LDFLAGS="$LDFLAGS -L$withval/lib"
		CPPFLAGS="$CPPFLAGS -I$withval/include"
		perl_interpreter="$withval/bin/perl"
		with_libperl="yes"
	else
		with_libperl="$withval"
	fi; fi
],
[
	with_libperl="yes"
])

AC_MSG_CHECKING([for perl])
perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
if test -x "$perl_interpreter"
then
	AC_MSG_RESULT([yes ($perl_interpreter)])
else
	perl_interpreter=""
	AC_MSG_RESULT([no])
fi

AC_SUBST(PERL, "$perl_interpreter")

if test "x$with_libperl" = "xyes" \
	&& test -n "$perl_interpreter"
then
  SAVE_CFLAGS="$CFLAGS"
  SAVE_LIBS="$LIBS"
dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
  PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
  PERL_LIBS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
  CFLAGS="$CFLAGS $PERL_CFLAGS"
  LIBS="$LIBS $PERL_LIBS"

  AC_CACHE_CHECK([for libperl],
    [c_cv_have_libperl],
    AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#define PERL_NO_GET_CONTEXT
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
]]],
[[[
       dTHX;
       load_module (PERL_LOADMOD_NOIMPORT,
			 newSVpv ("Collectd::Plugin::FooBar", 24),
			 Nullsv);
]]]
      )],
      [c_cv_have_libperl="yes"],
      [c_cv_have_libperl="no"]
    )
  )

  if test "x$c_cv_have_libperl" = "xyes"
  then
	  AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
	  AC_SUBST(PERL_CFLAGS)
	  AC_SUBST(PERL_LIBS)
  else
	  with_libperl="no"
  fi

  CFLAGS="$SAVE_CFLAGS"
  LIBS="$SAVE_LIBS"
else if test -z "$perl_interpreter"; then
  with_libperl="no (no perl interpreter found)"
  c_cv_have_libperl="no"
fi; fi
AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")

if test "x$with_libperl" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	SAVE_LIBS="$LIBS"
	CFLAGS="$CFLAGS $PERL_CFLAGS"
	LIBS="$LIBS $PERL_LIBS"

	AC_CACHE_CHECK([if perl supports ithreads],
		[c_cv_have_perl_ithreads],
		AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>

#if !defined(USE_ITHREADS)
# error "Perl does not support ithreads!"
#endif /* !defined(USE_ITHREADS) */
]]],
[[[ ]]]
			)],
			[c_cv_have_perl_ithreads="yes"],
			[c_cv_have_perl_ithreads="no"]
		)
	)

	if test "x$c_cv_have_perl_ithreads" = "xyes"
	then
		AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
	fi

	CFLAGS="$SAVE_CFLAGS"
	LIBS="$SAVE_LIBS"
fi

if test "x$with_libperl" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	SAVE_LIBS="$LIBS"
	# trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
	# (see issues #41 and #42)
	CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
	LIBS="$LIBS $PERL_LIBS"

	AC_CACHE_CHECK([for broken Perl_load_module()],
		[c_cv_have_broken_perl_load_module],
		AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#define PERL_NO_GET_CONTEXT
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
]]],
[[[
			 dTHX;
			 load_module (PERL_LOADMOD_NOIMPORT,
			     newSVpv ("Collectd::Plugin::FooBar", 24),
			     Nullsv);
]]]
			)],
			[c_cv_have_broken_perl_load_module="no"],
			[c_cv_have_broken_perl_load_module="yes"]
		)
	)

	CFLAGS="$SAVE_CFLAGS"
	LIBS="$SAVE_LIBS"
fi
AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
		test "x$c_cv_have_broken_perl_load_module" = "xyes")

if test "x$with_libperl" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	SAVE_LIBS="$LIBS"
	CFLAGS="$CFLAGS $PERL_CFLAGS"
	LIBS="$LIBS $PERL_LIBS"

	AC_CHECK_MEMBER(
		[struct mgvtbl.svt_local],
		[have_struct_mgvtbl_svt_local="yes"],
		[have_struct_mgvtbl_svt_local="no"],
		[
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
		])

	if test "x$have_struct_mgvtbl_svt_local" = "xyes"
	then
		AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
				  [Define if Perl's struct mgvtbl has member svt_local.])
	fi

	CFLAGS="$SAVE_CFLAGS"
	LIBS="$SAVE_LIBS"
fi
# }}}

# --with-libpq {{{
with_pg_config="pg_config"
with_libpq_includedir=""
with_libpq_libdir=""
with_libpq_cppflags=""
with_libpq_ldflags=""
AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
	[Path to libpq.])],
[
	if test "x$withval" = "xno"
	then
		with_libpq="no"
	else if test "x$withval" = "xyes"
	then
		with_libpq="yes"
	else
		if test -f "$withval" && test -x "$withval";
		then
			with_pg_config="$withval"
		else if test -x "$withval/bin/pg_config"
		then
			with_pg_config="$withval/bin/pg_config"
		fi; fi
		with_libpq="yes"
	fi; fi
],
[
	with_libpq="yes"
])
if test "x$with_libpq" = "xyes"
then
	with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
	pg_config_status=$?

	if test $pg_config_status -eq 0
	then
		if test -n "$with_libpq_includedir"; then
			for dir in $with_libpq_includedir; do
				with_libpq_cppflags="$with_libpq_cppflags -I$dir"
			done
		fi
	else
		AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
	fi

	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"

	AC_CHECK_HEADERS(libpq-fe.h, [],
		[with_libpq="no (libpq-fe.h not found)"], [])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libpq" = "xyes"
then
	with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
	pg_config_status=$?

	if test $pg_config_status -eq 0
	then
		if test -n "$with_libpq_libdir"; then
			for dir in $with_libpq_libdir; do
				with_libpq_ldflags="$with_libpq_ldflags -L$dir"
			done
		fi
	else
		AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
	fi

	SAVE_LDFLAGS="$LDFLAGS"
	LDFLAGS="$LDFLAGS $with_libpq_ldflags"

	AC_CHECK_LIB(pq, PQconnectdb,
		[with_libpq="yes"],
		[with_libpq="no (symbol 'PQconnectdb' not found)"])

	AC_CHECK_LIB(pq, PQserverVersion,
		[with_libpq="yes"],
		[with_libpq="no (symbol 'PQserverVersion' not found)"])

	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libpq" = "xyes"
then
	BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
	BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
	AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
# }}}

# --with-libpthread {{{
AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
[	if test "x$withval" != "xno" \
		&& test "x$withval" != "xyes"
	then
		LDFLAGS="$LDFLAGS -L$withval/lib"
		CPPFLAGS="$CPPFLAGS -I$withval/include"
		with_libpthread="yes"
	else
		if test "x$withval" = "xno"
		then
			with_libpthread="no (disabled)"
		fi
	fi
], [with_libpthread="yes"])
if test "x$with_libpthread" = "xyes"
then
	AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
fi

if test "x$with_libpthread" = "xyes"
then
	AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
fi
if test "x$with_libpthread" = "xyes"
then
	collect_pthread=1
else
	collect_pthread=0
fi
AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
	[Wether or not to use pthread (POSIX threads) library])
AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
# }}}

# --with-python {{{
with_python_prog=""
with_python_path="$PATH"
AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
[
 if test "x$withval" = "xyes" || test "x$withval" = "xno"
 then
	 with_python="$withval"
 else if test -x "$withval"
 then
	 with_python_prog="$withval"
	 with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
	 with_python="yes"
 else if test -d "$withval"
 then
	 with_python_path="$withval$PATH_SEPARATOR$with_python_path"
	 with_python="yes"
 else
	 AC_MSG_WARN([Argument not recognized: $withval])
 fi; fi; fi
], [with_python="yes"])

SAVE_PATH="$PATH"
SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
SAVE_LIBS="$LIBS"

PATH="$with_python_path"

if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
then
	AC_MSG_CHECKING([for python])
	with_python_prog="`which python 2>/dev/null`"
	if test "x$with_python_prog" = "x"
	then
		AC_MSG_RESULT([not found])
		with_python="no (interpreter not found)"
	else
		AC_MSG_RESULT([$with_python_prog])
	fi
fi

if test "x$with_python" = "xyes"
then
	AC_MSG_CHECKING([for Python CPPFLAGS])
	python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
	python_config_status=$?

	if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
	then
		AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
		with_python="no"
	else
		AC_MSG_RESULT([$python_include_path])
	fi
fi

if test "x$with_python" = "xyes"
then
	CPPFLAGS="-I$python_include_path $CPPFLAGS"
	AC_CHECK_HEADERS(Python.h,
			 [with_python="yes"],
			 [with_python="no ('Python.h' not found)"])
fi

if test "x$with_python" = "xyes"
then
	AC_MSG_CHECKING([for Python LDFLAGS])
	python_library_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"LIBDIR\").__getitem__(0))" | "$with_python_prog" 2>&1`
	python_config_status=$?

	if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
	then
		AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
		with_python="no"
	else
		AC_MSG_RESULT([$python_library_path])
	fi
fi

if test "x$with_python" = "xyes"
then
	AC_MSG_CHECKING([for Python LIBS])
	python_library_flags=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_config_vars(\"BLDLIBRARY\").__getitem__(0))" | "$with_python_prog" 2>&1`
	python_config_status=$?

	if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
	then
		AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
		with_python="no"
	else
		AC_MSG_RESULT([$python_library_flags])
	fi
fi

if test "x$with_python" = "xyes"
then
	LDFLAGS="-L$python_library_path $LDFLAGS"
	LIBS="$python_library_flags $LIBS"

	AC_CHECK_FUNC(PyObject_CallFunction,
		      [with_python="yes"],
		      [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
fi

PATH="$SAVE_PATH"
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
LIBS="$SAVE_LIBS"

if test "x$with_python" = "xyes"
then
	BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
	BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
	BUILD_WITH_PYTHON_LIBS="$python_library_flags"
	AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
	AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
	AC_SUBST(BUILD_WITH_PYTHON_LIBS)
fi
# }}} --with-python

# --with-librabbitmq {{{
with_librabbitmq_cppflags=""
with_librabbitmq_ldflags=""
AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_librabbitmq_cppflags="-I$withval/include"
		with_librabbitmq_ldflags="-L$withval/lib"
		with_librabbitmq="yes"
	else
		with_librabbitmq="$withval"
	fi
],
[
	with_librabbitmq="yes"
])
SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
if test "x$with_librabbitmq" = "xyes"
then
	AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
fi
if test "x$with_librabbitmq" = "xyes"
then
	# librabbitmq up to version 0.9.1 provides "library_errno", later
	# versions use "library_error". The library does not provide a version
	# macro :( Use "AC_CHECK_MEMBERS" (plural) for automatic defines.
	AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],,,
			 [
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STDIO_H
# include <stdio.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <amqp.h>
                         ])
fi
if test "x$with_librabbitmq" = "xyes"
then
	AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
fi
if test "x$with_librabbitmq" = "xyes"
then
	BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
	BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
	BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
	AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
	AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
fi
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")

with_amqp_tcp_socket="no"
if test "x$with_librabbitmq" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	SAVE_LIBS="$LIBS"
	CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
	LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
	LIBS="-lrabbitmq"

	AC_CHECK_HEADERS(amqp_tcp_socket.h amqp_socket.h)
	AC_CHECK_FUNC(amqp_tcp_socket_new, [with_amqp_tcp_socket="yes"], [with_amqp_tcp_socket="no"])
	if test "x$with_amqp_tcp_socket" = "xyes"
	then
		AC_DEFINE(HAVE_AMQP_TCP_SOCKET, 1,
				[Define if librabbitmq provides the new TCP socket interface.])
	fi

	AC_CHECK_DECLS(amqp_socket_close,
				[amqp_socket_close_decl="yes"], [amqp_socket_close_decl="no"],
				[[
#include <amqp.h>
#ifdef HAVE_AMQP_TCP_SOCKET_H
# include <amqp_tcp_socket.h>
#endif
#ifdef HAVE_AMQP_SOCKET_H
# include <amqp_socket.h>
#endif
				]])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
	LIBS="$SAVE_LIBS"
fi
# }}}

# --with-librdkafka {{{
AC_ARG_WITH(librdkafka, [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
[
  if test "x$withval" != "xno" && test "x$withval" != "xyes"
  then
    with_librdkafka_cppflags="-I$withval/include"
    with_librdkafka_ldflags="-L$withval/lib"
    with_librdkafka_rpath="$withval/lib"
    with_librdkafka="yes"
  else
    with_librdkafka="$withval"
  fi
],
[
  with_librdkafka="yes"
])
SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"

if test "x$with_librdkafka" = "xyes"
then
	AC_CHECK_HEADERS(librdkafka/rdkafka.h, [with_librdkafka="yes"], [with_librdkafka="no (librdkafka/rdkafka.h not found)"])
fi

if test "x$with_librdkafka" = "xyes"
then
	AC_CHECK_LIB(rdkafka, rd_kafka_new, [with_librdkafka="yes"], [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
  AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_log_cb, [with_librdkafka_log_cb="yes"], [with_librdkafka_log_cb="no"])
  AC_CHECK_LIB(rdkafka, rd_kafka_set_logger, [with_librdkafka_logger="yes"], [with_librdkafka_logger="no"])
fi
if test "x$with_librdkafka" = "xyes"
then
	BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
	BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
	if test "x$with_librdkafka_rpath" != "x"
	then
		BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
	else
		BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
	fi
	AC_SUBST(BUILD_WITH_LIBRDKAFKA_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBRDKAFKA_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBRDKAFKA_LIBS)
	AC_DEFINE(HAVE_LIBRDKAFKA, 1, [Define if librdkafka is present and usable.])
  if test "x$with_librdkafka_log_cb" = "xyes"
  then
        AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
  fi
  if test "x$with_librdkafka_logger" = "xyes"
  then
        AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
  fi
fi
CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
AM_CONDITIONAL(BUILD_WITH_LIBRDKAFKA, test "x$with_librdkafka" = "xyes")

# }}}

# --with-librouteros {{{
AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
[
 if test "x$withval" = "xyes"
 then
	 with_librouteros="yes"
 else if test "x$withval" = "xno"
 then
	 with_librouteros="no"
 else
	 with_librouteros="yes"
	 LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
	 LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
 fi; fi
],
[with_librouteros="yes"])

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"

CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"

if test "x$with_librouteros" = "xyes"
then
	if test "x$LIBROUTEROS_CPPFLAGS" != "x"
	then
		AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
	fi
	AC_CHECK_HEADERS(routeros_api.h,
	[with_librouteros="yes"],
	[with_librouteros="no (routeros_api.h not found)"])
fi
if test "x$with_librouteros" = "xyes"
then
	if test "x$LIBROUTEROS_LDFLAGS" != "x"
	then
		AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
	fi
	AC_CHECK_LIB(routeros, ros_interface,
	[with_librouteros="yes"],
	[with_librouteros="no (symbol 'ros_interface' not found)"])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_librouteros" = "xyes"
then
	BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
	BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
	AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
# }}}

# --with-librrd {{{
# AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
librrd_cflags=""
librrd_ldflags=""
librrd_threadsafe="yes"
librrd_rrdc_update="no"
AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
[	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		librrd_cflags="-I$withval/include"
		librrd_ldflags="-L$withval/lib"
		with_librrd="yes"
	else
		with_librrd="$withval"
	fi
], [with_librrd="yes"])
if test "x$with_librrd" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CPPFLAGS="$CPPFLAGS $librrd_cflags"
	LDFLAGS="$LDFLAGS $librrd_ldflags"

	AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_librrd" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CPPFLAGS="$CPPFLAGS $librrd_cflags"
	LDFLAGS="$LDFLAGS $librrd_ldflags"

	AC_CHECK_LIB(rrd_th, rrd_update_r,
	[with_librrd="yes"
	 librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
	],
	[librrd_threadsafe="no"
	 AC_CHECK_LIB(rrd, rrd_update,
	 [with_librrd="yes"
	  librrd_ldflags="$librrd_ldflags -lrrd -lm"
	 ],
	 [with_librrd="no (symbol 'rrd_update' not found)"],
	 [-lm])
	],
	[-lm])

	if test "x$librrd_threadsafe" = "xyes"
	then
		AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
	else
		AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
	fi

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_librrd" = "xyes"
then
	BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
	BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
	AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
fi
if test "x$librrd_threadsafe" = "xyes"
then
	AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
fi
# }}}

# --with-libsensors {{{
with_sensors_cflags=""
with_sensors_ldflags=""
AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
[
	if test "x$withval" = "xno"
	then
		with_libsensors="no"
	else
		with_libsensors="yes"
		if test "x$withval" != "xyes"
		then
			with_sensors_cflags="-I$withval/include"
			with_sensors_ldflags="-L$withval/lib"
			with_libsensors="yes"
		fi
	fi
],
[
	if test "x$ac_system" = "xLinux"
	then
		with_libsensors="yes"
	else
		with_libsensors="no (Linux only library)"
	fi
])
if test "x$with_libsensors" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_sensors_cflags"

#	AC_CHECK_HEADERS(sensors/sensors.h,
#	[
#		AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
#	],
#	[with_libsensors="no (sensors/sensors.h not found)"])
	AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libsensors" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
	LDFLAGS="$LDFLAGS $with_sensors_ldflags"

	AC_CHECK_LIB(sensors, sensors_init,
	[
		AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
	],
	[with_libsensors="no (libsensors not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libsensors" = "xyes"
then
	BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
	BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
	AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
# }}}

# --with-libsigrok {{{
with_libsigrok_cflags=""
with_libsigrok_ldflags=""
AC_ARG_WITH(libsigrok, [AS_HELP_STRING([--with-libsigrok@<:@=PREFIX@:>@], [Path to libsigrok.])],
[
	if test "x$withval" = "xno"
	then
		with_libsigrok="no"
	else
		with_libsigrok="yes"
		if test "x$withval" != "xyes"
		then
			with_libsigrok_cflags="-I$withval/include"
			with_libsigrok_ldflags="-L$withval/lib"
		fi
	fi
],[with_libsigrok="yes"])

# libsigrok has a glib dependency
if test "x$with_libsigrok" = "xyes"
then
m4_ifdef([AM_PATH_GLIB_2_0],
	[
	 AM_PATH_GLIB_2_0([2.28.0],
	 	[with_libsigrok_cflags="$with_libsigrok_cflags $GLIB_CFLAGS"; with_libsigrok_ldflags="$with_libsigrok_ldflags $GLIB_LIBS"])
	],
	[
	 with_libsigrok="no (glib not available)"
	]
)
fi

# libsigrok headers
if test "x$with_libsigrok" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"

	AC_CHECK_HEADERS(libsigrok/libsigrok.h, [], [with_libsigrok="no (libsigrok/libsigrok.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi

# libsigrok library
if test "x$with_libsigrok" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
	LDFLAGS="$LDFLAGS $with_libsigrok_ldflags"

	AC_CHECK_LIB(sigrok, sr_init,
	[
		AC_DEFINE(HAVE_LIBSIGROK, 1, [Define to 1 if you have the sigrok library (-lsigrok).])
	],
	[with_libsigrok="no (libsigrok not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libsigrok" = "xyes"
then
	BUILD_WITH_LIBSIGROK_CFLAGS="$with_libsigrok_cflags"
	BUILD_WITH_LIBSIGROK_LDFLAGS="$with_libsigrok_ldflags"
	AC_SUBST(BUILD_WITH_LIBSIGROK_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBSIGROK_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBSIGROK, test "x$with_libsigrok" = "xyes")
# }}}

# --with-libstatgrab {{{
with_libstatgrab_cflags=""
with_libstatgrab_ldflags=""
AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
[
 if test "x$withval" != "xno" \
   && test "x$withval" != "xyes"
 then
   with_libstatgrab_cflags="-I$withval/include"
   with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
   with_libstatgrab="yes"
   with_libstatgrab_pkg_config="no"
 else
   with_libstatgrab="$withval"
   with_libstatgrab_pkg_config="yes"
 fi
 ],
[
 with_libstatgrab="yes"
 with_libstatgrab_pkg_config="yes"
])

if test "x$with_libstatgrab" = "xyes" \
  && test "x$with_libstatgrab_pkg_config" = "xyes"
then
  if test "x$PKG_CONFIG" != "x"
  then
    AC_MSG_CHECKING([pkg-config for libstatgrab])
    temp_result="found"
    $PKG_CONFIG --exists libstatgrab 2>/dev/null
    if test "$?" != "0"
    then
      with_libstatgrab_pkg_config="no"
      with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
      temp_result="not found"
    fi
    AC_MSG_RESULT([$temp_result])
  else
    AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
    with_libstatgrab_pkg_config="no"
    with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
  fi
fi

if test "x$with_libstatgrab" = "xyes" \
  && test "x$with_libstatgrab_pkg_config" = "xyes" \
  && test "x$with_libstatgrab_cflags" = "x"
then
  AC_MSG_CHECKING([for libstatgrab CFLAGS])
  temp_result="`$PKG_CONFIG --cflags libstatgrab`"
  if test "$?" = "0"
  then
    with_libstatgrab_cflags="$temp_result"
  else
    with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
    temp_result="$PKG_CONFIG --cflags libstatgrab failed"
  fi
  AC_MSG_RESULT([$temp_result])
fi

if test "x$with_libstatgrab" = "xyes" \
  && test "x$with_libstatgrab_pkg_config" = "xyes" \
  && test "x$with_libstatgrab_ldflags" = "x"
then
  AC_MSG_CHECKING([for libstatgrab LDFLAGS])
  temp_result="`$PKG_CONFIG --libs libstatgrab`"
  if test "$?" = "0"
  then
    with_libstatgrab_ldflags="$temp_result"
  else
    with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
    temp_result="$PKG_CONFIG --libs libstatgrab failed"
  fi
  AC_MSG_RESULT([$temp_result])
fi

if test "x$with_libstatgrab" = "xyes"
then
  SAVE_CPPFLAGS="$CPPFLAGS"
  CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"

  AC_CHECK_HEADERS(statgrab.h,
		   [with_libstatgrab="yes"],
		   [with_libstatgrab="no (statgrab.h not found)"])

  CPPFLAGS="$SAVE_CPPFLAGS"
fi

if test "x$with_libstatgrab" = "xyes"
then
  SAVE_CFLAGS="$CFLAGS"
  SAVE_LDFLAGS="$LDFLAGS"

  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"

  AC_CHECK_LIB(statgrab, sg_init,
	       [with_libstatgrab="yes"],
	       [with_libstatgrab="no (symbol sg_init not found)"])

  CFLAGS="$SAVE_CFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"
fi

if test "x$with_libstatgrab" = "xyes"
then
  SAVE_CFLAGS="$CFLAGS"
  SAVE_LIBS="$LIBS"

  CFLAGS="$CFLAGS $with_libstatgrab_cflags"
  LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
  LIBS="-lstatgrab $LIBS"

  AC_CACHE_CHECK([if libstatgrab >= 0.90],
          [c_cv_have_libstatgrab_0_90],
          AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[[
#include <stdio.h>
#include <statgrab.h>
]]],
[[[
      if (sg_init()) return 0;
]]]
    )],
    [c_cv_have_libstatgrab_0_90="no"],
    [c_cv_have_libstatgrab_0_90="yes"]
          )
  )

  CFLAGS="$SAVE_CFLAGS"
  LDFLAGS="$SAVE_LDFLAGS"
  LIBS="$SAVE_LIBS"
fi

AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
if test "x$with_libstatgrab" = "xyes"
then
  AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
  BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
  BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
  AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
  AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
  if test "x$c_cv_have_libstatgrab_0_90" = "xyes"
  then
        AC_DEFINE(HAVE_LIBSTATGRAB_0_90, 1, [Define to 1 if libstatgrab version >= 0.90])
  fi
fi
# }}}

# --with-libtokyotyrant {{{
with_libtokyotyrant_cppflags=""
with_libtokyotyrant_ldflags=""
with_libtokyotyrant_libs=""
AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
[
  if test "x$withval" = "xno"
  then
    with_libtokyotyrant="no"
  else if test "x$withval" = "xyes"
  then
    with_libtokyotyrant="yes"
  else
    with_libtokyotyrant_cppflags="-I$withval/include"
    with_libtokyotyrant_ldflags="-L$withval/include"
    with_libtokyotyrant_libs="-ltokyotyrant"
    with_libtokyotyrant="yes"
  fi; fi
],
[
  with_libtokyotyrant="yes"
])

if test "x$with_libtokyotyrant" = "xyes"
then
  if $PKG_CONFIG --exists tokyotyrant
  then
    with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
    with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
    with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
  fi
fi

SAVE_CPPFLAGS="$CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"

if test "x$with_libtokyotyrant" = "xyes"
then
  AC_CHECK_HEADERS(tcrdb.h,
  [
          AC_DEFINE(HAVE_TCRDB_H, 1,
                    [Define to 1 if you have the <tcrdb.h> header file.])
  ], [with_libtokyotyrant="no (tcrdb.h not found)"])
fi

if test "x$with_libtokyotyrant" = "xyes"
then
  AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
  [
          AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
                    [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
  ],
  [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
  [$with_libtokyotyrant_libs])
fi

CPPFLAGS="$SAVE_CPPFLAGS"
LDFLAGS="$SAVE_LDFLAGS"

if test "x$with_libtokyotyrant" = "xyes"
then
  BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
  BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
  BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
  AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
# }}}

# --with-libudev {{{
with_libudev_cflags=""
with_libudev_ldflags=""
AC_ARG_WITH(libudev, [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
[
	if test "x$withval" = "xno"
	then
		with_libudev="no"
	else
		with_libudev="yes"
		if test "x$withval" != "xyes"
		then
			with_libudev_cflags="-I$withval/include"
			with_libudev_ldflags="-L$withval/lib"
			with_libudev="yes"
		fi
	fi
],
[
	if test "x$ac_system" = "xLinux"
	then
		with_libudev="yes"
	else
		with_libudev="no (Linux only library)"
	fi
])
if test "x$with_libudev" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libudev_cflags"

	AC_CHECK_HEADERS(libudev.h, [], [with_libudev="no (libudev.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libudev" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libudev_cflags"
	LDFLAGS="$LDFLAGS $with_libudev_ldflags"

	AC_CHECK_LIB(udev, udev_new,
	[
		AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if you have the udev library (-ludev).])
	],
	[with_libudev="no (libudev not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libudev" = "xyes"
then
	BUILD_WITH_LIBUDEV_CFLAGS="$with_libudev_cflags"
	BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
	AC_SUBST(BUILD_WITH_LIBUDEV_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBUDEV_LDFLAGS)
fi
AM_CONDITIONAL(BUILD_WITH_LIBUDEV, test "x$with_libudev" = "xyes")
# }}}

# --with-libupsclient {{{
with_libupsclient_config=""
with_libupsclient_cflags=""
with_libupsclient_libs=""
AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
[
	if test "x$withval" = "xno"
	then
		with_libupsclient="no"
	else if test "x$withval" = "xyes"
	then
		with_libupsclient="use_pkgconfig"
	else
		if test -x "$withval"
		then
			with_libupsclient_config="$withval"
			with_libupsclient="use_libupsclient_config"
		else if test -x "$withval/bin/libupsclient-config"
		then
			with_libupsclient_config="$withval/bin/libupsclient-config"
			with_libupsclient="use_libupsclient_config"
		else
			AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
			with_libupsclient_cflags="-I$withval/include"
			with_libupsclient_libs="-L$withval/lib -lupsclient"
			with_libupsclient="yes"
		fi; fi
	fi; fi
],
[with_libupsclient="use_pkgconfig"])

# configure using libupsclient-config
if test "x$with_libupsclient" = "xuse_libupsclient_config"
then
	AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
	with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
	if test $? -ne 0
	then
		with_libupsclient="no ($with_libupsclient_config failed)"
	fi
	with_libupsclient_libs="`$with_libupsclient_config --libs`"
	if test $? -ne 0
	then
		with_libupsclient="no ($with_libupsclient_config failed)"
	fi
fi
if test "x$with_libupsclient" = "xuse_libupsclient_config"
then
	with_libupsclient="yes"
fi

# configure using pkg-config
if test "x$with_libupsclient" = "xuse_pkgconfig"
then
	if test "x$PKG_CONFIG" = "x"
	then
		with_libupsclient="no (Don't have pkg-config)"
	fi
fi
if test "x$with_libupsclient" = "xuse_pkgconfig"
then
	AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
	$PKG_CONFIG --exists 'libupsclient' 2>/dev/null
	if test $? -ne 0
	then
		with_libupsclient="no (pkg-config doesn't know libupsclient)"
	fi
fi
if test "x$with_libupsclient" = "xuse_pkgconfig"
then
	with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
	if test $? -ne 0
	then
		with_libupsclient="no ($PKG_CONFIG failed)"
	fi
	with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
	if test $? -ne 0
	then
		with_libupsclient="no ($PKG_CONFIG failed)"
	fi
fi
if test "x$with_libupsclient" = "xuse_pkgconfig"
then
	with_libupsclient="yes"
fi

# with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
# the actual checks.
if test "x$with_libupsclient" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"

	AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libupsclient" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
	LDFLAGS="$LDFLAGS $with_libupsclient_libs"

	AC_CHECK_LIB(upsclient, upscli_connect,
		     [with_libupsclient="yes"],
		     [with_libupsclient="no (symbol upscli_connect not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libupsclient" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"

	AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
[#include <stdlib.h>
#include <stdio.h>
#include <upsclient.h>])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libupsclient" = "xyes"
then
	BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
	BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
	AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
fi
# }}}

# --with-libxmms {{{
with_xmms_config="xmms-config"
with_xmms_cflags=""
with_xmms_libs=""
AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
[
	if test "x$withval" != "xno" \
		&& test "x$withval" != "xyes"
	then
		if test -f "$withval" && test -x "$withval";
		then
			with_xmms_config="$withval"
		else if test -x "$withval/bin/xmms-config"
		then
			with_xmms_config="$withval/bin/xmms-config"
		fi; fi
		with_libxmms="yes"
	else if test "x$withval" = "xno"
	then
		with_libxmms="no"
	else
		with_libxmms="yes"
	fi; fi
],
[
	with_libxmms="yes"
])
if test "x$with_libxmms" = "xyes"
then
	with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
	xmms_config_status=$?

	if test $xmms_config_status -ne 0
	then
		with_libxmms="no"
	fi
fi
if test "x$with_libxmms" = "xyes"
then
	with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
	xmms_config_status=$?

	if test $xmms_config_status -ne 0
	then
		with_libxmms="no"
	fi
fi
if test "x$with_libxmms" = "xyes"
then
	AC_CHECK_LIB(xmms, xmms_remote_get_info,
	[
		BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
		BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
		AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
		AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
	],
	[
		with_libxmms="no"
	],
	[$with_xmms_libs])
fi
with_libxmms_numeric=0
if test "x$with_libxmms" = "xyes"
then
	with_libxmms_numeric=1
fi
AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
# }}}

# --with-libyajl {{{
with_libyajl_cppflags=""
with_libyajl_ldflags=""
AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_libyajl_cppflags="-I$withval/include"
		with_libyajl_ldflags="-L$withval/lib"
		with_libyajl="yes"
	else
		with_libyajl="$withval"
	fi
],
[
	with_libyajl="yes"
])
if test "x$with_libyajl" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"

	AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
	AC_CHECK_HEADERS(yajl/yajl_version.h)

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libyajl" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
	LDFLAGS="$LDFLAGS $with_libyajl_ldflags"

	AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libyajl" = "xyes"
then
	BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
	BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
	BUILD_WITH_LIBYAJL_LIBS="-lyajl"
	AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
	AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
fi
AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
# }}}

# --with-mic {{{
with_mic_cflags="-I/opt/intel/mic/sysmgmt/sdk/include"
with_mic_ldpath="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
with_mic_libs=""
AC_ARG_WITH(mic,[AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
[
	if test "x$withval" = "xno"
	then
		with_mic="no"
	else if test "x$withval" = "xyes"
	then
		with_mic="yes"
	else if test -d "$with_mic/lib"
	then
		AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
		with_mic_cflags="-I$withval/include"
		with_mic_ldpath="-L$withval/lib/Linux"
		with_mic_libs="-lMicAccessSDK -lscif -lpthread"
		with_mic="yes"
	fi; fi; fi
],
[with_mic="yes"])
if test "x$with_mic" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_mic_cflags"
	AC_CHECK_HEADERS(MicAccessApi.h,[],[with_mic="no (MicAccessApi not found)"])
	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_mic" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CPPFLAGS="$CPPFLAGS $with_mic_cflags"
	LDFLAGS="$LDFLAGS $with_mic_ldpath"

	AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
			[with_mic_ldpath="$with_mic_ldpath"
			with_mic_libs="-lMicAccessSDK -lscif -lpthread"],
			[with_mic="no (symbol MicInitAPI not found)"],[-lscif -lpthread])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi

if test "x$with_mic" = "xyes"
then
	BUILD_WITH_MIC_CPPFLAGS="$with_mic_cflags"
	BUILD_WITH_MIC_LIBPATH="$with_mic_ldpath"
	BUILD_WITH_MIC_LDADD="$with_mic_libs"
	AC_SUBST(BUILD_WITH_MIC_CPPFLAGS)
	AC_SUBST(BUILD_WITH_MIC_LIBPATH)
	AC_SUBST(BUILD_WITH_MIC_LDADD)
fi
#}}}

# --with-libvarnish {{{
with_libvarnish_cppflags=""
with_libvarnish_cflags=""
with_libvarnish_libs=""
AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
[
	if test "x$withval" = "xno"
	then
		with_libvarnish="no"
	else if test "x$withval" = "xyes"
	then
		with_libvarnish="use_pkgconfig"
	else if test -d "$with_libvarnish/lib"
	then
		AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
		with_libvarnish_cflags="-I$withval/include"
		with_libvarnish_libs="-L$withval/lib -lvarnishapi"
		with_libvarnish="yes"
	fi; fi; fi
],
[with_libvarnish="use_pkgconfig"])

# configure using pkg-config
if test "x$with_libvarnish" = "xuse_pkgconfig"
then
	if test "x$PKG_CONFIG" = "x"
	then
		with_libvarnish="no (Don't have pkg-config)"
	fi
fi
if test "x$with_libvarnish" = "xuse_pkgconfig"
then
	AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
	$PKG_CONFIG --exists 'varnishapi' 2>/dev/null
	if test $? -ne 0
	then
		with_libvarnish="no (pkg-config doesn't know varnishapi)"
	fi
fi
if test "x$with_libvarnish" = "xuse_pkgconfig"
then
	with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
	if test $? -ne 0
	then
		with_libvarnish="no ($PKG_CONFIG failed)"
	fi
	with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
	if test $? -ne 0
	then
		with_libvarnish="no ($PKG_CONFIG failed)"
	fi
fi
if test "x$with_libvarnish" = "xuse_pkgconfig"
then
	with_libvarnish="yes"
fi

# with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
# the actual checks.
if test "x$with_libvarnish" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"

	CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"

	AC_CHECK_HEADERS(varnish/vapi/vsc.h,
		[AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
		[AC_CHECK_HEADERS(varnish/vsc.h,
			[AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
			[AC_CHECK_HEADERS(varnish/varnishapi.h,
				[AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
				[with_libvarnish="no (found none of the varnish header files)"])])])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libvarnish" = "xyes"
then
	BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
	BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
	AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
fi
# }}}

# pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
with_libxml2="no (pkg-config isn't available)"
with_libxml2_cflags=""
with_libxml2_ldflags=""
with_libvirt="no (pkg-config isn't available)"
with_libvirt_cflags=""
with_libvirt_ldflags=""
if test "x$PKG_CONFIG" != "x"
then
	$PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
	if test "$?" = "0"
	then
		with_libxml2="yes"
	else
		with_libxml2="no (pkg-config doesn't know libxml-2.0)"
	fi

	$PKG_CONFIG --exists libvirt 2>/dev/null
	if test "$?" = "0"
	then
		with_libvirt="yes"
	else
		with_libvirt="no (pkg-config doesn't know libvirt)"
	fi
fi
if test "x$with_libxml2" = "xyes"
then
	with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
	if test $? -ne 0
	then
		with_libxml2="no"
	fi
	with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
	if test $? -ne 0
	then
		with_libxml2="no"
	fi
fi
if test "x$with_libxml2" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"

	AC_CHECK_HEADERS(libxml/parser.h, [],
		      [with_libxml2="no (libxml/parser.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libxml2" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CFLAGS="$CFLAGS $with_libxml2_cflags"
	LDFLAGS="$LDFLAGS $with_libxml2_ldflags"

	AC_CHECK_LIB(xml2, xmlXPathEval,
		     [with_libxml2="yes"],
		     [with_libxml2="no (symbol xmlXPathEval not found)"])

	CFLAGS="$SAVE_CFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
dnl Add the right compiler flags and libraries.
if test "x$with_libxml2" = "xyes"; then
	BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
	BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
	AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
fi
if test "x$with_libvirt" = "xyes"
then
	with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
	if test $? -ne 0
	then
		with_libvirt="no"
	fi
	with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
	if test $? -ne 0
	then
		with_libvirt="no"
	fi
fi
if test "x$with_libvirt" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"

	AC_CHECK_HEADERS(libvirt/libvirt.h, [],
		      [with_libvirt="no (libvirt/libvirt.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libvirt" = "xyes"
then
	SAVE_CFLAGS="$CFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"

	CFLAGS="$CFLAGS $with_libvirt_cflags"
	LDFLAGS="$LDFLAGS $with_libvirt_ldflags"

	AC_CHECK_LIB(virt, virDomainBlockStats,
		     [with_libvirt="yes"],
		     [with_libvirt="no (symbol virDomainBlockStats not found)"])

	CFLAGS="$SAVE_CFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
dnl Add the right compiler flags and libraries.
if test "x$with_libvirt" = "xyes"; then
	BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
	BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
	AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
	AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
fi
# }}}

# $PKG_CONFIG --exists OpenIPMIpthread {{{
with_libopenipmipthread="yes"
with_libopenipmipthread_cflags=""
with_libopenipmipthread_libs=""

AC_MSG_CHECKING([for pkg-config])
temp_result="no"
if test "x$PKG_CONFIG" = "x"
then
	with_libopenipmipthread="no"
	temp_result="no"
else
	temp_result="$PKG_CONFIG"
fi
AC_MSG_RESULT([$temp_result])

if test "x$with_libopenipmipthread" = "xyes"
then
	AC_MSG_CHECKING([for libOpenIPMIpthread])
	$PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
	if test "$?" != "0"
	then
		with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
	fi
	AC_MSG_RESULT([$with_libopenipmipthread])
fi

if test "x$with_libopenipmipthread" = "xyes"
then
	AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
	temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
	if test "$?" = "0"
	then
		with_libopenipmipthread_cflags="$temp_result"
	else
		with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
		temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
	fi
	AC_MSG_RESULT([$temp_result])
fi

if test "x$with_libopenipmipthread" = "xyes"
then
	AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
	temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
	if test "$?" = "0"
	then
		with_libopenipmipthread_ldflags="$temp_result"
	else
		with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
		temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
	fi
	AC_MSG_RESULT([$temp_result])
fi

if test "x$with_libopenipmipthread" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"

	AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
			 [with_libopenipmipthread="yes"],
			 [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
[#include <OpenIPMI/ipmiif.h>
#include <OpenIPMI/ipmi_err.h>
#include <OpenIPMI/ipmi_posix.h>
#include <OpenIPMI/ipmi_conn.h>
])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi

if test "x$with_libopenipmipthread" = "xyes"
then
	BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
	BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
	AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
	AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
fi
# }}}

# --with-libatasmart {{{
with_libatasmart_cppflags=""
with_libatasmart_ldflags=""
AC_ARG_WITH(libatasmart, [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		with_libatasmart_cppflags="-I$withval/include"
		with_libatasmart_ldflags="-L$withval/lib"
		with_libatasmart="yes"
	else
		with_libatasmart="$withval"
	fi
],
[
	if test "x$ac_system" = "xLinux"
	then
		with_libatasmart="yes"
	else
		with_libatasmart="no (Linux only library)"
	fi
])
if test "x$with_libatasmart" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"

	AC_CHECK_HEADERS(atasmart.h, [with_libatasmart="yes"], [with_libatasmart="no (atasmart.h not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libatasmart" = "xyes"
then
	SAVE_CPPFLAGS="$CPPFLAGS"
	SAVE_LDFLAGS="$LDFLAGS"
	CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
	LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"

	AC_CHECK_LIB(atasmart, sk_disk_open, [with_libatasmart="yes"], [with_libatasmart="no (Symbol 'sk_disk_open' not found)"])

	CPPFLAGS="$SAVE_CPPFLAGS"
	LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libatasmart" = "xyes"
then
	BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
	BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
	BUILD_WITH_LIBATASMART_LIBS="-latasmart"
	AC_SUBST(BUILD_WITH_LIBATASMART_CPPFLAGS)
	AC_SUBST(BUILD_WITH_LIBATASMART_LDFLAGS)
	AC_SUBST(BUILD_WITH_LIBATASMART_LIBS)
	AC_DEFINE(HAVE_LIBATASMART, 1, [Define if libatasmart is present and usable.])
fi
AM_CONDITIONAL(BUILD_WITH_LIBATASMART, test "x$with_libatasmart" = "xyes")
# }}}

PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
		[with_libnotify="yes"],
		[if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
			 with_libnotify="no"
		 else
			 with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
		 fi])

# Check for enabled/disabled features
#

# AC_COLLECTD(name, enable/disable, info-text, feature/module)
# ------------------------------------------------------------
dnl
m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
dnl
AC_DEFUN(
	[AC_COLLECTD],
	[
	m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
	m4_if(
		[$2],
		[enable],
		[dnl
		m4_define([EnDis],[disabled])dnl
		m4_define([YesNo],[no])dnl
		],dnl
		[m4_if(
			[$2],
			[disable],
			[dnl
			m4_define([EnDis],[enabled])dnl
			m4_define([YesNo],[yes])dnl
			],
			[dnl
			AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
			]dnl
		)]dnl
	)dnl
	m4_if([$3], [feature], [],
		[m4_if(
			[$3], [module], [],
			[dnl
			AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
			]dnl
		)]dnl
	)dnl
	AC_ARG_ENABLE(
		[$1],
		AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
		[],
		enable_$1='[YesNo]'dnl
	)# AC_ARG_ENABLE
if test "x$enable_$1" = "xno"
then
	collectd_$1=0
else
	if test "x$enable_$1" = "xyes"
	then
		collectd_$1=1
	else
		AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
		collectd_$1=1
		enable_$1='yes'
	fi
fi
	AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
	AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
	]dnl
)# AC_COLLECTD(name, enable/disable, info-text, feature/module)

# AC_PLUGIN(name, default, info)
# ------------------------------------------------------------
dnl
AC_DEFUN(
  [AC_PLUGIN],
  [
    enable_plugin="no"
    force="no"
    AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1],[$3]),
    [
     if test "x$enableval" = "xyes"
     then
	     enable_plugin="yes"
     else if test "x$enableval" = "xforce"
     then
	     enable_plugin="yes"
	     force="yes"
     else
	     enable_plugin="no (disabled on command line)"
     fi; fi
    ],
    [
	 if test "x$enable_all_plugins" = "xauto"
	 then
	     if test "x$2" = "xyes"
	     then
		     enable_plugin="yes"
	     else
		     enable_plugin="no"
	     fi
	 else
	     enable_plugin="$enable_all_plugins"
	 fi
    ])
    if test "x$enable_plugin" = "xyes"
    then
	    if test "x$2" = "xyes" || test "x$force" = "xyes"
	    then
		    AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
		    if test "x$2" != "xyes"
		    then
			    dependency_warning="yes"
		    fi
	    else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
		    dependency_error="yes"
		    enable_plugin="no (dependency error)"
	    fi
    fi
    AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
    enable_$1="$enable_plugin"
  ]
)# AC_PLUGIN(name, default, info)

m4_divert_once([HELP_ENABLE], [
collectd features:])
# FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
AC_COLLECTD([debug],     [enable],  [feature], [debugging])
AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])

dependency_warning="no"
dependency_error="no"

plugin_ascent="no"
plugin_barometer="no"
plugin_battery="no"
plugin_bind="no"
plugin_ceph="no"
plugin_cgroups="no"
plugin_conntrack="no"
plugin_contextswitch="no"
plugin_cpu="no"
plugin_cpufreq="no"
plugin_curl_json="no"
plugin_curl_xml="no"
plugin_df="no"
plugin_disk="no"
plugin_drbd="no"
plugin_entropy="no"
plugin_ethstat="no"
plugin_fscache="no"
plugin_interface="no"
plugin_ipmi="no"
plugin_ipvs="no"
plugin_irq="no"
plugin_load="no"
plugin_log_logstash="no"
plugin_memory="no"
plugin_multimeter="no"
plugin_nfs="no"
plugin_numa="no"
plugin_perl="no"
plugin_processes="no"
plugin_protocols="no"
plugin_serial="no"
plugin_swap="no"
plugin_tape="no"
plugin_tcpconns="no"
plugin_ted="no"
plugin_thermal="no"
plugin_turbostat="no"
plugin_uptime="no"
plugin_users="no"
plugin_virt="no"
plugin_vmem="no"
plugin_vserver="no"
plugin_wireless="no"
plugin_zfs_arc="no"
plugin_zookeeper="no"

# Linux
if test "x$ac_system" = "xLinux"
then
	plugin_battery="yes"
	plugin_conntrack="yes"
	plugin_contextswitch="yes"
	plugin_cgroups="yes"
	plugin_cpu="yes"
	plugin_cpufreq="yes"
	plugin_disk="yes"
	plugin_drbd="yes"
	plugin_entropy="yes"
	plugin_fscache="yes"
	plugin_interface="yes"
	plugin_ipc="yes"
	plugin_irq="yes"
	plugin_load="yes"
	plugin_lvm="yes"
	plugin_memory="yes"
	plugin_nfs="yes"
	plugin_numa="yes"
	plugin_processes="yes"
	plugin_protocols="yes"
	plugin_serial="yes"
	plugin_swap="yes"
	plugin_tcpconns="yes"
	plugin_thermal="yes"
	plugin_uptime="yes"
	plugin_vmem="yes"
	plugin_vserver="yes"
	plugin_wireless="yes"
	plugin_zfs_arc="yes"

	if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
	then
		plugin_ipvs="yes"
	fi
	if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"
	then
		plugin_turbostat="yes"
	fi
fi

if test "x$ac_system" = "xOpenBSD"
then
	plugin_tcpconns="yes"
fi

# Mac OS X devices
if test "x$with_libiokit" = "xyes"
then
	plugin_battery="yes"
	plugin_disk="yes"
fi

# AIX

if test "x$ac_system" = "xAIX"
then
        plugin_tcpconns="yes"
        plugin_ipc="yes"
fi

# FreeBSD

if test "x$ac_system" = "xFreeBSD"
then
        plugin_zfs_arc="yes"
fi


if test "x$with_perfstat" = "xyes"
then
	plugin_cpu="yes"
	plugin_contextswitch="yes"
	plugin_disk="yes"
	plugin_memory="yes"
	plugin_swap="yes"
	plugin_interface="yes"
	plugin_load="yes"
	plugin_uptime="yes"
fi

if test "x$with_procinfo" = "xyes"
then
	plugin_processes="yes"
fi

# Solaris
if test "x$with_kstat" = "xyes"
then
	plugin_nfs="yes"
	plugin_processes="yes"
	plugin_uptime="yes"
	plugin_zfs_arc="yes"
fi

if test "x$with_devinfo$with_kstat" = "xyesyes"
then
	plugin_cpu="yes"
	plugin_disk="yes"
	plugin_interface="yes"
	plugin_memory="yes"
	plugin_tape="yes"
fi

# libi2c-dev
with_libi2c="no"
if test "x$ac_system" = "xLinux"
then
AC_CHECK_DECL(i2c_smbus_read_i2c_block_data,
	[with_libi2c="yes"],
	[with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
	[[#include <stdlib.h>
	#include <linux/i2c-dev.h>]])
fi

if test "x$with_libi2c" = "xyes"
then
	plugin_barometer="yes"
fi


# libstatgrab
if test "x$with_libstatgrab" = "xyes"
then
	plugin_cpu="yes"
	plugin_disk="yes"
	plugin_interface="yes"
	plugin_load="yes"
	plugin_memory="yes"
	plugin_swap="yes"
	plugin_users="yes"
fi

if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
then
	plugin_ascent="yes"
	if test "x$have_strptime" = "xyes"
	then
		plugin_bind="yes"
	fi
fi

if test "x$with_libopenipmipthread" = "xyes"
then
	plugin_ipmi="yes"
fi

if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
then
	plugin_curl_json="yes"
fi

if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
then
	plugin_curl_xml="yes"
fi

if test "x$with_libyajl" = "xyes"
then
	plugin_ceph="yes"
fi

if test "x$have_processor_info" = "xyes"
then
	plugin_cpu="yes"
fi
if test "x$have_sysctl" = "xyes"
then
	plugin_cpu="yes"
	plugin_memory="yes"
	plugin_uptime="yes"
	if test "x$ac_system" = "xDarwin"
	then
		plugin_swap="yes"
	fi
fi
if test "x$have_sysctlbyname" = "xyes"
then
	plugin_contextswitch="yes"
	plugin_cpu="yes"
	plugin_memory="yes"
	plugin_tcpconns="yes"
fi

# Df plugin: Check if we know how to determine mount points first.
#if test "x$have_listmntent" = "xyes"; then
#	plugin_df="yes"
#fi
if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
then
	plugin_df="yes"
fi
if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
then
	plugin_df="yes"
fi
#if test "x$have_getmntent" = "xseq"
#then
#	plugin_df="yes"
#fi
if test "x$c_cv_have_one_getmntent" = "xyes"
then
	plugin_df="yes"
fi

# Df plugin: Check if we have either `statfs' or `statvfs' second.
if test "x$plugin_df" = "xyes"
then
	plugin_df="no"
	if test "x$have_statfs" = "xyes"
	then
		plugin_df="yes"
	fi
	if test "x$have_statvfs" = "xyes"
	then
		plugin_df="yes"
	fi
fi

if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
then
	plugin_ethstat="yes"
fi

if test "x$have_getifaddrs" = "xyes"
then
	plugin_interface="yes"
fi

if test "x$have_getloadavg" = "xyes"
then
	plugin_load="yes"
fi

if test "x$with_libyajl" = "xyes"
then
	plugin_log_logstash="yes"
fi

if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
then
	plugin_perl="yes"
fi

# Mac OS X memory interface
if test "x$have_host_statistics" = "xyes"
then
	plugin_memory="yes"
fi

if test "x$have_termios_h" = "xyes"
then
	if test "x$ac_system" != "xAIX"
	then
		plugin_multimeter="yes"
	fi
	plugin_ted="yes"
fi

if test "x$have_thread_info" = "xyes"
then
	plugin_processes="yes"
fi

if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
then
	plugin_processes="yes"
fi

if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"
then
	plugin_processes="yes"
fi

if test "x$with_kvm_getswapinfo" = "xyes"
then
	plugin_swap="yes"
fi

if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
then
	plugin_swap="yes"
fi

if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
then
	plugin_tcpconns="yes"
fi

if test "x$have_getutent" = "xyes"
then
	plugin_users="yes"
fi
if test "x$have_getutxent" = "xyes"
then
	plugin_users="yes"
fi

if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
then
	plugin_virt="yes"
fi


m4_divert_once([HELP_ENABLE], [
collectd plugins:])

AC_ARG_ENABLE([all-plugins],
		AS_HELP_STRING([--enable-all-plugins],[enable all plugins (auto by def)]),
		[
		 if test "x$enableval" = "xyes"
		 then
			 enable_all_plugins="yes"
		 else if test "x$enableval" = "xauto"
		 then
			 enable_all_plugins="auto"
		 else
			 enable_all_plugins="no"
		 fi; fi
		],
		[enable_all_plugins="auto"])

m4_divert_once([HELP_ENABLE], [])

AC_PLUGIN([aggregation], [yes],                [Aggregation plugin])
AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
AC_PLUGIN([aquaero],     [$with_libaquaero5],  [Aquaero's hardware sensors])
AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
AC_PLUGIN([barometer],   [$plugin_barometer],  [Barometer sensor on I2C])
AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
AC_PLUGIN([ceph],        [$plugin_ceph],       [Ceph daemon statistics])
AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
AC_PLUGIN([csv],         [yes],                [CSV output plugin])
AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
AC_PLUGIN([cgroups],     [$plugin_cgroups],    [CGroups CPU usage accounting])
AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
AC_PLUGIN([drbd],        [$plugin_drbd],       [DRBD statistics])
AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
AC_PLUGIN([email],       [yes],                [EMail statistics])
AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
AC_PLUGIN([ethstat],     [$plugin_ethstat],    [Stats from NIC driver])
AC_PLUGIN([exec],        [yes],                [Execution of external programs])
AC_PLUGIN([fhcount],     [yes],                [File handles statistics])
AC_PLUGIN([filecount],   [yes],                [Count files in directories])
AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
AC_PLUGIN([ipc],         [$plugin_ipc],        [IPC statistics])
AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
AC_PLUGIN([load],        [$plugin_load],       [System load])
AC_PLUGIN([logfile],     [yes],                [File logging plugin])
AC_PLUGIN([log_logstash], [$plugin_log_logstash], [Logstash json_event compatible logging])
AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
AC_PLUGIN([lvm],         [$with_liblvm2app],   [LVM statistics])
AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
AC_PLUGIN([match_hashed], [yes],               [The hashed match])
AC_PLUGIN([match_regex], [yes],                [The regex match])
AC_PLUGIN([match_timediff], [yes],             [The timediff match])
AC_PLUGIN([match_value], [yes],                [The value match])
AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
AC_PLUGIN([md],          [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
AC_PLUGIN([memcached],   [yes],                [memcached statistics])
AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
AC_PLUGIN([mic],         [$with_mic],          [Intel Many Integrated Core stats])
AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
AC_PLUGIN([netlink],     [$with_libmnl],       [Enhanced Linux network statistics])
AC_PLUGIN([network],     [yes],                [Network communication plugin])
AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
AC_PLUGIN([numa],        [$plugin_numa],       [NUMA virtual memory statistics])
AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
AC_PLUGIN([openldap],    [$with_libldap],      [OpenLDAP statistics])
AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
AC_PLUGIN([pf],          [$have_net_pfvar_h],  [BSD packet filter (PF) statistics])
# FIXME: Check for libevent, too.
AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
AC_PLUGIN([redis],       [$with_libhiredis],    [Redis plugin])
AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
AC_PLUGIN([sigrok],      [$with_libsigrok],    [sigrok acquisition sources])
AC_PLUGIN([smart],       [$with_libatasmart],  [SMART statistics])
AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
AC_PLUGIN([tail_csv],    [yes],                [Parsing of CSV files])
AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
AC_PLUGIN([target_notification], [yes],        [The notification target])
AC_PLUGIN([target_replace], [yes],             [The replace target])
AC_PLUGIN([target_scale],[yes],                [The scale target])
AC_PLUGIN([target_set],  [yes],                [The set target])
AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
AC_PLUGIN([turbostat],   [$plugin_turbostat],  [Advanced statistic on Intel cpu states])
AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
AC_PLUGIN([users],       [$plugin_users],      [User statistics])
AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
AC_PLUGIN([virt],        [$plugin_virt],       [Virtual machine statistics])
AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
AC_PLUGIN([write_graphite], [yes],             [Graphite / Carbon output plugin])
AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
AC_PLUGIN([write_kafka],  [$with_librdkafka],  [Kafka output plugin])
AC_PLUGIN([write_log], [yes],                  [Log output plugin])
AC_PLUGIN([write_mongodb], [$with_libmongoc],  [MongoDB output plugin])
AC_PLUGIN([write_redis], [$with_libhiredis],    [Redis output plugin])
AC_PLUGIN([write_riemann], [$have_protoc_c],   [Riemann output plugin])
AC_PLUGIN([write_sensu], [yes],                [Sensu output plugin])
AC_PLUGIN([write_tsdb],  [yes],                [TSDB output plugin])
AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
AC_PLUGIN([zookeeper],   [yes],  	       [Zookeeper statistics])

dnl Default configuration file
# Load either syslog or logfile
LOAD_PLUGIN_SYSLOG=""
LOAD_PLUGIN_LOGFILE=""
LOAD_PLUGIN_LOG_LOGSTASH=""

AC_MSG_CHECKING([which default log plugin to load])
default_log_plugin="none"
if test "x$enable_syslog" = "xyes"
then
	default_log_plugin="syslog"
else
	LOAD_PLUGIN_SYSLOG="##"
fi

if test "x$enable_logfile" = "xyes"
then
	if test "x$default_log_plugin" = "xnone"
	then
		default_log_plugin="logfile"
	else
		LOAD_PLUGIN_LOGFILE="#"
	fi
else
	LOAD_PLUGIN_LOGFILE="##"
fi

if test "x$enable_log_logstash" = "xyes"
then
  LOAD_PLUGIN_LOG_LOGSTASH="#"
else
  LOAD_PLUGIN_LOG_LOGSTASH="##"
fi


AC_MSG_RESULT([$default_log_plugin])

AC_SUBST(LOAD_PLUGIN_SYSLOG)
AC_SUBST(LOAD_PLUGIN_LOGFILE)
AC_SUBST(LOAD_PLUGIN_LOG_LOGSTASH)

DEFAULT_LOG_LEVEL="info"
if test "x$enable_debug" = "xyes"
then
	DEFAULT_LOG_LEVEL="debug"
fi
AC_SUBST(DEFAULT_LOG_LEVEL)

# Load only one of rrdtool, network, csv in the default config.
LOAD_PLUGIN_RRDTOOL=""
LOAD_PLUGIN_NETWORK=""
LOAD_PLUGIN_CSV=""

AC_MSG_CHECKING([which default write plugin to load])
default_write_plugin="none"
if test "x$enable_rrdtool" = "xyes"
then
	default_write_plugin="rrdtool"
else
	LOAD_PLUGIN_RRDTOOL="##"
fi

if test "x$enable_network" = "xyes"
then
	if test "x$default_write_plugin" = "xnone"
	then
		default_write_plugin="network"
	else
		LOAD_PLUGIN_NETWORK="#"
	fi
else
	LOAD_PLUGIN_NETWORK="##"
fi

if test "x$enable_csv" = "xyes"
then
	if test "x$default_write_plugin" = "xnone"
	then
		default_write_plugin="csv"
	else
		LOAD_PLUGIN_CSV="#"
	fi
else
	LOAD_PLUGIN_CSV="##"
fi
AC_MSG_RESULT([$default_write_plugin])

AC_SUBST(LOAD_PLUGIN_RRDTOOL)
AC_SUBST(LOAD_PLUGIN_NETWORK)
AC_SUBST(LOAD_PLUGIN_CSV)

dnl ip_vs.h
if test "x$ac_system" = "xLinux" \
	&& test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono"
then
	enable_ipvs="$enable_ipvs (ip_vs.h not found)"
fi

if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"
then
	enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
fi

dnl Perl bindings
PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
[
	if test "x$withval" != "xno" && test "x$withval" != "xyes"
	then
		PERL_BINDINGS_OPTIONS="$withval"
		with_perl_bindings="yes"
	else
		with_perl_bindings="$withval"
	fi
],
[
	if test -n "$perl_interpreter"
	then
		with_perl_bindings="yes"
	else
		with_perl_bindings="no (no perl interpreter found)"
	fi
])
if test "x$with_perl_bindings" = "xyes"
then
	PERL_BINDINGS="perl"
else
	PERL_BINDINGS=""
fi
AC_SUBST(PERL_BINDINGS)
AC_SUBST(PERL_BINDINGS_OPTIONS)

dnl libcollectdclient
LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`

LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`

LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"

AC_SUBST(LCC_VERSION_MAJOR)
AC_SUBST(LCC_VERSION_MINOR)
AC_SUBST(LCC_VERSION_PATCH)
AC_SUBST(LCC_VERSION_EXTRA)
AC_SUBST(LCC_VERSION_STRING)

AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)

AC_CONFIG_FILES([Makefile src/Makefile src/daemon/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile])
AC_OUTPUT

if test "x$with_librrd" = "xyes" \
	&& test "x$librrd_threadsafe" != "xyes"
then
	with_librrd="yes (warning: librrd is not thread-safe)"
fi

if test "x$with_libperl" = "xyes"
then
	with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
else
	enable_perl="no (needs libperl)"
fi

if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
then
	enable_perl="no (libperl doesn't support ithreads)"
fi

if test "x$with_perl_bindings" = "xyes" \
	&& test "x$PERL_BINDINGS_OPTIONS" != "x"
then
	with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
fi

cat <<EOF;

Configuration:
  Libraries:
    intel mic . . . . . . $with_mic
    libaquaero5 . . . . . $with_libaquaero5
    libatasmart . . . . . $with_libatasmart
    libcurl . . . . . . . $with_libcurl
    libdbi  . . . . . . . $with_libdbi
    libesmtp  . . . . . . $with_libesmtp
    libganglia  . . . . . $with_libganglia
    libgcrypt . . . . . . $with_libgcrypt
    libhal  . . . . . . . $with_libhal
    libhiredis  . . . . . $with_libhiredis
    libi2c-dev  . . . . . $with_libi2c
    libiokit  . . . . . . $with_libiokit
    libiptc . . . . . . . $with_libiptc
    libjvm  . . . . . . . $with_java
    libkstat  . . . . . . $with_kstat
    libkvm  . . . . . . . $with_libkvm
    libldap . . . . . . . $with_libldap
    liblvm2app  . . . . . $with_liblvm2app
    libmemcached  . . . . $with_libmemcached
    libmnl  . . . . . . . $with_libmnl
    libmodbus . . . . . . $with_libmodbus
    libmongoc . . . . . . $with_libmongoc
    libmysql  . . . . . . $with_libmysql
    libnetapp . . . . . . $with_libnetapp
    libnetsnmp  . . . . . $with_libnetsnmp
    libnotify . . . . . . $with_libnotify
    liboconfig  . . . . . $with_liboconfig
    libopenipmi . . . . . $with_libopenipmipthread
    liboping  . . . . . . $with_liboping
    libowcapi . . . . . . $with_libowcapi
    libpcap . . . . . . . $with_libpcap
    libperfstat . . . . . $with_perfstat
    libperl . . . . . . . $with_libperl
    libpq . . . . . . . . $with_libpq
    libpthread  . . . . . $with_libpthread
    librabbitmq . . . . . $with_librabbitmq
    librdkafka  . . . . . $with_librdkafka
    librouteros . . . . . $with_librouteros
    librrd  . . . . . . . $with_librrd
    libsensors  . . . . . $with_libsensors
    libsigrok   . . . . . $with_libsigrok
    libstatgrab . . . . . $with_libstatgrab
    libtokyotyrant  . . . $with_libtokyotyrant
    libudev . . . . . . . $with_libudev
    libupsclient  . . . . $with_libupsclient
    libvarnish  . . . . . $with_libvarnish
    libvirt . . . . . . . $with_libvirt
    libxml2 . . . . . . . $with_libxml2
    libxmms . . . . . . . $with_libxmms
    libyajl . . . . . . . $with_libyajl
    oracle  . . . . . . . $with_oracle
    protobuf-c  . . . . . $have_protoc_c
    python  . . . . . . . $with_python

  Features:
    daemon mode . . . . . $enable_daemon
    debug . . . . . . . . $enable_debug

  Bindings:
    perl  . . . . . . . . $with_perl_bindings

  Modules:
    aggregation . . . . . $enable_aggregation
    amqp    . . . . . . . $enable_amqp
    apache  . . . . . . . $enable_apache
    apcups  . . . . . . . $enable_apcups
    apple_sensors . . . . $enable_apple_sensors
    aquaero . . . . . . . $enable_aquaero
    ascent  . . . . . . . $enable_ascent
    barometer . . . . . . $enable_barometer
    battery . . . . . . . $enable_battery
    bind  . . . . . . . . $enable_bind
    ceph  . . . . . . . . $enable_ceph
    cgroups . . . . . . . $enable_cgroups
    conntrack . . . . . . $enable_conntrack
    contextswitch . . . . $enable_contextswitch
    cpu . . . . . . . . . $enable_cpu
    cpufreq . . . . . . . $enable_cpufreq
    csv . . . . . . . . . $enable_csv
    curl  . . . . . . . . $enable_curl
    curl_json . . . . . . $enable_curl_json
    curl_xml  . . . . . . $enable_curl_xml
    dbi . . . . . . . . . $enable_dbi
    df  . . . . . . . . . $enable_df
    disk  . . . . . . . . $enable_disk
    dns . . . . . . . . . $enable_dns
    drbd  . . . . . . . . $enable_drbd
    email . . . . . . . . $enable_email
    entropy . . . . . . . $enable_entropy
    ethstat . . . . . . . $enable_ethstat
    exec  . . . . . . . . $enable_exec
    fhcount . . . . . . . $enable_fhcount
    filecount . . . . . . $enable_filecount
    fscache . . . . . . . $enable_fscache
    gmond . . . . . . . . $enable_gmond
    hddtemp . . . . . . . $enable_hddtemp
    interface . . . . . . $enable_interface
    ipc . . . . . . . . . $enable_ipc
    ipmi  . . . . . . . . $enable_ipmi
    iptables  . . . . . . $enable_iptables
    ipvs  . . . . . . . . $enable_ipvs
    irq . . . . . . . . . $enable_irq
    java  . . . . . . . . $enable_java
    load  . . . . . . . . $enable_load
    logfile . . . . . . . $enable_logfile
    log_logstash  . . . . $enable_log_logstash
    lpar  . . . . . . . . $enable_lpar
    lvm . . . . . . . . . $enable_lvm
    madwifi . . . . . . . $enable_madwifi
    match_empty_counter . $enable_match_empty_counter
    match_hashed  . . . . $enable_match_hashed
    match_regex . . . . . $enable_match_regex
    match_timediff  . . . $enable_match_timediff
    match_value . . . . . $enable_match_value
    mbmon . . . . . . . . $enable_mbmon
    md  . . . . . . . . . $enable_md
    memcachec . . . . . . $enable_memcachec
    memcached . . . . . . $enable_memcached
    memory  . . . . . . . $enable_memory
    mic . . . . . . . . . $enable_mic
    modbus  . . . . . . . $enable_modbus
    multimeter  . . . . . $enable_multimeter
    mysql . . . . . . . . $enable_mysql
    netapp  . . . . . . . $enable_netapp
    netlink . . . . . . . $enable_netlink
    network . . . . . . . $enable_network
    nfs . . . . . . . . . $enable_nfs
    nginx . . . . . . . . $enable_nginx
    notify_desktop  . . . $enable_notify_desktop
    notify_email  . . . . $enable_notify_email
    ntpd  . . . . . . . . $enable_ntpd
    numa  . . . . . . . . $enable_numa
    nut . . . . . . . . . $enable_nut
    olsrd . . . . . . . . $enable_olsrd
    onewire . . . . . . . $enable_onewire
    openldap  . . . . . . $enable_openldap
    openvpn . . . . . . . $enable_openvpn
    oracle  . . . . . . . $enable_oracle
    perl  . . . . . . . . $enable_perl
    pf  . . . . . . . . . $enable_pf
    pinba . . . . . . . . $enable_pinba
    ping  . . . . . . . . $enable_ping
    postgresql  . . . . . $enable_postgresql
    powerdns  . . . . . . $enable_powerdns
    processes . . . . . . $enable_processes
    protocols . . . . . . $enable_protocols
    python  . . . . . . . $enable_python
    redis . . . . . . . . $enable_redis
    routeros  . . . . . . $enable_routeros
    rrdcached . . . . . . $enable_rrdcached
    rrdtool . . . . . . . $enable_rrdtool
    sensors . . . . . . . $enable_sensors
    serial  . . . . . . . $enable_serial
    sigrok  . . . . . . . $enable_sigrok
    smart . . . . . . . . $enable_smart
    snmp  . . . . . . . . $enable_snmp
    statsd  . . . . . . . $enable_statsd
    swap  . . . . . . . . $enable_swap
    syslog  . . . . . . . $enable_syslog
    table . . . . . . . . $enable_table
    tail_csv  . . . . . . $enable_tail_csv
    tail  . . . . . . . . $enable_tail
    tape  . . . . . . . . $enable_tape
    target_notification . $enable_target_notification
    target_replace  . . . $enable_target_replace
    target_scale  . . . . $enable_target_scale
    target_set  . . . . . $enable_target_set
    target_v5upgrade  . . $enable_target_v5upgrade
    tcpconns  . . . . . . $enable_tcpconns
    teamspeak2  . . . . . $enable_teamspeak2
    ted . . . . . . . . . $enable_ted
    thermal . . . . . . . $enable_thermal
    threshold . . . . . . $enable_threshold
    tokyotyrant . . . . . $enable_tokyotyrant
    turbostat . . . . . . $enable_turbostat
    unixsock  . . . . . . $enable_unixsock
    uptime  . . . . . . . $enable_uptime
    users . . . . . . . . $enable_users
    uuid  . . . . . . . . $enable_uuid
    varnish . . . . . . . $enable_varnish
    virt  . . . . . . . . $enable_virt
    vmem  . . . . . . . . $enable_vmem
    vserver . . . . . . . $enable_vserver
    wireless  . . . . . . $enable_wireless
    write_graphite  . . . $enable_write_graphite
    write_http  . . . . . $enable_write_http
    write_kafka . . . . . $enable_write_kafka
    write_log . . . . . . $enable_write_log
    write_mongodb . . . . $enable_write_mongodb
    write_redis . . . . . $enable_write_redis
    write_riemann . . . . $enable_write_riemann
    write_sensu . . . . . $enable_write_sensu
    write_tsdb  . . . . . $enable_write_tsdb
    xmms  . . . . . . . . $enable_xmms
    zfs_arc . . . . . . . $enable_zfs_arc
    zookeeper . . . . . . $enable_zookeeper

EOF

if test "x$dependency_error" = "xyes"; then
	AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
fi

if test "x$dependency_warning" = "xyes"; then
	AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
fi

# vim: set fdm=marker :