File: configure.ac

package info (click to toggle)
zabbix 1%3A4.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 83,104 kB
  • sloc: php: 162,280; ansic: 154,778; sql: 96,479; sh: 5,281; makefile: 1,340; java: 1,068; cpp: 227; perl: 41; xml: 29
file content (1983 lines) | stat: -rw-r--r-- 53,995 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
dnl
dnl Zabbix
dnl Copyright (C) 2001-2019 Zabbix SIA
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
dnl

dnl Process this file with autoconf to produce a configure script.

AC_INIT([Zabbix],[4.0.4])
AC_CONFIG_SRCDIR(src/zabbix_server/server.c)
AM_INIT_AUTOMAKE([subdir-objects])

AC_MSG_NOTICE([Configuring $PACKAGE_NAME $PACKAGE_VERSION])

AC_PROG_MAKE_SET

AM_CONFIG_HEADER(include/config.h)

AC_CANONICAL_HOST

dnl *****************************************************************
dnl *                                                               *
dnl *                     Checks for programs                       *
dnl *                                                               *
dnl *****************************************************************

AC_PROG_CC([cc c99 gcc clang])
AM_PROG_CC_C_O

dnl *****************************************************************
dnl *                                                               *
dnl *                   Checks for header files                     *
dnl *                                                               *
dnl *****************************************************************

AC_HEADER_STDC
AC_CHECK_HEADERS(stdio.h stdlib.h string.h unistd.h netdb.h signal.h \
  syslog.h time.h errno.h sys/types.h sys/stat.h netinet/in.h \
  math.h sys/socket.h dirent.h ctype.h \
  mtent.h fcntl.h sys/param.h arpa/inet.h \
  sys/vfs.h sys/pstat.h sys/sysinfo.h sys/statvfs.h sys/statfs.h \
  sys/socket.h sys/loadavg.h arpa/inet.h \
  sys/vmmeter.h strings.h vm/vm_param.h \
  sys/time.h kstat.h sys/syscall.h sys/sysmacros.h \
  stdint.h mach/host_info.h mach/mach_host.h knlist.h pwd.h \
  sys/var.h arpa/nameser.h assert.h sys/dkstat.h sys/disk.h sys/sched.h \
  zone.h nlist.h kvm.h linux/kernel.h procinfo.h sys/dk.h \
  sys/resource.h pthread.h windows.h process.h conio.h sys/wait.h \
  stdarg.h winsock2.h pdh.h psapi.h sys/sem.h sys/ipc.h sys/shm.h Winldap.h \
  Winber.h lber.h ws2tcpip.h inttypes.h sys/file.h grp.h \
  execinfo.h sys/systemcfg.h sys/mnttab.h mntent.h sys/times.h \
  dlfcn.h sys/utsname.h sys/un.h sys/protosw.h)
AC_CHECK_HEADERS(resolv.h, [], [], [
#ifdef HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#  include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#  include <arpa/nameser.h>
#endif
#ifdef HAVE_NETDB_H
#  include <netdb.h>
#endif
])
AC_CHECK_HEADERS(net/if.h net/if_mib.h, [], [], [
#include <stdio.h>
#ifdef STDC_HEADERS
#  include <stdlib.h>
#  include <stddef.h>
#else
#  ifdef HAVE_STDLIB_H
#    include <stdlib.h>
#  endif
#endif
#ifdef HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
/* for net/if_mib.h */
#ifdef HAVE_NET_IF_H
#  include <net/if.h>
#endif
])
AC_CHECK_HEADERS(sys/mount.h sys/proc.h sys/sysctl.h sys/user.h, [], [], [
#ifdef HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#  include <sys/param.h>
#endif
])
AC_CHECK_HEADERS(sys/swap.h, [], [], [
#ifdef HAVE_SYS_PARAM_H
#  include <sys/param.h>
#endif
])
AC_CHECK_HEADERS(sys/ucontext.h, [], [], [
#ifdef HAVE_SIGNAL_H
#  include <signal.h>
#endif
])
AC_CHECK_HEADERS(devstat.h, [], [], [
#ifdef HAVE_SYS_DKSTAT_H
#  include <sys/dkstat.h>
#endif
])
AC_CHECK_HEADERS(linux/netlink.h, [
	AC_CHECK_HEADERS(linux/inet_diag.h, [
		AC_DEFINE([HAVE_INET_DIAG], 1, [Define to 1 if you have NETLINK INET_DIAG support.])
	])
], [], [
#ifdef HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
])
AC_CHECK_HEADERS(libperfstat.h, [], [], [
#ifdef HAVE_SYS_PROTOSW_H
#  include <sys/protosw.h>
#endif
])

dnl *****************************************************************
dnl *                                                               *
dnl *                     Checks for libraries                      *
dnl *                                                               *
dnl *****************************************************************

AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(kstat_open, kstat)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(clock_gettime, rt)
AC_SEARCH_LIBS(dlopen, dl)

dnl AIX
AC_SEARCH_LIBS(perfstat_memory_total, perfstat, [AC_DEFINE([HAVE_LIBPERFSTAT], 1, [Define to 1 if you have the 'libperfstat' library (-lperfstat)])])
AC_SEARCH_LIBS(devstat_getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])
AC_SEARCH_LIBS(getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])

dnl on FreeBSD we have to link with -lexecinfo to get backtraces
AC_SEARCH_LIBS(backtrace_symbols, execinfo, [AC_DEFINE([HAVE_LIBEXECINFO], 1, [Define to 1 if you have the 'libexecinfo' library (-lexecinfo)])])

AC_CHECK_LIB(m, main)
AC_CHECK_LIB(kvm, main)

dnl check for DNS lookup functions
found_resolv="no"
LIBRESOLV_CHECK_CONFIG([no])
if test "x$found_resolv" != "xyes"; then
	AC_MSG_ERROR([Unable to do DNS lookups (libresolv check failed)])
fi
LIBS="${LIBS} ${RESOLV_LIBS}"

dnl *****************************************************************
dnl *                                                               *
dnl *          Checks for type definitions and structures           *
dnl *                                                               *
dnl *****************************************************************

dnl large file support
largefile=yes

dnl disable large file support on 32-bit Solaris as it's incompatible with procfs and swapctl
case "${host_os}" in
	solaris*)
		largefile=no
		;;
esac

if test "x$largefile" = "xyes"; then
	AC_SYS_LARGEFILE
fi

AC_C_CONST
AC_TYPE_PID_T

AC_MSG_CHECKING(for socklen_t)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
],[socklen_t s;],
AC_MSG_RESULT(yes),
[AC_DEFINE(socklen_t, int, [Define socklen_t type.])
AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for actual socklen_t parameter type in socket functions)
zbx_socklen_t=
for arg2 in "struct sockaddr" void; do
  for arg3 in socklen_t size_t int; do
    AC_TRY_COMPILE([
#ifdef HAVE_SYS_TYPES_H
#  include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#  include <sys/socket.h>
#endif
      extern int getpeername(int sockfd, $arg2 *addr, $arg3 *addrlen);
    ],[
      $arg3 addrlen;
      getpeername(0, 0, &addrlen);
    ],[
      zbx_socklen_t="$arg3"
      break 2
    ])
  done
done
if test "x$zbx_socklen_t" != "x"; then
  AC_MSG_RESULT($zbx_socklen_t)
  AC_DEFINE_UNQUOTED(ZBX_SOCKLEN_T, $zbx_socklen_t, [Define actual socklen_t parameter type in socket functions.])
else
  AC_MSG_RESULT(leaving undefined)
fi

