1PHP_ARG_WITH([snmp], 2 [for SNMP support], 3 [AS_HELP_STRING([[--with-snmp[=DIR]]], 4 [Include SNMP support. Use PKG_CONFIG_PATH (or SNMP_CFLAGS and SNMP_LIBS) 5 environment variables, or alternatively the optional DIR argument to 6 customize where to look for the net-snmp-config utility of the NET-SNMP 7 library.])]) 8 9if test "$PHP_SNMP" != "no"; then 10 snmp_found=no 11 AS_VAR_IF([PHP_SNMP], [yes], 12 [PKG_CHECK_MODULES([SNMP], [netsnmp >= 5.3], [snmp_found=yes], [:])]) 13 14 AS_VAR_IF([snmp_found], [no], [ 15 AS_VAR_IF([PHP_SNMP], [yes], 16 [AC_PATH_PROG([SNMP_CONFIG], [net-snmp-config],, [/usr/local/bin:$PATH])], 17 [SNMP_CONFIG="$PHP_SNMP/bin/net-snmp-config"]) 18 19 AS_IF([test ! -x "$SNMP_CONFIG"], 20 [AC_MSG_ERROR(m4_text_wrap([ 21 Could not find net-snmp-config binary. Please check your net-snmp 22 installation. 23 ]))]) 24 25 snmp_version=$($SNMP_CONFIG --version) 26 AS_VERSION_COMPARE([$snmp_version], [5.3], 27 [AC_MSG_ERROR(m4_text_wrap([ 28 Net-SNMP version 5.3 or greater required (detected $snmp_version). 29 ]))]) 30 31 SNMP_PREFIX=$($SNMP_CONFIG --prefix) 32 SNMP_CFLAGS="-I${SNMP_PREFIX}/include" 33 SNMP_LIBS=$($SNMP_CONFIG --netsnmp-libs) 34 SNMP_LIBS="$SNMP_LIBS $($SNMP_CONFIG --external-libs)" 35 36 AS_IF([test -z "$SNMP_LIBS" || test -z "$SNMP_PREFIX"], 37 [AC_MSG_ERROR(m4_text_wrap([ 38 Could not find the required paths. Please check your net-snmp 39 installation. 40 ]))]) 41 ]) 42 43 PHP_EVAL_INCLINE([$SNMP_CFLAGS]) 44 PHP_EVAL_LIBLINE([$SNMP_LIBS], [SNMP_SHARED_LIBADD]) 45 SNMP_LIBNAME=netsnmp 46 47 dnl Test build. 48 PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [init_snmp], 49 [AC_DEFINE([HAVE_SNMP], [1], 50 [Define to 1 if the PHP extension 'snmp' is available.])], 51 [AC_MSG_FAILURE([SNMP sanity check failed.])], 52 [$SNMP_SHARED_LIBADD]) 53 54 dnl Check whether shutdown_snmp_logging() exists. 55 PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [shutdown_snmp_logging], 56 [AC_DEFINE([HAVE_SHUTDOWN_SNMP_LOGGING], [1], 57 [Define to 1 if SNMP library has the 'shutdown_snmp_logging' function.])], 58 [], 59 [$SNMP_SHARED_LIBADD]) 60 61 CFLAGS_SAVE=$CFLAGS 62 LIBS_SAVE=$LIBS 63 CFLAGS="$CFLAGS $SNMP_CFLAGS" 64 LIBS="$LIBS $SNMP_LIBS" 65 66 AC_CHECK_DECL([usmHMAC192SHA256AuthProtocol], 67 [AC_DEFINE([HAVE_SNMP_SHA256], [1], 68 [Define to 1 if SNMP library has the 'usmHMAC192SHA256AuthProtocol' 69 array.])], 70 [], 71 [ 72 #include <net-snmp/net-snmp-config.h> 73 #include <net-snmp/net-snmp-includes.h> 74 ]) 75 76 AC_CHECK_DECL([usmHMAC384SHA512AuthProtocol], 77 [AC_DEFINE([HAVE_SNMP_SHA512], [1], 78 [Define to 1 if SNMP library has the 'usmHMAC384SHA512AuthProtocol' 79 array.])], 80 [], 81 [ 82 #include <net-snmp/net-snmp-config.h> 83 #include <net-snmp/net-snmp-includes.h> 84 ]) 85 86 CFLAGS=$CFLAGS_SAVE 87 LIBS=$LIBS_SAVE 88 89 PHP_NEW_EXTENSION([snmp], [snmp.c], [$ext_shared]) 90 PHP_ADD_EXTENSION_DEP(snmp, spl) 91 PHP_SUBST([SNMP_SHARED_LIBADD]) 92fi 93