-#
-# AC_WIRESHARK_NETSNMP_CHECK
-#
-AC_DEFUN([AC_WIRESHARK_NETSNMP_CHECK],
-[
- dnl get the net-snmp-config binary
- if test "x$netsnmpconfig" = "x" ; then
- #
- # The user didn't specify where net-snmp-config is
- # located; search for it.
- #
- AC_PATH_PROG(NETSNMPCONFIG, net-snmp-config)
- else
- NETSNMPCNFIG=$netsnmpconfig
- if test ! -x $NETSNMPCONFIG -o ! -f $NETSNMPCONFIG ; then
- NETSNMPCONFIG=$netsnmpconfig/bin/net-snmp-config
- if test ! -x $NETSNMPCONFIG -o ! -f $NETSNMPCONFIG ; then
- AC_MSG_ERROR(Invalid net-snmp-config: $netsnmpconfig)
- fi
- fi
- fi
-
- #
- # XXX - check whether $NETSNMPCONFIG is executable?
- # if test "x$NETSNMPCONFIG" != "xno" -a "x$NETSNMPCONFIG" != "x" -a -x "$NETSNMPCONFIG" ; then
- # We already did that if it was set; presumably AC_PATH_PROG
- # will fail if it doesn't find an executable version.
- #
- if test "x$NETSNMPCONFIG" != "x" ; then
- dnl other choices for flags to use here: could also use
- dnl --prefix or --exec-prefix if you don't want the full list.
-
- #
- # Save the current settings of CFLAGS and CPPFLAGS, and add
- # the output of "$NETSNMPCONFIG --cflags" to it, so that when
- # searching for the Net-SNMP headers, we look in whatever
- # directory that output specifies.
- #
- wireshark_save_CFLAGS="$CFLAGS"
- wireshark_save_CPPFLAGS="$CPPFLAGS"
- CFLAGS="$CFLAGS `$NETSNMPCONFIG --cflags`"
- CPPFLAGS="$CPPFLAGS `$NETSNMPCONFIG --cflags`"
-
- AC_CHECK_HEADERS(net-snmp/net-snmp-config.h net-snmp/library/default_store.h)
- if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = "xyes" -a "x$ac_cv_header_net_snmp_library_default_store_h" = "xyes" ; then
- SNMP_LIBS=`$NETSNMPCONFIG --libs`
- if echo "$SNMP_LIBS" | grep crypto >/dev/null && test "x$SSL_LIBS" = "x"; then
- if test "x$want_netsnmp" = "xyes" ; then
- AC_MSG_ERROR(Net-SNMP requires openssl but ssl not enabled)
- else
- AC_MSG_RESULT(Net-SNMP requires openssl but ssl not enabled - disabling Net-SNMP)
- fi
- CFLAGS="$wireshark_save_CFLAGS"
- CPPFLAGS="$wireshark_save_CPPFLAGS"
- SNMP_LIBS=
- else
- AC_DEFINE(HAVE_NET_SNMP, 1, [Define to enable support for Net-SNMP])
- have_net_snmp="yes"
- fi
- else
- if test "x$want_netsnmp" = "xyes" ; then
- AC_MSG_ERROR(Net-SNMP not found)
- else
- #
- # Restore the versions of CFLAGS and
- # CPPFLAGS before we added the output
- # of '$NETSNMPCONFIG --cflags", as we
- # didn't actually find Net-SNMP there.
- #
- CFLAGS="$wireshark_save_CFLAGS"
- CPPFLAGS="$wireshark_save_CPPFLAGS"
- fi
- fi
- fi
-])
-
-#
-# AC_WIRESHARK_UCDSNMP_CHECK
-#
-AC_DEFUN([AC_WIRESHARK_UCDSNMP_CHECK],
-[
- if test "x$ucdsnmp_dir" != "x"
- then
- #
- # The user specified a directory in which UCD SNMP resides,
- # so add the "include" subdirectory of that directory to
- # the include file search path and the "lib" subdirectory
- # of that directory to the library search path.
- #
- # XXX - if there's also a libpcap in a directory that's
- # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
- # make us find the version in the specified directory,
- # as the compiler and/or linker will search that other
- # directory before it searches the specified directory.
- #
- CFLAGS="$CFLAGS -I$ucdsnmp_dir/include"
- CPPFLAGS="$CPPFLAGS -I$ucdsnmp_dir/include"
- AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $ucdsnmp_dir/lib)
- fi
-
- #
- # Check for one of the UCD SNMP header files we include,
- # to see whether we have UCD SNMP installed.
- #
- AC_CHECK_HEADER(ucd-snmp/ucd-snmp-config.h,
- [
- #
- # UCD SNMP or Net-SNMP might require various helper
- # libraries on various platforms, such as "-ldes425"
- # in "/usr/kerberos/lib" on some versions of Red
- # Hat Linux, or "-lkstat" on Solaris.
- #
- # It might also require "-lcrypto" on some platforms;
- # if the user didn't specify --with-ssl, we check
- # whether it would have made a difference and, if so,
- # we tell the user that they needed to request it.
- # (There are annoying licensing issues with it and
- # GPL'ed code, so we don't include it by default.)
- #
- # XXX - autoconf really needs a way to test for
- # a given routine in a given library *and* to test
- # whether additional "-L"/"-R"/whatever flags are
- # needed *before* the "-l" flag for the library
- # and to test whether additional libraries are
- # needed after the library *and* to cache all that
- # information.
- #
- wireshark_save_LIBS="$LIBS"
- found_sprint_realloc_objid=no
- for extras in "" "-L/usr/kerberos/lib -ldes425" "-lkstat"
- do
- LIBS="-lsnmp $extras $SOCKET_LIBS $NSL_LIBS $SSL_LIBS"
- if test -z "$extras"
- then
- AC_MSG_CHECKING([whether UCD SNMP includes sprint_realloc_objid])
- else
- AC_MSG_CHECKING([whether UCD SNMP includes sprint_realloc_objid (linking with $extras)])
- fi
- AC_TRY_LINK(
- [
- ],
- [
- sprint_realloc_objid();
- ],
- [
- #
- # We found "sprint_realloc_objid()",
- # and required the libraries in
- # extras as well.
- #
- AC_MSG_RESULT(yes)
- SNMP_LIBS="-lsnmp $extras"; break;
- found_sprint_realloc_objid=yes
- break
- ],
- [
- #
- # The link failed. If they didn't ask
- # for SSL, try linking with -lcrypto
- # as well, and if *that* succeeds,
- # tell them they'll need to specify
- # --want-ssl.
- #
- AC_MSG_RESULT(no)
- if test "x$want_ssl" = "xno"
- then
- LIBS="$LIBS -lcrypto"
- AC_TRY_LINK(
- [
- ],
- [
- sprint_realloc_objid();
- ],
- [
- #
- # It worked with -lcrypto; tell
- # them they'll need to specify
- # --with-ssl.
- #
- found_sprint_realloc_objid=yesnocrypto
- AC_MSG_RESULT([UCD SNMP requires -lcrypto but --with-ssl was not specified - disabling UCD SNMP.])
- ])
- fi
- ])
- done
- LIBS="$wireshark_save_LIBS"
-
- #
- # If we didn't find "sprint_realloc_objid()", fail.
- # Either the user needs a newer version of UCD SNMP
- # with "sprint_realloc_objid()", or they may need to
- # specify "--with-ssl".
- #
- if test "$found_snmp_sprint_realloc_objid" = no; then
- AC_MSG_RESULT([UCD SNMP header files found, but sprint_realloc_objid not found in SNMP library - disabling UCD SNMP.])
- elif test "$found_snmp_sprint_realloc_objid" != yes -a "x$want_ucdsnmp" = "xyes"; then
- AC_MSG_ERROR(UCD SNMP requested but fails to build)
- fi
-
- #
- # We found it, so we have UCD SNMP.
- #
- AC_DEFINE(HAVE_UCD_SNMP, 1, [Define to enable support for UCD-SNMP])
- have_ucd_snmp="yes"
- ],[
- #
- # No, we don't have it.
- # If the user explicitly asked for UCD SNMP, fail,
- # otherwise just don't use the UCD SNMP library.
- #
- if test "x$want_ucdsnmp" = "xyes" ; then
- AC_MSG_ERROR(Header file ucd-snmp/snmp.h not found.)
- fi
- ])
-])
-