1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 project('systemd', 'c',
14 meson_version : '>= 0.44',
17 libsystemd_version = '0.22.0'
18 libudev_version = '1.6.10'
20 # We need the same data in two different formats, ugh!
21 # Also, for hysterical reasons, we use different variable
22 # names, sometimes. Not all variables are included in every
24 conf = configuration_data()
25 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
26 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
28 substs = configuration_data()
29 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
30 substs.set('PACKAGE_VERSION', meson.project_version())
32 #####################################################################
34 # Try to install the git pre-commit hook
35 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
36 if git_hook.returncode() == 0
37 message(git_hook.stdout().strip())
40 #####################################################################
42 if get_option('split-usr') == 'auto'
43 split_usr = run_command('test', '-L', '/bin').returncode() != 0
45 split_usr = get_option('split-usr') == 'true'
47 conf.set10('HAVE_SPLIT_USR', split_usr,
48 description : '/usr/bin and /bin directories are separate')
50 if get_option('split-bin') == 'auto'
51 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
53 split_bin = get_option('split-bin') == 'true'
55 conf.set10('HAVE_SPLIT_BIN', split_bin,
56 description : 'bin and sbin directories are separate')
58 rootprefixdir = get_option('rootprefix')
59 # Unusual rootprefixdir values are used by some distros
60 # (see https://github.com/systemd/systemd/pull/7461).
61 rootprefix_default = split_usr ? '/' : '/usr'
62 if rootprefixdir == ''
63 rootprefixdir = rootprefix_default
66 sysvinit_path = get_option('sysvinit-path')
67 sysvrcnd_path = get_option('sysvrcnd-path')
68 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
69 description : 'SysV init scripts and rcN.d links are supported')
71 # join_paths ignore the preceding arguments if an absolute component is
72 # encountered, so this should canonicalize various paths when they are
73 # absolute or relative.
74 prefixdir = get_option('prefix')
75 if not prefixdir.startswith('/')
76 error('Prefix is not absolute: "@0@"'.format(prefixdir))
78 bindir = join_paths(prefixdir, get_option('bindir'))
79 libdir = join_paths(prefixdir, get_option('libdir'))
80 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
81 includedir = join_paths(prefixdir, get_option('includedir'))
82 datadir = join_paths(prefixdir, get_option('datadir'))
83 localstatedir = join_paths('/', get_option('localstatedir'))
85 rootbindir = join_paths(rootprefixdir, 'bin')
86 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
87 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
89 rootlibdir = get_option('rootlibdir')
91 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
94 # Dirs of external packages
95 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
96 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
97 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
98 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
99 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
100 varlogdir = join_paths(localstatedir, 'log')
101 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
102 rpmmacrosdir = get_option('rpmmacrosdir')
103 if rpmmacrosdir != 'no'
104 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
106 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
109 pkgdatadir = join_paths(datadir, 'systemd')
110 environmentdir = join_paths(prefixdir, 'lib/environment.d')
111 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
112 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
113 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
114 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
115 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
116 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
117 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
118 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
119 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
120 pkgincludedir = join_paths(includedir, 'systemd')
121 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
122 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
123 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
124 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
125 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
126 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
127 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
128 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
129 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
130 udevhomedir = udevlibexecdir
131 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
132 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
133 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
134 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
135 factorydir = join_paths(datadir, 'factory')
136 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
137 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
138 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
139 catalogstatedir = join_paths(systemdstatedir, 'catalog')
140 randomseeddir = join_paths(localstatedir, 'lib/systemd')
141 profiledir = join_paths(rootlibexecdir, 'portable', 'profile')
143 docdir = get_option('docdir')
145 docdir = join_paths(datadir, 'doc/systemd')
148 dbuspolicydir = get_option('dbuspolicydir')
149 if dbuspolicydir == ''
150 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
153 dbussessionservicedir = get_option('dbussessionservicedir')
154 if dbussessionservicedir == ''
155 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
158 dbussystemservicedir = get_option('dbussystemservicedir')
159 if dbussystemservicedir == ''
160 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
163 pamlibdir = get_option('pamlibdir')
165 pamlibdir = join_paths(rootlibdir, 'security')
168 pamconfdir = get_option('pamconfdir')
170 pamconfdir = join_paths(sysconfdir, 'pam.d')
173 memory_accounting_default = get_option('memory-accounting-default')
175 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
176 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
177 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
178 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
179 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
180 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
181 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
183 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
185 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
186 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
187 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
188 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
189 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
190 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
191 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
192 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
193 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
194 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
195 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
196 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
197 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
198 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
199 conf.set_quoted('ROOTPREFIX', rootprefixdir)
200 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
201 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
202 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
203 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
204 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
205 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
206 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
207 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
208 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
209 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
210 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
211 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
212 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
213 conf.set_quoted('LIBDIR', libdir)
214 conf.set_quoted('ROOTLIBDIR', rootlibdir)
215 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
216 conf.set_quoted('BOOTLIBDIR', bootlibdir)
217 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
218 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
219 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
220 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
221 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
222 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
223 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
224 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
226 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
227 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
229 substs.set('prefix', prefixdir)
230 substs.set('exec_prefix', prefixdir)
231 substs.set('libdir', libdir)
232 substs.set('rootlibdir', rootlibdir)
233 substs.set('includedir', includedir)
234 substs.set('pkgsysconfdir', pkgsysconfdir)
235 substs.set('bindir', bindir)
236 substs.set('rootbindir', rootbindir)
237 substs.set('rootlibexecdir', rootlibexecdir)
238 substs.set('systemunitdir', systemunitdir)
239 substs.set('userunitdir', userunitdir)
240 substs.set('systempresetdir', systempresetdir)
241 substs.set('userpresetdir', userpresetdir)
242 substs.set('udevhwdbdir', udevhwdbdir)
243 substs.set('udevrulesdir', udevrulesdir)
244 substs.set('udevlibexecdir', udevlibexecdir)
245 substs.set('environmentdir', environmentdir)
246 substs.set('catalogdir', catalogdir)
247 substs.set('tmpfilesdir', tmpfilesdir)
248 substs.set('sysusersdir', sysusersdir)
249 substs.set('sysctldir', sysctldir)
250 substs.set('binfmtdir', binfmtdir)
251 substs.set('modulesloaddir', modulesloaddir)
252 substs.set('modprobedir', modprobedir)
253 substs.set('systemgeneratordir', systemgeneratordir)
254 substs.set('usergeneratordir', usergeneratordir)
255 substs.set('systemenvgeneratordir', systemenvgeneratordir)
256 substs.set('userenvgeneratordir', userenvgeneratordir)
257 substs.set('systemshutdowndir', systemshutdowndir)
258 substs.set('systemsleepdir', systemsleepdir)
259 substs.set('VARLOGDIR', varlogdir)
260 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
261 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
262 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
263 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
264 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
265 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
266 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
267 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
269 #####################################################################
271 cc = meson.get_compiler('c')
272 pkgconfig = import('pkgconfig')
273 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
274 meson_build_sh = find_program('tools/meson-build.sh')
276 if get_option('tests') != 'false'
277 cxx = find_program('c++', required : false)
279 # Used only for tests
284 want_ossfuzz = get_option('oss-fuzz')
285 want_libfuzzer = get_option('llvm-fuzz')
286 fuzzer_build = want_ossfuzz or want_libfuzzer
287 if want_ossfuzz and want_libfuzzer
288 error('only one of oss-fuzz and llvm-fuzz can be specified')
291 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
294 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
297 possible_cc_flags = [
301 '-Wmissing-include-dirs',
302 '-Wold-style-definition',
306 '-Wsuggest-attribute=noreturn',
307 '-Werror=missing-prototypes',
308 '-Werror=implicit-function-declaration',
309 '-Werror=missing-declarations',
310 '-Werror=return-type',
311 '-Werror=incompatible-pointer-types',
313 '-Wstrict-prototypes',
315 '-Wmissing-noreturn',
316 '-Wimplicit-fallthrough=5',
319 '-Wstrict-aliasing=2',
322 '-Werror=shift-count-overflow',
323 '-Werror=shift-overflow=2',
328 '-fdiagnostics-show-option',
329 '-fno-strict-aliasing',
330 '-fvisibility=hidden',
332 '-fstack-protector-strong',
333 '--param=ssp-buffer-size=4',
336 # --as-needed and --no-undefined are provided by meson by default,
337 # run mesonconf to see what is enabled
338 possible_link_flags = [
343 # the oss-fuzz fuzzers are not built with -fPIE, so don't
344 # enable it when we are linking against them
346 possible_cc_flags += '-fPIE'
347 possible_link_flags += '-pie'
350 if cc.get_id() == 'clang'
351 possible_cc_flags += [
352 '-Wno-typedef-redefinition',
353 '-Wno-gnu-variable-sized-type-not-at-end',
357 if get_option('buildtype') != 'debug'
358 possible_cc_flags += [
359 '-ffunction-sections',
363 possible_link_flags += '-Wl,--gc-sections'
366 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
368 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
369 # arguments, just emits a warning. So test for the "positive" version instead.
370 foreach arg : ['unused-parameter',
371 'missing-field-initializers',
374 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
376 if cc.has_argument('-W' + arg)
377 add_project_arguments('-Wno-' + arg, language : 'c')
383 #include <inttypes.h>
384 typedef uint64_t usec_t;
385 usec_t now(clockid_t clock);
390 ''', name : '-Werror=shadow with local shadowing')
391 add_project_arguments('-Werror=shadow', language : 'c')
394 link_test_c = files('tools/meson-link-test.c')
396 foreach arg : possible_link_flags
397 have = run_command(check_compilation_sh,
398 cc.cmd_array(), '-x', 'c', arg,
399 '-include', link_test_c).returncode() == 0
400 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
402 add_project_link_arguments(arg, language : 'c')
406 cpp = ' '.join(cc.cmd_array()) + ' -E'
408 #####################################################################
409 # compilation result tests
411 conf.set('_GNU_SOURCE', true)
412 conf.set('__SANE_USERSPACE_TYPES__', true)
414 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
415 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
416 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
417 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
418 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
419 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
420 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
424 #include <linux/ethtool.h>
425 #include <linux/fib_rules.h>
426 #include <linux/stat.h>
427 #include <sys/stat.h>
429 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
431 foreach decl : ['char16_t',
434 'struct ethtool_link_settings',
435 'struct fib_rule_uid_range',
439 # We get -1 if the size cannot be determined
440 have = cc.sizeof(decl, prefix : decl_headers) > 0
441 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
444 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
445 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
446 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
447 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
448 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
449 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
450 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
451 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
452 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
453 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
454 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
455 # if_tunnel.h is buggy and cannot be included on its own
456 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
457 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
458 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
459 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
460 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
461 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
462 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
463 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
464 ['NDA_IFINDEX', 'linux/neighbour.h'],
465 ['IFA_FLAGS', 'linux/if_addr.h'],
466 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
467 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
468 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
470 prefix = decl.length() > 2 ? decl[2] : ''
471 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
472 conf.set10('HAVE_' + decl[0], have)
475 foreach ident : ['secure_getenv', '__secure_getenv']
476 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
480 ['memfd_create', '''#include <sys/mman.h>'''],
481 ['gettid', '''#include <sys/types.h>
482 #include <unistd.h>'''],
483 ['pivot_root', '''#include <stdlib.h>
484 #include <unistd.h>'''], # no known header declares pivot_root
485 ['name_to_handle_at', '''#include <sys/types.h>
486 #include <sys/stat.h>
487 #include <fcntl.h>'''],
488 ['setns', '''#include <sched.h>'''],
489 ['renameat2', '''#include <stdio.h>
490 #include <fcntl.h>'''],
491 ['kcmp', '''#include <linux/kcmp.h>'''],
492 ['keyctl', '''#include <sys/types.h>
493 #include <keyutils.h>'''],
494 ['copy_file_range', '''#include <sys/syscall.h>
495 #include <unistd.h>'''],
496 ['bpf', '''#include <sys/syscall.h>
497 #include <unistd.h>'''],
498 ['statx', '''#include <sys/types.h>
499 #include <sys/stat.h>
500 #include <unistd.h>'''],
501 ['explicit_bzero' , '''#include <string.h>'''],
502 ['reallocarray', '''#include <malloc.h>'''],
505 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
506 conf.set10('HAVE_' + ident[0].to_upper(), have)
509 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
510 conf.set10('USE_SYS_RANDOM_H', true)
511 conf.set10('HAVE_GETRANDOM', true)
513 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
514 conf.set10('USE_SYS_RANDOM_H', false)
515 conf.set10('HAVE_GETRANDOM', have)
518 #####################################################################
520 sed = find_program('sed')
521 awk = find_program('awk')
522 m4 = find_program('m4')
523 stat = find_program('stat')
524 git = find_program('git', required : false)
525 env = find_program('env')
526 perl = find_program('perl', required : false)
528 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
529 mkdir_p = 'mkdir -p $DESTDIR/@0@'
530 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
531 splash_bmp = files('test/splash.bmp')
533 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
534 # /usr/sbin, /sbin, and fall back to the default from middle column.
535 progs = [['quotaon', '/usr/sbin/quotaon' ],
536 ['quotacheck', '/usr/sbin/quotacheck' ],
537 ['kmod', '/usr/bin/kmod' ],
538 ['kexec', '/usr/sbin/kexec' ],
539 ['sulogin', '/usr/sbin/sulogin' ],
540 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
541 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
542 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
543 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
546 path = get_option(prog[0] + '-path')
548 message('Using @1@ for @0@'.format(prog[0], path))
550 exe = find_program(prog[0],
551 '/usr/sbin/' + prog[0],
554 path = exe.found() ? exe.path() : prog[1]
556 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
557 conf.set_quoted(name, path)
558 substs.set(name, path)
561 conf.set_quoted('TELINIT', get_option('telinit-path'))
563 if run_command('ln', '--relative', '--help').returncode() != 0
564 error('ln does not support --relative (added in coreutils 8.16)')
567 ############################################################
569 gperf = find_program('gperf')
571 gperf_test_format = '''
573 const char * in_word_set(const char *, @0@);
576 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
577 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
578 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
579 if cc.compiles(gperf_test)
580 gperf_len_type = 'size_t'
582 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
583 if cc.compiles(gperf_test)
584 gperf_len_type = 'unsigned'
586 error('unable to determine gperf len type')
589 message('gperf len type is @0@'.format(gperf_len_type))
590 conf.set('GPERF_LEN_TYPE', gperf_len_type,
591 description : 'The type of gperf "len" parameter')
593 ############################################################
595 if not cc.has_header('sys/capability.h')
596 error('POSIX caps headers not found')
598 foreach header : ['crypt.h',
601 'linux/vm_sockets.h',
603 'valgrind/memcheck.h',
604 'valgrind/valgrind.h',
607 conf.set10('HAVE_' + header.underscorify().to_upper(),
608 cc.has_header(header))
611 ############################################################
613 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
614 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
615 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
617 default_hierarchy = get_option('default-hierarchy')
618 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
619 description : 'default cgroup hierarchy as string')
620 if default_hierarchy == 'legacy'
621 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
622 elif default_hierarchy == 'hybrid'
623 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
625 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
628 time_epoch = get_option('time-epoch')
631 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
633 time_epoch = time_epoch.to_int()
634 conf.set('TIME_EPOCH', time_epoch)
636 system_uid_max = get_option('system-uid-max')
637 if system_uid_max == ''
638 system_uid_max = run_command(
640 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
641 '/etc/login.defs').stdout().strip()
642 if system_uid_max == ''
643 system_uid_max = '999'
646 system_uid_max = system_uid_max.to_int()
647 conf.set('SYSTEM_UID_MAX', system_uid_max)
648 substs.set('systemuidmax', system_uid_max)
649 message('maximum system UID is @0@'.format(system_uid_max))
651 system_gid_max = get_option('system-gid-max')
652 if system_gid_max == ''
653 system_gid_max = run_command(
655 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
656 '/etc/login.defs').stdout().strip()
657 if system_gid_max == ''
658 system_gid_max = '999'
661 system_gid_max = system_gid_max.to_int()
662 conf.set('SYSTEM_GID_MAX', system_gid_max)
663 substs.set('systemgidmax', system_gid_max)
664 message('maximum system GID is @0@'.format(system_gid_max))
666 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
667 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
668 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
669 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
670 substs.set('dynamicuidmin', dynamic_uid_min)
671 substs.set('dynamicuidmax', dynamic_uid_max)
673 container_uid_base_min = get_option('container-uid-base-min').to_int()
674 container_uid_base_max = get_option('container-uid-base-max').to_int()
675 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
676 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
677 substs.set('containeruidbasemin', container_uid_base_min)
678 substs.set('containeruidbasemax', container_uid_base_max)
680 nobody_user = get_option('nobody-user')
681 nobody_group = get_option('nobody-group')
683 getent_result = run_command('getent', 'passwd', '65534')
684 if getent_result.returncode() == 0
685 name = getent_result.stdout().split(':')[0]
686 if name != nobody_user
688 '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) +
689 'Your build will result in an user table setup that is incompatible with the local system.')
692 id_result = run_command('id', '-u', nobody_user)
693 if id_result.returncode() == 0
694 id = id_result.stdout().to_int()
697 '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) +
698 'Your build will result in an user table setup that is incompatible with the local system.')
702 getent_result = run_command('getent', 'group', '65534')
703 if getent_result.returncode() == 0
704 name = getent_result.stdout().split(':')[0]
705 if name != nobody_group
707 '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) +
708 'Your build will result in an group table setup that is incompatible with the local system.')
711 id_result = run_command('id', '-g', nobody_group)
712 if id_result.returncode() == 0
713 id = id_result.stdout().to_int()
716 '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) +
717 'Your build will result in an group table setup that is incompatible with the local system.')
720 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
722 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
723 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
726 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
727 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
728 substs.set('NOBODY_USER_NAME', nobody_user)
729 substs.set('NOBODY_GROUP_NAME', nobody_group)
731 tty_gid = get_option('tty-gid')
732 conf.set('TTY_GID', tty_gid)
733 substs.set('TTY_GID', tty_gid)
735 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
736 if get_option('users-gid') != ''
737 users_gid = get_option('users-gid').to_int()
741 substs.set('USERS_GID', users_gid)
743 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
744 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
746 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
747 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
749 kill_user_processes = get_option('default-kill-user-processes')
750 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
751 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
752 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
754 dns_servers = get_option('dns-servers')
755 conf.set_quoted('DNS_SERVERS', dns_servers)
756 substs.set('DNS_SERVERS', dns_servers)
758 ntp_servers = get_option('ntp-servers')
759 conf.set_quoted('NTP_SERVERS', ntp_servers)
760 substs.set('NTP_SERVERS', ntp_servers)
762 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
764 substs.set('SUSHELL', get_option('debug-shell'))
765 substs.set('DEBUGTTY', get_option('debug-tty'))
767 enable_debug_hashmap = false
768 enable_debug_mmap_cache = false
769 foreach name : get_option('debug')
771 enable_debug_hashmap = true
772 elif name == 'mmap-cache'
773 enable_debug_mmap_cache = true
775 message('unknown debug option "@0@", ignoring'.format(name))
778 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
779 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
781 conf.set10('VALGRIND', get_option('valgrind'))
783 #####################################################################
785 threads = dependency('threads')
786 librt = cc.find_library('rt')
787 libm = cc.find_library('m')
788 libdl = cc.find_library('dl')
789 libcrypt = cc.find_library('crypt')
791 libcap = dependency('libcap', required : false)
792 if not libcap.found()
793 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
794 libcap = cc.find_library('cap')
797 libmount = dependency('mount',
798 version : fuzzer_build ? '>= 0' : '>= 2.30')
800 want_seccomp = get_option('seccomp')
801 if want_seccomp != 'false' and not fuzzer_build
802 libseccomp = dependency('libseccomp',
803 version : '>= 2.3.1',
804 required : want_seccomp == 'true')
805 have = libseccomp.found()
810 conf.set10('HAVE_SECCOMP', have)
812 want_selinux = get_option('selinux')
813 if want_selinux != 'false' and not fuzzer_build
814 libselinux = dependency('libselinux',
815 version : '>= 2.1.9',
816 required : want_selinux == 'true')
817 have = libselinux.found()
822 conf.set10('HAVE_SELINUX', have)
824 want_apparmor = get_option('apparmor')
825 if want_apparmor != 'false' and not fuzzer_build
826 libapparmor = dependency('libapparmor',
827 required : want_apparmor == 'true')
828 have = libapparmor.found()
833 conf.set10('HAVE_APPARMOR', have)
835 smack_run_label = get_option('smack-run-label')
836 if smack_run_label != ''
837 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
840 want_polkit = get_option('polkit')
841 install_polkit = false
842 install_polkit_pkla = false
843 if want_polkit != 'false' and not fuzzer_build
844 install_polkit = true
846 libpolkit = dependency('polkit-gobject-1',
848 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
849 message('Old polkit detected, will install pkla files')
850 install_polkit_pkla = true
853 conf.set10('ENABLE_POLKIT', install_polkit)
855 want_acl = get_option('acl')
856 if want_acl != 'false' and not fuzzer_build
857 libacl = cc.find_library('acl', required : want_acl == 'true')
858 have = libacl.found()
863 conf.set10('HAVE_ACL', have)
865 want_audit = get_option('audit')
866 if want_audit != 'false' and not fuzzer_build
867 libaudit = dependency('audit', required : want_audit == 'true')
868 have = libaudit.found()
873 conf.set10('HAVE_AUDIT', have)
875 want_blkid = get_option('blkid')
876 if want_blkid != 'false' and not fuzzer_build
877 libblkid = dependency('blkid', required : want_blkid == 'true')
878 have = libblkid.found()
883 conf.set10('HAVE_BLKID', have)
885 want_kmod = get_option('kmod')
886 if want_kmod != 'false' and not fuzzer_build
887 libkmod = dependency('libkmod',
889 required : want_kmod == 'true')
890 have = libkmod.found()
895 conf.set10('HAVE_KMOD', have)
897 want_pam = get_option('pam')
898 if want_pam != 'false' and not fuzzer_build
899 libpam = cc.find_library('pam', required : want_pam == 'true')
900 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
901 have = libpam.found() and libpam_misc.found()
907 conf.set10('HAVE_PAM', have)
909 want_microhttpd = get_option('microhttpd')
910 if want_microhttpd != 'false' and not fuzzer_build
911 libmicrohttpd = dependency('libmicrohttpd',
912 version : '>= 0.9.33',
913 required : want_microhttpd == 'true')
914 have = libmicrohttpd.found()
919 conf.set10('HAVE_MICROHTTPD', have)
921 want_libcryptsetup = get_option('libcryptsetup')
922 if want_libcryptsetup != 'false' and not fuzzer_build
923 libcryptsetup = dependency('libcryptsetup',
924 version : '>= 1.6.0',
925 required : want_libcryptsetup == 'true')
926 have = libcryptsetup.found()
931 conf.set10('HAVE_LIBCRYPTSETUP', have)
933 want_libcurl = get_option('libcurl')
934 if want_libcurl != 'false' and not fuzzer_build
935 libcurl = dependency('libcurl',
936 version : '>= 7.32.0',
937 required : want_libcurl == 'true')
938 have = libcurl.found()
943 conf.set10('HAVE_LIBCURL', have)
945 want_libidn = get_option('libidn')
946 want_libidn2 = get_option('libidn2')
947 if want_libidn == 'true' and want_libidn2 == 'true'
948 error('libidn and libidn2 cannot be requested simultaneously')
951 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
952 libidn = dependency('libidn',
953 required : want_libidn == 'true')
954 have = libidn.found()
959 conf.set10('HAVE_LIBIDN', have)
960 if not have and want_libidn2 != 'false' and not fuzzer_build
961 # libidn is used for both libidn and libidn2 objects
962 libidn = dependency('libidn2',
963 required : want_libidn2 == 'true')
964 have = libidn.found()
968 conf.set10('HAVE_LIBIDN2', have)
970 want_libiptc = get_option('libiptc')
971 if want_libiptc != 'false' and not fuzzer_build
972 libiptc = dependency('libiptc',
973 required : want_libiptc == 'true')
974 have = libiptc.found()
979 conf.set10('HAVE_LIBIPTC', have)
981 want_qrencode = get_option('qrencode')
982 if want_qrencode != 'false' and not fuzzer_build
983 libqrencode = dependency('libqrencode',
984 required : want_qrencode == 'true')
985 have = libqrencode.found()
990 conf.set10('HAVE_QRENCODE', have)
992 want_gcrypt = get_option('gcrypt')
993 if want_gcrypt != 'false' and not fuzzer_build
994 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
995 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
996 have = libgcrypt.found() and libgpg_error.found()
1001 # link to neither of the libs if one is not found
1005 conf.set10('HAVE_GCRYPT', have)
1007 want_gnutls = get_option('gnutls')
1008 if want_gnutls != 'false' and not fuzzer_build
1009 libgnutls = dependency('gnutls',
1010 version : '>= 3.1.4',
1011 required : want_gnutls == 'true')
1012 have = libgnutls.found()
1017 conf.set10('HAVE_GNUTLS', have)
1019 want_elfutils = get_option('elfutils')
1020 if want_elfutils != 'false' and not fuzzer_build
1021 libdw = dependency('libdw',
1022 required : want_elfutils == 'true')
1023 have = libdw.found()
1028 conf.set10('HAVE_ELFUTILS', have)
1030 want_zlib = get_option('zlib')
1031 if want_zlib != 'false' and not fuzzer_build
1032 libz = dependency('zlib',
1033 required : want_zlib == 'true')
1039 conf.set10('HAVE_ZLIB', have)
1041 want_bzip2 = get_option('bzip2')
1042 if want_bzip2 != 'false' and not fuzzer_build
1043 libbzip2 = cc.find_library('bz2',
1044 required : want_bzip2 == 'true')
1045 have = libbzip2.found()
1050 conf.set10('HAVE_BZIP2', have)
1052 want_xz = get_option('xz')
1053 if want_xz != 'false' and not fuzzer_build
1054 libxz = dependency('liblzma',
1055 required : want_xz == 'true')
1056 have = libxz.found()
1061 conf.set10('HAVE_XZ', have)
1063 want_lz4 = get_option('lz4')
1064 if want_lz4 != 'false' and not fuzzer_build
1065 liblz4 = dependency('liblz4',
1066 required : want_lz4 == 'true')
1067 have = liblz4.found()
1072 conf.set10('HAVE_LZ4', have)
1074 want_xkbcommon = get_option('xkbcommon')
1075 if want_xkbcommon != 'false' and not fuzzer_build
1076 libxkbcommon = dependency('xkbcommon',
1077 version : '>= 0.3.0',
1078 required : want_xkbcommon == 'true')
1079 have = libxkbcommon.found()
1084 conf.set10('HAVE_XKBCOMMON', have)
1086 want_pcre2 = get_option('pcre2')
1087 if want_pcre2 != 'false'
1088 libpcre2 = dependency('libpcre2-8',
1089 required : want_pcre2 == 'true')
1090 have = libpcre2.found()
1095 conf.set10('HAVE_PCRE2', have)
1097 want_glib = get_option('glib')
1098 if want_glib != 'false' and not fuzzer_build
1099 libglib = dependency('glib-2.0',
1100 version : '>= 2.22.0',
1101 required : want_glib == 'true')
1102 libgobject = dependency('gobject-2.0',
1103 version : '>= 2.22.0',
1104 required : want_glib == 'true')
1105 libgio = dependency('gio-2.0',
1106 required : want_glib == 'true')
1107 have = libglib.found() and libgobject.found() and libgio.found()
1114 conf.set10('HAVE_GLIB', have)
1116 want_dbus = get_option('dbus')
1117 if want_dbus != 'false' and not fuzzer_build
1118 libdbus = dependency('dbus-1',
1119 version : '>= 1.3.2',
1120 required : want_dbus == 'true')
1121 have = libdbus.found()
1126 conf.set10('HAVE_DBUS', have)
1128 default_dnssec = get_option('default-dnssec')
1130 default_dnssec = 'no'
1132 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1133 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1134 default_dnssec = 'no'
1136 conf.set('DEFAULT_DNSSEC_MODE',
1137 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1138 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1140 default_dns_over_tls = get_option('default-dns-over-tls')
1142 default_dns_over_tls = 'no'
1144 if default_dns_over_tls != 'no' and conf.get('HAVE_GNUTLS') == 0
1145 message('default-dns-over-tls cannot be set to strict or opportunistic when gnutls is disabled. Setting default-dns-over-tls to no.')
1146 default_dns_over_tls = 'no'
1148 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1149 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1150 substs.set('DEFAULT_DNS_OVER_TLS_MODE', default_dns_over_tls)
1152 want_importd = get_option('importd')
1153 if want_importd != 'false'
1154 have = (conf.get('HAVE_LIBCURL') == 1 and
1155 conf.get('HAVE_ZLIB') == 1 and
1156 conf.get('HAVE_BZIP2') == 1 and
1157 conf.get('HAVE_XZ') == 1 and
1158 conf.get('HAVE_GCRYPT') == 1)
1159 if want_importd == 'true' and not have
1160 error('importd support was requested, but dependencies are not available')
1165 conf.set10('ENABLE_IMPORTD', have)
1167 want_remote = get_option('remote')
1168 if want_remote != 'false'
1169 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1170 conf.get('HAVE_LIBCURL') == 1]
1171 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1172 # it's possible to build one without the other. Complain only if
1173 # support was explictly requested. The auxiliary files like sysusers
1174 # config should be installed when any of the programs are built.
1175 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1176 error('remote support was requested, but dependencies are not available')
1178 have = have_deps[0] or have_deps[1]
1182 conf.set10('ENABLE_REMOTE', have)
1184 foreach term : ['utmp',
1216 have = get_option(term)
1217 name = 'ENABLE_' + term.underscorify().to_upper()
1218 conf.set10(name, have)
1221 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1223 want_tests = get_option('tests')
1224 install_tests = get_option('install-tests')
1225 slow_tests = get_option('slow-tests')
1229 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1231 #####################################################################
1233 if get_option('efi')
1234 efi_arch = host_machine.cpu_family()
1236 if efi_arch == 'x86'
1237 EFI_MACHINE_TYPE_NAME = 'ia32'
1238 gnu_efi_arch = 'ia32'
1239 elif efi_arch == 'x86_64'
1240 EFI_MACHINE_TYPE_NAME = 'x64'
1241 gnu_efi_arch = 'x86_64'
1242 elif efi_arch == 'arm'
1243 EFI_MACHINE_TYPE_NAME = 'arm'
1244 gnu_efi_arch = 'arm'
1245 elif efi_arch == 'aarch64'
1246 EFI_MACHINE_TYPE_NAME = 'aa64'
1247 gnu_efi_arch = 'aarch64'
1249 EFI_MACHINE_TYPE_NAME = ''
1254 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1256 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1260 conf.set10('ENABLE_EFI', have)
1262 #####################################################################
1264 config_h = configure_file(
1265 output : 'config.h',
1266 configuration : conf)
1268 meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1270 includes = include_directories('src/basic',
1274 'src/journal-remote',
1278 'src/time-wait-sync',
1283 'src/libsystemd/sd-bus',
1284 'src/libsystemd/sd-device',
1285 'src/libsystemd/sd-hwdb',
1286 'src/libsystemd/sd-id128',
1287 'src/libsystemd/sd-netlink',
1288 'src/libsystemd/sd-network',
1289 'src/libsystemd-network',
1292 add_project_arguments('-include', 'config.h', language : 'c')
1296 subdir('src/systemd')
1298 subdir('src/libsystemd')
1299 subdir('src/libsystemd-network')
1300 subdir('src/journal')
1303 libjournal_core = static_library(
1305 libjournal_core_sources,
1307 include_directories : includes,
1310 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1311 libsystemd = shared_library(
1313 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1314 version : libsystemd_version,
1315 include_directories : includes,
1316 link_args : ['-shared',
1317 '-Wl,--version-script=' + libsystemd_sym_path],
1318 link_with : [libbasic,
1320 link_whole : [libsystemd_static,
1322 dependencies : [threads,
1326 link_depends : libsystemd_sym,
1328 install_dir : rootlibdir)
1330 static_libsystemd = get_option('static-libsystemd')
1331 static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1333 install_libsystemd_static = static_library(
1336 journal_client_sources,
1338 basic_gcrypt_sources,
1339 include_directories : includes,
1340 build_by_default : static_libsystemd != 'false',
1341 install : static_libsystemd != 'false',
1342 install_dir : rootlibdir,
1343 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1344 dependencies : [threads,
1353 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1355 ############################################################
1357 # binaries that have --help and are intended for use by humans,
1358 # usually, but not always, installed in /bin.
1359 public_programs = []
1361 subdir('src/libudev')
1362 subdir('src/shared')
1365 subdir('src/network')
1367 subdir('src/analyze')
1368 subdir('src/journal-remote')
1369 subdir('src/coredump')
1370 subdir('src/hostname')
1371 subdir('src/import')
1372 subdir('src/kernel-install')
1373 subdir('src/locale')
1374 subdir('src/machine')
1375 subdir('src/portable')
1376 subdir('src/nspawn')
1377 subdir('src/resolve')
1378 subdir('src/timedate')
1379 subdir('src/timesync')
1380 subdir('src/vconsole')
1381 subdir('src/boot/efi')
1388 ############################################################
1390 # only static linking apart from libdl, to make sure that the
1391 # module is linked to all libraries that it uses.
1392 test_dlopen = executable(
1395 include_directories : includes,
1396 link_with : [libbasic],
1397 dependencies : [libdl])
1399 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1400 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1401 ['mymachines', 'ENABLE_MACHINED'],
1402 ['resolve', 'ENABLE_RESOLVE']]
1404 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1408 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1409 version_script_arg = join_paths(meson.current_source_dir(), sym)
1411 nss = shared_library(
1413 'src/nss-@0@/nss-@0@.c'.format(module),
1415 include_directories : includes,
1416 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1417 link_args : ['-Wl,-z,nodelete',
1419 '-Wl,--version-script=' + version_script_arg,
1421 link_with : [libsystemd_static,
1423 dependencies : [threads,
1427 install_dir : rootlibdir)
1429 # We cannot use shared_module because it does not support version suffix.
1430 # Unfortunately shared_library insists on creating the symlink…
1431 meson.add_install_script('sh', '-c',
1432 'rm $DESTDIR@0@/libnss_@1@.so'
1433 .format(rootlibdir, module))
1435 test('dlopen-nss_' + module,
1437 args : [nss.full_path()]) # path to dlopen must include a slash
1441 ############################################################
1443 executable('systemd',
1445 include_directories : includes,
1446 link_with : [libcore,
1448 dependencies : [threads,
1454 install_rpath : rootlibexecdir,
1456 install_dir : rootlibexecdir)
1458 meson.add_install_script(meson_make_symlink,
1459 join_paths(rootlibexecdir, 'systemd'),
1460 join_paths(rootsbindir, 'init'))
1462 exe = executable('systemd-analyze',
1463 systemd_analyze_sources,
1464 include_directories : includes,
1465 link_with : [libcore,
1467 dependencies : [threads,
1473 install_rpath : rootlibexecdir,
1475 public_programs += [exe]
1477 executable('systemd-journald',
1478 systemd_journald_sources,
1479 include_directories : includes,
1480 link_with : [libjournal_core,
1482 dependencies : [threads,
1486 install_rpath : rootlibexecdir,
1488 install_dir : rootlibexecdir)
1490 exe = executable('systemd-cat',
1491 systemd_cat_sources,
1492 include_directories : includes,
1493 link_with : [libjournal_core,
1495 dependencies : [threads],
1496 install_rpath : rootlibexecdir,
1498 public_programs += [exe]
1500 exe = executable('journalctl',
1502 include_directories : includes,
1503 link_with : [libshared],
1504 dependencies : [threads,
1509 install_rpath : rootlibexecdir,
1511 install_dir : rootbindir)
1512 public_programs += [exe]
1514 executable('systemd-getty-generator',
1515 'src/getty-generator/getty-generator.c',
1516 include_directories : includes,
1517 link_with : [libshared],
1518 install_rpath : rootlibexecdir,
1520 install_dir : systemgeneratordir)
1522 executable('systemd-debug-generator',
1523 'src/debug-generator/debug-generator.c',
1524 include_directories : includes,
1525 link_with : [libshared],
1526 install_rpath : rootlibexecdir,
1528 install_dir : systemgeneratordir)
1530 executable('systemd-fstab-generator',
1531 'src/fstab-generator/fstab-generator.c',
1532 'src/core/mount-setup.c',
1533 include_directories : includes,
1534 link_with : [libshared],
1535 install_rpath : rootlibexecdir,
1537 install_dir : systemgeneratordir)
1539 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1540 executable('30-systemd-environment-d-generator',
1541 'src/environment-d-generator/environment-d-generator.c',
1542 include_directories : includes,
1543 link_with : [libshared],
1544 install_rpath : rootlibexecdir,
1546 install_dir : userenvgeneratordir)
1548 meson.add_install_script(meson_make_symlink,
1549 join_paths(sysconfdir, 'environment'),
1550 join_paths(environmentdir, '99-environment.conf'))
1553 if conf.get('ENABLE_HIBERNATE') == 1
1554 executable('systemd-hibernate-resume-generator',
1555 'src/hibernate-resume/hibernate-resume-generator.c',
1556 include_directories : includes,
1557 link_with : [libshared],
1558 install_rpath : rootlibexecdir,
1560 install_dir : systemgeneratordir)
1562 executable('systemd-hibernate-resume',
1563 'src/hibernate-resume/hibernate-resume.c',
1564 include_directories : includes,
1565 link_with : [libshared],
1566 install_rpath : rootlibexecdir,
1568 install_dir : rootlibexecdir)
1571 if conf.get('HAVE_BLKID') == 1
1572 executable('systemd-gpt-auto-generator',
1573 'src/gpt-auto-generator/gpt-auto-generator.c',
1574 'src/basic/blkid-util.h',
1575 include_directories : includes,
1576 link_with : [libshared],
1577 dependencies : libblkid,
1578 install_rpath : rootlibexecdir,
1580 install_dir : systemgeneratordir)
1582 exe = executable('systemd-dissect',
1583 'src/dissect/dissect.c',
1584 include_directories : includes,
1585 link_with : [libshared],
1586 install_rpath : rootlibexecdir,
1588 install_dir : rootlibexecdir)
1589 public_programs += [exe]
1592 if conf.get('ENABLE_RESOLVE') == 1
1593 executable('systemd-resolved',
1594 systemd_resolved_sources,
1595 include_directories : includes,
1596 link_with : [libshared,
1598 libsystemd_resolve_core],
1599 dependencies : [threads,
1604 install_rpath : rootlibexecdir,
1606 install_dir : rootlibexecdir)
1608 exe = executable('resolvectl',
1610 include_directories : includes,
1611 link_with : [libshared,
1613 libsystemd_resolve_core],
1614 dependencies : [threads,
1618 install_rpath : rootlibexecdir,
1620 public_programs += [exe]
1622 meson.add_install_script(meson_make_symlink,
1623 join_paths(bindir, 'resolvectl'),
1624 join_paths(rootsbindir, 'resolvconf'))
1626 meson.add_install_script(meson_make_symlink,
1627 join_paths(bindir, 'resolvectl'),
1628 join_paths(bindir, 'systemd-resolve'))
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 executable('systemd-user-runtime-dir',
1689 user_runtime_dir_sources,
1690 include_directories : includes,
1691 link_with : [libshared, liblogind_core],
1692 install_rpath : rootlibexecdir,
1694 install_dir : rootlibexecdir)
1696 if conf.get('HAVE_PAM') == 1
1697 executable('systemd-user-sessions',
1698 'src/user-sessions/user-sessions.c',
1699 include_directories : includes,
1700 link_with : [libshared],
1701 install_rpath : rootlibexecdir,
1703 install_dir : rootlibexecdir)
1706 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1707 exe = executable('bootctl',
1708 'src/boot/bootctl.c',
1709 include_directories : includes,
1710 link_with : [libshared],
1711 dependencies : [libblkid],
1712 install_rpath : rootlibexecdir,
1714 public_programs += [exe]
1717 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1718 include_directories : includes,
1719 link_with : [libshared],
1720 dependencies : [threads],
1721 install_rpath : rootlibexecdir,
1723 public_programs += [exe]
1726 if get_option('link-systemctl-shared')
1727 systemctl_link_with = [libshared]
1729 systemctl_link_with = [libsystemd_static,
1735 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1736 include_directories : includes,
1737 link_with : systemctl_link_with,
1738 dependencies : [threads,
1743 install_rpath : rootlibexecdir,
1745 install_dir : rootbindir)
1746 public_programs += [exe]
1748 if conf.get('ENABLE_PORTABLED') == 1
1749 executable('systemd-portabled',
1750 systemd_portabled_sources,
1751 include_directories : includes,
1752 link_with : [libshared],
1753 dependencies : [threads],
1754 install_rpath : rootlibexecdir,
1756 install_dir : rootlibexecdir)
1758 exe = executable('portablectl', 'src/portable/portablectl.c',
1759 include_directories : includes,
1760 link_with : [libshared],
1761 dependencies : [threads],
1762 install_rpath : rootlibexecdir,
1764 install_dir : rootlibexecdir)
1765 public_programs += [exe]
1768 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1769 meson.add_install_script(meson_make_symlink,
1770 join_paths(rootbindir, 'systemctl'),
1771 join_paths(rootsbindir, alias))
1774 if conf.get('ENABLE_BACKLIGHT') == 1
1775 executable('systemd-backlight',
1776 'src/backlight/backlight.c',
1777 include_directories : includes,
1778 link_with : [libshared],
1779 install_rpath : rootlibexecdir,
1781 install_dir : rootlibexecdir)
1784 if conf.get('ENABLE_RFKILL') == 1
1785 executable('systemd-rfkill',
1786 'src/rfkill/rfkill.c',
1787 include_directories : includes,
1788 link_with : [libshared],
1789 install_rpath : rootlibexecdir,
1791 install_dir : rootlibexecdir)
1794 executable('systemd-system-update-generator',
1795 'src/system-update-generator/system-update-generator.c',
1796 include_directories : includes,
1797 link_with : [libshared],
1798 install_rpath : rootlibexecdir,
1800 install_dir : systemgeneratordir)
1802 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1803 executable('systemd-cryptsetup',
1804 'src/cryptsetup/cryptsetup.c',
1805 include_directories : includes,
1806 link_with : [libshared],
1807 dependencies : [libcryptsetup],
1808 install_rpath : rootlibexecdir,
1810 install_dir : rootlibexecdir)
1812 executable('systemd-cryptsetup-generator',
1813 'src/cryptsetup/cryptsetup-generator.c',
1814 include_directories : includes,
1815 link_with : [libshared],
1816 dependencies : [libcryptsetup],
1817 install_rpath : rootlibexecdir,
1819 install_dir : systemgeneratordir)
1821 executable('systemd-veritysetup',
1822 'src/veritysetup/veritysetup.c',
1823 include_directories : includes,
1824 link_with : [libshared],
1825 dependencies : [libcryptsetup],
1826 install_rpath : rootlibexecdir,
1828 install_dir : rootlibexecdir)
1830 executable('systemd-veritysetup-generator',
1831 'src/veritysetup/veritysetup-generator.c',
1832 include_directories : includes,
1833 link_with : [libshared],
1834 dependencies : [libcryptsetup],
1835 install_rpath : rootlibexecdir,
1837 install_dir : systemgeneratordir)
1840 if conf.get('HAVE_SYSV_COMPAT') == 1
1841 executable('systemd-sysv-generator',
1842 'src/sysv-generator/sysv-generator.c',
1843 include_directories : includes,
1844 link_with : [libshared],
1845 install_rpath : rootlibexecdir,
1847 install_dir : systemgeneratordir)
1849 executable('systemd-rc-local-generator',
1850 'src/rc-local-generator/rc-local-generator.c',
1851 include_directories : includes,
1852 link_with : [libshared],
1853 install_rpath : rootlibexecdir,
1855 install_dir : systemgeneratordir)
1858 if conf.get('ENABLE_HOSTNAMED') == 1
1859 executable('systemd-hostnamed',
1860 'src/hostname/hostnamed.c',
1861 include_directories : includes,
1862 link_with : [libshared],
1863 install_rpath : rootlibexecdir,
1865 install_dir : rootlibexecdir)
1867 exe = executable('hostnamectl',
1868 'src/hostname/hostnamectl.c',
1869 include_directories : includes,
1870 link_with : [libshared],
1871 install_rpath : rootlibexecdir,
1873 public_programs += [exe]
1876 if conf.get('ENABLE_LOCALED') == 1
1877 if conf.get('HAVE_XKBCOMMON') == 1
1878 # logind will load libxkbcommon.so dynamically on its own
1884 executable('systemd-localed',
1885 systemd_localed_sources,
1886 include_directories : includes,
1887 link_with : [libshared],
1888 dependencies : deps,
1889 install_rpath : rootlibexecdir,
1891 install_dir : rootlibexecdir)
1893 exe = executable('localectl',
1895 include_directories : includes,
1896 link_with : [libshared],
1897 install_rpath : rootlibexecdir,
1899 public_programs += [exe]
1902 if conf.get('ENABLE_TIMEDATED') == 1
1903 executable('systemd-timedated',
1904 'src/timedate/timedated.c',
1905 include_directories : includes,
1906 link_with : [libshared],
1907 install_rpath : rootlibexecdir,
1909 install_dir : rootlibexecdir)
1912 if conf.get('ENABLE_TIMEDATECTL') == 1
1913 exe = executable('timedatectl',
1914 'src/timedate/timedatectl.c',
1915 include_directories : includes,
1916 install_rpath : rootlibexecdir,
1917 link_with : [libshared],
1918 dependencies : [libm],
1920 public_programs += [exe]
1923 if conf.get('ENABLE_TIMESYNCD') == 1
1924 executable('systemd-timesyncd',
1925 systemd_timesyncd_sources,
1926 include_directories : includes,
1927 link_with : [libshared],
1928 dependencies : [threads,
1930 install_rpath : rootlibexecdir,
1932 install_dir : rootlibexecdir)
1934 executable('systemd-time-wait-sync',
1935 'src/time-wait-sync/time-wait-sync.c',
1936 include_directories : includes,
1937 link_with : [libshared],
1938 install_rpath : rootlibexecdir,
1940 install_dir : rootlibexecdir)
1943 if conf.get('ENABLE_MACHINED') == 1
1944 executable('systemd-machined',
1945 systemd_machined_sources,
1946 include_directories : includes,
1947 link_with : [libmachine_core,
1949 install_rpath : rootlibexecdir,
1951 install_dir : rootlibexecdir)
1953 exe = executable('machinectl',
1954 'src/machine/machinectl.c',
1955 include_directories : includes,
1956 link_with : [libshared],
1957 dependencies : [threads,
1960 install_rpath : rootlibexecdir,
1962 install_dir : rootbindir)
1963 public_programs += [exe]
1966 if conf.get('ENABLE_IMPORTD') == 1
1967 executable('systemd-importd',
1968 systemd_importd_sources,
1969 include_directories : includes,
1970 link_with : [libshared],
1971 dependencies : [threads],
1972 install_rpath : rootlibexecdir,
1974 install_dir : rootlibexecdir)
1976 systemd_pull = executable('systemd-pull',
1977 systemd_pull_sources,
1978 include_directories : includes,
1979 link_with : [libshared],
1980 dependencies : [libcurl,
1985 install_rpath : rootlibexecdir,
1987 install_dir : rootlibexecdir)
1989 systemd_import = executable('systemd-import',
1990 systemd_import_sources,
1991 include_directories : includes,
1992 link_with : [libshared],
1993 dependencies : [libcurl,
1997 install_rpath : rootlibexecdir,
1999 install_dir : rootlibexecdir)
2001 systemd_export = executable('systemd-export',
2002 systemd_export_sources,
2003 include_directories : includes,
2004 link_with : [libshared],
2005 dependencies : [libcurl,
2009 install_rpath : rootlibexecdir,
2011 install_dir : rootlibexecdir)
2012 public_programs += [systemd_pull, systemd_import, systemd_export]
2015 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
2016 exe = executable('systemd-journal-upload',
2017 systemd_journal_upload_sources,
2018 include_directories : includes,
2019 link_with : [libshared],
2020 dependencies : [threads,
2025 install_rpath : rootlibexecdir,
2027 install_dir : rootlibexecdir)
2028 public_programs += [exe]
2031 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
2032 s_j_remote = executable('systemd-journal-remote',
2033 systemd_journal_remote_sources,
2034 include_directories : includes,
2035 link_with : [libshared,
2036 libsystemd_journal_remote],
2037 dependencies : [threads,
2042 install_rpath : rootlibexecdir,
2044 install_dir : rootlibexecdir)
2046 s_j_gatewayd = executable('systemd-journal-gatewayd',
2047 systemd_journal_gatewayd_sources,
2048 include_directories : includes,
2049 link_with : [libshared],
2050 dependencies : [threads,
2055 install_rpath : rootlibexecdir,
2057 install_dir : rootlibexecdir)
2058 public_programs += [s_j_remote, s_j_gatewayd]
2061 if conf.get('ENABLE_COREDUMP') == 1
2062 executable('systemd-coredump',
2063 systemd_coredump_sources,
2064 include_directories : includes,
2065 link_with : [libshared],
2066 dependencies : [threads,
2071 install_rpath : rootlibexecdir,
2073 install_dir : rootlibexecdir)
2075 exe = executable('coredumpctl',
2076 coredumpctl_sources,
2077 include_directories : includes,
2078 link_with : [libshared],
2079 dependencies : [threads,
2082 install_rpath : rootlibexecdir,
2084 public_programs += [exe]
2087 if conf.get('ENABLE_BINFMT') == 1
2088 exe = executable('systemd-binfmt',
2089 'src/binfmt/binfmt.c',
2090 include_directories : includes,
2091 link_with : [libshared],
2092 install_rpath : rootlibexecdir,
2094 install_dir : rootlibexecdir)
2095 public_programs += [exe]
2097 meson.add_install_script('sh', '-c',
2098 mkdir_p.format(binfmtdir))
2099 meson.add_install_script('sh', '-c',
2100 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2103 if conf.get('ENABLE_VCONSOLE') == 1
2104 executable('systemd-vconsole-setup',
2105 'src/vconsole/vconsole-setup.c',
2106 include_directories : includes,
2107 link_with : [libshared],
2108 install_rpath : rootlibexecdir,
2110 install_dir : rootlibexecdir)
2113 if conf.get('ENABLE_RANDOMSEED') == 1
2114 executable('systemd-random-seed',
2115 'src/random-seed/random-seed.c',
2116 include_directories : includes,
2117 link_with : [libshared],
2118 install_rpath : rootlibexecdir,
2120 install_dir : rootlibexecdir)
2123 if conf.get('ENABLE_FIRSTBOOT') == 1
2124 executable('systemd-firstboot',
2125 'src/firstboot/firstboot.c',
2126 include_directories : includes,
2127 link_with : [libshared],
2128 dependencies : [libcrypt],
2129 install_rpath : rootlibexecdir,
2131 install_dir : rootbindir)
2134 executable('systemd-remount-fs',
2135 'src/remount-fs/remount-fs.c',
2136 'src/core/mount-setup.c',
2137 'src/core/mount-setup.h',
2138 include_directories : includes,
2139 link_with : [libshared],
2140 install_rpath : rootlibexecdir,
2142 install_dir : rootlibexecdir)
2144 executable('systemd-machine-id-setup',
2145 'src/machine-id-setup/machine-id-setup-main.c',
2146 'src/core/machine-id-setup.c',
2147 'src/core/machine-id-setup.h',
2148 include_directories : includes,
2149 link_with : [libshared],
2150 install_rpath : rootlibexecdir,
2152 install_dir : rootbindir)
2154 executable('systemd-fsck',
2156 include_directories : includes,
2157 link_with : [libshared],
2158 install_rpath : rootlibexecdir,
2160 install_dir : rootlibexecdir)
2162 executable('systemd-growfs',
2163 'src/partition/growfs.c',
2164 include_directories : includes,
2165 link_with : [libshared],
2166 dependencies : [libcryptsetup],
2167 install_rpath : rootlibexecdir,
2169 install_dir : rootlibexecdir)
2171 executable('systemd-makefs',
2172 'src/partition/makefs.c',
2173 include_directories : includes,
2174 link_with : [libshared],
2175 install_rpath : rootlibexecdir,
2177 install_dir : rootlibexecdir)
2179 executable('systemd-sleep',
2180 'src/sleep/sleep.c',
2181 include_directories : includes,
2182 link_with : [libshared],
2183 install_rpath : rootlibexecdir,
2185 install_dir : rootlibexecdir)
2187 exe = executable('systemd-sysctl',
2188 'src/sysctl/sysctl.c',
2189 include_directories : includes,
2190 link_with : [libshared],
2191 install_rpath : rootlibexecdir,
2193 install_dir : rootlibexecdir)
2194 public_programs += [exe]
2196 executable('systemd-ac-power',
2197 'src/ac-power/ac-power.c',
2198 include_directories : includes,
2199 link_with : [libshared],
2200 install_rpath : rootlibexecdir,
2202 install_dir : rootlibexecdir)
2204 exe = executable('systemd-detect-virt',
2205 'src/detect-virt/detect-virt.c',
2206 include_directories : includes,
2207 link_with : [libshared],
2208 install_rpath : rootlibexecdir,
2210 public_programs += [exe]
2212 exe = executable('systemd-delta',
2213 'src/delta/delta.c',
2214 include_directories : includes,
2215 link_with : [libshared],
2216 install_rpath : rootlibexecdir,
2218 public_programs += [exe]
2220 exe = executable('systemd-escape',
2221 'src/escape/escape.c',
2222 include_directories : includes,
2223 link_with : [libshared],
2224 install_rpath : rootlibexecdir,
2226 install_dir : rootbindir)
2227 public_programs += [exe]
2229 exe = executable('systemd-notify',
2230 'src/notify/notify.c',
2231 include_directories : includes,
2232 link_with : [libshared],
2233 install_rpath : rootlibexecdir,
2235 install_dir : rootbindir)
2236 public_programs += [exe]
2238 executable('systemd-volatile-root',
2239 'src/volatile-root/volatile-root.c',
2240 include_directories : includes,
2241 link_with : [libshared],
2242 install_rpath : rootlibexecdir,
2244 install_dir : rootlibexecdir)
2246 executable('systemd-cgroups-agent',
2247 'src/cgroups-agent/cgroups-agent.c',
2248 include_directories : includes,
2249 link_with : [libshared],
2250 install_rpath : rootlibexecdir,
2252 install_dir : rootlibexecdir)
2254 exe = executable('systemd-path',
2256 include_directories : includes,
2257 link_with : [libshared],
2258 install_rpath : rootlibexecdir,
2260 public_programs += [exe]
2262 exe = executable('systemd-ask-password',
2263 'src/ask-password/ask-password.c',
2264 include_directories : includes,
2265 link_with : [libshared],
2266 install_rpath : rootlibexecdir,
2268 install_dir : rootbindir)
2269 public_programs += [exe]
2271 executable('systemd-reply-password',
2272 'src/reply-password/reply-password.c',
2273 include_directories : includes,
2274 link_with : [libshared],
2275 install_rpath : rootlibexecdir,
2277 install_dir : rootlibexecdir)
2279 exe = executable('systemd-tty-ask-password-agent',
2280 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2281 include_directories : includes,
2282 link_with : [libshared],
2283 install_rpath : rootlibexecdir,
2285 install_dir : rootbindir)
2286 public_programs += [exe]
2288 exe = executable('systemd-cgls',
2290 include_directories : includes,
2291 link_with : [libshared],
2292 install_rpath : rootlibexecdir,
2294 public_programs += [exe]
2296 exe = executable('systemd-cgtop',
2297 'src/cgtop/cgtop.c',
2298 include_directories : includes,
2299 link_with : [libshared],
2300 install_rpath : rootlibexecdir,
2302 public_programs += [exe]
2304 executable('systemd-initctl',
2305 'src/initctl/initctl.c',
2306 include_directories : includes,
2307 link_with : [libshared],
2308 install_rpath : rootlibexecdir,
2310 install_dir : rootlibexecdir)
2312 exe = executable('systemd-mount',
2313 'src/mount/mount-tool.c',
2314 include_directories : includes,
2315 link_with : [libshared],
2316 install_rpath : rootlibexecdir,
2318 public_programs += [exe]
2320 meson.add_install_script(meson_make_symlink,
2321 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2323 exe = executable('systemd-run',
2325 include_directories : includes,
2326 link_with : [libshared],
2327 install_rpath : rootlibexecdir,
2329 public_programs += [exe]
2331 exe = executable('systemd-stdio-bridge',
2332 'src/stdio-bridge/stdio-bridge.c',
2333 include_directories : includes,
2334 link_with : [libshared],
2335 install_rpath : rootlibexecdir,
2337 public_programs += [exe]
2339 exe = executable('busctl',
2340 'src/busctl/busctl.c',
2341 'src/busctl/busctl-introspect.c',
2342 'src/busctl/busctl-introspect.h',
2343 include_directories : includes,
2344 link_with : [libshared],
2345 install_rpath : rootlibexecdir,
2347 public_programs += [exe]
2349 if conf.get('ENABLE_SYSUSERS') == 1
2350 exe = executable('systemd-sysusers',
2351 'src/sysusers/sysusers.c',
2352 include_directories : includes,
2353 link_with : [libshared],
2354 install_rpath : rootlibexecdir,
2356 install_dir : rootbindir)
2357 public_programs += [exe]
2360 if conf.get('ENABLE_TMPFILES') == 1
2361 exe = executable('systemd-tmpfiles',
2362 'src/tmpfiles/tmpfiles.c',
2363 include_directories : includes,
2364 link_with : [libshared],
2365 dependencies : [libacl],
2366 install_rpath : rootlibexecdir,
2368 install_dir : rootbindir)
2369 public_programs += [exe]
2371 test('test-systemd-tmpfiles',
2372 test_systemd_tmpfiles_py,
2373 args : exe.full_path())
2374 # https://github.com/mesonbuild/meson/issues/2681
2377 if conf.get('ENABLE_HWDB') == 1
2378 exe = executable('systemd-hwdb',
2380 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2381 include_directories : includes,
2382 link_with : [libudev_static],
2383 install_rpath : udev_rpath,
2385 install_dir : rootbindir)
2386 public_programs += [exe]
2389 if conf.get('ENABLE_QUOTACHECK') == 1
2390 executable('systemd-quotacheck',
2391 'src/quotacheck/quotacheck.c',
2392 include_directories : includes,
2393 link_with : [libshared],
2394 install_rpath : rootlibexecdir,
2396 install_dir : rootlibexecdir)
2399 exe = executable('systemd-socket-proxyd',
2400 'src/socket-proxy/socket-proxyd.c',
2401 include_directories : includes,
2402 link_with : [libshared],
2403 dependencies : [threads],
2404 install_rpath : rootlibexecdir,
2406 install_dir : rootlibexecdir)
2407 public_programs += [exe]
2409 exe = executable('systemd-udevd',
2410 systemd_udevd_sources,
2411 include_directories : includes,
2412 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2413 link_with : [libudev_core,
2416 dependencies : [threads,
2421 install_rpath : udev_rpath,
2423 install_dir : rootlibexecdir)
2424 public_programs += [exe]
2426 exe = executable('udevadm',
2428 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2429 include_directories : includes,
2430 link_with : [libudev_core,
2433 dependencies : [threads,
2438 install_rpath : udev_rpath,
2440 install_dir : rootbindir)
2441 public_programs += [exe]
2443 executable('systemd-shutdown',
2444 systemd_shutdown_sources,
2445 include_directories : includes,
2446 link_with : [libshared],
2447 dependencies : [libmount],
2448 install_rpath : rootlibexecdir,
2450 install_dir : rootlibexecdir)
2452 executable('systemd-update-done',
2453 'src/update-done/update-done.c',
2454 include_directories : includes,
2455 link_with : [libshared],
2456 install_rpath : rootlibexecdir,
2458 install_dir : rootlibexecdir)
2460 executable('systemd-update-utmp',
2461 'src/update-utmp/update-utmp.c',
2462 include_directories : includes,
2463 link_with : [libshared],
2464 dependencies : [libaudit],
2465 install_rpath : rootlibexecdir,
2467 install_dir : rootlibexecdir)
2469 if conf.get('HAVE_KMOD') == 1
2470 executable('systemd-modules-load',
2471 'src/modules-load/modules-load.c',
2472 include_directories : includes,
2473 link_with : [libshared],
2474 dependencies : [libkmod],
2475 install_rpath : rootlibexecdir,
2477 install_dir : rootlibexecdir)
2479 meson.add_install_script('sh', '-c',
2480 mkdir_p.format(modulesloaddir))
2481 meson.add_install_script('sh', '-c',
2482 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2485 exe = executable('systemd-nspawn',
2486 systemd_nspawn_sources,
2487 'src/core/mount-setup.c', # FIXME: use a variable?
2488 'src/core/mount-setup.h',
2489 'src/core/loopback-setup.c',
2490 'src/core/loopback-setup.h',
2491 include_directories : includes,
2492 link_with : [libnspawn_core,
2494 dependencies : [libblkid],
2495 install_rpath : rootlibexecdir,
2497 public_programs += [exe]
2499 if conf.get('ENABLE_NETWORKD') == 1
2500 executable('systemd-networkd',
2501 systemd_networkd_sources,
2502 include_directories : includes,
2503 link_with : [libnetworkd_core,
2507 dependencies : [threads],
2508 install_rpath : rootlibexecdir,
2510 install_dir : rootlibexecdir)
2512 executable('systemd-networkd-wait-online',
2513 systemd_networkd_wait_online_sources,
2514 include_directories : includes,
2515 link_with : [libnetworkd_core,
2517 install_rpath : rootlibexecdir,
2519 install_dir : rootlibexecdir)
2521 exe = executable('networkctl',
2523 include_directories : includes,
2524 link_with : [libsystemd_network,
2526 install_rpath : rootlibexecdir,
2528 install_dir : rootbindir)
2529 public_programs += [exe]
2532 executable('systemd-sulogin-shell',
2533 ['src/sulogin-shell/sulogin-shell.c'],
2534 include_directories : includes,
2535 link_with : [libshared],
2536 install_rpath : rootlibexecdir,
2538 install_dir : rootlibexecdir)
2540 ############################################################
2542 foreach tuple : tests
2544 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2545 dependencies = tuple[2]
2546 condition = tuple.length() >= 4 ? tuple[3] : ''
2547 type = tuple.length() >= 5 ? tuple[4] : ''
2548 defs = tuple.length() >= 6 ? tuple[5] : []
2549 incs = tuple.length() >= 7 ? tuple[6] : includes
2552 name = sources[0].split('/')[-1].split('.')[0]
2553 if type.startswith('timeout=')
2554 timeout = type.split('=')[1].to_int()
2557 if want_tests == 'false'
2558 message('Not compiling @0@ because tests is set to false'.format(name))
2559 elif condition == '' or conf.get(condition) == 1
2563 include_directories : incs,
2564 link_with : link_with,
2565 dependencies : dependencies,
2567 install_rpath : rootlibexecdir,
2568 install : install_tests,
2569 install_dir : join_paths(testsdir, type))
2572 message('@0@ is a manual test'.format(name))
2573 elif type == 'unsafe' and want_tests != 'unsafe'
2574 message('@0@ is an unsafe test'.format(name))
2581 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2586 'test-libsystemd-sym',
2587 test_libsystemd_sym_c,
2588 include_directories : includes,
2589 link_with : [libsystemd],
2590 install : install_tests,
2591 install_dir : testsdir)
2592 test('test-libsystemd-sym', exe)
2595 'test-libsystemd-static-sym',
2596 test_libsystemd_sym_c,
2597 include_directories : includes,
2598 link_with : [install_libsystemd_static],
2599 dependencies : [threads], # threads is already included in dependencies on the library,
2600 # but does not seem to get propagated. Add here as a work-around.
2601 build_by_default : static_libsystemd_pic,
2602 install : install_tests and static_libsystemd_pic,
2603 install_dir : testsdir)
2604 if static_libsystemd_pic
2605 test('test-libsystemd-static-sym', exe)
2611 include_directories : includes,
2612 c_args : ['-Wno-deprecated-declarations'],
2613 link_with : [libudev],
2614 install : install_tests,
2615 install_dir : testsdir)
2616 test('test-libudev-sym', exe)
2619 'test-libudev-static-sym',
2621 include_directories : includes,
2622 c_args : ['-Wno-deprecated-declarations'],
2623 link_with : [install_libudev_static],
2624 build_by_default : static_libudev_pic,
2625 install : install_tests and static_libudev_pic,
2626 install_dir : testsdir)
2627 if static_libudev_pic
2628 test('test-libudev-static-sym', exe)
2631 ############################################################
2635 foreach tuple : fuzzers
2637 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2638 dependencies = tuple[2]
2639 defs = tuple.length() >= 4 ? tuple[3] : []
2640 incs = tuple.length() >= 5 ? tuple[4] : includes
2643 dependencies += fuzzing_engine
2645 sources += 'src/fuzz/fuzz-main.c'
2648 name = sources[0].split('/')[-1].split('.')[0]
2650 fuzzer_exes += executable(
2653 include_directories : [incs, include_directories('src/fuzz')],
2654 link_with : link_with,
2655 dependencies : dependencies,
2660 run_target('fuzzers',
2661 depends : fuzzer_exes,
2664 ############################################################
2666 make_directive_index_py = find_program('tools/make-directive-index.py')
2667 make_man_index_py = find_program('tools/make-man-index.py')
2668 xml_helper_py = find_program('tools/xml_helper.py')
2669 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2673 subdir('sysusers.d')
2674 subdir('tmpfiles.d')
2679 subdir('shell-completion/bash')
2680 subdir('shell-completion/zsh')
2681 subdir('doc/sysvinit')
2682 subdir('doc/var-log')
2684 # FIXME: figure out if the warning is true:
2685 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2686 install_subdir('factory/etc',
2687 install_dir : factorydir)
2690 install_data('xorg/50-systemd-user.sh',
2691 install_dir : xinitrcdir)
2692 install_data('modprobe.d/systemd.conf',
2693 install_dir : modprobedir)
2694 install_data('LICENSE.GPL2',
2699 'doc/DISTRO_PORTING',
2700 'doc/ENVIRONMENT.md',
2702 'doc/TRANSIENT-SETTINGS.md',
2705 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2706 install_dir : docdir)
2708 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2709 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2711 ############################################################
2713 meson_check_help = find_program('tools/meson-check-help.sh')
2715 foreach exec : public_programs
2716 name = exec.full_path().split('/')[-1]
2717 test('check-help-' + name,
2719 args : [exec.full_path()])
2722 ############################################################
2724 # Enable tests for all supported sanitizers
2725 foreach tuple : sanitizers
2726 sanitizer = tuple[0]
2729 have = run_command(check_compilation_sh,
2730 cc.cmd_array(), '-x', 'c',
2731 '-fsanitize=@0@'.format(sanitizer),
2732 '-include', link_test_c).returncode() == 0
2733 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2737 foreach p : fuzz_regression_tests
2738 b = p.split('/')[-2]
2739 c = p.split('/')[-1]
2741 name = '@0@:@1@'.format(b, sanitizer)
2744 if want_tests == 'false'
2745 message('Not compiling @0@ because tests is set to false'.format(name))
2747 exe = custom_target(
2751 command : [env, 'ln', '-fs',
2752 join_paths(build.full_path(), b),
2754 build_by_default : true)
2756 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2761 if want_tests != 'false' and slow_tests
2762 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2764 args : [exe.full_path(),
2765 join_paths(meson.source_root(),
2766 'test/fuzz-regressions',
2774 ############################################################
2777 all_files = run_command(
2779 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2782 all_files = files(all_files.stdout().split())
2787 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2790 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2794 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2797 command : [meson_git_contrib_sh])
2801 git_head = run_command(
2803 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2804 'rev-parse', 'HEAD']).stdout().strip()
2805 git_head_short = run_command(
2807 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2808 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2812 command : ['git', 'archive',
2813 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2815 '--prefix', 'systemd-@0@/'.format(git_head),
2819 ############################################################
2821 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2824 depends : [man, libsystemd, libudev],
2825 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2827 ############################################################
2830 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2832 'split /usr: @0@'.format(split_usr),
2833 'split bin-sbin: @0@'.format(split_bin),
2834 'prefix directory: @0@'.format(prefixdir),
2835 'rootprefix directory: @0@'.format(rootprefixdir),
2836 'sysconf directory: @0@'.format(sysconfdir),
2837 'include directory: @0@'.format(includedir),
2838 'lib directory: @0@'.format(libdir),
2839 'rootlib directory: @0@'.format(rootlibdir),
2840 'SysV init scripts: @0@'.format(sysvinit_path),
2841 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2842 'PAM modules directory: @0@'.format(pamlibdir),
2843 'PAM configuration directory: @0@'.format(pamconfdir),
2844 'RPM macros directory: @0@'.format(rpmmacrosdir),
2845 'modprobe.d directory: @0@'.format(modprobedir),
2846 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2847 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2848 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2849 'bash completions directory: @0@'.format(bashcompletiondir),
2850 'zsh completions directory: @0@'.format(zshcompletiondir),
2851 'extra start script: @0@'.format(get_option('rc-local')),
2852 'extra stop script: @0@'.format(get_option('halt-local')),
2853 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2854 get_option('debug-tty')),
2855 'TTY GID: @0@'.format(tty_gid),
2856 'users GID: @0@'.format(users_gid),
2857 'maximum system UID: @0@'.format(system_uid_max),
2858 'maximum system GID: @0@'.format(system_gid_max),
2859 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2860 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2861 'minimum container UID base: @0@'.format(container_uid_base_min),
2862 'maximum container UID base: @0@'.format(container_uid_base_max),
2863 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2864 'render group access mode: @0@'.format(get_option('group-render-mode')),
2865 'certificate root directory: @0@'.format(get_option('certificate-root')),
2866 'support URL: @0@'.format(support_url),
2867 'nobody user name: @0@'.format(nobody_user),
2868 'nobody group name: @0@'.format(nobody_group),
2869 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2870 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2872 'default DNSSEC mode: @0@'.format(default_dnssec),
2873 'default DNS-over-TLS mode: @0@'.format(default_dns_over_tls),
2874 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2875 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2877 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2878 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2880 'default DNS servers: @0@'.format(alt_dns_servers),
2881 'default NTP servers: @0@'.format(alt_ntp_servers)]
2883 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2884 '@@0@'.format(time_epoch)).stdout().strip()
2886 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2889 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2890 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2891 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2893 if conf.get('ENABLE_EFI') == 1
2895 'efi arch: @0@'.format(efi_arch)]
2899 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2900 'EFI CC @0@'.format(efi_cc),
2901 'EFI lib directory: @0@'.format(efi_libdir),
2902 'EFI lds directory: @0@'.format(efi_ldsdir),
2903 'EFI include directory: @0@'.format(efi_incdir)]
2957 ['legacy pkla', install_polkit_pkla],
2959 ['gnu-efi', have_gnu_efi],
2966 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2969 ['man pages', want_man],
2970 ['html pages', want_html],
2971 ['man page indices', want_man and have_lxml],
2976 ['adm group', get_option('adm-group')],
2977 ['wheel group', get_option('wheel-group')],
2980 ['debug mmap cache'],
2981 ['valgrind', conf.get('VALGRIND') == 1],
2984 if tuple.length() >= 2
2987 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2988 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2989 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2994 missing += [tuple[0]]
3000 'enabled features: @0@'.format(', '.join(found)),
3002 'disabled features: @0@'.format(', '.join(missing)),
3004 message('\n '.join(status))
3006 if rootprefixdir != rootprefix_default
3008 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3009 'systemd used fixed names for unit file directories and other paths, so anything\n' +
3010 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))