AC_MSG_CHECKING(for integer field name in union sigval of struct siginfo_t)
zbx_sival_int=
for field in sival_int sigval_int; do
  AC_TRY_COMPILE([
#ifdef HAVE_SIGNAL_H
#  include <signal.h>
#endif
  ],[
    siginfo_t siginfo;
    siginfo.si_value.$field = 0;
  ],[
    zbx_sival_int="$field"
    break
  ])
done
if test "x$zbx_sival_int" != "x"; then
  AC_MSG_RESULT($zbx_sival_int)
  AC_DEFINE_UNQUOTED(ZBX_SIVAL_INT, $zbx_sival_int, [Define integer field name in union 'sigval' of struct 'siginfo_t'])
else
  AC_MSG_ERROR(Unable to find integer field name in union sigval of struct siginfo_t)
fi

AC_MSG_CHECKING(for res_ninit)
AC_TRY_LINK(
[
#ifdef HAVE_SYS_TYPES_H
#	include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#	include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#	include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#	include <resolv.h>
#endif
#ifndef C_IN
#	define C_IN	ns_c_in
#endif	/* C_IN */
#ifndef T_SOA
#	define T_SOA	ns_t_soa
#endif	/* T_SOA */
],
[
	struct __res_state	res_state_local;

	res_ninit(&res_state_local);
],
AC_DEFINE(HAVE_RES_NINIT,1,[Define to 1 if 'res_ninit' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for res_ndestroy)
AC_TRY_LINK(
[
#ifdef HAVE_SYS_TYPES_H
#	include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#	include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#	include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#	include <resolv.h>
#endif
#ifndef C_IN
#	define C_IN	ns_c_in
#endif	/* C_IN */
#ifndef T_SOA
#	define T_SOA	ns_t_soa
#endif	/* T_SOA */
],
[
	struct __res_state	res_state_local;

	res_ninit(&res_state_local);
	res_ndestroy(&res_state_local);
],
AC_DEFINE(HAVE_RES_NDESTROY,1,[Define to 1 if 'res_ndestroy' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for union semun)
AC_TRY_COMPILE(
[
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
],
[union semun foo;],
AC_DEFINE(HAVE_SEMUN, 1, [Define to 1 if union 'semun' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct swaptable in sys/swap.h)
AC_TRY_COMPILE(
[
#include <stdlib.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/swap.h>

#ifndef NULL
#define NULL (void *)0
#endif
],
[
    register int cnt, i;
    register int t, f;
    struct swaptable *swt;
    struct swapent *ste;
    static char path[256];

    /* get total number of swap entries */
    cnt = swapctl(SC_GETNSWP, 0);

    /* allocate enough space to hold count + n swapents */
    swt = (struct swaptable *)malloc(sizeof(int) +
             cnt * sizeof(struct swapent));
    if (swt == NULL)
    {
  return;
    }
    swt->swt_n = cnt;

    /* fill in ste_path pointers: we do not care about the paths, so we
point
       them all to the same buffer */
    ste = &(swt->swt_ent[0]);
    i = cnt;
    while (--i >= 0)
    {
  ste++->ste_path = path;
    }

    /* grab all swap info */
    swapctl(SC_LIST, swt);

    /* walk through the structs and sum up the fields */
    t = f = 0;
    ste = &(swt->swt_ent[0]);
    i = cnt;
    while (--i >= 0)
    {
  /* do not count slots being deleted */
  if (!(ste->ste_flags & ST_INDEL) &&
      !(ste->ste_flags & ST_DOINGDEL))
  {
      t += ste->ste_pages;
      f += ste->ste_free;
  } ste++;
    }

    /* fill in the results */
    free(swt);

],
AC_DEFINE(HAVE_SYS_SWAP_SWAPTABLE,1,[Define to 1 if struct 'swaptable' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct sensordev in sys/sensors.h)
AC_TRY_COMPILE([
#include <stdlib.h>
#include <sys/queue.h>
#include <sys/sensors.h>],
[struct sensordev sensordev;
sensordev.xname[0]='\0';
sensordev.maxnumt[0]=0;
],
AC_DEFINE(HAVE_SENSORDEV,1,[Define to 1 if struct 'sensordev' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct statvfs64 in sys/statvfs.h)
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#	include <sys/types.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#	include <sys/statvfs.h>
#endif
],
[
	struct statvfs64	s;
	s.f_frsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
	statvfs64("/", &s);
],
AC_DEFINE(HAVE_SYS_STATVFS64, 1, [Define to 1 if struct 'statvfs64' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct statfs64 in sys/statfs.h)
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#	include <sys/types.h>
#endif
#ifdef HAVE_SYS_STATFS_H
#	include <sys/statfs.h>
#endif
],
[
	struct statfs64	s;
	s.f_bsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
	statfs64("/", &s);
],
AC_DEFINE(HAVE_SYS_STATFS64, 1, [Define to 1 if struct 'statfs64' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field ss_family in struct sockaddr_storage)
AC_TRY_COMPILE([#include <sys/socket.h>],
[struct sockaddr_storage ss;
ss.ss_family = 0;
],
AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_FAMILY, 1, [Define to 1 if 'sockaddr_storage.ss_family' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field mem_unit in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.mem_unit=0;
],
AC_DEFINE(HAVE_SYSINFO_MEM_UNIT,1,[Define to 1 if 'sysinfo.mem_unit' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field freeswap in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.freeswap=0;
],
AC_DEFINE(HAVE_SYSINFO_FREESWAP,1,[Define to 1 if 'sysinfo.freeswap' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field totalswap in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.totalswap=0;
],
AC_DEFINE(HAVE_SYSINFO_TOTALSWAP,1,[Define to 1 if 'sysinfo.totalswap' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field totalram in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.totalram=0;
],
AC_DEFINE(HAVE_SYSINFO_TOTALRAM,1,[Define to 1 if 'sysinfo.totalram' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field sharedram in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.sharedram=0;
],
AC_DEFINE(HAVE_SYSINFO_SHAREDRAM,1,[Define to 1 if 'sysinfo.sharedram' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field bufferram in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.bufferram=0;
],
AC_DEFINE(HAVE_SYSINFO_BUFFERRAM,1,[Define to 1 if 'sysinfo.bufferram' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field freeram in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.freeram=0;
],
AC_DEFINE(HAVE_SYSINFO_FREERAM,1,[Define to 1 if 'sysinfo.freeram' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field uptime in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.uptime=0;
],
AC_DEFINE(HAVE_SYSINFO_UPTIME,1,[Define to 1 if 'sysinfo.uptime' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field procs in struct sysinfo)
AC_TRY_COMPILE([#include <sys/sysinfo.h>],
[struct sysinfo sysinfo;
sysinfo.procs=0;
],
AC_DEFINE(HAVE_SYSINFO_PROCS,1,[Define to 1 if 'sysinfo.procs' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for field tm_gmtoff in struct tm)
AC_TRY_COMPILE([
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif	/* HAVE_SYS_TIME_H */

#ifdef HAVE_TIME_H
#include <time.h>
#endif	/* HAVE_TIME_H */
],
[
	struct tm tm;
	tm.tm_gmtoff;
],
AC_DEFINE(HAVE_TM_TM_GMTOFF,1,[Define to 1 if 'tm.tm_gmtoff' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl *****************************************************************
dnl *                                                               *
dnl *                     Checks for functions                      *
dnl *                                                               *
dnl *****************************************************************

AC_MSG_CHECKING(for function sysconf() in unistd.h)
AC_TRY_COMPILE(
[
#include <unistd.h>
],
[	int i;

	i=sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
	i=sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
],
AC_DEFINE(HAVE_UNISTD_SYSCONF,1,[Define to 1 if function 'sysconf' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function initgroups())
AC_TRY_LINK(
[
#include <sys/types.h>
#include <grp.h>
],
[
	char	*user = "zabbix";
	initgroups(user, 0);
],
AC_DEFINE(HAVE_FUNCTION_INITGROUPS,1,[Define to 1 if function 'initgroups' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for functions seteuid() and setegid())
AC_TRY_LINK(
[
#include <sys/types.h>
#include <unistd.h>
],
[
	seteuid(0);
	setegid(0);
],
AC_DEFINE(HAVE_FUNCTION_SETEUID,1,[Define to 1 if functions 'seteuid' and 'setegid' exist.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function setproctitle())
AC_TRY_LINK(
[
#include <sys/types.h>
#include <unistd.h>
],
[
	setproctitle("Test %d", 1);
],
AC_DEFINE(HAVE_FUNCTION_SETPROCTITLE,1,[Define to 1 if function 'setproctitle' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctlbyname())
AC_TRY_LINK(
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#include <sys/sysctl.h>
],
[
	sysctlbyname("", 0, 0, 0, 0);
],
AC_DEFINE(HAVE_FUNCTION_SYSCTLBYNAME,1,[Define to 1 if 'sysctlbyname' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME))
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#include <sys/sysctl.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
],
[
	size_t		len;
	struct timeval	uptime;
        int		mib[2];

        mib[0] = CTL_KERN;
        mib[1] = KERN_BOOTTIME;

        len = sizeof(uptime);
        sysctl(mib, 2, &uptime, &len, 0, 0);
],
AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME,1,[Define to 1 if 'KERN_BOOTTIME' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctl (HW_NCPU))
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#include <sys/sysctl.h>
],
[
	size_t	len;
	int	mib[2], ncpu;

	mib[0] = CTL_HW;
	mib[1] = HW_NCPU;

	len = sizeof(ncpu);
	sysctl(mib, 2, &ncpu, &len, 0, 0);
],
AC_DEFINE(HAVE_FUNCTION_SYSCTL_HW_NCPU,1,[Define to 1 if 'HW_NCPU' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES))
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#include <sys/sysctl.h>
],
[
	size_t	len;
        int	mib[2], maxfiles;

        mib[0] = CTL_KERN;
        mib[1] = KERN_MAXFILES;

        len = sizeof(maxfiles);
        sysctl(mib, 2, &maxfiles, &len, 0, 0);
],
AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES,1,[Define to 1 if 'KERN_MAXFILES' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC))
AC_TRY_COMPILE(
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#include <sys/sysctl.h>
],
[
	size_t	len;
	int	mib[2], maxproc;

        mib[0] = CTL_KERN;
        mib[1] = KERN_MAXPROC;

        len = sizeof(maxproc);
        sysctl(mib, 2, &maxproc, &len, 0, 0);
],
AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC,1,[Define to 1 if 'KERN_MAXPROC' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function sysctl (KERN_CPTIME,KERN_CPTIME2))
AC_TRY_COMPILE(
[
#include <sys/param.h>
#include <sys/sysctl.h>
#if defined(HAVE_SYS_DKSTAT_H)
#	include <sys/dkstat.h>
#elif defined(HAVE_SYS_SCHED_H)
#	include <sys/sched.h>
#endif
],
[
size_t	sz;
int	i[] = {CP_USER, CP_NICE, CP_SYS, CP_INTR, CP_IDLE};

{
	long	states[CPUSTATES];
	int	mib[2] = {CTL_KERN, KERN_CPTIME};

	sz = sizeof(states);
	sysctl(mib, 2, &states, &sz, NULL, 0);
}

{
	u_int64_t	states[CPUSTATES];
	int		mib[3] = {CTL_KERN, KERN_CPTIME2, 0};

	sz = sizeof(states);
	sysctl(mib, 3, &states, &sz, NULL, 0);
}
],
AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_CPTIME,1,[Define to 1 if 'KERN_CPTIME,KERN_CPTIME2' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for function clock_gettime in time.h)
AC_TRY_LINK([
#ifdef HAVE_TIME_H
#	include <time.h>
#elif HAVE_SYS_TIME_H
#	include <sys/time.h>
#endif	/* HAVE_SYS_TIME_H */
],
[struct timespec tp;
clock_gettime(CLOCK_REALTIME, &tp);
],
AC_DEFINE(HAVE_TIME_CLOCK_GETTIME,1,[Define to 1 if function 'clock_gettime' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl *****************************************************************
dnl *                                                               *
dnl *                      Checks for macros                        *
dnl *                                                               *
dnl *****************************************************************

AC_MSG_CHECKING(for macro __va_copy() in stdarg.h)
AC_TRY_COMPILE(
[
#include <stdarg.h>
],
[
	va_list	src,dst;

	__va_copy(dst,src);
],
AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if macro '__va_copy' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for macro __VA_ARGS__)
AC_TRY_COMPILE(
[
#define ZBX_CONST_STRING(str)   str
int test(const char *fmt, ...) { return 0; }
],
[
#define TEST(fmt, ...) test(ZBX_CONST_STRING(fmt), ##__VA_ARGS__)
TEST("%s","test");
TEST("test");
],
AC_DEFINE(HAVE___VA_ARGS__,1,[Define to 1 if macro '__VA_ARGS__' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

dnl *****************************************************************
dnl *                                                               *
dnl *                 Checks for library functions                  *
dnl *                                                               *
dnl *****************************************************************

AC_TYPE_SIGNAL
AC_REPLACE_FUNCS(getloadavg)
AC_CHECK_FUNCS(hstrerror)
AC_CHECK_FUNCS(getenv)
AC_CHECK_FUNCS(putenv)
AC_CHECK_FUNCS(sigqueue)

dnl *****************************************************************
dnl *                                                               *
dnl *            Checks for file system characteristics             *
dnl *                                                               *
dnl *****************************************************************

AC_MSG_CHECKING(for /proc filesystem)
if test -d /proc; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC,1,[Define to 1 if '/proc' file system should be used.])
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(for file /proc/stat)
if test -r /proc/stat; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC_STAT,1,[Define to 1 if file '/proc/stat' should be used.])
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(for file /proc/cpuinfo)
if test -r /proc/cpuinfo; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC_CPUINFO,1,[Define to 1 if file '/proc/cpuinfo' should be used.])
else
	AC_MSG_RESULT(no)
fi

dnl Solaris
AC_MSG_CHECKING(for file /proc/0/psinfo)
if test -r /proc/0/psinfo; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC_0_PSINFO,1,[Define to 1 if file '/proc/0/psinfo' should be used.])
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(for file /proc/loadavg)
if test -r /proc/loadavg; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define to 1 if file '/proc/loadavg' should be used.])
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(for file /proc/net/dev)
if test -r /proc/net/dev; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_PROC_NET_DEV,1,[Define to 1 if file '/proc/net/dev' should be used.])
else
	AC_MSG_RESULT(no)
fi

dnl *****************************************************************
dnl *                                                               *
dnl *              Checks for compiler characteristics              *
dnl *                                                               *
dnl *****************************************************************

dnl Check for %qu format (FreeBSD 4.x)
dnl FreeBSD 4.x does not support %llu
AC_MSG_CHECKING(for long long format)
AC_TRY_RUN(
[
#include <sys/types.h>
int main()
{
        uint64_t i;

        sscanf("200000000010020", "%qu", &i);

        if (i == 200000000010020) return 0;
        else return -1;
}
],
AC_DEFINE(HAVE_LONG_LONG_QU, 1 ,[Define to 1 if format '%qu' exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_RESULT(no))

dnl option -rdynamic is needed for readable backtraces
AC_MSG_CHECKING(for -rdynamic linking option)
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="-rdynamic $LDFLAGS"
AC_TRY_LINK([#include <execinfo.h>],
[void *bcktrc[6];
(void)backtrace(bcktrc, 6);
],
LDFLAGS="-rdynamic $saved_LDFLAGS"
AC_MSG_RESULT(yes),
LDFLAGS="$saved_LDFLAGS"
AC_MSG_RESULT(no))

dnl *****************************************************************
dnl *                                                               *
dnl *                 Checks for operating systems                  *
dnl *                                                               *
dnl *****************************************************************

AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset)
AC_TRY_COMPILE([#include <sys/protosw.h>
#include <libperfstat.h>],
[perfstat_memory_total_t	memstats;
memstats.virt_active = 0;
],
AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset)
AC_TRY_COMPILE([#include <sys/protosw.h>
#include <libperfstat.h>],
[perfstat_partition_total_t	lparstats;
lparstats.type.b.donate_enabled = 0;
lparstats.idle_donated_purr = 0;
lparstats.busy_donated_purr = 0;
lparstats.idle_stolen_purr = 0;
lparstats.busy_stolen_purr = 0;
],
AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))

case "$host_os" in
linux*)
	ARCH="linux"
	;;
aix*)
	ARCH="aix"
	;;
darwin*|rhapsody*)
	ARCH="osx"
	AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X.])
	;;
*solaris*)
	ARCH="solaris"
	;;
hpux*)
	ARCH="hpux"
	;;
freebsd*)
	ARCH="freebsd"
	;;
netbsd*)
	ARCH="netbsd"
	;;
osf*)
	ARCH="osf"
	;;
openbsd*)
	ARCH="openbsd"
	;;
*)
	ARCH="unknown"
	;;
esac

AC_MSG_CHECKING(for architecture)
AC_MSG_RESULT([$ARCH ($host_os)])

if test "x$ARCH" = "xlinux"; then
	AC_MSG_CHECKING([for the linux kernel version])

	kernel=`uname -r`

	case "${kernel}" in
		2.6.*)
			AC_MSG_RESULT([2.6 family (${kernel})])
			AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x])
			;;
		2.4.*)
			AC_MSG_RESULT([2.4 family (${kernel})])
			AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x])
			;;
		*)
			AC_MSG_RESULT([unknown family (${kernel})])
			;;
	esac
fi

if test "x$ARCH" = "xsolaris"; then
	dnl Forcing a 64-bit application for a 64-bit Solaris
	dnl A 32-bit program that uses /proc is able to look at 32-bit processes,
	dnl but is not able to understand all attributes of a 64-bit process.
	AC_MSG_CHECKING(for -m64 compilation flag)
	saved_CFLAGS="$CFLAGS"
	CFLAGS="-m64"
	AC_TRY_RUN(
	[int main(void) {return 0;}],
	CFLAGS="-m64 $saved_CFLAGS"
	AC_MSG_RESULT(yes),
	CFLAGS="$saved_CFLAGS"
	AC_MSG_RESULT(no))
fi

if test "x$ARCH" = "xhpux"; then
	dnl Low Level Discovery needs a way to get the list of network
	dnl interfaces available on the monitored system. On HP-UX systems
	dnl that way depends on the OS version.
	hpux_version=${host_os#hpux}
	hpux_major=${hpux_version%.*}
	hpux_minor=${hpux_version#*.}

	AC_DEFINE_UNQUOTED([HPUX_VERSION], $hpux_major$hpux_minor, [Define to HP-UX version])

	dnl This API level is needed so that "utsname.nodename" is not truncated.
	AC_MSG_CHECKING(for -D_HPUX_API_LEVEL=20040821 compilation flag)
	saved_CFLAGS="$CFLAGS"
	CFLAGS="-D_HPUX_API_LEVEL=20040821"
	AC_TRY_RUN(
[
#ifdef HAVE_DLFCN_H
#	include <dlfcn.h>
#endif
#ifdef HAVE_SYS_UTSNAME_H
#	include <sys/utsname.h>
#endif

int main(void)
{
	void		*p1, *p2;
	struct utsname	name;

	/* check that the compiler (e.g., GCC 4.3.0 and above) supports function-level versioning */

	p1 = uname;
	p2 = dlsym(RTLD_DEFAULT, "uname{20040821}");

	if (p1 != p2)
		return 1;

	/* uname() fails with EFAULT on HP-UX systems that were only partially upgraded to this API level */

	return -1 == uname(&name) ? 1 : 0;
}
],
	CFLAGS="-D_HPUX_API_LEVEL=20040821 $saved_CFLAGS"
	AC_MSG_RESULT(yes),
	CFLAGS="$saved_CFLAGS"
	AC_MSG_RESULT(no))
fi

AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing])
AC_SUBST(ARCH)

AC_CHECK_SIZEOF([void *])

dnl *****************************************************************
dnl *                                                               *
dnl *         Checks for options given on the command line          *
dnl *                                                               *
dnl *****************************************************************

AC_ARG_ENABLE(static,[  --enable-static         Build statically linked binaries],
[case "${enableval}" in
  yes)
    LDFLAGS="${LDFLAGS} -static"
    AC_MSG_CHECKING(if static linking is possible)
    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
      [AC_MSG_RESULT([yes])
        static_linking=yes],
      [AC_MSG_RESULT([no])
        static_linking=no])
      if test "x$static_linking" = "xno"; then
        AC_MSG_ERROR([static linking is not possible on this system])
      fi
    ;;
  no) ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static]) ;;
esac])

AC_ARG_ENABLE(server,[  --enable-server         Turn on build of Zabbix server],
[case "${enableval}" in
  yes) server=yes ;;
  no)  server=no ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-server]) ;;
esac],
[server=no])
AM_CONDITIONAL(SERVER, test "x$server" = "xyes")

AC_ARG_ENABLE(proxy,[  --enable-proxy          Turn on build of Zabbix proxy],
[case "${enableval}" in
  yes) proxy=yes ;;
  no)  proxy=no ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-proxy]) ;;
esac],
[proxy=no])
AM_CONDITIONAL(PROXY, test "x$proxy" = "xyes")

AC_ARG_ENABLE(agent,[  --enable-agent          Turn on build of Zabbix agent and client utilities],
[case "${enableval}" in
  yes) agent=yes ;;
  no)  agent=no ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-agent]) ;;
