1dnl Process this -*-m4-*- file with autoconf to produce a configure script. 2 3dnl Disable caching 4define([AC_CACHE_LOAD],) 5define([AC_CACHE_SAVE],) 6 7AC_INIT(base/nagios.c) 8AC_CONFIG_HEADER(include/config.h include/snprintf.h) 9AC_PREFIX_DEFAULT(/usr/local/nagios) 10 11PKG_NAME=nagios 12PKG_VERSION="3.5.1" 13PKG_HOME_URL="http://www.nagios.org/" 14PKG_REL_DATE="08-30-2013" 15 16dnl Figure out how to invoke "install" and what install options to use. 17AC_PROG_INSTALL 18AC_SUBST(INSTALL) 19 20dnl What OS are we running? 21AC_CANONICAL_HOST 22 23dnl Checks for programs. 24AC_PROG_CC 25AC_PROG_MAKE_SET 26AC_PATH_PROG([STRIP],[strip],[true]) 27 28dnl Checks for header files. 29AC_HEADER_STDC 30AC_HEADER_TIME 31AC_HEADER_SYS_WAIT 32AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h errno.h fcntl.h getopt.h grp.h libgen.h limits.h math.h netdb.h netinet/in.h pthread.h pthreads.h pwd.h regex.h signal.h socket.h stdarg.h string.h strings.h sys/mman.h sys/types.h sys/time.h sys/resource.h sys/wait.h sys/socket.h sys/stat.h sys/timeb.h sys/un.h sys/ipc.h sys/msg.h sys/poll.h syslog.h uio.h unistd.h locale.h wchar.h) 33 34dnl Checks for typedefs, structures, and compiler characteristics. 35AC_C_CONST 36AC_STRUCT_TM 37AC_STRUCT_TIMEZONE 38AC_TYPE_MODE_T 39AC_TYPE_PID_T 40AC_TYPE_SIZE_T 41AC_TYPE_SIGNAL 42AC_TYPE_GETGROUPS 43 44 45dnl Check for asprintf() and friends... 46AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[ 47AC_TRY_LINK([#include <stdarg.h> 48va_list ap1,ap2;], [va_copy(ap1,ap2);], 49ac_cv_HAVE_VA_COPY=yes, 50ac_cv_HAVE_VA_COPY=no)]) 51if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then 52 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) 53else 54 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[ 55 AC_TRY_LINK([#include <stdarg.h> 56 va_list ap1,ap2;], [__va_copy(ap1,ap2);], 57 ac_cv_HAVE___VA_COPY=yes, 58 ac_cv_HAVE___VA_COPY=no)]) 59 if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then 60 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) 61 fi 62fi 63 64AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=../common/snprintf.o) 65AC_CHECK_FUNC(snprintf,,SNPRINTF_O=../common/snprintf.o) 66AC_CHECK_FUNC(asprintf,,SNPRINTF_O=../common/snprintf.o) 67AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=../common/snprintf.o) 68 69AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[ 70AC_TRY_RUN([ 71#include <sys/types.h> 72#include <stdarg.h> 73void foo(const char *format, ...) { 74 va_list ap; 75 int len; 76 char buf[5]; 77 78 va_start(ap, format); 79 len = vsnprintf(buf, 0, format, ap); 80 va_end(ap); 81 if (len != 5) exit(1); 82 83 va_start(ap, format); 84 len = vsnprintf(0, 0, format, ap); 85 va_end(ap); 86 if (len != 5) exit(1); 87 88 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); 89 90 exit(0); 91} 92main() { foo("hello"); } 93], 94ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)]) 95if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then 96 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf]) 97fi 98 99dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=../common/snprintf.o) 100AC_SUBST(SNPRINTF_O) 101 102 103dnl Checks for library functions. 104AC_SEARCH_LIBS([getservbyname],[nsl], 105 [if test "$ac_cv_search_getservbyname" != "none required"; then 106 SOCKETLIBS="$SOCKETLIBS -lnsl" 107 fi]) 108AC_SEARCH_LIBS([connect],[socket], 109 [if test "$ac_cv_search_connect" != "none required"; then 110 SOCKETLIBS="$SOCKETLIBS -lsocket" 111 fi]) 112AC_SUBST(SOCKETLIBS) 113AC_CHECK_FUNCS(initgroups setenv strdup strstr strtoul unsetenv) 114 115AC_MSG_CHECKING(for type of socket size) 116AC_TRY_COMPILE([#include <stdlib.h> 117#include <sys/types.h> 118#include <sys/socket.h> 119], 120[int a = send(1, (const void *) 0, (size_t) 0, (int) 0);], 121[AC_DEFINE(SOCKET_SIZE_TYPE, size_t, [typedef for socket size]) AC_MSG_RESULT(size_t)], 122[AC_DEFINE(SOCKET_SIZE_TYPE, int, [typedef for socket size]) AC_MSG_RESULT(int)]) 123 124 125dnl Test for pthreads support - taken from ICU FreeBSD Port configure script 126THREADLIBS="" 127have_pthreads="no" 128 129dnl FreeBSD: Try ports/linuxthreads first - Mammad Zadeh <mammad@yahoo-inc.com> 130dnl FreeBSD -pthread check - Jonathan McDowell <noodles@earth.li> 131AC_DEFUN([AC_PTHREAD_FREEBSD],[ 132 AC_CHECK_LIB(lthread,pthread_create,[ 133 CFLAGS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -I/usr/include $CFLAGS" 134 THREADLIBS="-L/usr/local/lib -llthread -llgcc_r" 135 ],[ 136 AC_MSG_CHECKING([if we need -pthread for threads]) 137 AC_CACHE_VAL(ac_ldflag_pthread,[ 138 ac_save_LDFLAGS="$LDFLAGS" 139 LDFLAGS="-pthread $LDFLAGS" 140 AC_TRY_LINK([ 141 char pthread_create(); 142 ], 143 pthread_create();, 144 eval "ac_ldflag_pthread=yes", 145 eval "ac_ldflag_pthread=no" 146 ), 147 THREADLIBS="$ac_save_LDFLAGS" 148 ]) 149 if eval "test \"`echo $ac_ldflag_pthread`\" = yes"; then 150 AC_MSG_RESULT(yes) 151 else 152 AC_MSG_RESULT(no) 153 fi 154 ],-L/usr/local/lib) 155 ]) 156 157dnl Test for HPUX cma threads first.. 158AC_CHECK_LIB(cma,pthread_create,THREADLIBS="$THREADLIBS -lpthread") 159if test $ac_cv_lib_cma_pthread_create = yes; then 160 have_pthreads="yes" 161fi 162 163dnl special pthread handling 164dnl AIX uses pthreads instead of pthread, and HP/UX uses cma 165dnl FreeBSD users -pthread 166AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="$THREADLIBS -lpthread") 167if test $ac_cv_lib_pthread_pthread_create = yes; then 168 have_pthreads="yes" 169else 170 dnl For HP 11 171 AC_CHECK_LIB(pthread,pthread_mutex_init,THREADLIBS="$THREADLIBS -lpthread") 172 if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then 173 have_pthreads="yes" 174 fi 175fi 176 177dnl AIX uses pthreads instead of pthread 178if test $have_pthreads = "no"; then 179 AC_CHECK_LIB(pthreads,pthread_create,THREADLIBS="$THREADLIBS -lpthreads") 180 if test $ac_cv_lib_pthreads_pthread_create = yes; then 181 have_pthreads="yes" 182 fi 183fi 184 185dnl all other thread tests fail, try BSD's -pthread 186if test $have_pthreads = "no"; then 187 AC_PTHREAD_FREEBSD 188fi 189 190AC_SUBST(THREADLIBS) 191 192dnl Solaris needs rt or posix4 libraries for nanosleep() 193AC_SEARCH_LIBS(nanosleep,[rt posix4],,[ 194 echo "Error: nanosleep() needed for timing operations." 195 exit 1 196 ]) 197 198AC_ARG_WITH(nagios_user,AC_HELP_STRING([--with-nagios-user=<user>],[sets user name to run nagios]),nagios_user=$withval,nagios_user=nagios) 199AC_ARG_WITH(nagios_group,AC_HELP_STRING([--with-nagios-group=<grp>],[sets group name to run nagios]),nagios_grp=$withval,nagios_grp=nagios) 200AC_SUBST(nagios_user) 201AC_SUBST(nagios_grp) 202AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_USER,"$nagios_user",[user name to run nagios]) 203AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_GROUP,"$nagios_grp",[group name to run nagios]) 204INSTALL_OPTS="-o $nagios_user -g $nagios_grp" 205AC_SUBST(INSTALL_OPTS) 206 207AC_ARG_WITH(command_user,AC_HELP_STRING([--with-command-user=<user>],[sets user name for command access]),command_user=$withval,command_user=$nagios_user) 208AC_ARG_WITH(command_group,AC_HELP_STRING([--with-command-group=<grp>],[sets group name for command access]),command_grp=$withval,command_grp=$nagios_grp) 209AC_SUBST(command_user) 210AC_SUBST(command_grp) 211COMMAND_OPTS="-o $command_user -g $command_grp" 212AC_SUBST(COMMAND_OPTS) 213 214dnl Check for location of mail program 215MAIL_PROG=no 216AC_ARG_WITH(mail,--with-mail=<path_to_mail> sets path to equivalent program to mail,MAIL_PROG=$withval,MAIL_PROG=no) 217if test x$MAIL_PROG = xno; then 218 AC_PATH_PROG(MAIL_PROG,mail) 219fi 220dnl Fix for systems that don't (yet) have mail/mailx installed... 221if test x$MAIL_PROG = x; then 222 MAIL_PROG="/bin/mail" 223fi 224AC_SUBST(MAIL_PROG) 225 226dnl Check for location of Apache conf.d directory 227HTTP_CONF=no 228AC_ARG_WITH(httpd_conf,--with-httpd-conf=<path_to_conf> sets path to Apache conf.d directory,HTTPD_CONF=$withval,HTTPD_CONF=no) 229if test x$HTTPD_CONF = xno; then 230 if test -d /etc/httpd/conf.d; then 231 HTTPD_CONF="/etc/httpd/conf.d" 232 elif test -d /etc/apache2/conf.d; then 233 HTTPD_CONF="/etc/apache2/conf.d" 234 elif test -d /etc/apache/conf.d; then 235 HTTPD_CONF="/etc/apache/conf.d" 236 else 237 HTTPD_CONF="/etc/httpd/conf.d" 238 fi 239fi 240AC_SUBST(HTTPD_CONF) 241 242dnl Location of check result path 243CHECKRESULTDIR=no 244AC_ARG_WITH(checkresult-dir,--with-checkresult-dir=<path> sets path to check results spool directory,CHECKRESULTDIR=$withval,CHECKRESULTDIR=no) 245if test x$CHECKRESULTDIR = xno; then 246 CHECKRESULTDIR="$localstatedir/spool/checkresults" 247fi 248AC_SUBST(CHECKRESULTDIR) 249 250dnl Location of check result path 251TMPDIR=no 252AC_ARG_WITH(temp-dir,--with-temp-dir=<path> sets path to temp directory,TMPDIR=$withval,TMPDIR=no) 253if test x$TMPDIR = xno; then 254 TMPDIR="/tmp" 255fi 256AC_SUBST(TMPDIR) 257 258dnl Check for location of init scripts 259init_dir=/etc/rc.d/init.d 260if test -d /etc/rc.d/init.d; then 261 init_dir="/etc/rc.d/init.d" 262elif test -d /usr/local/etc/rc.d; then 263 init_dir="/usr/local/etc/rc.d" 264elif test -d /etc/rc.d; then 265 init_dir="/etc/rc.d" 266elif test -d /etc/init.d; then 267 init_dir="/etc/init.d" 268elif test -d /sbin/init.d; then 269 init_dir="/sbin/init.d" 270fi 271 272dnl User can override init script location 273AC_ARG_WITH(init_dir,--with-init-dir=<path> sets directory to place init script into,init_dir=$withval) 274AC_SUBST(init_dir) 275 276dnl User can override lock file location 277AC_ARG_WITH(lockfile,--with-lockfile=<path> sets path and file name for lock file,lockfile=$withval,lockfile=$localstatedir/nagios.lock) 278AC_SUBST(lockfile) 279 280 281 282dnl Default xdata routines... 283XSDTYPE=default 284XCDTYPE=default 285XRDTYPE=default 286XODTYPE=template 287XPDTYPE=default 288XDDTYPE=default 289 290XSDCOMMENT= 291XCDCOMMENT= 292XRDCOMMENT= 293XODCOMMENT= 294XPDCOMMENT= 295XDDCOMMENT= 296 297USE_MYSQL=no 298USE_PGSQL=no 299 300dnl Status data 301AC_DEFINE_UNQUOTED(USE_XSDDEFAULT,,[use default routines (in xdata/xsddefault.*) for status data I/O...]) 302XSDC="xsddefault.c" 303XSDH="xsddefault.h" 304XSDCOMMENT="Default (text file)" 305echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..." 306AC_SUBST(XSDC) 307AC_SUBST(XSDH) 308 309 310dnl Comment data 311AC_DEFINE_UNQUOTED(USE_XCDDEFAULT,,[use default routines (in xdata/xcddefault.*) for comment data I/O...]) 312XCDC="xcddefault.c" 313XCDH="xcddefault.h" 314XCDCOMMENT="Default (text file)" 315echo "We'll use default routines (in xdata/xcddefault.*) for comment data I/O..." 316AC_SUBST(XCDC) 317AC_SUBST(XCDH) 318 319 320dnl Retention data 321AC_DEFINE_UNQUOTED(USE_XRDDEFAULT,,[use default routines (in xdata/xrddefault.*) for retention data I/O...]) 322XRDC="xrddefault.c" 323XRDH="xrddefault.h" 324XRDCOMMENT="Default (text file)" 325echo "We'll use default routines (in xdata/xrddefault.*) for retention data I/O..." 326AC_SUBST(XRDC) 327AC_SUBST(XRDH) 328 329 330dnl Object data 331AC_DEFINE_UNQUOTED(USE_XODTEMPLATE,,[use template-based routines (in xdata/xodtemplate.*) for object data I/O...]) 332XODC="xodtemplate.c" 333XODH="xodtemplate.h" 334XODCOMMENT="Template-based (text file)" 335echo "We'll use template-based routines (in xdata/xodtemplate.*) for object data I/O..." 336AC_SUBST(XODC) 337AC_SUBST(XODH) 338 339 340 341dnl Performance data 342AC_DEFINE_UNQUOTED(USE_XPDDEFAULT,,[use default routines (in xdata/xpddefault.*) for performance data I/O...]) 343XPDC="xpddefault.c" 344XPDH="xpddefault.h" 345XPDCOMMENT="Default (external commands)" 346echo "We'll use default routines (in xdata/xpddefault.*) for performance data I/O..." 347AC_SUBST(XPDC) 348AC_SUBST(XPDH) 349 350 351dnl Downtime data 352AC_DEFINE_UNQUOTED(USE_XDDDEFAULT,,[use default routines (in xdata/xdddefault.*) for scheduled downtime data I/O...]) 353XDDC="xdddefault.c" 354XDDH="xdddefault.h" 355XDDCOMMENT="Default (text file)" 356echo "We'll use default routines (in xdata/xdddefault.*) for scheduled downtime data I/O..." 357AC_SUBST(XDDC) 358AC_SUBST(XDDH) 359 360 361dnl Optional GD library and include paths 362AC_ARG_WITH(gd-lib,--with-gd-lib=DIR sets location of the gd library,[ 363 LDFLAGS="${LDFLAGS} -L${withval}" 364 LD_RUN_PATH="${withval}${LD_RUN_PATH:+:}${LD_RUN_PATH}" 365 ]) 366AC_ARG_WITH(gd-inc,--with-gd-inc=DIR sets location of the gd include files,[ 367 CFLAGS="${CFLAGS} -I${withval}" 368 ]) 369 370 371TRYGD=yep 372 373dnl statusmap CGI enabled by default, unless users chooses not to use it 374TRYSTATUSMAP=yep 375AC_ARG_ENABLE(statusmap,--disable-statusmap=disables compilation of statusmap CGI,TRYSTATUSMAP=nope) 376 377 378dnl statuswrl CGI enabled by default, unless users chooses not to use it 379TRYSTATUSWRL=yep 380AC_ARG_ENABLE(statuswrl,--disable-statuswrl=disables compilation of statuswrl (VRML) CGI,TRYSTATUSWRL=nope) 381 382if test x$TRYSTATUSWRL = xyep; then 383 AC_DEFINE_UNQUOTED(USE_STATUSWRL,,[statuswrl CGI enabled by default, unless users chooses not to use it]) 384 CGIEXTRAS="$CGIEXTRAS statuswrl.cgi" 385fi 386 387 388dnl JMD_CHECK_LIB_ORDER(LIBRARY, FUNCTION, ORDER [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND 389dnl [, OTHER-LIBRARIES]]]) 390 AC_DEFUN([JMD_CHECK_LIB_ORDER], 391 [AC_MSG_CHECKING([for $2 in -l$1 (order $3)]) 392 dnl Use a cache variable name containing both the library and function name, 393 dnl because the test really is for library $1 defining function $2, not 394 dnl just for library $1. Separate tests with the same $1 and different $2s 395 dnl may have different results. 396 ac_lib_var=`echo $1['_']$2['_']$3 | sed 'y%./+-%__p_%'` 397 AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, 398 [ac_save_LIBS="$LIBS" 399 LIBS="-l$1 $6 $LIBS" 400 AC_TRY_LINK(dnl 401 ifelse([AC_LANG], [FORTRAN77], , 402 ifelse([$2], [main], , dnl Avoid conflicting decl of main. 403[/* Override any gcc2 internal prototype to avoid an error. */ 404]ifelse([AC_LANG], CPLUSPLUS, [#ifdef __cplusplus 405extern "C" 406#endif 407])dnl 408[/* We use char because int might match the return type of a gcc2 409 builtin and then its argument prototype would still apply. */ 410char $2(); 411])), 412 [$2()], 413 eval "ac_cv_lib_$ac_lib_var=yes", 414 eval "ac_cv_lib_$ac_lib_var=no") 415 LIBS="$ac_save_LIBS" 416 ])dnl 417 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then 418 AC_MSG_RESULT(yes) 419 ifelse([$4], , 420 [changequote(, )dnl 421 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ 422 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` 423 changequote([, ])dnl 424 AC_DEFINE_UNQUOTED($ac_tr_lib) 425 LIBS="-l$1 $LIBS" 426 ], [$4]) 427 else 428 AC_MSG_RESULT(no) 429 ifelse([$5], , , [$5 430 ])dnl 431 fi 432 ]) 433 434 435 436dnl Should we try and detect the GD libs? 437if test x$TRYGD = xyep; then 438 439 dnl libiconv is required on some systems - tack it on if found 440 AC_CHECK_LIB(iconv,main,ICONV=-liconv,) 441 442 dnl See if the GD lib is available and supports PNG images... 443 444 dnl GD > 1.8.3 requires the TrueType library to be present as well, so test for that first... 445 JMD_CHECK_LIB_ORDER(gd,gdImagePng,1,[ 446 GDLIBFOUND=yep 447 GDLIBS="-lgd -lttf -lpng -ljpeg -lz -lm" 448 ],:,[-lttf -lpng -ljpeg -lz -lm]) 449 450 dnl GD > 1.8.1 requires the jpeg library to be present as well, so test for that... 451 if test x$GDLIBFOUND = x; then 452 JMD_CHECK_LIB_ORDER(gd,gdImagePng,2,[ 453 GDLIBFOUND=yep 454 GDLIBS="-lgd $ICONV -lpng -ljpeg -lz -lm" 455 ],:,[$ICONV -lpng -ljpeg -lz -lm]) 456 fi 457 458 dnl If we failed the first test, try without jpeg library 459 if test x$GDLIBFOUND = x; then 460 JMD_CHECK_LIB_ORDER(gd,gdImagePng,3,[ 461 GDLIBFOUND=yep 462 GDLIBS="-lgd $ICONV -lz -lm -lpng" 463 ],:,[$ICONV -lz -lm -lpng]) 464 fi 465 466 dnl We failed again, so try a different library ordering (without jpeg libs) 467 if test x$GDLIBFOUND = x; then 468 JMD_CHECK_LIB_ORDER(gd,gdImagePng,4,[ 469 GDLIBFOUND=yep 470 GDLIBS="-lgd $ICONV -lpng -lz -lm" 471 ],:,[$ICONV -lpng -lz -lm]) 472 fi 473 474 dnl Did we find the necessary GD libraries? 475 if test x$GDLIBFOUND = x; then 476 echo "" 477 echo "" 478 echo "*** GD, PNG, and/or JPEG libraries could not be located... *********" 479 echo "" 480 echo "Boutell's GD library is required to compile the statusmap, trends" 481 echo "and histogram CGIs. Get it from http://www.boutell.com/gd/, compile" 482 echo "it, and use the --with-gd-lib and --with-gd-inc arguments to specify" 483 echo "the locations of the GD library and include files." 484 echo "" 485 echo "NOTE: In addition to the gd-devel library, you'll also need to make" 486 echo " sure you have the png-devel and jpeg-devel libraries installed" 487 echo " on your system." 488 echo "" 489 echo "NOTE: After you install the necessary libraries on your system:" 490 echo " 1. Make sure /etc/ld.so.conf has an entry for the directory in" 491 echo " which the GD, PNG, and JPEG libraries are installed." 492 echo " 2. Run 'ldconfig' to update the run-time linker options." 493 echo " 3. Run 'make clean' in the Nagios distribution to clean out" 494 echo " any old references to your previous compile." 495 echo " 4. Rerun the configure script." 496 echo "" 497 echo "NOTE: If you can't get the configure script to recognize the GD libs" 498 echo " on your system, get over it and move on to other things. The" 499 echo " CGIs that use the GD libs are just a small part of the entire" 500 echo " Nagios package. Get everything else working first and then" 501 echo " revisit the problem. Make sure to check the nagios-users" 502 echo " mailing list archives for possible solutions to GD library" 503 echo " problems when you resume your troubleshooting." 504 echo "" 505 echo "********************************************************************" 506 echo "" 507 echo "" 508 509 dnl We found the GD lib! 510 else 511 echo "GD library was found!" 512 if test x$TRYSTATUSMAP = xyep; then 513 AC_DEFINE_UNQUOTED(USE_STATUSMAP,,[defined if the user chose to include status map]) 514 CGIEXTRAS="$CGIEXTRAS statusmap.cgi" 515 AC_CHECK_LIB(gd,gdImageCreateTrueColor, 516 AC_DEFINE(HAVE_GDIMAGECREATETRUECOLOR,1, 517 [Define if your gd library has gdImageCreateTrueColor])) 518 fi 519 520 dnl compile trends CGI 521 AC_DEFINE_UNQUOTED(USE_TRENDS,,[compile trends CGI]) 522 CGIEXTRAS="$CGIEXTRAS trends.cgi" 523 524 dnl compile histogram CGI 525 AC_DEFINE_UNQUOTED(USE_HISTOGRAM,,[compile histogram CGI]) 526 CGIEXTRAS="$CGIEXTRAS histogram.cgi" 527 fi 528fi 529 530AC_ARG_WITH(cgiurl,--with-cgiurl=<local-url> sets URL for cgi programs (do not use a trailing slash),cgiurl=$withval,cgiurl=/nagios/cgi-bin) 531AC_ARG_WITH(htmurl,--with-htmurl=<local-url> sets URL for public html,htmurl=$withval,htmurl=/nagios) 532AC_SUBST(htmurl) 533AC_SUBST(cgiurl) 534 535USE_NANOSLEEP=yes 536AC_ARG_ENABLE(nanosleep,--enable-nanosleep enables use of nanosleep (instead of sleep) in event timing,USE_NANOSLEEP=$enableval,USE_NANOSLEEP=yes) 537if test x$USE_NANOSLEEP = xyes; then 538 AC_DEFINE_UNQUOTED(USE_NANOSLEEP,,[enables use of nanosleep (instead of sleep)]) 539fi 540 541USE_EVENTBROKER=yes 542AC_ARG_ENABLE(event-broker,--enable-event-broker enables integration of event broker routines,USE_EVENTBROKER=$enableval,USE_EVENTBROKER=yes) 543 544BROKER_LDFLAGS="" 545BROKERLIBS=""; 546some_dl_found="no"; 547if test x$USE_EVENTBROKER = xyes; then 548 549 dnl Which loader library should we use? libtdl or dl? 550 dnl Hopefully this will be portable and not give us headaches... 551 AC_CHECK_HEADER(ltdl.h,[ 552 AC_CHECK_LIB(ltdl,lt_dlinit,[ 553 AC_DEFINE(HAVE_LTDL_H,,[Which loader library should we use? libtdl or dl?]) 554 some_dl_found="yes" 555 BROKERLIBS="$BROKERLIBS -lltdl" 556 ]) 557 ]) 558 if test "x$some_dl_found" != xyes; then 559 AC_CHECK_HEADER(dlfcn.h,[ 560 AC_CHECK_LIB(dl,dlopen,[ 561 AC_DEFINE(HAVE_DLFCN_H,,[Which loader library should we use? libtdl or dl?]) 562 some_dl_found="yes" 563 BROKERLIBS="$BROKERLIBS -ldl" 564 ]) 565 ]) 566 fi 567 568 dnl - Modified from www.erlang.org 569 # Check how to export functions from the broker executable, needed 570 # when dynamically loaded drivers are loaded (so that they can find 571 # broker functions). 572 # OS'es with ELF executables using the GNU linker (Linux and recent *BSD, 573 # in rare cases Solaris) typically need '-Wl,-export-dynamic' (i.e. pass 574 # -export-dynamic to the linker - also known as -rdynamic and some other 575 # variants); some sysVr4 system(s) instead need(s) '-Wl,-Bexport'. 576 # AIX 4.x (perhaps only for x>=2) wants -Wl,-bexpall,-brtl and doesn't 577 # reliably return an error for others, thus we separate it out. 578 # Otherwise we assume that if the linker accepts the flag, it is needed. 579 AC_MSG_CHECKING(for extra flags needed to export symbols) 580 case $host_os in 581 aix4*|aix5*) 582 BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-bexpall,-brtl" 583 ;; 584 bsdi*) 585 BROKER_LDFLAGS="$BROKER_LDFLAGS -rdynamic" 586 ;; 587 *) 588 save_ldflags="$LDFLAGS" 589 LDFLAGS=-Wl,-export-dynamic 590 AC_TRY_LINK(,,[BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-export-dynamic"], [ 591 LDFLAGS=-Wl,-Bexport 592 AC_TRY_LINK(,,[BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-Bexport"], 593 AC_MSG_RESULT(none))]) 594 LDFLAGS="$save_ldflags" 595 ;; 596 esac 597 AC_SUBST(BROKER_LDFLAGS) 598 AC_SUBST(BROKERLIBS) 599 test "x$BROKER_LDFLAGS" != x && AC_MSG_RESULT([$BROKER_LDFLAGS]) 600 601 602 dnl - Modified version from www.erlang.org 603 dnl - Some 12/15/05 mods made after reading http://xaxxon.slackworks.com/phuku/dl.html 604 AC_MSG_CHECKING(for linker flags for loadable modules) 605 case $host_os in 606 solaris2*|sysv4*) 607 MOD_LDFLAGS="-G" 608 ;; 609 aix4*|aix5*) 610 #MOD_LDFLAGS="-G -bnoentry -bexpall" 611 MOD_LDFLAGS="-G -bM:SRE -bnoentry -bexpall" 612 ;; 613 freebsd2*) 614 # Non-ELF GNU linker 615 MOD_LDFLAGS="-Bshareable" 616 ;; 617 darwin*) 618 # Mach-O linker, a shared lib and a loadable 619 # object file is not the same thing. 620 MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress" 621 MOD_CFLAGS="$MOD_CFLAGS -fno-common" 622 ;; 623 linux* | k*bsd*-gnu*) 624 # assume GNU linker and ELF 625 MOD_LDFLAGS="-shared" 626 MOD_CFLAGS="-fPIC" 627 ;; 628 freebsd*) 629 MOD_LDFLAGS="-shared" 630 MOD_CFLAGS="-fPIC" 631 ;; 632 *) 633 # assume GNU linker and ELF 634 MOD_LDFLAGS="-shared" 635 ;; 636 esac 637 AC_MSG_RESULT([$MOD_LDFLAGS]) 638 AC_SUBST(MOD_CFLAGS) 639 AC_SUBST(MOD_LDFLAGS) 640 641 642 AC_DEFINE_UNQUOTED(USE_EVENT_BROKER,,[defined to bring in the event broker objects]) 643 BROKER_O="broker.o nebmods.o" 644 AC_SUBST(BROKER_O) 645 BROKER_H="../include/broker.h ../include/nebmods.h ../include/nebmodules.h ../include/nebcallbacks.h ../include/neberrors.h" 646 AC_SUBST(BROKER_H) 647fi 648 649 650USEPERL=no; 651INSTALLPERLSTUFF=no; 652AC_ARG_ENABLE(embedded-perl,--enable-embedded-perl will enable embedded Perl interpreter,[ 653 USEPERL=$enableval 654 ] 655 ,USEPERL=no) 656 657PERLCACHE=yes; 658AC_ARG_WITH(perlcache,--with-perlcache turns on cacheing of internally compiled Perl scripts,[ 659 PERLCACHE=$withval 660 ] 661 ,[ 662 AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl]) 663 PERLCACHE=yes; 664 ]) 665 666dnl Is embedded Perl being compiled in? 667if test x$USEPERL = xyes; then 668 669 AC_DEFINE_UNQUOTED(EMBEDDEDPERL,,[Is embedded Perl being compiled in?]) 670 PERLLIBS="`perl -MExtUtils::Embed -e ldopts`" 671 PERLDIR="`perl -MConfig -e 'print $Config{installsitearch}'`" 672 CFLAGS="${CFLAGS} `perl -MExtUtils::Embed -e ccopts`" 673 USEPERL=yes 674 INSTALLPERLSTUFF=yes; 675 PERLXSI_O=perlxsi.o 676 OBJS="${OBJS} ${PERLXSI_O}" 677 echo "creating base/perlxsi.c" 678 perl -MExtUtils::Embed -e xsinit -- -o base/perlxsi.c 679 680 echo "Embedded Perl interpreter will be compiled in..." 681 682 dnl Is caching enabled? 683 if test x$PERLCACHE = xyes; then 684 AC_DEFINE(DO_CLEAN,"0",[whether to clean cached compiled perl]) 685 PERLCACHE=yes; 686 echo "Internally compiled Perl scripts will be cached..." 687 else 688 AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl]) 689 echo "Internally compiled Perl scripts will NOT be cached..." 690 fi 691fi 692 693dnl Test if we're using threaded Perl (patch by Chip Ach) 694if test x$USEPERL = xyes; then 695 if (perl -e 'use Config;exit -1 unless ($Config{'usethreads'});'); then 696 echo "Using threaded perl" 697 AC_DEFINE_UNQUOTED(THREADEDPERL,,[defined if we're using threaded Perl]) 698 fi 699fi 700 701 702dnl Option for compiling under CYGWIN 703nagios_name=nagios 704nagiostats_name=nagiostats 705cygwin=no 706AC_ARG_ENABLE(cygwin,--enable-cygwin enables building under the CYGWIN environment,[ 707 cygwin=$enableval 708 ]) 709if test x$cygwin = xyes; then 710 CFLAGS="${CFLAGS} -DCYGWIN" 711 nagios_name=nagios.exe; 712 nagiostats_name=nagiostats.exe; 713fi 714AC_SUBST(nagios_name) 715AC_SUBST(nagiostats_name) 716 717 718dnl Should predictive failure routines be compiled in? 719dnl AC_ARG_ENABLE(failure-prediction,--enable-failure-prediction will enable integration with failure prediction module (NOT HERE YET!),[ 720dnl AC_DEFINE_UNQUOTED(PREDICT_FAILURES) 721dnl BASEEXTRALIBS="$BASEEXTRALIBS \$(FDATALIBS)" 722dnl echo "Failure prediction routines (incomplete!) will be compiled in..." 723dnl ]) 724 725dnl Find traceroute 726AC_PATH_PROG(PATH_TO_TRACEROUTE,traceroute) 727AC_DEFINE_UNQUOTED(TRACEROUTE_COMMAND,"$PATH_TO_TRACEROUTE",[traceroute command to use]) 728 729 730 731dnl Package directory for Solaris pkgmk (and other OSs, eventually) 732dnl VERSION=`grep 1.0 include/common.h | cut -d ' ' -f 3 | sed 's/"//g'` 733VERSION=$PKG_VERSION 734PACKDIR=`pwd`/pkg 735AC_SUBST(PACKDIR) 736AC_SUBST(VERSION) 737 738AC_MSG_CHECKING(for type va_list) 739AC_TRY_COMPILE([#ifdef __STDC__ 740#include <stdio.h> 741#include <stdlib.h> 742#include <stdarg.h> 743#else 744#include <sys/types.h> 745#include <stdio.h> 746#include <varargs.h> 747#endif], 748[va_list args;], 749[AC_MSG_RESULT(yes)], 750[AC_DEFINE(NEED_VA_LIST,,[defined if va_list fails to compile]) AC_MSG_RESULT(no)]) 751 752dnl Check if we should build local libtap 753dnl From Nagios Plugins 754dnl Have disabled autodetection of system library until later 755AC_ARG_ENABLE(libtap, 756 AC_HELP_STRING([--enable-libtap], 757 [Enable built-in libtap for unit-testing (default: no).]), 758 [enable_libtap=$enableval], 759 [enable_libtap=no]) 760#Disabled for moment 761#AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"]) 762 763# Disabled for moment 764# If not local, check if we can use the system one 765#if test "$enable_libtap" != "yes" ; then 766# dnl Check for libtap, to run perl-like tests 767# AC_CHECK_LIB(tap, plan_tests, 768# enable_libtap="yes" 769# ) 770#fi 771 772# Finally, define tests if we use libtap 773if test "$enable_libtap" = "yes" ; then 774 AC_CONFIG_SUBDIRS([tap]) 775 USE_LIBTAP=yes 776else 777 USE_LIBTAP=no 778fi 779 780 781AC_SUBST(USE_LIBTAP) 782AC_SUBST(CGIEXTRAS) 783AC_SUBST(GDLIBS) 784AC_SUBST(PERLLIBS) 785AC_SUBST(PERLDIR) 786AC_SUBST(PERLXSI_O) 787AC_SUBST(BASEEXTRALIBS) 788AC_SUBST(INITDIR) 789AC_SUBST(INSTALLPERLSTUFF) 790AC_SUBST(USE_EVENTBROKER) 791 792AC_PATH_PROG(PERL,perl) 793 794AC_OUTPUT(Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile xdata/Makefile daemon-init t/Makefile t-tap/Makefile) 795 796 797perl subst include/locations.h 798perl subst html/config.inc.php 799 800 801echo "" 802echo "Creating sample config files in sample-config/ ..." 803 804perl subst sample-config/nagios.cfg 805perl subst sample-config/cgi.cfg 806perl subst sample-config/resource.cfg 807perl subst sample-config/httpd.conf 808perl subst sample-config/mrtg.cfg 809 810perl subst sample-config/template-object/templates.cfg 811perl subst sample-config/template-object/commands.cfg 812perl subst sample-config/template-object/timeperiods.cfg 813perl subst sample-config/template-object/contacts.cfg 814 815perl subst sample-config/template-object/localhost.cfg 816perl subst sample-config/template-object/windows.cfg 817perl subst sample-config/template-object/printer.cfg 818perl subst sample-config/template-object/switch.cfg 819 820 821 822 823dnl Review options 824echo "" 825echo "" 826AC_MSG_RESULT([*** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:]) 827 828echo "" 829echo " General Options:" 830echo " -------------------------" 831 832AC_MSG_RESULT([ Nagios executable: $nagios_name]) 833AC_MSG_RESULT([ Nagios user/group: $nagios_user,$nagios_grp]) 834AC_MSG_RESULT([ Command user/group: $command_user,$command_grp]) 835if test x$USEPERL = xyes; then 836if test x$PERLCACHE = xyes; then 837AC_MSG_RESULT([ Embedded Perl: yes, with caching]) 838else 839AC_MSG_RESULT([ Embedded Perl: yes, without caching]) 840fi 841else 842AC_MSG_RESULT([ Embedded Perl: no]) 843fi 844if test x$USE_EVENTBROKER = xyes; then 845AC_MSG_RESULT([ Event Broker: yes]) 846else 847AC_MSG_RESULT([ Event Broker: no]) 848fi 849AC_MSG_RESULT([ Install \${prefix}: $prefix]) 850AC_MSG_RESULT([ Lock file: $lockfile]) 851AC_MSG_RESULT([ Check result directory: $CHECKRESULTDIR]) 852AC_MSG_RESULT([ Init directory: $init_dir]) 853AC_MSG_RESULT([ Apache conf.d directory: $HTTPD_CONF]) 854AC_MSG_RESULT([ Mail program: $MAIL_PROG]) 855AC_MSG_RESULT([ Host OS: $host_os]) 856 857echo "" 858echo " Web Interface Options:" 859echo " ------------------------" 860 861AC_MSG_RESULT([ HTML URL: http://localhost$htmurl/]) 862AC_MSG_RESULT([ CGI URL: http://localhost$cgiurl/]) 863AC_MSG_RESULT([ Traceroute (used by WAP): $PATH_TO_TRACEROUTE]) 864 865dnl echo "" 866dnl echo " External Data Routines:" 867dnl echo " ------------------------" 868 869dnl AC_MSG_RESULT([ Status data: $XSDCOMMENT]) 870dnl AC_MSG_RESULT([ Comment data: $XCDCOMMENT]) 871dnl AC_MSG_RESULT([ Downtime data: $XDDCOMMENT]) 872dnl AC_MSG_RESULT([ Peformance data: $XPDCOMMENT]) 873 874 875echo "" 876echo "" 877echo "Review the options above for accuracy. If they look okay," 878echo "type 'make all' to compile the main program and CGIs." 879echo "" 880 881