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],[3.0.32])
23AC_CONFIG_SRCDIR(src/zabbix_server/server.c)
24AM_INIT_AUTOMAKE
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
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 regex.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/protosw.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])
101AC_CHECK_HEADERS(sys/mount.h sys/proc.h sys/sysctl.h sys/user.h, [], [], [
102#ifdef HAVE_SYS_TYPES_H
103#  include <sys/types.h>
104#endif
105#ifdef HAVE_SYS_PARAM_H
106#  include <sys/param.h>
107#endif
108])
109AC_CHECK_HEADERS(sys/swap.h, [], [], [
110#ifdef HAVE_SYS_PARAM_H
111#  include <sys/param.h>
112#endif
113])
114AC_CHECK_HEADERS(sys/ucontext.h, [], [], [
115#ifdef HAVE_SIGNAL_H
116#  include <signal.h>
117#endif
118])
119AC_CHECK_HEADERS(devstat.h, [], [], [
120#ifdef HAVE_SYS_DKSTAT_H
121#  include <sys/dkstat.h>
122#endif
123])
124AC_CHECK_HEADERS(linux/netlink.h, [
125	AC_CHECK_HEADERS(linux/inet_diag.h, [
126		AC_DEFINE([HAVE_INET_DIAG], 1, [Define to 1 if you have NETLINK INET_DIAG support.])
127	])
128], [], [
129#ifdef HAVE_SYS_SOCKET_H
130#  include <sys/socket.h>
131#endif
132])
133AC_CHECK_HEADERS(libperfstat.h, [], [], [
134#ifdef HAVE_SYS_PROTOSW_H
135#  include <sys/protosw.h>
136#endif
137])
138
139dnl *****************************************************************
140dnl *                                                               *
141dnl *                     Checks for libraries                      *
142dnl *                                                               *
143dnl *****************************************************************
144
145AC_SEARCH_LIBS(socket, socket)
146AC_SEARCH_LIBS(kstat_open, kstat)
147AC_SEARCH_LIBS(gethostbyname, nsl)
148AC_SEARCH_LIBS(clock_gettime, rt)
149AC_SEARCH_LIBS(dlopen, dl)
150
151dnl AIX
152AC_SEARCH_LIBS(perfstat_memory_total, perfstat, [AC_DEFINE([HAVE_LIBPERFSTAT], 1, [Define to 1 if you have the 'libperfstat' library (-lperfstat)])])
153AC_SEARCH_LIBS(devstat_getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])
154AC_SEARCH_LIBS(getdevs, devstat, [AC_DEFINE([HAVE_LIBDEVSTAT], 1, [Define to 1 if you have the 'libdevstat' library (-ldevstat)])])
155
156dnl on FreeBSD we have to link with -lexecinfo to get backtraces
157AC_SEARCH_LIBS(backtrace_symbols, execinfo, [AC_DEFINE([HAVE_LIBEXECINFO], 1, [Define to 1 if you have the 'libexecinfo' library (-lexecinfo)])])
158
159AC_CHECK_LIB(m, main)
160AC_CHECK_LIB(kvm, main)
161
162dnl check for DNS lookup functions
163found_resolv="no"
164LIBRESOLV_CHECK_CONFIG([no])
165if test "x$found_resolv" != "xyes"; then
166	AC_MSG_ERROR([Unable to do DNS lookups (libresolv check failed)])
167fi
168LIBS="${LIBS} ${RESOLV_LIBS}"
169
170dnl *****************************************************************
171dnl *                                                               *
172dnl *          Checks for type definitions and structures           *
173dnl *                                                               *
174dnl *****************************************************************
175
176dnl large file support
177largefile=yes
178
179dnl disable large file support on 32-bit Solaris as it's incompatible with procfs and swapctl
180case "${host_os}" in
181	solaris*)
182		largefile=no
183		;;
184esac
185
186if test "x$largefile" = "xyes"; then
187	AC_SYS_LARGEFILE
188fi
189
190AC_C_CONST
191AC_TYPE_PID_T
192
193AC_MSG_CHECKING(for socklen_t)
194AC_TRY_COMPILE([
195#include <sys/types.h>
196#include <unistd.h>
197#include <sys/socket.h>
198],[socklen_t s;],
199AC_MSG_RESULT(yes),
200[AC_DEFINE(socklen_t, int, [Define socklen_t type.])
201AC_MSG_RESULT(no)])
202
203AC_MSG_CHECKING(for actual socklen_t parameter type in socket functions)
204zbx_socklen_t=
205for arg2 in "struct sockaddr" void; do
206  for arg3 in socklen_t size_t int; do
207    AC_TRY_COMPILE([
208#ifdef HAVE_SYS_TYPES_H
209#  include <sys/types.h>
210#endif
211#ifdef HAVE_SYS_SOCKET_H
212#  include <sys/socket.h>
213#endif
214      extern int getpeername(int sockfd, $arg2 *addr, $arg3 *addrlen);
215    ],[
216      $arg3 addrlen;
217      getpeername(0, 0, &addrlen);
218    ],[
219      zbx_socklen_t="$arg3"
220      break 2
221    ])
222  done
223done
224if test "x$zbx_socklen_t" != "x"; then
225  AC_MSG_RESULT($zbx_socklen_t)
226  AC_DEFINE_UNQUOTED(ZBX_SOCKLEN_T, $zbx_socklen_t, [Define actual socklen_t parameter type in socket functions.])
227else
228  AC_MSG_RESULT(leaving undefined)
229fi
230
231AC_MSG_CHECKING(for integer field name in union sigval of struct siginfo_t)
232zbx_sival_int=
233for field in sival_int sigval_int; do
234  AC_TRY_COMPILE([
235#ifdef HAVE_SIGNAL_H
236#  include <signal.h>
237#endif
238  ],[
239    siginfo_t siginfo;
240    siginfo.si_value.$field = 0;
241  ],[
242    zbx_sival_int="$field"
243    break
244  ])
245done
246if test "x$zbx_sival_int" != "x"; then
247  AC_MSG_RESULT($zbx_sival_int)
248  AC_DEFINE_UNQUOTED(ZBX_SIVAL_INT, $zbx_sival_int, [Define integer field name in union 'sigval' of struct 'siginfo_t'])
249else
250  AC_MSG_ERROR(Unable to find integer field name in union sigval of struct siginfo_t)
251fi
252
253AC_MSG_CHECKING(for res_ninit)
254AC_TRY_LINK(
255[
256#ifdef HAVE_SYS_TYPES_H
257#	include <sys/types.h>
258#endif
259#ifdef HAVE_NETINET_IN_H
260#	include <netinet/in.h>
261#endif
262#ifdef HAVE_ARPA_NAMESER_H
263#	include <arpa/nameser.h>
264#endif
265#ifdef HAVE_RESOLV_H
266#	include <resolv.h>
267#endif
268#ifndef C_IN
269#	define C_IN	ns_c_in
270#endif	/* C_IN */
271#ifndef T_SOA
272#	define T_SOA	ns_t_soa
273#endif	/* T_SOA */
274],
275[
276	struct __res_state	res_state_local;
277
278	res_ninit(&res_state_local);
279],
280AC_DEFINE(HAVE_RES_NINIT,1,[Define to 1 if 'res_ninit' exists.])
281AC_MSG_RESULT(yes),
282AC_MSG_RESULT(no))
283
284AC_MSG_CHECKING(for res_ndestroy)
285AC_TRY_LINK(
286[
287#ifdef HAVE_SYS_TYPES_H
288#	include <sys/types.h>
289#endif
290#ifdef HAVE_NETINET_IN_H
291#	include <netinet/in.h>
292#endif
293#ifdef HAVE_ARPA_NAMESER_H
294#	include <arpa/nameser.h>
295#endif
296#ifdef HAVE_RESOLV_H
297#	include <resolv.h>
298#endif
299#ifndef C_IN
300#	define C_IN	ns_c_in
301#endif	/* C_IN */
302#ifndef T_SOA
303#	define T_SOA	ns_t_soa
304#endif	/* T_SOA */
305],
306[
307	struct __res_state	res_state_local;
308
309	res_ninit(&res_state_local);
310	res_ndestroy(&res_state_local);
311],
312AC_DEFINE(HAVE_RES_NDESTROY,1,[Define to 1 if 'res_ndestroy' exists.])
313AC_MSG_RESULT(yes),
314AC_MSG_RESULT(no))
315
316AC_MSG_CHECKING(for union semun)
317AC_TRY_COMPILE(
318[
319#include <sys/types.h>
320#include <sys/ipc.h>
321#include <sys/sem.h>
322],
323[union semun foo;],
324AC_DEFINE(HAVE_SEMUN, 1, [Define to 1 if union 'semun' exists.])
325AC_MSG_RESULT(yes),
326AC_MSG_RESULT(no))
327
328AC_MSG_CHECKING(for struct swaptable in sys/swap.h)
329AC_TRY_COMPILE(
330[
331#include <stdlib.h>
332#include <sys/types.h>
333#include <sys/syscall.h>
334#include <sys/swap.h>
335
336#ifndef NULL
337#define NULL (void *)0
338#endif
339],
340[
341    register int cnt, i;
342    register int t, f;
343    struct swaptable *swt;
344    struct swapent *ste;
345    static char path[256];
346
347    /* get total number of swap entries */
348    cnt = swapctl(SC_GETNSWP, 0);
349
350    /* allocate enough space to hold count + n swapents */
351    swt = (struct swaptable *)malloc(sizeof(int) +
352             cnt * sizeof(struct swapent));
353    if (swt == NULL)
354    {
355  return;
356    }
357    swt->swt_n = cnt;
358
359    /* fill in ste_path pointers: we do not care about the paths, so we
360point
361       them all to the same buffer */
362    ste = &(swt->swt_ent[0]);
363    i = cnt;
364    while (--i >= 0)
365    {
366  ste++->ste_path = path;
367    }
368
369    /* grab all swap info */
370    swapctl(SC_LIST, swt);
371
372    /* walk through the structs and sum up the fields */
373    t = f = 0;
374    ste = &(swt->swt_ent[0]);
375    i = cnt;
376    while (--i >= 0)
377    {
378  /* do not count slots being deleted */
379  if (!(ste->ste_flags & ST_INDEL) &&
380      !(ste->ste_flags & ST_DOINGDEL))
381  {
382      t += ste->ste_pages;
383      f += ste->ste_free;
384  } ste++;
385    }
386
387    /* fill in the results */
388    free(swt);
389
390],
391AC_DEFINE(HAVE_SYS_SWAP_SWAPTABLE,1,[Define to 1 if struct 'swaptable' exists.])
392AC_MSG_RESULT(yes),
393AC_MSG_RESULT(no))
394
395AC_MSG_CHECKING(for struct sensordev in sys/sensors.h)
396AC_TRY_COMPILE([
397#include <stdlib.h>
398#include <sys/queue.h>
399#include <sys/sensors.h>],
400[struct sensordev sensordev;
401sensordev.xname[0]='\0';
402sensordev.maxnumt[0]=0;
403],
404AC_DEFINE(HAVE_SENSORDEV,1,[Define to 1 if struct 'sensordev' exists.])
405AC_MSG_RESULT(yes),
406AC_MSG_RESULT(no))
407
408AC_MSG_CHECKING(for struct statvfs64 in sys/statvfs.h)
409AC_TRY_COMPILE(
410[
411#ifdef HAVE_SYS_TYPES_H
412#	include <sys/types.h>
413#endif
414#ifdef HAVE_SYS_STATVFS_H
415#	include <sys/statvfs.h>
416#endif
417],
418[
419	struct statvfs64	s;
420	s.f_frsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
421	statvfs64("/", &s);
422],
423AC_DEFINE(HAVE_SYS_STATVFS64, 1, [Define to 1 if struct 'statvfs64' exists.])
424AC_MSG_RESULT(yes),
425AC_MSG_RESULT(no))
426
427AC_MSG_CHECKING(for struct statfs64 in sys/statfs.h)
428AC_TRY_COMPILE(
429[
430#ifdef HAVE_SYS_TYPES_H
431#	include <sys/types.h>
432#endif
433#ifdef HAVE_SYS_STATFS_H
434#	include <sys/statfs.h>
435#endif
436],
437[
438	struct statfs64	s;
439	s.f_bsize = s.f_blocks = s.f_bfree = s.f_bavail = 0;
440	statfs64("/", &s);
441],
442AC_DEFINE(HAVE_SYS_STATFS64, 1, [Define to 1 if struct 'statfs64' exists.])
443AC_MSG_RESULT(yes),
444AC_MSG_RESULT(no))
445
446AC_MSG_CHECKING(for field ss_family in struct sockaddr_storage)
447AC_TRY_COMPILE([#include <sys/socket.h>],
448[struct sockaddr_storage ss;
449ss.ss_family = 0;
450],
451AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_FAMILY, 1, [Define to 1 if 'sockaddr_storage.ss_family' exists.])
452AC_MSG_RESULT(yes),
453AC_MSG_RESULT(no))
454
455AC_MSG_CHECKING(for field mem_unit in struct sysinfo)
456AC_TRY_COMPILE([#include <sys/sysinfo.h>],
457[struct sysinfo sysinfo;
458sysinfo.mem_unit=0;
459],
460AC_DEFINE(HAVE_SYSINFO_MEM_UNIT,1,[Define to 1 if 'sysinfo.mem_unit' exists.])
461AC_MSG_RESULT(yes),
462AC_MSG_RESULT(no))
463
464AC_MSG_CHECKING(for field freeswap in struct sysinfo)
465AC_TRY_COMPILE([#include <sys/sysinfo.h>],
466[struct sysinfo sysinfo;
467sysinfo.freeswap=0;
468],
469AC_DEFINE(HAVE_SYSINFO_FREESWAP,1,[Define to 1 if 'sysinfo.freeswap' exists.])
470AC_MSG_RESULT(yes),
471AC_MSG_RESULT(no))
472
473AC_MSG_CHECKING(for field totalswap in struct sysinfo)
474AC_TRY_COMPILE([#include <sys/sysinfo.h>],
475[struct sysinfo sysinfo;
476sysinfo.totalswap=0;
477],
478AC_DEFINE(HAVE_SYSINFO_TOTALSWAP,1,[Define to 1 if 'sysinfo.totalswap' exists.])
479AC_MSG_RESULT(yes),
480AC_MSG_RESULT(no))
481
482AC_MSG_CHECKING(for field totalram in struct sysinfo)
483AC_TRY_COMPILE([#include <sys/sysinfo.h>],
484[struct sysinfo sysinfo;
485sysinfo.totalram=0;
486],
487AC_DEFINE(HAVE_SYSINFO_TOTALRAM,1,[Define to 1 if 'sysinfo.totalram' exists.])
488AC_MSG_RESULT(yes),
489AC_MSG_RESULT(no))
490
491AC_MSG_CHECKING(for field sharedram in struct sysinfo)
492AC_TRY_COMPILE([#include <sys/sysinfo.h>],
493[struct sysinfo sysinfo;
494sysinfo.sharedram=0;
495],
496AC_DEFINE(HAVE_SYSINFO_SHAREDRAM,1,[Define to 1 if 'sysinfo.sharedram' exists.])
497AC_MSG_RESULT(yes),
498AC_MSG_RESULT(no))
499
500AC_MSG_CHECKING(for field bufferram in struct sysinfo)
501AC_TRY_COMPILE([#include <sys/sysinfo.h>],
502[struct sysinfo sysinfo;
503sysinfo.bufferram=0;
504],
505AC_DEFINE(HAVE_SYSINFO_BUFFERRAM,1,[Define to 1 if 'sysinfo.bufferram' exists.])
506AC_MSG_RESULT(yes),
507AC_MSG_RESULT(no))
508
509AC_MSG_CHECKING(for field freeram in struct sysinfo)
510AC_TRY_COMPILE([#include <sys/sysinfo.h>],
511[struct sysinfo sysinfo;
512sysinfo.freeram=0;
513],
514AC_DEFINE(HAVE_SYSINFO_FREERAM,1,[Define to 1 if 'sysinfo.freeram' exists.])
515AC_MSG_RESULT(yes),
516AC_MSG_RESULT(no))
517
518AC_MSG_CHECKING(for field uptime in struct sysinfo)
519AC_TRY_COMPILE([#include <sys/sysinfo.h>],
520[struct sysinfo sysinfo;
521sysinfo.uptime=0;
522],
523AC_DEFINE(HAVE_SYSINFO_UPTIME,1,[Define to 1 if 'sysinfo.uptime' exists.])
524AC_MSG_RESULT(yes),
525AC_MSG_RESULT(no))
526
527AC_MSG_CHECKING(for field procs in struct sysinfo)
528AC_TRY_COMPILE([#include <sys/sysinfo.h>],
529[struct sysinfo sysinfo;
530sysinfo.procs=0;
531],
532AC_DEFINE(HAVE_SYSINFO_PROCS,1,[Define to 1 if 'sysinfo.procs' exists.])
533AC_MSG_RESULT(yes),
534AC_MSG_RESULT(no))
535
536AC_MSG_CHECKING(for field tm_gmtoff in struct tm)
537AC_TRY_COMPILE([
538#ifdef HAVE_SYS_TIME_H
539#include <sys/time.h>
540#endif	/* HAVE_SYS_TIME_H */
541
542#ifdef HAVE_TIME_H
543#include <time.h>
544#endif	/* HAVE_TIME_H */
545],
546[
547	struct tm tm;
548	tm.tm_gmtoff;
549],
550AC_DEFINE(HAVE_TM_TM_GMTOFF,1,[Define to 1 if 'tm.tm_gmtoff' exists.])
551AC_MSG_RESULT(yes),
552AC_MSG_RESULT(no))
553
554dnl *****************************************************************
555dnl *                                                               *
556dnl *                     Checks for functions                      *
557dnl *                                                               *
558dnl *****************************************************************
559
560AC_MSG_CHECKING(for function sysconf() in unistd.h)
561AC_TRY_COMPILE(
562[
563#include <unistd.h>
564],
565[	int i;
566
567	i=sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
568	i=sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
569],
570AC_DEFINE(HAVE_UNISTD_SYSCONF,1,[Define to 1 if function 'sysconf' exists.])
571AC_MSG_RESULT(yes),
572AC_MSG_RESULT(no))
573
574AC_MSG_CHECKING(for function initgroups())
575AC_TRY_LINK(
576[
577#include <sys/types.h>
578#include <grp.h>
579],
580[
581	char	*user = "zabbix";
582	initgroups(user, 0);
583],
584AC_DEFINE(HAVE_FUNCTION_INITGROUPS,1,[Define to 1 if function 'initgroups' exists.])
585AC_MSG_RESULT(yes),
586AC_MSG_RESULT(no))
587
588AC_MSG_CHECKING(for functions seteuid() and setegid())
589AC_TRY_LINK(
590[
591#include <sys/types.h>
592#include <unistd.h>
593],
594[
595	seteuid(0);
596	setegid(0);
597],
598AC_DEFINE(HAVE_FUNCTION_SETEUID,1,[Define to 1 if functions 'seteuid' and 'setegid' exist.])
599AC_MSG_RESULT(yes),
600AC_MSG_RESULT(no))
601
602AC_MSG_CHECKING(for function setproctitle())
603AC_TRY_LINK(
604[
605#include <sys/types.h>
606#include <unistd.h>
607],
608[
609	setproctitle("Test %d", 1);
610],
611AC_DEFINE(HAVE_FUNCTION_SETPROCTITLE,1,[Define to 1 if function 'setproctitle' exists.])
612AC_MSG_RESULT(yes),
613AC_MSG_RESULT(no))
614
615AC_MSG_CHECKING(for function sysctlbyname())
616AC_TRY_LINK(
617[
618#ifdef HAVE_SYS_TYPES_H
619#include <sys/types.h>
620#endif /* HAVE_SYS_TYPES_H */
621
622#ifdef HAVE_SYS_PARAM_H
623#include <sys/param.h>
624#endif /* HAVE_SYS_PARAM_H */
625
626#include <sys/sysctl.h>
627],
628[
629	sysctlbyname("", 0, 0, 0, 0);
630],
631AC_DEFINE(HAVE_FUNCTION_SYSCTLBYNAME,1,[Define to 1 if 'sysctlbyname' exists.])
632AC_MSG_RESULT(yes),
633AC_MSG_RESULT(no))
634
635AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME))
636AC_TRY_COMPILE(
637[
638#ifdef HAVE_SYS_TYPES_H
639#include <sys/types.h>
640#endif /* HAVE_SYS_TYPES_H */
641
642#ifdef HAVE_SYS_PARAM_H
643#include <sys/param.h>
644#endif /* HAVE_SYS_PARAM_H */
645
646#include <sys/sysctl.h>
647#include <unistd.h>
648#include <time.h>
649#include <sys/time.h>
650],
651[
652	size_t		len;
653	struct timeval	uptime;
654        int		mib[2];
655
656        mib[0] = CTL_KERN;
657        mib[1] = KERN_BOOTTIME;
658
659        len = sizeof(uptime);
660        sysctl(mib, 2, &uptime, &len, 0, 0);
661],
662AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME,1,[Define to 1 if 'KERN_BOOTTIME' exists.])
663AC_MSG_RESULT(yes),
664AC_MSG_RESULT(no))
665
666AC_MSG_CHECKING(for function sysctl (HW_NCPU))
667AC_TRY_COMPILE(
668[
669#ifdef HAVE_SYS_TYPES_H
670#include <sys/types.h>
671#endif /* HAVE_SYS_TYPES_H */
672
673#ifdef HAVE_SYS_PARAM_H
674#include <sys/param.h>
675#endif /* HAVE_SYS_PARAM_H */
676
677#include <sys/sysctl.h>
678],
679[
680	size_t	len;
681	int	mib[2], ncpu;
682
683	mib[0] = CTL_HW;
684	mib[1] = HW_NCPU;
685
686	len = sizeof(ncpu);
687	sysctl(mib, 2, &ncpu, &len, 0, 0);
688],
689AC_DEFINE(HAVE_FUNCTION_SYSCTL_HW_NCPU,1,[Define to 1 if 'HW_NCPU' exists.])
690AC_MSG_RESULT(yes),
691AC_MSG_RESULT(no))
692
693AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES))
694AC_TRY_COMPILE(
695[
696#ifdef HAVE_SYS_TYPES_H
697#include <sys/types.h>
698#endif /* HAVE_SYS_TYPES_H */
699
700#ifdef HAVE_SYS_PARAM_H
701#include <sys/param.h>
702#endif /* HAVE_SYS_PARAM_H */
703
704#include <sys/sysctl.h>
705],
706[
707	size_t	len;
708        int	mib[2], maxfiles;
709
710        mib[0] = CTL_KERN;
711        mib[1] = KERN_MAXFILES;
712
713        len = sizeof(maxfiles);
714        sysctl(mib, 2, &maxfiles, &len, 0, 0);
715],
716AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES,1,[Define to 1 if 'KERN_MAXFILES' exists.])
717AC_MSG_RESULT(yes),
718AC_MSG_RESULT(no))
719
720AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC))
721AC_TRY_COMPILE(
722[
723#ifdef HAVE_SYS_TYPES_H
724#include <sys/types.h>
725#endif /* HAVE_SYS_TYPES_H */
726
727#ifdef HAVE_SYS_PARAM_H
728#include <sys/param.h>
729#endif /* HAVE_SYS_PARAM_H */
730
731#include <sys/sysctl.h>
732],
733[
734	size_t	len;
735	int	mib[2], maxproc;
736
737        mib[0] = CTL_KERN;
738        mib[1] = KERN_MAXPROC;
739
740        len = sizeof(maxproc);
741        sysctl(mib, 2, &maxproc, &len, 0, 0);
742],
743AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC,1,[Define to 1 if 'KERN_MAXPROC' exists.])
744AC_MSG_RESULT(yes),
745AC_MSG_RESULT(no))
746
747AC_MSG_CHECKING(for function sysctl (KERN_CPTIME,KERN_CPTIME2))
748AC_TRY_COMPILE(
749[
750#include <sys/param.h>
751#include <sys/sysctl.h>
752#if defined(HAVE_SYS_DKSTAT_H)
753#	include <sys/dkstat.h>
754#elif defined(HAVE_SYS_SCHED_H)
755#	include <sys/sched.h>
756#endif
757],
758[
759size_t	sz;
760int	i[] = {CP_USER, CP_NICE, CP_SYS, CP_INTR, CP_IDLE};
761
762{
763	long	states[CPUSTATES];
764	int	mib[2] = {CTL_KERN, KERN_CPTIME};
765
766	sz = sizeof(states);
767	sysctl(mib, 2, &states, &sz, NULL, 0);
768}
769
770{
771	u_int64_t	states[CPUSTATES];
772	int		mib[3] = {CTL_KERN, KERN_CPTIME2, 0};
773
774	sz = sizeof(states);
775	sysctl(mib, 3, &states, &sz, NULL, 0);
776}
777],
778AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_CPTIME,1,[Define to 1 if 'KERN_CPTIME,KERN_CPTIME2' exists.])
779AC_MSG_RESULT(yes),
780AC_MSG_RESULT(no))
781
782AC_MSG_CHECKING(for function clock_gettime in time.h)
783AC_TRY_LINK([
784#ifdef HAVE_TIME_H
785#	include <time.h>
786#elif HAVE_SYS_TIME_H
787#	include <sys/time.h>
788#endif	/* HAVE_SYS_TIME_H */
789],
790[struct timespec tp;
791clock_gettime(CLOCK_REALTIME, &tp);
792],
793AC_DEFINE(HAVE_TIME_CLOCK_GETTIME,1,[Define to 1 if function 'clock_gettime' exists.])
794AC_MSG_RESULT(yes),
795AC_MSG_RESULT(no))
796
797dnl *****************************************************************
798dnl *                                                               *
799dnl *                      Checks for macros                        *
800dnl *                                                               *
801dnl *****************************************************************
802
803AC_MSG_CHECKING(for macro __va_copy() in stdarg.h)
804AC_TRY_COMPILE(
805[
806#include <stdarg.h>
807],
808[
809	va_list	src,dst;
810
811	__va_copy(dst,src);
812],
813AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if macro '__va_copy' exists.])
814AC_MSG_RESULT(yes),
815AC_MSG_RESULT(no))
816
817AC_MSG_CHECKING(for macro __VA_ARGS__)
818AC_TRY_COMPILE(
819[
820#define ZBX_CONST_STRING(str)   str
821int test(const char *fmt, ...) { return 0; }
822],
823[
824#define TEST(fmt, ...) test(ZBX_CONST_STRING(fmt), ##__VA_ARGS__)
825TEST("%s","test");
826TEST("test");
827],
828AC_DEFINE(HAVE___VA_ARGS__,1,[Define to 1 if macro '__VA_ARGS__' exists.])
829AC_MSG_RESULT(yes),
830AC_MSG_RESULT(no))
831
832dnl *****************************************************************
833dnl *                                                               *
834dnl *                 Checks for library functions                  *
835dnl *                                                               *
836dnl *****************************************************************
837
838AC_TYPE_SIGNAL
839AC_REPLACE_FUNCS(getloadavg)
840AC_CHECK_FUNCS(hstrerror)
841AC_CHECK_FUNCS(getenv)
842AC_CHECK_FUNCS(putenv)
843AC_CHECK_FUNCS(sigqueue)
844AC_CHECK_FUNCS(round)
845
846dnl *****************************************************************
847dnl *                                                               *
848dnl *            Checks for file system characteristics             *
849dnl *                                                               *
850dnl *****************************************************************
851
852AC_MSG_CHECKING(for /proc filesystem)
853if test -d /proc; then
854	AC_MSG_RESULT(yes)
855	AC_DEFINE(HAVE_PROC,1,[Define to 1 if '/proc' file system should be used.])
856else
857	AC_MSG_RESULT(no)
858fi
859
860AC_MSG_CHECKING(for file /proc/stat)
861if test -r /proc/stat; then
862	AC_MSG_RESULT(yes)
863	AC_DEFINE(HAVE_PROC_STAT,1,[Define to 1 if file '/proc/stat' should be used.])
864else
865	AC_MSG_RESULT(no)
866fi
867
868AC_MSG_CHECKING(for file /proc/cpuinfo)
869if test -r /proc/cpuinfo; then
870	AC_MSG_RESULT(yes)
871	AC_DEFINE(HAVE_PROC_CPUINFO,1,[Define to 1 if file '/proc/cpuinfo' should be used.])
872else
873	AC_MSG_RESULT(no)
874fi
875
876dnl Solaris
877AC_MSG_CHECKING(for file /proc/0/psinfo)
878if test -r /proc/0/psinfo; then
879	AC_MSG_RESULT(yes)
880	AC_DEFINE(HAVE_PROC_0_PSINFO,1,[Define to 1 if file '/proc/0/psinfo' should be used.])
881else
882	AC_MSG_RESULT(no)
883fi
884
885AC_MSG_CHECKING(for file /proc/loadavg)
886if test -r /proc/loadavg; then
887	AC_MSG_RESULT(yes)
888	AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define to 1 if file '/proc/loadavg' should be used.])
889else
890	AC_MSG_RESULT(no)
891fi
892
893AC_MSG_CHECKING(for file /proc/net/dev)
894if test -r /proc/net/dev; then
895	AC_MSG_RESULT(yes)
896	AC_DEFINE(HAVE_PROC_NET_DEV,1,[Define to 1 if file '/proc/net/dev' should be used.])
897else
898	AC_MSG_RESULT(no)
899fi
900
901dnl *****************************************************************
902dnl *                                                               *
903dnl *              Checks for compiler characteristics              *
904dnl *                                                               *
905dnl *****************************************************************
906
907dnl Check for %qu format (FreeBSD 4.x)
908dnl FreeBSD 4.x does not support %llu
909AC_MSG_CHECKING(for long long format)
910AC_TRY_RUN(
911[
912#include <sys/types.h>
913int main()
914{
915        uint64_t i;
916
917        sscanf("200000000010020", "%qu", &i);
918
919        if (i == 200000000010020) return 0;
920        else return -1;
921}
922],
923AC_DEFINE(HAVE_LONG_LONG_QU, 1 ,[Define to 1 if format '%qu' exists.])
924AC_MSG_RESULT(yes),
925AC_MSG_RESULT(no),
926AC_MSG_RESULT(no))
927
928dnl option -rdynamic is needed for readable backtraces
929AC_MSG_CHECKING(for -rdynamic linking option)
930saved_LDFLAGS="$LDFLAGS"
931LDFLAGS="-rdynamic $LDFLAGS"
932AC_TRY_LINK([#include <execinfo.h>],
933[void *bcktrc[6];
934(void)backtrace(bcktrc, 6);
935],
936LDFLAGS="-rdynamic $saved_LDFLAGS"
937AC_MSG_RESULT(yes),
938LDFLAGS="$saved_LDFLAGS"
939AC_MSG_RESULT(no))
940
941dnl *****************************************************************
942dnl *                                                               *
943dnl *                 Checks for operating systems                  *
944dnl *                                                               *
945dnl *****************************************************************
946
947AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset)
948AC_TRY_COMPILE([#include <sys/protosw.h>
949#include <libperfstat.h>],
950[perfstat_memory_total_t	memstats;
951memstats.virt_active = 0;
952],
953AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.])
954AC_MSG_RESULT(yes),
955AC_MSG_RESULT(no))
956
957AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset)
958AC_TRY_COMPILE([#include <sys/protosw.h>
959#include <libperfstat.h>],
960[perfstat_partition_total_t	lparstats;
961lparstats.type.b.donate_enabled = 0;
962lparstats.idle_donated_purr = 0;
963lparstats.busy_donated_purr = 0;
964lparstats.idle_stolen_purr = 0;
965lparstats.busy_stolen_purr = 0;
966],
967AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.])
968AC_MSG_RESULT(yes),
969AC_MSG_RESULT(no))
970
971case "$host_os" in
972linux*)
973	ARCH="linux"
974	;;
975aix*)
976	ARCH="aix"
977	;;
978darwin*|rhapsody*)
979	ARCH="osx"
980	AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X.])
981	;;
982*solaris*)
983	ARCH="solaris"
984	;;
985hpux*)
986	ARCH="hpux"
987	;;
988freebsd*)
989	ARCH="freebsd"
990	;;
991netbsd*)
992	ARCH="netbsd"
993	;;
994osf*)
995	ARCH="osf"
996	;;
997openbsd*)
998	ARCH="openbsd"
999	;;
1000*)
1001	ARCH="unknown"
1002	;;
1003esac
1004
1005AC_MSG_CHECKING(for architecture)
1006AC_MSG_RESULT([$ARCH ($host_os)])
1007
1008if test "x$ARCH" = "xlinux"; then
1009	AC_MSG_CHECKING([for the linux kernel version])
1010
1011	kernel=`uname -r`
1012
1013	case "${kernel}" in
1014		2.6.*)
1015			AC_MSG_RESULT([2.6 family (${kernel})])
1016			AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x])
1017			;;
1018		2.4.*)
1019			AC_MSG_RESULT([2.4 family (${kernel})])
1020			AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x])
1021			;;
1022		*)
1023			AC_MSG_RESULT([unknown family (${kernel})])
1024			;;
1025	esac
1026fi
1027
1028if test "x$ARCH" = "xsolaris"; then
1029	dnl Forcing a 64-bit application for a 64-bit Solaris
1030	dnl A 32-bit program that uses /proc is able to look at 32-bit processes,
1031	dnl but is not able to understand all attributes of a 64-bit process.
1032	AC_MSG_CHECKING(for -m64 compilation flag)
1033	saved_CFLAGS="$CFLAGS"
1034	CFLAGS="-m64"
1035	AC_TRY_RUN(
1036	[int main(void) {return 0;}],
1037	CFLAGS="-m64 $saved_CFLAGS"
1038	AC_MSG_RESULT(yes),
1039	CFLAGS="$saved_CFLAGS"
1040	AC_MSG_RESULT(no))
1041fi
1042
1043if test "x$ARCH" = "xhpux"; then
1044	dnl Low Level Discovery needs a way to get the list of network
1045	dnl interfaces available on the monitored system. On HP-UX systems
1046	dnl that way depends on the OS version.
1047	hpux_version=${host_os#hpux}
1048	hpux_major=${hpux_version%.*}
1049	hpux_minor=${hpux_version#*.}
1050
1051	AC_DEFINE_UNQUOTED([HPUX_VERSION], $hpux_major$hpux_minor, [Define to HP-UX version])
1052
1053	dnl This API level is needed so that "utsname.nodename" is not truncated.
1054	AC_MSG_CHECKING(for -D_HPUX_API_LEVEL=20040821 compilation flag)
1055	saved_CFLAGS="$CFLAGS"
1056	CFLAGS="-D_HPUX_API_LEVEL=20040821"
1057	AC_TRY_RUN(
1058[
1059#ifdef HAVE_DLFCN_H
1060#	include <dlfcn.h>
1061#endif
1062#ifdef HAVE_SYS_UTSNAME_H
1063#	include <sys/utsname.h>
1064#endif
1065
1066int main(void)
1067{
1068	void		*p1, *p2;
1069	struct utsname	name;
1070
1071	/* check that the compiler (e.g., GCC 4.3.0 and above) supports function-level versioning */
1072
1073	p1 = uname;
1074	p2 = dlsym(RTLD_DEFAULT, "uname{20040821}");
1075
1076	if (p1 != p2)
1077		return 1;
1078
1079	/* uname() fails with EFAULT on HP-UX systems that were only partially upgraded to this API level */
1080
1081	return -1 == uname(&name) ? 1 : 0;
1082}
1083],
1084	CFLAGS="-D_HPUX_API_LEVEL=20040821 $saved_CFLAGS"
1085	AC_MSG_RESULT(yes),
1086	CFLAGS="$saved_CFLAGS"
1087	AC_MSG_RESULT(no))
1088fi
1089
1090AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing])
1091AC_SUBST(ARCH)
1092
1093AC_CHECK_SIZEOF([void *])
1094
1095dnl *****************************************************************
1096dnl *                                                               *
1097dnl *         Checks for options given on the command line          *
1098dnl *                                                               *
1099dnl *****************************************************************
1100
1101AC_ARG_ENABLE(static,[  --enable-static         Build statically linked binaries],
1102[case "${enableval}" in
1103  yes)
1104    LDFLAGS="${LDFLAGS} -static"
1105    AC_MSG_CHECKING(if static linking is possible)
1106    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1107      [AC_MSG_RESULT([yes])
1108        static_linking=yes],
1109      [AC_MSG_RESULT([no])
1110        static_linking=no])
1111      if test "x$static_linking" = "xno"; then
1112        AC_MSG_ERROR([static linking is not possible on this system])
1113      fi
1114    ;;
1115  no) ;;
1116  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static]) ;;
1117esac])
1118
1119AC_ARG_ENABLE(server,[  --enable-server         Turn on build of Zabbix server],
1120[case "${enableval}" in
1121  yes) server=yes ;;
1122  no)  server=no ;;
1123  *) AC_MSG_ERROR([bad value ${enableval} for --enable-server]) ;;
1124esac],
1125[server=no])
1126AM_CONDITIONAL(SERVER, test "x$server" = "xyes")
1127
1128AC_ARG_ENABLE(proxy,[  --enable-proxy          Turn on build of Zabbix proxy],
1129[case "${enableval}" in
1130  yes) proxy=yes ;;
1131  no)  proxy=no ;;
1132  *) AC_MSG_ERROR([bad value ${enableval} for --enable-proxy]) ;;
1133esac],
1134[proxy=no])
1135AM_CONDITIONAL(PROXY, test "x$proxy" = "xyes")
1136
1137AC_ARG_ENABLE(agent,[  --enable-agent          Turn on build of Zabbix agent and client utilities],
1138[case "${enableval}" in
1139  yes) agent=yes ;;
1140  no)  agent=no ;;
1141  *) AC_MSG_ERROR([bad value ${enableval} for --enable-agent]) ;;
1142esac],
1143[agent=no])
1144AM_CONDITIONAL(AGENT, test "x$agent" = "xyes")
1145
1146AC_ARG_ENABLE(java,[  --enable-java           Turn on build of Zabbix Java gateway],
1147[case "${enableval}" in
1148  yes) java=yes ;;
1149  no)  java=no ;;
1150  *) AC_MSG_ERROR([bad value ${enableval} for --enable-java]) ;;
1151esac],
1152[java=no])
1153AM_CONDITIONAL(JAVA, test "x$java" = "xyes")
1154
1155AC_ARG_ENABLE(ipv6,[  --enable-ipv6           Turn on support of IPv6],
1156[case "${enableval}" in
1157  yes) ipv6=yes ;;
1158  no)  ipv6=no ;;
1159  *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
1160esac],
1161[ipv6=no])
1162
1163have_db="no"
1164have_unixodbc="no"
1165have_web_monitoring="no"
1166have_jabber="no"
1167have_snmp="no"
1168have_ipmi="no"
1169have_ipv6="no"
1170have_ssh2="no"
1171have_tls="no"
1172
1173if test "x$ipv6" = "xyes"; then
1174	AC_DEFINE(HAVE_IPV6,1,[Define to 1 if IPv6 should be enabled.])
1175	have_ipv6="yes"
1176fi
1177
1178if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then
1179
1180	have_multirow_insert="no"
1181
1182	dnl Checking for IBM DB2 support
1183	AX_LIB_IBM_DB2()
1184	if test "x$want_ibm_db2" = "xyes"; then
1185		if test "x$have_db" != "xno"; then
1186			AC_MSG_ERROR([You can configure for only one database.])
1187		fi
1188
1189		if test "x$found_ibm_db2" = "xyes"; then
1190			have_db="IBM DB2"
1191			have_multirow_insert="yes"
1192		else
1193			AC_MSG_ERROR([IBM DB2 library not found])
1194		fi
1195	fi
1196
1197	dnl Checking for MySQL support
1198	AX_LIB_MYSQL()
1199	if test "x$want_mysql" = "xyes"; then
1200		if test "x$have_db" != "xno"; then
1201			AC_MSG_ERROR([You can configure for only one database.])
1202		fi
1203
1204		if test "x$found_mysql" = "xyes"; then
1205			have_db="MySQL"
1206			have_multirow_insert="yes"
1207		else
1208			AC_MSG_ERROR([MySQL library not found])
1209		fi
1210	fi
1211
1212	dnl Checking for Oracle support
1213	AX_LIB_ORACLE_OCI([10.0])
1214	if test "x$want_oracle_oci" = "xyes"; then
1215		if test "x$have_db" != "xno"; then
1216			AC_MSG_ERROR([You can configure for only one database.])
1217		fi
1218
1219		if test "x$HAVE_ORACLE_OCI" = "xyes"; then
1220			have_db="Oracle"
1221
1222			ORACLE_CPPFLAGS="$ORACLE_OCI_CFLAGS"
1223			ORACLE_LDFLAGS="$ORACLE_OCI_LDFLAGS"
1224			ORACLE_LIBS="$ORACLE_OCI_LIBS"
1225
1226			AC_DEFINE(HAVE_ORACLE,1,[Define to 1 if Oracle should be enabled.])
1227		else
1228			AC_MSG_ERROR([Oracle OCI library not found])
1229		fi
1230	fi
1231
1232	dnl Checking for PostgreSQL support
1233	AX_LIB_POSTGRESQL("8.1")
1234	if test "x$want_postgresql" = "xyes"; then
1235		if test "x$have_db" != "xno"; then
1236			AC_MSG_ERROR([You can configure for only one database.])
1237		fi
1238
1239		if test "x$found_postgresql" = "xyes"; then
1240			if test "$postgresql_version_check" != "1"; then
1241				AC_MSG_ERROR([PostgreSQL version mismatch])
1242			fi
1243
1244			have_db="PostgreSQL"
1245
1246			if test "$postgresql_version_number" -ge 8002000; then
1247				have_multirow_insert="yes"
1248			fi
1249
1250		else
1251			AC_MSG_ERROR([PostgreSQL library not found])
1252		fi
1253	fi
1254
1255	dnl Checking for SQLite3 support
1256	AX_LIB_SQLITE3()
1257	if test "x$want_sqlite3" = "xyes"; then
1258		if test "x$have_db" != "xno"; then
1259			AC_MSG_ERROR([You can configure for only one database.])
1260		fi
1261
1262		if test "x$found_sqlite3" = "xyes"; then
1263			have_db="SQLite v3.x"
1264
1265			saved_CPPFLAGS="$CPPFLAGS"
1266			saved_LDFLAGS="$LDFLAGS"
1267
1268			CPPFLAGS="$CPPFLAGS $SQLITE3_CPPFLAGS"
1269			LDFLAGS="$LDFLAGS $SQLITE3_LDFLAGS $SQLITE3_LIBS"
1270
1271			AC_MSG_CHECKING([for function sqlite3_open_v2() in sqlite3.h])
1272			AC_TRY_LINK([#include <sqlite3.h>],
1273				[sqlite3 *conn = 0;
1274				sqlite3_open_v2("dbname", &conn, SQLITE_OPEN_READWRITE, 0);
1275				],
1276				AC_DEFINE(HAVE_FUNCTION_SQLITE3_OPEN_V2,1,[Define to 1 if function 'sqlite3_open_v2' exists.])
1277				AC_MSG_RESULT(yes),
1278				AC_MSG_RESULT(no))
1279
1280			CPPFLAGS="$saved_CPPFLAGS"
1281			LDFLAGS="$saved_LDFLAGS"
1282		else
1283			AC_MSG_ERROR([SQLite3 library not found])
1284		fi
1285	fi
1286
1287	AC_MSG_CHECKING(for Zabbix server/proxy database selection)
1288	if test "x$have_db" = "xno"; then
1289		AC_MSG_RESULT(error)
1290		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.])
1291	else
1292		AC_MSG_RESULT(ok)
1293	fi
1294
1295	AC_MSG_CHECKING(for multirow insert statements)
1296	if test "x$have_multirow_insert" = "xyes"; then
1297		AC_DEFINE(HAVE_MULTIROW_INSERT,1,[Define to 1 if database supports multirow insert statements.])
1298		AC_MSG_RESULT(yes)
1299	else
1300		AC_MSG_RESULT(no)
1301	fi
1302
1303	DB_CFLAGS="$IBM_DB2_CPPFLAGS $MYSQL_CFLAGS $ORACLE_CPPFLAGS $POSTGRESQL_CFLAGS $SQLITE3_CPPFLAGS"
1304	DB_LDFLAGS="$IBM_DB2_LDFLAGS $MYSQL_LDFLAGS $ORACLE_LDFLAGS $POSTGRESQL_LDFLAGS $SQLITE3_LDFLAGS"
1305	DB_LIBS="$IBM_DB2_LIBS $MYSQL_LIBS $ORACLE_LIBS $POSTGRESQL_LIBS $SQLITE3_LIBS"
1306
1307	AC_SUBST(DB_CFLAGS)
1308	AC_SUBST(DB_LDFLAGS)
1309	AC_SUBST(DB_LIBS)
1310
1311	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${DB_LDFLAGS}"
1312	SERVER_LIBS="${SERVER_LIBS} ${DB_LIBS}"
1313
1314	PROXY_LDFLAGS="${PROXY_LDFLAGS} ${DB_LDFLAGS}"
1315	PROXY_LIBS="${PROXY_LIBS} ${DB_LIBS}"
1316
1317	dnl Checking for Jabber libraries
1318	JABBER_CHECK_CONFIG()
1319	if test "x$want_jabber" = "xyes"; then
1320		if test "x$found_jabber" != "xyes"; then
1321			AC_MSG_ERROR([Jabber library not found])
1322		else
1323			have_jabber="yes"
1324		fi
1325	fi
1326	SERVER_LDFLAGS="$SERVER_LDFLAGS $JABBER_LDFLAGS"
1327	SERVER_LIBS="$SERVER_LIBS $JABBER_LIBS"
1328
1329	AC_SUBST(JABBER_CPPFLAGS)
1330
1331	dnl Check for LIBXML2 [by default - skip]
1332	LIBXML2_CHECK_CONFIG([no])
1333	if test "x$want_libxml2" = "xyes"; then
1334		if test "x$found_libxml2" != "xyes"; then
1335			AC_MSG_ERROR([LIBXML2 library not found])
1336		else
1337			have_libxml2="yes"
1338		fi
1339	fi
1340	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBXML2_LDFLAGS"
1341	SERVER_LIBS="$SERVER_LIBS $LIBXML2_LIBS"
1342
1343	PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBXML2_LDFLAGS"
1344	PROXY_LIBS="$PROXY_LIBS $LIBXML2_LIBS"
1345
1346	AC_SUBST(LIBXML2_CFLAGS)
1347
1348	dnl Checking for unixODBC support
1349	LIBUNIXODBC_CHECK_CONFIG([no])
1350	if test "x$want_unixodbc" = "xyes"; then
1351		if test "x$unixodbc_error" != "x"; then
1352			AC_MSG_ERROR($unixodbc_error)
1353		fi
1354		have_unixodbc="yes"
1355	fi
1356	SERVER_LDFLAGS="$SERVER_LDFLAGS $UNIXODBC_LDFLAGS"
1357	SERVER_LIBS="$SERVER_LIBS $UNIXODBC_LIBS"
1358
1359	PROXY_LDFLAGS="$PROXY_LDFLAGS $UNIXODBC_LDFLAGS"
1360	PROXY_LIBS="$PROXY_LIBS $UNIXODBC_LIBS"
1361
1362	AC_SUBST(UNIXODBC_CFLAGS)
1363
1364	dnl Check for Net-SNMP [by default - skip]
1365	LIBNETSNMP_CHECK_CONFIG([no])
1366	if test "x$want_netsnmp" = "xyes"; then
1367		if test "x$found_netsnmp" != "xyes"; then
1368			AC_MSG_ERROR([Invalid Net-SNMP directory - unable to find net-snmp-config])
1369		else
1370			have_snmp="yes"
1371		fi
1372	fi
1373	SERVER_LDFLAGS="$SERVER_LDFLAGS $SNMP_LDFLAGS"
1374	SERVER_LIBS="$SERVER_LIBS $SNMP_LIBS"
1375
1376	PROXY_LDFLAGS="$PROXY_LDFLAGS $SNMP_LDFLAGS"
1377	PROXY_LIBS="$PROXY_LIBS $SNMP_LIBS"
1378
1379	AC_SUBST(SNMP_CFLAGS)
1380
1381	dnl Check for LIBSSH2 [by default - skip] at least of version 1.0.0.
1382	LIBSSH2_CHECK_CONFIG([no])
1383	if test "x$want_ssh2" = "xyes"; then
1384		if test "x$found_ssh2" != "xyes"; then
1385			AC_MSG_ERROR([SSH2 library not found])
1386		elif test "x$accept_ssh2_version" != "xyes"; then
1387			AC_MSG_ERROR([SSH2 library version requirement not met (>= 1.0.0)])
1388		else
1389			have_ssh2="yes"
1390		fi
1391	fi
1392	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH2_LDFLAGS"
1393	SERVER_LIBS="$SERVER_LIBS $SSH2_LIBS"
1394
1395	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH2_LDFLAGS"
1396	PROXY_LIBS="$PROXY_LIBS $SSH2_LIBS"
1397
1398	AC_SUBST(SSH2_CFLAGS)
1399
1400	found_openipmi="no"
1401	dnl Check for libOpenIPMI [by default - skip]
1402	LIBOPENIPMI_CHECK_CONFIG([no])
1403	if test "x$want_openipmi" = "xyes"; then
1404		if test "x$found_openipmi" != "xyes"; then
1405			AC_MSG_ERROR([Invalid OPENIPMI directory - unable to find ipmiif.h])
1406		else
1407			have_ipmi="yes"
1408		fi
1409	fi
1410	SERVER_LDFLAGS="$SERVER_LDFLAGS $OPENIPMI_LDFLAGS"
1411	SERVER_LIBS="$SERVER_LIBS $OPENIPMI_LIBS"
1412
1413	PROXY_LDFLAGS="$PROXY_LDFLAGS $OPENIPMI_LDFLAGS"
1414	PROXY_LIBS="$PROXY_LIBS $OPENIPMI_LIBS"
1415
1416	AC_SUBST(OPENIPMI_CFLAGS)
1417fi
1418
1419dnl Check for mbed TLS (PolarSSL) libpolarssl [by default - skip]
1420LIBMBEDTLS_CHECK_CONFIG([no])
1421if test "x$want_mbedtls" = "xyes"; then
1422	if test "x$have_tls" != "xno"; then
1423		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1424	fi
1425
1426	if test "x$found_mbedtls" != "xyes"; then
1427		AC_MSG_ERROR([mbed TLS (PolarSSL) library libpolarssl not found])
1428	elif test "x$accept_mbedtls_version" != "xyes"; then
1429		AC_MSG_ERROR([mbed TLS (PolarSSL) library version requirement not met (>= 1.3.9)])
1430	else
1431		have_tls="mbed TLS"
1432	fi
1433	TLS_CFLAGS="$MBEDTLS_CFLAGS"
1434	TLS_LDFLAGS="$MBEDTLS_LDFLAGS"
1435	TLS_LIBS="$MBEDTLS_LIBS"
1436fi
1437
1438dnl Check for GnuTLS libgnutls [by default - skip]
1439LIBGNUTLS_CHECK_CONFIG([no])
1440if test "x$want_gnutls" = "xyes"; then
1441	if test "x$have_tls" != "xno"; then
1442		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1443	fi
1444
1445	if test "x$found_gnutls" != "xyes"; then
1446		AC_MSG_ERROR([GnuTLS library libgnutls not found])
1447	elif test "x$accept_gnutls_version" != "xyes"; then
1448		AC_MSG_ERROR([GnuTLS library version requirement not met (>= 3.1.18)])
1449	else
1450		have_tls="GnuTLS"
1451	fi
1452	TLS_CFLAGS="$GNUTLS_CFLAGS"
1453	TLS_LDFLAGS="$GNUTLS_LDFLAGS"
1454	TLS_LIBS="$GNUTLS_LIBS"
1455fi
1456
1457dnl Check for OpenSSL libssl and libcrypto [by default - skip]
1458LIBOPENSSL_CHECK_CONFIG([no])
1459if test "x$want_openssl" = "xyes"; then
1460	if test "x$have_tls" != "xno"; then
1461		AC_MSG_ERROR([You can configure for only one TLS library (--with-mbedtls, --with-gnutls or --with-openssl).])
1462	fi
1463
1464	if test "x$found_openssl" != "xOpenSSL" -a "x$found_openssl" != "xOpenSSL (PSK not supported)"; then
1465		AC_MSG_ERROR([OpenSSL library libssl or libcrypto not found])
1466	elif test "x$accept_openssl_version" != "xyes"; then
1467		AC_MSG_ERROR([OpenSSL library version requirement not met (>= 1.0.1)])
1468	else
1469		have_tls=$found_openssl
1470	fi
1471	TLS_CFLAGS="$OPENSSL_CFLAGS"
1472	TLS_LDFLAGS="$OPENSSL_LDFLAGS"
1473	TLS_LIBS="$OPENSSL_LIBS"
1474fi
1475AC_SUBST(TLS_CFLAGS)
1476
1477SERVER_LDFLAGS="$SERVER_LDFLAGS $TLS_LDFLAGS"
1478SERVER_LIBS="$SERVER_LIBS $TLS_LIBS"
1479
1480PROXY_LDFLAGS="$PROXY_LDFLAGS $TLS_LDFLAGS"
1481PROXY_LIBS="$PROXY_LIBS $TLS_LIBS"
1482
1483AGENT_LDFLAGS="$AGENT_LDFLAGS $TLS_LDFLAGS"
1484AGENT_LIBS="$AGENT_LIBS $TLS_LIBS"
1485
1486ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $TLS_LDFLAGS"
1487ZBXGET_LIBS="$ZBXGET_LIBS $TLS_LIBS"
1488
1489SENDER_LDFLAGS="$SENDER_LDFLAGS $TLS_LDFLAGS"
1490SENDER_LIBS="$SENDER_LIBS $TLS_LIBS"
1491
1492if test "x$java" = "xyes"; then
1493	AC_CHECK_PROGS([JAVAC], [javac], [no])
1494	if test "x$JAVAC" = "xno"; then
1495		AC_MSG_ERROR([Unable to find "javac" executable in path])
1496	fi
1497	AC_CHECK_PROGS([JAR], [jar], [no])
1498	if test "x$JAR" = "xno"; then
1499		AC_MSG_ERROR([Unable to find "jar" executable in path])
1500	fi
1501fi
1502
1503found_ldap="no"
1504dnl Check for libLDAP [by default - skip]
1505LIBLDAP_CHECK_CONFIG([no])
1506if test "x$want_ldap" = "xyes"; then
1507	if test "x$found_ldap" != "xyes"; then
1508		AC_MSG_ERROR([Invalid LDAP directory - unable to find ldap.h])
1509	fi
1510fi
1511SERVER_LDFLAGS="$SERVER_LDFLAGS $LDAP_LDFLAGS"
1512SERVER_LIBS="$SERVER_LIBS $LDAP_LIBS"
1513
1514PROXY_LDFLAGS="$PROXY_LDFLAGS $LDAP_LDFLAGS"
1515PROXY_LIBS="$PROXY_LIBS $LDAP_LIBS"
1516
1517AGENT_LDFLAGS="$AGENT_LDFLAGS $LDAP_LDFLAGS"
1518AGENT_LIBS="$AGENT_LIBS $LDAP_LIBS"
1519
1520AC_SUBST(LDAP_CPPFLAGS)
1521
1522found_curl="no"
1523dnl Checking for libCurl [by default - skip]
1524LIBCURL_CHECK_CONFIG(, [7.13.1], [],[])
1525if test "x$want_curl" = "xyes"; then
1526	if test "x$found_curl" != "xyes"; then
1527		AC_MSG_ERROR([Curl library not found])
1528	fi
1529fi
1530if test "x$found_curl" = "xyes"; then
1531	have_web_monitoring="cURL"
1532fi
1533CFLAGS="$LIBCURL_CFLAGS $CFLAGS"
1534
1535SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBCURL_LDFLAGS"
1536SERVER_LIBS="$SERVER_LIBS $LIBCURL_LIBS"
1537
1538PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBCURL_LDFLAGS"
1539PROXY_LIBS="$PROXY_LIBS $LIBCURL_LIBS"
1540
1541dnl Starting from 2.0 agent can do web monitoring
1542AGENT_LDFLAGS="$AGENT_LDFLAGS $LIBCURL_LDFLAGS"
1543AGENT_LIBS="$AGENT_LIBS $LIBCURL_LIBS"
1544
1545found_iconv="no"
1546dnl Check for libiconv [by default - skip]
1547LIBICONV_CHECK_CONFIG([no])
1548if test "x$found_iconv" != "xyes"; then
1549	AC_MSG_ERROR([Unable to use iconv (libiconv check failed)])
1550fi
1551LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
1552LIBS="$LIBS $ICONV_LIBS"
1553
1554AC_SUBST(ICONV_CFLAGS)
1555
1556RANLIB="ranlib"
1557AC_SUBST(RANLIB)
1558
1559AC_SUBST(SERVER_LDFLAGS)
1560AC_SUBST(SERVER_LIBS)
1561
1562AC_SUBST(PROXY_LDFLAGS)
1563AC_SUBST(PROXY_LIBS)
1564
1565AC_SUBST(AGENT_LDFLAGS)
1566AC_SUBST(AGENT_LIBS)
1567
1568AC_SUBST(ZBXGET_LDFLAGS)
1569AC_SUBST(ZBXGET_LIBS)
1570
1571AC_SUBST(SENDER_LDFLAGS)
1572AC_SUBST(SENDER_LIBS)
1573
1574dnl *****************************************************************
1575dnl *                                                               *
1576dnl *                         Other checks                          *
1577dnl *                                                               *
1578dnl *****************************************************************
1579
1580dnl Automake 1.8 to 1.9.6 sets mkdir_p macro (lower-cased).
1581AC_MSG_CHECKING(for mkdir -p candidate)
1582if test "x${MKDIR_P}" = "x"; then
1583        if test "x${mkdir_p}" = "x"; then
1584                AC_MSG_ERROR([No suitable "mkdir -p" candidate found.])
1585        fi
1586        AC_SUBST([MKDIR_P], ${mkdir_p})
1587fi
1588AC_MSG_RESULT([ok (${MKDIR_P})])
1589
1590dnl Check if process statistics collector should be enabled
1591case "x$ARCH" in
1592	xlinux|xsolaris)
1593		AC_DEFINE(ZBX_PROCSTAT_COLLECTOR, 1 , [Define to 1 on linux and solaris platforms])
1594		;;
1595esac
1596
1597
1598dnl *****************************************************************
1599dnl *                                                               *
1600dnl *                 Output configuration results                  *
1601dnl *                                                               *
1602dnl *****************************************************************
1603
1604AC_OUTPUT([
1605	Makefile
1606	database/Makefile
1607	misc/Makefile
1608	src/Makefile
1609	src/libs/Makefile
1610	src/libs/zbxlog/Makefile
1611	src/libs/zbxalgo/Makefile
1612	src/libs/zbxmemory/Makefile
1613	src/libs/zbxcrypto/Makefile
1614	src/libs/zbxconf/Makefile
1615	src/libs/zbxdbcache/Makefile
1616	src/libs/zbxdbhigh/Makefile
1617	src/libs/zbxmedia/Makefile
1618	src/libs/zbxsysinfo/Makefile
1619	src/libs/zbxcommon/Makefile
1620	src/libs/zbxsysinfo/agent/Makefile
1621	src/libs/zbxsysinfo/common/Makefile
1622	src/libs/zbxsysinfo/simple/Makefile
1623	src/libs/zbxsysinfo/linux/Makefile
1624	src/libs/zbxsysinfo/aix/Makefile
1625	src/libs/zbxsysinfo/freebsd/Makefile
1626	src/libs/zbxsysinfo/hpux/Makefile
1627	src/libs/zbxsysinfo/openbsd/Makefile
1628	src/libs/zbxsysinfo/osx/Makefile
1629	src/libs/zbxsysinfo/solaris/Makefile
1630	src/libs/zbxsysinfo/osf/Makefile
1631	src/libs/zbxsysinfo/netbsd/Makefile
1632	src/libs/zbxsysinfo/unknown/Makefile
1633	src/libs/zbxnix/Makefile
1634	src/libs/zbxsys/Makefile
1635	src/libs/zbxcomms/Makefile
1636	src/libs/zbxcommshigh/Makefile
1637	src/libs/zbxdb/Makefile
1638	src/libs/zbxdbupgrade/Makefile
1639	src/libs/zbxjson/Makefile
1640	src/libs/zbxserver/Makefile
1641	src/libs/zbxicmpping/Makefile
1642	src/libs/zbxexec/Makefile
1643	src/libs/zbxself/Makefile
1644	src/libs/zbxmodules/Makefile
1645	src/libs/zbxregexp/Makefile
1646	src/zabbix_agent/Makefile
1647	src/zabbix_get/Makefile
1648	src/zabbix_sender/Makefile
1649	src/zabbix_server/Makefile
1650	src/zabbix_server/alerter/Makefile
1651	src/zabbix_server/dbsyncer/Makefile
1652	src/zabbix_server/dbconfig/Makefile
1653	src/zabbix_server/discoverer/Makefile
1654	src/zabbix_server/housekeeper/Makefile
1655	src/zabbix_server/httppoller/Makefile
1656	src/zabbix_server/pinger/Makefile
1657	src/zabbix_server/poller/Makefile
1658	src/zabbix_server/snmptrapper/Makefile
1659	src/zabbix_server/timer/Makefile
1660	src/zabbix_server/trapper/Makefile
1661	src/zabbix_server/watchdog/Makefile
1662	src/zabbix_server/escalator/Makefile
1663	src/zabbix_server/proxypoller/Makefile
1664	src/zabbix_server/selfmon/Makefile
1665	src/zabbix_server/vmware/Makefile
1666	src/zabbix_proxy/Makefile
1667	src/zabbix_proxy/heart/Makefile
1668	src/zabbix_proxy/housekeeper/Makefile
1669	src/zabbix_proxy/proxyconfig/Makefile
1670	src/zabbix_proxy/datasender/Makefile
1671	src/zabbix_java/Makefile
1672	upgrades/Makefile
1673	man/Makefile
1674	])
1675
1676echo "
1677
1678Configuration:
1679
1680  Detected OS:           ${host_os}
1681  Install path:          ${prefix}
1682  Compilation arch:      ${ARCH}
1683
1684  Compiler:              ${CC}
1685  Compiler flags:        ${CFLAGS}
1686
1687  Library-specific flags:"
1688
1689if test "x$DB_CFLAGS" != "x"; then
1690	echo "    database:              ${DB_CFLAGS}"
1691fi
1692
1693if test "x$JABBER_CPPFLAGS" != "x"; then
1694	echo "    Jabber:                ${JABBER_CPPFLAGS}"
1695fi
1696
1697if test "x$LIBXML2_CFLAGS" != "x"; then
1698	echo "    libXML2:               ${LIBXML2_CFLAGS}"
1699fi
1700
1701if test "x$UNIXODBC_CFLAGS" != "x"; then
1702	echo "    unixODBC:              ${UNIXODBC_CFLAGS}"
1703fi
1704
1705if test "x$SNMP_CFLAGS" != "x"; then
1706	echo "    Net-SNMP:              ${SNMP_CFLAGS}"
1707fi
1708
1709if test "x$OPENIPMI_CFLAGS" != "x"; then
1710	echo "    OpenIPMI:              ${OPENIPMI_CFLAGS}"
1711fi
1712
1713if test "x$SSH2_CFLAGS" != "x"; then
1714	echo "    libssh2:               ${SSH2_CFLAGS}"
1715fi
1716
1717if test "x$TLS_CFLAGS" != "x"; then
1718	echo "    TLS:                   ${TLS_CFLAGS}"
1719fi
1720
1721if test "x$LDAP_CPPFLAGS" != "x"; then
1722	echo "    LDAP:                  ${LDAP_CPPFLAGS}"
1723fi
1724
1725if test "x$ICONV_CFLAGS" != "x"; then
1726	echo "    iconv:                 ${ICONV_CFLAGS}"
1727fi
1728
1729echo "
1730  Enable server:         ${server}"
1731
1732if test "x$server" != "xno"; then
1733
1734echo "  Server details:
1735    With database:         ${have_db}
1736    WEB Monitoring:        ${have_web_monitoring}
1737    Native Jabber:         ${have_jabber}
1738    SNMP:                  ${have_snmp}
1739    IPMI:                  ${have_ipmi}
1740    SSH:                   ${have_ssh2}
1741    TLS:                   ${have_tls}
1742    ODBC:                  ${have_unixodbc}
1743    Linker flags:          ${SERVER_LDFLAGS} ${LDFLAGS}
1744    Libraries:             ${SERVER_LIBS} ${LIBS}"
1745
1746fi
1747
1748echo "
1749  Enable proxy:          ${proxy}"
1750
1751if test "x$proxy" != "xno"; then
1752
1753echo "  Proxy details:
1754    With database:         ${have_db}
1755    WEB Monitoring:        ${have_web_monitoring}
1756    SNMP:                  ${have_snmp}
1757    IPMI:                  ${have_ipmi}
1758    SSH:                   ${have_ssh2}
1759    TLS:                   ${have_tls}
1760    ODBC:                  ${have_unixodbc}
1761    Linker flags:          ${PROXY_LDFLAGS} ${LDFLAGS}
1762    Libraries:             ${PROXY_LIBS} ${LIBS}"
1763
1764fi
1765
1766echo "
1767  Enable agent:          ${agent}"
1768
1769if test "x$agent" != "xno"; then
1770
1771echo "  Agent details:
1772    TLS:                   ${have_tls}
1773    Linker flags:          ${AGENT_LDFLAGS} ${LDFLAGS}
1774    Libraries:             ${AGENT_LIBS} ${LIBS}"
1775
1776fi
1777
1778echo "
1779  Enable Java gateway:   ${java}"
1780
1781if test "x$java" != "xno"; then
1782
1783echo "  Java gateway details:
1784    Java compiler:         ${JAVAC}
1785    Java archiver:         ${JAR}"
1786
1787fi
1788
1789echo "
1790  LDAP support:          ${found_ldap}
1791  IPv6 support:          ${have_ipv6}"
1792
1793echo
1794echo "***********************************************************"
1795echo "*            Now run '${am_make} install'                       *"
1796echo "*                                                         *"
1797echo "*            Thank you for using Zabbix!                  *"
1798echo "*              <http://www.zabbix.com>                    *"
1799echo "***********************************************************"
1800echo
1801