1333529Sdes#   macros for configuring systemd
2333529Sdes#   Copyright 2015, Sami Kerola, CloudFlare.
3333529Sdes#   BSD licensed.
4333529SdesAC_ARG_ENABLE([systemd],
5333529Sdes	[AS_HELP_STRING([--enable-systemd], [compile with systemd support])],
6333529Sdes	[], [enable_systemd=no])
7333529Sdeshave_systemd=no
8333529SdesAS_IF([test "x$enable_systemd" != xno], [
9333529Sdes    ifdef([PKG_CHECK_MODULES], [
10333529Sdes	dnl systemd v209 or newer
11333529Sdes	PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [have_systemd=yes], [have_systemd=no])
12333529Sdes	dnl old systemd library
13333529Sdes	AS_IF([test "x$have_systemd" != "xyes"], [
14333529Sdes		PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
15333529Sdes			[have_systemd_daemon=yes], [have_systemd_daemon=no])
16333529Sdes		AS_IF([test "x$have_systemd_daemon" = "xyes"],
17333529Sdes			[have_systemd=yes])
18333529Sdes	])
19333529Sdes	AS_CASE([$enable_systemd:$have_systemd],
20333529Sdes	[yes:no],
21333529Sdes		[AC_MSG_ERROR([systemd enabled but libsystemd not found])],
22333529Sdes	[*:yes],
23333529Sdes		[AC_DEFINE([HAVE_SYSTEMD], [1], [Define to 1 if systemd should be used])
24333529Sdes		LIBS="$LIBS $SYSTEMD_LIBS"
25333529Sdes		]
26333529Sdes	)
27333529Sdes    ], [
28333529Sdes    	AC_MSG_ERROR([systemd enabled but need pkg-config to configure for it])
29333529Sdes    ])
30333529Sdes])
31333529SdesAM_CONDITIONAL([USE_SYSTEMD], [test "x$have_systemd" = xyes])
32