]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Clean up configure check for libsmi.
authorGuy Harris <[email protected]>
Sun, 31 Aug 2014 18:57:04 +0000 (11:57 -0700)
committerGuy Harris <[email protected]>
Sun, 31 Aug 2014 18:57:04 +0000 (11:57 -0700)
First, check for smi.h.  If we don't have it, don't check for anything
else.

If we do have it, check for libsmi containing smiInit.  If we don't have
it, don't check for anything else.

If we do have it, check, with our test program, whether we can use it.

If that succeeds, prepend -lsmi to LIBS, and set USE_LIBSMI.  Otherwise,
don't do either of those.

Check, in source, *only* for USE_LIBSMI.  If it's set, use libsmi,
otherwise don't - don't even include smi.h, even if we happened to have
found it, and don't print the libsmi version string.

config.h.in
configure
configure.in
print-snmp.c
tcpdump.c

index 2138832fcd4eb006fe64405c2512fb16e9e8ac17..0342e6101a4d69dbe4c2c43f35d6ef90d49083df 100644 (file)
@@ -61,9 +61,6 @@
 /* Define to 1 if you have the `rpc' library (-lrpc). */
 #undef HAVE_LIBRPC
 
-/* Define to 1 if you have the `smi' library (-lsmi). */
-#undef HAVE_LIBSMI
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
 /* Define to 1 if you have the `sigset' function. */
 #undef HAVE_SIGSET
 
-/* Define to 1 if you have the <smi.h> header file. */
-#undef HAVE_SMI_H
-
 /* Define to 1 if you have the `snprintf' function. */
 #undef HAVE_SNPRINTF
 
 /* if unaligned access fails */
 #undef LBL_ALIGN
 
-/* Define if you enable support for libsmi */
-#undef LIBSMI
-
 /* define if you need to include missing/addrinfo.h */
 #undef NEED_ADDRINFO_H
 
 /* define if you have ether_ntohost() and it works */
 #undef USE_ETHER_NTOHOST
 
+/* Define if you enable support for libsmi */
+#undef USE_LIBSMI
+
 /* define if should chroot when dropping privileges */
 #undef WITH_CHROOT
 
index 516fdfcd674e794d438d71ed8c13a3849fce4c62..d6662dc8917349e87d1f354091ec33f66f542183 100755 (executable)
--- a/configure
+++ b/configure
@@ -4335,19 +4335,13 @@ fi
 
 
 if test "x$with_smi" != "xno" ; then
-for ac_header in smi.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
+       ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
 if test "x$ac_cv_header_smi_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SMI_H 1
-_ACEOF
-
-fi
-
-done
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
+               #
+               # OK, we found smi.h.  Do we have libsmi with smiInit?
+               #
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
 $as_echo_n "checking for smiInit in -lsmi... " >&6; }
 if ${ac_cv_lib_smi_smiInit+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -4384,27 +4378,26 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_smi_smiInit" >&5
 $as_echo "$ac_cv_lib_smi_smiInit" >&6; }
 if test "x$ac_cv_lib_smi_smiInit" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSMI 1
-_ACEOF
-
-  LIBS="-lsmi $LIBS"
 
-fi
-
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
+                       #
+                       # OK, we have libsmi with smiInit.  Can we use it?
+                       #
+                       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
 $as_echo_n "checking whether to enable libsmi... " >&6; }
-        if test "$cross_compiling" = yes; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
+                       savedlibs="$LIBS"
+                       LIBS="-lsmi $LIBS"
+                       if test "$cross_compiling" = yes; then :
+
+                                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
 $as_echo "not when cross-compiling" >&6; }
-  libsmi=no
+                                       LIBS="$savedlibs"
+
 
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
- /* libsmi available check */
+
+/* libsmi available check */
 #include <smi.h>
 main()
 {
@@ -4424,32 +4417,41 @@ main()
 
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+                                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-$as_echo "#define LIBSMI 1" >>confdefs.h
+$as_echo "#define USE_LIBSMI 1" >>confdefs.h
+
 
-  libsmi=yes
 else
-   case $? in
-  1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
+
+                                                                                                                                                                                                                                                                                       case $? in
+                                         1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
 $as_echo "no - smiInit failed" >&6; } ;;
-  2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
+                                         2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
 $as_echo "no - header/library version mismatch" >&6; } ;;
-  3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
+                                         3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
 $as_echo "no - can't determine library version" >&6; } ;;
-  4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
+                                         4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
 $as_echo "no - too old" >&6; } ;;
-  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+                                         *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; } ;;
-  esac
-  libsmi=no
+                                       esac
+                                       LIBS="$savedlibs"
+
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
+
 fi
+
+
+fi
+
+
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the possibly-buggy SMB printer" >&5
index a63087d7a8d77abaa0ac43add3498d05c6fe8409..5d0f771b37536c6574e347129172d963084795ba 100644 (file)
@@ -98,12 +98,22 @@ AC_ARG_WITH(smi,
    with_smi=yes)
 
 if test "x$with_smi" != "xno" ; then
