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.22.0'
31 libudev_version = '1.6.10'
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 if get_option('split-usr') == 'auto'
58 split_usr = run_command('test', '-L', '/bin').returncode() != 0
60 split_usr = get_option('split-usr') == 'true'
62 conf.set10('HAVE_SPLIT_USR', split_usr,
63 description : '/usr/bin and /bin directories are separate')
65 if get_option('split-bin') == 'auto'
66 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
68 split_bin = get_option('split-bin') == 'true'
70 conf.set10('HAVE_SPLIT_BIN', split_bin,
71 description : 'bin and sbin directories are separate')
73 rootprefixdir = get_option('rootprefix')
74 # Unusual rootprefixdir values are used by some distros
75 # (see https://github.com/systemd/systemd/pull/7461).
76 rootprefix_default = split_usr ? '/' : '/usr'
77 if rootprefixdir == ''
78 rootprefixdir = rootprefix_default
81 sysvinit_path = get_option('sysvinit-path')
82 sysvrcnd_path = get_option('sysvrcnd-path')
83 have = sysvinit_path != '' and sysvrcnd_path != ''
84 conf.set10('HAVE_SYSV_COMPAT', have,
85 description : 'SysV init scripts and rcN.d links are supported')
86 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
88 # join_paths ignore the preceding arguments if an absolute component is
89 # encountered, so this should canonicalize various paths when they are
90 # absolute or relative.
91 prefixdir = get_option('prefix')
92 if not prefixdir.startswith('/')
93 error('Prefix is not absolute: "@0@"'.format(prefixdir))
95 bindir = join_paths(prefixdir, get_option('bindir'))
96 libdir = join_paths(prefixdir, get_option('libdir'))
97 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
98 includedir = join_paths(prefixdir, get_option('includedir'))
99 datadir = join_paths(prefixdir, get_option('datadir'))
100 localstatedir = join_paths('/', get_option('localstatedir'))
102 rootbindir = join_paths(rootprefixdir, 'bin')
103 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
104 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
106 rootlibdir = get_option('rootlibdir')
108 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
111 # Dirs of external packages
112 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
113 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
114 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
115 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
116 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
117 varlogdir = join_paths(localstatedir, 'log')
118 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
119 rpmmacrosdir = get_option('rpmmacrosdir')
120 if rpmmacrosdir != 'no'
121 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
123 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
126 pkgdatadir = join_paths(datadir, 'systemd')
127 environmentdir = join_paths(prefixdir, 'lib/environment.d')
128 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
129 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
130 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
131 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
132 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
133 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
134 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
135 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
136 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
137 pkgincludedir = join_paths(includedir, 'systemd')
138 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
139 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
140 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
141 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
142 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
143 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
144 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
145 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
146 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
147 udevhomedir = udevlibexecdir
148 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
149 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
150 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
151 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
152 factorydir = join_paths(datadir, 'factory')
153 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
154 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
155 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
156 catalogstatedir = join_paths(systemdstatedir, 'catalog')
157 randomseeddir = join_paths(localstatedir, 'lib/systemd')
159 docdir = get_option('docdir')
161 docdir = join_paths(datadir, 'doc/systemd')
164 dbuspolicydir = get_option('dbuspolicydir')
165 if dbuspolicydir == ''
166 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
169 dbussessionservicedir = get_option('dbussessionservicedir')
170 if dbussessionservicedir == ''
171 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
174 dbussystemservicedir = get_option('dbussystemservicedir')
175 if dbussystemservicedir == ''
176 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
179 pamlibdir = get_option('pamlibdir')
181 pamlibdir = join_paths(rootlibdir, 'security')
184 pamconfdir = get_option('pamconfdir')
186 pamconfdir = join_paths(sysconfdir, 'pam.d')
189 memory_accounting_default = get_option('memory-accounting-default')
191 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
192 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
193 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
194 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
195 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
196 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
197 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
199 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
201 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
202 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
203 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
204 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
205 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
206 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
207 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
208 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
209 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
210 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
211 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
212 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
213 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
214 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
215 conf.set_quoted('ROOTPREFIX', rootprefixdir)
216 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
217 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
218 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
219 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
220 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
221 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
222 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
223 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
224 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
225 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
226 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
227 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
228 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
229 conf.set_quoted('LIBDIR', libdir)
230 conf.set_quoted('ROOTLIBDIR', rootlibdir)
231 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
232 conf.set_quoted('BOOTLIBDIR', bootlibdir)
233 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
234 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
235 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
236 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
237 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
238 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
239 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
240 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
242 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
243 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
245 substs.set('prefix', prefixdir)
246 substs.set('exec_prefix', prefixdir)
247 substs.set('libdir', libdir)
248 substs.set('rootlibdir', rootlibdir)
249 substs.set('includedir', includedir)
250 substs.set('pkgsysconfdir', pkgsysconfdir)
251 substs.set('bindir', bindir)
252 substs.set('rootbindir', rootbindir)
253 substs.set('rootlibexecdir', rootlibexecdir)
254 substs.set('systemunitdir', systemunitdir)
255 substs.set('userunitdir', userunitdir)
256 substs.set('systempresetdir', systempresetdir)
257 substs.set('userpresetdir', userpresetdir)
258 substs.set('udevhwdbdir', udevhwdbdir)
259 substs.set('udevrulesdir', udevrulesdir)
260 substs.set('udevlibexecdir', udevlibexecdir)
261 substs.set('catalogdir', catalogdir)
262 substs.set('tmpfilesdir', tmpfilesdir)
263 substs.set('sysusersdir', sysusersdir)
264 substs.set('sysctldir', sysctldir)
265 substs.set('binfmtdir', binfmtdir)
266 substs.set('modulesloaddir', modulesloaddir)
267 substs.set('systemgeneratordir', systemgeneratordir)
268 substs.set('usergeneratordir', usergeneratordir)
269 substs.set('systemenvgeneratordir', systemenvgeneratordir)
270 substs.set('userenvgeneratordir', userenvgeneratordir)
271 substs.set('systemshutdowndir', systemshutdowndir)
272 substs.set('systemsleepdir', systemsleepdir)
273 substs.set('VARLOGDIR', varlogdir)
274 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
275 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
276 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
277 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
278 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
279 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
280 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
281 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
283 #####################################################################
285 cc = meson.get_compiler('c')
286 pkgconfig = import('pkgconfig')
287 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
288 meson_build_sh = find_program('tools/meson-build.sh')
290 if get_option('tests') != 'false'
291 cxx = find_program('c++', required : false)
293 # Used only for tests
298 want_ossfuzz = get_option('oss-fuzz')
299 want_libfuzzer = get_option('llvm-fuzz')
300 fuzzer_build = want_ossfuzz or want_libfuzzer
301 if want_ossfuzz and want_libfuzzer
302 error('only one of oss-fuzz and llvm-fuzz can be specified')
305 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
308 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
311 foreach arg : ['-Wextra',
314 '-Wmissing-include-dirs',
315 '-Wold-style-definition',
318 '-Wdeclaration-after-statement',
320 '-Wsuggest-attribute=noreturn',
321 '-Werror=missing-prototypes',
322 '-Werror=implicit-function-declaration',
323 '-Werror=missing-declarations',
324 '-Werror=return-type',
325 '-Werror=incompatible-pointer-types',
327 '-Wstrict-prototypes',
329 '-Wmissing-noreturn',
330 '-Wimplicit-fallthrough=5',
333 '-Wstrict-aliasing=2',
340 '-fdiagnostics-show-option',
341 '-fno-strict-aliasing',
342 '-fvisibility=hidden',
344 '-fstack-protector-strong',
345 '--param=ssp-buffer-size=4',
347 if cc.has_argument(arg)
348 add_project_arguments(arg, language : 'c')
352 # the oss-fuzz fuzzers are not built with -fPIE, so don't
353 # enable it when we are linking against them
355 if cc.has_argument('-fPIE')
356 add_project_arguments('-fPIE', language : 'c')
360 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
361 # arguments, just emits a warnings. So test for the "positive" version instead.
362 foreach arg : ['unused-parameter',
363 'missing-field-initializers',
366 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
368 if cc.has_argument('-W' + arg)
369 add_project_arguments('-Wno-' + arg, language : 'c')
375 #include <inttypes.h>
376 typedef uint64_t usec_t;
377 usec_t now(clockid_t clock);
382 ''', name : '-Werror=shadow with local shadowing')
383 add_project_arguments('-Werror=shadow', language : 'c')
386 if cc.get_id() == 'clang'
387 foreach arg : ['-Wno-typedef-redefinition',
388 '-Wno-gnu-variable-sized-type-not-at-end',
390 if cc.has_argument(arg,
391 name : '@0@ is supported'.format(arg))
392 add_project_arguments(arg, language : 'c')
397 link_test_c = files('tools/meson-link-test.c')
399 # --as-needed and --no-undefined are provided by meson by default,
400 # run mesonconf to see what is enabled
401 foreach arg : ['-Wl,-z,relro',
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'))
410 if have and (arg != '-pie' or not fuzzer_build)
411 add_project_link_arguments(arg, language : 'c')
415 if get_option('buildtype') != 'debug'
416 foreach arg : ['-ffunction-sections',
418 if cc.has_argument(arg,
419 name : '@0@ is supported'.format(arg))
420 add_project_arguments(arg, language : 'c')
424 foreach arg : ['-Wl,--gc-sections']
425 have = run_command(check_compilation_sh,
426 cc.cmd_array(), '-x', 'c', arg,
427 '-include', link_test_c).returncode() == 0
428 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
430 add_project_link_arguments(arg, language : 'c')
435 cpp = ' '.join(cc.cmd_array()) + ' -E'
437 #####################################################################
438 # compilation result tests
440 conf.set('_GNU_SOURCE', true)
441 conf.set('__SANE_USERSPACE_TYPES__', true)
443 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
444 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
445 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
446 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
447 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
448 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
449 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
453 #include <linux/ethtool.h>
454 #include <linux/fib_rules.h>
455 #include <linux/stat.h>
456 #include <sys/stat.h>
458 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
460 foreach decl : ['char16_t',
463 'struct ethtool_link_settings',
464 'struct fib_rule_uid_range',
468 # We get -1 if the size cannot be determined
469 have = cc.sizeof(decl, prefix : decl_headers) > 0
470 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
473 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
474 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
475 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
476 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
477 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
478 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
479 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
480 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
481 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
482 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
483 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
484 # if_tunnel.h is buggy and cannot be included on its own
485 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
486 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
487 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
488 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
489 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
490 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
491 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
492 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
493 ['NDA_IFINDEX', 'linux/neighbour.h'],
494 ['IFA_FLAGS', 'linux/if_addr.h'],
495 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
496 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
497 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
499 prefix = decl.length() > 2 ? decl[2] : ''
500 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
501 conf.set10('HAVE_' + decl[0], have)
504 foreach ident : ['secure_getenv', '__secure_getenv']
505 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
509 ['memfd_create', '''#include <sys/mman.h>'''],
510 ['gettid', '''#include <sys/types.h>
511 #include <unistd.h>'''],
512 ['pivot_root', '''#include <stdlib.h>
513 #include <unistd.h>'''], # no known header declares pivot_root
514 ['name_to_handle_at', '''#include <sys/types.h>
515 #include <sys/stat.h>
516 #include <fcntl.h>'''],
517 ['setns', '''#include <sched.h>'''],
518 ['renameat2', '''#include <stdio.h>
519 #include <fcntl.h>'''],
520 ['kcmp', '''#include <linux/kcmp.h>'''],
521 ['keyctl', '''#include <sys/types.h>
522 #include <keyutils.h>'''],
523 ['copy_file_range', '''#include <sys/syscall.h>
524 #include <unistd.h>'''],
525 ['bpf', '''#include <sys/syscall.h>
526 #include <unistd.h>'''],
527 ['statx', '''#include <sys/types.h>
528 #include <sys/stat.h>
529 #include <unistd.h>'''],
530 ['explicit_bzero' , '''#include <string.h>'''],
531 ['reallocarray', '''#include <malloc.h>'''],
534 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
535 conf.set10('HAVE_' + ident[0].to_upper(), have)
538 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
539 conf.set10('USE_SYS_RANDOM_H', true)
540 conf.set10('HAVE_GETRANDOM', true)
542 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
543 conf.set10('USE_SYS_RANDOM_H', false)
544 conf.set10('HAVE_GETRANDOM', have)
547 #####################################################################
549 sed = find_program('sed')
550 awk = find_program('awk')
551 m4 = find_program('m4')
552 stat = find_program('stat')
553 git = find_program('git', required : false)
554 env = find_program('env')
555 perl = find_program('perl', required : false)
557 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
558 mkdir_p = 'mkdir -p $DESTDIR/@0@'
559 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
560 splash_bmp = files('test/splash.bmp')
562 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
563 # /usr/sbin, /sbin, and fall back to the default from middle column.
564 progs = [['quotaon', '/usr/sbin/quotaon' ],
565 ['quotacheck', '/usr/sbin/quotacheck' ],
566 ['kill', '/usr/bin/kill' ],
567 ['kmod', '/usr/bin/kmod' ],
568 ['kexec', '/usr/sbin/kexec' ],
569 ['sulogin', '/usr/sbin/sulogin' ],
570 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
571 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
572 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
573 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
576 path = get_option(prog[0] + '-path')
578 message('Using @1@ for @0@'.format(prog[0], path))
580 exe = find_program(prog[0],
581 '/usr/sbin/' + prog[0],
584 path = exe.found() ? exe.path() : prog[1]
586 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
587 conf.set_quoted(name, path)
588 substs.set(name, path)
591 conf.set_quoted('TELINIT', get_option('telinit-path'))
593 if run_command('ln', '--relative', '--help').returncode() != 0
594 error('ln does not support --relative (added in coreutils 8.16)')
597 ############################################################
599 gperf = find_program('gperf')
601 gperf_test_format = '''
603 const char * in_word_set(const char *, @0@);
606 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
607 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
608 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
609 if cc.compiles(gperf_test)
610 gperf_len_type = 'size_t'
612 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
613 if cc.compiles(gperf_test)
614 gperf_len_type = 'unsigned'
616 error('unable to determine gperf len type')
619 message('gperf len type is @0@'.format(gperf_len_type))
620 conf.set('GPERF_LEN_TYPE', gperf_len_type,
621 description : 'The type of gperf "len" parameter')
623 ############################################################
625 if not cc.has_header('sys/capability.h')
626 error('POSIX caps headers not found')
628 foreach header : ['crypt.h',
631 'linux/vm_sockets.h',
633 'valgrind/memcheck.h',
634 'valgrind/valgrind.h',
637 conf.set10('HAVE_' + header.underscorify().to_upper(),
638 cc.has_header(header))
641 ############################################################
643 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
644 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
645 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
647 default_hierarchy = get_option('default-hierarchy')
648 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
649 description : 'default cgroup hierarchy as string')
650 if default_hierarchy == 'legacy'
651 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
652 elif default_hierarchy == 'hybrid'
653 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
655 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
658 time_epoch = get_option('time-epoch')
661 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
663 time_epoch = time_epoch.to_int()
664 conf.set('TIME_EPOCH', time_epoch)
666 system_uid_max = get_option('system-uid-max')
667 if system_uid_max == ''
668 system_uid_max = run_command(
670 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
671 '/etc/login.defs').stdout().strip()
672 if system_uid_max == ''
673 system_uid_max = '999'
676 system_uid_max = system_uid_max.to_int()
677 conf.set('SYSTEM_UID_MAX', system_uid_max)
678 substs.set('systemuidmax', system_uid_max)
679 message('maximum system UID is @0@'.format(system_uid_max))
681 system_gid_max = get_option('system-gid-max')
682 if system_gid_max == ''
683 system_gid_max = run_command(
685 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
686 '/etc/login.defs').stdout().strip()
687 if system_gid_max == ''
688 system_gid_max = '999'
691 system_gid_max = system_gid_max.to_int()
692 conf.set('SYSTEM_GID_MAX', system_gid_max)
693 substs.set('systemgidmax', system_gid_max)
694 message('maximum system GID is @0@'.format(system_gid_max))
696 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
697 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
698 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
699 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
700 substs.set('dynamicuidmin', dynamic_uid_min)
701 substs.set('dynamicuidmax', dynamic_uid_max)
703 container_uid_base_min = get_option('container-uid-base-min').to_int()
704 container_uid_base_max = get_option('container-uid-base-max').to_int()
705 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
706 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
707 substs.set('containeruidbasemin', container_uid_base_min)
708 substs.set('containeruidbasemax', container_uid_base_max)
710 nobody_user = get_option('nobody-user')
711 nobody_group = get_option('nobody-group')
713 getent_result = run_command('getent', 'passwd', '65534')
714 if getent_result.returncode() == 0
715 name = getent_result.stdout().split(':')[0]
716 if name != nobody_user
717 message('WARNING:\n' +
718 ' 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) +
719 ' Your build will result in an user table setup that is incompatible with the local system.')
722 id_result = run_command('id', '-u', nobody_user)
723 if id_result.returncode() == 0
724 id = id_result.stdout().to_int()
726 message('WARNING:\n' +
727 ' 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) +
728 ' Your build will result in an user table setup that is incompatible with the local system.')
732 getent_result = run_command('getent', 'group', '65534')
733 if getent_result.returncode() == 0
734 name = getent_result.stdout().split(':')[0]
735 if name != nobody_group
736 message('WARNING:\n' +
737 ' 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) +
738 ' Your build will result in an group table setup that is incompatible with the local system.')
741 id_result = run_command('id', '-g', nobody_group)
742 if id_result.returncode() == 0
743 id = id_result.stdout().to_int()
745 message('WARNING:\n' +
746 ' 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) +
747 ' Your build will result in an group table setup that is incompatible with the local system.')
750 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
751 message('WARNING:\n' +
752 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
753 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
756 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
757 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
758 substs.set('NOBODY_USER_NAME', nobody_user)
759 substs.set('NOBODY_GROUP_NAME', nobody_group)
761 tty_gid = get_option('tty-gid')
762 conf.set('TTY_GID', tty_gid)
763 substs.set('TTY_GID', tty_gid)
765 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
766 if get_option('users-gid') != ''
767 users_gid = get_option('users-gid').to_int()
771 substs.set('USERS_GID', users_gid)
773 if get_option('adm-group')
774 m4_defines += ['-DENABLE_ADM_GROUP']
777 if get_option('wheel-group')
778 m4_defines += ['-DENABLE_WHEEL_GROUP']
781 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
782 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
784 kill_user_processes = get_option('default-kill-user-processes')
785 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
786 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
787 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
789 dns_servers = get_option('dns-servers')
790 conf.set_quoted('DNS_SERVERS', dns_servers)
791 substs.set('DNS_SERVERS', dns_servers)
793 ntp_servers = get_option('ntp-servers')
794 conf.set_quoted('NTP_SERVERS', ntp_servers)
795 substs.set('NTP_SERVERS', ntp_servers)
797 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
799 substs.set('SUSHELL', get_option('debug-shell'))
800 substs.set('DEBUGTTY', get_option('debug-tty'))
802 debug = get_option('debug')
803 enable_debug_hashmap = false
804 enable_debug_mmap_cache = false
806 foreach name : debug.split(',')
808 enable_debug_hashmap = true
809 elif name == 'mmap-cache'
810 enable_debug_mmap_cache = true
812 message('unknown debug option "@0@", ignoring'.format(name))
816 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
817 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
819 #####################################################################
821 threads = dependency('threads')
822 librt = cc.find_library('rt')
823 libm = cc.find_library('m')
824 libdl = cc.find_library('dl')
825 libcrypt = cc.find_library('crypt')
827 libcap = dependency('libcap', required : false)
828 if not libcap.found()
829 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
830 libcap = cc.find_library('cap')
833 libmount = dependency('mount',
834 version : fuzzer_build ? '>= 0' : '>= 2.30')
836 want_seccomp = get_option('seccomp')
837 if want_seccomp != 'false' and not fuzzer_build
838 libseccomp = dependency('libseccomp',
839 version : '>= 2.3.1',
840 required : want_seccomp == 'true')
841 have = libseccomp.found()
846 conf.set10('HAVE_SECCOMP', have)
847 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
849 want_selinux = get_option('selinux')
850 if want_selinux != 'false' and not fuzzer_build
851 libselinux = dependency('libselinux',
852 version : '>= 2.1.9',
853 required : want_selinux == 'true')
854 have = libselinux.found()
859 conf.set10('HAVE_SELINUX', have)
860 m4_defines += have ? ['-DHAVE_SELINUX'] : []
862 want_apparmor = get_option('apparmor')
863 if want_apparmor != 'false' and not fuzzer_build
864 libapparmor = dependency('libapparmor',
865 required : want_apparmor == 'true')
866 have = libapparmor.found()
871 conf.set10('HAVE_APPARMOR', have)
872 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
874 smack_run_label = get_option('smack-run-label')
875 if smack_run_label != ''
876 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
877 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
880 want_polkit = get_option('polkit')
881 install_polkit = false
882 install_polkit_pkla = false
883 if want_polkit != 'false' and not fuzzer_build
884 install_polkit = true
886 libpolkit = dependency('polkit-gobject-1',
888 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
889 message('Old polkit detected, will install pkla files')
890 install_polkit_pkla = true
893 conf.set10('ENABLE_POLKIT', install_polkit)
895 want_acl = get_option('acl')
896 if want_acl != 'false' and not fuzzer_build
897 libacl = cc.find_library('acl', required : want_acl == 'true')
898 have = libacl.found()
903 conf.set10('HAVE_ACL', have)
904 m4_defines += have ? ['-DHAVE_ACL'] : []
906 want_audit = get_option('audit')
907 if want_audit != 'false' and not fuzzer_build
908 libaudit = dependency('audit', required : want_audit == 'true')
909 have = libaudit.found()
914 conf.set10('HAVE_AUDIT', have)
916 want_blkid = get_option('blkid')
917 if want_blkid != 'false' and not fuzzer_build
918 libblkid = dependency('blkid', required : want_blkid == 'true')
919 have = libblkid.found()
924 conf.set10('HAVE_BLKID', have)
926 want_kmod = get_option('kmod')
927 if want_kmod != 'false' and not fuzzer_build
928 libkmod = dependency('libkmod',
930 required : want_kmod == 'true')
931 have = libkmod.found()
936 conf.set10('HAVE_KMOD', have)
938 want_pam = get_option('pam')
939 if want_pam != 'false' and not fuzzer_build
940 libpam = cc.find_library('pam', required : want_pam == 'true')
941 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
942 have = libpam.found() and libpam_misc.found()
948 conf.set10('HAVE_PAM', have)
949 m4_defines += have ? ['-DHAVE_PAM'] : []
951 want_microhttpd = get_option('microhttpd')
952 if want_microhttpd != 'false' and not fuzzer_build
953 libmicrohttpd = dependency('libmicrohttpd',
954 version : '>= 0.9.33',
955 required : want_microhttpd == 'true')
956 have = libmicrohttpd.found()
961 conf.set10('HAVE_MICROHTTPD', have)
962 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
964 want_libcryptsetup = get_option('libcryptsetup')
965 if want_libcryptsetup != 'false' and not fuzzer_build
966 libcryptsetup = dependency('libcryptsetup',
967 version : '>= 1.6.0',
968 required : want_libcryptsetup == 'true')
969 have = libcryptsetup.found()
974 conf.set10('HAVE_LIBCRYPTSETUP', have)
976 want_libcurl = get_option('libcurl')
977 if want_libcurl != 'false' and not fuzzer_build
978 libcurl = dependency('libcurl',
979 version : '>= 7.32.0',
980 required : want_libcurl == 'true')
981 have = libcurl.found()
986 conf.set10('HAVE_LIBCURL', have)
987 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
989 want_libidn = get_option('libidn')
990 want_libidn2 = get_option('libidn2')
991 if want_libidn == 'true' and want_libidn2 == 'true'
992 error('libidn and libidn2 cannot be requested simultaneously')
995 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
996 libidn = dependency('libidn',
997 required : want_libidn == 'true')
998 have = libidn.found()
1003 conf.set10('HAVE_LIBIDN', have)
1004 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1005 if not have and want_libidn2 != 'false' and not fuzzer_build
1006 # libidn is used for both libidn and libidn2 objects
1007 libidn = dependency('libidn2',
1008 required : want_libidn2 == 'true')
1009 have = libidn.found()
1013 conf.set10('HAVE_LIBIDN2', have)
1014 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1016 want_libiptc = get_option('libiptc')
1017 if want_libiptc != 'false' and not fuzzer_build
1018 libiptc = dependency('libiptc',
1019 required : want_libiptc == 'true')
1020 have = libiptc.found()
1025 conf.set10('HAVE_LIBIPTC', have)
1026 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1028 want_qrencode = get_option('qrencode')
1029 if want_qrencode != 'false' and not fuzzer_build
1030 libqrencode = dependency('libqrencode',
1031 required : want_qrencode == 'true')
1032 have = libqrencode.found()
1037 conf.set10('HAVE_QRENCODE', have)
1039 want_gcrypt = get_option('gcrypt')
1040 if want_gcrypt != 'false' and not fuzzer_build
1041 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1042 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1043 have = libgcrypt.found() and libgpg_error.found()
1048 # link to neither of the libs if one is not found
1052 conf.set10('HAVE_GCRYPT', have)
1054 want_gnutls = get_option('gnutls')
1055 if want_gnutls != 'false' and not fuzzer_build
1056 libgnutls = dependency('gnutls',
1057 version : '>= 3.1.4',
1058 required : want_gnutls == 'true')
1059 have = libgnutls.found()
1064 conf.set10('HAVE_GNUTLS', have)
1066 want_elfutils = get_option('elfutils')
1067 if want_elfutils != 'false' and not fuzzer_build
1068 libdw = dependency('libdw',
1069 required : want_elfutils == 'true')
1070 have = libdw.found()
1075 conf.set10('HAVE_ELFUTILS', have)
1077 want_zlib = get_option('zlib')
1078 if want_zlib != 'false' and not fuzzer_build
1079 libz = dependency('zlib',
1080 required : want_zlib == 'true')
1086 conf.set10('HAVE_ZLIB', have)
1088 want_bzip2 = get_option('bzip2')
1089 if want_bzip2 != 'false' and not fuzzer_build
1090 libbzip2 = cc.find_library('bz2',
1091 required : want_bzip2 == 'true')
1092 have = libbzip2.found()
1097 conf.set10('HAVE_BZIP2', have)
1099 want_xz = get_option('xz')
1100 if want_xz != 'false' and not fuzzer_build
1101 libxz = dependency('liblzma',
1102 required : want_xz == 'true')
1103 have = libxz.found()
1108 conf.set10('HAVE_XZ', have)
1110 want_lz4 = get_option('lz4')
1111 if want_lz4 != 'false' and not fuzzer_build
1112 liblz4 = dependency('liblz4',
1113 required : want_lz4 == 'true')
1114 have = liblz4.found()
1119 conf.set10('HAVE_LZ4', have)
1121 want_xkbcommon = get_option('xkbcommon')
1122 if want_xkbcommon != 'false' and not fuzzer_build
1123 libxkbcommon = dependency('xkbcommon',
1124 version : '>= 0.3.0',
1125 required : want_xkbcommon == 'true')
1126 have = libxkbcommon.found()
1131 conf.set10('HAVE_XKBCOMMON', have)
1133 want_pcre2 = get_option('pcre2')
1134 if want_pcre2 != 'false'
1135 libpcre2 = dependency('libpcre2-8',
1136 required : want_pcre2 == 'true')
1137 have = libpcre2.found()
1142 conf.set10('HAVE_PCRE2', have)
1144 want_glib = get_option('glib')
1145 if want_glib != 'false' and not fuzzer_build
1146 libglib = dependency('glib-2.0',
1147 version : '>= 2.22.0',
1148 required : want_glib == 'true')
1149 libgobject = dependency('gobject-2.0',
1150 version : '>= 2.22.0',
1151 required : want_glib == 'true')
1152 libgio = dependency('gio-2.0',
1153 required : want_glib == 'true')
1154 have = libglib.found() and libgobject.found() and libgio.found()
1161 conf.set10('HAVE_GLIB', have)
1163 want_dbus = get_option('dbus')
1164 if want_dbus != 'false' and not fuzzer_build
1165 libdbus = dependency('dbus-1',
1166 version : '>= 1.3.2',
1167 required : want_dbus == 'true')
1168 have = libdbus.found()
1173 conf.set10('HAVE_DBUS', have)
1175 default_dnssec = get_option('default-dnssec')
1177 default_dnssec = 'no'
1179 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1180 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1181 default_dnssec = 'no'
1183 conf.set('DEFAULT_DNSSEC_MODE',
1184 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1185 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1187 want_importd = get_option('importd')
1188 if want_importd != 'false'
1189 have = (conf.get('HAVE_LIBCURL') == 1 and
1190 conf.get('HAVE_ZLIB') == 1 and
1191 conf.get('HAVE_BZIP2') == 1 and
1192 conf.get('HAVE_XZ') == 1 and
1193 conf.get('HAVE_GCRYPT') == 1)
1194 if want_importd == 'true' and not have
1195 error('importd support was requested, but dependencies are not available')
1200 conf.set10('ENABLE_IMPORTD', have)
1202 want_remote = get_option('remote')
1203 if want_remote != 'false'
1204 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1205 conf.get('HAVE_LIBCURL') == 1]
1206 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1207 # it's possible to build one without the other. Complain only if
1208 # support was explictly requested. The auxiliary files like sysusers
1209 # config should be installed when any of the programs are built.
1210 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1211 error('remote support was requested, but dependencies are not available')
1213 have = have_deps[0] or have_deps[1]
1217 conf.set10('ENABLE_REMOTE', have)
1219 foreach term : ['utmp',
1250 have = get_option(term)
1251 name = 'ENABLE_' + term.underscorify().to_upper()
1252 conf.set10(name, have)
1253 m4_defines += have ? ['-D' + name] : []
1256 want_tests = get_option('tests')
1257 install_tests = get_option('install-tests')
1258 slow_tests = get_option('slow-tests')
1262 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1264 #####################################################################
1266 if get_option('efi')
1267 efi_arch = host_machine.cpu_family()
1269 if efi_arch == 'x86'
1270 EFI_MACHINE_TYPE_NAME = 'ia32'
1271 gnu_efi_arch = 'ia32'
1272 elif efi_arch == 'x86_64'
1273 EFI_MACHINE_TYPE_NAME = 'x64'
1274 gnu_efi_arch = 'x86_64'
1275 elif efi_arch == 'arm'
1276 EFI_MACHINE_TYPE_NAME = 'arm'
1277 gnu_efi_arch = 'arm'
1278 elif efi_arch == 'aarch64'
1279 EFI_MACHINE_TYPE_NAME = 'aa64'
1280 gnu_efi_arch = 'aarch64'
1282 EFI_MACHINE_TYPE_NAME = ''
1287 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1289 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1293 conf.set10('ENABLE_EFI', have)
1295 #####################################################################
1297 config_h = configure_file(
1298 output : 'config.h',
1299 configuration : conf)
1301 includes = include_directories('src/basic',
1307 'src/time-wait-sync',
1312 'src/libsystemd/sd-bus',
1313 'src/libsystemd/sd-device',
1314 'src/libsystemd/sd-hwdb',
1315 'src/libsystemd/sd-id128',
1316 'src/libsystemd/sd-netlink',
1317 'src/libsystemd/sd-network',
1318 'src/libsystemd-network',
1321 add_project_arguments('-include', 'config.h', language : 'c')
1325 subdir('src/systemd')
1327 subdir('src/libsystemd')
1328 subdir('src/libsystemd-network')
1329 subdir('src/journal')
1332 libjournal_core = static_library(
1334 libjournal_core_sources,
1336 include_directories : includes,
1339 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1340 libsystemd = shared_library(
1342 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1343 version : libsystemd_version,
1344 include_directories : includes,
1345 link_args : ['-shared',
1346 '-Wl,--version-script=' + libsystemd_sym_path],
1347 link_with : [libbasic,
1349 link_whole : [libsystemd_static,
1351 dependencies : [threads,
1355 link_depends : libsystemd_sym,
1357 install_dir : rootlibdir)
1359 ############################################################
1361 # binaries that have --help and are intended for use by humans,
1362 # usually, but not always, installed in /bin.
1363 public_programs = []
1365 subdir('src/libudev')
1366 subdir('src/shared')
1369 subdir('src/network')
1371 subdir('src/analyze')
1372 subdir('src/journal-remote')
1373 subdir('src/coredump')
1374 subdir('src/hostname')
1375 subdir('src/import')
1376 subdir('src/kernel-install')
1377 subdir('src/locale')
1378 subdir('src/machine')
1379 subdir('src/nspawn')
1380 subdir('src/resolve')
1381 subdir('src/timedate')
1382 subdir('src/timesync')
1383 subdir('src/vconsole')
1384 subdir('src/boot/efi')
1391 ############################################################
1393 # only static linking apart from libdl, to make sure that the
1394 # module is linked to all libraries that it uses.
1395 test_dlopen = executable(
1398 include_directories : includes,
1399 link_with : [libbasic],
1400 dependencies : [libdl])
1402 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1403 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1404 ['mymachines', 'ENABLE_MACHINED'],
1405 ['resolve', 'ENABLE_RESOLVE']]
1407 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1411 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1412 version_script_arg = join_paths(meson.current_source_dir(), sym)
1414 nss = shared_library(
1416 'src/nss-@0@/nss-@0@.c'.format(module),
1418 include_directories : includes,
1419 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1420 link_args : ['-Wl,-z,nodelete',
1422 '-Wl,--version-script=' + version_script_arg,
1424 link_with : [libsystemd_static,
1426 dependencies : [threads,
1430 install_dir : rootlibdir)
1432 # We cannot use shared_module because it does not support version suffix.
1433 # Unfortunately shared_library insists on creating the symlink…
1434 meson.add_install_script('sh', '-c',
1435 'rm $DESTDIR@0@/libnss_@1@.so'
1436 .format(rootlibdir, module))
1438 test('dlopen-nss_' + module,
1440 args : [nss.full_path()]) # path to dlopen must include a slash
1444 ############################################################
1446 executable('systemd',
1448 include_directories : includes,
1449 link_with : [libcore,
1451 dependencies : [threads,
1457 install_rpath : rootlibexecdir,
1459 install_dir : rootlibexecdir)
1461 meson.add_install_script(meson_make_symlink,
1462 join_paths(rootlibexecdir, 'systemd'),
1463 join_paths(rootsbindir, 'init'))
1465 exe = executable('systemd-analyze',
1466 systemd_analyze_sources,
1467 include_directories : includes,
1468 link_with : [libcore,
1470 dependencies : [threads,
1476 install_rpath : rootlibexecdir,
1478 public_programs += [exe]
1480 executable('systemd-journald',
1481 systemd_journald_sources,
1482 include_directories : includes,
1483 link_with : [libjournal_core,
1485 dependencies : [threads,
1489 install_rpath : rootlibexecdir,
1491 install_dir : rootlibexecdir)
1493 exe = executable('systemd-cat',
1494 systemd_cat_sources,
1495 include_directories : includes,
1496 link_with : [libjournal_core,
1498 dependencies : [threads],
1499 install_rpath : rootlibexecdir,
1501 public_programs += [exe]
1503 exe = executable('journalctl',
1505 include_directories : includes,
1506 link_with : [libshared],
1507 dependencies : [threads,
1512 install_rpath : rootlibexecdir,
1514 install_dir : rootbindir)
1515 public_programs += [exe]
1517 executable('systemd-getty-generator',
1518 'src/getty-generator/getty-generator.c',
1519 include_directories : includes,
1520 link_with : [libshared],
1521 install_rpath : rootlibexecdir,
1523 install_dir : systemgeneratordir)
1525 executable('systemd-debug-generator',
1526 'src/debug-generator/debug-generator.c',
1527 include_directories : includes,
1528 link_with : [libshared],
1529 install_rpath : rootlibexecdir,
1531 install_dir : systemgeneratordir)
1533 executable('systemd-fstab-generator',
1534 'src/fstab-generator/fstab-generator.c',
1535 'src/core/mount-setup.c',
1536 include_directories : includes,
1537 link_with : [libshared],
1538 install_rpath : rootlibexecdir,
1540 install_dir : systemgeneratordir)
1542 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1543 executable('30-systemd-environment-d-generator',
1544 'src/environment-d-generator/environment-d-generator.c',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 install_rpath : rootlibexecdir,
1549 install_dir : userenvgeneratordir)
1551 meson.add_install_script(meson_make_symlink,
1552 join_paths(sysconfdir, 'environment'),
1553 join_paths(environmentdir, '99-environment.conf'))
1556 if conf.get('ENABLE_HIBERNATE') == 1
1557 executable('systemd-hibernate-resume-generator',
1558 'src/hibernate-resume/hibernate-resume-generator.c',
1559 include_directories : includes,
1560 link_with : [libshared],
1561 install_rpath : rootlibexecdir,
1563 install_dir : systemgeneratordir)
1565 executable('systemd-hibernate-resume',
1566 'src/hibernate-resume/hibernate-resume.c',
1567 include_directories : includes,
1568 link_with : [libshared],
1569 install_rpath : rootlibexecdir,
1571 install_dir : rootlibexecdir)
1574 if conf.get('HAVE_BLKID') == 1
1575 executable('systemd-gpt-auto-generator',
1576 'src/gpt-auto-generator/gpt-auto-generator.c',
1577 'src/basic/blkid-util.h',
1578 include_directories : includes,
1579 link_with : [libshared],
1580 dependencies : libblkid,
1581 install_rpath : rootlibexecdir,
1583 install_dir : systemgeneratordir)
1585 exe = executable('systemd-dissect',
1586 'src/dissect/dissect.c',
1587 include_directories : includes,
1588 link_with : [libshared],
1589 install_rpath : rootlibexecdir,
1591 install_dir : rootlibexecdir)
1592 public_programs += [exe]
1595 if conf.get('ENABLE_RESOLVE') == 1
1596 executable('systemd-resolved',
1597 systemd_resolved_sources,
1598 include_directories : includes,
1599 link_with : [libshared,
1601 libsystemd_resolve_core],
1602 dependencies : [threads,
1606 install_rpath : rootlibexecdir,
1608 install_dir : rootlibexecdir)
1610 exe = executable('systemd-resolve',
1611 systemd_resolve_sources,
1612 include_directories : includes,
1613 link_with : [libshared,
1615 libsystemd_resolve_core],
1616 dependencies : [threads,
1620 install_rpath : rootlibexecdir,
1622 public_programs += [exe]
1624 meson.add_install_script(meson_make_symlink,
1625 join_paths(bindir, 'systemd-resolve'),
1626 join_paths(rootsbindir, 'resolvconf'))
1629 if conf.get('ENABLE_LOGIND') == 1
1630 executable('systemd-logind',
1631 systemd_logind_sources,
1632 include_directories : includes,
1633 link_with : [liblogind_core,
1635 dependencies : [threads,
1637 install_rpath : rootlibexecdir,
1639 install_dir : rootlibexecdir)
1641 exe = executable('loginctl',
1643 include_directories : includes,
1644 link_with : [libshared],
1645 dependencies : [threads,
1648 install_rpath : rootlibexecdir,
1650 install_dir : rootbindir)
1651 public_programs += [exe]
1653 exe = executable('systemd-inhibit',
1654 'src/login/inhibit.c',
1655 include_directories : includes,
1656 link_with : [libshared],
1657 install_rpath : rootlibexecdir,
1659 install_dir : rootbindir)
1660 public_programs += [exe]
1662 if conf.get('HAVE_PAM') == 1
1663 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1664 pam_systemd = shared_library(
1668 include_directories : includes,
1669 link_args : ['-shared',
1670 '-Wl,--version-script=' + version_script_arg],
1671 link_with : [libsystemd_static,
1673 dependencies : [threads,
1676 link_depends : pam_systemd_sym,
1678 install_dir : pamlibdir)
1680 test('dlopen-pam_systemd',
1682 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1686 if conf.get('HAVE_PAM') == 1
1687 executable('systemd-user-sessions',
1688 'src/user-sessions/user-sessions.c',
1689 include_directories : includes,
1690 link_with : [libshared],
1691 install_rpath : rootlibexecdir,
1693 install_dir : rootlibexecdir)
1696 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1697 exe = executable('bootctl',
1698 'src/boot/bootctl.c',
1699 include_directories : includes,
1700 link_with : [libshared],
1701 dependencies : [libblkid],
1702 install_rpath : rootlibexecdir,
1704 public_programs += [exe]
1707 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1708 include_directories : includes,
1709 link_with : [libshared],
1710 dependencies : [threads],
1711 install_rpath : rootlibexecdir,
1713 public_programs += [exe]
1715 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1716 include_directories : includes,
1717 link_with : [libshared],
1718 dependencies : [threads,
1723 install_rpath : rootlibexecdir,
1725 install_dir : rootbindir)
1726 public_programs += [exe]
1728 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1729 meson.add_install_script(meson_make_symlink,
1730 join_paths(rootbindir, 'systemctl'),
1731 join_paths(rootsbindir, alias))
1734 if conf.get('ENABLE_BACKLIGHT') == 1
1735 executable('systemd-backlight',
1736 'src/backlight/backlight.c',
1737 include_directories : includes,
1738 link_with : [libshared],
1739 install_rpath : rootlibexecdir,
1741 install_dir : rootlibexecdir)
1744 if conf.get('ENABLE_RFKILL') == 1
1745 executable('systemd-rfkill',
1746 'src/rfkill/rfkill.c',
1747 include_directories : includes,
1748 link_with : [libshared],
1749 install_rpath : rootlibexecdir,
1751 install_dir : rootlibexecdir)
1754 executable('systemd-system-update-generator',
1755 'src/system-update-generator/system-update-generator.c',
1756 include_directories : includes,
1757 link_with : [libshared],
1758 install_rpath : rootlibexecdir,
1760 install_dir : systemgeneratordir)
1762 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1763 executable('systemd-cryptsetup',
1764 'src/cryptsetup/cryptsetup.c',
1765 include_directories : includes,
1766 link_with : [libshared],
1767 dependencies : [libcryptsetup],
1768 install_rpath : rootlibexecdir,
1770 install_dir : rootlibexecdir)
1772 executable('systemd-cryptsetup-generator',
1773 'src/cryptsetup/cryptsetup-generator.c',
1774 include_directories : includes,
1775 link_with : [libshared],
1776 dependencies : [libcryptsetup],
1777 install_rpath : rootlibexecdir,
1779 install_dir : systemgeneratordir)
1781 executable('systemd-veritysetup',
1782 'src/veritysetup/veritysetup.c',
1783 include_directories : includes,
1784 link_with : [libshared],
1785 dependencies : [libcryptsetup],
1786 install_rpath : rootlibexecdir,
1788 install_dir : rootlibexecdir)
1790 executable('systemd-veritysetup-generator',
1791 'src/veritysetup/veritysetup-generator.c',
1792 include_directories : includes,
1793 link_with : [libshared],
1794 dependencies : [libcryptsetup],
1795 install_rpath : rootlibexecdir,
1797 install_dir : systemgeneratordir)
1800 if conf.get('HAVE_SYSV_COMPAT') == 1
1801 executable('systemd-sysv-generator',
1802 'src/sysv-generator/sysv-generator.c',
1803 include_directories : includes,
1804 link_with : [libshared],
1805 install_rpath : rootlibexecdir,
1807 install_dir : systemgeneratordir)
1809 executable('systemd-rc-local-generator',
1810 'src/rc-local-generator/rc-local-generator.c',
1811 include_directories : includes,
1812 link_with : [libshared],
1813 install_rpath : rootlibexecdir,
1815 install_dir : systemgeneratordir)
1818 if conf.get('ENABLE_HOSTNAMED') == 1
1819 executable('systemd-hostnamed',
1820 'src/hostname/hostnamed.c',
1821 include_directories : includes,
1822 link_with : [libshared],
1823 install_rpath : rootlibexecdir,
1825 install_dir : rootlibexecdir)
1827 exe = executable('hostnamectl',
1828 'src/hostname/hostnamectl.c',
1829 include_directories : includes,
1830 link_with : [libshared],
1831 install_rpath : rootlibexecdir,
1833 public_programs += [exe]
1836 if conf.get('ENABLE_LOCALED') == 1
1837 if conf.get('HAVE_XKBCOMMON') == 1
1838 # logind will load libxkbcommon.so dynamically on its own
1844 executable('systemd-localed',
1845 systemd_localed_sources,
1846 include_directories : includes,
1847 link_with : [libshared],
1848 dependencies : deps,
1849 install_rpath : rootlibexecdir,
1851 install_dir : rootlibexecdir)
1853 exe = executable('localectl',
1855 include_directories : includes,
1856 link_with : [libshared],
1857 install_rpath : rootlibexecdir,
1859 public_programs += [exe]
1862 if conf.get('ENABLE_TIMEDATED') == 1
1863 executable('systemd-timedated',
1864 'src/timedate/timedated.c',
1865 include_directories : includes,
1866 link_with : [libshared],
1867 install_rpath : rootlibexecdir,
1869 install_dir : rootlibexecdir)
1871 exe = executable('timedatectl',
1872 'src/timedate/timedatectl.c',
1873 include_directories : includes,
1874 install_rpath : rootlibexecdir,
1875 link_with : [libshared],
1877 public_programs += [exe]
1880 if conf.get('ENABLE_TIMESYNCD') == 1
1881 executable('systemd-timesyncd',
1882 systemd_timesyncd_sources,
1883 include_directories : includes,
1884 link_with : [libshared],
1885 dependencies : [threads,
1887 install_rpath : rootlibexecdir,
1889 install_dir : rootlibexecdir)
1891 executable('systemd-time-wait-sync',
1892 'src/time-wait-sync/time-wait-sync.c',
1893 include_directories : includes,
1894 link_with : [libshared],
1895 install_rpath : rootlibexecdir,
1897 install_dir : rootlibexecdir)
1900 if conf.get('ENABLE_MACHINED') == 1
1901 executable('systemd-machined',
1902 systemd_machined_sources,
1903 include_directories : includes,
1904 link_with : [libmachine_core,
1906 install_rpath : rootlibexecdir,
1908 install_dir : rootlibexecdir)
1910 exe = executable('machinectl',
1911 'src/machine/machinectl.c',
1912 include_directories : includes,
1913 link_with : [libshared],
1914 dependencies : [threads,
1917 install_rpath : rootlibexecdir,
1919 install_dir : rootbindir)
1920 public_programs += [exe]
1923 if conf.get('ENABLE_IMPORTD') == 1
1924 executable('systemd-importd',
1925 systemd_importd_sources,
1926 include_directories : includes,
1927 link_with : [libshared],
1928 dependencies : [threads],
1929 install_rpath : rootlibexecdir,
1931 install_dir : rootlibexecdir)
1933 systemd_pull = executable('systemd-pull',
1934 systemd_pull_sources,
1935 include_directories : includes,
1936 link_with : [libshared],
1937 dependencies : [libcurl,
1942 install_rpath : rootlibexecdir,
1944 install_dir : rootlibexecdir)
1946 systemd_import = executable('systemd-import',
1947 systemd_import_sources,
1948 include_directories : includes,
1949 link_with : [libshared],
1950 dependencies : [libcurl,
1954 install_rpath : rootlibexecdir,
1956 install_dir : rootlibexecdir)
1958 systemd_export = executable('systemd-export',
1959 systemd_export_sources,
1960 include_directories : includes,
1961 link_with : [libshared],
1962 dependencies : [libcurl,
1966 install_rpath : rootlibexecdir,
1968 install_dir : rootlibexecdir)
1969 public_programs += [systemd_pull, systemd_import, systemd_export]
1972 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1973 exe = executable('systemd-journal-upload',
1974 systemd_journal_upload_sources,
1975 include_directories : includes,
1976 link_with : [libshared],
1977 dependencies : [threads,
1982 install_rpath : rootlibexecdir,
1984 install_dir : rootlibexecdir)
1985 public_programs += [exe]
1988 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1989 s_j_remote = executable('systemd-journal-remote',
1990 systemd_journal_remote_sources,
1991 include_directories : includes,
1992 link_with : [libshared],
1993 dependencies : [threads,
1998 install_rpath : rootlibexecdir,
2000 install_dir : rootlibexecdir)
2002 s_j_gatewayd = executable('systemd-journal-gatewayd',
2003 systemd_journal_gatewayd_sources,
2004 include_directories : includes,
2005 link_with : [libshared],
2006 dependencies : [threads,
2011 install_rpath : rootlibexecdir,
2013 install_dir : rootlibexecdir)
2014 public_programs += [s_j_remote, s_j_gatewayd]
2017 if conf.get('ENABLE_COREDUMP') == 1
2018 executable('systemd-coredump',
2019 systemd_coredump_sources,
2020 include_directories : includes,
2021 link_with : [libshared],
2022 dependencies : [threads,
2027 install_rpath : rootlibexecdir,
2029 install_dir : rootlibexecdir)
2031 exe = executable('coredumpctl',
2032 coredumpctl_sources,
2033 include_directories : includes,
2034 link_with : [libshared],
2035 dependencies : [threads,
2038 install_rpath : rootlibexecdir,
2040 public_programs += [exe]
2043 if conf.get('ENABLE_BINFMT') == 1
2044 exe = executable('systemd-binfmt',
2045 'src/binfmt/binfmt.c',
2046 include_directories : includes,
2047 link_with : [libshared],
2048 install_rpath : rootlibexecdir,
2050 install_dir : rootlibexecdir)
2051 public_programs += [exe]
2053 meson.add_install_script('sh', '-c',
2054 mkdir_p.format(binfmtdir))
2055 meson.add_install_script('sh', '-c',
2056 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2059 if conf.get('ENABLE_VCONSOLE') == 1
2060 executable('systemd-vconsole-setup',
2061 'src/vconsole/vconsole-setup.c',
2062 include_directories : includes,
2063 link_with : [libshared],
2064 install_rpath : rootlibexecdir,
2066 install_dir : rootlibexecdir)
2069 if conf.get('ENABLE_RANDOMSEED') == 1
2070 executable('systemd-random-seed',
2071 'src/random-seed/random-seed.c',
2072 include_directories : includes,
2073 link_with : [libshared],
2074 install_rpath : rootlibexecdir,
2076 install_dir : rootlibexecdir)
2079 if conf.get('ENABLE_FIRSTBOOT') == 1
2080 executable('systemd-firstboot',
2081 'src/firstboot/firstboot.c',
2082 include_directories : includes,
2083 link_with : [libshared],
2084 dependencies : [libcrypt],
2085 install_rpath : rootlibexecdir,
2087 install_dir : rootbindir)
2090 executable('systemd-remount-fs',
2091 'src/remount-fs/remount-fs.c',
2092 'src/core/mount-setup.c',
2093 'src/core/mount-setup.h',
2094 include_directories : includes,
2095 link_with : [libshared],
2096 install_rpath : rootlibexecdir,
2098 install_dir : rootlibexecdir)
2100 executable('systemd-machine-id-setup',
2101 'src/machine-id-setup/machine-id-setup-main.c',
2102 'src/core/machine-id-setup.c',
2103 'src/core/machine-id-setup.h',
2104 include_directories : includes,
2105 link_with : [libshared],
2106 install_rpath : rootlibexecdir,
2108 install_dir : rootbindir)
2110 executable('systemd-fsck',
2112 include_directories : includes,
2113 link_with : [libshared],
2114 install_rpath : rootlibexecdir,
2116 install_dir : rootlibexecdir)
2118 executable('systemd-growfs',
2119 'src/partition/growfs.c',
2120 include_directories : includes,
2121 link_with : [libshared],
2122 dependencies : [libcryptsetup],
2123 install_rpath : rootlibexecdir,
2125 install_dir : rootlibexecdir)
2127 executable('systemd-makefs',
2128 'src/partition/makefs.c',
2129 include_directories : includes,
2130 link_with : [libshared],
2131 install_rpath : rootlibexecdir,
2133 install_dir : rootlibexecdir)
2135 executable('systemd-sleep',
2136 'src/sleep/sleep.c',
2137 include_directories : includes,
2138 link_with : [libshared],
2139 install_rpath : rootlibexecdir,
2141 install_dir : rootlibexecdir)
2143 exe = executable('systemd-sysctl',
2144 'src/sysctl/sysctl.c',
2145 include_directories : includes,
2146 link_with : [libshared],
2147 install_rpath : rootlibexecdir,
2149 install_dir : rootlibexecdir)
2150 public_programs += [exe]
2152 executable('systemd-ac-power',
2153 'src/ac-power/ac-power.c',
2154 include_directories : includes,
2155 link_with : [libshared],
2156 install_rpath : rootlibexecdir,
2158 install_dir : rootlibexecdir)
2160 exe = executable('systemd-detect-virt',
2161 'src/detect-virt/detect-virt.c',
2162 include_directories : includes,
2163 link_with : [libshared],
2164 install_rpath : rootlibexecdir,
2166 public_programs += [exe]
2168 exe = executable('systemd-delta',
2169 'src/delta/delta.c',
2170 include_directories : includes,
2171 link_with : [libshared],
2172 install_rpath : rootlibexecdir,
2174 public_programs += [exe]
2176 exe = executable('systemd-escape',
2177 'src/escape/escape.c',
2178 include_directories : includes,
2179 link_with : [libshared],
2180 install_rpath : rootlibexecdir,
2182 install_dir : rootbindir)
2183 public_programs += [exe]
2185 exe = executable('systemd-notify',
2186 'src/notify/notify.c',
2187 include_directories : includes,
2188 link_with : [libshared],
2189 install_rpath : rootlibexecdir,
2191 install_dir : rootbindir)
2192 public_programs += [exe]
2194 executable('systemd-volatile-root',
2195 'src/volatile-root/volatile-root.c',
2196 include_directories : includes,
2197 link_with : [libshared],
2198 install_rpath : rootlibexecdir,
2200 install_dir : rootlibexecdir)
2202 executable('systemd-cgroups-agent',
2203 'src/cgroups-agent/cgroups-agent.c',
2204 include_directories : includes,
2205 link_with : [libshared],
2206 install_rpath : rootlibexecdir,
2208 install_dir : rootlibexecdir)
2210 exe = executable('systemd-path',
2212 include_directories : includes,
2213 link_with : [libshared],
2214 install_rpath : rootlibexecdir,
2216 public_programs += [exe]
2218 exe = executable('systemd-ask-password',
2219 'src/ask-password/ask-password.c',
2220 include_directories : includes,
2221 link_with : [libshared],
2222 install_rpath : rootlibexecdir,
2224 install_dir : rootbindir)
2225 public_programs += [exe]
2227 executable('systemd-reply-password',
2228 'src/reply-password/reply-password.c',
2229 include_directories : includes,
2230 link_with : [libshared],
2231 install_rpath : rootlibexecdir,
2233 install_dir : rootlibexecdir)
2235 exe = executable('systemd-tty-ask-password-agent',
2236 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2237 include_directories : includes,
2238 link_with : [libshared],
2239 install_rpath : rootlibexecdir,
2241 install_dir : rootbindir)
2242 public_programs += [exe]
2244 exe = executable('systemd-cgls',
2246 include_directories : includes,
2247 link_with : [libshared],
2248 install_rpath : rootlibexecdir,
2250 public_programs += [exe]
2252 exe = executable('systemd-cgtop',
2253 'src/cgtop/cgtop.c',
2254 include_directories : includes,
2255 link_with : [libshared],
2256 install_rpath : rootlibexecdir,
2258 public_programs += [exe]
2260 executable('systemd-initctl',
2261 'src/initctl/initctl.c',
2262 include_directories : includes,
2263 link_with : [libshared],
2264 install_rpath : rootlibexecdir,
2266 install_dir : rootlibexecdir)
2268 exe = executable('systemd-mount',
2269 'src/mount/mount-tool.c',
2270 include_directories : includes,
2271 link_with : [libshared],
2272 install_rpath : rootlibexecdir,
2274 public_programs += [exe]
2276 meson.add_install_script(meson_make_symlink,
2277 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2279 exe = executable('systemd-run',
2281 include_directories : includes,
2282 link_with : [libshared],
2283 install_rpath : rootlibexecdir,
2285 public_programs += [exe]
2287 exe = executable('systemd-stdio-bridge',
2288 'src/stdio-bridge/stdio-bridge.c',
2289 include_directories : includes,
2290 link_with : [libshared],
2291 install_rpath : rootlibexecdir,
2293 public_programs += [exe]
2295 exe = executable('busctl',
2296 'src/busctl/busctl.c',
2297 'src/busctl/busctl-introspect.c',
2298 'src/busctl/busctl-introspect.h',
2299 include_directories : includes,
2300 link_with : [libshared],
2301 install_rpath : rootlibexecdir,
2303 public_programs += [exe]
2305 if conf.get('ENABLE_SYSUSERS') == 1
2306 exe = executable('systemd-sysusers',
2307 'src/sysusers/sysusers.c',
2308 include_directories : includes,
2309 link_with : [libshared],
2310 install_rpath : rootlibexecdir,
2312 install_dir : rootbindir)
2313 public_programs += [exe]
2316 if conf.get('ENABLE_TMPFILES') == 1
2317 exe = executable('systemd-tmpfiles',
2318 'src/tmpfiles/tmpfiles.c',
2319 include_directories : includes,
2320 link_with : [libshared],
2321 dependencies : [libacl],
2322 install_rpath : rootlibexecdir,
2324 install_dir : rootbindir)
2325 public_programs += [exe]
2327 test('test-systemd-tmpfiles',
2328 test_systemd_tmpfiles_py,
2329 args : exe.full_path())
2330 # https://github.com/mesonbuild/meson/issues/2681
2333 if conf.get('ENABLE_HWDB') == 1
2334 exe = executable('systemd-hwdb',
2336 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2337 include_directories : includes,
2338 link_with : [libudev_static],
2339 install_rpath : udev_rpath,
2341 install_dir : rootbindir)
2342 public_programs += [exe]
2345 if conf.get('ENABLE_QUOTACHECK') == 1
2346 executable('systemd-quotacheck',
2347 'src/quotacheck/quotacheck.c',
2348 include_directories : includes,
2349 link_with : [libshared],
2350 install_rpath : rootlibexecdir,
2352 install_dir : rootlibexecdir)
2355 exe = executable('systemd-socket-proxyd',
2356 'src/socket-proxy/socket-proxyd.c',
2357 include_directories : includes,
2358 link_with : [libshared],
2359 dependencies : [threads],
2360 install_rpath : rootlibexecdir,
2362 install_dir : rootlibexecdir)
2363 public_programs += [exe]
2365 exe = executable('systemd-udevd',
2366 systemd_udevd_sources,
2367 include_directories : includes,
2368 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2369 link_with : [libudev_core,
2372 dependencies : [threads,
2377 install_rpath : udev_rpath,
2379 install_dir : rootlibexecdir)
2380 public_programs += [exe]
2382 exe = executable('udevadm',
2384 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2385 include_directories : includes,
2386 link_with : [libudev_core,
2389 dependencies : [threads,
2394 install_rpath : udev_rpath,
2396 install_dir : rootbindir)
2397 public_programs += [exe]
2399 executable('systemd-shutdown',
2400 systemd_shutdown_sources,
2401 include_directories : includes,
2402 link_with : [libshared],
2403 dependencies : [libmount],
2404 install_rpath : rootlibexecdir,
2406 install_dir : rootlibexecdir)
2408 executable('systemd-update-done',
2409 'src/update-done/update-done.c',
2410 include_directories : includes,
2411 link_with : [libshared],
2412 install_rpath : rootlibexecdir,
2414 install_dir : rootlibexecdir)
2416 executable('systemd-update-utmp',
2417 'src/update-utmp/update-utmp.c',
2418 include_directories : includes,
2419 link_with : [libshared],
2420 dependencies : [libaudit],
2421 install_rpath : rootlibexecdir,
2423 install_dir : rootlibexecdir)
2425 if conf.get('HAVE_KMOD') == 1
2426 executable('systemd-modules-load',
2427 'src/modules-load/modules-load.c',
2428 include_directories : includes,
2429 link_with : [libshared],
2430 dependencies : [libkmod],
2431 install_rpath : rootlibexecdir,
2433 install_dir : rootlibexecdir)
2435 meson.add_install_script('sh', '-c',
2436 mkdir_p.format(modulesloaddir))
2437 meson.add_install_script('sh', '-c',
2438 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2441 exe = executable('systemd-nspawn',
2442 systemd_nspawn_sources,
2443 'src/core/mount-setup.c', # FIXME: use a variable?
2444 'src/core/mount-setup.h',
2445 'src/core/loopback-setup.c',
2446 'src/core/loopback-setup.h',
2447 include_directories : [includes, include_directories('src/nspawn')],
2448 link_with : [libshared],
2449 dependencies : [libacl,
2453 install_rpath : rootlibexecdir,
2455 public_programs += [exe]
2457 if conf.get('ENABLE_NETWORKD') == 1
2458 executable('systemd-networkd',
2459 systemd_networkd_sources,
2460 include_directories : includes,
2461 link_with : [libnetworkd_core,
2465 dependencies : [threads],
2466 install_rpath : rootlibexecdir,
2468 install_dir : rootlibexecdir)
2470 executable('systemd-networkd-wait-online',
2471 systemd_networkd_wait_online_sources,
2472 include_directories : includes,
2473 link_with : [libnetworkd_core,
2475 install_rpath : rootlibexecdir,
2477 install_dir : rootlibexecdir)
2479 exe = executable('networkctl',
2481 include_directories : includes,
2482 link_with : [libsystemd_network,
2484 install_rpath : rootlibexecdir,
2486 install_dir : rootbindir)
2487 public_programs += [exe]
2490 executable('systemd-sulogin-shell',
2491 ['src/sulogin-shell/sulogin-shell.c'],
2492 include_directories : includes,
2493 link_with : [libshared],
2494 install_rpath : rootlibexecdir,
2496 install_dir : rootlibexecdir)
2498 ############################################################
2500 foreach tuple : tests
2502 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2503 dependencies = tuple[2]
2504 condition = tuple.length() >= 4 ? tuple[3] : ''
2505 type = tuple.length() >= 5 ? tuple[4] : ''
2506 defs = tuple.length() >= 6 ? tuple[5] : []
2507 incs = tuple.length() >= 7 ? tuple[6] : includes
2510 name = sources[0].split('/')[-1].split('.')[0]
2511 if type.startswith('timeout=')
2512 timeout = type.split('=')[1].to_int()
2515 if want_tests == 'false'
2516 message('Not compiling @0@ because tests is set to false'.format(name))
2517 elif condition == '' or conf.get(condition) == 1
2521 include_directories : incs,
2522 link_with : link_with,
2523 dependencies : dependencies,
2525 install_rpath : rootlibexecdir,
2526 install : install_tests,
2527 install_dir : join_paths(testsdir, type))
2530 message('@0@ is a manual test'.format(name))
2531 elif type == 'unsafe' and want_tests != 'unsafe'
2532 message('@0@ is an unsafe test'.format(name))
2539 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2543 test_libsystemd_sym = executable(
2544 'test-libsystemd-sym',
2545 test_libsystemd_sym_c,
2546 include_directories : includes,
2547 link_with : [libsystemd],
2548 install : install_tests,
2549 install_dir : testsdir)
2550 test('test-libsystemd-sym',
2551 test_libsystemd_sym)
2553 test_libudev_sym = executable(
2556 include_directories : includes,
2557 c_args : ['-Wno-deprecated-declarations'],
2558 link_with : [libudev],
2559 install : install_tests,
2560 install_dir : testsdir)
2561 test('test-libudev-sym',
2564 ############################################################
2568 foreach tuple : fuzzers
2570 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2571 dependencies = tuple[2]
2572 defs = tuple.length() >= 4 ? tuple[3] : []
2573 incs = tuple.length() >= 5 ? tuple[4] : includes
2576 dependencies += fuzzing_engine
2578 sources += 'src/fuzz/fuzz-main.c'
2581 name = sources[0].split('/')[-1].split('.')[0]
2583 fuzzer_exes += executable(
2586 include_directories : [incs, include_directories('src/fuzz')],
2587 link_with : link_with,
2588 dependencies : dependencies,
2593 run_target('fuzzers',
2594 depends : fuzzer_exes,
2597 ############################################################
2599 make_directive_index_py = find_program('tools/make-directive-index.py')
2600 make_man_index_py = find_program('tools/make-man-index.py')
2601 xml_helper_py = find_program('tools/xml_helper.py')
2602 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2606 subdir('sysusers.d')
2607 subdir('tmpfiles.d')
2612 subdir('shell-completion/bash')
2613 subdir('shell-completion/zsh')
2614 subdir('doc/sysvinit')
2615 subdir('doc/var-log')
2617 # FIXME: figure out if the warning is true:
2618 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2619 install_subdir('factory/etc',
2620 install_dir : factorydir)
2623 install_data('xorg/50-systemd-user.sh',
2624 install_dir : xinitrcdir)
2625 install_data('modprobe.d/systemd.conf',
2626 install_dir : modprobedir)
2627 install_data('LICENSE.GPL2',
2632 'doc/DISTRO_PORTING',
2633 'doc/ENVIRONMENT.md',
2635 'doc/TRANSIENT-SETTINGS.md',
2638 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2639 install_dir : docdir)
2641 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2642 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2644 ############################################################
2646 meson_check_help = find_program('tools/meson-check-help.sh')
2648 foreach exec : public_programs
2649 name = exec.full_path().split('/')[-1]
2650 test('check-help-' + name,
2652 args : [exec.full_path()])
2655 ############################################################
2657 # Enable tests for all supported sanitizers
2658 foreach tuple : sanitizers
2659 sanitizer = tuple[0]
2662 have = run_command(check_compilation_sh,
2663 cc.cmd_array(), '-x', 'c',
2664 '-fsanitize=@0@'.format(sanitizer),
2665 '-include', link_test_c).returncode() == 0
2666 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
2670 foreach p : fuzz_regression_tests
2671 b = p.split('/')[-2]
2672 c = p.split('/')[-1]
2674 name = '@0@:@1@'.format(b, sanitizer)
2677 if want_tests == 'false'
2678 message('Not compiling @0@ because tests is set to false'.format(name))
2680 exe = custom_target(
2684 command : [env, 'ln', '-fs',
2685 join_paths(build.full_path(), b),
2687 build_by_default : true)
2689 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2694 if want_tests != 'false' and slow_tests
2695 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2697 args : [exe.full_path(),
2698 join_paths(meson.source_root(),
2699 'test/fuzz-regressions',
2707 ############################################################
2710 all_files = run_command(
2712 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2715 all_files = files(all_files.stdout().split())
2720 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2724 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2728 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2731 command : [meson_git_contrib_sh])
2735 git_head = run_command(
2737 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2738 'rev-parse', 'HEAD']).stdout().strip()
2739 git_head_short = run_command(
2741 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2742 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2746 command : ['git', 'archive',
2747 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2749 '--prefix', 'systemd-@0@/'.format(git_head),
2753 ############################################################
2755 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2758 depends : [man, libsystemd, libudev],
2759 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2761 ############################################################
2764 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2766 'split /usr: @0@'.format(split_usr),
2767 'split bin-sbin: @0@'.format(split_bin),
2768 'prefix directory: @0@'.format(prefixdir),
2769 'rootprefix directory: @0@'.format(rootprefixdir),
2770 'sysconf directory: @0@'.format(sysconfdir),
2771 'include directory: @0@'.format(includedir),
2772 'lib directory: @0@'.format(libdir),
2773 'rootlib directory: @0@'.format(rootlibdir),
2774 'SysV init scripts: @0@'.format(sysvinit_path),
2775 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2776 'PAM modules directory: @0@'.format(pamlibdir),
2777 'PAM configuration directory: @0@'.format(pamconfdir),
2778 'RPM macros directory: @0@'.format(rpmmacrosdir),
2779 'modprobe.d directory: @0@'.format(modprobedir),
2780 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2781 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2782 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2783 'bash completions directory: @0@'.format(bashcompletiondir),
2784 'zsh completions directory: @0@'.format(zshcompletiondir),
2785 'extra start script: @0@'.format(get_option('rc-local')),
2786 'extra stop script: @0@'.format(get_option('halt-local')),
2787 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2788 get_option('debug-tty')),
2789 'TTY GID: @0@'.format(tty_gid),
2790 'users GID: @0@'.format(users_gid),
2791 'maximum system UID: @0@'.format(system_uid_max),
2792 'maximum system GID: @0@'.format(system_gid_max),
2793 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2794 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2795 'minimum container UID base: @0@'.format(container_uid_base_min),
2796 'maximum container UID base: @0@'.format(container_uid_base_max),
2797 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2798 'render group access mode: @0@'.format(get_option('group-render-mode')),
2799 'certificate root directory: @0@'.format(get_option('certificate-root')),
2800 'support URL: @0@'.format(support_url),
2801 'nobody user name: @0@'.format(nobody_user),
2802 'nobody group name: @0@'.format(nobody_group),
2803 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2804 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2806 'default DNSSEC mode: @0@'.format(default_dnssec),
2807 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2808 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2810 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2811 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2813 'default DNS servers: @0@'.format(alt_dns_servers),
2814 'default NTP servers: @0@'.format(alt_ntp_servers)]
2816 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2817 '@@0@'.format(time_epoch)).stdout().strip()
2819 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2822 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2823 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2824 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2826 if conf.get('ENABLE_EFI') == 1
2828 'efi arch: @0@'.format(efi_arch)]
2832 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2833 'EFI CC @0@'.format(efi_cc),
2834 'EFI lib directory: @0@'.format(efi_libdir),
2835 'EFI lds directory: @0@'.format(efi_ldsdir),
2836 'EFI include directory: @0@'.format(efi_incdir)]
2889 ['legacy pkla', install_polkit_pkla],
2891 ['gnu-efi', have_gnu_efi],
2898 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2901 ['man pages', want_man],
2902 ['html pages', want_html],
2903 ['man page indices', want_man and have_lxml],
2908 ['adm group', get_option('adm-group')],
2909 ['wheel group', get_option('wheel-group')],
2912 ['debug mmap cache'],
2915 if tuple.length() >= 2
2918 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2919 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2920 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2925 missing += [tuple[0]]
2931 'enabled features: @0@'.format(', '.join(found)),
2933 'disabled features: @0@'.format(', '.join(missing)),
2935 message('\n '.join(status))
2937 if rootprefixdir != rootprefix_default
2938 message('WARNING:\n' +
2939 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2940 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2941 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))