]> granicus.if.org Git - php/commitdiff
Fix build problems with UCD-SNMP 4.1.x.
authorSascha Schumann <sas@php.net>
Sun, 19 Mar 2000 12:38:53 +0000 (12:38 +0000)
committerSascha Schumann <sas@php.net>
Sun, 19 Mar 2000 12:38:53 +0000 (12:38 +0000)
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
ext/snmp/snmp.c

index 9d59f2501eb3bbc8d8dbe6473f21c21fd4bc36da..c1d35fc4e7b51f18c58b6be516aa3dfd5e709b1d 100644 (file)
@@ -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 <evp.h>)
+  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 <ucd-snmp-config.h>
+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"
index 1a075c70a2b7bcd3957746fbe7576597c85a0c0a..90649a4c3909ba2d5cfb70878f704c62045990f3 100644 (file)
@@ -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"