"Fossies" - the Fresh Open Source Software Archive

Member "monit-5.28.0/configure.ac" (28 Mar 2021, 34048 Bytes) of package /linux/privat/monit-5.28.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 5.27.2_vs_5.28.0.

    1 # Process this file with bootstrap to produce a configure script.
    2 
    3 # autoconf requirement
    4 AC_PREREQ([2.53])
    5 
    6 # Note: in  case of beta subversion, use underscore "_" rather then dash "-"
    7 # since RPM doesn't allow dash in Version
    8 # Example: 5.0_beta2
    9 AC_INIT([monit], [5.28.0], [monit-general@nongnu.org])
   10 AC_CONFIG_AUX_DIR(config)
   11 AC_CONFIG_MACRO_DIR([m4])
   12 AM_INIT_AUTOMAKE
   13 AC_CONFIG_SRCDIR([src/monit.c])
   14 AC_CONFIG_SUBDIRS([libmonit])
   15 AC_CONFIG_COMMANDS([libtool_patch],[test `uname` = "OpenBSD" && perl -p -i -e "s/deplibs_check_method=.*/deplibs_check_method=pass_all/g" libtool])
   16 AC_CONFIG_COMMANDS([monitrc], [chmod 600 monitrc])
   17 
   18 # ------------------------------------------------------------------------
   19 # Programs
   20 # ------------------------------------------------------------------------
   21 
   22 AC_PROG_CC
   23 AC_PROG_INSTALL
   24 AC_PROG_MAKE_SET
   25 AC_CHECK_PROGS([YACC], ['bison -y' byacc yacc], [no], [$PATH:/usr/local/bin:/usr/bin])
   26 if test "x$YACC" = "xno"; then
   27 	# Require bison unless y.tab.c already is built
   28 	if test ! -f src/y.tab.c; then
   29                 AC_MSG_ERROR([Monit require bison, byacc or yacc. Download bison from http://www.gnu.org/software/bison/])
   30 	fi
   31 fi
   32 AC_PATH_PROG([FLEX], [flex], [no], [$PATH:/usr/local/bin:/usr/bin])
   33 if test "x$FLEX" = "xno"; then
   34 	# Require flex unless lex.yy.c already is built
   35 	if test ! -f src/lex.yy.c; then
   36                 AC_MSG_ERROR([flex is required. Download from http://www.gnu.org/software/flex/])
   37 	fi
   38 fi
   39 AC_PATH_PROG([POD2MAN], [pod2man], [no], [$PATH:/usr/local/bin:/usr/bin])
   40 if test "x$POD2MAN" = "xno"; then
   41 	# Require pod2man unless monit.1 already is built
   42 	if test ! -f monit.1; then
   43 		AC_MSG_ERROR([pod2man is required to build the monit.1 man file.])
   44 	fi
   45 else
   46 	POD2MANFLAGS="--center 'User Commands' --release AC_PACKAGE_VERSION --date='www.mmonit.com' --lax"
   47 	AC_SUBST([POD2MANFLAGS])
   48 fi
   49 
   50 AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
   51 if test `uname` != "AIX"; then
   52         AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [CFLAGS="$CFLAGS -fstack-protector-all"])
   53         AX_CHECK_COMPILE_FLAG([-fcf-protection=full], [CFLAGS="$CFLAGS -fcf-protection=full"])
   54         AX_CHECK_COMPILE_FLAG([-fstack-clash-protection], [CFLAGS="$CFLAGS -fstack-clash-protection"])
   55 fi
   56 
   57 
   58 # ------------------------------------------------------------------------
   59 # Libtool
   60 # ------------------------------------------------------------------------
   61 
   62 AC_DISABLE_STATIC
   63 LT_INIT
   64 
   65 
   66 # ------------------------------------------------------------------------
   67 # Libraries
   68 # ------------------------------------------------------------------------
   69 
   70 # Check for libraries
   71 AC_CHECK_LIB([socket], [socket])
   72 AC_CHECK_LIB([inet],   [socket])
   73 AC_CHECK_LIB([nsl],    [inet_addr])
   74 AC_CHECK_LIB([resolv], [inet_aton])
   75 AC_CHECK_LIB([c], [crypt], [:], [AC_CHECK_LIB([crypt], [crypt])])
   76 AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([POSIX thread library is required])])
   77 
   78 
   79 # ------------------------------------------------------------------------
   80 # Header files
   81 # ------------------------------------------------------------------------
   82 
   83 AC_HEADER_STDC
   84 AC_HEADER_SYS_WAIT
   85 AC_HEADER_STAT
   86 AC_HEADER_TIME
   87 
   88 AC_CHECK_HEADERS([ \
   89         alloca.h \
   90 	arpa/inet.h \
   91 	asm/page.h \
   92 	asm/param.h \
   93 	cf.h \
   94 	crt_externs.h \
   95 	ctype.h \
   96 	crypt.h \
   97 	CoreFoundation/CoreFoundation.h \
   98 	devstat.h \
   99 	dirent.h \
  100 	DiskArbitration/DiskArbitration.h \
  101 	errno.h \
  102 	execinfo.h \
  103 	fcntl.h \
  104 	getopt.h \
  105 	glob.h \
  106 	grp.h \
  107 	ifaddrs.h \
  108 	IOKit/storage/IOBlockStorageDriver.h \
  109 	kinfo.h \
  110 	kvm.h \
  111 	paths.h \
  112 	kstat.h \
  113 	libzfs.h \
  114 	zone.h \
  115 	sys/protosw.h \
  116 	libproc.h \
  117 	limits.h \
  118 	loadavg.h \
  119 	locale.h \
  120 	lvm.h \
  121         mach/host_info.h \
  122         mach/mach.h \
  123         mach/mach_host.h \
  124 	memory.h \
  125 	mntent.h \
  126 	netdb.h \
  127         sys/socket.h \
  128 	netinet/in.h \
  129 	netinet/tcp.h \
  130         netinet/in_systm.h \
  131         pam/pam_appl.h \
  132         security/pam_appl.h \
  133 	poll.h \
  134 	procfs.h \
  135 	sys/procfs.h \
  136 	procinfo.h \
  137 	pthread.h \
  138 	pwd.h \
  139 	regex.h \
  140 	setjmp.h \
  141 	signal.h \
  142 	stdarg.h \
  143         stddef.h \
  144 	stdio.h \
  145 	string.h \
  146 	strings.h \
  147 	stropts.h \
  148 	sys/cfgodm.h \
  149 	sys/cfgdb.h \
  150 	sys/dk.h \
  151 	sys/dkstat.h \
  152 	sys/disk.h \
  153 	sys/filio.h \
  154 	sys/fs/zfs.h \
  155 	sys/instance.h \
  156 	sys/ioctl.h \
  157 	sys/iostat.h \
  158 	sys/loadavg.h \
  159 	sys/lock.h \
  160 	sys/mntent.h \
  161 	sys/mnttab.h \
  162 	sys/mutex.h \
  163 	sys/nlist.h \
  164 	sys/nvpair.h \
  165 	sys/param.h \
  166 	sys/pstat.h \
  167 	sys/queue.h \
  168 	sys/resource.h \
  169 	sys/sched.h \
  170 	sys/statfs.h \
  171 	sys/statvfs.h \
  172 	sys/sysinfo.h \
  173 	sys/sysmacros.h \
  174 	sys/systemcfg.h \
  175 	sys/time.h \
  176 	sys/tree.h \
  177 	sys/types.h \
  178 	sys/un.h \
  179 	sys/utsname.h \
  180         sys/var.h \
  181         sys/vmmeter.h \
  182         sys/vm_usage.h \
  183 	sys/vfs.h \
  184 	syslog.h \
  185 	unistd.h \
  186 	utmpx.h \
  187         uvm/uvm_extern.h \
  188         uvm/uvm_param.h \
  189         vm/vm.h \
  190         net/if_media.h \
  191         net/if_dl.h \
  192         net/route.h
  193 	])
  194 
  195 AC_CHECK_HEADERS([ \
  196 	libperfstat.h \
  197         ],
  198         [],
  199         [],
  200         [
  201          #ifdef HAVE_SYS_PROTOSW_H
  202          #include <sys/protosw.h>
  203          #endif
  204         ])
  205 
  206 AC_CHECK_HEADERS([ \
  207 	netinet/ip.h \
  208         ],
  209         [],
  210         [],
  211         [
  212          #ifdef HAVE_SYS_TYPES_H
  213          #include <sys/types.h>
  214          #endif
  215          #if HAVE_NETINET_IN_SYSTM_H
  216          #include <netinet/in_systm.h>
  217          #endif
  218          #if HAVE_NETINET_IN_SYSTM_H
  219          #include <netinet/in.h>
  220          #endif
  221         ])
  222 
  223 AC_CHECK_HEADERS([ \
  224 	net/if.h \
  225 	netinet/ip_icmp.h \
  226         ],
  227         [],
  228         [],
  229         [
  230          #ifdef HAVE_SYS_TYPES_H
  231          #include <sys/types.h>
  232          #endif
  233          #if HAVE_SYS_SOCKET_H
  234          #include <sys/socket.h>
  235          #endif
  236          #if HAVE_NETINET_IN_SYSTM_H
  237          #include <netinet/in.h>
  238          #endif
  239          #if HAVE_NETINET_IN_SYSTM_H
  240          #include <netinet/in_systm.h>
  241          #endif
  242          #if HAVE_NETINET_IP_H
  243          #include <netinet/ip.h>
  244          #endif
  245         ])
  246         
  247 AC_CHECK_HEADERS([ \
  248 	netinet/icmp6.h \
  249         ],
  250         [],
  251         [],
  252         [
  253          #ifdef HAVE_SYS_TYPES_H
  254          #include <sys/types.h>
  255          #endif
  256          #if HAVE_NETINET_IP_H
  257          #include <netinet/in.h>
  258          #endif
  259         ])
  260 
  261 AC_CHECK_HEADERS([ \
  262         sys/sysctl.h \
  263         sys/mount.h \
  264         sys/proc.h \
  265         sys/swap.h \
  266 	sys/ucred.h \
  267         sys/user.h \
  268         ],
  269         [],
  270         [],
  271         [
  272          #ifdef HAVE_SYS_PARAM_H
  273          #include <sys/param.h>
  274          #endif
  275         ])
  276 
  277 AC_CHECK_HEADERS([ \
  278 	machine/vmparam.h \
  279         vm/pmap.h \
  280         machine/pmap.h \
  281         vm/vm_map.h \
  282 	vm/vm_object.h \
  283         ],
  284         [],
  285         [],
  286         [
  287          #ifdef HAVE_SYS_PARAM_H
  288          #include <sys/param.h>
  289          #endif
  290          #ifdef HAVE_SYS_QUEUE_H
  291          #include <sys/queue.h>
  292          #endif
  293          #ifdef HAVE_SYS_LOCK_H
  294          #include <sys/lock.h>
  295          #endif
  296          #ifdef HAVE_SYS_MUTEX_H
  297          #include <sys/mutex.h>
  298          #endif
  299          #ifdef HAVE_VM_VM_H
  300          #include <vm/vm.h>
  301          #endif
  302          #ifdef HAVE_VM_PMAP_H
  303          #include <vm/pmap.h>
  304          #endif
  305         ])
  306 
  307 AC_CHECK_HEADERS([ \
  308         sys/resourcevar.h \
  309         ],
  310         [],
  311         [],
  312         [
  313          #ifdef HAVE_SYS_TIME_H
  314          #include <sys/time.h>
  315          #endif
  316          #ifdef HAVE_SYS_RESOURCE_H
  317          #include <sys/resource.h>
  318          #endif
  319         ])
  320 
  321 AC_CHECK_HEADERS([ \
  322 	uvm/uvm_map.h \
  323 	uvm/uvm_pmap.h \
  324 	uvm/uvm_object.h \
  325         ],
  326         [],
  327         [],
  328         [
  329          #ifdef HAVE_SYS_TIME_H
  330          #include <sys/time.h>
  331          #endif
  332          #ifdef HAVE_SYS_LOCK_H
  333          #include <sys/lock.h>
  334          #endif
  335          #ifdef HAVE_SYS_TREE_H
  336          #include <sys/tree.h>
  337          #endif
  338          #ifdef HAVE_UVM_UVM_EXTERN_H
  339          #include <uvm/uvm_extern.h>
  340          #endif
  341         ])
  342 
  343 AC_CHECK_HEADERS([ \
  344 	uvm/uvm.h \
  345         ],
  346         [],
  347         [],
  348         [
  349          #ifdef HAVE_SYS_MUTEX_H
  350          #include <sys/mutex.h>
  351          #endif
  352          #ifdef HAVE_SYS_TYPES_H
  353          #include <sys/types.h>
  354          #endif
  355          #ifdef HAVE_SYS_PARAM_H
  356          #include <sys/param.h>
  357          #endif
  358          #ifdef HAVE_UVM_UVM_PARAM_H
  359          #include <uvm/uvm_param.h>
  360          #endif
  361         ])
  362 
  363 # ------------------------------------------------------------------------
  364 # Types
  365 # ------------------------------------------------------------------------
  366 
  367 AC_TYPE_MODE_T
  368 AC_TYPE_PID_T
  369 AC_TYPE_SIZE_T
  370 AC_TYPE_PID_T
  371 
  372 # Check for structures.
  373 AC_STRUCT_TM
  374 AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
  375 
  376 
  377 # ------------------------------------------------------------------------
  378 # Functions
  379 # ------------------------------------------------------------------------
  380 
  381 # Checks for library functions.
  382 AC_FUNC_ERROR_AT_LINE
  383 AC_FUNC_FORK
  384 AC_FUNC_STAT
  385 AC_FUNC_STRFTIME
  386 AC_CHECK_FUNCS(statfs)
  387 AC_CHECK_FUNCS(statvfs)
  388 AC_CHECK_FUNCS(setlocale)
  389 AC_CHECK_FUNCS(getaddrinfo)
  390 AC_CHECK_FUNCS(syslog)
  391 AC_CHECK_FUNCS(vsyslog)
  392 AC_CHECK_FUNCS(backtrace)
  393 AC_CHECK_FUNCS(getloadavg)
  394 AC_CHECK_FUNCS(getopt_long)
  395 
  396 
  397 # ------------------------------------------------------------------------
  398 # Compiler
  399 # ------------------------------------------------------------------------
  400 
  401 AC_PROG_CC
  402 AC_PROG_CXX
  403 AC_C_CONST
  404 AC_C_BIGENDIAN
  405 # Define _GNU_SOURCE so we can have Posix headers etc included. We use the
  406 # -std=cXX compiler switch which only include a minimum of C headers
  407 CFLAGS="$CFLAGS -D_GNU_SOURCE"
  408 
  409 # Compiler; tune warnings and make the char type unsigned
  410 CFLAGS="$CFLAGS -Wall -Wunused -Wno-unused-label -funsigned-char";
  411 # does this compiler support -Wno-pointer-sign ?
  412 svd_CFLAGS="$CFLAGS"
  413 CFLAGS="-Wno-pointer-sign $CFLAGS"
  414 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 0;])], [], [CFLAGS="$svd_CFLAGS"])
  415 # does this compiler support -Wno-address ?
  416 svd_CFLAGS="$CFLAGS"
  417 CFLAGS="-Wno-address $CFLAGS"
  418 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 0;])], [], [CFLAGS="$svd_CFLAGS"])
  419 
  420 # Require at least C99 and use C11 if available
  421 AC_COMPUTE_INT([STDC_VERSION],[__STDC_VERSION__],,[STDC_VERSION=0])
  422 AS_IF([test "$STDC_VERSION" -ge 201112],[CFLAGS="$CFLAGS -std=c11"],[CFLAGS="$CFLAGS -std=c99"])
  423 AC_CHECK_HEADERS([stdint.h stdbool.h], [], [AC_MSG_ERROR([toolchain does not have C99 headers])])
  424 
  425 
  426 # ------------------------------------------------------------------------
  427 # IPv6 Support
  428 # ------------------------------------------------------------------------
  429 
  430 AC_ARG_WITH(ipv6,
  431     AS_HELP_STRING([--without-ipv6], [Disable the IPv6 support (default: check)]),
  432     [
  433         if test "x$withval" = "xno"
  434         then
  435             with_ipv6=0
  436         elif test "x$withval" = "xyes"
  437         then
  438             with_ipv6=1
  439             AC_DEFINE([HAVE_IPV6], 1, [Define to 1 if the system supports IPv6])
  440         fi
  441     ],
  442     [
  443         # Note inverse test. Check by default
  444         AC_MSG_CHECKING(for IPv6 support)
  445         AC_CACHE_VAL(ac_cv_ipv6,
  446                 AC_RUN_IFELSE([
  447                 AC_LANG_SOURCE([[
  448                 #include <sys/types.h>
  449                 #include <sys/socket.h>
  450                 #include <netinet/in.h>
  451                 /* Make sure the definitions for AF_INET6 and struct sockaddr_in6
  452                  * are defined, and that we can actually create an IPv6 TCP socket.*/
  453                 main()
  454                 {
  455                         int fd;
  456                         struct sockaddr_in6 foo;
  457                         fd = socket(AF_INET6, SOCK_STREAM, 0);
  458                         exit(fd >= 0 ? 0 : 1);
  459                 }]])],
  460                 [ac_cv_ipv6=yes],
  461                 [ac_cv_ipv6=no],
  462                 [ac_cv_ipv6=no])
  463         )
  464         AC_MSG_RESULT($ac_cv_ipv6)
  465 
  466         if test $ac_cv_ipv6 = yes
  467         then
  468                 with_ipv6=1
  469                 AC_DEFINE([HAVE_IPV6], 1, [Define to 1 if the system supports IPv6])
  470         else
  471                 with_ipv6=0
  472         fi
  473     ]
  474 )
  475 
  476 
  477 # ------------------------------------------------------------------------
  478 # Paths
  479 # ------------------------------------------------------------------------
  480 
  481 # Find the right directory to put the root-mode PID file in
  482 AC_MSG_CHECKING([pid file location])
  483 if test -d "/run"
  484 then
  485 	piddir="/run"
  486 elif test -d "/var/run"; then
  487         piddir="/var/run"
  488 elif test -d "/etc"; then
  489         piddir="/etc"
  490 fi
  491 
  492 AC_DEFINE_UNQUOTED([PIDDIR], "$piddir",
  493 	  [Define to the pid storage directory.])
  494 AC_MSG_RESULT([$piddir])
  495 
  496 # Test mounted filesystem description file
  497 if test -f "/etc/mtab"
  498 then
  499   AC_DEFINE([HAVE_MTAB], 1, [Define to 1 if you have /etc/mtab])
  500 elif test -f "/etc/mnttab"; then
  501   AC_DEFINE([HAVE_MNTTAB], 1, [Define to 1 if you have /etc/mnttab])
  502 fi
  503 
  504 
  505 # ------------------------------------------------------------------------
  506 # Architecture/OS detection
  507 # ------------------------------------------------------------------------
  508 
  509 # Backward compatibility until we get ride of arch settings
  510 architecture=`uname`
  511 if test "$architecture" = "SunOS"
  512 then
  513    ARCH="SOLARIS"
  514    CFLAGS="$CFLAGS -D _REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D__EXTENSIONS__ -m64"
  515    LDFLAGS="$LDFLAGS -m64"
  516    AC_CHECK_LIB([zfs], [libzfs_init])
  517    AC_CHECK_LIB([nvpair], [nvlist_free])
  518    AC_CHECK_LIB([kstat], [kstat_open])
  519    if test `uname -m` = "i86pc"
  520    then
  521       if test "x$GCC" = "xyes"
  522       then
  523             CFLAGS="$CFLAGS -mtune=opteron"
  524             LDFLAGS="$LDFLAGS -mtune=opteron"
  525       else
  526             CFLAGS="$CFLAGS -xarch=sse2"
  527             LDFLAGS="$LDFLAGS -xarch=sse2"
  528       fi
  529    else
  530       if test "x$GCC" = "xyes"
  531       then
  532             CFLAGS="$CFLAGS -mtune=v9"
  533             LDFLAGS="$LDFLAGS -mtune=v9"
  534       else
  535             CFLAGS="$CFLAGS -xarch=sparc"
  536             LDFLAGS="$LDFLAGS -xarch=sparc"
  537       fi
  538    fi
  539 elif test "$architecture" = "Linux"
  540 then
  541    ARCH="LINUX"
  542    CFLAGS="$CFLAGS -D _REENTRANT"
  543    LDFLAGS="$LDFLAGS -rdynamic"
  544 elif test "$architecture" = "OpenBSD"
  545 then
  546    ARCH="OPENBSD"
  547    CFLAGS="$CFLAGS -D _REENTRANT"
  548    AC_CHECK_LIB([kvm], [kvm_open])
  549    with_pam=0 # No PAM on OpenBSD (supports BSD Auth API instead of PAM)
  550 elif test "$architecture" = "FreeBSD"
  551 then
  552    ARCH="FREEBSD"
  553    CFLAGS="$CFLAGS -D _REENTRANT"
  554    AC_CHECK_LIB([devstat], [devstat_getnumdevs])
  555    AC_CHECK_LIB([kvm], [kvm_open])
  556 elif test "$architecture" = "GNU/kFreeBSD"
  557 then
  558    ARCH="FREEBSD"
  559    CFLAGS="$CFLAGS -D _REENTRANT"
  560    AC_CHECK_LIB([devstat], [devstat_getnumdevs])
  561    AC_CHECK_LIB([kvm], [kvm_open])
  562 elif test "$architecture" = "NetBSD"
  563 then
  564    ARCH="NETBSD"
  565    CFLAGS="$CFLAGS -D _REENTRANT -Wno-char-subscripts"
  566    AC_CHECK_LIB([kvm], [kvm_open])
  567 elif test "$architecture" = "DragonFly"
  568 then
  569    ARCH="DRAGONFLY"
  570    CFLAGS="$CFLAGS -D _REENTRANT"
  571    AC_CHECK_LIB([kvm], [kvm_open])
  572    AC_CHECK_LIB([devstat], [getnumdevs])
  573 elif test "$architecture" = "Darwin"
  574 then
  575    ARCH="DARWIN"
  576    CFLAGS="$CFLAGS -DREENTRANT -no-cpp-precomp -DNEED_SOCKLEN_T_DEFINED"
  577    LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
  578    AC_CHECK_LIB([kvm], [kvm_open])
  579    LIBS="$LIBS -framework System -framework CoreFoundation -framework DiskArbitration -framework IOKit -multiply_defined suppress"
  580 elif test "$architecture" = "AIX"
  581 then
  582    ARCH="AIX"
  583    CFLAGS=`echo $CFLAGS|sed 's/-g//g'`
  584    CFLAGS="$CFLAGS -D_THREAD_SAFE -D_REENTRANT"
  585    LIBS="$LIBS -lodm -lperfstat -lm"
  586 else
  587    AC_MSG_WARN([Architecture not supported: ${architecture}])
  588    CFLAGS="$CFLAGS -D _REENTRANT"
  589    ARCH="UNKNOWN"
  590 fi
  591 AC_SUBST(ARCH)
  592 
  593 
  594 # ------------------------------------------------------------------------
  595 # Large files code
  596 # ------------------------------------------------------------------------
  597 
  598 # Check if we want to have large files support
  599 AC_MSG_CHECKING([for large files support])
  600 AC_ARG_WITH(largefiles,
  601     [  --without-largefiles    disable large files support (default: enabled)],
  602     [
  603         dnl Check the withvalue
  604         if test "x$withval" = "xno" ; then
  605             with_largefiles=0
  606             AC_MSG_RESULT([disabled])
  607         fi
  608         if test "x$withval" = "xyes" ; then
  609             with_largefiles=1
  610             AC_MSG_RESULT([enabled])
  611         fi
  612     ],
  613     [
  614 	if test `uname` = "AIX"
  615 	then
  616 	    with_largefiles=0
  617 	    AC_MSG_RESULT([disabled])
  618 	else
  619 	    with_largefiles=1
  620 	    AC_MSG_RESULT([enabled])
  621 	fi
  622     ]
  623 )
  624 
  625 # Settings for largefiles support
  626 if test $with_largefiles -eq 1; then
  627         AC_SYS_LARGEFILE
  628         AC_DEFINE([HAVE_LARGEFILES], 1, [Define to 1 if you have large files support])
  629 fi
  630 
  631 
  632 # ------------------------------------------------------------------------
  633 # zlib Code
  634 # ------------------------------------------------------------------------
  635 
  636 AC_ARG_WITH([zlib],
  637         AS_HELP_STRING([--with-zlib(=<path>)],
  638                 [Link Monit with zlib. An optional path argument may
  639                 be given to specify the top-level directory to search for
  640                 zlib to link with]),
  641      [
  642         if test "x$withval" = "xyes"; then
  643                 AC_CHECK_LIB([z], [zlibVersion], [], [AC_MSG_ERROR([libz not found])])
  644                 with_zlib=1
  645                 AC_CHECK_HEADERS([zlib.h])
  646         elif test "x$withval" != "xno"; then
  647                 AC_MSG_CHECKING([for zlib in $withval])
  648                 LDFLAGS="-L$withval/lib -lz $LDFLAGS "
  649                 CFLAGS="-I$withval/include $CFLAGS"
  650                 if test -r "$withval/lib/libz.a" -a -r "$withval/include/zlib.h"; then
  651                         with_zlib=1
  652                         AC_DEFINE([HAVE_LIBZ], [1], [Define if you have zlib library])
  653                         AC_DEFINE([HAVE_ZLIB_H], [1], [Define if you have zlib header])
  654                         AC_MSG_RESULT([ok])
  655                 else
  656                         with_zlib=0
  657                         AC_MSG_ERROR([zlib not found in $withval])
  658                 fi
  659         else
  660                 with_zlib=0
  661         fi
  662      ],[
  663         AC_CHECK_LIB([z], [zlibVersion], [], [AC_MSG_ERROR([libz not found])])
  664         with_zlib=1
  665         AC_CHECK_HEADERS([zlib.h])
  666      ]
  667 )
  668 
  669 # ------------------------------------------------------------------------
  670 # PAM Code
  671 # ------------------------------------------------------------------------
  672 
  673 AC_MSG_CHECKING([for PAM support])
  674 AC_ARG_WITH(pam,
  675     [  --without-pam           disable the use of pam (default: enabled)],
  676     [
  677         dnl Check the withvalue
  678         if test "x$withval" = "xno" || test "x$with_pam" = "x0"; then
  679                 with_pam=0
  680                 AC_MSG_RESULT([disabled])
  681         else
  682                 with_pam=1
  683                 AC_MSG_RESULT([enabled])
  684         fi
  685     ],
  686     [
  687         # Note inverse test. On by default
  688         with_pam=1
  689         AC_MSG_RESULT([enabled])
  690     ]
  691 )
  692 
  693 if test $with_pam -eq 1; then
  694         AC_CHECK_LIB([pam], [pam_start], [], [AC_MSG_ERROR([PAM enabled but headers or library not found, install the PAM development support or run configure --without-pam])])
  695 fi
  696 
  697 
  698 # ------------------------------------------------------------------------
  699 # AddressSanitizer
  700 # ------------------------------------------------------------------------
  701 
  702 AC_MSG_CHECKING([for AddressSanitizer support])
  703 AC_ARG_WITH(asan,
  704     [  --with-asan             enable the use of AddressSanitizer (default: disabled)],
  705     [
  706         dnl Check the withvalue
  707         if test "x$withval" = "xno" ; then
  708             with_asan=0
  709             AC_MSG_RESULT([disabled])
  710         fi
  711         if test "x$withval" = "xyes" ; then
  712             with_asan=1
  713             AC_MSG_RESULT([enabled])
  714         fi
  715     ],
  716     [
  717         with_asan=0
  718         AC_MSG_RESULT([disabled])
  719     ]
  720 )
  721 
  722 if test $with_asan -eq 1; then
  723         AX_CHECK_COMPILE_FLAG([-fsanitize=address], [CFLAGS="$CFLAGS -fsanitize=address"])
  724         AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], [CFLAGS="$CFLAGS -fno-omit-frame-pointer"])
  725         AX_CHECK_COMPILE_FLAG([-fsanitize=bool], [CFLAGS="$CFLAGS -fsanitize=bool"])
  726         AX_CHECK_COMPILE_FLAG([-fsanitize=enum], [CFLAGS="$CFLAGS -fsanitize=enum"])
  727         AX_CHECK_COMPILE_FLAG([-fsanitize=float-divide-by-zero], [CFLAGS="$CFLAGS -fsanitize=float-divide-by-zero"])
  728         AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"])
  729         AX_CHECK_COMPILE_FLAG([-fsanitize=signed-integer-overflow], [CFLAGS="$CFLAGS -fsanitize=signed-integer-overflow"])
  730         AX_CHECK_COMPILE_FLAG([-fsanitize=vla-bound], [CFLAGS="$CFLAGS -fsanitize=vla-bound"])
  731         AX_CHECK_COMPILE_FLAG([-fsanitize=bounds-strict], [CFLAGS="$CFLAGS -fsanitize=bounds-strict"])
  732         AX_CHECK_COMPILE_FLAG([-fsanitize=null], [CFLAGS="$CFLAGS -fsanitize=null "])
  733         AX_CHECK_COMPILE_FLAG([-fsanitize=object-size], [CFLAGS="$CFLAGS -fsanitize=object-size"])
  734         AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [CFLAGS="$CFLAGS -fsanitize=undefined"])
  735         AC_DEFINE([HAVE_ASAN], 1, [Define to 1 if you have address sanitizer.])
  736 fi
  737 
  738 
  739 # ------------------------------------------------------------------------
  740 # SSL Code
  741 # ------------------------------------------------------------------------
  742 
  743 # Check for ssl includes
  744 checksslincldir() { :
  745     if test -f "$1/openssl/ssl.h"; then
  746         sslincldir="$1"
  747         return 0
  748     fi
  749     return 1
  750 }
  751 
  752 # Check for ssl libraries
  753 checkssllibdirdynamic() { :
  754     CRYPTOLIB=`ls -1 $1/libcrypto.so* $1/libcrypto.dylib* 2>/dev/null | wc -l`
  755     SSLLIB=`ls -1 $1/libssl.so* $1/libssl.dylib* 2>/dev/null | wc -l`
  756     if test "(" $CRYPTOLIB -gt 0 -a $SSLLIB -gt 0 ")"
  757     then
  758         ssllibdir="$1"
  759         return 0
  760     fi
  761     return 1
  762 }
  763 
  764 checkssllibdirstatic() { :
  765     if test "(" -f "$1/libcrypto.a" ")"  -a \
  766             "(" -f "$1/libssl.a" ")" ; then
  767         ssllibdir="$1"
  768         return 0
  769     fi
  770     return 1
  771 }
  772 
  773 # Check if we want to have SSL
  774 
  775 AC_MSG_CHECKING([for static SSL support])
  776 
  777 AC_ARG_WITH(ssl-static,
  778     [  --with-ssl-static=DIR       location of SSL installation],
  779     [
  780         dnl Check the specified location only
  781         for dir in "$withval" "$withval/include"; do
  782             checksslincldir "$dir"
  783         done
  784         for dir in "$withval" "$withval/lib"; do
  785             checkssllibdirstatic "$dir" && break
  786         done
  787         with_sslstatic=1
  788         LDFLAGS="`echo $LDFLAGS | sed -e 's/-rdynamic/-ldl/g'`"
  789         AC_MSG_RESULT([enabled])
  790         AC_DEFINE([HAVE_OPENSSL], 1, [Define to 1 if you have openssl.])
  791         AC_SUBST(sslincldir)
  792         AC_SUBST(ssllibdir)
  793         CFLAGS="$CFLAGS -I$sslincldir"
  794         LIBS="$LIBS $ssllibdir/libssl.a $ssllibdir/libcrypto.a"
  795         if test `uname` = "Linux" && test `uname -m` = "aarch64"; then
  796             LIBS="$LIBS -ldl"
  797         fi
  798     ],
  799     [
  800 	with_sslstatic=0
  801         AC_MSG_RESULT([disabled])
  802     ]
  803 )
  804 
  805 if test $with_sslstatic -eq 0
  806 then
  807     AC_MSG_CHECKING([for SSL support])
  808 
  809     AC_ARG_WITH(ssl,
  810         [  --without-ssl           disable the use of ssl (default: enabled)],
  811         [
  812             dnl Check the withvalue
  813             if test "x$withval" = "xno" ; then
  814                 with_ssl=0
  815                 AC_MSG_RESULT([disabled])
  816             fi
  817             if test "x$withval" = "xyes" ; then
  818                 with_ssl=1
  819                 AC_MSG_RESULT([enabled])
  820             fi
  821         ],
  822         [
  823                 # Note inverse test. On by default
  824                 with_ssl=1
  825                 AC_MSG_RESULT([enabled])
  826         ]
  827     )
  828 
  829 
  830     # Check for SSL directory
  831     if test $with_ssl -eq 1; then
  832 
  833         AC_ARG_WITH(ssl-dir,
  834             [  --with-ssl-dir=DIR       location of SSL installation],
  835             [
  836                 dnl Check the specified location only
  837                 for dir in "$withval" "$withval/include"; do
  838                 	checksslincldir "$dir"
  839                 done
  840                 for dir in "$withval" "$withval/lib"; do
  841                     checkssllibdirdynamic "$dir" && break
  842                 done
  843             ]
  844         )
  845 
  846         AC_MSG_CHECKING([for SSL include directory])
  847         AC_ARG_WITH(ssl-incl-dir,
  848             [  --with-ssl-incl-dir=DIR  location of installed SSL include files],
  849             [
  850                 dnl Check the specified location only
  851                 checksslincldir "$withval"
  852             ],
  853             [
  854                 if test -z "$sslincldir"; then
  855                     dnl Search default locations of SSL includes
  856                     for maindir in /usr /usr/local /usr/lib /usr/pkg /var /opt /usr/sfw /opt/csw /opt/freeware; do
  857                         for dir in "$maindir/include"\
  858                                    "$maindir/include/openssl"\
  859                                    "$maindir/include/ssl"\
  860                                    "$maindir/ssl/include"; do
  861                             checksslincldir $dir && break 2
  862                         done
  863                     done
  864                 fi
  865             ]
  866         )
  867         if test -z "$sslincldir"; then
  868             AC_MSG_RESULT([Not found])
  869             echo
  870             echo "Couldn't find your SSL header files."
  871             echo "Use --with-ssl-incl-dir option to fix this problem or disable"
  872             echo "the SSL support with --without-ssl"
  873             echo
  874             exit 1
  875         fi
  876         AC_MSG_RESULT([$sslincldir])
  877 
  878         AC_MSG_CHECKING([for SSL library directory])
  879         AC_ARG_WITH(ssl-lib-dir,
  880             [  --with-ssl-lib-dir=DIR   location of installed SSL library files],
  881             [
  882                 dnl Check the specified location only
  883                 checkssllibdirdynamic "$withval"
  884             ],
  885             [
  886                 if test -z "$ssllibdir"; then
  887                     dnl Search default locations of SSL libraries
  888                     for maindir in "" \
  889                                    /usr \
  890                                    /usr/local \
  891                                    /usr/pkg \
  892                                    /var \
  893                                    /opt \
  894                                    /usr/sfw \
  895                                    /opt/csw \
  896                                    /opt/freeware; do
  897                         for dir in $maindir \
  898                                    $maindir/openssl \
  899                                    $maindir/ssl \
  900                                    $maindir/lib \
  901                                    $maindir/lib/openssl \
  902                                    $maindir/lib/ssl \
  903                                    $maindir/ssl/lib \
  904                                    $maindir/lib/64 \
  905                                    $maindir/lib/64/openssl \
  906                                    $maindir/lib/64/ssl \
  907                                    $maindir/ssl/lib/64 \
  908                                    $maindir/lib64 \
  909                                    $maindir/lib64/openssl \
  910                                    $maindir/lib64/ssl \
  911                                    $maindir/ssl/lib64 \
  912                                    $maindir/lib/${host} \
  913                                    $maindir/lib/${host_alias}; do
  914                             checkssllibdirdynamic $dir && break 2
  915                         done
  916                     done
  917                 fi
  918             ]
  919         )
  920         if test -z "$ssllibdir"; then
  921             AC_MSG_RESULT([Not found])
  922             dnl Let the compiler find the library using default paths
  923             AC_CHECK_LIB([ssl], [SSL_new], [], [AC_MSG_ERROR([Could not find SSL library, please use --with-ssl-lib-dir option or disabled the SSL support using --without-ssl])])
  924             AC_CHECK_LIB([crypto],[CRYPTO_new_ex_data], [], [AC_MSG_ERROR([Could not find SSL library, please use --with-ssl-lib-dir option or disabled the SSL support using --without-ssl])])
  925         else
  926             AC_MSG_RESULT([$ssllibdir])
  927         fi
  928 
  929         AC_DEFINE([HAVE_OPENSSL], 1, [Define to 1 if you have openssl.])
  930         AC_SUBST(sslincldir)
  931         AC_SUBST(ssllibdir)
  932     fi
  933 
  934     # Add SSL includes and libraries
  935     if test "$sslincldir" -a "$ssllibdir"
  936     then
  937         if test "x$ARCH" = "xDARWIN"; then
  938          # Darwin already knows about ssldirs
  939          LIBS="$LIBS -lssl -lcrypto"
  940         elif test -f "/usr/kerberos/include/krb5.h"; then
  941          # Redhat 9 compilation fix:
  942          CFLAGS="$CFLAGS -I$sslincldir -I/usr/kerberos/include"
  943          LIBS="$LIBS -L$ssllibdir -lssl -lcrypto"
  944         else
  945          CFLAGS="$CFLAGS -I$sslincldir"
  946          LIBS="$LIBS -L$ssllibdir -lssl -lcrypto"
  947         fi
  948     fi
  949 fi
  950 # Check TLS version
  951 if test $with_sslstatic -eq 1 || test $with_ssl -eq 1; then
  952         if test "x$sslincldir" != "x"; then
  953                 CFLAGS="$CFLAGS -I$sslincldir"
  954         fi
  955         if test "x$ssllibdir" != "x"; then
  956                 LIBS="$LIBS -L$ssllibdir"
  957         fi
  958 
  959         AC_MSG_CHECKING([for SSLv2])
  960         AC_LINK_IFELSE(
  961                 [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSLv2_client_method()])],
  962                 [sslv2=yes],
  963                 [sslv2=no])
  964         AC_MSG_RESULT($sslv2)
  965         if test "$sslv2" = "yes" ; then
  966                 AC_DEFINE([HAVE_SSLV2], 1, [Define to 1 if you have openssl with SSLv2])
  967         fi
  968 
  969         AC_CHECK_DECL([SSL_OP_NO_TLSv1_1], [AC_DEFINE([HAVE_TLSV1_1], 1, [Define to 1 if you have openssl with TLSv1.1])], [], [[#include <openssl/ssl.h>]])
  970         AC_CHECK_DECL([SSL_OP_NO_TLSv1_2], [AC_DEFINE([HAVE_TLSV1_2], 1, [Define to 1 if you have openssl with TLSv1.2])], [], [[#include <openssl/ssl.h>]])
  971         AC_CHECK_DECL([SSL_OP_NO_TLSv1_3], [AC_DEFINE([HAVE_TLSV1_3], 1, [Define to 1 if you have openssl with TLSv1.3])], [], [[#include <openssl/ssl.h>]])
  972 
  973         AC_MSG_CHECKING([for EC_KEY support])
  974         AC_LINK_IFELSE(
  975                 [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [EC_KEY_new_by_curve_name(0)])],
  976                 [ec=yes],
  977                 [ec=no])
  978         AC_MSG_RESULT($ec)
  979         if test "$ec" = "yes" ; then
  980                 AC_DEFINE([HAVE_EC_KEY], 1, [Define to 1 if you have openssl with EC_KEY])
  981         fi
  982 
  983         AC_MSG_CHECKING([for ASN1_TIME_diff support])
  984         AC_LINK_IFELSE(
  985                 [AC_LANG_PROGRAM([#include <openssl/ssl.h>], [ASN1_TIME_diff(0, 0, 0, 0)])],
  986                 [asn1timediff=yes],
  987                 [asn1timediff=no])
  988         AC_MSG_RESULT($asn1timediff)
  989         if test "$asn1timediff" = "yes" ; then
  990                 AC_DEFINE([HAVE_ASN1_TIME_DIFF], 1, [Define to 1 if you have openssl with ASN1_TIME_diff])
  991         fi
  992 fi
  993 
  994 
  995 # ---------------------------------------------------------------------------
  996 # Build options
  997 # ---------------------------------------------------------------------------
  998 
  999 AC_ARG_ENABLE(optimized,
 1000         AS_HELP_STRING([--enable-optimized],
 1001                 [Build software optimized]),
 1002     [
 1003         CFLAGS=`echo $CFLAGS|sed 's/-O.//g'`
 1004         if test "x$enableval" = "xyes" ; then
 1005                 CFLAGS=`echo $CFLAGS|sed 's/-g[[^ ]]*//g'`
 1006                 CFLAGS=`echo $CFLAGS|sed 's/-O.//g'`
 1007                 CFLAGS="$CFLAGS -O3 -DNDEBUG"
 1008                 enable_optimized=1
 1009         else
 1010                 enable_optimized=0
 1011         fi
 1012     ],
 1013     [
 1014         enable_optimized=0
 1015     ]
 1016 )
 1017 
 1018 AC_ARG_ENABLE(profiling,
 1019         AS_HELP_STRING([--enable-profiling],
 1020                 [Build with debug and profiling options]),
 1021     [
 1022         if test "x$enableval" = "xyes" ; then
 1023                 CFLAGS=`echo $CFLAGS|sed 's/-g.//g'`
 1024                 CFLAGS=`echo $CFLAGS|sed 's/-O.//g'`
 1025                 CFLAGS="$CFLAGS -g -pg -fprofile-arcs -ftest-coverage"
 1026                 enable_profile=1
 1027         else
 1028                 enable_profile=0
 1029         fi
 1030     ],
 1031     [
 1032         enable_profile=0
 1033     ]
 1034 )
 1035 
 1036 AC_ARG_ENABLE([codesign],
 1037         AS_HELP_STRING([--enable-codesign=identity],
 1038                 [Add code signature to the monit binary on macOS]),
 1039      [
 1040         if test "x$enableval" = "xno" ; then
 1041                 enable_codesign=0
 1042         else
 1043                 AC_MSG_CHECKING([for validity of signing identity])
 1044                 if test "x$enableval" = "xyes"; then
 1045                         AC_MSG_ERROR([Please provide a signing identity])
 1046                 else
 1047                         if test -n "$(security find-identity -v|grep $enableval)"; then
 1048                                 enable_codesign=1
 1049                                 AC_SUBST([CODESIGN_IDENTITY], [$enableval])
 1050                                 AC_MSG_RESULT(yes)
 1051                         else
 1052                                 AC_MSG_ERROR([Signing identity not found])
 1053                         fi
 1054                 fi
 1055         fi
 1056      ],[enable_codesign=0]
 1057 )
 1058 AM_CONDITIONAL([WITH_CODESIGN], [test $enable_codesign -eq 1])
 1059 
 1060 
 1061 # ------------------------------------------------------------------------
 1062 # Outputs
 1063 # ------------------------------------------------------------------------
 1064 
 1065 AH_BOTTOM([
 1066 /* Mask out GCC __attribute__ extension for non-gcc compilers. */
 1067 #ifndef __GNUC__
 1068 #define __attribute__(x)
 1069 #endif
 1070 ])
 1071 
 1072 AC_CONFIG_HEADER([src/config.h])
 1073 AC_CONFIG_FILES([Makefile])
 1074 AC_CONFIG_FILES([system/startup/monit.upstart])
 1075 AC_CONFIG_FILES([system/startup/monit.service])
 1076 
 1077 AC_OUTPUT
 1078 
 1079 echo
 1080 echo "Monit Build Information:"
 1081 echo
 1082 echo "                Architecture: ${ARCH}"
 1083 if test $with_sslstatic -eq 1 || test $with_ssl -eq 1; then
 1084 echo "       SSL include directory: ${sslincldir}"
 1085 echo "       SSL library directory: ${ssllibdir}"
 1086 fi
 1087 echo "              Compiler flags: ${CFLAGS}"
 1088 echo "                Linker flags: ${LIBS}"
 1089 echo "           pid file location: ${piddir}"
 1090 echo "           Install directory: ${prefix}"
 1091 echo
 1092 
 1093 AX_INFO_AGPL()
 1094 AX_INFO_TITLE([Monit has been configured with the following options:])
 1095 AX_INFO_ENABLED([Compression:],           [test $with_zlib -eq 1])
 1096 AX_INFO_ENABLED([PAM support:],           [test $with_pam -eq 1])
 1097 AX_INFO_ENABLED([SSL support:],           [test $with_sslstatic -eq 1 || test $with_ssl -eq 1])
 1098 AX_INFO_ENABLED([Large files support:],   [test $with_largefiles -eq 1])
 1099 AX_INFO_ENABLED([ASAN support:],          [test $with_asan -eq 1])
 1100 AX_INFO_ENABLED([IPv6 support:],          [test $with_ipv6 -eq 1])
 1101 AX_INFO_ENABLED([Optimized:],             [test $enable_optimized -eq 1])
 1102 AX_INFO_ENABLED([Profiling:],             [test $enable_profile -eq 1])
 1103 if test "x$ARCH" = "xDARWIN"; then
 1104 AX_INFO_SEPARATOR()
 1105 AX_INFO_ENABLED([MacOS Code Signing:],    [test $enable_codesign -eq 1])
 1106 fi
 1107 AX_INFO_BREAK()