configure.ac: always use pkg-config to detect hal
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 24 Jul 2016 14:43:30 +0000 (16:43 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 24 Jul 2016 14:45:52 +0000 (16:45 +0200)
Hal needs dbus, but we need pkg-config to tell us that.
Now that pkg-config is not optional anymore, rewrite the
check to always use it. Also add a check for the header.

Fixes building the uuid plugin on Solaris 11.3

configure.ac

index c69842c..e3d09da 100644 (file)
@@ -1621,18 +1621,31 @@ AC_CHECK_LIB(resolv, res_search,
 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
 
 dnl Check for HAL (hardware abstraction library)
-with_libhal="yes"
-AC_CHECK_LIB(hal,libhal_device_property_exists,
-            [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
-            [with_libhal="no"])
-if test "x$with_libhal" = "xyes"; then
-       if test "x$PKG_CONFIG" != "x"; then
-               BUILD_WITH_LIBHAL_CFLAGS="`$PKG_CONFIG --cflags hal`"
-               BUILD_WITH_LIBHAL_LIBS="`$PKG_CONFIG --libs hal`"
-               AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
-               AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
-       fi
-fi
+with_libhal="no"
+PKG_CHECK_MODULES([HAL], [hal],
+  [
+    SAVE_LIBS="$LIBS"
+    LIBS="$HAL_LIBS $LIBS"
+    AC_CHECK_LIB([hal], [libhal_device_property_exists],
+      [
+        SAVE_CPPFLAGS="$CPPFLAGS"
+        CPPFLAGS="$HAL_CFLAGS $CPPFLAGS"
+        AC_CHECK_HEADERS([libhal.h],
+        [
+          with_libhal="yes"
+          BUILD_WITH_LIBHAL_CFLAGS="$HAL_CFLAGS"
+          BUILD_WITH_LIBHAL_LIBS="$HAL_LIBS"
+        ])
+        CPPFLAGS="$SAVE_CPPFLAGS"
+      ],
+      []
+    )
+    LIBS="$SAVE_LIBS"
+  ]
+)
+AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
+AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
+
 
 SAVE_LIBS="$LIBS"
 AC_CHECK_LIB([pthread],