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,
63 description : '/usr/bin and /bin directories are separate')
65 if get_option('split-bin') == 'auto'
66 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
68 split_bin = get_option('split-bin') == 'true'
70 conf.set10('HAVE_SPLIT_BIN', split_bin,
71 description : 'bin and sbin directories are separate')
73 rootprefixdir = get_option('rootprefix')
74 # Unusual rootprefixdir values are used by some distros
75 # (see https://github.com/systemd/systemd/pull/7461).
76 rootprefix_default = split_usr ? '/' : '/usr'
77 if rootprefixdir == ''
78 rootprefixdir = rootprefix_default
81 sysvinit_path = get_option('sysvinit-path')
82 sysvrcnd_path = get_option('sysvrcnd-path')
83 have = sysvinit_path != '' and sysvrcnd_path != ''
84 conf.set10('HAVE_SYSV_COMPAT', have,
85 description : 'SysV init scripts and rcN.d links are supported')
86 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
88 # join_paths ignore the preceding arguments if an absolute component is
89 # encountered, so this should canonicalize various paths when they are
90 # absolute or relative.
91 prefixdir = get_option('prefix')
92 if not prefixdir.startswith('/')
93 error('Prefix is not absolute: "@0@"'.format(prefixdir))
95 bindir = join_paths(prefixdir, get_option('bindir'))
96 libdir = join_paths(prefixdir, get_option('libdir'))
97 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
98 includedir = join_paths(prefixdir, get_option('includedir'))
99 datadir = join_paths(prefixdir, get_option('datadir'))
100 localstatedir = join_paths('/', get_option('localstatedir'))
102 rootbindir = join_paths(rootprefixdir, 'bin')
103 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
104 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
106 rootlibdir = get_option('rootlibdir')
108 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
111 # Dirs of external packages
112 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
113 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
114 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
115 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
116 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
117 varlogdir = join_paths(localstatedir, 'log')
118 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
119 rpmmacrosdir = get_option('rpmmacrosdir')
120 if rpmmacrosdir != 'no'
121 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
123 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
126 pkgdatadir = join_paths(datadir, 'systemd')
127 environmentdir = join_paths(prefixdir, 'lib/environment.d')
128 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
129 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
130 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
131 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
132 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
133 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
134 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
135 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
136 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
137 pkgincludedir = join_paths(includedir, 'systemd')
138 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
139 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
140 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
141 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
142 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
143 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
144 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
145 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
146 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
147 udevhomedir = udevlibexecdir
148 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
149 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
150 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
151 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
152 factorydir = join_paths(datadir, 'factory')
153 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
154 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
155 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
156 catalogstatedir = join_paths(systemdstatedir, 'catalog')
157 randomseeddir = join_paths(localstatedir, 'lib/systemd')
159 docdir = get_option('docdir')
161 docdir = join_paths(datadir, 'doc/systemd')
164 dbuspolicydir = get_option('dbuspolicydir')
165 if dbuspolicydir == ''
166 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
169 dbussessionservicedir = get_option('dbussessionservicedir')
170 if dbussessionservicedir == ''
171 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
174 dbussystemservicedir = get_option('dbussystemservicedir')
175 if dbussystemservicedir == ''
176 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
179 pamlibdir = get_option('pamlibdir')
181 pamlibdir = join_paths(rootlibdir, 'security')
184 pamconfdir = get_option('pamconfdir')
186 pamconfdir = join_paths(sysconfdir, 'pam.d')
189 memory_accounting_default = get_option('memory-accounting-default')
191 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
192 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
193 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
194 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
195 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
196 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
197 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
198 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
199 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
200 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
201 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
202 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
203 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
204 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
205 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
206 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
207 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
208 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
209 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
210 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
211 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
212 conf.set_quoted('ROOTPREFIX', rootprefixdir)
213 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
214 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
215 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
216 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
217 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
218 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
219 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
220 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
221 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
222 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
223 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
224 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
225 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
226 conf.set_quoted('LIBDIR', libdir)
227 conf.set_quoted('ROOTLIBDIR', rootlibdir)
228 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
229 conf.set_quoted('BOOTLIBDIR', bootlibdir)
230 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
231 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
232 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
233 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
234 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
235 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
236 conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
237 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_ON_OFF', memory_accounting_default ? 'on' : 'off')
239 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
240 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
242 substs.set('prefix', prefixdir)
243 substs.set('exec_prefix', prefixdir)
244 substs.set('libdir', libdir)
245 substs.set('rootlibdir', rootlibdir)
246 substs.set('includedir', includedir)
247 substs.set('pkgsysconfdir', pkgsysconfdir)
248 substs.set('bindir', bindir)
249 substs.set('rootbindir', rootbindir)
250 substs.set('rootlibexecdir', rootlibexecdir)
251 substs.set('systemunitdir', systemunitdir)
252 substs.set('userunitdir', userunitdir)
253 substs.set('systempresetdir', systempresetdir)
254 substs.set('userpresetdir', userpresetdir)
255 substs.set('udevhwdbdir', udevhwdbdir)
256 substs.set('udevrulesdir', udevrulesdir)
257 substs.set('udevlibexecdir', udevlibexecdir)
258 substs.set('catalogdir', catalogdir)
259 substs.set('tmpfilesdir', tmpfilesdir)
260 substs.set('sysusersdir', sysusersdir)
261 substs.set('sysctldir', sysctldir)
262 substs.set('binfmtdir', binfmtdir)
263 substs.set('modulesloaddir', modulesloaddir)
264 substs.set('systemgeneratordir', systemgeneratordir)
265 substs.set('usergeneratordir', usergeneratordir)
266 substs.set('systemenvgeneratordir', systemenvgeneratordir)
267 substs.set('userenvgeneratordir', userenvgeneratordir)
268 substs.set('systemshutdowndir', systemshutdowndir)
269 substs.set('systemsleepdir', systemsleepdir)
270 substs.set('VARLOGDIR', varlogdir)
271 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
272 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
273 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
274 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
275 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
276 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
277 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
278 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
280 #####################################################################
282 cc = meson.get_compiler('c')
283 pkgconfig = import('pkgconfig')
284 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
285 meson_build_sh = find_program('tools/meson-build.sh')
287 if get_option('tests') != 'false'
288 cxx = find_program('c++', required : false)
290 # Used only for tests
295 want_ossfuzz = get_option('oss-fuzz')
296 want_libfuzzer = get_option('llvm-fuzz')
297 fuzzer_build = want_ossfuzz or want_libfuzzer
298 if want_ossfuzz and want_libfuzzer
299 error('only one of oss-fuzz and llvm-fuzz can be specified')
302 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
305 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
308 foreach arg : ['-Wextra',
311 '-Wmissing-include-dirs',
312 '-Wold-style-definition',
315 '-Wdeclaration-after-statement',
317 '-Wsuggest-attribute=noreturn',
318 '-Werror=missing-prototypes',
319 '-Werror=implicit-function-declaration',
320 '-Werror=missing-declarations',
321 '-Werror=return-type',
322 '-Werror=incompatible-pointer-types',
324 '-Wstrict-prototypes',
326 '-Wmissing-noreturn',
327 '-Wimplicit-fallthrough=5',
330 '-Wstrict-aliasing=2',
337 '-fdiagnostics-show-option',
338 '-fno-strict-aliasing',
339 '-fvisibility=hidden',
341 '-fstack-protector-strong',
342 '--param=ssp-buffer-size=4',
344 if cc.has_argument(arg)
345 add_project_arguments(arg, language : 'c')
349 # the oss-fuzz fuzzers are not built with -fPIE, so don't
350 # enable it when we are linking against them
352 if cc.has_argument('-fPIE')
353 add_project_arguments('-fPIE', language : 'c')
357 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
358 # arguments, just emits a warnings. So test for the "positive" version instead.
359 foreach arg : ['unused-parameter',
360 'missing-field-initializers',
363 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
365 if cc.has_argument('-W' + arg)
366 add_project_arguments('-Wno-' + arg, language : 'c')
372 #include <inttypes.h>
373 typedef uint64_t usec_t;
374 usec_t now(clockid_t clock);
379 ''', name : '-Werror=shadow with local shadowing')
380 add_project_arguments('-Werror=shadow', language : 'c')
383 if cc.get_id() == 'clang'
384 foreach arg : ['-Wno-typedef-redefinition',
385 '-Wno-gnu-variable-sized-type-not-at-end',
387 if cc.has_argument(arg,
388 name : '@0@ is supported'.format(arg))
389 add_project_arguments(arg, language : 'c')
394 link_test_c = files('tools/meson-link-test.c')
396 # --as-needed and --no-undefined are provided by meson by default,
397 # run mesonconf to see what is enabled
398 foreach arg : ['-Wl,-z,relro',
403 have = run_command(check_compilation_sh,
404 cc.cmd_array(), '-x', 'c', arg,
405 '-include', link_test_c).returncode() == 0
406 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
407 if have and (arg != '-pie' or not fuzzer_build)
408 add_project_link_arguments(arg, language : 'c')
412 # Check if various sanitizers are supported
414 foreach arg : ['address']
416 have = run_command(check_compilation_sh,
417 cc.cmd_array(), '-x', 'c',
418 '-fsanitize=@0@'.format(arg),
419 '-include', link_test_c).returncode() == 0
420 message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
426 if get_option('buildtype') != 'debug'
427 foreach arg : ['-ffunction-sections',
429 if cc.has_argument(arg,
430 name : '@0@ is supported'.format(arg))
431 add_project_arguments(arg, language : 'c')
435 foreach arg : ['-Wl,--gc-sections']
436 have = run_command(check_compilation_sh,
437 cc.cmd_array(), '-x', 'c', arg,
438 '-include', link_test_c).returncode() == 0
439 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
441 add_project_link_arguments(arg, language : 'c')
446 cpp = ' '.join(cc.cmd_array()) + ' -E'
448 #####################################################################
449 # compilation result tests
451 conf.set('_GNU_SOURCE', true)
452 conf.set('__SANE_USERSPACE_TYPES__', true)
454 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
455 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
456 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
457 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
458 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
459 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
460 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
464 #include <linux/ethtool.h>
465 #include <linux/fib_rules.h>
466 #include <linux/stat.h>
467 #include <sys/stat.h>
469 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
471 foreach decl : ['char16_t',
474 'struct ethtool_link_settings',
475 'struct fib_rule_uid_range',
479 # We get -1 if the size cannot be determined
480 have = cc.sizeof(decl, prefix : decl_headers) > 0
481 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
484 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
485 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
486 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
487 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
488 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
489 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
490 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
491 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
492 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
493 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
494 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
495 # if_tunnel.h is buggy and cannot be included on its own
496 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
497 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
498 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
499 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
500 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
501 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
502 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
503 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
504 ['NDA_IFINDEX', 'linux/neighbour.h'],
505 ['IFA_FLAGS', 'linux/if_addr.h'],
506 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
507 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
508 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
510 prefix = decl.length() > 2 ? decl[2] : ''
511 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
512 conf.set10('HAVE_' + decl[0], have)
515 foreach ident : ['secure_getenv', '__secure_getenv']
516 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
520 ['memfd_create', '''#include <sys/mman.h>'''],
521 ['gettid', '''#include <sys/types.h>
522 #include <unistd.h>'''],
523 ['pivot_root', '''#include <stdlib.h>
524 #include <unistd.h>'''], # no known header declares pivot_root
525 ['name_to_handle_at', '''#include <sys/types.h>
526 #include <sys/stat.h>
527 #include <fcntl.h>'''],
528 ['setns', '''#include <sched.h>'''],
529 ['renameat2', '''#include <stdio.h>
530 #include <fcntl.h>'''],
531 ['kcmp', '''#include <linux/kcmp.h>'''],
532 ['keyctl', '''#include <sys/types.h>
533 #include <keyutils.h>'''],
534 ['copy_file_range', '''#include <sys/syscall.h>
535 #include <unistd.h>'''],
536 ['bpf', '''#include <sys/syscall.h>
537 #include <unistd.h>'''],
538 ['statx', '''#include <sys/types.h>
539 #include <sys/stat.h>
540 #include <unistd.h>'''],
541 ['explicit_bzero' , '''#include <string.h>'''],
542 ['reallocarray', '''#include <malloc.h>'''],
545 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
546 conf.set10('HAVE_' + ident[0].to_upper(), have)
549 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
550 conf.set10('USE_SYS_RANDOM_H', true)
551 conf.set10('HAVE_GETRANDOM', true)
553 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
554 conf.set10('USE_SYS_RANDOM_H', false)
555 conf.set10('HAVE_GETRANDOM', have)
558 #####################################################################
560 sed = find_program('sed')
561 awk = find_program('awk')
562 m4 = find_program('m4')
563 stat = find_program('stat')
564 git = find_program('git', required : false)
565 env = find_program('env')
567 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
568 mkdir_p = 'mkdir -p $DESTDIR/@0@'
569 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
570 splash_bmp = files('test/splash.bmp')
572 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
573 # /usr/sbin, /sbin, and fall back to the default from middle column.
574 progs = [['quotaon', '/usr/sbin/quotaon' ],
575 ['quotacheck', '/usr/sbin/quotacheck' ],
576 ['kill', '/usr/bin/kill' ],
577 ['kmod', '/usr/bin/kmod' ],
578 ['kexec', '/usr/sbin/kexec' ],
579 ['sulogin', '/usr/sbin/sulogin' ],
580 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
581 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
582 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
583 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
586 path = get_option(prog[0] + '-path')
588 message('Using @1@ for @0@'.format(prog[0], path))
590 exe = find_program(prog[0],
591 '/usr/sbin/' + prog[0],
594 path = exe.found() ? exe.path() : prog[1]
596 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
597 conf.set_quoted(name, path)
598 substs.set(name, path)
601 conf.set_quoted('TELINIT', get_option('telinit-path'))
603 if run_command('ln', '--relative', '--help').returncode() != 0
604 error('ln does not support --relative')
607 ############################################################
609 gperf = find_program('gperf')
611 gperf_test_format = '''
613 const char * in_word_set(const char *, @0@);
616 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
617 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
618 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
619 if cc.compiles(gperf_test)
620 gperf_len_type = 'size_t'
622 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
623 if cc.compiles(gperf_test)
624 gperf_len_type = 'unsigned'
626 error('unable to determine gperf len type')
629 message('gperf len type is @0@'.format(gperf_len_type))
630 conf.set('GPERF_LEN_TYPE', gperf_len_type,
631 description : 'The type of gperf "len" parameter')
633 ############################################################
635 if not cc.has_header('sys/capability.h')
636 error('POSIX caps headers not found')
638 foreach header : ['crypt.h',
641 'linux/vm_sockets.h',
643 'valgrind/memcheck.h',
644 'valgrind/valgrind.h',
647 conf.set10('HAVE_' + header.underscorify().to_upper(),
648 cc.has_header(header))
651 ############################################################
653 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
654 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
655 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
657 default_hierarchy = get_option('default-hierarchy')
658 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
659 description : 'default cgroup hierarchy as string')
660 if default_hierarchy == 'legacy'
661 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
662 elif default_hierarchy == 'hybrid'
663 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
665 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
668 time_epoch = get_option('time-epoch')
671 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
673 time_epoch = time_epoch.to_int()
674 conf.set('TIME_EPOCH', time_epoch)
676 system_uid_max = get_option('system-uid-max')
677 if system_uid_max == ''
678 system_uid_max = run_command(
680 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
681 '/etc/login.defs').stdout().strip()
682 if system_uid_max == ''
683 system_uid_max = '999'
686 system_uid_max = system_uid_max.to_int()
687 conf.set('SYSTEM_UID_MAX', system_uid_max)
688 substs.set('systemuidmax', system_uid_max)
689 message('maximum system UID is @0@'.format(system_uid_max))
691 system_gid_max = get_option('system-gid-max')
692 if system_gid_max == ''
693 system_gid_max = run_command(
695 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
696 '/etc/login.defs').stdout().strip()
697 if system_gid_max == ''
698 system_gid_max = '999'
701 system_gid_max = system_gid_max.to_int()
702 conf.set('SYSTEM_GID_MAX', system_gid_max)
703 substs.set('systemgidmax', system_gid_max)
704 message('maximum system GID is @0@'.format(system_gid_max))
706 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
707 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
708 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
709 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
710 substs.set('dynamicuidmin', dynamic_uid_min)
711 substs.set('dynamicuidmax', dynamic_uid_max)
713 container_uid_base_min = get_option('container-uid-base-min').to_int()
714 container_uid_base_max = get_option('container-uid-base-max').to_int()
715 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
716 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
717 substs.set('containeruidbasemin', container_uid_base_min)
718 substs.set('containeruidbasemax', container_uid_base_max)
720 nobody_user = get_option('nobody-user')
721 nobody_group = get_option('nobody-group')
723 getent_result = run_command('getent', 'passwd', '65534')
724 if getent_result.returncode() == 0
725 name = getent_result.stdout().split(':')[0]
726 if name != nobody_user
727 message('WARNING:\n' +
728 ' 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) +
729 ' Your build will result in an user table setup that is incompatible with the local system.')
732 id_result = run_command('id', '-u', nobody_user)
733 if id_result.returncode() == 0
734 id = id_result.stdout().to_int()
736 message('WARNING:\n' +
737 ' 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) +
738 ' Your build will result in an user table setup that is incompatible with the local system.')
742 getent_result = run_command('getent', 'group', '65534')
743 if getent_result.returncode() == 0
744 name = getent_result.stdout().split(':')[0]
745 if name != nobody_group
746 message('WARNING:\n' +
747 ' 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) +
748 ' Your build will result in an group table setup that is incompatible with the local system.')
751 id_result = run_command('id', '-g', nobody_group)
752 if id_result.returncode() == 0
753 id = id_result.stdout().to_int()
755 message('WARNING:\n' +
756 ' 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) +
757 ' Your build will result in an group table setup that is incompatible with the local system.')
760 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
761 message('WARNING:\n' +
762 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
763 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
766 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
767 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
768 substs.set('NOBODY_USER_NAME', nobody_user)
769 substs.set('NOBODY_GROUP_NAME', nobody_group)
771 tty_gid = get_option('tty-gid')
772 conf.set('TTY_GID', tty_gid)
773 substs.set('TTY_GID', tty_gid)
775 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
776 if get_option('users-gid') != ''
777 users_gid = get_option('users-gid').to_int()
781 substs.set('USERS_GID', users_gid)
783 if get_option('adm-group')
784 m4_defines += ['-DENABLE_ADM_GROUP']
787 if get_option('wheel-group')
788 m4_defines += ['-DENABLE_WHEEL_GROUP']
791 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
792 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
794 kill_user_processes = get_option('default-kill-user-processes')
795 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
796 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
798 dns_servers = get_option('dns-servers')
799 conf.set_quoted('DNS_SERVERS', dns_servers)
800 substs.set('DNS_SERVERS', dns_servers)
802 ntp_servers = get_option('ntp-servers')
803 conf.set_quoted('NTP_SERVERS', ntp_servers)
804 substs.set('NTP_SERVERS', ntp_servers)
806 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
808 substs.set('SUSHELL', get_option('debug-shell'))
809 substs.set('DEBUGTTY', get_option('debug-tty'))
811 debug = get_option('debug')
812 enable_debug_hashmap = false
813 enable_debug_mmap_cache = false
815 foreach name : debug.split(',')
817 enable_debug_hashmap = true
818 elif name == 'mmap-cache'
819 enable_debug_mmap_cache = true
821 message('unknown debug option "@0@", ignoring'.format(name))
825 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
826 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
828 #####################################################################
830 threads = dependency('threads')
831 librt = cc.find_library('rt')
832 libm = cc.find_library('m')
833 libdl = cc.find_library('dl')
834 libcrypt = cc.find_library('crypt')
836 libcap = dependency('libcap', required : false)
837 if not libcap.found()
838 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
839 libcap = cc.find_library('cap')
842 libmount = dependency('mount',
844 required : not fuzzer_build)
846 want_seccomp = get_option('seccomp')
847 if want_seccomp != 'false' and not fuzzer_build
848 libseccomp = dependency('libseccomp',
849 version : '>= 2.3.1',
850 required : want_seccomp == 'true')
851 have = libseccomp.found()
856 conf.set10('HAVE_SECCOMP', have)
857 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
859 want_selinux = get_option('selinux')
860 if want_selinux != 'false' and not fuzzer_build
861 libselinux = dependency('libselinux',
862 version : '>= 2.1.9',
863 required : want_selinux == 'true')
864 have = libselinux.found()
869 conf.set10('HAVE_SELINUX', have)
870 m4_defines += have ? ['-DHAVE_SELINUX'] : []
872 want_apparmor = get_option('apparmor')
873 if want_apparmor != 'false' and not fuzzer_build
874 libapparmor = dependency('libapparmor',
875 required : want_apparmor == 'true')
876 have = libapparmor.found()
881 conf.set10('HAVE_APPARMOR', have)
882 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
884 smack_run_label = get_option('smack-run-label')
885 if smack_run_label != ''
886 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
887 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
890 want_polkit = get_option('polkit')
891 install_polkit = false
892 install_polkit_pkla = false
893 if want_polkit != 'false' and not fuzzer_build
894 install_polkit = true
896 libpolkit = dependency('polkit-gobject-1',
898 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
899 message('Old polkit detected, will install pkla files')
900 install_polkit_pkla = true
903 conf.set10('ENABLE_POLKIT', install_polkit)
905 want_acl = get_option('acl')
906 if want_acl != 'false' and not fuzzer_build
907 libacl = cc.find_library('acl', required : want_acl == 'true')
908 have = libacl.found()
913 conf.set10('HAVE_ACL', have)
914 m4_defines += have ? ['-DHAVE_ACL'] : []
916 want_audit = get_option('audit')
917 if want_audit != 'false' and not fuzzer_build
918 libaudit = dependency('audit', required : want_audit == 'true')
919 have = libaudit.found()
924 conf.set10('HAVE_AUDIT', have)
926 want_blkid = get_option('blkid')
927 if want_blkid != 'false' and not fuzzer_build
928 libblkid = dependency('blkid', required : want_blkid == 'true')
929 have = libblkid.found()
934 conf.set10('HAVE_BLKID', have)
936 want_kmod = get_option('kmod')
937 if want_kmod != 'false' and not fuzzer_build
938 libkmod = dependency('libkmod',
940 required : want_kmod == 'true')
941 have = libkmod.found()
946 conf.set10('HAVE_KMOD', have)
948 want_pam = get_option('pam')
949 if want_pam != 'false' and not fuzzer_build
950 libpam = cc.find_library('pam', required : want_pam == 'true')
951 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
952 have = libpam.found() and libpam_misc.found()
958 conf.set10('HAVE_PAM', have)
959 m4_defines += have ? ['-DHAVE_PAM'] : []
961 want_microhttpd = get_option('microhttpd')
962 if want_microhttpd != 'false' and not fuzzer_build
963 libmicrohttpd = dependency('libmicrohttpd',
964 version : '>= 0.9.33',
965 required : want_microhttpd == 'true')
966 have = libmicrohttpd.found()
971 conf.set10('HAVE_MICROHTTPD', have)
972 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
974 want_libcryptsetup = get_option('libcryptsetup')
975 if want_libcryptsetup != 'false' and not fuzzer_build
976 libcryptsetup = dependency('libcryptsetup',
977 version : '>= 1.6.0',
978 required : want_libcryptsetup == 'true')
979 have = libcryptsetup.found()
984 conf.set10('HAVE_LIBCRYPTSETUP', have)
986 want_libcurl = get_option('libcurl')
987 if want_libcurl != 'false' and not fuzzer_build
988 libcurl = dependency('libcurl',
989 version : '>= 7.32.0',
990 required : want_libcurl == 'true')
991 have = libcurl.found()
996 conf.set10('HAVE_LIBCURL', have)
997 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
999 want_libidn = get_option('libidn')
1000 want_libidn2 = get_option('libidn2')
1001 if want_libidn == 'true' and want_libidn2 == 'true'
1002 error('libidn and libidn2 cannot be requested simultaneously')
1005 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
1006 libidn = dependency('libidn',
1007 required : want_libidn == 'true')
1008 have = libidn.found()
1013 conf.set10('HAVE_LIBIDN', have)
1014 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1015 if not have and want_libidn2 != 'false' and not fuzzer_build
1016 # libidn is used for both libidn and libidn2 objects
1017 libidn = dependency('libidn2',
1018 required : want_libidn2 == 'true')
1019 have = libidn.found()
1023 conf.set10('HAVE_LIBIDN2', have)
1024 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1026 want_libiptc = get_option('libiptc')
1027 if want_libiptc != 'false' and not fuzzer_build
1028 libiptc = dependency('libiptc',
1029 required : want_libiptc == 'true')
1030 have = libiptc.found()
1035 conf.set10('HAVE_LIBIPTC', have)
1036 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1038 want_qrencode = get_option('qrencode')
1039 if want_qrencode != 'false' and not fuzzer_build
1040 libqrencode = dependency('libqrencode',
1041 required : want_qrencode == 'true')
1042 have = libqrencode.found()
1047 conf.set10('HAVE_QRENCODE', have)
1049 want_gcrypt = get_option('gcrypt')
1050 if want_gcrypt != 'false' and not fuzzer_build
1051 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1052 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1053 have = libgcrypt.found() and libgpg_error.found()
1058 # link to neither of the libs if one is not found
1062 conf.set10('HAVE_GCRYPT', have)
1064 want_gnutls = get_option('gnutls')
1065 if want_gnutls != 'false' and not fuzzer_build
1066 libgnutls = dependency('gnutls',
1067 version : '>= 3.1.4',
1068 required : want_gnutls == 'true')
1069 have = libgnutls.found()
1074 conf.set10('HAVE_GNUTLS', have)
1076 want_elfutils = get_option('elfutils')
1077 if want_elfutils != 'false' and not fuzzer_build
1078 libdw = dependency('libdw',
1079 required : want_elfutils == 'true')
1080 have = libdw.found()
1085 conf.set10('HAVE_ELFUTILS', have)
1087 want_zlib = get_option('zlib')
1088 if want_zlib != 'false' and not fuzzer_build
1089 libz = dependency('zlib',
1090 required : want_zlib == 'true')
1096 conf.set10('HAVE_ZLIB', have)
1098 want_bzip2 = get_option('bzip2')
1099 if want_bzip2 != 'false' and not fuzzer_build
1100 libbzip2 = cc.find_library('bz2',
1101 required : want_bzip2 == 'true')
1102 have = libbzip2.found()
1107 conf.set10('HAVE_BZIP2', have)
1109 want_xz = get_option('xz')
1110 if want_xz != 'false' and not fuzzer_build
1111 libxz = dependency('liblzma',
1112 required : want_xz == 'true')
1113 have = libxz.found()
1118 conf.set10('HAVE_XZ', have)
1120 want_lz4 = get_option('lz4')
1121 if want_lz4 != 'false' and not fuzzer_build
1122 liblz4 = dependency('liblz4',
1123 required : want_lz4 == 'true')
1124 have = liblz4.found()
1129 conf.set10('HAVE_LZ4', have)
1131 want_xkbcommon = get_option('xkbcommon')
1132 if want_xkbcommon != 'false' and not fuzzer_build
1133 libxkbcommon = dependency('xkbcommon',
1134 version : '>= 0.3.0',
1135 required : want_xkbcommon == 'true')
1136 have = libxkbcommon.found()
1141 conf.set10('HAVE_XKBCOMMON', have)
1143 want_pcre2 = get_option('pcre2')
1144 if want_pcre2 != 'false'
1145 libpcre2 = dependency('libpcre2-8',
1146 required : want_pcre2 == 'true')
1147 have = libpcre2.found()
1152 conf.set10('HAVE_PCRE2', have)
1154 want_glib = get_option('glib')
1155 if want_glib != 'false' and not fuzzer_build
1156 libglib = dependency('glib-2.0',
1157 version : '>= 2.22.0',
1158 required : want_glib == 'true')
1159 libgobject = dependency('gobject-2.0',
1160 version : '>= 2.22.0',
1161 required : want_glib == 'true')
1162 libgio = dependency('gio-2.0',
1163 required : want_glib == 'true')
1164 have = libglib.found() and libgobject.found() and libgio.found()
1171 conf.set10('HAVE_GLIB', have)
1173 want_dbus = get_option('dbus')
1174 if want_dbus != 'false' and not fuzzer_build
1175 libdbus = dependency('dbus-1',
1176 version : '>= 1.3.2',
1177 required : want_dbus == 'true')
1178 have = libdbus.found()
1183 conf.set10('HAVE_DBUS', have)
1185 default_dnssec = get_option('default-dnssec')
1187 default_dnssec = 'no'
1189 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1190 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1191 default_dnssec = 'no'
1193 conf.set('DEFAULT_DNSSEC_MODE',
1194 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1195 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1197 want_importd = get_option('importd')
1198 if want_importd != 'false'
1199 have = (conf.get('HAVE_LIBCURL') == 1 and
1200 conf.get('HAVE_ZLIB') == 1 and
1201 conf.get('HAVE_BZIP2') == 1 and
1202 conf.get('HAVE_XZ') == 1 and
1203 conf.get('HAVE_GCRYPT') == 1)
1204 if want_importd == 'true' and not have
1205 error('importd support was requested, but dependencies are not available')
1210 conf.set10('ENABLE_IMPORTD', have)
1212 want_remote = get_option('remote')
1213 if want_remote != 'false'
1214 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1215 conf.get('HAVE_LIBCURL') == 1]
1216 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1217 # it's possible to build one without the other. Complain only if
1218 # support was explictly requested. The auxiliary files like sysusers
1219 # config should be installed when any of the programs are built.
1220 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1221 error('remote support was requested, but dependencies are not available')
1223 have = have_deps[0] or have_deps[1]
1227 conf.set10('ENABLE_REMOTE', have)
1229 foreach term : ['utmp',
1260 have = get_option(term)
1261 name = 'ENABLE_' + term.underscorify().to_upper()
1262 conf.set10(name, have)
1263 m4_defines += have ? ['-D' + name] : []
1266 want_tests = get_option('tests')
1267 install_tests = get_option('install-tests')
1268 slow_tests = get_option('slow-tests')
1272 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1274 #####################################################################
1276 if get_option('efi')
1277 efi_arch = host_machine.cpu_family()
1279 if efi_arch == 'x86'
1280 EFI_MACHINE_TYPE_NAME = 'ia32'
1281 gnu_efi_arch = 'ia32'
1282 elif efi_arch == 'x86_64'
1283 EFI_MACHINE_TYPE_NAME = 'x64'
1284 gnu_efi_arch = 'x86_64'
1285 elif efi_arch == 'arm'
1286 EFI_MACHINE_TYPE_NAME = 'arm'
1287 gnu_efi_arch = 'arm'
1288 elif efi_arch == 'aarch64'
1289 EFI_MACHINE_TYPE_NAME = 'aa64'
1290 gnu_efi_arch = 'aarch64'
1292 EFI_MACHINE_TYPE_NAME = ''
1297 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1299 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1303 conf.set10('ENABLE_EFI', have)
1305 #####################################################################
1307 config_h = configure_file(
1308 output : 'config.h',
1309 configuration : conf)
1311 includes = include_directories('src/basic',
1321 'src/libsystemd/sd-bus',
1322 'src/libsystemd/sd-device',
1323 'src/libsystemd/sd-hwdb',
1324 'src/libsystemd/sd-id128',
1325 'src/libsystemd/sd-netlink',
1326 'src/libsystemd/sd-network',
1327 'src/libsystemd-network',
1330 add_project_arguments('-include', 'config.h', language : 'c')
1334 subdir('src/systemd')
1336 subdir('src/libsystemd')
1337 subdir('src/libsystemd-network')
1338 subdir('src/journal')
1341 libjournal_core = static_library(
1343 libjournal_core_sources,
1345 include_directories : includes,
1348 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1349 libsystemd = shared_library(
1351 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1352 version : libsystemd_version,
1353 include_directories : includes,
1354 link_args : ['-shared',
1355 '-Wl,--version-script=' + libsystemd_sym_path],
1356 link_with : [libbasic,
1358 link_whole : [libsystemd_static,
1360 dependencies : [threads,
1364 link_depends : libsystemd_sym,
1366 install_dir : rootlibdir)
1368 ############################################################
1370 # binaries that have --help and are intended for use by humans,
1371 # usually, but not always, installed in /bin.
1372 public_programs = []
1374 subdir('src/libudev')
1375 subdir('src/shared')
1378 subdir('src/network')
1380 subdir('src/analyze')
1381 subdir('src/journal-remote')
1382 subdir('src/coredump')
1383 subdir('src/hostname')
1384 subdir('src/import')
1385 subdir('src/kernel-install')
1386 subdir('src/locale')
1387 subdir('src/machine')
1388 subdir('src/nspawn')
1389 subdir('src/resolve')
1390 subdir('src/timedate')
1391 subdir('src/timesync')
1392 subdir('src/vconsole')
1393 subdir('src/boot/efi')
1400 ############################################################
1402 # only static linking apart from libdl, to make sure that the
1403 # module is linked to all libraries that it uses.
1404 test_dlopen = executable(
1407 include_directories : includes,
1408 link_with : [libbasic],
1409 dependencies : [libdl])
1411 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1412 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1413 ['mymachines', 'ENABLE_MACHINED'],
1414 ['resolve', 'ENABLE_RESOLVE']]
1416 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1420 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1421 version_script_arg = join_paths(meson.current_source_dir(), sym)
1423 nss = shared_library(
1425 'src/nss-@0@/nss-@0@.c'.format(module),
1427 include_directories : includes,
1428 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1429 link_args : ['-Wl,-z,nodelete',
1431 '-Wl,--version-script=' + version_script_arg,
1433 link_with : [libsystemd_static,
1435 dependencies : [threads,
1439 install_dir : rootlibdir)
1441 # We cannot use shared_module because it does not support version suffix.
1442 # Unfortunately shared_library insists on creating the symlink…
1443 meson.add_install_script('sh', '-c',
1444 'rm $DESTDIR@0@/libnss_@1@.so'
1445 .format(rootlibdir, module))
1447 test('dlopen-nss_' + module,
1449 args : [nss.full_path()]) # path to dlopen must include a slash
1453 ############################################################
1455 executable('systemd',
1457 include_directories : includes,
1458 link_with : [libcore,
1460 dependencies : [threads,
1466 install_rpath : rootlibexecdir,
1468 install_dir : rootlibexecdir)
1470 meson.add_install_script(meson_make_symlink,
1471 join_paths(rootlibexecdir, 'systemd'),
1472 join_paths(rootsbindir, 'init'))
1474 exe = executable('systemd-analyze',
1475 systemd_analyze_sources,
1476 include_directories : includes,
1477 link_with : [libcore,
1479 dependencies : [threads,
1485 install_rpath : rootlibexecdir,
1487 public_programs += [exe]
1489 executable('systemd-journald',
1490 systemd_journald_sources,
1491 include_directories : includes,
1492 link_with : [libjournal_core,
1494 dependencies : [threads,
1498 install_rpath : rootlibexecdir,
1500 install_dir : rootlibexecdir)
1502 exe = executable('systemd-cat',
1503 systemd_cat_sources,
1504 include_directories : includes,
1505 link_with : [libjournal_core,
1507 dependencies : [threads],
1508 install_rpath : rootlibexecdir,
1510 public_programs += [exe]
1512 exe = executable('journalctl',
1514 include_directories : includes,
1515 link_with : [libshared],
1516 dependencies : [threads,
1521 install_rpath : rootlibexecdir,
1523 install_dir : rootbindir)
1524 public_programs += [exe]
1526 executable('systemd-getty-generator',
1527 'src/getty-generator/getty-generator.c',
1528 include_directories : includes,
1529 link_with : [libshared],
1530 install_rpath : rootlibexecdir,
1532 install_dir : systemgeneratordir)
1534 executable('systemd-debug-generator',
1535 'src/debug-generator/debug-generator.c',
1536 include_directories : includes,
1537 link_with : [libshared],
1538 install_rpath : rootlibexecdir,
1540 install_dir : systemgeneratordir)
1542 executable('systemd-fstab-generator',
1543 'src/fstab-generator/fstab-generator.c',
1544 'src/core/mount-setup.c',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 install_rpath : rootlibexecdir,
1549 install_dir : systemgeneratordir)
1551 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1552 executable('30-systemd-environment-d-generator',
1553 'src/environment-d-generator/environment-d-generator.c',
1554 include_directories : includes,
1555 link_with : [libshared],
1556 install_rpath : rootlibexecdir,
1558 install_dir : userenvgeneratordir)
1560 meson.add_install_script(meson_make_symlink,
1561 join_paths(sysconfdir, 'environment'),
1562 join_paths(environmentdir, '99-environment.conf'))
1565 if conf.get('ENABLE_HIBERNATE') == 1
1566 executable('systemd-hibernate-resume-generator',
1567 'src/hibernate-resume/hibernate-resume-generator.c',
1568 include_directories : includes,
1569 link_with : [libshared],
1570 install_rpath : rootlibexecdir,
1572 install_dir : systemgeneratordir)
1574 executable('systemd-hibernate-resume',
1575 'src/hibernate-resume/hibernate-resume.c',
1576 include_directories : includes,
1577 link_with : [libshared],
1578 install_rpath : rootlibexecdir,
1580 install_dir : rootlibexecdir)
1583 if conf.get('HAVE_BLKID') == 1
1584 executable('systemd-gpt-auto-generator',
1585 'src/gpt-auto-generator/gpt-auto-generator.c',
1586 'src/basic/blkid-util.h',
1587 include_directories : includes,
1588 link_with : [libshared],
1589 dependencies : libblkid,
1590 install_rpath : rootlibexecdir,
1592 install_dir : systemgeneratordir)
1594 exe = executable('systemd-dissect',
1595 'src/dissect/dissect.c',
1596 include_directories : includes,
1597 link_with : [libshared],
1598 install_rpath : rootlibexecdir,
1600 install_dir : rootlibexecdir)
1601 public_programs += [exe]
1604 if conf.get('ENABLE_RESOLVE') == 1
1605 executable('systemd-resolved',
1606 systemd_resolved_sources,
1607 include_directories : includes,
1608 link_with : [libshared,
1610 libsystemd_resolve_core],
1611 dependencies : [threads,
1615 install_rpath : rootlibexecdir,
1617 install_dir : rootlibexecdir)
1619 exe = executable('systemd-resolve',
1620 systemd_resolve_sources,
1621 include_directories : includes,
1622 link_with : [libshared,
1624 libsystemd_resolve_core],
1625 dependencies : [threads,
1629 install_rpath : rootlibexecdir,
1631 public_programs += [exe]
1634 if conf.get('ENABLE_LOGIND') == 1
1635 executable('systemd-logind',
1636 systemd_logind_sources,
1637 include_directories : includes,
1638 link_with : [liblogind_core,
1640 dependencies : [threads,
1642 install_rpath : rootlibexecdir,
1644 install_dir : rootlibexecdir)
1646 exe = executable('loginctl',
1648 include_directories : includes,
1649 link_with : [libshared],
1650 dependencies : [threads,
1653 install_rpath : rootlibexecdir,
1655 install_dir : rootbindir)
1656 public_programs += [exe]
1658 exe = executable('systemd-inhibit',
1659 'src/login/inhibit.c',
1660 include_directories : includes,
1661 link_with : [libshared],
1662 install_rpath : rootlibexecdir,
1664 install_dir : rootbindir)
1665 public_programs += [exe]
1667 if conf.get('HAVE_PAM') == 1
1668 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1669 pam_systemd = shared_library(
1673 include_directories : includes,
1674 link_args : ['-shared',
1675 '-Wl,--version-script=' + version_script_arg],
1676 link_with : [libsystemd_static,
1678 dependencies : [threads,
1681 link_depends : pam_systemd_sym,
1683 install_dir : pamlibdir)
1685 test('dlopen-pam_systemd',
1687 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1691 if conf.get('HAVE_PAM') == 1
1692 executable('systemd-user-sessions',
1693 'src/user-sessions/user-sessions.c',
1694 include_directories : includes,
1695 link_with : [libshared],
1696 install_rpath : rootlibexecdir,
1698 install_dir : rootlibexecdir)
1701 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1702 exe = executable('bootctl',
1703 'src/boot/bootctl.c',
1704 include_directories : includes,
1705 link_with : [libshared],
1706 dependencies : [libblkid],
1707 install_rpath : rootlibexecdir,
1709 public_programs += [exe]
1712 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1713 include_directories : includes,
1714 link_with : [libshared],
1715 dependencies : [threads],
1716 install_rpath : rootlibexecdir,
1718 public_programs += [exe]
1720 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1721 include_directories : includes,
1722 link_with : [libshared],
1723 dependencies : [threads,
1728 install_rpath : rootlibexecdir,
1730 install_dir : rootbindir)
1731 public_programs += [exe]
1733 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1734 meson.add_install_script(meson_make_symlink,
1735 join_paths(rootbindir, 'systemctl'),
1736 join_paths(rootsbindir, alias))
1739 if conf.get('ENABLE_BACKLIGHT') == 1
1740 executable('systemd-backlight',
1741 'src/backlight/backlight.c',
1742 include_directories : includes,
1743 link_with : [libshared],
1744 install_rpath : rootlibexecdir,
1746 install_dir : rootlibexecdir)
1749 if conf.get('ENABLE_RFKILL') == 1
1750 executable('systemd-rfkill',
1751 'src/rfkill/rfkill.c',
1752 include_directories : includes,
1753 link_with : [libshared],
1754 install_rpath : rootlibexecdir,
1756 install_dir : rootlibexecdir)
1759 executable('systemd-system-update-generator',
1760 'src/system-update-generator/system-update-generator.c',
1761 include_directories : includes,
1762 link_with : [libshared],
1763 install_rpath : rootlibexecdir,
1765 install_dir : systemgeneratordir)
1767 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1768 executable('systemd-cryptsetup',
1769 'src/cryptsetup/cryptsetup.c',
1770 include_directories : includes,
1771 link_with : [libshared],
1772 dependencies : [libcryptsetup],
1773 install_rpath : rootlibexecdir,
1775 install_dir : rootlibexecdir)
1777 executable('systemd-cryptsetup-generator',
1778 'src/cryptsetup/cryptsetup-generator.c',
1779 include_directories : includes,
1780 link_with : [libshared],
1781 dependencies : [libcryptsetup],
1782 install_rpath : rootlibexecdir,
1784 install_dir : systemgeneratordir)
1786 executable('systemd-veritysetup',
1787 'src/veritysetup/veritysetup.c',
1788 include_directories : includes,
1789 link_with : [libshared],
1790 dependencies : [libcryptsetup],
1791 install_rpath : rootlibexecdir,
1793 install_dir : rootlibexecdir)
1795 executable('systemd-veritysetup-generator',
1796 'src/veritysetup/veritysetup-generator.c',
1797 include_directories : includes,
1798 link_with : [libshared],
1799 dependencies : [libcryptsetup],
1800 install_rpath : rootlibexecdir,
1802 install_dir : systemgeneratordir)
1805 if conf.get('HAVE_SYSV_COMPAT') == 1
1806 executable('systemd-sysv-generator',
1807 'src/sysv-generator/sysv-generator.c',
1808 include_directories : includes,
1809 link_with : [libshared],
1810 install_rpath : rootlibexecdir,
1812 install_dir : systemgeneratordir)
1814 executable('systemd-rc-local-generator',
1815 'src/rc-local-generator/rc-local-generator.c',
1816 include_directories : includes,
1817 link_with : [libshared],
1818 install_rpath : rootlibexecdir,
1820 install_dir : systemgeneratordir)
1823 if conf.get('ENABLE_HOSTNAMED') == 1
1824 executable('systemd-hostnamed',
1825 'src/hostname/hostnamed.c',
1826 include_directories : includes,
1827 link_with : [libshared],
1828 install_rpath : rootlibexecdir,
1830 install_dir : rootlibexecdir)
1832 exe = executable('hostnamectl',
1833 'src/hostname/hostnamectl.c',
1834 include_directories : includes,
1835 link_with : [libshared],
1836 install_rpath : rootlibexecdir,
1838 public_programs += [exe]
1841 if conf.get('ENABLE_LOCALED') == 1
1842 if conf.get('HAVE_XKBCOMMON') == 1
1843 # logind will load libxkbcommon.so dynamically on its own
1849 executable('systemd-localed',
1850 systemd_localed_sources,
1851 include_directories : includes,
1852 link_with : [libshared],
1853 dependencies : deps,
1854 install_rpath : rootlibexecdir,
1856 install_dir : rootlibexecdir)
1858 exe = executable('localectl',
1860 include_directories : includes,
1861 link_with : [libshared],
1862 install_rpath : rootlibexecdir,
1864 public_programs += [exe]
1867 if conf.get('ENABLE_TIMEDATED') == 1
1868 executable('systemd-timedated',
1869 'src/timedate/timedated.c',
1870 include_directories : includes,
1871 link_with : [libshared],
1872 install_rpath : rootlibexecdir,
1874 install_dir : rootlibexecdir)
1876 exe = executable('timedatectl',
1877 'src/timedate/timedatectl.c',
1878 include_directories : includes,
1879 install_rpath : rootlibexecdir,
1880 link_with : [libshared],
1882 public_programs += [exe]
1885 if conf.get('ENABLE_TIMESYNCD') == 1
1886 executable('systemd-timesyncd',
1887 systemd_timesyncd_sources,
1888 include_directories : includes,
1889 link_with : [libshared],
1890 dependencies : [threads,
1892 install_rpath : rootlibexecdir,
1894 install_dir : rootlibexecdir)
1897 if conf.get('ENABLE_MACHINED') == 1
1898 executable('systemd-machined',
1899 systemd_machined_sources,
1900 include_directories : includes,
1901 link_with : [libmachine_core,
1903 install_rpath : rootlibexecdir,
1905 install_dir : rootlibexecdir)
1907 exe = executable('machinectl',
1908 'src/machine/machinectl.c',
1909 include_directories : includes,
1910 link_with : [libshared],
1911 dependencies : [threads,
1914 install_rpath : rootlibexecdir,
1916 install_dir : rootbindir)
1917 public_programs += [exe]
1920 if conf.get('ENABLE_IMPORTD') == 1
1921 executable('systemd-importd',
1922 systemd_importd_sources,
1923 include_directories : includes,
1924 link_with : [libshared],
1925 dependencies : [threads],
1926 install_rpath : rootlibexecdir,
1928 install_dir : rootlibexecdir)
1930 systemd_pull = executable('systemd-pull',
1931 systemd_pull_sources,
1932 include_directories : includes,
1933 link_with : [libshared],
1934 dependencies : [libcurl,
1939 install_rpath : rootlibexecdir,
1941 install_dir : rootlibexecdir)
1943 systemd_import = executable('systemd-import',
1944 systemd_import_sources,
1945 include_directories : includes,
1946 link_with : [libshared],
1947 dependencies : [libcurl,
1951 install_rpath : rootlibexecdir,
1953 install_dir : rootlibexecdir)
1955 systemd_export = executable('systemd-export',
1956 systemd_export_sources,
1957 include_directories : includes,
1958 link_with : [libshared],
1959 dependencies : [libcurl,
1963 install_rpath : rootlibexecdir,
1965 install_dir : rootlibexecdir)
1966 public_programs += [systemd_pull, systemd_import, systemd_export]
1969 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1970 exe = executable('systemd-journal-upload',
1971 systemd_journal_upload_sources,
1972 include_directories : includes,
1973 link_with : [libshared],
1974 dependencies : [threads,
1979 install_rpath : rootlibexecdir,
1981 install_dir : rootlibexecdir)
1982 public_programs += [exe]
1985 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1986 s_j_remote = executable('systemd-journal-remote',
1987 systemd_journal_remote_sources,
1988 include_directories : includes,
1989 link_with : [libshared],
1990 dependencies : [threads,
1995 install_rpath : rootlibexecdir,
1997 install_dir : rootlibexecdir)
1999 s_j_gatewayd = executable('systemd-journal-gatewayd',
2000 systemd_journal_gatewayd_sources,
2001 include_directories : includes,
2002 link_with : [libshared],
2003 dependencies : [threads,
2008 install_rpath : rootlibexecdir,
2010 install_dir : rootlibexecdir)
2011 public_programs += [s_j_remote, s_j_gatewayd]
2014 if conf.get('ENABLE_COREDUMP') == 1
2015 executable('systemd-coredump',
2016 systemd_coredump_sources,
2017 include_directories : includes,
2018 link_with : [libshared],
2019 dependencies : [threads,
2024 install_rpath : rootlibexecdir,
2026 install_dir : rootlibexecdir)
2028 exe = executable('coredumpctl',
2029 coredumpctl_sources,
2030 include_directories : includes,
2031 link_with : [libshared],
2032 dependencies : [threads,
2035 install_rpath : rootlibexecdir,
2037 public_programs += [exe]
2040 if conf.get('ENABLE_BINFMT') == 1
2041 exe = executable('systemd-binfmt',
2042 'src/binfmt/binfmt.c',
2043 include_directories : includes,
2044 link_with : [libshared],
2045 install_rpath : rootlibexecdir,
2047 install_dir : rootlibexecdir)
2048 public_programs += [exe]
2050 meson.add_install_script('sh', '-c',
2051 mkdir_p.format(binfmtdir))
2052 meson.add_install_script('sh', '-c',
2053 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2056 if conf.get('ENABLE_VCONSOLE') == 1
2057 executable('systemd-vconsole-setup',
2058 'src/vconsole/vconsole-setup.c',
2059 include_directories : includes,
2060 link_with : [libshared],
2061 install_rpath : rootlibexecdir,
2063 install_dir : rootlibexecdir)
2066 if conf.get('ENABLE_RANDOMSEED') == 1
2067 executable('systemd-random-seed',
2068 'src/random-seed/random-seed.c',
2069 include_directories : includes,
2070 link_with : [libshared],
2071 install_rpath : rootlibexecdir,
2073 install_dir : rootlibexecdir)
2076 if conf.get('ENABLE_FIRSTBOOT') == 1
2077 executable('systemd-firstboot',
2078 'src/firstboot/firstboot.c',
2079 include_directories : includes,
2080 link_with : [libshared],
2081 dependencies : [libcrypt],
2082 install_rpath : rootlibexecdir,
2084 install_dir : rootbindir)
2087 executable('systemd-remount-fs',
2088 'src/remount-fs/remount-fs.c',
2089 'src/core/mount-setup.c',
2090 'src/core/mount-setup.h',
2091 include_directories : includes,
2092 link_with : [libshared],
2093 install_rpath : rootlibexecdir,
2095 install_dir : rootlibexecdir)
2097 executable('systemd-machine-id-setup',
2098 'src/machine-id-setup/machine-id-setup-main.c',
2099 'src/core/machine-id-setup.c',
2100 'src/core/machine-id-setup.h',
2101 include_directories : includes,
2102 link_with : [libshared],
2103 install_rpath : rootlibexecdir,
2105 install_dir : rootbindir)
2107 executable('systemd-fsck',
2109 include_directories : includes,
2110 link_with : [libshared],
2111 install_rpath : rootlibexecdir,
2113 install_dir : rootlibexecdir)
2115 executable('systemd-growfs',
2116 'src/partition/growfs.c',
2117 include_directories : includes,
2118 link_with : [libshared],
2119 dependencies : [libcryptsetup],
2120 install_rpath : rootlibexecdir,
2122 install_dir : rootlibexecdir)
2124 executable('systemd-makefs',
2125 'src/partition/makefs.c',
2126 include_directories : includes,
2127 link_with : [libshared],
2128 install_rpath : rootlibexecdir,
2130 install_dir : rootlibexecdir)
2132 executable('systemd-sleep',
2133 'src/sleep/sleep.c',
2134 include_directories : includes,
2135 link_with : [libshared],
2136 install_rpath : rootlibexecdir,
2138 install_dir : rootlibexecdir)
2140 exe = executable('systemd-sysctl',
2141 'src/sysctl/sysctl.c',
2142 include_directories : includes,
2143 link_with : [libshared],
2144 install_rpath : rootlibexecdir,
2146 install_dir : rootlibexecdir)
2147 public_programs += [exe]
2149 executable('systemd-ac-power',
2150 'src/ac-power/ac-power.c',
2151 include_directories : includes,
2152 link_with : [libshared],
2153 install_rpath : rootlibexecdir,
2155 install_dir : rootlibexecdir)
2157 exe = executable('systemd-detect-virt',
2158 'src/detect-virt/detect-virt.c',
2159 include_directories : includes,
2160 link_with : [libshared],
2161 install_rpath : rootlibexecdir,
2163 public_programs += [exe]
2165 exe = executable('systemd-delta',
2166 'src/delta/delta.c',
2167 include_directories : includes,
2168 link_with : [libshared],
2169 install_rpath : rootlibexecdir,
2171 public_programs += [exe]
2173 exe = executable('systemd-escape',
2174 'src/escape/escape.c',
2175 include_directories : includes,
2176 link_with : [libshared],
2177 install_rpath : rootlibexecdir,
2179 install_dir : rootbindir)
2180 public_programs += [exe]
2182 exe = executable('systemd-notify',
2183 'src/notify/notify.c',
2184 include_directories : includes,
2185 link_with : [libshared],
2186 install_rpath : rootlibexecdir,
2188 install_dir : rootbindir)
2189 public_programs += [exe]
2191 executable('systemd-volatile-root',
2192 'src/volatile-root/volatile-root.c',
2193 include_directories : includes,
2194 link_with : [libshared],
2195 install_rpath : rootlibexecdir,
2197 install_dir : rootlibexecdir)
2199 executable('systemd-cgroups-agent',
2200 'src/cgroups-agent/cgroups-agent.c',
2201 include_directories : includes,
2202 link_with : [libshared],
2203 install_rpath : rootlibexecdir,
2205 install_dir : rootlibexecdir)
2207 exe = executable('systemd-path',
2209 include_directories : includes,
2210 link_with : [libshared],
2211 install_rpath : rootlibexecdir,
2213 public_programs += [exe]
2215 exe = executable('systemd-ask-password',
2216 'src/ask-password/ask-password.c',
2217 include_directories : includes,
2218 link_with : [libshared],
2219 install_rpath : rootlibexecdir,
2221 install_dir : rootbindir)
2222 public_programs += [exe]
2224 executable('systemd-reply-password',
2225 'src/reply-password/reply-password.c',
2226 include_directories : includes,
2227 link_with : [libshared],
2228 install_rpath : rootlibexecdir,
2230 install_dir : rootlibexecdir)
2232 exe = executable('systemd-tty-ask-password-agent',
2233 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2234 include_directories : includes,
2235 link_with : [libshared],
2236 install_rpath : rootlibexecdir,
2238 install_dir : rootbindir)
2239 public_programs += [exe]
2241 exe = executable('systemd-cgls',
2243 include_directories : includes,
2244 link_with : [libshared],
2245 install_rpath : rootlibexecdir,
2247 public_programs += [exe]
2249 exe = executable('systemd-cgtop',
2250 'src/cgtop/cgtop.c',
2251 include_directories : includes,
2252 link_with : [libshared],
2253 install_rpath : rootlibexecdir,
2255 public_programs += [exe]
2257 executable('systemd-initctl',
2258 'src/initctl/initctl.c',
2259 include_directories : includes,
2260 link_with : [libshared],
2261 install_rpath : rootlibexecdir,
2263 install_dir : rootlibexecdir)
2265 exe = executable('systemd-mount',
2266 'src/mount/mount-tool.c',
2267 include_directories : includes,
2268 link_with : [libshared],
2269 install_rpath : rootlibexecdir,
2271 public_programs += [exe]
2273 meson.add_install_script(meson_make_symlink,
2274 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2276 exe = executable('systemd-run',
2278 include_directories : includes,
2279 link_with : [libshared],
2280 install_rpath : rootlibexecdir,
2282 public_programs += [exe]
2284 exe = executable('systemd-stdio-bridge',
2285 'src/stdio-bridge/stdio-bridge.c',
2286 include_directories : includes,
2287 link_with : [libshared],
2288 install_rpath : rootlibexecdir,
2290 public_programs += [exe]
2292 exe = executable('busctl',
2293 'src/busctl/busctl.c',
2294 'src/busctl/busctl-introspect.c',
2295 'src/busctl/busctl-introspect.h',
2296 include_directories : includes,
2297 link_with : [libshared],
2298 install_rpath : rootlibexecdir,
2300 public_programs += [exe]
2302 if conf.get('ENABLE_SYSUSERS') == 1
2303 exe = executable('systemd-sysusers',
2304 'src/sysusers/sysusers.c',
2305 include_directories : includes,
2306 link_with : [libshared],
2307 install_rpath : rootlibexecdir,
2309 install_dir : rootbindir)
2310 public_programs += [exe]
2313 if conf.get('ENABLE_TMPFILES') == 1
2314 exe = executable('systemd-tmpfiles',
2315 'src/tmpfiles/tmpfiles.c',
2316 include_directories : includes,
2317 link_with : [libshared],
2318 dependencies : [libacl],
2319 install_rpath : rootlibexecdir,
2321 install_dir : rootbindir)
2322 public_programs += [exe]
2324 test('test-systemd-tmpfiles',
2325 test_systemd_tmpfiles_py,
2326 args : exe.full_path())
2327 # https://github.com/mesonbuild/meson/issues/2681
2330 if conf.get('ENABLE_HWDB') == 1
2331 exe = executable('systemd-hwdb',
2333 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2334 include_directories : includes,
2335 link_with : [libudev_static],
2336 install_rpath : udev_rpath,
2338 install_dir : rootbindir)
2339 public_programs += [exe]
2342 if conf.get('ENABLE_QUOTACHECK') == 1
2343 executable('systemd-quotacheck',
2344 'src/quotacheck/quotacheck.c',
2345 include_directories : includes,
2346 link_with : [libshared],
2347 install_rpath : rootlibexecdir,
2349 install_dir : rootlibexecdir)
2352 exe = executable('systemd-socket-proxyd',
2353 'src/socket-proxy/socket-proxyd.c',
2354 include_directories : includes,
2355 link_with : [libshared],
2356 dependencies : [threads],
2357 install_rpath : rootlibexecdir,
2359 install_dir : rootlibexecdir)
2360 public_programs += [exe]
2362 exe = executable('systemd-udevd',
2363 systemd_udevd_sources,
2364 include_directories : includes,
2365 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2366 link_with : [libudev_core,
2369 dependencies : [threads,
2374 install_rpath : udev_rpath,
2376 install_dir : rootlibexecdir)
2377 public_programs += [exe]
2379 exe = executable('udevadm',
2381 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2382 include_directories : includes,
2383 link_with : [libudev_core,
2386 dependencies : [threads,
2391 install_rpath : udev_rpath,
2393 install_dir : rootbindir)
2394 public_programs += [exe]
2396 executable('systemd-shutdown',
2397 systemd_shutdown_sources,
2398 include_directories : includes,
2399 link_with : [libshared],
2400 install_rpath : rootlibexecdir,
2402 install_dir : rootlibexecdir)
2404 executable('systemd-update-done',
2405 'src/update-done/update-done.c',
2406 include_directories : includes,
2407 link_with : [libshared],
2408 install_rpath : rootlibexecdir,
2410 install_dir : rootlibexecdir)
2412 executable('systemd-update-utmp',
2413 'src/update-utmp/update-utmp.c',
2414 include_directories : includes,
2415 link_with : [libshared],
2416 dependencies : [libaudit],
2417 install_rpath : rootlibexecdir,
2419 install_dir : rootlibexecdir)
2421 if conf.get('HAVE_KMOD') == 1
2422 executable('systemd-modules-load',
2423 'src/modules-load/modules-load.c',
2424 include_directories : includes,
2425 link_with : [libshared],
2426 dependencies : [libkmod],
2427 install_rpath : rootlibexecdir,
2429 install_dir : rootlibexecdir)
2431 meson.add_install_script('sh', '-c',
2432 mkdir_p.format(modulesloaddir))
2433 meson.add_install_script('sh', '-c',
2434 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2437 exe = executable('systemd-nspawn',
2438 systemd_nspawn_sources,
2439 'src/core/mount-setup.c', # FIXME: use a variable?
2440 'src/core/mount-setup.h',
2441 'src/core/loopback-setup.c',
2442 'src/core/loopback-setup.h',
2443 include_directories : [includes, include_directories('src/nspawn')],
2444 link_with : [libshared],
2445 dependencies : [libacl,
2449 install_rpath : rootlibexecdir,
2451 public_programs += [exe]
2453 if conf.get('ENABLE_NETWORKD') == 1
2454 executable('systemd-networkd',
2455 systemd_networkd_sources,
2456 include_directories : includes,
2457 link_with : [libnetworkd_core,
2461 dependencies : [threads],
2462 install_rpath : rootlibexecdir,
2464 install_dir : rootlibexecdir)
2466 executable('systemd-networkd-wait-online',
2467 systemd_networkd_wait_online_sources,
2468 include_directories : includes,
2469 link_with : [libnetworkd_core,
2471 install_rpath : rootlibexecdir,
2473 install_dir : rootlibexecdir)
2475 exe = executable('networkctl',
2477 include_directories : includes,
2478 link_with : [libsystemd_network,
2480 install_rpath : rootlibexecdir,
2482 install_dir : rootbindir)
2483 public_programs += [exe]
2486 executable('systemd-sulogin-shell',
2487 ['src/sulogin-shell/sulogin-shell.c'],
2488 include_directories : includes,
2489 link_with : [libshared],
2490 install_rpath : rootlibexecdir,
2492 install_dir : rootlibexecdir)
2494 ############################################################
2496 foreach tuple : tests
2498 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2499 dependencies = tuple[2]
2500 condition = tuple.length() >= 4 ? tuple[3] : ''
2501 type = tuple.length() >= 5 ? tuple[4] : ''
2502 defs = tuple.length() >= 6 ? tuple[5] : []
2503 incs = tuple.length() >= 7 ? tuple[6] : includes
2506 name = sources[0].split('/')[-1].split('.')[0]
2507 if type.startswith('timeout=')
2508 timeout = type.split('=')[1].to_int()
2511 if want_tests == 'false'
2512 message('Not compiling @0@ because tests is set to false'.format(name))
2513 elif condition == '' or conf.get(condition) == 1
2517 include_directories : incs,
2518 link_with : link_with,
2519 dependencies : dependencies,
2521 install_rpath : rootlibexecdir,
2522 install : install_tests,
2523 install_dir : join_paths(testsdir, type))
2526 message('@0@ is a manual test'.format(name))
2527 elif type == 'unsafe' and want_tests != 'unsafe'
2528 message('@0@ is an unsafe test'.format(name))
2535 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2539 test_libsystemd_sym = executable(
2540 'test-libsystemd-sym',
2541 test_libsystemd_sym_c,
2542 include_directories : includes,
2543 link_with : [libsystemd],
2544 install : install_tests,
2545 install_dir : testsdir)
2546 test('test-libsystemd-sym',
2547 test_libsystemd_sym)
2549 test_libudev_sym = executable(
2552 include_directories : includes,
2553 c_args : ['-Wno-deprecated-declarations'],
2554 link_with : [libudev],
2555 install : install_tests,
2556 install_dir : testsdir)
2557 test('test-libudev-sym',
2560 ############################################################
2564 foreach tuple : fuzzers
2566 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2567 dependencies = tuple[2]
2568 defs = tuple.length() >= 4 ? tuple[3] : []
2569 incs = tuple.length() >= 5 ? tuple[4] : includes
2572 dependencies += fuzzing_engine
2574 sources += 'src/fuzz/fuzz-main.c'
2577 name = sources[0].split('/')[-1].split('.')[0]
2579 fuzzer_exes += executable(
2582 include_directories : [incs, include_directories('src/fuzz')],
2583 link_with : link_with,
2584 dependencies : dependencies,
2589 run_target('fuzzers',
2590 depends : fuzzer_exes,
2593 ############################################################
2595 make_directive_index_py = find_program('tools/make-directive-index.py')
2596 make_man_index_py = find_program('tools/make-man-index.py')
2597 xml_helper_py = find_program('tools/xml_helper.py')
2598 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2602 subdir('sysusers.d')
2603 subdir('tmpfiles.d')
2608 subdir('shell-completion/bash')
2609 subdir('shell-completion/zsh')
2610 subdir('docs/sysvinit')
2611 subdir('docs/var-log')
2613 # FIXME: figure out if the warning is true:
2614 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2615 install_subdir('factory/etc',
2616 install_dir : factorydir)
2619 install_data('xorg/50-systemd-user.sh',
2620 install_dir : xinitrcdir)
2621 install_data('modprobe.d/systemd.conf',
2622 install_dir : modprobedir)
2623 install_data('LICENSE.GPL2',
2628 'doc/DISTRO_PORTING',
2629 'doc/ENVIRONMENT.md',
2631 'doc/TRANSIENT-SETTINGS.md',
2634 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2635 install_dir : docdir)
2637 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2638 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2640 ############################################################
2642 meson_check_help = find_program('tools/meson-check-help.sh')
2644 foreach exec : public_programs
2645 name = exec.full_path().split('/')[-1]
2646 test('check-help-' + name,
2648 args : [exec.full_path()])
2651 ############################################################
2654 foreach p : fuzz_regression_tests
2655 a = p.split('/')[-3]
2656 b = p.split('/')[-2]
2657 c = p.split('/')[-1]
2660 build = sanitize_address
2662 error('unknown sanitizer @0@'.format(a))
2665 name = '@1@:@0@'.format(a, b)
2668 if want_tests == 'false'
2669 message('Not compiling @0@ because tests is set to false'.format(name))
2670 elif not sanitizers.contains(a)
2671 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2673 exe = custom_target(
2677 command : [env, 'ln', '-fs',
2678 join_paths(build.full_path(), b),
2680 build_by_default : true)
2682 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2687 if want_tests != 'false' and slow_tests
2688 test(c, env, args : [exe.full_path(),
2689 join_paths(meson.source_root(),
2690 'test/fuzz-regressions',
2695 ############################################################
2698 all_files = run_command(
2700 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2703 all_files = files(all_files.stdout().split())
2708 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2712 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2716 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2719 command : [meson_git_contrib_sh])
2723 git_head = run_command(
2725 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2726 'rev-parse', 'HEAD']).stdout().strip()
2727 git_head_short = run_command(
2729 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2730 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2734 command : ['git', 'archive',
2735 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2737 '--prefix', 'systemd-@0@/'.format(git_head),
2741 ############################################################
2743 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2746 depends : [man, libsystemd, libudev],
2747 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2749 ############################################################
2752 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2754 'split /usr: @0@'.format(split_usr),
2755 'split bin-sbin: @0@'.format(split_bin),
2756 'prefix directory: @0@'.format(prefixdir),
2757 'rootprefix directory: @0@'.format(rootprefixdir),
2758 'sysconf directory: @0@'.format(sysconfdir),
2759 'include directory: @0@'.format(includedir),
2760 'lib directory: @0@'.format(libdir),
2761 'rootlib directory: @0@'.format(rootlibdir),
2762 'SysV init scripts: @0@'.format(sysvinit_path),
2763 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2764 'PAM modules directory: @0@'.format(pamlibdir),
2765 'PAM configuration directory: @0@'.format(pamconfdir),
2766 'RPM macros directory: @0@'.format(rpmmacrosdir),
2767 'modprobe.d directory: @0@'.format(modprobedir),
2768 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2769 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2770 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2771 'bash completions directory: @0@'.format(bashcompletiondir),
2772 'zsh completions directory: @0@'.format(zshcompletiondir),
2773 'extra start script: @0@'.format(get_option('rc-local')),
2774 'extra stop script: @0@'.format(get_option('halt-local')),
2775 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2776 get_option('debug-tty')),
2777 'TTY GID: @0@'.format(tty_gid),
2778 'users GID: @0@'.format(users_gid),
2779 'maximum system UID: @0@'.format(system_uid_max),
2780 'maximum system GID: @0@'.format(system_gid_max),
2781 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2782 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2783 'minimum container UID base: @0@'.format(container_uid_base_min),
2784 'maximum container UID base: @0@'.format(container_uid_base_max),
2785 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2786 'render group access mode: @0@'.format(get_option('group-render-mode')),
2787 'certificate root directory: @0@'.format(get_option('certificate-root')),
2788 'support URL: @0@'.format(support_url),
2789 'nobody user name: @0@'.format(nobody_user),
2790 'nobody group name: @0@'.format(nobody_group),
2791 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2792 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2794 'default DNSSEC mode: @0@'.format(default_dnssec),
2795 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2796 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2798 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2799 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2801 'default DNS servers: @0@'.format(alt_dns_servers),
2802 'default NTP servers: @0@'.format(alt_ntp_servers)]
2804 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2805 '@@0@'.format(time_epoch)).stdout().strip()
2807 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2810 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2811 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2812 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2814 if conf.get('ENABLE_EFI') == 1
2816 'efi arch: @0@'.format(efi_arch)]
2820 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2821 'EFI CC @0@'.format(efi_cc),
2822 'EFI lib directory: @0@'.format(efi_libdir),
2823 'EFI lds directory: @0@'.format(efi_ldsdir),
2824 'EFI include directory: @0@'.format(efi_incdir)]
2877 ['legacy pkla', install_polkit_pkla],
2879 ['gnu-efi', have_gnu_efi],
2886 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2889 ['man pages', want_man],
2890 ['html pages', want_html],
2891 ['man page indices', want_man and have_lxml],
2896 ['adm group', get_option('adm-group')],
2897 ['wheel group', get_option('wheel-group')],
2900 ['debug mmap cache'],
2903 cond = tuple.get(1, '')
2905 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2906 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2907 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2912 missing += [tuple[0]]
2918 'enabled features: @0@'.format(', '.join(found)),
2920 'disabled features: @0@'.format(', '.join(missing)),
2922 message('\n '.join(status))
2924 if rootprefixdir != rootprefix_default
2925 message('WARNING:\n' +
2926 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2927 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2928 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))