# LIBNETSNMP_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
# Checks for net-snmp. DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-net-snmp or --without-net-snmp.
# If not supplied, DEFAULT-ACTION is no.
# This macro #defines HAVE_NETSNMP if required header files are
# found, and sets @SNMP_LDFLAGS@ and @SNMP_CFLAGS@ to the necessary
# Users may override the detected values by doing something like:
# SNMP_LDFLAGS="-lsnmp" SNMP_CFLAGS="-I/usr/myinclude" ./configure
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([LIBNETSNMP_CHECK_CONFIG],
[If you want to use Net-SNMP library:
AS_HELP_STRING([--with-net-snmp@<:@=ARG@:>@],
[use Net-SNMP package @<:@default=no@:>@, optionally specify path to net-snmp-config])
],[ if test "$withval" = "no"; then
elif test "$withval" = "yes"; then
_libnetsnmp_config=$withval
],[want_netsnmp=ifelse([$1],,[no],[$1])])
if test "x$want_netsnmp" != "xno"; then
if test "x$_libnetsnmp_config" = "xno"; then
AC_PATH_PROG([_libnetsnmp_config], [net-snmp-config], [])
test "x$enable_static_libs" = "xyes" && want_static_netsnmp="yes"
want_static_netsnmp="yes"
if test -d "$_libnetsnmp_config"; then
AC_PATH_PROG([_libnetsnmp_config_bin], [net-snmp-config], [$_libnetsnmp_config/bin], [$_libnetsnmp_config])
_libnetsnmp_config=$_libnetsnmp_config_bin
if test -d "$_libnetsnmp_config"; then
AC_PATH_PROG([_libnetsnmp_config_root], [net-snmp-config], [], [$_libnetsnmp_config])
test -z $_libnetsnmp_config_root || _libnetsnmp_config=$_libnetsnmp_config_root
if test -x "$_libnetsnmp_config"; then
if test -n "$netsnmp_version_req"; then
AC_MSG_CHECKING(version of netsnmp library)
LIBNETSNMP_CONFIG_VERSION=`$_libnetsnmp_config --version`
netsnmp_version_major=`expr $LIBNETSNMP_CONFIG_VERSION : '\([[0-9]]*\)'`
netsnmp_version_minor=`expr $LIBNETSNMP_CONFIG_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
netsnmp_version_micro=`expr $LIBNETSNMP_CONFIG_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$netsnmp_version_micro" = "x"; then
netsnmp_version_micro="0"
netsnmp_version_number=`expr $netsnmp_version_major \* 1000000 \
\+ $netsnmp_version_minor \* 1000 \
\+ $netsnmp_version_micro`
netsnmp_version_req_major=`expr $netsnmp_version_req : '\([[0-9]]*\)'`
netsnmp_version_req_minor=`expr $netsnmp_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
netsnmp_version_req_micro=`expr $netsnmp_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$netsnmp_version_req_micro" = "x"; then
netsnmp_version_req_micro="0"
netsnmp_version_req_number=`expr $netsnmp_version_req_major \* 1000000 \
\+ $netsnmp_version_req_minor \* 1000 \
\+ $netsnmp_version_req_micro`
netsnmp_version_check=`expr $netsnmp_version_number \>\= $netsnmp_version_req_number`