1 From 72c2e53981a204d746737d8c01c4ad3738cd4880 Mon Sep 17 00:00:00 2001
2 From: =?utf8?q?Jo=C3=A3o=20Valverde?= <joao.valverde@tecnico.ulisboa.pt>
3 Date: Sun, 5 Nov 2017 12:05:43 +0000
4 Subject: [PATCH 1/1] autotools: Use pkg-config to configure Libsmi
6 Content-Type: text/plain; charset=utf8
7 Content-Transfer-Encoding: 8bit
9 Change-Id: Icecea743739aa7e1a65753f623f311514260d373
10 Reviewed-on: https://code.wireshark.org/review/24252
11 Petri-Dish: João Valverde <j@v6e.pt>
12 Tested-by: Petri Dish Buildbot
13 Reviewed-by: João Valverde <j@v6e.pt>
16 configure.ac | 27 +++++++++---
17 epan/Makefile.am | 2 +-
18 m4/libsmi.m4 | 125 -------------------------------------------------------
19 4 files changed, 24 insertions(+), 132 deletions(-)
20 delete mode 100644 m4/libsmi.m4
22 diff --git a/Makefile.am b/Makefile.am
23 index a2851e0..e6ed5eb 100644
26 @@ -422,7 +422,7 @@ EPAN_EXTRA_LIBS = \
33 # Libraries and plugin flags with which to link wireshark.
35 diff --git a/configure.ac b/configure.ac
36 index 3b3475b..326561c 100644
39 @@ -432,10 +432,6 @@ linux*)
44 -# FIXME: currently the path argument to with-libsmi is being ignored
48 # Check if we should build the Wireshark User's Guide
50 @@ -2427,6 +2423,27 @@ else
52 AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes")
58 + AC_HELP_STRING([--with-libsmi=@<:@yes/no@:>@],
59 + [use libsmi MIB/PIB library @<:@default=yes, if available@:>@]),
60 + [], [with_libsmi="if_available"])
63 +if test "x$with_libsmi" != "xno"; then
64 + PKG_CHECK_MODULES(LIBSMI, libsmi,
66 + AC_DEFINE(HAVE_LIBSMI, 1, [Define if you have libsmi])
68 + [if test "x$with_libsmi" = "xyes"; then
69 + # Error out if the user explicitly requested libsmi
70 + AC_MSG_ERROR([Libsmi was requested, but is not installed for development])
77 dnl check whether plugins should be enabled
78 @@ -3012,7 +3029,7 @@ echo " Use pcap library : $want_pcap"
79 echo " Use zlib library : $zlib_message"
80 echo " Use kerberos library : $krb5_message"
81 echo " Use c-ares library : $c_ares_message"
82 -echo " Use SMI MIB library : $libsmi_message"
83 +echo " Use SMI MIB library : $have_libsmi"
84 echo " Use GNU gcrypt library : yes"
85 echo " Use GnuTLS library : $tls_message"
86 echo " Use POSIX capabilities library : $libcap_message"
87 diff --git a/epan/Makefile.am b/epan/Makefile.am
88 index 9f7de62..e85f97b 100644
89 --- a/epan/Makefile.am
90 +++ b/epan/Makefile.am
91 @@ -330,7 +330,7 @@ libwireshark_la_LIBADD = \
100 diff --git a/m4/libsmi.m4 b/m4/libsmi.m4
101 deleted file mode 100644
102 index d719438..0000000
106 -# Configure paths for libsmi
107 -# Shamelessly stolen from http://autoconf-archive.cryp.to/ax_lib_sqlite3.html
109 -# Synopsis: AX_LIBSMI([minimum library version])
110 -# The default minimum library version is 2
112 -# This macro sets/substitutes the following:
113 -# AC_DEFINE(HAVE_LIBSMI)
114 -# AC_SUBST(LIBSMI_CFLAGS)
115 -# AC_SUBST(LIBSMI_LDFLAGS)
116 -# AC_SUBST(LIBSMI_VERSION)
117 -# $libsmi_message is set to "yes" or "no"
119 -AC_DEFUN([AX_LIBSMI],
121 - AC_ARG_WITH([libsmi],
123 - [--with-libsmi=@<:@DIR@:>@],
124 - [use libsmi MIB/PIB library @<:@default=yes@:>@, optionally specify the prefix for libsmi]
127 - if test "$withval" = "no"; then
129 - elif test "$withval" = "yes"; then
134 - ac_libsmi_path="$withval"
137 - [WANT_LIBSMI="yes"]
140 - libsmi_message="no"
145 - if test "x$WANT_LIBSMI" = "xyes"; then
147 - ac_libsmi_header="smi.h"
149 - libsmi_version_req=ifelse([$1], [], [2], [$1])
151 - AC_MSG_CHECKING([for libsmi >= $libsmi_version_req])
153 - if test "$ac_libsmi_path" != ""; then
154 - ac_libsmi_ldflags="-L$ac_libsmi_path/lib"
155 - ac_libsmi_cflags="-I$ac_libsmi_path/include"
157 - for ac_libsmi_path_tmp in /usr /usr/local /opt $prefix; do
158 - if test -f "$ac_libsmi_path_tmp/include/$ac_libsmi_header" \
159 - && test -r "$ac_libsmi_path_tmp/include/$ac_libsmi_header"; then
160 - ac_libsmi_path=$ac_libsmi_path_tmp
161 - ac_libsmi_ldflags="-L$ac_libsmi_path_tmp/lib"
162 - ac_libsmi_cflags="-I$ac_libsmi_path_tmp/include"
168 - ac_libsmi_ldflags="$ac_libsmi_ldflags -lsmi"
170 - saved_CFLAGS="$CFLAGS"
171 - CFLAGS="$CFLAGS $ac_libsmi_cflags"
176 - AC_LANG_PROGRAM([[@%:@include <smi.h>]],
178 - int current, revision, age, n;
179 - const int required = $libsmi_version_req;
182 - if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
184 - n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
187 - if (required < current - age || required > current)
193 - AC_MSG_RESULT([yes])
194 - libsmi_message="yes"
197 - AC_MSG_RESULT([not found])
198 - libsmi_message="no"
203 - CFLAGS="$saved_CFLAGS"
205 - if test "$libsmi_message" = "yes"; then
207 - LIBSMI_CFLAGS="$ac_libsmi_cflags"
208 - LIBSMI_LDFLAGS="$ac_libsmi_ldflags"
210 - ac_libsmi_header_path="$ac_libsmi_path/include/$ac_libsmi_header"
212 - dnl Retrieve libsmi release version
213 - if test "x$ac_libsmi_header_path" != "x"; then
214 - ac_libsmi_version=`cat $ac_libsmi_header_path \
215 - | grep '#define.*SMI_LIBRARY_VERSION.*\"' | sed -e 's/.* "//' \
217 - if test $ac_libsmi_version != ""; then
218 - LIBSMI_VERSION=$ac_libsmi_version
220 - AC_MSG_WARN([Can not find SMI_LIBRARY_VERSION macro in smi.h header to retrieve libsmi version!])
224 - AC_SUBST(LIBSMI_CFLAGS)
225 - AC_SUBST(LIBSMI_LDFLAGS)
226 - AC_SUBST(LIBSMI_VERSION)
227 - AC_DEFINE(HAVE_LIBSMI, 1, [Define to 1 if you have the `smi' library (-lsmi).])