1dnl
2dnl Zabbix
3dnl Copyright (C) 2001-2021 Zabbix SIA
4dnl
5dnl This program is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 2 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; if not, write to the Free Software
17dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18dnl
19
20dnl Process this file with autoconf to produce a configure script.
21
22AC_INIT([Zabbix],[4.0.30])
23AC_CONFIG_SRCDIR(src/zabbix_server/server.c)
24AM_INIT_AUTOMAKE([subdir-objects  filename-length-max=99])
25
26AC_MSG_NOTICE([Configuring $PACKAGE_NAME $PACKAGE_VERSION])
27
28AC_PROG_MAKE_SET
29
30AM_CONFIG_HEADER(include/config.h)
31
32AC_CANONICAL_HOST
33
34dnl *****************************************************************
35dnl *                                                               *
36dnl *                     Checks for programs                       *
37dnl *                                                               *
38dnl *****************************************************************
39
40AC_PROG_CC([cc c99 gcc clang])
41AM_PROG_CC_C_O
42
43dnl *****************************************************************
44dnl *                                                               *
45dnl *                   Checks for header files                     *
46dnl *                                                               *
47dnl *****************************************************************
48
49AC_HEADER_STDC
50AC_CHECK_HEADERS(stdio.h stdlib.h string.h unistd.h netdb.h signal.h \
51  syslog.h time.h errno.h sys/types.h sys/stat.h netinet/in.h \
52  math.h sys/socket.h dirent.h ctype.h \
53  mtent.h fcntl.h sys/param.h arpa/inet.h \
54  sys/vfs.h sys/pstat.h sys/sysinfo.h sys/statvfs.h sys/statfs.h \
55  sys/socket.h sys/loadavg.h arpa/inet.h \
56  sys/vmmeter.h strings.h vm/vm_param.h \
57  sys/time.h kstat.h sys/syscall.h sys/sysmacros.h \
58  stdint.h mach/host_info.h mach/mach_host.h knlist.h pwd.h \
59  sys/var.h arpa/nameser.h assert.h sys/dkstat.h sys/disk.h sys/sched.h \
60  zone.h nlist.h kvm.h linux/kernel.h procinfo.h sys/dk.h \
61  sys/resource.h pthread.h windows.h process.h conio.h sys/wait.h \
62  stdarg.h winsock2.h pdh.h psapi.h sys/sem.h sys/ipc.h sys/shm.h Winldap.h \
63  Winber.h lber.h ws2tcpip.h inttypes.h sys/file.h grp.h \
64  execinfo.h sys/systemcfg.h sys/mnttab.h mntent.h sys/times.h \
65  dlfcn.h sys/utsname.h sys/un.h sys/protosw.h stddef.h limits.h)
66AC_CHECK_HEADERS(resolv.h, [], [], [
67#ifdef HAVE_SYS_TYPES_H
68#  include <sys/types.h>
69#endif
70#ifdef HAVE_NETINET_IN_H
71#  include <netinet/in.h>
72#endif
73#ifdef HAVE_ARPA_NAMESER_H
74#  include <arpa/nameser.h>
75#endif
76#ifdef HAVE_NETDB_H
77#  include <netdb.h>
78#endif
79])
80AC_CHECK_HEADERS(net/if.h net/if_mib.h, [], [], [
81#include <stdio.h>
82#ifdef STDC_HEADERS
83#  include <stdlib.h>
84#  include <stddef.h>
85#else
86#  ifdef HAVE_STDLIB_H
87#    include <stdlib.h>
88#  endif
89#endif
90#ifdef HAVE_SYS_TYPES_H
91#  include <sys/types.h>
92#endif
93#ifdef HAVE_SYS_SOCKET_H
94#  include <sys/socket.h>
95#endif
96/* for net/if_mib.h */
97#ifdef HAVE_NET_IF_H
98#  include <net/if.h>
99#endif
100])
101
102AC_MSG_CHECKING(whether compiler supports -Werror=cpp)
103checked_werror_cpp_CFLAGS=""
104saved_CFLAGS="$CFLAGS"
105CFLAGS="$CFLAGS -Werror=cpp"
106AC_TRY_COMPILE(,[
107  void f() {};
108],checked_werror_cpp_CFLAGS="-Werror=cpp"
109  AC_MSG_RESULT(yes),
110  AC_MSG_RESULT(no)
111)
112CFLAGS="$saved_CFLAGS"
113
114saved_CFLAGS="$CFLAGS"
115CFLAGS="$checked_werror_cpp_CFLAGS $CFLAGS"
116AC_CHECK_HEADERS(sys/mount.h sys/proc.h sys/sysctl.h sys/user.h, [], [], [
117#ifdef HAVE_SYS_TYPES_H
118#  include <sys/types.h>
119#endif
120#ifdef HAVE_SYS_PARAM_H
121#  include <sys/param.h>
122#endif
123])
124CFLAGS="$saved_CFLAGS"
125
126AC_CHECK_HEADERS(sys/swap.h, [], [], [
127#ifdef HAVE_SYS_PARAM_H
128#  include <sys/param.h>
129#endif
130])
131AC_CHECK_HEADERS(sys/ucontext.h, [], [], [
132#ifdef HAVE_SIGNAL_H
133#  include <signal.h>
134#endif
135])
136AC_CHECK_HEADERS(devstat.h, [], [], [
137#ifdef HAVE_SYS_DKSTAT_H
138#  include <sys/dkstat.h>
139#endif
140])
141AC_CHECK_HEADERS(linux/netlink.h, [
142	AC_CHECK_HEADERS(linux/inet_diag.h, [
143		AC_DEFINE([HAVE_INET_DIAG], 1, [Define to 1 if you have NETLINK INET_DIAG support.])
144	])
145], [], [
146#ifdef HAVE_SYS_SOCKET_H
147#  include <sys/socket.h>
148#endif
149])
150AC_CHECK_HEADERS(libperfstat.h, [], [], [
151#ifdef HAVE_SYS_PROTOSW_H
152#  include <sys/protosw.h>
153#endif
154])
155
156dnl *****************************************************************
157dnl *                                                               *
158dnl *                     Checks for libraries                      *
159dnl *                                                               *
160dnl *****************************************************************
161
162AC_SEARCH_LIBS(socket, socket)
163AC_SEARCH_LIBS(kstat_open, kstat)
164AC_SEARCH_LIBS(gethostbyname, nsl)
165AC_SEARCH_LIBS(clock_gettime, rt)
166AC_SEARCH_LIBS(dlopen, dl)
167
168dnl AIX
169AC_SEARCH_LIBS(perfstat_memory_total, perfstat, [AC_DEFINE([HAVE_LIBPERFSTAT], 1, [Define to 1 if you have the 'libperfstat' library (-lperfstat)])])
170AC_SEARCH_LIBS(devstat_getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])
171AC_SEARCH_LIBS(getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])
172
173dnl on FreeBSD we have to link with -lexecinfo to get backtraces
174AC_SEARCH_LIBS(backtrace_symbols, execinfo, [AC_DEFINE([HAVE_LIBEXECINFO], 1, [Define to 1 if you have the 'libexecinfo' library (-lexecinfo)])])
175
176AC_CHECK_LIB(m, main)
177AC_CHECK_LIB(kvm, main)
178
179dnl check for DNS lookup functions
180found_resolv="no"
181LIBRESOLV_CHECK_CONFIG([no])
182if test "x$found_resolv" != "xyes"; then
183	AC_MSG_ERROR([Unable to do DNS lookups (libresolv check failed)])
184fi
185LIBS="${LIBS} ${RESOLV_LIBS}"
186
187dnl *****************************************************************
188dnl *                                                               *
189dnl *          Checks for type definitions and structures           *
190dnl *                                                               *
191dnl *****************************************************************
192
193dnl large file support
194largefile=yes
195
196dnl disable large file support on 32-bit Solaris as it's incompatible with procfs and swapctl
197case "${host_os}" in
198	solaris*)
199		largefile=no
200		;;
201esac
202
203if test "x$largefile" = "xyes"; then
204	AC_SYS_LARGEFILE
205fi
206
207AC_C_CONST
208AC_TYPE_PID_T
209
210AC_MSG_CHECKING(for socklen_t)
211AC_TRY_COMPILE([
212#include <sys/types.h>
213#include <unistd.h>
214#include <sys/socket.h>
215],[socklen_t s;],
216AC_MSG_RESULT(yes),
217[AC_DEFINE(socklen_t, int, [Define socklen_t type.])
218AC_MSG_RESULT(no)])
219
220AC_MSG_CHECKING(for actual socklen_t parameter type in socket functions)
221zbx_socklen_t=
222for arg2 in "struct sockaddr" void; do
223  for arg3 in socklen_t size_t int; do
224    AC_TRY_COMPILE([
225#ifdef HAVE_SYS_TYPES_H
226#  include <sys/types.h>
227#endif
228#ifdef HAVE_SYS_SOCKET_H
229#  include <sys/socket.h>
230#endif
231      extern int getpeername(int sockfd, $arg2 *addr, $arg3 *addrlen);
232    ],[
233      $arg3 addrlen;
234      getpeername(0, 0, &addrlen);
235    ],[
236      zbx_socklen_t="$arg3"
237      break 2
238    ])
239  done
240done
241if test "x$zbx_socklen_t" != "x"; then
242  AC_MSG_RESULT($zbx_socklen_t)
243  AC_DEFINE_UNQUOTED(ZBX_SOCKLEN_T, $zbx_socklen_t, [Define actual socklen_t parameter type in socket functions.])
244else
245  AC_MSG_RESULT(leaving undefined)
246fi
247
248AC_MSG_CHECKING(for integer field name in union sigval of struct siginfo_t)
249zbx_sival_int=
250for field in sival_int sigval_int; do
251  AC_TRY_COMPILE([
252#ifdef HAVE_SIGNAL_H
253#  include <signal.h>
254#endif
255  ],[
256    siginfo_t siginfo;
257    siginfo.si_value.$field = 0;
258  ],[
259    zbx_sival_int="$field"
260    break
261  ])
262done
263if test "x$zbx_sival_int" != "x"; then
264  AC_MSG_RESULT($zbx_sival_int)
265  AC_DEFINE_UNQUOTED(ZBX_SIVAL_INT, $zbx_sival_int, [Define integer field name in union 'sigval' of struct 'siginfo_t'])
266else
267  AC_MSG_ERROR(Unable to find integer field name in union sigval of struct siginfo_t)
268fi
269
270AC_MSG_CHECKING(for res_ninit)
271AC_TRY_LINK(
272[
273#ifdef HAVE_SYS_TYPES_H
274#	include <sys/types.h>
275#endif
276#ifdef HAVE_NETINET_IN_H
277#	include <netinet/in.h>
278#endif
279#ifdef HAVE_ARPA_NAMESER_H
280#	include <arpa/nameser.h>
281#endif
282#ifdef HAVE_RESOLV_H
283#	include <resolv.h>
284#endif
285#ifndef C_IN
286#	define C_IN	ns_c_in
287#endif	/* C_IN */
288#ifndef T_SOA
289#	define T_SOA	ns_t_soa
290#endif	/* T_SOA */
291],
292[
293	struct __res_state	res_state_local;
294
295	res_ninit(&res_state_local);
296],
297AC_DEFINE(HAVE_RES_NINIT,1,[Define to 1 if 'res_ninit' exists.])
298AC_MSG_RESULT(yes),
299AC_MSG_RESULT(no))
300
301AC_MSG_CHECKING(for res_ndestroy)
302AC_TRY_LINK(
303[
304#ifdef HAVE_SYS_TYPES_H
305#	include <sys/types.h>
306#endif
307#ifdef HAVE_NETINET_IN_H
308#	include <netinet/in.h>
309#endif
310#ifdef HAVE_ARPA_NAMESER_H
311#	include <arpa/nameser.h>
312#endif
313#ifdef HAVE_RESOLV_H
314#	include <resolv.h>
315#endif
316#ifndef C_IN
317#	define C_IN	ns_c_in
318#endif	/* C_IN */
319#ifndef T_SOA
320#	define T_SOA	ns_t_soa
321#endif	/* T_SOA */
322],
323[
324	struct __res_state	res_state_local;
325
326	res_ninit(&res_state_local);
327	res_ndestroy(&res_state_local);
328],
329AC_DEFINE(HAVE_RES_NDESTROY,1,[Define to 1 if 'res_ndestroy' exists.])
330AC_MSG_RESULT(yes),
331AC_MSG_RESULT(no))
332
333AC_MSG_CHECKING(for _res._u._ext.nsaddrs[])
334AC_TRY_LINK(
335[
336#ifdef HAVE_SYS_TYPES_H
337#	include <sys/types.h>
338#endif
339#ifdef HAVE_NETINET_IN_H
340#	include <netinet/in.h>
341#endif
342#ifdef HAVE_ARPA_NAMESER_H
343#	include <arpa/nameser.h>
344#endif
345#ifdef HAVE_RESOLV_H
346#	include <resolv.h>
347#endif
348#ifndef C_IN
349#	define C_IN	ns_c_in
350#endif	/* C_IN */
351#ifndef T_SOA
352#	define T_SOA	ns_t_soa
353#endif	/* T_SOA */
354],
355[
356	struct sockaddr_in6	*sockaddrin6;
357
358	sockaddrin6 = _res._u._ext.nsaddrs[0];
359],
360AC_DEFINE(HAVE_RES_U_EXT,1,[Define to 1 if '_res._u._ext.nsaddrs[]' exists. /Linux/])
361AC_MSG_RESULT(yes),
362AC_MSG_RESULT(no))
363
364AC_MSG_CHECKING(for _res._u._ext.ext)
365AC_TRY_LINK(
366[
367#ifdef HAVE_SYS_TYPES_H
368#	include <sys/types.h>
369#endif
370#ifdef HAVE_NETINET_IN_H
371#	include <netinet/in.h>
372#endif
373#ifdef HAVE_ARPA_NAMESER_H
374#	include <arpa/nameser.h>
375#endif
376#ifdef HAVE_RESOLV_H
377#	include <resolv.h>
378#endif
379#ifndef C_IN
380#	define C_IN	ns_c_in
381#endif	/* C_IN */
382#ifndef T_SOA
383#	define T_SOA	ns_t_soa
384#endif	/* T_SOA */
385],
386[
387	struct __res_state_ext	*ext;
388
389	ext = _res._u._ext.ext;
390],
391AC_DEFINE(HAVE_RES_U_EXT_EXT,1,[Define to 1 if '_res._u._ext.ext' exists. /BSD/])
392AC_MSG_RESULT(yes),
393AC_MSG_RESULT(no))
394
395AC_MSG_CHECKING(for _res._ext.ext.nsaddrs[])
396AC_TRY_LINK(
397[
398#ifdef HAVE_SYS_TYPES_H
399#	include <sys/types.h>
400#endif
401#ifdef HAVE_NETINET_IN_H
402#	include <netinet/in.h>
403#endif
404#ifdef HAVE_ARPA_NAMESER_H
405#	include <arpa/nameser.h>
406#endif
407#ifdef HAVE_RESOLV_H
408#	include <resolv.h>
409#endif
410#ifndef C_IN
411#	define C_IN	ns_c_in
412#endif	/* C_IN */
413#ifndef T_SOA
414#	define T_SOA	ns_t_soa
415#endif	/* T_SOA */
416],
417[
418	union res_sockaddr_union	*na;
419
420	na = &_res._ext.ext.nsaddrs[0];
421],
422AC_DEFINE(HAVE_RES_EXT_EXT,1,[Define to 1 if '_res._ext.ext.nsaddrs[]' exists. /AIX/])
423AC_MSG_RESULT(yes),
424AC_MSG_RESULT(no))
425
426AC_MSG_CHECKING(for struct sockaddr_in6.sin6_len)
427AC_TRY_LINK(
428[
429#ifdef HAVE_SYS_TYPES_H
430#	include <sys/types.h>
431#endif
432#ifdef HAVE_NETINET_IN_H
433#	include <netinet/in.h>
434#endif
435#ifdef HAVE_ARPA_NAMESER_H
436#	include <arpa/nameser.h>
437#endif
438#ifdef HAVE_RESOLV_H
439#	include <resolv.h>
440#endif
441#ifndef C_IN
442#	define C_IN	ns_c_in
443#endif	/* C_IN */
444#ifndef T_SOA
445#	define T_SOA	ns_t_soa
446#endif	/* T_SOA */
447],
448[
449	struct sockaddr_in6	sin6;
450	unsigned int		len;
451
452	len = sin6.sin6_len;
453],
454AC_DEFINE(HAVE_RES_SIN6_LEN,1,[Define to 1 if 'sockaddr_in6.sin6_len' exists. /BSD/])
455AC_MSG_RESULT(yes),
456AC_MSG_RESULT(no))
457
458AC_MSG_CHECKING(for union semun)
459AC_TRY_COMPILE(
460[
461#include <sys/types.h>
462#include <sys/ipc.h>
463#include <sys/sem.h>
464],
465[union semun foo;],
466AC_DEFINE(HAVE_SEMUN, 1, [Define to 1 if union 'semun' exists.])
467AC_MSG_RESULT(yes),
468AC_MSG_RESULT(no))
469
470AC_MSG_CHECKING(for struct swaptable in sys/swap.h)
471AC_TRY_COMPILE(
472[
473#include <stdlib.h>
474#include <sys/types.h>
475#include <sys/syscall.h>
476#include <sys/swap.h>
477
478#ifndef NULL
479#define NULL (void *)0
480#endif
481],
482[
483    register int cnt, i;
484    register int t, f;
485    struct swaptable *swt;
486    struct swapent *ste;
487    static char path[256];
488
489    /* get total number of swap entries */
490    cnt = swapctl(SC_GETNSWP, 0);
491
492    /* allocate enough space to hold count + n swapents */
493    swt = (struct swaptable *)malloc(sizeof(int) +
494             cnt * sizeof(struct swapent));
495    if (swt == NULL)
496    {
497  return;
498    }
499    swt->swt_n = cnt;
500
501    /* fill in ste_path pointers: we do not care about the paths, so we
502point
503       them all to the same buffer */
504    ste = &(swt->swt_ent[0]);
505    i = cnt;
506    while (--i >= 0)
507    {
508  ste++->ste_path = path;
509    }
510
511    /* grab all swap info */
512    swapctl(SC_LIST, swt);
513
514    /* walk through the structs and sum up the fields */
515    t = f = 0;
516    ste = &(swt->swt_ent[0]);
517    i = cnt;
518    while (--i >= 0)
519    {
520  /* do not count slots being deleted */
521  if (!(ste->ste_flags & ST_INDEL) &&
522      !(ste->ste_flags & ST_DOINGDEL))
523  {
524      t += ste->ste_pages;
525      f += ste->ste_free;
526  } ste++;
527    }
528
529    /* fill in the results */
530    free(swt);
531
532],
533AC_DEFINE(HAVE_SYS_SWAP_SWAPTABLE,1,[Define to 1 if struct 'swaptable' exists.])
534AC_MSG_RESULT(yes),
535AC_MSG_RESULT(no))
536
537AC_MSG_CHECKING(for struct sensordev in sys/sensors.h)
538AC_TRY_COMPILE([
539#include <stdlib.h>
540#include <sys/queue.h>
541#include <sys/sensors.h>],
542[struct sensordev sensordev;
543sensordev.xname[0]='\0';
544sensordev.maxnumt[0]=0;
545],
546AC_DEFINE(HAVE_SENSORDEV,1,[Define to 1 if struct 'sensordev' exists.])
547AC_MSG_RESULT(yes),
548AC_MSG_RESULT(no))
549
550AC_MSG_CHECKING(for struct statvfs64 in sys/statvfs.h)
551AC_TRY_COMPILE(
552[
553#ifdef HAVE_SYS_TYPES_H
554#	include <sys/types.h>
555#endif
556#ifdef HAVE_SYS_STATVFS_H
557#	include <sys/statvfs.h>
558#endif
559],
560[
561	struct statvfs64	s;
562	s.f_frsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
563	statvfs64("/", &s);
564],
565AC_DEFINE(HAVE_SYS_STATVFS64, 1, [Define to 1 if struct 'statvfs64' exists.])
566AC_MSG_RESULT(yes),
567AC_MSG_RESULT(no))
568
569AC_MSG_CHECKING(for struct statfs64 in sys/statfs.h)
570AC_TRY_COMPILE(
571[
572#ifdef HAVE_SYS_TYPES_H
573#	include <sys/types.h>
574#endif
575#ifdef HAVE_SYS_STATFS_H
576#	include <sys/statfs.h>
577#endif
578],
579[
580	struct statfs64	s;
581	s.f_bsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
582	statfs64("/", &s);
583],
584AC_DEFINE(HAVE_SYS_STATFS64, 1, [Define to 1 if struct 'statfs64' exists.])
585AC_MSG_RESULT(yes),
586AC_MSG_RESULT(no))
587
588AC_MSG_CHECKING(for field ss_family in struct sockaddr_storage)
589AC_TRY_COMPILE([#include <sys/socket.h>],
590[struct sockaddr_storage ss;
591ss.ss_family = 0;
592],
593AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_FAMILY, 1, [Define to 1 if 'sockaddr_storage.ss_family' exists.])
594AC_MSG_RESULT(yes),
595AC_MSG_RESULT(no))
596
597AC_MSG_CHECKING(for field mem_unit in struct sysinfo)
598AC_TRY_COMPILE([#include <sys/sysinfo.h>],
599[struct sysinfo sysinfo;
600sysinfo.mem_unit=0;
601],
602AC_DEFINE(HAVE_SYSINFO_MEM_UNIT,1,[Define to 1 if 'sysinfo.mem_unit' exists.])
603AC_MSG_RESULT(yes),
604AC_MSG_RESULT(no))
605
606AC_MSG_CHECKING(for field freeswap in struct sysinfo)
607AC_TRY_COMPILE([#include <sys/sysinfo.h>],
608[struct sysinfo sysinfo;
609sysinfo.freeswap=0;
610],
611AC_DEFINE(HAVE_SYSINFO_FREESWAP,1,[Define to 1 if 'sysinfo.freeswap' exists.])
612AC_MSG_RESULT(yes),
613AC_MSG_RESULT(no))
614
615AC_MSG_CHECKING(for field totalswap in struct sysinfo)
616AC_TRY_COMPILE([#include <sys/sysinfo.h>],
617[struct sysinfo sysinfo;
618sysinfo.totalswap=0;
619],
620AC_DEFINE(HAVE_SYSINFO_TOTALSWAP,1,[Define to 1 if 'sysinfo.totalswap' exists.])
621AC_MSG_RESULT(yes),
622AC_MSG_RESULT(no))
623
624AC_MSG_CHECKING(for field totalram in struct sysinfo)
625AC_TRY_COMPILE([#include <sys/sysinfo.h>],
626[struct sysinfo sysinfo;
627sysinfo.totalram=0;
628],
629AC_DEFINE(HAVE_SYSINFO_TOTALRAM,1,[Define to 1 if 'sysinfo.totalram' exists.])
630AC_MSG_RESULT(yes),
631AC_MSG_RESULT(no))
632
633AC_MSG_CHECKING(for field sharedram in struct sysinfo)
634AC_TRY_COMPILE([#include <sys/sysinfo.h>],
635[struct sysinfo sysinfo;
636sysinfo.sharedram=0;
637],
638AC_DEFINE(HAVE_SYSINFO_SHAREDRAM,1,[Define to 1 if 'sysinfo.sharedram' exists.])
639AC_MSG_RESULT(yes),
640AC_MSG_RESULT(no))
641
642AC_MSG_CHECKING(for field bufferram in struct sysinfo)
643AC_TRY_COMPILE([#include <sys/sysinfo.h>],
644[struct sysinfo sysinfo;
645sysinfo.bufferram=0;
646],
647AC_DEFINE(HAVE_SYSINFO_BUFFERRAM,1,[Define to 1 if 'sysinfo.bufferram' exists.])
648AC_MSG_RESULT(yes),
649AC_MSG_RESULT(no))
650
651AC_MSG_CHECKING(for field freeram in struct sysinfo)
652AC_TRY_COMPILE([#include <sys/sysinfo.h>],
653[struct sysinfo sysinfo;
654sysinfo.freeram=0;
655],
656AC_DEFINE(HAVE_SYSINFO_FREERAM,1,[Define to 1 if 'sysinfo.freeram' exists.])
657AC_MSG_RESULT(yes),
658AC_MSG_RESULT(no))
659
660AC_MSG_CHECKING(for field uptime in struct sysinfo)
661AC_TRY_COMPILE([#include <sys/sysinfo.h>],
662[struct sysinfo sysinfo;
663sysinfo.uptime=0;
664],
665AC_DEFINE(HAVE_SYSINFO_UPTIME,1,[Define to 1 if 'sysinfo.uptime' exists.])
666AC_MSG_RESULT(yes),
667AC_MSG_RESULT(no))
668
669AC_MSG_CHECKING(for field procs in struct sysinfo)
670AC_TRY_COMPILE([#include <sys/sysinfo.h>],
671[struct sysinfo sysinfo;
672sysinfo.procs=0;
673],
674AC_DEFINE(HAVE_SYSINFO_PROCS,1,[Define to 1 if 'sysinfo.procs' exists.])
675AC_MSG_RESULT(yes),
676AC_MSG_RESULT(no))
677
678AC_MSG_CHECKING(for field tm_gmtoff in struct tm)
679AC_TRY_COMPILE([
680#ifdef HAVE_SYS_TIME_H
681#include <sys/time.h>
682#endif	/* HAVE_SYS_TIME_H */
683
684#ifdef HAVE_TIME_H
685#include <time.h>
686#endif	/* HAVE_TIME_H */
687],
688[
689	struct tm tm;
690	tm.tm_gmtoff;
691],
692AC_DEFINE(HAVE_TM_TM_GMTOFF,1,[Define to 1 if 'tm.tm_gmtoff' exists.])
693AC_MSG_RESULT(yes),
694AC_MSG_RESULT(no))
695
696AC_MSG_CHECKING(for field updates in struct vminfo_t)
697AC_TRY_COMPILE([
698#include <sys/sysinfo.h>
699],
700[
701	vminfo_t vminfo;
702	vminfo.updates;
703],
704AC_DEFINE(HAVE_VMINFO_T_UPDATES,1,[Define to 1 if 'vminfo.updates' exists.])
705AC_MSG_RESULT(yes),
706AC_MSG_RESULT(no))
707
708dnl *****************************************************************
709dnl *                                                               *
710dnl *                     Checks for functions                      *
711dnl *                                                               *
712dnl *****************************************************************
713
714AC_MSG_CHECKING(for function sysconf() in unistd.h)
715AC_TRY_COMPILE(
716[
717#include <unistd.h>
718],
719[	int i;
720
721	i=sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
722	i=sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
723],
724AC_DEFINE(HAVE_UNISTD_SYSCONF,1,[Define to 1 if function 'sysconf' exists.])
725AC_MSG_RESULT(yes),
726AC_MSG_RESULT(no))
727
728AC_MSG_CHECKING(for function initgroups())
729AC_TRY_LINK(
730[
731#include <sys/types.h>
732#include <grp.h>
733],
734[
735	char	*user = "zabbix";
736	initgroups(user, 0);
737],
738AC_DEFINE(HAVE_FUNCTION_INITGROUPS,1,[Define to 1 if function 'initgroups' exists.])
739AC_MSG_RESULT(yes),
740AC_MSG_RESULT(no))
741
742AC_MSG_CHECKING(for functions seteuid() and setegid())
743AC_TRY_LINK(
744[
745#include <sys/types.h>
746#include <unistd.h>
747],
748[
749	seteuid(0);
750	setegid(0);
751],
752AC_DEFINE(HAVE_FUNCTION_SETEUID,1,[Define to 1 if functions 'seteuid' and 'setegid' exist.])
753AC_MSG_RESULT(yes),
754AC_MSG_RESULT(no))
755
756AC_MSG_CHECKING(for function setproctitle())
757AC_TRY_LINK(
758[
759#include <sys/types.h>
760#include <unistd.h>
761],
762[
763	setproctitle("Test %d", 1);
764],
765AC_DEFINE(HAVE_FUNCTION_SETPROCTITLE,1,[Define to 1 if function 'setproctitle' exists.])
766AC_MSG_RESULT(yes),
767AC_MSG_RESULT(no))
768
769AC_MSG_CHECKING(for function sysctlbyname())
770AC_TRY_LINK(
771[
772#ifdef HAVE_SYS_TYPES_H
773#include <sys/types.h>
774#endif /* HAVE_SYS_TYPES_H */
775
776#ifdef HAVE_SYS_PARAM_H
777#include <sys/param.h>
778#endif /* HAVE_SYS_PARAM_H */
779
780#include <sys/sysctl.h>
781],
782[
783	sysctlbyname("", 0, 0, 0, 0);
784],
785AC_DEFINE(HAVE_FUNCTION_SYSCTLBYNAME,1,[Define to 1 if 'sysctlbyname' exists.])
786AC_MSG_RESULT(yes),
787AC_MSG_RESULT(no))
788
789AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME))
790AC_TRY_COMPILE(
791[
792#ifdef HAVE_SYS_TYPES_H
793#include <sys/types.h>
794#endif /* HAVE_SYS_TYPES_H */
795
796#ifdef HAVE_SYS_PARAM_H
797#include <sys/param.h>
798#endif /* HAVE_SYS_PARAM_H */
799
800#include <sys/sysctl.h>
801#include <unistd.h>
802#include <time.h>
803#include <sys/time.h>
804],
805[
806	size_t		len;
807	struct timeval	uptime;
808        int		mib[2];
809
810        mib[0] = CTL_KERN;
811        mib[1] = KERN_BOOTTIME;
812
813        len = sizeof(uptime);
814        sysctl(mib, 2, &uptime, &len, 0, 0);
815],
816AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME,1,[Define to 1 if 'KERN_BOOTTIME' exists.])
817AC_MSG_RESULT(yes),
818AC_MSG_RESULT(no))
819
820AC_MSG_CHECKING(for function sysctl (HW_NCPU))
821AC_TRY_COMPILE(
822[
823#ifdef HAVE_SYS_TYPES_H
824#include <sys/types.h>
825#endif /* HAVE_SYS_TYPES_H */
826
827#ifdef HAVE_SYS_PARAM_H
828#include <sys/param.h>
829#endif /* HAVE_SYS_PARAM_H */
830
831#include <sys/sysctl.h>
832],
833[
834	size_t	len;
835	int	mib[2], ncpu;
836
837	mib[0] = CTL_HW;
838	mib[1] = HW_NCPU;
839
840	len = sizeof(ncpu);
841	sysctl(mib, 2, &ncpu, &len, 0, 0);
842],
843AC_DEFINE(HAVE_FUNCTION_SYSCTL_HW_NCPU,1,[Define to 1 if 'HW_NCPU' exists.])
844AC_MSG_RESULT(yes),
845AC_MSG_RESULT(no))
846
847AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES))
848AC_TRY_COMPILE(
849[
850#ifdef HAVE_SYS_TYPES_H
851#include <sys/types.h>
852#endif /* HAVE_SYS_TYPES_H */
853
854#ifdef HAVE_SYS_PARAM_H
855#include <sys/param.h>
856#endif /* HAVE_SYS_PARAM_H */
857
858#include <sys/sysctl.h>
859],
860[
861	size_t	len;
862        int	mib[2], maxfiles;
863
864        mib[0] = CTL_KERN;
865        mib[1] = KERN_MAXFILES;
866
867        len = sizeof(maxfiles);
868        sysctl(mib, 2, &maxfiles, &len, 0, 0);
869],
870AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES,1,[Define to 1 if 'KERN_MAXFILES' exists.])
871AC_MSG_RESULT(yes),
872AC_MSG_RESULT(no))
873
874AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC))
875AC_TRY_COMPILE(
876[
877#ifdef HAVE_SYS_TYPES_H
878#include <sys/types.h>
879#endif /* HAVE_SYS_TYPES_H */
880
881#ifdef HAVE_SYS_PARAM_H
882#include <sys/param.h>
883#endif /* HAVE_SYS_PARAM_H */
884
885#include <sys/sysctl.h>
886],
887[
888	size_t	len;
889	int	mib[2], maxproc;
890
891        mib[0] = CTL_KERN;
892        mib[1] = KERN_MAXPROC;
893
894        len = sizeof(maxproc);
895        sysctl(mib, 2, &maxproc, &len, 0, 0);
896],
897AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC,1,[Define to 1 if 'KERN_MAXPROC' exists.])
898AC_MSG_RESULT(yes),
899AC_MSG_RESULT(no))
900
901AC_MSG_CHECKING(for function sysctl (KERN_CPTIME,KERN_CPTIME2))
902AC_TRY_COMPILE(
903[
904#include <sys/param.h>
905#include <sys/sysctl.h>
906#if defined(HAVE_SYS_DKSTAT_H)
907#	include <sys/dkstat.h>
908#elif defined(HAVE_SYS_SCHED_H)
909#	include <sys/sched.h>
910#endif
911],
912[
913size_t	sz;
914int	i[] = {CP_USER, CP_NICE, CP_SYS, CP_INTR, CP_IDLE};
915
916{
917	long	states[CPUSTATES];
918	int	mib[2] = {CTL_KERN, KERN_CPTIME};
919
920	sz = sizeof(states);
921	sysctl(mib, 2, &states, &sz, NULL, 0);
922}
923
924{
925	u_int64_t	states[CPUSTATES];
926	int		mib[3] = {CTL_KERN, KERN_CPTIME2, 0};
927
928	sz = sizeof(states);
929	sysctl(mib, 3, &states, &sz, NULL, 0);
930}
931],
932AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_CPTIME,1,[Define to 1 if 'KERN_CPTIME,KERN_CPTIME2' exists.])
933AC_MSG_RESULT(yes),
934AC_MSG_RESULT(no))
935
936AC_MSG_CHECKING(for function clock_gettime in time.h)
937AC_TRY_LINK([
938#ifdef HAVE_TIME_H
939#	include <time.h>
940#elif HAVE_SYS_TIME_H
941#	include <sys/time.h>
942#endif	/* HAVE_SYS_TIME_H */
943],
944[struct timespec tp;
945clock_gettime(CLOCK_REALTIME, &tp);
946],
947AC_DEFINE(HAVE_TIME_CLOCK_GETTIME,1,[Define to 1 if function 'clock_gettime' exists.])
948AC_MSG_RESULT(yes),
949AC_MSG_RESULT(no))
950
951dnl *****************************************************************
952dnl *                                                               *
953dnl *                      Checks for macros                        *
954dnl *                                                               *
955dnl *****************************************************************
956
957AC_MSG_CHECKING(for macro __va_copy() in stdarg.h)
958AC_TRY_COMPILE(
959[
960#include <stdarg.h>
961],
962[
963	va_list	src,dst;
964
965	__va_copy(dst,src);
966],
967AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if macro '__va_copy' exists.])
968AC_MSG_RESULT(yes),
969AC_MSG_RESULT(no))
970
971AC_MSG_CHECKING(for macro __VA_ARGS__)
972AC_TRY_COMPILE(
973[
974#define ZBX_CONST_STRING(str)   str
975int test(const char *fmt, ...) { return 0; }
976],
977[
978#define TEST(fmt, ...) test(ZBX_CONST_STRING(fmt), ##__VA_ARGS__)
979TEST("%s","test");
980TEST("test");
981],
982AC_DEFINE(HAVE___VA_ARGS__,1,[Define to 1 if macro '__VA_ARGS__' exists.])
983AC_MSG_RESULT(yes),
984AC_MSG_RESULT(no))
985
986dnl *****************************************************************
987dnl *                                                               *
988dnl *                 Checks for library functions                  *
989dnl *                                                               *
990dnl *****************************************************************
991
992AC_TYPE_SIGNAL
993AC_REPLACE_FUNCS(getloadavg)
994AC_CHECK_FUNCS(hstrerror)
995AC_CHECK_FUNCS(getenv)
996AC_CHECK_FUNCS(putenv)
997AC_CHECK_FUNCS(sigqueue)
998AC_CHECK_FUNCS(round)
999
1000dnl *****************************************************************
1001dnl *                                                               *
1002dnl *            Checks for file system characteristics             *
1003dnl *                                                               *
1004dnl *****************************************************************
1005
1006AC_MSG_CHECKING(for /proc filesystem)
1007if test -d /proc; then
1008	AC_MSG_RESULT(yes)
1009	AC_DEFINE(HAVE_PROC,1,[Define to 1 if '/proc' file system should be used.])
1010else
1011	AC_MSG_RESULT(no)
1012fi
1013
1014AC_MSG_CHECKING(for file /proc/stat)
1015if test -r /proc/stat; then
1016	AC_MSG_RESULT(yes)
1017	AC_DEFINE(HAVE_PROC_STAT,1,[Define to 1 if file '/proc/stat' should be used.])
1018else
1019	AC_MSG_RESULT(no)
1020fi
1021
1022AC_MSG_CHECKING(for file /proc/cpuinfo)
1023if test -r /proc/cpuinfo; then
1024	AC_MSG_RESULT(yes)
1025	AC_DEFINE(HAVE_PROC_CPUINFO,1,[Define to 1 if file '/proc/cpuinfo' should be used.])
1026else
1027	AC_MSG_RESULT(no)
1028fi
1029
1030dnl Solaris
1031AC_MSG_CHECKING(for file /proc/0/psinfo)
1032if test -r /proc/0/psinfo; then
1033	AC_MSG_RESULT(yes)
1034	AC_DEFINE(HAVE_PROC_0_PSINFO,1,[Define to 1 if file '/proc/0/psinfo' should be used.])
1035else
1036	AC_MSG_RESULT(no)
1037fi
1038
1039AC_MSG_CHECKING(for file /proc/loadavg)
1040if test -r /proc/loadavg; then
1041	AC_MSG_RESULT(yes)
1042	AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define to 1 if file '/proc/loadavg' should be used.])
1043else
1044	AC_MSG_RESULT(no)
1045fi
1046
1047AC_MSG_CHECKING(for file /proc/net/dev)
1048if test -r /proc/net/dev; then
1049	AC_MSG_RESULT(yes)
1050	AC_DEFINE(HAVE_PROC_NET_DEV,1,[Define to 1 if file '/proc/net/dev' should be used.])
1051else
1052	AC_MSG_RESULT(no)
1053fi
1054
1055dnl *****************************************************************
1056dnl *                                                               *
1057dnl *              Checks for compiler characteristics              *
1058dnl *                                                               *
1059dnl *****************************************************************
1060
1061dnl Check for %qu format (FreeBSD 4.x)
1062dnl FreeBSD 4.x does not support %llu
1063AC_MSG_CHECKING(for long long format)
1064AC_TRY_RUN(
1065[
1066#include <sys/types.h>
1067int main()
1068{
1069        uint64_t i;
1070
1071        sscanf("200000000010020", "%qu", &i);
1072
1073        if (i == 200000000010020) return 0;
1074        else return -1;
1075}
1076],
1077AC_DEFINE(HAVE_LONG_LONG_QU, 1 ,[Define to 1 if format '%qu' exists.])
1078AC_MSG_RESULT(yes),
1079AC_MSG_RESULT(no),
1080AC_MSG_RESULT(no))
1081
1082dnl option -rdynamic is needed for readable backtraces
1083AC_MSG_CHECKING(for -rdynamic linking option)
1084saved_LDFLAGS="$LDFLAGS"
1085LDFLAGS="-rdynamic $LDFLAGS"
1086AC_TRY_LINK([#include <execinfo.h>],
1087[void *bcktrc[6];
1088(void)backtrace(bcktrc, 6);
1089],
1090LDFLAGS="-rdynamic $saved_LDFLAGS"
1091AC_MSG_RESULT(yes),
1092LDFLAGS="$saved_LDFLAGS"
1093AC_MSG_RESULT(no))
1094
1095dnl *****************************************************************
1096dnl *                                                               *
1097dnl *                 Checks for operating systems                  *
1098dnl *                                                               *
1099dnl *****************************************************************
1100
1101AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset)
1102AC_TRY_COMPILE([#include <sys/protosw.h>
1103#include <libperfstat.h>],
1104[perfstat_memory_total_t	memstats;
1105memstats.virt_active = 0;
1106],
1107AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.])
1108AC_MSG_RESULT(yes),
1109AC_MSG_RESULT(no))
1110
1111AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset)
1112AC_TRY_COMPILE([#include <sys/protosw.h>
1113#include <libperfstat.h>],
1114[perfstat_partition_total_t	lparstats;
1115lparstats.type.b.donate_enabled = 0;
1116lparstats.idle_donated_purr = 0;
1117lparstats.busy_donated_purr = 0;
1118lparstats.idle_stolen_purr = 0;
1119lparstats.busy_stolen_purr = 0;
1120],
1121AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.])
1122AC_MSG_RESULT(yes),
1123AC_MSG_RESULT(no))
1124
1125case "$host_os" in
1126linux*)
1127	ARCH="linux"
1128	;;
1129aix*)
1130	ARCH="aix"
1131	;;
1132darwin*|rhapsody*)
1133	ARCH="osx"
1134	AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X.])
1135	;;
1136*solaris*)
1137	ARCH="solaris"
1138	;;
1139hpux*)
1140	ARCH="hpux"
1141	;;
1142freebsd*)
1143	ARCH="freebsd"
1144	;;
1145netbsd*)
1146	ARCH="netbsd"
1147	;;
1148osf*)
1149	ARCH="osf"
1150	;;
1151openbsd*)
1152	ARCH="openbsd"
1153	;;
1154*)
1155	ARCH="unknown"
1156	;;
1157esac
1158
1159AC_MSG_CHECKING(for architecture)
1160AC_MSG_RESULT([$ARCH ($host_os)])
1161
1162if test "x$ARCH" = "xlinux"; then
1163	AC_MSG_CHECKING([for the linux kernel version])
1164
1165	kernel=`uname -r`
1166
1167	case "${kernel}" in
1168		2.6.*)
1169			AC_MSG_RESULT([2.6 family (${kernel})])
1170			AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x])
1171			;;
1172		2.4.*)
1173			AC_MSG_RESULT([2.4 family (${kernel})])
1174			AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x])
1175			;;
1176		*)
1177			AC_MSG_RESULT([unknown family (${kernel})])
1178			;;
1179	esac
1180fi
1181
1182if test "x$ARCH" = "xsolaris"; then
1183	dnl Forcing a 64-bit application for a 64-bit Solaris
1184	dnl A 32-bit program that uses /proc is able to look at 32-bit processes,
1185	dnl but is not able to understand all attributes of a 64-bit process.
1186	AC_MSG_CHECKING(for -m64 compilation flag)
1187	saved_CFLAGS="$CFLAGS"
1188	CFLAGS="-m64"
1189	AC_TRY_RUN(
1190	[int main(void) {return 0;}],
1191	CFLAGS="-m64 $saved_CFLAGS"
1192	AC_MSG_RESULT(yes),
1193	CFLAGS="$saved_CFLAGS"
1194	AC_MSG_RESULT(no))
1195fi
1196
1197if test "x$ARCH" = "xhpux"; then
1198	dnl Low Level Discovery needs a way to get the list of network
1199	dnl interfaces available on the monitored system. On HP-UX systems
1200	dnl that way depends on the OS version.
1201	hpux_version=${host_os#hpux}
1202	hpux_major=${hpux_version%.*}
1203	hpux_minor=${hpux_version#*.}
1204
1205	AC_DEFINE_UNQUOTED([HPUX_VERSION], $hpux_major$hpux_minor, [Define to HP-UX version])
1206
1207	dnl This API level is needed so that "utsname.nodename" is not truncated.
1208	AC_MSG_CHECKING(for -D_HPUX_API_LEVEL=20040821 compilation flag)
1209	saved_CFLAGS="$CFLAGS"
1210	CFLAGS="-D_HPUX_API_LEVEL=20040821"
1211	AC_TRY_RUN(
1212[
1213#ifdef HAVE_DLFCN_H
1214#	include <dlfcn.h>
1215#endif
1216#ifdef HAVE_SYS_UTSNAME_H
1217#	include <sys/utsname.h>
1218#endif
1219
1220int main(void)
1221{
1222	void		*p1, *p2;
1223	struct utsname	name;
1224
1225	/* check that the compiler (e.g., GCC 4.3.0 and above) supports function-level versioning */
1226
1227	p1 = uname;
1228	p2 = dlsym(RTLD_DEFAULT, "uname{20040821}");
1229
1230	if (p1 != p2)
1231		return 1;
1232
1233	/* uname() fails with EFAULT on HP-UX systems that were only partially upgraded to this API level */
1234
1235	return -1 == uname(&name) ? 1 : 0;
1236}
1237],
1238	CFLAGS="-D_HPUX_API_LEVEL=20040821 $saved_CFLAGS"
1239	AC_MSG_RESULT(yes),
1240	CFLAGS="$saved_CFLAGS"
1241	AC_MSG_RESULT(no))
1242fi
1243
1244AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing])
1245AC_SUBST(ARCH)
1246
1247AC_CHECK_SIZEOF([void *])
1248
1249dnl *****************************************************************
1250dnl *                                                               *
1251dnl *         Checks for options given on the command line          *
1252dnl *                                                               *
1253dnl *****************************************************************
1254
1255AC_ARG_ENABLE(static,[  --enable-static         Build statically linked binaries],
1256[case "${enableval}" in
1257  yes)
1258    LDFLAGS="${LDFLAGS} -static"
1259    AC_MSG_CHECKING(if static linking is possible)
1260    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1261      [AC_MSG_RESULT([yes])
1262        static_linking=yes],
1263      [AC_MSG_RESULT([no])
1264        static_linking=no])
1265      if test "x$static_linking" = "xno"; then
1266        AC_MSG_ERROR([static linking is not possible on this system])
1267      fi
1268    ;;
1269  no) ;;
1270  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static]) ;;
1271esac])
1272
1273AC_ARG_ENABLE(static-libs,[  --enable-static-libs    Build statically linked binaries with selected libs from default folders],
1274[case "${enableval}" in
1275  yes)
1276    static_linking_libs=yes
1277    saved_LIBS="$LIBS"
1278    LIBS="${saved_LIBS} -Wl,-bstatic -Wl,-bdynamic"
1279    AC_MSG_CHECKING([if libs static linking with "-Wl,-b" is possible])
1280    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1281      [AC_MSG_RESULT([yes])
1282        static_linking_support="-Wl,-b"],
1283      [AC_MSG_RESULT([no])
1284        static_linking_support=no])
1285        LIBS="$saved_LIBS"
1286
1287    if test "x$static_linking_support" = "xno"; then
1288      LIBS="${saved_LIBS} -Wl,-Bstatic -Wl,-Bdynamic"
1289      AC_MSG_CHECKING([if libs static linking with "-Wl,-B" is possible])
1290      AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1291        [AC_MSG_RESULT([yes])
1292          static_linking_support="-Wl,-B"],
1293        [AC_MSG_RESULT([no])
1294          static_linking_support=no])
1295          LIBS="$saved_LIBS"
1296    fi
1297    ;;
1298  no) ;;
1299  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static-libs]) ;;
1300esac])
1301
1302AC_ARG_ENABLE(server,[  --enable-server         Turn on build of Zabbix server],
1303[case "${enableval}" in
1304  yes) server=yes ;;
1305  no)  server=no ;;
1306  *) AC_MSG_ERROR([bad value ${enableval} for --enable-server]) ;;
1307esac],
1308[server=no])
1309AM_CONDITIONAL(SERVER, test "x$server" = "xyes")
1310
1311AC_ARG_ENABLE(proxy,[  --enable-proxy          Turn on build of Zabbix proxy],
1312[case "${enableval}" in
1313  yes) proxy=yes ;;
1314  no)  proxy=no ;;
1315  *) AC_MSG_ERROR([bad value ${enableval} for --enable-proxy]) ;;
1316esac],
1317[proxy=no])
1318AM_CONDITIONAL(PROXY, test "x$proxy" = "xyes")
1319
1320AC_ARG_ENABLE(agent,[  --enable-agent          Turn on build of Zabbix agent and client utilities],
1321[case "${enableval}" in
1322  yes) agent=yes ;;
1323  no)  agent=no ;;
1324  *) AC_MSG_ERROR([bad value ${enableval} for --enable-agent]) ;;
1325esac],
1326[agent=no])
1327AM_CONDITIONAL(AGENT, test "x$agent" = "xyes")
1328
1329AC_ARG_ENABLE(java,[  --enable-java           Turn on build of Zabbix Java gateway],
1330[case "${enableval}" in
1331  yes) java=yes ;;
1332  no)  java=no ;;
1333  *) AC_MSG_ERROR([bad value ${enableval} for --enable-java]) ;;
1334esac],
1335[java=no])
1336AM_CONDITIONAL(JAVA, test "x$java" = "xyes")
1337
1338AC_ARG_ENABLE(ipv6,[  --enable-ipv6           Turn on support of IPv6],
1339[case "${enableval}" in
1340  yes) ipv6=yes ;;
1341  no)  ipv6=no ;;
1342  *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
1343esac],
1344[ipv6=no])
1345AM_CONDITIONAL(IPV6, test "x$ipv6" = "xyes")
1346
1347AM_CONDITIONAL([DBSCHEMA], [test -d create])
1348
1349AM_CONDITIONAL([ZBXCMOCKA], [(test -d tests/) && (test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes")])
1350
1351have_db="no"
1352have_unixodbc="no"
1353have_web_monitoring="no"
1354have_jabber="no"
1355have_snmp="no"
1356have_ipmi="no"
1357have_ipv6="no"
1358have_ssh="no"
1359have_tls="no"
1360
1361
1362if test "x$ipv6" = "xyes"; then
1363	AC_DEFINE(HAVE_IPV6,1,[Define to 1 if IPv6 should be enabled.])
1364	have_ipv6="yes"
1365fi
1366
1367if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then
1368
1369	have_multirow_insert="no"
1370
1371	dnl Checking for IBM DB2 support
1372	AX_LIB_IBM_DB2()
1373	if test "x$want_ibm_db2" = "xyes"; then
1374		if test "x$have_db" != "xno"; then
1375			AC_MSG_ERROR([You can configure for only one database.])
1376		fi
1377
1378		if test "x$found_ibm_db2" = "xyes"; then
1379			have_db="IBM DB2"
1380			have_multirow_insert="yes"
1381		else
1382			AC_MSG_ERROR([IBM DB2 library not found])
1383		fi
1384	fi
1385
1386	dnl Checking for MySQL support
1387	AX_LIB_MYSQL()
1388	if test "x$want_mysql" = "xyes"; then
1389		if test "x$have_db" != "xno"; then
1390			AC_MSG_ERROR([You can configure for only one database.])
1391		fi
1392
1393		if test "x$found_mysql" = "xyes"; then
1394			have_db="MySQL"
1395			have_multirow_insert="yes"
1396		else
1397			AC_MSG_ERROR([MySQL library not found])
1398		fi
1399	fi
1400
1401	dnl Checking for Oracle support
1402	AX_LIB_ORACLE_OCI([10.0])
1403	if test "x$want_oracle_oci" = "xyes"; then
1404		if test "x$have_db" != "xno"; then
1405			AC_MSG_ERROR([You can configure for only one database.])
1406		fi
1407
1408		if test "x$HAVE_ORACLE_OCI" = "xyes"; then
1409			have_db="Oracle"
1410
1411			ORACLE_CPPFLAGS="$ORACLE_OCI_CFLAGS"
1412			ORACLE_LDFLAGS="$ORACLE_OCI_LDFLAGS"
1413			ORACLE_LIBS="$ORACLE_OCI_LIBS"
1414
1415			AC_DEFINE(HAVE_ORACLE,1,[Define to 1 if Oracle should be enabled.])
1416		else
1417			AC_MSG_ERROR([Oracle OCI library not found])
1418		fi
1419	fi
1420
1421	dnl Checking for PostgreSQL support
1422	AX_LIB_POSTGRESQL("8.1")
1423	if test "x$want_postgresql" = "xyes"; then
1424		if test "x$have_db" != "xno"; then
1425			AC_MSG_ERROR([You can configure for only one database.])
1426		fi
1427
1428		if test "x$found_postgresql" = "xyes"; then
1429			if test "$postgresql_version_check" != "1"; then
1430				AC_MSG_ERROR([PostgreSQL version mismatch])
1431			fi
1432
1433			have_db="PostgreSQL"
1434
1435			if test "$postgresql_version_number" -ge 8002000; then
1436				have_multirow_insert="yes"
1437			fi
1438
1439		else
1440			AC_MSG_ERROR([PostgreSQL library not found])
1441		fi
1442	fi
1443
1444	dnl Checking for SQLite3 support
1445	AX_LIB_SQLITE3()
1446	if test "x$want_sqlite3" = "xyes"; then
1447		if test "x$server" = "xyes"; then
1448			AC_MSG_ERROR([SQLite is not supported as a main Zabbix database backend.])
1449		fi
1450
1451		if test "x$have_db" != "xno"; then
1452			AC_MSG_ERROR([You can configure for only one database.])
1453		fi
1454
1455		if test "x$found_sqlite3" = "xyes"; then
1456			have_db="SQLite v3.x"
1457
1458			saved_CPPFLAGS="$CPPFLAGS"
1459			saved_LDFLAGS="$LDFLAGS"
1460
1461			CPPFLAGS="$CPPFLAGS $SQLITE3_CPPFLAGS"
1462			LDFLAGS="$LDFLAGS $SQLITE3_LDFLAGS $SQLITE3_LIBS"
1463
1464			AC_MSG_CHECKING([for function sqlite3_open_v2() in sqlite3.h])
1465			AC_TRY_LINK([#include <sqlite3.h>],
1466				[sqlite3 *conn = 0;
1467				sqlite3_open_v2("dbname", &conn, SQLITE_OPEN_READWRITE, 0);
1468				],
1469				AC_DEFINE(HAVE_FUNCTION_SQLITE3_OPEN_V2,1,[Define to 1 if function 'sqlite3_open_v2' exists.])
1470				AC_MSG_RESULT(yes),
1471				AC_MSG_RESULT(no))
1472
1473			CPPFLAGS="$saved_CPPFLAGS"
1474			LDFLAGS="$saved_LDFLAGS"
1475		else
1476			AC_MSG_ERROR([SQLite3 library not found])
1477		fi
1478	fi
1479
1480	AC_MSG_CHECKING(for Zabbix server/proxy database selection)
1481	if test "x$have_db" = "xno"; then
1482		AC_MSG_RESULT(error)
1483		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.])
1484	else
1485		AC_MSG_RESULT(ok)
1486	fi
1487
1488	AC_MSG_CHECKING(for multirow insert statements)
1489	if test "x$have_multirow_insert" = "xyes"; then
1490		AC_DEFINE(HAVE_MULTIROW_INSERT,1,[Define to 1 if database supports multirow insert statements.])
1491		AC_MSG_RESULT(yes)
1492	else
1493		AC_MSG_RESULT(no)
1494	fi
1495
1496	DB_CFLAGS="$IBM_DB2_CPPFLAGS $MYSQL_CFLAGS $ORACLE_CPPFLAGS $POSTGRESQL_CFLAGS $SQLITE3_CPPFLAGS"
1497	DB_LDFLAGS="$IBM_DB2_LDFLAGS $MYSQL_LDFLAGS $ORACLE_LDFLAGS $POSTGRESQL_LDFLAGS $SQLITE3_LDFLAGS"
1498	DB_LIBS="$IBM_DB2_LIBS $MYSQL_LIBS $ORACLE_LIBS $POSTGRESQL_LIBS $SQLITE3_LIBS"
1499
1500	AC_SUBST(DB_CFLAGS)
1501	AC_SUBST(DB_LDFLAGS)
1502	AC_SUBST(DB_LIBS)
1503
1504	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${DB_LDFLAGS}"
1505	SERVER_LIBS="${SERVER_LIBS} ${DB_LIBS}"
1506
1507	PROXY_LDFLAGS="${PROXY_LDFLAGS} ${DB_LDFLAGS}"
1508	PROXY_LIBS="${PROXY_LIBS} ${DB_LIBS}"
1509
1510	dnl Checking for Jabber libraries
1511	JABBER_CHECK_CONFIG()
1512	if test "x$want_jabber" = "xyes"; then
1513		if test "x$found_jabber" != "xyes"; then
1514			AC_MSG_ERROR([Jabber library not found])
1515		else
1516			have_jabber="yes"
1517		fi
1518	fi
1519	SERVER_LDFLAGS="$SERVER_LDFLAGS $JABBER_LDFLAGS"
1520	SERVER_LIBS="$SERVER_LIBS $JABBER_LIBS"
1521
1522	AC_SUBST(JABBER_CPPFLAGS)
1523
1524	dnl Check for LIBXML2 [by default - skip]
1525	LIBXML2_CHECK_CONFIG([no])
1526	if test "x$want_libxml2" = "xyes"; then
1527		if test "x$found_libxml2" != "xyes"; then
1528			AC_MSG_ERROR([LIBXML2 library not found])
1529		else
1530			have_libxml2="yes"
1531		fi
1532	fi
1533	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBXML2_LDFLAGS"
1534	SERVER_LIBS="$SERVER_LIBS $LIBXML2_LIBS"
1535
1536	PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBXML2_LDFLAGS"
1537	PROXY_LIBS="$PROXY_LIBS $LIBXML2_LIBS"
1538
1539	AC_SUBST(LIBXML2_CFLAGS)
1540
1541	dnl Checking for unixODBC support
1542	LIBUNIXODBC_CHECK_CONFIG([no])
1543	if test "x$want_unixodbc" = "xyes"; then
1544		if test "x$unixodbc_error" != "x"; then
1545			AC_MSG_ERROR($unixodbc_error)
1546		fi
1547		have_unixodbc="yes"
1548	fi
1549	SERVER_LDFLAGS="$SERVER_LDFLAGS $UNIXODBC_LDFLAGS"
1550	SERVER_LIBS="$SERVER_LIBS $UNIXODBC_LIBS"
1551
1552	PROXY_LDFLAGS="$PROXY_LDFLAGS $UNIXODBC_LDFLAGS"
1553	PROXY_LIBS="$PROXY_LIBS $UNIXODBC_LIBS"
1554
1555	AC_SUBST(UNIXODBC_CFLAGS)
1556
1557	dnl Check for Net-SNMP [by default - skip]
1558	LIBNETSNMP_CHECK_CONFIG([no])
1559	if test "x$want_netsnmp" = "xyes"; then
1560		if test "x$found_netsnmp" != "xyes"; then
1561			AC_MSG_ERROR([Invalid Net-SNMP directory - unable to find net-snmp-config])
1562		else
1563			have_snmp="yes"
1564		fi
1565	fi
1566	SERVER_LDFLAGS="$SERVER_LDFLAGS $SNMP_LDFLAGS"
1567	SERVER_LIBS="$SERVER_LIBS $SNMP_LIBS"
1568
1569	PROXY_LDFLAGS="$PROXY_LDFLAGS $SNMP_LDFLAGS"
1570	PROXY_LIBS="$PROXY_LIBS $SNMP_LIBS"
1571
1572	AC_SUBST(SNMP_CFLAGS)
1573
1574	dnl Check for LIBSSH2 [by default - skip] at least of version 1.0.0.
1575	LIBSSH2_CHECK_CONFIG([no])
1576	LIBSSH_CHECK_CONFIG([no])
1577	if test "x$want_ssh2" = "xyes"; then
1578		if test "x$want_ssh" != "xno"; then
1579			AC_MSG_ERROR([You can configure for only one SSH library (--with-ssh or --with-ssh2).])
1580		fi
1581
1582		if test "x$found_ssh2" != "xyes"; then
1583			AC_MSG_ERROR([SSH2 library not found])
1584		elif test "x$accept_ssh2_version" != "xyes"; then
1585			AC_MSG_ERROR([SSH2 library version requirement not met (>= 1.0.0)])
1586		else
1587			have_ssh="yes (libssh2)"
1588		fi
1589	fi
1590	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH2_LDFLAGS"
1591	SERVER_LIBS="$SERVER_LIBS $SSH2_LIBS"
1592
1593	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH2_LDFLAGS"
1594	PROXY_LIBS="$PROXY_LIBS $SSH2_LIBS"
1595
1596	AC_SUBST(SSH2_CFLAGS)
1597
1598	dnl Check for LIBSSH [by default - skip] at least of version 0.7.0.
1599	if test "x$want_ssh" = "xyes"; then
1600		if test "x$found_ssh" != "xyes"; then
1601			AC_MSG_ERROR([SSH library not found])
1602		elif test "x$accept_ssh_version" != "xyes"; then
1603			AC_MSG_ERROR([SSH library version requirement not met (>= 0.6.0)])
1604		else
1605			have_ssh="yes (libssh)"
1606		fi
1607	fi
1608	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH_LDFLAGS"
1609	SERVER_LIBS="$SERVER_LIBS $SSH_LIBS"
1610
1611	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH_LDFLAGS"
1612	PROXY_LIBS="$PROXY_LIBS $SSH_LIBS"
1613
1614	AC_SUBST(SSH_CFLAGS)
1615
1616	found_openipmi="no"
1617	dnl Check for libOpenIPMI [by default - skip]
1618	LIBOPENIPMI_CHECK_CONFIG([no])
1619	if test "x$want_openipmi" = "xyes"; then
1620		if test "x$found_openipmi" != "xyes"; then
1621			AC_MSG_ERROR([Invalid OPENIPMI directory - unable to find ipmiif.h])
1622		else
1623			have_ipmi="yes"
1624		fi
1625	fi
1626
1627	SERVER_LDFLAGS="$SERVER_LDFLAGS $OPENIPMI_LDFLAGS"
1628	SERVER_LIBS="$SERVER_LIBS $OPENIPMI_LIBS"
1629
1630	PROXY_LDFLAGS="$PROXY_LDFLAGS $OPENIPMI_LDFLAGS"
1631	PROXY_LIBS="$PROXY_LIBS $OPENIPMI_LIBS"
1632
1633	AC_SUBST(OPENIPMI_CFLAGS)
1634
1635	dnl Check for zlib, used by Zabbix server-proxy communications
1636	ZLIB_CHECK_CONFIG([no])
1637	if test "x$found_zlib" != "xyes"; then
1638		AC_MSG_ERROR([Unable to use zlib (zlib check failed)])
1639	fi
1640
1641	AC_SUBST(ZLIB_CFLAGS)
1642
1643	dnl Check for 'libpthread' library that supports PTHREAD_PROCESS_SHARED flag
1644	LIBPTHREAD_CHECK_CONFIG([no])
1645	if test "x$found_libpthread" != "xyes"; then
1646		AC_MSG_ERROR([Unable to use libpthread (libpthread check failed)])
1647	fi
1648fi
1649
1650SERVER_LDFLAGS="$SERVER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1651SERVER_LIBS="$SERVER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1652
1653PROXY_LDFLAGS="$PROXY_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1654PROXY_LIBS="$PROXY_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1655
1656AGENT_LDFLAGS="$AGENT_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1657AGENT_LIBS="$AGENT_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1658
1659AM_CONDITIONAL(HAVE_IPMI, [test "x$have_ipmi" = "xyes"])
1660AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes")
1661
1662dnl Check if Zabbix internal IPC services are used
1663have_ipcservice="no"
1664if test "x$have_ipmi" = "xyes"; then
1665	have_ipcservice="yes"
1666fi
1667
1668if test "x$server" = "xyes"; then
1669	have_ipcservice="yes"
1670fi
1671
1672AM_CONDITIONAL(PROXY_IPCSERVICE, [test "x$have_ipmi" = "xyes"])
1673
1674dnl Check for libevent, used by Zabbix IPC services
1675if test "x$have_ipcservice" = "xyes"; then
1676	AC_DEFINE([HAVE_IPCSERVICE], 1, [Define to 1 if Zabbix IPC services are used])
1677
1678	LIBEVENT_CHECK_CONFIG([no])
1679	if test "x$found_libevent" != "xyes"; then
1680		AC_MSG_ERROR([Unable to use libevent (libevent check failed)])
1681	fi
1682
1683	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBEVENT_LDFLAGS"
1684	SERVER_LIBS="$SERVER_LIBS $LIBEVENT_LIBS"
1685
1686	if test "x$have_ipmi" = "xyes"; then
1687		PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBEVENT_LDFLAGS"
1688		PROXY_LIBS="$PROXY_LIBS $LIBEVENT_LIBS"
1689	fi
1690fi
1691
1692dnl Check for mbed TLS (PolarSSL) libpolarssl [by default - skip]
1693LIBMBEDTLS_CHECK_CONFIG([no])
1694if test "x$want_mbedtls" = "xyes"; then
1695	if test "x$have_tls" != "xno"; then
1696		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1697	fi
1698
1699	if test "x$found_mbedtls" != "xyes"; then
1700		AC_MSG_ERROR([mbed TLS (PolarSSL) library libpolarssl not found])
1701	elif test "x$accept_mbedtls_version" != "xyes"; then
1702		AC_MSG_ERROR([mbed TLS (PolarSSL) library version requirement not met (>= 1.3.9)])
1703	else
1704		have_tls="mbed TLS"
1705	fi
1706	TLS_CFLAGS="$MBEDTLS_CFLAGS"
1707	TLS_LDFLAGS="$MBEDTLS_LDFLAGS"
1708	TLS_LIBS="$MBEDTLS_LIBS"
1709fi
1710
1711dnl Check for GnuTLS libgnutls [by default - skip]
1712LIBGNUTLS_CHECK_CONFIG([no])
1713if test "x$want_gnutls" = "xyes"; then
1714	if test "x$have_tls" != "xno"; then
1715		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1716	fi
1717
1718	if test "x$found_gnutls" != "xyes"; then
1719		AC_MSG_ERROR([GnuTLS library libgnutls not found])
1720	elif test "x$accept_gnutls_version" != "xyes"; then
1721		AC_MSG_ERROR([GnuTLS library version requirement not met (>= 3.1.18)])
1722	else
1723		have_tls="GnuTLS"
1724	fi
1725	TLS_CFLAGS="$GNUTLS_CFLAGS"
1726	TLS_LDFLAGS="$GNUTLS_LDFLAGS"
1727	TLS_LIBS="$GNUTLS_LIBS"
1728fi
1729
1730dnl Check for OpenSSL libssl and libcrypto [by default - skip]
1731LIBOPENSSL_CHECK_CONFIG([no])
1732if test "x$want_openssl" = "xyes"; then
1733	if test "x$have_tls" != "xno"; then
1734		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1735	fi
1736
1737	if test "x$found_openssl" != "xOpenSSL" -a "x$found_openssl" != "xOpenSSL (PSK not supported)"; then
1738		AC_MSG_ERROR([OpenSSL library libssl or libcrypto not found])
1739	elif test "x$accept_openssl_version" != "xyes"; then
1740		AC_MSG_ERROR([OpenSSL library version requirement not met (>= 1.0.1)])
1741	else
1742		have_tls=$found_openssl
1743	fi
1744	TLS_CFLAGS="$OPENSSL_CFLAGS"
1745	TLS_LDFLAGS="$OPENSSL_LDFLAGS"
1746	TLS_LIBS="$OPENSSL_LIBS"
1747fi
1748AC_SUBST(TLS_CFLAGS)
1749
1750SERVER_LDFLAGS="$SERVER_LDFLAGS $TLS_LDFLAGS"
1751SERVER_LIBS="$SERVER_LIBS $TLS_LIBS"
1752
1753PROXY_LDFLAGS="$PROXY_LDFLAGS $TLS_LDFLAGS"
1754PROXY_LIBS="$PROXY_LIBS $TLS_LIBS"
1755
1756AGENT_LDFLAGS="$AGENT_LDFLAGS $TLS_LDFLAGS"
1757AGENT_LIBS="$AGENT_LIBS $TLS_LIBS"
1758
1759ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $TLS_LDFLAGS"
1760ZBXGET_LIBS="$ZBXGET_LIBS $TLS_LIBS"
1761
1762SENDER_LDFLAGS="$SENDER_LDFLAGS $TLS_LDFLAGS"
1763SENDER_LIBS="$SENDER_LIBS $TLS_LIBS"
1764
1765if test "x$java" = "xyes"; then
1766	AC_CHECK_PROGS([JAVAC], [javac], [no])
1767	if test "x$JAVAC" = "xno"; then
1768		AC_MSG_ERROR([Unable to find "javac" executable in path])
1769	fi
1770	AC_CHECK_PROGS([JAR], [jar], [no])
1771	if test "x$JAR" = "xno"; then
1772		AC_MSG_ERROR([Unable to find "jar" executable in path])
1773	fi
1774fi
1775
1776found_ldap="no"
1777dnl Check for libLDAP [by default - skip]
1778LIBLDAP_CHECK_CONFIG([no])
1779if test "x$want_ldap" = "xyes"; then
1780	if test "x$found_ldap" != "xyes"; then
1781		AC_MSG_ERROR([Invalid LDAP directory - unable to find ldap.h])
1782	fi
1783fi
1784SERVER_LDFLAGS="$SERVER_LDFLAGS $LDAP_LDFLAGS"
1785SERVER_LIBS="$SERVER_LIBS $LDAP_LIBS"
1786
1787PROXY_LDFLAGS="$PROXY_LDFLAGS $LDAP_LDFLAGS"
1788PROXY_LIBS="$PROXY_LIBS $LDAP_LIBS"
1789
1790AGENT_LDFLAGS="$AGENT_LDFLAGS $LDAP_LDFLAGS"
1791AGENT_LIBS="$AGENT_LIBS $LDAP_LIBS"
1792
1793AC_SUBST(LDAP_CPPFLAGS)
1794
1795found_curl="no"
1796dnl Checking for libCurl [by default - skip]
1797LIBCURL_CHECK_CONFIG(, [7.13.1], [],[])
1798if test "x$want_curl" = "xyes"; then
1799	if test "x$found_curl" != "xyes"; then
1800		AC_MSG_ERROR([Curl library not found])
1801	fi
1802fi
1803if test "x$found_curl" = "xyes"; then
1804	have_web_monitoring="cURL"
1805fi
1806CFLAGS="$LIBCURL_CFLAGS $CFLAGS"
1807
1808SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBCURL_LDFLAGS"
1809SERVER_LIBS="$SERVER_LIBS $LIBCURL_LIBS"
1810
1811PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBCURL_LDFLAGS"
1812PROXY_LIBS="$PROXY_LIBS $LIBCURL_LIBS"
1813
1814AM_CONDITIONAL(HAVE_LIBCURL, test "x$found_curl" = "xyes")
1815
1816dnl Starting from 2.0 agent can do web monitoring
1817AGENT_LDFLAGS="$AGENT_LDFLAGS $LIBCURL_LDFLAGS"
1818AGENT_LIBS="$AGENT_LIBS $LIBCURL_LIBS"
1819
1820ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1821ZBXGET_LIBS="$ZBXGET_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1822
1823SENDER_LDFLAGS="$SENDER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1824SENDER_LIBS="$SENDER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1825
1826dnl Check for libpcre, used by Zabbix for regular expressions
1827if test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes"; then
1828	LIBPCRE_CHECK_CONFIG([no])
1829	if test "x$found_libpcre" != "xyes"; then
1830		AC_MSG_ERROR([Unable to use libpcre (libpcre check failed)])
1831	fi
1832fi
1833
1834CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
1835LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS"
1836if test "x$ARCH" = "xosx"; then
1837	LIBS="$LIBPCRE_LIBS $LIBS"
1838else
1839	LIBS="$LIBS $LIBPCRE_LIBS"
1840fi
1841
1842found_iconv="no"
1843dnl Check for libiconv [by default - skip]
1844LIBICONV_CHECK_CONFIG([no])
1845if test "x$found_iconv" != "xyes"; then
1846	AC_MSG_ERROR([Unable to use iconv (libiconv check failed)])
1847fi
1848LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
1849LIBS="$LIBS $ICONV_LIBS"
1850
1851RANLIB="ranlib"
1852AC_SUBST(RANLIB)
1853
1854SERVER_CONFIG_FILE="${sysconfdir}/zabbix_server.conf"
1855PROXY_CONFIG_FILE="${sysconfdir}/zabbix_proxy.conf"
1856AGENT_CONFIG_FILE="${sysconfdir}/zabbix_agentd.conf"
1857
1858EXTERNAL_SCRIPTS_PATH="${datadir}/zabbix/externalscripts"
1859ALERT_SCRIPTS_PATH="${datadir}/zabbix/alertscripts"
1860
1861CURL_SSL_CERT_LOCATION="${datadir}/zabbix/ssl/certs"
1862CURL_SSL_KEY_LOCATION="${datadir}/zabbix/ssl/keys"
1863
1864LOAD_MODULE_PATH="${libdir}/modules"
1865
1866AC_SUBST(SERVER_LDFLAGS)
1867AC_SUBST(SERVER_LIBS)
1868
1869AC_SUBST(PROXY_LDFLAGS)
1870AC_SUBST(PROXY_LIBS)
1871
1872AC_SUBST(AGENT_LDFLAGS)
1873AC_SUBST(AGENT_LIBS)
1874
1875AC_SUBST(ZBXGET_LDFLAGS)
1876AC_SUBST(ZBXGET_LIBS)
1877
1878AC_SUBST(SENDER_LDFLAGS)
1879AC_SUBST(SENDER_LIBS)
1880
1881AC_SUBST(SERVER_CONFIG_FILE)
1882AC_SUBST(PROXY_CONFIG_FILE)
1883AC_SUBST(AGENT_CONFIG_FILE)
1884
1885AC_SUBST(EXTERNAL_SCRIPTS_PATH)
1886AC_SUBST(ALERT_SCRIPTS_PATH)
1887
1888AC_SUBST(CURL_SSL_CERT_LOCATION)
1889AC_SUBST(CURL_SSL_KEY_LOCATION)
1890
1891AC_SUBST(LOAD_MODULE_PATH)
1892
1893dnl *****************************************************************
1894dnl *                                                               *
1895dnl *                         Other checks                          *
1896dnl *                                                               *
1897dnl *****************************************************************
1898
1899dnl Automake 1.8 to 1.9.6 sets mkdir_p macro (lower-cased).
1900AC_MSG_CHECKING(for mkdir -p candidate)
1901if test "x${MKDIR_P}" = "x"; then
1902        if test "x${mkdir_p}" = "x"; then
1903                AC_MSG_ERROR([No suitable "mkdir -p" candidate found.])
1904        fi
1905        AC_SUBST([MKDIR_P], ${mkdir_p})
1906fi
1907AC_MSG_RESULT([ok (${MKDIR_P})])
1908
1909dnl Check if process statistics collector should be enabled
1910case "x$ARCH" in
1911	xlinux|xsolaris)
1912		AC_DEFINE(ZBX_PROCSTAT_COLLECTOR, 1 , [Define to 1 on linux and solaris platforms])
1913		;;
1914esac
1915
1916dnl *****************************************************************
1917dnl *                                                               *
1918dnl *                 Output configuration results                  *
1919dnl *                                                               *
1920dnl *****************************************************************
1921
1922m4_ifdef([CONF_TESTS],[CONF_TESTS(ZBXCMOCKA)])
1923
1924AC_OUTPUT([
1925	Makefile
1926	database/Makefile
1927	database/ibm_db2/Makefile
1928	database/mysql/Makefile
1929	database/oracle/Makefile
1930	database/postgresql/Makefile
1931	database/sqlite3/Makefile
1932	misc/Makefile
1933	src/Makefile
1934	src/libs/Makefile
1935	src/libs/zbxlog/Makefile
1936	src/libs/zbxalgo/Makefile
1937	src/libs/zbxmemory/Makefile
1938	src/libs/zbxcrypto/Makefile
1939	src/libs/zbxconf/Makefile
1940	src/libs/zbxdbcache/Makefile
1941	src/libs/zbxdbhigh/Makefile
1942	src/libs/zbxmedia/Makefile
1943	src/libs/zbxsysinfo/Makefile
1944	src/libs/zbxcommon/Makefile
1945	src/libs/zbxsysinfo/agent/Makefile
1946	src/libs/zbxsysinfo/common/Makefile
1947	src/libs/zbxsysinfo/simple/Makefile
1948	src/libs/zbxsysinfo/linux/Makefile
1949	src/libs/zbxsysinfo/aix/Makefile
1950	src/libs/zbxsysinfo/freebsd/Makefile
1951	src/libs/zbxsysinfo/hpux/Makefile
1952	src/libs/zbxsysinfo/openbsd/Makefile
1953	src/libs/zbxsysinfo/osx/Makefile
1954	src/libs/zbxsysinfo/solaris/Makefile
1955	src/libs/zbxsysinfo/osf/Makefile
1956	src/libs/zbxsysinfo/netbsd/Makefile
1957	src/libs/zbxsysinfo/unknown/Makefile
1958	src/libs/zbxnix/Makefile
1959	src/libs/zbxsys/Makefile
1960	src/libs/zbxcomms/Makefile
1961	src/libs/zbxcommshigh/Makefile
1962	src/libs/zbxdb/Makefile
1963	src/libs/zbxdbupgrade/Makefile
1964	src/libs/zbxjson/Makefile
1965	src/libs/zbxhttp/Makefile
1966	src/libs/zbxserver/Makefile
1967	src/libs/zbxicmpping/Makefile
1968	src/libs/zbxexec/Makefile
1969	src/libs/zbxself/Makefile
1970	src/libs/zbxmodules/Makefile
1971	src/libs/zbxregexp/Makefile
1972	src/libs/zbxtasks/Makefile
1973	src/libs/zbxipcservice/Makefile
1974	src/libs/zbxhistory/Makefile
1975	src/libs/zbxcompress/Makefile
1976	src/zabbix_agent/Makefile
1977	src/zabbix_get/Makefile
1978	src/zabbix_sender/Makefile
1979	src/zabbix_server/Makefile
1980	src/zabbix_server/alerter/Makefile
1981	src/zabbix_server/dbsyncer/Makefile
1982	src/zabbix_server/dbconfig/Makefile
1983	src/zabbix_server/discoverer/Makefile
1984	src/zabbix_server/housekeeper/Makefile
1985	src/zabbix_server/httppoller/Makefile
1986	src/zabbix_server/pinger/Makefile
1987	src/zabbix_server/poller/Makefile
1988	src/zabbix_server/snmptrapper/Makefile
1989	src/zabbix_server/timer/Makefile
1990	src/zabbix_server/trapper/Makefile
1991	src/zabbix_server/escalator/Makefile
1992	src/zabbix_server/proxypoller/Makefile
1993	src/zabbix_server/selfmon/Makefile
1994	src/zabbix_server/vmware/Makefile
1995	src/zabbix_server/taskmanager/Makefile
1996	src/zabbix_server/ipmi/Makefile
1997	src/zabbix_server/odbc/Makefile
1998	src/zabbix_server/scripts/Makefile
1999	src/zabbix_server/preprocessor/Makefile
2000	src/zabbix_proxy/Makefile
2001	src/zabbix_proxy/heart/Makefile
2002	src/zabbix_proxy/housekeeper/Makefile
2003	src/zabbix_proxy/proxyconfig/Makefile
2004	src/zabbix_proxy/datasender/Makefile
2005	src/zabbix_proxy/taskmanager/Makefile
2006	src/zabbix_java/Makefile
2007	man/Makefile
2008	])
2009
2010dnl The following variables use autoconf variables such as
2011dnl ${sysconfdir} and ${datadir} . Which in turn contain
2012dnl variables such as ${prefix}. In order to completely
2013dnl substitute all variables and output end-value in
2014dnl Configuration output below it is required to perform 2
2015dnl substitutions.
2016
2017SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`
2018SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`
2019
2020PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`
2021PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`
2022
2023AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`
2024AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`
2025
2026EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`
2027EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`
2028
2029ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`
2030ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`
2031
2032CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`
2033CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`
2034
2035CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`
2036CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`
2037
2038LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`
2039LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`
2040
2041echo "
2042
2043Configuration:
2044
2045  Detected OS:           ${host_os}
2046  Install path:          ${prefix}
2047  Compilation arch:      ${ARCH}
2048
2049  Compiler:              ${CC}
2050  Compiler flags:        ${CFLAGS}
2051
2052  Library-specific flags:"
2053
2054if test "x$DB_CFLAGS" != "x"; then
2055	echo "    database:              ${DB_CFLAGS}"
2056fi
2057
2058if test "x$JABBER_CPPFLAGS" != "x"; then
2059	echo "    Jabber:                ${JABBER_CPPFLAGS}"
2060fi
2061
2062if test "x$LIBXML2_CFLAGS" != "x"; then
2063	echo "    libXML2:               ${LIBXML2_CFLAGS}"
2064fi
2065
2066if test "x$UNIXODBC_CFLAGS" != "x"; then
2067	echo "    unixODBC:              ${UNIXODBC_CFLAGS}"
2068fi
2069
2070if test "x$SNMP_CFLAGS" != "x"; then
2071	echo "    Net-SNMP:              ${SNMP_CFLAGS}"
2072fi
2073
2074if test "x$OPENIPMI_CFLAGS" != "x"; then
2075	echo "    OpenIPMI:              ${OPENIPMI_CFLAGS}"
2076fi
2077
2078if test "x$SSH2_CFLAGS" != "x"; then
2079	echo "    libssh2:               ${SSH2_CFLAGS}"
2080fi
2081
2082if test "x$SSH_CFLAGS" != "x"; then
2083	echo "    libssh:                ${SSH_CFLAGS}"
2084fi
2085
2086if test "x$TLS_CFLAGS" != "x"; then
2087	echo "    TLS:                   ${TLS_CFLAGS}"
2088fi
2089
2090if test "x$LDAP_CPPFLAGS" != "x"; then
2091	echo "    LDAP:                  ${LDAP_CPPFLAGS}"
2092fi
2093
2094if test "x$ICONV_CFLAGS" != "x"; then
2095	echo "    iconv:                 ${ICONV_CFLAGS}"
2096fi
2097
2098if test "x$LIBEVENT_CFLAGS" != "x"; then
2099	echo "    libevent:              ${LIBEVENT_CFLAGS}"
2100fi
2101
2102echo "
2103  Enable server:         ${server}"
2104
2105if test "x$server" != "xno"; then
2106
2107echo "  Server details:
2108    With database:         ${have_db}
2109    WEB Monitoring:        ${have_web_monitoring}"
2110
2111if test "x$have_web_monitoring" = "xcURL"; then
2112echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
2113      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
2114fi
2115
2116echo "    Native Jabber:         ${have_jabber}
2117    SNMP:                  ${have_snmp}
2118    IPMI:                  ${have_ipmi}
2119    SSH:                   ${have_ssh}
2120    TLS:                   ${have_tls}
2121    ODBC:                  ${have_unixodbc}
2122    Linker flags:          ${SERVER_LDFLAGS} ${LDFLAGS}
2123    Libraries:             ${SERVER_LIBS} ${LIBS}
2124    Configuration file:    ${SERVER_CONFIG_FILE}
2125    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
2126    Alert scripts:         ${ALERT_SCRIPTS_PATH}
2127    Modules:               ${LOAD_MODULE_PATH}"
2128
2129fi
2130
2131echo "
2132  Enable proxy:          ${proxy}"
2133
2134if test "x$proxy" != "xno"; then
2135
2136echo "  Proxy details:
2137    With database:         ${have_db}
2138    WEB Monitoring:        ${have_web_monitoring}"
2139
2140if test "x$have_web_monitoring" = "xcURL"; then
2141echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
2142      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
2143fi
2144
2145echo "    SNMP:                  ${have_snmp}
2146    IPMI:                  ${have_ipmi}
2147    SSH:                   ${have_ssh}
2148    TLS:                   ${have_tls}
2149    ODBC:                  ${have_unixodbc}
2150    Linker flags:          ${PROXY_LDFLAGS} ${LDFLAGS}
2151    Libraries:             ${PROXY_LIBS} ${LIBS}
2152    Configuration file:    ${PROXY_CONFIG_FILE}
2153    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
2154    Modules:               ${LOAD_MODULE_PATH}"
2155
2156fi
2157
2158echo "
2159  Enable agent:          ${agent}"
2160
2161if test "x$agent" != "xno"; then
2162
2163echo "  Agent details:
2164    TLS:                   ${have_tls}
2165    Linker flags:          ${AGENT_LDFLAGS} ${LDFLAGS}
2166    Libraries:             ${AGENT_LIBS} ${LIBS}
2167    Configuration file:    ${AGENT_CONFIG_FILE}
2168    Modules:               ${LOAD_MODULE_PATH}"
2169
2170fi
2171
2172echo "
2173  Enable Java gateway:   ${java}"
2174
2175if test "x$java" != "xno"; then
2176
2177echo "  Java gateway details:
2178    Java compiler:         ${JAVAC}
2179    Java archiver:         ${JAR}"
2180
2181fi
2182
2183echo "
2184  LDAP support:          ${found_ldap}
2185  IPv6 support:          ${have_ipv6}"
2186
2187echo
2188echo "***********************************************************"
2189echo "*            Now run '${am_make} install'                       *"
2190echo "*                                                         *"
2191echo "*            Thank you for using Zabbix!                  *"
2192echo "*              <http://www.zabbix.com>                    *"
2193echo "***********************************************************"
2194echo
2195