1 # Configure paths for libsmi
2 # Shamelessly stolen from http://autoconf-archive.cryp.to/ax_lib_sqlite3.html
5 # Synopsis: AX_LIBSMI([minimum library version])
6 # The default minimum library version is 2
8 # This macro sets/substitutes the following:
9 # AC_DEFINE(HAVE_LIBSMI)
10 # AC_SUBST(LIBSMI_CFLAGS)
11 # AC_SUBST(LIBSMI_LDFLAGS)
12 # AC_SUBST(LIBSMI_VERSION)
13 # $libsmi_message is set to "yes" or "no"
19 [--with-libsmi=@<:@DIR@:>@],
20 [use libsmi MIB/PIB library @<:@default=yes@:>@, optionally specify the prefix for libsmi]
23 if test "$withval" = "no"; then
25 elif test "$withval" = "yes"; then
30 ac_libsmi_path="$withval"
41 if test "x$WANT_LIBSMI" = "xyes"; then
43 ac_libsmi_header="smi.h"
45 libsmi_version_req=ifelse([$1], [], [2], [$1])
47 AC_MSG_CHECKING([for libsmi >= $libsmi_version_req])
49 if test "$ac_libsmi_path" != ""; then
50 ac_libsmi_ldflags="-L$ac_libsmi_path/lib"
51 ac_libsmi_cflags="-I$ac_libsmi_path/include"
53 for ac_libsmi_path_tmp in /usr /usr/local /opt $prefix; do
54 if test -f "$ac_libsmi_path_tmp/include/$ac_libsmi_header" \
55 && test -r "$ac_libsmi_path_tmp/include/$ac_libsmi_header"; then
56 ac_libsmi_path=$ac_libsmi_path_tmp
57 ac_libsmi_ldflags="-L$ac_libsmi_path_tmp/lib"
58 ac_libsmi_cflags="-I$ac_libsmi_path_tmp/include"
64 ac_libsmi_ldflags="$ac_libsmi_ldflags -lsmi"
66 saved_CFLAGS="$CFLAGS"
67 CFLAGS="$CFLAGS $ac_libsmi_cflags"
72 AC_LANG_PROGRAM([[@%:@include <smi.h>]],
74 int current, revision, age, n;
75 const int required = $libsmi_version_req;
78 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
80 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
83 if (required < current - age || required > current)
93 AC_MSG_RESULT([not found])
99 CFLAGS="$saved_CFLAGS"
101 if test "$libsmi_message" = "yes"; then
103 LIBSMI_CFLAGS="$ac_libsmi_cflags"
104 LIBSMI_LDFLAGS="$ac_libsmi_ldflags"
106 ac_libsmi_header_path="$ac_libsmi_path/include/$ac_libsmi_header"
108 dnl Retrieve libsmi release version
109 if test "x$ac_libsmi_header_path" != "x"; then
110 ac_libsmi_version=`cat $ac_libsmi_header_path \
111 | grep '#define.*SMI_LIBRARY_VERSION.*\"' | sed -e 's/.* "//' \
113 if test $ac_libsmi_version != ""; then
114 LIBSMI_VERSION=$ac_libsmi_version
116 AC_MSG_WARN([Can not find SMI_LIBRARY_VERSION macro in smi.h header to retrieve libsmi version!])
120 AC_SUBST(LIBSMI_CFLAGS)
121 AC_SUBST(LIBSMI_LDFLAGS)
122 AC_SUBST(LIBSMI_VERSION)
123 AC_DEFINE(HAVE_LIBSMI, 1, [Define to 1 if you have the `smi' library (-lsmi).])