esac],
[agent=no])
AM_CONDITIONAL(AGENT, test "x$agent" = "xyes")

AC_ARG_ENABLE(java,[  --enable-java           Turn on build of Zabbix Java gateway],
[case "${enableval}" in
  yes) java=yes ;;
  no)  java=no ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-java]) ;;
esac],
[java=no])
AM_CONDITIONAL(JAVA, test "x$java" = "xyes")

AC_ARG_ENABLE(ipv6,[  --enable-ipv6           Turn on support of IPv6],
[case "${enableval}" in
  yes) ipv6=yes ;;
  no)  ipv6=no ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
esac],
[ipv6=no])

AM_CONDITIONAL([DBSCHEMA], [test -d create])

AM_CONDITIONAL([ZBXCUNIT], [test -f src/libs/zbxcunit/zbxcunit.c])


have_db="no"
have_unixodbc="no"
have_web_monitoring="no"
have_jabber="no"
have_snmp="no"
have_ipmi="no"
have_ipv6="no"
have_ssh2="no"
have_tls="no"


if test "x$ipv6" = "xyes"; then
	AC_DEFINE(HAVE_IPV6,1,[Define to 1 if IPv6 should be enabled.])
	have_ipv6="yes"
fi

if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then

	have_multirow_insert="no"

	dnl Checking for IBM DB2 support
	AX_LIB_IBM_DB2()
	if test "x$want_ibm_db2" = "xyes"; then
		if test "x$have_db" != "xno"; then
			AC_MSG_ERROR([You can configure for only one database.])
		fi

		if test "x$found_ibm_db2" = "xyes"; then
			have_db="IBM DB2"
			have_multirow_insert="yes"
		else
			AC_MSG_ERROR([IBM DB2 library not found])
		fi
	fi

	dnl Checking for MySQL support
	AX_LIB_MYSQL()
	if test "x$want_mysql" = "xyes"; then
		if test "x$have_db" != "xno"; then
			AC_MSG_ERROR([You can configure for only one database.])
		fi

		if test "x$found_mysql" = "xyes"; then
			have_db="MySQL"
			have_multirow_insert="yes"
		else
			AC_MSG_ERROR([MySQL library not found])
		fi
	fi

	dnl Checking for Oracle support
	AX_LIB_ORACLE_OCI([10.0])
	if test "x$want_oracle_oci" = "xyes"; then
		if test "x$have_db" != "xno"; then
			AC_MSG_ERROR([You can configure for only one database.])
		fi

		if test "x$HAVE_ORACLE_OCI" = "xyes"; then
			have_db="Oracle"

			ORACLE_CPPFLAGS="$ORACLE_OCI_CFLAGS"
			ORACLE_LDFLAGS="$ORACLE_OCI_LDFLAGS"
			ORACLE_LIBS="$ORACLE_OCI_LIBS"

			AC_DEFINE(HAVE_ORACLE,1,[Define to 1 if Oracle should be enabled.])
		else
			AC_MSG_ERROR([Oracle OCI library not found])
		fi
	fi

	dnl Checking for PostgreSQL support
	AX_LIB_POSTGRESQL("8.1")
	if test "x$want_postgresql" = "xyes"; then
		if test "x$have_db" != "xno"; then
			AC_MSG_ERROR([You can configure for only one database.])
		fi

		if test "x$found_postgresql" = "xyes"; then
			if test "$postgresql_version_check" != "1"; then
				AC_MSG_ERROR([PostgreSQL version mismatch])
			fi

			have_db="PostgreSQL"

			if test "$postgresql_version_number" -ge 8002000; then
				have_multirow_insert="yes"
			fi

		else
			AC_MSG_ERROR([PostgreSQL library not found])
		fi
	fi

	dnl Checking for SQLite3 support
	AX_LIB_SQLITE3()
	if test "x$want_sqlite3" = "xyes"; then
		if test "x$server" = "xyes"; then
			AC_MSG_ERROR([SQLite is not supported as a main Zabbix database backend.])
		fi

		if test "x$have_db" != "xno"; then
			AC_MSG_ERROR([You can configure for only one database.])
		fi

		if test "x$found_sqlite3" = "xyes"; then
			have_db="SQLite v3.x"

			saved_CPPFLAGS="$CPPFLAGS"
			saved_LDFLAGS="$LDFLAGS"

			CPPFLAGS="$CPPFLAGS $SQLITE3_CPPFLAGS"
			LDFLAGS="$LDFLAGS $SQLITE3_LDFLAGS $SQLITE3_LIBS"

			AC_MSG_CHECKING([for function sqlite3_open_v2() in sqlite3.h])
			AC_TRY_LINK([#include <sqlite3.h>],
				[sqlite3 *conn = 0;
				sqlite3_open_v2("dbname", &conn, SQLITE_OPEN_READWRITE, 0);
				],
				AC_DEFINE(HAVE_FUNCTION_SQLITE3_OPEN_V2,1,[Define to 1 if function 'sqlite3_open_v2' exists.])
				AC_MSG_RESULT(yes),
				AC_MSG_RESULT(no))

			CPPFLAGS="$saved_CPPFLAGS"
			LDFLAGS="$saved_LDFLAGS"
		else
			AC_MSG_ERROR([SQLite3 library not found])
		fi
	fi

	AC_MSG_CHECKING(for Zabbix server/proxy database selection)
	if test "x$have_db" = "xno"; then
		AC_MSG_RESULT(error)
		AC_MSG_ERROR([No database selected for Zabbix server/proxy. Use --with-ibm-db2 or --with-mysql or --with-oracle or --with-postgresql or --with-sqlite3.])
	else
		AC_MSG_RESULT(ok)
	fi

	AC_MSG_CHECKING(for multirow insert statements)
	if test "x$have_multirow_insert" = "xyes"; then
		AC_DEFINE(HAVE_MULTIROW_INSERT,1,[Define to 1 if database supports multirow insert statements.])
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
	fi

	DB_CFLAGS="$IBM_DB2_CPPFLAGS $MYSQL_CFLAGS $ORACLE_CPPFLAGS $POSTGRESQL_CFLAGS $SQLITE3_CPPFLAGS"
	DB_LDFLAGS="$IBM_DB2_LDFLAGS $MYSQL_LDFLAGS $ORACLE_LDFLAGS $POSTGRESQL_LDFLAGS $SQLITE3_LDFLAGS"
	DB_LIBS="$IBM_DB2_LIBS $MYSQL_LIBS $ORACLE_LIBS $POSTGRESQL_LIBS $SQLITE3_LIBS"

	AC_SUBST(DB_CFLAGS)
	AC_SUBST(DB_LDFLAGS)
	AC_SUBST(DB_LIBS)

	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${DB_LDFLAGS}"
	SERVER_LIBS="${SERVER_LIBS} ${DB_LIBS}"

	PROXY_LDFLAGS="${PROXY_LDFLAGS} ${DB_LDFLAGS}"
	PROXY_LIBS="${PROXY_LIBS} ${DB_LIBS}"

	dnl Checking for Jabber libraries
	JABBER_CHECK_CONFIG()
	if test "x$want_jabber" = "xyes"; then
		if test "x$found_jabber" != "xyes"; then
			AC_MSG_ERROR([Jabber library not found])
		else
			have_jabber="yes"
		fi
	fi
	SERVER_LDFLAGS="$SERVER_LDFLAGS $JABBER_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $JABBER_LIBS"

	AC_SUBST(JABBER_CPPFLAGS)

	dnl Check for LIBXML2 [by default - skip]
	LIBXML2_CHECK_CONFIG([no])
	if test "x$want_libxml2" = "xyes"; then
		if test "x$found_libxml2" != "xyes"; then
			AC_MSG_ERROR([LIBXML2 library not found])
		else
			have_libxml2="yes"
		fi
	fi
	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBXML2_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $LIBXML2_LIBS"

	PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBXML2_LDFLAGS"
	PROXY_LIBS="$PROXY_LIBS $LIBXML2_LIBS"

	AC_SUBST(LIBXML2_CFLAGS)

	dnl Checking for unixODBC support
	LIBUNIXODBC_CHECK_CONFIG([no])
	if test "x$want_unixodbc" = "xyes"; then
		if test "x$unixodbc_error" != "x"; then
			AC_MSG_ERROR($unixodbc_error)
		fi
		have_unixodbc="yes"
	fi
	SERVER_LDFLAGS="$SERVER_LDFLAGS $UNIXODBC_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $UNIXODBC_LIBS"

	PROXY_LDFLAGS="$PROXY_LDFLAGS $UNIXODBC_LDFLAGS"
	PROXY_LIBS="$PROXY_LIBS $UNIXODBC_LIBS"

	AC_SUBST(UNIXODBC_CFLAGS)

	dnl Check for Net-SNMP [by default - skip]
	LIBNETSNMP_CHECK_CONFIG([no])
	if test "x$want_netsnmp" = "xyes"; then
		if test "x$found_netsnmp" != "xyes"; then
			AC_MSG_ERROR([Invalid Net-SNMP directory - unable to find net-snmp-config])
		else
			have_snmp="yes"
		fi
	fi
	SERVER_LDFLAGS="$SERVER_LDFLAGS $SNMP_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $SNMP_LIBS"

	PROXY_LDFLAGS="$PROXY_LDFLAGS $SNMP_LDFLAGS"
	PROXY_LIBS="$PROXY_LIBS $SNMP_LIBS"

	AC_SUBST(SNMP_CFLAGS)

	dnl Check for LIBSSH2 [by default - skip] at least of version 1.0.0.
	LIBSSH2_CHECK_CONFIG([no])
	if test "x$want_ssh2" = "xyes"; then
		if test "x$found_ssh2" != "xyes"; then
			AC_MSG_ERROR([SSH2 library not found])
		elif test "x$accept_ssh2_version" != "xyes"; then
			AC_MSG_ERROR([SSH2 library version requirement not met (>= 1.0.0)])
		else
			have_ssh2="yes"
		fi
	fi
	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH2_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $SSH2_LIBS"

	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH2_LDFLAGS"
	PROXY_LIBS="$PROXY_LIBS $SSH2_LIBS"

	AC_SUBST(SSH2_CFLAGS)

	found_openipmi="no"
	dnl Check for libOpenIPMI [by default - skip]
	LIBOPENIPMI_CHECK_CONFIG([no])
	if test "x$want_openipmi" = "xyes"; then
		if test "x$found_openipmi" != "xyes"; then
			AC_MSG_ERROR([Invalid OPENIPMI directory - unable to find ipmiif.h])
		else
			have_ipmi="yes"
		fi
	fi

	SERVER_LDFLAGS="$SERVER_LDFLAGS $OPENIPMI_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $OPENIPMI_LIBS"

	PROXY_LDFLAGS="$PROXY_LDFLAGS $OPENIPMI_LDFLAGS"
	PROXY_LIBS="$PROXY_LIBS $OPENIPMI_LIBS"

	AC_SUBST(OPENIPMI_CFLAGS)

	dnl Check for zlib, used by Zabbix server-proxy communications
	ZLIB_CHECK_CONFIG([no])
	if test "x$found_zlib" != "xyes"; then
		AC_MSG_ERROR([Unable to use zlib (zlib check failed)])
	fi

	AC_SUBST(ZLIB_CFLAGS)

	dnl Check for 'libpthread' library that supports PTHREAD_PROCESS_SHARED flag
	LIBPTHREAD_CHECK_CONFIG([no])
	if test "x$found_libpthread" != "xyes"; then
		AC_MSG_ERROR([Unable to use libpthread (libpthread check failed)])
	fi
fi

SERVER_LDFLAGS="$SERVER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
SERVER_LIBS="$SERVER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"

PROXY_LDFLAGS="$PROXY_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
PROXY_LIBS="$PROXY_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"

AGENT_LDFLAGS="$AGENT_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
AGENT_LIBS="$AGENT_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"

ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
ZBXGET_LIBS="$ZBXGET_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"

SENDER_LDFLAGS="$SENDER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
SENDER_LIBS="$SENDER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"

AM_CONDITIONAL(HAVE_IPMI, [test "x$have_ipmi" = "xyes"])

dnl Check if Zabbix internal IPC services are used
have_ipcservice="no"
if test "x$have_ipmi" = "xyes"; then
	have_ipcservice="yes"
fi

if test "x$server" = "xyes"; then
	have_ipcservice="yes"
fi

AM_CONDITIONAL(PROXY_IPCSERVICE, [test "x$have_ipmi" = "xyes"])

dnl Check for libevent, used by Zabbix IPC services
if test "x$have_ipcservice" = "xyes"; then
	AC_DEFINE([HAVE_IPCSERVICE], 1, [Define to 1 if Zabbix IPC services are used])

	LIBEVENT_CHECK_CONFIG([no])
	if test "x$found_libevent" != "xyes"; then
		AC_MSG_ERROR([Unable to use libevent (libevent check failed)])
	fi

	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBEVENT_LDFLAGS"
	SERVER_LIBS="$SERVER_LIBS $LIBEVENT_LIBS"

	if test "x$have_ipmi" = "xyes"; then
		PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBEVENT_LDFLAGS"
		PROXY_LIBS="$PROXY_LIBS $LIBEVENT_LIBS"
	fi
fi

dnl Check for mbed TLS (PolarSSL) libpolarssl [by default - skip]
LIBMBEDTLS_CHECK_CONFIG([no])
if test "x$want_mbedtls" = "xyes"; then
	if test "x$have_tls" != "xno"; then
		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
	fi

	if test "x$found_mbedtls" != "xyes"; then
		AC_MSG_ERROR([mbed TLS (PolarSSL) library libpolarssl not found])
	elif test "x$accept_mbedtls_version" != "xyes"; then
		AC_MSG_ERROR([mbed TLS (PolarSSL) library version requirement not met (>= 1.3.9)])
	else
		have_tls="mbed TLS"
	fi
	TLS_CFLAGS="$MBEDTLS_CFLAGS"
	TLS_LDFLAGS="$MBEDTLS_LDFLAGS"
	TLS_LIBS="$MBEDTLS_LIBS"
fi

dnl Check for GnuTLS libgnutls [by default - skip]
LIBGNUTLS_CHECK_CONFIG([no])
if test "x$want_gnutls" = "xyes"; then
	if test "x$have_tls" != "xno"; then
		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
	fi

	if test "x$found_gnutls" != "xyes"; then
		AC_MSG_ERROR([GnuTLS library libgnutls not found])
	elif test "x$accept_gnutls_version" != "xyes"; then
		AC_MSG_ERROR([GnuTLS library version requirement not met (>= 3.1.18)])
	else
		have_tls="GnuTLS"
	fi
	TLS_CFLAGS="$GNUTLS_CFLAGS"
	TLS_LDFLAGS="$GNUTLS_LDFLAGS"
	TLS_LIBS="$GNUTLS_LIBS"
fi

dnl Check for OpenSSL libssl and libcrypto [by default - skip]
LIBOPENSSL_CHECK_CONFIG([no])
if test "x$want_openssl" = "xyes"; then
	if test "x$have_tls" != "xno"; then
		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
	fi

	if test "x$found_openssl" != "xyes"; then
		AC_MSG_ERROR([OpenSSL library libssl or libcrypto not found])
	elif test "x$accept_openssl_version" != "xyes"; then
		AC_MSG_ERROR([OpenSSL library version requirement not met (>= 1.0.1)])
	else
		have_tls="OpenSSL"
	fi
	TLS_CFLAGS="$OPENSSL_CFLAGS"
	TLS_LDFLAGS="$OPENSSL_LDFLAGS"
	TLS_LIBS="$OPENSSL_LIBS"
fi
AC_SUBST(TLS_CFLAGS)

SERVER_LDFLAGS="$SERVER_LDFLAGS $TLS_LDFLAGS"
SERVER_LIBS="$SERVER_LIBS $TLS_LIBS"

PROXY_LDFLAGS="$PROXY_LDFLAGS $TLS_LDFLAGS"
PROXY_LIBS="$PROXY_LIBS $TLS_LIBS"

AGENT_LDFLAGS="$AGENT_LDFLAGS $TLS_LDFLAGS"
AGENT_LIBS="$AGENT_LIBS $TLS_LIBS"

ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $TLS_LDFLAGS"
ZBXGET_LIBS="$ZBXGET_LIBS $TLS_LIBS"

SENDER_LDFLAGS="$SENDER_LDFLAGS $TLS_LDFLAGS"
SENDER_LIBS="$SENDER_LIBS $TLS_LIBS"

if test "x$java" = "xyes"; then
	AC_CHECK_PROGS([JAVAC], [javac], [no])
	if test "x$JAVAC" = "xno"; then
		AC_MSG_ERROR([Unable to find "javac" executable in path])
	fi
	AC_CHECK_PROGS([JAR], [jar], [no])
	if test "x$JAR" = "xno"; then
		AC_MSG_ERROR([Unable to find "jar" executable in path])
	fi
fi

found_ldap="no"
dnl Check for libLDAP [by default - skip]
LIBLDAP_CHECK_CONFIG([no])
if test "x$want_ldap" = "xyes"; then
	if test "x$found_ldap" != "xyes"; then
		AC_MSG_ERROR([Invalid LDAP directory - unable to find ldap.h])
	fi
fi
SERVER_LDFLAGS="$SERVER_LDFLAGS $LDAP_LDFLAGS"
SERVER_LIBS="$SERVER_LIBS $LDAP_LIBS"

PROXY_LDFLAGS="$PROXY_LDFLAGS $LDAP_LDFLAGS"
PROXY_LIBS="$PROXY_LIBS $LDAP_LIBS"

AGENT_LDFLAGS="$AGENT_LDFLAGS $LDAP_LDFLAGS"
AGENT_LIBS="$AGENT_LIBS $LDAP_LIBS"

AC_SUBST(LDAP_CPPFLAGS)

found_curl="no"
dnl Checking for libCurl [by default - skip]
LIBCURL_CHECK_CONFIG(, [7.13.1], [],[])
if test "x$want_curl" = "xyes"; then
	if test "x$found_curl" != "xyes"; then
		AC_MSG_ERROR([Curl library not found])
	fi
fi
if test "x$found_curl" = "xyes"; then
	have_web_monitoring="cURL"
fi
CFLAGS="$LIBCURL_CFLAGS $CFLAGS"

SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBCURL_LDFLAGS"
SERVER_LIBS="$SERVER_LIBS $LIBCURL_LIBS"

PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBCURL_LDFLAGS"
PROXY_LIBS="$PROXY_LIBS $LIBCURL_LIBS"

dnl Starting from 2.0 agent can do web monitoring
AGENT_LDFLAGS="$AGENT_LDFLAGS $LIBCURL_LDFLAGS"
AGENT_LIBS="$AGENT_LIBS $LIBCURL_LIBS"

dnl Check for libpcre, used by Zabbix for regular expressions
if test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes"; then
	LIBPCRE_CHECK_CONFIG([no])
	if test "x$found_libpcre" != "xyes"; then
		AC_MSG_ERROR([Unable to use libpcre (libpcre check failed)])
	fi
fi

CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS"
if test "x$ARCH" = "xosx"; then
	LIBS="$LIBPCRE_LIBS $LIBS"
else
	LIBS="$LIBS $LIBPCRE_LIBS"
fi

AC_SUBST(LIBPCRE_CFLAGS)

found_iconv="no"
dnl Check for libiconv [by default - skip]
LIBICONV_CHECK_CONFIG([no])
if test "x$found_iconv" != "xyes"; then
	AC_MSG_ERROR([Unable to use iconv (libiconv check failed)])
fi
LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
LIBS="$LIBS $ICONV_LIBS"

AC_SUBST(ICONV_CFLAGS)

RANLIB="ranlib"
AC_SUBST(RANLIB)

SERVER_CONFIG_FILE="${sysconfdir}/zabbix_server.conf"
PROXY_CONFIG_FILE="${sysconfdir}/zabbix_proxy.conf"
AGENT_CONFIG_FILE="${sysconfdir}/zabbix_agentd.conf"

EXTERNAL_SCRIPTS_PATH="${datadir}/zabbix/externalscripts"
ALERT_SCRIPTS_PATH="${datadir}/zabbix/alertscripts"

CURL_SSL_CERT_LOCATION="${datadir}/zabbix/ssl/certs"
CURL_SSL_KEY_LOCATION="${datadir}/zabbix/ssl/keys"

LOAD_MODULE_PATH="${libdir}/modules"

AC_SUBST(SERVER_LDFLAGS)
AC_SUBST(SERVER_LIBS)

AC_SUBST(PROXY_LDFLAGS)
AC_SUBST(PROXY_LIBS)

AC_SUBST(AGENT_LDFLAGS)
AC_SUBST(AGENT_LIBS)

AC_SUBST(ZBXGET_LDFLAGS)
AC_SUBST(ZBXGET_LIBS)

AC_SUBST(SENDER_LDFLAGS)
AC_SUBST(SENDER_LIBS)

AC_SUBST(SERVER_CONFIG_FILE)
AC_SUBST(PROXY_CONFIG_FILE)
AC_SUBST(AGENT_CONFIG_FILE)

AC_SUBST(EXTERNAL_SCRIPTS_PATH)
AC_SUBST(ALERT_SCRIPTS_PATH)

AC_SUBST(CURL_SSL_CERT_LOCATION)
AC_SUBST(CURL_SSL_KEY_LOCATION)

AC_SUBST(LOAD_MODULE_PATH)

dnl *****************************************************************
dnl *                                                               *
dnl *                         Other checks                          *
dnl *                                                               *
dnl *****************************************************************

dnl Automake 1.8 to 1.9.6 sets mkdir_p macro (lower-cased).
AC_MSG_CHECKING(for mkdir -p candidate)
if test "x${MKDIR_P}" = "x"; then
        if test "x${mkdir_p}" = "x"; then
                AC_MSG_ERROR([No suitable "mkdir -p" candidate found.])
        fi
        AC_SUBST([MKDIR_P], ${mkdir_p})
fi
AC_MSG_RESULT([ok (${MKDIR_P})])

dnl Check if process statistics collector should be enabled
case "x$ARCH" in
	xlinux|xsolaris)
		AC_DEFINE(ZBX_PROCSTAT_COLLECTOR, 1 , [Define to 1 on linux and solaris platforms])
		;;
