1# LIBNETSNMP_CHECK_CONFIG ([DEFAULT-ACTION]) 2# ---------------------------------------------------------- 3# Eugene Grigorjev <eugene@zabbix.com> Feb-02-2007 4# 5# Checks for net-snmp. DEFAULT-ACTION is the string yes or no to 6# specify whether to default to --with-net-snmp or --without-net-snmp. 7# If not supplied, DEFAULT-ACTION is no. 8# 9# This macro #defines HAVE_NETSNMP if required header files are 10# found, and sets @SNMP_LDFLAGS@ and @SNMP_CFLAGS@ to the necessary 11# values. 12# 13# Users may override the detected values by doing something like: 14# SNMP_LDFLAGS="-lsnmp" SNMP_CFLAGS="-I/usr/myinclude" ./configure 15# 16# This macro is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 20AC_DEFUN([LIBNETSNMP_CHECK_CONFIG], 21[ 22 _libnetsnmp_config="no" 23 24 AC_ARG_WITH(net-snmp, 25[If you want to use Net-SNMP library: 26AC_HELP_STRING([--with-net-snmp@<:@=ARG@:>@], 27 [use Net-SNMP package @<:@default=no@:>@, optionally specify path to net-snmp-config]) 28 ],[ if test "$withval" = "no"; then 29 want_netsnmp="no" 30 elif test "$withval" = "yes"; then 31 want_netsnmp="yes" 32 else 33 want_netsnmp="yes" 34 _libnetsnmp_config=$withval 35 fi 36 ],[want_netsnmp=ifelse([$1],,[no],[$1])]) 37 38 SNMP_CFLAGS="" 39 SNMP_LDFLAGS="" 40 SNMP_LIBS="" 41 42 if test "x$want_netsnmp" != "xno"; then 43 44 AC_PATH_PROG([_libnetsnmp_config], [net-snmp-config], []) 45 46 if test -x "$_libnetsnmp_config"; then 47 48 _full_libnetsnmp_cflags="`$_libnetsnmp_config --cflags`" 49 for i in $_full_libnetsnmp_cflags; do 50 case $i in 51 -I*) 52 SNMP_CFLAGS="$SNMP_CFLAGS $i" 53 54 ;; 55 esac 56 done 57 58 _full_libnetsnmp_libs="`$_libnetsnmp_config --netsnmp-libs`" 59 for i in $_full_libnetsnmp_libs; do 60 case $i in 61 -L*) 62 SNMP_LDFLAGS="${SNMP_LDFLAGS} $i" 63 ;; 64 -R*) 65 SNMP_LDFLAGS="${SNMP_LDFLAGS} -Wl,$i" 66 ;; 67 -l*) 68 SNMP_LIBS="${SNMP_LIBS} $i" 69 ;; 70 esac 71 done 72 73 if test "x$enable_static" = "xyes"; then 74 _full_libnetsnmp_libs="`$_libnetsnmp_config --libs`" 75 for i in $_full_libnetsnmp_libs; do 76 case $i in 77 -lnetsnmp) 78 ;; 79 -l*) 80 _lib_name="`echo "$i" | cut -b3-`" 81 AC_CHECK_LIB($_lib_name, main, [ 82 SNMP_LIBS="$SNMP_LIBS $i" 83 ],[ 84 AC_MSG_ERROR([Not found $_lib_name library]) 85 ]) 86 87 ;; 88 esac 89 done 90 fi 91 92 _save_netsnmp_cflags="$CFLAGS" 93 _save_netsnmp_ldflags="$LDFLAGS" 94 _save_netsnmp_libs="$LIBS" 95 CFLAGS="$CFLAGS $SNMP_CFLAGS" 96 LDFLAGS="$LDFLAGS $SNMP_LDFLAGS" 97 LIBS="$LIBS $SNMP_LIBS" 98 99 AC_CHECK_LIB(netsnmp, main, , [AC_MSG_ERROR([Not found Net-SNMP library])]) 100 101 dnl Check for localname in struct snmp_session 102 AC_MSG_CHECKING(for localname in struct snmp_session) 103 AC_TRY_COMPILE([ 104#include <net-snmp/net-snmp-config.h> 105#include <net-snmp/net-snmp-includes.h>], 106 [ 107struct snmp_session session; 108session.localname = ""; 109 ], 110 AC_DEFINE(HAVE_NETSNMP_SESSION_LOCALNAME, 1, [Define to 1 if 'session.localname' exist.]) 111 AC_MSG_RESULT(yes), 112 AC_MSG_RESULT(no)) 113 114 CFLAGS="$_save_netsnmp_cflags" 115 LDFLAGS="$_save_netsnmp_ldflags" 116 LIBS="$_save_netsnmp_libs" 117 unset _save_netsnmp_cflags 118 unset _save_netsnmp_ldflags 119 unset _save_netsnmp_libs 120 121 AC_DEFINE(HAVE_NETSNMP, 1, [Define to 1 if Net-SNMP should be enabled.]) 122 123 found_netsnmp="yes" 124 else 125 found_netsnmp="no" 126 fi 127 fi 128 129 AC_SUBST(SNMP_CFLAGS) 130 AC_SUBST(SNMP_LDFLAGS) 131 AC_SUBST(SNMP_LIBS) 132])dnl 133