1 # SPDX-License-Identifier: LGPL-2.1+
3 # Copyright 2017 Zbigniew Jędrzejewski-Szmek
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 project('systemd', 'c',
27 meson_version : '>= 0.41',
30 libsystemd_version = '0.21.0'
31 libudev_version = '1.6.9'
33 # We need the same data in three different formats, ugh!
34 # Also, for hysterical reasons, we use different variable
35 # names, sometimes. Not all variables are included in every
37 conf = configuration_data()
38 conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
39 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
41 substs = configuration_data()
42 substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
43 substs.set('PACKAGE_VERSION', meson.project_version())
47 #####################################################################
49 # Try to install the git pre-commit hook
50 git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
51 if git_hook.returncode() == 0
52 message(git_hook.stdout().strip())
55 #####################################################################
57 split_usr = get_option('split-usr')
58 conf.set10('HAVE_SPLIT_USR', split_usr)
60 rootprefixdir = get_option('rootprefix')
61 # Unusual rootprefixdir values are used by some distros
62 # (see https://github.com/systemd/systemd/pull/7461).
63 rootprefix_default = get_option('split-usr') ? '/' : '/usr'
64 if rootprefixdir == ''
65 rootprefixdir = rootprefix_default
68 sysvinit_path = get_option('sysvinit-path')
69 sysvrcnd_path = get_option('sysvrcnd-path')
70 have = sysvinit_path != '' and sysvrcnd_path != ''
71 conf.set10('HAVE_SYSV_COMPAT', have,
72 description : 'SysV init scripts and rcN.d links are supported')
73 m4_defines += have ? ['-DHAVE_SYSV_COMPAT'] : []
75 # join_paths ignore the preceding arguments if an absolute component is
76 # encountered, so this should canonicalize various paths when they are
77 # absolute or relative.
78 prefixdir = get_option('prefix')
79 if not prefixdir.startswith('/')
80 error('Prefix is not absolute: "@0@"'.format(prefixdir))
82 bindir = join_paths(prefixdir, get_option('bindir'))
83 libdir = join_paths(prefixdir, get_option('libdir'))
84 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
85 includedir = join_paths(prefixdir, get_option('includedir'))
86 datadir = join_paths(prefixdir, get_option('datadir'))
87 localstatedir = join_paths('/', get_option('localstatedir'))
89 rootbindir = join_paths(rootprefixdir, 'bin')
90 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
92 rootlibdir = get_option('rootlibdir')
94 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
97 # Dirs of external packages
98 pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
99 pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
100 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
101 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
102 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
103 varlogdir = join_paths(localstatedir, 'log')
104 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
105 rpmmacrosdir = get_option('rpmmacrosdir')
106 if rpmmacrosdir != 'no'
107 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
109 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
112 pkgdatadir = join_paths(datadir, 'systemd')
113 environmentdir = join_paths(prefixdir, 'lib/environment.d')
114 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
115 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
116 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
117 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
118 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
119 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
120 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
121 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
122 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
123 pkgincludedir = join_paths(includedir, 'systemd')
124 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
125 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
126 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
127 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
128 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
129 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
130 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
131 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
132 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
133 udevhomedir = udevlibexecdir
134 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
135 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
136 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
137 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
138 factorydir = join_paths(datadir, 'factory')
139 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
140 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
141 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
142 catalogstatedir = join_paths(systemdstatedir, 'catalog')
143 randomseeddir = join_paths(localstatedir, 'lib/systemd')
145 docdir = get_option('docdir')
147 docdir = join_paths(datadir, 'doc/systemd')
150 dbuspolicydir = get_option('dbuspolicydir')
151 if dbuspolicydir == ''
152 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
155 dbussessionservicedir = get_option('dbussessionservicedir')
156 if dbussessionservicedir == ''
157 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
160 dbussystemservicedir = get_option('dbussystemservicedir')
161 if dbussystemservicedir == ''
162 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
165 pamlibdir = get_option('pamlibdir')
167 pamlibdir = join_paths(rootlibdir, 'security')
170 pamconfdir = get_option('pamconfdir')
172 pamconfdir = join_paths(sysconfdir, 'pam.d')
175 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
176 conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
177 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
178 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
179 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
180 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
181 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
182 conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
183 conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
184 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
185 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
186 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
187 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
188 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
189 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
190 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
191 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
192 conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
193 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
194 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
195 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
196 conf.set_quoted('ROOTPREFIX', rootprefixdir)
197 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
198 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
199 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
200 conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
201 conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
202 conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
203 conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
204 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
205 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
206 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
207 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
208 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
209 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
210 conf.set_quoted('LIBDIR', libdir)
211 conf.set_quoted('ROOTLIBDIR', rootlibdir)
212 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
213 conf.set_quoted('BOOTLIBDIR', bootlibdir)
214 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
215 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
216 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
217 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
218 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
219 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
221 conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
222 conf.set_quoted('ABS_SRC_DIR', meson.source_root())
224 substs.set('prefix', prefixdir)
225 substs.set('exec_prefix', prefixdir)
226 substs.set('libdir', libdir)
227 substs.set('rootlibdir', rootlibdir)
228 substs.set('includedir', includedir)
229 substs.set('pkgsysconfdir', pkgsysconfdir)
230 substs.set('bindir', bindir)
231 substs.set('rootbindir', rootbindir)
232 substs.set('rootlibexecdir', rootlibexecdir)
233 substs.set('systemunitdir', systemunitdir)
234 substs.set('userunitdir', userunitdir)
235 substs.set('systempresetdir', systempresetdir)
236 substs.set('userpresetdir', userpresetdir)
237 substs.set('udevhwdbdir', udevhwdbdir)
238 substs.set('udevrulesdir', udevrulesdir)
239 substs.set('udevlibexecdir', udevlibexecdir)
240 substs.set('catalogdir', catalogdir)
241 substs.set('tmpfilesdir', tmpfilesdir)
242 substs.set('sysusersdir', sysusersdir)
243 substs.set('sysctldir', sysctldir)
244 substs.set('binfmtdir', binfmtdir)
245 substs.set('modulesloaddir', modulesloaddir)
246 substs.set('systemgeneratordir', systemgeneratordir)
247 substs.set('usergeneratordir', usergeneratordir)
248 substs.set('systemenvgeneratordir', systemenvgeneratordir)
249 substs.set('userenvgeneratordir', userenvgeneratordir)
250 substs.set('systemshutdowndir', systemshutdowndir)
251 substs.set('systemsleepdir', systemsleepdir)
252 substs.set('VARLOGDIR', varlogdir)
253 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
254 substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
255 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
256 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
257 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
258 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
259 substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
261 #####################################################################
263 cc = meson.get_compiler('c')
264 pkgconfig = import('pkgconfig')
265 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
266 meson_build_sh = find_program('tools/meson-build.sh')
268 if get_option('tests') != 'false'
269 cxx = find_program('c++', required : false)
271 # Used only for tests
276 want_ossfuzz = get_option('oss-fuzz')
277 want_libfuzzer = get_option('llvm-fuzz')
278 fuzzer_build = want_ossfuzz or want_libfuzzer
279 if want_ossfuzz and want_libfuzzer
280 error('only one of oss-fuzz and llvm-fuzz can be specified')
283 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
286 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
289 foreach arg : ['-Wextra',
292 '-Wmissing-include-dirs',
293 '-Wold-style-definition',
296 '-Wdeclaration-after-statement',
298 '-Wsuggest-attribute=noreturn',
299 '-Werror=missing-prototypes',
300 '-Werror=implicit-function-declaration',
301 '-Werror=missing-declarations',
302 '-Werror=return-type',
303 '-Werror=incompatible-pointer-types',
305 '-Wstrict-prototypes',
307 '-Wmissing-noreturn',
308 '-Wimplicit-fallthrough=5',
311 '-Wstrict-aliasing=2',
318 '-fdiagnostics-show-option',
319 '-fno-strict-aliasing',
320 '-fvisibility=hidden',
322 '-fstack-protector-strong',
323 '--param=ssp-buffer-size=4',
325 if cc.has_argument(arg)
326 add_project_arguments(arg, language : 'c')
330 # the oss-fuzz fuzzers are not built with -fPIE, so don't
331 # enable it when we are linking against them
333 if cc.has_argument('-fPIE')
334 add_project_arguments('-fPIE', language : 'c')
338 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
339 # arguments, just emits a warnings. So test for the "positive" version instead.
340 foreach arg : ['unused-parameter',
341 'missing-field-initializers',
344 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
346 if cc.has_argument('-W' + arg)
347 add_project_arguments('-Wno-' + arg, language : 'c')
353 #include <inttypes.h>
354 typedef uint64_t usec_t;
355 usec_t now(clockid_t clock);
360 ', name : '-Werror=shadow with local shadowing')
361 add_project_arguments('-Werror=shadow', language : 'c')
364 if cc.get_id() == 'clang'
365 foreach arg : ['-Wno-typedef-redefinition',
366 '-Wno-gnu-variable-sized-type-not-at-end',
368 if cc.has_argument(arg,
369 name : '@0@ is supported'.format(arg))
370 add_project_arguments(arg, language : 'c')
375 link_test_c = files('tools/meson-link-test.c')
377 # --as-needed and --no-undefined are provided by meson by default,
378 # run mesonconf to see what is enabled
379 foreach arg : ['-Wl,-z,relro',
384 have = run_command(check_compilation_sh,
385 cc.cmd_array(), '-x', 'c', arg,
386 '-include', link_test_c).returncode() == 0
387 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
388 if have and (arg != '-pie' or not fuzzer_build)
389 add_project_link_arguments(arg, language : 'c')
393 # Check if various sanitizers are supported
395 foreach arg : ['address']
397 have = run_command(check_compilation_sh,
398 cc.cmd_array(), '-x', 'c',
399 '-fsanitize=@0@'.format(arg),
400 '-include', link_test_c).returncode() == 0
401 message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
407 if get_option('buildtype') != 'debug'
408 foreach arg : ['-ffunction-sections',
410 if cc.has_argument(arg,
411 name : '@0@ is supported'.format(arg))
412 add_project_arguments(arg, language : 'c')
416 foreach arg : ['-Wl,--gc-sections']
417 have = run_command(check_compilation_sh,
418 cc.cmd_array(), '-x', 'c', arg,
419 '-include', link_test_c).returncode() == 0
420 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
422 add_project_link_arguments(arg, language : 'c')
427 cpp = ' '.join(cc.cmd_array()) + ' -E'
429 #####################################################################
430 # compilation result tests
432 conf.set('_GNU_SOURCE', true)
433 conf.set('__SANE_USERSPACE_TYPES__', true)
435 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
436 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
437 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
438 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
439 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
440 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
441 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
445 #include <linux/ethtool.h>
446 #include <linux/fib_rules.h>
448 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
450 foreach decl : ['char16_t',
453 'struct ethtool_link_settings',
454 'struct fib_rule_uid_range',
457 # We get -1 if the size cannot be determined
458 have = cc.sizeof(decl, prefix : decl_headers) > 0
459 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
462 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
463 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
464 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
465 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
466 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
467 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
468 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
469 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
470 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
471 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
472 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
473 # if_tunnel.h is buggy and cannot be included on its own
474 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
475 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
476 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
477 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
478 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
479 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
480 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
481 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
482 ['NDA_IFINDEX', 'linux/neighbour.h'],
483 ['IFA_FLAGS', 'linux/if_addr.h'],
484 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
485 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
486 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
488 prefix = decl.length() > 2 ? decl[2] : ''
489 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
490 conf.set10('HAVE_' + decl[0], have)
493 foreach ident : ['secure_getenv', '__secure_getenv']
494 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
498 ['memfd_create', '''#include <sys/mman.h>'''],
499 ['gettid', '''#include <sys/types.h>
500 #include <unistd.h>'''],
501 ['pivot_root', '''#include <stdlib.h>
502 #include <unistd.h>'''], # no known header declares pivot_root
503 ['name_to_handle_at', '''#include <sys/types.h>
504 #include <sys/stat.h>
505 #include <fcntl.h>'''],
506 ['setns', '''#include <sched.h>'''],
507 ['renameat2', '''#include <stdio.h>
508 #include <fcntl.h>'''],
509 ['kcmp', '''#include <linux/kcmp.h>'''],
510 ['keyctl', '''#include <sys/types.h>
511 #include <keyutils.h>'''],
512 ['copy_file_range', '''#include <sys/syscall.h>
513 #include <unistd.h>'''],
514 ['bpf', '''#include <sys/syscall.h>
515 #include <unistd.h>'''],
516 ['explicit_bzero' , '''#include <string.h>'''],
519 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
520 conf.set10('HAVE_' + ident[0].to_upper(), have)
523 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
524 conf.set10('USE_SYS_RANDOM_H', true)
525 conf.set10('HAVE_GETRANDOM', true)
527 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
528 conf.set10('USE_SYS_RANDOM_H', false)
529 conf.set10('HAVE_GETRANDOM', have)
532 #####################################################################
534 sed = find_program('sed')
535 awk = find_program('awk')
536 m4 = find_program('m4')
537 stat = find_program('stat')
538 git = find_program('git', required : false)
539 env = find_program('env')
541 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
542 mkdir_p = 'mkdir -p $DESTDIR/@0@'
543 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
544 splash_bmp = files('test/splash.bmp')
546 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
547 # /usr/sbin, /sbin, and fall back to the default from middle column.
548 progs = [['quotaon', '/usr/sbin/quotaon' ],
549 ['quotacheck', '/usr/sbin/quotacheck' ],
550 ['kill', '/usr/bin/kill' ],
551 ['kmod', '/usr/bin/kmod' ],
552 ['kexec', '/usr/sbin/kexec' ],
553 ['sulogin', '/usr/sbin/sulogin' ],
554 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
555 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
556 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
557 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
560 path = get_option(prog[0] + '-path')
562 message('Using @1@ for @0@'.format(prog[0], path))
564 exe = find_program(prog[0],
565 '/usr/sbin/' + prog[0],
568 path = exe.found() ? exe.path() : prog[1]
570 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
571 conf.set_quoted(name, path)
572 substs.set(name, path)
575 conf.set_quoted('TELINIT', get_option('telinit-path'))
577 if run_command('ln', '--relative', '--help').returncode() != 0
578 error('ln does not support --relative')
581 ############################################################
583 gperf = find_program('gperf')
585 gperf_test_format = '''
587 const char * in_word_set(const char *, @0@);
590 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
591 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
592 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
593 if cc.compiles(gperf_test)
594 gperf_len_type = 'size_t'
596 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
597 if cc.compiles(gperf_test)
598 gperf_len_type = 'unsigned'
600 error('unable to determine gperf len type')
603 message('gperf len type is @0@'.format(gperf_len_type))
604 conf.set('GPERF_LEN_TYPE', gperf_len_type,
605 description : 'The type of gperf "len" parameter')
607 ############################################################
609 if not cc.has_header('sys/capability.h')
610 error('POSIX caps headers not found')
612 foreach header : ['crypt.h',
615 'linux/vm_sockets.h',
617 'valgrind/memcheck.h',
618 'valgrind/valgrind.h',
621 conf.set10('HAVE_' + header.underscorify().to_upper(),
622 cc.has_header(header))
625 ############################################################
627 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
628 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
629 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
631 default_hierarchy = get_option('default-hierarchy')
632 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
633 description : 'default cgroup hierarchy as string')
634 if default_hierarchy == 'legacy'
635 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
636 elif default_hierarchy == 'hybrid'
637 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
639 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
642 time_epoch = get_option('time-epoch')
645 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
647 time_epoch = time_epoch.to_int()
648 conf.set('TIME_EPOCH', time_epoch)
650 system_uid_max = get_option('system-uid-max')
651 if system_uid_max == ''
652 system_uid_max = run_command(
654 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
655 '/etc/login.defs').stdout()
657 system_uid_max = system_uid_max.to_int()
658 conf.set('SYSTEM_UID_MAX', system_uid_max)
659 substs.set('systemuidmax', system_uid_max)
660 message('maximum system UID is @0@'.format(system_uid_max))
662 system_gid_max = get_option('system-gid-max')
663 if system_gid_max == ''
664 system_gid_max = run_command(
666 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
667 '/etc/login.defs').stdout()
669 system_gid_max = system_gid_max.to_int()
670 conf.set('SYSTEM_GID_MAX', system_gid_max)
671 substs.set('systemgidmax', system_gid_max)
672 message('maximum system GID is @0@'.format(system_gid_max))
674 dynamic_uid_min = get_option('dynamic-uid-min').to_int()
675 dynamic_uid_max = get_option('dynamic-uid-max').to_int()
676 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
677 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
678 substs.set('dynamicuidmin', dynamic_uid_min)
679 substs.set('dynamicuidmax', dynamic_uid_max)
681 container_uid_base_min = get_option('container-uid-base-min').to_int()
682 container_uid_base_max = get_option('container-uid-base-max').to_int()
683 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
684 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
685 substs.set('containeruidbasemin', container_uid_base_min)
686 substs.set('containeruidbasemax', container_uid_base_max)
688 nobody_user = get_option('nobody-user')
689 nobody_group = get_option('nobody-group')
691 getent_result = run_command('getent', 'passwd', '65534')
692 if getent_result.returncode() == 0
693 name = getent_result.stdout().split(':')[0]
694 if name != nobody_user
695 message('WARNING:\n' +
696 ' 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) +
697 ' Your build will result in an user table setup that is incompatible with the local system.')
700 id_result = run_command('id', '-u', nobody_user)
701 if id_result.returncode() == 0
702 id = id_result.stdout().to_int()
704 message('WARNING:\n' +
705 ' 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) +
706 ' Your build will result in an user table setup that is incompatible with the local system.')
710 getent_result = run_command('getent', 'group', '65534')
711 if getent_result.returncode() == 0
712 name = getent_result.stdout().split(':')[0]
713 if name != nobody_group
714 message('WARNING:\n' +
715 ' 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) +
716 ' Your build will result in an group table setup that is incompatible with the local system.')
719 id_result = run_command('id', '-g', nobody_group)
720 if id_result.returncode() == 0
721 id = id_result.stdout().to_int()
723 message('WARNING:\n' +
724 ' 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) +
725 ' Your build will result in an group table setup that is incompatible with the local system.')
728 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
729 message('WARNING:\n' +
730 ' The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
731 ' Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
734 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
735 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
736 substs.set('NOBODY_USER_NAME', nobody_user)
737 substs.set('NOBODY_GROUP_NAME', nobody_group)
739 tty_gid = get_option('tty-gid')
740 conf.set('TTY_GID', tty_gid)
741 substs.set('TTY_GID', tty_gid)
743 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
744 if get_option('users-gid') != ''
745 users_gid = get_option('users-gid').to_int()
749 substs.set('USERS_GID', users_gid)
751 if get_option('adm-group')
752 m4_defines += ['-DENABLE_ADM_GROUP']
755 if get_option('wheel-group')
756 m4_defines += ['-DENABLE_WHEEL_GROUP']
759 substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
760 substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
762 kill_user_processes = get_option('default-kill-user-processes')
763 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
764 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
766 dns_servers = get_option('dns-servers')
767 conf.set_quoted('DNS_SERVERS', dns_servers)
768 substs.set('DNS_SERVERS', dns_servers)
770 ntp_servers = get_option('ntp-servers')
771 conf.set_quoted('NTP_SERVERS', ntp_servers)
772 substs.set('NTP_SERVERS', ntp_servers)
774 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
776 substs.set('SUSHELL', get_option('debug-shell'))
777 substs.set('DEBUGTTY', get_option('debug-tty'))
779 debug = get_option('debug')
780 enable_debug_hashmap = false
781 enable_debug_mmap_cache = false
783 foreach name : debug.split(',')
785 enable_debug_hashmap = true
786 elif name == 'mmap-cache'
787 enable_debug_mmap_cache = true
789 message('unknown debug option "@0@", ignoring'.format(name))
793 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
794 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
796 #####################################################################
798 threads = dependency('threads')
799 librt = cc.find_library('rt')
800 libm = cc.find_library('m')
801 libdl = cc.find_library('dl')
802 libcrypt = cc.find_library('crypt')
804 libcap = dependency('libcap', required : false)
805 if not libcap.found()
806 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
807 libcap = cc.find_library('cap')
810 libmount = dependency('mount',
812 required : not fuzzer_build)
814 want_seccomp = get_option('seccomp')
815 if want_seccomp != 'false' and not fuzzer_build
816 libseccomp = dependency('libseccomp',
817 version : '>= 2.3.1',
818 required : want_seccomp == 'true')
819 have = libseccomp.found()
824 conf.set10('HAVE_SECCOMP', have)
825 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
827 want_selinux = get_option('selinux')
828 if want_selinux != 'false' and not fuzzer_build
829 libselinux = dependency('libselinux',
830 version : '>= 2.1.9',
831 required : want_selinux == 'true')
832 have = libselinux.found()
837 conf.set10('HAVE_SELINUX', have)
838 m4_defines += have ? ['-DHAVE_SELINUX'] : []
840 want_apparmor = get_option('apparmor')
841 if want_apparmor != 'false' and not fuzzer_build
842 libapparmor = dependency('libapparmor',
843 required : want_apparmor == 'true')
844 have = libapparmor.found()
849 conf.set10('HAVE_APPARMOR', have)
850 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
852 smack_run_label = get_option('smack-run-label')
853 if smack_run_label != ''
854 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
855 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
858 want_polkit = get_option('polkit')
859 install_polkit = false
860 install_polkit_pkla = false
861 if want_polkit != 'false' and not fuzzer_build
862 install_polkit = true
864 libpolkit = dependency('polkit-gobject-1',
866 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
867 message('Old polkit detected, will install pkla files')
868 install_polkit_pkla = true
871 conf.set10('ENABLE_POLKIT', install_polkit)
873 want_acl = get_option('acl')
874 if want_acl != 'false' and not fuzzer_build
875 libacl = cc.find_library('acl', required : want_acl == 'true')
876 have = libacl.found()
881 conf.set10('HAVE_ACL', have)
882 m4_defines += have ? ['-DHAVE_ACL'] : []
884 want_audit = get_option('audit')
885 if want_audit != 'false' and not fuzzer_build
886 libaudit = dependency('audit', required : want_audit == 'true')
887 have = libaudit.found()
892 conf.set10('HAVE_AUDIT', have)
894 want_blkid = get_option('blkid')
895 if want_blkid != 'false' and not fuzzer_build
896 libblkid = dependency('blkid', required : want_blkid == 'true')
897 have = libblkid.found()
902 conf.set10('HAVE_BLKID', have)
904 want_kmod = get_option('kmod')
905 if want_kmod != 'false' and not fuzzer_build
906 libkmod = dependency('libkmod',
908 required : want_kmod == 'true')
909 have = libkmod.found()
914 conf.set10('HAVE_KMOD', have)
916 want_pam = get_option('pam')
917 if want_pam != 'false' and not fuzzer_build
918 libpam = cc.find_library('pam', required : want_pam == 'true')
919 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
920 have = libpam.found() and libpam_misc.found()
926 conf.set10('HAVE_PAM', have)
927 m4_defines += have ? ['-DHAVE_PAM'] : []
929 want_microhttpd = get_option('microhttpd')
930 if want_microhttpd != 'false' and not fuzzer_build
931 libmicrohttpd = dependency('libmicrohttpd',
932 version : '>= 0.9.33',
933 required : want_microhttpd == 'true')
934 have = libmicrohttpd.found()
939 conf.set10('HAVE_MICROHTTPD', have)
940 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
942 want_libcryptsetup = get_option('libcryptsetup')
943 if want_libcryptsetup != 'false' and not fuzzer_build
944 libcryptsetup = dependency('libcryptsetup',
945 version : '>= 1.6.0',
946 required : want_libcryptsetup == 'true')
947 have = libcryptsetup.found()
952 conf.set10('HAVE_LIBCRYPTSETUP', have)
954 want_libcurl = get_option('libcurl')
955 if want_libcurl != 'false' and not fuzzer_build
956 libcurl = dependency('libcurl',
957 version : '>= 7.32.0',
958 required : want_libcurl == 'true')
959 have = libcurl.found()
964 conf.set10('HAVE_LIBCURL', have)
965 m4_defines += have ? ['-DHAVE_LIBCURL'] : []
967 want_libidn = get_option('libidn')
968 want_libidn2 = get_option('libidn2')
969 if want_libidn == 'true' and want_libidn2 == 'true'
970 error('libidn and libidn2 cannot be requested simultaneously')
973 if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
974 libidn = dependency('libidn',
975 required : want_libidn == 'true')
976 have = libidn.found()
981 conf.set10('HAVE_LIBIDN', have)
982 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
983 if not have and want_libidn2 != 'false' and not fuzzer_build
984 # libidn is used for both libidn and libidn2 objects
985 libidn = dependency('libidn2',
986 required : want_libidn2 == 'true')
987 have = libidn.found()
991 conf.set10('HAVE_LIBIDN2', have)
992 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
994 want_libiptc = get_option('libiptc')
995 if want_libiptc != 'false' and not fuzzer_build
996 libiptc = dependency('libiptc',
997 required : want_libiptc == 'true')
998 have = libiptc.found()
1003 conf.set10('HAVE_LIBIPTC', have)
1004 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1006 want_qrencode = get_option('qrencode')
1007 if want_qrencode != 'false' and not fuzzer_build
1008 libqrencode = dependency('libqrencode',
1009 required : want_qrencode == 'true')
1010 have = libqrencode.found()
1015 conf.set10('HAVE_QRENCODE', have)
1017 want_gcrypt = get_option('gcrypt')
1018 if want_gcrypt != 'false' and not fuzzer_build
1019 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1020 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1021 have = libgcrypt.found() and libgpg_error.found()
1026 # link to neither of the libs if one is not found
1030 conf.set10('HAVE_GCRYPT', have)
1032 want_gnutls = get_option('gnutls')
1033 if want_gnutls != 'false' and not fuzzer_build
1034 libgnutls = dependency('gnutls',
1035 version : '>= 3.1.4',
1036 required : want_gnutls == 'true')
1037 have = libgnutls.found()
1042 conf.set10('HAVE_GNUTLS', have)
1044 want_elfutils = get_option('elfutils')
1045 if want_elfutils != 'false' and not fuzzer_build
1046 libdw = dependency('libdw',
1047 required : want_elfutils == 'true')
1048 have = libdw.found()
1053 conf.set10('HAVE_ELFUTILS', have)
1055 want_zlib = get_option('zlib')
1056 if want_zlib != 'false' and not fuzzer_build
1057 libz = dependency('zlib',
1058 required : want_zlib == 'true')
1064 conf.set10('HAVE_ZLIB', have)
1066 want_bzip2 = get_option('bzip2')
1067 if want_bzip2 != 'false' and not fuzzer_build
1068 libbzip2 = cc.find_library('bz2',
1069 required : want_bzip2 == 'true')
1070 have = libbzip2.found()
1075 conf.set10('HAVE_BZIP2', have)
1077 want_xz = get_option('xz')
1078 if want_xz != 'false' and not fuzzer_build
1079 libxz = dependency('liblzma',
1080 required : want_xz == 'true')
1081 have = libxz.found()
1086 conf.set10('HAVE_XZ', have)
1088 want_lz4 = get_option('lz4')
1089 if want_lz4 != 'false' and not fuzzer_build
1090 liblz4 = dependency('liblz4',
1091 required : want_lz4 == 'true')
1092 have = liblz4.found()
1097 conf.set10('HAVE_LZ4', have)
1099 want_xkbcommon = get_option('xkbcommon')
1100 if want_xkbcommon != 'false' and not fuzzer_build
1101 libxkbcommon = dependency('xkbcommon',
1102 version : '>= 0.3.0',
1103 required : want_xkbcommon == 'true')
1104 have = libxkbcommon.found()
1109 conf.set10('HAVE_XKBCOMMON', have)
1111 want_pcre2 = get_option('pcre2')
1112 if want_pcre2 != 'false'
1113 libpcre2 = dependency('libpcre2-8',
1114 required : want_pcre2 == 'true')
1115 have = libpcre2.found()
1120 conf.set10('HAVE_PCRE2', have)
1122 want_glib = get_option('glib')
1123 if want_glib != 'false' and not fuzzer_build
1124 libglib = dependency('glib-2.0',
1125 version : '>= 2.22.0',
1126 required : want_glib == 'true')
1127 libgobject = dependency('gobject-2.0',
1128 version : '>= 2.22.0',
1129 required : want_glib == 'true')
1130 libgio = dependency('gio-2.0',
1131 required : want_glib == 'true')
1132 have = libglib.found() and libgobject.found() and libgio.found()
1139 conf.set10('HAVE_GLIB', have)
1141 want_dbus = get_option('dbus')
1142 if want_dbus != 'false' and not fuzzer_build
1143 libdbus = dependency('dbus-1',
1144 version : '>= 1.3.2',
1145 required : want_dbus == 'true')
1146 have = libdbus.found()
1151 conf.set10('HAVE_DBUS', have)
1153 default_dnssec = get_option('default-dnssec')
1155 default_dnssec = 'no'
1157 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1158 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1159 default_dnssec = 'no'
1161 conf.set('DEFAULT_DNSSEC_MODE',
1162 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1163 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1165 want_importd = get_option('importd')
1166 if want_importd != 'false'
1167 have = (conf.get('HAVE_LIBCURL') == 1 and
1168 conf.get('HAVE_ZLIB') == 1 and
1169 conf.get('HAVE_BZIP2') == 1 and
1170 conf.get('HAVE_XZ') == 1 and
1171 conf.get('HAVE_GCRYPT') == 1)
1172 if want_importd == 'true' and not have
1173 error('importd support was requested, but dependencies are not available')
1178 conf.set10('ENABLE_IMPORTD', have)
1180 want_remote = get_option('remote')
1181 if want_remote != 'false'
1182 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1183 conf.get('HAVE_LIBCURL') == 1]
1184 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1185 # it's possible to build one without the other. Complain only if
1186 # support was explictly requested. The auxiliary files like sysusers
1187 # config should be installed when any of the programs are built.
1188 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1189 error('remote support was requested, but dependencies are not available')
1191 have = have_deps[0] or have_deps[1]
1195 conf.set10('ENABLE_REMOTE', have)
1197 foreach term : ['utmp',
1228 have = get_option(term)
1229 name = 'ENABLE_' + term.underscorify().to_upper()
1230 conf.set10(name, have)
1231 m4_defines += have ? ['-D' + name] : []
1234 want_tests = get_option('tests')
1235 install_tests = get_option('install-tests')
1236 slow_tests = get_option('slow-tests')
1240 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1242 #####################################################################
1244 if get_option('efi')
1245 efi_arch = host_machine.cpu_family()
1247 if efi_arch == 'x86'
1248 EFI_MACHINE_TYPE_NAME = 'ia32'
1249 gnu_efi_arch = 'ia32'
1250 elif efi_arch == 'x86_64'
1251 EFI_MACHINE_TYPE_NAME = 'x64'
1252 gnu_efi_arch = 'x86_64'
1253 elif efi_arch == 'arm'
1254 EFI_MACHINE_TYPE_NAME = 'arm'
1255 gnu_efi_arch = 'arm'
1256 elif efi_arch == 'aarch64'
1257 EFI_MACHINE_TYPE_NAME = 'aa64'
1258 gnu_efi_arch = 'aarch64'
1260 EFI_MACHINE_TYPE_NAME = ''
1265 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1267 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1271 conf.set10('ENABLE_EFI', have)
1273 #####################################################################
1275 config_h = configure_file(
1276 output : 'config.h',
1277 configuration : conf)
1279 includes = include_directories('src/basic',
1289 'src/libsystemd/sd-bus',
1290 'src/libsystemd/sd-device',
1291 'src/libsystemd/sd-hwdb',
1292 'src/libsystemd/sd-id128',
1293 'src/libsystemd/sd-netlink',
1294 'src/libsystemd/sd-network',
1295 'src/libsystemd-network',
1298 add_project_arguments('-include', 'config.h', language : 'c')
1302 subdir('src/systemd')
1304 subdir('src/libsystemd')
1305 subdir('src/libsystemd-network')
1306 subdir('src/journal')
1309 libjournal_core = static_library(
1311 libjournal_core_sources,
1313 include_directories : includes,
1316 libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
1317 libsystemd = shared_library(
1319 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1320 version : libsystemd_version,
1321 include_directories : includes,
1322 link_args : ['-shared',
1323 '-Wl,--version-script=' + libsystemd_sym_path],
1324 link_with : [libbasic,
1326 link_whole : [libsystemd_static,
1328 dependencies : [threads,
1332 link_depends : libsystemd_sym,
1334 install_dir : rootlibdir)
1336 ############################################################
1338 # binaries that have --help and are intended for use by humans,
1339 # usually, but not always, installed in /bin.
1340 public_programs = []
1342 subdir('src/libudev')
1343 subdir('src/shared')
1346 subdir('src/network')
1348 subdir('src/analyze')
1349 subdir('src/journal-remote')
1350 subdir('src/coredump')
1351 subdir('src/hostname')
1352 subdir('src/import')
1353 subdir('src/kernel-install')
1354 subdir('src/locale')
1355 subdir('src/machine')
1356 subdir('src/nspawn')
1357 subdir('src/resolve')
1358 subdir('src/timedate')
1359 subdir('src/timesync')
1360 subdir('src/vconsole')
1361 subdir('src/boot/efi')
1368 ############################################################
1370 # only static linking apart from libdl, to make sure that the
1371 # module is linked to all libraries that it uses.
1372 test_dlopen = executable(
1375 include_directories : includes,
1376 link_with : [libbasic],
1377 dependencies : [libdl])
1379 foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1380 ['systemd', 'ENABLE_NSS_SYSTEMD'],
1381 ['mymachines', 'ENABLE_MACHINED'],
1382 ['resolve', 'ENABLE_RESOLVE']]
1384 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1388 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1389 version_script_arg = join_paths(meson.current_source_dir(), sym)
1391 nss = shared_library(
1393 'src/nss-@0@/nss-@0@.c'.format(module),
1395 include_directories : includes,
1396 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1397 link_args : ['-Wl,-z,nodelete',
1399 '-Wl,--version-script=' + version_script_arg,
1401 link_with : [libsystemd_static,
1403 dependencies : [threads,
1407 install_dir : rootlibdir)
1409 # We cannot use shared_module because it does not support version suffix.
1410 # Unfortunately shared_library insists on creating the symlink…
1411 meson.add_install_script('sh', '-c',
1412 'rm $DESTDIR@0@/libnss_@1@.so'
1413 .format(rootlibdir, module))
1415 test('dlopen-nss_' + module,
1417 args : [nss.full_path()]) # path to dlopen must include a slash
1421 ############################################################
1423 executable('systemd',
1425 include_directories : includes,
1426 link_with : [libcore,
1428 dependencies : [threads,
1434 install_rpath : rootlibexecdir,
1436 install_dir : rootlibexecdir)
1438 exe = executable('systemd-analyze',
1439 systemd_analyze_sources,
1440 include_directories : includes,
1441 link_with : [libcore,
1443 dependencies : [threads,
1449 install_rpath : rootlibexecdir,
1451 public_programs += [exe]
1453 executable('systemd-journald',
1454 systemd_journald_sources,
1455 include_directories : includes,
1456 link_with : [libjournal_core,
1458 dependencies : [threads,
1462 install_rpath : rootlibexecdir,
1464 install_dir : rootlibexecdir)
1466 exe = executable('systemd-cat',
1467 systemd_cat_sources,
1468 include_directories : includes,
1469 link_with : [libjournal_core,
1471 dependencies : [threads],
1472 install_rpath : rootlibexecdir,
1474 public_programs += [exe]
1476 exe = executable('journalctl',
1478 include_directories : includes,
1479 link_with : [libshared],
1480 dependencies : [threads,
1485 install_rpath : rootlibexecdir,
1487 install_dir : rootbindir)
1488 public_programs += [exe]
1490 executable('systemd-getty-generator',
1491 'src/getty-generator/getty-generator.c',
1492 include_directories : includes,
1493 link_with : [libshared],
1494 install_rpath : rootlibexecdir,
1496 install_dir : systemgeneratordir)
1498 executable('systemd-debug-generator',
1499 'src/debug-generator/debug-generator.c',
1500 include_directories : includes,
1501 link_with : [libshared],
1502 install_rpath : rootlibexecdir,
1504 install_dir : systemgeneratordir)
1506 executable('systemd-fstab-generator',
1507 'src/fstab-generator/fstab-generator.c',
1508 'src/core/mount-setup.c',
1509 include_directories : includes,
1510 link_with : [libshared],
1511 install_rpath : rootlibexecdir,
1513 install_dir : systemgeneratordir)
1515 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1516 executable('30-systemd-environment-d-generator',
1517 'src/environment-d-generator/environment-d-generator.c',
1518 include_directories : includes,
1519 link_with : [libshared],
1520 install_rpath : rootlibexecdir,
1522 install_dir : userenvgeneratordir)
1524 meson.add_install_script(meson_make_symlink,
1525 join_paths(sysconfdir, 'environment'),
1526 join_paths(environmentdir, '99-environment.conf'))
1529 if conf.get('ENABLE_HIBERNATE') == 1
1530 executable('systemd-hibernate-resume-generator',
1531 'src/hibernate-resume/hibernate-resume-generator.c',
1532 include_directories : includes,
1533 link_with : [libshared],
1534 install_rpath : rootlibexecdir,
1536 install_dir : systemgeneratordir)
1538 executable('systemd-hibernate-resume',
1539 'src/hibernate-resume/hibernate-resume.c',
1540 include_directories : includes,
1541 link_with : [libshared],
1542 install_rpath : rootlibexecdir,
1544 install_dir : rootlibexecdir)
1547 if conf.get('HAVE_BLKID') == 1
1548 executable('systemd-gpt-auto-generator',
1549 'src/gpt-auto-generator/gpt-auto-generator.c',
1550 'src/basic/blkid-util.h',
1551 include_directories : includes,
1552 link_with : [libshared],
1553 dependencies : libblkid,
1554 install_rpath : rootlibexecdir,
1556 install_dir : systemgeneratordir)
1558 exe = executable('systemd-dissect',
1559 'src/dissect/dissect.c',
1560 include_directories : includes,
1561 link_with : [libshared],
1562 install_rpath : rootlibexecdir,
1564 install_dir : rootlibexecdir)
1565 public_programs += [exe]
1568 if conf.get('ENABLE_RESOLVE') == 1
1569 executable('systemd-resolved',
1570 systemd_resolved_sources,
1571 include_directories : includes,
1572 link_with : [libshared,
1574 libsystemd_resolve_core],
1575 dependencies : [threads,
1579 install_rpath : rootlibexecdir,
1581 install_dir : rootlibexecdir)
1583 exe = executable('systemd-resolve',
1584 systemd_resolve_sources,
1585 include_directories : includes,
1586 link_with : [libshared,
1588 libsystemd_resolve_core],
1589 dependencies : [threads,
1593 install_rpath : rootlibexecdir,
1595 public_programs += [exe]
1598 if conf.get('ENABLE_LOGIND') == 1
1599 executable('systemd-logind',
1600 systemd_logind_sources,
1601 include_directories : includes,
1602 link_with : [liblogind_core,
1604 dependencies : [threads,
1606 install_rpath : rootlibexecdir,
1608 install_dir : rootlibexecdir)
1610 exe = executable('loginctl',
1612 include_directories : includes,
1613 link_with : [libshared],
1614 dependencies : [threads,
1617 install_rpath : rootlibexecdir,
1619 install_dir : rootbindir)
1620 public_programs += [exe]
1622 exe = executable('systemd-inhibit',
1623 'src/login/inhibit.c',
1624 include_directories : includes,
1625 link_with : [libshared],
1626 install_rpath : rootlibexecdir,
1628 install_dir : rootbindir)
1629 public_programs += [exe]
1631 if conf.get('HAVE_PAM') == 1
1632 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1633 pam_systemd = shared_library(
1637 include_directories : includes,
1638 link_args : ['-shared',
1639 '-Wl,--version-script=' + version_script_arg],
1640 link_with : [libsystemd_static,
1642 dependencies : [threads,
1645 link_depends : pam_systemd_sym,
1647 install_dir : pamlibdir)
1649 test('dlopen-pam_systemd',
1651 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1655 if conf.get('HAVE_PAM') == 1
1656 executable('systemd-user-sessions',
1657 'src/user-sessions/user-sessions.c',
1658 include_directories : includes,
1659 link_with : [libshared],
1660 install_rpath : rootlibexecdir,
1662 install_dir : rootlibexecdir)
1665 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1666 exe = executable('bootctl',
1667 'src/boot/bootctl.c',
1668 include_directories : includes,
1669 link_with : [libshared],
1670 dependencies : [libblkid],
1671 install_rpath : rootlibexecdir,
1673 public_programs += [exe]
1676 exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1677 include_directories : includes,
1678 link_with : [libshared],
1679 dependencies : [threads],
1680 install_rpath : rootlibexecdir,
1682 public_programs += [exe]
1684 exe = executable('systemctl', 'src/systemctl/systemctl.c',
1685 include_directories : includes,
1686 link_with : [libshared],
1687 dependencies : [threads,
1692 install_rpath : rootlibexecdir,
1694 install_dir : rootbindir)
1695 public_programs += [exe]
1697 if conf.get('ENABLE_BACKLIGHT') == 1
1698 executable('systemd-backlight',
1699 'src/backlight/backlight.c',
1700 include_directories : includes,
1701 link_with : [libshared],
1702 install_rpath : rootlibexecdir,
1704 install_dir : rootlibexecdir)
1707 if conf.get('ENABLE_RFKILL') == 1
1708 executable('systemd-rfkill',
1709 'src/rfkill/rfkill.c',
1710 include_directories : includes,
1711 link_with : [libshared],
1712 install_rpath : rootlibexecdir,
1714 install_dir : rootlibexecdir)
1717 executable('systemd-system-update-generator',
1718 'src/system-update-generator/system-update-generator.c',
1719 include_directories : includes,
1720 link_with : [libshared],
1721 install_rpath : rootlibexecdir,
1723 install_dir : systemgeneratordir)
1725 if conf.get('HAVE_LIBCRYPTSETUP') == 1
1726 executable('systemd-cryptsetup',
1727 'src/cryptsetup/cryptsetup.c',
1728 include_directories : includes,
1729 link_with : [libshared],
1730 dependencies : [libcryptsetup],
1731 install_rpath : rootlibexecdir,
1733 install_dir : rootlibexecdir)
1735 executable('systemd-cryptsetup-generator',
1736 'src/cryptsetup/cryptsetup-generator.c',
1737 include_directories : includes,
1738 link_with : [libshared],
1739 dependencies : [libcryptsetup],
1740 install_rpath : rootlibexecdir,
1742 install_dir : systemgeneratordir)
1744 executable('systemd-veritysetup',
1745 'src/veritysetup/veritysetup.c',
1746 include_directories : includes,
1747 link_with : [libshared],
1748 dependencies : [libcryptsetup],
1749 install_rpath : rootlibexecdir,
1751 install_dir : rootlibexecdir)
1753 executable('systemd-veritysetup-generator',
1754 'src/veritysetup/veritysetup-generator.c',
1755 include_directories : includes,
1756 link_with : [libshared],
1757 dependencies : [libcryptsetup],
1758 install_rpath : rootlibexecdir,
1760 install_dir : systemgeneratordir)
1763 if conf.get('HAVE_SYSV_COMPAT') == 1
1764 executable('systemd-sysv-generator',
1765 'src/sysv-generator/sysv-generator.c',
1766 include_directories : includes,
1767 link_with : [libshared],
1768 install_rpath : rootlibexecdir,
1770 install_dir : systemgeneratordir)
1772 executable('systemd-rc-local-generator',
1773 'src/rc-local-generator/rc-local-generator.c',
1774 include_directories : includes,
1775 link_with : [libshared],
1776 install_rpath : rootlibexecdir,
1778 install_dir : systemgeneratordir)
1781 if conf.get('ENABLE_HOSTNAMED') == 1
1782 executable('systemd-hostnamed',
1783 'src/hostname/hostnamed.c',
1784 include_directories : includes,
1785 link_with : [libshared],
1786 install_rpath : rootlibexecdir,
1788 install_dir : rootlibexecdir)
1790 exe = executable('hostnamectl',
1791 'src/hostname/hostnamectl.c',
1792 include_directories : includes,
1793 link_with : [libshared],
1794 install_rpath : rootlibexecdir,
1796 public_programs += [exe]
1799 if conf.get('ENABLE_LOCALED') == 1
1800 if conf.get('HAVE_XKBCOMMON') == 1
1801 # logind will load libxkbcommon.so dynamically on its own
1807 executable('systemd-localed',
1808 systemd_localed_sources,
1809 include_directories : includes,
1810 link_with : [libshared],
1811 dependencies : deps,
1812 install_rpath : rootlibexecdir,
1814 install_dir : rootlibexecdir)
1816 exe = executable('localectl',
1818 include_directories : includes,
1819 link_with : [libshared],
1820 install_rpath : rootlibexecdir,
1822 public_programs += [exe]
1825 if conf.get('ENABLE_TIMEDATED') == 1
1826 executable('systemd-timedated',
1827 'src/timedate/timedated.c',
1828 include_directories : includes,
1829 link_with : [libshared],
1830 install_rpath : rootlibexecdir,
1832 install_dir : rootlibexecdir)
1834 exe = executable('timedatectl',
1835 'src/timedate/timedatectl.c',
1836 include_directories : includes,
1837 install_rpath : rootlibexecdir,
1838 link_with : [libshared],
1840 public_programs += [exe]
1843 if conf.get('ENABLE_TIMESYNCD') == 1
1844 executable('systemd-timesyncd',
1845 systemd_timesyncd_sources,
1846 include_directories : includes,
1847 link_with : [libshared],
1848 dependencies : [threads,
1850 install_rpath : rootlibexecdir,
1852 install_dir : rootlibexecdir)
1855 if conf.get('ENABLE_MACHINED') == 1
1856 executable('systemd-machined',
1857 systemd_machined_sources,
1858 include_directories : includes,
1859 link_with : [libmachine_core,
1861 install_rpath : rootlibexecdir,
1863 install_dir : rootlibexecdir)
1865 exe = executable('machinectl',
1866 'src/machine/machinectl.c',
1867 include_directories : includes,
1868 link_with : [libshared],
1869 dependencies : [threads,
1872 install_rpath : rootlibexecdir,
1874 install_dir : rootbindir)
1875 public_programs += [exe]
1878 if conf.get('ENABLE_IMPORTD') == 1
1879 executable('systemd-importd',
1880 systemd_importd_sources,
1881 include_directories : includes,
1882 link_with : [libshared],
1883 dependencies : [threads],
1884 install_rpath : rootlibexecdir,
1886 install_dir : rootlibexecdir)
1888 systemd_pull = executable('systemd-pull',
1889 systemd_pull_sources,
1890 include_directories : includes,
1891 link_with : [libshared],
1892 dependencies : [libcurl,
1897 install_rpath : rootlibexecdir,
1899 install_dir : rootlibexecdir)
1901 systemd_import = executable('systemd-import',
1902 systemd_import_sources,
1903 include_directories : includes,
1904 link_with : [libshared],
1905 dependencies : [libcurl,
1909 install_rpath : rootlibexecdir,
1911 install_dir : rootlibexecdir)
1913 systemd_export = executable('systemd-export',
1914 systemd_export_sources,
1915 include_directories : includes,
1916 link_with : [libshared],
1917 dependencies : [libcurl,
1921 install_rpath : rootlibexecdir,
1923 install_dir : rootlibexecdir)
1924 public_programs += [systemd_pull, systemd_import, systemd_export]
1927 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
1928 exe = executable('systemd-journal-upload',
1929 systemd_journal_upload_sources,
1930 include_directories : includes,
1931 link_with : [libshared],
1932 dependencies : [threads,
1937 install_rpath : rootlibexecdir,
1939 install_dir : rootlibexecdir)
1940 public_programs += [exe]
1943 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
1944 s_j_remote = executable('systemd-journal-remote',
1945 systemd_journal_remote_sources,
1946 include_directories : includes,
1947 link_with : [libshared],
1948 dependencies : [threads,
1953 install_rpath : rootlibexecdir,
1955 install_dir : rootlibexecdir)
1957 s_j_gatewayd = executable('systemd-journal-gatewayd',
1958 systemd_journal_gatewayd_sources,
1959 include_directories : includes,
1960 link_with : [libshared],
1961 dependencies : [threads,
1966 install_rpath : rootlibexecdir,
1968 install_dir : rootlibexecdir)
1969 public_programs += [s_j_remote, s_j_gatewayd]
1972 if conf.get('ENABLE_COREDUMP') == 1
1973 executable('systemd-coredump',
1974 systemd_coredump_sources,
1975 include_directories : includes,
1976 link_with : [libshared],
1977 dependencies : [threads,
1982 install_rpath : rootlibexecdir,
1984 install_dir : rootlibexecdir)
1986 exe = executable('coredumpctl',
1987 coredumpctl_sources,
1988 include_directories : includes,
1989 link_with : [libshared],
1990 dependencies : [threads,
1993 install_rpath : rootlibexecdir,
1995 public_programs += [exe]
1998 if conf.get('ENABLE_BINFMT') == 1
1999 exe = executable('systemd-binfmt',
2000 'src/binfmt/binfmt.c',
2001 include_directories : includes,
2002 link_with : [libshared],
2003 install_rpath : rootlibexecdir,
2005 install_dir : rootlibexecdir)
2006 public_programs += [exe]
2008 meson.add_install_script('sh', '-c',
2009 mkdir_p.format(binfmtdir))
2010 meson.add_install_script('sh', '-c',
2011 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2014 if conf.get('ENABLE_VCONSOLE') == 1
2015 executable('systemd-vconsole-setup',
2016 'src/vconsole/vconsole-setup.c',
2017 include_directories : includes,
2018 link_with : [libshared],
2019 install_rpath : rootlibexecdir,
2021 install_dir : rootlibexecdir)
2024 if conf.get('ENABLE_RANDOMSEED') == 1
2025 executable('systemd-random-seed',
2026 'src/random-seed/random-seed.c',
2027 include_directories : includes,
2028 link_with : [libshared],
2029 install_rpath : rootlibexecdir,
2031 install_dir : rootlibexecdir)
2034 if conf.get('ENABLE_FIRSTBOOT') == 1
2035 executable('systemd-firstboot',
2036 'src/firstboot/firstboot.c',
2037 include_directories : includes,
2038 link_with : [libshared],
2039 dependencies : [libcrypt],
2040 install_rpath : rootlibexecdir,
2042 install_dir : rootbindir)
2045 executable('systemd-remount-fs',
2046 'src/remount-fs/remount-fs.c',
2047 'src/core/mount-setup.c',
2048 'src/core/mount-setup.h',
2049 include_directories : includes,
2050 link_with : [libshared],
2051 install_rpath : rootlibexecdir,
2053 install_dir : rootlibexecdir)
2055 executable('systemd-machine-id-setup',
2056 'src/machine-id-setup/machine-id-setup-main.c',
2057 'src/core/machine-id-setup.c',
2058 'src/core/machine-id-setup.h',
2059 include_directories : includes,
2060 link_with : [libshared],
2061 install_rpath : rootlibexecdir,
2063 install_dir : rootbindir)
2065 executable('systemd-fsck',
2067 include_directories : includes,
2068 link_with : [libshared],
2069 install_rpath : rootlibexecdir,
2071 install_dir : rootlibexecdir)
2073 executable('systemd-growfs',
2074 'src/partition/growfs.c',
2075 include_directories : includes,
2076 link_with : [libshared],
2077 dependencies : [libcryptsetup],
2078 install_rpath : rootlibexecdir,
2080 install_dir : rootlibexecdir)
2082 executable('systemd-makefs',
2083 'src/partition/makefs.c',
2084 include_directories : includes,
2085 link_with : [libshared],
2086 install_rpath : rootlibexecdir,
2088 install_dir : rootlibexecdir)
2090 executable('systemd-sleep',
2091 'src/sleep/sleep.c',
2092 include_directories : includes,
2093 link_with : [libshared],
2094 install_rpath : rootlibexecdir,
2096 install_dir : rootlibexecdir)
2098 exe = executable('systemd-sysctl',
2099 'src/sysctl/sysctl.c',
2100 include_directories : includes,
2101 link_with : [libshared],
2102 install_rpath : rootlibexecdir,
2104 install_dir : rootlibexecdir)
2105 public_programs += [exe]
2107 executable('systemd-ac-power',
2108 'src/ac-power/ac-power.c',
2109 include_directories : includes,
2110 link_with : [libshared],
2111 install_rpath : rootlibexecdir,
2113 install_dir : rootlibexecdir)
2115 exe = executable('systemd-detect-virt',
2116 'src/detect-virt/detect-virt.c',
2117 include_directories : includes,
2118 link_with : [libshared],
2119 install_rpath : rootlibexecdir,
2121 public_programs += [exe]
2123 exe = executable('systemd-delta',
2124 'src/delta/delta.c',
2125 include_directories : includes,
2126 link_with : [libshared],
2127 install_rpath : rootlibexecdir,
2129 public_programs += [exe]
2131 exe = executable('systemd-escape',
2132 'src/escape/escape.c',
2133 include_directories : includes,
2134 link_with : [libshared],
2135 install_rpath : rootlibexecdir,
2137 install_dir : rootbindir)
2138 public_programs += [exe]
2140 exe = executable('systemd-notify',
2141 'src/notify/notify.c',
2142 include_directories : includes,
2143 link_with : [libshared],
2144 install_rpath : rootlibexecdir,
2146 install_dir : rootbindir)
2147 public_programs += [exe]
2149 executable('systemd-volatile-root',
2150 'src/volatile-root/volatile-root.c',
2151 include_directories : includes,
2152 link_with : [libshared],
2153 install_rpath : rootlibexecdir,
2155 install_dir : rootlibexecdir)
2157 executable('systemd-cgroups-agent',
2158 'src/cgroups-agent/cgroups-agent.c',
2159 include_directories : includes,
2160 link_with : [libshared],
2161 install_rpath : rootlibexecdir,
2163 install_dir : rootlibexecdir)
2165 exe = executable('systemd-path',
2167 include_directories : includes,
2168 link_with : [libshared],
2169 install_rpath : rootlibexecdir,
2171 public_programs += [exe]
2173 exe = executable('systemd-ask-password',
2174 'src/ask-password/ask-password.c',
2175 include_directories : includes,
2176 link_with : [libshared],
2177 install_rpath : rootlibexecdir,
2179 install_dir : rootbindir)
2180 public_programs += [exe]
2182 executable('systemd-reply-password',
2183 'src/reply-password/reply-password.c',
2184 include_directories : includes,
2185 link_with : [libshared],
2186 install_rpath : rootlibexecdir,
2188 install_dir : rootlibexecdir)
2190 exe = executable('systemd-tty-ask-password-agent',
2191 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2192 include_directories : includes,
2193 link_with : [libshared],
2194 install_rpath : rootlibexecdir,
2196 install_dir : rootbindir)
2197 public_programs += [exe]
2199 exe = executable('systemd-cgls',
2201 include_directories : includes,
2202 link_with : [libshared],
2203 install_rpath : rootlibexecdir,
2205 public_programs += [exe]
2207 exe = executable('systemd-cgtop',
2208 'src/cgtop/cgtop.c',
2209 include_directories : includes,
2210 link_with : [libshared],
2211 install_rpath : rootlibexecdir,
2213 public_programs += [exe]
2215 executable('systemd-initctl',
2216 'src/initctl/initctl.c',
2217 include_directories : includes,
2218 link_with : [libshared],
2219 install_rpath : rootlibexecdir,
2221 install_dir : rootlibexecdir)
2223 exe = executable('systemd-mount',
2224 'src/mount/mount-tool.c',
2225 include_directories : includes,
2226 link_with : [libshared],
2227 install_rpath : rootlibexecdir,
2229 public_programs += [exe]
2231 meson.add_install_script(meson_make_symlink,
2232 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2234 exe = executable('systemd-run',
2236 include_directories : includes,
2237 link_with : [libshared],
2238 install_rpath : rootlibexecdir,
2240 public_programs += [exe]
2242 exe = executable('systemd-stdio-bridge',
2243 'src/stdio-bridge/stdio-bridge.c',
2244 include_directories : includes,
2245 link_with : [libshared],
2246 install_rpath : rootlibexecdir,
2248 public_programs += [exe]
2250 exe = executable('busctl',
2251 'src/busctl/busctl.c',
2252 'src/busctl/busctl-introspect.c',
2253 'src/busctl/busctl-introspect.h',
2254 include_directories : includes,
2255 link_with : [libshared],
2256 install_rpath : rootlibexecdir,
2258 public_programs += [exe]
2260 if conf.get('ENABLE_SYSUSERS') == 1
2261 exe = executable('systemd-sysusers',
2262 'src/sysusers/sysusers.c',
2263 include_directories : includes,
2264 link_with : [libshared],
2265 install_rpath : rootlibexecdir,
2267 install_dir : rootbindir)
2268 public_programs += [exe]
2271 if conf.get('ENABLE_TMPFILES') == 1
2272 exe = executable('systemd-tmpfiles',
2273 'src/tmpfiles/tmpfiles.c',
2274 include_directories : includes,
2275 link_with : [libshared],
2276 dependencies : [libacl],
2277 install_rpath : rootlibexecdir,
2279 install_dir : rootbindir)
2280 public_programs += [exe]
2282 test('test-systemd-tmpfiles',
2283 test_systemd_tmpfiles_py,
2284 args : exe.full_path())
2285 # https://github.com/mesonbuild/meson/issues/2681
2288 if conf.get('ENABLE_HWDB') == 1
2289 exe = executable('systemd-hwdb',
2291 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2292 include_directories : includes,
2293 link_with : [libudev_static],
2294 install_rpath : udev_rpath,
2296 install_dir : rootbindir)
2297 public_programs += [exe]
2300 if conf.get('ENABLE_QUOTACHECK') == 1
2301 executable('systemd-quotacheck',
2302 'src/quotacheck/quotacheck.c',
2303 include_directories : includes,
2304 link_with : [libshared],
2305 install_rpath : rootlibexecdir,
2307 install_dir : rootlibexecdir)
2310 exe = executable('systemd-socket-proxyd',
2311 'src/socket-proxy/socket-proxyd.c',
2312 include_directories : includes,
2313 link_with : [libshared],
2314 dependencies : [threads],
2315 install_rpath : rootlibexecdir,
2317 install_dir : rootlibexecdir)
2318 public_programs += [exe]
2320 exe = executable('systemd-udevd',
2321 systemd_udevd_sources,
2322 include_directories : includes,
2323 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2324 link_with : [libudev_core,
2327 dependencies : [threads,
2332 install_rpath : udev_rpath,
2334 install_dir : rootlibexecdir)
2335 public_programs += [exe]
2337 exe = executable('udevadm',
2339 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
2340 include_directories : includes,
2341 link_with : [libudev_core,
2344 dependencies : [threads,
2349 install_rpath : udev_rpath,
2351 install_dir : rootbindir)
2352 public_programs += [exe]
2354 executable('systemd-shutdown',
2355 systemd_shutdown_sources,
2356 include_directories : includes,
2357 link_with : [libshared],
2358 install_rpath : rootlibexecdir,
2360 install_dir : rootlibexecdir)
2362 executable('systemd-update-done',
2363 'src/update-done/update-done.c',
2364 include_directories : includes,
2365 link_with : [libshared],
2366 install_rpath : rootlibexecdir,
2368 install_dir : rootlibexecdir)
2370 executable('systemd-update-utmp',
2371 'src/update-utmp/update-utmp.c',
2372 include_directories : includes,
2373 link_with : [libshared],
2374 dependencies : [libaudit],
2375 install_rpath : rootlibexecdir,
2377 install_dir : rootlibexecdir)
2379 if conf.get('HAVE_KMOD') == 1
2380 executable('systemd-modules-load',
2381 'src/modules-load/modules-load.c',
2382 include_directories : includes,
2383 link_with : [libshared],
2384 dependencies : [libkmod],
2385 install_rpath : rootlibexecdir,
2387 install_dir : rootlibexecdir)
2389 meson.add_install_script('sh', '-c',
2390 mkdir_p.format(modulesloaddir))
2391 meson.add_install_script('sh', '-c',
2392 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2395 exe = executable('systemd-nspawn',
2396 systemd_nspawn_sources,
2397 'src/core/mount-setup.c', # FIXME: use a variable?
2398 'src/core/mount-setup.h',
2399 'src/core/loopback-setup.c',
2400 'src/core/loopback-setup.h',
2401 include_directories : [includes, include_directories('src/nspawn')],
2402 link_with : [libshared],
2403 dependencies : [libacl,
2407 install_rpath : rootlibexecdir,
2409 public_programs += [exe]
2411 if conf.get('ENABLE_NETWORKD') == 1
2412 executable('systemd-networkd',
2413 systemd_networkd_sources,
2414 include_directories : includes,
2415 link_with : [libnetworkd_core,
2419 dependencies : [threads],
2420 install_rpath : rootlibexecdir,
2422 install_dir : rootlibexecdir)
2424 executable('systemd-networkd-wait-online',
2425 systemd_networkd_wait_online_sources,
2426 include_directories : includes,
2427 link_with : [libnetworkd_core,
2429 install_rpath : rootlibexecdir,
2431 install_dir : rootlibexecdir)
2433 exe = executable('networkctl',
2435 include_directories : includes,
2436 link_with : [libsystemd_network,
2438 install_rpath : rootlibexecdir,
2440 install_dir : rootbindir)
2441 public_programs += [exe]
2444 executable('systemd-sulogin-shell',
2445 ['src/sulogin-shell/sulogin-shell.c'],
2446 include_directories : includes,
2447 link_with : [libshared],
2448 install_rpath : rootlibexecdir,
2450 install_dir : rootlibexecdir)
2452 ############################################################
2454 foreach tuple : tests
2456 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2457 dependencies = tuple[2]
2458 condition = tuple.length() >= 4 ? tuple[3] : ''
2459 type = tuple.length() >= 5 ? tuple[4] : ''
2460 defs = tuple.length() >= 6 ? tuple[5] : []
2461 incs = tuple.length() >= 7 ? tuple[6] : includes
2464 name = sources[0].split('/')[-1].split('.')[0]
2465 if type.startswith('timeout=')
2466 timeout = type.split('=')[1].to_int()
2469 if want_tests == 'false'
2470 message('Not compiling @0@ because tests is set to false'.format(name))
2471 elif condition == '' or conf.get(condition) == 1
2475 include_directories : incs,
2476 link_with : link_with,
2477 dependencies : dependencies,
2479 install_rpath : rootlibexecdir,
2480 install : install_tests,
2481 install_dir : join_paths(testsdir, type))
2484 message('@0@ is a manual test'.format(name))
2485 elif type == 'unsafe' and want_tests != 'unsafe'
2486 message('@0@ is an unsafe test'.format(name))
2493 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2497 test_libsystemd_sym = executable(
2498 'test-libsystemd-sym',
2499 test_libsystemd_sym_c,
2500 include_directories : includes,
2501 link_with : [libsystemd],
2502 install : install_tests,
2503 install_dir : testsdir)
2504 test('test-libsystemd-sym',
2505 test_libsystemd_sym)
2507 test_libudev_sym = executable(
2510 include_directories : includes,
2511 c_args : ['-Wno-deprecated-declarations'],
2512 link_with : [libudev],
2513 install : install_tests,
2514 install_dir : testsdir)
2515 test('test-libudev-sym',
2518 ############################################################
2522 foreach tuple : fuzzers
2524 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2525 dependencies = tuple[2]
2526 defs = tuple.length() >= 4 ? tuple[3] : []
2527 incs = tuple.length() >= 5 ? tuple[4] : includes
2530 dependencies += fuzzing_engine
2532 sources += 'src/fuzz/fuzz-main.c'
2535 name = sources[0].split('/')[-1].split('.')[0]
2537 fuzzer_exes += executable(
2540 include_directories : [incs, include_directories('src/fuzz')],
2541 link_with : link_with,
2542 dependencies : dependencies,
2547 run_target('fuzzers',
2548 depends : fuzzer_exes,
2551 ############################################################
2553 make_directive_index_py = find_program('tools/make-directive-index.py')
2554 make_man_index_py = find_program('tools/make-man-index.py')
2555 xml_helper_py = find_program('tools/xml_helper.py')
2556 hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2560 subdir('sysusers.d')
2561 subdir('tmpfiles.d')
2566 subdir('shell-completion/bash')
2567 subdir('shell-completion/zsh')
2568 subdir('docs/sysvinit')
2569 subdir('docs/var-log')
2571 # FIXME: figure out if the warning is true:
2572 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2573 install_subdir('factory/etc',
2574 install_dir : factorydir)
2577 install_data('xorg/50-systemd-user.sh',
2578 install_dir : xinitrcdir)
2579 install_data('modprobe.d/systemd.conf',
2580 install_dir : modprobedir)
2581 install_data('README',
2588 'TRANSIENT-SETTINGS.md',
2590 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2591 install_dir : docdir)
2593 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2594 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2596 ############################################################
2598 meson_check_help = find_program('tools/meson-check-help.sh')
2600 foreach exec : public_programs
2601 name = exec.full_path().split('/')[-1]
2602 test('check-help-' + name,
2604 args : [exec.full_path()])
2607 ############################################################
2610 foreach p : fuzz_regression_tests
2611 a = p.split('/')[-3]
2612 b = p.split('/')[-2]
2613 c = p.split('/')[-1]
2616 build = sanitize_address
2618 error('unknown sanitizer @0@'.format(a))
2621 name = '@1@:@0@'.format(a, b)
2624 if want_tests == 'false'
2625 message('Not compiling @0@ because tests is set to false'.format(name))
2626 elif not sanitizers.contains(a)
2627 message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2629 exe = custom_target(
2633 command : [env, 'ln', '-fs',
2634 join_paths(build.full_path(), b),
2636 build_by_default : true)
2638 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2643 if want_tests != 'false' and slow_tests
2644 test(c, env, args : [exe.full_path(),
2645 join_paths(meson.source_root(),
2646 'test/fuzz-regressions',
2651 ############################################################
2654 all_files = run_command(
2656 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2659 all_files = files(all_files.stdout().split())
2664 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2668 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
2672 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
2675 command : [meson_git_contrib_sh])
2679 git_head = run_command(
2681 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2682 'rev-parse', 'HEAD']).stdout().strip()
2683 git_head_short = run_command(
2685 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
2686 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2690 command : ['git', 'archive',
2691 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
2693 '--prefix', 'systemd-@0@/'.format(git_head),
2697 ############################################################
2699 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2702 depends : [man, libsystemd, libudev],
2703 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2705 ############################################################
2708 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2710 'prefix directory: @0@'.format(prefixdir),
2711 'rootprefix directory: @0@'.format(rootprefixdir),
2712 'sysconf directory: @0@'.format(sysconfdir),
2713 'include directory: @0@'.format(includedir),
2714 'lib directory: @0@'.format(libdir),
2715 'rootlib directory: @0@'.format(rootlibdir),
2716 'SysV init scripts: @0@'.format(sysvinit_path),
2717 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
2718 'PAM modules directory: @0@'.format(pamlibdir),
2719 'PAM configuration directory: @0@'.format(pamconfdir),
2720 'RPM macros directory: @0@'.format(rpmmacrosdir),
2721 'modprobe.d directory: @0@'.format(modprobedir),
2722 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2723 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2724 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2725 'bash completions directory: @0@'.format(bashcompletiondir),
2726 'zsh completions directory: @0@'.format(zshcompletiondir),
2727 'extra start script: @0@'.format(get_option('rc-local')),
2728 'extra stop script: @0@'.format(get_option('halt-local')),
2729 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2730 get_option('debug-tty')),
2731 'TTY GID: @0@'.format(tty_gid),
2732 'users GID: @0@'.format(users_gid),
2733 'maximum system UID: @0@'.format(system_uid_max),
2734 'maximum system GID: @0@'.format(system_gid_max),
2735 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2736 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2737 'minimum container UID base: @0@'.format(container_uid_base_min),
2738 'maximum container UID base: @0@'.format(container_uid_base_max),
2739 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
2740 'render group access mode: @0@'.format(get_option('group-render-mode')),
2741 'certificate root directory: @0@'.format(get_option('certificate-root')),
2742 'support URL: @0@'.format(support_url),
2743 'nobody user name: @0@'.format(nobody_user),
2744 'nobody group name: @0@'.format(nobody_group),
2745 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
2746 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
2748 'default DNSSEC mode: @0@'.format(default_dnssec),
2749 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2750 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2752 alt_dns_servers = '\n '.join(dns_servers.split(' '))
2753 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2755 'default DNS servers: @0@'.format(alt_dns_servers),
2756 'default NTP servers: @0@'.format(alt_ntp_servers)]
2758 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2759 '@@0@'.format(time_epoch)).stdout().strip()
2761 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2764 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2765 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2766 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2768 if conf.get('ENABLE_EFI') == 1
2770 'efi arch: @0@'.format(efi_arch)]
2774 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2775 'EFI CC @0@'.format(efi_cc),
2776 'EFI lib directory: @0@'.format(efi_libdir),
2777 'EFI lds directory: @0@'.format(efi_ldsdir),
2778 'EFI include directory: @0@'.format(efi_incdir)]
2831 ['legacy pkla', install_polkit_pkla],
2833 ['gnu-efi', have_gnu_efi],
2840 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
2843 ['man pages', want_man],
2844 ['html pages', want_html],
2845 ['man page indices', want_man and have_lxml],
2846 ['split /usr', conf.get('HAVE_SPLIT_USR') == 1],
2851 ['adm group', get_option('adm-group')],
2852 ['wheel group', get_option('wheel-group')],
2855 ['debug mmap cache'],
2858 cond = tuple.get(1, '')
2860 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2861 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
2862 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
2867 missing += [tuple[0]]
2873 'enabled features: @0@'.format(', '.join(found)),
2875 'disabled features: @0@'.format(', '.join(missing)),
2877 message('\n '.join(status))
2879 if rootprefixdir != rootprefix_default
2880 message('WARNING:\n' +
2881 ' Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2882 ' systemd used fixed names for unit file directories and other paths, so anything\n' +
2883 ' except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))