xref: /PHP-7.4/ext/snmp/config.m4 (revision 74380465)
1PHP_ARG_WITH([snmp],
2  [for SNMP support],
3  [AS_HELP_STRING([[--with-snmp[=DIR]]],
4    [Include SNMP support])])
5
6if test "$PHP_SNMP" != "no"; then
7
8  if test "$PHP_SNMP" = "yes"; then
9    AC_PATH_PROG(SNMP_CONFIG,net-snmp-config,,[/usr/local/bin:$PATH])
10  else
11    SNMP_CONFIG="$PHP_SNMP/bin/net-snmp-config"
12  fi
13
14  if test -x "$SNMP_CONFIG"; then
15    SNMP_LIBS=`$SNMP_CONFIG --netsnmp-libs`
16    SNMP_LIBS="$SNMP_LIBS `$SNMP_CONFIG --external-libs`"
17    SNMP_PREFIX=`$SNMP_CONFIG --prefix`
18    snmp_full_version=`$SNMP_CONFIG --version`
19    ac_IFS=$IFS
20    IFS="."
21    set $snmp_full_version
22    IFS=$ac_IFS
23    SNMP_VERSION=`expr [$]1 \* 1000 + [$]2`
24    if test "$SNMP_VERSION" -ge "5003"; then
25      if test -n "$SNMP_LIBS" && test -n "$SNMP_PREFIX"; then
26        PHP_ADD_INCLUDE(${SNMP_PREFIX}/include)
27        PHP_EVAL_LIBLINE($SNMP_LIBS, SNMP_SHARED_LIBADD)
28        SNMP_LIBNAME=netsnmp
29      else
30        AC_MSG_ERROR([Could not find the required paths. Please check your net-snmp installation.])
31      fi
32    else
33      AC_MSG_ERROR([Net-SNMP version 5.3 or greater reqired (detected $snmp_full_version).])
34    fi
35  else
36    AC_MSG_ERROR([Could not find net-snmp-config binary. Please check your net-snmp installation.])
37  fi
38
39  dnl Test build.
40  PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp,
41  [
42    AC_DEFINE(HAVE_SNMP,1,[ ])
43  ], [
44    AC_MSG_ERROR([SNMP sanity check failed. Please check config.log for more information.])
45  ], [
46    $SNMP_SHARED_LIBADD
47  ])
48
49  dnl Check whether shutdown_snmp_logging() exists.
50  PHP_CHECK_LIBRARY($SNMP_LIBNAME, shutdown_snmp_logging,
51  [
52    AC_DEFINE(HAVE_SHUTDOWN_SNMP_LOGGING, 1, [ ])
53  ], [], [
54    $SNMP_SHARED_LIBADD
55  ])
56
57  PHP_NEW_EXTENSION(snmp, snmp.c, $ext_shared)
58  PHP_SUBST(SNMP_SHARED_LIBADD)
59fi
60