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 static_libsystemd = get_option('static-libsystemd')
1327 static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1329 install_libsystemd_static = static_library(
1332 journal_client_sources,
1334 basic_gcrypt_sources,
1335 include_directories : includes,
1336 build_by_default : static_libsystemd != 'false',
1337 install : static_libsystemd != 'false',
1338 install_dir : rootlibdir,
1339 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1340 dependencies : [threads,
1349 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1351 ############################################################
1353 # binaries that have --help and are intended for use by humans,
1354 # usually, but not always, installed in /bin.
1355 public_programs = []
1357 subdir('src/libudev')
1358 subdir('src/shared')
1361 subdir('src/network')
1363 subdir('src/analyze')
1364 subdir('src/journal-remote')
1365 subdir('src/coredump')
1366 subdir('src/hostname')
1367 subdir('src/import')
1368 subdir('src/kernel-install')
1369 subdir('src/locale')
1370 subdir('src/machine')
1371 subdir('src/nspawn')
1372 subdir('src/resolve')
1373 subdir('src/timedate')
1374 subdir('src/timesync')
1375 subdir('src/vconsole')
1376 subdir('src/boot/efi')
1383 ############################################################
1385 # only static linking apart from libdl, to make sure that the
1386 # module is linked to all libraries that it uses.
1387 test_dlopen = executable(
1390 include_directories : includes,
1391 link_with : [libbasic],
1392 dependencies : [libdl])
1394 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1395 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1396 ['mymachines', 'ENABLE_MACHINED'],
1397 ['resolve', 'ENABLE_RESOLVE']]
1399 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1403 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1404 version_script_arg = join_paths(meson.current_source_dir(), sym)
1406 nss = shared_library(
1408 'src/nss-@0@/nss-@0@.c'.format(module),
1410 include_directories : includes,
1411 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1412 link_args : ['-Wl,-z,nodelete',
1414 '-Wl,--version-script=' + version_script_arg,
1416 link_with : [libsystemd_static,
1418 dependencies : [threads,
1422 install_dir : rootlibdir)
1424 # We cannot use shared_module because it does not support version suffix.
1425 # Unfortunately shared_library insists on creating the symlink…
1426 meson.add_install_script('sh', '-c',
1427 'rm $DESTDIR@0@/libnss_@1@.so'
1428 .format(rootlibdir, module))
1430 test('dlopen-nss_' + module,
1432 args : [nss.full_path()]) # path to dlopen must include a slash
1436 ############################################################
1438 executable('systemd',
1440 include_directories : includes,
1441 link_with : [libcore,
1443 dependencies : [threads,
1449 install_rpath : rootlibexecdir,
1451 install_dir : rootlibexecdir)
1453 meson.add_install_script(meson_make_symlink,
1454 join_paths(rootlibexecdir, 'systemd'),
1455 join_paths(rootsbindir, 'init'))
1457 exe = executable('systemd-analyze',
1458 systemd_analyze_sources,
1459 include_directories : includes,
1460 link_with : [libcore,
1462 dependencies : [threads,
1468 install_rpath : rootlibexecdir,
1470 public_programs += [exe]
1472 executable('systemd-journald',
1473 systemd_journald_sources,
1474 include_directories : includes,
1475 link_with : [libjournal_core,
1477 dependencies : [threads,
1481 install_rpath : rootlibexecdir,
1483 install_dir : rootlibexecdir)
1485 exe = executable('systemd-cat',
1486 systemd_cat_sources,
1487 include_directories : includes,
1488 link_with : [libjournal_core,
1490 dependencies : [threads],
1491 install_rpath : rootlibexecdir,
1493 public_programs += [exe]
1495 exe = executable('journalctl',
1497 include_directories : includes,
1498 link_with : [libshared],
1499 dependencies : [threads,
1504 install_rpath : rootlibexecdir,
1506 install_dir : rootbindir)
1507 public_programs += [exe]
1509 executable('systemd-getty-generator',
1510 'src/getty-generator/getty-generator.c',
1511 include_directories : includes,
1512 link_with : [libshared],
1513 install_rpath : rootlibexecdir,
1515 install_dir : systemgeneratordir)
1517 executable('systemd-debug-generator',
1518 'src/debug-generator/debug-generator.c',
1519 include_directories : includes,
1520 link_with : [libshared],
1521 install_rpath : rootlibexecdir,
1523 install_dir : systemgeneratordir)
1525 executable('systemd-fstab-generator',
1526 'src/fstab-generator/fstab-generator.c',
1527 'src/core/mount-setup.c',
1528 include_directories : includes,
1529 link_with : [libshared],
1530 install_rpath : rootlibexecdir,
1532 install_dir : systemgeneratordir)
1534 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1535 executable('30-systemd-environment-d-generator',
1536 'src/environment-d-generator/environment-d-generator.c',
1537 include_directories : includes,
1538 link_with : [libshared],
1539 install_rpath : rootlibexecdir,
1541 install_dir : userenvgeneratordir)
1543 meson.add_install_script(meson_make_symlink,
1544 join_paths(sysconfdir, 'environment'),
1545 join_paths(environmentdir, '99-environment.conf'))
1548 if conf.get('ENABLE_HIBERNATE') == 1
1549 executable('systemd-hibernate-resume-generator',
1550 'src/hibernate-resume/hibernate-resume-generator.c',
1551 include_directories : includes,
1552 link_with : [libshared],
1553 install_rpath : rootlibexecdir,
1555 install_dir : systemgeneratordir)
1557 executable('systemd-hibernate-resume',
1558 'src/hibernate-resume/hibernate-resume.c',
1559 include_directories : includes,
1560 link_with : [libshared],
1561 install_rpath : rootlibexecdir,
1563 install_dir : rootlibexecdir)
1566 if conf.get('HAVE_BLKID') == 1
1567 executable('systemd-gpt-auto-generator',
1568 'src/gpt-auto-generator/gpt-auto-generator.c',
1569 'src/basic/blkid-util.h',
1570 include_directories : includes,
1571 link_with : [libshared],
1572 dependencies : libblkid,
1573 install_rpath : rootlibexecdir,
1575 install_dir : systemgeneratordir)
1577 exe = executable('systemd-dissect',
1578 'src/dissect/dissect.c',
1579 include_directories : includes,
1580 link_with : [libshared],
1581 install_rpath : rootlibexecdir,
1583 install_dir : rootlibexecdir)
1584 public_programs += [exe]
1587 if conf.get('ENABLE_RESOLVE') == 1
1588 executable('systemd-resolved',
1589 systemd_resolved_sources,
1590 include_directories : includes,
1591 link_with : [libshared,
1593 libsystemd_resolve_core],
1594 dependencies : [threads,
1598 install_rpath : rootlibexecdir,
1600 install_dir : rootlibexecdir)
1602 exe = executable('resolvectl',
1604 include_directories : includes,
1605 link_with : [libshared,
1607 libsystemd_resolve_core],
1608 dependencies : [threads,
1612 install_rpath : rootlibexecdir,
1614 public_programs += [exe]
1616 meson.add_install_script(meson_make_symlink,
1617 join_paths(bindir, 'resolvectl'),
1618 join_paths(rootsbindir, 'resolvconf'))
1620 meson.add_install_script(meson_make_symlink,
1621 join_paths(bindir, 'resolvectl'),
1622 join_paths(bindir, 'systemd-resolve'))
1625 if conf.get('ENABLE_LOGIND') == 1
1626 executable('systemd-logind',
1627 systemd_logind_sources,
1628 include_directories : includes,
1629 link_with : [liblogind_core,
1631 dependencies : [threads,
1633 install_rpath : rootlibexecdir,
1635 install_dir : rootlibexecdir)
1637 exe = executable('loginctl',
1639 include_directories : includes,
1640 link_with : [libshared],
1641 dependencies : [threads,
1644 install_rpath : rootlibexecdir,
1646 install_dir : rootbindir)
1647 public_programs += [exe]
1649 exe = executable('systemd-inhibit',
1650 'src/login/inhibit.c',
1651 include_directories : includes,
1652 link_with : [libshared],
1653 install_rpath : rootlibexecdir,
1655 install_dir : rootbindir)
1656 public_programs += [exe]
1658 if conf.get('HAVE_PAM') == 1
1659 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1660 pam_systemd = shared_library(
1664 include_directories : includes,
1665 link_args : ['-shared',
1666 '-Wl,--version-script=' + version_script_arg],
1667 link_with : [libsystemd_static,
1669 dependencies : [threads,
1672 link_depends : pam_systemd_sym,
1674 install_dir : pamlibdir)
1676 test('dlopen-pam_systemd',
1678 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1682 executable('systemd-user-runtime-dir',
1683 user_runtime_dir_sources,
1684 include_directories : includes,
1685 link_with : [libshared, liblogind_core],
1686 install_rpath : rootlibexecdir,
1688 install_dir : rootlibexecdir)
1690 if conf.get('HAVE_PAM') == 1
1691 executable('systemd-user-sessions',
1692 'src/user-sessions/user-sessions.c',
1693 include_directories : includes,
1694 link_with : [libshared],
1695 install_rpath : rootlibexecdir,
1697 install_dir : rootlibexecdir)
1700 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1701 exe = executable('bootctl',
1702 'src/boot/bootctl.c',
1703 include_directories : includes,
1704 link_with : [libshared],
1705 dependencies : [libblkid],
1706 install_rpath : rootlibexecdir,
1708 public_programs += [exe]
1711 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1712 include_directories : includes,
1713 link_with : [libshared],
1714 dependencies : [threads],
1715 install_rpath : rootlibexecdir,
1717 public_programs += [exe]
1719 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1720 include_directories : includes,
1721 link_with : [libshared],
1722 dependencies : [threads,
1727 install_rpath : rootlibexecdir,
1729 install_dir : rootbindir)
1730 public_programs += [exe]
1732 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1733 meson.add_install_script(meson_make_symlink,
1734 join_paths(rootbindir, 'systemctl'),
1735 join_paths(rootsbindir, alias))
1738 if conf.get('ENABLE_BACKLIGHT') == 1
1739 executable('systemd-backlight',
1740 'src/backlight/backlight.c',
1741 include_directories : includes,
1742 link_with : [libshared],
1743 install_rpath : rootlibexecdir,
1745 install_dir : rootlibexecdir)
1748 if conf.get('ENABLE_RFKILL') == 1
1749 executable('systemd-rfkill',
1750 'src/rfkill/rfkill.c',
1751 include_directories : includes,
1752 link_with : [libshared],
1753 install_rpath : rootlibexecdir,
1755 install_dir : rootlibexecdir)
1758 executable('systemd-system-update-generator',
1759 'src/system-update-generator/system-update-generator.c',
1760 include_directories : includes,
1761 link_with : [libshared],
1762 install_rpath : rootlibexecdir,
1764 install_dir : systemgeneratordir)
1766 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1767 executable('systemd-cryptsetup',
1768 'src/cryptsetup/cryptsetup.c',
1769 include_directories : includes,
1770 link_with : [libshared],
1771 dependencies : [libcryptsetup],
1772 install_rpath : rootlibexecdir,
1774 install_dir : rootlibexecdir)
1776 executable('systemd-cryptsetup-generator',
1777 'src/cryptsetup/cryptsetup-generator.c',
1778 include_directories : includes,
1779 link_with : [libshared],
1780 dependencies : [libcryptsetup],
1781 install_rpath : rootlibexecdir,
1783 install_dir : systemgeneratordir)
1785 executable('systemd-veritysetup',
1786 'src/veritysetup/veritysetup.c',
1787 include_directories : includes,
1788 link_with : [libshared],
1789 dependencies : [libcryptsetup],
1790 install_rpath : rootlibexecdir,
1792 install_dir : rootlibexecdir)
1794 executable('systemd-veritysetup-generator',
1795 'src/veritysetup/veritysetup-generator.c',
1796 include_directories : includes,
1797 link_with : [libshared],
1798 dependencies : [libcryptsetup],
1799 install_rpath : rootlibexecdir,
1801 install_dir : systemgeneratordir)
1804 if conf.get('HAVE_SYSV_COMPAT') == 1
1805 executable('systemd-sysv-generator',
1806 'src/sysv-generator/sysv-generator.c',
1807 include_directories : includes,
1808 link_with : [libshared],
1809 install_rpath : rootlibexecdir,
1811 install_dir : systemgeneratordir)
1813 executable('systemd-rc-local-generator',
1814 'src/rc-local-generator/rc-local-generator.c',
1815 include_directories : includes,
1816 link_with : [libshared],
1817 install_rpath : rootlibexecdir,
1819 install_dir : systemgeneratordir)
1822 if conf.get('ENABLE_HOSTNAMED') == 1
1823 executable('systemd-hostnamed',
1824 'src/hostname/hostnamed.c',
1825 include_directories : includes,
1826 link_with : [libshared],
1827 install_rpath : rootlibexecdir,
1829 install_dir : rootlibexecdir)
1831 exe = executable('hostnamectl',
1832 'src/hostname/hostnamectl.c',
1833 include_directories : includes,
1834 link_with : [libshared],
1835 install_rpath : rootlibexecdir,
1837 public_programs += [exe]
1840 if conf.get('ENABLE_LOCALED') == 1
1841 if conf.get('HAVE_XKBCOMMON') == 1
1842 # logind will load libxkbcommon.so dynamically on its own
1848 executable('systemd-localed',
1849 systemd_localed_sources,
1850 include_directories : includes,
1851 link_with : [libshared],
1852 dependencies : deps,
1853 install_rpath : rootlibexecdir,
1855 install_dir : rootlibexecdir)
1857 exe = executable('localectl',
1859 include_directories : includes,
1860 link_with : [libshared],
1861 install_rpath : rootlibexecdir,
1863 public_programs += [exe]
1866 if conf.get('ENABLE_TIMEDATED') == 1
1867 executable('systemd-timedated',
1868 'src/timedate/timedated.c',
1869 include_directories : includes,
1870 link_with : [libshared],
1871 install_rpath : rootlibexecdir,
1873 install_dir : rootlibexecdir)
1876 if conf.get('ENABLE_TIMEDATECTL') == 1
1877 exe = executable('timedatectl',
1878 'src/timedate/timedatectl.c',
1879 include_directories : includes,
1880 install_rpath : rootlibexecdir,
1881 link_with : [libshared],
1882 dependencies : [libm],
1884 public_programs += [exe]
1887 if conf.get('ENABLE_TIMESYNCD') == 1
1888 executable('systemd-timesyncd',
1889 systemd_timesyncd_sources,
1890 include_directories : includes,
1891 link_with : [libshared],
1892 dependencies : [threads,
1894 install_rpath : rootlibexecdir,
1896 install_dir : rootlibexecdir)
1898 executable('systemd-time-wait-sync',
1899 'src/time-wait-sync/time-wait-sync.c',
1900 include_directories : includes,
1901 link_with : [libshared],
1902 install_rpath : rootlibexecdir,
1904 install_dir : rootlibexecdir)
1907 if conf.get('ENABLE_MACHINED') == 1
1908 executable('systemd-machined',
1909 systemd_machined_sources,
1910 include_directories : includes,
1911 link_with : [libmachine_core,
1913 install_rpath : rootlibexecdir,
1915 install_dir : rootlibexecdir)
1917 exe = executable('machinectl',
1918 'src/machine/machinectl.c',
1919 include_directories : includes,
1920 link_with : [libshared],
1921 dependencies : [threads,
1924 install_rpath : rootlibexecdir,
1926 install_dir : rootbindir)
1927 public_programs += [exe]
1930 if conf.get('ENABLE_IMPORTD') == 1
1931 executable('systemd-importd',
1932 systemd_importd_sources,
1933 include_directories : includes,
1934 link_with : [libshared],
1935 dependencies : [threads],
1936 install_rpath : rootlibexecdir,
1938 install_dir : rootlibexecdir)
1940 systemd_pull = executable('systemd-pull',
1941 systemd_pull_sources,
1942 include_directories : includes,
1943 link_with : [libshared],
1944 dependencies : [libcurl,
1949 install_rpath : rootlibexecdir,
1951 install_dir : rootlibexecdir)
1953 systemd_import = executable('systemd-import',
1954 systemd_import_sources,
1955 include_directories : includes,
1956 link_with : [libshared],
1957 dependencies : [libcurl,
1961 install_rpath : rootlibexecdir,
1963 install_dir : rootlibexecdir)
1965 systemd_export = executable('systemd-export',
1966 systemd_export_sources,
1967 include_directories : includes,
1968 link_with : [libshared],
1969 dependencies : [libcurl,
1973 install_rpath : rootlibexecdir,
1975 install_dir : rootlibexecdir)
1976 public_programs += [systemd_pull, systemd_import, systemd_export]
1979 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1980 exe = executable('systemd-journal-upload',
1981 systemd_journal_upload_sources,
1982 include_directories : includes,
1983 link_with : [libshared],
1984 dependencies : [threads,
1989 install_rpath : rootlibexecdir,
1991 install_dir : rootlibexecdir)
1992 public_programs += [exe]
1995 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1996 s_j_remote = executable('systemd-journal-remote',
1997 systemd_journal_remote_sources,
1998 include_directories : includes,
1999 link_with : [libshared],
2000 dependencies : [threads,
2005 install_rpath : rootlibexecdir,
2007 install_dir : rootlibexecdir)
2009 s_j_gatewayd = executable('systemd-journal-gatewayd',
2010 systemd_journal_gatewayd_sources,
2011 include_directories : includes,
2012 link_with : [libshared],
2013 dependencies : [threads,
2018 install_rpath : rootlibexecdir,
2020 install_dir : rootlibexecdir)
2021 public_programs += [s_j_remote, s_j_gatewayd]
2024 if conf.get('ENABLE_COREDUMP') == 1
2025 executable('systemd-coredump',
2026 systemd_coredump_sources,
2027 include_directories : includes,
2028 link_with : [libshared],
2029 dependencies : [threads,
2034 install_rpath : rootlibexecdir,
2036 install_dir : rootlibexecdir)
2038 exe = executable('coredumpctl',
2039 coredumpctl_sources,
2040 include_directories : includes,
2041 link_with : [libshared],
2042 dependencies : [threads,
2045 install_rpath : rootlibexecdir,
2047 public_programs += [exe]
2050 if conf.get('ENABLE_BINFMT') == 1
2051 exe = executable('systemd-binfmt',
2052 'src/binfmt/binfmt.c',
2053 include_directories : includes,
2054 link_with : [libshared],
2055 install_rpath : rootlibexecdir,
2057 install_dir : rootlibexecdir)
2058 public_programs += [exe]
2060 meson.add_install_script('sh', '-c',
2061 mkdir_p.format(binfmtdir))
2062 meson.add_install_script('sh', '-c',
2063 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2066 if conf.get('ENABLE_VCONSOLE') == 1
2067 executable('systemd-vconsole-setup',
2068 'src/vconsole/vconsole-setup.c',
2069 include_directories : includes,
2070 link_with : [libshared],
2071 install_rpath : rootlibexecdir,
2073 install_dir : rootlibexecdir)
2076 if conf.get('ENABLE_RANDOMSEED') == 1
2077 executable('systemd-random-seed',
2078 'src/random-seed/random-seed.c',
2079 include_directories : includes,
2080 link_with : [libshared],
2081 install_rpath : rootlibexecdir,
2083 install_dir : rootlibexecdir)
2086 if conf.get('ENABLE_FIRSTBOOT') == 1
2087 executable('systemd-firstboot',
2088 'src/firstboot/firstboot.c',
2089 include_directories : includes,
2090 link_with : [libshared],
2091 dependencies : [libcrypt],
2092 install_rpath : rootlibexecdir,
2094 install_dir : rootbindir)
2097 executable('systemd-remount-fs',
2098 'src/remount-fs/remount-fs.c',
2099 'src/core/mount-setup.c',
2100 'src/core/mount-setup.h',
2101 include_directories : includes,
2102 link_with : [libshared],
2103 install_rpath : rootlibexecdir,
2105 install_dir : rootlibexecdir)
2107 executable('systemd-machine-id-setup',
2108 'src/machine-id-setup/machine-id-setup-main.c',
2109 'src/core/machine-id-setup.c',
2110 'src/core/machine-id-setup.h',
2111 include_directories : includes,
2112 link_with : [libshared],
2113 install_rpath : rootlibexecdir,
2115 install_dir : rootbindir)
2117 executable('systemd-fsck',
2119 include_directories : includes,
2120 link_with : [libshared],
2121 install_rpath : rootlibexecdir,
2123 install_dir : rootlibexecdir)
2125 executable('systemd-growfs',
2126 'src/partition/growfs.c',
2127 include_directories : includes,
2128 link_with : [libshared],
2129 dependencies : [libcryptsetup],
2130 install_rpath : rootlibexecdir,
2132 install_dir : rootlibexecdir)
2134 executable('systemd-makefs',
2135 'src/partition/makefs.c',
2136 include_directories : includes,
2137 link_with : [libshared],
2138 install_rpath : rootlibexecdir,
2140 install_dir : rootlibexecdir)
2142 executable('systemd-sleep',
2143 'src/sleep/sleep.c',
2144 include_directories : includes,
2145 link_with : [libshared],
2146 install_rpath : rootlibexecdir,
2148 install_dir : rootlibexecdir)
2150 exe = executable('systemd-sysctl',
2151 'src/sysctl/sysctl.c',
2152 include_directories : includes,
2153 link_with : [libshared],
2154 install_rpath : rootlibexecdir,
2156 install_dir : rootlibexecdir)
2157 public_programs += [exe]
2159 executable('systemd-ac-power',
2160 'src/ac-power/ac-power.c',
2161 include_directories : includes,
2162 link_with : [libshared],
2163 install_rpath : rootlibexecdir,
2165 install_dir : rootlibexecdir)
2167 exe = executable('systemd-detect-virt',
2168 'src/detect-virt/detect-virt.c',
2169 include_directories : includes,
2170 link_with : [libshared],
2171 install_rpath : rootlibexecdir,
2173 public_programs += [exe]
2175 exe = executable('systemd-delta',
2176 'src/delta/delta.c',
2177 include_directories : includes,
2178 link_with : [libshared],
2179 install_rpath : rootlibexecdir,
2181 public_programs += [exe]
2183 exe = executable('systemd-escape',
2184 'src/escape/escape.c',
2185 include_directories : includes,
2186 link_with : [libshared],
2187 install_rpath : rootlibexecdir,
2189 install_dir : rootbindir)
2190 public_programs += [exe]
2192 exe = executable('systemd-notify',
2193 'src/notify/notify.c',
2194 include_directories : includes,
2195 link_with : [libshared],
2196 install_rpath : rootlibexecdir,
2198 install_dir : rootbindir)
2199 public_programs += [exe]
2201 executable('systemd-volatile-root',
2202 'src/volatile-root/volatile-root.c',
2203 include_directories : includes,
2204 link_with : [libshared],
2205 install_rpath : rootlibexecdir,
2207 install_dir : rootlibexecdir)
2209 executable('systemd-cgroups-agent',
2210 'src/cgroups-agent/cgroups-agent.c',
2211 include_directories : includes,
2212 link_with : [libshared],
2213 install_rpath : rootlibexecdir,
2215 install_dir : rootlibexecdir)
2217 exe = executable('systemd-path',
2219 include_directories : includes,
2220 link_with : [libshared],
2221 install_rpath : rootlibexecdir,
2223 public_programs += [exe]
2225 exe = executable('systemd-ask-password',
2226 'src/ask-password/ask-password.c',
2227 include_directories : includes,
2228 link_with : [libshared],
2229 install_rpath : rootlibexecdir,
2231 install_dir : rootbindir)
2232 public_programs += [exe]
2234 executable('systemd-reply-password',
2235 'src/reply-password/reply-password.c',
2236 include_directories : includes,
2237 link_with : [libshared],
2238 install_rpath : rootlibexecdir,
2240 install_dir : rootlibexecdir)
2242 exe = executable('systemd-tty-ask-password-agent',
2243 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2248 install_dir : rootbindir)
2249 public_programs += [exe]
2251 exe = executable('systemd-cgls',
2253 include_directories : includes,
2254 link_with : [libshared],
2255 install_rpath : rootlibexecdir,
2257 public_programs += [exe]
2259 exe = executable('systemd-cgtop',
2260 'src/cgtop/cgtop.c',
2261 include_directories : includes,
2262 link_with : [libshared],
2263 install_rpath : rootlibexecdir,
2265 public_programs += [exe]
2267 executable('systemd-initctl',
2268 'src/initctl/initctl.c',
2269 include_directories : includes,
2270 link_with : [libshared],
2271 install_rpath : rootlibexecdir,
2273 install_dir : rootlibexecdir)
2275 exe = executable('systemd-mount',
2276 'src/mount/mount-tool.c',
2277 include_directories : includes,
2278 link_with : [libshared],
2279 install_rpath : rootlibexecdir,
2281 public_programs += [exe]
2283 meson.add_install_script(meson_make_symlink,
2284 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2286 exe = executable('systemd-run',
2288 include_directories : includes,
2289 link_with : [libshared],
2290 install_rpath : rootlibexecdir,
2292 public_programs += [exe]
2294 exe = executable('systemd-stdio-bridge',
2295 'src/stdio-bridge/stdio-bridge.c',
2296 include_directories : includes,
2297 link_with : [libshared],
2298 install_rpath : rootlibexecdir,
2300 public_programs += [exe]
2302 exe = executable('busctl',
2303 'src/busctl/busctl.c',
2304 'src/busctl/busctl-introspect.c',
2305 'src/busctl/busctl-introspect.h',
2306 include_directories : includes,
2307 link_with : [libshared],
2308 install_rpath : rootlibexecdir,
2310 public_programs += [exe]
2312 if conf.get('ENABLE_SYSUSERS') == 1
2313 exe = executable('systemd-sysusers',
2314 'src/sysusers/sysusers.c',
2315 include_directories : includes,
2316 link_with : [libshared],
2317 install_rpath : rootlibexecdir,
2319 install_dir : rootbindir)
2320 public_programs += [exe]
2323 if conf.get('ENABLE_TMPFILES') == 1
2324 exe = executable('systemd-tmpfiles',
2325 'src/tmpfiles/tmpfiles.c',
2326 include_directories : includes,
2327 link_with : [libshared],
2328 dependencies : [libacl],
2329 install_rpath : rootlibexecdir,
2331 install_dir : rootbindir)
2332 public_programs += [exe]
2334 test('test-systemd-tmpfiles',
2335 test_systemd_tmpfiles_py,
2336 args : exe.full_path())
2337 # https://github.com/mesonbuild/meson/issues/2681
2340 if conf.get('ENABLE_HWDB') == 1
2341 exe = executable('systemd-hwdb',
2343 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2344 include_directories : includes,
2345 link_with : [libudev_static],
2346 install_rpath : udev_rpath,
2348 install_dir : rootbindir)
2349 public_programs += [exe]
2352 if conf.get('ENABLE_QUOTACHECK') == 1
2353 executable('systemd-quotacheck',
2354 'src/quotacheck/quotacheck.c',
2355 include_directories : includes,
2356 link_with : [libshared],
2357 install_rpath : rootlibexecdir,
2359 install_dir : rootlibexecdir)
2362 exe = executable('systemd-socket-proxyd',
2363 'src/socket-proxy/socket-proxyd.c',
2364 include_directories : includes,
2365 link_with : [libshared],
2366 dependencies : [threads],
2367 install_rpath : rootlibexecdir,
2369 install_dir : rootlibexecdir)
2370 public_programs += [exe]
2372 exe = executable('systemd-udevd',
2373 systemd_udevd_sources,
2374 include_directories : includes,
2375 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2376 link_with : [libudev_core,
2379 dependencies : [threads,
2384 install_rpath : udev_rpath,
2386 install_dir : rootlibexecdir)
2387 public_programs += [exe]
2389 exe = executable('udevadm',
2391 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2392 include_directories : includes,
2393 link_with : [libudev_core,
2396 dependencies : [threads,
2401 install_rpath : udev_rpath,
2403 install_dir : rootbindir)
2404 public_programs += [exe]
2406 executable('systemd-shutdown',
2407 systemd_shutdown_sources,
2408 include_directories : includes,
2409 link_with : [libshared],
2410 dependencies : [libmount],
2411 install_rpath : rootlibexecdir,
2413 install_dir : rootlibexecdir)
2415 executable('systemd-update-done',
2416 'src/update-done/update-done.c',
2417 include_directories : includes,
2418 link_with : [libshared],
2419 install_rpath : rootlibexecdir,
2421 install_dir : rootlibexecdir)
2423 executable('systemd-update-utmp',
2424 'src/update-utmp/update-utmp.c',
2425 include_directories : includes,
2426 link_with : [libshared],
2427 dependencies : [libaudit],
2428 install_rpath : rootlibexecdir,
2430 install_dir : rootlibexecdir)
2432 if conf.get('HAVE_KMOD') == 1
2433 executable('systemd-modules-load',
2434 'src/modules-load/modules-load.c',
2435 include_directories : includes,
2436 link_with : [libshared],
2437 dependencies : [libkmod],
2438 install_rpath : rootlibexecdir,
2440 install_dir : rootlibexecdir)
2442 meson.add_install_script('sh', '-c',
2443 mkdir_p.format(modulesloaddir))
2444 meson.add_install_script('sh', '-c',
2445 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2448 exe = executable('systemd-nspawn',
2449 systemd_nspawn_sources,
2450 'src/core/mount-setup.c', # FIXME: use a variable?
2451 'src/core/mount-setup.h',
2452 'src/core/loopback-setup.c',
2453 'src/core/loopback-setup.h',
2454 include_directories : [includes, include_directories('src/nspawn')],
2455 link_with : [libshared],
2456 dependencies : [libacl,
2460 install_rpath : rootlibexecdir,
2462 public_programs += [exe]
2464 if conf.get('ENABLE_NETWORKD') == 1
2465 executable('systemd-networkd',
2466 systemd_networkd_sources,
2467 include_directories : includes,
2468 link_with : [libnetworkd_core,
2472 dependencies : [threads],
2473 install_rpath : rootlibexecdir,
2475 install_dir : rootlibexecdir)
2477 executable('systemd-networkd-wait-online',
2478 systemd_networkd_wait_online_sources,
2479 include_directories : includes,
2480 link_with : [libnetworkd_core,
2482 install_rpath : rootlibexecdir,
2484 install_dir : rootlibexecdir)
2486 exe = executable('networkctl',
2488 include_directories : includes,
2489 link_with : [libsystemd_network,
2491 install_rpath : rootlibexecdir,
2493 install_dir : rootbindir)
2494 public_programs += [exe]
2497 executable('systemd-sulogin-shell',
2498 ['src/sulogin-shell/sulogin-shell.c'],
2499 include_directories : includes,
2500 link_with : [libshared],
2501 install_rpath : rootlibexecdir,
2503 install_dir : rootlibexecdir)
2505 ############################################################
2507 foreach tuple : tests
2509 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2510 dependencies = tuple[2]
2511 condition = tuple.length() >= 4 ? tuple[3] : ''
2512 type = tuple.length() >= 5 ? tuple[4] : ''
2513 defs = tuple.length() >= 6 ? tuple[5] : []
2514 incs = tuple.length() >= 7 ? tuple[6] : includes
2517 name = sources[0].split('/')[-1].split('.')[0]
2518 if type.startswith('timeout=')
2519 timeout = type.split('=')[1].to_int()
2522 if want_tests == 'false'
2523 message('Not compiling @0@ because tests is set to false'.format(name))
2524 elif condition == '' or conf.get(condition) == 1
2528 include_directories : incs,
2529 link_with : link_with,
2530 dependencies : dependencies,
2532 install_rpath : rootlibexecdir,
2533 install : install_tests,
2534 install_dir : join_paths(testsdir, type))
2537 message('@0@ is a manual test'.format(name))
2538 elif type == 'unsafe' and want_tests != 'unsafe'
2539 message('@0@ is an unsafe test'.format(name))
2546 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2551 'test-libsystemd-sym',
2552 test_libsystemd_sym_c,
2553 include_directories : includes,
2554 link_with : [libsystemd],
2555 install : install_tests,
2556 install_dir : testsdir)
2557 test('test-libsystemd-sym', exe)
2560 'test-libsystemd-static-sym',
2561 test_libsystemd_sym_c,
2562 include_directories : includes,
2563 link_with : [install_libsystemd_static],
2564 dependencies : [threads], # threads is already included in dependencies on the library,
2565 # but does not seem to get propagated. Add here as a work-around.
2566 build_by_default : static_libsystemd_pic,
2567 install : install_tests and static_libsystemd_pic,
2568 install_dir : testsdir)
2569 if static_libsystemd_pic
2570 test('test-libsystemd-static-sym', exe)
2576 include_directories : includes,
2577 c_args : ['-Wno-deprecated-declarations'],
2578 link_with : [libudev],
2579 install : install_tests,
2580 install_dir : testsdir)
2581 test('test-libudev-sym', exe)
2584 'test-libudev-static-sym',
2586 include_directories : includes,
2587 c_args : ['-Wno-deprecated-declarations'],
2588 link_with : [install_libudev_static],
2589 build_by_default : static_libudev_pic,
2590 install : install_tests and static_libudev_pic,
2591 install_dir : testsdir)
2592 if static_libudev_pic
2593 test('test-libudev-static-sym', exe)
2596 ############################################################
2600 foreach tuple : fuzzers
2602 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2603 dependencies = tuple[2]
2604 defs = tuple.length() >= 4 ? tuple[3] : []
2605 incs = tuple.length() >= 5 ? tuple[4] : includes
2608 dependencies += fuzzing_engine
2610 sources += 'src/fuzz/fuzz-main.c'
2613 name = sources[0].split('/')[-1].split('.')[0]
2615 fuzzer_exes += executable(
2618 include_directories : [incs, include_directories('src/fuzz')],
2619 link_with : link_with,
2620 dependencies : dependencies,
2625 run_target('fuzzers',
2626 depends : fuzzer_exes,
2629 ############################################################
2631 make_directive_index_py = find_program('tools/make-directive-index.py')
2632 make_man_index_py = find_program('tools/make-man-index.py')
2633 xml_helper_py = find_program('tools/xml_helper.py')
2634 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2638 subdir('sysusers.d')
2639 subdir('tmpfiles.d')
2644 subdir('shell-completion/bash')
2645 subdir('shell-completion/zsh')
2646 subdir('doc/sysvinit')
2647 subdir('doc/var-log')
2649 # FIXME: figure out if the warning is true:
2650 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2651 install_subdir('factory/etc',
2652 install_dir : factorydir)
2655 install_data('xorg/50-systemd-user.sh',
2656 install_dir : xinitrcdir)
2657 install_data('modprobe.d/systemd.conf',
2658 install_dir : modprobedir)
2659 install_data('LICENSE.GPL2',
2664 'doc/DISTRO_PORTING',
2665 'doc/ENVIRONMENT.md',
2667 'doc/TRANSIENT-SETTINGS.md',
2670 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2671 install_dir : docdir)
2673 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2674 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2676 ############################################################
2678 meson_check_help = find_program('tools/meson-check-help.sh')
2680 foreach exec : public_programs
2681 name = exec.full_path().split('/')[-1]
2682 test('check-help-' + name,
2684 args : [exec.full_path()])
2687 ############################################################
2689 # Enable tests for all supported sanitizers
2690 foreach tuple : sanitizers
2691 sanitizer = tuple[0]
2694 have = run_command(check_compilation_sh,
2695 cc.cmd_array(), '-x', 'c',
2696 '-fsanitize=@0@'.format(sanitizer),
2697 '-include', link_test_c).returncode() == 0
2698 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2702 foreach p : fuzz_regression_tests
2703 b = p.split('/')[-2]
2704 c = p.split('/')[-1]
2706 name = '@0@:@1@'.format(b, sanitizer)
2709 if want_tests == 'false'
2710 message('Not compiling @0@ because tests is set to false'.format(name))
2712 exe = custom_target(
2716 command : [env, 'ln', '-fs',
2717 join_paths(build.full_path(), b),
2719 build_by_default : true)
2721 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2726 if want_tests != 'false' and slow_tests
2727 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2729 args : [exe.full_path(),
2730 join_paths(meson.source_root(),
2731 'test/fuzz-regressions',
2739 ############################################################
2742 all_files = run_command(
2744 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2747 all_files = files(all_files.stdout().split())
2752 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2756 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2760 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2763 command : [meson_git_contrib_sh])
2767 git_head = run_command(
2769 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2770 'rev-parse', 'HEAD']).stdout().strip()
2771 git_head_short = run_command(
2773 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2774 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2778 command : ['git', 'archive',
2779 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2781 '--prefix', 'systemd-@0@/'.format(git_head),
2785 ############################################################
2787 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2790 depends : [man, libsystemd, libudev],
2791 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2793 ############################################################
2796 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2798 'split /usr: @0@'.format(split_usr),
2799 'split bin-sbin: @0@'.format(split_bin),
2800 'prefix directory: @0@'.format(prefixdir),
2801 'rootprefix directory: @0@'.format(rootprefixdir),
2802 'sysconf directory: @0@'.format(sysconfdir),
2803 'include directory: @0@'.format(includedir),
2804 'lib directory: @0@'.format(libdir),
2805 'rootlib directory: @0@'.format(rootlibdir),
2806 'SysV init scripts: @0@'.format(sysvinit_path),
2807 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2808 'PAM modules directory: @0@'.format(pamlibdir),
2809 'PAM configuration directory: @0@'.format(pamconfdir),
2810 'RPM macros directory: @0@'.format(rpmmacrosdir),
2811 'modprobe.d directory: @0@'.format(modprobedir),
2812 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2813 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2814 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2815 'bash completions directory: @0@'.format(bashcompletiondir),
2816 'zsh completions directory: @0@'.format(zshcompletiondir),
2817 'extra start script: @0@'.format(get_option('rc-local')),
2818 'extra stop script: @0@'.format(get_option('halt-local')),
2819 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2820 get_option('debug-tty')),
2821 'TTY GID: @0@'.format(tty_gid),
2822 'users GID: @0@'.format(users_gid),
2823 'maximum system UID: @0@'.format(system_uid_max),
2824 'maximum system GID: @0@'.format(system_gid_max),
2825 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2826 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2827 'minimum container UID base: @0@'.format(container_uid_base_min),
2828 'maximum container UID base: @0@'.format(container_uid_base_max),
2829 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2830 'render group access mode: @0@'.format(get_option('group-render-mode')),
2831 'certificate root directory: @0@'.format(get_option('certificate-root')),
2832 'support URL: @0@'.format(support_url),
2833 'nobody user name: @0@'.format(nobody_user),
2834 'nobody group name: @0@'.format(nobody_group),
2835 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2836 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2838 'default DNSSEC mode: @0@'.format(default_dnssec),
2839 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2840 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2842 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2843 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2845 'default DNS servers: @0@'.format(alt_dns_servers),
2846 'default NTP servers: @0@'.format(alt_ntp_servers)]
2848 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2849 '@@0@'.format(time_epoch)).stdout().strip()
2851 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2854 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2855 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2856 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2858 if conf.get('ENABLE_EFI') == 1
2860 'efi arch: @0@'.format(efi_arch)]
2864 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2865 'EFI CC @0@'.format(efi_cc),
2866 'EFI lib directory: @0@'.format(efi_libdir),
2867 'EFI lds directory: @0@'.format(efi_ldsdir),
2868 'EFI include directory: @0@'.format(efi_incdir)]
2921 ['legacy pkla', install_polkit_pkla],
2923 ['gnu-efi', have_gnu_efi],
2930 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2933 ['man pages', want_man],
2934 ['html pages', want_html],
2935 ['man page indices', want_man and have_lxml],
2940 ['adm group', get_option('adm-group')],
2941 ['wheel group', get_option('wheel-group')],
2944 ['debug mmap cache'],
2947 if tuple.length() >= 2
2950 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2951 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2952 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2957 missing += [tuple[0]]
2963 'enabled features: @0@'.format(', '.join(found)),
2965 'disabled features: @0@'.format(', '.join(missing)),
2967 message('\n '.join(status))
2969 if rootprefixdir != rootprefix_default
2970 message('WARNING:\n' +
2971 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2972 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2973 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))