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>
452 #include <linux/stat.h>
453 #include <sys/stat.h>
455 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
457 foreach decl : ['char16_t',
460 'struct ethtool_link_settings',
461 'struct fib_rule_uid_range',
465 # We get -1 if the size cannot be determined
466 have = cc.sizeof(decl, prefix : decl_headers) > 0
467 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
470 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
471 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
472 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
473 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
474 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
475 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
476 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
477 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
478 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
479 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
480 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
481 # if_tunnel.h is buggy and cannot be included on its own
482 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
483 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
484 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
485 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
486 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
487 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
488 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
489 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
490 ['NDA_IFINDEX', 'linux/neighbour.h'],
491 ['IFA_FLAGS', 'linux/if_addr.h'],
492 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
493 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
494 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
496 prefix = decl.length() > 2 ? decl[2] : ''
497 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
498 conf.set10('HAVE_' + decl[0], have)
501 foreach ident : ['secure_getenv', '__secure_getenv']
502 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
506 ['memfd_create', '''#include <sys/mman.h>'''],
507 ['gettid', '''#include <sys/types.h>
508 #include <unistd.h>'''],
509 ['pivot_root', '''#include <stdlib.h>
510 #include <unistd.h>'''], # no known header declares pivot_root
511 ['name_to_handle_at', '''#include <sys/types.h>
512 #include <sys/stat.h>
513 #include <fcntl.h>'''],
514 ['setns', '''#include <sched.h>'''],
515 ['renameat2', '''#include <stdio.h>
516 #include <fcntl.h>'''],
517 ['kcmp', '''#include <linux/kcmp.h>'''],
518 ['keyctl', '''#include <sys/types.h>
519 #include <keyutils.h>'''],
520 ['copy_file_range', '''#include <sys/syscall.h>
521 #include <unistd.h>'''],
522 ['bpf', '''#include <sys/syscall.h>
523 #include <unistd.h>'''],
524 ['statx', '''#include <sys/types.h>
525 #include <sys/stat.h>
526 #include <unistd.h>'''],
527 ['explicit_bzero' , '''#include <string.h>'''],
528 ['reallocarray', '''#include <malloc.h>'''],
531 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
532 conf.set10('HAVE_' + ident[0].to_upper(), have)
535 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
536 conf.set10('USE_SYS_RANDOM_H', true)
537 conf.set10('HAVE_GETRANDOM', true)
539 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
540 conf.set10('USE_SYS_RANDOM_H', false)
541 conf.set10('HAVE_GETRANDOM', have)
544 #####################################################################
546 sed = find_program('sed')
547 awk = find_program('awk')
548 m4 = find_program('m4')
549 stat = find_program('stat')
550 git = find_program('git', required : false)
551 env = find_program('env')
553 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
554 mkdir_p = 'mkdir -p $DESTDIR/@0@'
555 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
556 splash_bmp = files('test/splash.bmp')
558 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
559 # /usr/sbin, /sbin, and fall back to the default from middle column.
560 progs = [['quotaon', '/usr/sbin/quotaon' ],
561 ['quotacheck', '/usr/sbin/quotacheck' ],
562 ['kill', '/usr/bin/kill' ],
563 ['kmod', '/usr/bin/kmod' ],
564 ['kexec', '/usr/sbin/kexec' ],
565 ['sulogin', '/usr/sbin/sulogin' ],
566 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
567 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
568 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
569 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
572 path = get_option(prog[0] + '-path')
574 message('Using @1@ for @0@'.format(prog[0], path))
576 exe = find_program(prog[0],
577 '/usr/sbin/' + prog[0],
580 path = exe.found() ? exe.path() : prog[1]
582 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
583 conf.set_quoted(name, path)
584 substs.set(name, path)
587 conf.set_quoted('TELINIT', get_option('telinit-path'))
589 if run_command('ln', '--relative', '--help').returncode() != 0
590 error('ln does not support --relative')
593 ############################################################
595 gperf = find_program('gperf')
597 gperf_test_format = '''
599 const char * in_word_set(const char *, @0@);
602 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
603 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
604 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
605 if cc.compiles(gperf_test)
606 gperf_len_type = 'size_t'
608 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
609 if cc.compiles(gperf_test)
610 gperf_len_type = 'unsigned'
612 error('unable to determine gperf len type')
615 message('gperf len type is @0@'.format(gperf_len_type))
616 conf.set('GPERF_LEN_TYPE', gperf_len_type,
617 description : 'The type of gperf "len" parameter')
619 ############################################################
621 if not cc.has_header('sys/capability.h')
622 error('POSIX caps headers not found')
624 foreach header : ['crypt.h',
627 'linux/vm_sockets.h',
629 'valgrind/memcheck.h',
630 'valgrind/valgrind.h',
633 conf.set10('HAVE_' + header.underscorify().to_upper(),
634 cc.has_header(header))
637 ############################################################
639 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
640 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
641 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
643 default_hierarchy = get_option('default-hierarchy')
644 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
645 description : 'default cgroup hierarchy as string')
646 if default_hierarchy == 'legacy'
647 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
648 elif default_hierarchy == 'hybrid'
649 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
651 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
654 time_epoch = get_option('time-epoch')
657 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
659 time_epoch = time_epoch.to_int()
660 conf.set('TIME_EPOCH', time_epoch)
662 system_uid_max = get_option('system-uid-max')
663 if system_uid_max == ''
664 system_uid_max = run_command(
666 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
667 '/etc/login.defs').stdout().strip()
668 if system_uid_max == ''
669 system_uid_max = '999'
672 system_uid_max = system_uid_max.to_int()
673 conf.set('SYSTEM_UID_MAX', system_uid_max)
674 substs.set('systemuidmax', system_uid_max)
675 message('maximum system UID is @0@'.format(system_uid_max))
677 system_gid_max = get_option('system-gid-max')
678 if system_gid_max == ''
679 system_gid_max = run_command(
681 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
682 '/etc/login.defs').stdout().strip()
683 if system_gid_max == ''
684 system_gid_max = '999'
687 system_gid_max = system_gid_max.to_int()
688 conf.set('SYSTEM_GID_MAX', system_gid_max)
689 substs.set('systemgidmax', system_gid_max)
690 message('maximum system GID is @0@'.format(system_gid_max))
692 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
693 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
694 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
695 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
696 substs.set('dynamicuidmin', dynamic_uid_min)
697 substs.set('dynamicuidmax', dynamic_uid_max)
699 container_uid_base_min = get_option('container-uid-base-min').to_int()
700 container_uid_base_max = get_option('container-uid-base-max').to_int()
701 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
702 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
703 substs.set('containeruidbasemin', container_uid_base_min)
704 substs.set('containeruidbasemax', container_uid_base_max)
706 nobody_user = get_option('nobody-user')
707 nobody_group = get_option('nobody-group')
709 getent_result = run_command('getent', 'passwd', '65534')
710 if getent_result.returncode() == 0
711 name = getent_result.stdout().split(':')[0]
712 if name != nobody_user
713 message('WARNING:\n' +
714 ' 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) +
715 ' Your build will result in an user table setup that is incompatible with the local system.')
718 id_result = run_command('id', '-u', nobody_user)
719 if id_result.returncode() == 0
720 id = id_result.stdout().to_int()
722 message('WARNING:\n' +
723 ' 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) +
724 ' Your build will result in an user table setup that is incompatible with the local system.')
728 getent_result = run_command('getent', 'group', '65534')
729 if getent_result.returncode() == 0
730 name = getent_result.stdout().split(':')[0]
731 if name != nobody_group
732 message('WARNING:\n' +
733 ' 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) +
734 ' Your build will result in an group table setup that is incompatible with the local system.')
737 id_result = run_command('id', '-g', nobody_group)
738 if id_result.returncode() == 0
739 id = id_result.stdout().to_int()
741 message('WARNING:\n' +
742 ' 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) +
743 ' Your build will result in an group table setup that is incompatible with the local system.')
746 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
747 message('WARNING:\n' +
748 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
749 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
752 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
753 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
754 substs.set('NOBODY_USER_NAME', nobody_user)
755 substs.set('NOBODY_GROUP_NAME', nobody_group)
757 tty_gid = get_option('tty-gid')
758 conf.set('TTY_GID', tty_gid)
759 substs.set('TTY_GID', tty_gid)
761 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
762 if get_option('users-gid') != ''
763 users_gid = get_option('users-gid').to_int()
767 substs.set('USERS_GID', users_gid)
769 if get_option('adm-group')
770 m4_defines += ['-DENABLE_ADM_GROUP']
773 if get_option('wheel-group')
774 m4_defines += ['-DENABLE_WHEEL_GROUP']
777 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
778 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
780 kill_user_processes = get_option('default-kill-user-processes')
781 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
782 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
784 dns_servers = get_option('dns-servers')
785 conf.set_quoted('DNS_SERVERS', dns_servers)
786 substs.set('DNS_SERVERS', dns_servers)
788 ntp_servers = get_option('ntp-servers')
789 conf.set_quoted('NTP_SERVERS', ntp_servers)
790 substs.set('NTP_SERVERS', ntp_servers)
792 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
794 substs.set('SUSHELL', get_option('debug-shell'))
795 substs.set('DEBUGTTY', get_option('debug-tty'))
797 debug = get_option('debug')
798 enable_debug_hashmap = false
799 enable_debug_mmap_cache = false
801 foreach name : debug.split(',')
803 enable_debug_hashmap = true
804 elif name == 'mmap-cache'
805 enable_debug_mmap_cache = true
807 message('unknown debug option "@0@", ignoring'.format(name))
811 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
812 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
814 #####################################################################
816 threads = dependency('threads')
817 librt = cc.find_library('rt')
818 libm = cc.find_library('m')
819 libdl = cc.find_library('dl')
820 libcrypt = cc.find_library('crypt')
822 libcap = dependency('libcap', required : false)
823 if not libcap.found()
824 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
825 libcap = cc.find_library('cap')
828 libmount = dependency('mount',
830 required : not fuzzer_build)
832 want_seccomp = get_option('seccomp')
833 if want_seccomp != 'false' and not fuzzer_build
834 libseccomp = dependency('libseccomp',
835 version : '>= 2.3.1',
836 required : want_seccomp == 'true')
837 have = libseccomp.found()
842 conf.set10('HAVE_SECCOMP', have)
843 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
845 want_selinux = get_option('selinux')
846 if want_selinux != 'false' and not fuzzer_build
847 libselinux = dependency('libselinux',
848 version : '>= 2.1.9',
849 required : want_selinux == 'true')
850 have = libselinux.found()
855 conf.set10('HAVE_SELINUX', have)
856 m4_defines += have ? ['-DHAVE_SELINUX'] : []
858 want_apparmor = get_option('apparmor')
859 if want_apparmor != 'false' and not fuzzer_build
860 libapparmor = dependency('libapparmor',
861 required : want_apparmor == 'true')
862 have = libapparmor.found()
867 conf.set10('HAVE_APPARMOR', have)
868 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
870 smack_run_label = get_option('smack-run-label')
871 if smack_run_label != ''
872 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
873 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
876 want_polkit = get_option('polkit')
877 install_polkit = false
878 install_polkit_pkla = false
879 if want_polkit != 'false' and not fuzzer_build
880 install_polkit = true
882 libpolkit = dependency('polkit-gobject-1',
884 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
885 message('Old polkit detected, will install pkla files')
886 install_polkit_pkla = true
889 conf.set10('ENABLE_POLKIT', install_polkit)
891 want_acl = get_option('acl')
892 if want_acl != 'false' and not fuzzer_build
893 libacl = cc.find_library('acl', required : want_acl == 'true')
894 have = libacl.found()
899 conf.set10('HAVE_ACL', have)
900 m4_defines += have ? ['-DHAVE_ACL'] : []
902 want_audit = get_option('audit')
903 if want_audit != 'false' and not fuzzer_build
904 libaudit = dependency('audit', required : want_audit == 'true')
905 have = libaudit.found()
910 conf.set10('HAVE_AUDIT', have)
912 want_blkid = get_option('blkid')
913 if want_blkid != 'false' and not fuzzer_build
914 libblkid = dependency('blkid', required : want_blkid == 'true')
915 have = libblkid.found()
920 conf.set10('HAVE_BLKID', have)
922 want_kmod = get_option('kmod')
923 if want_kmod != 'false' and not fuzzer_build
924 libkmod = dependency('libkmod',
926 required : want_kmod == 'true')
927 have = libkmod.found()
932 conf.set10('HAVE_KMOD', have)
934 want_pam = get_option('pam')
935 if want_pam != 'false' and not fuzzer_build
936 libpam = cc.find_library('pam', required : want_pam == 'true')
937 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
938 have = libpam.found() and libpam_misc.found()
944 conf.set10('HAVE_PAM', have)
945 m4_defines += have ? ['-DHAVE_PAM'] : []
947 want_microhttpd = get_option('microhttpd')
948 if want_microhttpd != 'false' and not fuzzer_build
949 libmicrohttpd = dependency('libmicrohttpd',
950 version : '>= 0.9.33',
951 required : want_microhttpd == 'true')
952 have = libmicrohttpd.found()
957 conf.set10('HAVE_MICROHTTPD', have)
958 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
960 want_libcryptsetup = get_option('libcryptsetup')
961 if want_libcryptsetup != 'false' and not fuzzer_build
962 libcryptsetup = dependency('libcryptsetup',
963 version : '>= 1.6.0',
964 required : want_libcryptsetup == 'true')
965 have = libcryptsetup.found()
970 conf.set10('HAVE_LIBCRYPTSETUP', have)
972 want_libcurl = get_option('libcurl')
973 if want_libcurl != 'false' and not fuzzer_build
974 libcurl = dependency('libcurl',
975 version : '>= 7.32.0',
976 required : want_libcurl == 'true')
977 have = libcurl.found()
982 conf.set10('HAVE_LIBCURL', have)
983 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
985 want_libidn = get_option('libidn')
986 want_libidn2 = get_option('libidn2')
987 if want_libidn == 'true' and want_libidn2 == 'true'
988 error('libidn and libidn2 cannot be requested simultaneously')
991 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
992 libidn = dependency('libidn',
993 required : want_libidn == 'true')
994 have = libidn.found()
999 conf.set10('HAVE_LIBIDN', have)
1000 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1001 if not have and want_libidn2 != 'false' and not fuzzer_build
1002 # libidn is used for both libidn and libidn2 objects
1003 libidn = dependency('libidn2',
1004 required : want_libidn2 == 'true')
1005 have = libidn.found()
1009 conf.set10('HAVE_LIBIDN2', have)
1010 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1012 want_libiptc = get_option('libiptc')
1013 if want_libiptc != 'false' and not fuzzer_build
1014 libiptc = dependency('libiptc',
1015 required : want_libiptc == 'true')
1016 have = libiptc.found()
1021 conf.set10('HAVE_LIBIPTC', have)
1022 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1024 want_qrencode = get_option('qrencode')
1025 if want_qrencode != 'false' and not fuzzer_build
1026 libqrencode = dependency('libqrencode',
1027 required : want_qrencode == 'true')
1028 have = libqrencode.found()
1033 conf.set10('HAVE_QRENCODE', have)
1035 want_gcrypt = get_option('gcrypt')
1036 if want_gcrypt != 'false' and not fuzzer_build
1037 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1038 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1039 have = libgcrypt.found() and libgpg_error.found()
1044 # link to neither of the libs if one is not found
1048 conf.set10('HAVE_GCRYPT', have)
1050 want_gnutls = get_option('gnutls')
1051 if want_gnutls != 'false' and not fuzzer_build
1052 libgnutls = dependency('gnutls',
1053 version : '>= 3.1.4',
1054 required : want_gnutls == 'true')
1055 have = libgnutls.found()
1060 conf.set10('HAVE_GNUTLS', have)
1062 want_elfutils = get_option('elfutils')
1063 if want_elfutils != 'false' and not fuzzer_build
1064 libdw = dependency('libdw',
1065 required : want_elfutils == 'true')
1066 have = libdw.found()
1071 conf.set10('HAVE_ELFUTILS', have)
1073 want_zlib = get_option('zlib')
1074 if want_zlib != 'false' and not fuzzer_build
1075 libz = dependency('zlib',
1076 required : want_zlib == 'true')
1082 conf.set10('HAVE_ZLIB', have)
1084 want_bzip2 = get_option('bzip2')
1085 if want_bzip2 != 'false' and not fuzzer_build
1086 libbzip2 = cc.find_library('bz2',
1087 required : want_bzip2 == 'true')
1088 have = libbzip2.found()
1093 conf.set10('HAVE_BZIP2', have)
1095 want_xz = get_option('xz')
1096 if want_xz != 'false' and not fuzzer_build
1097 libxz = dependency('liblzma',
1098 required : want_xz == 'true')
1099 have = libxz.found()
1104 conf.set10('HAVE_XZ', have)
1106 want_lz4 = get_option('lz4')
1107 if want_lz4 != 'false' and not fuzzer_build
1108 liblz4 = dependency('liblz4',
1109 required : want_lz4 == 'true')
1110 have = liblz4.found()
1115 conf.set10('HAVE_LZ4', have)
1117 want_xkbcommon = get_option('xkbcommon')
1118 if want_xkbcommon != 'false' and not fuzzer_build
1119 libxkbcommon = dependency('xkbcommon',
1120 version : '>= 0.3.0',
1121 required : want_xkbcommon == 'true')
1122 have = libxkbcommon.found()
1127 conf.set10('HAVE_XKBCOMMON', have)
1129 want_pcre2 = get_option('pcre2')
1130 if want_pcre2 != 'false'
1131 libpcre2 = dependency('libpcre2-8',
1132 required : want_pcre2 == 'true')
1133 have = libpcre2.found()
1138 conf.set10('HAVE_PCRE2', have)
1140 want_glib = get_option('glib')
1141 if want_glib != 'false' and not fuzzer_build
1142 libglib = dependency('glib-2.0',
1143 version : '>= 2.22.0',
1144 required : want_glib == 'true')
1145 libgobject = dependency('gobject-2.0',
1146 version : '>= 2.22.0',
1147 required : want_glib == 'true')
1148 libgio = dependency('gio-2.0',
1149 required : want_glib == 'true')
1150 have = libglib.found() and libgobject.found() and libgio.found()
1157 conf.set10('HAVE_GLIB', have)
1159 want_dbus = get_option('dbus')
1160 if want_dbus != 'false' and not fuzzer_build
1161 libdbus = dependency('dbus-1',
1162 version : '>= 1.3.2',
1163 required : want_dbus == 'true')
1164 have = libdbus.found()
1169 conf.set10('HAVE_DBUS', have)
1171 default_dnssec = get_option('default-dnssec')
1173 default_dnssec = 'no'
1175 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1176 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1177 default_dnssec = 'no'
1179 conf.set('DEFAULT_DNSSEC_MODE',
1180 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1181 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1183 want_importd = get_option('importd')
1184 if want_importd != 'false'
1185 have = (conf.get('HAVE_LIBCURL') == 1 and
1186 conf.get('HAVE_ZLIB') == 1 and
1187 conf.get('HAVE_BZIP2') == 1 and
1188 conf.get('HAVE_XZ') == 1 and
1189 conf.get('HAVE_GCRYPT') == 1)
1190 if want_importd == 'true' and not have
1191 error('importd support was requested, but dependencies are not available')
1196 conf.set10('ENABLE_IMPORTD', have)
1198 want_remote = get_option('remote')
1199 if want_remote != 'false'
1200 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1201 conf.get('HAVE_LIBCURL') == 1]
1202 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1203 # it's possible to build one without the other. Complain only if
1204 # support was explictly requested. The auxiliary files like sysusers
1205 # config should be installed when any of the programs are built.
1206 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1207 error('remote support was requested, but dependencies are not available')
1209 have = have_deps[0] or have_deps[1]
1213 conf.set10('ENABLE_REMOTE', have)
1215 foreach term : ['utmp',
1246 have = get_option(term)
1247 name = 'ENABLE_' + term.underscorify().to_upper()
1248 conf.set10(name, have)
1249 m4_defines += have ? ['-D' + name] : []
1252 want_tests = get_option('tests')
1253 install_tests = get_option('install-tests')
1254 slow_tests = get_option('slow-tests')
1258 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1260 #####################################################################
1262 if get_option('efi')
1263 efi_arch = host_machine.cpu_family()
1265 if efi_arch == 'x86'
1266 EFI_MACHINE_TYPE_NAME = 'ia32'
1267 gnu_efi_arch = 'ia32'
1268 elif efi_arch == 'x86_64'
1269 EFI_MACHINE_TYPE_NAME = 'x64'
1270 gnu_efi_arch = 'x86_64'
1271 elif efi_arch == 'arm'
1272 EFI_MACHINE_TYPE_NAME = 'arm'
1273 gnu_efi_arch = 'arm'
1274 elif efi_arch == 'aarch64'
1275 EFI_MACHINE_TYPE_NAME = 'aa64'
1276 gnu_efi_arch = 'aarch64'
1278 EFI_MACHINE_TYPE_NAME = ''
1283 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1285 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1289 conf.set10('ENABLE_EFI', have)
1291 #####################################################################
1293 config_h = configure_file(
1294 output : 'config.h',
1295 configuration : conf)
1297 includes = include_directories('src/basic',
1307 'src/libsystemd/sd-bus',
1308 'src/libsystemd/sd-device',
1309 'src/libsystemd/sd-hwdb',
1310 'src/libsystemd/sd-id128',
1311 'src/libsystemd/sd-netlink',
1312 'src/libsystemd/sd-network',
1313 'src/libsystemd-network',
1316 add_project_arguments('-include', 'config.h', language : 'c')
1320 subdir('src/systemd')
1322 subdir('src/libsystemd')
1323 subdir('src/libsystemd-network')
1324 subdir('src/journal')
1327 libjournal_core = static_library(
1329 libjournal_core_sources,
1331 include_directories : includes,
1334 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1335 libsystemd = shared_library(
1337 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1338 version : libsystemd_version,
1339 include_directories : includes,
1340 link_args : ['-shared',
1341 '-Wl,--version-script=' + libsystemd_sym_path],
1342 link_with : [libbasic,
1344 link_whole : [libsystemd_static,
1346 dependencies : [threads,
1350 link_depends : libsystemd_sym,
1352 install_dir : rootlibdir)
1354 ############################################################
1356 # binaries that have --help and are intended for use by humans,
1357 # usually, but not always, installed in /bin.
1358 public_programs = []
1360 subdir('src/libudev')
1361 subdir('src/shared')
1364 subdir('src/network')
1366 subdir('src/analyze')
1367 subdir('src/journal-remote')
1368 subdir('src/coredump')
1369 subdir('src/hostname')
1370 subdir('src/import')
1371 subdir('src/kernel-install')
1372 subdir('src/locale')
1373 subdir('src/machine')
1374 subdir('src/nspawn')
1375 subdir('src/resolve')
1376 subdir('src/timedate')
1377 subdir('src/timesync')
1378 subdir('src/vconsole')
1379 subdir('src/boot/efi')
1386 ############################################################
1388 # only static linking apart from libdl, to make sure that the
1389 # module is linked to all libraries that it uses.
1390 test_dlopen = executable(
1393 include_directories : includes,
1394 link_with : [libbasic],
1395 dependencies : [libdl])
1397 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1398 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1399 ['mymachines', 'ENABLE_MACHINED'],
1400 ['resolve', 'ENABLE_RESOLVE']]
1402 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1406 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1407 version_script_arg = join_paths(meson.current_source_dir(), sym)
1409 nss = shared_library(
1411 'src/nss-@0@/nss-@0@.c'.format(module),
1413 include_directories : includes,
1414 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1415 link_args : ['-Wl,-z,nodelete',
1417 '-Wl,--version-script=' + version_script_arg,
1419 link_with : [libsystemd_static,
1421 dependencies : [threads,
1425 install_dir : rootlibdir)
1427 # We cannot use shared_module because it does not support version suffix.
1428 # Unfortunately shared_library insists on creating the symlink…
1429 meson.add_install_script('sh', '-c',
1430 'rm $DESTDIR@0@/libnss_@1@.so'
1431 .format(rootlibdir, module))
1433 test('dlopen-nss_' + module,
1435 args : [nss.full_path()]) # path to dlopen must include a slash
1439 ############################################################
1441 executable('systemd',
1443 include_directories : includes,
1444 link_with : [libcore,
1446 dependencies : [threads,
1452 install_rpath : rootlibexecdir,
1454 install_dir : rootlibexecdir)
1456 exe = executable('systemd-analyze',
1457 systemd_analyze_sources,
1458 include_directories : includes,
1459 link_with : [libcore,
1461 dependencies : [threads,
1467 install_rpath : rootlibexecdir,
1469 public_programs += [exe]
1471 executable('systemd-journald',
1472 systemd_journald_sources,
1473 include_directories : includes,
1474 link_with : [libjournal_core,
1476 dependencies : [threads,
1480 install_rpath : rootlibexecdir,
1482 install_dir : rootlibexecdir)
1484 exe = executable('systemd-cat',
1485 systemd_cat_sources,
1486 include_directories : includes,
1487 link_with : [libjournal_core,
1489 dependencies : [threads],
1490 install_rpath : rootlibexecdir,
1492 public_programs += [exe]
1494 exe = executable('journalctl',
1496 include_directories : includes,
1497 link_with : [libshared],
1498 dependencies : [threads,
1503 install_rpath : rootlibexecdir,
1505 install_dir : rootbindir)
1506 public_programs += [exe]
1508 executable('systemd-getty-generator',
1509 'src/getty-generator/getty-generator.c',
1510 include_directories : includes,
1511 link_with : [libshared],
1512 install_rpath : rootlibexecdir,
1514 install_dir : systemgeneratordir)
1516 executable('systemd-debug-generator',
1517 'src/debug-generator/debug-generator.c',
1518 include_directories : includes,
1519 link_with : [libshared],
1520 install_rpath : rootlibexecdir,
1522 install_dir : systemgeneratordir)
1524 executable('systemd-fstab-generator',
1525 'src/fstab-generator/fstab-generator.c',
1526 'src/core/mount-setup.c',
1527 include_directories : includes,
1528 link_with : [libshared],
1529 install_rpath : rootlibexecdir,
1531 install_dir : systemgeneratordir)
1533 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1534 executable('30-systemd-environment-d-generator',
1535 'src/environment-d-generator/environment-d-generator.c',
1536 include_directories : includes,
1537 link_with : [libshared],
1538 install_rpath : rootlibexecdir,
1540 install_dir : userenvgeneratordir)
1542 meson.add_install_script(meson_make_symlink,
1543 join_paths(sysconfdir, 'environment'),
1544 join_paths(environmentdir, '99-environment.conf'))
1547 if conf.get('ENABLE_HIBERNATE') == 1
1548 executable('systemd-hibernate-resume-generator',
1549 'src/hibernate-resume/hibernate-resume-generator.c',
1550 include_directories : includes,
1551 link_with : [libshared],
1552 install_rpath : rootlibexecdir,
1554 install_dir : systemgeneratordir)
1556 executable('systemd-hibernate-resume',
1557 'src/hibernate-resume/hibernate-resume.c',
1558 include_directories : includes,
1559 link_with : [libshared],
1560 install_rpath : rootlibexecdir,
1562 install_dir : rootlibexecdir)
1565 if conf.get('HAVE_BLKID') == 1
1566 executable('systemd-gpt-auto-generator',
1567 'src/gpt-auto-generator/gpt-auto-generator.c',
1568 'src/basic/blkid-util.h',
1569 include_directories : includes,
1570 link_with : [libshared],
1571 dependencies : libblkid,
1572 install_rpath : rootlibexecdir,
1574 install_dir : systemgeneratordir)
1576 exe = executable('systemd-dissect',
1577 'src/dissect/dissect.c',
1578 include_directories : includes,
1579 link_with : [libshared],
1580 install_rpath : rootlibexecdir,
1582 install_dir : rootlibexecdir)
1583 public_programs += [exe]
1586 if conf.get('ENABLE_RESOLVE') == 1
1587 executable('systemd-resolved',
1588 systemd_resolved_sources,
1589 include_directories : includes,
1590 link_with : [libshared,
1592 libsystemd_resolve_core],
1593 dependencies : [threads,
1597 install_rpath : rootlibexecdir,
1599 install_dir : rootlibexecdir)
1601 exe = executable('systemd-resolve',
1602 systemd_resolve_sources,
1603 include_directories : includes,
1604 link_with : [libshared,
1606 libsystemd_resolve_core],
1607 dependencies : [threads,
1611 install_rpath : rootlibexecdir,
1613 public_programs += [exe]
1616 if conf.get('ENABLE_LOGIND') == 1
1617 executable('systemd-logind',
1618 systemd_logind_sources,
1619 include_directories : includes,
1620 link_with : [liblogind_core,
1622 dependencies : [threads,
1624 install_rpath : rootlibexecdir,
1626 install_dir : rootlibexecdir)
1628 exe = executable('loginctl',
1630 include_directories : includes,
1631 link_with : [libshared],
1632 dependencies : [threads,
1635 install_rpath : rootlibexecdir,
1637 install_dir : rootbindir)
1638 public_programs += [exe]
1640 exe = executable('systemd-inhibit',
1641 'src/login/inhibit.c',
1642 include_directories : includes,
1643 link_with : [libshared],
1644 install_rpath : rootlibexecdir,
1646 install_dir : rootbindir)
1647 public_programs += [exe]
1649 if conf.get('HAVE_PAM') == 1
1650 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1651 pam_systemd = shared_library(
1655 include_directories : includes,
1656 link_args : ['-shared',
1657 '-Wl,--version-script=' + version_script_arg],
1658 link_with : [libsystemd_static,
1660 dependencies : [threads,
1663 link_depends : pam_systemd_sym,
1665 install_dir : pamlibdir)
1667 test('dlopen-pam_systemd',
1669 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1673 if conf.get('HAVE_PAM') == 1
1674 executable('systemd-user-sessions',
1675 'src/user-sessions/user-sessions.c',
1676 include_directories : includes,
1677 link_with : [libshared],
1678 install_rpath : rootlibexecdir,
1680 install_dir : rootlibexecdir)
1683 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1684 exe = executable('bootctl',
1685 'src/boot/bootctl.c',
1686 include_directories : includes,
1687 link_with : [libshared],
1688 dependencies : [libblkid],
1689 install_rpath : rootlibexecdir,
1691 public_programs += [exe]
1694 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1695 include_directories : includes,
1696 link_with : [libshared],
1697 dependencies : [threads],
1698 install_rpath : rootlibexecdir,
1700 public_programs += [exe]
1702 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1703 include_directories : includes,
1704 link_with : [libshared],
1705 dependencies : [threads,
1710 install_rpath : rootlibexecdir,
1712 install_dir : rootbindir)
1713 public_programs += [exe]
1715 if conf.get('ENABLE_BACKLIGHT') == 1
1716 executable('systemd-backlight',
1717 'src/backlight/backlight.c',
1718 include_directories : includes,
1719 link_with : [libshared],
1720 install_rpath : rootlibexecdir,
1722 install_dir : rootlibexecdir)
1725 if conf.get('ENABLE_RFKILL') == 1
1726 executable('systemd-rfkill',
1727 'src/rfkill/rfkill.c',
1728 include_directories : includes,
1729 link_with : [libshared],
1730 install_rpath : rootlibexecdir,
1732 install_dir : rootlibexecdir)
1735 executable('systemd-system-update-generator',
1736 'src/system-update-generator/system-update-generator.c',
1737 include_directories : includes,
1738 link_with : [libshared],
1739 install_rpath : rootlibexecdir,
1741 install_dir : systemgeneratordir)
1743 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1744 executable('systemd-cryptsetup',
1745 'src/cryptsetup/cryptsetup.c',
1746 include_directories : includes,
1747 link_with : [libshared],
1748 dependencies : [libcryptsetup],
1749 install_rpath : rootlibexecdir,
1751 install_dir : rootlibexecdir)
1753 executable('systemd-cryptsetup-generator',
1754 'src/cryptsetup/cryptsetup-generator.c',
1755 include_directories : includes,
1756 link_with : [libshared],
1757 dependencies : [libcryptsetup],
1758 install_rpath : rootlibexecdir,
1760 install_dir : systemgeneratordir)
1762 executable('systemd-veritysetup',
1763 'src/veritysetup/veritysetup.c',
1764 include_directories : includes,
1765 link_with : [libshared],
1766 dependencies : [libcryptsetup],
1767 install_rpath : rootlibexecdir,
1769 install_dir : rootlibexecdir)
1771 executable('systemd-veritysetup-generator',
1772 'src/veritysetup/veritysetup-generator.c',
1773 include_directories : includes,
1774 link_with : [libshared],
1775 dependencies : [libcryptsetup],
1776 install_rpath : rootlibexecdir,
1778 install_dir : systemgeneratordir)
1781 if conf.get('HAVE_SYSV_COMPAT') == 1
1782 executable('systemd-sysv-generator',
1783 'src/sysv-generator/sysv-generator.c',
1784 include_directories : includes,
1785 link_with : [libshared],
1786 install_rpath : rootlibexecdir,
1788 install_dir : systemgeneratordir)
1790 executable('systemd-rc-local-generator',
1791 'src/rc-local-generator/rc-local-generator.c',
1792 include_directories : includes,
1793 link_with : [libshared],
1794 install_rpath : rootlibexecdir,
1796 install_dir : systemgeneratordir)
1799 if conf.get('ENABLE_HOSTNAMED') == 1
1800 executable('systemd-hostnamed',
1801 'src/hostname/hostnamed.c',
1802 include_directories : includes,
1803 link_with : [libshared],
1804 install_rpath : rootlibexecdir,
1806 install_dir : rootlibexecdir)
1808 exe = executable('hostnamectl',
1809 'src/hostname/hostnamectl.c',
1810 include_directories : includes,
1811 link_with : [libshared],
1812 install_rpath : rootlibexecdir,
1814 public_programs += [exe]
1817 if conf.get('ENABLE_LOCALED') == 1
1818 if conf.get('HAVE_XKBCOMMON') == 1
1819 # logind will load libxkbcommon.so dynamically on its own
1825 executable('systemd-localed',
1826 systemd_localed_sources,
1827 include_directories : includes,
1828 link_with : [libshared],
1829 dependencies : deps,
1830 install_rpath : rootlibexecdir,
1832 install_dir : rootlibexecdir)
1834 exe = executable('localectl',
1836 include_directories : includes,
1837 link_with : [libshared],
1838 install_rpath : rootlibexecdir,
1840 public_programs += [exe]
1843 if conf.get('ENABLE_TIMEDATED') == 1
1844 executable('systemd-timedated',
1845 'src/timedate/timedated.c',
1846 include_directories : includes,
1847 link_with : [libshared],
1848 install_rpath : rootlibexecdir,
1850 install_dir : rootlibexecdir)
1852 exe = executable('timedatectl',
1853 'src/timedate/timedatectl.c',
1854 include_directories : includes,
1855 install_rpath : rootlibexecdir,
1856 link_with : [libshared],
1858 public_programs += [exe]
1861 if conf.get('ENABLE_TIMESYNCD') == 1
1862 executable('systemd-timesyncd',
1863 systemd_timesyncd_sources,
1864 include_directories : includes,
1865 link_with : [libshared],
1866 dependencies : [threads,
1868 install_rpath : rootlibexecdir,
1870 install_dir : rootlibexecdir)
1873 if conf.get('ENABLE_MACHINED') == 1
1874 executable('systemd-machined',
1875 systemd_machined_sources,
1876 include_directories : includes,
1877 link_with : [libmachine_core,
1879 install_rpath : rootlibexecdir,
1881 install_dir : rootlibexecdir)
1883 exe = executable('machinectl',
1884 'src/machine/machinectl.c',
1885 include_directories : includes,
1886 link_with : [libshared],
1887 dependencies : [threads,
1890 install_rpath : rootlibexecdir,
1892 install_dir : rootbindir)
1893 public_programs += [exe]
1896 if conf.get('ENABLE_IMPORTD') == 1
1897 executable('systemd-importd',
1898 systemd_importd_sources,
1899 include_directories : includes,
1900 link_with : [libshared],
1901 dependencies : [threads],
1902 install_rpath : rootlibexecdir,
1904 install_dir : rootlibexecdir)
1906 systemd_pull = executable('systemd-pull',
1907 systemd_pull_sources,
1908 include_directories : includes,
1909 link_with : [libshared],
1910 dependencies : [libcurl,
1915 install_rpath : rootlibexecdir,
1917 install_dir : rootlibexecdir)
1919 systemd_import = executable('systemd-import',
1920 systemd_import_sources,
1921 include_directories : includes,
1922 link_with : [libshared],
1923 dependencies : [libcurl,
1927 install_rpath : rootlibexecdir,
1929 install_dir : rootlibexecdir)
1931 systemd_export = executable('systemd-export',
1932 systemd_export_sources,
1933 include_directories : includes,
1934 link_with : [libshared],
1935 dependencies : [libcurl,
1939 install_rpath : rootlibexecdir,
1941 install_dir : rootlibexecdir)
1942 public_programs += [systemd_pull, systemd_import, systemd_export]
1945 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1946 exe = executable('systemd-journal-upload',
1947 systemd_journal_upload_sources,
1948 include_directories : includes,
1949 link_with : [libshared],
1950 dependencies : [threads,
1955 install_rpath : rootlibexecdir,
1957 install_dir : rootlibexecdir)
1958 public_programs += [exe]
1961 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1962 s_j_remote = executable('systemd-journal-remote',
1963 systemd_journal_remote_sources,
1964 include_directories : includes,
1965 link_with : [libshared],
1966 dependencies : [threads,
1971 install_rpath : rootlibexecdir,
1973 install_dir : rootlibexecdir)
1975 s_j_gatewayd = executable('systemd-journal-gatewayd',
1976 systemd_journal_gatewayd_sources,
1977 include_directories : includes,
1978 link_with : [libshared],
1979 dependencies : [threads,
1984 install_rpath : rootlibexecdir,
1986 install_dir : rootlibexecdir)
1987 public_programs += [s_j_remote, s_j_gatewayd]
1990 if conf.get('ENABLE_COREDUMP') == 1
1991 executable('systemd-coredump',
1992 systemd_coredump_sources,
1993 include_directories : includes,
1994 link_with : [libshared],
1995 dependencies : [threads,
2000 install_rpath : rootlibexecdir,
2002 install_dir : rootlibexecdir)
2004 exe = executable('coredumpctl',
2005 coredumpctl_sources,
2006 include_directories : includes,
2007 link_with : [libshared],
2008 dependencies : [threads,
2011 install_rpath : rootlibexecdir,
2013 public_programs += [exe]
2016 if conf.get('ENABLE_BINFMT') == 1
2017 exe = executable('systemd-binfmt',
2018 'src/binfmt/binfmt.c',
2019 include_directories : includes,
2020 link_with : [libshared],
2021 install_rpath : rootlibexecdir,
2023 install_dir : rootlibexecdir)
2024 public_programs += [exe]
2026 meson.add_install_script('sh', '-c',
2027 mkdir_p.format(binfmtdir))
2028 meson.add_install_script('sh', '-c',
2029 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2032 if conf.get('ENABLE_VCONSOLE') == 1
2033 executable('systemd-vconsole-setup',
2034 'src/vconsole/vconsole-setup.c',
2035 include_directories : includes,
2036 link_with : [libshared],
2037 install_rpath : rootlibexecdir,
2039 install_dir : rootlibexecdir)
2042 if conf.get('ENABLE_RANDOMSEED') == 1
2043 executable('systemd-random-seed',
2044 'src/random-seed/random-seed.c',
2045 include_directories : includes,
2046 link_with : [libshared],
2047 install_rpath : rootlibexecdir,
2049 install_dir : rootlibexecdir)
2052 if conf.get('ENABLE_FIRSTBOOT') == 1
2053 executable('systemd-firstboot',
2054 'src/firstboot/firstboot.c',
2055 include_directories : includes,
2056 link_with : [libshared],
2057 dependencies : [libcrypt],
2058 install_rpath : rootlibexecdir,
2060 install_dir : rootbindir)
2063 executable('systemd-remount-fs',
2064 'src/remount-fs/remount-fs.c',
2065 'src/core/mount-setup.c',
2066 'src/core/mount-setup.h',
2067 include_directories : includes,
2068 link_with : [libshared],
2069 install_rpath : rootlibexecdir,
2071 install_dir : rootlibexecdir)
2073 executable('systemd-machine-id-setup',
2074 'src/machine-id-setup/machine-id-setup-main.c',
2075 'src/core/machine-id-setup.c',
2076 'src/core/machine-id-setup.h',
2077 include_directories : includes,
2078 link_with : [libshared],
2079 install_rpath : rootlibexecdir,
2081 install_dir : rootbindir)
2083 executable('systemd-fsck',
2085 include_directories : includes,
2086 link_with : [libshared],
2087 install_rpath : rootlibexecdir,
2089 install_dir : rootlibexecdir)
2091 executable('systemd-growfs',
2092 'src/partition/growfs.c',
2093 include_directories : includes,
2094 link_with : [libshared],
2095 dependencies : [libcryptsetup],
2096 install_rpath : rootlibexecdir,
2098 install_dir : rootlibexecdir)
2100 executable('systemd-makefs',
2101 'src/partition/makefs.c',
2102 include_directories : includes,
2103 link_with : [libshared],
2104 install_rpath : rootlibexecdir,
2106 install_dir : rootlibexecdir)
2108 executable('systemd-sleep',
2109 'src/sleep/sleep.c',
2110 include_directories : includes,
2111 link_with : [libshared],
2112 install_rpath : rootlibexecdir,
2114 install_dir : rootlibexecdir)
2116 exe = executable('systemd-sysctl',
2117 'src/sysctl/sysctl.c',
2118 include_directories : includes,
2119 link_with : [libshared],
2120 install_rpath : rootlibexecdir,
2122 install_dir : rootlibexecdir)
2123 public_programs += [exe]
2125 executable('systemd-ac-power',
2126 'src/ac-power/ac-power.c',
2127 include_directories : includes,
2128 link_with : [libshared],
2129 install_rpath : rootlibexecdir,
2131 install_dir : rootlibexecdir)
2133 exe = executable('systemd-detect-virt',
2134 'src/detect-virt/detect-virt.c',
2135 include_directories : includes,
2136 link_with : [libshared],
2137 install_rpath : rootlibexecdir,
2139 public_programs += [exe]
2141 exe = executable('systemd-delta',
2142 'src/delta/delta.c',
2143 include_directories : includes,
2144 link_with : [libshared],
2145 install_rpath : rootlibexecdir,
2147 public_programs += [exe]
2149 exe = executable('systemd-escape',
2150 'src/escape/escape.c',
2151 include_directories : includes,
2152 link_with : [libshared],
2153 install_rpath : rootlibexecdir,
2155 install_dir : rootbindir)
2156 public_programs += [exe]
2158 exe = executable('systemd-notify',
2159 'src/notify/notify.c',
2160 include_directories : includes,
2161 link_with : [libshared],
2162 install_rpath : rootlibexecdir,
2164 install_dir : rootbindir)
2165 public_programs += [exe]
2167 executable('systemd-volatile-root',
2168 'src/volatile-root/volatile-root.c',
2169 include_directories : includes,
2170 link_with : [libshared],
2171 install_rpath : rootlibexecdir,
2173 install_dir : rootlibexecdir)
2175 executable('systemd-cgroups-agent',
2176 'src/cgroups-agent/cgroups-agent.c',
2177 include_directories : includes,
2178 link_with : [libshared],
2179 install_rpath : rootlibexecdir,
2181 install_dir : rootlibexecdir)
2183 exe = executable('systemd-path',
2185 include_directories : includes,
2186 link_with : [libshared],
2187 install_rpath : rootlibexecdir,
2189 public_programs += [exe]
2191 exe = executable('systemd-ask-password',
2192 'src/ask-password/ask-password.c',
2193 include_directories : includes,
2194 link_with : [libshared],
2195 install_rpath : rootlibexecdir,
2197 install_dir : rootbindir)
2198 public_programs += [exe]
2200 executable('systemd-reply-password',
2201 'src/reply-password/reply-password.c',
2202 include_directories : includes,
2203 link_with : [libshared],
2204 install_rpath : rootlibexecdir,
2206 install_dir : rootlibexecdir)
2208 exe = executable('systemd-tty-ask-password-agent',
2209 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2210 include_directories : includes,
2211 link_with : [libshared],
2212 install_rpath : rootlibexecdir,
2214 install_dir : rootbindir)
2215 public_programs += [exe]
2217 exe = executable('systemd-cgls',
2219 include_directories : includes,
2220 link_with : [libshared],
2221 install_rpath : rootlibexecdir,
2223 public_programs += [exe]
2225 exe = executable('systemd-cgtop',
2226 'src/cgtop/cgtop.c',
2227 include_directories : includes,
2228 link_with : [libshared],
2229 install_rpath : rootlibexecdir,
2231 public_programs += [exe]
2233 executable('systemd-initctl',
2234 'src/initctl/initctl.c',
2235 include_directories : includes,
2236 link_with : [libshared],
2237 install_rpath : rootlibexecdir,
2239 install_dir : rootlibexecdir)
2241 exe = executable('systemd-mount',
2242 'src/mount/mount-tool.c',
2243 include_directories : includes,
2244 link_with : [libshared],
2245 install_rpath : rootlibexecdir,
2247 public_programs += [exe]
2249 meson.add_install_script(meson_make_symlink,
2250 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2252 exe = executable('systemd-run',
2254 include_directories : includes,
2255 link_with : [libshared],
2256 install_rpath : rootlibexecdir,
2258 public_programs += [exe]
2260 exe = executable('systemd-stdio-bridge',
2261 'src/stdio-bridge/stdio-bridge.c',
2262 include_directories : includes,
2263 link_with : [libshared],
2264 install_rpath : rootlibexecdir,
2266 public_programs += [exe]
2268 exe = executable('busctl',
2269 'src/busctl/busctl.c',
2270 'src/busctl/busctl-introspect.c',
2271 'src/busctl/busctl-introspect.h',
2272 include_directories : includes,
2273 link_with : [libshared],
2274 install_rpath : rootlibexecdir,
2276 public_programs += [exe]
2278 if conf.get('ENABLE_SYSUSERS') == 1
2279 exe = executable('systemd-sysusers',
2280 'src/sysusers/sysusers.c',
2281 include_directories : includes,
2282 link_with : [libshared],
2283 install_rpath : rootlibexecdir,
2285 install_dir : rootbindir)
2286 public_programs += [exe]
2289 if conf.get('ENABLE_TMPFILES') == 1
2290 exe = executable('systemd-tmpfiles',
2291 'src/tmpfiles/tmpfiles.c',
2292 include_directories : includes,
2293 link_with : [libshared],
2294 dependencies : [libacl],
2295 install_rpath : rootlibexecdir,
2297 install_dir : rootbindir)
2298 public_programs += [exe]
2300 test('test-systemd-tmpfiles',
2301 test_systemd_tmpfiles_py,
2302 args : exe.full_path())
2303 # https://github.com/mesonbuild/meson/issues/2681
2306 if conf.get('ENABLE_HWDB') == 1
2307 exe = executable('systemd-hwdb',
2309 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2310 include_directories : includes,
2311 link_with : [libudev_static],
2312 install_rpath : udev_rpath,
2314 install_dir : rootbindir)
2315 public_programs += [exe]
2318 if conf.get('ENABLE_QUOTACHECK') == 1
2319 executable('systemd-quotacheck',
2320 'src/quotacheck/quotacheck.c',
2321 include_directories : includes,
2322 link_with : [libshared],
2323 install_rpath : rootlibexecdir,
2325 install_dir : rootlibexecdir)
2328 exe = executable('systemd-socket-proxyd',
2329 'src/socket-proxy/socket-proxyd.c',
2330 include_directories : includes,
2331 link_with : [libshared],
2332 dependencies : [threads],
2333 install_rpath : rootlibexecdir,
2335 install_dir : rootlibexecdir)
2336 public_programs += [exe]
2338 exe = executable('systemd-udevd',
2339 systemd_udevd_sources,
2340 include_directories : includes,
2341 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2342 link_with : [libudev_core,
2345 dependencies : [threads,
2350 install_rpath : udev_rpath,
2352 install_dir : rootlibexecdir)
2353 public_programs += [exe]
2355 exe = executable('udevadm',
2357 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2358 include_directories : includes,
2359 link_with : [libudev_core,
2362 dependencies : [threads,
2367 install_rpath : udev_rpath,
2369 install_dir : rootbindir)
2370 public_programs += [exe]
2372 executable('systemd-shutdown',
2373 systemd_shutdown_sources,
2374 include_directories : includes,
2375 link_with : [libshared],
2376 install_rpath : rootlibexecdir,
2378 install_dir : rootlibexecdir)
2380 executable('systemd-update-done',
2381 'src/update-done/update-done.c',
2382 include_directories : includes,
2383 link_with : [libshared],
2384 install_rpath : rootlibexecdir,
2386 install_dir : rootlibexecdir)
2388 executable('systemd-update-utmp',
2389 'src/update-utmp/update-utmp.c',
2390 include_directories : includes,
2391 link_with : [libshared],
2392 dependencies : [libaudit],
2393 install_rpath : rootlibexecdir,
2395 install_dir : rootlibexecdir)
2397 if conf.get('HAVE_KMOD') == 1
2398 executable('systemd-modules-load',
2399 'src/modules-load/modules-load.c',
2400 include_directories : includes,
2401 link_with : [libshared],
2402 dependencies : [libkmod],
2403 install_rpath : rootlibexecdir,
2405 install_dir : rootlibexecdir)
2407 meson.add_install_script('sh', '-c',
2408 mkdir_p.format(modulesloaddir))
2409 meson.add_install_script('sh', '-c',
2410 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2413 exe = executable('systemd-nspawn',
2414 systemd_nspawn_sources,
2415 'src/core/mount-setup.c', # FIXME: use a variable?
2416 'src/core/mount-setup.h',
2417 'src/core/loopback-setup.c',
2418 'src/core/loopback-setup.h',
2419 include_directories : [includes, include_directories('src/nspawn')],
2420 link_with : [libshared],
2421 dependencies : [libacl,
2425 install_rpath : rootlibexecdir,
2427 public_programs += [exe]
2429 if conf.get('ENABLE_NETWORKD') == 1
2430 executable('systemd-networkd',
2431 systemd_networkd_sources,
2432 include_directories : includes,
2433 link_with : [libnetworkd_core,
2437 dependencies : [threads],
2438 install_rpath : rootlibexecdir,
2440 install_dir : rootlibexecdir)
2442 executable('systemd-networkd-wait-online',
2443 systemd_networkd_wait_online_sources,
2444 include_directories : includes,
2445 link_with : [libnetworkd_core,
2447 install_rpath : rootlibexecdir,
2449 install_dir : rootlibexecdir)
2451 exe = executable('networkctl',
2453 include_directories : includes,
2454 link_with : [libsystemd_network,
2456 install_rpath : rootlibexecdir,
2458 install_dir : rootbindir)
2459 public_programs += [exe]
2462 executable('systemd-sulogin-shell',
2463 ['src/sulogin-shell/sulogin-shell.c'],
2464 include_directories : includes,
2465 link_with : [libshared],
2466 install_rpath : rootlibexecdir,
2468 install_dir : rootlibexecdir)
2470 ############################################################
2472 foreach tuple : tests
2474 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2475 dependencies = tuple[2]
2476 condition = tuple.length() >= 4 ? tuple[3] : ''
2477 type = tuple.length() >= 5 ? tuple[4] : ''
2478 defs = tuple.length() >= 6 ? tuple[5] : []
2479 incs = tuple.length() >= 7 ? tuple[6] : includes
2482 name = sources[0].split('/')[-1].split('.')[0]
2483 if type.startswith('timeout=')
2484 timeout = type.split('=')[1].to_int()
2487 if want_tests == 'false'
2488 message('Not compiling @0@ because tests is set to false'.format(name))
2489 elif condition == '' or conf.get(condition) == 1
2493 include_directories : incs,
2494 link_with : link_with,
2495 dependencies : dependencies,
2497 install_rpath : rootlibexecdir,
2498 install : install_tests,
2499 install_dir : join_paths(testsdir, type))
2502 message('@0@ is a manual test'.format(name))
2503 elif type == 'unsafe' and want_tests != 'unsafe'
2504 message('@0@ is an unsafe test'.format(name))
2511 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2515 test_libsystemd_sym = executable(
2516 'test-libsystemd-sym',
2517 test_libsystemd_sym_c,
2518 include_directories : includes,
2519 link_with : [libsystemd],
2520 install : install_tests,
2521 install_dir : testsdir)
2522 test('test-libsystemd-sym',
2523 test_libsystemd_sym)
2525 test_libudev_sym = executable(
2528 include_directories : includes,
2529 c_args : ['-Wno-deprecated-declarations'],
2530 link_with : [libudev],
2531 install : install_tests,
2532 install_dir : testsdir)
2533 test('test-libudev-sym',
2536 ############################################################
2540 foreach tuple : fuzzers
2542 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2543 dependencies = tuple[2]
2544 defs = tuple.length() >= 4 ? tuple[3] : []
2545 incs = tuple.length() >= 5 ? tuple[4] : includes
2548 dependencies += fuzzing_engine
2550 sources += 'src/fuzz/fuzz-main.c'
2553 name = sources[0].split('/')[-1].split('.')[0]
2555 fuzzer_exes += executable(
2558 include_directories : [incs, include_directories('src/fuzz')],
2559 link_with : link_with,
2560 dependencies : dependencies,
2565 run_target('fuzzers',
2566 depends : fuzzer_exes,
2569 ############################################################
2571 make_directive_index_py = find_program('tools/make-directive-index.py')
2572 make_man_index_py = find_program('tools/make-man-index.py')
2573 xml_helper_py = find_program('tools/xml_helper.py')
2574 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2578 subdir('sysusers.d')
2579 subdir('tmpfiles.d')
2584 subdir('shell-completion/bash')
2585 subdir('shell-completion/zsh')
2586 subdir('docs/sysvinit')
2587 subdir('docs/var-log')
2589 # FIXME: figure out if the warning is true:
2590 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2591 install_subdir('factory/etc',
2592 install_dir : factorydir)
2595 install_data('xorg/50-systemd-user.sh',
2596 install_dir : xinitrcdir)
2597 install_data('modprobe.d/systemd.conf',
2598 install_dir : modprobedir)
2599 install_data('LICENSE.GPL2',
2604 'doc/DISTRO_PORTING',
2605 'doc/ENVIRONMENT.md',
2607 'doc/TRANSIENT-SETTINGS.md',
2610 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2611 install_dir : docdir)
2613 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2614 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2616 ############################################################
2618 meson_check_help = find_program('tools/meson-check-help.sh')
2620 foreach exec : public_programs
2621 name = exec.full_path().split('/')[-1]
2622 test('check-help-' + name,
2624 args : [exec.full_path()])
2627 ############################################################
2630 foreach p : fuzz_regression_tests
2631 a = p.split('/')[-3]
2632 b = p.split('/')[-2]
2633 c = p.split('/')[-1]
2636 build = sanitize_address
2638 error('unknown sanitizer @0@'.format(a))
2641 name = '@1@:@0@'.format(a, b)
2644 if want_tests == 'false'
2645 message('Not compiling @0@ because tests is set to false'.format(name))
2646 elif not sanitizers.contains(a)
2647 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2649 exe = custom_target(
2653 command : [env, 'ln', '-fs',
2654 join_paths(build.full_path(), b),
2656 build_by_default : true)
2658 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2663 if want_tests != 'false' and slow_tests
2664 test(c, env, args : [exe.full_path(),
2665 join_paths(meson.source_root(),
2666 'test/fuzz-regressions',
2671 ############################################################
2674 all_files = run_command(
2676 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2679 all_files = files(all_files.stdout().split())
2684 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2688 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2692 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2695 command : [meson_git_contrib_sh])
2699 git_head = run_command(
2701 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2702 'rev-parse', 'HEAD']).stdout().strip()
2703 git_head_short = run_command(
2705 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2706 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2710 command : ['git', 'archive',
2711 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2713 '--prefix', 'systemd-@0@/'.format(git_head),
2717 ############################################################
2719 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2722 depends : [man, libsystemd, libudev],
2723 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2725 ############################################################
2728 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2730 'prefix directory: @0@'.format(prefixdir),
2731 'rootprefix directory: @0@'.format(rootprefixdir),
2732 'sysconf directory: @0@'.format(sysconfdir),
2733 'include directory: @0@'.format(includedir),
2734 'lib directory: @0@'.format(libdir),
2735 'rootlib directory: @0@'.format(rootlibdir),
2736 'SysV init scripts: @0@'.format(sysvinit_path),
2737 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2738 'PAM modules directory: @0@'.format(pamlibdir),
2739 'PAM configuration directory: @0@'.format(pamconfdir),
2740 'RPM macros directory: @0@'.format(rpmmacrosdir),
2741 'modprobe.d directory: @0@'.format(modprobedir),
2742 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2743 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2744 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2745 'bash completions directory: @0@'.format(bashcompletiondir),
2746 'zsh completions directory: @0@'.format(zshcompletiondir),
2747 'extra start script: @0@'.format(get_option('rc-local')),
2748 'extra stop script: @0@'.format(get_option('halt-local')),
2749 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2750 get_option('debug-tty')),
2751 'TTY GID: @0@'.format(tty_gid),
2752 'users GID: @0@'.format(users_gid),
2753 'maximum system UID: @0@'.format(system_uid_max),
2754 'maximum system GID: @0@'.format(system_gid_max),
2755 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2756 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2757 'minimum container UID base: @0@'.format(container_uid_base_min),
2758 'maximum container UID base: @0@'.format(container_uid_base_max),
2759 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2760 'render group access mode: @0@'.format(get_option('group-render-mode')),
2761 'certificate root directory: @0@'.format(get_option('certificate-root')),
2762 'support URL: @0@'.format(support_url),
2763 'nobody user name: @0@'.format(nobody_user),
2764 'nobody group name: @0@'.format(nobody_group),
2765 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2766 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2768 'default DNSSEC mode: @0@'.format(default_dnssec),
2769 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2770 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2772 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2773 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2775 'default DNS servers: @0@'.format(alt_dns_servers),
2776 'default NTP servers: @0@'.format(alt_ntp_servers)]
2778 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2779 '@@0@'.format(time_epoch)).stdout().strip()
2781 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2784 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2785 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2786 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2788 if conf.get('ENABLE_EFI') == 1
2790 'efi arch: @0@'.format(efi_arch)]
2794 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2795 'EFI CC @0@'.format(efi_cc),
2796 'EFI lib directory: @0@'.format(efi_libdir),
2797 'EFI lds directory: @0@'.format(efi_ldsdir),
2798 'EFI include directory: @0@'.format(efi_incdir)]
2851 ['legacy pkla', install_polkit_pkla],
2853 ['gnu-efi', have_gnu_efi],
2860 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2863 ['man pages', want_man],
2864 ['html pages', want_html],
2865 ['man page indices', want_man and have_lxml],
2866 ['split /usr', conf.get('HAVE_SPLIT_USR') == 1],
2871 ['adm group', get_option('adm-group')],
2872 ['wheel group', get_option('wheel-group')],
2875 ['debug mmap cache'],
2878 cond = tuple.get(1, '')
2880 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2881 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2882 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2887 missing += [tuple[0]]
2893 'enabled features: @0@'.format(', '.join(found)),
2895 'disabled features: @0@'.format(', '.join(missing)),
2897 message('\n '.join(status))
2899 if rootprefixdir != rootprefix_default
2900 message('WARNING:\n' +
2901 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2902 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2903 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))