1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 project('systemd', 'c',
27 meson_version : '>= 0.41',
30 libsystemd_version = '0.21.0'
31 libudev_version = '1.6.9'
33 # We need the same data in three different formats, ugh!
34 # Also, for hysterical reasons, we use different variable
35 # names, sometimes. Not all variables are included in every
37 conf = configuration_data()
38 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
39 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
41 substs = configuration_data()
42 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
43 substs.set('PACKAGE_VERSION', meson.project_version())
47 #####################################################################
49 # Try to install the git pre-commit hook
50 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
51 if git_hook.returncode() == 0
52 message(git_hook.stdout().strip())
55 #####################################################################
57 if get_option('split-usr') == 'auto'
58 split_usr = run_command('test', '-L', '/bin').returncode() != 0
60 split_usr = get_option('split-usr') == 'true'
62 conf.set10('HAVE_SPLIT_USR', split_usr)
64 if get_option('split-bin') == 'auto'
65 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
67 split_bin = get_option('split-bin') == 'true'
70 rootprefixdir = get_option('rootprefix')
71 # Unusual rootprefixdir values are used by some distros
72 # (see https://github.com/systemd/systemd/pull/7461).
73 rootprefix_default = split_usr ? '/' : '/usr'
74 if rootprefixdir == ''
75 rootprefixdir = rootprefix_default
78 sysvinit_path = get_option('sysvinit-path')
79 sysvrcnd_path = get_option('sysvrcnd-path')
80 have = sysvinit_path != '' and sysvrcnd_path != ''
81 conf.set10('HAVE_SYSV_COMPAT', have,
82 description : 'SysV init scripts and rcN.d links are supported')
83 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
85 # join_paths ignore the preceding arguments if an absolute component is
86 # encountered, so this should canonicalize various paths when they are
87 # absolute or relative.
88 prefixdir = get_option('prefix')
89 if not prefixdir.startswith('/')
90 error('Prefix is not absolute: "@0@"'.format(prefixdir))
92 bindir = join_paths(prefixdir, get_option('bindir'))
93 libdir = join_paths(prefixdir, get_option('libdir'))
94 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
95 includedir = join_paths(prefixdir, get_option('includedir'))
96 datadir = join_paths(prefixdir, get_option('datadir'))
97 localstatedir = join_paths('/', get_option('localstatedir'))
99 rootbindir = join_paths(rootprefixdir, 'bin')
100 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
101 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
103 rootlibdir = get_option('rootlibdir')
105 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
108 # Dirs of external packages
109 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
110 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
111 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
112 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
113 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
114 varlogdir = join_paths(localstatedir, 'log')
115 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
116 rpmmacrosdir = get_option('rpmmacrosdir')
117 if rpmmacrosdir != 'no'
118 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
120 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
123 pkgdatadir = join_paths(datadir, 'systemd')
124 environmentdir = join_paths(prefixdir, 'lib/environment.d')
125 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
126 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
127 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
128 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
129 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
130 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
131 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
132 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
133 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
134 pkgincludedir = join_paths(includedir, 'systemd')
135 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
136 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
137 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
138 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
139 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
140 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
141 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
142 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
143 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
144 udevhomedir = udevlibexecdir
145 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
146 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
147 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
148 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
149 factorydir = join_paths(datadir, 'factory')
150 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
151 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
152 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
153 catalogstatedir = join_paths(systemdstatedir, 'catalog')
154 randomseeddir = join_paths(localstatedir, 'lib/systemd')
156 docdir = get_option('docdir')
158 docdir = join_paths(datadir, 'doc/systemd')
161 dbuspolicydir = get_option('dbuspolicydir')
162 if dbuspolicydir == ''
163 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
166 dbussessionservicedir = get_option('dbussessionservicedir')
167 if dbussessionservicedir == ''
168 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
171 dbussystemservicedir = get_option('dbussystemservicedir')
172 if dbussystemservicedir == ''
173 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
176 pamlibdir = get_option('pamlibdir')
178 pamlibdir = join_paths(rootlibdir, 'security')
181 pamconfdir = get_option('pamconfdir')
183 pamconfdir = join_paths(sysconfdir, 'pam.d')
186 memory_accounting_default = get_option('memory-accounting-default')
188 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
189 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
190 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
191 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
192 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
193 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
194 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
195 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
196 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
197 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
198 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
199 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
200 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
201 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
202 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
203 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
204 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
205 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
206 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
207 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
208 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
209 conf.set_quoted('ROOTPREFIX', rootprefixdir)
210 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
211 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
212 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
213 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
214 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
215 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
216 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
217 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
218 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
219 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
220 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
221 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
222 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
223 conf.set_quoted('LIBDIR', libdir)
224 conf.set_quoted('ROOTLIBDIR', rootlibdir)
225 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
226 conf.set_quoted('BOOTLIBDIR', bootlibdir)
227 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
228 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
229 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
230 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
231 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
232 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
233 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
234 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_ON_OFF', memory_accounting_default ? 'on' : 'off')
236 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
237 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
239 substs.set('prefix', prefixdir)
240 substs.set('exec_prefix', prefixdir)
241 substs.set('libdir', libdir)
242 substs.set('rootlibdir', rootlibdir)
243 substs.set('includedir', includedir)
244 substs.set('pkgsysconfdir', pkgsysconfdir)
245 substs.set('bindir', bindir)
246 substs.set('rootbindir', rootbindir)
247 substs.set('rootlibexecdir', rootlibexecdir)
248 substs.set('systemunitdir', systemunitdir)
249 substs.set('userunitdir', userunitdir)
250 substs.set('systempresetdir', systempresetdir)
251 substs.set('userpresetdir', userpresetdir)
252 substs.set('udevhwdbdir', udevhwdbdir)
253 substs.set('udevrulesdir', udevrulesdir)
254 substs.set('udevlibexecdir', udevlibexecdir)
255 substs.set('catalogdir', catalogdir)
256 substs.set('tmpfilesdir', tmpfilesdir)
257 substs.set('sysusersdir', sysusersdir)
258 substs.set('sysctldir', sysctldir)
259 substs.set('binfmtdir', binfmtdir)
260 substs.set('modulesloaddir', modulesloaddir)
261 substs.set('systemgeneratordir', systemgeneratordir)
262 substs.set('usergeneratordir', usergeneratordir)
263 substs.set('systemenvgeneratordir', systemenvgeneratordir)
264 substs.set('userenvgeneratordir', userenvgeneratordir)
265 substs.set('systemshutdowndir', systemshutdowndir)
266 substs.set('systemsleepdir', systemsleepdir)
267 substs.set('VARLOGDIR', varlogdir)
268 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
269 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
270 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
271 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
272 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
273 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
274 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
275 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
277 #####################################################################
279 cc = meson.get_compiler('c')
280 pkgconfig = import('pkgconfig')
281 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
282 meson_build_sh = find_program('tools/meson-build.sh')
284 if get_option('tests') != 'false'
285 cxx = find_program('c++', required : false)
287 # Used only for tests
292 want_ossfuzz = get_option('oss-fuzz')
293 want_libfuzzer = get_option('llvm-fuzz')
294 fuzzer_build = want_ossfuzz or want_libfuzzer
295 if want_ossfuzz and want_libfuzzer
296 error('only one of oss-fuzz and llvm-fuzz can be specified')
299 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
302 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
305 foreach arg : ['-Wextra',
308 '-Wmissing-include-dirs',
309 '-Wold-style-definition',
312 '-Wdeclaration-after-statement',
314 '-Wsuggest-attribute=noreturn',
315 '-Werror=missing-prototypes',
316 '-Werror=implicit-function-declaration',
317 '-Werror=missing-declarations',
318 '-Werror=return-type',
319 '-Werror=incompatible-pointer-types',
321 '-Wstrict-prototypes',
323 '-Wmissing-noreturn',
324 '-Wimplicit-fallthrough=5',
327 '-Wstrict-aliasing=2',
334 '-fdiagnostics-show-option',
335 '-fno-strict-aliasing',
336 '-fvisibility=hidden',
338 '-fstack-protector-strong',
339 '--param=ssp-buffer-size=4',
341 if cc.has_argument(arg)
342 add_project_arguments(arg, language : 'c')
346 # the oss-fuzz fuzzers are not built with -fPIE, so don't
347 # enable it when we are linking against them
349 if cc.has_argument('-fPIE')
350 add_project_arguments('-fPIE', language : 'c')
354 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
355 # arguments, just emits a warnings. So test for the "positive" version instead.
356 foreach arg : ['unused-parameter',
357 'missing-field-initializers',
360 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
362 if cc.has_argument('-W' + arg)
363 add_project_arguments('-Wno-' + arg, language : 'c')
369 #include <inttypes.h>
370 typedef uint64_t usec_t;
371 usec_t now(clockid_t clock);
376 ''', name : '-Werror=shadow with local shadowing')
377 add_project_arguments('-Werror=shadow', language : 'c')
380 if cc.get_id() == 'clang'
381 foreach arg : ['-Wno-typedef-redefinition',
382 '-Wno-gnu-variable-sized-type-not-at-end',
384 if cc.has_argument(arg,
385 name : '@0@ is supported'.format(arg))
386 add_project_arguments(arg, language : 'c')
391 link_test_c = files('tools/meson-link-test.c')
393 # --as-needed and --no-undefined are provided by meson by default,
394 # run mesonconf to see what is enabled
395 foreach arg : ['-Wl,-z,relro',
400 have = run_command(check_compilation_sh,
401 cc.cmd_array(), '-x', 'c', arg,
402 '-include', link_test_c).returncode() == 0
403 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
404 if have and (arg != '-pie' or not fuzzer_build)
405 add_project_link_arguments(arg, language : 'c')
409 # Check if various sanitizers are supported
411 foreach arg : ['address']
413 have = run_command(check_compilation_sh,
414 cc.cmd_array(), '-x', 'c',
415 '-fsanitize=@0@'.format(arg),
416 '-include', link_test_c).returncode() == 0
417 message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
423 if get_option('buildtype') != 'debug'
424 foreach arg : ['-ffunction-sections',
426 if cc.has_argument(arg,
427 name : '@0@ is supported'.format(arg))
428 add_project_arguments(arg, language : 'c')
432 foreach arg : ['-Wl,--gc-sections']
433 have = run_command(check_compilation_sh,
434 cc.cmd_array(), '-x', 'c', arg,
435 '-include', link_test_c).returncode() == 0
436 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
438 add_project_link_arguments(arg, language : 'c')
443 cpp = ' '.join(cc.cmd_array()) + ' -E'
445 #####################################################################
446 # compilation result tests
448 conf.set('_GNU_SOURCE', true)
449 conf.set('__SANE_USERSPACE_TYPES__', true)
451 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
452 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
453 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
454 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
455 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
456 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
457 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
461 #include <linux/ethtool.h>
462 #include <linux/fib_rules.h>
463 #include <linux/stat.h>
464 #include <sys/stat.h>
466 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
468 foreach decl : ['char16_t',
471 'struct ethtool_link_settings',
472 'struct fib_rule_uid_range',
476 # We get -1 if the size cannot be determined
477 have = cc.sizeof(decl, prefix : decl_headers) > 0
478 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
481 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
482 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
483 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
484 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
485 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
486 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
487 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
488 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
489 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
490 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
491 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
492 # if_tunnel.h is buggy and cannot be included on its own
493 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
494 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
495 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
496 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
497 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
498 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
499 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
500 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
501 ['NDA_IFINDEX', 'linux/neighbour.h'],
502 ['IFA_FLAGS', 'linux/if_addr.h'],
503 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
504 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
505 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
507 prefix = decl.length() > 2 ? decl[2] : ''
508 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
509 conf.set10('HAVE_' + decl[0], have)
512 foreach ident : ['secure_getenv', '__secure_getenv']
513 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
517 ['memfd_create', '''#include <sys/mman.h>'''],
518 ['gettid', '''#include <sys/types.h>
519 #include <unistd.h>'''],
520 ['pivot_root', '''#include <stdlib.h>
521 #include <unistd.h>'''], # no known header declares pivot_root
522 ['name_to_handle_at', '''#include <sys/types.h>
523 #include <sys/stat.h>
524 #include <fcntl.h>'''],
525 ['setns', '''#include <sched.h>'''],
526 ['renameat2', '''#include <stdio.h>
527 #include <fcntl.h>'''],
528 ['kcmp', '''#include <linux/kcmp.h>'''],
529 ['keyctl', '''#include <sys/types.h>
530 #include <keyutils.h>'''],
531 ['copy_file_range', '''#include <sys/syscall.h>
532 #include <unistd.h>'''],
533 ['bpf', '''#include <sys/syscall.h>
534 #include <unistd.h>'''],
535 ['statx', '''#include <sys/types.h>
536 #include <sys/stat.h>
537 #include <unistd.h>'''],
538 ['explicit_bzero' , '''#include <string.h>'''],
539 ['reallocarray', '''#include <malloc.h>'''],
542 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
543 conf.set10('HAVE_' + ident[0].to_upper(), have)
546 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
547 conf.set10('USE_SYS_RANDOM_H', true)
548 conf.set10('HAVE_GETRANDOM', true)
550 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
551 conf.set10('USE_SYS_RANDOM_H', false)
552 conf.set10('HAVE_GETRANDOM', have)
555 #####################################################################
557 sed = find_program('sed')
558 awk = find_program('awk')
559 m4 = find_program('m4')
560 stat = find_program('stat')
561 git = find_program('git', required : false)
562 env = find_program('env')
564 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
565 mkdir_p = 'mkdir -p $DESTDIR/@0@'
566 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
567 splash_bmp = files('test/splash.bmp')
569 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
570 # /usr/sbin, /sbin, and fall back to the default from middle column.
571 progs = [['quotaon', '/usr/sbin/quotaon' ],
572 ['quotacheck', '/usr/sbin/quotacheck' ],
573 ['kill', '/usr/bin/kill' ],
574 ['kmod', '/usr/bin/kmod' ],
575 ['kexec', '/usr/sbin/kexec' ],
576 ['sulogin', '/usr/sbin/sulogin' ],
577 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
578 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
579 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
580 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
583 path = get_option(prog[0] + '-path')
585 message('Using @1@ for @0@'.format(prog[0], path))
587 exe = find_program(prog[0],
588 '/usr/sbin/' + prog[0],
591 path = exe.found() ? exe.path() : prog[1]
593 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
594 conf.set_quoted(name, path)
595 substs.set(name, path)
598 conf.set_quoted('TELINIT', get_option('telinit-path'))
600 if run_command('ln', '--relative', '--help').returncode() != 0
601 error('ln does not support --relative')
604 ############################################################
606 gperf = find_program('gperf')
608 gperf_test_format = '''
610 const char * in_word_set(const char *, @0@);
613 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
614 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
615 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
616 if cc.compiles(gperf_test)
617 gperf_len_type = 'size_t'
619 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
620 if cc.compiles(gperf_test)
621 gperf_len_type = 'unsigned'
623 error('unable to determine gperf len type')
626 message('gperf len type is @0@'.format(gperf_len_type))
627 conf.set('GPERF_LEN_TYPE', gperf_len_type,
628 description : 'The type of gperf "len" parameter')
630 ############################################################
632 if not cc.has_header('sys/capability.h')
633 error('POSIX caps headers not found')
635 foreach header : ['crypt.h',
638 'linux/vm_sockets.h',
640 'valgrind/memcheck.h',
641 'valgrind/valgrind.h',
644 conf.set10('HAVE_' + header.underscorify().to_upper(),
645 cc.has_header(header))
648 ############################################################
650 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
651 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
652 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
654 default_hierarchy = get_option('default-hierarchy')
655 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
656 description : 'default cgroup hierarchy as string')
657 if default_hierarchy == 'legacy'
658 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
659 elif default_hierarchy == 'hybrid'
660 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
662 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
665 time_epoch = get_option('time-epoch')
668 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
670 time_epoch = time_epoch.to_int()
671 conf.set('TIME_EPOCH', time_epoch)
673 system_uid_max = get_option('system-uid-max')
674 if system_uid_max == ''
675 system_uid_max = run_command(
677 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
678 '/etc/login.defs').stdout().strip()
679 if system_uid_max == ''
680 system_uid_max = '999'
683 system_uid_max = system_uid_max.to_int()
684 conf.set('SYSTEM_UID_MAX', system_uid_max)
685 substs.set('systemuidmax', system_uid_max)
686 message('maximum system UID is @0@'.format(system_uid_max))
688 system_gid_max = get_option('system-gid-max')
689 if system_gid_max == ''
690 system_gid_max = run_command(
692 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
693 '/etc/login.defs').stdout().strip()
694 if system_gid_max == ''
695 system_gid_max = '999'
698 system_gid_max = system_gid_max.to_int()
699 conf.set('SYSTEM_GID_MAX', system_gid_max)
700 substs.set('systemgidmax', system_gid_max)
701 message('maximum system GID is @0@'.format(system_gid_max))
703 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
704 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
705 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
706 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
707 substs.set('dynamicuidmin', dynamic_uid_min)
708 substs.set('dynamicuidmax', dynamic_uid_max)
710 container_uid_base_min = get_option('container-uid-base-min').to_int()
711 container_uid_base_max = get_option('container-uid-base-max').to_int()
712 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
713 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
714 substs.set('containeruidbasemin', container_uid_base_min)
715 substs.set('containeruidbasemax', container_uid_base_max)
717 nobody_user = get_option('nobody-user')
718 nobody_group = get_option('nobody-group')
720 getent_result = run_command('getent', 'passwd', '65534')
721 if getent_result.returncode() == 0
722 name = getent_result.stdout().split(':')[0]
723 if name != nobody_user
724 message('WARNING:\n' +
725 ' The local user with the UID 65534 does not match the configured user name "@0@" of the nobody user (its name is @1@).\n'.format(nobody_user, name) +
726 ' Your build will result in an user table setup that is incompatible with the local system.')
729 id_result = run_command('id', '-u', nobody_user)
730 if id_result.returncode() == 0
731 id = id_result.stdout().to_int()
733 message('WARNING:\n' +
734 ' The local user with the configured user name "@0@" of the nobody user does not have UID 65534 (it has @1@).\n'.format(nobody_user, id) +
735 ' Your build will result in an user table setup that is incompatible with the local system.')
739 getent_result = run_command('getent', 'group', '65534')
740 if getent_result.returncode() == 0
741 name = getent_result.stdout().split(':')[0]
742 if name != nobody_group
743 message('WARNING:\n' +
744 ' The local group with the GID 65534 does not match the configured group name "@0@" of the nobody group (its name is @1@).\n'.format(nobody_group, name) +
745 ' Your build will result in an group table setup that is incompatible with the local system.')
748 id_result = run_command('id', '-g', nobody_group)
749 if id_result.returncode() == 0
750 id = id_result.stdout().to_int()
752 message('WARNING:\n' +
753 ' The local group with the configured group name "@0@" of the nobody group does not have UID 65534 (it has @1@).\n'.format(nobody_group, id) +
754 ' Your build will result in an group table setup that is incompatible with the local system.')
757 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
758 message('WARNING:\n' +
759 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
760 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
763 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
764 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
765 substs.set('NOBODY_USER_NAME', nobody_user)
766 substs.set('NOBODY_GROUP_NAME', nobody_group)
768 tty_gid = get_option('tty-gid')
769 conf.set('TTY_GID', tty_gid)
770 substs.set('TTY_GID', tty_gid)
772 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
773 if get_option('users-gid') != ''
774 users_gid = get_option('users-gid').to_int()
778 substs.set('USERS_GID', users_gid)
780 if get_option('adm-group')
781 m4_defines += ['-DENABLE_ADM_GROUP']
784 if get_option('wheel-group')
785 m4_defines += ['-DENABLE_WHEEL_GROUP']
788 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
789 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
791 kill_user_processes = get_option('default-kill-user-processes')
792 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
793 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
795 dns_servers = get_option('dns-servers')
796 conf.set_quoted('DNS_SERVERS', dns_servers)
797 substs.set('DNS_SERVERS', dns_servers)
799 ntp_servers = get_option('ntp-servers')
800 conf.set_quoted('NTP_SERVERS', ntp_servers)
801 substs.set('NTP_SERVERS', ntp_servers)
803 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
805 substs.set('SUSHELL', get_option('debug-shell'))
806 substs.set('DEBUGTTY', get_option('debug-tty'))
808 debug = get_option('debug')
809 enable_debug_hashmap = false
810 enable_debug_mmap_cache = false
812 foreach name : debug.split(',')
814 enable_debug_hashmap = true
815 elif name == 'mmap-cache'
816 enable_debug_mmap_cache = true
818 message('unknown debug option "@0@", ignoring'.format(name))
822 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
823 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
825 #####################################################################
827 threads = dependency('threads')
828 librt = cc.find_library('rt')
829 libm = cc.find_library('m')
830 libdl = cc.find_library('dl')
831 libcrypt = cc.find_library('crypt')
833 libcap = dependency('libcap', required : false)
834 if not libcap.found()
835 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
836 libcap = cc.find_library('cap')
839 libmount = dependency('mount',
841 required : not fuzzer_build)
843 want_seccomp = get_option('seccomp')
844 if want_seccomp != 'false' and not fuzzer_build
845 libseccomp = dependency('libseccomp',
846 version : '>= 2.3.1',
847 required : want_seccomp == 'true')
848 have = libseccomp.found()
853 conf.set10('HAVE_SECCOMP', have)
854 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
856 want_selinux = get_option('selinux')
857 if want_selinux != 'false' and not fuzzer_build
858 libselinux = dependency('libselinux',
859 version : '>= 2.1.9',
860 required : want_selinux == 'true')
861 have = libselinux.found()
866 conf.set10('HAVE_SELINUX', have)
867 m4_defines += have ? ['-DHAVE_SELINUX'] : []
869 want_apparmor = get_option('apparmor')
870 if want_apparmor != 'false' and not fuzzer_build
871 libapparmor = dependency('libapparmor',
872 required : want_apparmor == 'true')
873 have = libapparmor.found()
878 conf.set10('HAVE_APPARMOR', have)
879 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
881 smack_run_label = get_option('smack-run-label')
882 if smack_run_label != ''
883 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
884 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
887 want_polkit = get_option('polkit')
888 install_polkit = false
889 install_polkit_pkla = false
890 if want_polkit != 'false' and not fuzzer_build
891 install_polkit = true
893 libpolkit = dependency('polkit-gobject-1',
895 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
896 message('Old polkit detected, will install pkla files')
897 install_polkit_pkla = true
900 conf.set10('ENABLE_POLKIT', install_polkit)
902 want_acl = get_option('acl')
903 if want_acl != 'false' and not fuzzer_build
904 libacl = cc.find_library('acl', required : want_acl == 'true')
905 have = libacl.found()
910 conf.set10('HAVE_ACL', have)
911 m4_defines += have ? ['-DHAVE_ACL'] : []
913 want_audit = get_option('audit')
914 if want_audit != 'false' and not fuzzer_build
915 libaudit = dependency('audit', required : want_audit == 'true')
916 have = libaudit.found()
921 conf.set10('HAVE_AUDIT', have)
923 want_blkid = get_option('blkid')
924 if want_blkid != 'false' and not fuzzer_build
925 libblkid = dependency('blkid', required : want_blkid == 'true')
926 have = libblkid.found()
931 conf.set10('HAVE_BLKID', have)
933 want_kmod = get_option('kmod')
934 if want_kmod != 'false' and not fuzzer_build
935 libkmod = dependency('libkmod',
937 required : want_kmod == 'true')
938 have = libkmod.found()
943 conf.set10('HAVE_KMOD', have)
945 want_pam = get_option('pam')
946 if want_pam != 'false' and not fuzzer_build
947 libpam = cc.find_library('pam', required : want_pam == 'true')
948 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
949 have = libpam.found() and libpam_misc.found()
955 conf.set10('HAVE_PAM', have)
956 m4_defines += have ? ['-DHAVE_PAM'] : []
958 want_microhttpd = get_option('microhttpd')
959 if want_microhttpd != 'false' and not fuzzer_build
960 libmicrohttpd = dependency('libmicrohttpd',
961 version : '>= 0.9.33',
962 required : want_microhttpd == 'true')
963 have = libmicrohttpd.found()
968 conf.set10('HAVE_MICROHTTPD', have)
969 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
971 want_libcryptsetup = get_option('libcryptsetup')
972 if want_libcryptsetup != 'false' and not fuzzer_build
973 libcryptsetup = dependency('libcryptsetup',
974 version : '>= 1.6.0',
975 required : want_libcryptsetup == 'true')
976 have = libcryptsetup.found()
981 conf.set10('HAVE_LIBCRYPTSETUP', have)
983 want_libcurl = get_option('libcurl')
984 if want_libcurl != 'false' and not fuzzer_build
985 libcurl = dependency('libcurl',
986 version : '>= 7.32.0',
987 required : want_libcurl == 'true')
988 have = libcurl.found()
993 conf.set10('HAVE_LIBCURL', have)
994 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
996 want_libidn = get_option('libidn')
997 want_libidn2 = get_option('libidn2')
998 if want_libidn == 'true' and want_libidn2 == 'true'
999 error('libidn and libidn2 cannot be requested simultaneously')
1002 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
1003 libidn = dependency('libidn',
1004 required : want_libidn == 'true')
1005 have = libidn.found()
1010 conf.set10('HAVE_LIBIDN', have)
1011 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1012 if not have and want_libidn2 != 'false' and not fuzzer_build
1013 # libidn is used for both libidn and libidn2 objects
1014 libidn = dependency('libidn2',
1015 required : want_libidn2 == 'true')
1016 have = libidn.found()
1020 conf.set10('HAVE_LIBIDN2', have)
1021 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1023 want_libiptc = get_option('libiptc')
1024 if want_libiptc != 'false' and not fuzzer_build
1025 libiptc = dependency('libiptc',
1026 required : want_libiptc == 'true')
1027 have = libiptc.found()
1032 conf.set10('HAVE_LIBIPTC', have)
1033 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1035 want_qrencode = get_option('qrencode')
1036 if want_qrencode != 'false' and not fuzzer_build
1037 libqrencode = dependency('libqrencode',
1038 required : want_qrencode == 'true')
1039 have = libqrencode.found()
1044 conf.set10('HAVE_QRENCODE', have)
1046 want_gcrypt = get_option('gcrypt')
1047 if want_gcrypt != 'false' and not fuzzer_build
1048 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1049 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1050 have = libgcrypt.found() and libgpg_error.found()
1055 # link to neither of the libs if one is not found
1059 conf.set10('HAVE_GCRYPT', have)
1061 want_gnutls = get_option('gnutls')
1062 if want_gnutls != 'false' and not fuzzer_build
1063 libgnutls = dependency('gnutls',
1064 version : '>= 3.1.4',
1065 required : want_gnutls == 'true')
1066 have = libgnutls.found()
1071 conf.set10('HAVE_GNUTLS', have)
1073 want_elfutils = get_option('elfutils')
1074 if want_elfutils != 'false' and not fuzzer_build
1075 libdw = dependency('libdw',
1076 required : want_elfutils == 'true')
1077 have = libdw.found()
1082 conf.set10('HAVE_ELFUTILS', have)
1084 want_zlib = get_option('zlib')
1085 if want_zlib != 'false' and not fuzzer_build
1086 libz = dependency('zlib',
1087 required : want_zlib == 'true')
1093 conf.set10('HAVE_ZLIB', have)
1095 want_bzip2 = get_option('bzip2')
1096 if want_bzip2 != 'false' and not fuzzer_build
1097 libbzip2 = cc.find_library('bz2',
1098 required : want_bzip2 == 'true')
1099 have = libbzip2.found()
1104 conf.set10('HAVE_BZIP2', have)
1106 want_xz = get_option('xz')
1107 if want_xz != 'false' and not fuzzer_build
1108 libxz = dependency('liblzma',
1109 required : want_xz == 'true')
1110 have = libxz.found()
1115 conf.set10('HAVE_XZ', have)
1117 want_lz4 = get_option('lz4')
1118 if want_lz4 != 'false' and not fuzzer_build
1119 liblz4 = dependency('liblz4',
1120 required : want_lz4 == 'true')
1121 have = liblz4.found()
1126 conf.set10('HAVE_LZ4', have)
1128 want_xkbcommon = get_option('xkbcommon')
1129 if want_xkbcommon != 'false' and not fuzzer_build
1130 libxkbcommon = dependency('xkbcommon',
1131 version : '>= 0.3.0',
1132 required : want_xkbcommon == 'true')
1133 have = libxkbcommon.found()
1138 conf.set10('HAVE_XKBCOMMON', have)
1140 want_pcre2 = get_option('pcre2')
1141 if want_pcre2 != 'false'
1142 libpcre2 = dependency('libpcre2-8',
1143 required : want_pcre2 == 'true')
1144 have = libpcre2.found()
1149 conf.set10('HAVE_PCRE2', have)
1151 want_glib = get_option('glib')
1152 if want_glib != 'false' and not fuzzer_build
1153 libglib = dependency('glib-2.0',
1154 version : '>= 2.22.0',
1155 required : want_glib == 'true')
1156 libgobject = dependency('gobject-2.0',
1157 version : '>= 2.22.0',
1158 required : want_glib == 'true')
1159 libgio = dependency('gio-2.0',
1160 required : want_glib == 'true')
1161 have = libglib.found() and libgobject.found() and libgio.found()
1168 conf.set10('HAVE_GLIB', have)
1170 want_dbus = get_option('dbus')
1171 if want_dbus != 'false' and not fuzzer_build
1172 libdbus = dependency('dbus-1',
1173 version : '>= 1.3.2',
1174 required : want_dbus == 'true')
1175 have = libdbus.found()
1180 conf.set10('HAVE_DBUS', have)
1182 default_dnssec = get_option('default-dnssec')
1184 default_dnssec = 'no'
1186 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1187 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1188 default_dnssec = 'no'
1190 conf.set('DEFAULT_DNSSEC_MODE',
1191 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1192 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1194 want_importd = get_option('importd')
1195 if want_importd != 'false'
1196 have = (conf.get('HAVE_LIBCURL') == 1 and
1197 conf.get('HAVE_ZLIB') == 1 and
1198 conf.get('HAVE_BZIP2') == 1 and
1199 conf.get('HAVE_XZ') == 1 and
1200 conf.get('HAVE_GCRYPT') == 1)
1201 if want_importd == 'true' and not have
1202 error('importd support was requested, but dependencies are not available')
1207 conf.set10('ENABLE_IMPORTD', have)
1209 want_remote = get_option('remote')
1210 if want_remote != 'false'
1211 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1212 conf.get('HAVE_LIBCURL') == 1]
1213 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1214 # it's possible to build one without the other. Complain only if
1215 # support was explictly requested. The auxiliary files like sysusers
1216 # config should be installed when any of the programs are built.
1217 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1218 error('remote support was requested, but dependencies are not available')
1220 have = have_deps[0] or have_deps[1]
1224 conf.set10('ENABLE_REMOTE', have)
1226 foreach term : ['utmp',
1257 have = get_option(term)
1258 name = 'ENABLE_' + term.underscorify().to_upper()
1259 conf.set10(name, have)
1260 m4_defines += have ? ['-D' + name] : []
1263 want_tests = get_option('tests')
1264 install_tests = get_option('install-tests')
1265 slow_tests = get_option('slow-tests')
1269 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1271 #####################################################################
1273 if get_option('efi')
1274 efi_arch = host_machine.cpu_family()
1276 if efi_arch == 'x86'
1277 EFI_MACHINE_TYPE_NAME = 'ia32'
1278 gnu_efi_arch = 'ia32'
1279 elif efi_arch == 'x86_64'
1280 EFI_MACHINE_TYPE_NAME = 'x64'
1281 gnu_efi_arch = 'x86_64'
1282 elif efi_arch == 'arm'
1283 EFI_MACHINE_TYPE_NAME = 'arm'
1284 gnu_efi_arch = 'arm'
1285 elif efi_arch == 'aarch64'
1286 EFI_MACHINE_TYPE_NAME = 'aa64'
1287 gnu_efi_arch = 'aarch64'
1289 EFI_MACHINE_TYPE_NAME = ''
1294 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1296 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1300 conf.set10('ENABLE_EFI', have)
1302 #####################################################################
1304 config_h = configure_file(
1305 output : 'config.h',
1306 configuration : conf)
1308 includes = include_directories('src/basic',
1318 'src/libsystemd/sd-bus',
1319 'src/libsystemd/sd-device',
1320 'src/libsystemd/sd-hwdb',
1321 'src/libsystemd/sd-id128',
1322 'src/libsystemd/sd-netlink',
1323 'src/libsystemd/sd-network',
1324 'src/libsystemd-network',
1327 add_project_arguments('-include', 'config.h', language : 'c')
1331 subdir('src/systemd')
1333 subdir('src/libsystemd')
1334 subdir('src/libsystemd-network')
1335 subdir('src/journal')
1338 libjournal_core = static_library(
1340 libjournal_core_sources,
1342 include_directories : includes,
1345 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1346 libsystemd = shared_library(
1348 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1349 version : libsystemd_version,
1350 include_directories : includes,
1351 link_args : ['-shared',
1352 '-Wl,--version-script=' + libsystemd_sym_path],
1353 link_with : [libbasic,
1355 link_whole : [libsystemd_static,
1357 dependencies : [threads,
1361 link_depends : libsystemd_sym,
1363 install_dir : rootlibdir)
1365 ############################################################
1367 # binaries that have --help and are intended for use by humans,
1368 # usually, but not always, installed in /bin.
1369 public_programs = []
1371 subdir('src/libudev')
1372 subdir('src/shared')
1375 subdir('src/network')
1377 subdir('src/analyze')
1378 subdir('src/journal-remote')
1379 subdir('src/coredump')
1380 subdir('src/hostname')
1381 subdir('src/import')
1382 subdir('src/kernel-install')
1383 subdir('src/locale')
1384 subdir('src/machine')
1385 subdir('src/nspawn')
1386 subdir('src/resolve')
1387 subdir('src/timedate')
1388 subdir('src/timesync')
1389 subdir('src/vconsole')
1390 subdir('src/boot/efi')
1397 ############################################################
1399 # only static linking apart from libdl, to make sure that the
1400 # module is linked to all libraries that it uses.
1401 test_dlopen = executable(
1404 include_directories : includes,
1405 link_with : [libbasic],
1406 dependencies : [libdl])
1408 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1409 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1410 ['mymachines', 'ENABLE_MACHINED'],
1411 ['resolve', 'ENABLE_RESOLVE']]
1413 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1417 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1418 version_script_arg = join_paths(meson.current_source_dir(), sym)
1420 nss = shared_library(
1422 'src/nss-@0@/nss-@0@.c'.format(module),
1424 include_directories : includes,
1425 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1426 link_args : ['-Wl,-z,nodelete',
1428 '-Wl,--version-script=' + version_script_arg,
1430 link_with : [libsystemd_static,
1432 dependencies : [threads,
1436 install_dir : rootlibdir)
1438 # We cannot use shared_module because it does not support version suffix.
1439 # Unfortunately shared_library insists on creating the symlink…
1440 meson.add_install_script('sh', '-c',
1441 'rm $DESTDIR@0@/libnss_@1@.so'
1442 .format(rootlibdir, module))
1444 test('dlopen-nss_' + module,
1446 args : [nss.full_path()]) # path to dlopen must include a slash
1450 ############################################################
1452 executable('systemd',
1454 include_directories : includes,
1455 link_with : [libcore,
1457 dependencies : [threads,
1463 install_rpath : rootlibexecdir,
1465 install_dir : rootlibexecdir)
1467 meson.add_install_script(meson_make_symlink,
1468 join_paths(rootlibexecdir, 'systemd'),
1469 join_paths(rootsbindir, 'init'))
1471 exe = executable('systemd-analyze',
1472 systemd_analyze_sources,
1473 include_directories : includes,
1474 link_with : [libcore,
1476 dependencies : [threads,
1482 install_rpath : rootlibexecdir,
1484 public_programs += [exe]
1486 executable('systemd-journald',
1487 systemd_journald_sources,
1488 include_directories : includes,
1489 link_with : [libjournal_core,
1491 dependencies : [threads,
1495 install_rpath : rootlibexecdir,
1497 install_dir : rootlibexecdir)
1499 exe = executable('systemd-cat',
1500 systemd_cat_sources,
1501 include_directories : includes,
1502 link_with : [libjournal_core,
1504 dependencies : [threads],
1505 install_rpath : rootlibexecdir,
1507 public_programs += [exe]
1509 exe = executable('journalctl',
1511 include_directories : includes,
1512 link_with : [libshared],
1513 dependencies : [threads,
1518 install_rpath : rootlibexecdir,
1520 install_dir : rootbindir)
1521 public_programs += [exe]
1523 executable('systemd-getty-generator',
1524 'src/getty-generator/getty-generator.c',
1525 include_directories : includes,
1526 link_with : [libshared],
1527 install_rpath : rootlibexecdir,
1529 install_dir : systemgeneratordir)
1531 executable('systemd-debug-generator',
1532 'src/debug-generator/debug-generator.c',
1533 include_directories : includes,
1534 link_with : [libshared],
1535 install_rpath : rootlibexecdir,
1537 install_dir : systemgeneratordir)
1539 executable('systemd-fstab-generator',
1540 'src/fstab-generator/fstab-generator.c',
1541 'src/core/mount-setup.c',
1542 include_directories : includes,
1543 link_with : [libshared],
1544 install_rpath : rootlibexecdir,
1546 install_dir : systemgeneratordir)
1548 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1549 executable('30-systemd-environment-d-generator',
1550 'src/environment-d-generator/environment-d-generator.c',
1551 include_directories : includes,
1552 link_with : [libshared],
1553 install_rpath : rootlibexecdir,
1555 install_dir : userenvgeneratordir)
1557 meson.add_install_script(meson_make_symlink,
1558 join_paths(sysconfdir, 'environment'),
1559 join_paths(environmentdir, '99-environment.conf'))
1562 if conf.get('ENABLE_HIBERNATE') == 1
1563 executable('systemd-hibernate-resume-generator',
1564 'src/hibernate-resume/hibernate-resume-generator.c',
1565 include_directories : includes,
1566 link_with : [libshared],
1567 install_rpath : rootlibexecdir,
1569 install_dir : systemgeneratordir)
1571 executable('systemd-hibernate-resume',
1572 'src/hibernate-resume/hibernate-resume.c',
1573 include_directories : includes,
1574 link_with : [libshared],
1575 install_rpath : rootlibexecdir,
1577 install_dir : rootlibexecdir)
1580 if conf.get('HAVE_BLKID') == 1
1581 executable('systemd-gpt-auto-generator',
1582 'src/gpt-auto-generator/gpt-auto-generator.c',
1583 'src/basic/blkid-util.h',
1584 include_directories : includes,
1585 link_with : [libshared],
1586 dependencies : libblkid,
1587 install_rpath : rootlibexecdir,
1589 install_dir : systemgeneratordir)
1591 exe = executable('systemd-dissect',
1592 'src/dissect/dissect.c',
1593 include_directories : includes,
1594 link_with : [libshared],
1595 install_rpath : rootlibexecdir,
1597 install_dir : rootlibexecdir)
1598 public_programs += [exe]
1601 if conf.get('ENABLE_RESOLVE') == 1
1602 executable('systemd-resolved',
1603 systemd_resolved_sources,
1604 include_directories : includes,
1605 link_with : [libshared,
1607 libsystemd_resolve_core],
1608 dependencies : [threads,
1612 install_rpath : rootlibexecdir,
1614 install_dir : rootlibexecdir)
1616 exe = executable('systemd-resolve',
1617 systemd_resolve_sources,
1618 include_directories : includes,
1619 link_with : [libshared,
1621 libsystemd_resolve_core],
1622 dependencies : [threads,
1626 install_rpath : rootlibexecdir,
1628 public_programs += [exe]
1631 if conf.get('ENABLE_LOGIND') == 1
1632 executable('systemd-logind',
1633 systemd_logind_sources,
1634 include_directories : includes,
1635 link_with : [liblogind_core,
1637 dependencies : [threads,
1639 install_rpath : rootlibexecdir,
1641 install_dir : rootlibexecdir)
1643 exe = executable('loginctl',
1645 include_directories : includes,
1646 link_with : [libshared],
1647 dependencies : [threads,
1650 install_rpath : rootlibexecdir,
1652 install_dir : rootbindir)
1653 public_programs += [exe]
1655 exe = executable('systemd-inhibit',
1656 'src/login/inhibit.c',
1657 include_directories : includes,
1658 link_with : [libshared],
1659 install_rpath : rootlibexecdir,
1661 install_dir : rootbindir)
1662 public_programs += [exe]
1664 if conf.get('HAVE_PAM') == 1
1665 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1666 pam_systemd = shared_library(
1670 include_directories : includes,
1671 link_args : ['-shared',
1672 '-Wl,--version-script=' + version_script_arg],
1673 link_with : [libsystemd_static,
1675 dependencies : [threads,
1678 link_depends : pam_systemd_sym,
1680 install_dir : pamlibdir)
1682 test('dlopen-pam_systemd',
1684 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1688 if conf.get('HAVE_PAM') == 1
1689 executable('systemd-user-sessions',
1690 'src/user-sessions/user-sessions.c',
1691 include_directories : includes,
1692 link_with : [libshared],
1693 install_rpath : rootlibexecdir,
1695 install_dir : rootlibexecdir)
1698 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1699 exe = executable('bootctl',
1700 'src/boot/bootctl.c',
1701 include_directories : includes,
1702 link_with : [libshared],
1703 dependencies : [libblkid],
1704 install_rpath : rootlibexecdir,
1706 public_programs += [exe]
1709 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1710 include_directories : includes,
1711 link_with : [libshared],
1712 dependencies : [threads],
1713 install_rpath : rootlibexecdir,
1715 public_programs += [exe]
1717 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1718 include_directories : includes,
1719 link_with : [libshared],
1720 dependencies : [threads,
1725 install_rpath : rootlibexecdir,
1727 install_dir : rootbindir)
1728 public_programs += [exe]
1730 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1731 meson.add_install_script(meson_make_symlink,
1732 join_paths(rootbindir, 'systemctl'),
1733 join_paths(rootsbindir, alias))
1736 if conf.get('ENABLE_BACKLIGHT') == 1
1737 executable('systemd-backlight',
1738 'src/backlight/backlight.c',
1739 include_directories : includes,
1740 link_with : [libshared],
1741 install_rpath : rootlibexecdir,
1743 install_dir : rootlibexecdir)
1746 if conf.get('ENABLE_RFKILL') == 1
1747 executable('systemd-rfkill',
1748 'src/rfkill/rfkill.c',
1749 include_directories : includes,
1750 link_with : [libshared],
1751 install_rpath : rootlibexecdir,
1753 install_dir : rootlibexecdir)
1756 executable('systemd-system-update-generator',
1757 'src/system-update-generator/system-update-generator.c',
1758 include_directories : includes,
1759 link_with : [libshared],
1760 install_rpath : rootlibexecdir,
1762 install_dir : systemgeneratordir)
1764 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1765 executable('systemd-cryptsetup',
1766 'src/cryptsetup/cryptsetup.c',
1767 include_directories : includes,
1768 link_with : [libshared],
1769 dependencies : [libcryptsetup],
1770 install_rpath : rootlibexecdir,
1772 install_dir : rootlibexecdir)
1774 executable('systemd-cryptsetup-generator',
1775 'src/cryptsetup/cryptsetup-generator.c',
1776 include_directories : includes,
1777 link_with : [libshared],
1778 dependencies : [libcryptsetup],
1779 install_rpath : rootlibexecdir,
1781 install_dir : systemgeneratordir)
1783 executable('systemd-veritysetup',
1784 'src/veritysetup/veritysetup.c',
1785 include_directories : includes,
1786 link_with : [libshared],
1787 dependencies : [libcryptsetup],
1788 install_rpath : rootlibexecdir,
1790 install_dir : rootlibexecdir)
1792 executable('systemd-veritysetup-generator',
1793 'src/veritysetup/veritysetup-generator.c',
1794 include_directories : includes,
1795 link_with : [libshared],
1796 dependencies : [libcryptsetup],
1797 install_rpath : rootlibexecdir,
1799 install_dir : systemgeneratordir)
1802 if conf.get('HAVE_SYSV_COMPAT') == 1
1803 executable('systemd-sysv-generator',
1804 'src/sysv-generator/sysv-generator.c',
1805 include_directories : includes,
1806 link_with : [libshared],
1807 install_rpath : rootlibexecdir,
1809 install_dir : systemgeneratordir)
1811 executable('systemd-rc-local-generator',
1812 'src/rc-local-generator/rc-local-generator.c',
1813 include_directories : includes,
1814 link_with : [libshared],
1815 install_rpath : rootlibexecdir,
1817 install_dir : systemgeneratordir)
1820 if conf.get('ENABLE_HOSTNAMED') == 1
1821 executable('systemd-hostnamed',
1822 'src/hostname/hostnamed.c',
1823 include_directories : includes,
1824 link_with : [libshared],
1825 install_rpath : rootlibexecdir,
1827 install_dir : rootlibexecdir)
1829 exe = executable('hostnamectl',
1830 'src/hostname/hostnamectl.c',
1831 include_directories : includes,
1832 link_with : [libshared],
1833 install_rpath : rootlibexecdir,
1835 public_programs += [exe]
1838 if conf.get('ENABLE_LOCALED') == 1
1839 if conf.get('HAVE_XKBCOMMON') == 1
1840 # logind will load libxkbcommon.so dynamically on its own
1846 executable('systemd-localed',
1847 systemd_localed_sources,
1848 include_directories : includes,
1849 link_with : [libshared],
1850 dependencies : deps,
1851 install_rpath : rootlibexecdir,
1853 install_dir : rootlibexecdir)
1855 exe = executable('localectl',
1857 include_directories : includes,
1858 link_with : [libshared],
1859 install_rpath : rootlibexecdir,
1861 public_programs += [exe]
1864 if conf.get('ENABLE_TIMEDATED') == 1
1865 executable('systemd-timedated',
1866 'src/timedate/timedated.c',
1867 include_directories : includes,
1868 link_with : [libshared],
1869 install_rpath : rootlibexecdir,
1871 install_dir : rootlibexecdir)
1873 exe = executable('timedatectl',
1874 'src/timedate/timedatectl.c',
1875 include_directories : includes,
1876 install_rpath : rootlibexecdir,
1877 link_with : [libshared],
1879 public_programs += [exe]
1882 if conf.get('ENABLE_TIMESYNCD') == 1
1883 executable('systemd-timesyncd',
1884 systemd_timesyncd_sources,
1885 include_directories : includes,
1886 link_with : [libshared],
1887 dependencies : [threads,
1889 install_rpath : rootlibexecdir,
1891 install_dir : rootlibexecdir)
1894 if conf.get('ENABLE_MACHINED') == 1
1895 executable('systemd-machined',
1896 systemd_machined_sources,
1897 include_directories : includes,
1898 link_with : [libmachine_core,
1900 install_rpath : rootlibexecdir,
1902 install_dir : rootlibexecdir)
1904 exe = executable('machinectl',
1905 'src/machine/machinectl.c',
1906 include_directories : includes,
1907 link_with : [libshared],
1908 dependencies : [threads,
1911 install_rpath : rootlibexecdir,
1913 install_dir : rootbindir)
1914 public_programs += [exe]
1917 if conf.get('ENABLE_IMPORTD') == 1
1918 executable('systemd-importd',
1919 systemd_importd_sources,
1920 include_directories : includes,
1921 link_with : [libshared],
1922 dependencies : [threads],
1923 install_rpath : rootlibexecdir,
1925 install_dir : rootlibexecdir)
1927 systemd_pull = executable('systemd-pull',
1928 systemd_pull_sources,
1929 include_directories : includes,
1930 link_with : [libshared],
1931 dependencies : [libcurl,
1936 install_rpath : rootlibexecdir,
1938 install_dir : rootlibexecdir)
1940 systemd_import = executable('systemd-import',
1941 systemd_import_sources,
1942 include_directories : includes,
1943 link_with : [libshared],
1944 dependencies : [libcurl,
1948 install_rpath : rootlibexecdir,
1950 install_dir : rootlibexecdir)
1952 systemd_export = executable('systemd-export',
1953 systemd_export_sources,
1954 include_directories : includes,
1955 link_with : [libshared],
1956 dependencies : [libcurl,
1960 install_rpath : rootlibexecdir,
1962 install_dir : rootlibexecdir)
1963 public_programs += [systemd_pull, systemd_import, systemd_export]
1966 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1967 exe = executable('systemd-journal-upload',
1968 systemd_journal_upload_sources,
1969 include_directories : includes,
1970 link_with : [libshared],
1971 dependencies : [threads,
1976 install_rpath : rootlibexecdir,
1978 install_dir : rootlibexecdir)
1979 public_programs += [exe]
1982 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1983 s_j_remote = executable('systemd-journal-remote',
1984 systemd_journal_remote_sources,
1985 include_directories : includes,
1986 link_with : [libshared],
1987 dependencies : [threads,
1992 install_rpath : rootlibexecdir,
1994 install_dir : rootlibexecdir)
1996 s_j_gatewayd = executable('systemd-journal-gatewayd',
1997 systemd_journal_gatewayd_sources,
1998 include_directories : includes,
1999 link_with : [libshared],
2000 dependencies : [threads,
2005 install_rpath : rootlibexecdir,
2007 install_dir : rootlibexecdir)
2008 public_programs += [s_j_remote, s_j_gatewayd]
2011 if conf.get('ENABLE_COREDUMP') == 1
2012 executable('systemd-coredump',
2013 systemd_coredump_sources,
2014 include_directories : includes,
2015 link_with : [libshared],
2016 dependencies : [threads,
2021 install_rpath : rootlibexecdir,
2023 install_dir : rootlibexecdir)
2025 exe = executable('coredumpctl',
2026 coredumpctl_sources,
2027 include_directories : includes,
2028 link_with : [libshared],
2029 dependencies : [threads,
2032 install_rpath : rootlibexecdir,
2034 public_programs += [exe]
2037 if conf.get('ENABLE_BINFMT') == 1
2038 exe = executable('systemd-binfmt',
2039 'src/binfmt/binfmt.c',
2040 include_directories : includes,
2041 link_with : [libshared],
2042 install_rpath : rootlibexecdir,
2044 install_dir : rootlibexecdir)
2045 public_programs += [exe]
2047 meson.add_install_script('sh', '-c',
2048 mkdir_p.format(binfmtdir))
2049 meson.add_install_script('sh', '-c',
2050 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2053 if conf.get('ENABLE_VCONSOLE') == 1
2054 executable('systemd-vconsole-setup',
2055 'src/vconsole/vconsole-setup.c',
2056 include_directories : includes,
2057 link_with : [libshared],
2058 install_rpath : rootlibexecdir,
2060 install_dir : rootlibexecdir)
2063 if conf.get('ENABLE_RANDOMSEED') == 1
2064 executable('systemd-random-seed',
2065 'src/random-seed/random-seed.c',
2066 include_directories : includes,
2067 link_with : [libshared],
2068 install_rpath : rootlibexecdir,
2070 install_dir : rootlibexecdir)
2073 if conf.get('ENABLE_FIRSTBOOT') == 1
2074 executable('systemd-firstboot',
2075 'src/firstboot/firstboot.c',
2076 include_directories : includes,
2077 link_with : [libshared],
2078 dependencies : [libcrypt],
2079 install_rpath : rootlibexecdir,
2081 install_dir : rootbindir)
2084 executable('systemd-remount-fs',
2085 'src/remount-fs/remount-fs.c',
2086 'src/core/mount-setup.c',
2087 'src/core/mount-setup.h',
2088 include_directories : includes,
2089 link_with : [libshared],
2090 install_rpath : rootlibexecdir,
2092 install_dir : rootlibexecdir)
2094 executable('systemd-machine-id-setup',
2095 'src/machine-id-setup/machine-id-setup-main.c',
2096 'src/core/machine-id-setup.c',
2097 'src/core/machine-id-setup.h',
2098 include_directories : includes,
2099 link_with : [libshared],
2100 install_rpath : rootlibexecdir,
2102 install_dir : rootbindir)
2104 executable('systemd-fsck',
2106 include_directories : includes,
2107 link_with : [libshared],
2108 install_rpath : rootlibexecdir,
2110 install_dir : rootlibexecdir)
2112 executable('systemd-growfs',
2113 'src/partition/growfs.c',
2114 include_directories : includes,
2115 link_with : [libshared],
2116 dependencies : [libcryptsetup],
2117 install_rpath : rootlibexecdir,
2119 install_dir : rootlibexecdir)
2121 executable('systemd-makefs',
2122 'src/partition/makefs.c',
2123 include_directories : includes,
2124 link_with : [libshared],
2125 install_rpath : rootlibexecdir,
2127 install_dir : rootlibexecdir)
2129 executable('systemd-sleep',
2130 'src/sleep/sleep.c',
2131 include_directories : includes,
2132 link_with : [libshared],
2133 install_rpath : rootlibexecdir,
2135 install_dir : rootlibexecdir)
2137 exe = executable('systemd-sysctl',
2138 'src/sysctl/sysctl.c',
2139 include_directories : includes,
2140 link_with : [libshared],
2141 install_rpath : rootlibexecdir,
2143 install_dir : rootlibexecdir)
2144 public_programs += [exe]
2146 executable('systemd-ac-power',
2147 'src/ac-power/ac-power.c',
2148 include_directories : includes,
2149 link_with : [libshared],
2150 install_rpath : rootlibexecdir,
2152 install_dir : rootlibexecdir)
2154 exe = executable('systemd-detect-virt',
2155 'src/detect-virt/detect-virt.c',
2156 include_directories : includes,
2157 link_with : [libshared],
2158 install_rpath : rootlibexecdir,
2160 public_programs += [exe]
2162 exe = executable('systemd-delta',
2163 'src/delta/delta.c',
2164 include_directories : includes,
2165 link_with : [libshared],
2166 install_rpath : rootlibexecdir,
2168 public_programs += [exe]
2170 exe = executable('systemd-escape',
2171 'src/escape/escape.c',
2172 include_directories : includes,
2173 link_with : [libshared],
2174 install_rpath : rootlibexecdir,
2176 install_dir : rootbindir)
2177 public_programs += [exe]
2179 exe = executable('systemd-notify',
2180 'src/notify/notify.c',
2181 include_directories : includes,
2182 link_with : [libshared],
2183 install_rpath : rootlibexecdir,
2185 install_dir : rootbindir)
2186 public_programs += [exe]
2188 executable('systemd-volatile-root',
2189 'src/volatile-root/volatile-root.c',
2190 include_directories : includes,
2191 link_with : [libshared],
2192 install_rpath : rootlibexecdir,
2194 install_dir : rootlibexecdir)
2196 executable('systemd-cgroups-agent',
2197 'src/cgroups-agent/cgroups-agent.c',
2198 include_directories : includes,
2199 link_with : [libshared],
2200 install_rpath : rootlibexecdir,
2202 install_dir : rootlibexecdir)
2204 exe = executable('systemd-path',
2206 include_directories : includes,
2207 link_with : [libshared],
2208 install_rpath : rootlibexecdir,
2210 public_programs += [exe]
2212 exe = executable('systemd-ask-password',
2213 'src/ask-password/ask-password.c',
2214 include_directories : includes,
2215 link_with : [libshared],
2216 install_rpath : rootlibexecdir,
2218 install_dir : rootbindir)
2219 public_programs += [exe]
2221 executable('systemd-reply-password',
2222 'src/reply-password/reply-password.c',
2223 include_directories : includes,
2224 link_with : [libshared],
2225 install_rpath : rootlibexecdir,
2227 install_dir : rootlibexecdir)
2229 exe = executable('systemd-tty-ask-password-agent',
2230 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2231 include_directories : includes,
2232 link_with : [libshared],
2233 install_rpath : rootlibexecdir,
2235 install_dir : rootbindir)
2236 public_programs += [exe]
2238 exe = executable('systemd-cgls',
2240 include_directories : includes,
2241 link_with : [libshared],
2242 install_rpath : rootlibexecdir,
2244 public_programs += [exe]
2246 exe = executable('systemd-cgtop',
2247 'src/cgtop/cgtop.c',
2248 include_directories : includes,
2249 link_with : [libshared],
2250 install_rpath : rootlibexecdir,
2252 public_programs += [exe]
2254 executable('systemd-initctl',
2255 'src/initctl/initctl.c',
2256 include_directories : includes,
2257 link_with : [libshared],
2258 install_rpath : rootlibexecdir,
2260 install_dir : rootlibexecdir)
2262 exe = executable('systemd-mount',
2263 'src/mount/mount-tool.c',
2264 include_directories : includes,
2265 link_with : [libshared],
2266 install_rpath : rootlibexecdir,
2268 public_programs += [exe]
2270 meson.add_install_script(meson_make_symlink,
2271 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2273 exe = executable('systemd-run',
2275 include_directories : includes,
2276 link_with : [libshared],
2277 install_rpath : rootlibexecdir,
2279 public_programs += [exe]
2281 exe = executable('systemd-stdio-bridge',
2282 'src/stdio-bridge/stdio-bridge.c',
2283 include_directories : includes,
2284 link_with : [libshared],
2285 install_rpath : rootlibexecdir,
2287 public_programs += [exe]
2289 exe = executable('busctl',
2290 'src/busctl/busctl.c',
2291 'src/busctl/busctl-introspect.c',
2292 'src/busctl/busctl-introspect.h',
2293 include_directories : includes,
2294 link_with : [libshared],
2295 install_rpath : rootlibexecdir,
2297 public_programs += [exe]
2299 if conf.get('ENABLE_SYSUSERS') == 1
2300 exe = executable('systemd-sysusers',
2301 'src/sysusers/sysusers.c',
2302 include_directories : includes,
2303 link_with : [libshared],
2304 install_rpath : rootlibexecdir,
2306 install_dir : rootbindir)
2307 public_programs += [exe]
2310 if conf.get('ENABLE_TMPFILES') == 1
2311 exe = executable('systemd-tmpfiles',
2312 'src/tmpfiles/tmpfiles.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 dependencies : [libacl],
2316 install_rpath : rootlibexecdir,
2318 install_dir : rootbindir)
2319 public_programs += [exe]
2321 test('test-systemd-tmpfiles',
2322 test_systemd_tmpfiles_py,
2323 args : exe.full_path())
2324 # https://github.com/mesonbuild/meson/issues/2681
2327 if conf.get('ENABLE_HWDB') == 1
2328 exe = executable('systemd-hwdb',
2330 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2331 include_directories : includes,
2332 link_with : [libudev_static],
2333 install_rpath : udev_rpath,
2335 install_dir : rootbindir)
2336 public_programs += [exe]
2339 if conf.get('ENABLE_QUOTACHECK') == 1
2340 executable('systemd-quotacheck',
2341 'src/quotacheck/quotacheck.c',
2342 include_directories : includes,
2343 link_with : [libshared],
2344 install_rpath : rootlibexecdir,
2346 install_dir : rootlibexecdir)
2349 exe = executable('systemd-socket-proxyd',
2350 'src/socket-proxy/socket-proxyd.c',
2351 include_directories : includes,
2352 link_with : [libshared],
2353 dependencies : [threads],
2354 install_rpath : rootlibexecdir,
2356 install_dir : rootlibexecdir)
2357 public_programs += [exe]
2359 exe = executable('systemd-udevd',
2360 systemd_udevd_sources,
2361 include_directories : includes,
2362 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2363 link_with : [libudev_core,
2366 dependencies : [threads,
2371 install_rpath : udev_rpath,
2373 install_dir : rootlibexecdir)
2374 public_programs += [exe]
2376 exe = executable('udevadm',
2378 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2379 include_directories : includes,
2380 link_with : [libudev_core,
2383 dependencies : [threads,
2388 install_rpath : udev_rpath,
2390 install_dir : rootbindir)
2391 public_programs += [exe]
2393 executable('systemd-shutdown',
2394 systemd_shutdown_sources,
2395 include_directories : includes,
2396 link_with : [libshared],
2397 install_rpath : rootlibexecdir,
2399 install_dir : rootlibexecdir)
2401 executable('systemd-update-done',
2402 'src/update-done/update-done.c',
2403 include_directories : includes,
2404 link_with : [libshared],
2405 install_rpath : rootlibexecdir,
2407 install_dir : rootlibexecdir)
2409 executable('systemd-update-utmp',
2410 'src/update-utmp/update-utmp.c',
2411 include_directories : includes,
2412 link_with : [libshared],
2413 dependencies : [libaudit],
2414 install_rpath : rootlibexecdir,
2416 install_dir : rootlibexecdir)
2418 if conf.get('HAVE_KMOD') == 1
2419 executable('systemd-modules-load',
2420 'src/modules-load/modules-load.c',
2421 include_directories : includes,
2422 link_with : [libshared],
2423 dependencies : [libkmod],
2424 install_rpath : rootlibexecdir,
2426 install_dir : rootlibexecdir)
2428 meson.add_install_script('sh', '-c',
2429 mkdir_p.format(modulesloaddir))
2430 meson.add_install_script('sh', '-c',
2431 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2434 exe = executable('systemd-nspawn',
2435 systemd_nspawn_sources,
2436 'src/core/mount-setup.c', # FIXME: use a variable?
2437 'src/core/mount-setup.h',
2438 'src/core/loopback-setup.c',
2439 'src/core/loopback-setup.h',
2440 include_directories : [includes, include_directories('src/nspawn')],
2441 link_with : [libshared],
2442 dependencies : [libacl,
2446 install_rpath : rootlibexecdir,
2448 public_programs += [exe]
2450 if conf.get('ENABLE_NETWORKD') == 1
2451 executable('systemd-networkd',
2452 systemd_networkd_sources,
2453 include_directories : includes,
2454 link_with : [libnetworkd_core,
2458 dependencies : [threads],
2459 install_rpath : rootlibexecdir,
2461 install_dir : rootlibexecdir)
2463 executable('systemd-networkd-wait-online',
2464 systemd_networkd_wait_online_sources,
2465 include_directories : includes,
2466 link_with : [libnetworkd_core,
2468 install_rpath : rootlibexecdir,
2470 install_dir : rootlibexecdir)
2472 exe = executable('networkctl',
2474 include_directories : includes,
2475 link_with : [libsystemd_network,
2477 install_rpath : rootlibexecdir,
2479 install_dir : rootbindir)
2480 public_programs += [exe]
2483 executable('systemd-sulogin-shell',
2484 ['src/sulogin-shell/sulogin-shell.c'],
2485 include_directories : includes,
2486 link_with : [libshared],
2487 install_rpath : rootlibexecdir,
2489 install_dir : rootlibexecdir)
2491 ############################################################
2493 foreach tuple : tests
2495 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2496 dependencies = tuple[2]
2497 condition = tuple.length() >= 4 ? tuple[3] : ''
2498 type = tuple.length() >= 5 ? tuple[4] : ''
2499 defs = tuple.length() >= 6 ? tuple[5] : []
2500 incs = tuple.length() >= 7 ? tuple[6] : includes
2503 name = sources[0].split('/')[-1].split('.')[0]
2504 if type.startswith('timeout=')
2505 timeout = type.split('=')[1].to_int()
2508 if want_tests == 'false'
2509 message('Not compiling @0@ because tests is set to false'.format(name))
2510 elif condition == '' or conf.get(condition) == 1
2514 include_directories : incs,
2515 link_with : link_with,
2516 dependencies : dependencies,
2518 install_rpath : rootlibexecdir,
2519 install : install_tests,
2520 install_dir : join_paths(testsdir, type))
2523 message('@0@ is a manual test'.format(name))
2524 elif type == 'unsafe' and want_tests != 'unsafe'
2525 message('@0@ is an unsafe test'.format(name))
2532 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2536 test_libsystemd_sym = executable(
2537 'test-libsystemd-sym',
2538 test_libsystemd_sym_c,
2539 include_directories : includes,
2540 link_with : [libsystemd],
2541 install : install_tests,
2542 install_dir : testsdir)
2543 test('test-libsystemd-sym',
2544 test_libsystemd_sym)
2546 test_libudev_sym = executable(
2549 include_directories : includes,
2550 c_args : ['-Wno-deprecated-declarations'],
2551 link_with : [libudev],
2552 install : install_tests,
2553 install_dir : testsdir)
2554 test('test-libudev-sym',
2557 ############################################################
2561 foreach tuple : fuzzers
2563 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2564 dependencies = tuple[2]
2565 defs = tuple.length() >= 4 ? tuple[3] : []
2566 incs = tuple.length() >= 5 ? tuple[4] : includes
2569 dependencies += fuzzing_engine
2571 sources += 'src/fuzz/fuzz-main.c'
2574 name = sources[0].split('/')[-1].split('.')[0]
2576 fuzzer_exes += executable(
2579 include_directories : [incs, include_directories('src/fuzz')],
2580 link_with : link_with,
2581 dependencies : dependencies,
2586 run_target('fuzzers',
2587 depends : fuzzer_exes,
2590 ############################################################
2592 make_directive_index_py = find_program('tools/make-directive-index.py')
2593 make_man_index_py = find_program('tools/make-man-index.py')
2594 xml_helper_py = find_program('tools/xml_helper.py')
2595 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2599 subdir('sysusers.d')
2600 subdir('tmpfiles.d')
2605 subdir('shell-completion/bash')
2606 subdir('shell-completion/zsh')
2607 subdir('docs/sysvinit')
2608 subdir('docs/var-log')
2610 # FIXME: figure out if the warning is true:
2611 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2612 install_subdir('factory/etc',
2613 install_dir : factorydir)
2616 install_data('xorg/50-systemd-user.sh',
2617 install_dir : xinitrcdir)
2618 install_data('modprobe.d/systemd.conf',
2619 install_dir : modprobedir)
2620 install_data('LICENSE.GPL2',
2625 'doc/DISTRO_PORTING',
2626 'doc/ENVIRONMENT.md',
2628 'doc/TRANSIENT-SETTINGS.md',
2631 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2632 install_dir : docdir)
2634 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2635 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2637 ############################################################
2639 meson_check_help = find_program('tools/meson-check-help.sh')
2641 foreach exec : public_programs
2642 name = exec.full_path().split('/')[-1]
2643 test('check-help-' + name,
2645 args : [exec.full_path()])
2648 ############################################################
2651 foreach p : fuzz_regression_tests
2652 a = p.split('/')[-3]
2653 b = p.split('/')[-2]
2654 c = p.split('/')[-1]
2657 build = sanitize_address
2659 error('unknown sanitizer @0@'.format(a))
2662 name = '@1@:@0@'.format(a, b)
2665 if want_tests == 'false'
2666 message('Not compiling @0@ because tests is set to false'.format(name))
2667 elif not sanitizers.contains(a)
2668 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2670 exe = custom_target(
2674 command : [env, 'ln', '-fs',
2675 join_paths(build.full_path(), b),
2677 build_by_default : true)
2679 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2684 if want_tests != 'false' and slow_tests
2685 test(c, env, args : [exe.full_path(),
2686 join_paths(meson.source_root(),
2687 'test/fuzz-regressions',
2692 ############################################################
2695 all_files = run_command(
2697 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2700 all_files = files(all_files.stdout().split())
2705 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2709 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2713 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2716 command : [meson_git_contrib_sh])
2720 git_head = run_command(
2722 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2723 'rev-parse', 'HEAD']).stdout().strip()
2724 git_head_short = run_command(
2726 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2727 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2731 command : ['git', 'archive',
2732 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2734 '--prefix', 'systemd-@0@/'.format(git_head),
2738 ############################################################
2740 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2743 depends : [man, libsystemd, libudev],
2744 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2746 ############################################################
2749 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2751 'split /usr: @0@'.format(split_usr),
2752 'split bin-sbin: @0@'.format(split_bin),
2753 'prefix directory: @0@'.format(prefixdir),
2754 'rootprefix directory: @0@'.format(rootprefixdir),
2755 'sysconf directory: @0@'.format(sysconfdir),
2756 'include directory: @0@'.format(includedir),
2757 'lib directory: @0@'.format(libdir),
2758 'rootlib directory: @0@'.format(rootlibdir),
2759 'SysV init scripts: @0@'.format(sysvinit_path),
2760 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2761 'PAM modules directory: @0@'.format(pamlibdir),
2762 'PAM configuration directory: @0@'.format(pamconfdir),
2763 'RPM macros directory: @0@'.format(rpmmacrosdir),
2764 'modprobe.d directory: @0@'.format(modprobedir),
2765 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2766 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2767 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2768 'bash completions directory: @0@'.format(bashcompletiondir),
2769 'zsh completions directory: @0@'.format(zshcompletiondir),
2770 'extra start script: @0@'.format(get_option('rc-local')),
2771 'extra stop script: @0@'.format(get_option('halt-local')),
2772 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2773 get_option('debug-tty')),
2774 'TTY GID: @0@'.format(tty_gid),
2775 'users GID: @0@'.format(users_gid),
2776 'maximum system UID: @0@'.format(system_uid_max),
2777 'maximum system GID: @0@'.format(system_gid_max),
2778 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2779 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2780 'minimum container UID base: @0@'.format(container_uid_base_min),
2781 'maximum container UID base: @0@'.format(container_uid_base_max),
2782 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2783 'render group access mode: @0@'.format(get_option('group-render-mode')),
2784 'certificate root directory: @0@'.format(get_option('certificate-root')),
2785 'support URL: @0@'.format(support_url),
2786 'nobody user name: @0@'.format(nobody_user),
2787 'nobody group name: @0@'.format(nobody_group),
2788 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2789 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2791 'default DNSSEC mode: @0@'.format(default_dnssec),
2792 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2793 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2795 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2796 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2798 'default DNS servers: @0@'.format(alt_dns_servers),
2799 'default NTP servers: @0@'.format(alt_ntp_servers)]
2801 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2802 '@@0@'.format(time_epoch)).stdout().strip()
2804 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2807 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2808 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2809 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2811 if conf.get('ENABLE_EFI') == 1
2813 'efi arch: @0@'.format(efi_arch)]
2817 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2818 'EFI CC @0@'.format(efi_cc),
2819 'EFI lib directory: @0@'.format(efi_libdir),
2820 'EFI lds directory: @0@'.format(efi_ldsdir),
2821 'EFI include directory: @0@'.format(efi_incdir)]
2874 ['legacy pkla', install_polkit_pkla],
2876 ['gnu-efi', have_gnu_efi],
2883 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2886 ['man pages', want_man],
2887 ['html pages', want_html],
2888 ['man page indices', want_man and have_lxml],
2893 ['adm group', get_option('adm-group')],
2894 ['wheel group', get_option('wheel-group')],
2897 ['debug mmap cache'],
2900 cond = tuple.get(1, '')
2902 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2903 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2904 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2909 missing += [tuple[0]]
2915 'enabled features: @0@'.format(', '.join(found)),
2917 'disabled features: @0@'.format(', '.join(missing)),
2919 message('\n '.join(status))
2921 if rootprefixdir != rootprefix_default
2922 message('WARNING:\n' +
2923 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2924 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2925 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))