1 # Configure paths for libsmi
2 # Shamelessly stolen from http://autoconf-archive.cryp.to/ax_lib_sqlite3.html
4 # Synopsis: AX_LIBSMI([minimum library version])
5 # The default minimum library version is 2
7 # This macro sets/substitutes the following:
8 # AC_DEFINE(HAVE_LIBSMI)
9 # AC_SUBST(LIBSMI_CFLAGS)
10 # AC_SUBST(LIBSMI_LDFLAGS)
11 # AC_SUBST(LIBSMI_VERSION)
12 # $libsmi_message is set to "yes" or "no"
18 [--with-libsmi=@<:@DIR@:>@],
19 [use libsmi MIB/PIB library @<:@default=yes@:>@, optionally specify the prefix for libsmi]
22 if test "$withval" = "no"; then
24 elif test "$withval" = "yes"; then
29 ac_libsmi_path="$withval"
40 if test "x$WANT_LIBSMI" = "xyes"; then
42 ac_libsmi_header="smi.h"
44 libsmi_version_req=ifelse([$1], [], [2], [$1])
46 AC_MSG_CHECKING([for libsmi >= $libsmi_version_req])
48 if test "$ac_libsmi_path" != ""; then
49 ac_libsmi_ldflags="-L$ac_libsmi_path/lib"
50 ac_libsmi_cflags="-I$ac_libsmi_path/include"
52 for ac_libsmi_path_tmp in /usr /usr/local /opt $prefix; do
53 if test -f "$ac_libsmi_path_tmp/include/$ac_libsmi_header" \
54 && test -r "$ac_libsmi_path_tmp/include/$ac_libsmi_header"; then
55 ac_libsmi_path=$ac_libsmi_path_tmp
56 ac_libsmi_ldflags="-L$ac_libsmi_path_tmp/lib"
57 ac_libsmi_cflags="-I$ac_libsmi_path_tmp/include"
63 ac_libsmi_ldflags="$ac_libsmi_ldflags -lsmi"
65 saved_CFLAGS="$CFLAGS"
66 CFLAGS="$CFLAGS $ac_libsmi_cflags"
71 AC_LANG_PROGRAM([[@%:@include <smi.h>]],
73 int current, revision, age, n;
74 const int required = $libsmi_version_req;
77 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
79 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
82 if (required < current - age || required > current)
92 AC_MSG_RESULT([not found])
98 CFLAGS="$saved_CFLAGS"
100 if test "$libsmi_message" = "yes"; then
102 LIBSMI_CFLAGS="$ac_libsmi_cflags"
103 LIBSMI_LDFLAGS="$ac_libsmi_ldflags"
105 ac_libsmi_header_path="$ac_libsmi_path/include/$ac_libsmi_header"
107 dnl Retrieve libsmi release version
108 if test "x$ac_libsmi_header_path" != "x"; then
109 ac_libsmi_version=`cat $ac_libsmi_header_path \
110 | grep '#define.*SMI_LIBRARY_VERSION.*\"' | sed -e 's/.* "//' \
112 if test $ac_libsmi_version != ""; then
113 LIBSMI_VERSION=$ac_libsmi_version
115 AC_MSG_WARN([Can not find SMI_LIBRARY_VERSION macro in smi.h header to retrieve libsmi version!])
119 AC_SUBST(LIBSMI_CFLAGS)
120 AC_SUBST(LIBSMI_LDFLAGS)
121 AC_SUBST(LIBSMI_VERSION)
122 AC_DEFINE(HAVE_LIBSMI, 1, [Define to 1 if you have the `smi' library (-lsmi).])