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 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)
64 rootprefixdir = get_option('rootprefix')
65 # Unusual rootprefixdir values are used by some distros
66 # (see https://github.com/systemd/systemd/pull/7461).
67 rootprefix_default = split_usr ? '/' : '/usr'
68 if rootprefixdir == ''
69 rootprefixdir = rootprefix_default
72 sysvinit_path = get_option('sysvinit-path')
73 sysvrcnd_path = get_option('sysvrcnd-path')
74 have = sysvinit_path != '' and sysvrcnd_path != ''
75 conf.set10('HAVE_SYSV_COMPAT', have,
76 description : 'SysV init scripts and rcN.d links are supported')
77 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
79 # join_paths ignore the preceding arguments if an absolute component is
80 # encountered, so this should canonicalize various paths when they are
81 # absolute or relative.
82 prefixdir = get_option('prefix')
83 if not prefixdir.startswith('/')
84 error('Prefix is not absolute: "@0@"'.format(prefixdir))
86 bindir = join_paths(prefixdir, get_option('bindir'))
87 libdir = join_paths(prefixdir, get_option('libdir'))
88 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
89 includedir = join_paths(prefixdir, get_option('includedir'))
90 datadir = join_paths(prefixdir, get_option('datadir'))
91 localstatedir = join_paths('/', get_option('localstatedir'))
93 rootbindir = join_paths(rootprefixdir, 'bin')
94 rootsbindir = join_paths(rootprefixdir, 'sbin')
95 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
97 rootlibdir = get_option('rootlibdir')
99 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
102 # Dirs of external packages
103 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
104 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
105 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
106 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
107 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
108 varlogdir = join_paths(localstatedir, 'log')
109 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
110 rpmmacrosdir = get_option('rpmmacrosdir')
111 if rpmmacrosdir != 'no'
112 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
114 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
117 pkgdatadir = join_paths(datadir, 'systemd')
118 environmentdir = join_paths(prefixdir, 'lib/environment.d')
119 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
120 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
121 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
122 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
123 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
124 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
125 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
126 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
127 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
128 pkgincludedir = join_paths(includedir, 'systemd')
129 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
130 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
131 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
132 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
133 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
134 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
135 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
136 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
137 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
138 udevhomedir = udevlibexecdir
139 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
140 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
141 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
142 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
143 factorydir = join_paths(datadir, 'factory')
144 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
145 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
146 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
147 catalogstatedir = join_paths(systemdstatedir, 'catalog')
148 randomseeddir = join_paths(localstatedir, 'lib/systemd')
150 docdir = get_option('docdir')
152 docdir = join_paths(datadir, 'doc/systemd')
155 dbuspolicydir = get_option('dbuspolicydir')
156 if dbuspolicydir == ''
157 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
160 dbussessionservicedir = get_option('dbussessionservicedir')
161 if dbussessionservicedir == ''
162 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
165 dbussystemservicedir = get_option('dbussystemservicedir')
166 if dbussystemservicedir == ''
167 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
170 pamlibdir = get_option('pamlibdir')
172 pamlibdir = join_paths(rootlibdir, 'security')
175 pamconfdir = get_option('pamconfdir')
177 pamconfdir = join_paths(sysconfdir, 'pam.d')
180 memory_accounting_default = get_option('memory-accounting-default')
182 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
183 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
184 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
185 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
186 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
187 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
188 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
189 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
190 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
191 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
192 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
193 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
194 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
195 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
196 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
197 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
198 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
199 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
200 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
201 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
202 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
203 conf.set_quoted('ROOTPREFIX', rootprefixdir)
204 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
205 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
206 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
207 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
208 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
209 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
210 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
211 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
212 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
213 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
214 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
215 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
216 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
217 conf.set_quoted('LIBDIR', libdir)
218 conf.set_quoted('ROOTLIBDIR', rootlibdir)
219 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
220 conf.set_quoted('BOOTLIBDIR', bootlibdir)
221 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
222 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
223 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
224 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
225 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
226 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
227 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
228 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_ON_OFF', memory_accounting_default ? 'on' : 'off')
230 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
231 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
233 substs.set('prefix', prefixdir)
234 substs.set('exec_prefix', prefixdir)
235 substs.set('libdir', libdir)
236 substs.set('rootlibdir', rootlibdir)
237 substs.set('includedir', includedir)
238 substs.set('pkgsysconfdir', pkgsysconfdir)
239 substs.set('bindir', bindir)
240 substs.set('rootbindir', rootbindir)
241 substs.set('rootlibexecdir', rootlibexecdir)
242 substs.set('systemunitdir', systemunitdir)
243 substs.set('userunitdir', userunitdir)
244 substs.set('systempresetdir', systempresetdir)
245 substs.set('userpresetdir', userpresetdir)
246 substs.set('udevhwdbdir', udevhwdbdir)
247 substs.set('udevrulesdir', udevrulesdir)
248 substs.set('udevlibexecdir', udevlibexecdir)
249 substs.set('catalogdir', catalogdir)
250 substs.set('tmpfilesdir', tmpfilesdir)
251 substs.set('sysusersdir', sysusersdir)
252 substs.set('sysctldir', sysctldir)
253 substs.set('binfmtdir', binfmtdir)
254 substs.set('modulesloaddir', modulesloaddir)
255 substs.set('systemgeneratordir', systemgeneratordir)
256 substs.set('usergeneratordir', usergeneratordir)
257 substs.set('systemenvgeneratordir', systemenvgeneratordir)
258 substs.set('userenvgeneratordir', userenvgeneratordir)
259 substs.set('systemshutdowndir', systemshutdowndir)
260 substs.set('systemsleepdir', systemsleepdir)
261 substs.set('VARLOGDIR', varlogdir)
262 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
263 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
264 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
265 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
266 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
267 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
268 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
269 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
271 #####################################################################
273 cc = meson.get_compiler('c')
274 pkgconfig = import('pkgconfig')
275 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
276 meson_build_sh = find_program('tools/meson-build.sh')
278 if get_option('tests') != 'false'
279 cxx = find_program('c++', required : false)
281 # Used only for tests
286 want_ossfuzz = get_option('oss-fuzz')
287 want_libfuzzer = get_option('llvm-fuzz')
288 fuzzer_build = want_ossfuzz or want_libfuzzer
289 if want_ossfuzz and want_libfuzzer
290 error('only one of oss-fuzz and llvm-fuzz can be specified')
293 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
296 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
299 foreach arg : ['-Wextra',
302 '-Wmissing-include-dirs',
303 '-Wold-style-definition',
306 '-Wdeclaration-after-statement',
308 '-Wsuggest-attribute=noreturn',
309 '-Werror=missing-prototypes',
310 '-Werror=implicit-function-declaration',
311 '-Werror=missing-declarations',
312 '-Werror=return-type',
313 '-Werror=incompatible-pointer-types',
315 '-Wstrict-prototypes',
317 '-Wmissing-noreturn',
318 '-Wimplicit-fallthrough=5',
321 '-Wstrict-aliasing=2',
328 '-fdiagnostics-show-option',
329 '-fno-strict-aliasing',
330 '-fvisibility=hidden',
332 '-fstack-protector-strong',
333 '--param=ssp-buffer-size=4',
335 if cc.has_argument(arg)
336 add_project_arguments(arg, language : 'c')
340 # the oss-fuzz fuzzers are not built with -fPIE, so don't
341 # enable it when we are linking against them
343 if cc.has_argument('-fPIE')
344 add_project_arguments('-fPIE', language : 'c')
348 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
349 # arguments, just emits a warnings. So test for the "positive" version instead.
350 foreach arg : ['unused-parameter',
351 'missing-field-initializers',
354 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
356 if cc.has_argument('-W' + arg)
357 add_project_arguments('-Wno-' + arg, language : 'c')
363 #include <inttypes.h>
364 typedef uint64_t usec_t;
365 usec_t now(clockid_t clock);
370 ''', name : '-Werror=shadow with local shadowing')
371 add_project_arguments('-Werror=shadow', language : 'c')
374 if cc.get_id() == 'clang'
375 foreach arg : ['-Wno-typedef-redefinition',
376 '-Wno-gnu-variable-sized-type-not-at-end',
378 if cc.has_argument(arg,
379 name : '@0@ is supported'.format(arg))
380 add_project_arguments(arg, language : 'c')
385 link_test_c = files('tools/meson-link-test.c')
387 # --as-needed and --no-undefined are provided by meson by default,
388 # run mesonconf to see what is enabled
389 foreach arg : ['-Wl,-z,relro',
394 have = run_command(check_compilation_sh,
395 cc.cmd_array(), '-x', 'c', arg,
396 '-include', link_test_c).returncode() == 0
397 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
398 if have and (arg != '-pie' or not fuzzer_build)
399 add_project_link_arguments(arg, language : 'c')
403 # Check if various sanitizers are supported
405 foreach arg : ['address']
407 have = run_command(check_compilation_sh,
408 cc.cmd_array(), '-x', 'c',
409 '-fsanitize=@0@'.format(arg),
410 '-include', link_test_c).returncode() == 0
411 message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
417 if get_option('buildtype') != 'debug'
418 foreach arg : ['-ffunction-sections',
420 if cc.has_argument(arg,
421 name : '@0@ is supported'.format(arg))
422 add_project_arguments(arg, language : 'c')
426 foreach arg : ['-Wl,--gc-sections']
427 have = run_command(check_compilation_sh,
428 cc.cmd_array(), '-x', 'c', arg,
429 '-include', link_test_c).returncode() == 0
430 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
432 add_project_link_arguments(arg, language : 'c')
437 cpp = ' '.join(cc.cmd_array()) + ' -E'
439 #####################################################################
440 # compilation result tests
442 conf.set('_GNU_SOURCE', true)
443 conf.set('__SANE_USERSPACE_TYPES__', true)
445 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
446 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
447 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
448 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
449 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
450 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
451 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
455 #include <linux/ethtool.h>
456 #include <linux/fib_rules.h>
457 #include <linux/stat.h>
458 #include <sys/stat.h>
460 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
462 foreach decl : ['char16_t',
465 'struct ethtool_link_settings',
466 'struct fib_rule_uid_range',
470 # We get -1 if the size cannot be determined
471 have = cc.sizeof(decl, prefix : decl_headers) > 0
472 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
475 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
476 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
477 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
478 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
479 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
480 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
481 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
482 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
483 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
484 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
485 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
486 # if_tunnel.h is buggy and cannot be included on its own
487 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
488 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
489 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
490 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
491 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
492 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
493 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
494 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
495 ['NDA_IFINDEX', 'linux/neighbour.h'],
496 ['IFA_FLAGS', 'linux/if_addr.h'],
497 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
498 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
499 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
501 prefix = decl.length() > 2 ? decl[2] : ''
502 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
503 conf.set10('HAVE_' + decl[0], have)
506 foreach ident : ['secure_getenv', '__secure_getenv']
507 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
511 ['memfd_create', '''#include <sys/mman.h>'''],
512 ['gettid', '''#include <sys/types.h>
513 #include <unistd.h>'''],
514 ['pivot_root', '''#include <stdlib.h>
515 #include <unistd.h>'''], # no known header declares pivot_root
516 ['name_to_handle_at', '''#include <sys/types.h>
517 #include <sys/stat.h>
518 #include <fcntl.h>'''],
519 ['setns', '''#include <sched.h>'''],
520 ['renameat2', '''#include <stdio.h>
521 #include <fcntl.h>'''],
522 ['kcmp', '''#include <linux/kcmp.h>'''],
523 ['keyctl', '''#include <sys/types.h>
524 #include <keyutils.h>'''],
525 ['copy_file_range', '''#include <sys/syscall.h>
526 #include <unistd.h>'''],
527 ['bpf', '''#include <sys/syscall.h>
528 #include <unistd.h>'''],
529 ['statx', '''#include <sys/types.h>
530 #include <sys/stat.h>
531 #include <unistd.h>'''],
532 ['explicit_bzero' , '''#include <string.h>'''],
533 ['reallocarray', '''#include <malloc.h>'''],
536 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
537 conf.set10('HAVE_' + ident[0].to_upper(), have)
540 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
541 conf.set10('USE_SYS_RANDOM_H', true)
542 conf.set10('HAVE_GETRANDOM', true)
544 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
545 conf.set10('USE_SYS_RANDOM_H', false)
546 conf.set10('HAVE_GETRANDOM', have)
549 #####################################################################
551 sed = find_program('sed')
552 awk = find_program('awk')
553 m4 = find_program('m4')
554 stat = find_program('stat')
555 git = find_program('git', required : false)
556 env = find_program('env')
558 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
559 mkdir_p = 'mkdir -p $DESTDIR/@0@'
560 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
561 splash_bmp = files('test/splash.bmp')
563 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
564 # /usr/sbin, /sbin, and fall back to the default from middle column.
565 progs = [['quotaon', '/usr/sbin/quotaon' ],
566 ['quotacheck', '/usr/sbin/quotacheck' ],
567 ['kill', '/usr/bin/kill' ],
568 ['kmod', '/usr/bin/kmod' ],
569 ['kexec', '/usr/sbin/kexec' ],
570 ['sulogin', '/usr/sbin/sulogin' ],
571 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
572 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
573 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
574 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
577 path = get_option(prog[0] + '-path')
579 message('Using @1@ for @0@'.format(prog[0], path))
581 exe = find_program(prog[0],
582 '/usr/sbin/' + prog[0],
585 path = exe.found() ? exe.path() : prog[1]
587 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
588 conf.set_quoted(name, path)
589 substs.set(name, path)
592 conf.set_quoted('TELINIT', get_option('telinit-path'))
594 if run_command('ln', '--relative', '--help').returncode() != 0
595 error('ln does not support --relative')
598 ############################################################
600 gperf = find_program('gperf')
602 gperf_test_format = '''
604 const char * in_word_set(const char *, @0@);
607 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
608 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
609 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
610 if cc.compiles(gperf_test)
611 gperf_len_type = 'size_t'
613 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
614 if cc.compiles(gperf_test)
615 gperf_len_type = 'unsigned'
617 error('unable to determine gperf len type')
620 message('gperf len type is @0@'.format(gperf_len_type))
621 conf.set('GPERF_LEN_TYPE', gperf_len_type,
622 description : 'The type of gperf "len" parameter')
624 ############################################################
626 if not cc.has_header('sys/capability.h')
627 error('POSIX caps headers not found')
629 foreach header : ['crypt.h',
632 'linux/vm_sockets.h',
634 'valgrind/memcheck.h',
635 'valgrind/valgrind.h',
638 conf.set10('HAVE_' + header.underscorify().to_upper(),
639 cc.has_header(header))
642 ############################################################
644 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
645 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
646 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
648 default_hierarchy = get_option('default-hierarchy')
649 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
650 description : 'default cgroup hierarchy as string')
651 if default_hierarchy == 'legacy'
652 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
653 elif default_hierarchy == 'hybrid'
654 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
656 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
659 time_epoch = get_option('time-epoch')
662 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
664 time_epoch = time_epoch.to_int()
665 conf.set('TIME_EPOCH', time_epoch)
667 system_uid_max = get_option('system-uid-max')
668 if system_uid_max == ''
669 system_uid_max = run_command(
671 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
672 '/etc/login.defs').stdout().strip()
673 if system_uid_max == ''
674 system_uid_max = '999'
677 system_uid_max = system_uid_max.to_int()
678 conf.set('SYSTEM_UID_MAX', system_uid_max)
679 substs.set('systemuidmax', system_uid_max)
680 message('maximum system UID is @0@'.format(system_uid_max))
682 system_gid_max = get_option('system-gid-max')
683 if system_gid_max == ''
684 system_gid_max = run_command(
686 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
687 '/etc/login.defs').stdout().strip()
688 if system_gid_max == ''
689 system_gid_max = '999'
692 system_gid_max = system_gid_max.to_int()
693 conf.set('SYSTEM_GID_MAX', system_gid_max)
694 substs.set('systemgidmax', system_gid_max)
695 message('maximum system GID is @0@'.format(system_gid_max))
697 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
698 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
699 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
700 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
701 substs.set('dynamicuidmin', dynamic_uid_min)
702 substs.set('dynamicuidmax', dynamic_uid_max)
704 container_uid_base_min = get_option('container-uid-base-min').to_int()
705 container_uid_base_max = get_option('container-uid-base-max').to_int()
706 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
707 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
708 substs.set('containeruidbasemin', container_uid_base_min)
709 substs.set('containeruidbasemax', container_uid_base_max)
711 nobody_user = get_option('nobody-user')
712 nobody_group = get_option('nobody-group')
714 getent_result = run_command('getent', 'passwd', '65534')
715 if getent_result.returncode() == 0
716 name = getent_result.stdout().split(':')[0]
717 if name != nobody_user
718 message('WARNING:\n' +
719 ' 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) +
720 ' Your build will result in an user table setup that is incompatible with the local system.')
723 id_result = run_command('id', '-u', nobody_user)
724 if id_result.returncode() == 0
725 id = id_result.stdout().to_int()
727 message('WARNING:\n' +
728 ' 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) +
729 ' Your build will result in an user table setup that is incompatible with the local system.')
733 getent_result = run_command('getent', 'group', '65534')
734 if getent_result.returncode() == 0
735 name = getent_result.stdout().split(':')[0]
736 if name != nobody_group
737 message('WARNING:\n' +
738 ' 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) +
739 ' Your build will result in an group table setup that is incompatible with the local system.')
742 id_result = run_command('id', '-g', nobody_group)
743 if id_result.returncode() == 0
744 id = id_result.stdout().to_int()
746 message('WARNING:\n' +
747 ' 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) +
748 ' Your build will result in an group table setup that is incompatible with the local system.')
751 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
752 message('WARNING:\n' +
753 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
754 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
757 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
758 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
759 substs.set('NOBODY_USER_NAME', nobody_user)
760 substs.set('NOBODY_GROUP_NAME', nobody_group)
762 tty_gid = get_option('tty-gid')
763 conf.set('TTY_GID', tty_gid)
764 substs.set('TTY_GID', tty_gid)
766 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
767 if get_option('users-gid') != ''
768 users_gid = get_option('users-gid').to_int()
772 substs.set('USERS_GID', users_gid)
774 if get_option('adm-group')
775 m4_defines += ['-DENABLE_ADM_GROUP']
778 if get_option('wheel-group')
779 m4_defines += ['-DENABLE_WHEEL_GROUP']
782 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
783 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
785 kill_user_processes = get_option('default-kill-user-processes')
786 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
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',
835 required : not fuzzer_build)
837 want_seccomp = get_option('seccomp')
838 if want_seccomp != 'false' and not fuzzer_build
839 libseccomp = dependency('libseccomp',
840 version : '>= 2.3.1',
841 required : want_seccomp == 'true')
842 have = libseccomp.found()
847 conf.set10('HAVE_SECCOMP', have)
848 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
850 want_selinux = get_option('selinux')
851 if want_selinux != 'false' and not fuzzer_build
852 libselinux = dependency('libselinux',
853 version : '>= 2.1.9',
854 required : want_selinux == 'true')
855 have = libselinux.found()
860 conf.set10('HAVE_SELINUX', have)
861 m4_defines += have ? ['-DHAVE_SELINUX'] : []
863 want_apparmor = get_option('apparmor')
864 if want_apparmor != 'false' and not fuzzer_build
865 libapparmor = dependency('libapparmor',
866 required : want_apparmor == 'true')
867 have = libapparmor.found()
872 conf.set10('HAVE_APPARMOR', have)
873 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
875 smack_run_label = get_option('smack-run-label')
876 if smack_run_label != ''
877 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
878 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
881 want_polkit = get_option('polkit')
882 install_polkit = false
883 install_polkit_pkla = false
884 if want_polkit != 'false' and not fuzzer_build
885 install_polkit = true
887 libpolkit = dependency('polkit-gobject-1',
889 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
890 message('Old polkit detected, will install pkla files')
891 install_polkit_pkla = true
894 conf.set10('ENABLE_POLKIT', install_polkit)
896 want_acl = get_option('acl')
897 if want_acl != 'false' and not fuzzer_build
898 libacl = cc.find_library('acl', required : want_acl == 'true')
899 have = libacl.found()
904 conf.set10('HAVE_ACL', have)
905 m4_defines += have ? ['-DHAVE_ACL'] : []
907 want_audit = get_option('audit')
908 if want_audit != 'false' and not fuzzer_build
909 libaudit = dependency('audit', required : want_audit == 'true')
910 have = libaudit.found()
915 conf.set10('HAVE_AUDIT', have)
917 want_blkid = get_option('blkid')
918 if want_blkid != 'false' and not fuzzer_build
919 libblkid = dependency('blkid', required : want_blkid == 'true')
920 have = libblkid.found()
925 conf.set10('HAVE_BLKID', have)
927 want_kmod = get_option('kmod')
928 if want_kmod != 'false' and not fuzzer_build
929 libkmod = dependency('libkmod',
931 required : want_kmod == 'true')
932 have = libkmod.found()
937 conf.set10('HAVE_KMOD', have)
939 want_pam = get_option('pam')
940 if want_pam != 'false' and not fuzzer_build
941 libpam = cc.find_library('pam', required : want_pam == 'true')
942 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
943 have = libpam.found() and libpam_misc.found()
949 conf.set10('HAVE_PAM', have)
950 m4_defines += have ? ['-DHAVE_PAM'] : []
952 want_microhttpd = get_option('microhttpd')
953 if want_microhttpd != 'false' and not fuzzer_build
954 libmicrohttpd = dependency('libmicrohttpd',
955 version : '>= 0.9.33',
956 required : want_microhttpd == 'true')
957 have = libmicrohttpd.found()
962 conf.set10('HAVE_MICROHTTPD', have)
963 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
965 want_libcryptsetup = get_option('libcryptsetup')
966 if want_libcryptsetup != 'false' and not fuzzer_build
967 libcryptsetup = dependency('libcryptsetup',
968 version : '>= 1.6.0',
969 required : want_libcryptsetup == 'true')
970 have = libcryptsetup.found()
975 conf.set10('HAVE_LIBCRYPTSETUP', have)
977 want_libcurl = get_option('libcurl')
978 if want_libcurl != 'false' and not fuzzer_build
979 libcurl = dependency('libcurl',
980 version : '>= 7.32.0',
981 required : want_libcurl == 'true')
982 have = libcurl.found()
987 conf.set10('HAVE_LIBCURL', have)
988 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
990 want_libidn = get_option('libidn')
991 want_libidn2 = get_option('libidn2')
992 if want_libidn == 'true' and want_libidn2 == 'true'
993 error('libidn and libidn2 cannot be requested simultaneously')
996 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
997 libidn = dependency('libidn',
998 required : want_libidn == 'true')
999 have = libidn.found()
1004 conf.set10('HAVE_LIBIDN', have)
1005 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1006 if not have and want_libidn2 != 'false' and not fuzzer_build
1007 # libidn is used for both libidn and libidn2 objects
1008 libidn = dependency('libidn2',
1009 required : want_libidn2 == 'true')
1010 have = libidn.found()
1014 conf.set10('HAVE_LIBIDN2', have)
1015 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1017 want_libiptc = get_option('libiptc')
1018 if want_libiptc != 'false' and not fuzzer_build
1019 libiptc = dependency('libiptc',
1020 required : want_libiptc == 'true')
1021 have = libiptc.found()
1026 conf.set10('HAVE_LIBIPTC', have)
1027 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1029 want_qrencode = get_option('qrencode')
1030 if want_qrencode != 'false' and not fuzzer_build
1031 libqrencode = dependency('libqrencode',
1032 required : want_qrencode == 'true')
1033 have = libqrencode.found()
1038 conf.set10('HAVE_QRENCODE', have)
1040 want_gcrypt = get_option('gcrypt')
1041 if want_gcrypt != 'false' and not fuzzer_build
1042 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1043 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1044 have = libgcrypt.found() and libgpg_error.found()
1049 # link to neither of the libs if one is not found
1053 conf.set10('HAVE_GCRYPT', have)
1055 want_gnutls = get_option('gnutls')
1056 if want_gnutls != 'false' and not fuzzer_build
1057 libgnutls = dependency('gnutls',
1058 version : '>= 3.1.4',
1059 required : want_gnutls == 'true')
1060 have = libgnutls.found()
1065 conf.set10('HAVE_GNUTLS', have)
1067 want_elfutils = get_option('elfutils')
1068 if want_elfutils != 'false' and not fuzzer_build
1069 libdw = dependency('libdw',
1070 required : want_elfutils == 'true')
1071 have = libdw.found()
1076 conf.set10('HAVE_ELFUTILS', have)
1078 want_zlib = get_option('zlib')
1079 if want_zlib != 'false' and not fuzzer_build
1080 libz = dependency('zlib',
1081 required : want_zlib == 'true')
1087 conf.set10('HAVE_ZLIB', have)
1089 want_bzip2 = get_option('bzip2')
1090 if want_bzip2 != 'false' and not fuzzer_build
1091 libbzip2 = cc.find_library('bz2',
1092 required : want_bzip2 == 'true')
1093 have = libbzip2.found()
1098 conf.set10('HAVE_BZIP2', have)
1100 want_xz = get_option('xz')
1101 if want_xz != 'false' and not fuzzer_build
1102 libxz = dependency('liblzma',
1103 required : want_xz == 'true')
1104 have = libxz.found()
1109 conf.set10('HAVE_XZ', have)
1111 want_lz4 = get_option('lz4')
1112 if want_lz4 != 'false' and not fuzzer_build
1113 liblz4 = dependency('liblz4',
1114 required : want_lz4 == 'true')
1115 have = liblz4.found()
1120 conf.set10('HAVE_LZ4', have)
1122 want_xkbcommon = get_option('xkbcommon')
1123 if want_xkbcommon != 'false' and not fuzzer_build
1124 libxkbcommon = dependency('xkbcommon',
1125 version : '>= 0.3.0',
1126 required : want_xkbcommon == 'true')
1127 have = libxkbcommon.found()
1132 conf.set10('HAVE_XKBCOMMON', have)
1134 want_pcre2 = get_option('pcre2')
1135 if want_pcre2 != 'false'
1136 libpcre2 = dependency('libpcre2-8',
1137 required : want_pcre2 == 'true')
1138 have = libpcre2.found()
1143 conf.set10('HAVE_PCRE2', have)
1145 want_glib = get_option('glib')
1146 if want_glib != 'false' and not fuzzer_build
1147 libglib = dependency('glib-2.0',
1148 version : '>= 2.22.0',
1149 required : want_glib == 'true')
1150 libgobject = dependency('gobject-2.0',
1151 version : '>= 2.22.0',
1152 required : want_glib == 'true')
1153 libgio = dependency('gio-2.0',
1154 required : want_glib == 'true')
1155 have = libglib.found() and libgobject.found() and libgio.found()
1162 conf.set10('HAVE_GLIB', have)
1164 want_dbus = get_option('dbus')
1165 if want_dbus != 'false' and not fuzzer_build
1166 libdbus = dependency('dbus-1',
1167 version : '>= 1.3.2',
1168 required : want_dbus == 'true')
1169 have = libdbus.found()
1174 conf.set10('HAVE_DBUS', have)
1176 default_dnssec = get_option('default-dnssec')
1178 default_dnssec = 'no'
1180 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1181 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1182 default_dnssec = 'no'
1184 conf.set('DEFAULT_DNSSEC_MODE',
1185 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1186 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1188 want_importd = get_option('importd')
1189 if want_importd != 'false'
1190 have = (conf.get('HAVE_LIBCURL') == 1 and
1191 conf.get('HAVE_ZLIB') == 1 and
1192 conf.get('HAVE_BZIP2') == 1 and
1193 conf.get('HAVE_XZ') == 1 and
1194 conf.get('HAVE_GCRYPT') == 1)
1195 if want_importd == 'true' and not have
1196 error('importd support was requested, but dependencies are not available')
1201 conf.set10('ENABLE_IMPORTD', have)
1203 want_remote = get_option('remote')
1204 if want_remote != 'false'
1205 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1206 conf.get('HAVE_LIBCURL') == 1]
1207 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1208 # it's possible to build one without the other. Complain only if
1209 # support was explictly requested. The auxiliary files like sysusers
1210 # config should be installed when any of the programs are built.
1211 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1212 error('remote support was requested, but dependencies are not available')
1214 have = have_deps[0] or have_deps[1]
1218 conf.set10('ENABLE_REMOTE', have)
1220 foreach term : ['utmp',
1251 have = get_option(term)
1252 name = 'ENABLE_' + term.underscorify().to_upper()
1253 conf.set10(name, have)
1254 m4_defines += have ? ['-D' + name] : []
1257 want_tests = get_option('tests')
1258 install_tests = get_option('install-tests')
1259 slow_tests = get_option('slow-tests')
1263 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1265 #####################################################################
1267 if get_option('efi')
1268 efi_arch = host_machine.cpu_family()
1270 if efi_arch == 'x86'
1271 EFI_MACHINE_TYPE_NAME = 'ia32'
1272 gnu_efi_arch = 'ia32'
1273 elif efi_arch == 'x86_64'
1274 EFI_MACHINE_TYPE_NAME = 'x64'
1275 gnu_efi_arch = 'x86_64'
1276 elif efi_arch == 'arm'
1277 EFI_MACHINE_TYPE_NAME = 'arm'
1278 gnu_efi_arch = 'arm'
1279 elif efi_arch == 'aarch64'
1280 EFI_MACHINE_TYPE_NAME = 'aa64'
1281 gnu_efi_arch = 'aarch64'
1283 EFI_MACHINE_TYPE_NAME = ''
1288 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1290 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1294 conf.set10('ENABLE_EFI', have)
1296 #####################################################################
1298 config_h = configure_file(
1299 output : 'config.h',
1300 configuration : conf)
1302 includes = include_directories('src/basic',
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]
1625 if conf.get('ENABLE_LOGIND') == 1
1626 executable('systemd-logind',
1627 systemd_logind_sources,
1628 include_directories : includes,
1629 link_with : [liblogind_core,
1631 dependencies : [threads,
1633 install_rpath : rootlibexecdir,
1635 install_dir : rootlibexecdir)
1637 exe = executable('loginctl',
1639 include_directories : includes,
1640 link_with : [libshared],
1641 dependencies : [threads,
1644 install_rpath : rootlibexecdir,
1646 install_dir : rootbindir)
1647 public_programs += [exe]
1649 exe = executable('systemd-inhibit',
1650 'src/login/inhibit.c',
1651 include_directories : includes,
1652 link_with : [libshared],
1653 install_rpath : rootlibexecdir,
1655 install_dir : rootbindir)
1656 public_programs += [exe]
1658 if conf.get('HAVE_PAM') == 1
1659 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1660 pam_systemd = shared_library(
1664 include_directories : includes,
1665 link_args : ['-shared',
1666 '-Wl,--version-script=' + version_script_arg],
1667 link_with : [libsystemd_static,
1669 dependencies : [threads,
1672 link_depends : pam_systemd_sym,
1674 install_dir : pamlibdir)
1676 test('dlopen-pam_systemd',
1678 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1682 if conf.get('HAVE_PAM') == 1
1683 executable('systemd-user-sessions',
1684 'src/user-sessions/user-sessions.c',
1685 include_directories : includes,
1686 link_with : [libshared],
1687 install_rpath : rootlibexecdir,
1689 install_dir : rootlibexecdir)
1692 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1693 exe = executable('bootctl',
1694 'src/boot/bootctl.c',
1695 include_directories : includes,
1696 link_with : [libshared],
1697 dependencies : [libblkid],
1698 install_rpath : rootlibexecdir,
1700 public_programs += [exe]
1703 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1704 include_directories : includes,
1705 link_with : [libshared],
1706 dependencies : [threads],
1707 install_rpath : rootlibexecdir,
1709 public_programs += [exe]
1711 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1712 include_directories : includes,
1713 link_with : [libshared],
1714 dependencies : [threads,
1719 install_rpath : rootlibexecdir,
1721 install_dir : rootbindir)
1722 public_programs += [exe]
1724 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1725 meson.add_install_script(meson_make_symlink,
1726 join_paths(rootbindir, 'systemctl'),
1727 join_paths(rootsbindir, alias))
1730 if conf.get('ENABLE_BACKLIGHT') == 1
1731 executable('systemd-backlight',
1732 'src/backlight/backlight.c',
1733 include_directories : includes,
1734 link_with : [libshared],
1735 install_rpath : rootlibexecdir,
1737 install_dir : rootlibexecdir)
1740 if conf.get('ENABLE_RFKILL') == 1
1741 executable('systemd-rfkill',
1742 'src/rfkill/rfkill.c',
1743 include_directories : includes,
1744 link_with : [libshared],
1745 install_rpath : rootlibexecdir,
1747 install_dir : rootlibexecdir)
1750 executable('systemd-system-update-generator',
1751 'src/system-update-generator/system-update-generator.c',
1752 include_directories : includes,
1753 link_with : [libshared],
1754 install_rpath : rootlibexecdir,
1756 install_dir : systemgeneratordir)
1758 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1759 executable('systemd-cryptsetup',
1760 'src/cryptsetup/cryptsetup.c',
1761 include_directories : includes,
1762 link_with : [libshared],
1763 dependencies : [libcryptsetup],
1764 install_rpath : rootlibexecdir,
1766 install_dir : rootlibexecdir)
1768 executable('systemd-cryptsetup-generator',
1769 'src/cryptsetup/cryptsetup-generator.c',
1770 include_directories : includes,
1771 link_with : [libshared],
1772 dependencies : [libcryptsetup],
1773 install_rpath : rootlibexecdir,
1775 install_dir : systemgeneratordir)
1777 executable('systemd-veritysetup',
1778 'src/veritysetup/veritysetup.c',
1779 include_directories : includes,
1780 link_with : [libshared],
1781 dependencies : [libcryptsetup],
1782 install_rpath : rootlibexecdir,
1784 install_dir : rootlibexecdir)
1786 executable('systemd-veritysetup-generator',
1787 'src/veritysetup/veritysetup-generator.c',
1788 include_directories : includes,
1789 link_with : [libshared],
1790 dependencies : [libcryptsetup],
1791 install_rpath : rootlibexecdir,
1793 install_dir : systemgeneratordir)
1796 if conf.get('HAVE_SYSV_COMPAT') == 1
1797 executable('systemd-sysv-generator',
1798 'src/sysv-generator/sysv-generator.c',
1799 include_directories : includes,
1800 link_with : [libshared],
1801 install_rpath : rootlibexecdir,
1803 install_dir : systemgeneratordir)
1805 executable('systemd-rc-local-generator',
1806 'src/rc-local-generator/rc-local-generator.c',
1807 include_directories : includes,
1808 link_with : [libshared],
1809 install_rpath : rootlibexecdir,
1811 install_dir : systemgeneratordir)
1814 if conf.get('ENABLE_HOSTNAMED') == 1
1815 executable('systemd-hostnamed',
1816 'src/hostname/hostnamed.c',
1817 include_directories : includes,
1818 link_with : [libshared],
1819 install_rpath : rootlibexecdir,
1821 install_dir : rootlibexecdir)
1823 exe = executable('hostnamectl',
1824 'src/hostname/hostnamectl.c',
1825 include_directories : includes,
1826 link_with : [libshared],
1827 install_rpath : rootlibexecdir,
1829 public_programs += [exe]
1832 if conf.get('ENABLE_LOCALED') == 1
1833 if conf.get('HAVE_XKBCOMMON') == 1
1834 # logind will load libxkbcommon.so dynamically on its own
1840 executable('systemd-localed',
1841 systemd_localed_sources,
1842 include_directories : includes,
1843 link_with : [libshared],
1844 dependencies : deps,
1845 install_rpath : rootlibexecdir,
1847 install_dir : rootlibexecdir)
1849 exe = executable('localectl',
1851 include_directories : includes,
1852 link_with : [libshared],
1853 install_rpath : rootlibexecdir,
1855 public_programs += [exe]
1858 if conf.get('ENABLE_TIMEDATED') == 1
1859 executable('systemd-timedated',
1860 'src/timedate/timedated.c',
1861 include_directories : includes,
1862 link_with : [libshared],
1863 install_rpath : rootlibexecdir,
1865 install_dir : rootlibexecdir)
1867 exe = executable('timedatectl',
1868 'src/timedate/timedatectl.c',
1869 include_directories : includes,
1870 install_rpath : rootlibexecdir,
1871 link_with : [libshared],
1873 public_programs += [exe]
1876 if conf.get('ENABLE_TIMESYNCD') == 1
1877 executable('systemd-timesyncd',
1878 systemd_timesyncd_sources,
1879 include_directories : includes,
1880 link_with : [libshared],
1881 dependencies : [threads,
1883 install_rpath : rootlibexecdir,
1885 install_dir : rootlibexecdir)
1888 if conf.get('ENABLE_MACHINED') == 1
1889 executable('systemd-machined',
1890 systemd_machined_sources,
1891 include_directories : includes,
1892 link_with : [libmachine_core,
1894 install_rpath : rootlibexecdir,
1896 install_dir : rootlibexecdir)
1898 exe = executable('machinectl',
1899 'src/machine/machinectl.c',
1900 include_directories : includes,
1901 link_with : [libshared],
1902 dependencies : [threads,
1905 install_rpath : rootlibexecdir,
1907 install_dir : rootbindir)
1908 public_programs += [exe]
1911 if conf.get('ENABLE_IMPORTD') == 1
1912 executable('systemd-importd',
1913 systemd_importd_sources,
1914 include_directories : includes,
1915 link_with : [libshared],
1916 dependencies : [threads],
1917 install_rpath : rootlibexecdir,
1919 install_dir : rootlibexecdir)
1921 systemd_pull = executable('systemd-pull',
1922 systemd_pull_sources,
1923 include_directories : includes,
1924 link_with : [libshared],
1925 dependencies : [libcurl,
1930 install_rpath : rootlibexecdir,
1932 install_dir : rootlibexecdir)
1934 systemd_import = executable('systemd-import',
1935 systemd_import_sources,
1936 include_directories : includes,
1937 link_with : [libshared],
1938 dependencies : [libcurl,
1942 install_rpath : rootlibexecdir,
1944 install_dir : rootlibexecdir)
1946 systemd_export = executable('systemd-export',
1947 systemd_export_sources,
1948 include_directories : includes,
1949 link_with : [libshared],
1950 dependencies : [libcurl,
1954 install_rpath : rootlibexecdir,
1956 install_dir : rootlibexecdir)
1957 public_programs += [systemd_pull, systemd_import, systemd_export]
1960 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1961 exe = executable('systemd-journal-upload',
1962 systemd_journal_upload_sources,
1963 include_directories : includes,
1964 link_with : [libshared],
1965 dependencies : [threads,
1970 install_rpath : rootlibexecdir,
1972 install_dir : rootlibexecdir)
1973 public_programs += [exe]
1976 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1977 s_j_remote = executable('systemd-journal-remote',
1978 systemd_journal_remote_sources,
1979 include_directories : includes,
1980 link_with : [libshared],
1981 dependencies : [threads,
1986 install_rpath : rootlibexecdir,
1988 install_dir : rootlibexecdir)
1990 s_j_gatewayd = executable('systemd-journal-gatewayd',
1991 systemd_journal_gatewayd_sources,
1992 include_directories : includes,
1993 link_with : [libshared],
1994 dependencies : [threads,
1999 install_rpath : rootlibexecdir,
2001 install_dir : rootlibexecdir)
2002 public_programs += [s_j_remote, s_j_gatewayd]
2005 if conf.get('ENABLE_COREDUMP') == 1
2006 executable('systemd-coredump',
2007 systemd_coredump_sources,
2008 include_directories : includes,
2009 link_with : [libshared],
2010 dependencies : [threads,
2015 install_rpath : rootlibexecdir,
2017 install_dir : rootlibexecdir)
2019 exe = executable('coredumpctl',
2020 coredumpctl_sources,
2021 include_directories : includes,
2022 link_with : [libshared],
2023 dependencies : [threads,
2026 install_rpath : rootlibexecdir,
2028 public_programs += [exe]
2031 if conf.get('ENABLE_BINFMT') == 1
2032 exe = executable('systemd-binfmt',
2033 'src/binfmt/binfmt.c',
2034 include_directories : includes,
2035 link_with : [libshared],
2036 install_rpath : rootlibexecdir,
2038 install_dir : rootlibexecdir)
2039 public_programs += [exe]
2041 meson.add_install_script('sh', '-c',
2042 mkdir_p.format(binfmtdir))
2043 meson.add_install_script('sh', '-c',
2044 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2047 if conf.get('ENABLE_VCONSOLE') == 1
2048 executable('systemd-vconsole-setup',
2049 'src/vconsole/vconsole-setup.c',
2050 include_directories : includes,
2051 link_with : [libshared],
2052 install_rpath : rootlibexecdir,
2054 install_dir : rootlibexecdir)
2057 if conf.get('ENABLE_RANDOMSEED') == 1
2058 executable('systemd-random-seed',
2059 'src/random-seed/random-seed.c',
2060 include_directories : includes,
2061 link_with : [libshared],
2062 install_rpath : rootlibexecdir,
2064 install_dir : rootlibexecdir)
2067 if conf.get('ENABLE_FIRSTBOOT') == 1
2068 executable('systemd-firstboot',
2069 'src/firstboot/firstboot.c',
2070 include_directories : includes,
2071 link_with : [libshared],
2072 dependencies : [libcrypt],
2073 install_rpath : rootlibexecdir,
2075 install_dir : rootbindir)
2078 executable('systemd-remount-fs',
2079 'src/remount-fs/remount-fs.c',
2080 'src/core/mount-setup.c',
2081 'src/core/mount-setup.h',
2082 include_directories : includes,
2083 link_with : [libshared],
2084 install_rpath : rootlibexecdir,
2086 install_dir : rootlibexecdir)
2088 executable('systemd-machine-id-setup',
2089 'src/machine-id-setup/machine-id-setup-main.c',
2090 'src/core/machine-id-setup.c',
2091 'src/core/machine-id-setup.h',
2092 include_directories : includes,
2093 link_with : [libshared],
2094 install_rpath : rootlibexecdir,
2096 install_dir : rootbindir)
2098 executable('systemd-fsck',
2100 include_directories : includes,
2101 link_with : [libshared],
2102 install_rpath : rootlibexecdir,
2104 install_dir : rootlibexecdir)
2106 executable('systemd-growfs',
2107 'src/partition/growfs.c',
2108 include_directories : includes,
2109 link_with : [libshared],
2110 dependencies : [libcryptsetup],
2111 install_rpath : rootlibexecdir,
2113 install_dir : rootlibexecdir)
2115 executable('systemd-makefs',
2116 'src/partition/makefs.c',
2117 include_directories : includes,
2118 link_with : [libshared],
2119 install_rpath : rootlibexecdir,
2121 install_dir : rootlibexecdir)
2123 executable('systemd-sleep',
2124 'src/sleep/sleep.c',
2125 include_directories : includes,
2126 link_with : [libshared],
2127 install_rpath : rootlibexecdir,
2129 install_dir : rootlibexecdir)
2131 exe = executable('systemd-sysctl',
2132 'src/sysctl/sysctl.c',
2133 include_directories : includes,
2134 link_with : [libshared],
2135 install_rpath : rootlibexecdir,
2137 install_dir : rootlibexecdir)
2138 public_programs += [exe]
2140 executable('systemd-ac-power',
2141 'src/ac-power/ac-power.c',
2142 include_directories : includes,
2143 link_with : [libshared],
2144 install_rpath : rootlibexecdir,
2146 install_dir : rootlibexecdir)
2148 exe = executable('systemd-detect-virt',
2149 'src/detect-virt/detect-virt.c',
2150 include_directories : includes,
2151 link_with : [libshared],
2152 install_rpath : rootlibexecdir,
2154 public_programs += [exe]
2156 exe = executable('systemd-delta',
2157 'src/delta/delta.c',
2158 include_directories : includes,
2159 link_with : [libshared],
2160 install_rpath : rootlibexecdir,
2162 public_programs += [exe]
2164 exe = executable('systemd-escape',
2165 'src/escape/escape.c',
2166 include_directories : includes,
2167 link_with : [libshared],
2168 install_rpath : rootlibexecdir,
2170 install_dir : rootbindir)
2171 public_programs += [exe]
2173 exe = executable('systemd-notify',
2174 'src/notify/notify.c',
2175 include_directories : includes,
2176 link_with : [libshared],
2177 install_rpath : rootlibexecdir,
2179 install_dir : rootbindir)
2180 public_programs += [exe]
2182 executable('systemd-volatile-root',
2183 'src/volatile-root/volatile-root.c',
2184 include_directories : includes,
2185 link_with : [libshared],
2186 install_rpath : rootlibexecdir,
2188 install_dir : rootlibexecdir)
2190 executable('systemd-cgroups-agent',
2191 'src/cgroups-agent/cgroups-agent.c',
2192 include_directories : includes,
2193 link_with : [libshared],
2194 install_rpath : rootlibexecdir,
2196 install_dir : rootlibexecdir)
2198 exe = executable('systemd-path',
2200 include_directories : includes,
2201 link_with : [libshared],
2202 install_rpath : rootlibexecdir,
2204 public_programs += [exe]
2206 exe = executable('systemd-ask-password',
2207 'src/ask-password/ask-password.c',
2208 include_directories : includes,
2209 link_with : [libshared],
2210 install_rpath : rootlibexecdir,
2212 install_dir : rootbindir)
2213 public_programs += [exe]
2215 executable('systemd-reply-password',
2216 'src/reply-password/reply-password.c',
2217 include_directories : includes,
2218 link_with : [libshared],
2219 install_rpath : rootlibexecdir,
2221 install_dir : rootlibexecdir)
2223 exe = executable('systemd-tty-ask-password-agent',
2224 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2225 include_directories : includes,
2226 link_with : [libshared],
2227 install_rpath : rootlibexecdir,
2229 install_dir : rootbindir)
2230 public_programs += [exe]
2232 exe = executable('systemd-cgls',
2234 include_directories : includes,
2235 link_with : [libshared],
2236 install_rpath : rootlibexecdir,
2238 public_programs += [exe]
2240 exe = executable('systemd-cgtop',
2241 'src/cgtop/cgtop.c',
2242 include_directories : includes,
2243 link_with : [libshared],
2244 install_rpath : rootlibexecdir,
2246 public_programs += [exe]
2248 executable('systemd-initctl',
2249 'src/initctl/initctl.c',
2250 include_directories : includes,
2251 link_with : [libshared],
2252 install_rpath : rootlibexecdir,
2254 install_dir : rootlibexecdir)
2256 exe = executable('systemd-mount',
2257 'src/mount/mount-tool.c',
2258 include_directories : includes,
2259 link_with : [libshared],
2260 install_rpath : rootlibexecdir,
2262 public_programs += [exe]
2264 meson.add_install_script(meson_make_symlink,
2265 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2267 exe = executable('systemd-run',
2269 include_directories : includes,
2270 link_with : [libshared],
2271 install_rpath : rootlibexecdir,
2273 public_programs += [exe]
2275 exe = executable('systemd-stdio-bridge',
2276 'src/stdio-bridge/stdio-bridge.c',
2277 include_directories : includes,
2278 link_with : [libshared],
2279 install_rpath : rootlibexecdir,
2281 public_programs += [exe]
2283 exe = executable('busctl',
2284 'src/busctl/busctl.c',
2285 'src/busctl/busctl-introspect.c',
2286 'src/busctl/busctl-introspect.h',
2287 include_directories : includes,
2288 link_with : [libshared],
2289 install_rpath : rootlibexecdir,
2291 public_programs += [exe]
2293 if conf.get('ENABLE_SYSUSERS') == 1
2294 exe = executable('systemd-sysusers',
2295 'src/sysusers/sysusers.c',
2296 include_directories : includes,
2297 link_with : [libshared],
2298 install_rpath : rootlibexecdir,
2300 install_dir : rootbindir)
2301 public_programs += [exe]
2304 if conf.get('ENABLE_TMPFILES') == 1
2305 exe = executable('systemd-tmpfiles',
2306 'src/tmpfiles/tmpfiles.c',
2307 include_directories : includes,
2308 link_with : [libshared],
2309 dependencies : [libacl],
2310 install_rpath : rootlibexecdir,
2312 install_dir : rootbindir)
2313 public_programs += [exe]
2315 test('test-systemd-tmpfiles',
2316 test_systemd_tmpfiles_py,
2317 args : exe.full_path())
2318 # https://github.com/mesonbuild/meson/issues/2681
2321 if conf.get('ENABLE_HWDB') == 1
2322 exe = executable('systemd-hwdb',
2324 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2325 include_directories : includes,
2326 link_with : [libudev_static],
2327 install_rpath : udev_rpath,
2329 install_dir : rootbindir)
2330 public_programs += [exe]
2333 if conf.get('ENABLE_QUOTACHECK') == 1
2334 executable('systemd-quotacheck',
2335 'src/quotacheck/quotacheck.c',
2336 include_directories : includes,
2337 link_with : [libshared],
2338 install_rpath : rootlibexecdir,
2340 install_dir : rootlibexecdir)
2343 exe = executable('systemd-socket-proxyd',
2344 'src/socket-proxy/socket-proxyd.c',
2345 include_directories : includes,
2346 link_with : [libshared],
2347 dependencies : [threads],
2348 install_rpath : rootlibexecdir,
2350 install_dir : rootlibexecdir)
2351 public_programs += [exe]
2353 exe = executable('systemd-udevd',
2354 systemd_udevd_sources,
2355 include_directories : includes,
2356 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2357 link_with : [libudev_core,
2360 dependencies : [threads,
2365 install_rpath : udev_rpath,
2367 install_dir : rootlibexecdir)
2368 public_programs += [exe]
2370 exe = executable('udevadm',
2372 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2373 include_directories : includes,
2374 link_with : [libudev_core,
2377 dependencies : [threads,
2382 install_rpath : udev_rpath,
2384 install_dir : rootbindir)
2385 public_programs += [exe]
2387 executable('systemd-shutdown',
2388 systemd_shutdown_sources,
2389 include_directories : includes,
2390 link_with : [libshared],
2391 install_rpath : rootlibexecdir,
2393 install_dir : rootlibexecdir)
2395 executable('systemd-update-done',
2396 'src/update-done/update-done.c',
2397 include_directories : includes,
2398 link_with : [libshared],
2399 install_rpath : rootlibexecdir,
2401 install_dir : rootlibexecdir)
2403 executable('systemd-update-utmp',
2404 'src/update-utmp/update-utmp.c',
2405 include_directories : includes,
2406 link_with : [libshared],
2407 dependencies : [libaudit],
2408 install_rpath : rootlibexecdir,
2410 install_dir : rootlibexecdir)
2412 if conf.get('HAVE_KMOD') == 1
2413 executable('systemd-modules-load',
2414 'src/modules-load/modules-load.c',
2415 include_directories : includes,
2416 link_with : [libshared],
2417 dependencies : [libkmod],
2418 install_rpath : rootlibexecdir,
2420 install_dir : rootlibexecdir)
2422 meson.add_install_script('sh', '-c',
2423 mkdir_p.format(modulesloaddir))
2424 meson.add_install_script('sh', '-c',
2425 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2428 exe = executable('systemd-nspawn',
2429 systemd_nspawn_sources,
2430 'src/core/mount-setup.c', # FIXME: use a variable?
2431 'src/core/mount-setup.h',
2432 'src/core/loopback-setup.c',
2433 'src/core/loopback-setup.h',
2434 include_directories : [includes, include_directories('src/nspawn')],
2435 link_with : [libshared],
2436 dependencies : [libacl,
2440 install_rpath : rootlibexecdir,
2442 public_programs += [exe]
2444 if conf.get('ENABLE_NETWORKD') == 1
2445 executable('systemd-networkd',
2446 systemd_networkd_sources,
2447 include_directories : includes,
2448 link_with : [libnetworkd_core,
2452 dependencies : [threads],
2453 install_rpath : rootlibexecdir,
2455 install_dir : rootlibexecdir)
2457 executable('systemd-networkd-wait-online',
2458 systemd_networkd_wait_online_sources,
2459 include_directories : includes,
2460 link_with : [libnetworkd_core,
2462 install_rpath : rootlibexecdir,
2464 install_dir : rootlibexecdir)
2466 exe = executable('networkctl',
2468 include_directories : includes,
2469 link_with : [libsystemd_network,
2471 install_rpath : rootlibexecdir,
2473 install_dir : rootbindir)
2474 public_programs += [exe]
2477 executable('systemd-sulogin-shell',
2478 ['src/sulogin-shell/sulogin-shell.c'],
2479 include_directories : includes,
2480 link_with : [libshared],
2481 install_rpath : rootlibexecdir,
2483 install_dir : rootlibexecdir)
2485 ############################################################
2487 foreach tuple : tests
2489 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2490 dependencies = tuple[2]
2491 condition = tuple.length() >= 4 ? tuple[3] : ''
2492 type = tuple.length() >= 5 ? tuple[4] : ''
2493 defs = tuple.length() >= 6 ? tuple[5] : []
2494 incs = tuple.length() >= 7 ? tuple[6] : includes
2497 name = sources[0].split('/')[-1].split('.')[0]
2498 if type.startswith('timeout=')
2499 timeout = type.split('=')[1].to_int()
2502 if want_tests == 'false'
2503 message('Not compiling @0@ because tests is set to false'.format(name))
2504 elif condition == '' or conf.get(condition) == 1
2508 include_directories : incs,
2509 link_with : link_with,
2510 dependencies : dependencies,
2512 install_rpath : rootlibexecdir,
2513 install : install_tests,
2514 install_dir : join_paths(testsdir, type))
2517 message('@0@ is a manual test'.format(name))
2518 elif type == 'unsafe' and want_tests != 'unsafe'
2519 message('@0@ is an unsafe test'.format(name))
2526 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2530 test_libsystemd_sym = executable(
2531 'test-libsystemd-sym',
2532 test_libsystemd_sym_c,
2533 include_directories : includes,
2534 link_with : [libsystemd],
2535 install : install_tests,
2536 install_dir : testsdir)
2537 test('test-libsystemd-sym',
2538 test_libsystemd_sym)
2540 test_libudev_sym = executable(
2543 include_directories : includes,
2544 c_args : ['-Wno-deprecated-declarations'],
2545 link_with : [libudev],
2546 install : install_tests,
2547 install_dir : testsdir)
2548 test('test-libudev-sym',
2551 ############################################################
2555 foreach tuple : fuzzers
2557 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2558 dependencies = tuple[2]
2559 defs = tuple.length() >= 4 ? tuple[3] : []
2560 incs = tuple.length() >= 5 ? tuple[4] : includes
2563 dependencies += fuzzing_engine
2565 sources += 'src/fuzz/fuzz-main.c'
2568 name = sources[0].split('/')[-1].split('.')[0]
2570 fuzzer_exes += executable(
2573 include_directories : [incs, include_directories('src/fuzz')],
2574 link_with : link_with,
2575 dependencies : dependencies,
2580 run_target('fuzzers',
2581 depends : fuzzer_exes,
2584 ############################################################
2586 make_directive_index_py = find_program('tools/make-directive-index.py')
2587 make_man_index_py = find_program('tools/make-man-index.py')
2588 xml_helper_py = find_program('tools/xml_helper.py')
2589 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2593 subdir('sysusers.d')
2594 subdir('tmpfiles.d')
2599 subdir('shell-completion/bash')
2600 subdir('shell-completion/zsh')
2601 subdir('docs/sysvinit')
2602 subdir('docs/var-log')
2604 # FIXME: figure out if the warning is true:
2605 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2606 install_subdir('factory/etc',
2607 install_dir : factorydir)
2610 install_data('xorg/50-systemd-user.sh',
2611 install_dir : xinitrcdir)
2612 install_data('modprobe.d/systemd.conf',
2613 install_dir : modprobedir)
2614 install_data('LICENSE.GPL2',
2619 'doc/DISTRO_PORTING',
2620 'doc/ENVIRONMENT.md',
2622 'doc/TRANSIENT-SETTINGS.md',
2625 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2626 install_dir : docdir)
2628 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2629 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2631 ############################################################
2633 meson_check_help = find_program('tools/meson-check-help.sh')
2635 foreach exec : public_programs
2636 name = exec.full_path().split('/')[-1]
2637 test('check-help-' + name,
2639 args : [exec.full_path()])
2642 ############################################################
2645 foreach p : fuzz_regression_tests
2646 a = p.split('/')[-3]
2647 b = p.split('/')[-2]
2648 c = p.split('/')[-1]
2651 build = sanitize_address
2653 error('unknown sanitizer @0@'.format(a))
2656 name = '@1@:@0@'.format(a, b)
2659 if want_tests == 'false'
2660 message('Not compiling @0@ because tests is set to false'.format(name))
2661 elif not sanitizers.contains(a)
2662 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2664 exe = custom_target(
2668 command : [env, 'ln', '-fs',
2669 join_paths(build.full_path(), b),
2671 build_by_default : true)
2673 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2678 if want_tests != 'false' and slow_tests
2679 test(c, env, args : [exe.full_path(),
2680 join_paths(meson.source_root(),
2681 'test/fuzz-regressions',
2686 ############################################################
2689 all_files = run_command(
2691 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2694 all_files = files(all_files.stdout().split())
2699 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2703 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2707 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2710 command : [meson_git_contrib_sh])
2714 git_head = run_command(
2716 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2717 'rev-parse', 'HEAD']).stdout().strip()
2718 git_head_short = run_command(
2720 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2721 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2725 command : ['git', 'archive',
2726 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2728 '--prefix', 'systemd-@0@/'.format(git_head),
2732 ############################################################
2734 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2737 depends : [man, libsystemd, libudev],
2738 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2740 ############################################################
2743 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2745 'split /usr: @0@'.format(split_usr),
2746 'prefix directory: @0@'.format(prefixdir),
2747 'rootprefix directory: @0@'.format(rootprefixdir),
2748 'sysconf directory: @0@'.format(sysconfdir),
2749 'include directory: @0@'.format(includedir),
2750 'lib directory: @0@'.format(libdir),
2751 'rootlib directory: @0@'.format(rootlibdir),
2752 'SysV init scripts: @0@'.format(sysvinit_path),
2753 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2754 'PAM modules directory: @0@'.format(pamlibdir),
2755 'PAM configuration directory: @0@'.format(pamconfdir),
2756 'RPM macros directory: @0@'.format(rpmmacrosdir),
2757 'modprobe.d directory: @0@'.format(modprobedir),
2758 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2759 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2760 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2761 'bash completions directory: @0@'.format(bashcompletiondir),
2762 'zsh completions directory: @0@'.format(zshcompletiondir),
2763 'extra start script: @0@'.format(get_option('rc-local')),
2764 'extra stop script: @0@'.format(get_option('halt-local')),
2765 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2766 get_option('debug-tty')),
2767 'TTY GID: @0@'.format(tty_gid),
2768 'users GID: @0@'.format(users_gid),
2769 'maximum system UID: @0@'.format(system_uid_max),
2770 'maximum system GID: @0@'.format(system_gid_max),
2771 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2772 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2773 'minimum container UID base: @0@'.format(container_uid_base_min),
2774 'maximum container UID base: @0@'.format(container_uid_base_max),
2775 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2776 'render group access mode: @0@'.format(get_option('group-render-mode')),
2777 'certificate root directory: @0@'.format(get_option('certificate-root')),
2778 'support URL: @0@'.format(support_url),
2779 'nobody user name: @0@'.format(nobody_user),
2780 'nobody group name: @0@'.format(nobody_group),
2781 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2782 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2784 'default DNSSEC mode: @0@'.format(default_dnssec),
2785 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2786 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2788 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2789 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2791 'default DNS servers: @0@'.format(alt_dns_servers),
2792 'default NTP servers: @0@'.format(alt_ntp_servers)]
2794 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2795 '@@0@'.format(time_epoch)).stdout().strip()
2797 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2800 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2801 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2802 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2804 if conf.get('ENABLE_EFI') == 1
2806 'efi arch: @0@'.format(efi_arch)]
2810 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2811 'EFI CC @0@'.format(efi_cc),
2812 'EFI lib directory: @0@'.format(efi_libdir),
2813 'EFI lds directory: @0@'.format(efi_ldsdir),
2814 'EFI include directory: @0@'.format(efi_incdir)]
2867 ['legacy pkla', install_polkit_pkla],
2869 ['gnu-efi', have_gnu_efi],
2876 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2879 ['man pages', want_man],
2880 ['html pages', want_html],
2881 ['man page indices', want_man and have_lxml],
2886 ['adm group', get_option('adm-group')],
2887 ['wheel group', get_option('wheel-group')],
2890 ['debug mmap cache'],
2893 cond = tuple.get(1, '')
2895 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2896 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2897 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2902 missing += [tuple[0]]
2908 'enabled features: @0@'.format(', '.join(found)),
2910 'disabled features: @0@'.format(', '.join(missing)),
2912 message('\n '.join(status))
2914 if rootprefixdir != rootprefix_default
2915 message('WARNING:\n' +
2916 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2917 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2918 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))