Bläddra i källkod

Fix compilation on AIX

Detect if linker supports rpath option.
Only use rpath if it is required (missing library or version mismatch).
Add Makefile recipe for snprintf.o as AIX libc doesn't have asprintf.
Doug Nazar 1 år sedan
förälder
incheckning
9766a6d814

+ 75 - 7
aclocal.m4

@@ -1,7 +1,75 @@
-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])
+# generated automatically by aclocal 1.17 -*- Autoconf -*-
+
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the linker or gives an error.
+#   (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AC_DEFUN([AX_CHECK_LINK_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS $4 $1"
+  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  LDFLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_LINK_FLAGS
+
+m4_include([macros/ax_nagios_get_distrib.m4])
+m4_include([macros/ax_nagios_get_files.m4])
+m4_include([macros/ax_nagios_get_inetd.m4])
+m4_include([macros/ax_nagios_get_init.m4])
+m4_include([macros/ax_nagios_get_os.m4])
+m4_include([macros/ax_nagios_get_paths.m4])
+m4_include([macros/ax_nagios_get_ssl.m4])

+ 148 - 70
configure

@@ -720,7 +720,6 @@ infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -823,7 +822,6 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1076,15 +1074,6 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1222,7 +1211,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1804,7 +1793,7 @@ else
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 if (sizeof ($2))
 	 return 0;
@@ -1817,7 +1806,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 if (sizeof (($2)))
 	    return 0;
@@ -1855,7 +1844,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(($2) >= 0)];
 test_array [0] = 0;
@@ -1872,7 +1861,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
 test_array [0] = 0;
@@ -1899,7 +1888,7 @@ else
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(($2) < 0)];
 test_array [0] = 0;
@@ -1916,7 +1905,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(($2) >= $ac_mid)];
 test_array [0] = 0;
@@ -1951,7 +1940,7 @@ while test "x$ac_lo" != "x$ac_hi"; do
 /* end confdefs.h.  */
 $4
 int
-main ()
+main (void)
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
 test_array [0] = 0;
@@ -1976,12 +1965,12 @@ esac
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $4
-static long int longval () { return $2; }
-static unsigned long int ulongval () { return $2; }
+static long int longval (void) { return $2; }
+static unsigned long int ulongval (void) { return $2; }
 #include <stdio.h>
 #include <stdlib.h>
 int
