configure: Use PKG_CHECK_MODULES to detect Net-SNMP

The output of "net-snmp-config --cflags" can contain optimization flags.
These might not be applicable to the current compiler, causing warnings.

Use PKG_CHECK_MODULES to check for Net-SNMP and obtain the compiler and
linker flags instead, in the same way as for libcurl or poppler-glib.
merge-requests/729/head
David Ward 2022-04-26 02:12:25 -04:00
rodzic 4b15f35e75
commit 9e1819c3f7
1 zmienionych plików z 18 dodań i 39 usunięć

Wyświetl plik

@ -152,48 +152,27 @@ AC_CHECK_LIB(sane, sane_init, LIBSANE_EXISTS="yes")
dnl ************************************************************** dnl **************************************************************
dnl SNMP CHECKS dnl Check for libsnmp availability
dnl ************************************************************** dnl **************************************************************
AC_ARG_WITH(snmp, AC_ARG_WITH(snmp,
AS_HELP_STRING([--with-snmp], [enable SNMP support @<:@default=yes@:>@])) AS_HELP_STRING([--with-snmp],
[enable SNMP support @<:@default=check@:>@]),
if test "$with_snmp" = "no"; then [],
echo "Not including SNMP support" [with_snmp=check])
else AC_DEFINE(HAVE_LIBSNMP,
AC_PATH_PROG(SNMP_CONFIG_PATH, net-snmp-config, "no") [0], [Define to 1 if libsnmp is available])
AC_CHECK_LIB([netsnmp], [snmp_timeout], LIBSNMP_EXISTS="yes") AS_IF([test xno != "x$with_snmp"],
AC_MSG_CHECKING(for proper SNMP version) [PKG_CHECK_MODULES(SNMP, [netsnmp >= 5.6],
if test "$SNMP_CONFIG_PATH" != "no" ; then [AC_DEFINE([HAVE_LIBSNMP], [1])
snmp_version=`$SNMP_CONFIG_PATH --version 2>/dev/null` with_snmp=yes
vers=`echo $snmp_version | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2);}'` ],
if test -n "$vers" && test "$vers" -ge 5006; then [AS_IF([test xcheck != "x$with_snmp"],
SNMP_LIBS=`$SNMP_CONFIG_PATH --libs` [AC_MSG_ERROR([libsnmp requested but not found])])
SNMP_CFLAGS=`$SNMP_CONFIG_PATH --cflags` with_snmp=no
AC_MSG_RESULT(yes) ])
with_snmp="yes" ])
else AM_CONDITIONAL([have_snmp], [test x != "x$SNMP_LIBS"])
AC_MSG_RESULT(no)
AC_MSG_WARN([You need at least net-snmp 5.6, your version is $snmp_version])
with_snmp="no"
fi
else
with_snmp="no"
AC_MSG_RESULT(no)
fi
fi
if test "$with_snmp" = "yes" && test "${LIBSNMP_EXISTS}x" = "yesx"; then
AC_SUBST(SNMP_LIBS)
AC_SUBST(SNMP_CFLAGS)
AC_DEFINE(HAVE_LIBSNMP, 1, [Define to 1 if you have the net-snmp library.])
else
AC_MSG_WARN([net-snmp library disabled, autodetecting network scanners will not be supported.])
fi
dnl *********************************************************************** dnl ***********************************************************************
dnl Checks for header files. dnl Checks for header files.