])
AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
- AC_CHECK_HEADER([systemd/sd-daemon.h], [
- AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [libsystemddaemon="y"])
- ])
- AS_IF([test "x$libsystemddaemon" = x], [
- AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library])
- ])
-
PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon])
dnl pkg-config older than 0.24 does not set these for
dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
])
AC_DEFUN([AX_CHECK_SYSTEMD_ENABLE_AVAILABLE], [
- AC_CHECK_HEADER([systemd/sd-daemon.h], [
- AC_CHECK_LIB([systemd-daemon], [sd_listen_fds], [systemd="y"])
- ])
+ PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon], [systemd="y"],
+ [systemd="n"])
])
dnl Enables systemd by default and requires a --disable-systemd option flag
- ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default"
-if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sd_listen_fds in -lsystemd-daemon" >&5
-$as_echo_n "checking for sd_listen_fds in -lsystemd-daemon... " >&6; }
-if ${ac_cv_lib_systemd_daemon_sd_listen_fds+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsystemd-daemon $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SYSTEMD" >&5
+$as_echo_n "checking for SYSTEMD... " >&6; }
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char sd_listen_fds ();
-int
-main ()
-{
-return sd_listen_fds ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_systemd_daemon_sd_listen_fds=yes
+if test -n "$SYSTEMD_CFLAGS"; then
+ pkg_cv_SYSTEMD_CFLAGS="$SYSTEMD_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd-daemon\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libsystemd-daemon") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_SYSTEMD_CFLAGS=`$PKG_CONFIG --cflags "libsystemd-daemon" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
else
- ac_cv_lib_systemd_daemon_sd_listen_fds=no
+ pkg_failed=yes
fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ else
+ pkg_failed=untried
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_daemon_sd_listen_fds" >&5
-$as_echo "$ac_cv_lib_systemd_daemon_sd_listen_fds" >&6; }
-if test "x$ac_cv_lib_systemd_daemon_sd_listen_fds" = xyes; then :
- systemd="y"
+if test -n "$SYSTEMD_LIBS"; then
+ pkg_cv_SYSTEMD_LIBS="$SYSTEMD_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd-daemon\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libsystemd-daemon") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_SYSTEMD_LIBS=`$PKG_CONFIG --libs "libsystemd-daemon" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
fi
-
-
+ else
+ pkg_failed=untried
fi
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
- if test "x$enable_systemd" != "xno"; then :
-
- if test "x$systemd" = "xy" ; then :
-
-
-$as_echo "#define HAVE_SYSTEMD 1" >>confdefs.h
-
- systemd=y
-
- ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default"
-if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes; then :
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sd_listen_fds in -lsystemd-daemon" >&5
-$as_echo_n "checking for sd_listen_fds in -lsystemd-daemon... " >&6; }
-if ${ac_cv_lib_systemd_daemon_sd_listen_fds+:} false; then :
- $as_echo_n "(cached) " >&6
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsystemd-daemon $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd-daemon" 2>&1`
+ else
+ SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd-daemon" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$SYSTEMD_PKG_ERRORS" >&5
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char sd_listen_fds ();
-int
-main ()
-{
-return sd_listen_fds ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_systemd_daemon_sd_listen_fds=yes
+ systemd="n"
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ systemd="n"
else
- ac_cv_lib_systemd_daemon_sd_listen_fds=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_daemon_sd_listen_fds" >&5
-$as_echo "$ac_cv_lib_systemd_daemon_sd_listen_fds" >&6; }
-if test "x$ac_cv_lib_systemd_daemon_sd_listen_fds" = xyes; then :
- libsystemddaemon="y"
+ SYSTEMD_CFLAGS=$pkg_cv_SYSTEMD_CFLAGS
+ SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ systemd="y"
fi
-fi
+ if test "x$enable_systemd" != "xno"; then :
+ if test "x$systemd" = "xy" ; then :
- if test "x$libsystemddaemon" = x; then :
- as_fn_error $? "Unable to find a suitable libsystemd-daemon library" "$LINENO" 5
+$as_echo "#define HAVE_SYSTEMD 1" >>confdefs.h
-fi
+ systemd=y
pkg_failed=no