xref: /PHP-5.3/ext/snmp/config.m4 (revision 8af7bc20)
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_WITH(snmp,for SNMP support,
6[  --with-snmp[=DIR]       Include SNMP support])
7
8PHP_ARG_WITH(openssl-dir,OpenSSL dir for SNMP,
9[  --with-openssl-dir[=DIR]  SNMP: openssl install prefix], no, no)
10
11PHP_ARG_ENABLE(ucd-snmp-hack, whether to enable UCD SNMP hack,
12[  --enable-ucd-snmp-hack    SNMP: Enable UCD SNMP hack], no, no)
13
14if test "$PHP_SNMP" != "no"; then
15
16  dnl
17  dnl Try net-snmp first
18  dnl
19  if test "$PHP_SNMP" = "yes"; then
20    AC_PATH_PROG(SNMP_CONFIG,net-snmp-config,,[/usr/local/bin:$PATH])
21  else
22    SNMP_CONFIG="$PHP_SNMP/bin/net-snmp-config"
23  fi
24
25  if test -x "$SNMP_CONFIG"; then
26    SNMP_LIBS=`$SNMP_CONFIG --netsnmp-libs`
27    SNMP_LIBS="$SNMP_LIBS `$SNMP_CONFIG --external-libs`"
28    SNMP_PREFIX=`$SNMP_CONFIG --prefix`
29
30    if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then
31      PHP_ADD_INCLUDE(${SNMP_PREFIX}/include)
32      PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD)
33      AC_DEFINE(HAVE_NET_SNMP,1,[ ])
34      SNMP_LIBNAME=netsnmp
35    else
36      AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.])
37    fi
38  else
39
40    dnl
41    dnl Try ucd-snmp if net-snmp test failed
42    dnl
43
44    if test "$PHP_SNMP" = "yes"; then
45      for i in /usr/include /usr/local/include; do
46        test -f $i/snmp.h                       && SNMP_INCDIR=$i
47        test -f $i/ucd-snmp/snmp.h              && SNMP_INCDIR=$i/ucd-snmp
48        test -f $i/snmp/snmp.h                  && SNMP_INCDIR=$i/snmp
49        test -f $i/snmp/include/ucd-snmp/snmp.h && SNMP_INCDIR=$i/snmp/include/ucd-snmp
50      done
51      for i in /usr/$PHP_LIBDIR /usr/snmp/lib /usr/local/$PHP_LIBDIR /usr/local/lib /usr/local/snmp/lib; do
52        test -f $i/libsnmp.a || test -f $i/libsnmp.$SHLIB_SUFFIX_NAME && SNMP_LIBDIR=$i
53      done
54    else
55      SNMP_INCDIR=$PHP_SNMP/include
56      test -d $PHP_SNMP/include/ucd-snmp && SNMP_INCDIR=$PHP_SNMP/include/ucd-snmp
57      SNMP_LIBDIR=$PHP_SNMP/lib
58    fi
59
60    if test -z "$SNMP_INCDIR"; then
61      AC_MSG_ERROR(snmp.h not found. Check your SNMP installation.)
62    elif test -z "$SNMP_LIBDIR"; then
63      AC_MSG_ERROR(libsnmp not found. Check your SNMP installation.)
64    fi
65
66    old_CPPFLAGS=$CPPFLAGS
67    CPPFLAGS=-I$SNMP_INCDIR
68    AC_CHECK_HEADERS(default_store.h)
69    if test "$ac_cv_header_default_store_h" = "yes"; then
70      AC_MSG_CHECKING(for OpenSSL support in SNMP libraries)
71      AC_EGREP_CPP(yes,[
72#include <ucd-snmp-config.h>
73#if USE_OPENSSL
74        yes
75#endif
76      ],[
77        SNMP_SSL=yes
78      ],[
79        SNMP_SSL=no
80      ])
81    fi
82    CPPFLAGS=$old_CPPFLAGS
83    AC_MSG_RESULT($SNMP_SSL)
84
85    if test "$SNMP_SSL" = "yes"; then
86      if test "$PHP_OPENSSL_DIR" != "no"; then
87        PHP_OPENSSL=$PHP_OPENSSL_DIR
88      fi
89
90      if test "$PHP_OPENSSL" = "no"; then
91        AC_MSG_ERROR([The UCD-SNMP in this system is built with SSL support.
92
93        Add --with-openssl-dir=DIR to your configure line.])
94      else
95        PHP_SETUP_OPENSSL(SNMP_SHARED_LIBADD, [], [
96          AC_MSG_ERROR([SNMP: OpenSSL check failed. Please check config.log for more information.])
97        ])
98      fi
99    fi
100
101    AC_CHECK_LIB(kstat, kstat_read, [ PHP_ADD_LIBRARY(kstat,,SNMP_SHARED_LIBADD) ])
102    PHP_ADD_INCLUDE($SNMP_INCDIR)
103    PHP_ADD_LIBRARY_WITH_PATH(snmp, $SNMP_LIBDIR, SNMP_SHARED_LIBADD)
104    SNMP_LIBNAME=snmp
105  fi
106
107  dnl Check whether snmp_parse_oid() exists.
108  PHP_CHECK_LIBRARY($SNMP_LIBNAME, snmp_parse_oid,
109  [
110    AC_DEFINE(HAVE_SNMP_PARSE_OID, 1, [ ])
111  ], [], [
112    $SNMP_SHARED_LIBADD
113  ])
114
115  dnl Test build.
116  PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp,
117  [
118    AC_DEFINE(HAVE_SNMP,1,[ ])
119  ], [
120    AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.])
121  ], [
122    $SNMP_SHARED_LIBADD
123  ])
124
125  if test "$PHP_UCD_SNMP_HACK" = "yes" ; then
126    AC_DEFINE(UCD_SNMP_HACK, 1, [ ])
127  fi
128
129  PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
130  PHP_SUBST(SNMP_SHARED_LIBADD)
131fi
132