nut/m4/nut_check_libpowerman.m4

60 lines
1.7 KiB
Text
Raw Normal View History

2010-03-25 23:20:59 +00:00
dnl Check for LIBPOWERMAN compiler flags. On success, set nut_have_libpowerman="yes"
2011-01-26 09:35:08 +00:00
dnl and set LIBPOWERMAN_CFLAGS and LIBPOWERMAN_LIBS. On failure, set
2010-03-25 23:20:59 +00:00
dnl nut_have_libpowerman="no". This macro can be run multiple times, but will
dnl do the checking only once.
AC_DEFUN([NUT_CHECK_LIBPOWERMAN],
[
if test -z "${nut_have_libpowerman_seen}"; then
nut_have_libpowerman_seen=yes
2011-01-26 09:35:08 +00:00
dnl save CFLAGS and LIBS
2010-03-25 23:20:59 +00:00
CFLAGS_ORIG="${CFLAGS}"
2011-01-26 09:35:08 +00:00
LIBS_ORIG="${LIBS}"
2010-03-25 23:20:59 +00:00
AC_MSG_CHECKING(for libpowerman cflags)
2011-01-26 09:35:08 +00:00
AC_ARG_WITH(powerman-includes,
AS_HELP_STRING([@<:@--with-powerman-includes=CFLAGS@:>@], [include flags for the libpowerman library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-powerman-includes - see docs/configure.txt)
;;
*)
CFLAGS="${withval}"
;;
esac
], [CFLAGS="`pkg-config --silence-errors --cflags libpowerman 2>/dev/null`"])
2010-03-25 23:20:59 +00:00
AC_MSG_RESULT([${CFLAGS}])
AC_MSG_CHECKING(for libpowerman libs)
2011-01-26 09:35:08 +00:00
AC_ARG_WITH(powerman-libs,
AS_HELP_STRING([@<:@--with-powerman-libs=LIBS@:>@], [linker flags for the libpowerman library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-powerman-libs - see docs/configure.txt)
;;
*)
LIBS="${withval}"
;;
esac
], [LIBS="`pkg-config --silence-errors --libs libpowerman 2>/dev/null`"])
AC_MSG_RESULT([${LIBS}])
2010-03-25 23:20:59 +00:00
dnl check if libpowerman is usable
AC_CHECK_HEADERS(libpowerman.h, [nut_have_libpowerman=yes], [nut_have_libpowerman=no], [AC_INCLUDES_DEFAULT])
AC_CHECK_FUNCS(pm_connect, [], [nut_have_libpowerman=no])
if test "${nut_have_libpowerman}" = "yes"; then
LIBPOWERMAN_CFLAGS="${CFLAGS}"
2011-01-26 09:35:08 +00:00
LIBPOWERMAN_LIBS="${LIBS}"
2010-03-25 23:20:59 +00:00
fi
2011-01-26 09:35:08 +00:00
dnl restore original CFLAGS and LIBS
2010-03-25 23:20:59 +00:00
CFLAGS="${CFLAGS_ORIG}"
2011-01-26 09:35:08 +00:00
LIBS="${LIBS_ORIG}"
2010-03-25 23:20:59 +00:00
fi
])