2010-03-25 23:20:59 +00:00
|
|
|
dnl Check for LIBHAL compiler flags. On success, set nut_have_libhal="yes"
|
2011-01-26 09:35:08 +00:00
|
|
|
dnl and set LIBHAL_CFLAGS and LIBHAL_LIBS. On failure, set
|
2010-03-25 23:20:59 +00:00
|
|
|
dnl nut_have_libhal="no". This macro can be run multiple times, but will
|
|
|
|
dnl do the checking only once.
|
|
|
|
dnl NUT requires HAL version 0.5.8 at least
|
|
|
|
|
|
|
|
AC_DEFUN([NUT_CHECK_LIBHAL],
|
|
|
|
[
|
|
|
|
if test -z "${nut_have_libhal_seen}"; then
|
|
|
|
nut_have_libhal_seen=yes
|
|
|
|
|
|
|
|
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 libhal version via pkg-config (0.5.8 minimum required))
|
2011-01-26 09:35:08 +00:00
|
|
|
HAL_VERSION="`pkg-config --silence-errors --modversion hal 2>/dev/null`"
|
|
|
|
if test "$?" != "0" -o -z "${HAL_VERSION}"; then
|
|
|
|
AC_MSG_RESULT(none found)
|
|
|
|
elif pkg-config --silence-errors --atleast-version=0.5.8 hal 2>/dev/null; then
|
|
|
|
AC_MSG_RESULT(${HAL_VERSION} found)
|
2010-03-25 23:20:59 +00:00
|
|
|
else
|
2011-01-26 09:35:08 +00:00
|
|
|
AC_MSG_WARN(${HAL_VERSION} is too old)
|
2010-03-25 23:20:59 +00:00
|
|
|
fi
|
|
|
|
|
2011-01-26 09:35:08 +00:00
|
|
|
AC_MSG_CHECKING(for libhal cflags)
|
|
|
|
AC_ARG_WITH(hal-includes,
|
|
|
|
AS_HELP_STRING([@<:@--with-hal-includes=CFLAGS@:>@], [include flags for the HAL library]),
|
|
|
|
[
|
|
|
|
case "${withval}" in
|
|
|
|
yes|no)
|
|
|
|
AC_MSG_ERROR(invalid option --with(out)-hal-includes - see docs/configure.txt)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
CFLAGS="${withval}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
], [
|
|
|
|
dnl also get cflags from glib-2.0 to workaround a bug in dbus-glib
|
|
|
|
CFLAGS="`pkg-config --silence-errors --cflags hal dbus-glib-1 2>/dev/null`"
|
|
|
|
if test "$?" != "0"; then
|
|
|
|
CFLAGS="-DDBUS_API_SUBJECT_TO_CHANGE -I/usr/include/hal -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include"
|
2010-03-25 23:20:59 +00:00
|
|
|
fi
|
2011-01-26 09:35:08 +00:00
|
|
|
])
|
|
|
|
AC_MSG_RESULT([${CFLAGS}])
|
2010-03-25 23:20:59 +00:00
|
|
|
|
2011-01-26 09:35:08 +00:00
|
|
|
AC_MSG_CHECKING(for libhal ldflags)
|
|
|
|
AC_ARG_WITH(hal-libs,
|
|
|
|
AS_HELP_STRING([@<:@--with-hal-libs=LIBS@:>@], [linker flags for the HAL library]),
|
|
|
|
[
|
|
|
|
case "${withval}" in
|
|
|
|
yes|no)
|
|
|
|
AC_MSG_ERROR(invalid option --with(out)-hal-libs - see docs/configure.txt)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
LIBS="${withval}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
], [
|
|
|
|
dnl also get libs from glib-2.0 to workaround a bug in dbus-glib
|
|
|
|
LIBS="`pkg-config --silence-errors --libs hal dbus-glib-1 2>/dev/null`"
|
2010-03-25 23:20:59 +00:00
|
|
|
if test "$?" != "0"; then
|
2011-01-26 09:35:08 +00:00
|
|
|
LIBS="-lhal -ldbus-1 -lpthread"
|
2010-03-25 23:20:59 +00:00
|
|
|
fi
|
2011-01-26 09:35:08 +00:00
|
|
|
])
|
|
|
|
AC_MSG_RESULT([${LIBS}])
|
2010-03-25 23:20:59 +00:00
|
|
|
|
2011-01-26 09:35:08 +00:00
|
|
|
dnl check if HAL is usable
|
|
|
|
AC_CHECK_HEADERS(libhal.h, [nut_have_libhal=yes], [nut_have_libhal=no], [AC_INCLUDES_DEFAULT])
|
|
|
|
AC_CHECK_HEADERS(glib.h dbus/dbus-glib.h, [], [nut_have_libhal=no], [AC_INCLUDES_DEFAULT])
|
|
|
|
AC_CHECK_FUNCS(libhal_device_new_changeset, [], [nut_have_libhal=no])
|
2010-03-25 23:20:59 +00:00
|
|
|
|
2011-01-26 09:35:08 +00:00
|
|
|
if test "${nut_have_libhal}" = "yes"; then
|
|
|
|
AC_CHECK_FUNCS(g_timeout_add_seconds)
|
|
|
|
LIBHAL_CFLAGS="${CFLAGS}"
|
|
|
|
LIBHAL_LIBS="${LIBS}"
|
2010-03-25 23:20:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
CFLAGS="${CFLAGS_ORIG}"
|
2011-01-26 09:35:08 +00:00
|
|
|
LIBS="${LIBS_ORIG}"
|
2010-03-25 23:20:59 +00:00
|
|
|
fi
|
|
|
|
])
|