From e5ceb99a1e517b797a31ddf040e27f6bbfa9f38d Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Sun, 19 Mar 2000 12:38:53 +0000 Subject: [PATCH] Fix build problems with UCD-SNMP 4.1.x. First, we need to include default_store.h. Second, UCD-SNMP supports OpenSSL now, so we additionally need to link against that. The changes should be completely backwards-compatible. Partly suggested by: thor2001@gmx.net PR: #3451, #3668, #3868 --- ext/snmp/config.m4 | 54 +++++++++++++++++++++++++++++++++++++++++++++- ext/snmp/snmp.c | 3 +++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index 9d59f2501e..c1d35fc4e7 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -1,5 +1,37 @@ dnl $Id$ +AC_ARG_WITH(openssl, +[ --with-openssl[=DIR] Include OpenSSL support in SNMP.],[ + PHP_OPENSSL=$withval +],[ + PHP_OPENSSL=no +]) + +AC_DEFUN(PHP_SETUP_OPENSSL,[ + for i in /usr/local/ssl /usr/local /usr /usr/local/openssl $PHP_OPENSSL; do + if test -r $i/include/openssl/evp.h; then + OPENSSL_DIR=$i + OPENSSL_INC=$i/include/openssl + elif test -r $i/include/evp.h; then + OPENSSL_DIR=$i + OPENSSL_INC=$i/include + fi + done + + AC_MSG_CHECKING(for OpenSSL) + + if test -z "$OPENSSL_DIR"; then + AC_MSG_ERROR(Cannot find OpenSSL's ) + fi + + AC_MSG_RESULT($OPENSSL_DIR, Include files in $OPENSSL_INC) + + AC_ADD_LIBPATH($OPENSSL_DIR/lib) + AC_ADD_LIBRARY(ssl, yes) + AC_ADD_LIBRARY(crypto, yes) + AC_ADD_INCLUDE($OPENSSL_INC) +]) + AC_MSG_CHECKING(for SNMP support) AC_ARG_WITH(snmp, [ --with-snmp[=DIR] Include SNMP support. DIR is the SNMP base @@ -51,7 +83,27 @@ AC_ARG_WITH(snmp, AC_ADD_INCLUDE($SNMP_INCDIR) SNMP_STATIC="libphpext_snmp.la" fi - PHP_EXTENSION(snmp,$shared) + old_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$INCLUDES $CPPFLAGS" + AC_CHECK_HEADERS(default_store.h) + if test "$ac_cv_header_default_store_h" = "yes"; then + dnl UCD SNMP 4.1.x + AC_TRY_RUN([ +#include +main() { exit(USE_OPENSSL != 1); } + ],[ + SNMP_SSL=yes + ],[ + SNMP_SSL=no + ],[ + SNMP_SSL=no + ]) + if test "$SNMP_SSL" = "yes"; then + PHP_SETUP_OPENSSL + fi + fi + CPPFLAGS="$old_CPPFLAGS" + PHP_EXTENSION(snmp,$shared) AC_CHECK_LIB(kstat, kstat_read, [ if test "$shared" = yes; then KSTAT_LIBS="-lkstat" diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 1a075c70a2..90649a4c39 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -54,6 +54,9 @@ #endif #endif +#ifdef HAVE_DEFAULT_STORE_H +#include "default_store.h" +#endif #include "asn1.h" #include "snmp_api.h" #include "snmp_client.h" -- 2.50.1