esac

dnl *****************************************************************
dnl *                                                               *
dnl *                 Output configuration results                  *
dnl *                                                               *
dnl *****************************************************************


AC_OUTPUT([
	Makefile
	database/Makefile
	database/ibm_db2/Makefile
	database/mysql/Makefile
	database/oracle/Makefile
	database/postgresql/Makefile
	database/sqlite3/Makefile
	misc/Makefile
	src/Makefile
	src/libs/Makefile
	src/libs/zbxlog/Makefile
	src/libs/zbxalgo/Makefile
	src/libs/zbxmemory/Makefile
	src/libs/zbxcrypto/Makefile
	src/libs/zbxconf/Makefile
	src/libs/zbxdbcache/Makefile
	src/libs/zbxdbhigh/Makefile
	src/libs/zbxmedia/Makefile
	src/libs/zbxsysinfo/Makefile
	src/libs/zbxcommon/Makefile
	src/libs/zbxsysinfo/agent/Makefile
	src/libs/zbxsysinfo/common/Makefile
	src/libs/zbxsysinfo/simple/Makefile
	src/libs/zbxsysinfo/linux/Makefile
	src/libs/zbxsysinfo/aix/Makefile
	src/libs/zbxsysinfo/freebsd/Makefile
	src/libs/zbxsysinfo/hpux/Makefile
	src/libs/zbxsysinfo/openbsd/Makefile
	src/libs/zbxsysinfo/osx/Makefile
	src/libs/zbxsysinfo/solaris/Makefile
	src/libs/zbxsysinfo/osf/Makefile
	src/libs/zbxsysinfo/netbsd/Makefile
	src/libs/zbxsysinfo/unknown/Makefile
	src/libs/zbxnix/Makefile
	src/libs/zbxsys/Makefile
	src/libs/zbxcomms/Makefile
	src/libs/zbxcommshigh/Makefile
	src/libs/zbxdb/Makefile
	src/libs/zbxdbupgrade/Makefile
	src/libs/zbxjson/Makefile
	src/libs/zbxhttp/Makefile
	src/libs/zbxserver/Makefile
	src/libs/zbxicmpping/Makefile
	src/libs/zbxexec/Makefile
	src/libs/zbxself/Makefile
	src/libs/zbxmodules/Makefile
	src/libs/zbxregexp/Makefile
	src/libs/zbxtasks/Makefile
	src/libs/zbxipcservice/Makefile
	src/libs/zbxhistory/Makefile
	src/libs/zbxcompress/Makefile
	src/zabbix_agent/Makefile
	src/zabbix_get/Makefile
	src/zabbix_sender/Makefile
	src/zabbix_server/Makefile
	src/zabbix_server/alerter/Makefile
	src/zabbix_server/dbsyncer/Makefile
	src/zabbix_server/dbconfig/Makefile
	src/zabbix_server/discoverer/Makefile
	src/zabbix_server/housekeeper/Makefile
	src/zabbix_server/httppoller/Makefile
	src/zabbix_server/pinger/Makefile
	src/zabbix_server/poller/Makefile
	src/zabbix_server/snmptrapper/Makefile
	src/zabbix_server/timer/Makefile
	src/zabbix_server/trapper/Makefile
	src/zabbix_server/escalator/Makefile
	src/zabbix_server/proxypoller/Makefile
	src/zabbix_server/selfmon/Makefile
	src/zabbix_server/vmware/Makefile
	src/zabbix_server/taskmanager/Makefile
	src/zabbix_server/ipmi/Makefile
	src/zabbix_server/odbc/Makefile
	src/zabbix_server/scripts/Makefile
	src/zabbix_server/preprocessor/Makefile
	src/zabbix_proxy/Makefile
	src/zabbix_proxy/heart/Makefile
	src/zabbix_proxy/housekeeper/Makefile
	src/zabbix_proxy/proxyconfig/Makefile
	src/zabbix_proxy/datasender/Makefile
	src/zabbix_proxy/taskmanager/Makefile
	src/zabbix_java/Makefile
	man/Makefile
	])

