Add a directory argument and some default directories to "configure
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 30 Nov 2007 00:45:12 +0000 (00:45 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 30 Nov 2007 00:45:12 +0000 (00:45 +0000)
--with-libsmi".

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23676 f5534014-38df-0310-8fa8-9805f1628bb7

Makefile.am
aclocal-fallback/libsmi.m4
configure.in
epan/Makefile.am

index 5bc114e8283fa963ed2c3213eb151e5917b6ac87..180b8291f5053ce230829f70a4647d052521e3f4 100644 (file)
@@ -312,6 +312,7 @@ wireshark_LDADD = \
        @LIBICONV@                      \
        @LIBGCRYPT_LIBS@                \
        @LIBGNUTLS_LIBS@                \
+       @LIBSMI_LDFLAGS@                \
        @PORTAUDIO_LIBS@
 
 if ENABLE_STATIC
@@ -334,7 +335,8 @@ tshark_LDADD = \
        @FRAMEWORKS@                    \
        @LIBICONV@                      \
        @LIBGCRYPT_LIBS@                \
-       @LIBGNUTLS_LIBS@
+       @LIBGNUTLS_LIBS@                \
+       @LIBSMI_LDFLAGS@
 
 # Optional objects that I know how to build, and that are needed by
 # text2pcap.
@@ -379,7 +381,8 @@ dftest_LDADD = \
        @PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@ @KRB5_LIBS@ \
        @LIBICONV@                      \
        @LIBGCRYPT_LIBS@                \
-       @LIBGNUTLS_LIBS@
+       @LIBGNUTLS_LIBS@                \
+       @LIBSMI_LDFLAGS@
 
 # Libraries with which to link dumpcap.
 dumpcap_LDADD = \
@@ -392,7 +395,7 @@ dumpcap_LDADD = \
 
 # Common headers
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap \
-       $(LIBGNUTLS_CFLAGS) $(LIBGCRYPT_CFLAGS)
+       $(LIBGNUTLS_CFLAGS) $(LIBGCRYPT_CFLAGS) $(LIBSMI_CFLAGS)
 
 #
 # Build the version string
index 29ce71935257dde3d649177623b85148ebb3ae47..1a8983967d91c182ca625134f0f3b8a3efc15375 100644 (file)
@@ -1,21 +1,77 @@
-# Configure paths for libsmi.
-
-dnl AM_PATH_LIBSMI()
-dnl Test for libsmi and defines the symbol LIBSMI if the test is
-dnl successful. Also defines HAVE_LIBSMI_H and adds -llibsmi to the 
-dnl LIBS variable.
-dnl 
-AC_DEFUN([AM_PATH_LIBSMI],
+# Configure paths for libsmi
+# Shamelessly stolen from http://autoconf-archive.cryp.to/ax_lib_sqlite3.html
+
+# Synopsis: AX_LIBSMI([minimum library version])
+# The default minimum library version is 2
+
+# This macro sets/substitutes the following:
+# AC_DEFINE(HAVE_LIBSMI)
+# AC_SUBST(LIBSMI_CFLAGS)
+# AC_SUBST(LIBSMI_LDLAGS)
+# AC_SUBST(LIBSMI_VERSION)
+# $libsmi_message is set to "yes" or "no"
+
+AC_DEFUN([AX_LIBSMI],
 [
-  AC_CHECK_HEADERS(smi.h)
-  AC_CHECK_LIB(smi, smiInit)
-  AC_MSG_CHECKING([whether to enable libsmi])
-  AC_TRY_RUN([ /* libsmi available check */
-#include <smi.h>
-main()
-{
+    AC_ARG_WITH([libsmi],
+        AC_HELP_STRING(
+            [--with-libsmi=@<:@DIR@:>@],
+            [use libsmi MIB/PIB library @<:@default=yes@:>@, optionally specify the prefix for libsmi]
+        ),
+        [
+        if test "$withval" = "no"; then
+            WANT_LIBSMI="no"
+        elif test "$withval" = "yes"; then
+            WANT_LIBSMI="yes"
+            ac_libsmi_path=""
+        else
+            WANT_LIBSMI="yes"
+            ac_libsmi_path="$withval"
+        fi
+        ],
+        [WANT_LIBSMI="yes"]
+    )
+
+    libsmi_message="no"
+    LIBSMI_CFLAGS=""
+    LIBSMI_LDFLAGS=""
+    LIBSMI_VERSION=""
+
+    if test "x$WANT_LIBSMI" = "xyes"; then
+
+        ac_libsmi_header="smi.h"
+
+        libsmi_version_req=ifelse([$1], [], [2], [$1])
+
+        AC_MSG_CHECKING([for libsmi >= $libsmi_version_req])
+
+        if test "$ac_libsmi_path" != ""; then
+            ac_libsmi_ldflags="-L$ac_libsmi_path/lib"
+            ac_libsmi_cflags="-I$ac_libsmi_path/include"
+        else
+            for ac_libsmi_path_tmp in /usr /usr/local /opt ; do
+                if test -f "$ac_libsmi_path_tmp/include/$ac_libsmi_header" \
+                    && test -r "$ac_libsmi_path_tmp/include/$ac_libsmi_header"; then
+                    ac_libsmi_path=$ac_libsmi_path_tmp
+                    ac_libsmi_ldlags="-L$ac_libsmi_path_tmp/lib"
+                    ac_libsmi_cflags="-I$ac_libsmi_path_tmp/include"
+                    break;
+                fi
+            done
+        fi
+
+        ac_libsmi_ldflags="$ac_libsmi_ldflags -lsmi"
+
+        saved_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $ac_libsmi_cflags"
+
+        AC_LANG_PUSH(C)
+        AC_COMPILE_IFELSE(
+            [
+            AC_LANG_PROGRAM([[@%:@include <smi.h>]],
+                [[
   int current, revision, age, n;
-  const int required = 2;
+  const int required = $libsmi_version_req;
   if (smiInit(""))
     exit(1);
   if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
@@ -25,14 +81,47 @@ main()
     exit(3);
   if (required < current - age || required > current)
     exit(4);
-  exit(0);
-}
-],
-  [ AC_MSG_RESULT(yes)
-    libsmi=yes],
-  [ AC_MSG_RESULT(no)
-    libsmi=no],
-  [ AC_MSG_RESULT(not when cross-compiling)
-    libsmi=no]
-  )
+                ]]
+            )
+            ],
+            [
+            AC_MSG_RESULT([yes])
+            libsmi_message="yes"
+            ],
+            [
+            AC_MSG_RESULT([not found])
+            libsmi_message="no"
+            ]
+        )
+        AC_LANG_POP([C])
+
+        CFLAGS="$saved_CFLAGS"
+
+        if test "$libsmi_message" = "yes"; then
+
+            LIBSMI_CFLAGS="$ac_libsmi_cflags"
+            LIBSMI_LDFLAGS="$ac_libsmi_ldflags"
+
+            ac_libsmi_header_path="$ac_libsmi_path/include/$ac_libsmi_header"
+
+            dnl Retrieve libsmi release version
+            if test "x$ac_libsmi_header_path" != "x"; then
+                ac_libsmi_version=`cat $ac_libsmi_header_path \
+                    | grep '#define.*SMI_LIBRARY_VERSION.*\"' | sed -e 's/.* "//' \
+                        | sed -e 's/"//'`
+                if test $ac_libsmi_version != ""; then
+                    LIBSMI_VERSION=$ac_libsmi_version
+                else
+                    AC_MSG_WARN([Can not find SMI_LIBRARY_VERSION macro in smi.h header to retrieve libsmi version!])
+                fi
+            fi
+
+            AC_SUBST(LIBSMI_CFLAGS)
+            AC_SUBST(LIBSMI_LDFLAGS)
+            AC_SUBST(LIBSMI_VERSION)
+            AC_DEFINE(HAVE_LIBSMI, 1, [Define to 1 if you have the `smi' library (-lsmi).])
+        fi
+    fi
 ])
+
+
index 350cbb0ff45f16454331fddd5d30bba257e81a25..b4d50f1594e32b9635e73053e645c594137d950f 100644 (file)
@@ -131,15 +131,7 @@ fi
 
 # libsmi
 # FIXME: currently the path argument to with-libsmi is being ignored
-libsmi="no"
-AC_ARG_WITH([libsmi],
-  AC_HELP_STRING( [--with-libsmi=@<:@yes/no@:>@],
-                 [use smi library @<:@default=yes@:>@]),
-  with_libsmi="$withval", with_libsmi="yes")
-if test "x$with_libsmi" = "xyes"; then
-  AM_PATH_LIBSMI
-  AM_CONDITIONAL(HAVE_SMI, test "x$with_libsmi" = "xyes")
-fi
+AX_LIBSMI
 
 # Check for xsltproc
 AC_PATH_PROG(XSLTPROC, xsltproc)
@@ -411,7 +403,7 @@ if test "x$ac_cv_enable_usr_local" = "xyes" ; then
        #
        # Arrange that we search for header files in the source directory
        # and in its "wiretap" subdirectory, as well as in "/usr/local/include",
-       # as various packages we use ("libpcap", "zlib", an SNMP library)
+       # as various packages we use ("libpcap", "zlib", "adns", "pcre")
        # may have been installed under "/usr/local/include".
        #
        CFLAGS="$CFLAGS -I/usr/local/include"
@@ -1730,7 +1722,7 @@ echo "                   Use zlib library : $zlib_message"
 echo "                   Use pcre library : $pcre_message"
 echo "               Use kerberos library : $krb5_message"
 echo "               Use GNU ADNS library : $adns_message"
-echo "               Use SMI SNMP library : $libsmi"
+echo "                Use SMI MIB library : $libsmi_message"
 echo "             Use GNU crypto library : $gcrypt_message"
 echo "             Use SSL crypto library : $ssl_message"
 echo "           Use IPv6 name resolution : $enable_ipv6"
index e161a54203cd92598b99c59ae5786a28ab2a0978..cc20a0b4f3776d54f21bed43cc20571843fe529a 100644 (file)
@@ -48,7 +48,7 @@ libwireshark_la_LDFLAGS = -version-info 0:1:0 @LDFLAGS_SHAREDLIB@
 include Makefile.common
 
 INCLUDES = -I$(srcdir)/.. -I$(srcdir)/$(LEMON) @LUA_INCLUDES@ \
-       $(LIBGNUTLS_CFLAGS) $(LIBGCRYPT_CFLAGS)
+       $(LIBGNUTLS_CFLAGS) $(LIBGCRYPT_CFLAGS) $(LIBSMI_CFLAGS)
 
 
 if HAVE_WARNINGS_AS_ERRORS
@@ -123,7 +123,7 @@ MAINTAINERCLEANFILES = \
 #
 # Add the object files for missing routines, if any.
 #
-libwireshark_la_LIBADD = @G_ASCII_STRCASECMP_LO@ @G_ASCII_STRTOULL_LO@ @INET_ATON_LO@ @INET_PTON_LO@ @INET_NTOP_LO@ libwireshark_generated.la libwireshark_asmopt.la crypt/libairpdcap.la ftypes/libftypes.la dfilter/libdfilter.la dissectors/libcleandissectors.la dissectors/libdissectors.la dissectors/libasndissectors.la dissectors/libpidldissectors.la $(wslua_lib) @ADNS_LIBS@ @LIBGNUTLS_LIBS@ @LIBICONV@ @KRB5_LIBS@ @SSL_LIBS@ -lm
+libwireshark_la_LIBADD = @G_ASCII_STRCASECMP_LO@ @G_ASCII_STRTOULL_LO@ @INET_ATON_LO@ @INET_PTON_LO@ @INET_NTOP_LO@ libwireshark_generated.la libwireshark_asmopt.la crypt/libairpdcap.la ftypes/libftypes.la dfilter/libdfilter.la dissectors/libcleandissectors.la dissectors/libdissectors.la dissectors/libasndissectors.la dissectors/libpidldissectors.la $(wslua_lib) @ADNS_LIBS@ @LIBGNUTLS_LIBS@ @LIBICONV@ @KRB5_LIBS@ @SSL_LIBS@ @LIBSMI_LDFLAGS@ -lm
 libwireshark_la_DEPENDENCIES = @G_ASCII_STRCASECMP_LO@ @G_ASCII_STRTOULL_LO@ @INET_ATON_LO@ @INET_PTON_LO@ @INET_NTOP_LO@ libwireshark_generated.la libwireshark_asmopt.la crypt/libairpdcap.la ftypes/libftypes.la dfilter/libdfilter.la dissectors/libcleandissectors.la dissectors/libdissectors.la dissectors/libasndissectors.la dissectors/libpidldissectors.la $(wslua_lib)
 
 #EXTRA_PROGRAMS = reassemble_test