1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 project('systemd', 'c',
14 meson_version : '>= 0.41',
17 libsystemd_version = '0.22.0'
18 libudev_version = '1.6.10'
20 # We need the same data in three 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())
34 #####################################################################
36 # Try to install the git pre-commit hook
37 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
38 if git_hook.returncode() == 0
39 message(git_hook.stdout().strip())
42 #####################################################################
44 if get_option('split-usr') == 'auto'
45 split_usr = run_command('test', '-L', '/bin').returncode() != 0
47 split_usr = get_option('split-usr') == 'true'
49 conf.set10('HAVE_SPLIT_USR', split_usr,
50 description : '/usr/bin and /bin directories are separate')
52 if get_option('split-bin') == 'auto'
53 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
55 split_bin = get_option('split-bin') == 'true'
57 conf.set10('HAVE_SPLIT_BIN', split_bin,
58 description : 'bin and sbin directories are separate')
60 rootprefixdir = get_option('rootprefix')
61 # Unusual rootprefixdir values are used by some distros
62 # (see https://github.com/systemd/systemd/pull/7461).
63 rootprefix_default = split_usr ? '/' : '/usr'
64 if rootprefixdir == ''
65 rootprefixdir = rootprefix_default
68 sysvinit_path = get_option('sysvinit-path')
69 sysvrcnd_path = get_option('sysvrcnd-path')
70 have = sysvinit_path != '' and sysvrcnd_path != ''
71 conf.set10('HAVE_SYSV_COMPAT', have,
72 description : 'SysV init scripts and rcN.d links are supported')
73 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
75 # join_paths ignore the preceding arguments if an absolute component is
76 # encountered, so this should canonicalize various paths when they are
77 # absolute or relative.
78 prefixdir = get_option('prefix')
79 if not prefixdir.startswith('/')
80 error('Prefix is not absolute: "@0@"'.format(prefixdir))
82 bindir = join_paths(prefixdir, get_option('bindir'))
83 libdir = join_paths(prefixdir, get_option('libdir'))
84 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
85 includedir = join_paths(prefixdir, get_option('includedir'))
86 datadir = join_paths(prefixdir, get_option('datadir'))
87 localstatedir = join_paths('/', get_option('localstatedir'))
89 rootbindir = join_paths(rootprefixdir, 'bin')
90 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
91 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
93 rootlibdir = get_option('rootlibdir')
95 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
98 # Dirs of external packages
99 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
100 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
101 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
102 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
103 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
104 varlogdir = join_paths(localstatedir, 'log')
105 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
106 rpmmacrosdir = get_option('rpmmacrosdir')
107 if rpmmacrosdir != 'no'
108 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
110 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
113 pkgdatadir = join_paths(datadir, 'systemd')
114 environmentdir = join_paths(prefixdir, 'lib/environment.d')
115 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
116 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
117 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
118 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
119 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
120 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
121 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
122 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
123 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
124 pkgincludedir = join_paths(includedir, 'systemd')
125 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
126 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
127 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
128 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
129 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
130 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
131 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
132 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
133 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
134 udevhomedir = udevlibexecdir
135 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
136 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
137 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
138 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
139 factorydir = join_paths(datadir, 'factory')
140 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
141 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
142 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
143 catalogstatedir = join_paths(systemdstatedir, 'catalog')
144 randomseeddir = join_paths(localstatedir, 'lib/systemd')
146 docdir = get_option('docdir')
148 docdir = join_paths(datadir, 'doc/systemd')
151 dbuspolicydir = get_option('dbuspolicydir')
152 if dbuspolicydir == ''
153 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
156 dbussessionservicedir = get_option('dbussessionservicedir')
157 if dbussessionservicedir == ''
158 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
161 dbussystemservicedir = get_option('dbussystemservicedir')
162 if dbussystemservicedir == ''
163 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
166 pamlibdir = get_option('pamlibdir')
168 pamlibdir = join_paths(rootlibdir, 'security')
171 pamconfdir = get_option('pamconfdir')
173 pamconfdir = join_paths(sysconfdir, 'pam.d')
176 memory_accounting_default = get_option('memory-accounting-default')
178 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
179 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
180 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
181 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
182 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
183 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
184 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
186 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
188 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
189 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
190 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
191 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
192 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
193 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
194 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
195 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
196 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
197 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
198 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
199 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
200 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
201 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
202 conf.set_quoted('ROOTPREFIX', rootprefixdir)
203 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
204 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
205 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
206 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
207 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
208 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
209 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
210 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
211 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
212 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
213 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
214 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
215 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
216 conf.set_quoted('LIBDIR', libdir)
217 conf.set_quoted('ROOTLIBDIR', rootlibdir)
218 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
219 conf.set_quoted('BOOTLIBDIR', bootlibdir)
220 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
221 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
222 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
223 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
224 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
225 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
226 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
227 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
229 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
230 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
232 substs.set('prefix', prefixdir)
233 substs.set('exec_prefix', prefixdir)
234 substs.set('libdir', libdir)
235 substs.set('rootlibdir', rootlibdir)
236 substs.set('includedir', includedir)
237 substs.set('pkgsysconfdir', pkgsysconfdir)
238 substs.set('bindir', bindir)
239 substs.set('rootbindir', rootbindir)
240 substs.set('rootlibexecdir', rootlibexecdir)
241 substs.set('systemunitdir', systemunitdir)
242 substs.set('userunitdir', userunitdir)
243 substs.set('systempresetdir', systempresetdir)
244 substs.set('userpresetdir', userpresetdir)
245 substs.set('udevhwdbdir', udevhwdbdir)
246 substs.set('udevrulesdir', udevrulesdir)
247 substs.set('udevlibexecdir', udevlibexecdir)
248 substs.set('catalogdir', catalogdir)
249 substs.set('tmpfilesdir', tmpfilesdir)
250 substs.set('sysusersdir', sysusersdir)
251 substs.set('sysctldir', sysctldir)
252 substs.set('binfmtdir', binfmtdir)
253 substs.set('modulesloaddir', modulesloaddir)
254 substs.set('systemgeneratordir', systemgeneratordir)
255 substs.set('usergeneratordir', usergeneratordir)
256 substs.set('systemenvgeneratordir', systemenvgeneratordir)
257 substs.set('userenvgeneratordir', userenvgeneratordir)
258 substs.set('systemshutdowndir', systemshutdowndir)
259 substs.set('systemsleepdir', systemsleepdir)
260 substs.set('VARLOGDIR', varlogdir)
261 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
262 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
263 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
264 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
265 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
266 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
267 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
268 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
270 #####################################################################
272 cc = meson.get_compiler('c')
273 pkgconfig = import('pkgconfig')
274 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
275 meson_build_sh = find_program('tools/meson-build.sh')
277 if get_option('tests') != 'false'
278 cxx = find_program('c++', required : false)
280 # Used only for tests
285 want_ossfuzz = get_option('oss-fuzz')
286 want_libfuzzer = get_option('llvm-fuzz')
287 fuzzer_build = want_ossfuzz or want_libfuzzer
288 if want_ossfuzz and want_libfuzzer
289 error('only one of oss-fuzz and llvm-fuzz can be specified')
292 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
295 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
298 foreach arg : ['-Wextra',
301 '-Wmissing-include-dirs',
302 '-Wold-style-definition',
305 '-Wdeclaration-after-statement',
307 '-Wsuggest-attribute=noreturn',
308 '-Werror=missing-prototypes',
309 '-Werror=implicit-function-declaration',
310 '-Werror=missing-declarations',
311 '-Werror=return-type',
312 '-Werror=incompatible-pointer-types',
314 '-Wstrict-prototypes',
316 '-Wmissing-noreturn',
317 '-Wimplicit-fallthrough=5',
320 '-Wstrict-aliasing=2',
327 '-fdiagnostics-show-option',
328 '-fno-strict-aliasing',
329 '-fvisibility=hidden',
331 '-fstack-protector-strong',
332 '--param=ssp-buffer-size=4',
334 if cc.has_argument(arg)
335 add_project_arguments(arg, language : 'c')
339 # the oss-fuzz fuzzers are not built with -fPIE, so don't
340 # enable it when we are linking against them
342 if cc.has_argument('-fPIE')
343 add_project_arguments('-fPIE', language : 'c')
347 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
348 # arguments, just emits a warnings. So test for the "positive" version instead.
349 foreach arg : ['unused-parameter',
350 'missing-field-initializers',
353 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
355 if cc.has_argument('-W' + arg)
356 add_project_arguments('-Wno-' + arg, language : 'c')
362 #include <inttypes.h>
363 typedef uint64_t usec_t;
364 usec_t now(clockid_t clock);
369 ''', name : '-Werror=shadow with local shadowing')
370 add_project_arguments('-Werror=shadow', language : 'c')
373 if cc.get_id() == 'clang'
374 foreach arg : ['-Wno-typedef-redefinition',
375 '-Wno-gnu-variable-sized-type-not-at-end',
377 if cc.has_argument(arg)
378 add_project_arguments(arg, language : 'c')
383 link_test_c = files('tools/meson-link-test.c')
385 # --as-needed and --no-undefined are provided by meson by default,
386 # run mesonconf to see what is enabled
387 foreach arg : ['-Wl,-z,relro',
392 have = run_command(check_compilation_sh,
393 cc.cmd_array(), '-x', 'c', arg,
394 '-include', link_test_c).returncode() == 0
395 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
396 if have and (arg != '-pie' or not fuzzer_build)
397 add_project_link_arguments(arg, language : 'c')
401 if get_option('buildtype') != 'debug'
402 foreach arg : ['-ffunction-sections',
404 if cc.has_argument(arg,
405 name : '@0@ is supported'.format(arg))
406 add_project_arguments(arg, language : 'c')
410 foreach arg : ['-Wl,--gc-sections']
411 have = run_command(check_compilation_sh,
412 cc.cmd_array(), '-x', 'c', arg,
413 '-include', link_test_c).returncode() == 0
414 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
416 add_project_link_arguments(arg, language : 'c')
421 cpp = ' '.join(cc.cmd_array()) + ' -E'
423 #####################################################################
424 # compilation result tests
426 conf.set('_GNU_SOURCE', true)
427 conf.set('__SANE_USERSPACE_TYPES__', true)
429 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
430 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
431 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
432 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
433 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
434 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
435 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
439 #include <linux/ethtool.h>
440 #include <linux/fib_rules.h>
441 #include <linux/stat.h>
442 #include <sys/stat.h>
444 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
446 foreach decl : ['char16_t',
449 'struct ethtool_link_settings',
450 'struct fib_rule_uid_range',
454 # We get -1 if the size cannot be determined
455 have = cc.sizeof(decl, prefix : decl_headers) > 0
456 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
459 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
460 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
461 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
462 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
463 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
464 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
465 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
466 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
467 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
468 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
469 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
470 # if_tunnel.h is buggy and cannot be included on its own
471 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
472 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
473 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
474 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
475 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
476 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
477 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
478 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
479 ['NDA_IFINDEX', 'linux/neighbour.h'],
480 ['IFA_FLAGS', 'linux/if_addr.h'],
481 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
482 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
483 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
485 prefix = decl.length() > 2 ? decl[2] : ''
486 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
487 conf.set10('HAVE_' + decl[0], have)
490 foreach ident : ['secure_getenv', '__secure_getenv']
491 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
495 ['memfd_create', '''#include <sys/mman.h>'''],
496 ['gettid', '''#include <sys/types.h>
497 #include <unistd.h>'''],
498 ['pivot_root', '''#include <stdlib.h>
499 #include <unistd.h>'''], # no known header declares pivot_root
500 ['name_to_handle_at', '''#include <sys/types.h>
501 #include <sys/stat.h>
502 #include <fcntl.h>'''],
503 ['setns', '''#include <sched.h>'''],
504 ['renameat2', '''#include <stdio.h>
505 #include <fcntl.h>'''],
506 ['kcmp', '''#include <linux/kcmp.h>'''],
507 ['keyctl', '''#include <sys/types.h>
508 #include <keyutils.h>'''],
509 ['copy_file_range', '''#include <sys/syscall.h>
510 #include <unistd.h>'''],
511 ['bpf', '''#include <sys/syscall.h>
512 #include <unistd.h>'''],
513 ['statx', '''#include <sys/types.h>
514 #include <sys/stat.h>
515 #include <unistd.h>'''],
516 ['explicit_bzero' , '''#include <string.h>'''],
517 ['reallocarray', '''#include <malloc.h>'''],
520 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
521 conf.set10('HAVE_' + ident[0].to_upper(), have)
524 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
525 conf.set10('USE_SYS_RANDOM_H', true)
526 conf.set10('HAVE_GETRANDOM', true)
528 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
529 conf.set10('USE_SYS_RANDOM_H', false)
530 conf.set10('HAVE_GETRANDOM', have)
533 #####################################################################
535 sed = find_program('sed')
536 awk = find_program('awk')
537 m4 = find_program('m4')
538 stat = find_program('stat')
539 git = find_program('git', required : false)
540 env = find_program('env')
541 perl = find_program('perl', required : false)
543 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
544 mkdir_p = 'mkdir -p $DESTDIR/@0@'
545 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
546 splash_bmp = files('test/splash.bmp')
548 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
549 # /usr/sbin, /sbin, and fall back to the default from middle column.
550 progs = [['quotaon', '/usr/sbin/quotaon' ],
551 ['quotacheck', '/usr/sbin/quotacheck' ],
552 ['kmod', '/usr/bin/kmod' ],
553 ['kexec', '/usr/sbin/kexec' ],
554 ['sulogin', '/usr/sbin/sulogin' ],
555 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
556 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
557 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
558 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
561 path = get_option(prog[0] + '-path')
563 message('Using @1@ for @0@'.format(prog[0], path))
565 exe = find_program(prog[0],
566 '/usr/sbin/' + prog[0],
569 path = exe.found() ? exe.path() : prog[1]
571 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
572 conf.set_quoted(name, path)
573 substs.set(name, path)
576 conf.set_quoted('TELINIT', get_option('telinit-path'))
578 if run_command('ln', '--relative', '--help').returncode() != 0
579 error('ln does not support --relative (added in coreutils 8.16)')
582 ############################################################
584 gperf = find_program('gperf')
586 gperf_test_format = '''
588 const char * in_word_set(const char *, @0@);
591 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
592 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
593 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
594 if cc.compiles(gperf_test)
595 gperf_len_type = 'size_t'
597 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
598 if cc.compiles(gperf_test)
599 gperf_len_type = 'unsigned'
601 error('unable to determine gperf len type')
604 message('gperf len type is @0@'.format(gperf_len_type))
605 conf.set('GPERF_LEN_TYPE', gperf_len_type,
606 description : 'The type of gperf "len" parameter')
608 ############################################################
610 if not cc.has_header('sys/capability.h')
611 error('POSIX caps headers not found')
613 foreach header : ['crypt.h',
616 'linux/vm_sockets.h',
618 'valgrind/memcheck.h',
619 'valgrind/valgrind.h',
622 conf.set10('HAVE_' + header.underscorify().to_upper(),
623 cc.has_header(header))
626 ############################################################
628 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
629 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
630 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
632 default_hierarchy = get_option('default-hierarchy')
633 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
634 description : 'default cgroup hierarchy as string')
635 if default_hierarchy == 'legacy'
636 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
637 elif default_hierarchy == 'hybrid'
638 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
640 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
643 time_epoch = get_option('time-epoch')
646 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
648 time_epoch = time_epoch.to_int()
649 conf.set('TIME_EPOCH', time_epoch)
651 system_uid_max = get_option('system-uid-max')
652 if system_uid_max == ''
653 system_uid_max = run_command(
655 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
656 '/etc/login.defs').stdout().strip()
657 if system_uid_max == ''
658 system_uid_max = '999'
661 system_uid_max = system_uid_max.to_int()
662 conf.set('SYSTEM_UID_MAX', system_uid_max)
663 substs.set('systemuidmax', system_uid_max)
664 message('maximum system UID is @0@'.format(system_uid_max))
666 system_gid_max = get_option('system-gid-max')
667 if system_gid_max == ''
668 system_gid_max = run_command(
670 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
671 '/etc/login.defs').stdout().strip()
672 if system_gid_max == ''
673 system_gid_max = '999'
676 system_gid_max = system_gid_max.to_int()
677 conf.set('SYSTEM_GID_MAX', system_gid_max)
678 substs.set('systemgidmax', system_gid_max)
679 message('maximum system GID is @0@'.format(system_gid_max))
681 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
682 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
683 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
684 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
685 substs.set('dynamicuidmin', dynamic_uid_min)
686 substs.set('dynamicuidmax', dynamic_uid_max)
688 container_uid_base_min = get_option('container-uid-base-min').to_int()
689 container_uid_base_max = get_option('container-uid-base-max').to_int()
690 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
691 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
692 substs.set('containeruidbasemin', container_uid_base_min)
693 substs.set('containeruidbasemax', container_uid_base_max)
695 nobody_user = get_option('nobody-user')
696 nobody_group = get_option('nobody-group')
698 getent_result = run_command('getent', 'passwd', '65534')
699 if getent_result.returncode() == 0
700 name = getent_result.stdout().split(':')[0]
701 if name != nobody_user
702 message('WARNING:\n' +
703 ' 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) +
704 ' Your build will result in an user table setup that is incompatible with the local system.')
707 id_result = run_command('id', '-u', nobody_user)
708 if id_result.returncode() == 0
709 id = id_result.stdout().to_int()
711 message('WARNING:\n' +
712 ' 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) +
713 ' Your build will result in an user table setup that is incompatible with the local system.')
717 getent_result = run_command('getent', 'group', '65534')
718 if getent_result.returncode() == 0
719 name = getent_result.stdout().split(':')[0]
720 if name != nobody_group
721 message('WARNING:\n' +
722 ' 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) +
723 ' Your build will result in an group table setup that is incompatible with the local system.')
726 id_result = run_command('id', '-g', nobody_group)
727 if id_result.returncode() == 0
728 id = id_result.stdout().to_int()
730 message('WARNING:\n' +
731 ' 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) +
732 ' Your build will result in an group table setup that is incompatible with the local system.')
735 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
736 message('WARNING:\n' +
737 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
738 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
741 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
742 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
743 substs.set('NOBODY_USER_NAME', nobody_user)
744 substs.set('NOBODY_GROUP_NAME', nobody_group)
746 tty_gid = get_option('tty-gid')
747 conf.set('TTY_GID', tty_gid)
748 substs.set('TTY_GID', tty_gid)
750 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
751 if get_option('users-gid') != ''
752 users_gid = get_option('users-gid').to_int()
756 substs.set('USERS_GID', users_gid)
758 if get_option('adm-group')
759 m4_defines += ['-DENABLE_ADM_GROUP']
762 if get_option('wheel-group')
763 m4_defines += ['-DENABLE_WHEEL_GROUP']
766 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
767 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
769 kill_user_processes = get_option('default-kill-user-processes')
770 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
771 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
772 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
774 dns_servers = get_option('dns-servers')
775 conf.set_quoted('DNS_SERVERS', dns_servers)
776 substs.set('DNS_SERVERS', dns_servers)
778 ntp_servers = get_option('ntp-servers')
779 conf.set_quoted('NTP_SERVERS', ntp_servers)
780 substs.set('NTP_SERVERS', ntp_servers)
782 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
784 substs.set('SUSHELL', get_option('debug-shell'))
785 substs.set('DEBUGTTY', get_option('debug-tty'))
787 debug = get_option('debug')
788 enable_debug_hashmap = false
789 enable_debug_mmap_cache = false
791 foreach name : debug.split(',')
793 enable_debug_hashmap = true
794 elif name == 'mmap-cache'
795 enable_debug_mmap_cache = true
797 message('unknown debug option "@0@", ignoring'.format(name))
801 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
802 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
804 #####################################################################
806 threads = dependency('threads')
807 librt = cc.find_library('rt')
808 libm = cc.find_library('m')
809 libdl = cc.find_library('dl')
810 libcrypt = cc.find_library('crypt')
812 libcap = dependency('libcap', required : false)
813 if not libcap.found()
814 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
815 libcap = cc.find_library('cap')
818 libmount = dependency('mount',
819 version : fuzzer_build ? '>= 0' : '>= 2.30')
821 want_seccomp = get_option('seccomp')
822 if want_seccomp != 'false' and not fuzzer_build
823 libseccomp = dependency('libseccomp',
824 version : '>= 2.3.1',
825 required : want_seccomp == 'true')
826 have = libseccomp.found()
831 conf.set10('HAVE_SECCOMP', have)
832 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
834 want_selinux = get_option('selinux')
835 if want_selinux != 'false' and not fuzzer_build
836 libselinux = dependency('libselinux',
837 version : '>= 2.1.9',
838 required : want_selinux == 'true')
839 have = libselinux.found()
844 conf.set10('HAVE_SELINUX', have)
845 m4_defines += have ? ['-DHAVE_SELINUX'] : []
847 want_apparmor = get_option('apparmor')
848 if want_apparmor != 'false' and not fuzzer_build
849 libapparmor = dependency('libapparmor',
850 required : want_apparmor == 'true')
851 have = libapparmor.found()
856 conf.set10('HAVE_APPARMOR', have)
857 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
859 smack_run_label = get_option('smack-run-label')
860 if smack_run_label != ''
861 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
862 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
865 want_polkit = get_option('polkit')
866 install_polkit = false
867 install_polkit_pkla = false
868 if want_polkit != 'false' and not fuzzer_build
869 install_polkit = true
871 libpolkit = dependency('polkit-gobject-1',
873 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
874 message('Old polkit detected, will install pkla files')
875 install_polkit_pkla = true
878 conf.set10('ENABLE_POLKIT', install_polkit)
880 want_acl = get_option('acl')
881 if want_acl != 'false' and not fuzzer_build
882 libacl = cc.find_library('acl', required : want_acl == 'true')
883 have = libacl.found()
888 conf.set10('HAVE_ACL', have)
889 m4_defines += have ? ['-DHAVE_ACL'] : []
891 want_audit = get_option('audit')
892 if want_audit != 'false' and not fuzzer_build
893 libaudit = dependency('audit', required : want_audit == 'true')
894 have = libaudit.found()
899 conf.set10('HAVE_AUDIT', have)
901 want_blkid = get_option('blkid')
902 if want_blkid != 'false' and not fuzzer_build
903 libblkid = dependency('blkid', required : want_blkid == 'true')
904 have = libblkid.found()
909 conf.set10('HAVE_BLKID', have)
911 want_kmod = get_option('kmod')
912 if want_kmod != 'false' and not fuzzer_build
913 libkmod = dependency('libkmod',
915 required : want_kmod == 'true')
916 have = libkmod.found()
921 conf.set10('HAVE_KMOD', have)
923 want_pam = get_option('pam')
924 if want_pam != 'false' and not fuzzer_build
925 libpam = cc.find_library('pam', required : want_pam == 'true')
926 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
927 have = libpam.found() and libpam_misc.found()
933 conf.set10('HAVE_PAM', have)
934 m4_defines += have ? ['-DHAVE_PAM'] : []
936 want_microhttpd = get_option('microhttpd')
937 if want_microhttpd != 'false' and not fuzzer_build
938 libmicrohttpd = dependency('libmicrohttpd',
939 version : '>= 0.9.33',
940 required : want_microhttpd == 'true')
941 have = libmicrohttpd.found()
946 conf.set10('HAVE_MICROHTTPD', have)
947 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
949 want_libcryptsetup = get_option('libcryptsetup')
950 if want_libcryptsetup != 'false' and not fuzzer_build
951 libcryptsetup = dependency('libcryptsetup',
952 version : '>= 1.6.0',
953 required : want_libcryptsetup == 'true')
954 have = libcryptsetup.found()
959 conf.set10('HAVE_LIBCRYPTSETUP', have)
961 want_libcurl = get_option('libcurl')
962 if want_libcurl != 'false' and not fuzzer_build
963 libcurl = dependency('libcurl',
964 version : '>= 7.32.0',
965 required : want_libcurl == 'true')
966 have = libcurl.found()
971 conf.set10('HAVE_LIBCURL', have)
972 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
974 want_libidn = get_option('libidn')
975 want_libidn2 = get_option('libidn2')
976 if want_libidn == 'true' and want_libidn2 == 'true'
977 error('libidn and libidn2 cannot be requested simultaneously')
980 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
981 libidn = dependency('libidn',
982 required : want_libidn == 'true')
983 have = libidn.found()
988 conf.set10('HAVE_LIBIDN', have)
989 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
990 if not have and want_libidn2 != 'false' and not fuzzer_build
991 # libidn is used for both libidn and libidn2 objects
992 libidn = dependency('libidn2',
993 required : want_libidn2 == 'true')
994 have = libidn.found()
998 conf.set10('HAVE_LIBIDN2', have)
999 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1001 want_libiptc = get_option('libiptc')
1002 if want_libiptc != 'false' and not fuzzer_build
1003 libiptc = dependency('libiptc',
1004 required : want_libiptc == 'true')
1005 have = libiptc.found()
1010 conf.set10('HAVE_LIBIPTC', have)
1011 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1013 want_qrencode = get_option('qrencode')
1014 if want_qrencode != 'false' and not fuzzer_build
1015 libqrencode = dependency('libqrencode',
1016 required : want_qrencode == 'true')
1017 have = libqrencode.found()
1022 conf.set10('HAVE_QRENCODE', have)
1024 want_gcrypt = get_option('gcrypt')
1025 if want_gcrypt != 'false' and not fuzzer_build
1026 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1027 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1028 have = libgcrypt.found() and libgpg_error.found()
1033 # link to neither of the libs if one is not found
1037 conf.set10('HAVE_GCRYPT', have)
1039 want_gnutls = get_option('gnutls')
1040 if want_gnutls != 'false' and not fuzzer_build
1041 libgnutls = dependency('gnutls',
1042 version : '>= 3.1.4',
1043 required : want_gnutls == 'true')
1044 have = libgnutls.found()
1049 conf.set10('HAVE_GNUTLS', have)
1051 want_elfutils = get_option('elfutils')
1052 if want_elfutils != 'false' and not fuzzer_build
1053 libdw = dependency('libdw',
1054 required : want_elfutils == 'true')
1055 have = libdw.found()
1060 conf.set10('HAVE_ELFUTILS', have)
1062 want_zlib = get_option('zlib')
1063 if want_zlib != 'false' and not fuzzer_build
1064 libz = dependency('zlib',
1065 required : want_zlib == 'true')
1071 conf.set10('HAVE_ZLIB', have)
1073 want_bzip2 = get_option('bzip2')
1074 if want_bzip2 != 'false' and not fuzzer_build
1075 libbzip2 = cc.find_library('bz2',
1076 required : want_bzip2 == 'true')
1077 have = libbzip2.found()
1082 conf.set10('HAVE_BZIP2', have)
1084 want_xz = get_option('xz')
1085 if want_xz != 'false' and not fuzzer_build
1086 libxz = dependency('liblzma',
1087 required : want_xz == 'true')
1088 have = libxz.found()
1093 conf.set10('HAVE_XZ', have)
1095 want_lz4 = get_option('lz4')
1096 if want_lz4 != 'false' and not fuzzer_build
1097 liblz4 = dependency('liblz4',
1098 required : want_lz4 == 'true')
1099 have = liblz4.found()
1104 conf.set10('HAVE_LZ4', have)
1106 want_xkbcommon = get_option('xkbcommon')
1107 if want_xkbcommon != 'false' and not fuzzer_build
1108 libxkbcommon = dependency('xkbcommon',
1109 version : '>= 0.3.0',
1110 required : want_xkbcommon == 'true')
1111 have = libxkbcommon.found()
1116 conf.set10('HAVE_XKBCOMMON', have)
1118 want_pcre2 = get_option('pcre2')
1119 if want_pcre2 != 'false'
1120 libpcre2 = dependency('libpcre2-8',
1121 required : want_pcre2 == 'true')
1122 have = libpcre2.found()
1127 conf.set10('HAVE_PCRE2', have)
1129 want_glib = get_option('glib')
1130 if want_glib != 'false' and not fuzzer_build
1131 libglib = dependency('glib-2.0',
1132 version : '>= 2.22.0',
1133 required : want_glib == 'true')
1134 libgobject = dependency('gobject-2.0',
1135 version : '>= 2.22.0',
1136 required : want_glib == 'true')
1137 libgio = dependency('gio-2.0',
1138 required : want_glib == 'true')
1139 have = libglib.found() and libgobject.found() and libgio.found()
1146 conf.set10('HAVE_GLIB', have)
1148 want_dbus = get_option('dbus')
1149 if want_dbus != 'false' and not fuzzer_build
1150 libdbus = dependency('dbus-1',
1151 version : '>= 1.3.2',
1152 required : want_dbus == 'true')
1153 have = libdbus.found()
1158 conf.set10('HAVE_DBUS', have)
1160 default_dnssec = get_option('default-dnssec')
1162 default_dnssec = 'no'
1164 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1165 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1166 default_dnssec = 'no'
1168 conf.set('DEFAULT_DNSSEC_MODE',
1169 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1170 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1172 want_importd = get_option('importd')
1173 if want_importd != 'false'
1174 have = (conf.get('HAVE_LIBCURL') == 1 and
1175 conf.get('HAVE_ZLIB') == 1 and
1176 conf.get('HAVE_BZIP2') == 1 and
1177 conf.get('HAVE_XZ') == 1 and
1178 conf.get('HAVE_GCRYPT') == 1)
1179 if want_importd == 'true' and not have
1180 error('importd support was requested, but dependencies are not available')
1185 conf.set10('ENABLE_IMPORTD', have)
1187 want_remote = get_option('remote')
1188 if want_remote != 'false'
1189 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1190 conf.get('HAVE_LIBCURL') == 1]
1191 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1192 # it's possible to build one without the other. Complain only if
1193 # support was explictly requested. The auxiliary files like sysusers
1194 # config should be installed when any of the programs are built.
1195 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1196 error('remote support was requested, but dependencies are not available')
1198 have = have_deps[0] or have_deps[1]
1202 conf.set10('ENABLE_REMOTE', have)
1204 foreach term : ['utmp',
1235 have = get_option(term)
1236 name = 'ENABLE_' + term.underscorify().to_upper()
1237 conf.set10(name, have)
1238 m4_defines += have ? ['-D' + name] : []
1241 want_tests = get_option('tests')
1242 install_tests = get_option('install-tests')
1243 slow_tests = get_option('slow-tests')
1247 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1249 #####################################################################
1251 if get_option('efi')
1252 efi_arch = host_machine.cpu_family()
1254 if efi_arch == 'x86'
1255 EFI_MACHINE_TYPE_NAME = 'ia32'
1256 gnu_efi_arch = 'ia32'
1257 elif efi_arch == 'x86_64'
1258 EFI_MACHINE_TYPE_NAME = 'x64'
1259 gnu_efi_arch = 'x86_64'
1260 elif efi_arch == 'arm'
1261 EFI_MACHINE_TYPE_NAME = 'arm'
1262 gnu_efi_arch = 'arm'
1263 elif efi_arch == 'aarch64'
1264 EFI_MACHINE_TYPE_NAME = 'aa64'
1265 gnu_efi_arch = 'aarch64'
1267 EFI_MACHINE_TYPE_NAME = ''
1272 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1274 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1278 conf.set10('ENABLE_EFI', have)
1280 #####################################################################
1282 config_h = configure_file(
1283 output : 'config.h',
1284 configuration : conf)
1286 includes = include_directories('src/basic',
1292 'src/time-wait-sync',
1297 'src/libsystemd/sd-bus',
1298 'src/libsystemd/sd-device',
1299 'src/libsystemd/sd-hwdb',
1300 'src/libsystemd/sd-id128',
1301 'src/libsystemd/sd-netlink',
1302 'src/libsystemd/sd-network',
1303 'src/libsystemd-network',
1306 add_project_arguments('-include', 'config.h', language : 'c')
1310 subdir('src/systemd')
1312 subdir('src/libsystemd')
1313 subdir('src/libsystemd-network')
1314 subdir('src/journal')
1317 libjournal_core = static_library(
1319 libjournal_core_sources,
1321 include_directories : includes,
1324 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1325 libsystemd = shared_library(
1327 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1328 version : libsystemd_version,
1329 include_directories : includes,
1330 link_args : ['-shared',
1331 '-Wl,--version-script=' + libsystemd_sym_path],
1332 link_with : [libbasic,
1334 link_whole : [libsystemd_static,
1336 dependencies : [threads,
1340 link_depends : libsystemd_sym,
1342 install_dir : rootlibdir)
1344 ############################################################
1346 # binaries that have --help and are intended for use by humans,
1347 # usually, but not always, installed in /bin.
1348 public_programs = []
1350 subdir('src/libudev')
1351 subdir('src/shared')
1354 subdir('src/network')
1356 subdir('src/analyze')
1357 subdir('src/journal-remote')
1358 subdir('src/coredump')
1359 subdir('src/hostname')
1360 subdir('src/import')
1361 subdir('src/kernel-install')
1362 subdir('src/locale')
1363 subdir('src/machine')
1364 subdir('src/nspawn')
1365 subdir('src/resolve')
1366 subdir('src/timedate')
1367 subdir('src/timesync')
1368 subdir('src/vconsole')
1369 subdir('src/boot/efi')
1376 ############################################################
1378 # only static linking apart from libdl, to make sure that the
1379 # module is linked to all libraries that it uses.
1380 test_dlopen = executable(
1383 include_directories : includes,
1384 link_with : [libbasic],
1385 dependencies : [libdl])
1387 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1388 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1389 ['mymachines', 'ENABLE_MACHINED'],
1390 ['resolve', 'ENABLE_RESOLVE']]
1392 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1396 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1397 version_script_arg = join_paths(meson.current_source_dir(), sym)
1399 nss = shared_library(
1401 'src/nss-@0@/nss-@0@.c'.format(module),
1403 include_directories : includes,
1404 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1405 link_args : ['-Wl,-z,nodelete',
1407 '-Wl,--version-script=' + version_script_arg,
1409 link_with : [libsystemd_static,
1411 dependencies : [threads,
1415 install_dir : rootlibdir)
1417 # We cannot use shared_module because it does not support version suffix.
1418 # Unfortunately shared_library insists on creating the symlink…
1419 meson.add_install_script('sh', '-c',
1420 'rm $DESTDIR@0@/libnss_@1@.so'
1421 .format(rootlibdir, module))
1423 test('dlopen-nss_' + module,
1425 args : [nss.full_path()]) # path to dlopen must include a slash
1429 ############################################################
1431 executable('systemd',
1433 include_directories : includes,
1434 link_with : [libcore,
1436 dependencies : [threads,
1442 install_rpath : rootlibexecdir,
1444 install_dir : rootlibexecdir)
1446 meson.add_install_script(meson_make_symlink,
1447 join_paths(rootlibexecdir, 'systemd'),
1448 join_paths(rootsbindir, 'init'))
1450 exe = executable('systemd-analyze',
1451 systemd_analyze_sources,
1452 include_directories : includes,
1453 link_with : [libcore,
1455 dependencies : [threads,
1461 install_rpath : rootlibexecdir,
1463 public_programs += [exe]
1465 executable('systemd-journald',
1466 systemd_journald_sources,
1467 include_directories : includes,
1468 link_with : [libjournal_core,
1470 dependencies : [threads,
1474 install_rpath : rootlibexecdir,
1476 install_dir : rootlibexecdir)
1478 exe = executable('systemd-cat',
1479 systemd_cat_sources,
1480 include_directories : includes,
1481 link_with : [libjournal_core,
1483 dependencies : [threads],
1484 install_rpath : rootlibexecdir,
1486 public_programs += [exe]
1488 exe = executable('journalctl',
1490 include_directories : includes,
1491 link_with : [libshared],
1492 dependencies : [threads,
1497 install_rpath : rootlibexecdir,
1499 install_dir : rootbindir)
1500 public_programs += [exe]
1502 executable('systemd-getty-generator',
1503 'src/getty-generator/getty-generator.c',
1504 include_directories : includes,
1505 link_with : [libshared],
1506 install_rpath : rootlibexecdir,
1508 install_dir : systemgeneratordir)
1510 executable('systemd-debug-generator',
1511 'src/debug-generator/debug-generator.c',
1512 include_directories : includes,
1513 link_with : [libshared],
1514 install_rpath : rootlibexecdir,
1516 install_dir : systemgeneratordir)
1518 executable('systemd-fstab-generator',
1519 'src/fstab-generator/fstab-generator.c',
1520 'src/core/mount-setup.c',
1521 include_directories : includes,
1522 link_with : [libshared],
1523 install_rpath : rootlibexecdir,
1525 install_dir : systemgeneratordir)
1527 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1528 executable('30-systemd-environment-d-generator',
1529 'src/environment-d-generator/environment-d-generator.c',
1530 include_directories : includes,
1531 link_with : [libshared],
1532 install_rpath : rootlibexecdir,
1534 install_dir : userenvgeneratordir)
1536 meson.add_install_script(meson_make_symlink,
1537 join_paths(sysconfdir, 'environment'),
1538 join_paths(environmentdir, '99-environment.conf'))
1541 if conf.get('ENABLE_HIBERNATE') == 1
1542 executable('systemd-hibernate-resume-generator',
1543 'src/hibernate-resume/hibernate-resume-generator.c',
1544 include_directories : includes,
1545 link_with : [libshared],
1546 install_rpath : rootlibexecdir,
1548 install_dir : systemgeneratordir)
1550 executable('systemd-hibernate-resume',
1551 'src/hibernate-resume/hibernate-resume.c',
1552 include_directories : includes,
1553 link_with : [libshared],
1554 install_rpath : rootlibexecdir,
1556 install_dir : rootlibexecdir)
1559 if conf.get('HAVE_BLKID') == 1
1560 executable('systemd-gpt-auto-generator',
1561 'src/gpt-auto-generator/gpt-auto-generator.c',
1562 'src/basic/blkid-util.h',
1563 include_directories : includes,
1564 link_with : [libshared],
1565 dependencies : libblkid,
1566 install_rpath : rootlibexecdir,
1568 install_dir : systemgeneratordir)
1570 exe = executable('systemd-dissect',
1571 'src/dissect/dissect.c',
1572 include_directories : includes,
1573 link_with : [libshared],
1574 install_rpath : rootlibexecdir,
1576 install_dir : rootlibexecdir)
1577 public_programs += [exe]
1580 if conf.get('ENABLE_RESOLVE') == 1
1581 executable('systemd-resolved',
1582 systemd_resolved_sources,
1583 include_directories : includes,
1584 link_with : [libshared,
1586 libsystemd_resolve_core],
1587 dependencies : [threads,
1591 install_rpath : rootlibexecdir,
1593 install_dir : rootlibexecdir)
1595 exe = executable('resolvectl',
1597 include_directories : includes,
1598 link_with : [libshared,
1600 libsystemd_resolve_core],
1601 dependencies : [threads,
1605 install_rpath : rootlibexecdir,
1607 public_programs += [exe]
1609 meson.add_install_script(meson_make_symlink,
1610 join_paths(bindir, 'resolvectl'),
1611 join_paths(rootsbindir, 'resolvconf'))
1613 meson.add_install_script(meson_make_symlink,
1614 join_paths(bindir, 'resolvectl'),
1615 join_paths(bindir, 'systemd-resolve'))
1618 if conf.get('ENABLE_LOGIND') == 1
1619 executable('systemd-logind',
1620 systemd_logind_sources,
1621 include_directories : includes,
1622 link_with : [liblogind_core,
1624 dependencies : [threads,
1626 install_rpath : rootlibexecdir,
1628 install_dir : rootlibexecdir)
1630 exe = executable('loginctl',
1632 include_directories : includes,
1633 link_with : [libshared],
1634 dependencies : [threads,
1637 install_rpath : rootlibexecdir,
1639 install_dir : rootbindir)
1640 public_programs += [exe]
1642 exe = executable('systemd-inhibit',
1643 'src/login/inhibit.c',
1644 include_directories : includes,
1645 link_with : [libshared],
1646 install_rpath : rootlibexecdir,
1648 install_dir : rootbindir)
1649 public_programs += [exe]
1651 if conf.get('HAVE_PAM') == 1
1652 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1653 pam_systemd = shared_library(
1657 include_directories : includes,
1658 link_args : ['-shared',
1659 '-Wl,--version-script=' + version_script_arg],
1660 link_with : [libsystemd_static,
1662 dependencies : [threads,
1665 link_depends : pam_systemd_sym,
1667 install_dir : pamlibdir)
1669 test('dlopen-pam_systemd',
1671 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1675 if conf.get('HAVE_PAM') == 1
1676 executable('systemd-user-sessions',
1677 'src/user-sessions/user-sessions.c',
1678 include_directories : includes,
1679 link_with : [libshared],
1680 install_rpath : rootlibexecdir,
1682 install_dir : rootlibexecdir)
1685 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1686 exe = executable('bootctl',
1687 'src/boot/bootctl.c',
1688 include_directories : includes,
1689 link_with : [libshared],
1690 dependencies : [libblkid],
1691 install_rpath : rootlibexecdir,
1693 public_programs += [exe]
1696 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1697 include_directories : includes,
1698 link_with : [libshared],
1699 dependencies : [threads],
1700 install_rpath : rootlibexecdir,
1702 public_programs += [exe]
1704 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1705 include_directories : includes,
1706 link_with : [libshared],
1707 dependencies : [threads,
1712 install_rpath : rootlibexecdir,
1714 install_dir : rootbindir)
1715 public_programs += [exe]
1717 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1718 meson.add_install_script(meson_make_symlink,
1719 join_paths(rootbindir, 'systemctl'),
1720 join_paths(rootsbindir, alias))
1723 if conf.get('ENABLE_BACKLIGHT') == 1
1724 executable('systemd-backlight',
1725 'src/backlight/backlight.c',
1726 include_directories : includes,
1727 link_with : [libshared],
1728 install_rpath : rootlibexecdir,
1730 install_dir : rootlibexecdir)
1733 if conf.get('ENABLE_RFKILL') == 1
1734 executable('systemd-rfkill',
1735 'src/rfkill/rfkill.c',
1736 include_directories : includes,
1737 link_with : [libshared],
1738 install_rpath : rootlibexecdir,
1740 install_dir : rootlibexecdir)
1743 executable('systemd-system-update-generator',
1744 'src/system-update-generator/system-update-generator.c',
1745 include_directories : includes,
1746 link_with : [libshared],
1747 install_rpath : rootlibexecdir,
1749 install_dir : systemgeneratordir)
1751 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1752 executable('systemd-cryptsetup',
1753 'src/cryptsetup/cryptsetup.c',
1754 include_directories : includes,
1755 link_with : [libshared],
1756 dependencies : [libcryptsetup],
1757 install_rpath : rootlibexecdir,
1759 install_dir : rootlibexecdir)
1761 executable('systemd-cryptsetup-generator',
1762 'src/cryptsetup/cryptsetup-generator.c',
1763 include_directories : includes,
1764 link_with : [libshared],
1765 dependencies : [libcryptsetup],
1766 install_rpath : rootlibexecdir,
1768 install_dir : systemgeneratordir)
1770 executable('systemd-veritysetup',
1771 'src/veritysetup/veritysetup.c',
1772 include_directories : includes,
1773 link_with : [libshared],
1774 dependencies : [libcryptsetup],
1775 install_rpath : rootlibexecdir,
1777 install_dir : rootlibexecdir)
1779 executable('systemd-veritysetup-generator',
1780 'src/veritysetup/veritysetup-generator.c',
1781 include_directories : includes,
1782 link_with : [libshared],
1783 dependencies : [libcryptsetup],
1784 install_rpath : rootlibexecdir,
1786 install_dir : systemgeneratordir)
1789 if conf.get('HAVE_SYSV_COMPAT') == 1
1790 executable('systemd-sysv-generator',
1791 'src/sysv-generator/sysv-generator.c',
1792 include_directories : includes,
1793 link_with : [libshared],
1794 install_rpath : rootlibexecdir,
1796 install_dir : systemgeneratordir)
1798 executable('systemd-rc-local-generator',
1799 'src/rc-local-generator/rc-local-generator.c',
1800 include_directories : includes,
1801 link_with : [libshared],
1802 install_rpath : rootlibexecdir,
1804 install_dir : systemgeneratordir)
1807 if conf.get('ENABLE_HOSTNAMED') == 1
1808 executable('systemd-hostnamed',
1809 'src/hostname/hostnamed.c',
1810 include_directories : includes,
1811 link_with : [libshared],
1812 install_rpath : rootlibexecdir,
1814 install_dir : rootlibexecdir)
1816 exe = executable('hostnamectl',
1817 'src/hostname/hostnamectl.c',
1818 include_directories : includes,
1819 link_with : [libshared],
1820 install_rpath : rootlibexecdir,
1822 public_programs += [exe]
1825 if conf.get('ENABLE_LOCALED') == 1
1826 if conf.get('HAVE_XKBCOMMON') == 1
1827 # logind will load libxkbcommon.so dynamically on its own
1833 executable('systemd-localed',
1834 systemd_localed_sources,
1835 include_directories : includes,
1836 link_with : [libshared],
1837 dependencies : deps,
1838 install_rpath : rootlibexecdir,
1840 install_dir : rootlibexecdir)
1842 exe = executable('localectl',
1844 include_directories : includes,
1845 link_with : [libshared],
1846 install_rpath : rootlibexecdir,
1848 public_programs += [exe]
1851 if conf.get('ENABLE_TIMEDATED') == 1
1852 executable('systemd-timedated',
1853 'src/timedate/timedated.c',
1854 include_directories : includes,
1855 link_with : [libshared],
1856 install_rpath : rootlibexecdir,
1858 install_dir : rootlibexecdir)
1860 exe = executable('timedatectl',
1861 'src/timedate/timedatectl.c',
1862 include_directories : includes,
1863 install_rpath : rootlibexecdir,
1864 link_with : [libshared],
1866 public_programs += [exe]
1869 if conf.get('ENABLE_TIMESYNCD') == 1
1870 executable('systemd-timesyncd',
1871 systemd_timesyncd_sources,
1872 include_directories : includes,
1873 link_with : [libshared],
1874 dependencies : [threads,
1876 install_rpath : rootlibexecdir,
1878 install_dir : rootlibexecdir)
1880 executable('systemd-time-wait-sync',
1881 'src/time-wait-sync/time-wait-sync.c',
1882 include_directories : includes,
1883 link_with : [libshared],
1884 install_rpath : rootlibexecdir,
1886 install_dir : rootlibexecdir)
1889 if conf.get('ENABLE_MACHINED') == 1
1890 executable('systemd-machined',
1891 systemd_machined_sources,
1892 include_directories : includes,
1893 link_with : [libmachine_core,
1895 install_rpath : rootlibexecdir,
1897 install_dir : rootlibexecdir)
1899 exe = executable('machinectl',
1900 'src/machine/machinectl.c',
1901 include_directories : includes,
1902 link_with : [libshared],
1903 dependencies : [threads,
1906 install_rpath : rootlibexecdir,
1908 install_dir : rootbindir)
1909 public_programs += [exe]
1912 if conf.get('ENABLE_IMPORTD') == 1
1913 executable('systemd-importd',
1914 systemd_importd_sources,
1915 include_directories : includes,
1916 link_with : [libshared],
1917 dependencies : [threads],
1918 install_rpath : rootlibexecdir,
1920 install_dir : rootlibexecdir)
1922 systemd_pull = executable('systemd-pull',
1923 systemd_pull_sources,
1924 include_directories : includes,
1925 link_with : [libshared],
1926 dependencies : [libcurl,
1931 install_rpath : rootlibexecdir,
1933 install_dir : rootlibexecdir)
1935 systemd_import = executable('systemd-import',
1936 systemd_import_sources,
1937 include_directories : includes,
1938 link_with : [libshared],
1939 dependencies : [libcurl,
1943 install_rpath : rootlibexecdir,
1945 install_dir : rootlibexecdir)
1947 systemd_export = executable('systemd-export',
1948 systemd_export_sources,
1949 include_directories : includes,
1950 link_with : [libshared],
1951 dependencies : [libcurl,
1955 install_rpath : rootlibexecdir,
1957 install_dir : rootlibexecdir)
1958 public_programs += [systemd_pull, systemd_import, systemd_export]
1961 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1962 exe = executable('systemd-journal-upload',
1963 systemd_journal_upload_sources,
1964 include_directories : includes,
1965 link_with : [libshared],
1966 dependencies : [threads,
1971 install_rpath : rootlibexecdir,
1973 install_dir : rootlibexecdir)
1974 public_programs += [exe]
1977 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1978 s_j_remote = executable('systemd-journal-remote',
1979 systemd_journal_remote_sources,
1980 include_directories : includes,
1981 link_with : [libshared],
1982 dependencies : [threads,
1987 install_rpath : rootlibexecdir,
1989 install_dir : rootlibexecdir)
1991 s_j_gatewayd = executable('systemd-journal-gatewayd',
1992 systemd_journal_gatewayd_sources,
1993 include_directories : includes,
1994 link_with : [libshared],
1995 dependencies : [threads,
2000 install_rpath : rootlibexecdir,
2002 install_dir : rootlibexecdir)
2003 public_programs += [s_j_remote, s_j_gatewayd]
2006 if conf.get('ENABLE_COREDUMP') == 1
2007 executable('systemd-coredump',
2008 systemd_coredump_sources,
2009 include_directories : includes,
2010 link_with : [libshared],
2011 dependencies : [threads,
2016 install_rpath : rootlibexecdir,
2018 install_dir : rootlibexecdir)
2020 exe = executable('coredumpctl',
2021 coredumpctl_sources,
2022 include_directories : includes,
2023 link_with : [libshared],
2024 dependencies : [threads,
2027 install_rpath : rootlibexecdir,
2029 public_programs += [exe]
2032 if conf.get('ENABLE_BINFMT') == 1
2033 exe = executable('systemd-binfmt',
2034 'src/binfmt/binfmt.c',
2035 include_directories : includes,
2036 link_with : [libshared],
2037 install_rpath : rootlibexecdir,
2039 install_dir : rootlibexecdir)
2040 public_programs += [exe]
2042 meson.add_install_script('sh', '-c',
2043 mkdir_p.format(binfmtdir))
2044 meson.add_install_script('sh', '-c',
2045 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2048 if conf.get('ENABLE_VCONSOLE') == 1
2049 executable('systemd-vconsole-setup',
2050 'src/vconsole/vconsole-setup.c',
2051 include_directories : includes,
2052 link_with : [libshared],
2053 install_rpath : rootlibexecdir,
2055 install_dir : rootlibexecdir)
2058 if conf.get('ENABLE_RANDOMSEED') == 1
2059 executable('systemd-random-seed',
2060 'src/random-seed/random-seed.c',
2061 include_directories : includes,
2062 link_with : [libshared],
2063 install_rpath : rootlibexecdir,
2065 install_dir : rootlibexecdir)
2068 if conf.get('ENABLE_FIRSTBOOT') == 1
2069 executable('systemd-firstboot',
2070 'src/firstboot/firstboot.c',
2071 include_directories : includes,
2072 link_with : [libshared],
2073 dependencies : [libcrypt],
2074 install_rpath : rootlibexecdir,
2076 install_dir : rootbindir)
2079 executable('systemd-remount-fs',
2080 'src/remount-fs/remount-fs.c',
2081 'src/core/mount-setup.c',
2082 'src/core/mount-setup.h',
2083 include_directories : includes,
2084 link_with : [libshared],
2085 install_rpath : rootlibexecdir,
2087 install_dir : rootlibexecdir)
2089 executable('systemd-machine-id-setup',
2090 'src/machine-id-setup/machine-id-setup-main.c',
2091 'src/core/machine-id-setup.c',
2092 'src/core/machine-id-setup.h',
2093 include_directories : includes,
2094 link_with : [libshared],
2095 install_rpath : rootlibexecdir,
2097 install_dir : rootbindir)
2099 executable('systemd-fsck',
2101 include_directories : includes,
2102 link_with : [libshared],
2103 install_rpath : rootlibexecdir,
2105 install_dir : rootlibexecdir)
2107 executable('systemd-growfs',
2108 'src/partition/growfs.c',
2109 include_directories : includes,
2110 link_with : [libshared],
2111 dependencies : [libcryptsetup],
2112 install_rpath : rootlibexecdir,
2114 install_dir : rootlibexecdir)
2116 executable('systemd-makefs',
2117 'src/partition/makefs.c',
2118 include_directories : includes,
2119 link_with : [libshared],
2120 install_rpath : rootlibexecdir,
2122 install_dir : rootlibexecdir)
2124 executable('systemd-sleep',
2125 'src/sleep/sleep.c',
2126 include_directories : includes,
2127 link_with : [libshared],
2128 install_rpath : rootlibexecdir,
2130 install_dir : rootlibexecdir)
2132 exe = executable('systemd-sysctl',
2133 'src/sysctl/sysctl.c',
2134 include_directories : includes,
2135 link_with : [libshared],
2136 install_rpath : rootlibexecdir,
2138 install_dir : rootlibexecdir)
2139 public_programs += [exe]
2141 executable('systemd-ac-power',
2142 'src/ac-power/ac-power.c',
2143 include_directories : includes,
2144 link_with : [libshared],
2145 install_rpath : rootlibexecdir,
2147 install_dir : rootlibexecdir)
2149 exe = executable('systemd-detect-virt',
2150 'src/detect-virt/detect-virt.c',
2151 include_directories : includes,
2152 link_with : [libshared],
2153 install_rpath : rootlibexecdir,
2155 public_programs += [exe]
2157 exe = executable('systemd-delta',
2158 'src/delta/delta.c',
2159 include_directories : includes,
2160 link_with : [libshared],
2161 install_rpath : rootlibexecdir,
2163 public_programs += [exe]
2165 exe = executable('systemd-escape',
2166 'src/escape/escape.c',
2167 include_directories : includes,
2168 link_with : [libshared],
2169 install_rpath : rootlibexecdir,
2171 install_dir : rootbindir)
2172 public_programs += [exe]
2174 exe = executable('systemd-notify',
2175 'src/notify/notify.c',
2176 include_directories : includes,
2177 link_with : [libshared],
2178 install_rpath : rootlibexecdir,
2180 install_dir : rootbindir)
2181 public_programs += [exe]
2183 executable('systemd-volatile-root',
2184 'src/volatile-root/volatile-root.c',
2185 include_directories : includes,
2186 link_with : [libshared],
2187 install_rpath : rootlibexecdir,
2189 install_dir : rootlibexecdir)
2191 executable('systemd-cgroups-agent',
2192 'src/cgroups-agent/cgroups-agent.c',
2193 include_directories : includes,
2194 link_with : [libshared],
2195 install_rpath : rootlibexecdir,
2197 install_dir : rootlibexecdir)
2199 exe = executable('systemd-path',
2201 include_directories : includes,
2202 link_with : [libshared],
2203 install_rpath : rootlibexecdir,
2205 public_programs += [exe]
2207 exe = executable('systemd-ask-password',
2208 'src/ask-password/ask-password.c',
2209 include_directories : includes,
2210 link_with : [libshared],
2211 install_rpath : rootlibexecdir,
2213 install_dir : rootbindir)
2214 public_programs += [exe]
2216 executable('systemd-reply-password',
2217 'src/reply-password/reply-password.c',
2218 include_directories : includes,
2219 link_with : [libshared],
2220 install_rpath : rootlibexecdir,
2222 install_dir : rootlibexecdir)
2224 exe = executable('systemd-tty-ask-password-agent',
2225 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2226 include_directories : includes,
2227 link_with : [libshared],
2228 install_rpath : rootlibexecdir,
2230 install_dir : rootbindir)
2231 public_programs += [exe]
2233 exe = executable('systemd-cgls',
2235 include_directories : includes,
2236 link_with : [libshared],
2237 install_rpath : rootlibexecdir,
2239 public_programs += [exe]
2241 exe = executable('systemd-cgtop',
2242 'src/cgtop/cgtop.c',
2243 include_directories : includes,
2244 link_with : [libshared],
2245 install_rpath : rootlibexecdir,
2247 public_programs += [exe]
2249 executable('systemd-initctl',
2250 'src/initctl/initctl.c',
2251 include_directories : includes,
2252 link_with : [libshared],
2253 install_rpath : rootlibexecdir,
2255 install_dir : rootlibexecdir)
2257 exe = executable('systemd-mount',
2258 'src/mount/mount-tool.c',
2259 include_directories : includes,
2260 link_with : [libshared],
2261 install_rpath : rootlibexecdir,
2263 public_programs += [exe]
2265 meson.add_install_script(meson_make_symlink,
2266 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2268 exe = executable('systemd-run',
2270 include_directories : includes,
2271 link_with : [libshared],
2272 install_rpath : rootlibexecdir,
2274 public_programs += [exe]
2276 exe = executable('systemd-stdio-bridge',
2277 'src/stdio-bridge/stdio-bridge.c',
2278 include_directories : includes,
2279 link_with : [libshared],
2280 install_rpath : rootlibexecdir,
2282 public_programs += [exe]
2284 exe = executable('busctl',
2285 'src/busctl/busctl.c',
2286 'src/busctl/busctl-introspect.c',
2287 'src/busctl/busctl-introspect.h',
2288 include_directories : includes,
2289 link_with : [libshared],
2290 install_rpath : rootlibexecdir,
2292 public_programs += [exe]
2294 if conf.get('ENABLE_SYSUSERS') == 1
2295 exe = executable('systemd-sysusers',
2296 'src/sysusers/sysusers.c',
2297 include_directories : includes,
2298 link_with : [libshared],
2299 install_rpath : rootlibexecdir,
2301 install_dir : rootbindir)
2302 public_programs += [exe]
2305 if conf.get('ENABLE_TMPFILES') == 1
2306 exe = executable('systemd-tmpfiles',
2307 'src/tmpfiles/tmpfiles.c',
2308 include_directories : includes,
2309 link_with : [libshared],
2310 dependencies : [libacl],
2311 install_rpath : rootlibexecdir,
2313 install_dir : rootbindir)
2314 public_programs += [exe]
2316 test('test-systemd-tmpfiles',
2317 test_systemd_tmpfiles_py,
2318 args : exe.full_path())
2319 # https://github.com/mesonbuild/meson/issues/2681
2322 if conf.get('ENABLE_HWDB') == 1
2323 exe = executable('systemd-hwdb',
2325 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2326 include_directories : includes,
2327 link_with : [libudev_static],
2328 install_rpath : udev_rpath,
2330 install_dir : rootbindir)
2331 public_programs += [exe]
2334 if conf.get('ENABLE_QUOTACHECK') == 1
2335 executable('systemd-quotacheck',
2336 'src/quotacheck/quotacheck.c',
2337 include_directories : includes,
2338 link_with : [libshared],
2339 install_rpath : rootlibexecdir,
2341 install_dir : rootlibexecdir)
2344 exe = executable('systemd-socket-proxyd',
2345 'src/socket-proxy/socket-proxyd.c',
2346 include_directories : includes,
2347 link_with : [libshared],
2348 dependencies : [threads],
2349 install_rpath : rootlibexecdir,
2351 install_dir : rootlibexecdir)
2352 public_programs += [exe]
2354 exe = executable('systemd-udevd',
2355 systemd_udevd_sources,
2356 include_directories : includes,
2357 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2358 link_with : [libudev_core,
2361 dependencies : [threads,
2366 install_rpath : udev_rpath,
2368 install_dir : rootlibexecdir)
2369 public_programs += [exe]
2371 exe = executable('udevadm',
2373 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2374 include_directories : includes,
2375 link_with : [libudev_core,
2378 dependencies : [threads,
2383 install_rpath : udev_rpath,
2385 install_dir : rootbindir)
2386 public_programs += [exe]
2388 executable('systemd-shutdown',
2389 systemd_shutdown_sources,
2390 include_directories : includes,
2391 link_with : [libshared],
2392 dependencies : [libmount],
2393 install_rpath : rootlibexecdir,
2395 install_dir : rootlibexecdir)
2397 executable('systemd-update-done',
2398 'src/update-done/update-done.c',
2399 include_directories : includes,
2400 link_with : [libshared],
2401 install_rpath : rootlibexecdir,
2403 install_dir : rootlibexecdir)
2405 executable('systemd-update-utmp',
2406 'src/update-utmp/update-utmp.c',
2407 include_directories : includes,
2408 link_with : [libshared],
2409 dependencies : [libaudit],
2410 install_rpath : rootlibexecdir,
2412 install_dir : rootlibexecdir)
2414 if conf.get('HAVE_KMOD') == 1
2415 executable('systemd-modules-load',
2416 'src/modules-load/modules-load.c',
2417 include_directories : includes,
2418 link_with : [libshared],
2419 dependencies : [libkmod],
2420 install_rpath : rootlibexecdir,
2422 install_dir : rootlibexecdir)
2424 meson.add_install_script('sh', '-c',
2425 mkdir_p.format(modulesloaddir))
2426 meson.add_install_script('sh', '-c',
2427 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2430 exe = executable('systemd-nspawn',
2431 systemd_nspawn_sources,
2432 'src/core/mount-setup.c', # FIXME: use a variable?
2433 'src/core/mount-setup.h',
2434 'src/core/loopback-setup.c',
2435 'src/core/loopback-setup.h',
2436 include_directories : [includes, include_directories('src/nspawn')],
2437 link_with : [libshared],
2438 dependencies : [libacl,
2442 install_rpath : rootlibexecdir,
2444 public_programs += [exe]
2446 if conf.get('ENABLE_NETWORKD') == 1
2447 executable('systemd-networkd',
2448 systemd_networkd_sources,
2449 include_directories : includes,
2450 link_with : [libnetworkd_core,
2454 dependencies : [threads],
2455 install_rpath : rootlibexecdir,
2457 install_dir : rootlibexecdir)
2459 executable('systemd-networkd-wait-online',
2460 systemd_networkd_wait_online_sources,
2461 include_directories : includes,
2462 link_with : [libnetworkd_core,
2464 install_rpath : rootlibexecdir,
2466 install_dir : rootlibexecdir)
2468 exe = executable('networkctl',
2470 include_directories : includes,
2471 link_with : [libsystemd_network,
2473 install_rpath : rootlibexecdir,
2475 install_dir : rootbindir)
2476 public_programs += [exe]
2479 executable('systemd-sulogin-shell',
2480 ['src/sulogin-shell/sulogin-shell.c'],
2481 include_directories : includes,
2482 link_with : [libshared],
2483 install_rpath : rootlibexecdir,
2485 install_dir : rootlibexecdir)
2487 ############################################################
2489 foreach tuple : tests
2491 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2492 dependencies = tuple[2]
2493 condition = tuple.length() >= 4 ? tuple[3] : ''
2494 type = tuple.length() >= 5 ? tuple[4] : ''
2495 defs = tuple.length() >= 6 ? tuple[5] : []
2496 incs = tuple.length() >= 7 ? tuple[6] : includes
2499 name = sources[0].split('/')[-1].split('.')[0]
2500 if type.startswith('timeout=')
2501 timeout = type.split('=')[1].to_int()
2504 if want_tests == 'false'
2505 message('Not compiling @0@ because tests is set to false'.format(name))
2506 elif condition == '' or conf.get(condition) == 1
2510 include_directories : incs,
2511 link_with : link_with,
2512 dependencies : dependencies,
2514 install_rpath : rootlibexecdir,
2515 install : install_tests,
2516 install_dir : join_paths(testsdir, type))
2519 message('@0@ is a manual test'.format(name))
2520 elif type == 'unsafe' and want_tests != 'unsafe'
2521 message('@0@ is an unsafe test'.format(name))
2528 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2532 test_libsystemd_sym = executable(
2533 'test-libsystemd-sym',
2534 test_libsystemd_sym_c,
2535 include_directories : includes,
2536 link_with : [libsystemd],
2537 install : install_tests,
2538 install_dir : testsdir)
2539 test('test-libsystemd-sym',
2540 test_libsystemd_sym)
2542 test_libudev_sym = executable(
2545 include_directories : includes,
2546 c_args : ['-Wno-deprecated-declarations'],
2547 link_with : [libudev],
2548 install : install_tests,
2549 install_dir : testsdir)
2550 test('test-libudev-sym',
2553 ############################################################
2557 foreach tuple : fuzzers
2559 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2560 dependencies = tuple[2]
2561 defs = tuple.length() >= 4 ? tuple[3] : []
2562 incs = tuple.length() >= 5 ? tuple[4] : includes
2565 dependencies += fuzzing_engine
2567 sources += 'src/fuzz/fuzz-main.c'
2570 name = sources[0].split('/')[-1].split('.')[0]
2572 fuzzer_exes += executable(
2575 include_directories : [incs, include_directories('src/fuzz')],
2576 link_with : link_with,
2577 dependencies : dependencies,
2582 run_target('fuzzers',
2583 depends : fuzzer_exes,
2586 ############################################################
2588 make_directive_index_py = find_program('tools/make-directive-index.py')
2589 make_man_index_py = find_program('tools/make-man-index.py')
2590 xml_helper_py = find_program('tools/xml_helper.py')
2591 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2595 subdir('sysusers.d')
2596 subdir('tmpfiles.d')
2601 subdir('shell-completion/bash')
2602 subdir('shell-completion/zsh')
2603 subdir('doc/sysvinit')
2604 subdir('doc/var-log')
2606 # FIXME: figure out if the warning is true:
2607 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2608 install_subdir('factory/etc',
2609 install_dir : factorydir)
2612 install_data('xorg/50-systemd-user.sh',
2613 install_dir : xinitrcdir)
2614 install_data('modprobe.d/systemd.conf',
2615 install_dir : modprobedir)
2616 install_data('LICENSE.GPL2',
2621 'doc/DISTRO_PORTING',
2622 'doc/ENVIRONMENT.md',
2624 'doc/TRANSIENT-SETTINGS.md',
2627 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2628 install_dir : docdir)
2630 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2631 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2633 ############################################################
2635 meson_check_help = find_program('tools/meson-check-help.sh')
2637 foreach exec : public_programs
2638 name = exec.full_path().split('/')[-1]
2639 test('check-help-' + name,
2641 args : [exec.full_path()])
2644 ############################################################
2646 # Enable tests for all supported sanitizers
2647 foreach tuple : sanitizers
2648 sanitizer = tuple[0]
2651 have = run_command(check_compilation_sh,
2652 cc.cmd_array(), '-x', 'c',
2653 '-fsanitize=@0@'.format(sanitizer),
2654 '-include', link_test_c).returncode() == 0
2655 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2659 foreach p : fuzz_regression_tests
2660 b = p.split('/')[-2]
2661 c = p.split('/')[-1]
2663 name = '@0@:@1@'.format(b, sanitizer)
2666 if want_tests == 'false'
2667 message('Not compiling @0@ because tests is set to false'.format(name))
2669 exe = custom_target(
2673 command : [env, 'ln', '-fs',
2674 join_paths(build.full_path(), b),
2676 build_by_default : true)
2678 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2683 if want_tests != 'false' and slow_tests
2684 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2686 args : [exe.full_path(),
2687 join_paths(meson.source_root(),
2688 'test/fuzz-regressions',
2696 ############################################################
2699 all_files = run_command(
2701 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2704 all_files = files(all_files.stdout().split())
2709 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2713 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2717 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2720 command : [meson_git_contrib_sh])
2724 git_head = run_command(
2726 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2727 'rev-parse', 'HEAD']).stdout().strip()
2728 git_head_short = run_command(
2730 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2731 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2735 command : ['git', 'archive',
2736 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2738 '--prefix', 'systemd-@0@/'.format(git_head),
2742 ############################################################
2744 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2747 depends : [man, libsystemd, libudev],
2748 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2750 ############################################################
2753 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2755 'split /usr: @0@'.format(split_usr),
2756 'split bin-sbin: @0@'.format(split_bin),
2757 'prefix directory: @0@'.format(prefixdir),
2758 'rootprefix directory: @0@'.format(rootprefixdir),
2759 'sysconf directory: @0@'.format(sysconfdir),
2760 'include directory: @0@'.format(includedir),
2761 'lib directory: @0@'.format(libdir),
2762 'rootlib directory: @0@'.format(rootlibdir),
2763 'SysV init scripts: @0@'.format(sysvinit_path),
2764 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2765 'PAM modules directory: @0@'.format(pamlibdir),
2766 'PAM configuration directory: @0@'.format(pamconfdir),
2767 'RPM macros directory: @0@'.format(rpmmacrosdir),
2768 'modprobe.d directory: @0@'.format(modprobedir),
2769 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2770 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2771 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2772 'bash completions directory: @0@'.format(bashcompletiondir),
2773 'zsh completions directory: @0@'.format(zshcompletiondir),
2774 'extra start script: @0@'.format(get_option('rc-local')),
2775 'extra stop script: @0@'.format(get_option('halt-local')),
2776 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2777 get_option('debug-tty')),
2778 'TTY GID: @0@'.format(tty_gid),
2779 'users GID: @0@'.format(users_gid),
2780 'maximum system UID: @0@'.format(system_uid_max),
2781 'maximum system GID: @0@'.format(system_gid_max),
2782 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2783 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2784 'minimum container UID base: @0@'.format(container_uid_base_min),
2785 'maximum container UID base: @0@'.format(container_uid_base_max),
2786 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2787 'render group access mode: @0@'.format(get_option('group-render-mode')),
2788 'certificate root directory: @0@'.format(get_option('certificate-root')),
2789 'support URL: @0@'.format(support_url),
2790 'nobody user name: @0@'.format(nobody_user),
2791 'nobody group name: @0@'.format(nobody_group),
2792 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2793 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2795 'default DNSSEC mode: @0@'.format(default_dnssec),
2796 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2797 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2799 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2800 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2802 'default DNS servers: @0@'.format(alt_dns_servers),
2803 'default NTP servers: @0@'.format(alt_ntp_servers)]
2805 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2806 '@@0@'.format(time_epoch)).stdout().strip()
2808 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2811 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2812 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2813 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2815 if conf.get('ENABLE_EFI') == 1
2817 'efi arch: @0@'.format(efi_arch)]
2821 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2822 'EFI CC @0@'.format(efi_cc),
2823 'EFI lib directory: @0@'.format(efi_libdir),
2824 'EFI lds directory: @0@'.format(efi_ldsdir),
2825 'EFI include directory: @0@'.format(efi_incdir)]
2878 ['legacy pkla', install_polkit_pkla],
2880 ['gnu-efi', have_gnu_efi],
2887 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2890 ['man pages', want_man],
2891 ['html pages', want_html],
2892 ['man page indices', want_man and have_lxml],
2897 ['adm group', get_option('adm-group')],
2898 ['wheel group', get_option('wheel-group')],
2901 ['debug mmap cache'],
2904 if tuple.length() >= 2
2907 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2908 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2909 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2914 missing += [tuple[0]]
2920 'enabled features: @0@'.format(', '.join(found)),
2922 'disabled features: @0@'.format(', '.join(missing)),
2924 message('\n '.join(status))
2926 if rootprefixdir != rootprefix_default
2927 message('WARNING:\n' +
2928 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2929 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2930 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))