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 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')
142 docdir = get_option('docdir')
144 docdir = join_paths(datadir, 'doc/systemd')
147 dbuspolicydir = get_option('dbuspolicydir')
148 if dbuspolicydir == ''
149 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
152 dbussessionservicedir = get_option('dbussessionservicedir')
153 if dbussessionservicedir == ''
154 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
157 dbussystemservicedir = get_option('dbussystemservicedir')
158 if dbussystemservicedir == ''
159 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
162 pamlibdir = get_option('pamlibdir')
164 pamlibdir = join_paths(rootlibdir, 'security')
167 pamconfdir = get_option('pamconfdir')
169 pamconfdir = join_paths(sysconfdir, 'pam.d')
172 memory_accounting_default = get_option('memory-accounting-default')
174 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
175 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
176 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
177 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
178 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
179 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
180 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
182 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
184 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
185 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
186 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
187 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
188 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
189 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
190 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
191 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
192 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
193 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
194 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
195 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
196 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
197 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
198 conf.set_quoted('ROOTPREFIX', rootprefixdir)
199 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
200 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
201 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
202 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
203 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
204 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
205 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
206 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
207 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
208 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
209 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
210 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
211 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
212 conf.set_quoted('LIBDIR', libdir)
213 conf.set_quoted('ROOTLIBDIR', rootlibdir)
214 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
215 conf.set_quoted('BOOTLIBDIR', bootlibdir)
216 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
217 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
218 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
219 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
220 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
221 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
222 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
223 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
225 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
226 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
228 substs.set('prefix', prefixdir)
229 substs.set('exec_prefix', prefixdir)
230 substs.set('libdir', libdir)
231 substs.set('rootlibdir', rootlibdir)
232 substs.set('includedir', includedir)
233 substs.set('pkgsysconfdir', pkgsysconfdir)
234 substs.set('bindir', bindir)
235 substs.set('rootbindir', rootbindir)
236 substs.set('rootlibexecdir', rootlibexecdir)
237 substs.set('systemunitdir', systemunitdir)
238 substs.set('userunitdir', userunitdir)
239 substs.set('systempresetdir', systempresetdir)
240 substs.set('userpresetdir', userpresetdir)
241 substs.set('udevhwdbdir', udevhwdbdir)
242 substs.set('udevrulesdir', udevrulesdir)
243 substs.set('udevlibexecdir', udevlibexecdir)
244 substs.set('catalogdir', catalogdir)
245 substs.set('tmpfilesdir', tmpfilesdir)
246 substs.set('sysusersdir', sysusersdir)
247 substs.set('sysctldir', sysctldir)
248 substs.set('binfmtdir', binfmtdir)
249 substs.set('modulesloaddir', modulesloaddir)
250 substs.set('systemgeneratordir', systemgeneratordir)
251 substs.set('usergeneratordir', usergeneratordir)
252 substs.set('systemenvgeneratordir', systemenvgeneratordir)
253 substs.set('userenvgeneratordir', userenvgeneratordir)
254 substs.set('systemshutdowndir', systemshutdowndir)
255 substs.set('systemsleepdir', systemsleepdir)
256 substs.set('VARLOGDIR', varlogdir)
257 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
258 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
259 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
260 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
261 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
262 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
263 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
264 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
266 #####################################################################
268 cc = meson.get_compiler('c')
269 pkgconfig = import('pkgconfig')
270 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
271 meson_build_sh = find_program('tools/meson-build.sh')
273 if get_option('tests') != 'false'
274 cxx = find_program('c++', required : false)
276 # Used only for tests
281 want_ossfuzz = get_option('oss-fuzz')
282 want_libfuzzer = get_option('llvm-fuzz')
283 fuzzer_build = want_ossfuzz or want_libfuzzer
284 if want_ossfuzz and want_libfuzzer
285 error('only one of oss-fuzz and llvm-fuzz can be specified')
288 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
291 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
294 foreach arg : ['-Wextra',
297 '-Wmissing-include-dirs',
298 '-Wold-style-definition',
301 '-Wdeclaration-after-statement',
303 '-Wsuggest-attribute=noreturn',
304 '-Werror=missing-prototypes',
305 '-Werror=implicit-function-declaration',
306 '-Werror=missing-declarations',
307 '-Werror=return-type',
308 '-Werror=incompatible-pointer-types',
310 '-Wstrict-prototypes',
312 '-Wmissing-noreturn',
313 '-Wimplicit-fallthrough=5',
316 '-Wstrict-aliasing=2',
323 '-fdiagnostics-show-option',
324 '-fno-strict-aliasing',
325 '-fvisibility=hidden',
327 '-fstack-protector-strong',
328 '--param=ssp-buffer-size=4',
330 if cc.has_argument(arg)
331 add_project_arguments(arg, language : 'c')
335 # the oss-fuzz fuzzers are not built with -fPIE, so don't
336 # enable it when we are linking against them
338 if cc.has_argument('-fPIE')
339 add_project_arguments('-fPIE', language : 'c')
343 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
344 # arguments, just emits a warnings. So test for the "positive" version instead.
345 foreach arg : ['unused-parameter',
346 'missing-field-initializers',
349 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
351 if cc.has_argument('-W' + arg)
352 add_project_arguments('-Wno-' + arg, language : 'c')
358 #include <inttypes.h>
359 typedef uint64_t usec_t;
360 usec_t now(clockid_t clock);
365 ''', name : '-Werror=shadow with local shadowing')
366 add_project_arguments('-Werror=shadow', language : 'c')
369 if cc.get_id() == 'clang'
370 foreach arg : ['-Wno-typedef-redefinition',
371 '-Wno-gnu-variable-sized-type-not-at-end',
373 if cc.has_argument(arg)
374 add_project_arguments(arg, language : 'c')
379 link_test_c = files('tools/meson-link-test.c')
381 # --as-needed and --no-undefined are provided by meson by default,
382 # run mesonconf to see what is enabled
383 foreach arg : ['-Wl,-z,relro',
388 have = run_command(check_compilation_sh,
389 cc.cmd_array(), '-x', 'c', arg,
390 '-include', link_test_c).returncode() == 0
391 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
392 if have and (arg != '-pie' or not fuzzer_build)
393 add_project_link_arguments(arg, language : 'c')
397 if get_option('buildtype') != 'debug'
398 foreach arg : ['-ffunction-sections',
400 if cc.has_argument(arg)
401 add_project_arguments(arg, language : 'c')
405 foreach arg : ['-Wl,--gc-sections']
406 have = run_command(check_compilation_sh,
407 cc.cmd_array(), '-x', 'c', arg,
408 '-include', link_test_c).returncode() == 0
409 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
411 add_project_link_arguments(arg, language : 'c')
416 cpp = ' '.join(cc.cmd_array()) + ' -E'
418 #####################################################################
419 # compilation result tests
421 conf.set('_GNU_SOURCE', true)
422 conf.set('__SANE_USERSPACE_TYPES__', true)
424 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
425 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
426 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
427 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
428 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
429 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
430 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
434 #include <linux/ethtool.h>
435 #include <linux/fib_rules.h>
436 #include <linux/stat.h>
437 #include <sys/stat.h>
439 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
441 foreach decl : ['char16_t',
444 'struct ethtool_link_settings',
445 'struct fib_rule_uid_range',
449 # We get -1 if the size cannot be determined
450 have = cc.sizeof(decl, prefix : decl_headers) > 0
451 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
454 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
455 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
456 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
457 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
458 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
459 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
460 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
461 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
462 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
463 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
464 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
465 # if_tunnel.h is buggy and cannot be included on its own
466 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
467 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
468 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
469 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
470 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
471 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
472 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
473 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
474 ['NDA_IFINDEX', 'linux/neighbour.h'],
475 ['IFA_FLAGS', 'linux/if_addr.h'],
476 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
477 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
478 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
480 prefix = decl.length() > 2 ? decl[2] : ''
481 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
482 conf.set10('HAVE_' + decl[0], have)
485 foreach ident : ['secure_getenv', '__secure_getenv']
486 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
490 ['memfd_create', '''#include <sys/mman.h>'''],
491 ['gettid', '''#include <sys/types.h>
492 #include <unistd.h>'''],
493 ['pivot_root', '''#include <stdlib.h>
494 #include <unistd.h>'''], # no known header declares pivot_root
495 ['name_to_handle_at', '''#include <sys/types.h>
496 #include <sys/stat.h>
497 #include <fcntl.h>'''],
498 ['setns', '''#include <sched.h>'''],
499 ['renameat2', '''#include <stdio.h>
500 #include <fcntl.h>'''],
501 ['kcmp', '''#include <linux/kcmp.h>'''],
502 ['keyctl', '''#include <sys/types.h>
503 #include <keyutils.h>'''],
504 ['copy_file_range', '''#include <sys/syscall.h>
505 #include <unistd.h>'''],
506 ['bpf', '''#include <sys/syscall.h>
507 #include <unistd.h>'''],
508 ['statx', '''#include <sys/types.h>
509 #include <sys/stat.h>
510 #include <unistd.h>'''],
511 ['explicit_bzero' , '''#include <string.h>'''],
512 ['reallocarray', '''#include <malloc.h>'''],
515 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
516 conf.set10('HAVE_' + ident[0].to_upper(), have)
519 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
520 conf.set10('USE_SYS_RANDOM_H', true)
521 conf.set10('HAVE_GETRANDOM', true)
523 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
524 conf.set10('USE_SYS_RANDOM_H', false)
525 conf.set10('HAVE_GETRANDOM', have)
528 #####################################################################
530 sed = find_program('sed')
531 awk = find_program('awk')
532 m4 = find_program('m4')
533 stat = find_program('stat')
534 git = find_program('git', required : false)
535 env = find_program('env')
536 perl = find_program('perl', required : false)
538 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
539 mkdir_p = 'mkdir -p $DESTDIR/@0@'
540 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
541 splash_bmp = files('test/splash.bmp')
543 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
544 # /usr/sbin, /sbin, and fall back to the default from middle column.
545 progs = [['quotaon', '/usr/sbin/quotaon' ],
546 ['quotacheck', '/usr/sbin/quotacheck' ],
547 ['kmod', '/usr/bin/kmod' ],
548 ['kexec', '/usr/sbin/kexec' ],
549 ['sulogin', '/usr/sbin/sulogin' ],
550 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
551 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
552 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
553 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
556 path = get_option(prog[0] + '-path')
558 message('Using @1@ for @0@'.format(prog[0], path))
560 exe = find_program(prog[0],
561 '/usr/sbin/' + prog[0],
564 path = exe.found() ? exe.path() : prog[1]
566 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
567 conf.set_quoted(name, path)
568 substs.set(name, path)
571 conf.set_quoted('TELINIT', get_option('telinit-path'))
573 if run_command('ln', '--relative', '--help').returncode() != 0
574 error('ln does not support --relative (added in coreutils 8.16)')
577 ############################################################
579 gperf = find_program('gperf')
581 gperf_test_format = '''
583 const char * in_word_set(const char *, @0@);
586 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
587 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
588 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
589 if cc.compiles(gperf_test)
590 gperf_len_type = 'size_t'
592 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
593 if cc.compiles(gperf_test)
594 gperf_len_type = 'unsigned'
596 error('unable to determine gperf len type')
599 message('gperf len type is @0@'.format(gperf_len_type))
600 conf.set('GPERF_LEN_TYPE', gperf_len_type,
601 description : 'The type of gperf "len" parameter')
603 ############################################################
605 if not cc.has_header('sys/capability.h')
606 error('POSIX caps headers not found')
608 foreach header : ['crypt.h',
611 'linux/vm_sockets.h',
613 'valgrind/memcheck.h',
614 'valgrind/valgrind.h',
617 conf.set10('HAVE_' + header.underscorify().to_upper(),
618 cc.has_header(header))
621 ############################################################
623 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
624 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
625 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
627 default_hierarchy = get_option('default-hierarchy')
628 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
629 description : 'default cgroup hierarchy as string')
630 if default_hierarchy == 'legacy'
631 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
632 elif default_hierarchy == 'hybrid'
633 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
635 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
638 time_epoch = get_option('time-epoch')
641 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
643 time_epoch = time_epoch.to_int()
644 conf.set('TIME_EPOCH', time_epoch)
646 system_uid_max = get_option('system-uid-max')
647 if system_uid_max == ''
648 system_uid_max = run_command(
650 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
651 '/etc/login.defs').stdout().strip()
652 if system_uid_max == ''
653 system_uid_max = '999'
656 system_uid_max = system_uid_max.to_int()
657 conf.set('SYSTEM_UID_MAX', system_uid_max)
658 substs.set('systemuidmax', system_uid_max)
659 message('maximum system UID is @0@'.format(system_uid_max))
661 system_gid_max = get_option('system-gid-max')
662 if system_gid_max == ''
663 system_gid_max = run_command(
665 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
666 '/etc/login.defs').stdout().strip()
667 if system_gid_max == ''
668 system_gid_max = '999'
671 system_gid_max = system_gid_max.to_int()
672 conf.set('SYSTEM_GID_MAX', system_gid_max)
673 substs.set('systemgidmax', system_gid_max)
674 message('maximum system GID is @0@'.format(system_gid_max))
676 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
677 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
678 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
679 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
680 substs.set('dynamicuidmin', dynamic_uid_min)
681 substs.set('dynamicuidmax', dynamic_uid_max)
683 container_uid_base_min = get_option('container-uid-base-min').to_int()
684 container_uid_base_max = get_option('container-uid-base-max').to_int()
685 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
686 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
687 substs.set('containeruidbasemin', container_uid_base_min)
688 substs.set('containeruidbasemax', container_uid_base_max)
690 nobody_user = get_option('nobody-user')
691 nobody_group = get_option('nobody-group')
693 getent_result = run_command('getent', 'passwd', '65534')
694 if getent_result.returncode() == 0
695 name = getent_result.stdout().split(':')[0]
696 if name != nobody_user
697 message('WARNING:\n' +
698 ' 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) +
699 ' Your build will result in an user table setup that is incompatible with the local system.')
702 id_result = run_command('id', '-u', nobody_user)
703 if id_result.returncode() == 0
704 id = id_result.stdout().to_int()
706 message('WARNING:\n' +
707 ' 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) +
708 ' Your build will result in an user table setup that is incompatible with the local system.')
712 getent_result = run_command('getent', 'group', '65534')
713 if getent_result.returncode() == 0
714 name = getent_result.stdout().split(':')[0]
715 if name != nobody_group
716 message('WARNING:\n' +
717 ' 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) +
718 ' Your build will result in an group table setup that is incompatible with the local system.')
721 id_result = run_command('id', '-g', nobody_group)
722 if id_result.returncode() == 0
723 id = id_result.stdout().to_int()
725 message('WARNING:\n' +
726 ' 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) +
727 ' Your build will result in an group table setup that is incompatible with the local system.')
730 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
731 message('WARNING:\n' +
732 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
733 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
736 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
737 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
738 substs.set('NOBODY_USER_NAME', nobody_user)
739 substs.set('NOBODY_GROUP_NAME', nobody_group)
741 tty_gid = get_option('tty-gid')
742 conf.set('TTY_GID', tty_gid)
743 substs.set('TTY_GID', tty_gid)
745 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
746 if get_option('users-gid') != ''
747 users_gid = get_option('users-gid').to_int()
751 substs.set('USERS_GID', users_gid)
753 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
754 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
756 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
757 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
759 kill_user_processes = get_option('default-kill-user-processes')
760 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
761 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
762 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
764 dns_servers = get_option('dns-servers')
765 conf.set_quoted('DNS_SERVERS', dns_servers)
766 substs.set('DNS_SERVERS', dns_servers)
768 ntp_servers = get_option('ntp-servers')
769 conf.set_quoted('NTP_SERVERS', ntp_servers)
770 substs.set('NTP_SERVERS', ntp_servers)
772 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
774 substs.set('SUSHELL', get_option('debug-shell'))
775 substs.set('DEBUGTTY', get_option('debug-tty'))
777 debug = get_option('debug')
778 enable_debug_hashmap = false
779 enable_debug_mmap_cache = false
781 foreach name : debug.split(',')
783 enable_debug_hashmap = true
784 elif name == 'mmap-cache'
785 enable_debug_mmap_cache = true
787 message('unknown debug option "@0@", ignoring'.format(name))
791 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
792 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
794 #####################################################################
796 threads = dependency('threads')
797 librt = cc.find_library('rt')
798 libm = cc.find_library('m')
799 libdl = cc.find_library('dl')
800 libcrypt = cc.find_library('crypt')
802 libcap = dependency('libcap', required : false)
803 if not libcap.found()
804 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
805 libcap = cc.find_library('cap')
808 libmount = dependency('mount',
809 version : fuzzer_build ? '>= 0' : '>= 2.30')
811 want_seccomp = get_option('seccomp')
812 if want_seccomp != 'false' and not fuzzer_build
813 libseccomp = dependency('libseccomp',
814 version : '>= 2.3.1',
815 required : want_seccomp == 'true')
816 have = libseccomp.found()
821 conf.set10('HAVE_SECCOMP', have)
823 want_selinux = get_option('selinux')
824 if want_selinux != 'false' and not fuzzer_build
825 libselinux = dependency('libselinux',
826 version : '>= 2.1.9',
827 required : want_selinux == 'true')
828 have = libselinux.found()
833 conf.set10('HAVE_SELINUX', have)
835 want_apparmor = get_option('apparmor')
836 if want_apparmor != 'false' and not fuzzer_build
837 libapparmor = dependency('libapparmor',
838 required : want_apparmor == 'true')
839 have = libapparmor.found()
844 conf.set10('HAVE_APPARMOR', have)
846 smack_run_label = get_option('smack-run-label')
847 if smack_run_label != ''
848 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
851 want_polkit = get_option('polkit')
852 install_polkit = false
853 install_polkit_pkla = false
854 if want_polkit != 'false' and not fuzzer_build
855 install_polkit = true
857 libpolkit = dependency('polkit-gobject-1',
859 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
860 message('Old polkit detected, will install pkla files')
861 install_polkit_pkla = true
864 conf.set10('ENABLE_POLKIT', install_polkit)
866 want_acl = get_option('acl')
867 if want_acl != 'false' and not fuzzer_build
868 libacl = cc.find_library('acl', required : want_acl == 'true')
869 have = libacl.found()
874 conf.set10('HAVE_ACL', have)
876 want_audit = get_option('audit')
877 if want_audit != 'false' and not fuzzer_build
878 libaudit = dependency('audit', required : want_audit == 'true')
879 have = libaudit.found()
884 conf.set10('HAVE_AUDIT', have)
886 want_blkid = get_option('blkid')
887 if want_blkid != 'false' and not fuzzer_build
888 libblkid = dependency('blkid', required : want_blkid == 'true')
889 have = libblkid.found()
894 conf.set10('HAVE_BLKID', have)
896 want_kmod = get_option('kmod')
897 if want_kmod != 'false' and not fuzzer_build
898 libkmod = dependency('libkmod',
900 required : want_kmod == 'true')
901 have = libkmod.found()
906 conf.set10('HAVE_KMOD', have)
908 want_pam = get_option('pam')
909 if want_pam != 'false' and not fuzzer_build
910 libpam = cc.find_library('pam', required : want_pam == 'true')
911 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
912 have = libpam.found() and libpam_misc.found()
918 conf.set10('HAVE_PAM', have)
920 want_microhttpd = get_option('microhttpd')
921 if want_microhttpd != 'false' and not fuzzer_build
922 libmicrohttpd = dependency('libmicrohttpd',
923 version : '>= 0.9.33',
924 required : want_microhttpd == 'true')
925 have = libmicrohttpd.found()
930 conf.set10('HAVE_MICROHTTPD', have)
932 want_libcryptsetup = get_option('libcryptsetup')
933 if want_libcryptsetup != 'false' and not fuzzer_build
934 libcryptsetup = dependency('libcryptsetup',
935 version : '>= 1.6.0',
936 required : want_libcryptsetup == 'true')
937 have = libcryptsetup.found()
942 conf.set10('HAVE_LIBCRYPTSETUP', have)
944 want_libcurl = get_option('libcurl')
945 if want_libcurl != 'false' and not fuzzer_build
946 libcurl = dependency('libcurl',
947 version : '>= 7.32.0',
948 required : want_libcurl == 'true')
949 have = libcurl.found()
954 conf.set10('HAVE_LIBCURL', have)
956 want_libidn = get_option('libidn')
957 want_libidn2 = get_option('libidn2')
958 if want_libidn == 'true' and want_libidn2 == 'true'
959 error('libidn and libidn2 cannot be requested simultaneously')
962 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
963 libidn = dependency('libidn',
964 required : want_libidn == 'true')
965 have = libidn.found()
970 conf.set10('HAVE_LIBIDN', have)
971 if not have and want_libidn2 != 'false' and not fuzzer_build
972 # libidn is used for both libidn and libidn2 objects
973 libidn = dependency('libidn2',
974 required : want_libidn2 == 'true')
975 have = libidn.found()
979 conf.set10('HAVE_LIBIDN2', have)
981 want_libiptc = get_option('libiptc')
982 if want_libiptc != 'false' and not fuzzer_build
983 libiptc = dependency('libiptc',
984 required : want_libiptc == 'true')
985 have = libiptc.found()
990 conf.set10('HAVE_LIBIPTC', have)
992 want_qrencode = get_option('qrencode')
993 if want_qrencode != 'false' and not fuzzer_build
994 libqrencode = dependency('libqrencode',
995 required : want_qrencode == 'true')
996 have = libqrencode.found()
1001 conf.set10('HAVE_QRENCODE', have)
1003 want_gcrypt = get_option('gcrypt')
1004 if want_gcrypt != 'false' and not fuzzer_build
1005 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1006 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1007 have = libgcrypt.found() and libgpg_error.found()
1012 # link to neither of the libs if one is not found
1016 conf.set10('HAVE_GCRYPT', have)
1018 want_gnutls = get_option('gnutls')
1019 if want_gnutls != 'false' and not fuzzer_build
1020 libgnutls = dependency('gnutls',
1021 version : '>= 3.1.4',
1022 required : want_gnutls == 'true')
1023 have = libgnutls.found()
1028 conf.set10('HAVE_GNUTLS', have)
1030 want_elfutils = get_option('elfutils')
1031 if want_elfutils != 'false' and not fuzzer_build
1032 libdw = dependency('libdw',
1033 required : want_elfutils == 'true')
1034 have = libdw.found()
1039 conf.set10('HAVE_ELFUTILS', have)
1041 want_zlib = get_option('zlib')
1042 if want_zlib != 'false' and not fuzzer_build
1043 libz = dependency('zlib',
1044 required : want_zlib == 'true')
1050 conf.set10('HAVE_ZLIB', have)
1052 want_bzip2 = get_option('bzip2')
1053 if want_bzip2 != 'false' and not fuzzer_build
1054 libbzip2 = cc.find_library('bz2',
1055 required : want_bzip2 == 'true')
1056 have = libbzip2.found()
1061 conf.set10('HAVE_BZIP2', have)
1063 want_xz = get_option('xz')
1064 if want_xz != 'false' and not fuzzer_build
1065 libxz = dependency('liblzma',
1066 required : want_xz == 'true')
1067 have = libxz.found()
1072 conf.set10('HAVE_XZ', have)
1074 want_lz4 = get_option('lz4')
1075 if want_lz4 != 'false' and not fuzzer_build
1076 liblz4 = dependency('liblz4',
1077 required : want_lz4 == 'true')
1078 have = liblz4.found()
1083 conf.set10('HAVE_LZ4', have)
1085 want_xkbcommon = get_option('xkbcommon')
1086 if want_xkbcommon != 'false' and not fuzzer_build
1087 libxkbcommon = dependency('xkbcommon',
1088 version : '>= 0.3.0',
1089 required : want_xkbcommon == 'true')
1090 have = libxkbcommon.found()
1095 conf.set10('HAVE_XKBCOMMON', have)
1097 want_pcre2 = get_option('pcre2')
1098 if want_pcre2 != 'false'
1099 libpcre2 = dependency('libpcre2-8',
1100 required : want_pcre2 == 'true')
1101 have = libpcre2.found()
1106 conf.set10('HAVE_PCRE2', have)
1108 want_glib = get_option('glib')
1109 if want_glib != 'false' and not fuzzer_build
1110 libglib = dependency('glib-2.0',
1111 version : '>= 2.22.0',
1112 required : want_glib == 'true')
1113 libgobject = dependency('gobject-2.0',
1114 version : '>= 2.22.0',
1115 required : want_glib == 'true')
1116 libgio = dependency('gio-2.0',
1117 required : want_glib == 'true')
1118 have = libglib.found() and libgobject.found() and libgio.found()
1125 conf.set10('HAVE_GLIB', have)
1127 want_dbus = get_option('dbus')
1128 if want_dbus != 'false' and not fuzzer_build
1129 libdbus = dependency('dbus-1',
1130 version : '>= 1.3.2',
1131 required : want_dbus == 'true')
1132 have = libdbus.found()
1137 conf.set10('HAVE_DBUS', have)
1139 default_dnssec = get_option('default-dnssec')
1141 default_dnssec = 'no'
1143 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1144 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1145 default_dnssec = 'no'
1147 conf.set('DEFAULT_DNSSEC_MODE',
1148 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1149 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1151 want_importd = get_option('importd')
1152 if want_importd != 'false'
1153 have = (conf.get('HAVE_LIBCURL') == 1 and
1154 conf.get('HAVE_ZLIB') == 1 and
1155 conf.get('HAVE_BZIP2') == 1 and
1156 conf.get('HAVE_XZ') == 1 and
1157 conf.get('HAVE_GCRYPT') == 1)
1158 if want_importd == 'true' and not have
1159 error('importd support was requested, but dependencies are not available')
1164 conf.set10('ENABLE_IMPORTD', have)
1166 want_remote = get_option('remote')
1167 if want_remote != 'false'
1168 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1169 conf.get('HAVE_LIBCURL') == 1]
1170 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1171 # it's possible to build one without the other. Complain only if
1172 # support was explictly requested. The auxiliary files like sysusers
1173 # config should be installed when any of the programs are built.
1174 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1175 error('remote support was requested, but dependencies are not available')
1177 have = have_deps[0] or have_deps[1]
1181 conf.set10('ENABLE_REMOTE', have)
1183 foreach term : ['utmp',
1214 have = get_option(term)
1215 name = 'ENABLE_' + term.underscorify().to_upper()
1216 conf.set10(name, have)
1219 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1221 want_tests = get_option('tests')
1222 install_tests = get_option('install-tests')
1223 slow_tests = get_option('slow-tests')
1227 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1229 #####################################################################
1231 if get_option('efi')
1232 efi_arch = host_machine.cpu_family()
1234 if efi_arch == 'x86'
1235 EFI_MACHINE_TYPE_NAME = 'ia32'
1236 gnu_efi_arch = 'ia32'
1237 elif efi_arch == 'x86_64'
1238 EFI_MACHINE_TYPE_NAME = 'x64'
1239 gnu_efi_arch = 'x86_64'
1240 elif efi_arch == 'arm'
1241 EFI_MACHINE_TYPE_NAME = 'arm'
1242 gnu_efi_arch = 'arm'
1243 elif efi_arch == 'aarch64'
1244 EFI_MACHINE_TYPE_NAME = 'aa64'
1245 gnu_efi_arch = 'aarch64'
1247 EFI_MACHINE_TYPE_NAME = ''
1252 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1254 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1258 conf.set10('ENABLE_EFI', have)
1260 #####################################################################
1262 config_h = configure_file(
1263 output : 'config.h',
1264 configuration : conf)
1266 meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1268 includes = include_directories('src/basic',
1274 'src/time-wait-sync',
1279 'src/libsystemd/sd-bus',
1280 'src/libsystemd/sd-device',
1281 'src/libsystemd/sd-hwdb',
1282 'src/libsystemd/sd-id128',
1283 'src/libsystemd/sd-netlink',
1284 'src/libsystemd/sd-network',
1285 'src/libsystemd-network',
1288 add_project_arguments('-include', 'config.h', language : 'c')
1292 subdir('src/systemd')
1294 subdir('src/libsystemd')
1295 subdir('src/libsystemd-network')
1296 subdir('src/journal')
1299 libjournal_core = static_library(
1301 libjournal_core_sources,
1303 include_directories : includes,
1306 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1307 libsystemd = shared_library(
1309 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1310 version : libsystemd_version,
1311 include_directories : includes,
1312 link_args : ['-shared',
1313 '-Wl,--version-script=' + libsystemd_sym_path],
1314 link_with : [libbasic,
1316 link_whole : [libsystemd_static,
1318 dependencies : [threads,
1322 link_depends : libsystemd_sym,
1324 install_dir : rootlibdir)
1326 ############################################################
1328 # binaries that have --help and are intended for use by humans,
1329 # usually, but not always, installed in /bin.
1330 public_programs = []
1332 subdir('src/libudev')
1333 subdir('src/shared')
1336 subdir('src/network')
1338 subdir('src/analyze')
1339 subdir('src/journal-remote')
1340 subdir('src/coredump')
1341 subdir('src/hostname')
1342 subdir('src/import')
1343 subdir('src/kernel-install')
1344 subdir('src/locale')
1345 subdir('src/machine')
1346 subdir('src/nspawn')
1347 subdir('src/resolve')
1348 subdir('src/timedate')
1349 subdir('src/timesync')
1350 subdir('src/vconsole')
1351 subdir('src/boot/efi')
1358 ############################################################
1360 # only static linking apart from libdl, to make sure that the
1361 # module is linked to all libraries that it uses.
1362 test_dlopen = executable(
1365 include_directories : includes,
1366 link_with : [libbasic],
1367 dependencies : [libdl])
1369 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1370 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1371 ['mymachines', 'ENABLE_MACHINED'],
1372 ['resolve', 'ENABLE_RESOLVE']]
1374 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1378 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1379 version_script_arg = join_paths(meson.current_source_dir(), sym)
1381 nss = shared_library(
1383 'src/nss-@0@/nss-@0@.c'.format(module),
1385 include_directories : includes,
1386 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1387 link_args : ['-Wl,-z,nodelete',
1389 '-Wl,--version-script=' + version_script_arg,
1391 link_with : [libsystemd_static,
1393 dependencies : [threads,
1397 install_dir : rootlibdir)
1399 # We cannot use shared_module because it does not support version suffix.
1400 # Unfortunately shared_library insists on creating the symlink…
1401 meson.add_install_script('sh', '-c',
1402 'rm $DESTDIR@0@/libnss_@1@.so'
1403 .format(rootlibdir, module))
1405 test('dlopen-nss_' + module,
1407 args : [nss.full_path()]) # path to dlopen must include a slash
1411 ############################################################
1413 executable('systemd',
1415 include_directories : includes,
1416 link_with : [libcore,
1418 dependencies : [threads,
1424 install_rpath : rootlibexecdir,
1426 install_dir : rootlibexecdir)
1428 meson.add_install_script(meson_make_symlink,
1429 join_paths(rootlibexecdir, 'systemd'),
1430 join_paths(rootsbindir, 'init'))
1432 exe = executable('systemd-analyze',
1433 systemd_analyze_sources,
1434 include_directories : includes,
1435 link_with : [libcore,
1437 dependencies : [threads,
1443 install_rpath : rootlibexecdir,
1445 public_programs += [exe]
1447 executable('systemd-journald',
1448 systemd_journald_sources,
1449 include_directories : includes,
1450 link_with : [libjournal_core,
1452 dependencies : [threads,
1456 install_rpath : rootlibexecdir,
1458 install_dir : rootlibexecdir)
1460 exe = executable('systemd-cat',
1461 systemd_cat_sources,
1462 include_directories : includes,
1463 link_with : [libjournal_core,
1465 dependencies : [threads],
1466 install_rpath : rootlibexecdir,
1468 public_programs += [exe]
1470 exe = executable('journalctl',
1472 include_directories : includes,
1473 link_with : [libshared],
1474 dependencies : [threads,
1479 install_rpath : rootlibexecdir,
1481 install_dir : rootbindir)
1482 public_programs += [exe]
1484 executable('systemd-getty-generator',
1485 'src/getty-generator/getty-generator.c',
1486 include_directories : includes,
1487 link_with : [libshared],
1488 install_rpath : rootlibexecdir,
1490 install_dir : systemgeneratordir)
1492 executable('systemd-debug-generator',
1493 'src/debug-generator/debug-generator.c',
1494 include_directories : includes,
1495 link_with : [libshared],
1496 install_rpath : rootlibexecdir,
1498 install_dir : systemgeneratordir)
1500 executable('systemd-fstab-generator',
1501 'src/fstab-generator/fstab-generator.c',
1502 'src/core/mount-setup.c',
1503 include_directories : includes,
1504 link_with : [libshared],
1505 install_rpath : rootlibexecdir,
1507 install_dir : systemgeneratordir)
1509 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1510 executable('30-systemd-environment-d-generator',
1511 'src/environment-d-generator/environment-d-generator.c',
1512 include_directories : includes,
1513 link_with : [libshared],
1514 install_rpath : rootlibexecdir,
1516 install_dir : userenvgeneratordir)
1518 meson.add_install_script(meson_make_symlink,
1519 join_paths(sysconfdir, 'environment'),
1520 join_paths(environmentdir, '99-environment.conf'))
1523 if conf.get('ENABLE_HIBERNATE') == 1
1524 executable('systemd-hibernate-resume-generator',
1525 'src/hibernate-resume/hibernate-resume-generator.c',
1526 include_directories : includes,
1527 link_with : [libshared],
1528 install_rpath : rootlibexecdir,
1530 install_dir : systemgeneratordir)
1532 executable('systemd-hibernate-resume',
1533 'src/hibernate-resume/hibernate-resume.c',
1534 include_directories : includes,
1535 link_with : [libshared],
1536 install_rpath : rootlibexecdir,
1538 install_dir : rootlibexecdir)
1541 if conf.get('HAVE_BLKID') == 1
1542 executable('systemd-gpt-auto-generator',
1543 'src/gpt-auto-generator/gpt-auto-generator.c',
1544 'src/basic/blkid-util.h',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 dependencies : libblkid,
1548 install_rpath : rootlibexecdir,
1550 install_dir : systemgeneratordir)
1552 exe = executable('systemd-dissect',
1553 'src/dissect/dissect.c',
1554 include_directories : includes,
1555 link_with : [libshared],
1556 install_rpath : rootlibexecdir,
1558 install_dir : rootlibexecdir)
1559 public_programs += [exe]
1562 if conf.get('ENABLE_RESOLVE') == 1
1563 executable('systemd-resolved',
1564 systemd_resolved_sources,
1565 include_directories : includes,
1566 link_with : [libshared,
1568 libsystemd_resolve_core],
1569 dependencies : [threads,
1573 install_rpath : rootlibexecdir,
1575 install_dir : rootlibexecdir)
1577 exe = executable('resolvectl',
1579 include_directories : includes,
1580 link_with : [libshared,
1582 libsystemd_resolve_core],
1583 dependencies : [threads,
1587 install_rpath : rootlibexecdir,
1589 public_programs += [exe]
1591 meson.add_install_script(meson_make_symlink,
1592 join_paths(bindir, 'resolvectl'),
1593 join_paths(rootsbindir, 'resolvconf'))
1595 meson.add_install_script(meson_make_symlink,
1596 join_paths(bindir, 'resolvectl'),
1597 join_paths(bindir, 'systemd-resolve'))
1600 if conf.get('ENABLE_LOGIND') == 1
1601 executable('systemd-logind',
1602 systemd_logind_sources,
1603 include_directories : includes,
1604 link_with : [liblogind_core,
1606 dependencies : [threads,
1608 install_rpath : rootlibexecdir,
1610 install_dir : rootlibexecdir)
1612 exe = executable('loginctl',
1614 include_directories : includes,
1615 link_with : [libshared],
1616 dependencies : [threads,
1619 install_rpath : rootlibexecdir,
1621 install_dir : rootbindir)
1622 public_programs += [exe]
1624 exe = executable('systemd-inhibit',
1625 'src/login/inhibit.c',
1626 include_directories : includes,
1627 link_with : [libshared],
1628 install_rpath : rootlibexecdir,
1630 install_dir : rootbindir)
1631 public_programs += [exe]
1633 if conf.get('HAVE_PAM') == 1
1634 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1635 pam_systemd = shared_library(
1639 include_directories : includes,
1640 link_args : ['-shared',
1641 '-Wl,--version-script=' + version_script_arg],
1642 link_with : [libsystemd_static,
1644 dependencies : [threads,
1647 link_depends : pam_systemd_sym,
1649 install_dir : pamlibdir)
1651 test('dlopen-pam_systemd',
1653 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1657 executable('systemd-user-runtime-dir',
1658 user_runtime_dir_sources,
1659 include_directories : includes,
1660 link_with : [libshared, liblogind_core],
1661 install_rpath : rootlibexecdir,
1663 install_dir : rootlibexecdir)
1665 if conf.get('HAVE_PAM') == 1
1666 executable('systemd-user-sessions',
1667 'src/user-sessions/user-sessions.c',
1668 include_directories : includes,
1669 link_with : [libshared],
1670 install_rpath : rootlibexecdir,
1672 install_dir : rootlibexecdir)
1675 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1676 exe = executable('bootctl',
1677 'src/boot/bootctl.c',
1678 include_directories : includes,
1679 link_with : [libshared],
1680 dependencies : [libblkid],
1681 install_rpath : rootlibexecdir,
1683 public_programs += [exe]
1686 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1687 include_directories : includes,
1688 link_with : [libshared],
1689 dependencies : [threads],
1690 install_rpath : rootlibexecdir,
1692 public_programs += [exe]
1694 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1695 include_directories : includes,
1696 link_with : [libshared],
1697 dependencies : [threads,
1702 install_rpath : rootlibexecdir,
1704 install_dir : rootbindir)
1705 public_programs += [exe]
1707 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1708 meson.add_install_script(meson_make_symlink,
1709 join_paths(rootbindir, 'systemctl'),
1710 join_paths(rootsbindir, alias))
1713 if conf.get('ENABLE_BACKLIGHT') == 1
1714 executable('systemd-backlight',
1715 'src/backlight/backlight.c',
1716 include_directories : includes,
1717 link_with : [libshared],
1718 install_rpath : rootlibexecdir,
1720 install_dir : rootlibexecdir)
1723 if conf.get('ENABLE_RFKILL') == 1
1724 executable('systemd-rfkill',
1725 'src/rfkill/rfkill.c',
1726 include_directories : includes,
1727 link_with : [libshared],
1728 install_rpath : rootlibexecdir,
1730 install_dir : rootlibexecdir)
1733 executable('systemd-system-update-generator',
1734 'src/system-update-generator/system-update-generator.c',
1735 include_directories : includes,
1736 link_with : [libshared],
1737 install_rpath : rootlibexecdir,
1739 install_dir : systemgeneratordir)
1741 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1742 executable('systemd-cryptsetup',
1743 'src/cryptsetup/cryptsetup.c',
1744 include_directories : includes,
1745 link_with : [libshared],
1746 dependencies : [libcryptsetup],
1747 install_rpath : rootlibexecdir,
1749 install_dir : rootlibexecdir)
1751 executable('systemd-cryptsetup-generator',
1752 'src/cryptsetup/cryptsetup-generator.c',
1753 include_directories : includes,
1754 link_with : [libshared],
1755 dependencies : [libcryptsetup],
1756 install_rpath : rootlibexecdir,
1758 install_dir : systemgeneratordir)
1760 executable('systemd-veritysetup',
1761 'src/veritysetup/veritysetup.c',
1762 include_directories : includes,
1763 link_with : [libshared],
1764 dependencies : [libcryptsetup],
1765 install_rpath : rootlibexecdir,
1767 install_dir : rootlibexecdir)
1769 executable('systemd-veritysetup-generator',
1770 'src/veritysetup/veritysetup-generator.c',
1771 include_directories : includes,
1772 link_with : [libshared],
1773 dependencies : [libcryptsetup],
1774 install_rpath : rootlibexecdir,
1776 install_dir : systemgeneratordir)
1779 if conf.get('HAVE_SYSV_COMPAT') == 1
1780 executable('systemd-sysv-generator',
1781 'src/sysv-generator/sysv-generator.c',
1782 include_directories : includes,
1783 link_with : [libshared],
1784 install_rpath : rootlibexecdir,
1786 install_dir : systemgeneratordir)
1788 executable('systemd-rc-local-generator',
1789 'src/rc-local-generator/rc-local-generator.c',
1790 include_directories : includes,
1791 link_with : [libshared],
1792 install_rpath : rootlibexecdir,
1794 install_dir : systemgeneratordir)
1797 if conf.get('ENABLE_HOSTNAMED') == 1
1798 executable('systemd-hostnamed',
1799 'src/hostname/hostnamed.c',
1800 include_directories : includes,
1801 link_with : [libshared],
1802 install_rpath : rootlibexecdir,
1804 install_dir : rootlibexecdir)
1806 exe = executable('hostnamectl',
1807 'src/hostname/hostnamectl.c',
1808 include_directories : includes,
1809 link_with : [libshared],
1810 install_rpath : rootlibexecdir,
1812 public_programs += [exe]
1815 if conf.get('ENABLE_LOCALED') == 1
1816 if conf.get('HAVE_XKBCOMMON') == 1
1817 # logind will load libxkbcommon.so dynamically on its own
1823 executable('systemd-localed',
1824 systemd_localed_sources,
1825 include_directories : includes,
1826 link_with : [libshared],
1827 dependencies : deps,
1828 install_rpath : rootlibexecdir,
1830 install_dir : rootlibexecdir)
1832 exe = executable('localectl',
1834 include_directories : includes,
1835 link_with : [libshared],
1836 install_rpath : rootlibexecdir,
1838 public_programs += [exe]
1841 if conf.get('ENABLE_TIMEDATED') == 1
1842 executable('systemd-timedated',
1843 'src/timedate/timedated.c',
1844 include_directories : includes,
1845 link_with : [libshared],
1846 install_rpath : rootlibexecdir,
1848 install_dir : rootlibexecdir)
1851 if conf.get('ENABLE_TIMEDATECTL') == 1
1852 exe = executable('timedatectl',
1853 'src/timedate/timedatectl.c',
1854 include_directories : includes,
1855 install_rpath : rootlibexecdir,
1856 link_with : [libshared],
1857 dependencies : [libm],
1859 public_programs += [exe]
1862 if conf.get('ENABLE_TIMESYNCD') == 1
1863 executable('systemd-timesyncd',
1864 systemd_timesyncd_sources,
1865 include_directories : includes,
1866 link_with : [libshared],
1867 dependencies : [threads,
1869 install_rpath : rootlibexecdir,
1871 install_dir : rootlibexecdir)
1873 executable('systemd-time-wait-sync',
1874 'src/time-wait-sync/time-wait-sync.c',
1875 include_directories : includes,
1876 link_with : [libshared],
1877 install_rpath : rootlibexecdir,
1879 install_dir : rootlibexecdir)
1882 if conf.get('ENABLE_MACHINED') == 1
1883 executable('systemd-machined',
1884 systemd_machined_sources,
1885 include_directories : includes,
1886 link_with : [libmachine_core,
1888 install_rpath : rootlibexecdir,
1890 install_dir : rootlibexecdir)
1892 exe = executable('machinectl',
1893 'src/machine/machinectl.c',
1894 include_directories : includes,
1895 link_with : [libshared],
1896 dependencies : [threads,
1899 install_rpath : rootlibexecdir,
1901 install_dir : rootbindir)
1902 public_programs += [exe]
1905 if conf.get('ENABLE_IMPORTD') == 1
1906 executable('systemd-importd',
1907 systemd_importd_sources,
1908 include_directories : includes,
1909 link_with : [libshared],
1910 dependencies : [threads],
1911 install_rpath : rootlibexecdir,
1913 install_dir : rootlibexecdir)
1915 systemd_pull = executable('systemd-pull',
1916 systemd_pull_sources,
1917 include_directories : includes,
1918 link_with : [libshared],
1919 dependencies : [libcurl,
1924 install_rpath : rootlibexecdir,
1926 install_dir : rootlibexecdir)
1928 systemd_import = executable('systemd-import',
1929 systemd_import_sources,
1930 include_directories : includes,
1931 link_with : [libshared],
1932 dependencies : [libcurl,
1936 install_rpath : rootlibexecdir,
1938 install_dir : rootlibexecdir)
1940 systemd_export = executable('systemd-export',
1941 systemd_export_sources,
1942 include_directories : includes,
1943 link_with : [libshared],
1944 dependencies : [libcurl,
1948 install_rpath : rootlibexecdir,
1950 install_dir : rootlibexecdir)
1951 public_programs += [systemd_pull, systemd_import, systemd_export]
1954 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1955 exe = executable('systemd-journal-upload',
1956 systemd_journal_upload_sources,
1957 include_directories : includes,
1958 link_with : [libshared],
1959 dependencies : [threads,
1964 install_rpath : rootlibexecdir,
1966 install_dir : rootlibexecdir)
1967 public_programs += [exe]
1970 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1971 s_j_remote = executable('systemd-journal-remote',
1972 systemd_journal_remote_sources,
1973 include_directories : includes,
1974 link_with : [libshared],
1975 dependencies : [threads,
1980 install_rpath : rootlibexecdir,
1982 install_dir : rootlibexecdir)
1984 s_j_gatewayd = executable('systemd-journal-gatewayd',
1985 systemd_journal_gatewayd_sources,
1986 include_directories : includes,
1987 link_with : [libshared],
1988 dependencies : [threads,
1993 install_rpath : rootlibexecdir,
1995 install_dir : rootlibexecdir)
1996 public_programs += [s_j_remote, s_j_gatewayd]
1999 if conf.get('ENABLE_COREDUMP') == 1
2000 executable('systemd-coredump',
2001 systemd_coredump_sources,
2002 include_directories : includes,
2003 link_with : [libshared],
2004 dependencies : [threads,
2009 install_rpath : rootlibexecdir,
2011 install_dir : rootlibexecdir)
2013 exe = executable('coredumpctl',
2014 coredumpctl_sources,
2015 include_directories : includes,
2016 link_with : [libshared],
2017 dependencies : [threads,
2020 install_rpath : rootlibexecdir,
2022 public_programs += [exe]
2025 if conf.get('ENABLE_BINFMT') == 1
2026 exe = executable('systemd-binfmt',
2027 'src/binfmt/binfmt.c',
2028 include_directories : includes,
2029 link_with : [libshared],
2030 install_rpath : rootlibexecdir,
2032 install_dir : rootlibexecdir)
2033 public_programs += [exe]
2035 meson.add_install_script('sh', '-c',
2036 mkdir_p.format(binfmtdir))
2037 meson.add_install_script('sh', '-c',
2038 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2041 if conf.get('ENABLE_VCONSOLE') == 1
2042 executable('systemd-vconsole-setup',
2043 'src/vconsole/vconsole-setup.c',
2044 include_directories : includes,
2045 link_with : [libshared],
2046 install_rpath : rootlibexecdir,
2048 install_dir : rootlibexecdir)
2051 if conf.get('ENABLE_RANDOMSEED') == 1
2052 executable('systemd-random-seed',
2053 'src/random-seed/random-seed.c',
2054 include_directories : includes,
2055 link_with : [libshared],
2056 install_rpath : rootlibexecdir,
2058 install_dir : rootlibexecdir)
2061 if conf.get('ENABLE_FIRSTBOOT') == 1
2062 executable('systemd-firstboot',
2063 'src/firstboot/firstboot.c',
2064 include_directories : includes,
2065 link_with : [libshared],
2066 dependencies : [libcrypt],
2067 install_rpath : rootlibexecdir,
2069 install_dir : rootbindir)
2072 executable('systemd-remount-fs',
2073 'src/remount-fs/remount-fs.c',
2074 'src/core/mount-setup.c',
2075 'src/core/mount-setup.h',
2076 include_directories : includes,
2077 link_with : [libshared],
2078 install_rpath : rootlibexecdir,
2080 install_dir : rootlibexecdir)
2082 executable('systemd-machine-id-setup',
2083 'src/machine-id-setup/machine-id-setup-main.c',
2084 'src/core/machine-id-setup.c',
2085 'src/core/machine-id-setup.h',
2086 include_directories : includes,
2087 link_with : [libshared],
2088 install_rpath : rootlibexecdir,
2090 install_dir : rootbindir)
2092 executable('systemd-fsck',
2094 include_directories : includes,
2095 link_with : [libshared],
2096 install_rpath : rootlibexecdir,
2098 install_dir : rootlibexecdir)
2100 executable('systemd-growfs',
2101 'src/partition/growfs.c',
2102 include_directories : includes,
2103 link_with : [libshared],
2104 dependencies : [libcryptsetup],
2105 install_rpath : rootlibexecdir,
2107 install_dir : rootlibexecdir)
2109 executable('systemd-makefs',
2110 'src/partition/makefs.c',
2111 include_directories : includes,
2112 link_with : [libshared],
2113 install_rpath : rootlibexecdir,
2115 install_dir : rootlibexecdir)
2117 executable('systemd-sleep',
2118 'src/sleep/sleep.c',
2119 include_directories : includes,
2120 link_with : [libshared],
2121 install_rpath : rootlibexecdir,
2123 install_dir : rootlibexecdir)
2125 exe = executable('systemd-sysctl',
2126 'src/sysctl/sysctl.c',
2127 include_directories : includes,
2128 link_with : [libshared],
2129 install_rpath : rootlibexecdir,
2131 install_dir : rootlibexecdir)
2132 public_programs += [exe]
2134 executable('systemd-ac-power',
2135 'src/ac-power/ac-power.c',
2136 include_directories : includes,
2137 link_with : [libshared],
2138 install_rpath : rootlibexecdir,
2140 install_dir : rootlibexecdir)
2142 exe = executable('systemd-detect-virt',
2143 'src/detect-virt/detect-virt.c',
2144 include_directories : includes,
2145 link_with : [libshared],
2146 install_rpath : rootlibexecdir,
2148 public_programs += [exe]
2150 exe = executable('systemd-delta',
2151 'src/delta/delta.c',
2152 include_directories : includes,
2153 link_with : [libshared],
2154 install_rpath : rootlibexecdir,
2156 public_programs += [exe]
2158 exe = executable('systemd-escape',
2159 'src/escape/escape.c',
2160 include_directories : includes,
2161 link_with : [libshared],
2162 install_rpath : rootlibexecdir,
2164 install_dir : rootbindir)
2165 public_programs += [exe]
2167 exe = executable('systemd-notify',
2168 'src/notify/notify.c',
2169 include_directories : includes,
2170 link_with : [libshared],
2171 install_rpath : rootlibexecdir,
2173 install_dir : rootbindir)
2174 public_programs += [exe]
2176 executable('systemd-volatile-root',
2177 'src/volatile-root/volatile-root.c',
2178 include_directories : includes,
2179 link_with : [libshared],
2180 install_rpath : rootlibexecdir,
2182 install_dir : rootlibexecdir)
2184 executable('systemd-cgroups-agent',
2185 'src/cgroups-agent/cgroups-agent.c',
2186 include_directories : includes,
2187 link_with : [libshared],
2188 install_rpath : rootlibexecdir,
2190 install_dir : rootlibexecdir)
2192 exe = executable('systemd-path',
2194 include_directories : includes,
2195 link_with : [libshared],
2196 install_rpath : rootlibexecdir,
2198 public_programs += [exe]
2200 exe = executable('systemd-ask-password',
2201 'src/ask-password/ask-password.c',
2202 include_directories : includes,
2203 link_with : [libshared],
2204 install_rpath : rootlibexecdir,
2206 install_dir : rootbindir)
2207 public_programs += [exe]
2209 executable('systemd-reply-password',
2210 'src/reply-password/reply-password.c',
2211 include_directories : includes,
2212 link_with : [libshared],
2213 install_rpath : rootlibexecdir,
2215 install_dir : rootlibexecdir)
2217 exe = executable('systemd-tty-ask-password-agent',
2218 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2219 include_directories : includes,
2220 link_with : [libshared],
2221 install_rpath : rootlibexecdir,
2223 install_dir : rootbindir)
2224 public_programs += [exe]
2226 exe = executable('systemd-cgls',
2228 include_directories : includes,
2229 link_with : [libshared],
2230 install_rpath : rootlibexecdir,
2232 public_programs += [exe]
2234 exe = executable('systemd-cgtop',
2235 'src/cgtop/cgtop.c',
2236 include_directories : includes,
2237 link_with : [libshared],
2238 install_rpath : rootlibexecdir,
2240 public_programs += [exe]
2242 executable('systemd-initctl',
2243 'src/initctl/initctl.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2248 install_dir : rootlibexecdir)
2250 exe = executable('systemd-mount',
2251 'src/mount/mount-tool.c',
2252 include_directories : includes,
2253 link_with : [libshared],
2254 install_rpath : rootlibexecdir,
2256 public_programs += [exe]
2258 meson.add_install_script(meson_make_symlink,
2259 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2261 exe = executable('systemd-run',
2263 include_directories : includes,
2264 link_with : [libshared],
2265 install_rpath : rootlibexecdir,
2267 public_programs += [exe]
2269 exe = executable('systemd-stdio-bridge',
2270 'src/stdio-bridge/stdio-bridge.c',
2271 include_directories : includes,
2272 link_with : [libshared],
2273 install_rpath : rootlibexecdir,
2275 public_programs += [exe]
2277 exe = executable('busctl',
2278 'src/busctl/busctl.c',
2279 'src/busctl/busctl-introspect.c',
2280 'src/busctl/busctl-introspect.h',
2281 include_directories : includes,
2282 link_with : [libshared],
2283 install_rpath : rootlibexecdir,
2285 public_programs += [exe]
2287 if conf.get('ENABLE_SYSUSERS') == 1
2288 exe = executable('systemd-sysusers',
2289 'src/sysusers/sysusers.c',
2290 include_directories : includes,
2291 link_with : [libshared],
2292 install_rpath : rootlibexecdir,
2294 install_dir : rootbindir)
2295 public_programs += [exe]
2298 if conf.get('ENABLE_TMPFILES') == 1
2299 exe = executable('systemd-tmpfiles',
2300 'src/tmpfiles/tmpfiles.c',
2301 include_directories : includes,
2302 link_with : [libshared],
2303 dependencies : [libacl],
2304 install_rpath : rootlibexecdir,
2306 install_dir : rootbindir)
2307 public_programs += [exe]
2309 test('test-systemd-tmpfiles',
2310 test_systemd_tmpfiles_py,
2311 args : exe.full_path())
2312 # https://github.com/mesonbuild/meson/issues/2681
2315 if conf.get('ENABLE_HWDB') == 1
2316 exe = executable('systemd-hwdb',
2318 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2319 include_directories : includes,
2320 link_with : [libudev_static],
2321 install_rpath : udev_rpath,
2323 install_dir : rootbindir)
2324 public_programs += [exe]
2327 if conf.get('ENABLE_QUOTACHECK') == 1
2328 executable('systemd-quotacheck',
2329 'src/quotacheck/quotacheck.c',
2330 include_directories : includes,
2331 link_with : [libshared],
2332 install_rpath : rootlibexecdir,
2334 install_dir : rootlibexecdir)
2337 exe = executable('systemd-socket-proxyd',
2338 'src/socket-proxy/socket-proxyd.c',
2339 include_directories : includes,
2340 link_with : [libshared],
2341 dependencies : [threads],
2342 install_rpath : rootlibexecdir,
2344 install_dir : rootlibexecdir)
2345 public_programs += [exe]
2347 exe = executable('systemd-udevd',
2348 systemd_udevd_sources,
2349 include_directories : includes,
2350 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2351 link_with : [libudev_core,
2354 dependencies : [threads,
2359 install_rpath : udev_rpath,
2361 install_dir : rootlibexecdir)
2362 public_programs += [exe]
2364 exe = executable('udevadm',
2366 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2367 include_directories : includes,
2368 link_with : [libudev_core,
2371 dependencies : [threads,
2376 install_rpath : udev_rpath,
2378 install_dir : rootbindir)
2379 public_programs += [exe]
2381 executable('systemd-shutdown',
2382 systemd_shutdown_sources,
2383 include_directories : includes,
2384 link_with : [libshared],
2385 dependencies : [libmount],
2386 install_rpath : rootlibexecdir,
2388 install_dir : rootlibexecdir)
2390 executable('systemd-update-done',
2391 'src/update-done/update-done.c',
2392 include_directories : includes,
2393 link_with : [libshared],
2394 install_rpath : rootlibexecdir,
2396 install_dir : rootlibexecdir)
2398 executable('systemd-update-utmp',
2399 'src/update-utmp/update-utmp.c',
2400 include_directories : includes,
2401 link_with : [libshared],
2402 dependencies : [libaudit],
2403 install_rpath : rootlibexecdir,
2405 install_dir : rootlibexecdir)
2407 if conf.get('HAVE_KMOD') == 1
2408 executable('systemd-modules-load',
2409 'src/modules-load/modules-load.c',
2410 include_directories : includes,
2411 link_with : [libshared],
2412 dependencies : [libkmod],
2413 install_rpath : rootlibexecdir,
2415 install_dir : rootlibexecdir)
2417 meson.add_install_script('sh', '-c',
2418 mkdir_p.format(modulesloaddir))
2419 meson.add_install_script('sh', '-c',
2420 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2423 exe = executable('systemd-nspawn',
2424 systemd_nspawn_sources,
2425 'src/core/mount-setup.c', # FIXME: use a variable?
2426 'src/core/mount-setup.h',
2427 'src/core/loopback-setup.c',
2428 'src/core/loopback-setup.h',
2429 include_directories : [includes, include_directories('src/nspawn')],
2430 link_with : [libshared],
2431 dependencies : [libacl,
2435 install_rpath : rootlibexecdir,
2437 public_programs += [exe]
2439 if conf.get('ENABLE_NETWORKD') == 1
2440 executable('systemd-networkd',
2441 systemd_networkd_sources,
2442 include_directories : includes,
2443 link_with : [libnetworkd_core,
2447 dependencies : [threads],
2448 install_rpath : rootlibexecdir,
2450 install_dir : rootlibexecdir)
2452 executable('systemd-networkd-wait-online',
2453 systemd_networkd_wait_online_sources,
2454 include_directories : includes,
2455 link_with : [libnetworkd_core,
2457 install_rpath : rootlibexecdir,
2459 install_dir : rootlibexecdir)
2461 exe = executable('networkctl',
2463 include_directories : includes,
2464 link_with : [libsystemd_network,
2466 install_rpath : rootlibexecdir,
2468 install_dir : rootbindir)
2469 public_programs += [exe]
2472 executable('systemd-sulogin-shell',
2473 ['src/sulogin-shell/sulogin-shell.c'],
2474 include_directories : includes,
2475 link_with : [libshared],
2476 install_rpath : rootlibexecdir,
2478 install_dir : rootlibexecdir)
2480 ############################################################
2482 foreach tuple : tests
2484 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2485 dependencies = tuple[2]
2486 condition = tuple.length() >= 4 ? tuple[3] : ''
2487 type = tuple.length() >= 5 ? tuple[4] : ''
2488 defs = tuple.length() >= 6 ? tuple[5] : []
2489 incs = tuple.length() >= 7 ? tuple[6] : includes
2492 name = sources[0].split('/')[-1].split('.')[0]
2493 if type.startswith('timeout=')
2494 timeout = type.split('=')[1].to_int()
2497 if want_tests == 'false'
2498 message('Not compiling @0@ because tests is set to false'.format(name))
2499 elif condition == '' or conf.get(condition) == 1
2503 include_directories : incs,
2504 link_with : link_with,
2505 dependencies : dependencies,
2507 install_rpath : rootlibexecdir,
2508 install : install_tests,
2509 install_dir : join_paths(testsdir, type))
2512 message('@0@ is a manual test'.format(name))
2513 elif type == 'unsafe' and want_tests != 'unsafe'
2514 message('@0@ is an unsafe test'.format(name))
2521 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2525 test_libsystemd_sym = executable(
2526 'test-libsystemd-sym',
2527 test_libsystemd_sym_c,
2528 include_directories : includes,
2529 link_with : [libsystemd],
2530 install : install_tests,
2531 install_dir : testsdir)
2532 test('test-libsystemd-sym',
2533 test_libsystemd_sym)
2535 test_libudev_sym = executable(
2538 include_directories : includes,
2539 c_args : ['-Wno-deprecated-declarations'],
2540 link_with : [libudev],
2541 install : install_tests,
2542 install_dir : testsdir)
2543 test('test-libudev-sym',
2546 ############################################################
2550 foreach tuple : fuzzers
2552 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2553 dependencies = tuple[2]
2554 defs = tuple.length() >= 4 ? tuple[3] : []
2555 incs = tuple.length() >= 5 ? tuple[4] : includes
2558 dependencies += fuzzing_engine
2560 sources += 'src/fuzz/fuzz-main.c'
2563 name = sources[0].split('/')[-1].split('.')[0]
2565 fuzzer_exes += executable(
2568 include_directories : [incs, include_directories('src/fuzz')],
2569 link_with : link_with,
2570 dependencies : dependencies,
2575 run_target('fuzzers',
2576 depends : fuzzer_exes,
2579 ############################################################
2581 make_directive_index_py = find_program('tools/make-directive-index.py')
2582 make_man_index_py = find_program('tools/make-man-index.py')
2583 xml_helper_py = find_program('tools/xml_helper.py')
2584 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2588 subdir('sysusers.d')
2589 subdir('tmpfiles.d')
2594 subdir('shell-completion/bash')
2595 subdir('shell-completion/zsh')
2596 subdir('doc/sysvinit')
2597 subdir('doc/var-log')
2599 # FIXME: figure out if the warning is true:
2600 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2601 install_subdir('factory/etc',
2602 install_dir : factorydir)
2605 install_data('xorg/50-systemd-user.sh',
2606 install_dir : xinitrcdir)
2607 install_data('modprobe.d/systemd.conf',
2608 install_dir : modprobedir)
2609 install_data('LICENSE.GPL2',
2614 'doc/DISTRO_PORTING',
2615 'doc/ENVIRONMENT.md',
2617 'doc/TRANSIENT-SETTINGS.md',
2620 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2621 install_dir : docdir)
2623 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2624 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2626 ############################################################
2628 meson_check_help = find_program('tools/meson-check-help.sh')
2630 foreach exec : public_programs
2631 name = exec.full_path().split('/')[-1]
2632 test('check-help-' + name,
2634 args : [exec.full_path()])
2637 ############################################################
2639 # Enable tests for all supported sanitizers
2640 foreach tuple : sanitizers
2641 sanitizer = tuple[0]
2644 have = run_command(check_compilation_sh,
2645 cc.cmd_array(), '-x', 'c',
2646 '-fsanitize=@0@'.format(sanitizer),
2647 '-include', link_test_c).returncode() == 0
2648 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2652 foreach p : fuzz_regression_tests
2653 b = p.split('/')[-2]
2654 c = p.split('/')[-1]
2656 name = '@0@:@1@'.format(b, sanitizer)
2659 if want_tests == 'false'
2660 message('Not compiling @0@ because tests is set to false'.format(name))
2662 exe = custom_target(
2666 command : [env, 'ln', '-fs',
2667 join_paths(build.full_path(), b),
2669 build_by_default : true)
2671 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2676 if want_tests != 'false' and slow_tests
2677 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2679 args : [exe.full_path(),
2680 join_paths(meson.source_root(),
2681 'test/fuzz-regressions',
2689 ############################################################
2692 all_files = run_command(
2694 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2697 all_files = files(all_files.stdout().split())
2702 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2706 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2710 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2713 command : [meson_git_contrib_sh])
2717 git_head = run_command(
2719 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2720 'rev-parse', 'HEAD']).stdout().strip()
2721 git_head_short = run_command(
2723 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2724 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2728 command : ['git', 'archive',
2729 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2731 '--prefix', 'systemd-@0@/'.format(git_head),
2735 ############################################################
2737 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2740 depends : [man, libsystemd, libudev],
2741 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2743 ############################################################
2746 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2748 'split /usr: @0@'.format(split_usr),
2749 'split bin-sbin: @0@'.format(split_bin),
2750 'prefix directory: @0@'.format(prefixdir),
2751 'rootprefix directory: @0@'.format(rootprefixdir),
2752 'sysconf directory: @0@'.format(sysconfdir),
2753 'include directory: @0@'.format(includedir),
2754 'lib directory: @0@'.format(libdir),
2755 'rootlib directory: @0@'.format(rootlibdir),
2756 'SysV init scripts: @0@'.format(sysvinit_path),
2757 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2758 'PAM modules directory: @0@'.format(pamlibdir),
2759 'PAM configuration directory: @0@'.format(pamconfdir),
2760 'RPM macros directory: @0@'.format(rpmmacrosdir),
2761 'modprobe.d directory: @0@'.format(modprobedir),
2762 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2763 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2764 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2765 'bash completions directory: @0@'.format(bashcompletiondir),
2766 'zsh completions directory: @0@'.format(zshcompletiondir),
2767 'extra start script: @0@'.format(get_option('rc-local')),
2768 'extra stop script: @0@'.format(get_option('halt-local')),
2769 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2770 get_option('debug-tty')),
2771 'TTY GID: @0@'.format(tty_gid),
2772 'users GID: @0@'.format(users_gid),
2773 'maximum system UID: @0@'.format(system_uid_max),
2774 'maximum system GID: @0@'.format(system_gid_max),
2775 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2776 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2777 'minimum container UID base: @0@'.format(container_uid_base_min),
2778 'maximum container UID base: @0@'.format(container_uid_base_max),
2779 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2780 'render group access mode: @0@'.format(get_option('group-render-mode')),
2781 'certificate root directory: @0@'.format(get_option('certificate-root')),
2782 'support URL: @0@'.format(support_url),
2783 'nobody user name: @0@'.format(nobody_user),
2784 'nobody group name: @0@'.format(nobody_group),
2785 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2786 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2788 'default DNSSEC mode: @0@'.format(default_dnssec),
2789 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2790 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2792 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2793 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2795 'default DNS servers: @0@'.format(alt_dns_servers),
2796 'default NTP servers: @0@'.format(alt_ntp_servers)]
2798 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2799 '@@0@'.format(time_epoch)).stdout().strip()
2801 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2804 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2805 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2806 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2808 if conf.get('ENABLE_EFI') == 1
2810 'efi arch: @0@'.format(efi_arch)]
2814 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2815 'EFI CC @0@'.format(efi_cc),
2816 'EFI lib directory: @0@'.format(efi_libdir),
2817 'EFI lds directory: @0@'.format(efi_ldsdir),
2818 'EFI include directory: @0@'.format(efi_incdir)]
2871 ['legacy pkla', install_polkit_pkla],
2873 ['gnu-efi', have_gnu_efi],
2880 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2883 ['man pages', want_man],
2884 ['html pages', want_html],
2885 ['man page indices', want_man and have_lxml],
2890 ['adm group', get_option('adm-group')],
2891 ['wheel group', get_option('wheel-group')],
2894 ['debug mmap cache'],
2897 if tuple.length() >= 2
2900 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2901 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2902 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2907 missing += [tuple[0]]
2913 'enabled features: @0@'.format(', '.join(found)),
2915 'disabled features: @0@'.format(', '.join(missing)),
2917 message('\n '.join(status))
2919 if rootprefixdir != rootprefix_default
2920 message('WARNING:\n' +
2921 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2922 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2923 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))