1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 project('systemd', 'c',
27 meson_version : '>= 0.41',
30 libsystemd_version = '0.21.0'
31 libudev_version = '1.6.9'
33 # We need the same data in three different formats, ugh!
34 # Also, for hysterical reasons, we use different variable
35 # names, sometimes. Not all variables are included in every
37 conf = configuration_data()
38 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
39 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
41 substs = configuration_data()
42 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
43 substs.set('PACKAGE_VERSION', meson.project_version())
47 #####################################################################
49 # Try to install the git pre-commit hook
50 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
51 if git_hook.returncode() == 0
52 message(git_hook.stdout().strip())
55 #####################################################################
57 split_usr = get_option('split-usr')
58 conf.set10('HAVE_SPLIT_USR', split_usr)
60 rootprefixdir = get_option('rootprefix')
61 # Unusual rootprefixdir values are used by some distros
62 # (see https://github.com/systemd/systemd/pull/7461).
63 rootprefix_default = get_option('split-usr') ? '/' : '/usr'
64 if rootprefixdir == ''
65 rootprefixdir = rootprefix_default
68 sysvinit_path = get_option('sysvinit-path')
69 sysvrcnd_path = get_option('sysvrcnd-path')
70 have = sysvinit_path != '' and sysvrcnd_path != ''
71 conf.set10('HAVE_SYSV_COMPAT', have,
72 description : 'SysV init scripts and rcN.d links are supported')
73 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
75 # join_paths ignore the preceding arguments if an absolute component is
76 # encountered, so this should canonicalize various paths when they are
77 # absolute or relative.
78 prefixdir = get_option('prefix')
79 if not prefixdir.startswith('/')
80 error('Prefix is not absolute: "@0@"'.format(prefixdir))
82 bindir = join_paths(prefixdir, get_option('bindir'))
83 libdir = join_paths(prefixdir, get_option('libdir'))
84 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
85 includedir = join_paths(prefixdir, get_option('includedir'))
86 datadir = join_paths(prefixdir, get_option('datadir'))
87 localstatedir = join_paths('/', get_option('localstatedir'))
89 rootbindir = join_paths(rootprefixdir, 'bin')
90 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
92 rootlibdir = get_option('rootlibdir')
94 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
97 # Dirs of external packages
98 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
99 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
100 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
101 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
102 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
103 varlogdir = join_paths(localstatedir, 'log')
104 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
105 rpmmacrosdir = get_option('rpmmacrosdir')
106 if rpmmacrosdir != 'no'
107 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
109 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
112 pkgdatadir = join_paths(datadir, 'systemd')
113 environmentdir = join_paths(prefixdir, 'lib/environment.d')
114 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
115 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
116 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
117 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
118 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
119 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
120 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
121 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
122 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
123 pkgincludedir = join_paths(includedir, 'systemd')
124 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
125 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
126 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
127 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
128 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
129 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
130 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
131 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
132 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
133 udevhomedir = udevlibexecdir
134 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
135 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
136 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
137 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
138 factorydir = join_paths(datadir, 'factory')
139 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
140 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
141 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
142 catalogstatedir = join_paths(systemdstatedir, 'catalog')
143 randomseeddir = join_paths(localstatedir, 'lib/systemd')
145 docdir = get_option('docdir')
147 docdir = join_paths(datadir, 'doc/systemd')
150 dbuspolicydir = get_option('dbuspolicydir')
151 if dbuspolicydir == ''
152 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
155 dbussessionservicedir = get_option('dbussessionservicedir')
156 if dbussessionservicedir == ''
157 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
160 dbussystemservicedir = get_option('dbussystemservicedir')
161 if dbussystemservicedir == ''
162 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
165 pamlibdir = get_option('pamlibdir')
167 pamlibdir = join_paths(rootlibdir, 'security')
170 pamconfdir = get_option('pamconfdir')
172 pamconfdir = join_paths(sysconfdir, 'pam.d')
175 memory_accounting_default = get_option('memory-accounting-default')
177 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
178 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
179 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
180 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
181 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
182 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
183 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
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_ON_OFF', memory_accounting_default ? 'on' : 'off')
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 name : '@0@ is supported'.format(arg))
375 add_project_arguments(arg, language : 'c')
380 link_test_c = files('tools/meson-link-test.c')
382 # --as-needed and --no-undefined are provided by meson by default,
383 # run mesonconf to see what is enabled
384 foreach arg : ['-Wl,-z,relro',
389 have = run_command(check_compilation_sh,
390 cc.cmd_array(), '-x', 'c', arg,
391 '-include', link_test_c).returncode() == 0
392 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
393 if have and (arg != '-pie' or not fuzzer_build)
394 add_project_link_arguments(arg, language : 'c')
398 # Check if various sanitizers are supported
400 foreach arg : ['address']
402 have = run_command(check_compilation_sh,
403 cc.cmd_array(), '-x', 'c',
404 '-fsanitize=@0@'.format(arg),
405 '-include', link_test_c).returncode() == 0
406 message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
412 if get_option('buildtype') != 'debug'
413 foreach arg : ['-ffunction-sections',
415 if cc.has_argument(arg,
416 name : '@0@ is supported'.format(arg))
417 add_project_arguments(arg, language : 'c')
421 foreach arg : ['-Wl,--gc-sections']
422 have = run_command(check_compilation_sh,
423 cc.cmd_array(), '-x', 'c', arg,
424 '-include', link_test_c).returncode() == 0
425 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
427 add_project_link_arguments(arg, language : 'c')
432 cpp = ' '.join(cc.cmd_array()) + ' -E'
434 #####################################################################
435 # compilation result tests
437 conf.set('_GNU_SOURCE', true)
438 conf.set('__SANE_USERSPACE_TYPES__', true)
440 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
441 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
442 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
443 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
444 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
445 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
446 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
450 #include <linux/ethtool.h>
451 #include <linux/fib_rules.h>
453 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
455 foreach decl : ['char16_t',
458 'struct ethtool_link_settings',
459 'struct fib_rule_uid_range',
462 # We get -1 if the size cannot be determined
463 have = cc.sizeof(decl, prefix : decl_headers) > 0
464 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
467 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
468 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
469 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
470 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
471 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
472 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
473 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
474 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
475 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
476 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
477 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
478 # if_tunnel.h is buggy and cannot be included on its own
479 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
480 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
481 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
482 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
483 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
484 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
485 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
486 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
487 ['NDA_IFINDEX', 'linux/neighbour.h'],
488 ['IFA_FLAGS', 'linux/if_addr.h'],
489 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
490 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
491 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
493 prefix = decl.length() > 2 ? decl[2] : ''
494 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
495 conf.set10('HAVE_' + decl[0], have)
498 foreach ident : ['secure_getenv', '__secure_getenv']
499 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
503 ['memfd_create', '''#include <sys/mman.h>'''],
504 ['gettid', '''#include <sys/types.h>
505 #include <unistd.h>'''],
506 ['pivot_root', '''#include <stdlib.h>
507 #include <unistd.h>'''], # no known header declares pivot_root
508 ['name_to_handle_at', '''#include <sys/types.h>
509 #include <sys/stat.h>
510 #include <fcntl.h>'''],
511 ['setns', '''#include <sched.h>'''],
512 ['renameat2', '''#include <stdio.h>
513 #include <fcntl.h>'''],
514 ['kcmp', '''#include <linux/kcmp.h>'''],
515 ['keyctl', '''#include <sys/types.h>
516 #include <keyutils.h>'''],
517 ['copy_file_range', '''#include <sys/syscall.h>
518 #include <unistd.h>'''],
519 ['bpf', '''#include <sys/syscall.h>
520 #include <unistd.h>'''],
521 ['explicit_bzero' , '''#include <string.h>'''],
524 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
525 conf.set10('HAVE_' + ident[0].to_upper(), have)
528 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
529 conf.set10('USE_SYS_RANDOM_H', true)
530 conf.set10('HAVE_GETRANDOM', true)
532 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
533 conf.set10('USE_SYS_RANDOM_H', false)
534 conf.set10('HAVE_GETRANDOM', have)
537 #####################################################################
539 sed = find_program('sed')
540 awk = find_program('awk')
541 m4 = find_program('m4')
542 stat = find_program('stat')
543 git = find_program('git', required : false)
544 env = find_program('env')
546 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
547 mkdir_p = 'mkdir -p $DESTDIR/@0@'
548 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
549 splash_bmp = files('test/splash.bmp')
551 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
552 # /usr/sbin, /sbin, and fall back to the default from middle column.
553 progs = [['quotaon', '/usr/sbin/quotaon' ],
554 ['quotacheck', '/usr/sbin/quotacheck' ],
555 ['kill', '/usr/bin/kill' ],
556 ['kmod', '/usr/bin/kmod' ],
557 ['kexec', '/usr/sbin/kexec' ],
558 ['sulogin', '/usr/sbin/sulogin' ],
559 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
560 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
561 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
562 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
565 path = get_option(prog[0] + '-path')
567 message('Using @1@ for @0@'.format(prog[0], path))
569 exe = find_program(prog[0],
570 '/usr/sbin/' + prog[0],
573 path = exe.found() ? exe.path() : prog[1]
575 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
576 conf.set_quoted(name, path)
577 substs.set(name, path)
580 conf.set_quoted('TELINIT', get_option('telinit-path'))
582 if run_command('ln', '--relative', '--help').returncode() != 0
583 error('ln does not support --relative')
586 ############################################################
588 gperf = find_program('gperf')
590 gperf_test_format = '''
592 const char * in_word_set(const char *, @0@);
595 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
596 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
597 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
598 if cc.compiles(gperf_test)
599 gperf_len_type = 'size_t'
601 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
602 if cc.compiles(gperf_test)
603 gperf_len_type = 'unsigned'
605 error('unable to determine gperf len type')
608 message('gperf len type is @0@'.format(gperf_len_type))
609 conf.set('GPERF_LEN_TYPE', gperf_len_type,
610 description : 'The type of gperf "len" parameter')
612 ############################################################
614 if not cc.has_header('sys/capability.h')
615 error('POSIX caps headers not found')
617 foreach header : ['crypt.h',
620 'linux/vm_sockets.h',
622 'valgrind/memcheck.h',
623 'valgrind/valgrind.h',
626 conf.set10('HAVE_' + header.underscorify().to_upper(),
627 cc.has_header(header))
630 ############################################################
632 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
633 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
634 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
636 default_hierarchy = get_option('default-hierarchy')
637 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
638 description : 'default cgroup hierarchy as string')
639 if default_hierarchy == 'legacy'
640 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
641 elif default_hierarchy == 'hybrid'
642 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
644 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
647 time_epoch = get_option('time-epoch')
650 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
652 time_epoch = time_epoch.to_int()
653 conf.set('TIME_EPOCH', time_epoch)
655 system_uid_max = get_option('system-uid-max')
656 if system_uid_max == ''
657 system_uid_max = run_command(
659 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
660 '/etc/login.defs').stdout().strip()
661 if system_uid_max == ''
662 system_uid_max = '999'
665 system_uid_max = system_uid_max.to_int()
666 conf.set('SYSTEM_UID_MAX', system_uid_max)
667 substs.set('systemuidmax', system_uid_max)
668 message('maximum system UID is @0@'.format(system_uid_max))
670 system_gid_max = get_option('system-gid-max')
671 if system_gid_max == ''
672 system_gid_max = run_command(
674 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
675 '/etc/login.defs').stdout().strip()
676 if system_gid_max == ''
677 system_gid_max = '999'
680 system_gid_max = system_gid_max.to_int()
681 conf.set('SYSTEM_GID_MAX', system_gid_max)
682 substs.set('systemgidmax', system_gid_max)
683 message('maximum system GID is @0@'.format(system_gid_max))
685 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
686 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
687 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
688 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
689 substs.set('dynamicuidmin', dynamic_uid_min)
690 substs.set('dynamicuidmax', dynamic_uid_max)
692 container_uid_base_min = get_option('container-uid-base-min').to_int()
693 container_uid_base_max = get_option('container-uid-base-max').to_int()
694 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
695 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
696 substs.set('containeruidbasemin', container_uid_base_min)
697 substs.set('containeruidbasemax', container_uid_base_max)
699 nobody_user = get_option('nobody-user')
700 nobody_group = get_option('nobody-group')
702 getent_result = run_command('getent', 'passwd', '65534')
703 if getent_result.returncode() == 0
704 name = getent_result.stdout().split(':')[0]
705 if name != nobody_user
706 message('WARNING:\n' +
707 ' 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) +
708 ' Your build will result in an user table setup that is incompatible with the local system.')
711 id_result = run_command('id', '-u', nobody_user)
712 if id_result.returncode() == 0
713 id = id_result.stdout().to_int()
715 message('WARNING:\n' +
716 ' 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) +
717 ' Your build will result in an user table setup that is incompatible with the local system.')
721 getent_result = run_command('getent', 'group', '65534')
722 if getent_result.returncode() == 0
723 name = getent_result.stdout().split(':')[0]
724 if name != nobody_group
725 message('WARNING:\n' +
726 ' 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) +
727 ' Your build will result in an group table setup that is incompatible with the local system.')
730 id_result = run_command('id', '-g', nobody_group)
731 if id_result.returncode() == 0
732 id = id_result.stdout().to_int()
734 message('WARNING:\n' +
735 ' 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) +
736 ' Your build will result in an group table setup that is incompatible with the local system.')
739 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
740 message('WARNING:\n' +
741 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
742 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
745 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
746 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
747 substs.set('NOBODY_USER_NAME', nobody_user)
748 substs.set('NOBODY_GROUP_NAME', nobody_group)
750 tty_gid = get_option('tty-gid')
751 conf.set('TTY_GID', tty_gid)
752 substs.set('TTY_GID', tty_gid)
754 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
755 if get_option('users-gid') != ''
756 users_gid = get_option('users-gid').to_int()
760 substs.set('USERS_GID', users_gid)
762 if get_option('adm-group')
763 m4_defines += ['-DENABLE_ADM_GROUP']
766 if get_option('wheel-group')
767 m4_defines += ['-DENABLE_WHEEL_GROUP']
770 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
771 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
773 kill_user_processes = get_option('default-kill-user-processes')
774 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
775 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
777 dns_servers = get_option('dns-servers')
778 conf.set_quoted('DNS_SERVERS', dns_servers)
779 substs.set('DNS_SERVERS', dns_servers)
781 ntp_servers = get_option('ntp-servers')
782 conf.set_quoted('NTP_SERVERS', ntp_servers)
783 substs.set('NTP_SERVERS', ntp_servers)
785 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
787 substs.set('SUSHELL', get_option('debug-shell'))
788 substs.set('DEBUGTTY', get_option('debug-tty'))
790 debug = get_option('debug')
791 enable_debug_hashmap = false
792 enable_debug_mmap_cache = false
794 foreach name : debug.split(',')
796 enable_debug_hashmap = true
797 elif name == 'mmap-cache'
798 enable_debug_mmap_cache = true
800 message('unknown debug option "@0@", ignoring'.format(name))
804 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
805 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
807 #####################################################################
809 threads = dependency('threads')
810 librt = cc.find_library('rt')
811 libm = cc.find_library('m')
812 libdl = cc.find_library('dl')
813 libcrypt = cc.find_library('crypt')
815 libcap = dependency('libcap', required : false)
816 if not libcap.found()
817 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
818 libcap = cc.find_library('cap')
821 libmount = dependency('mount',
823 required : not fuzzer_build)
825 want_seccomp = get_option('seccomp')
826 if want_seccomp != 'false' and not fuzzer_build
827 libseccomp = dependency('libseccomp',
828 version : '>= 2.3.1',
829 required : want_seccomp == 'true')
830 have = libseccomp.found()
835 conf.set10('HAVE_SECCOMP', have)
836 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
838 want_selinux = get_option('selinux')
839 if want_selinux != 'false' and not fuzzer_build
840 libselinux = dependency('libselinux',
841 version : '>= 2.1.9',
842 required : want_selinux == 'true')
843 have = libselinux.found()
848 conf.set10('HAVE_SELINUX', have)
849 m4_defines += have ? ['-DHAVE_SELINUX'] : []
851 want_apparmor = get_option('apparmor')
852 if want_apparmor != 'false' and not fuzzer_build
853 libapparmor = dependency('libapparmor',
854 required : want_apparmor == 'true')
855 have = libapparmor.found()
860 conf.set10('HAVE_APPARMOR', have)
861 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
863 smack_run_label = get_option('smack-run-label')
864 if smack_run_label != ''
865 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
866 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
869 want_polkit = get_option('polkit')
870 install_polkit = false
871 install_polkit_pkla = false
872 if want_polkit != 'false' and not fuzzer_build
873 install_polkit = true
875 libpolkit = dependency('polkit-gobject-1',
877 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
878 message('Old polkit detected, will install pkla files')
879 install_polkit_pkla = true
882 conf.set10('ENABLE_POLKIT', install_polkit)
884 want_acl = get_option('acl')
885 if want_acl != 'false' and not fuzzer_build
886 libacl = cc.find_library('acl', required : want_acl == 'true')
887 have = libacl.found()
892 conf.set10('HAVE_ACL', have)
893 m4_defines += have ? ['-DHAVE_ACL'] : []
895 want_audit = get_option('audit')
896 if want_audit != 'false' and not fuzzer_build
897 libaudit = dependency('audit', required : want_audit == 'true')
898 have = libaudit.found()
903 conf.set10('HAVE_AUDIT', have)
905 want_blkid = get_option('blkid')
906 if want_blkid != 'false' and not fuzzer_build
907 libblkid = dependency('blkid', required : want_blkid == 'true')
908 have = libblkid.found()
913 conf.set10('HAVE_BLKID', have)
915 want_kmod = get_option('kmod')
916 if want_kmod != 'false' and not fuzzer_build
917 libkmod = dependency('libkmod',
919 required : want_kmod == 'true')
920 have = libkmod.found()
925 conf.set10('HAVE_KMOD', have)
927 want_pam = get_option('pam')
928 if want_pam != 'false' and not fuzzer_build
929 libpam = cc.find_library('pam', required : want_pam == 'true')
930 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
931 have = libpam.found() and libpam_misc.found()
937 conf.set10('HAVE_PAM', have)
938 m4_defines += have ? ['-DHAVE_PAM'] : []
940 want_microhttpd = get_option('microhttpd')
941 if want_microhttpd != 'false' and not fuzzer_build
942 libmicrohttpd = dependency('libmicrohttpd',
943 version : '>= 0.9.33',
944 required : want_microhttpd == 'true')
945 have = libmicrohttpd.found()
950 conf.set10('HAVE_MICROHTTPD', have)
951 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
953 want_libcryptsetup = get_option('libcryptsetup')
954 if want_libcryptsetup != 'false' and not fuzzer_build
955 libcryptsetup = dependency('libcryptsetup',
956 version : '>= 1.6.0',
957 required : want_libcryptsetup == 'true')
958 have = libcryptsetup.found()
963 conf.set10('HAVE_LIBCRYPTSETUP', have)
965 want_libcurl = get_option('libcurl')
966 if want_libcurl != 'false' and not fuzzer_build
967 libcurl = dependency('libcurl',
968 version : '>= 7.32.0',
969 required : want_libcurl == 'true')
970 have = libcurl.found()
975 conf.set10('HAVE_LIBCURL', have)
976 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
978 want_libidn = get_option('libidn')
979 want_libidn2 = get_option('libidn2')
980 if want_libidn == 'true' and want_libidn2 == 'true'
981 error('libidn and libidn2 cannot be requested simultaneously')
984 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
985 libidn = dependency('libidn',
986 required : want_libidn == 'true')
987 have = libidn.found()
992 conf.set10('HAVE_LIBIDN', have)
993 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
994 if not have and want_libidn2 != 'false' and not fuzzer_build
995 # libidn is used for both libidn and libidn2 objects
996 libidn = dependency('libidn2',
997 required : want_libidn2 == 'true')
998 have = libidn.found()
1002 conf.set10('HAVE_LIBIDN2', have)
1003 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1005 want_libiptc = get_option('libiptc')
1006 if want_libiptc != 'false' and not fuzzer_build
1007 libiptc = dependency('libiptc',
1008 required : want_libiptc == 'true')
1009 have = libiptc.found()
1014 conf.set10('HAVE_LIBIPTC', have)
1015 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1017 want_qrencode = get_option('qrencode')
1018 if want_qrencode != 'false' and not fuzzer_build
1019 libqrencode = dependency('libqrencode',
1020 required : want_qrencode == 'true')
1021 have = libqrencode.found()
1026 conf.set10('HAVE_QRENCODE', have)
1028 want_gcrypt = get_option('gcrypt')
1029 if want_gcrypt != 'false' and not fuzzer_build
1030 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1031 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1032 have = libgcrypt.found() and libgpg_error.found()
1037 # link to neither of the libs if one is not found
1041 conf.set10('HAVE_GCRYPT', have)
1043 want_gnutls = get_option('gnutls')
1044 if want_gnutls != 'false' and not fuzzer_build
1045 libgnutls = dependency('gnutls',
1046 version : '>= 3.1.4',
1047 required : want_gnutls == 'true')
1048 have = libgnutls.found()
1053 conf.set10('HAVE_GNUTLS', have)
1055 want_elfutils = get_option('elfutils')
1056 if want_elfutils != 'false' and not fuzzer_build
1057 libdw = dependency('libdw',
1058 required : want_elfutils == 'true')
1059 have = libdw.found()
1064 conf.set10('HAVE_ELFUTILS', have)
1066 want_zlib = get_option('zlib')
1067 if want_zlib != 'false' and not fuzzer_build
1068 libz = dependency('zlib',
1069 required : want_zlib == 'true')
1075 conf.set10('HAVE_ZLIB', have)
1077 want_bzip2 = get_option('bzip2')
1078 if want_bzip2 != 'false' and not fuzzer_build
1079 libbzip2 = cc.find_library('bz2',
1080 required : want_bzip2 == 'true')
1081 have = libbzip2.found()
1086 conf.set10('HAVE_BZIP2', have)
1088 want_xz = get_option('xz')
1089 if want_xz != 'false' and not fuzzer_build
1090 libxz = dependency('liblzma',
1091 required : want_xz == 'true')
1092 have = libxz.found()
1097 conf.set10('HAVE_XZ', have)
1099 want_lz4 = get_option('lz4')
1100 if want_lz4 != 'false' and not fuzzer_build
1101 liblz4 = dependency('liblz4',
1102 required : want_lz4 == 'true')
1103 have = liblz4.found()
1108 conf.set10('HAVE_LZ4', have)
1110 want_xkbcommon = get_option('xkbcommon')
1111 if want_xkbcommon != 'false' and not fuzzer_build
1112 libxkbcommon = dependency('xkbcommon',
1113 version : '>= 0.3.0',
1114 required : want_xkbcommon == 'true')
1115 have = libxkbcommon.found()
1120 conf.set10('HAVE_XKBCOMMON', have)
1122 want_pcre2 = get_option('pcre2')
1123 if want_pcre2 != 'false'
1124 libpcre2 = dependency('libpcre2-8',
1125 required : want_pcre2 == 'true')
1126 have = libpcre2.found()
1131 conf.set10('HAVE_PCRE2', have)
1133 want_glib = get_option('glib')
1134 if want_glib != 'false' and not fuzzer_build
1135 libglib = dependency('glib-2.0',
1136 version : '>= 2.22.0',
1137 required : want_glib == 'true')
1138 libgobject = dependency('gobject-2.0',
1139 version : '>= 2.22.0',
1140 required : want_glib == 'true')
1141 libgio = dependency('gio-2.0',
1142 required : want_glib == 'true')
1143 have = libglib.found() and libgobject.found() and libgio.found()
1150 conf.set10('HAVE_GLIB', have)
1152 want_dbus = get_option('dbus')
1153 if want_dbus != 'false' and not fuzzer_build
1154 libdbus = dependency('dbus-1',
1155 version : '>= 1.3.2',
1156 required : want_dbus == 'true')
1157 have = libdbus.found()
1162 conf.set10('HAVE_DBUS', have)
1164 default_dnssec = get_option('default-dnssec')
1166 default_dnssec = 'no'
1168 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1169 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1170 default_dnssec = 'no'
1172 conf.set('DEFAULT_DNSSEC_MODE',
1173 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1174 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1176 want_importd = get_option('importd')
1177 if want_importd != 'false'
1178 have = (conf.get('HAVE_LIBCURL') == 1 and
1179 conf.get('HAVE_ZLIB') == 1 and
1180 conf.get('HAVE_BZIP2') == 1 and
1181 conf.get('HAVE_XZ') == 1 and
1182 conf.get('HAVE_GCRYPT') == 1)
1183 if want_importd == 'true' and not have
1184 error('importd support was requested, but dependencies are not available')
1189 conf.set10('ENABLE_IMPORTD', have)
1191 want_remote = get_option('remote')
1192 if want_remote != 'false'
1193 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1194 conf.get('HAVE_LIBCURL') == 1]
1195 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1196 # it's possible to build one without the other. Complain only if
1197 # support was explictly requested. The auxiliary files like sysusers
1198 # config should be installed when any of the programs are built.
1199 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1200 error('remote support was requested, but dependencies are not available')
1202 have = have_deps[0] or have_deps[1]
1206 conf.set10('ENABLE_REMOTE', have)
1208 foreach term : ['utmp',
1239 have = get_option(term)
1240 name = 'ENABLE_' + term.underscorify().to_upper()
1241 conf.set10(name, have)
1242 m4_defines += have ? ['-D' + name] : []
1245 want_tests = get_option('tests')
1246 install_tests = get_option('install-tests')
1247 slow_tests = get_option('slow-tests')
1251 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1253 #####################################################################
1255 if get_option('efi')
1256 efi_arch = host_machine.cpu_family()
1258 if efi_arch == 'x86'
1259 EFI_MACHINE_TYPE_NAME = 'ia32'
1260 gnu_efi_arch = 'ia32'
1261 elif efi_arch == 'x86_64'
1262 EFI_MACHINE_TYPE_NAME = 'x64'
1263 gnu_efi_arch = 'x86_64'
1264 elif efi_arch == 'arm'
1265 EFI_MACHINE_TYPE_NAME = 'arm'
1266 gnu_efi_arch = 'arm'
1267 elif efi_arch == 'aarch64'
1268 EFI_MACHINE_TYPE_NAME = 'aa64'
1269 gnu_efi_arch = 'aarch64'
1271 EFI_MACHINE_TYPE_NAME = ''
1276 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1278 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1282 conf.set10('ENABLE_EFI', have)
1284 #####################################################################
1286 config_h = configure_file(
1287 output : 'config.h',
1288 configuration : conf)
1290 includes = include_directories('src/basic',
1300 'src/libsystemd/sd-bus',
1301 'src/libsystemd/sd-device',
1302 'src/libsystemd/sd-hwdb',
1303 'src/libsystemd/sd-id128',
1304 'src/libsystemd/sd-netlink',
1305 'src/libsystemd/sd-network',
1306 'src/libsystemd-network',
1309 add_project_arguments('-include', 'config.h', language : 'c')
1313 subdir('src/systemd')
1315 subdir('src/libsystemd')
1316 subdir('src/libsystemd-network')
1317 subdir('src/journal')
1320 libjournal_core = static_library(
1322 libjournal_core_sources,
1324 include_directories : includes,
1327 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1328 libsystemd = shared_library(
1330 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1331 version : libsystemd_version,
1332 include_directories : includes,
1333 link_args : ['-shared',
1334 '-Wl,--version-script=' + libsystemd_sym_path],
1335 link_with : [libbasic,
1337 link_whole : [libsystemd_static,
1339 dependencies : [threads,
1343 link_depends : libsystemd_sym,
1345 install_dir : rootlibdir)
1347 ############################################################
1349 # binaries that have --help and are intended for use by humans,
1350 # usually, but not always, installed in /bin.
1351 public_programs = []
1353 subdir('src/libudev')
1354 subdir('src/shared')
1357 subdir('src/network')
1359 subdir('src/analyze')
1360 subdir('src/journal-remote')
1361 subdir('src/coredump')
1362 subdir('src/hostname')
1363 subdir('src/import')
1364 subdir('src/kernel-install')
1365 subdir('src/locale')
1366 subdir('src/machine')
1367 subdir('src/nspawn')
1368 subdir('src/resolve')
1369 subdir('src/timedate')
1370 subdir('src/timesync')
1371 subdir('src/vconsole')
1372 subdir('src/boot/efi')
1379 ############################################################
1381 # only static linking apart from libdl, to make sure that the
1382 # module is linked to all libraries that it uses.
1383 test_dlopen = executable(
1386 include_directories : includes,
1387 link_with : [libbasic],
1388 dependencies : [libdl])
1390 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1391 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1392 ['mymachines', 'ENABLE_MACHINED'],
1393 ['resolve', 'ENABLE_RESOLVE']]
1395 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1399 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1400 version_script_arg = join_paths(meson.current_source_dir(), sym)
1402 nss = shared_library(
1404 'src/nss-@0@/nss-@0@.c'.format(module),
1406 include_directories : includes,
1407 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1408 link_args : ['-Wl,-z,nodelete',
1410 '-Wl,--version-script=' + version_script_arg,
1412 link_with : [libsystemd_static,
1414 dependencies : [threads,
1418 install_dir : rootlibdir)
1420 # We cannot use shared_module because it does not support version suffix.
1421 # Unfortunately shared_library insists on creating the symlink…
1422 meson.add_install_script('sh', '-c',
1423 'rm $DESTDIR@0@/libnss_@1@.so'
1424 .format(rootlibdir, module))
1426 test('dlopen-nss_' + module,
1428 args : [nss.full_path()]) # path to dlopen must include a slash
1432 ############################################################
1434 executable('systemd',
1436 include_directories : includes,
1437 link_with : [libcore,
1439 dependencies : [threads,
1445 install_rpath : rootlibexecdir,
1447 install_dir : rootlibexecdir)
1449 exe = executable('systemd-analyze',
1450 systemd_analyze_sources,
1451 include_directories : includes,
1452 link_with : [libcore,
1454 dependencies : [threads,
1460 install_rpath : rootlibexecdir,
1462 public_programs += [exe]
1464 executable('systemd-journald',
1465 systemd_journald_sources,
1466 include_directories : includes,
1467 link_with : [libjournal_core,
1469 dependencies : [threads,
1473 install_rpath : rootlibexecdir,
1475 install_dir : rootlibexecdir)
1477 exe = executable('systemd-cat',
1478 systemd_cat_sources,
1479 include_directories : includes,
1480 link_with : [libjournal_core,
1482 dependencies : [threads],
1483 install_rpath : rootlibexecdir,
1485 public_programs += [exe]
1487 exe = executable('journalctl',
1489 include_directories : includes,
1490 link_with : [libshared],
1491 dependencies : [threads,
1496 install_rpath : rootlibexecdir,
1498 install_dir : rootbindir)
1499 public_programs += [exe]
1501 executable('systemd-getty-generator',
1502 'src/getty-generator/getty-generator.c',
1503 include_directories : includes,
1504 link_with : [libshared],
1505 install_rpath : rootlibexecdir,
1507 install_dir : systemgeneratordir)
1509 executable('systemd-debug-generator',
1510 'src/debug-generator/debug-generator.c',
1511 include_directories : includes,
1512 link_with : [libshared],
1513 install_rpath : rootlibexecdir,
1515 install_dir : systemgeneratordir)
1517 executable('systemd-fstab-generator',
1518 'src/fstab-generator/fstab-generator.c',
1519 'src/core/mount-setup.c',
1520 include_directories : includes,
1521 link_with : [libshared],
1522 install_rpath : rootlibexecdir,
1524 install_dir : systemgeneratordir)
1526 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1527 executable('30-systemd-environment-d-generator',
1528 'src/environment-d-generator/environment-d-generator.c',
1529 include_directories : includes,
1530 link_with : [libshared],
1531 install_rpath : rootlibexecdir,
1533 install_dir : userenvgeneratordir)
1535 meson.add_install_script(meson_make_symlink,
1536 join_paths(sysconfdir, 'environment'),
1537 join_paths(environmentdir, '99-environment.conf'))
1540 if conf.get('ENABLE_HIBERNATE') == 1
1541 executable('systemd-hibernate-resume-generator',
1542 'src/hibernate-resume/hibernate-resume-generator.c',
1543 include_directories : includes,
1544 link_with : [libshared],
1545 install_rpath : rootlibexecdir,
1547 install_dir : systemgeneratordir)
1549 executable('systemd-hibernate-resume',
1550 'src/hibernate-resume/hibernate-resume.c',
1551 include_directories : includes,
1552 link_with : [libshared],
1553 install_rpath : rootlibexecdir,
1555 install_dir : rootlibexecdir)
1558 if conf.get('HAVE_BLKID') == 1
1559 executable('systemd-gpt-auto-generator',
1560 'src/gpt-auto-generator/gpt-auto-generator.c',
1561 'src/basic/blkid-util.h',
1562 include_directories : includes,
1563 link_with : [libshared],
1564 dependencies : libblkid,
1565 install_rpath : rootlibexecdir,
1567 install_dir : systemgeneratordir)
1569 exe = executable('systemd-dissect',
1570 'src/dissect/dissect.c',
1571 include_directories : includes,
1572 link_with : [libshared],
1573 install_rpath : rootlibexecdir,
1575 install_dir : rootlibexecdir)
1576 public_programs += [exe]
1579 if conf.get('ENABLE_RESOLVE') == 1
1580 executable('systemd-resolved',
1581 systemd_resolved_sources,
1582 include_directories : includes,
1583 link_with : [libshared,
1585 libsystemd_resolve_core],
1586 dependencies : [threads,
1590 install_rpath : rootlibexecdir,
1592 install_dir : rootlibexecdir)
1594 exe = executable('systemd-resolve',
1595 systemd_resolve_sources,
1596 include_directories : includes,
1597 link_with : [libshared,
1599 libsystemd_resolve_core],
1600 dependencies : [threads,
1604 install_rpath : rootlibexecdir,
1606 public_programs += [exe]
1609 if conf.get('ENABLE_LOGIND') == 1
1610 executable('systemd-logind',
1611 systemd_logind_sources,
1612 include_directories : includes,
1613 link_with : [liblogind_core,
1615 dependencies : [threads,
1617 install_rpath : rootlibexecdir,
1619 install_dir : rootlibexecdir)
1621 exe = executable('loginctl',
1623 include_directories : includes,
1624 link_with : [libshared],
1625 dependencies : [threads,
1628 install_rpath : rootlibexecdir,
1630 install_dir : rootbindir)
1631 public_programs += [exe]
1633 exe = executable('systemd-inhibit',
1634 'src/login/inhibit.c',
1635 include_directories : includes,
1636 link_with : [libshared],
1637 install_rpath : rootlibexecdir,
1639 install_dir : rootbindir)
1640 public_programs += [exe]
1642 if conf.get('HAVE_PAM') == 1
1643 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1644 pam_systemd = shared_library(
1648 include_directories : includes,
1649 link_args : ['-shared',
1650 '-Wl,--version-script=' + version_script_arg],
1651 link_with : [libsystemd_static,
1653 dependencies : [threads,
1656 link_depends : pam_systemd_sym,
1658 install_dir : pamlibdir)
1660 test('dlopen-pam_systemd',
1662 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1666 if conf.get('HAVE_PAM') == 1
1667 executable('systemd-user-sessions',
1668 'src/user-sessions/user-sessions.c',
1669 include_directories : includes,
1670 link_with : [libshared],
1671 install_rpath : rootlibexecdir,
1673 install_dir : rootlibexecdir)
1676 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1677 exe = executable('bootctl',
1678 'src/boot/bootctl.c',
1679 include_directories : includes,
1680 link_with : [libshared],
1681 dependencies : [libblkid],
1682 install_rpath : rootlibexecdir,
1684 public_programs += [exe]
1687 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1688 include_directories : includes,
1689 link_with : [libshared],
1690 dependencies : [threads],
1691 install_rpath : rootlibexecdir,
1693 public_programs += [exe]
1695 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1696 include_directories : includes,
1697 link_with : [libshared],
1698 dependencies : [threads,
1703 install_rpath : rootlibexecdir,
1705 install_dir : rootbindir)
1706 public_programs += [exe]
1708 if conf.get('ENABLE_BACKLIGHT') == 1
1709 executable('systemd-backlight',
1710 'src/backlight/backlight.c',
1711 include_directories : includes,
1712 link_with : [libshared],
1713 install_rpath : rootlibexecdir,
1715 install_dir : rootlibexecdir)
1718 if conf.get('ENABLE_RFKILL') == 1
1719 executable('systemd-rfkill',
1720 'src/rfkill/rfkill.c',
1721 include_directories : includes,
1722 link_with : [libshared],
1723 install_rpath : rootlibexecdir,
1725 install_dir : rootlibexecdir)
1728 executable('systemd-system-update-generator',
1729 'src/system-update-generator/system-update-generator.c',
1730 include_directories : includes,
1731 link_with : [libshared],
1732 install_rpath : rootlibexecdir,
1734 install_dir : systemgeneratordir)
1736 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1737 executable('systemd-cryptsetup',
1738 'src/cryptsetup/cryptsetup.c',
1739 include_directories : includes,
1740 link_with : [libshared],
1741 dependencies : [libcryptsetup],
1742 install_rpath : rootlibexecdir,
1744 install_dir : rootlibexecdir)
1746 executable('systemd-cryptsetup-generator',
1747 'src/cryptsetup/cryptsetup-generator.c',
1748 include_directories : includes,
1749 link_with : [libshared],
1750 dependencies : [libcryptsetup],
1751 install_rpath : rootlibexecdir,
1753 install_dir : systemgeneratordir)
1755 executable('systemd-veritysetup',
1756 'src/veritysetup/veritysetup.c',
1757 include_directories : includes,
1758 link_with : [libshared],
1759 dependencies : [libcryptsetup],
1760 install_rpath : rootlibexecdir,
1762 install_dir : rootlibexecdir)
1764 executable('systemd-veritysetup-generator',
1765 'src/veritysetup/veritysetup-generator.c',
1766 include_directories : includes,
1767 link_with : [libshared],
1768 dependencies : [libcryptsetup],
1769 install_rpath : rootlibexecdir,
1771 install_dir : systemgeneratordir)
1774 if conf.get('HAVE_SYSV_COMPAT') == 1
1775 executable('systemd-sysv-generator',
1776 'src/sysv-generator/sysv-generator.c',
1777 include_directories : includes,
1778 link_with : [libshared],
1779 install_rpath : rootlibexecdir,
1781 install_dir : systemgeneratordir)
1783 executable('systemd-rc-local-generator',
1784 'src/rc-local-generator/rc-local-generator.c',
1785 include_directories : includes,
1786 link_with : [libshared],
1787 install_rpath : rootlibexecdir,
1789 install_dir : systemgeneratordir)
1792 if conf.get('ENABLE_HOSTNAMED') == 1
1793 executable('systemd-hostnamed',
1794 'src/hostname/hostnamed.c',
1795 include_directories : includes,
1796 link_with : [libshared],
1797 install_rpath : rootlibexecdir,
1799 install_dir : rootlibexecdir)
1801 exe = executable('hostnamectl',
1802 'src/hostname/hostnamectl.c',
1803 include_directories : includes,
1804 link_with : [libshared],
1805 install_rpath : rootlibexecdir,
1807 public_programs += [exe]
1810 if conf.get('ENABLE_LOCALED') == 1
1811 if conf.get('HAVE_XKBCOMMON') == 1
1812 # logind will load libxkbcommon.so dynamically on its own
1818 executable('systemd-localed',
1819 systemd_localed_sources,
1820 include_directories : includes,
1821 link_with : [libshared],
1822 dependencies : deps,
1823 install_rpath : rootlibexecdir,
1825 install_dir : rootlibexecdir)
1827 exe = executable('localectl',
1829 include_directories : includes,
1830 link_with : [libshared],
1831 install_rpath : rootlibexecdir,
1833 public_programs += [exe]
1836 if conf.get('ENABLE_TIMEDATED') == 1
1837 executable('systemd-timedated',
1838 'src/timedate/timedated.c',
1839 include_directories : includes,
1840 link_with : [libshared],
1841 install_rpath : rootlibexecdir,
1843 install_dir : rootlibexecdir)
1845 exe = executable('timedatectl',
1846 'src/timedate/timedatectl.c',
1847 include_directories : includes,
1848 install_rpath : rootlibexecdir,
1849 link_with : [libshared],
1851 public_programs += [exe]
1854 if conf.get('ENABLE_TIMESYNCD') == 1
1855 executable('systemd-timesyncd',
1856 systemd_timesyncd_sources,
1857 include_directories : includes,
1858 link_with : [libshared],
1859 dependencies : [threads,
1861 install_rpath : rootlibexecdir,
1863 install_dir : rootlibexecdir)
1866 if conf.get('ENABLE_MACHINED') == 1
1867 executable('systemd-machined',
1868 systemd_machined_sources,
1869 include_directories : includes,
1870 link_with : [libmachine_core,
1872 install_rpath : rootlibexecdir,
1874 install_dir : rootlibexecdir)
1876 exe = executable('machinectl',
1877 'src/machine/machinectl.c',
1878 include_directories : includes,
1879 link_with : [libshared],
1880 dependencies : [threads,
1883 install_rpath : rootlibexecdir,
1885 install_dir : rootbindir)
1886 public_programs += [exe]
1889 if conf.get('ENABLE_IMPORTD') == 1
1890 executable('systemd-importd',
1891 systemd_importd_sources,
1892 include_directories : includes,
1893 link_with : [libshared],
1894 dependencies : [threads],
1895 install_rpath : rootlibexecdir,
1897 install_dir : rootlibexecdir)
1899 systemd_pull = executable('systemd-pull',
1900 systemd_pull_sources,
1901 include_directories : includes,
1902 link_with : [libshared],
1903 dependencies : [libcurl,
1908 install_rpath : rootlibexecdir,
1910 install_dir : rootlibexecdir)
1912 systemd_import = executable('systemd-import',
1913 systemd_import_sources,
1914 include_directories : includes,
1915 link_with : [libshared],
1916 dependencies : [libcurl,
1920 install_rpath : rootlibexecdir,
1922 install_dir : rootlibexecdir)
1924 systemd_export = executable('systemd-export',
1925 systemd_export_sources,
1926 include_directories : includes,
1927 link_with : [libshared],
1928 dependencies : [libcurl,
1932 install_rpath : rootlibexecdir,
1934 install_dir : rootlibexecdir)
1935 public_programs += [systemd_pull, systemd_import, systemd_export]
1938 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1939 exe = executable('systemd-journal-upload',
1940 systemd_journal_upload_sources,
1941 include_directories : includes,
1942 link_with : [libshared],
1943 dependencies : [threads,
1948 install_rpath : rootlibexecdir,
1950 install_dir : rootlibexecdir)
1951 public_programs += [exe]
1954 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1955 s_j_remote = executable('systemd-journal-remote',
1956 systemd_journal_remote_sources,
1957 include_directories : includes,
1958 link_with : [libshared],
1959 dependencies : [threads,
1964 install_rpath : rootlibexecdir,
1966 install_dir : rootlibexecdir)
1968 s_j_gatewayd = executable('systemd-journal-gatewayd',
1969 systemd_journal_gatewayd_sources,
1970 include_directories : includes,
1971 link_with : [libshared],
1972 dependencies : [threads,
1977 install_rpath : rootlibexecdir,
1979 install_dir : rootlibexecdir)
1980 public_programs += [s_j_remote, s_j_gatewayd]
1983 if conf.get('ENABLE_COREDUMP') == 1
1984 executable('systemd-coredump',
1985 systemd_coredump_sources,
1986 include_directories : includes,
1987 link_with : [libshared],
1988 dependencies : [threads,
1993 install_rpath : rootlibexecdir,
1995 install_dir : rootlibexecdir)
1997 exe = executable('coredumpctl',
1998 coredumpctl_sources,
1999 include_directories : includes,
2000 link_with : [libshared],
2001 dependencies : [threads,
2004 install_rpath : rootlibexecdir,
2006 public_programs += [exe]
2009 if conf.get('ENABLE_BINFMT') == 1
2010 exe = executable('systemd-binfmt',
2011 'src/binfmt/binfmt.c',
2012 include_directories : includes,
2013 link_with : [libshared],
2014 install_rpath : rootlibexecdir,
2016 install_dir : rootlibexecdir)
2017 public_programs += [exe]
2019 meson.add_install_script('sh', '-c',
2020 mkdir_p.format(binfmtdir))
2021 meson.add_install_script('sh', '-c',
2022 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2025 if conf.get('ENABLE_VCONSOLE') == 1
2026 executable('systemd-vconsole-setup',
2027 'src/vconsole/vconsole-setup.c',
2028 include_directories : includes,
2029 link_with : [libshared],
2030 install_rpath : rootlibexecdir,
2032 install_dir : rootlibexecdir)
2035 if conf.get('ENABLE_RANDOMSEED') == 1
2036 executable('systemd-random-seed',
2037 'src/random-seed/random-seed.c',
2038 include_directories : includes,
2039 link_with : [libshared],
2040 install_rpath : rootlibexecdir,
2042 install_dir : rootlibexecdir)
2045 if conf.get('ENABLE_FIRSTBOOT') == 1
2046 executable('systemd-firstboot',
2047 'src/firstboot/firstboot.c',
2048 include_directories : includes,
2049 link_with : [libshared],
2050 dependencies : [libcrypt],
2051 install_rpath : rootlibexecdir,
2053 install_dir : rootbindir)
2056 executable('systemd-remount-fs',
2057 'src/remount-fs/remount-fs.c',
2058 'src/core/mount-setup.c',
2059 'src/core/mount-setup.h',
2060 include_directories : includes,
2061 link_with : [libshared],
2062 install_rpath : rootlibexecdir,
2064 install_dir : rootlibexecdir)
2066 executable('systemd-machine-id-setup',
2067 'src/machine-id-setup/machine-id-setup-main.c',
2068 'src/core/machine-id-setup.c',
2069 'src/core/machine-id-setup.h',
2070 include_directories : includes,
2071 link_with : [libshared],
2072 install_rpath : rootlibexecdir,
2074 install_dir : rootbindir)
2076 executable('systemd-fsck',
2078 include_directories : includes,
2079 link_with : [libshared],
2080 install_rpath : rootlibexecdir,
2082 install_dir : rootlibexecdir)
2084 executable('systemd-growfs',
2085 'src/partition/growfs.c',
2086 include_directories : includes,
2087 link_with : [libshared],
2088 dependencies : [libcryptsetup],
2089 install_rpath : rootlibexecdir,
2091 install_dir : rootlibexecdir)
2093 executable('systemd-makefs',
2094 'src/partition/makefs.c',
2095 include_directories : includes,
2096 link_with : [libshared],
2097 install_rpath : rootlibexecdir,
2099 install_dir : rootlibexecdir)
2101 executable('systemd-sleep',
2102 'src/sleep/sleep.c',
2103 include_directories : includes,
2104 link_with : [libshared],
2105 install_rpath : rootlibexecdir,
2107 install_dir : rootlibexecdir)
2109 exe = executable('systemd-sysctl',
2110 'src/sysctl/sysctl.c',
2111 include_directories : includes,
2112 link_with : [libshared],
2113 install_rpath : rootlibexecdir,
2115 install_dir : rootlibexecdir)
2116 public_programs += [exe]
2118 executable('systemd-ac-power',
2119 'src/ac-power/ac-power.c',
2120 include_directories : includes,
2121 link_with : [libshared],
2122 install_rpath : rootlibexecdir,
2124 install_dir : rootlibexecdir)
2126 exe = executable('systemd-detect-virt',
2127 'src/detect-virt/detect-virt.c',
2128 include_directories : includes,
2129 link_with : [libshared],
2130 install_rpath : rootlibexecdir,
2132 public_programs += [exe]
2134 exe = executable('systemd-delta',
2135 'src/delta/delta.c',
2136 include_directories : includes,
2137 link_with : [libshared],
2138 install_rpath : rootlibexecdir,
2140 public_programs += [exe]
2142 exe = executable('systemd-escape',
2143 'src/escape/escape.c',
2144 include_directories : includes,
2145 link_with : [libshared],
2146 install_rpath : rootlibexecdir,
2148 install_dir : rootbindir)
2149 public_programs += [exe]
2151 exe = executable('systemd-notify',
2152 'src/notify/notify.c',
2153 include_directories : includes,
2154 link_with : [libshared],
2155 install_rpath : rootlibexecdir,
2157 install_dir : rootbindir)
2158 public_programs += [exe]
2160 executable('systemd-volatile-root',
2161 'src/volatile-root/volatile-root.c',
2162 include_directories : includes,
2163 link_with : [libshared],
2164 install_rpath : rootlibexecdir,
2166 install_dir : rootlibexecdir)
2168 executable('systemd-cgroups-agent',
2169 'src/cgroups-agent/cgroups-agent.c',
2170 include_directories : includes,
2171 link_with : [libshared],
2172 install_rpath : rootlibexecdir,
2174 install_dir : rootlibexecdir)
2176 exe = executable('systemd-path',
2178 include_directories : includes,
2179 link_with : [libshared],
2180 install_rpath : rootlibexecdir,
2182 public_programs += [exe]
2184 exe = executable('systemd-ask-password',
2185 'src/ask-password/ask-password.c',
2186 include_directories : includes,
2187 link_with : [libshared],
2188 install_rpath : rootlibexecdir,
2190 install_dir : rootbindir)
2191 public_programs += [exe]
2193 executable('systemd-reply-password',
2194 'src/reply-password/reply-password.c',
2195 include_directories : includes,
2196 link_with : [libshared],
2197 install_rpath : rootlibexecdir,
2199 install_dir : rootlibexecdir)
2201 exe = executable('systemd-tty-ask-password-agent',
2202 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2203 include_directories : includes,
2204 link_with : [libshared],
2205 install_rpath : rootlibexecdir,
2207 install_dir : rootbindir)
2208 public_programs += [exe]
2210 exe = executable('systemd-cgls',
2212 include_directories : includes,
2213 link_with : [libshared],
2214 install_rpath : rootlibexecdir,
2216 public_programs += [exe]
2218 exe = executable('systemd-cgtop',
2219 'src/cgtop/cgtop.c',
2220 include_directories : includes,
2221 link_with : [libshared],
2222 install_rpath : rootlibexecdir,
2224 public_programs += [exe]
2226 executable('systemd-initctl',
2227 'src/initctl/initctl.c',
2228 include_directories : includes,
2229 link_with : [libshared],
2230 install_rpath : rootlibexecdir,
2232 install_dir : rootlibexecdir)
2234 exe = executable('systemd-mount',
2235 'src/mount/mount-tool.c',
2236 include_directories : includes,
2237 link_with : [libshared],
2238 install_rpath : rootlibexecdir,
2240 public_programs += [exe]
2242 meson.add_install_script(meson_make_symlink,
2243 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2245 exe = executable('systemd-run',
2247 include_directories : includes,
2248 link_with : [libshared],
2249 install_rpath : rootlibexecdir,
2251 public_programs += [exe]
2253 exe = executable('systemd-stdio-bridge',
2254 'src/stdio-bridge/stdio-bridge.c',
2255 include_directories : includes,
2256 link_with : [libshared],
2257 install_rpath : rootlibexecdir,
2259 public_programs += [exe]
2261 exe = executable('busctl',
2262 'src/busctl/busctl.c',
2263 'src/busctl/busctl-introspect.c',
2264 'src/busctl/busctl-introspect.h',
2265 include_directories : includes,
2266 link_with : [libshared],
2267 install_rpath : rootlibexecdir,
2269 public_programs += [exe]
2271 if conf.get('ENABLE_SYSUSERS') == 1
2272 exe = executable('systemd-sysusers',
2273 'src/sysusers/sysusers.c',
2274 include_directories : includes,
2275 link_with : [libshared],
2276 install_rpath : rootlibexecdir,
2278 install_dir : rootbindir)
2279 public_programs += [exe]
2282 if conf.get('ENABLE_TMPFILES') == 1
2283 exe = executable('systemd-tmpfiles',
2284 'src/tmpfiles/tmpfiles.c',
2285 include_directories : includes,
2286 link_with : [libshared],
2287 dependencies : [libacl],
2288 install_rpath : rootlibexecdir,
2290 install_dir : rootbindir)
2291 public_programs += [exe]
2293 test('test-systemd-tmpfiles',
2294 test_systemd_tmpfiles_py,
2295 args : exe.full_path())
2296 # https://github.com/mesonbuild/meson/issues/2681
2299 if conf.get('ENABLE_HWDB') == 1
2300 exe = executable('systemd-hwdb',
2302 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2303 include_directories : includes,
2304 link_with : [libudev_static],
2305 install_rpath : udev_rpath,
2307 install_dir : rootbindir)
2308 public_programs += [exe]
2311 if conf.get('ENABLE_QUOTACHECK') == 1
2312 executable('systemd-quotacheck',
2313 'src/quotacheck/quotacheck.c',
2314 include_directories : includes,
2315 link_with : [libshared],
2316 install_rpath : rootlibexecdir,
2318 install_dir : rootlibexecdir)
2321 exe = executable('systemd-socket-proxyd',
2322 'src/socket-proxy/socket-proxyd.c',
2323 include_directories : includes,
2324 link_with : [libshared],
2325 dependencies : [threads],
2326 install_rpath : rootlibexecdir,
2328 install_dir : rootlibexecdir)
2329 public_programs += [exe]
2331 exe = executable('systemd-udevd',
2332 systemd_udevd_sources,
2333 include_directories : includes,
2334 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2335 link_with : [libudev_core,
2338 dependencies : [threads,
2343 install_rpath : udev_rpath,
2345 install_dir : rootlibexecdir)
2346 public_programs += [exe]
2348 exe = executable('udevadm',
2350 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2351 include_directories : includes,
2352 link_with : [libudev_core,
2355 dependencies : [threads,
2360 install_rpath : udev_rpath,
2362 install_dir : rootbindir)
2363 public_programs += [exe]
2365 executable('systemd-shutdown',
2366 systemd_shutdown_sources,
2367 include_directories : includes,
2368 link_with : [libshared],
2369 install_rpath : rootlibexecdir,
2371 install_dir : rootlibexecdir)
2373 executable('systemd-update-done',
2374 'src/update-done/update-done.c',
2375 include_directories : includes,
2376 link_with : [libshared],
2377 install_rpath : rootlibexecdir,
2379 install_dir : rootlibexecdir)
2381 executable('systemd-update-utmp',
2382 'src/update-utmp/update-utmp.c',
2383 include_directories : includes,
2384 link_with : [libshared],
2385 dependencies : [libaudit],
2386 install_rpath : rootlibexecdir,
2388 install_dir : rootlibexecdir)
2390 if conf.get('HAVE_KMOD') == 1
2391 executable('systemd-modules-load',
2392 'src/modules-load/modules-load.c',
2393 include_directories : includes,
2394 link_with : [libshared],
2395 dependencies : [libkmod],
2396 install_rpath : rootlibexecdir,
2398 install_dir : rootlibexecdir)
2400 meson.add_install_script('sh', '-c',
2401 mkdir_p.format(modulesloaddir))
2402 meson.add_install_script('sh', '-c',
2403 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2406 exe = executable('systemd-nspawn',
2407 systemd_nspawn_sources,
2408 'src/core/mount-setup.c', # FIXME: use a variable?
2409 'src/core/mount-setup.h',
2410 'src/core/loopback-setup.c',
2411 'src/core/loopback-setup.h',
2412 include_directories : [includes, include_directories('src/nspawn')],
2413 link_with : [libshared],
2414 dependencies : [libacl,
2418 install_rpath : rootlibexecdir,
2420 public_programs += [exe]
2422 if conf.get('ENABLE_NETWORKD') == 1
2423 executable('systemd-networkd',
2424 systemd_networkd_sources,
2425 include_directories : includes,
2426 link_with : [libnetworkd_core,
2430 dependencies : [threads],
2431 install_rpath : rootlibexecdir,
2433 install_dir : rootlibexecdir)
2435 executable('systemd-networkd-wait-online',
2436 systemd_networkd_wait_online_sources,
2437 include_directories : includes,
2438 link_with : [libnetworkd_core,
2440 install_rpath : rootlibexecdir,
2442 install_dir : rootlibexecdir)
2444 exe = executable('networkctl',
2446 include_directories : includes,
2447 link_with : [libsystemd_network,
2449 install_rpath : rootlibexecdir,
2451 install_dir : rootbindir)
2452 public_programs += [exe]
2455 executable('systemd-sulogin-shell',
2456 ['src/sulogin-shell/sulogin-shell.c'],
2457 include_directories : includes,
2458 link_with : [libshared],
2459 install_rpath : rootlibexecdir,
2461 install_dir : rootlibexecdir)
2463 ############################################################
2465 foreach tuple : tests
2467 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2468 dependencies = tuple[2]
2469 condition = tuple.length() >= 4 ? tuple[3] : ''
2470 type = tuple.length() >= 5 ? tuple[4] : ''
2471 defs = tuple.length() >= 6 ? tuple[5] : []
2472 incs = tuple.length() >= 7 ? tuple[6] : includes
2475 name = sources[0].split('/')[-1].split('.')[0]
2476 if type.startswith('timeout=')
2477 timeout = type.split('=')[1].to_int()
2480 if want_tests == 'false'
2481 message('Not compiling @0@ because tests is set to false'.format(name))
2482 elif condition == '' or conf.get(condition) == 1
2486 include_directories : incs,
2487 link_with : link_with,
2488 dependencies : dependencies,
2490 install_rpath : rootlibexecdir,
2491 install : install_tests,
2492 install_dir : join_paths(testsdir, type))
2495 message('@0@ is a manual test'.format(name))
2496 elif type == 'unsafe' and want_tests != 'unsafe'
2497 message('@0@ is an unsafe test'.format(name))
2504 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2508 test_libsystemd_sym = executable(
2509 'test-libsystemd-sym',
2510 test_libsystemd_sym_c,
2511 include_directories : includes,
2512 link_with : [libsystemd],
2513 install : install_tests,
2514 install_dir : testsdir)
2515 test('test-libsystemd-sym',
2516 test_libsystemd_sym)
2518 test_libudev_sym = executable(
2521 include_directories : includes,
2522 c_args : ['-Wno-deprecated-declarations'],
2523 link_with : [libudev],
2524 install : install_tests,
2525 install_dir : testsdir)
2526 test('test-libudev-sym',
2529 ############################################################
2533 foreach tuple : fuzzers
2535 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2536 dependencies = tuple[2]
2537 defs = tuple.length() >= 4 ? tuple[3] : []
2538 incs = tuple.length() >= 5 ? tuple[4] : includes
2541 dependencies += fuzzing_engine
2543 sources += 'src/fuzz/fuzz-main.c'
2546 name = sources[0].split('/')[-1].split('.')[0]
2548 fuzzer_exes += executable(
2551 include_directories : [incs, include_directories('src/fuzz')],
2552 link_with : link_with,
2553 dependencies : dependencies,
2558 run_target('fuzzers',
2559 depends : fuzzer_exes,
2562 ############################################################
2564 make_directive_index_py = find_program('tools/make-directive-index.py')
2565 make_man_index_py = find_program('tools/make-man-index.py')
2566 xml_helper_py = find_program('tools/xml_helper.py')
2567 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2571 subdir('sysusers.d')
2572 subdir('tmpfiles.d')
2577 subdir('shell-completion/bash')
2578 subdir('shell-completion/zsh')
2579 subdir('docs/sysvinit')
2580 subdir('docs/var-log')
2582 # FIXME: figure out if the warning is true:
2583 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2584 install_subdir('factory/etc',
2585 install_dir : factorydir)
2588 install_data('xorg/50-systemd-user.sh',
2589 install_dir : xinitrcdir)
2590 install_data('modprobe.d/systemd.conf',
2591 install_dir : modprobedir)
2592 install_data('README',
2599 'TRANSIENT-SETTINGS.md',
2601 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2602 install_dir : docdir)
2604 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2605 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2607 ############################################################
2609 meson_check_help = find_program('tools/meson-check-help.sh')
2611 foreach exec : public_programs
2612 name = exec.full_path().split('/')[-1]
2613 test('check-help-' + name,
2615 args : [exec.full_path()])
2618 ############################################################
2621 foreach p : fuzz_regression_tests
2622 a = p.split('/')[-3]
2623 b = p.split('/')[-2]
2624 c = p.split('/')[-1]
2627 build = sanitize_address
2629 error('unknown sanitizer @0@'.format(a))
2632 name = '@1@:@0@'.format(a, b)
2635 if want_tests == 'false'
2636 message('Not compiling @0@ because tests is set to false'.format(name))
2637 elif not sanitizers.contains(a)
2638 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2640 exe = custom_target(
2644 command : [env, 'ln', '-fs',
2645 join_paths(build.full_path(), b),
2647 build_by_default : true)
2649 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2654 if want_tests != 'false' and slow_tests
2655 test(c, env, args : [exe.full_path(),
2656 join_paths(meson.source_root(),
2657 'test/fuzz-regressions',
2662 ############################################################
2665 all_files = run_command(
2667 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2670 all_files = files(all_files.stdout().split())
2675 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2679 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2683 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2686 command : [meson_git_contrib_sh])
2690 git_head = run_command(
2692 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2693 'rev-parse', 'HEAD']).stdout().strip()
2694 git_head_short = run_command(
2696 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2697 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2701 command : ['git', 'archive',
2702 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2704 '--prefix', 'systemd-@0@/'.format(git_head),
2708 ############################################################
2710 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2713 depends : [man, libsystemd, libudev],
2714 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2716 ############################################################
2719 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2721 'prefix directory: @0@'.format(prefixdir),
2722 'rootprefix directory: @0@'.format(rootprefixdir),
2723 'sysconf directory: @0@'.format(sysconfdir),
2724 'include directory: @0@'.format(includedir),
2725 'lib directory: @0@'.format(libdir),
2726 'rootlib directory: @0@'.format(rootlibdir),
2727 'SysV init scripts: @0@'.format(sysvinit_path),
2728 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2729 'PAM modules directory: @0@'.format(pamlibdir),
2730 'PAM configuration directory: @0@'.format(pamconfdir),
2731 'RPM macros directory: @0@'.format(rpmmacrosdir),
2732 'modprobe.d directory: @0@'.format(modprobedir),
2733 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2734 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2735 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2736 'bash completions directory: @0@'.format(bashcompletiondir),
2737 'zsh completions directory: @0@'.format(zshcompletiondir),
2738 'extra start script: @0@'.format(get_option('rc-local')),
2739 'extra stop script: @0@'.format(get_option('halt-local')),
2740 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2741 get_option('debug-tty')),
2742 'TTY GID: @0@'.format(tty_gid),
2743 'users GID: @0@'.format(users_gid),
2744 'maximum system UID: @0@'.format(system_uid_max),
2745 'maximum system GID: @0@'.format(system_gid_max),
2746 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2747 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2748 'minimum container UID base: @0@'.format(container_uid_base_min),
2749 'maximum container UID base: @0@'.format(container_uid_base_max),
2750 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2751 'render group access mode: @0@'.format(get_option('group-render-mode')),
2752 'certificate root directory: @0@'.format(get_option('certificate-root')),
2753 'support URL: @0@'.format(support_url),
2754 'nobody user name: @0@'.format(nobody_user),
2755 'nobody group name: @0@'.format(nobody_group),
2756 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2757 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2759 'default DNSSEC mode: @0@'.format(default_dnssec),
2760 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2761 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2763 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2764 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2766 'default DNS servers: @0@'.format(alt_dns_servers),
2767 'default NTP servers: @0@'.format(alt_ntp_servers)]
2769 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2770 '@@0@'.format(time_epoch)).stdout().strip()
2772 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2775 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2776 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2777 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2779 if conf.get('ENABLE_EFI') == 1
2781 'efi arch: @0@'.format(efi_arch)]
2785 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2786 'EFI CC @0@'.format(efi_cc),
2787 'EFI lib directory: @0@'.format(efi_libdir),
2788 'EFI lds directory: @0@'.format(efi_ldsdir),
2789 'EFI include directory: @0@'.format(efi_incdir)]
2842 ['legacy pkla', install_polkit_pkla],
2844 ['gnu-efi', have_gnu_efi],
2851 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2854 ['man pages', want_man],
2855 ['html pages', want_html],
2856 ['man page indices', want_man and have_lxml],
2857 ['split /usr', conf.get('HAVE_SPLIT_USR') == 1],
2862 ['adm group', get_option('adm-group')],
2863 ['wheel group', get_option('wheel-group')],
2866 ['debug mmap cache'],
2869 cond = tuple.get(1, '')
2871 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2872 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2873 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2878 missing += [tuple[0]]
2884 'enabled features: @0@'.format(', '.join(found)),
2886 'disabled features: @0@'.format(', '.join(missing)),
2888 message('\n '.join(status))
2890 if rootprefixdir != rootprefix_default
2891 message('WARNING:\n' +
2892 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2893 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2894 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))