dnl dnl Zabbix dnl Copyright (C) 2000,2001,2002,2003 Alexei Vladishev dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dnl dnl Process this file with autoconf to produce a configure script. AC_INIT(src/zabbix_sucker/zabbix_sucker.c) dnl AM_INIT_AUTOMAKE(PACKAGE,all) AC_PROG_MAKE_SET dnl AM_CONFIG_HEADER(include/config.h) dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. AC_CHECK_LIB(crypto, main) AC_CHECK_LIB(snmp, main, LIBS="-lsnmp $LIBS") AC_CHECK_LIB(socket, main) AC_CHECK_LIB(nsl, main) dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(stdio.h stdlib.h string.h unistd.h netdb.h signal.h \ syslog.h time.h errno.h sys/types.h sys/stat.h netinet/in.h \ sys/socket.h ucd-snmp/ucd-snmp-config.h ucd-snmp/system.h \ ucd-snmp/ucd-snmp-includes.h dirent.h \ mtent.h fcntl.h sys/param.h sys/mount.h arpa/inet.h \ sys/vfs.h sys/pstat.h sys/sysinfo.h sys/statvfs.h \ sys/socket.h sys/loadavg.h netinet/in.h arpa/inet.h \ sys/swap.h sys/vmmeter.h strings.h sys/sysctl.h vm/vm_param.h \ sys/time.h kstat.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T dnl Check for socklen_t AC_MSG_CHECKING(for socklen_t) AC_TRY_COMPILE( [#include #include #include ], [socklen_t s;], AC_MSG_RESULT(yes), AC_DEFINE(socklen_t, int) AC_MSG_RESULT(no)) dnl Check for /proc filesystem AC_MSG_CHECKING(for /proc filesystem) if test -d /proc; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PROC) else AC_MSG_RESULT(no) fi dnl Check for file /proc/1/status AC_MSG_CHECKING(for file /proc/1/status) if test -r /proc/1/status; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PROC_1_STATUS) else AC_MSG_RESULT(no) fi dnl Check for file /proc/loadavg AC_MSG_CHECKING(for file /proc/loadavg) if test -r /proc/loadavg; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PROC_LOADAVG) else AC_MSG_RESULT(no) fi dnl Check for file /proc/net/dev AC_MSG_CHECKING(for file /proc/net/dev) if test -r /proc/net/dev; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PROC_NET_DEV) else AC_MSG_RESULT(no) fi dnl Check for freeswap in struct sysinfo AC_MSG_CHECKING(for freeswap in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.freeswap=0; ], AC_DEFINE(HAVE_SYSINFO_FREESWAP) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for vmtotal in sys/vmmeter.h AC_MSG_CHECKING(for vmtotal in struct sys/vmmeter.h) AC_TRY_COMPILE( [ #include #include #include #include #include ], [ int mib[2],len; struct vmtotal v; len=sizeof(struct vmtotal); mib[0]=CTL_VM; mib[1]=VM_METER; sysctl(mib,2,&v,&len,NULL,0); ], AC_DEFINE(HAVE_SYS_VMMETER_VMTOTAL) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for struct swaptable in sys/swap.h AC_MSG_CHECKING(for struct swaptable in sys/swap.h) AC_TRY_COMPILE( [ #include #include #include #include ], [ register int cnt, i; register int t, f; struct swaptable *swt; struct swapent *ste; static char path[256]; /* get total number of swap entries */ cnt = swapctl(SC_GETNSWP, 0); /* allocate enough space to hold count + n swapents */ swt = (struct swaptable *)malloc(sizeof(int) + cnt * sizeof(struct swapent)); if (swt == NULL) { *total = 0; *fr = 0; return; } swt->swt_n = cnt; /* fill in ste_path pointers: we don't care about the paths, so we point them all to the same buffer */ ste = &(swt->swt_ent[0]); i = cnt; while (--i >= 0) { ste++->ste_path = path; } /* grab all swap info */ swapctl(SC_LIST, swt); /* walk thru the structs and sum up the fields */ t = f = 0; ste = &(swt->swt_ent[0]); i = cnt; while (--i >= 0) { /* dont count slots being deleted */ if (!(ste->ste_flags & ST_INDEL) && !(ste->ste_flags & ST_DOINGDEL)) { t += ste->ste_pages; f += ste->ste_free; } ste++; } /* fill in the results */ *total = t; *fr = f; free(swt); ], AC_DEFINE(HAVE_SYS_SWAP_SWAPTABLE) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for totalswap in struct sysinfo AC_MSG_CHECKING(for totalswap in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.totalswap=0; ], AC_DEFINE(HAVE_SYSINFO_TOTALSWAP) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function sysctl (KERN_BOOTTIME) AC_MSG_CHECKING(for function sysctl (KERN_BOOTTIME)) AC_TRY_COMPILE( [ #include #include #include #include #include ], [ struct timeval uptime; int mib[2],len; int now; mib[0]=CTL_KERN; mib[1]=KERN_BOOTTIME; len=sizeof(uptime); sysctl(mib,2,&uptime,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_BOOTTIME) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function sysctl (KERN_MAXFILES) AC_MSG_CHECKING(for function sysctl (KERN_MAXFILES)) AC_TRY_COMPILE( [ #include #include ], [ int mib[2],len; int maxfiles; mib[0]=CTL_KERN; mib[1]=KERN_MAXFILES; len=sizeof(maxfiles); sysctl(mib,2,&maxfiles,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXFILES) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function sysctl (KENR_MAXPROC) AC_MSG_CHECKING(for function sysctl (KERN_MAXPROC)) AC_TRY_COMPILE( [ #include #include ], [ int mib[2],len; int maxproc; mib[0]=CTL_KERN; mib[1]=KERN_MAXPROC; len=sizeof(maxproc); sysctl(mib,2,&maxproc,&len,0,0); ], AC_DEFINE(HAVE_FUNCTION_SYSCTL_KERN_MAXPROC) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function seteuid() AC_MSG_CHECKING(for function seteuid()) AC_TRY_LINK( [ #include #include ], [ seteuid(0); setegid(0); ], AC_DEFINE(HAVE_FUNCTION_SETEUID) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for function setproctitle() AC_MSG_CHECKING(for function setproctitle()) AC_TRY_LINK( [ #include #include ], [ setproctitle("Test %d", 1); ], AC_DEFINE(HAVE_FUNCTION_SETPROCTITLE) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for totalram in struct sysinfo AC_MSG_CHECKING(for totalram in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.totalram=0; ], AC_DEFINE(HAVE_SYSINFO_TOTALRAM) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for totalram in struct sysinfo AC_MSG_CHECKING(for totalram in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.totalram=0; ], AC_DEFINE(HAVE_SYSINFO_TOTALRAM) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for sharedram in struct sysinfo AC_MSG_CHECKING(for sharedram in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.sharedram=0; ], AC_DEFINE(HAVE_SYSINFO_SHAREDRAM) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for bufferram in struct sysinfo AC_MSG_CHECKING(for bufferram in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.bufferram=0; ], AC_DEFINE(HAVE_SYSINFO_BUFFERRAM) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for freeram in struct sysinfo AC_MSG_CHECKING(for freeram in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.freeram=0; ], AC_DEFINE(HAVE_SYSINFO_FREERAM) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for uptime in struct sysinfo AC_MSG_CHECKING(for uptime in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.uptime=0; ], AC_DEFINE(HAVE_SYSINFO_UPTIME) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Check for procs in struct sysinfo AC_MSG_CHECKING(for procs in struct sysinfo) AC_TRY_COMPILE([#include ], [struct sysinfo sysinfo; sysinfo.procs=0; ], AC_DEFINE(HAVE_SYSINFO_PROCS) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) dnl Checks for library functions. AC_TYPE_SIGNAL AC_FUNC_GETLOADAVG AC_CHECK_FUNCS(socket strtod) dnl Check if we want to compile everything with static AC_ARG_ENABLE(static,[ --enable-static Build statically linked binaries], CFLAGS="-static $CFLAGS" LIBS="") AC_MSG_CHECKING(for MySQL support) AC_ARG_WITH(mysql, [ What DBMS do you want to use (please select only one): --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base install directory, default is to search through a number of common places for the MySQL files.], [ if test "$withval" != "no"; then if test "$withval" = "yes"; then if test -f /usr/local/mysql/include/mysql/mysql.h; then MYSQL_INCDIR=/usr/local/mysql/include/mysql MYSQL_LIBDIR=/usr/local/mysql/lib/mysql elif test -f /usr/include/mysql/mysql.h; then MYSQL_INCDIR=/usr/include/mysql MYSQL_LIBDIR=/usr/lib/mysql elif test -f /usr/include/mysql.h; then MYSQL_INCDIR=/usr/include MYSQL_LIBDIR=/usr/lib elif test -f /usr/local/include/mysql/mysql.h; then MYSQL_INCDIR=/usr/local/include/mysql MYSQL_LIBDIR=/usr/local/lib/mysql elif test -f /usr/local/include/mysql.h; then MYSQL_INCDIR=/usr/local/include MYSQL_LIBDIR=/usr/local/lib else AC_MSG_RESULT(no) AC_MSG_ERROR(Invalid MySQL directory - unable to find mysql.h) fi else if test -f $withval/include/mysql/mysql.h; then MYSQL_INCDIR=$withval/include/mysql MYSQL_LIBDIR=$withval/lib/mysql elif test -f $withval/include/mysql.h; then MYSQL_INCDIR=$withval/include MYSQL_LIBDIR=$withval/lib else AC_MSG_RESULT(no) AC_MSG_ERROR(Invalid MySQL directory - unable to find mysql.h under $withval) fi fi MYSQL_INCLUDE=-I$MYSQL_INCDIR MYSQL_LFLAGS="-L$MYSQL_LIBDIR -lmysqlclient" AC_DEFINE(HAVE_MYSQL) AC_MSG_RESULT(yes) have_db=yes dnl MySQL requires -lm sometime AC_CHECK_FUNC(floor, , AC_CHECK_LIB(m, floor, MYSQL_LFLAGS="$MYSQL_LFLAGS -lm")) dnl MySQL 3.23 requires -lz sometime dnl This does not work for some reason dnl AC_CHECK_FUNC(compress, , AC_CHECK_LIB(z, compress, MYSQL_LFLAGS="$MYSQL_LFLAGS -lz")) AC_CHECK_LIB(z, compress, MYSQL_LFLAGS="$MYSQL_LFLAGS -lz") else AC_MSG_RESULT(no) fi ],[ AC_MSG_RESULT(no) ]) AC_SUBST(MYSQL_LFLAGS) AC_SUBST(MYSQL_INCLUDE) AC_MSG_CHECKING(for PostgreSQL support) AC_ARG_WITH(pgsql, [ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL base install directory, defaults to /usr/local/pgsql.], [ if test "$withval" != "no"; then if test "$have_db" = "yes"; then AC_MSG_RESULT(error) AC_MSG_ERROR("You can configure for only one database."); fi if test "$withval" = "yes"; then if test -f /usr/include/pgsql/libpq-fe.h; then PGSQL_INCDIR=/usr/include/pgsql elif test -f /usr/include/postgresql/libpq-fe.h; then PGSQL_INCDIR=/usr/include/postgresql elif test -f /usr/local/include/libpq-fe.h; then PGSQL_INCDIR=/usr/local/include elif test -f /usr/local/include/pgsql/libpq-fe.h; then PGSQL_INCDIR=/usr/local/include/pgsql else PGSQL_INCDIR=/usr/local/pgsql/include fi if test -f /usr/lib/libpq.a; then PGSQL_LIBDIR=/usr/lib elif test -f /usr/local/lib/libpq.a; then PGSQL_LIBDIR=/usr/local/lib else PGSQL_LIBDIR=/usr/local/pgsql/lib fi else PGSQL_INCDIR=$withval/include test -d $withval/include/pgsql && PGSQL_INCDIR=$withval/include/pgsql PGSQL_LIBDIR=$withval/lib test -d $withval/lib/pgsql && PGSQL_LIBDIR=$withval/lib/pgsql fi PGSQL_INCLUDE=-I$PGSQL_INCDIR PGSQL_LFLAGS="-L$PGSQL_LIBDIR -lpq" AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt, crypt, LIBS="-lcrypt $LIBS")) AC_DEFINE(HAVE_PGSQL) AC_MSG_RESULT(yes) have_db=yes else AC_MSG_RESULT(no) fi ],[ AC_MSG_RESULT(no) ]) AC_SUBST(PGSQL_LFLAGS) AC_SUBST(PGSQL_INCLUDE) if test "$have_db" != "yes"; then echo "configure: No database selected! Use --with-XXX where XXX is your preferred database type"; echo "configure: Server processes (zabbix_suckerd and zabbix_trapper) will not be created !"; SUBDIRS="src/zabbix_agent src/zabbix_sender" else SUBDIRS="src/zabbix_agent src/zabbix_sender src/zabbix_sucker src/zabbix_trapper" fi AC_SUBST(SUBDIRS) AC_CONFIG_HEADER(include/config.h) AC_OUTPUT(Makefile src/zabbix_sender/Makefile src/zabbix_agent/Makefile \ src/zabbix_sucker/Makefile src/zabbix_trapper/Makefile) echo echo "***********************************************************" echo "* Now run make *" echo "* *" echo "* Thank you for using Zabbix ! *" echo "* *" echo "***********************************************************" echo