1# LIBOPENIPMI_CHECK_CONFIG ([DEFAULT-ACTION])
2# ----------------------------------------------------------
3#    Alexander Vladishev                      Sep-10-2008
4#
5# Checks for openipmi.  DEFAULT-ACTION is the string yes or no to
6# specify whether to default to --with-openipmi or --without-openipmi.
7# If not supplied, DEFAULT-ACTION is no.
8#
9# This macro #defines HAVE_OPENIPMI if a required header files is
10# found, and sets @OPENIPMI_LDFLAGS@ and @OPENIPMI_CFLAGS@ to the necessary
11# values.
12#
13# Users may override the detected values by doing something like:
14# OPENIPMI_LDFLAGS="-lOpenIPMI" OPENIPMI_CFLAGS="-I/usr/myinclude" ./configure
15#
16# This macro is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20AC_DEFUN([LIBOPENIPMI_CHECK_CONFIG],
21[
22  AC_ARG_WITH(openipmi,[
23If you want to check IPMI devices:
24AC_HELP_STRING([--with-openipmi@<:@=DIR@:>@],[Include OPENIPMI support @<:@default=no@:>@. DIR is the OPENIPMI base install directory, default is to search through a number of common places for the OPENIPMI files.])],
25     [ if test "$withval" = "no"; then
26            want_openipmi="no"
27            _libopenipmi_with="no"
28        elif test "$withval" = "yes"; then
29            want_openipmi="yes"
30            _libopenipmi_with="yes"
31        else
32            want_openipmi="yes"
33            _libopenipmi_with=$withval
34        fi
35     ],[_libopenipmi_with=ifelse([$1],,[no],[$1])])
36
37  if test "x$_libopenipmi_with" != x"no"; then
38       AC_MSG_CHECKING(for OPENIPMI support)
39
40       if test "$_libopenipmi_with" = "yes"; then
41               if test -f /usr/local/include/OpenIPMI/ipmiif.h; then
42                       OPENIPMI_INCDIR=/usr/local/include
43                       OPENIPMI_LIBDIR=/usr/local/lib
44		       found_openipmi="yes"
45               elif test -f /usr/include/OpenIPMI/ipmiif.h; then
46                       OPENIPMI_INCDIR=/usr/include
47                       OPENIPMI_LIBDIR=/usr/lib
48		       found_openipmi="yes"
49               else
50                       found_openipmi="no"
51                       AC_MSG_RESULT(no)
52               fi
53       else
54               if test -f $_libopenipmi_with/include/OpenIPMI/ipmiif.h; then
55                       OPENIPMI_INCDIR=$_libopenipmi_with/include
56                       OPENIPMI_LIBDIR=$_libopenipmi_with/lib
57		       found_openipmi="yes"
58               else
59                       found_openipmi="no"
60                       AC_MSG_RESULT(no)
61               fi
62       fi
63
64       if test "x$found_openipmi" != "xno" ; then
65               OPENIPMI_CFLAGS="-I$OPENIPMI_INCDIR"
66               OPENIPMI_LDFLAGS="-L$OPENIPMI_LIBDIR"
67               OPENIPMI_LIBS="-lOpenIPMI -lOpenIPMIposix"
68
69               found_openipmi="yes"
70               AC_DEFINE(HAVE_OPENIPMI,1,[Define to 1 if OPENIPMI should be enabled.])
71	       AC_DEFINE(OPENIPMI_DEPRECATED, 1, [Define to 1 if OPENIPMI deprecated functions is used.])
72               AC_MSG_RESULT(yes)
73	fi
74  fi
75
76  AC_SUBST(OPENIPMI_CFLAGS)
77  AC_SUBST(OPENIPMI_LDFLAGS)
78  AC_SUBST(OPENIPMI_LIBS)
79
80  unset _libopenipmi_with
81])dnl
82