1dnl Process this -*-m4-*- file with autoconf to produce a configure script. 2dnl 3dnl Copyright 2009-2014 Nagios Core Development Team and Community Contributors 4dnl Copyright 2005-2009 Ethan Galstad 5dnl 6dnl This file is part of NDOUtils. 7dnl 8dnl NDOUtils is free software: you can redistribute it and/or modify 9dnl it under the terms of the GNU General Public License version 2 as 10dnl published by the Free Software Foundation. 11dnl 12dnl NDOUtils is distributed in the hope that it will be useful, 13dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15dnl GNU General Public License for more details. 16dnl 17dnl You should have received a copy of the GNU General Public License 18dnl along with NDOUtils. If not, see <http://www.gnu.org/licenses/>. 19 20dnl Disable caching 21define([AC_CACHE_LOAD],) 22define([AC_CACHE_SAVE],) 23 24AC_INIT(src/ndo2db.c) 25AC_CONFIG_HEADER(include/config.h) 26AC_PREFIX_DEFAULT(/usr/local/nagios) 27 28AC_DEFINE([DEFAULT_NAGIOS_USER], [nagios], [Default Nagios User]) 29AC_DEFINE([DEFAULT_NAGIOS_GROUP], [nagios], [Default Nagios Group]) 30 31PKG_NAME=ndoutils 32INIT_PROG=ndo2db 33PKG_VERSION="2.1.3" 34PKG_HOME_URL="http://www.nagios.org/" 35PKG_REL_DATE="2017-04-13" 36 37dnl Figure out how to invoke "install" and what install options to use. 38AC_PROG_INSTALL 39AC_SUBST(INSTALL) 40 41dnl Figure out how to invoke "perl" 42AC_PATH_PROG(PERL,perl) 43 44dnl What OS are we running? 45AC_CANONICAL_HOST 46 47dnl Checks for programs. 48AC_PROG_CC 49AC_PROG_MAKE_SET 50 51dnl Nagios O/S, Distribution, Startup, Paths, Files macros 52AC_NAGIOS_GET_OS 53AC_NAGIOS_GET_DISTRIB_TYPE 54AC_NAGIOS_GET_INIT 55AC_NAGIOS_GET_INETD 56AC_NAGIOS_GET_PATHS 57AC_NAGIOS_GET_FILES 58 59case $host_os in 60*bsd*|darwin*) 61 root_grp=wheel 62 ;; 63*) 64 root_grp=root 65 ;; 66esac 67 68dnl Checks for header files. 69AC_HEADER_STDC 70AC_HEADER_TIME 71AC_HEADER_SYS_WAIT 72AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h dlfcn.h errno.h fcntl.h float.h getopt.h grp.h inttypes.h limits.h ltdl.h math.h netdb.h netinet/in.h pthread.h pwd.h regex.h signal.h socket.h stdarg.h stdint.h string.h strings.h sys/ipc.h sys/mman.h sys/msg.h sys/poll.h sys/resource.h sys/sendfile.h sys/socket.h sys/stat.h sys/time.h sys/timeb.h sys/types.h sys/un.h sys/wait.h syslog.h tcpd.h unistd.h values.h) 73 74dnl Checks for typedefs, structures, and compiler characteristics. 75AC_C_CONST 76AC_STRUCT_TM 77AC_TYPE_MODE_T 78AC_TYPE_PID_T 79AC_TYPE_SIZE_T 80AC_TYPE_SIGNAL 81AC_TYPE_GETGROUPS 82 83dnl Check lengths for later tests of u_int32_t and int32_t 84AC_CHECK_SIZEOF(int) 85AC_CHECK_SIZEOF(short) 86AC_CHECK_SIZEOF(long) 87 88dnl Define u_int32_t if we don't have it already (Solaris, etc.) 89AC_CHECK_TYPE(uint32_t,unsigned int) 90AC_CHECK_TYPE(u_int32_t,unsigned int) 91if test "$ac_cv_type_u_int32_t" = no ; then 92 if test "$ac_cv_type_u_int32_t" = yes ; then 93 AC_DEFINE(U_INT32_T_IS_UINT32_T) 94 else 95 if test "$ac_cv_sizeof_int" = 4 ; then 96 AC_DEFINE(U_INT32_T_IS_UINT) 97 else 98 if test "$ac_cv_sizeof_long" = 4 ; then 99 AC_DEFINE(U_INT32_T_IS_ULONG) 100 else 101 if test "$ac_cv_sizeof_short" = 4 ; then 102 AC_DEFINE(U_INT32_T_IS_USHORT) 103 fi 104 fi 105 fi 106 fi 107fi 108 109dnl Define int32_t if we don't have it already 110AC_CHECK_TYPE(int32_t,int) 111if test "$ac_cv_type_int32_t" = no ; then 112 if test "$ac_cv_sizeof_int" = 4 ; then 113 AC_DEFINE(INT32_T_IS_UINT) 114 else 115 if test "$ac_cv_sizeof_long" = 4 ; then 116 AC_DEFINE(INT32_T_IS_ULONG) 117 else 118 if test "$ac_cv_sizeof_short" = 4 ; then 119 AC_DEFINE(INT32_T_IS_USHORT) 120 fi 121 fi 122 fi 123fi 124 125 126dnl Check for getopt_long (Solaris) 127# AC_CHECK_FUNCS([getopt_long],,AC_CHECK_LIB([iberty],[getopt_long],OTHERLIBS="$OTHERLIBS -liberty")) 128# AC_SUBST(OTHERLIBS) 129 130dnl Checks for library functions. 131AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl") 132AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket") 133AC_SUBST(SOCKETLIBS) 134AC_CHECK_LIB(wrap,main,[ 135 LIBWRAPLIBS="$LIBWRAPLIBS -lwrap" 136 AC_DEFINE(HAVE_LIBWRAP) 137 ]) 138AC_SUBST(LIBWRAPLIBS) 139AC_CHECK_FUNCS(getopt_long strdup strstr strtoul initgroups strtof nanosleep) 140 141dnl Check for asprintf() and friends... 142AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[ 143AC_TRY_LINK([#include <stdarg.h> 144va_list ap1,ap2;], [va_copy(ap1,ap2);], 145ac_cv_HAVE_VA_COPY=yes, 146ac_cv_HAVE_VA_COPY=no)]) 147if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then 148 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) 149else 150 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[ 151 AC_TRY_LINK([#include <stdarg.h> 152 va_list ap1,ap2;], [__va_copy(ap1,ap2);], 153 ac_cv_HAVE___VA_COPY=yes, 154 ac_cv_HAVE___VA_COPY=no)]) 155 if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then 156 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) 157 fi 158fi 159AC_SUBST(SNPRINTF_O) 160 161AC_CHECK_FUNC(snprintf,,SNPRINTF_O=./snprintf.o) 162AC_CHECK_FUNC(asprintf,,SNPRINTF_O=./snprintf.o) 163 164AC_MSG_CHECKING(for type of socket size) 165AC_TRY_COMPILE([#include <stdlib.h> 166#include <sys/types.h> 167#include <sys/socket.h> 168], 169[int a = send(1, (const void *)0, (size_t *) 0, (int *) 0);], 170[AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)], 171[AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)]) 172 173dnl Stolen from Python code: loewis@users.sourceforge.net 174dnl AC_CHECK_TYPE(socklen_t,int, 175dnl AC_DEFINE(socklen_t,int, 176dnl Define to `int' if <sys/socket.h> does not define.),[ 177dnl #ifdef HAVE_SYS_TYPES_H 178dnl #include <sys/types.h> 179dnl #endif 180dnl #ifdef HAVE_SYS_SOCKET_H 181dnl #include <sys/socket.h> 182dnl #endif 183dnl ]) 184 185dnl Check if SUN_LEN exists 186AC_TRY_LINK([ 187 #include<sys/types.h> 188 #include<sys/un.h>], 189 [struct sockaddr_un su; int i = SUN_LEN(&su);], 190 [AC_DEFINE(HAVE_SUN_LEN)], ) 191 192dnl Check for location of init scripts 193init_dir=/etc/rc.d/init.d 194if test -d /etc/rc.d/init.d; then 195 init_dir="/etc/rc.d/init.d" 196elif test -d /usr/local/etc/rc.d; then 197 init_dir="/usr/local/etc/rc.d" 198elif test -d /etc/rc.d; then 199 init_dir="/etc/rc.d" 200elif test -d /etc/init.d; then 201 init_dir="/etc/init.d" 202elif test -d /sbin/init.d; then 203 init_dir="/sbin/init.d" 204fi 205 206AC_ARG_WITH([ndo2db_port], 207 AS_HELP_STRING([--with-ndo2db-port=<port>], 208 [sets port number for NDO2DB to listen on]), 209 [ndo2db_port=$withval], 210 [ndo2db_port=5668]) 211AC_DEFINE_UNQUOTED(DEFAULT_SERVER_PORT,$ndo2db_port,[Default port for NDO2DB daemon]) 212AC_SUBST(ndo2db_port) 213 214dnl - Modified version from www.erlang.org 215dnl - Some 12/15/05 mods made after reading http://xaxxon.slackworks.com/phuku/dl.html 216AC_MSG_CHECKING(for linker flags for loadable modules) 217case $host_os in 218 solaris2*|sysv4*) 219 MOD_LDFLAGS="-G" 220 MOD_CFLAGS="-fPIC" 221 ;; 222 aix4*|aix5*) 223 #MOD_LDFLAGS="-G -bnoentry -bexpall" 224 MOD_LDFLAGS="-G -bM:SRE -bnoentry -bexpall" 225 ;; 226 freebsd2*) 227 # Non-ELF GNU linker 228 MOD_LDFLAGS="-Bshareable" 229 ;; 230 darwin*) 231 # Mach-O linker, a shared lib and a loadable 232 # object file is not the same thing. 233 MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress" 234 MOD_CFLAGS="$MOD_CFLAGS -fno-common" 235 ;; 236 linux* | k*bsd*-gnu*) 237 # assume GNU linker and ELF 238 MOD_LDFLAGS="-shared" 239 MOD_CFLAGS="-fPIC" 240 ;; 241 *) 242 # assume GNU linker and ELF 243 MOD_LDFLAGS="-shared" 244 ;; 245esac 246 247if test "$dist_type" = aix; then 248 MOD_LDFLAGS="$MOD_LDFLAGS -Wl,-berok" 249fi 250 251AC_MSG_RESULT([$MOD_LDFLAGS]) 252AC_SUBST(MOD_CFLAGS) 253AC_SUBST(MOD_LDFLAGS) 254 255 256dnl DB support options 257USE_MYSQL=yes 258AC_ARG_ENABLE(mysql,AC_HELP_STRING([--enable-mysql],[enables MySQL database support])) 259AS_IF([test x$enable_mysql = xno], [USE_MYSQL=no]) 260 261 262dnl Are we using any MySQL routines? 263if test $USE_MYSQL = yes; then 264 np_mysqlclient 265 if test $with_mysql = "no" ; then 266 echo "" 267 echo "" 268 echo "*** MySQL library could not be located... **************************" 269 echo "" 270 echo "You chose to compile NDOutils with MySQL support, but I was unable to" 271 echo "locate the MySQL library on your system. If the library is" 272 echo "installed, use the --with-mysql=DIR argument to specify the" 273 echo "location of the MySQL library, We assume mysql_config is in DIR/bin" 274 echo "NOTE: After you install the necessary libraries on your system:" 275 echo " 1. Make sure /etc/ld.so.conf has an entry for the directory in" 276 echo " which the MySQL libraries are installed." 277 echo " 2. Run 'ldconfig' to update the run-time linker options." 278 echo " 3. Run 'make devclean' in the NDBXT distribution to clean out" 279 echo " any old references to your previous compile." 280 echo " 4. Rerun the configure script." 281 echo "" 282 echo "TIP: Try the following...." 283 echo " ./configure --with-mysql=/usr/lib/mysql" 284 echo "" 285 echo "********************************************************************" 286 echo "" 287 echo "" 288 289 USE_MYSQL=no 290 else 291 echo "MySQL library and include file(s) were found!" 292 AC_DEFINE_UNQUOTED(USE_MYSQL) 293 DBLIBS="$DBLIBS $np_mysql_libs" 294 CFLAGS="$CFLAGS $np_mysql_include" 295 fi 296fi 297 298save_LDFLAGS="$LDFLAGS" 299LDFLAGS="${LDFLAGS} ${DBLDFLAGS}" 300save_CPPFLAGS="$CPPFLAGS" 301CPPFLAGS="${DBCFLAGS}" 302save_CFLAGS="$CFLAGS" 303CFLAGS="${DBCFLAGS}" 304 305 306AC_SUBST(DBCFLAGS) 307AC_SUBST(DBLDFLAGS) 308AC_SUBST(DBLIBS) 309 310LDFLAGS="$save_LDFLAGS" 311CPPFLAGS="$save_CPPFLAGS" 312CFLAGS="$save_CFLAGS" 313 314 315dnl Moving this before the Mysql detection options breaks them.... 316AC_ARG_WITH(ndo2db_user,AC_HELP_STRING([--with-ndo2db-user=<user>],[sets user name to run NDO2DB]),ndo2db_user=$withval,ndo2db_user=nagios) 317AC_ARG_WITH(ndo2db_group,AC_HELP_STRING([--with-ndo2db-group=<group>],[sets group name to run NDO2DB]),ndo2db_group=$withval,ndo2db_group=nagios) 318AC_SUBST(ndo2db_user) 319AC_SUBST(ndo2db_group) 320INSTALL_OPTS="-o $ndo2db_user -g $ndo2db_group" 321AC_SUBST(INSTALL_OPTS) 322 323 324dnl Does the user want to check for systemd? 325AC_ARG_ENABLE([systemd-sockets], 326 AC_HELP_STRING([--enable-systemd-sockets],[enables systemd socket activation]), 327 [],[enable_systemd_sockets=auto]) 328 329dnl Try to compile and link a program that checks for systemd sockets. 330if test x$enable_systemd_sockets != xno; then 331 have_systemd=no 332 333 AC_SEARCH_LIBS([sd_listen_fds],[systemd systemd-daemon], 334 AC_TRY_LINK([#include <systemd/sd-daemon.h>],[sd_listen_fds(0);],[have_systemd=yes])) 335 336 if test x$have_systemd = xyes; then 337 AC_DEFINE([HAVE_SYSTEMD]) 338 elif test x$enable_systemd_sockets = xyes; then 339 AC_MSG_ERROR([systemd was requested, but could not be found]) 340 fi 341fi 342 343 344dnl Does user want to check for SSL? 345AC_ARG_ENABLE(ssl,AC_HELP_STRING([--enable-ssl],[enables native SSL support]),[ 346 if test x$enableval = xyes; then 347 check_for_ssl=yes 348 else 349 check_for_ssl=no 350 fi 351 ],check_for_ssl=no) 352 353dnl Optional SSL library and include paths 354if test x$check_for_ssl = xyes; then 355 # need_dh should only be set for NRPE and NDOUTILS 356 need_dh=yes 357 AC_NAGIOS_GET_SSL 358fi 359 360 361if test x$HAVE_NANOSLEEP = x; then 362 USE_NANOSLEEP=no 363else 364 USE_NANOSLEEP=yes 365 AC_ARG_ENABLE(nanosleep,AC_HELP_STRING([--enable-nanosleep],[enables use of nanosleep (instead of sleep) in event timing])) 366 AS_IF([test x$enable_nanosleep = xno],[USE_NANOSLEEP=no],[USE_NANOSLEEP=yes]) 367 if test x$USE_NANOSLEEP = xyes ; then 368 AC_DEFINE_UNQUOTED(USE_NANOSLEEP) 369 fi 370fi 371 372AC_CONFIG_FILES([Makefile 373 src/Makefile 374 config/ndo2db.cfg-sample 375 config/ndomod.cfg-sample 376 config/nagios.cfg 377 config/misccommands.cfg 378 docs/docbook/en-en/Makefile 379 include/io.h 380 include/common.h 381 startup/bsd-init 382 startup/debian-init 383 startup/default-init 384 startup/default-inetd 385 startup/default-service 386 startup/default-socket 387 startup/default-socket-svc 388 startup/default-xinetd 389 startup/mac-init.plist 390 startup/mac-inetd.plist 391 startup/newbsd-init 392 startup/openbsd-init 393 startup/openrc-conf 394 startup/openrc-init 395 startup/solaris-init.xml 396 startup/solaris-inetd.xml 397 startup/tmpfile.conf 398 startup/upstart-init 399 startup/rh-upstart-init 400]) 401 402AC_OUTPUT() 403 404 405dnl Review options 406echo "" 407echo "" 408AC_MSG_RESULT([*** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:]) 409 410echo "" 411echo " General Options:" 412echo " -------------------------" 413 414AC_MSG_RESULT([ NDO2DB user: $ndo2db_user]) 415AC_MSG_RESULT([ NDO2DB group: $ndo2db_group]) 416AC_MSG_RESULT([ NDO2DB tcp port: $ndo2db_port]) 417 418 419echo "";\ 420echo "";\ 421echo "Review the options above for accuracy. If they look";\ 422echo "okay, type 'make all' to compile the NDO utilities,";\ 423echo "or type 'make' to get a list of make options.";\ 424echo "" 425