dnl The following variables use autoconf variables such as
dnl ${sysconfdir} and ${datadir} . Which in turn contain
dnl variables such as ${prefix}. In order to completely
dnl substitute all variables and output end-value in
dnl Configuration output below it is required to perform 2
dnl substitutions.

SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`
SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`

PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`
PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`

AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`
AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`

EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`
EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`

ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`
ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`

CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`
CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`

CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`
CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`

LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`
LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`

echo "

Configuration:

  Detected OS:           ${host_os}
  Install path:          ${prefix}
  Compilation arch:      ${ARCH}

  Compiler:              ${CC}
  Compiler flags:        ${CFLAGS}

  Library-specific flags:"

if test "x$DB_CFLAGS" != "x"; then
	echo "    database:              ${DB_CFLAGS}"
fi

if test "x$JABBER_CPPFLAGS" != "x"; then
	echo "    Jabber:                ${JABBER_CPPFLAGS}"
fi

if test "x$LIBXML2_CFLAGS" != "x"; then
	echo "    libXML2:               ${LIBXML2_CFLAGS}"
fi

if test "x$UNIXODBC_CFLAGS" != "x"; then
	echo "    unixODBC:              ${UNIXODBC_CFLAGS}"
fi

if test "x$SNMP_CFLAGS" != "x"; then
	echo "    Net-SNMP:              ${SNMP_CFLAGS}"