-AC_CHECK_HEADERS(smi.h)
-AC_CHECK_LIB(smi, smiInit)
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-AC_MSG_CHECKING([whether to enable libsmi])
-        AC_TRY_RUN([ /* libsmi available check */
+       AC_CHECK_HEADER(smi.h,
+       [
+               #
+               # OK, we found smi.h.  Do we have libsmi with smiInit?
+               #
+               AC_CHECK_LIB(smi, smiInit,
+               [
+                       #
+                       # OK, we have libsmi with smiInit.  Can we use it?
+                       #
+                       AC_MSG_CHECKING([whether to enable libsmi])
+                       savedlibs="$LIBS"
+                       LIBS="-lsmi $LIBS"
+                       AC_TRY_RUN(
+                               [
+/* libsmi available check */
 #include <smi.h>
 main()
 {
@@ -120,25 +130,35 @@ main()
     exit(4);
   exit(0);
 }
-],
-[ AC_MSG_RESULT(yes)
-  AC_DEFINE(LIBSMI, 1, [Define if you enable support for libsmi])
-  libsmi=yes],
-dnl autoconf documentation says that $? contains the exit value.
-dnl reality is that it does not.  We leave this in just in case
-dnl autoconf ever comes back to match the documentation.
-[ case $? in
-  1) AC_MSG_RESULT(no - smiInit failed) ;;
-  2) AC_MSG_RESULT(no - header/library version mismatch) ;;
-  3) AC_MSG_RESULT(no - can't determine library version) ;;
-  4) AC_MSG_RESULT(no - too old) ;;
-  *) AC_MSG_RESULT(no) ;;
-  esac
-  libsmi=no],
-[ AC_MSG_RESULT(not when cross-compiling)
-  libsmi=no]
-)
-fi
+                               ],
+                               [
+                                       AC_MSG_RESULT(yes)
+                                       AC_DEFINE(USE_LIBSMI, 1,
+                                           [Define if you enable support for libsmi])
+                               ],
+                               [
+                                       dnl autoconf documentation says that
+                                       dnl $? contains the exit value.
+                                       dnl reality is that it does not.
+                                       dnl We leave this in just in case
+                                       dnl autoconf ever comes back to
+                                       dnl match the documentation.
+                                       case $? in
+                                         1) AC_MSG_RESULT(no - smiInit failed) ;;
+                                         2) AC_MSG_RESULT(no - header/library version mismatch) ;;
+                                         3) AC_MSG_RESULT(no - can't determine library version) ;;
+                                         4) AC_MSG_RESULT(no - too old) ;;
+                                         *) AC_MSG_RESULT(no) ;;
+                                       esac
+                                       LIBS="$savedlibs"
+                               ],
+                               [
+                                       AC_MSG_RESULT(not when cross-compiling)
+                                       LIBS="$savedlibs"
+                               ]
+                       )
+               ])
+       ])
 fi
 
 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
index 53bc210a367e99d70668e54f92c429623b375c54..f5501582ba7a3b8aec3455ec7f55a4857ab013fd 100644 (file)
@@ -66,7 +66,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
 #include <smi.h>
 #endif
 
@@ -867,7 +867,7 @@ asn1_decode(u_char *p, u_int length)
 }
 #endif
 
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
 
 struct smi2be {
     SmiBasetype basetype;
@@ -1200,7 +1200,7 @@ varbind_print(netdissect_options *ndo,
 {
        struct be elem;
        int count = 0, ind;
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
        SmiNode *smiNode = NULL;
 #endif
        int status;
@@ -1247,7 +1247,7 @@ varbind_print(netdissect_options *ndo,
                        asn1_print(ndo, &elem);
                        return;
                }
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
                smiNode = smi_print_variable(ndo, &elem, &status);
 #else
                status = asn1_print(ndo, &elem);
@@ -1273,7 +1273,7 @@ varbind_print(netdissect_options *ndo,
                        }
                } else {
                        if (elem.type != BE_NULL) {
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
                                status = smi_print_value(ndo, smiNode, pduid, &elem);
 #else
                                status = asn1_print(ndo, &elem);
index 11dc8bc8b854f356ccbe805ef0308357afbd637f..8d615d74cb8c2bbc3097521b855e5143193845bb 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -53,7 +53,7 @@ extern int SIZE_BUF;
 #define uint UINT
 #endif /* WIN32 */
 
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
 #include <smi.h>
 #endif
 
@@ -954,7 +954,7 @@ main(int argc, char **argv)
        if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
                error("%s", ebuf);
 
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
        smiInit("tcpdump");
 #endif
 
@@ -1135,7 +1135,7 @@ main(int argc, char **argv)
                        break;
 
                case 'm':
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
                        if (smiLoadModule(optarg) == 0) {
                                error("could not load MIB module %s", optarg);
                        }
@@ -2487,7 +2487,7 @@ print_version(void)
        (void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION));
 #endif
 
-#if defined(HAVE_SMI_H)
+#ifdef USE_LIBSMI
        (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
 #endif
 }