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],[5.0.19])
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 float.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 procs in struct sysinfo)
661AC_TRY_COMPILE([#include <sys/sysinfo.h>],
662[struct sysinfo sysinfo;
663sysinfo.procs=0;
664],
665AC_DEFINE(HAVE_SYSINFO_PROCS,1,[Define to 1 if 'sysinfo.procs' exists.])
666AC_MSG_RESULT(yes),
667AC_MSG_RESULT(no))
668
669AC_MSG_CHECKING(for field tm_gmtoff in struct tm)
670AC_TRY_COMPILE([
671#ifdef HAVE_SYS_TIME_H
672#include <sys/time.h>
673#endif	/* HAVE_SYS_TIME_H */
674
675#ifdef HAVE_TIME_H
676#include <time.h>
677#endif	/* HAVE_TIME_H */
678],
679[
680	struct tm tm;
681	tm.tm_gmtoff;
682],
683AC_DEFINE(HAVE_TM_TM_GMTOFF,1,[Define to 1 if 'tm.tm_gmtoff' exists.])
684AC_MSG_RESULT(yes),
685AC_MSG_RESULT(no))
686
687AC_MSG_CHECKING(for linker options --start-group/--end-group)
688saved_LDFLAGS="$LDFLAGS"
689LDFLAGS="-Wl,--start-group -Wl,--end-group"
690AC_TRY_LINK([], [],
691HAVE_START_GROUP="yes"
692AC_MSG_RESULT(yes),
693AC_MSG_RESULT(no)
694)
695LDFLAGS="$saved_LDFLAGS"
696
697AC_MSG_CHECKING(for '__thread' compiler support)
698AC_TRY_COMPILE([#include <stdio.h>],[static __thread int a = 0;],
699AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define to 1 if compiler keyword '__thread' supported.])
700AC_MSG_RESULT(yes),
701AC_MSG_RESULT(no)
702HAVE_THREAD_LOCAL="no")
703
704AC_MSG_CHECKING(for field updates in struct vminfo_t)
705AC_TRY_COMPILE([
706#include <sys/sysinfo.h>
707],
708[
709	vminfo_t vminfo;
710	vminfo.updates;
711],
712AC_DEFINE(HAVE_VMINFO_T_UPDATES,1,[Define to 1 if 'vminfo.updates' exists.])
713AC_MSG_RESULT(yes),
714AC_MSG_RESULT(no))
715
716dnl *****************************************************************
717dnl *                                                               *
718dnl *                     Checks for functions                      *
719dnl *                                                               *
720dnl *****************************************************************
721
722AC_MSG_CHECKING(for function sysconf() in unistd.h)
723AC_TRY_COMPILE(
724[
725#include <unistd.h>
726],
727[	int i;
728
729	i=sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
730	i=sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PHYS_PAGES);
731],
732AC_DEFINE(HAVE_UNISTD_SYSCONF,1,[Define to 1 if function 'sysconf' exists.])
733AC_MSG_RESULT(yes),
734AC_MSG_RESULT(no))
735
736AC_MSG_CHECKING(for function initgroups())
737AC_TRY_LINK(
738[
739#include <sys/types.h>
740#include <grp.h>
741],
742[
743	char	*user = "zabbix";
744	initgroups(user, 0);
745],
746AC_DEFINE(HAVE_FUNCTION_INITGROUPS,1,[Define to 1 if function 'initgroups' exists.])
747AC_MSG_RESULT(yes),
748AC_MSG_RESULT(no))
749
750AC_MSG_CHECKING(for functions seteuid() and setegid())
751AC_TRY_LINK(
752[
753#include <sys/types.h>
754#include <unistd.h>
755],
756[
757	seteuid(0);
758	setegid(0);
759],
760AC_DEFINE(HAVE_FUNCTION_SETEUID,1,[Define to 1 if functions 'seteuid' and 'setegid' exist.])
761AC_MSG_RESULT(yes),
762AC_MSG_RESULT(no))
763
764AC_MSG_CHECKING(for function setproctitle())
765AC_TRY_LINK(
766[
767#include <sys/types.h>
768#include <unistd.h>
769],
770[
771	setproctitle("Test %d", 1);
772],
773AC_DEFINE(HAVE_FUNCTION_SETPROCTITLE,1,[Define to 1 if function 'setproctitle' exists.])
774AC_MSG_RESULT(yes),
775AC_MSG_RESULT(no))
776
777AC_MSG_CHECKING(for function sysctlbyname())
778AC_TRY_LINK(
779[
780#ifdef HAVE_SYS_TYPES_H
781#include <sys/types.h>
782#endif /* HAVE_SYS_TYPES_H */
783
784#ifdef HAVE_SYS_PARAM_H
785#include <sys/param.h>
786#endif /* HAVE_SYS_PARAM_H */
787
788#include <sys/sysctl.h>
789],
790[
791	sysctlbyname("", 0, 0, 0, 0);
792],
793AC_DEFINE(HAVE_FUNCTION_SYSCTLBYNAME,1,[Define to 1 if 'sysctlbyname' exists.])
794AC_MSG_RESULT(yes),
795AC_MSG_RESULT(no))
796
797AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME))
798AC_TRY_COMPILE(
799[
800#ifdef HAVE_SYS_TYPES_H
801#include <sys/types.h>
802#endif /* HAVE_SYS_TYPES_H */
803
804#ifdef HAVE_SYS_PARAM_H
805#include <sys/param.h>
806#endif /* HAVE_SYS_PARAM_H */
807
808#include <sys/sysctl.h>
809#include <unistd.h>
810#include <time.h>
811#include <sys/time.h>
812],
813[
814	size_t		len;
815	struct timeval	uptime;
816        int		mib[2];
817
818        mib[0] = CTL_KERN;
819        mib[1] = KERN_BOOTTIME;
820
821        len = sizeof(uptime);
822        sysctl(mib, 2, &uptime, &len, 0, 0);
823],
824AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME,1,[Define to 1 if 'KERN_BOOTTIME' exists.])
825AC_MSG_RESULT(yes),
826AC_MSG_RESULT(no))
827
828AC_MSG_CHECKING(for function sysctl (HW_NCPU))
829AC_TRY_COMPILE(
830[
831#ifdef HAVE_SYS_TYPES_H
832#include <sys/types.h>
833#endif /* HAVE_SYS_TYPES_H */
834
835#ifdef HAVE_SYS_PARAM_H
836#include <sys/param.h>
837#endif /* HAVE_SYS_PARAM_H */
838
839#include <sys/sysctl.h>
840],
841[
842	size_t	len;
843	int	mib[2], ncpu;
844
845	mib[0] = CTL_HW;
846	mib[1] = HW_NCPU;
847
848	len = sizeof(ncpu);
849	sysctl(mib, 2, &ncpu, &len, 0, 0);
850],
851AC_DEFINE(HAVE_FUNCTION_SYSCTL_HW_NCPU,1,[Define to 1 if 'HW_NCPU' exists.])
852AC_MSG_RESULT(yes),
853AC_MSG_RESULT(no))
854
855AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES))
856AC_TRY_COMPILE(
857[
858#ifdef HAVE_SYS_TYPES_H
859#include <sys/types.h>
860#endif /* HAVE_SYS_TYPES_H */
861
862#ifdef HAVE_SYS_PARAM_H
863#include <sys/param.h>
864#endif /* HAVE_SYS_PARAM_H */
865
866#include <sys/sysctl.h>
867],
868[
869	size_t	len;
870        int	mib[2], maxfiles;
871
872        mib[0] = CTL_KERN;
873        mib[1] = KERN_MAXFILES;
874
875        len = sizeof(maxfiles);
876        sysctl(mib, 2, &maxfiles, &len, 0, 0);
877],
878AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES,1,[Define to 1 if 'KERN_MAXFILES' exists.])
879AC_MSG_RESULT(yes),
880AC_MSG_RESULT(no))
881
882AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC))
883AC_TRY_COMPILE(
884[
885#ifdef HAVE_SYS_TYPES_H
886#include <sys/types.h>
887#endif /* HAVE_SYS_TYPES_H */
888
889#ifdef HAVE_SYS_PARAM_H
890#include <sys/param.h>
891#endif /* HAVE_SYS_PARAM_H */
892
893#include <sys/sysctl.h>
894],
895[
896	size_t	len;
897	int	mib[2], maxproc;
898
899        mib[0] = CTL_KERN;
900        mib[1] = KERN_MAXPROC;
901
902        len = sizeof(maxproc);
903        sysctl(mib, 2, &maxproc, &len, 0, 0);
904],
905AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC,1,[Define to 1 if 'KERN_MAXPROC' exists.])
906AC_MSG_RESULT(yes),
907AC_MSG_RESULT(no))
908
909AC_MSG_CHECKING(for function sysctl (KERN_CPTIME,KERN_CPTIME2))
910AC_TRY_COMPILE(
911[
912#include <sys/param.h>
913#include <sys/sysctl.h>
914#if defined(HAVE_SYS_DKSTAT_H)
915#	include <sys/dkstat.h>
916#elif defined(HAVE_SYS_SCHED_H)
917#	include <sys/sched.h>
918#endif
919],
920[
921size_t	sz;
922int	i[] = {CP_USER, CP_NICE, CP_SYS, CP_INTR, CP_IDLE};
923
924{
925	long	states[CPUSTATES];
926	int	mib[2] = {CTL_KERN, KERN_CPTIME};
927
928	sz = sizeof(states);
929	sysctl(mib, 2, &states, &sz, NULL, 0);
930}
931
932{
933	u_int64_t	states[CPUSTATES];
934	int		mib[3] = {CTL_KERN, KERN_CPTIME2, 0};
935
936	sz = sizeof(states);
937	sysctl(mib, 3, &states, &sz, NULL, 0);
938}
939],
940AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_CPTIME,1,[Define to 1 if 'KERN_CPTIME,KERN_CPTIME2' exists.])
941AC_MSG_RESULT(yes),
942AC_MSG_RESULT(no))
943
944AC_MSG_CHECKING(for function clock_gettime in time.h)
945AC_TRY_LINK([
946#ifdef HAVE_TIME_H
947#	include <time.h>
948#elif HAVE_SYS_TIME_H
949#	include <sys/time.h>
950#endif	/* HAVE_SYS_TIME_H */
951],
952[struct timespec tp;
953clock_gettime(CLOCK_REALTIME, &tp);
954],
955AC_DEFINE(HAVE_TIME_CLOCK_GETTIME,1,[Define to 1 if function 'clock_gettime' exists.])
956AC_MSG_RESULT(yes),
957AC_MSG_RESULT(no))
958
959dnl *****************************************************************
960dnl *                                                               *
961dnl *                      Checks for macros                        *
962dnl *                                                               *
963dnl *****************************************************************
964
965AC_MSG_CHECKING(for macro __va_copy() in stdarg.h)
966AC_TRY_COMPILE(
967[
968#include <stdarg.h>
969],
970[
971	va_list	src,dst;
972
973	__va_copy(dst,src);
974],
975AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if macro '__va_copy' exists.])
976AC_MSG_RESULT(yes),
977AC_MSG_RESULT(no))
978
979AC_MSG_CHECKING(for macro __VA_ARGS__)
980AC_TRY_COMPILE(
981[
982#define ZBX_CONST_STRING(str)   str
983int test(const char *fmt, ...) { return 0; }
984],
985[
986#define TEST(fmt, ...) test(ZBX_CONST_STRING(fmt), ##__VA_ARGS__)
987TEST("%s","test");
988TEST("test");
989],
990AC_DEFINE(HAVE___VA_ARGS__,1,[Define to 1 if macro '__VA_ARGS__' exists.])
991AC_MSG_RESULT(yes),
992AC_MSG_RESULT(no))
993
994dnl *****************************************************************
995dnl *                                                               *
996dnl *                 Checks for library functions                  *
997dnl *                                                               *
998dnl *****************************************************************
999
1000AC_TYPE_SIGNAL
1001AC_REPLACE_FUNCS(getloadavg)
1002AC_CHECK_FUNCS(hstrerror)
1003AC_CHECK_FUNCS(getenv)
1004AC_CHECK_FUNCS(putenv)
1005AC_CHECK_FUNCS(sigqueue)
1006AC_CHECK_FUNCS(round)
1007
1008dnl *****************************************************************
1009dnl *                                                               *
1010dnl *            Checks for file system characteristics             *
1011dnl *                                                               *
1012dnl *****************************************************************
1013
1014AC_MSG_CHECKING(for /proc filesystem)
1015if test -d /proc; then
1016	AC_MSG_RESULT(yes)
1017	AC_DEFINE(HAVE_PROC,1,[Define to 1 if '/proc' file system should be used.])
1018else
1019	AC_MSG_RESULT(no)
1020fi
1021
1022AC_MSG_CHECKING(for file /proc/stat)
1023if test -r /proc/stat; then
1024	AC_MSG_RESULT(yes)
1025	AC_DEFINE(HAVE_PROC_STAT,1,[Define to 1 if file '/proc/stat' should be used.])
1026else
1027	AC_MSG_RESULT(no)
1028fi
1029
1030AC_MSG_CHECKING(for file /proc/cpuinfo)
1031if test -r /proc/cpuinfo; then
1032	AC_MSG_RESULT(yes)
1033	AC_DEFINE(HAVE_PROC_CPUINFO,1,[Define to 1 if file '/proc/cpuinfo' should be used.])
1034else
1035	AC_MSG_RESULT(no)
1036fi
1037
1038dnl Solaris
1039AC_MSG_CHECKING(for file /proc/0/psinfo)
1040if test -r /proc/0/psinfo; then
1041	AC_MSG_RESULT(yes)
1042	AC_DEFINE(HAVE_PROC_0_PSINFO,1,[Define to 1 if file '/proc/0/psinfo' should be used.])
1043else
1044	AC_MSG_RESULT(no)
1045fi
1046
1047AC_MSG_CHECKING(for file /proc/loadavg)
1048if test -r /proc/loadavg; then
1049	AC_MSG_RESULT(yes)
1050	AC_DEFINE(HAVE_PROC_LOADAVG,1,[Define to 1 if file '/proc/loadavg' should be used.])
1051else
1052	AC_MSG_RESULT(no)
1053fi
1054
1055AC_MSG_CHECKING(for file /proc/net/dev)
1056if test -r /proc/net/dev; then
1057	AC_MSG_RESULT(yes)
1058	AC_DEFINE(HAVE_PROC_NET_DEV,1,[Define to 1 if file '/proc/net/dev' should be used.])
1059else
1060	AC_MSG_RESULT(no)
1061fi
1062
1063dnl *****************************************************************
1064dnl *                                                               *
1065dnl *              Checks for compiler characteristics              *
1066dnl *                                                               *
1067dnl *****************************************************************
1068
1069dnl Check for %qu format (FreeBSD 4.x)
1070dnl FreeBSD 4.x does not support %llu
1071AC_MSG_CHECKING(for long long format)
1072AC_TRY_RUN(
1073[
1074#include <sys/types.h>
1075int main()
1076{
1077        uint64_t i;
1078
1079        sscanf("200000000010020", "%qu", &i);
1080
1081        if (i == 200000000010020) return 0;
1082        else return -1;
1083}
1084],
1085AC_DEFINE(HAVE_LONG_LONG_QU, 1 ,[Define to 1 if format '%qu' exists.])
1086AC_MSG_RESULT(yes),
1087AC_MSG_RESULT(no),
1088AC_MSG_RESULT(no))
1089
1090dnl option -rdynamic is needed for readable backtraces
1091AC_MSG_CHECKING(for -rdynamic linking option)
1092saved_LDFLAGS="$LDFLAGS"
1093LDFLAGS="-rdynamic $LDFLAGS"
1094AC_TRY_LINK([#include <execinfo.h>],
1095[void *bcktrc[6];
1096(void)backtrace(bcktrc, 6);
1097],
1098LDFLAGS="-rdynamic $saved_LDFLAGS"
1099AC_MSG_RESULT(yes),
1100LDFLAGS="$saved_LDFLAGS"
1101AC_MSG_RESULT(no))
1102
1103dnl *****************************************************************
1104dnl *                                                               *
1105dnl *                 Checks for operating systems                  *
1106dnl *                                                               *
1107dnl *****************************************************************
1108
1109AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset)
1110AC_TRY_COMPILE([#include <sys/protosw.h>
1111#include <libperfstat.h>],
1112[perfstat_memory_total_t	memstats;
1113memstats.virt_active = 0;
1114],
1115AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.])
1116AC_MSG_RESULT(yes),
1117AC_MSG_RESULT(no))
1118
1119AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset)
1120AC_TRY_COMPILE([#include <sys/protosw.h>
1121#include <libperfstat.h>],
1122[perfstat_partition_total_t	lparstats;
1123lparstats.type.b.donate_enabled = 0;
1124lparstats.idle_donated_purr = 0;
1125lparstats.busy_donated_purr = 0;
1126lparstats.idle_stolen_purr = 0;
1127lparstats.busy_stolen_purr = 0;
1128],
1129AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.])
1130AC_MSG_RESULT(yes),
1131AC_MSG_RESULT(no))
1132
1133case "$host_os" in
1134linux*)
1135	ARCH="linux"
1136	;;
1137aix*)
1138	ARCH="aix"
1139	;;
1140darwin*|rhapsody*)
1141	ARCH="osx"
1142	AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X.])
1143	;;
1144*solaris*)
1145	ARCH="solaris"
1146	;;
1147hpux*)
1148	ARCH="hpux"
1149	;;
1150freebsd*)
1151	ARCH="freebsd"
1152	;;
1153dragonfly*)
1154	ARCH="dragonfly"
1155	;;
1156netbsd*)
1157	ARCH="netbsd"
1158	;;
1159osf*)
1160	ARCH="osf"
1161	;;
1162openbsd*)
1163	ARCH="openbsd"
1164	;;
1165*)
1166	ARCH="unknown"
1167	;;
1168esac
1169
1170AC_MSG_CHECKING(for architecture)
1171AC_MSG_RESULT([$ARCH ($host_os)])
1172
1173if test "x$ARCH" = "xlinux"; then
1174	AC_MSG_CHECKING([for the linux kernel version])
1175
1176	kernel=`uname -r`
1177
1178	case "${kernel}" in
1179		2.6.*)
1180			AC_MSG_RESULT([2.6 family (${kernel})])
1181			AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x])
1182			;;
1183		2.4.*)
1184			AC_MSG_RESULT([2.4 family (${kernel})])
1185			AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x])
1186			;;
1187		*)
1188			AC_MSG_RESULT([unknown family (${kernel})])
1189			;;
1190	esac
1191fi
1192
1193if test "x$ARCH" = "xsolaris"; then
1194	dnl Forcing a 64-bit application for a 64-bit Solaris
1195	dnl A 32-bit program that uses /proc is able to look at 32-bit processes,
1196	dnl but is not able to understand all attributes of a 64-bit process.
1197	AC_MSG_CHECKING(for -m64 compilation flag)
1198	saved_CFLAGS="$CFLAGS"
1199	CFLAGS="-m64"
1200	AC_TRY_RUN(
1201	[int main(void) {return 0;}],
1202	CFLAGS="-m64 $saved_CFLAGS"
1203	AC_MSG_RESULT(yes),
1204	CFLAGS="$saved_CFLAGS"
1205	AC_MSG_RESULT(no))
1206	CFLAGS="${CFLAGS} -DZBX_OLD_SOLARIS"
1207fi
1208
1209if test "x$ARCH" = "xhpux"; then
1210	dnl Low Level Discovery needs a way to get the list of network
1211	dnl interfaces available on the monitored system. On HP-UX systems
1212	dnl that way depends on the OS version.
1213	hpux_version=${host_os#hpux}
1214	hpux_major=${hpux_version%.*}
1215	hpux_minor=${hpux_version#*.}
1216
1217	AC_DEFINE_UNQUOTED([HPUX_VERSION], $hpux_major$hpux_minor, [Define to HP-UX version])
1218
1219	dnl This API level is needed so that "utsname.nodename" is not truncated.
1220	AC_MSG_CHECKING(for -D_HPUX_API_LEVEL=20040821 compilation flag)
1221	saved_CFLAGS="$CFLAGS"
1222	CFLAGS="-D_HPUX_API_LEVEL=20040821"
1223	AC_TRY_RUN(
1224[
1225#ifdef HAVE_DLFCN_H
1226#	include <dlfcn.h>
1227#endif
1228#ifdef HAVE_SYS_UTSNAME_H
1229#	include <sys/utsname.h>
1230#endif
1231
1232int main(void)
1233{
1234	void		*p1, *p2;
1235	struct utsname	name;
1236
1237	/* check that the compiler (e.g., GCC 4.3.0 and above) supports function-level versioning */
1238
1239	p1 = uname;
1240	p2 = dlsym(RTLD_DEFAULT, "uname{20040821}");
1241
1242	if (p1 != p2)
1243		return 1;
1244
1245	/* uname() fails with EFAULT on HP-UX systems that were only partially upgraded to this API level */
1246
1247	return -1 == uname(&name) ? 1 : 0;
1248}
1249],
1250	CFLAGS="-D_HPUX_API_LEVEL=20040821 $saved_CFLAGS"
1251	AC_MSG_RESULT(yes),
1252	CFLAGS="$saved_CFLAGS"
1253	AC_MSG_RESULT(no))
1254fi
1255
1256AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing])
1257AC_SUBST(ARCH)
1258
1259AC_CHECK_SIZEOF([void *])
1260
1261dnl *****************************************************************
1262dnl *                                                               *
1263dnl *         Checks for options given on the command line          *
1264dnl *                                                               *
1265dnl *****************************************************************
1266
1267AC_ARG_ENABLE(static,[  --enable-static         Build statically linked binaries],
1268[case "${enableval}" in
1269  yes)
1270    LDFLAGS="${LDFLAGS} -static"
1271    AC_MSG_CHECKING(if static linking is possible)
1272    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1273      [AC_MSG_RESULT([yes])
1274        static_linking=yes],
1275      [AC_MSG_RESULT([no])
1276        static_linking=no])
1277      if test "x$static_linking" = "xno"; then
1278        AC_MSG_ERROR([static linking is not possible on this system])
1279      fi
1280    ;;
1281  no) ;;
1282  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static]) ;;
1283esac])
1284
1285AC_ARG_ENABLE(static-libs,[  --enable-static-libs    Build statically linked binaries with selected libs from default folders],
1286[case "${enableval}" in
1287  yes)
1288    static_linking_libs=yes
1289    saved_LIBS="$LIBS"
1290    LIBS="${saved_LIBS} -Wl,-bstatic -Wl,-bdynamic"
1291    AC_MSG_CHECKING([if libs static linking with "-Wl,-b" is possible])
1292    AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1293      [AC_MSG_RESULT([yes])
1294        static_linking_support="-Wl,-b"],
1295      [AC_MSG_RESULT([no])
1296        static_linking_support=no])
1297        LIBS="$saved_LIBS"
1298
1299    if test "x$static_linking_support" = "xno"; then
1300      LIBS="${saved_LIBS} -Wl,-Bstatic -Wl,-Bdynamic"
1301      AC_MSG_CHECKING([if libs static linking with "-Wl,-B" is possible])
1302      AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
1303        [AC_MSG_RESULT([yes])
1304          static_linking_support="-Wl,-B"],
1305        [AC_MSG_RESULT([no])
1306          static_linking_support=no])
1307          LIBS="$saved_LIBS"
1308    fi
1309    ;;
1310  no) ;;
1311  *) AC_MSG_ERROR([bad value ${enableval} for --enable-static-libs]) ;;
1312esac])
1313
1314AC_ARG_ENABLE(server,[  --enable-server         Turn on build of Zabbix server],
1315[case "${enableval}" in
1316  yes) server=yes ;;
1317  no)  server=no ;;
1318  *) AC_MSG_ERROR([bad value ${enableval} for --enable-server]) ;;
1319esac],
1320[server=no])
1321AM_CONDITIONAL(SERVER, test "x$server" = "xyes")
1322
1323AC_ARG_ENABLE(proxy,[  --enable-proxy          Turn on build of Zabbix proxy],
1324[case "${enableval}" in
1325  yes) proxy=yes ;;
1326  no)  proxy=no ;;
1327  *) AC_MSG_ERROR([bad value ${enableval} for --enable-proxy]) ;;
1328esac],
1329[proxy=no])
1330AM_CONDITIONAL(PROXY, test "x$proxy" = "xyes")
1331
1332AC_ARG_ENABLE(agent,[  --enable-agent          Turn on build of Zabbix agent and client utilities],
1333[case "${enableval}" in
1334  yes) agent=yes ;;
1335  no)  agent=no ;;
1336  *) AC_MSG_ERROR([bad value ${enableval} for --enable-agent]) ;;
1337esac],
1338[agent=no])
1339AM_CONDITIONAL(AGENT, test "x$agent" = "xyes")
1340
1341AC_ARG_ENABLE(agent2,[  --enable-agent2         Turn on build of Zabbix agent 2],
1342[case "${enableval}" in
1343  yes) agent2=yes ;;
1344  no)  agent2=no ;;
1345  *) AC_MSG_ERROR([bad value ${enableval} for --enable-agent2]) ;;
1346esac
1347test "x$agent2" = "xyes" -a "x$HAVE_THREAD_LOCAL" = "xno" && AC_MSG_ERROR([C compiler is not compatible with agent2 assembly])
1348],
1349[agent2=no])
1350AM_CONDITIONAL(AGENT2, test "x$agent2" = "xyes")
1351
1352AC_ARG_ENABLE(java,[  --enable-java           Turn on build of Zabbix Java gateway],
1353[case "${enableval}" in
1354  yes) java=yes ;;
1355  no)  java=no ;;
1356  *) AC_MSG_ERROR([bad value ${enableval} for --enable-java]) ;;
1357esac],
1358[java=no])
1359AM_CONDITIONAL(JAVA, test "x$java" = "xyes")
1360
1361AC_ARG_ENABLE(ipv6,[  --enable-ipv6           Turn on support of IPv6],
1362[case "${enableval}" in
1363  yes) ipv6=yes ;;
1364  no)  ipv6=no ;;
1365  *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
1366esac],
1367[ipv6=no])
1368AM_CONDITIONAL(IPV6, test "x$ipv6" = "xyes")
1369
1370AM_CONDITIONAL([DBSCHEMA], [test -d create])
1371
1372AM_CONDITIONAL([ZBXCMOCKA], [(test -d tests/) && (test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes")])
1373
1374have_db="no"
1375have_unixodbc="no"
1376have_web_monitoring="no"
1377have_snmp="no"
1378have_ipmi="no"
1379have_ipv6="no"
1380have_ssh="no"
1381have_tls="no"
1382
1383
1384if test "x$ipv6" = "xyes"; then
1385	AC_DEFINE(HAVE_IPV6,1,[Define to 1 if IPv6 should be enabled.])
1386	have_ipv6="yes"
1387fi
1388
1389if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then
1390
1391
1392	dnl Checking for MySQL support
1393	AX_LIB_MYSQL()
1394	if test "x$want_mysql" = "xyes"; then
1395		if test "x$have_db" != "xno"; then
1396			AC_MSG_ERROR([You can configure for only one database.])
1397		fi
1398
1399		if test "x$found_mysql" = "xyes"; then
1400			have_db="MySQL"
1401			have_multirow_insert="yes"
1402		else
1403			AC_MSG_ERROR([MySQL library not found])
1404		fi
1405	fi
1406
1407	dnl Checking for Oracle support
1408	AX_LIB_ORACLE_OCI([10.0])
1409	if test "x$want_oracle_oci" = "xyes"; then
1410		if test "x$have_db" != "xno"; then
1411			AC_MSG_ERROR([You can configure for only one database.])
1412		fi
1413
1414		if test "x$HAVE_ORACLE_OCI" = "xyes"; then
1415			have_db="Oracle"
1416
1417			ORACLE_CPPFLAGS="$ORACLE_OCI_CFLAGS"
1418			ORACLE_LDFLAGS="$ORACLE_OCI_LDFLAGS"
1419			ORACLE_LIBS="$ORACLE_OCI_LIBS"
1420
1421			AC_DEFINE(HAVE_ORACLE,1,[Define to 1 if Oracle should be enabled.])
1422		else
1423			AC_MSG_ERROR([Oracle OCI library not found])
1424		fi
1425	fi
1426
1427	dnl Checking for PostgreSQL support
1428	AX_LIB_POSTGRESQL("9.2")
1429	if test "x$want_postgresql" = "xyes"; then
1430		if test "x$have_db" != "xno"; then
1431			AC_MSG_ERROR([You can configure for only one database.])
1432		fi
1433
1434		if test "x$found_postgresql" = "xyes"; then
1435			if test "$postgresql_version_check" != "1"; then
1436				AC_MSG_ERROR([PostgreSQL version mismatch])
1437			fi
1438
1439			have_db="PostgreSQL"
1440
1441			if test "$postgresql_version_number" -ge 8002000; then
1442				have_multirow_insert="yes"
1443			fi
1444
1445		else
1446			AC_MSG_ERROR([PostgreSQL library not found])
1447		fi
1448	fi
1449
1450	dnl Checking for SQLite3 support
1451	AX_LIB_SQLITE3()
1452	if test "x$want_sqlite3" = "xyes"; then
1453		if test "x$server" = "xyes"; then
1454			AC_MSG_ERROR([SQLite is not supported as a main Zabbix database backend.])
1455		fi
1456
1457		if test "x$have_db" != "xno"; then
1458			AC_MSG_ERROR([You can configure for only one database.])
1459		fi
1460
1461		if test "x$found_sqlite3" = "xyes"; then
1462			have_db="SQLite v3.x"
1463
1464			saved_CPPFLAGS="$CPPFLAGS"
1465			saved_LDFLAGS="$LDFLAGS"
1466
1467			CPPFLAGS="$CPPFLAGS $SQLITE3_CPPFLAGS"
1468			LDFLAGS="$LDFLAGS $SQLITE3_LDFLAGS $SQLITE3_LIBS"
1469
1470			AC_MSG_CHECKING([for function sqlite3_open_v2() in sqlite3.h])
1471			AC_TRY_LINK([#include <sqlite3.h>],
1472				[sqlite3 *conn = 0;
1473				sqlite3_open_v2("dbname", &conn, SQLITE_OPEN_READWRITE, 0);
1474				],
1475				AC_DEFINE(HAVE_FUNCTION_SQLITE3_OPEN_V2,1,[Define to 1 if function 'sqlite3_open_v2' exists.])
1476				AC_MSG_RESULT(yes),
1477				AC_MSG_RESULT(no))
1478
1479			CPPFLAGS="$saved_CPPFLAGS"
1480			LDFLAGS="$saved_LDFLAGS"
1481		else
1482			AC_MSG_ERROR([SQLite3 library not found])
1483		fi
1484	fi
1485
1486	AC_MSG_CHECKING(for Zabbix server/proxy database selection)
1487	if test "x$have_db" = "xno"; then
1488		AC_MSG_RESULT(error)
1489		AC_MSG_ERROR([No database selected for Zabbix server/proxy. Use --with-mysql or --with-oracle or --with-postgresql or --with-sqlite3.])
1490	else
1491		AC_MSG_RESULT(ok)
1492	fi
1493
1494	AC_MSG_CHECKING(for multirow insert statements)
1495	if test "x$have_multirow_insert" = "xyes"; then
1496		AC_DEFINE(HAVE_MULTIROW_INSERT,1,[Define to 1 if database supports multirow insert statements.])
1497		AC_MSG_RESULT(yes)
1498	else
1499		AC_MSG_RESULT(no)
1500	fi
1501
1502	DB_CFLAGS="$MYSQL_CFLAGS $ORACLE_CPPFLAGS $POSTGRESQL_CFLAGS $SQLITE3_CPPFLAGS"
1503	DB_LDFLAGS="$MYSQL_LDFLAGS $ORACLE_LDFLAGS $POSTGRESQL_LDFLAGS $SQLITE3_LDFLAGS"
1504	DB_LIBS="$MYSQL_LIBS $ORACLE_LIBS $POSTGRESQL_LIBS $SQLITE3_LIBS"
1505
1506	AC_SUBST(DB_CFLAGS)
1507	AC_SUBST(DB_LDFLAGS)
1508	AC_SUBST(DB_LIBS)
1509
1510	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${DB_LDFLAGS}"
1511	SERVER_LIBS="${SERVER_LIBS} ${DB_LIBS}"
1512
1513	PROXY_LDFLAGS="${PROXY_LDFLAGS} ${DB_LDFLAGS}"
1514	PROXY_LIBS="${PROXY_LIBS} ${DB_LIBS}"
1515
1516	dnl Check for LIBXML2 [by default - skip]
1517	LIBXML2_CHECK_CONFIG([no])
1518	if test "x$want_libxml2" = "xyes"; then
1519		if test "x$found_libxml2" != "xyes"; then
1520			AC_MSG_ERROR([LIBXML2 library not found])
1521		else
1522			have_libxml2="yes"
1523		fi
1524	fi
1525	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBXML2_LDFLAGS"
1526	SERVER_LIBS="$SERVER_LIBS $LIBXML2_LIBS"
1527
1528	PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBXML2_LDFLAGS"
1529	PROXY_LIBS="$PROXY_LIBS $LIBXML2_LIBS"
1530
1531	AC_SUBST(LIBXML2_CFLAGS)
1532
1533	dnl Checking for unixODBC support
1534	LIBUNIXODBC_CHECK_CONFIG([no])
1535	if test "x$want_unixodbc" = "xyes"; then
1536		if test "x$unixodbc_error" != "x"; then
1537			AC_MSG_ERROR($unixodbc_error)
1538		fi
1539		have_unixodbc="yes"
1540	fi
1541	SERVER_LDFLAGS="$SERVER_LDFLAGS $UNIXODBC_LDFLAGS"
1542	SERVER_LIBS="$SERVER_LIBS $UNIXODBC_LIBS"
1543
1544	PROXY_LDFLAGS="$PROXY_LDFLAGS $UNIXODBC_LDFLAGS"
1545	PROXY_LIBS="$PROXY_LIBS $UNIXODBC_LIBS"
1546
1547	AC_SUBST(UNIXODBC_CFLAGS)
1548
1549	dnl Check for Net-SNMP [by default - skip]
1550	LIBNETSNMP_CHECK_CONFIG([no], "5.3.0")
1551
1552	if test "x$want_netsnmp" = "xyes"; then
1553		if test "x$found_netsnmp" != "xyes"; then
1554			AC_MSG_ERROR([Invalid Net-SNMP directory - unable to find net-snmp-config])
1555		else
1556			have_snmp="yes"
1557		fi
1558	fi
1559	SERVER_LDFLAGS="$SERVER_LDFLAGS $SNMP_LDFLAGS"
1560	SERVER_LIBS="$SERVER_LIBS $SNMP_LIBS"
1561
1562	PROXY_LDFLAGS="$PROXY_LDFLAGS $SNMP_LDFLAGS"
1563	PROXY_LIBS="$PROXY_LIBS $SNMP_LIBS"
1564
1565	AC_SUBST(SNMP_CFLAGS)
1566
1567	dnl Check for LIBSSH2 [by default - skip] at least of version 1.0.0.
1568	LIBSSH2_CHECK_CONFIG([no])
1569	LIBSSH_CHECK_CONFIG([no])
1570	if test "x$want_ssh2" = "xyes"; then
1571		if test "x$want_ssh" != "xno"; then
1572			AC_MSG_ERROR([You can configure for only one SSH library (--with-ssh or --with-ssh2).])
1573		fi
1574
1575		if test "x$found_ssh2" != "xyes"; then
1576			AC_MSG_ERROR([SSH2 library not found])
1577		elif test "x$accept_ssh2_version" != "xyes"; then
1578			AC_MSG_ERROR([SSH2 library version requirement not met (>= 1.0.0)])
1579		else
1580			have_ssh="yes (libssh2)"
1581		fi
1582	fi
1583	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH2_LDFLAGS"
1584	SERVER_LIBS="$SERVER_LIBS $SSH2_LIBS"
1585
1586	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH2_LDFLAGS"
1587	PROXY_LIBS="$PROXY_LIBS $SSH2_LIBS"
1588
1589	AC_SUBST(SSH2_CFLAGS)
1590
1591	dnl Check for LIBSSH [by default - skip] at least of version 0.7.0.
1592	if test "x$want_ssh" = "xyes"; then
1593		if test "x$found_ssh" != "xyes"; then
1594			AC_MSG_ERROR([SSH library not found])
1595		elif test "x$accept_ssh_version" != "xyes"; then
1596			AC_MSG_ERROR([SSH library version requirement not met (>= 0.6.0)])
1597		else
1598			have_ssh="yes (libssh)"
1599		fi
1600	fi
1601	SERVER_LDFLAGS="$SERVER_LDFLAGS $SSH_LDFLAGS"
1602	SERVER_LIBS="$SERVER_LIBS $SSH_LIBS"
1603
1604	PROXY_LDFLAGS="$PROXY_LDFLAGS $SSH_LDFLAGS"
1605	PROXY_LIBS="$PROXY_LIBS $SSH_LIBS"
1606
1607	AC_SUBST(SSH_CFLAGS)
1608
1609	found_openipmi="no"
1610	dnl Check for libOpenIPMI [by default - skip]
1611	LIBOPENIPMI_CHECK_CONFIG([no])
1612	if test "x$want_openipmi" = "xyes"; then
1613		if test "x$found_openipmi" != "xyes"; then
1614			AC_MSG_ERROR([Invalid OPENIPMI directory - unable to find ipmiif.h])
1615		else
1616			have_ipmi="yes"
1617		fi
1618	fi
1619
1620	SERVER_LDFLAGS="$SERVER_LDFLAGS $OPENIPMI_LDFLAGS"
1621	SERVER_LIBS="$SERVER_LIBS $OPENIPMI_LIBS"
1622
1623	PROXY_LDFLAGS="$PROXY_LDFLAGS $OPENIPMI_LDFLAGS"
1624	PROXY_LIBS="$PROXY_LIBS $OPENIPMI_LIBS"
1625
1626	AC_SUBST(OPENIPMI_CFLAGS)
1627
1628	dnl Check for zlib, used by Zabbix server-proxy communications
1629	ZLIB_CHECK_CONFIG([no])
1630	if test "x$found_zlib" != "xyes"; then
1631		AC_MSG_ERROR([Unable to use zlib (zlib check failed)])
1632	fi
1633
1634	AC_SUBST(ZLIB_CFLAGS)
1635
1636	dnl Check for 'libpthread' library that supports PTHREAD_PROCESS_SHARED flag
1637	LIBPTHREAD_CHECK_CONFIG([no])
1638	if test "x$found_libpthread" != "xyes"; then
1639		AC_MSG_ERROR([Unable to use libpthread (libpthread check failed)])
1640	fi
1641fi
1642
1643SERVER_LDFLAGS="$SERVER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1644SERVER_LIBS="$SERVER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1645
1646PROXY_LDFLAGS="$PROXY_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1647PROXY_LIBS="$PROXY_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1648
1649AGENT_LDFLAGS="$AGENT_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1650AGENT_LIBS="$AGENT_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1651
1652AGENT2_LDFLAGS="$AGENT2_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1653AGENT2_LIBS="$AGENT2_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1654
1655ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1656ZBXGET_LIBS="$ZBXGET_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1657
1658SENDER_LDFLAGS="$SENDER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1659SENDER_LIBS="$SENDER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1660
1661ZBXJS_LDFLAGS="$ZBXJS_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1662ZBXJS_LIBS="$ZBXJS_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1663
1664AM_CONDITIONAL(HAVE_IPMI, [test "x$have_ipmi" = "xyes"])
1665AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes")
1666
1667dnl Check if Zabbix internal IPC services are used
1668have_ipcservice="no"
1669if test "x$have_ipmi" = "xyes"; then
1670	have_ipcservice="yes"
1671fi
1672
1673if test "x$server" = "xyes"; then
1674	have_ipcservice="yes"
1675fi
1676
1677if test "x$proxy" = "xyes"; then
1678	have_ipcservice="yes"
1679fi
1680
1681AM_CONDITIONAL(PROXY_IPCSERVICE, [test "x$have_ipmi" = "xyes"])
1682
1683dnl Check for libevent, used by Zabbix IPC services
1684if test "x$have_ipcservice" = "xyes"; then
1685	AC_DEFINE([HAVE_IPCSERVICE], 1, [Define to 1 if Zabbix IPC services are used])
1686
1687	LIBEVENT_CHECK_CONFIG([no])
1688	if test "x$found_libevent" != "xyes"; then
1689		AC_MSG_ERROR([Unable to use libevent (libevent check failed)])
1690	fi
1691
1692	SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBEVENT_LDFLAGS"
1693	SERVER_LIBS="$SERVER_LIBS $LIBEVENT_LIBS"
1694
1695	PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBEVENT_LDFLAGS"
1696	PROXY_LIBS="$PROXY_LIBS $LIBEVENT_LIBS"
1697fi
1698
1699dnl Check for GnuTLS libgnutls [by default - skip]
1700LIBGNUTLS_CHECK_CONFIG([no])
1701if test "x$want_gnutls" = "xyes"; then
1702	if test "x$have_tls" != "xno"; then
1703		AC_MSG_ERROR([You can configure for only one TLS library (--with-gnutls or --with-openssl).])
1704	fi
1705
1706	if test "x$found_gnutls" != "xyes"; then
1707		AC_MSG_ERROR([GnuTLS library libgnutls not found])
1708	elif test "x$accept_gnutls_version" != "xyes"; then
1709		AC_MSG_ERROR([GnuTLS library version requirement not met (>= 3.1.18)])
1710	else
1711		have_tls="GnuTLS"
1712	fi
1713	TLS_CFLAGS="$GNUTLS_CFLAGS"
1714	TLS_LDFLAGS="$GNUTLS_LDFLAGS"
1715	TLS_LIBS="$GNUTLS_LIBS"
1716fi
1717
1718dnl Check for OpenSSL libssl and libcrypto [by default - skip]
1719LIBOPENSSL_CHECK_CONFIG([no])
1720if test "x$want_openssl" = "xyes"; then
1721	if test "x$have_tls" != "xno"; then
1722		AC_MSG_ERROR([You can configure for only one TLS library (--with-gnutls or --with-openssl).])
1723	fi
1724
1725	if test "x$found_openssl" != "xOpenSSL" -a "x$found_openssl" != "xOpenSSL (PSK not supported)"; then
1726		AC_MSG_ERROR([OpenSSL library libssl or libcrypto not found])
1727	elif test "x$accept_openssl_version" != "xyes"; then
1728		AC_MSG_ERROR([OpenSSL library version requirement not met (>= 1.0.1)])
1729	else
1730		have_tls=$found_openssl
1731	fi
1732	TLS_CFLAGS="$OPENSSL_CFLAGS"
1733	TLS_LDFLAGS="$OPENSSL_LDFLAGS"
1734	TLS_LIBS="$OPENSSL_LIBS"
1735fi
1736AC_SUBST(TLS_CFLAGS)
1737
1738SERVER_LDFLAGS="$SERVER_LDFLAGS $TLS_LDFLAGS"
1739SERVER_LIBS="$SERVER_LIBS $TLS_LIBS"
1740
1741PROXY_LDFLAGS="$PROXY_LDFLAGS $TLS_LDFLAGS"
1742PROXY_LIBS="$PROXY_LIBS $TLS_LIBS"
1743
1744AGENT_LDFLAGS="$AGENT_LDFLAGS $TLS_LDFLAGS"
1745AGENT_LIBS="$AGENT_LIBS $TLS_LIBS"
1746
1747AGENT2_LDFLAGS="$AGENT2_LDFLAGS $TLS_LDFLAGS"
1748AGENT2_LIBS="$AGENT2_LIBS $TLS_LIBS"
1749
1750ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $TLS_LDFLAGS"
1751ZBXGET_LIBS="$ZBXGET_LIBS $TLS_LIBS"
1752
1753SENDER_LDFLAGS="$SENDER_LDFLAGS $TLS_LDFLAGS"
1754SENDER_LIBS="$SENDER_LIBS $TLS_LIBS"
1755
1756ZBXJS_LDFLAGS="$ZLIB_LDFLAGS $TLS_LDFLAGS"
1757ZBXJS_LIBS="$ZBXJS_LIBS $TLS_LIBS"
1758
1759if test "x$agent2" = "xyes"; then
1760	AC_CHECK_PROGS([GO], [go], [no])
1761	if test "x$GO" = "xno"; then
1762		AC_MSG_ERROR([Unable to find "go" executable in path])
1763	fi
1764	AC_DEFINE(ZBX_BUILD_AGENT2,1,[Define to 1 if Agent2 is being built.])
1765fi
1766
1767if test "x$java" = "xyes"; then
1768	AC_CHECK_PROGS([JAVAC], [javac], [no])
1769	if test "x$JAVAC" = "xno"; then
1770		AC_MSG_ERROR([Unable to find "javac" executable in path])
1771	fi
1772	AC_CHECK_PROGS([JAR], [jar], [no])
1773	if test "x$JAR" = "xno"; then
1774		AC_MSG_ERROR([Unable to find "jar" executable in path])
1775	fi
1776fi
1777
1778found_ldap="no"
1779dnl Check for libLDAP [by default - skip]
1780LIBLDAP_CHECK_CONFIG([no])
1781if test "x$want_ldap" = "xyes"; then
1782	if test "x$found_ldap" != "xyes"; then
1783		AC_MSG_ERROR([Invalid LDAP directory - unable to find ldap.h])
1784	fi
1785fi
1786SERVER_LDFLAGS="$SERVER_LDFLAGS $LDAP_LDFLAGS"
1787SERVER_LIBS="$SERVER_LIBS $LDAP_LIBS"
1788
1789PROXY_LDFLAGS="$PROXY_LDFLAGS $LDAP_LDFLAGS"
1790PROXY_LIBS="$PROXY_LIBS $LDAP_LIBS"
1791
1792AGENT_LDFLAGS="$AGENT_LDFLAGS $LDAP_LDFLAGS"
1793AGENT_LIBS="$AGENT_LIBS $LDAP_LIBS"
1794
1795AC_SUBST(LDAP_CPPFLAGS)
1796
1797found_curl="no"
1798dnl Checking for libCurl [by default - skip]
1799LIBCURL_CHECK_CONFIG(, [7.13.1], [],[])
1800if test "x$want_curl" = "xyes"; then
1801	if test "x$found_curl" != "xyes"; then
1802		AC_MSG_ERROR([Curl library not found])
1803	fi
1804fi
1805if test "x$found_curl" = "xyes"; then
1806	have_web_monitoring="cURL"
1807fi
1808CFLAGS="$LIBCURL_CFLAGS $CFLAGS"
1809
1810SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBCURL_LDFLAGS"
1811SERVER_LIBS="$SERVER_LIBS $LIBCURL_LIBS"
1812
1813PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBCURL_LDFLAGS"
1814PROXY_LIBS="$PROXY_LIBS $LIBCURL_LIBS"
1815
1816AM_CONDITIONAL(HAVE_LIBCURL, test "x$found_curl" = "xyes")
1817
1818dnl Starting from 2.0 agent can do web monitoring
1819AGENT_LDFLAGS="$AGENT_LDFLAGS $LIBCURL_LDFLAGS"
1820AGENT_LIBS="$AGENT_LIBS $LIBCURL_LIBS"
1821
1822ZBXGET_LDFLAGS="$ZBXGET_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1823ZBXGET_LIBS="$ZBXGET_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1824
1825SENDER_LDFLAGS="$SENDER_LDFLAGS $ZLIB_LDFLAGS $LIBPTHREAD_LDFLAGS"
1826SENDER_LIBS="$SENDER_LIBS $ZLIB_LIBS $LIBPTHREAD_LIBS"
1827
1828ZBXJS_LDFLAGS="$ZBXJS_LDFLAGS $LIBCURL_LDFLAGS"
1829ZBXJS_LIBS="$ZBXJS_LIBS $LIBCURL_LIBS"
1830
1831dnl Check for libpcre, used by Zabbix for regular expressions
1832if test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes" || test "x$agent2" = "xyes"; then
1833	LIBPCRE_CHECK_CONFIG([no])
1834	if test "x$found_libpcre" != "xyes"; then
1835		AC_MSG_ERROR([Unable to use libpcre (libpcre check failed)])
1836	fi
1837fi
1838
1839CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
1840LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS"
1841if test "x$ARCH" = "xosx"; then
1842	LIBS="$LIBPCRE_LIBS $LIBS"
1843else
1844	LIBS="$LIBS $LIBPCRE_LIBS"
1845fi
1846
1847found_iconv="no"
1848dnl Check for libiconv [by default - skip]
1849LIBICONV_CHECK_CONFIG([no])
1850if test "x$found_iconv" != "xyes"; then
1851	AC_MSG_ERROR([Unable to use iconv (libiconv check failed)])
1852fi
1853LDFLAGS="$LDFLAGS $ICONV_LDFLAGS"
1854LIBS="$LIBS $ICONV_LIBS"
1855
1856RANLIB="ranlib"
1857AC_SUBST(RANLIB)
1858
1859SERVER_CONFIG_FILE="${sysconfdir}/zabbix_server.conf"
1860PROXY_CONFIG_FILE="${sysconfdir}/zabbix_proxy.conf"
1861AGENT_CONFIG_FILE="${sysconfdir}/zabbix_agentd.conf"
1862AGENT2_CONFIG_FILE="${sysconfdir}/zabbix_agent2.conf"
1863
1864EXTERNAL_SCRIPTS_PATH="${datadir}/zabbix/externalscripts"
1865ALERT_SCRIPTS_PATH="${datadir}/zabbix/alertscripts"
1866
1867CURL_SSL_CERT_LOCATION="${datadir}/zabbix/ssl/certs"
1868CURL_SSL_KEY_LOCATION="${datadir}/zabbix/ssl/keys"
1869
1870LOAD_MODULE_PATH="${libdir}/modules"
1871
1872AC_SUBST(SERVER_LDFLAGS)
1873AC_SUBST(SERVER_LIBS)
1874
1875AC_SUBST(PROXY_LDFLAGS)
1876AC_SUBST(PROXY_LIBS)
1877
1878AC_SUBST(AGENT_LDFLAGS)
1879AC_SUBST(AGENT_LIBS)
1880
1881AC_SUBST(AGENT2_LDFLAGS)
1882AC_SUBST(AGENT2_LIBS)
1883
1884if test "x$HAVE_START_GROUP" = "xyes"; then
1885	LD_START_GROUP=-Wl,--start-group
1886	LD_END_GROUP=-Wl,--end-group
1887fi
1888
1889CGO_CFLAGS=$TLS_CFLAGS
1890CGO_LDFLAGS="$AGENT2_LDFLAGS $LD_START_GROUP \
1891	\${abs_top_builddir}/src/zabbix_agent/logfiles/libzbxlogfiles.a \
1892	\${abs_top_builddir}/src/libs/zbxcomms/libzbxcomms.a \
1893	\${abs_top_builddir}/src/libs/zbxcommon/libzbxcommon.a \
1894	\${abs_top_builddir}/src/libs/zbxcrypto/libzbxcrypto.a \
1895	\${abs_top_builddir}/src/libs/zbxsys/libzbxsys.a \
1896	\${abs_top_builddir}/src/libs/zbxnix/libzbxnix.a \
1897	\${abs_top_builddir}/src/libs/zbxconf/libzbxconf.a \
1898	\${abs_top_builddir}/src/libs/zbxhttp/libzbxhttp.a \
1899	\${abs_top_builddir}/src/libs/zbxcompress/libzbxcompress.a \
1900	\${abs_top_builddir}/src/libs/zbxregexp/libzbxregexp.a \
1901	\${abs_top_builddir}/src/libs/zbxsysinfo/libzbxagent2sysinfo.a \
1902	\${abs_top_builddir}/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
1903	\${abs_top_builddir}/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
1904	\${abs_top_builddir}/src/libs/zbxsysinfo/"$ARCH"/libspechostnamesysinfo.a \
1905	\${abs_top_builddir}/src/libs/zbxsysinfo/"$ARCH"/libspecsysinfo.a \
1906	\${abs_top_builddir}/src/libs/zbxexec/libzbxexec.a \
1907	\${abs_top_builddir}/src/libs/zbxalgo/libzbxalgo.a \
1908	\${abs_top_builddir}/src/libs/zbxjson/libzbxjson.a \
1909	$LIBS $AGENT2_LIBS $LD_END_GROUP"
1910
1911AC_SUBST(CGO_CFLAGS)
1912AC_SUBST(CGO_LDFLAGS)
1913
1914AC_SUBST(ZBXGET_LDFLAGS)
1915AC_SUBST(ZBXGET_LIBS)
1916
1917AC_SUBST(SENDER_LDFLAGS)
1918AC_SUBST(SENDER_LIBS)
1919
1920AC_SUBST(ZBXJS_LDFLAGS)
1921AC_SUBST(ZBXJS_LIBS)
1922
1923AC_SUBST(SERVER_CONFIG_FILE)
1924AC_SUBST(PROXY_CONFIG_FILE)
1925AC_SUBST(AGENT_CONFIG_FILE)
1926AC_SUBST(AGENT2_CONFIG_FILE)
1927
1928AC_SUBST(EXTERNAL_SCRIPTS_PATH)
1929AC_SUBST(ALERT_SCRIPTS_PATH)
1930
1931AC_SUBST(CURL_SSL_CERT_LOCATION)
1932AC_SUBST(CURL_SSL_KEY_LOCATION)
1933
1934AC_SUBST(LOAD_MODULE_PATH)
1935
1936GOBIN=${sbindir}
1937GOCMD=go
1938GOWORKDIR=$ac_abs_confdir/go/src/zabbix
1939
1940export GOBIN=${GOBIN}
1941AC_SUBST(GOBIN)
1942AC_SUBST(GOCMD)
1943AC_SUBST(GOWORKDIR)
1944
1945dnl *****************************************************************
1946dnl *                                                               *
1947dnl *                         Other checks                          *
1948dnl *                                                               *
1949dnl *****************************************************************
1950
1951dnl Automake 1.8 to 1.9.6 sets mkdir_p macro (lower-cased).
1952AC_MSG_CHECKING(for mkdir -p candidate)
1953if test "x${MKDIR_P}" = "x"; then
1954        if test "x${mkdir_p}" = "x"; then
1955                AC_MSG_ERROR([No suitable "mkdir -p" candidate found.])
1956        fi
1957        AC_SUBST([MKDIR_P], ${mkdir_p})
1958fi
1959AC_MSG_RESULT([ok (${MKDIR_P})])
1960
1961dnl Check if process statistics collector should be enabled
1962case "x$ARCH" in
1963	xlinux|xsolaris)
1964		AC_DEFINE(ZBX_PROCSTAT_COLLECTOR, 1 , [Define to 1 on linux and solaris platforms])
1965		;;
1966esac
1967
1968dnl *****************************************************************
1969dnl *                                                               *
1970dnl *                 Output configuration results                  *
1971dnl *                                                               *
1972dnl *****************************************************************
1973
1974m4_ifdef([CONF_TESTS],[CONF_TESTS(ZBXCMOCKA)])
1975
1976AC_OUTPUT([
1977	Makefile
1978	database/Makefile
1979	database/mysql/Makefile
1980	database/oracle/Makefile
1981	database/postgresql/Makefile
1982	database/sqlite3/Makefile
1983	misc/Makefile
1984	src/Makefile
1985	src/go/Makefile
1986	src/libs/Makefile
1987	src/libs/zbxlog/Makefile
1988	src/libs/zbxalgo/Makefile
1989	src/libs/zbxmemory/Makefile
1990	src/libs/zbxcrypto/Makefile
1991	src/libs/zbxconf/Makefile
1992	src/libs/zbxdbcache/Makefile
1993	src/libs/zbxdbhigh/Makefile
1994	src/libs/zbxmedia/Makefile
1995	src/libs/zbxsysinfo/Makefile
1996	src/libs/zbxcommon/Makefile
1997	src/libs/zbxsysinfo/agent/Makefile
1998	src/libs/zbxsysinfo/common/Makefile
1999	src/libs/zbxsysinfo/simple/Makefile
2000	src/libs/zbxsysinfo/linux/Makefile
2001	src/libs/zbxsysinfo/aix/Makefile
2002	src/libs/zbxsysinfo/freebsd/Makefile
2003	src/libs/zbxsysinfo/dragonfly/Makefile
2004	src/libs/zbxsysinfo/hpux/Makefile
2005	src/libs/zbxsysinfo/openbsd/Makefile
2006	src/libs/zbxsysinfo/osx/Makefile
2007	src/libs/zbxsysinfo/solaris/Makefile
2008	src/libs/zbxsysinfo/osf/Makefile
2009	src/libs/zbxsysinfo/netbsd/Makefile
2010	src/libs/zbxsysinfo/unknown/Makefile
2011	src/libs/zbxnix/Makefile
2012	src/libs/zbxsys/Makefile
2013	src/libs/zbxcomms/Makefile
2014	src/libs/zbxcommshigh/Makefile
2015	src/libs/zbxdb/Makefile
2016	src/libs/zbxdbupgrade/Makefile
2017	src/libs/zbxjson/Makefile
2018	src/libs/zbxhttp/Makefile
2019	src/libs/zbxserver/Makefile
2020	src/libs/zbxicmpping/Makefile
2021	src/libs/zbxexec/Makefile
2022	src/libs/zbxself/Makefile
2023	src/libs/zbxmodules/Makefile
2024	src/libs/zbxregexp/Makefile
2025	src/libs/zbxtasks/Makefile
2026	src/libs/zbxipcservice/Makefile
2027	src/libs/zbxhistory/Makefile
2028	src/libs/zbxcompress/Makefile
2029	src/libs/zbxembed/Makefile
2030	src/libs/zbxprometheus/Makefile
2031	src/libs/zbxdiag/Makefile
2032	src/libs/zbxxml/Makefile
2033	src/zabbix_agent/Makefile
2034	src/zabbix_agent/logfiles/Makefile
2035	src/zabbix_get/Makefile
2036	src/zabbix_js/Makefile
2037	src/zabbix_sender/Makefile
2038	src/zabbix_server/Makefile
2039	src/zabbix_server/alerter/Makefile
2040	src/zabbix_server/dbsyncer/Makefile
2041	src/zabbix_server/dbconfig/Makefile
2042	src/zabbix_server/discoverer/Makefile
2043	src/zabbix_server/housekeeper/Makefile
2044	src/zabbix_server/httppoller/Makefile
2045	src/zabbix_server/pinger/Makefile
2046	src/zabbix_server/poller/Makefile
2047	src/zabbix_server/snmptrapper/Makefile
2048	src/zabbix_server/timer/Makefile
2049	src/zabbix_server/trapper/Makefile
2050	src/zabbix_server/escalator/Makefile
2051	src/zabbix_server/proxypoller/Makefile
2052	src/zabbix_server/selfmon/Makefile
2053	src/zabbix_server/vmware/Makefile
2054	src/zabbix_server/taskmanager/Makefile
2055	src/zabbix_server/ipmi/Makefile
2056	src/zabbix_server/odbc/Makefile
2057	src/zabbix_server/scripts/Makefile
2058	src/zabbix_server/preprocessor/Makefile
2059	src/zabbix_server/lld/Makefile
2060	src/zabbix_proxy/Makefile
2061	src/zabbix_proxy/heart/Makefile
2062	src/zabbix_proxy/housekeeper/Makefile
2063	src/zabbix_proxy/proxyconfig/Makefile
2064	src/zabbix_proxy/datasender/Makefile
2065	src/zabbix_proxy/taskmanager/Makefile
2066	src/zabbix_java/Makefile
2067	man/Makefile
2068	])
2069
2070dnl The following variables use autoconf variables such as
2071dnl ${sysconfdir} and ${datadir} . Which in turn contain
2072dnl variables such as ${prefix}. In order to completely
2073dnl substitute all variables and output end-value in
2074dnl Configuration output below it is required to perform 2
2075dnl substitutions.
2076
2077SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`
2078SERVER_CONFIG_FILE=`eval echo "${SERVER_CONFIG_FILE}"`
2079
2080PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`
2081PROXY_CONFIG_FILE=`eval echo "${PROXY_CONFIG_FILE}"`
2082
2083AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`
2084AGENT_CONFIG_FILE=`eval echo "${AGENT_CONFIG_FILE}"`
2085
2086AGENT2_CONFIG_FILE=`eval echo "${AGENT2_CONFIG_FILE}"`
2087AGENT2_CONFIG_FILE=`eval echo "${AGENT2_CONFIG_FILE}"`
2088
2089EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`
2090EXTERNAL_SCRIPTS_PATH=`eval echo "${EXTERNAL_SCRIPTS_PATH}"`
2091
2092ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`
2093ALERT_SCRIPTS_PATH=`eval echo "${ALERT_SCRIPTS_PATH}"`
2094
2095CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`
2096CURL_SSL_CERT_LOCATION=`eval echo "${CURL_SSL_CERT_LOCATION}"`
2097
2098CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`
2099CURL_SSL_KEY_LOCATION=`eval echo "${CURL_SSL_KEY_LOCATION}"`
2100
2101LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`
2102LOAD_MODULE_PATH=`eval echo "${LOAD_MODULE_PATH}"`
2103
2104echo "
2105
2106Configuration:
2107
2108  Detected OS:           ${host_os}
2109  Install path:          ${prefix}
2110  Compilation arch:      ${ARCH}
2111
2112  Compiler:              ${CC}
2113  Compiler flags:        ${CFLAGS}
2114
2115  Library-specific flags:"
2116
2117if test "x$DB_CFLAGS" != "x"; then
2118	echo "    database:              ${DB_CFLAGS}"
2119fi
2120
2121if test "x$LIBXML2_CFLAGS" != "x"; then
2122	echo "    libXML2:               ${LIBXML2_CFLAGS}"
2123fi
2124
2125if test "x$UNIXODBC_CFLAGS" != "x"; then
2126	echo "    unixODBC:              ${UNIXODBC_CFLAGS}"
2127fi
2128
2129if test "x$SNMP_CFLAGS" != "x"; then
2130	echo "    Net-SNMP:              ${SNMP_CFLAGS}"
2131fi
2132
2133if test "x$OPENIPMI_CFLAGS" != "x"; then
2134	echo "    OpenIPMI:              ${OPENIPMI_CFLAGS}"
2135fi
2136
2137if test "x$SSH2_CFLAGS" != "x"; then
2138	echo "    libssh2:               ${SSH2_CFLAGS}"
2139fi
2140
2141if test "x$SSH_CFLAGS" != "x"; then
2142	echo "    libssh:                ${SSH_CFLAGS}"
2143fi
2144
2145if test "x$TLS_CFLAGS" != "x"; then
2146	echo "    TLS:                   ${TLS_CFLAGS}"
2147fi
2148
2149if test "x$LDAP_CPPFLAGS" != "x"; then
2150	echo "    LDAP:                  ${LDAP_CPPFLAGS}"
2151fi
2152
2153if test "x$ICONV_CFLAGS" != "x"; then
2154	echo "    iconv:                 ${ICONV_CFLAGS}"
2155fi
2156
2157if test "x$LIBEVENT_CFLAGS" != "x"; then
2158	echo "    libevent:              ${LIBEVENT_CFLAGS}"
2159fi
2160
2161echo "
2162  Enable server:         ${server}"
2163
2164if test "x$server" != "xno"; then
2165
2166echo "  Server details:
2167    With database:         ${have_db}
2168    WEB Monitoring:        ${have_web_monitoring}"
2169
2170if test "x$have_web_monitoring" = "xcURL"; then
2171echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
2172      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
2173fi
2174
2175echo "    SNMP:                  ${have_snmp}
2176    IPMI:                  ${have_ipmi}
2177    SSH:                   ${have_ssh}
2178    TLS:                   ${have_tls}
2179    ODBC:                  ${have_unixodbc}
2180    Linker flags:          ${SERVER_LDFLAGS} ${LDFLAGS}
2181    Libraries:             ${SERVER_LIBS} ${LIBS}
2182    Configuration file:    ${SERVER_CONFIG_FILE}
2183    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
2184    Alert scripts:         ${ALERT_SCRIPTS_PATH}
2185    Modules:               ${LOAD_MODULE_PATH}"
2186
2187fi
2188
2189echo "
2190  Enable proxy:          ${proxy}"
2191
2192if test "x$proxy" != "xno"; then
2193
2194echo "  Proxy details:
2195    With database:         ${have_db}
2196    WEB Monitoring:        ${have_web_monitoring}"
2197
2198if test "x$have_web_monitoring" = "xcURL"; then
2199echo "      SSL certificates:      ${CURL_SSL_CERT_LOCATION}
2200      SSL keys:              ${CURL_SSL_KEY_LOCATION}"
2201fi
2202
2203echo "    SNMP:                  ${have_snmp}
2204    IPMI:                  ${have_ipmi}
2205    SSH:                   ${have_ssh}
2206    TLS:                   ${have_tls}
2207    ODBC:                  ${have_unixodbc}
2208    Linker flags:          ${PROXY_LDFLAGS} ${LDFLAGS}
2209    Libraries:             ${PROXY_LIBS} ${LIBS}
2210    Configuration file:    ${PROXY_CONFIG_FILE}
2211    External scripts:      ${EXTERNAL_SCRIPTS_PATH}
2212    Modules:               ${LOAD_MODULE_PATH}"
2213
2214fi
2215
2216echo "
2217  Enable agent:          ${agent}"
2218
2219if test "x$agent" != "xno"; then
2220
2221echo "  Agent details:
2222    TLS:                   ${have_tls}
2223    Linker flags:          ${AGENT_LDFLAGS} ${LDFLAGS}
2224    Libraries:             ${AGENT_LIBS} ${LIBS}
2225    Configuration file:    ${AGENT_CONFIG_FILE}
2226    Modules:               ${LOAD_MODULE_PATH}"
2227
2228fi
2229
2230echo "
2231  Enable agent 2:        ${agent2}"
2232
2233echo "
2234  Enable Java gateway:   ${java}"
2235
2236if test "x$java" != "xno"; then
2237
2238echo "  Java gateway details:
2239    Java compiler:         ${JAVAC}
2240    Java archiver:         ${JAR}"
2241
2242fi
2243
2244echo "
2245  LDAP support:          ${found_ldap}
2246  IPv6 support:          ${have_ipv6}"
2247
2248echo
2249echo "***********************************************************"
2250echo "*            Now run '${am_make} install'                       *"
2251echo "*                                                         *"
2252echo "*            Thank you for using Zabbix!                  *"
2253echo "*              <http://www.zabbix.com>                    *"
2254echo "***********************************************************"
2255echo
2256