Imported Upstream version 0.4.8
[platform/upstream/libsmi.git] / libsmi.m4
1 # Configure paths for libsmi.
2
3 dnl AM_PATH_LIBSMI()
4 dnl Test for libsmi and defines the symbol LIBSMI if the test is
5 dnl successful. Also defines HAVE_LIBSMI_H and adds -llibsmi to the 
6 dnl LIBS variable.
7 dnl 
8 AC_DEFUN([AM_PATH_LIBSMI],
9 [
10   AC_CHECK_HEADERS(smi.h)
11   AC_CHECK_LIB(smi, smiInit)
12   AC_MSG_CHECKING([whether to enable libsmi])
13   AC_TRY_RUN([ /* libsmi available check */
14 #include <smi.h>
15 main()
16 {
17   int current, revision, age, n;
18   const int required = 2;
19   if (smiInit(""))
20     exit(1);
21   if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
22     exit(2);
23   n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
24   if (n != 3)
25     exit(3);
26   if (required < current - age || required > current)
27     exit(4);
28   exit(0);
29 }
30 ],
31   [ AC_MSG_RESULT(yes)
32     libsmi=yes],
33   [ AC_MSG_RESULT(no)
34     libsmi=no],
35   [ AC_MSG_RESULT(not when cross-compiling)
36     libsmi=no]
37   )
38 ])