nut/m4/nut_check_libnetsnmp.m4

68 lines
1.9 KiB
Text
Raw Permalink Normal View History

2010-03-25 23:20:59 +00:00
dnl Check for LIBNETSNMP compiler flags. On success, set
dnl nut_have_libnetsnmp="yes" and set LIBNETSNMP_CFLAGS and
2011-01-26 09:35:08 +00:00
dnl LIBNETSNMP_LIBS. On failure, set nut_have_libnetsnmp="no".
2010-03-25 23:20:59 +00:00
dnl This macro can be run multiple times, but will do the checking only
dnl once.
AC_DEFUN([NUT_CHECK_LIBNETSNMP],
[
if test -z "${nut_have_libnetsnmp_seen}"; then
nut_have_libnetsnmp_seen=yes
2011-01-26 09:35:08 +00:00
dnl save CFLAGS and LIBS
2010-03-25 23:20:59 +00:00
CFLAGS_ORIG="${CFLAGS}"
2011-01-26 09:35:08 +00:00
LIBS_ORIG="${LIBS}"
2010-03-25 23:20:59 +00:00
dnl See which version of the Net-SNMP library (if any) is installed
AC_MSG_CHECKING(for Net-SNMP version via net-snmp-config)
SNMP_VERSION=`net-snmp-config --version 2>/dev/null`
2011-01-26 09:35:08 +00:00
if test "$?" != "0" -o -z "${SNMP_VERSION}"; then
SNMP_VERSION="none"
2010-03-25 23:20:59 +00:00
fi
2011-01-26 09:35:08 +00:00
AC_MSG_RESULT(${SNMP_VERSION} found)
2010-03-25 23:20:59 +00:00
AC_MSG_CHECKING(for Net-SNMP cflags)
2011-01-26 09:35:08 +00:00
AC_ARG_WITH(snmp-includes,
AS_HELP_STRING([@<:@--with-snmp-includes=CFLAGS@:>@], [include flags for the Net-SNMP library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-snmp-includes - see docs/configure.txt)
;;
*)
CFLAGS="${withval}"
;;
esac
], [CFLAGS="`net-snmp-config --base-cflags 2>/dev/null`"])
2010-03-25 23:20:59 +00:00
AC_MSG_RESULT([${CFLAGS}])
AC_MSG_CHECKING(for Net-SNMP libs)
2011-01-26 09:35:08 +00:00
AC_ARG_WITH(snmp-libs,
AS_HELP_STRING([@<:@--with-snmp-libs=LIBS@:>@], [linker flags for the Net-SNMP library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-snmp-libs - see docs/configure.txt)
;;
*)
LIBS="${withval}"
;;
esac
], [LIBS="`net-snmp-config --libs 2>/dev/null`"])
AC_MSG_RESULT([${LIBS}])
2010-03-25 23:20:59 +00:00
dnl Check if the Net-SNMP library is usable
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [nut_have_libnetsnmp=yes], [nut_have_libnetsnmp=no], [AC_INCLUDES_DEFAULT])
AC_CHECK_FUNCS(init_snmp, [], [nut_have_libnetsnmp=no])
if test "${nut_have_libnetsnmp}" = "yes"; then
LIBNETSNMP_CFLAGS="${CFLAGS}"
2011-01-26 09:35:08 +00:00
LIBNETSNMP_LIBS="${LIBS}"
2010-03-25 23:20:59 +00:00
fi
2011-01-26 09:35:08 +00:00
dnl restore original CFLAGS and LIBS
2010-03-25 23:20:59 +00:00
CFLAGS="${CFLAGS_ORIG}"
2011-01-26 09:35:08 +00:00
LIBS="${LIBS_ORIG}"
2010-03-25 23:20:59 +00:00
fi
])