Ver código fonte

Initial import of macro files, .gitignore, and README.md

John C. Frickson 9 anos atrás
pai
commit
a26a7c64ed
9 arquivos alterados com 1920 adições e 1 exclusões
  1. 1 0
      .gitignore
  2. 183 1
      README.md
  3. 158 0
      ax_nagios_get_distrib
  4. 131 0
      ax_nagios_get_files
  5. 145 0
      ax_nagios_get_inetd
  6. 195 0
      ax_nagios_get_init
  7. 101 0
      ax_nagios_get_os
  8. 725 0
      ax_nagios_get_paths
  9. 281 0
      ax_nagios_get_ssl

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+nbproject/

+ 183 - 1
README.md

@@ -1 +1,183 @@
-# autoconf-macros
+autoconf-macros README
+======================
+
+Sections below are: Purpose, Contents, Usage, References
+
+
+
+##Purpose
+
+The purpose of Nagios autoconf-macros is to have a central place for
+autoconf macros that can be maintained in one place, but be used by any
+of the Nagios software. It is intended to be used as a git subtree.
+See the Usage and References section below.
+
+Since this project will be included in several parent projects, any
+changes must be as project-neutral as possible.
+
+
+
+## Contents
+
+The collection consists of the following macros:
+
+### AX_NAGIOS_GET_OS alias AC_NAGIOS_GET_OS
+
+> Output Variable : opsys
+
+This macro detects the operating system, and transforms it into a generic
+label. The most common OS's that use Nagios software are recognized and
+used in subsequent macros.
+
+### AX_NAGIOS_GET_DISTRIB_TYPE alias AC_NAGIOS_GET_DISTRIB_TYPE
+
+> Output Variables : dist_type, dist_ver
+
+This macro detects the distribution type. For Linux, this would be rh
+(for Red Hat and derivitives), suse (OpenSUSE, SLES, derivitives), gentoo
+(Gentoo and derivitives), debian (Debian and derivitives), and so on.
+For BSD, this would be openbsd, netbsd, freebsd, dragonfly, etc. It can
+also be aix, solaris, osx, and so on for Unix operating systems.
+
+### AX_NAGIOS_GET_INIT alias AC_NAGIOS_GET_INIT
+
+> Output Variable : init_type
+
+This macro detects what software is used to start daemons on bootup
+or on request, generally knows as the "init system". The init_type
+will generally be one of sysv (many), bsd (Slackware), newbsd (*BSD),
+launchd (OS X), smf10 or smf11 (Solaris), systemd (newer Linux),
+gentoo (older Gentoo), upstart (several), or unknown.
+
+### AX_NAGIOS_GET_INETD alias AC_NAGIOS_GET_INETD
+
+> Output Variable : inetd_type
+
+This macro detects what software is used to start daemons or services
+on demand, which historically has been "inetd". The inetd_type
+will generally be one of inetd, xinetd, launchd (OS X), smf10 or smf11
+(Solaris), systemd (newer Linux), upstart (several), or unknown.
+
+### AX_NAGIOS_GET_PATHS alias AC_NAGIOS_GET_PATHS
+
+> Output Variables : many!
+
+This macro determines the installation paths for binaries, config files,
+PID files, and so on. For a "standard" install of Nagios, NRPE, NDO Utils,
+etc., most will be in the /usr/local/nagios hierarchy with startup files
+located in /etc. For distributions or software repositories, the
+"--enable-install-method=os" option can be used. This will determine the
+O/S dependant directories, such as /usr/bin, /usr/sbin, /var/lib/nagios,
+/usr/lib/nagios, etc. or for OS X, /Library/LaunchDaemons.
+
+### AX_NAGIOS_GET_FILES alias AC_NAGIOS_GET_FILES
+
+> Output Variables : src_init, src_inetd, src_tmpfile
+
+Each Nagios project will have a top-level directory named "/startup/".
+In that directory will be "*.in" files for the various "init_type" and
+"inetd_type" systems. This macro will determine which file(s) from
+that directory will be needed.
+
+### AX_NAGIOS_GET_SSL alias AC_NAGIOS_GET_SSL
+
+> Output Variables : HAVE_KRB5_H, HAVE_SSL, SSL_INC_DIR, SSL_LIB_DIR, CFLAGS, LDFLAGS, LIBS
+
+This macro checks various directories for SSL libraries and header files.
+The searches are based on known install locations on various operating
+systems and distributions, for openssl, gnutls-openssl, and nss_compat_ossl.
+If it finds the headers and libraries, it will then do an `AC_LINK_IFELSE`
+on a simple program to make sure a compile and link will work correctly.
+
+
+
+## Usage
+
+This repo is intended to be used as a git subtree, so changes will
+automatically propogate, and still be reasonably easy to use.
+
+* First, Create, checkout, clone, or branch your project. If you do an
+`ls -AF` it might look something like this:
+
+           .git/      .gitignore    ChangeLog   LICENSE   Makefile.in
+           README     configure.ac  include/    src/
+
+* Then make a reference to _this_ project inside your project.
+
+           git remote add autoconf-macros git@github.com:NagiosEnterprises/autoconf-macros
+           git subtree add --prefix=macros/ autoconf-macros master
+
+* After executing the above two commands, if you do an `ls -AF` now,
+it should look like this:
+
+           .git/      .gitignore    ChangeLog   LICENSE   Makefile.in
+           README     configure.ac  include/    macros/   src/
+The `macros/` directory has been added.
+
+* Now do a `git push` to save everything.
+
+* If you make any changes to autoconf-macros, commit them separately
+from any parent-project changes to keep from polluting the commit
+history with unrelated comments.
+
+* To submit your changes to autoconf-macros:
+
+           git subtree push --prefix=macros autoconf-macros peters-updates
+This will create a new branch called `peters-updates`. You then need to
+create a _pull request_ to get your changes merged into autoconf-macros
+master.
+
+* To get the latest version of `autoconf-macros` into your parent project:
+
+           git subtgree pull --prefix=macros autoconf-macros master
+
+* If you already have an autoconf directory, such as `build_aux`, you can
+replace `--prefix=macros` with `--prefix=build_aux` in any of the
+commands above, or references below.
+
+
+## References
+
+Now that autoconf-macros is available to your project, you will need to
+reference it.
+
+* Create (or add these lines to) file `YourProject/aclocal.m4`
+
+           m4_include([macros/ax_nagios_get_os])
+           m4_include([macros/ax_nagios_get_distrib])
+           m4_include([macros/ax_nagios_get_init])
+           m4_include([macros/ax_nagios_get_inetd])
+           m4_include([macros/ax_nagios_get_paths])
+           m4_include([macros/ax_nagios_get_files])
+           m4_include([macros/ax_nagios_get_ssl])
+
+* In your `YourProject/configure.ac` add the following lines. A good place
+to put them would be right after any `AC_PROG_*` entries:
+
+           AC_NAGIOS_GET_OS
+           AC_NAGIOS_GET_DISTRIB_TYPE
+           AC_NAGIOS_GET_INIT
+           AC_NAGIOS_GET_INETD
+           AC_NAGIOS_GET_PATHS
+           AC_NAGIOS_GET_FILES
+
+* If you need SSL functionality, add the following to `YourProject/configure.ac`
+where you want to check for SSL:
+
+           AC_NAGIOS_GET_SSL
+
+* You will now be able to reference any of the variables in `config.h.in`
+and any files listed in the `AC_CONFIG_FILES` macro in `configure.ac`.
+
+
+
+
+
+
+
+<style>
+h1 { text-decoration:underline; color:#660000; }
+h2 { margin-top:2em; text-decoration:underline; color:#006600; }
+h3 { margin-top:1.5em; color:#000066 }
+blockquote { font-style:italic; font-weight:bold; }
+</style>

+ 158 - 0
ax_nagios_get_distrib

@@ -0,0 +1,158 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_DISTRIB_TYPE
+#
+# DESCRIPTION
+#
+#    This macro determines the O/S distribution of the computer it is run on.
+#    $dist_type will be set and will be one of:
+#        unknown (could not be determined)
+#        freebsd, netbsd, openbsd, dragonfly, etc (The BSDs)
+#        suse, rh, debian, gentoo (and possibly their descendants)
+#        Other major Linux distributions (and possibly their descendants)
+#        The O/S name for the rest
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_DISTRIB_TYPE], [AX_NAGIOS_GET_DISTRIB_TYPE])
+AC_DEFUN([AX_NAGIOS_GET_DISTRIB_TYPE],
+[
+
+AC_SUBST(dist_type)
+AC_SUBST(dist_ver)
+
+#
+# Get user hints for possible cross-compile
+#
+	AC_MSG_CHECKING(what the distribution type is )
+	AC_ARG_WITH(dist-type, AC_HELP_STRING([--with-dist-type=type],
+	[specify distribution type (suse, rh, debian, etc.)]),
+		[
+			#
+			# Run this if --with was specified
+			#
+			if test "x$withval" = x -o x$withval = xno; then
+				dist_type_wanted=yes
+			else
+				dist_type_wanted=no
+				dist_type="$withval"
+				dist_ver="unknown"
+				AC_MSG_RESULT($dist_type)
+			fi
+		], [
+			#
+			# Run this if --with was not specified
+			#
+			dist_type_wanted=yes
+		])
+
+		if test x$dist_type = xno; then
+			dist_type_wanted=yes
+		elif test x$dist_type = xyes; then
+			AC_MSG_ERROR([you must enter a distribution type if '--with-dist-type' is specified])
+		fi
+
+		#
+		# Determine distribution type if it wasn't supplied
+		#
+		dist_ver="unknown"
+
+		if test $dist_type_wanted=yes; then
+			dist_type="unknown"
+
+			if test "$opsys" != "linux"; then
+				dist_type="$opsys"
+				AS_CASE([$opsys],
+					[bsd],
+						dist_type=`uname -s | tr ["[A-Z]" "[a-z]"]`
+						dist_ver=`uname -r`,
+					[aix|hp-ux],
+						dist_ver=$OSTYPE,
+					[solaris],
+						dist_ver=`echo $OSTYPE | cut -d'.' -f2`,
+					[*],
+						dist_ver=$OSTYPE
+				)
+
+			else
+
+				if test -r "/etc/gentoo-release"; then
+					dist_type="gentoo"
+					dist_ver=`cat /etc/gentoo-release`
+
+				elif test -r "/etc/os-release"; then
+					. /etc/os-release
+					if test x"$ID_LIKE" != x; then
+						dist_type=`echo $ID_LIKE | cut -d' ' -f1 | tr ["[A-Z]" "[a-z]"]`
+					elif test x"$ID" = xol; then
+						dist_type=rh
+					else
+						dist_type=`echo $ID | tr ["[A-Z]" "[a-z]"]`
+					fi
+					if test x"$dist_type" = sles; then
+						dist_type=suse
+					fi
+					if test x"$VERSION_ID" != x; then
+						dist_ver=$VERSION_ID
+					elif test x"$VERSION" != x; then
+						dist_ver=`echo $VERSION | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
+					fi
+
+				elif test -r "/etc/redhat-release"; then
+					dist_type=rh
+					dist_ver=`cat /etc/redhat-release`
+
+				elif test -r "/etc/debian_version"; then
+					dist_type="debian"
+					if test -r "/etc/lsb-release"; then
+						. /etc/lsb-release
+						dist_ver=`echo "$DISTRIB_RELEASE"`
+					else
+						dist_ver=`cat /etc/debian_version`
+					fi
+
+				elif test -r "/etc/SuSE-release"; then
+					dist_type=suse
+					dist_ver=`grep VERSION /etc/SuSE-release`
+
+				fi
+
+			fi
+
+			if test "$dist_ver" != "unknown"; then
+				dist_ver=`echo "$dist_ver" | cut -d'.' -f1 | tr -d [:alpha:][:blank:][:punct:]`
+			fi
+		fi
+
+		AC_MSG_RESULT($dist_type)
+])

+ 131 - 0
ax_nagios_get_files

@@ -0,0 +1,131 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_FILES
+#
+# DESCRIPTION
+#
+#    This macro figures out which init and/or inetd files to use based
+#    on the results of the AX_NAGIOS_GET_OS, AX_NAGIOS_GET_DISTRIB_TYPE,
+#    AX_NAGIOS_GET_INIT and AX_NAGIOS_GET_INETD macros. It will select
+#    the appropriate files(s) from the 'startup' directory and copy it.
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_FILES], [AX_NAGIOS_GET_FILES])
+AC_DEFUN([AX_NAGIOS_GET_FILES],
+[
+
+AC_SUBST(src_init)
+AC_SUBST(src_inetd)
+AC_SUBST(src_tmpfile)
+AC_SUBST(bsd_enable)
+
+src_inetd=""
+src_init=""
+bsd_enable=""
+
+AC_MSG_CHECKING(for which init file to use )
+
+AS_CASE([$init_type],
+
+	[sysv],
+		src_init=default-init,
+
+	[systemd],
+		src_tmpfile=tmpfile.conf
+		src_init=default-service,
+
+	[bsd],
+		src_init=bsd-init,
+
+	[newbsd],
+		if test $dist_type = freebsd ; then
+			bsd_enable="_enable"
+			src_init=newbsd-init
+		elif test $dist_type = openbsd ; then
+			bsd_enable="_flags"
+			src_init=openbsd-init
+		elif test $dist_type = netbsd ; then
+			bsd_enable=""
+			src_init=newbsd-init
+		fi,
+
+#	[gentoo],
+
+	[openrc],
+		src_init=openrc-init,
+
+	[smf*],
+		src_init="solaris-init.xml"
+		src_inetd="solaris-inetd.xml",
+
+	[upstart],
+		if test $dist_type = rh ; then
+			src_init=rh-upstart-init
+		else
+			src_init=upstart-init
+		fi,
+
+	[launchd],
+		src_init="mac-init.plist"
+
+	[*],
+		src_init="unknown"
+)
+AC_MSG_RESULT($src_init)
+
+AC_MSG_CHECKING(for which inetd files to use )
+
+if test x$src_inetd = x; then
+
+	AS_CASE([$inetd_type],
+		[inetd*],
+			src_inetd=default-inetd,
+
+		[xinetd],
+			src_inetd=default-xinetd,
+
+		[systemd],
+			src_inetd=default-socket,
+
+		[launchd],
+			src_inetd="mac-inetd.plist",
+
+		[*],
+			src_inetd="unknown"
+	)
+
+fi
+AC_MSG_RESULT($src_inetd)
+
+])

+ 145 - 0
ax_nagios_get_inetd

@@ -0,0 +1,145 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_INETD
+#
+# DESCRIPTION
+#
+#    This macro determines whether inetd or xinetd is being used
+#    The argument are:
+#        the init type as determined by AX_NAGIOS_GET_INIT
+#    $inetd_type will be set and will be one of:
+#        unknown (could not be determined)
+#        launchd (Mac OS X)
+#        smf10   (Solaris)
+#        smf11   (Solaris)
+#        upstart (Older Debian)
+#        xinetd  (Most Linux, BSD)
+#        inetd   (The rest)
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_INETD], [AX_NAGIOS_GET_INETD])
+AC_DEFUN([AX_NAGIOS_GET_INETD],
+[
+
+AC_SUBST(inetd_type)
+
+#
+# Get user hints for possible cross-compile
+#
+	AC_MSG_CHECKING(what inetd is being used )
+	AC_ARG_WITH(inetd_type, AC_HELP_STRING([--with-inetd-type=type],
+	[which super-server the system runs (inetd, xinetd, systemd, launchd,
+	 smf10, smf11, etc.)]),
+		[
+			inetd_type_wanted=yes
+			#
+			# Run this if --with was specified
+			#
+			if test "x$withval" = x -o x$withval = xno; then
+				inetd_type_wanted=yes
+			else
+				inetd_type_wanted=no
+				inetd_type="$withval"
+				AC_MSG_RESULT($inetd_type)
+			fi
+		], [
+			#
+			# Run this if --with was not specified
+			#
+			inetd_type_wanted=yes
+		])
+
+		if test x$inetd_type = xno; then
+			inetd_type_wanted=yes
+		elif test x$inetd_type = xyes; then
+			AC_MSG_ERROR([you must enter an inetd type if '--with-inetd-type' is specified])
+		fi
+
+		#
+		# Determine inetd type if it wasn't supplied
+		#
+		if test $inetd_type_wanted = yes; then
+
+			inetd_disabled=""
+
+			if test x"$init_type" = "xupstart"; then
+				inetd_type="upstart"
+			elif test "$opsys" = "osx"; then
+				inetd_type="launchd"
+			fi
+
+			if test x"$inetd_type" = x; then
+				AS_CASE([$dist_type],
+					[solaris],
+						if test x"$init_type" = "xsmf10" -o x"$init_type" = "xsmf11"; then
+							inetd_type="$init_type"
+						else
+							inetd_type="inetd"
+						fi,
+
+					[*bsd*],
+						inetd_type=`ps -A -o comm -c | grep inetd`,
+
+					[aix|hp-ux],
+						inetd_type=`UNIX95= ps -A -o comm | grep inetd | head -1`,
+
+					[*],
+						inetd_type=[`ps -C "inetd,xinetd" -o fname | grep -vi COMMAND`])
+			fi
+
+			if test x"$inetd_type" = x; then
+				if test -f /etc/xinetd.conf -a -d /etc/xinetd.d; then
+					inetd_disabled="(Not running)"
+					inetd_type=xinetd
+				elif test -f /etc/inetd.conf -o -f /usr/sbin/inetd; then
+					inetd_type=inetd
+					inetd_disabled="(Not running)"
+				fi
+			fi
+
+			if test x"$inetd_type" = x; then
+				if test x"$init_type" = "xsystemd"; then
+					inetd_type="systemd"
+				else
+					inetd_type="unknown"
+				fi
+			fi
+
+			if test -n "$inetd_disabled"; then
+				AC_MSG_RESULT($inetd_type $inetd_disabled)
+			else
+				AC_MSG_RESULT($inetd_type)
+			fi
+		fi
+])

+ 195 - 0
ax_nagios_get_init

@@ -0,0 +1,195 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_INIT
+#
+# DESCRIPTION
+#
+#    This macro determines the O/S distribution of the computer it is run on.
+#    $init_type will be set and will be one of:
+#        unknown (could not be determined)
+#        launchd (Mac OS X)
+#        bsd     (Slackware Linux)
+#        newbsd  (FreeBSD, OpenBSD, NetBSD, Dragonfly, etc)
+#        smf10   (Solaris)
+#        smf11   (Solaris)
+#        systemd (Linux SystemD)
+#        gentoo  (Older Gentoo)
+#        openrc  (Recent Gentoo and some others)
+#        upstart (Older Debian)
+#        sysv    (The rest)
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_INIT], [AX_NAGIOS_GET_INIT])
+AC_DEFUN([AX_NAGIOS_GET_INIT],
+[
+
+AC_SUBST(init_type)
+
+#
+# Get user hints for possible cross-compile
+#
+	AC_MSG_CHECKING(what init system is being used )
+	AC_ARG_WITH(init_type,AC_HELP_STRING([--with-init-type=type],
+	 [specify init type (bsd, sysv, systemd, launchd, smf10, smf11, upstart,
+		openrc, etc.)]),
+		[
+			#
+			# Run this if --with was specified
+			#
+			if test "x$withval" = x -o x$withval = xno; then
+					init_type_wanted=yes
+			else
+					init_type_wanted=no
+					init_type="$withval"
+					AC_MSG_RESULT($init_type)
+			fi
+		], [
+			#
+			# Run this if --with was not specified
+			#
+			init_type_wanted=yes
+		])
+
+		if test x$init_type = xno; then
+			init_type_wanted=yes
+		elif test x$init_type = xyes; then
+			AC_MSG_ERROR([you must enter an init type if '--with-init-type' is specified])
+		fi
+
+		#
+		# Determine init type if it wasn't supplied
+		#
+		if test $init_type_wanted = yes; then
+			init_type=""
+
+			if test x"$opsys" = x; then
+				init_type="unknown"
+				init_type_wanted=no
+			elif test x"$dist_type" = x; then
+				init_type="unknown"
+				init_type_wanted=no
+			elif test "$opsys" = "osx"; then
+				init_type="launchd"
+				init_type_wanted=no
+			elif test "$opsys" = "bsd"; then
+				init_type="newbsd"
+				init_type_wanted=no
+			elif test "$dist_type" = "solaris"; then
+				if test -d "/lib/svc/manifest"; then
+					init_type="smf11"
+					init_type_wanted=no
+				elif test -d "/lib/svc/monitor"; then
+					init_type="smf10"
+					init_type_wanted=no
+				else
+					init_type="sysv"
+					init_type_wanted=no
+				fi
+			elif test "$dist_type" = "slackware"; then
+				init_type="bsd"
+				init_type_wanted=no
+			fi
+		fi
+
+		PSCMD="ps -p1 -o args"
+		AS_CASE([$dist_type],
+			[aix],		PSCMD="env UNIX95=1; ps -p1 -o args",
+			[solaris],	PSCMD="env UNIX95=1; ps -p1 -o args",
+			[hp-ux],	PSCMD="env UNIX95=1; ps -p1 -o args")
+
+		if test "$init_type_wanted" = yes; then
+			pid1=`$PSCMD | grep -vi COMMAND | cut -d' ' -f1`
+			if test x"$pid1" = "x"; then
+				init_type="unknown"
+				init_type_wanted=no
+			fi
+			if `echo $pid1 | grep "systemd" > /dev/null`; then
+				init_type="systemd"
+				init_type_wanted=no
+			fi
+
+			if test "$init_type_wanted" = yes; then
+				if test "$pid1" = "init"; then
+					if test -e "/sbin/init"; then
+						pid1="/sbin/init";
+					elif test -e "/usr/sbin/init"; then
+						pid1="/usr/sbin/init"
+					else
+						init_type="unknown"
+						init_type_wanted=no
+					fi
+				fi
+				if test -L "$pid1"; then
+					pid1=`readlink "$pid1"`
+				fi
+			fi
+
+			if test "$init_type_wanted" = yes; then
+				if `echo $pid1 | grep "systemd" > /dev/null`; then
+					init_type="systemd"
+					init_type_wanted=no
+				elif test -f "/sbin/rc"; then
+					if test -f /sbin/runscript; then
+						init_type_wanted=no
+						if `/sbin/start-stop-daemon -V | grep "OpenRC" > /dev/null`; then
+							init_type="openrc"
+						else
+							init_type="gentoo"
+						fi
+					fi
+				fi
+			fi
+
+			if test "$init_type_wanted" = yes; then
+				if test "$pid1" = "/sbin/init" -o "$pid1" = "/usr/sbin/init"; then
+					if `/sbin/init --version 2>/dev/null | grep "upstart" >/dev/null`; then
+						init_type="upstart"
+						init_type_wanted=no
+					elif test -f "/etc/rc" -a ! -L "/etc/rc"; then
+						init_type="newbsd"
+						init_type_wanted=no
+					else
+						init_type="sysv"
+						init_type_wanted=no
+					fi
+				fi
+			fi
+
+			if test "$init_type_wanted" = yes; then
+				init_type="unknown"
+			fi
+		fi
+
+		AC_MSG_RESULT($init_type)
+])

+ 101 - 0
ax_nagios_get_os

@@ -0,0 +1,101 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_OS
+#
+# DESCRIPTION
+#
+#    This macro determines the operating system of the computer it is run on.
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_OS], [AX_NAGIOS_GET_OS])
+AC_DEFUN([AX_NAGIOS_GET_OS],
+[
+
+AC_SUBST(opsys)
+AC_SUBST(arch)
+
+#
+# Get user hints
+#
+	AC_MSG_CHECKING(what the operating system is )
+	AC_ARG_WITH(opsys, AC_HELP_STRING([--with-opsys=OS],
+	[specify operating system (linux, osx, bsd, solaris, irix, cygwin,
+	 aix, hp-ux, etc.)]),
+		[
+			#
+			# Run this if --with was specified
+			#
+			if test "x$withval" = x -o x$withval = xno; then
+				opsys_wanted=yes
+			else
+				opsys_wanted=no
+				opsys="$withval"
+				AC_MSG_RESULT($opsys)
+			fi
+		], [
+			#
+			# Run this if --with was not specified
+			#
+			opsys_wanted=yes
+		])
+
+		if test x$opsys = xno; then
+			opsys=""
+			opsys_wanted=yes
+		elif test x$opsys = xyes; then
+			AC_MSG_ERROR([you must enter an O/S type if '--with-opsys' is specified])
+		fi
+
+		#
+		# Determine operating system if it wasn't supplied
+		#
+		if test $opsys_wanted=yes; then
+			opsys=`uname -s | tr ["[A-Z]" "[a-z]"]`
+			if test x"$opsys" = "x"; then opsys="unknown"; fi
+			AS_CASE([$opsys],
+				[darwin*],		opsys="osx",
+				[*bsd*],		opsys="bsd",
+				[dragonfly],	opsys="bsd",
+				[sunos],		opsys="solaris",
+				[gnu/hurd],		opsys="linux",
+				[irix*],		opsys="irix",
+				[cygwin*],		opsys="cygwin",
+				[mingw*],		opsys="mingw",
+				[msys*],		opsys="msys")
+		fi
+
+		arch=`uname -m | tr ["[A-Z]" "[a-z]"]`
+
+		AC_MSG_RESULT($opsys)
+])

+ 725 - 0
ax_nagios_get_paths

@@ -0,0 +1,725 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_PATHS
+#
+# DESCRIPTION
+#
+#    This macro figures out the installation & run paths for various systems
+#    The argument are:
+#        the O/S determined by the AX_NAGIOS_GET_OS macro.
+#        the distribution type as determined by AX_NAGIOS_GET_DISTRIB_TYPE
+#        the init type as determined by AX_NAGIOS_GET_INIT
+#        the inetd type as determined by AX_NAGIOS_GET_INETD
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_PATHS], [AX_NAGIOS_GET_PATHS])
+AC_DEFUN([AX_NAGIOS_GET_PATHS],
+[
+
+AC_SUBST(pkgsysconfdir)
+AC_SUBST(objsysconfdir)
+AC_SUBST(sbindir)
+AC_SUBST(initname)
+AC_SUBST(inetdname)
+AC_SUBST(pluginsdir)
+AC_SUBST(brokersdir)
+AC_SUBST(cgibindir)
+AC_SUBST(webdir)
+AC_SUBST(privatesysconfdir)
+AC_SUBST(pkglocalstatedir)
+AC_SUBST(logdir)
+AC_SUBST(piddir)
+AC_SUBST(pipedir)
+AC_SUBST(spooldir)
+AC_SUBST(initdir)
+AC_SUBST(inetddir)
+AC_SUBST(tmpfilesd)
+AC_SUBST(subsyslockdir)
+AC_SUBST(subsyslockfile)
+
+if test x$DBG_PATHS != x; then
+	echo
+	echo Incoming paths:
+	echo "    prefix        $prefix"
+	echo "    exec_prefix   $exec_prefix"
+	echo "    bindir        $bindir"
+	echo "    sbindir       $sbindir"
+	echo "    libexecdir    $libexecdir"
+	echo "    sysconfdir    $sysconfdir"
+	echo "    localstatedir $localstatedir"
+	echo "    datarootdir   $datarootdir"
+	echo "    datadir       $datadir"
+	echo "    localedir     $localedir"
+	echo
+fi
+
+AC_MSG_CHECKING(for which paths to use )
+
+AC_ARG_ENABLE(install_method,
+	AC_HELP_STRING([--enable-install-method=<method>],
+	[sets the install method to use: 'default' (the default) will install to
+	/usr/local/nagios, 'os' will try to determine which method to use based
+	on OS type and distribution. Fine tuning using the '--bindir', etc.
+	overrides above will still work]),
+	install_method=$enableval,
+	install_method=default
+)
+
+AC_ARG_ENABLE(showdirs_only,
+	AC_HELP_STRING([--enable-showdirs-only=yes],
+	[This option will cause 'configure' to stop after determining the install
+	 locations based on '--enable-install-method', so you can see the
+	 destinations before a full './configure', 'make', 'make install'
+	 process.]),
+	showdirs_only=$enableval,
+	showdirs_only=no
+)
+
+AS_CASE([$install_method],
+	[yes], install_method="os",
+	[no],  install_method="default",
+	[default|os], :,
+	[*], echo >&6; AC_MSG_ERROR(['--enable-install-method=$install_method' is invalid])
+)
+
+if test $showdirs_only != "no"; then showdirs_only="yes"; fi
+
+AS_CASE([$dist_type],
+	[*solaris*|*hp-ux*|*aix*|*osx*], opsys=unix)
+
+
+need_cgi=no
+need_web=no
+need_brk=no
+need_plg=no
+need_pipe=no
+need_spl=no
+need_loc=no
+need_log_subdir=no
+need_etc_subdir=no
+need_pls_dir=no
+
+AS_CASE([$PKG_NAME],
+	[nagios],
+		need_log_subdir=yes
+		need_etc_subdir=yes
+		need_pls_dir=yes
+		need_brk=yes
+		need_pipe=yes
+		need_spl=yes
+		need_loc=yes
+		need_cgi=yes
+		need_web=yes,
+
+	[ndoutils],
+		need_spl=yes,
+
+	[nrpe],
+		need_plg=yes,
+
+	[nsca],
+		need_cgi=no,
+
+	[plugins],
+		need_loc=yes
+		need_plg=yes
+)
+
+AC_ARG_WITH(pkgsysconfdir, AC_HELP_STRING([--with-pkgsysconfdir=DIR],
+	[where configuration files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		pkgsysconfdir="$withval"
+	fi)
+AC_ARG_WITH(objsysconfdir, AC_HELP_STRING([--with-objsysconfdir=DIR],
+	[where object configuration files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		objsysconfdir="$withval"
+	fi)
+AC_ARG_WITH(privatesysconfdir, AC_HELP_STRING([--with-privatesysconfdir=DIR],
+	[where private configuration files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		privatesysconfdir="$withval"
+	fi)
+AC_ARG_WITH(webdir, AC_HELP_STRING([--with-webdir=DIR],
+	[where the website files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		webdir="$withval"
+	fi)
+AC_ARG_WITH(pluginsdir, AC_HELP_STRING([--with-pluginsdir=DIR],
+	[where the plugins should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		pluginsdir="$withval"
+	fi)
+AC_ARG_WITH(brokersdir, AC_HELP_STRING([--with-brokersdir=DIR],
+	[where the broker modules should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		brokersdir="$withval"
+	fi)
+AC_ARG_WITH(cgibindir, AC_HELP_STRING([--with-cgibindir=DIR],
+	[where the CGI programs should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		cgibindir="$withval"
+	fi)
+AC_ARG_WITH(logdir, AC_HELP_STRING([--with-logdir=DIR],
+	[where log files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		logdir="$withval"
+	fi)
+AC_ARG_WITH(piddir, AC_HELP_STRING([--with-piddir=DIR],
+	[where the PID file should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		piddir="$withval"
+	fi)
+AC_ARG_WITH(pipedir, AC_HELP_STRING([--with-pipedir=DIR],
+	[where socket and pipe files should be placed]),
+	if test x$withval != x -a x$withval != xno -a x$withval != xyes; then
+		pipedir="$withval"
+	fi)
+
+
+#
+# Setup the base directory
+#
+
+if test $install_method = "default"; then
+	if test $opsys = "unix"; then
+		if test x"$prefix" = "xNONE"; then prefix="/usr/local/nagios"; fi
+	else
+		if test x"$prefix" = "xNONE"; then prefix=${ac_default_prefix}; fi
+	fi
+	datarootdir=${datarootdir="$prefix"}
+
+else
+	if test x"$datadir" = x'${datarootdir}'; then AS_UNSET(datadir); fi
+	if test x"$sysconfdir" = x'${prefix}/etc'; then AS_UNSET(sysconfdir); fi
+
+	if test x"$prefix" = "xNONE"; then
+		if test $dist_type = freebsd -o $dist_type = openbsd -o $dist_type = osx; then
+			prefix="/usr/local"
+		elif test $dist_type = netbsd; then
+			prefix="/usr/pkg"
+		else
+			prefix="/usr"
+		fi
+	fi
+	if test x"$exec_prefix" = "xNONE"; then exec_prefix=$prefix; fi
+	if test x"$localstatedir" = x'${prefix}/var'; then
+		if test $dist_type = "osx"; then
+			localstatedir="/private/var"
+		else
+			localstatedir="/var"
+		fi
+	fi
+
+	if test $opsys = "unix"; then
+		if test x"$datarootdir" = x'${prefix}/share'; then
+			if test $dist_type = "hp-ux"; then
+				datarootdir="/usr/local/share"
+				if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+					libexecdir="/usr/nagios"
+				fi
+			elif test $dist_type = "osx"; then
+				datarootdir="/usr/local/share"
+				if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+					libexecdir="/usr/local/nagios"
+				fi
+			elif test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+				libexecdir="/usr/lib/nagios"
+			fi
+		fi
+		if test $dist_type = "osx"; then
+			if test x"$sbindir" = x'${exec_prefix}/sbin'; then
+				sbindir="$libexecdir"
+			fi
+			if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+				libexecdir="/usr/local/libexec/nagios"
+			fi
+		fi
+	elif test $opsys = "bsd"; then
+		if test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+			libexecdir=${exec_prefix}/libexec/nagios;
+		fi
+	elif test x"$libexecdir" = x'${exec_prefix}/lib'; then
+		libexecdir=${libexecdir}/nagios;
+	elif test x"$libexecdir" = x'${exec_prefix}/libexec'; then
+		libexecdir=${exec_prefix}/lib/nagios;
+	fi
+
+fi
+
+if test x"$exec_prefix" = "xNONE"; then exec_prefix=${prefix}; fi
+
+tmpfilesd=${tmpfilesd="/usr/lib/tmpfiles.d"}
+if test ! -d "$tmpfilesd"; then
+	tmpfilesd="N/A"
+else
+	tmpfilesd="$tmpfilesd/$PKG_NAME.conf"
+fi
+subsyslockdir=${subsyslockdir="/var/lock/subsys"}
+if test ! -d "$subsyslockdir"; then
+	subsyslockdir="N/A"
+	subsyslockfile="N/A"
+else
+	subsyslockfile="$subsyslockdir/$PKG_NAME"
+fi
+if test "$need_loc" = no; then
+	localedir="N/A"
+fi
+
+if test $install_method = "default" ; then
+	#
+	# Do the default setup
+	#
+	sbindir=${bindir}
+	datadir=${datadir="$datarootdir"}
+	if test $need_web = yes; then
+		webdir=${webdir="$datadir"}
+	else
+		webdir="N/A"
+	fi
+	if test $opsys = "unix"; then
+		sysconfdir=${sysconfdir="/etc/opt"}
+	fi
+	pkgsysconfdir=${pkgsysconfdir="$sysconfdir"}
+	if test $need_etc_subdir = yes; then
+		objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
+	else
+		objsysconfdir="N/A"
+	fi
+	privatesysconfdir=${privatesysconfdir="$pkgsysconfdir"}
+	logdir=${logdir="$localstatedir"}
+	piddir=${piddir="$localstatedir"}
+	if test "$need_pipe" = yes; then
+		pipedir=${pipedir="$localstatedir/rw"}
+	else
+		pipedir="N/A"
+	fi
+	if test "$need_pls_dir" = yes; then
+		pkglocalstatedir=${pkglocalstatedir="$localstatedir"}
+	else
+		pkglocalstatedir="N/A"
+	fi
+	if test "$need_spl" = yes; then
+		spooldir=${spooldir="$localstatedir/var"}
+	else
+		spooldir="N/A"
+	fi
+	if test $need_brk = yes; then
+		brokersdir=${brokersdir="$bindir"}
+	else
+		brokersdir="N/A"
+	fi
+	if test $need_plg = yes; then
+		pluginsdir=${pluginsdir="$libexecdir"}
+	else
+		pluginsdir="N/A"
+	fi
+	if test $need_cgi = yes; then
+		cgibindir=${cgibindir="$prefix/sbin"}
+	else
+		cgibindir="N/A"
+	fi
+
+elif test $opsys = "linux"; then
+
+	#
+	# Linux "Standard" install
+	#
+	install_method="$install_method : FHS"
+	datadir=${datadir="$datarootdir/nagios"}
+	if test $need_web = yes; then
+		webdir=${webdir="$datadir/html"}
+	else
+		webdir="N/A"
+	fi
+	sysconfdir=${sysconfdir="/etc"}
+	pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
+	if test $need_etc_subdir = yes; then
+		objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
+	else
+		objsysconfdir="N/A"
+	fi
+	privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
+	if test $need_log_subdir = yes; then
+		logdir=${logdir="$localstatedir/log/$PKG_NAME"}
+	else
+		logdir=${logdir="$localstatedir/log"}
+	fi
+	piddir=${piddir="$localstatedir/run/${PKG_NAME}"}
+	if test "$need_pipe" = yes; then
+		pipedir=${pipedir="$localstatedir/run/${PKG_NAME}"}
+	else
+		pipedir="N/A"
+	fi
+	if test "$need_pls_dir" = yes; then
+		pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$PKG_NAME"}
+	else
+		pkglocalstatedir="N/A"
+	fi
+	if test "$need_spl" = yes; then
+		spooldir=${spooldir="$localstatedir/spool/$PKG_NAME"}
+	else
+		spooldir="N/A"
+	fi
+	if test $need_brk = yes; then
+		brokersdir=${brokersdir="$libexecdir/brokers"}
+	else
+		brokersdir="N/A"
+	fi
+	if test $need_plg = yes; then
+		pluginsdir=${pluginsdir="$libexecdir/plugins"}
+	else
+		pluginsdir="N/A"
+	fi
+	if test $need_cgi = yes; then
+		cgibindir=${cgibindir="$libexecdir/cgi-bin"}
+	else
+		cgibindir="N/A"
+	fi
+
+elif test $opsys = "unix"; then
+
+	#
+	# "Standard" Unix install
+	#
+	install_method="$install_method : Unix Standard"
+	if test $dist_type = osx; then
+		install_method="$install_method : OS X Standard"
+		sbindir=${sbindir="/usr/local/libexec"}
+	fi
+	datadir=${datadir="$datarootdir/nagios"}
+	if test $need_web = yes; then
+		webdir=${webdir="$datadir/html"}
+	else
+		webdir="N/A"
+	fi
+	if test $dist_type = osx; then
+		sysconfdir=${sysconfdir="/private/etc"}
+	else
+		sysconfdir=${sysconfdir="/etc"}
+	fi
+	pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
+	if test $need_etc_subdir = yes; then
+		objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
+	else
+		objsysconfdir="N/A"
+	fi
+	privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
+	if test "$need_pls_dir" = yes; then
+		pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$PKG_NAME"}
+	else
+		pkglocalstatedir="N/A"
+	fi
+	if test "$need_loc" = yes; then
+		localedir=${localedir="/usr/local/share/locale/<lang>/LC_MESSAGES/nagios-plugins.mo"}
+	fi
+	if test "$need_spl" = yes; then
+		spooldir=${spooldir="$localstatedir/spool/$PKG_NAME"}
+	else
+		spooldir="N/A"
+	fi
+	if test $need_brk = yes; then
+		brokersdir=${brokersdir="$libexecdir/brokers"}
+	else
+		brokersdir="N/A"
+	fi
+	if test $need_plg = yes; then
+		pluginsdir=${pluginsdir="$libexecdir/plugins"}
+	else
+		pluginsdir="N/A"
+	fi
+	if test $need_cgi = yes; then
+		cgibindir=${cgibindir="$libexecdir/cgi-bin"}
+	else
+		cgibindir="N/A"
+	fi
+	AS_CASE([$dist_type],
+		[*hp-ux*],
+			piddir=${piddir="$pkgsysconfdir"}
+			pipedir=${pipedir="$pkglocalstatedir"}
+			logdir=${logdir="$pkglocalstatedir/log"},
+
+		[*],
+			piddir=${piddir="$localstatedir/run/${PKG_NAME}"}
+			if test "$need_pipe" = yes; then
+				pipedir=${pipedir="$localstatedir/run/${PKG_NAME}"}
+			else
+				pipedir="N/A"
+			fi
+			if test $need_log_subdir = yes; then
+				logdir=${logdir="$localstatedir/log/$PKG_NAME"}
+			else
+				logdir=${logdir="$localstatedir/log"}
+			fi
+	)
+
+elif test $opsys = "bsd"; then
+
+	#
+	# "Standard" BSD install
+	#
+	install_method="$install_method : BSD"
+	if test $dist_type = freebsd -o $dist_type = openbsd; then
+		prefix=${prefix="/usr/local"}
+		exec_prefix=${exec_prefix="/usr/local"}
+		if test $dist_type = freebsd; then
+			install_method="$install_method : FreeBSD"
+		else
+			install_method="$install_method : OpenBSD"
+		fi
+	elif test $dist_type = netbsd; then
+		prefix=${prefix="/usr/pkg"}
+		exec_prefix=${exec_prefix="/usr/pkg"}
+		install_method="$install_method : NetBSD"
+	fi
+	datadir=${datadir="$datarootdir/nagios"}
+	if test $need_web = yes -o $need_cgi = yes; then
+		if test $dist_type = freebsd; then
+			webdir=${webdir="$prefix/www/nagios"}
+		elif test $dist_type = netbsd; then
+			webdir=${webdir="$prefix/share/nagios"}
+		elif test $dist_type = openbsd; then
+			webdir=${webdir="/var/www/nagios"}
+		fi
+	else
+		webdir="N/A"
+	fi
+	if test $dist_type = freebsd; then
+		sysconfdir=${sysconfdir="/usr/local/etc"}
+	else
+		sysconfdir=${sysconfdir="/etc"}
+	fi
+	pkgsysconfdir=${pkgsysconfdir="$sysconfdir/nagios"}
+	if test $need_etc_subdir = yes; then
+		objsysconfdir=${objsysconfdir="$pkgsysconfdir/objects"}
+	else
+		objsysconfdir="N/A"
+	fi
+	privatesysconfdir=${privatesysconfdir="$pkgsysconfdir/private"}
+	if test "$need_pls_dir" = yes; then
+		pkglocalstatedir=${pkglocalstatedir="$localstatedir/lib/$PKG_NAME"}
+	else
+		pkglocalstatedir="N/A"
+	fi
+	if test "$need_loc" = yes; then
+		localedir=${localedir="/usr/local/share/locale/<lang>/LC_MESSAGES/nagios-plugins.mo"}
+	fi
+	if test "$need_spl" = yes; then
+		spooldir=${spooldir="$localstatedir/spool/$PKG_NAME"}
+	else
+		spooldir="N/A"
+	fi
+	if test $need_brk = yes; then
+		brokersdir=${brokersdir="$libexecdir/brokers"}
+	else
+		brokersdir="N/A"
+	fi
+	if test $need_plg = yes; then
+		pluginsdir=${pluginsdir="$libexecdir/plugins"}
+	else
+		pluginsdir="N/A"
+	fi
+	if test $need_cgi = yes; then
+		if test $dist_type = freebsd; then
+			cgibindir=${cgibindir="$webdir/cgi-bin"}
+		elif test $dist_type = netbsd; then
+			cgibindir=${pluginsdir="$libexecdir/cgi-bin"}
+		elif test $dist_type = openbsd; then
+			cgibindir=${pluginsdir="/var/www/cgi-bin/nagios"}
+		fi
+	else
+		cgibindir="N/A"
+	fi
+	piddir=${piddir="$localstatedir/run/${PKG_NAME}"}
+	if test "$need_pipe" = yes; then
+		pipedir=${pipedir="$localstatedir/run/${PKG_NAME}"}
+	else
+		pipedir="N/A"
+	fi
+	if test $need_log_subdir = yes; then
+		logdir=${logdir="$localstatedir/log/$PKG_NAME"}
+	else
+		logdir=${logdir="$localstatedir/log"}
+	fi
+
+else
+
+	#
+	# Unknown install
+	#
+	install_method="unknown"
+	webdir=unknown
+	pkgsysconfdir=unknown
+	objsysconfdir=unknown
+	privatesysconfdir=unknown
+	logdir=unknown
+	piddir=unknown
+	pipedir=unknown
+	pkglocalstatedir=unknown
+	spooldir=unknown
+	brokersdir=unknown
+	pluginsdir=unknown
+	cgibindir=unknown
+
+fi
+
+eval prefix=$prefix
+eval exec_prefix=$exec_prefix
+eval bindir=$bindir
+eval sbindir=$sbindir
+eval datarootdir=$datarootdir
+eval datadir=$datadir
+eval libexecdir=$libexecdir
+eval brokersdir=$brokersdir
+eval pluginsdir=$pluginsdir
+eval cgibindir=$cgibindir
+eval pkglocalstatedir=$pkglocalstatedir
+eval webdir=$webdir
+eval localedir=$localedir
+eval sysconfdir=$sysconfdir
+eval pkgsysconfdir=$pkgsysconfdir
+eval piddir=$piddir
+
+#
+# Init scripts/files
+#
+AS_CASE([$init_type],
+
+	[sysv],
+		if test $dist_type = "hp-ux"; then
+			initdir=${initdir="/sbin/init.d"}
+		else
+			initdir=${initdir="/etc/init.d"}
+		fi
+		initname=${initname="$PKG_NAME"}
+		initconfdir=${initconfdir="/etc/conf.d"}
+		initconf=${initconf="$initconfdir/$PKG_NAME"},
+
+	[systemd],
+		if test $dist_type = "debian"; then
+			initdir=${initdir="/lib/systemd/system"}
+		else
+			initdir=${initdir="/usr/lib/systemd/system"}
+		fi
+		initname=${initname="$PKG_NAME.service"},
+
+	[bsd],
+		initdir=${initdir="/etc/rc.d"}
+		initname=${initname="rc.$PKG_NAME"},
+
+	[newbsd],
+		initdir=${initdir="/etc/rc.d"}
+		initname=${initname="$PKG_NAME"},
+
+	[gentoo],
+		initdir=${initdir="/etc/init.d"}
+		initname=${initname="$PKG_NAME"}
+		initconfdir=${initconfdir="/etc/init.d"}
+		initconf=${initconf="$initconfdir/$PKG_NAME"},
+
+	[openrc],
+		initdir=${initdir="/etc/init.d"}
+		initname=${initname="$PKG_NAME"}
+		initconfdir=${initconfdir="/etc/conf.d"}
+		initconf=${initconf="$initconfdir/$PKG_NAME"},
+
+	[smf*],
+		if test $init_type = smf10; then
+			initdir=${initdir="/var/svc/manifest/network/nagios"}
+		else
+			initdir=${initdir="/lib/svc/manifest/network/nagios"}
+		fi
+		initname=${initname="$PKG_NAME.xml"}
+		initconfdir=unknown
+		initconf=unknown,
+
+	[upstart],
+		initdir=${initdir="/etc/init"}
+		initname=${initname="$PKG_NAME.conf"}
+		initconfdir=${initconfdir="/etc/default"}
+		initconf=${initconf="$initconfdir/$PKG_NAME"},
+
+	[launchd],
+		initdir=${initdir="/Library/LaunchDaemons"}
+		initname=${initname="org.nagios.$PKG_NAME.plist"},
+#		initconfdir=${initconfdir="/private/etc"}
+#		initconf=${initconf="$initconfdir/$PKG_NAME"},
+
+
+	[*],
+		initdir=unknown
+		initname=unknown)
+
+#
+# Inetd (per connection) scripts/files
+#
+AS_CASE([$inetd_type],
+	[inetd*],
+		inetddir=${inetddir="/etc"}
+		inetdname=${inetdname="inetd.conf"},
+
+	[xinetd],
+		inetddir=${inetddir="/etc/xinetd.d"}
+		inetdname=${inetdname="$PKG_NAME"},
+
+	[systemd],
+		if test $dist_type = "debian"; then
+			inetddir=${inetddir="/lib/systemd/system"}
+		else
+			inetddir=${inetddir="/usr/lib/systemd/system"}
+		fi
+		netdname=${inetdname="$PKG_NAME.socket"},
+
+	[smf*],
+		if test $init_type = smf10; then
+			inetddir=${inetddir="/var/svc/manifest/network/nagios"}
+		else
+			inetddir=${inetddir="/lib/svc/manifest/network/nagios"}
+		fi
+		inetdname=${inetdname="$PKG_NAME.xml"},
+
+#	[upstart],
+#		inetddir=${inetddir="/etc/init.d"}
+#		inetdname=${inetdname="$PKG_NAME"},
+
+	[launchd],
+		inetddir=${inetddir="/Library/LaunchDaemons"}
+		inetdname=${inetdname="org.nagios.$PKG_NAME.plist"},
+
+	[*],
+		inetddir=${inetddir="unknown"}
+		inetdname=${inetdname="unknown"})
+
+AC_MSG_RESULT($install_method)
+])

+ 281 - 0
ax_nagios_get_ssl

@@ -0,0 +1,281 @@
+# ===========================================================================
+# SYNOPSIS
+#
+#   AX_NAGIOS_GET_SSL
+#
+# DESCRIPTION
+#
+#    This macro finds the openssl binary, the header files directory and
+#    the library files directory. It will also search for the gnutls
+#    compatibility library/headers and the nss compatibility library/headers.
+#
+# LICENSE
+#
+#    Copyright (c) 2016 Nagios Core Development Team
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 2 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+# ===========================================================================
+
+AU_ALIAS([AC_NAGIOS_GET_SSL], [AX_NAGIOS_GET_SSL])
+AC_DEFUN([AX_NAGIOS_GET_SSL],
+[
+
+# -------------------------------
+#  SSL library and include paths
+# -------------------------------
+
+SSL_TYPE=openssl
+ssl_dir=
+ssl_inc_dir=
+ssl_lib_dir=
+SSL_INC_DIR=
+SSL_LIB_DIR=
+
+AC_SUBST(HAVE_SSL)
+AC_SUBST(SSL_INC_DIR)
+AC_SUBST(SSL_LIB_DIR)
+
+
+# gnutls/openssl.h
+# nss_compat_ossl/nss_compat_ossl.h
+
+# Which type - openssl, gnutls-openssl, nss
+AC_ARG_WITH([ssl-type],
+dnl	AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls or nss to use one of these instead of openssl]),
+	AS_HELP_STRING([--with-ssl-type=TYPE],[replace TYPE with gnutls to use that instead of openssl]),
+	[SSL_TYPE=$withval])
+
+AC_ARG_WITH([ssl],
+	AS_HELP_STRING([--with-ssl=DIR],[sets location of the SSL installation]),
+	[ssl_dir=$withval])
+AC_ARG_WITH([ssl-inc],
+	AS_HELP_STRING([--with-ssl-inc=DIR],
+		[sets location of the SSL include files]),
+	[ssl_inc_dir=$withval])
+AC_ARG_WITH([ssl-lib],
+	AS_HELP_STRING([--with-ssl-lib=DIR],[sets location of the SSL libraries]),
+	[ssl_lib_dir=$withval])
+
+AC_ARG_WITH([kerberos-inc],
+	AS_HELP_STRING([--with-kerberos-inc=DIR],
+		[sets location of the Kerberos include files]),
+	[kerberos_inc_dir=$withval])
+
+if test x$SSL_TYPE = xyes; then
+    SSL_TYPE=openssl
+fi
+
+
+dflt_hdrs="$ssl_inc_dir $ssl_dir $ssl_dir/include $ssl_dir/include \
+			/usr/local/opt/{BBB} /usr/include/{BBB} /usr/local/include{BBB} \
+			/usr/local/{AAA} /usr/local/{BBB} /usr/lib/{AAA} /usr/lib/{BBB} \
+			/usr/{AAA} /usr/pkg /usr/local /usr /usr/freeware/lib/{BBB} \
+			/usr/sfw /usr/sfw/include /opt/{BBB}"
+
+dflt_libs="$ssl_lib_dir {ssldir} {ssldir}/lib {ssldir}/lib64 /usr/lib64 \
+			/usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu \
+			/usr/local/lib /usr/lib/{AAA} /usr/{AAA}/lib /usr/{BBB}/lib \
+			/usr/pkg/lib /usr/freeware/lib/{BBB} /usr/sfw/lib /opt/freeware/lib \
+			/opt/{BBB}/lib/hpux64 /opt/{BBB}/lib/pa20_64 /opt/{BBB}/lib/hpux32 \
+			/opt/{BBB}/lib /opt/{BBB}";
+
+
+AS_CASE([$SSL_TYPE],
+	[no], [SSL_TYPE=NONE],
+	[yes|openssl],
+		[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/ssl/g' | sed -e 's/{BBB}/openssl/g'`
+		 ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/ssl/g' | sed -e 's/{BBB}/openssl/g'`
+		 ssl_hdr=ssl.h
+		 ssl_lib=libssl],
+	[gnutls],
+		[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
+		 ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/gnutls/g' | sed -e 's/{BBB}/gnutls/g'`
+		 ssl_hdr=compat.h
+		 ssl_lib=libgnutls],
+	[nss],
+		[ssl_hdr_dirs=`echo "$dflt_hdrs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
+		 ssl_lib_dirs=`echo "$dflt_libs" | sed -e 's/{AAA}/nss_compat_ossl/g' | sed -e 's/{BBB}/nss_compat_ossl/g'`
+		 ssl_hdr=nss_compat_ossl.h
+		 ssl_lib=libnss_compat],
+	[*], echo >&6; AC_MSG_ERROR(['--with-ssl-type=$SSL_TYPE' is invalid])
+)
+
+
+# Check for SSL support
+
+if test x$SSL_TYPE != xNONE; then
+
+	found_ssl=no
+
+	# RedHat 8.0 and 9.0 include openssl compiled with kerberos,
+	# so we must include header file
+	# Must come before openssl checks for Redhat EL 3
+	AC_MSG_CHECKING(for Kerberos include files)
+	found_kerberos=no
+	for dir in $kerberos_inc_dir /usr/kerberos/include /usr/include/krb5 \
+				/usr/include; do
+		kerbdir="$dir"
+		if test -f "$dir/krb5.h"; then
+			found_kerberos=yes
+			CFLAGS="$CFLAGS -I$kerbdir"
+			AC_DEFINE_UNQUOTED(HAVE_KRB5_H,[1],[Have the krb5.h header file])
+			break
+		fi
+	done
+
+	if test x_$found_kerberos != x_yes; then
+		AC_MSG_WARN(could not find include files)
+	else
+		AC_MSG_RESULT(found Kerberos include files in $kerbdir)
+	fi
+
+	# First, try using pkg_config
+#	AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
+#	if test x"$PKG_CONFIG" != x ; then
+#		cflags=`$PKG_CONFIG $SSL_TYPE --cflags-only-I 2>/dev/null`
+#		if test $? = 0; then
+#			CFLAGS="$CFLAGS $cflags"
+#			LDFLAGS="$LDFLAGS `$PKG_CONFIG $SSL_TYPE --libs-only-L 2>/dev/null`"
+#			LIBS="$LIBS `$PKG_CONFIG $SSL_TYPE --libs-only-l 2>/dev/null`"
+#			found_ssl=yes
+#			AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
+#		fi
+#	fi
+
+	if test x_$found_ssl != x_yes; then
+
+		# Find the SSL Headers
+
+		AC_MSG_CHECKING(for SSL headers)
+		for dir in $ssl_hdr_dirs; do
+			ssldir="$dir"
+			if test -f "$dir/include/openssl/$ssl_hdr"; then
+				found_ssl=yes
+				CFLAGS="$CFLAGS -I$dir/include/openssl -I$ssldir/include"
+				SSL_INC_DIR="$dir/include/openssl"
+				break
+			fi
+			if test -f "$dir/include/$ssl_hdr"; then
+				found_ssl=yes
+				CFLAGS="$CFLAGS -I$dir/include"
+				SSL_INC_DIR="$dir/include"
+				break
+			fi
+			if test -f "$dir/$ssl_hdr"; then
+				found_ssl=yes
+				CFLAGS="$CFLAGS -I$dir"
+				SSL_INC_DIR="$dir"
+				ssldir="$dir/.."
+				break
+			fi
+			if test -f "$dir/openssl/$ssl_hdr"; then
+				found_ssl=yes
+				CFLAGS="$CFLAGS -I$dir/openssl"
+				SSL_INC_DIR="$dir/openssl"
+				ssldir="$dir/.."
+				break
+			fi
+		done
+
+		if test x_$found_ssl != x_yes; then
+			AC_MSG_ERROR(Cannot find ssl headers)
+		else
+			AC_MSG_RESULT(found in $ssldir)
+
+			# Now try and find SSL libraries
+
+			AC_MSG_CHECKING(for SSL libraries)
+			found_ssl=no
+			ssl_lib_dirs=`echo "$ssl_lib_dirs" | sed -e "s|{ssldir}|$ssldir|g"`
+
+			if test "`uname -s`" = "Darwin" ; then
+				soext="dylib"
+			elif test "`uname -s`" = "HP-UX" ; then
+				if test x$arch = "xia64"; then
+					soext="so"
+				else
+					soext="sl"
+				fi
+			elif test "`uname -s`" = "AIX" ; then
+				soext="a"
+			else
+				soext="so"
+			fi
+
+			for dir in $ssl_lib_dirs; do
+				if test -f "$dir/$ssl_lib.$soext"; then
+					found_ssl=yes
+					SSL_LIB_DIR="$dir"
+					break
+				fi
+			done
+
+			if test x_$found_ssl != x_yes; then
+				AC_MSG_ERROR(Cannot find ssl libraries)
+			else
+				AC_MSG_RESULT(found in $SSL_LIB_DIR)
+
+				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR";
+				LIBS="$LIBS -l`echo $ssl_lib | sed -e 's/^lib//'` -lcrypto";
+				AC_DEFINE_UNQUOTED(HAVE_SSL,[1],[Have SSL support])
+			fi
+		fi
+	fi
+
+	if test x$found_ssl = xyes ; then
+		# try to compile and link to see if SSL is set up properly
+		AC_MSG_CHECKING([whether compiling and linking against SSL works])
+
+		AC_LINK_IFELSE(
+			[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
+			[
+				AC_MSG_RESULT([yes])
+				$1
+			], [
+				AC_MSG_ERROR([no])
+				$2
+			])
+	fi
+
+	if test x$found_ssl = xyes -a x$need_dh = xyes; then
+
+		# Find the openssl program
+
+		if test x$need_dh = xyes; then
+			AC_PATH_PROG(sslbin,openssl,value-if-not-found,$ssl_dir/sbin$PATH_SEPARATOR$ssl_dir/bin$PATH_SEPARATOR$PATH)
+			AC_DEFINE(USE_SSL_DH)
+			# Generate DH parameters
+			if test -f "$sslbin"; then
+				echo ""
+				echo "*** Generating DH Parameters for SSL/TLS ***"
+				# awk to strip off meta data at bottom of dhparam output
+				$sslbin dhparam -C 2048 | awk '/^-----/ {exit} {print}' > include/dh.h
+			fi
+		fi
+	fi
+fi
+])