[Asterisk-code-review] res_snmp: As build tool, prefer pkg-config over net-snmp-config. (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Nov 4 10:49:55 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16651 )

Change subject: res_snmp: As build tool, prefer pkg-config over net-snmp-config.
......................................................................

res_snmp: As build tool, prefer pkg-config over net-snmp-config.

ASTERISK-29709

Change-Id: Ie169df878bdfc3a06b3097c5c38d185b480f54d4
---
M configure
M configure.ac
2 files changed, 97 insertions(+), 0 deletions(-)

Approvals:
  Sean Bright: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit



diff --git a/configure b/configure
index 18193eb..3caa8a4 100755
--- a/configure
+++ b/configure
@@ -665,6 +665,8 @@
 PJPROJECT_CFLAGS
 PG_CONFIG
 CONFIG_NETSNMP
+NETSNMP_LIBS
+NETSNMP_CFLAGS
 CONFIG_NEON29
 CONFIG_NEON
 CONFIG_MYSQLCLIENT
@@ -1481,6 +1483,8 @@
 JANSSON_LIBS
 ILBC_CFLAGS
 ILBC_LIBS
+NETSNMP_CFLAGS
+NETSNMP_LIBS
 PJPROJECT_CFLAGS
 PJPROJECT_LIBS
 PYTHONDEV_CFLAGS
@@ -2262,6 +2266,10 @@
               linker flags for JANSSON, overriding pkg-config
   ILBC_CFLAGS C compiler flags for ILBC, overriding pkg-config
   ILBC_LIBS   linker flags for ILBC, overriding pkg-config
+  NETSNMP_CFLAGS
+              C compiler flags for NETSNMP, overriding pkg-config
+  NETSNMP_LIBS
+              linker flags for NETSNMP, overriding pkg-config
   PJPROJECT_CFLAGS
               C compiler flags for PJPROJECT, overriding pkg-config
   PJPROJECT_LIBS
@@ -23819,6 +23827,94 @@
 
 
 
+   if test "x${PBX_NETSNMP}" != "x1" -a "${USE_NETSNMP}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for netsnmp-agent" >&5
+$as_echo_n "checking for netsnmp-agent... " >&6; }
+
+if test -n "$NETSNMP_CFLAGS"; then
+    pkg_cv_NETSNMP_CFLAGS="$NETSNMP_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"netsnmp-agent\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "netsnmp-agent") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_NETSNMP_CFLAGS=`$PKG_CONFIG --cflags "netsnmp-agent" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$NETSNMP_LIBS"; then
+    pkg_cv_NETSNMP_LIBS="$NETSNMP_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"netsnmp-agent\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "netsnmp-agent") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_NETSNMP_LIBS=`$PKG_CONFIG --libs "netsnmp-agent" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        NETSNMP_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "netsnmp-agent" 2>&1`
+        else
+	        NETSNMP_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "netsnmp-agent" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$NETSNMP_PKG_ERRORS" >&5
+
+
+            PBX_NETSNMP=0
+
+
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+            PBX_NETSNMP=0
+
+
+else
+	NETSNMP_CFLAGS=$pkg_cv_NETSNMP_CFLAGS
+	NETSNMP_LIBS=$pkg_cv_NETSNMP_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+            PBX_NETSNMP=1
+            NETSNMP_INCLUDE=$(echo ${NETSNMP_CFLAGS} | $SED -e "s|-std=c99||g")
+            NETSNMP_LIB="$NETSNMP_LIBS"
+
+$as_echo "#define HAVE_NETSNMP 1" >>confdefs.h
+
+
+fi
+   fi
+
+
 		if test "x${PBX_NETSNMP}" != "x1" -a "${USE_NETSNMP}" != "no"; then
 		PBX_NETSNMP=0
 		if test -n "$ac_tool_prefix"; then
diff --git a/configure.ac b/configure.ac
index 9c7cb88..6f96967 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2352,6 +2352,7 @@
 #error Need libneon >= 0.29.0
 #endif])
 
+AST_PKG_CONFIG_CHECK(NETSNMP, netsnmp-agent)
 AST_EXT_TOOL_CHECK([NETSNMP], [net-snmp-config], , [--agent-libs],
 [#include <net-snmp/net-snmp-config.h>
 #include <net-snmp/net-snmp-includes.h>

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16651
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ie169df878bdfc3a06b3097c5c38d185b480f54d4
Gerrit-Change-Number: 16651
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211104/ff4f8a45/attachment.html>


More information about the asterisk-code-review mailing list