-main ()
+main (void)
 {
 
   FILE *f = fopen ("conftest.val", "w");
@@ -2088,7 +2077,7 @@ else
 #define $2 innocuous_$2
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
+    which can conflict with char $2 (void); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -2106,7 +2095,7 @@ else
 #ifdef __cplusplus
 extern "C"
 #endif
-char $2 ();
+char $2 (void);
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
@@ -2115,7 +2104,7 @@ choke me
 #endif
 
 int
-main ()
+main (void)
 {
 return $2 ();
   ;
@@ -2504,6 +2493,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
 
+
 PKG_NAME=nrpe
 PKG_VERSION="4.1.3"
 PKG_HOME_URL="http://www.nagios.org/"
@@ -3902,7 +3892,8 @@ $as_echo "$src_inetd" >&6; }
 
 
 if test "$dist_type" = solaris -a "$dist_ver" = 10; then
-	$as_echo "#define SOLARIS_10 yes" >>confdefs.h
+
+$as_echo "#define SOLARIS_10 1" >>confdefs.h
 
 fi
 
@@ -5329,7 +5320,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -5469,7 +5460,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdio.h>
 int
-main ()
+main (void)
 {
 FILE *f = fopen ("conftest.out", "w");
  return ferror (f) || fclose (f) != 0;
@@ -5533,7 +5524,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -5584,7 +5575,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 #ifndef __GNUC__
        choke me
@@ -5625,7 +5616,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -5640,7 +5631,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -5656,7 +5647,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -5705,9 +5696,7 @@ struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
+static char *e (char **p, int i)
 {
   return p[i];
 }
@@ -5742,7 +5731,7 @@ int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, i
 int argc;
 char **argv;
 int
-main ()
+main (void)
 {
 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   ;
@@ -6100,7 +6089,7 @@ else
 #include <float.h>
 
 int
-main ()
+main (void)
 {
 
   ;
@@ -6170,7 +6159,7 @@ else
 
 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 int
-main ()
+main (void)
 {
   int i;
   for (i = 0; i < 256; i++)
@@ -6211,7 +6200,7 @@ else
 #include <time.h>
 
 int
-main ()
+main (void)
 {
 if ((struct tm *) 0)
 return 0;
@@ -6251,7 +6240,7 @@ else
 #endif
 
 int
-main ()
+main (void)
 {
   int s;
   wait (&s);
@@ -6366,7 +6355,7 @@ else
 /* end confdefs.h.  */
 
 int
-main ()
+main (void)
 {
 
 #ifndef __cplusplus
@@ -6449,7 +6438,7 @@ else
 #include <time.h>
 
 int
-main ()
+main (void)
 {
 struct tm tm;
 				     int *p = &tm.tm_sec;
@@ -6517,7 +6506,7 @@ else
 #include <signal.h>
 
 int
-main ()
+main (void)
 {
 return *(signal (0, 0)) (0) == 1;
   ;
@@ -6586,7 +6575,7 @@ $ac_includes_default
 #define MAX(x, y) ((x) > (y) ? (x) : (y))
 
 int
-main ()
+main (void)
 {
   gid_t gidset[NGID];
   int i, n;
@@ -6830,10 +6819,12 @@ fi
 
 ac_fn_c_check_func "$LINENO" "seteuid" "ac_cv_func_seteuid"
 if test "x$ac_cv_func_seteuid" = xyes; then :
-  $as_echo "#define SETEUID(id) seteuid(id)" >>confdefs.h
+
+$as_echo "#define SETEUID(id) seteuid(id)" >>confdefs.h
 
 else
-  $as_echo "#define SETEUID(id) setresuid((uid_t) -1, id, (uid_t) -1)" >>confdefs.h
+
+$as_echo "#define SETEUID(id) setresuid((uid_t) -1, id, (uid_t) -1)" >>confdefs.h
 
 
 fi
@@ -6850,7 +6841,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #include <stdarg.h>
 va_list ap1,ap2;
 int
-main ()
+main (void)
 {
 va_copy(ap1,ap2);
   ;
@@ -6883,7 +6874,7 @@ else
 #include <stdarg.h>
 	va_list ap1,ap2;
 int
-main ()
+main (void)
 {
 __va_copy(ap1,ap2);
   ;
@@ -6911,28 +6902,28 @@ ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf"
 if test "x$ac_cv_func_vsnprintf" = xyes; then :
 
 else
-  SNPRINTF_O=./snprintf.o
+  SNPRINTF_O=snprintf.o
 fi
 
 ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
 if test "x$ac_cv_func_snprintf" = xyes; then :
 
 else
-  SNPRINTF_O=./snprintf.o
+  SNPRINTF_O=snprintf.o
 fi
 
 ac_fn_c_check_func "$LINENO" "asprintf" "ac_cv_func_asprintf"
 if test "x$ac_cv_func_asprintf" = xyes; then :
 
 else
-  SNPRINTF_O=./snprintf.o
+  SNPRINTF_O=snprintf.o
 fi
 
 ac_fn_c_check_func "$LINENO" "vasprintf" "ac_cv_func_vasprintf"
 if test "x$ac_cv_func_vasprintf" = xyes; then :
 
 else
-  SNPRINTF_O=./snprintf.o
+  SNPRINTF_O=snprintf.o
 fi
 
 
@@ -7016,9 +7007,9 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char getopt_long ();
+char getopt_long (void);
 int
-main ()
+main (void)
 {
 return getopt_long ();
   ;
@@ -7056,7 +7047,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 
 
 int
-main ()
+main (void)
 {
 return main ();
   ;
@@ -7094,9 +7085,9 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char socket ();
+char socket (void);
 int
-main ()
+main (void)
 {
 return socket ();
   ;
@@ -7148,7 +7139,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 
 
 int
-main ()
+main (void)
 {
 return main ();
   ;
@@ -7177,7 +7168,7 @@ $as_echo "#define HAVE_LIBWRAP 1" >>confdefs.h
 #include <tcpd.h>
 
 int
-main ()
+main (void)
 {
 int a = rfc931_timeout;
   ;
@@ -7185,7 +7176,8 @@ int a = rfc931_timeout;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  $as_echo "#define HAVE_RFC931_TIMEOUT 1" >>confdefs.h
+
+$as_echo "#define HAVE_RFC931_TIMEOUT 1" >>confdefs.h
 
 fi
 rm -f core conftest.err conftest.$ac_objext \
@@ -7245,7 +7237,7 @@ else
 					int getpeername (int, $arg2 *, $t *);
 
 int
-main ()
+main (void)
 {
 
 					$t len;
@@ -7291,7 +7283,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #include <sys/socket.h>
 
 int
-main ()
+main (void)
 {
 int a = send(1, (const void *)0, (size_t *) 0, (int *) 0);
   ;
@@ -7654,6 +7646,43 @@ $as_echo "found in $sslincdir" >&6; }
 
 			# Now try and find SSL libraries
 
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,-rpath,/" >&5
+$as_echo_n "checking whether the linker accepts -Wl,-rpath,/... " >&6; }
+if ${ax_cv_check_ldflags___Wl__rpath__+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS  -Wl,-rpath,/"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ax_cv_check_ldflags___Wl__rpath__=yes
+else
+  ax_cv_check_ldflags___Wl__rpath__=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl__rpath__" >&5
+$as_echo "$ax_cv_check_ldflags___Wl__rpath__" >&6; }
+if test "x$ax_cv_check_ldflags___Wl__rpath__" = xyes; then :
+  RPATH=yes
+else
+  RPATH=no
+fi
+
+
 			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL libraries" >&5
 $as_echo_n "checking for SSL libraries... " >&6; }
 			found_ssl=no
@@ -7692,12 +7721,59 @@ $as_echo_n "checking for SSL libraries... " >&6; }
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found in $SSL_LIB_DIR" >&5
 $as_echo "found in $SSL_LIB_DIR" >&6; }
 
-				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR -Wl,-rpath,$SSL_LIB_DIR";
+				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR";
 				LIBS="$LIBS -l`echo $ssl_lib | sed -e 's/^lib//'` -lcrypto";
 
-cat >>confdefs.h <<_ACEOF
-#define HAVE_SSL 1
+				if test x$RPATH == xyes ; then
+					# Do we need to add rpath?
+					if test -n "$SSL_INC_PREFIX" ; then
+						tmp_prefix="${SSL_INC_PREFIX}/"
+					fi
+
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: checking checking if rpath is required..." >&5
+$as_echo_n "checking checking if rpath is required...... " >&6; }
+					if test "$cross_compiling" = yes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+							#include <${tmp_prefix}opensslv.h>
+							#include <${tmp_prefix}crypto.h>
+
+int
+main (void)
+{
+
+							#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+								return OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+							#else
+								return SSLeay() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+							#endif
+
+  ;
+  return 0;
+}
 _ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+						 LDFLAGS="$LDFLAGS -Wl,-rpath,$SSL_LIB_DIR"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+					tmp_prefix=""
+				fi
+
+$as_echo "#define HAVE_SSL 1" >>confdefs.h
 
 			fi
 		fi
@@ -7716,7 +7792,7 @@ $as_echo_n "checking whether compiling and linking against SSL works... " >&6; }
 /* end confdefs.h.  */
 #include <${SSL_INC_PREFIX}${SSL_HDR}>
 int
-main ()
+main (void)
 {
 SSL_new(NULL)
   ;
@@ -7749,7 +7825,7 @@ rm -f core conftest.err conftest.$ac_objext \
 				#include <${SSL_INC_PREFIX}${SSL_HDR}>
 
 int
-main ()
+main (void)
 {
 
 				#ifdef OPENSSL_VERSION_MAJOR
@@ -7780,7 +7856,8 @@ rm -f core conftest.err conftest.$ac_objext \
 		fi
 
 		if test x$auto_dh = xyes; then
-			$as_echo "#define AUTO_SSL_DH 1" >>confdefs.h
+
+$as_echo "#define AUTO_SSL_DH 1" >>confdefs.h
 
 		fi
 
@@ -7843,7 +7920,8 @@ fi
 				SSL_DH_HEADER=../include/dh.h
 
 			fi
-			$as_echo "#define USE_SSL_DH 1" >>confdefs.h
+
+$as_echo "#define USE_SSL_DH 1" >>confdefs.h
 
 		fi
 	fi

+ 10 - 9
configure.ac

@@ -8,6 +8,7 @@ m4_include([build-aux/custom_help.m4])
 AC_INIT([nrpe],[newdate],[nagios-users@lists.sourceforge.net],[nrpe],[https://www.nagios.org/downloads/nagios-core-addons/])
 AC_CONFIG_SRCDIR([src/nrpe.c])
 AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([macros])
 AC_PREFIX_DEFAULT(/usr/local/nagios)
 
 PKG_NAME=nrpe
@@ -61,7 +62,7 @@ AC_NAGIOS_GET_PATHS
 AC_NAGIOS_GET_FILES
 
 if test "$dist_type" = solaris -a "$dist_ver" = 10; then
-	AC_DEFINE(SOLARIS_10,yes)
+	AC_DEFINE(SOLARIS_10,[1],[Set to 1 if we are on Solaris 10])
 fi
 
 dnl Do they just want to see where things will go?
@@ -171,8 +172,8 @@ AC_CHECK_TYPES([struct sockaddr_storage],[],[],[#include <sys/socket.h>])
 
 dnl Should we use seteuid() or setresuid()?
 AC_CHECK_FUNC(seteuid,
-	AC_DEFINE(SETEUID(id),[seteuid(id)]),
-	AC_DEFINE(SETEUID(id),[setresuid((uid_t) -1, id, (uid_t) -1)])
+	AC_DEFINE(SETEUID(id),[seteuid(id)],[Use seteuid() or setresuid() depending on the platform]),
+	AC_DEFINE(SETEUID(id),[setresuid((uid_t) -1, id, (uid_t) -1)],[Use seteuid() or setresuid() depending on the platform])
 )
 
 dnl Check for asprintf() and friends...
@@ -194,10 +195,10 @@ else
 	fi
 fi
 
-AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(snprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(asprintf,,SNPRINTF_O=./snprintf.o)
-AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=./snprintf.o)
+AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(snprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(asprintf,,SNPRINTF_O=snprintf.o)
+AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=snprintf.o)
 
 AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
 AC_TRY_RUN([
@@ -229,7 +230,7 @@ if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
 	AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
 fi
 
-dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=./snprintf.o)
+dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=snprintf.o)
 
 dnl Check for getopt_long (Solaris)
 AC_CHECK_FUNCS([getopt_long],,AC_CHECK_LIB([iberty],[getopt_long],OTHERLIBS="$OTHERLIBS -liberty"))
@@ -253,7 +254,7 @@ if test x$check_for_tcpd != xno; then
 		LIBWRAPLIBS="$LIBWRAPLIBS -lwrap"
 		AC_DEFINE(HAVE_LIBWRAP,[1],[Have the TCP wrappers library])
 		AC_TRY_LINK([#include <tcpd.h>
-			],[int a = rfc931_timeout;],AC_DEFINE(HAVE_RFC931_TIMEOUT))
+			],[int a = rfc931_timeout;],AC_DEFINE(HAVE_RFC931_TIMEOUT, [1], [Set to 1 if you have rfc931_timeout]))
 	],[
 		if test x$check_for_tcpd = xyes; then
 			AC_MSG_ERROR(--enable-tcpd specified but unable to locate libwrap.)

+ 0 - 0
macros/ax_nagios_get_distrib → macros/ax_nagios_get_distrib.m4


+ 0 - 0
macros/ax_nagios_get_files → macros/ax_nagios_get_files.m4


+ 0 - 0
macros/ax_nagios_get_inetd → macros/ax_nagios_get_inetd.m4


+ 0 - 0
macros/ax_nagios_get_init → macros/ax_nagios_get_init.m4


+ 0 - 0
macros/ax_nagios_get_os → macros/ax_nagios_get_os.m4


+ 0 - 0
macros/ax_nagios_get_paths → macros/ax_nagios_get_paths.m4


+ 33 - 4
macros/ax_nagios_get_ssl → macros/ax_nagios_get_ssl.m4

@@ -242,6 +242,8 @@ if test x$SSL_TYPE != xNONE; then
 
 			# Now try and find SSL libraries
 
+			AX_CHECK_LINK_FLAG([-Wl,-rpath,/], [RPATH=yes], [RPATH=no])
+
 			AC_MSG_CHECKING(for SSL libraries)
 			found_ssl=no
 			ssl_lib_dirs=`echo "$ssl_lib_dirs" | sed -e "s|{ssldir}|$ssldir|g"`
@@ -278,9 +280,36 @@ if test x$SSL_TYPE != xNONE; then
 			else
 				AC_MSG_RESULT(found in $SSL_LIB_DIR)
 
-				LDFLAGS="$LDFLAGS -L$SSL_LIB_DIR -Wl,-rpath,$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])
+
+				if test x$RPATH == xyes ; then
+					# Do we need to add rpath?
+					if test -n "$SSL_INC_PREFIX" ; then
+						tmp_prefix="${SSL_INC_PREFIX}/"
+					fi
+
+					AC_MSG_CHECKING([checking if rpath is required...])
+					AC_RUN_IFELSE(
+						[AC_LANG_PROGRAM([[
+							#include <${tmp_prefix}opensslv.h>
+							#include <${tmp_prefix}crypto.h>
+						]],[[
+							#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+								return OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+							#else
+								return SSLeay() == OPENSSL_VERSION_NUMBER ? EXIT_SUCCESS : EXIT_FAILURE;
+							#endif
+						]])],
+						[AC_MSG_RESULT([no])],
+						[AC_MSG_RESULT([yes])
+						 LDFLAGS="$LDFLAGS -Wl,-rpath,$SSL_LIB_DIR"],
+						[AC_MSG_RESULT([no])]
+					)
+
+					tmp_prefix=""
+				fi
+				AC_DEFINE([HAVE_SSL], [1], [Have SSL support])
 			fi
 		fi
 	fi
@@ -333,7 +362,7 @@ if test x$SSL_TYPE != xNONE; then
 		fi
 
 		if test x$auto_dh = xyes; then
-			AC_DEFINE(AUTO_SSL_DH)
+			AC_DEFINE([AUTO_SSL_DH], [1], [Define to 1 to auto configure SSL DH parameters])
 		fi
 
 
@@ -353,7 +382,7 @@ if test x$SSL_TYPE != xNONE; then
 
 				AC_SUBST(SSL_DH_HEADER,../include/dh.h)
 			fi
-			AC_DEFINE(USE_SSL_DH)
+			AC_DEFINE([USE_SSL_DH], [1], [Define to 1 to use SSL DH])
 		fi
 	fi
 fi

+ 3 - 0
src/Makefile.in

@@ -55,6 +55,9 @@ check_nrpe: $(srcdir)/check_nrpe.c utils.o $(SRC_INCLUDE)/utils.h $(CFG_INCLUDE)
 utils.o: $(srcdir)/utils.c $(SRC_INCLUDE)/utils.h $(CFG_INCLUDE)/common.h $(CFG_INCLUDE)/config.h
 	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/utils.c
 
+snprintf.o: $(srcdir)/snprintf.c
+	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/snprintf.c
+
 nrpe-ssl.o: $(srcdir)/nrpe-ssl.c $(SRC_INCLUDE)/nrpe-ssl.h $(CFG_INCLUDE)/common.h $(CFG_INCLUDE)/config.h
 	$(CC) $(CFLAGS) -c -o $@ $(srcdir)/nrpe-ssl.c