fi

if test "x$OPENIPMI_CFLAGS" != "x"; then
	echo "    OpenIPMI:              ${OPENIPMI_CFLAGS}"
fi

if test "x$SSH2_CFLAGS" != "x"; then
	echo "    libssh2:               ${SSH2_CFLAGS}"
fi

if test "x$TLS_CFLAGS" != "x"; then
	echo "    TLS:                   ${TLS_CFLAGS}"
fi

if test "x$LDAP_CPPFLAGS" != "x"; then
	echo "    LDAP:                  ${LDAP_CPPFLAGS}"
fi

if test "x$ICONV_CFLAGS" != "x"; then
	echo "    iconv:                 ${ICONV_CFLAGS}"
fi

if test "x$LIBEVENT_CFLAGS" != "x"; then
	echo "    libevent:              ${LIBEVENT_CFLAGS}"
fi

echo "
  Enable server:         ${server}"

if test "x$server" != "xno"; then

echo "  Server details:
    With database:         ${have_db}
    WEB Monitoring:        ${have_web_monitoring}"

if test "x$have_web_monitoring" = "xcURL"; then
echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
fi

echo "    Native Jabber:         ${have_jabber}
    SNMP:                  ${have_snmp}
    IPMI:                  ${have_ipmi}
    SSH:                   ${have_ssh2}
    TLS:                   ${have_tls}
    ODBC:                  ${have_unixodbc}
    Linker flags:          ${SERVER_LDFLAGS} ${LDFLAGS}
    Libraries:             ${SERVER_LIBS} ${LIBS}
    Configuration file:    ${SERVER_CONFIG_FILE}
    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
    Alert scripts:         ${ALERT_SCRIPTS_PATH}
    Modules:               ${LOAD_MODULE_PATH}"

