aboutsummaryrefslogtreecommitdiffstats
path: root/aclocal-fallback/libsmi.m4
blob: 29ce71935257dde3d649177623b85148ebb3ae47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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],
[
  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()
{
  int current, revision, age, n;
  const int required = 2;
  if (smiInit(""))
    exit(1);
  if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
    exit(2);
  n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
  if (n != 3)
    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]
  )
])