]> git.ipfire.org Git - thirdparty/pdns.git/blob - m4/systemd.m4
document makeIPCipherKey and fix links to it
[thirdparty/pdns.git] / m4 / systemd.m4
1 # systemd.m4 - Macros to check for and enable systemd -*- Autoconf -*-
2 #
3 # Copyright (C) 2014 Luis R. Rodriguez <mcgrof@suse.com>
4 # Copyright (C) 2016 Pieter Lexis <pieter.lexis@powerdns.com>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 #serial 2
21
22 dnl Some optional path options
23 AC_DEFUN([AX_SYSTEMD_OPTIONS], [
24 AC_ARG_WITH(systemd, [ --with-systemd set directory for systemd service files],
25 SYSTEMD_DIR="$withval", SYSTEMD_DIR="")
26 AC_SUBST(SYSTEMD_DIR)
27
28 AC_ARG_WITH(systemd, [ --with-systemd-modules-load set directory for systemd modules load files],
29 SYSTEMD_MODULES_LOAD="$withval", SYSTEMD_MODULES_LOAD="")
30 AC_SUBST(SYSTEMD_MODULES_LOAD)
31 ])
32
33 AC_DEFUN([AX_ENABLE_SYSTEMD_OPTS], [
34 AX_ARG_DEFAULT_ENABLE([systemd], [Disable systemd support])
35 AX_SYSTEMD_OPTIONS()
36 ])
37
38 AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [
39 AX_ARG_DEFAULT_DISABLE([systemd], [Enable systemd support], [$1])
40 AX_SYSTEMD_OPTIONS()
41 ])
42
43 AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [
44 AC_REQUIRE([AX_CHECK_SYSTEMD_DETECT_AND_ENABLE])
45 AS_IF([test "x$libsystemd" = x], [
46 AC_MSG_ERROR([Unable to find a suitable libsystemd library])
47 ])
48
49 PKG_CHECK_MODULES([SYSTEMD], [$libsystemd_daemon])
50 dnl pkg-config older than 0.24 does not set these for
51 dnl PKG_CHECK_MODULES() worth also noting is that as of version 208
52 dnl of systemd pkg-config --cflags currently yields no extra flags yet.
53 AC_SUBST([SYSTEMD_CFLAGS])
54 AC_SUBST([SYSTEMD_LIBS])
55
56 AS_IF([test "x$SYSTEMD_DIR" = x], [
57 dnl In order to use the line below we need to fix upstream systemd
58 dnl to properly ${prefix} for child variables in
59 dnl src/core/systemd.pc.in but this is a bit complex at the
60 dnl moment as they depend on another rootprefix, which can vary
61 dnl from prefix in practice. We provide our own definition as we
62 dnl *know* where systemd will dump this to, but this does limit
63 dnl us to stick to a non custom systemdsystemunitdir, dnl to work
64 dnl around this we provide the additional configure option
65 dnl --with-systemd where you can specify the directory for the unit
66 dnl files. It would also be best to just extend the upstream
67 dnl pkg-config pkg.m4 with an AC_DEFUN() to do this neatly.
68 dnl SYSTEMD_DIR="`$PKG_CONFIG --define-variable=prefix=$PREFIX --variable=systemdsystemunitdir systemd`"
69 SYSTEMD_DIR="\$(prefix)/lib/systemd/system/"
70 ], [])
71
72 AS_IF([test "x$SYSTEMD_DIR" = x], [
73 AC_MSG_ERROR([SYSTEMD_DIR is unset])
74 ], [])
75
76 dnl There is no variable for this yet for some reason
77 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [
78 SYSTEMD_MODULES_LOAD="\$(prefix)/lib/modules-load.d/"
79 ], [])
80
81 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [
82 AC_MSG_ERROR([SYSTEMD_MODULES_LOAD is unset])
83 ], [])
84 ])
85
86 AC_DEFUN([AX_CHECK_SYSTEMD], [
87 dnl Respect user override to disable
88 AS_IF([test "x$enable_systemd" != "xno"], [
89 AS_IF([test "x$systemd" = "xy" ], [
90 AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled])
91 systemd=y
92 AX_CHECK_SYSTEMD_LIBS()
93 ],[systemd=n])
94 ],[systemd=n])
95 ])
96
97 AC_DEFUN([AX_CHECK_SYSTEMD_DETECT_AND_ENABLE], [
98 AC_CHECK_HEADER([systemd/sd-daemon.h], [
99 for libname in systemd-daemon systemd; do
100 AC_CHECK_LIB([$libname], [sd_listen_fds], [
101 libsystemd_daemon="lib$libname"
102 systemd=y
103 libsystemd=y
104 ])
105 done
106 ])
107 ])
108
109 dnl Enables systemd by default and requires a --disable-systemd option flag
110 dnl to configure if you want to disable.
111 AC_DEFUN([AX_ENABLE_SYSTEMD], [
112 AX_ENABLE_SYSTEMD_OPTS()
113 AX_CHECK_SYSTEMD()
114 ])
115
116 dnl Systemd will be disabled by default and requires you to run configure with
117 dnl --enable-systemd to look for and enable systemd.
118 AC_DEFUN([AX_ALLOW_SYSTEMD], [
119 AX_ALLOW_SYSTEMD_OPTS()
120 AX_CHECK_SYSTEMD()
121 ])
122
123 dnl Systemd will be disabled by default but if your build system is detected
124 dnl to have systemd build libraries it will be enabled. You can always force
125 dnl disable with --disable-systemd
126 AC_DEFUN([AX_AVAILABLE_SYSTEMD], [
127 AX_ALLOW_SYSTEMD_OPTS([, but will be enabled when libraries are found])
128 AX_CHECK_SYSTEMD_DETECT_AND_ENABLE()
129 AX_CHECK_SYSTEMD()
130 ])
131
132 AC_DEFUN([AX_CHECK_SYSTEMD_FEATURES], [
133 if test x"$systemd" = "xy"; then
134 _systemd_version=`systemctl --version|head -1 |cut -d" " -f 2`
135 if test $_systemd_version -ge 183; then
136 systemd_private_tmp=y
137 fi
138 if test $_systemd_version -ge 209; then
139 systemd_system_call_architectures=y
140 systemd_private_devices=y
141 fi
142 if test $_systemd_version -ge 211; then
143 systemd_restrict_address_families=y
144 fi
145 if test $_systemd_version -ge 214; then
146 systemd_protect_system=y
147 systemd_protect_home=y
148 fi
149 if test $_systemd_version -ge 231; then
150 systemd_restrict_realtime=y
151 systemd_memory_deny_write_execute=y
152 fi
153 if test $_systemd_version -ge 232; then
154 systemd_protect_control_groups=y
155 systemd_protect_kernel_modules=y
156 systemd_protect_kernel_tunables=y
157 systemd_remove_ipc=y
158 systemd_dynamic_user=y
159 systemd_private_users=y
160 systemd_protect_system_strict=y
161 fi
162 if test $_systemd_version -ge 233; then
163 systemd_restrict_namespaces=y
164 fi
165 if test $_systemd_version -ge 235; then
166 systemd_lock_personality=y
167 # while SystemCallFilter is technically available starting with 187,
168 # we use the pre-defined call filter sets that have been introduced later.
169 # Initial support for these landed in 231
170 # @filesystem @reboot @swap in 233
171 # @aio, @sync, @chown, @setuid, @memlock, @signal and @timer in 235
172 systemd_system_call_filter=y
173 fi
174 fi
175 AM_CONDITIONAL([HAVE_SYSTEMD_DYNAMIC_USER], [ test x"$systemd_dynamic_user" = "xy" ])
176 AM_CONDITIONAL([HAVE_SYSTEMD_LOCK_PERSONALITY], [ test x"$systemd_lock_personality" = "xy" ])
177 AM_CONDITIONAL([HAVE_SYSTEMD_MEMORY_DENY_WRITE_EXECUTE], [ test x"$systemd_memory_deny_write_execute" = "xy" ])
178 AM_CONDITIONAL([HAVE_SYSTEMD_PRIVATE_DEVICES], [ test x"$systemd_private_devices" = "xy" ])
179 AM_CONDITIONAL([HAVE_SYSTEMD_PRIVATE_TMP], [ test x"$systemd_private_tmp" = "xy" ])
180 AM_CONDITIONAL([HAVE_SYSTEMD_PRIVATE_USERS], [ test x"$systemd_private_users" = "xy" ])
181 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_CONTROL_GROUPS], [ test x"$systemd_protect_control_groups" = "xy" ])
182 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_HOME], [ test x"$systemd_protect_home" = "xy" ])
183 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_KERNEL_MODULES], [ test x"$systemd_protect_kernel_modules" = "xy" ])
184 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_KERNEL_TUNABLES], [ test x"$systemd_protect_kernel_tunables" = "xy" ])
185 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_SYSTEM], [ test x"$systemd_protect_system" = "xy" ])
186 AM_CONDITIONAL([HAVE_SYSTEMD_PROTECT_SYSTEM_STRICT], [ test x"$systemd_protect_system_strict" = "xy" ])
187 AM_CONDITIONAL([HAVE_SYSTEMD_REMOVE_IPC], [ test x"$systemd_remove_ipc" = "xy" ])
188 AM_CONDITIONAL([HAVE_SYSTEMD_RESTRICT_ADDRESS_FAMILIES], [ test x"$systemd_restrict_address_families" = "xy" ])
189 AM_CONDITIONAL([HAVE_SYSTEMD_RESTRICT_NAMESPACES], [ test x"$systemd_restrict_namespaces" = "xy" ])
190 AM_CONDITIONAL([HAVE_SYSTEMD_RESTRICT_REALTIME], [ test x"$systemd_restrict_realtime" = "xy" ])
191 AM_CONDITIONAL([HAVE_SYSTEMD_SYSTEM_CALL_ARCHITECTURES], [ test x"$systemd_system_call_architectures" = "xy" ])
192 AM_CONDITIONAL([HAVE_SYSTEMD_SYSTEM_CALL_FILTER], [ test x"$systemd_system_call_filter" = "xy" ])
193 ])