fi

echo "
  Enable proxy:          ${proxy}"

if test "x$proxy" != "xno"; then

echo "  Proxy details:
    With database:         ${have_db}
    WEB Monitoring:        ${have_web_monitoring}"

if test "x$have_web_monitoring" = "xcURL"; then
echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
fi

echo "    SNMP:                  ${have_snmp}
    IPMI:                  ${have_ipmi}
    SSH:                   ${have_ssh2}
    TLS:                   ${have_tls}
    ODBC:                  ${have_unixodbc}
    Linker flags:          ${PROXY_LDFLAGS} ${LDFLAGS}
    Libraries:             ${PROXY_LIBS} ${LIBS}
    Configuration file:    ${PROXY_CONFIG_FILE}
    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
    Modules:               ${LOAD_MODULE_PATH}"

fi

echo "
  Enable agent:          ${agent}"

if test "x$agent" != "xno"; then

echo "  Agent details:
    TLS:                   ${have_tls}
    Linker flags:          ${AGENT_LDFLAGS} ${LDFLAGS}
    Libraries:             ${AGENT_LIBS} ${LIBS}
    Configuration file:    ${AGENT_CONFIG_FILE}
    Modules:               ${LOAD_MODULE_PATH}"

fi

echo "
  Enable Java gateway:   ${java}"

if test "x$java" != "xno"; then

echo "  Java gateway details:
    Java compiler:         ${JAVAC}
    Java archiver:         ${JAR}"

fi

echo "
  LDAP support:          ${found_ldap}
  IPv6 support:          ${have_ipv6}"

echo
echo "***********************************************************"
echo "*            Now run '${am_make} install'                       *"
echo "*                                                         *"
echo "*            Thank you for using Zabbix!                  *"
echo "*              <http://www.zabbix.com>                    *"
echo "***********************************************************"
echo