xref: /freebsd/contrib/unbound/systemd.m4 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1#   macros for configuring systemd
2#   Copyright 2015, Sami Kerola, CloudFlare.
3#   BSD licensed.
4AC_ARG_ENABLE([systemd],
5	[AS_HELP_STRING([--enable-systemd], [compile with systemd support])],
6	[], [enable_systemd=no])
7have_systemd=no
8AS_IF([test "x$enable_systemd" != xno], [
9    ifdef([PKG_CHECK_MODULES], [
10	dnl systemd v209 or newer
11	PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [have_systemd=yes], [have_systemd=no])
12	dnl old systemd library
13	AS_IF([test "x$have_systemd" != "xyes"], [
14		PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
15			[have_systemd_daemon=yes], [have_systemd_daemon=no])
16		AS_IF([test "x$have_systemd_daemon" = "xyes"],
17			[have_systemd=yes])
18	])
19	AS_CASE([$enable_systemd:$have_systemd],
20	[yes:no],
21		[AC_MSG_ERROR([systemd enabled but libsystemd not found])],
22	[*:yes],
23		[AC_DEFINE([HAVE_SYSTEMD], [1], [Define to 1 if systemd should be used])
24		LIBS="$LIBS $SYSTEMD_LIBS"
25		]
26	)
27    ], [
28    	AC_MSG_ERROR([systemd enabled but need pkg-config to configure for it])
29    ])
30])
31AM_CONDITIONAL([USE_SYSTEMD], [test "x$have_systemd" = xyes])
32