xref: /openbsd-src/usr.sbin/unbound/systemd.m4 (revision a43524d9cc222a049058246319ec6a29f2d9ca78)
177079be7Ssthen#   macros for configuring systemd
277079be7Ssthen#   Copyright 2015, Sami Kerola, CloudFlare.
377079be7Ssthen#   BSD licensed.
477079be7SsthenAC_ARG_ENABLE([systemd],
5*a43524d9Ssthen	[AS_HELP_STRING([--enable-systemd], [compile with systemd support (requires libsystemd, pkg-config)])],
677079be7Ssthen	[], [enable_systemd=no])
777079be7Ssthenhave_systemd=no
877079be7SsthenAS_IF([test "x$enable_systemd" != xno], [
9*a43524d9Ssthen    if test -n "$PKG_CONFIG"; then
1077079be7Ssthen	dnl systemd v209 or newer
11*a43524d9Ssthen	have_systemd=no
12*a43524d9Ssthen	PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [have_systemd=yes], [])
1377079be7Ssthen	dnl old systemd library
1477079be7Ssthen	AS_IF([test "x$have_systemd" != "xyes"], [
15*a43524d9Ssthen		have_systemd_daemon=no
1677079be7Ssthen		PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
17*a43524d9Ssthen			[have_systemd_daemon=yes], [])
1877079be7Ssthen		AS_IF([test "x$have_systemd_daemon" = "xyes"],
1977079be7Ssthen			[have_systemd=yes])
2077079be7Ssthen	])
2177079be7Ssthen	AS_CASE([$enable_systemd:$have_systemd],
2277079be7Ssthen	[yes:no],
2377079be7Ssthen		[AC_MSG_ERROR([systemd enabled but libsystemd not found])],
2477079be7Ssthen	[*:yes],
2577079be7Ssthen		[AC_DEFINE([HAVE_SYSTEMD], [1], [Define to 1 if systemd should be used])
2677079be7Ssthen		LIBS="$LIBS $SYSTEMD_LIBS"
2777079be7Ssthen		]
2877079be7Ssthen	)
29*a43524d9Ssthen    else
3077079be7Ssthen    	AC_MSG_ERROR([systemd enabled but need pkg-config to configure for it])
31*a43524d9Ssthen    fi
3277079be7Ssthen])
3377079be7SsthenAM_CONDITIONAL([USE_SYSTEMD], [test "x$have_systemd" = xyes])
34