diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-11-30 00:45:12 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-11-30 00:45:12 +0000 |
commit | 36f0b417ea9cdce0346eca637b773a812e9da8d4 (patch) | |
tree | 02ca6080fd37012f02eb29bf2b6efb5e14da2af3 /aclocal-fallback | |
parent | 70b6bb00674a1e1082d7f995b8ecd22ddc9df91e (diff) | |
download | wireshark-36f0b417ea9cdce0346eca637b773a812e9da8d4.tar.gz wireshark-36f0b417ea9cdce0346eca637b773a812e9da8d4.tar.bz2 wireshark-36f0b417ea9cdce0346eca637b773a812e9da8d4.zip |
Add a directory argument and some default directories to "configure
--with-libsmi".
svn path=/trunk/; revision=23676
Diffstat (limited to 'aclocal-fallback')
-rw-r--r-- | aclocal-fallback/libsmi.m4 | 141 |
1 files changed, 115 insertions, 26 deletions
diff --git a/aclocal-fallback/libsmi.m4 b/aclocal-fallback/libsmi.m4 index 29ce719352..1a8983967d 100644 --- a/aclocal-fallback/libsmi.m4 +++ b/aclocal-fallback/libsmi.m4 @@ -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 ]) + + |