]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
b87d5c63a358d886eecee8ab75f8fdbea8d352a0
[thirdparty/systemd.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1+
2
3 project('systemd', 'c',
4 version : '245',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu99',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 'warning_level=2',
12 ],
13 meson_version : '>= 0.46',
14 )
15
16 libsystemd_version = '0.28.0'
17 libudev_version = '1.6.17'
18
19 # We need the same data in two different formats, ugh!
20 # Also, for hysterical reasons, we use different variable
21 # names, sometimes. Not all variables are included in every
22 # set. Ugh, ugh, ugh!
23 conf = configuration_data()
24 conf.set('PROJECT_VERSION', meson.project_version(),
25 description : 'Numerical project version (used where a simple number is expected)')
26
27 substs = configuration_data()
28 substs.set('PROJECT_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
29 substs.set('PROJECT_VERSION', meson.project_version(),
30 description : 'Numerical project version (used where a simple number is expected)')
31
32 # This is to be used instead of meson.source_root(), as the latter will return
33 # the wrong result when systemd is being built as a meson subproject
34 project_source_root = meson.current_source_dir()
35 project_build_root = meson.current_build_dir()
36 relative_source_path = run_command('realpath',
37 '--relative-to=@0@'.format(project_build_root),
38 project_source_root).stdout().strip()
39 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
40
41 want_ossfuzz = get_option('oss-fuzz')
42 want_libfuzzer = get_option('llvm-fuzz')
43 if want_ossfuzz + want_libfuzzer > 1
44 error('only one of oss-fuzz or llvm-fuzz can be specified')
45 endif
46
47 skip_deps = want_ossfuzz or want_libfuzzer
48 fuzzer_build = want_ossfuzz or want_libfuzzer
49
50 #####################################################################
51
52 # Try to install the git pre-commit hook
53 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
54 if add_git_hook_sh.found()
55 git_hook = run_command(add_git_hook_sh)
56 if git_hook.returncode() == 0
57 message(git_hook.stdout().strip())
58 endif
59 endif
60
61 #####################################################################
62
63 if get_option('split-usr') == 'auto'
64 split_usr = run_command('test', '-L', '/bin').returncode() != 0
65 else
66 split_usr = get_option('split-usr') == 'true'
67 endif
68 conf.set10('HAVE_SPLIT_USR', split_usr,
69 description : '/usr/bin and /bin directories are separate')
70
71 if get_option('split-bin') == 'auto'
72 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
73 else
74 split_bin = get_option('split-bin') == 'true'
75 endif
76 conf.set10('HAVE_SPLIT_BIN', split_bin,
77 description : 'bin and sbin directories are separate')
78
79 rootprefixdir = get_option('rootprefix')
80 # Unusual rootprefixdir values are used by some distros
81 # (see https://github.com/systemd/systemd/pull/7461).
82 rootprefix_default = split_usr ? '/' : '/usr'
83 if rootprefixdir == ''
84 rootprefixdir = rootprefix_default
85 endif
86 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
87
88 sysvinit_path = get_option('sysvinit-path')
89 sysvrcnd_path = get_option('sysvrcnd-path')
90 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
91 description : 'SysV init scripts and rcN.d links are supported')
92
93 if get_option('hibernate') and not get_option('initrd')
94 error('hibernate depends on initrd')
95 endif
96
97 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
98 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
99 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
100
101 # join_paths ignores the preceding arguments if an absolute component is
102 # encountered, so this should canonicalize various paths when they are
103 # absolute or relative.
104 prefixdir = get_option('prefix')
105 if not prefixdir.startswith('/')
106 error('Prefix is not absolute: "@0@"'.format(prefixdir))
107 endif
108 bindir = join_paths(prefixdir, get_option('bindir'))
109 libdir = join_paths(prefixdir, get_option('libdir'))
110 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
111 includedir = join_paths(prefixdir, get_option('includedir'))
112 datadir = join_paths(prefixdir, get_option('datadir'))
113 localstatedir = join_paths('/', get_option('localstatedir'))
114
115 rootbindir = join_paths(rootprefixdir, 'bin')
116 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
117 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
118
119 rootlibdir = get_option('rootlibdir')
120 if rootlibdir == ''
121 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
122 endif
123
124 # Dirs of external packages
125 pkgconfigdatadir = get_option('pkgconfigdatadir') == '' ? join_paths(datadir, 'pkgconfig') : get_option('pkgconfigdatadir')
126 pkgconfiglibdir = get_option('pkgconfiglibdir') == '' ? join_paths(libdir, 'pkgconfig') : get_option('pkgconfiglibdir')
127 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
128 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
129 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
130 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
131 rpmmacrosdir = get_option('rpmmacrosdir')
132 if rpmmacrosdir != 'no'
133 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
134 endif
135 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
136
137 # Our own paths
138 pkgdatadir = join_paths(datadir, 'systemd')
139 environmentdir = join_paths(prefixdir, 'lib/environment.d')
140 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
141 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
142 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
143 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
144 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
145 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
146 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
147 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
148 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
149 pkgincludedir = join_paths(includedir, 'systemd')
150 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
151 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
152 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
153 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
154 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
155 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
156 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
157 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
158 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
159 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
160 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
161 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
162 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
163 factorydir = join_paths(datadir, 'factory')
164 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
165 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
166 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
167 catalogstatedir = join_paths(systemdstatedir, 'catalog')
168 randomseeddir = join_paths(localstatedir, 'lib/systemd')
169 profiledir = join_paths(rootlibexecdir, 'portable', 'profile')
170 ntpservicelistdir = join_paths(rootprefixdir, 'lib/systemd/ntp-units.d')
171
172 docdir = get_option('docdir')
173 if docdir == ''
174 docdir = join_paths(datadir, 'doc/systemd')
175 endif
176
177 dbuspolicydir = get_option('dbuspolicydir')
178 if dbuspolicydir == ''
179 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
180 endif
181
182 dbussessionservicedir = get_option('dbussessionservicedir')
183 if dbussessionservicedir == ''
184 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
185 endif
186
187 dbussystemservicedir = get_option('dbussystemservicedir')
188 if dbussystemservicedir == ''
189 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
190 endif
191
192 pamlibdir = get_option('pamlibdir')
193 if pamlibdir == ''
194 pamlibdir = join_paths(rootlibdir, 'security')
195 endif
196
197 pamconfdir = get_option('pamconfdir')
198 if pamconfdir == ''
199 pamconfdir = join_paths(sysconfdir, 'pam.d')
200 endif
201
202 memory_accounting_default = get_option('memory-accounting-default')
203 status_unit_format_default = get_option('status-unit-format-default')
204
205 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
206 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', join_paths(pkgsysconfdir, 'system'))
207 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
208 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
209 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
210 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
211
212 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
213
214 conf.set_quoted('USER_CONFIG_UNIT_DIR', join_paths(pkgsysconfdir, 'user'))
215 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
216 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
217 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
218 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
219 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
220 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
221 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
222 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
223 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
224 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
225 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
226 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
227 conf.set_quoted('ROOTPREFIX', rootprefixdir)
228 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
229 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
230 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
231 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
232 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
233 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
234 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
235 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
236 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
237 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
238 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
239 conf.set_quoted('SYSTEMD_TEST_DATA', join_paths(testsdir, 'testdata'))
240 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
241 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
242 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
243 conf.set_quoted('LIBDIR', libdir)
244 conf.set_quoted('ROOTLIBDIR', rootlibdir)
245 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
246 conf.set_quoted('BOOTLIBDIR', bootlibdir)
247 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
248 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
249 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', join_paths(rootlibexecdir, 'systemd-import-fs'))
250 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
251 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
252 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
253 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
254 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', join_paths(rootlibexecdir, 'systemd-homework'))
255 conf.set_quoted('SYSTEMD_USERWORK_PATH', join_paths(rootlibexecdir, 'systemd-userwork'))
256 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
257 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
258 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
259
260 substs.set('prefix', prefixdir)
261 substs.set('rootprefix', rootprefixdir)
262 substs.set('rootprefix_noslash', rootprefixdir_noslash)
263 substs.set('exec_prefix', prefixdir)
264 substs.set('libdir', libdir)
265 substs.set('rootlibdir', rootlibdir)
266 substs.set('includedir', includedir)
267 substs.set('sysconfdir', sysconfdir)
268 substs.set('bindir', bindir)
269 substs.set('rootbindir', rootbindir)
270 substs.set('rootlibexecdir', rootlibexecdir)
271 substs.set('systemunitdir', systemunitdir)
272 substs.set('userunitdir', userunitdir)
273 substs.set('systempresetdir', systempresetdir)
274 substs.set('userpresetdir', userpresetdir)
275 substs.set('udevhwdbdir', udevhwdbdir)
276 substs.set('udevrulesdir', udevrulesdir)
277 substs.set('udevlibexecdir', udevlibexecdir)
278 substs.set('environmentdir', environmentdir)
279 substs.set('catalogdir', catalogdir)
280 substs.set('tmpfilesdir', tmpfilesdir)
281 substs.set('sysusersdir', sysusersdir)
282 substs.set('sysctldir', sysctldir)
283 substs.set('binfmtdir', binfmtdir)
284 substs.set('modulesloaddir', modulesloaddir)
285 substs.set('modprobedir', modprobedir)
286 substs.set('systemgeneratordir', systemgeneratordir)
287 substs.set('usergeneratordir', usergeneratordir)
288 substs.set('systemenvgeneratordir', systemenvgeneratordir)
289 substs.set('userenvgeneratordir', userenvgeneratordir)
290 substs.set('systemshutdowndir', systemshutdowndir)
291 substs.set('systemsleepdir', systemsleepdir)
292 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
293 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
294 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
295 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
296 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
297 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
298 substs.set('STATUS_UNIT_FORMAT_DEFAULT', status_unit_format_default)
299 substs.set('HIGH_RLIMIT_NOFILE', conf.get('HIGH_RLIMIT_NOFILE'))
300 substs.set('BUILD_ROOT', project_build_root)
301
302 #####################################################################
303
304 cc = meson.get_compiler('c')
305 pkgconfig = import('pkgconfig')
306 check_compilation_sh = find_program('tools/check-compilation.sh')
307 meson_build_sh = find_program('tools/meson-build.sh')
308
309 want_tests = get_option('tests')
310 slow_tests = want_tests != 'false' and get_option('slow-tests')
311 fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
312 install_tests = get_option('install-tests')
313
314 if add_languages('cpp', required : fuzzer_build)
315 # Used only for tests
316 cxx = meson.get_compiler('cpp')
317 cxx_cmd = ' '.join(cxx.cmd_array())
318 else
319 cxx_cmd = ''
320 endif
321
322 if want_libfuzzer
323 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
324 if fuzzing_engine.found()
325 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
326 elif cc.has_argument('-fsanitize=fuzzer-no-link')
327 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
328 else
329 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
330 endif
331 elif want_ossfuzz
332 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
333 endif
334
335 # Those generate many false positives, and we do not want to change the code to
336 # avoid them.
337 basic_disabled_warnings = [
338 '-Wno-unused-parameter',
339 '-Wno-missing-field-initializers',
340 '-Wno-unused-result',
341 '-Wno-format-signedness',
342 ]
343
344 possible_cc_flags = [
345 '-Werror=undef',
346 '-Wlogical-op',
347 '-Wmissing-include-dirs',
348 '-Wold-style-definition',
349 '-Wpointer-arith',
350 '-Winit-self',
351 '-Wfloat-equal',
352 '-Wsuggest-attribute=noreturn',
353 '-Werror=missing-prototypes',
354 '-Werror=implicit-function-declaration',
355 '-Werror=missing-declarations',
356 '-Werror=return-type',
357 '-Werror=incompatible-pointer-types',
358 '-Werror=format=2',
359 '-Wstrict-prototypes',
360 '-Wredundant-decls',
361 '-Wmissing-noreturn',
362 '-Wimplicit-fallthrough=5',
363 '-Wshadow',
364 '-Wendif-labels',
365 '-Wstrict-aliasing=2',
366 '-Wwrite-strings',
367 '-Werror=overflow',
368 '-Werror=shift-count-overflow',
369 '-Werror=shift-overflow=2',
370 '-Wdate-time',
371 '-Wnested-externs',
372
373 # negative arguments are correctly detected starting with meson 0.46.
374 '-Wno-error=#warnings', # clang
375 '-Wno-string-plus-int', # clang
376
377 # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
378 # optimizations enabled, producing essentially false positives.
379 '-Wno-maybe-uninitialized',
380
381 '-ffast-math',
382 '-fno-common',
383 '-fdiagnostics-show-option',
384 '-fno-strict-aliasing',
385 '-fvisibility=hidden',
386 '-fstack-protector',
387 '-fstack-protector-strong',
388 '--param=ssp-buffer-size=4',
389 ]
390
391 # --as-needed and --no-undefined are provided by meson by default,
392 # run mesonconf to see what is enabled
393 possible_link_flags = [
394 '-Wl,-z,relro',
395 '-Wl,-z,now',
396 '-fstack-protector',
397 ]
398
399 if cc.get_id() == 'clang'
400 possible_cc_flags += [
401 '-Wno-typedef-redefinition',
402 '-Wno-gnu-variable-sized-type-not-at-end',
403 ]
404 endif
405
406 if get_option('buildtype') != 'debug'
407 possible_cc_flags += [
408 '-ffunction-sections',
409 '-fdata-sections',
410 ]
411
412 possible_link_flags += '-Wl,--gc-sections'
413 endif
414
415 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
416 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
417 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
418
419 have = cc.has_argument('-Wzero-length-bounds')
420 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
421
422 if cc.compiles('''
423 #include <time.h>
424 #include <inttypes.h>
425 typedef uint64_t usec_t;
426 usec_t now(clockid_t clock);
427 int main(void) {
428 struct timespec now;
429 return 0;
430 }
431 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
432 add_project_arguments('-Werror=shadow', language : 'c')
433 endif
434
435 if cxx_cmd != ''
436 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
437 endif
438
439 cpp = ' '.join(cc.cmd_array()) + ' -E'
440
441 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
442
443 #####################################################################
444 # compilation result tests
445
446 conf.set('_GNU_SOURCE', true)
447 conf.set('__SANE_USERSPACE_TYPES__', true)
448 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
449
450 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
451 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
452 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
453 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
454
455 decl_headers = '''
456 #include <uchar.h>
457 #include <sys/stat.h>
458 '''
459
460 foreach decl : ['char16_t',
461 'char32_t',
462 'struct statx',
463 ]
464
465 # We get -1 if the size cannot be determined
466 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
467
468 if decl == 'struct statx'
469 if have
470 want_linux_stat_h = false
471 else
472 have = cc.sizeof(decl,
473 prefix : decl_headers + '#include <linux/stat.h>',
474 args : '-D_GNU_SOURCE') > 0
475 want_linux_stat_h = have
476 endif
477 endif
478
479 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
480 endforeach
481
482 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
483
484 foreach ident : ['secure_getenv', '__secure_getenv']
485 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
486 endforeach
487
488 foreach ident : [
489 ['memfd_create', '''#include <sys/mman.h>'''],
490 ['gettid', '''#include <sys/types.h>
491 #include <unistd.h>'''],
492 ['pivot_root', '''#include <stdlib.h>
493 #include <unistd.h>'''], # no known header declares pivot_root
494 ['name_to_handle_at', '''#include <sys/types.h>
495 #include <sys/stat.h>
496 #include <fcntl.h>'''],
497 ['setns', '''#include <sched.h>'''],
498 ['renameat2', '''#include <stdio.h>
499 #include <fcntl.h>'''],
500 ['kcmp', '''#include <linux/kcmp.h>'''],
501 ['keyctl', '''#include <sys/types.h>
502 #include <keyutils.h>'''],
503 ['copy_file_range', '''#include <sys/syscall.h>
504 #include <unistd.h>'''],
505 ['bpf', '''#include <sys/syscall.h>
506 #include <unistd.h>'''],
507 ['statx', '''#include <sys/types.h>
508 #include <sys/stat.h>
509 #include <unistd.h>'''],
510 ['explicit_bzero' , '''#include <string.h>'''],
511 ['reallocarray', '''#include <malloc.h>'''],
512 ['set_mempolicy', '''#include <stdlib.h>
513 #include <unistd.h>'''],
514 ['get_mempolicy', '''#include <stdlib.h>
515 #include <unistd.h>'''],
516 ['pidfd_send_signal', '''#include <stdlib.h>
517 #include <unistd.h>
518 #include <signal.h>
519 #include <sys/wait.h>'''],
520 ['pidfd_open', '''#include <stdlib.h>
521 #include <unistd.h>
522 #include <signal.h>
523 #include <sys/wait.h>'''],
524 ['rt_sigqueueinfo', '''#include <stdlib.h>
525 #include <unistd.h>
526 #include <signal.h>
527 #include <sys/wait.h>'''],
528 ]
529
530 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
531 conf.set10('HAVE_' + ident[0].to_upper(), have)
532 endforeach
533
534 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
535 conf.set10('USE_SYS_RANDOM_H', true)
536 conf.set10('HAVE_GETRANDOM', true)
537 else
538 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
539 conf.set10('USE_SYS_RANDOM_H', false)
540 conf.set10('HAVE_GETRANDOM', have)
541 endif
542
543 #####################################################################
544
545 vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh',
546 project_source_root,
547 get_option('version-tag'),
548 meson.project_version()]
549
550 version_h = vcs_tag(
551 input : 'src/version/version.h.in',
552 output : 'version.h',
553 command: vcs_tagger)
554
555 versiondep = declare_dependency(sources: version_h)
556
557 sed = find_program('sed')
558 awk = find_program('awk')
559 m4 = find_program('m4')
560 stat = find_program('stat')
561 git = find_program('git', required : false)
562 env = find_program('env')
563 perl = find_program('perl', required : false)
564
565 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
566 mkdir_p = 'mkdir -p $DESTDIR/@0@'
567 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
568 splash_bmp = files('test/splash.bmp')
569
570 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
571 # /usr/sbin, /sbin, and fall back to the default from middle column.
572 progs = [['quotaon', '/usr/sbin/quotaon' ],
573 ['quotacheck', '/usr/sbin/quotacheck' ],
574 ['kmod', '/usr/bin/kmod' ],
575 ['kexec', '/usr/sbin/kexec' ],
576 ['sulogin', '/usr/sbin/sulogin' ],
577 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
578 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
579 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
580 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
581 ['nologin', '/usr/sbin/nologin', ],
582 ]
583 foreach prog : progs
584 path = get_option(prog[0] + '-path')
585 if path != ''
586 message('Using @1@ for @0@'.format(prog[0], path))
587 else
588 exe = find_program(prog[0],
589 '/usr/sbin/' + prog[0],
590 '/sbin/' + prog[0],
591 required: false)
592 path = exe.found() ? exe.path() : prog[1]
593 endif
594 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
595 conf.set_quoted(name, path)
596 substs.set(name, path)
597 endforeach
598
599 conf.set_quoted('TELINIT', get_option('telinit-path'))
600
601 if run_command('ln', '--relative', '--help').returncode() != 0
602 error('ln does not support --relative (added in coreutils 8.16)')
603 endif
604
605 ############################################################
606
607 gperf = find_program('gperf')
608
609 gperf_test_format = '''
610 #include <string.h>
611 const char * in_word_set(const char *, @0@);
612 @1@
613 '''
614 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
615 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
616 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
617 if cc.compiles(gperf_test)
618 gperf_len_type = 'size_t'
619 else
620 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
621 if cc.compiles(gperf_test)
622 gperf_len_type = 'unsigned'
623 else
624 error('unable to determine gperf len type')
625 endif
626 endif
627 message('gperf len type is @0@'.format(gperf_len_type))
628 conf.set('GPERF_LEN_TYPE', gperf_len_type,
629 description : 'The type of gperf "len" parameter')
630
631 ############################################################
632
633 if not cc.has_header('sys/capability.h')
634 error('POSIX caps headers not found')
635 endif
636 foreach header : ['crypt.h',
637 'linux/memfd.h',
638 'linux/vm_sockets.h',
639 'sys/auxv.h',
640 'valgrind/memcheck.h',
641 'valgrind/valgrind.h',
642 ]
643
644 conf.set10('HAVE_' + header.underscorify().to_upper(),
645 cc.has_header(header))
646 endforeach
647
648 ############################################################
649
650 fallback_hostname = get_option('fallback-hostname')
651 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
652 error('Invalid fallback-hostname configuration')
653 # A more extensive test is done in test-hostname-util. Let's catch
654 # the most obvious errors here so we don't fail with an assert later.
655 endif
656 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
657
658 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
659 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
660
661 default_hierarchy = get_option('default-hierarchy')
662 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
663 description : 'default cgroup hierarchy as string')
664 if default_hierarchy == 'legacy'
665 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
666 elif default_hierarchy == 'hybrid'
667 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
668 else
669 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
670 endif
671
672 default_net_naming_scheme = get_option('default-net-naming-scheme')
673 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
674
675 time_epoch = get_option('time-epoch')
676 if time_epoch == -1
677 source_date_epoch = run_command('sh', ['-c', 'echo "$SOURCE_DATE_EPOCH"']).stdout().strip()
678 if source_date_epoch != ''
679 time_epoch = source_date_epoch.to_int()
680 else
681 NEWS = files('NEWS')
682 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout().to_int()
683 endif
684 endif
685 conf.set('TIME_EPOCH', time_epoch)
686
687 system_uid_max = get_option('system-uid-max')
688 if system_uid_max == -1
689 system_uid_max = run_command(
690 awk,
691 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
692 '/etc/login.defs').stdout().strip()
693 if system_uid_max == ''
694 system_uid_max = 999
695 else
696 system_uid_max = system_uid_max.to_int()
697 endif
698 endif
699 conf.set('SYSTEM_UID_MAX', system_uid_max)
700 substs.set('systemuidmax', system_uid_max)
701
702 system_gid_max = get_option('system-gid-max')
703 if system_gid_max == -1
704 system_gid_max = run_command(
705 awk,
706 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
707 '/etc/login.defs').stdout().strip()
708 if system_gid_max == ''
709 system_gid_max = 999
710 else
711 system_gid_max = system_gid_max.to_int()
712 endif
713 endif
714 conf.set('SYSTEM_GID_MAX', system_gid_max)
715 substs.set('systemgidmax', system_gid_max)
716
717 dynamic_uid_min = get_option('dynamic-uid-min')
718 dynamic_uid_max = get_option('dynamic-uid-max')
719 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
720 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
721 substs.set('dynamicuidmin', dynamic_uid_min)
722 substs.set('dynamicuidmax', dynamic_uid_max)
723
724 container_uid_base_min = get_option('container-uid-base-min')
725 container_uid_base_max = get_option('container-uid-base-max')
726 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
727 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
728 substs.set('containeruidbasemin', container_uid_base_min)
729 substs.set('containeruidbasemax', container_uid_base_max)
730
731 nobody_user = get_option('nobody-user')
732 nobody_group = get_option('nobody-group')
733
734 if not meson.is_cross_build()
735 getent_result = run_command('getent', 'passwd', '65534')
736 if getent_result.returncode() == 0
737 name = getent_result.stdout().split(':')[0]
738 if name != nobody_user
739 warning('\n' +
740 '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) +
741 'Your build will result in an user table setup that is incompatible with the local system.')
742 endif
743 endif
744 id_result = run_command('id', '-u', nobody_user)
745 if id_result.returncode() == 0
746 id = id_result.stdout().to_int()
747 if id != 65534
748 warning('\n' +
749 '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) +
750 'Your build will result in an user table setup that is incompatible with the local system.')
751 endif
752 endif
753
754 getent_result = run_command('getent', 'group', '65534')
755 if getent_result.returncode() == 0
756 name = getent_result.stdout().split(':')[0]
757 if name != nobody_group
758 warning('\n' +
759 '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) +
760 'Your build will result in an group table setup that is incompatible with the local system.')
761 endif
762 endif
763 id_result = run_command('id', '-g', nobody_group)
764 if id_result.returncode() == 0
765 id = id_result.stdout().to_int()
766 if id != 65534
767 warning('\n' +
768 '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) +
769 'Your build will result in an group table setup that is incompatible with the local system.')
770 endif
771 endif
772 endif
773 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
774 warning('\n' +
775 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
776 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
777 endif
778
779 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
780 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
781 substs.set('NOBODY_USER_NAME', nobody_user)
782 substs.set('NOBODY_GROUP_NAME', nobody_group)
783
784 tty_gid = get_option('tty-gid')
785 conf.set('TTY_GID', tty_gid)
786 substs.set('TTY_GID', tty_gid)
787
788 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
789 users_gid = get_option('users-gid')
790 substs.set('USERS_GID', users_gid < 0 ? '-' : users_gid)
791
792 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
793 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
794
795 dev_kvm_mode = get_option('dev-kvm-mode')
796 substs.set('DEV_KVM_MODE', dev_kvm_mode)
797 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
798 group_render_mode = get_option('group-render-mode')
799 substs.set('GROUP_RENDER_MODE', group_render_mode)
800 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
801
802 kill_user_processes = get_option('default-kill-user-processes')
803 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
804 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
805 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
806
807 dns_servers = get_option('dns-servers')
808 conf.set_quoted('DNS_SERVERS', dns_servers)
809 substs.set('DNS_SERVERS', dns_servers)
810
811 ntp_servers = get_option('ntp-servers')
812 conf.set_quoted('NTP_SERVERS', ntp_servers)
813 substs.set('NTP_SERVERS', ntp_servers)
814
815 default_locale = get_option('default-locale')
816 if default_locale == ''
817 if not meson.is_cross_build()
818 choose_default_locale_sh = find_program('tools/choose-default-locale.sh')
819 default_locale = run_command(choose_default_locale_sh).stdout().strip()
820 else
821 default_locale = 'C.UTF-8'
822 endif
823 endif
824 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
825
826 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
827
828 service_watchdog = get_option('service-watchdog')
829 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
830 substs.set('SERVICE_WATCHDOG', watchdog_value)
831
832 substs.set('SUSHELL', get_option('debug-shell'))
833 substs.set('DEBUGTTY', get_option('debug-tty'))
834 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
835
836 enable_debug_hashmap = false
837 enable_debug_mmap_cache = false
838 enable_debug_siphash = false
839 foreach name : get_option('debug-extra')
840 if name == 'hashmap'
841 enable_debug_hashmap = true
842 elif name == 'mmap-cache'
843 enable_debug_mmap_cache = true
844 elif name == 'siphash'
845 enable_debug_siphash = true
846 else
847 message('unknown debug option "@0@", ignoring'.format(name))
848 endif
849 endforeach
850 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
851 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
852 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
853
854 conf.set10('VALGRIND', get_option('valgrind'))
855 conf.set10('LOG_TRACE', get_option('log-trace'))
856
857 default_user_path = get_option('user-path')
858 if default_user_path != ''
859 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
860 default_user_path_display = default_user_path
861 else
862 # meson 0.49 fails when ?: is used in .format()
863 default_user_path_display = '(same as system services)'
864 endif
865
866
867 #####################################################################
868
869 threads = dependency('threads')
870 librt = cc.find_library('rt')
871 libm = cc.find_library('m')
872 libdl = cc.find_library('dl')
873 libcrypt = cc.find_library('crypt')
874
875 libcap = dependency('libcap', required : false)
876 if not libcap.found()
877 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
878 libcap = cc.find_library('cap')
879 endif
880
881 libmount = dependency('mount',
882 version : fuzzer_build ? '>= 0' : '>= 2.30')
883
884 want_libfdisk = get_option('fdisk')
885 if want_libfdisk != 'false' and not skip_deps
886 libfdisk = dependency('fdisk',
887 required : want_libfdisk == 'true')
888 have = libfdisk.found()
889 else
890 have = false
891 libfdisk = []
892 endif
893 conf.set10('HAVE_LIBFDISK', have)
894
895 want_pwquality = get_option('pwquality')
896 if want_pwquality != 'false' and not skip_deps
897 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
898 have = libpwquality.found()
899 else
900 have = false
901 libpwquality = []
902 endif
903 conf.set10('HAVE_PWQUALITY', have)
904
905 want_seccomp = get_option('seccomp')
906 if want_seccomp != 'false' and not skip_deps
907 libseccomp = dependency('libseccomp',
908 version : '>= 2.3.1',
909 required : want_seccomp == 'true')
910 have = libseccomp.found()
911 else
912 have = false
913 libseccomp = []
914 endif
915 conf.set10('HAVE_SECCOMP', have)
916
917 want_selinux = get_option('selinux')
918 if want_selinux != 'false' and not skip_deps
919 libselinux = dependency('libselinux',
920 version : '>= 2.1.9',
921 required : want_selinux == 'true')
922 have = libselinux.found()
923 else
924 have = false
925 libselinux = []
926 endif
927 conf.set10('HAVE_SELINUX', have)
928
929 want_apparmor = get_option('apparmor')
930 if want_apparmor != 'false' and not skip_deps
931 libapparmor = dependency('libapparmor',
932 required : want_apparmor == 'true')
933 have = libapparmor.found()
934 else
935 have = false
936 libapparmor = []
937 endif
938 conf.set10('HAVE_APPARMOR', have)
939
940 smack_run_label = get_option('smack-run-label')
941 if smack_run_label != ''
942 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
943 endif
944
945 want_polkit = get_option('polkit')
946 install_polkit = false
947 install_polkit_pkla = false
948 if want_polkit != 'false' and not skip_deps
949 install_polkit = true
950
951 libpolkit = dependency('polkit-gobject-1',
952 required : false)
953 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
954 message('Old polkit detected, will install pkla files')
955 install_polkit_pkla = true
956 endif
957 endif
958 conf.set10('ENABLE_POLKIT', install_polkit)
959
960 want_acl = get_option('acl')
961 if want_acl != 'false' and not skip_deps
962 libacl = cc.find_library('acl', required : want_acl == 'true')
963 have = libacl.found()
964 else
965 have = false
966 libacl = []
967 endif
968 conf.set10('HAVE_ACL', have)
969
970 want_audit = get_option('audit')
971 if want_audit != 'false' and not skip_deps
972 libaudit = dependency('audit', required : want_audit == 'true')
973 have = libaudit.found()
974 else
975 have = false
976 libaudit = []
977 endif
978 conf.set10('HAVE_AUDIT', have)
979
980 want_blkid = get_option('blkid')
981 if want_blkid != 'false' and not skip_deps
982 libblkid = dependency('blkid', required : want_blkid == 'true')
983 have = libblkid.found()
984 else
985 have = false
986 libblkid = []
987 endif
988 conf.set10('HAVE_BLKID', have)
989
990 want_kmod = get_option('kmod')
991 if want_kmod != 'false' and not skip_deps
992 libkmod = dependency('libkmod',
993 version : '>= 15',
994 required : want_kmod == 'true')
995 have = libkmod.found()
996 else
997 have = false
998 libkmod = []
999 endif
1000 conf.set10('HAVE_KMOD', have)
1001
1002 want_pam = get_option('pam')
1003 if want_pam != 'false' and not skip_deps
1004 libpam = cc.find_library('pam', required : want_pam == 'true')
1005 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1006 have = libpam.found() and libpam_misc.found()
1007 else
1008 have = false
1009 libpam = []
1010 libpam_misc = []
1011 endif
1012 conf.set10('HAVE_PAM', have)
1013
1014 want_microhttpd = get_option('microhttpd')
1015 if want_microhttpd != 'false' and not skip_deps
1016 libmicrohttpd = dependency('libmicrohttpd',
1017 version : '>= 0.9.33',
1018 required : want_microhttpd == 'true')
1019 have = libmicrohttpd.found()
1020 else
1021 have = false
1022 libmicrohttpd = []
1023 endif
1024 conf.set10('HAVE_MICROHTTPD', have)
1025
1026 want_libcryptsetup = get_option('libcryptsetup')
1027 if want_libcryptsetup != 'false' and not skip_deps
1028 libcryptsetup = dependency('libcryptsetup',
1029 version : '>= 2.0.1',
1030 required : want_libcryptsetup == 'true')
1031 have = libcryptsetup.found()
1032
1033 conf.set10('HAVE_CRYPT_SET_METADATA_SIZE',
1034 have and cc.has_function('crypt_set_metadata_size', dependencies : libcryptsetup))
1035 else
1036 have = false
1037 libcryptsetup = []
1038 endif
1039 conf.set10('HAVE_LIBCRYPTSETUP', have)
1040
1041 want_libcurl = get_option('libcurl')
1042 if want_libcurl != 'false' and not skip_deps
1043 libcurl = dependency('libcurl',
1044 version : '>= 7.32.0',
1045 required : want_libcurl == 'true')
1046 have = libcurl.found()
1047 else
1048 have = false
1049 libcurl = []
1050 endif
1051 conf.set10('HAVE_LIBCURL', have)
1052
1053 want_libidn = get_option('libidn')
1054 want_libidn2 = get_option('libidn2')
1055 if want_libidn == 'true' and want_libidn2 == 'true'
1056 error('libidn and libidn2 cannot be requested simultaneously')
1057 endif
1058
1059 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1060 libidn = dependency('libidn2',
1061 required : want_libidn2 == 'true')
1062 have = libidn.found()
1063 else
1064 have = false
1065 libidn = []
1066 endif
1067 conf.set10('HAVE_LIBIDN2', have)
1068 if not have and want_libidn != 'false' and not skip_deps
1069 # libidn is used for both libidn and libidn2 objects
1070 libidn = dependency('libidn',
1071 required : want_libidn == 'true')
1072 have = libidn.found()
1073 else
1074 have = false
1075 endif
1076 conf.set10('HAVE_LIBIDN', have)
1077
1078 want_libiptc = get_option('libiptc')
1079 if want_libiptc != 'false' and not skip_deps
1080 libiptc = dependency('libiptc',
1081 required : want_libiptc == 'true')
1082 have = libiptc.found()
1083 else
1084 have = false
1085 libiptc = []
1086 endif
1087 conf.set10('HAVE_LIBIPTC', have)
1088
1089 want_qrencode = get_option('qrencode')
1090 if want_qrencode != 'false' and not skip_deps
1091 libqrencode = dependency('libqrencode',
1092 required : want_qrencode == 'true')
1093 have = libqrencode.found()
1094 else
1095 have = false
1096 libqrencode = []
1097 endif
1098 conf.set10('HAVE_QRENCODE', have)
1099
1100 want_gcrypt = get_option('gcrypt')
1101 if want_gcrypt != 'false' and not skip_deps
1102 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1103 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1104 have = libgcrypt.found() and libgpg_error.found()
1105 else
1106 have = false
1107 endif
1108 if not have
1109 # link to neither of the libs if one is not found
1110 libgcrypt = []
1111 libgpg_error = []
1112 endif
1113 conf.set10('HAVE_GCRYPT', have)
1114
1115 want_gnutls = get_option('gnutls')
1116 if want_gnutls != 'false' and not skip_deps
1117 libgnutls = dependency('gnutls',
1118 version : '>= 3.1.4',
1119 required : want_gnutls == 'true')
1120 have = libgnutls.found()
1121 else
1122 have = false
1123 libgnutls = []
1124 endif
1125 conf.set10('HAVE_GNUTLS', have)
1126
1127 want_openssl = get_option('openssl')
1128 if want_openssl != 'false' and not skip_deps
1129 libopenssl = dependency('openssl',
1130 version : '>= 1.1.0',
1131 required : want_openssl == 'true')
1132 have = libopenssl.found()
1133 else
1134 have = false
1135 libopenssl = []
1136 endif
1137 conf.set10('HAVE_OPENSSL', have)
1138
1139 want_p11kit = get_option('p11kit')
1140 if want_p11kit != 'false' and not skip_deps
1141 libp11kit = dependency('p11-kit-1',
1142 version : '>= 0.23.3',
1143 required : want_p11kit == 'true')
1144 have = libp11kit.found()
1145 else
1146 have = false
1147 libp11kit = []
1148 endif
1149 conf.set10('HAVE_P11KIT', have)
1150
1151 want_elfutils = get_option('elfutils')
1152 if want_elfutils != 'false' and not skip_deps
1153 libdw = dependency('libdw',
1154 required : want_elfutils == 'true')
1155 have = libdw.found()
1156 else
1157 have = false
1158 libdw = []
1159 endif
1160 conf.set10('HAVE_ELFUTILS', have)
1161
1162 want_zlib = get_option('zlib')
1163 if want_zlib != 'false' and not skip_deps
1164 libz = dependency('zlib',
1165 required : want_zlib == 'true')
1166 have = libz.found()
1167 else
1168 have = false
1169 libz = []
1170 endif
1171 conf.set10('HAVE_ZLIB', have)
1172
1173 want_bzip2 = get_option('bzip2')
1174 if want_bzip2 != 'false' and not skip_deps
1175 libbzip2 = cc.find_library('bz2',
1176 required : want_bzip2 == 'true')
1177 have = libbzip2.found()
1178 else
1179 have = false
1180 libbzip2 = []
1181 endif
1182 conf.set10('HAVE_BZIP2', have)
1183
1184 want_xz = get_option('xz')
1185 if want_xz != 'false' and not skip_deps
1186 libxz = dependency('liblzma',
1187 required : want_xz == 'true')
1188 have = libxz.found()
1189 else
1190 have = false
1191 libxz = []
1192 endif
1193 conf.set10('HAVE_XZ', have)
1194
1195 want_lz4 = get_option('lz4')
1196 if want_lz4 != 'false' and not skip_deps
1197 liblz4 = dependency('liblz4',
1198 version : '>= 1.3.0',
1199 required : want_lz4 == 'true')
1200 have = liblz4.found()
1201 else
1202 have = false
1203 liblz4 = []
1204 endif
1205 conf.set10('HAVE_LZ4', have)
1206
1207 want_zstd = get_option('zstd')
1208 if want_zstd != 'false' and not skip_deps
1209 libzstd = dependency('libzstd',
1210 required : want_zstd == 'true',
1211 version : '>= 1.4.0')
1212 have = libzstd.found()
1213 else
1214 have = false
1215 libzstd = []
1216 endif
1217 conf.set10('HAVE_ZSTD', have)
1218
1219 want_xkbcommon = get_option('xkbcommon')
1220 if want_xkbcommon != 'false' and not skip_deps
1221 libxkbcommon = dependency('xkbcommon',
1222 version : '>= 0.3.0',
1223 required : want_xkbcommon == 'true')
1224 have = libxkbcommon.found()
1225 else
1226 have = false
1227 libxkbcommon = []
1228 endif
1229 conf.set10('HAVE_XKBCOMMON', have)
1230
1231 want_pcre2 = get_option('pcre2')
1232 if want_pcre2 != 'false'
1233 libpcre2 = dependency('libpcre2-8',
1234 required : want_pcre2 == 'true')
1235 have = libpcre2.found()
1236 else
1237 have = false
1238 libpcre2 = []
1239 endif
1240 conf.set10('HAVE_PCRE2', have)
1241
1242 want_glib = get_option('glib')
1243 if want_glib != 'false' and not skip_deps
1244 libglib = dependency('glib-2.0',
1245 version : '>= 2.22.0',
1246 required : want_glib == 'true')
1247 libgobject = dependency('gobject-2.0',
1248 version : '>= 2.22.0',
1249 required : want_glib == 'true')
1250 libgio = dependency('gio-2.0',
1251 required : want_glib == 'true')
1252 have = libglib.found() and libgobject.found() and libgio.found()
1253 else
1254 have = false
1255 libglib = []
1256 libgobject = []
1257 libgio = []
1258 endif
1259 conf.set10('HAVE_GLIB', have)
1260
1261 want_dbus = get_option('dbus')
1262 if want_dbus != 'false' and not skip_deps
1263 libdbus = dependency('dbus-1',
1264 version : '>= 1.3.2',
1265 required : want_dbus == 'true')
1266 have = libdbus.found()
1267 else
1268 have = false
1269 libdbus = []
1270 endif
1271 conf.set10('HAVE_DBUS', have)
1272
1273 default_dnssec = get_option('default-dnssec')
1274 if skip_deps
1275 default_dnssec = 'no'
1276 endif
1277 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1278 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1279 default_dnssec = 'no'
1280 endif
1281 conf.set('DEFAULT_DNSSEC_MODE',
1282 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1283 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1284
1285 dns_over_tls = get_option('dns-over-tls')
1286 if dns_over_tls != 'false'
1287 if dns_over_tls == 'openssl'
1288 have_gnutls = false
1289 else
1290 have_gnutls = (conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0'))
1291 if dns_over_tls == 'gnutls' and not have_gnutls
1292 error('DNS-over-TLS support was requested with gnutls, but dependencies are not available')
1293 endif
1294 endif
1295 if dns_over_tls == 'gnutls' or have_gnutls
1296 have_openssl = false
1297 else
1298 have_openssl = conf.get('HAVE_OPENSSL') == 1
1299 if dns_over_tls != 'auto' and not have_openssl
1300 str = dns_over_tls == 'openssl' ? ' with openssl' : ''
1301 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1302 endif
1303 endif
1304 have = have_gnutls or have_openssl
1305 else
1306 have = false
1307 have_gnutls = false
1308 have_openssl = false
1309 endif
1310 conf.set10('ENABLE_DNS_OVER_TLS', have)
1311 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1312 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1313
1314 default_dns_over_tls = get_option('default-dns-over-tls')
1315 if skip_deps
1316 default_dns_over_tls = 'no'
1317 endif
1318 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1319 message('default-dns-over-tls cannot be enabled or set to opportunistic when DNS-over-TLS support is disabled. Setting default-dns-over-tls to no.')
1320 default_dns_over_tls = 'no'
1321 endif
1322 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1323 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1324 substs.set('DEFAULT_DNS_OVER_TLS_MODE', default_dns_over_tls)
1325
1326 default_mdns = get_option('default-mdns')
1327 conf.set('DEFAULT_MDNS_MODE',
1328 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1329 substs.set('DEFAULT_MDNS_MODE', default_mdns)
1330
1331 default_llmnr = get_option('default-llmnr')
1332 conf.set('DEFAULT_LLMNR_MODE',
1333 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1334 substs.set('DEFAULT_LLMNR_MODE', default_llmnr)
1335
1336 want_repart = get_option('repart')
1337 if want_repart != 'false'
1338 have = (conf.get('HAVE_OPENSSL') == 1 and
1339 conf.get('HAVE_LIBFDISK') == 1)
1340 if want_repart == 'true' and not have
1341 error('repart support was requested, but dependencies are not available')
1342 endif
1343 else
1344 have = false
1345 endif
1346 conf.set10('ENABLE_REPART', have)
1347
1348 want_importd = get_option('importd')
1349 if want_importd != 'false'
1350 have = (conf.get('HAVE_LIBCURL') == 1 and
1351 conf.get('HAVE_ZLIB') == 1 and
1352 conf.get('HAVE_XZ') == 1 and
1353 conf.get('HAVE_GCRYPT') == 1)
1354 if want_importd == 'true' and not have
1355 error('importd support was requested, but dependencies are not available')
1356 endif
1357 else
1358 have = false
1359 endif
1360 conf.set10('ENABLE_IMPORTD', have)
1361
1362 want_homed = get_option('homed')
1363 if want_homed != 'false'
1364 have = (conf.get('HAVE_OPENSSL') == 1 and
1365 conf.get('HAVE_LIBFDISK') == 1 and
1366 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1367 if want_homed == 'true' and not have
1368 error('homed support was requested, but dependencies are not available')
1369 endif
1370 else
1371 have = false
1372 endif
1373 conf.set10('ENABLE_HOMED', have)
1374
1375 have = have and conf.get('HAVE_PAM') == 1
1376 conf.set10('ENABLE_PAM_HOME', have)
1377
1378 want_remote = get_option('remote')
1379 if want_remote != 'false'
1380 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1381 conf.get('HAVE_LIBCURL') == 1]
1382 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1383 # it's possible to build one without the other. Complain only if
1384 # support was explicitly requested. The auxiliary files like sysusers
1385 # config should be installed when any of the programs are built.
1386 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1387 error('remote support was requested, but dependencies are not available')
1388 endif
1389 have = have_deps[0] or have_deps[1]
1390 else
1391 have = false
1392 endif
1393 conf.set10('ENABLE_REMOTE', have)
1394
1395 foreach term : ['utmp',
1396 'hibernate',
1397 'environment-d',
1398 'binfmt',
1399 'coredump',
1400 'pstore',
1401 'resolve',
1402 'logind',
1403 'hostnamed',
1404 'localed',
1405 'machined',
1406 'portabled',
1407 'userdb',
1408 'networkd',
1409 'timedated',
1410 'timesyncd',
1411 'firstboot',
1412 'randomseed',
1413 'backlight',
1414 'vconsole',
1415 'quotacheck',
1416 'sysusers',
1417 'tmpfiles',
1418 'hwdb',
1419 'rfkill',
1420 'ldconfig',
1421 'efi',
1422 'tpm',
1423 'ima',
1424 'smack',
1425 'gshadow',
1426 'idn',
1427 'initrd',
1428 'nss-myhostname',
1429 'nss-systemd']
1430 have = get_option(term)
1431 name = 'ENABLE_' + term.underscorify().to_upper()
1432 conf.set10(name, have)
1433 endforeach
1434
1435 foreach tuple : [['nss-mymachines', 'machined'],
1436 ['nss-resolve', 'resolve']]
1437 want = get_option(tuple[0])
1438 if want != 'false'
1439 have = get_option(tuple[1])
1440 if want == 'true' and not have
1441 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1442 endif
1443 else
1444 have = false
1445 endif
1446 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1447 conf.set10(name, have)
1448 endforeach
1449
1450 enable_nss = false
1451 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1452 'ENABLE_NSS_MYMACHINES',
1453 'ENABLE_NSS_RESOLVE',
1454 'ENABLE_NSS_SYSTEMD']
1455 if conf.get(term) == 1
1456 enable_nss = true
1457 endif
1458 endforeach
1459 conf.set10('ENABLE_NSS', enable_nss)
1460
1461 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1462
1463 tests = []
1464 fuzzers = []
1465
1466 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1467
1468 #####################################################################
1469
1470 if get_option('efi')
1471 efi_arch = host_machine.cpu_family()
1472
1473 if efi_arch == 'x86'
1474 EFI_MACHINE_TYPE_NAME = 'ia32'
1475 gnu_efi_arch = 'ia32'
1476 elif efi_arch == 'x86_64'
1477 EFI_MACHINE_TYPE_NAME = 'x64'
1478 gnu_efi_arch = 'x86_64'
1479 elif efi_arch == 'arm'
1480 EFI_MACHINE_TYPE_NAME = 'arm'
1481 gnu_efi_arch = 'arm'
1482 elif efi_arch == 'aarch64'
1483 EFI_MACHINE_TYPE_NAME = 'aa64'
1484 gnu_efi_arch = 'aarch64'
1485 else
1486 EFI_MACHINE_TYPE_NAME = ''
1487 gnu_efi_arch = ''
1488 endif
1489
1490 have = true
1491 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1492
1493 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
1494 else
1495 have = false
1496 endif
1497 conf.set10('ENABLE_EFI', have)
1498
1499 #####################################################################
1500
1501 config_h = configure_file(
1502 output : 'config.h',
1503 configuration : conf)
1504
1505 meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1506
1507 includes = include_directories('src/basic',
1508 'src/boot',
1509 'src/home',
1510 'src/shared',
1511 'src/systemd',
1512 'src/journal',
1513 'src/journal-remote',
1514 'src/nspawn',
1515 'src/resolve',
1516 'src/timesync',
1517 'src/time-wait-sync',
1518 'src/login',
1519 'src/udev',
1520 'src/libudev',
1521 'src/core',
1522 'src/shutdown',
1523 'src/libsystemd/sd-bus',
1524 'src/libsystemd/sd-device',
1525 'src/libsystemd/sd-event',
1526 'src/libsystemd/sd-hwdb',
1527 'src/libsystemd/sd-id128',
1528 'src/libsystemd/sd-netlink',
1529 'src/libsystemd/sd-network',
1530 'src/libsystemd/sd-resolve',
1531 'src/libsystemd-network',
1532 '.')
1533
1534 add_project_arguments('-include', 'config.h', language : 'c')
1535
1536 generate_gperfs = find_program('tools/generate-gperfs.py')
1537
1538 subdir('po')
1539 subdir('catalog')
1540 subdir('src/systemd')
1541 subdir('src/basic')
1542 subdir('src/libsystemd')
1543 subdir('src/libsystemd-network')
1544 subdir('src/journal')
1545 subdir('src/login')
1546
1547 libjournal_core = static_library(
1548 'journal-core',
1549 libjournal_core_sources,
1550 journald_gperf_c,
1551 include_directories : includes,
1552 install : false)
1553
1554 libsystemd_sym_path = '@0@/@1@'.format(project_source_root, libsystemd_sym)
1555 libsystemd = shared_library(
1556 'systemd',
1557 disable_mempool_c,
1558 version : libsystemd_version,
1559 include_directories : includes,
1560 link_args : ['-shared',
1561 '-Wl,--version-script=' + libsystemd_sym_path],
1562 link_with : [libbasic,
1563 libbasic_gcrypt],
1564 link_whole : [libsystemd_static,
1565 libjournal_client],
1566 dependencies : [threads,
1567 librt,
1568 libxz,
1569 libzstd,
1570 liblz4],
1571 link_depends : libsystemd_sym,
1572 install : true,
1573 install_dir : rootlibdir)
1574
1575 static_libsystemd = get_option('static-libsystemd')
1576 static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1577
1578 install_libsystemd_static = static_library(
1579 'systemd',
1580 libsystemd_sources,
1581 journal_client_sources,
1582 basic_sources,
1583 basic_gcrypt_sources,
1584 disable_mempool_c,
1585 include_directories : includes,
1586 build_by_default : static_libsystemd != 'false',
1587 install : static_libsystemd != 'false',
1588 install_dir : rootlibdir,
1589 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1590 dependencies : [threads,
1591 librt,
1592 libxz,
1593 libzstd,
1594 liblz4,
1595 libcap,
1596 libblkid,
1597 libmount,
1598 libselinux,
1599 libgcrypt],
1600 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1601
1602 # Generate autosuspend rules
1603 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1604
1605 ############################################################
1606
1607 # binaries that have --help and are intended for use by humans,
1608 # usually, but not always, installed in /bin.
1609 public_programs = []
1610
1611 subdir('src/libudev')
1612 subdir('src/shared')
1613 subdir('src/core')
1614 subdir('src/shutdown')
1615 subdir('src/udev')
1616 subdir('src/network')
1617
1618 subdir('src/analyze')
1619 subdir('src/journal-remote')
1620 subdir('src/coredump')
1621 subdir('src/pstore')
1622 subdir('src/hostname')
1623 subdir('src/import')
1624 subdir('src/partition')
1625 subdir('src/kernel-install')
1626 subdir('src/locale')
1627 subdir('src/machine')
1628 subdir('src/portable')
1629 subdir('src/userdb')
1630 subdir('src/home')
1631 subdir('src/nspawn')
1632 subdir('src/resolve')
1633 subdir('src/timedate')
1634 subdir('src/timesync')
1635 subdir('src/vconsole')
1636 subdir('src/boot/efi')
1637
1638 subdir('src/test')
1639 subdir('src/fuzz')
1640 subdir('rules.d')
1641 subdir('test')
1642
1643 ############################################################
1644
1645 # only static linking apart from libdl, to make sure that the
1646 # module is linked to all libraries that it uses.
1647 test_dlopen = executable(
1648 'test-dlopen',
1649 test_dlopen_c,
1650 disable_mempool_c,
1651 include_directories : includes,
1652 link_with : [libbasic],
1653 dependencies : [libdl],
1654 build_by_default : want_tests != 'false')
1655
1656 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
1657 ['systemd', 'ENABLE_NSS_SYSTEMD', 'src/nss-systemd/userdb-glue.c src/nss-systemd/userdb-glue.h'],
1658 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
1659 ['resolve', 'ENABLE_NSS_RESOLVE']]
1660
1661 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1662 if condition
1663 module = tuple[0]
1664
1665 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1666 version_script_arg = join_paths(project_source_root, sym)
1667
1668 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
1669 if tuple.length() > 2
1670 sources += tuple[2].split()
1671 endif
1672
1673 nss = shared_library(
1674 'nss_' + module,
1675 sources,
1676 disable_mempool_c,
1677 version : '2',
1678 include_directories : includes,
1679 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1680 link_args : ['-Wl,-z,nodelete',
1681 '-shared',
1682 '-Wl,--version-script=' + version_script_arg],
1683 link_with : [libsystemd_static,
1684 libshared_static,
1685 libbasic],
1686 dependencies : [threads,
1687 librt],
1688 link_depends : sym,
1689 install : true,
1690 install_dir : rootlibdir)
1691
1692 # We cannot use shared_module because it does not support version suffix.
1693 # Unfortunately shared_library insists on creating the symlink…
1694 meson.add_install_script('sh', '-c',
1695 'rm $DESTDIR@0@/libnss_@1@.so'
1696 .format(rootlibdir, module))
1697
1698 if want_tests != 'false'
1699 test('dlopen-nss_' + module,
1700 test_dlopen,
1701 # path to dlopen must include a slash
1702 args : nss.full_path())
1703 endif
1704 endif
1705 endforeach
1706
1707 ############################################################
1708
1709 executable(
1710 'systemd',
1711 systemd_sources,
1712 include_directories : includes,
1713 link_with : [libcore,
1714 libshared],
1715 dependencies : [versiondep,
1716 threads,
1717 librt,
1718 libseccomp,
1719 libselinux,
1720 libmount,
1721 libblkid],
1722 install_rpath : rootlibexecdir,
1723 install : true,
1724 install_dir : rootlibexecdir)
1725
1726 meson.add_install_script(meson_make_symlink,
1727 join_paths(rootlibexecdir, 'systemd'),
1728 join_paths(rootsbindir, 'init'))
1729
1730 public_programs += executable(
1731 'systemd-analyze',
1732 systemd_analyze_sources,
1733 include_directories : includes,
1734 link_with : [libcore,
1735 libshared],
1736 dependencies : [versiondep,
1737 threads,
1738 librt,
1739 libseccomp,
1740 libselinux,
1741 libmount,
1742 libblkid],
1743 install_rpath : rootlibexecdir,
1744 install : get_option('analyze'))
1745
1746 executable(
1747 'systemd-journald',
1748 systemd_journald_sources,
1749 include_directories : includes,
1750 link_with : [libjournal_core,
1751 libshared],
1752 dependencies : [threads,
1753 libxz,
1754 liblz4,
1755 libselinux,
1756 libzstd],
1757 install_rpath : rootlibexecdir,
1758 install : true,
1759 install_dir : rootlibexecdir)
1760
1761 public_programs += executable(
1762 'systemd-cat',
1763 systemd_cat_sources,
1764 include_directories : includes,
1765 link_with : [libjournal_core,
1766 libshared],
1767 dependencies : [threads],
1768 install_rpath : rootlibexecdir,
1769 install : true)
1770
1771 public_programs += executable(
1772 'journalctl',
1773 journalctl_sources,
1774 include_directories : includes,
1775 link_with : [libshared],
1776 dependencies : [threads,
1777 libqrencode,
1778 libxz,
1779 liblz4,
1780 libpcre2,
1781 libzstd],
1782 install_rpath : rootlibexecdir,
1783 install : true,
1784 install_dir : rootbindir)
1785
1786 executable(
1787 'systemd-getty-generator',
1788 'src/getty-generator/getty-generator.c',
1789 include_directories : includes,
1790 link_with : [libshared],
1791 install_rpath : rootlibexecdir,
1792 install : true,
1793 install_dir : systemgeneratordir)
1794
1795 executable(
1796 'systemd-debug-generator',
1797 'src/debug-generator/debug-generator.c',
1798 include_directories : includes,
1799 link_with : [libshared],
1800 install_rpath : rootlibexecdir,
1801 install : true,
1802 install_dir : systemgeneratordir)
1803
1804 executable(
1805 'systemd-run-generator',
1806 'src/run-generator/run-generator.c',
1807 include_directories : includes,
1808 link_with : [libshared],
1809 install_rpath : rootlibexecdir,
1810 install : true,
1811 install_dir : systemgeneratordir)
1812
1813 executable(
1814 'systemd-fstab-generator',
1815 'src/fstab-generator/fstab-generator.c',
1816 include_directories : includes,
1817 link_with : [libcore_shared,
1818 libshared],
1819 install_rpath : rootlibexecdir,
1820 install : true,
1821 install_dir : systemgeneratordir)
1822
1823 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1824 executable(
1825 '30-systemd-environment-d-generator',
1826 'src/environment-d-generator/environment-d-generator.c',
1827 include_directories : includes,
1828 link_with : [libshared],
1829 install_rpath : rootlibexecdir,
1830 install : true,
1831 install_dir : userenvgeneratordir)
1832
1833 meson.add_install_script(meson_make_symlink,
1834 join_paths(sysconfdir, 'environment'),
1835 join_paths(environmentdir, '99-environment.conf'))
1836 endif
1837
1838 if conf.get('ENABLE_HIBERNATE') == 1
1839 executable(
1840 'systemd-hibernate-resume-generator',
1841 'src/hibernate-resume/hibernate-resume-generator.c',
1842 include_directories : includes,
1843 link_with : [libshared],
1844 install_rpath : rootlibexecdir,
1845 install : true,
1846 install_dir : systemgeneratordir)
1847
1848 executable(
1849 'systemd-hibernate-resume',
1850 'src/hibernate-resume/hibernate-resume.c',
1851 include_directories : includes,
1852 link_with : [libshared],
1853 install_rpath : rootlibexecdir,
1854 install : true,
1855 install_dir : rootlibexecdir)
1856 endif
1857
1858 if conf.get('HAVE_BLKID') == 1
1859 executable(
1860 'systemd-gpt-auto-generator',
1861 'src/gpt-auto-generator/gpt-auto-generator.c',
1862 'src/shared/blkid-util.h',
1863 include_directories : includes,
1864 link_with : [libshared],
1865 dependencies : libblkid,
1866 install_rpath : rootlibexecdir,
1867 install : true,
1868 install_dir : systemgeneratordir)
1869
1870 public_programs += executable(
1871 'systemd-dissect',
1872 'src/dissect/dissect.c',
1873 include_directories : includes,
1874 link_with : [libshared],
1875 install_rpath : rootlibexecdir,
1876 install : true,
1877 install_dir : rootlibexecdir)
1878 endif
1879
1880 if conf.get('ENABLE_RESOLVE') == 1
1881 executable(
1882 'systemd-resolved',
1883 systemd_resolved_sources,
1884 include_directories : includes,
1885 link_with : [libshared,
1886 libbasic_gcrypt,
1887 libsystemd_resolve_core],
1888 dependencies : systemd_resolved_dependencies,
1889 install_rpath : rootlibexecdir,
1890 install : true,
1891 install_dir : rootlibexecdir)
1892
1893 public_programs += executable(
1894 'resolvectl',
1895 resolvectl_sources,
1896 include_directories : includes,
1897 link_with : [libshared,
1898 libbasic_gcrypt,
1899 libsystemd_resolve_core],
1900 dependencies : [threads,
1901 libgpg_error,
1902 libm,
1903 libidn],
1904 install_rpath : rootlibexecdir,
1905 install : true)
1906
1907 meson.add_install_script(meson_make_symlink,
1908 join_paths(bindir, 'resolvectl'),
1909 join_paths(rootsbindir, 'resolvconf'))
1910
1911 meson.add_install_script(meson_make_symlink,
1912 join_paths(bindir, 'resolvectl'),
1913 join_paths(bindir, 'systemd-resolve'))
1914 endif
1915
1916 if conf.get('ENABLE_LOGIND') == 1
1917 executable(
1918 'systemd-logind',
1919 systemd_logind_sources,
1920 include_directories : includes,
1921 link_with : [liblogind_core,
1922 libshared],
1923 dependencies : [threads,
1924 libacl],
1925 install_rpath : rootlibexecdir,
1926 install : true,
1927 install_dir : rootlibexecdir)
1928
1929 public_programs += executable(
1930 'loginctl',
1931 loginctl_sources,
1932 include_directories : includes,
1933 link_with : [libshared],
1934 dependencies : [threads,
1935 liblz4,
1936 libxz,
1937 libzstd],
1938 install_rpath : rootlibexecdir,
1939 install : true,
1940 install_dir : rootbindir)
1941
1942 public_programs += executable(
1943 'systemd-inhibit',
1944 'src/login/inhibit.c',
1945 include_directories : includes,
1946 link_with : [libshared],
1947 install_rpath : rootlibexecdir,
1948 install : true,
1949 install_dir : rootbindir)
1950
1951 if conf.get('HAVE_PAM') == 1
1952 version_script_arg = join_paths(project_source_root, pam_systemd_sym)
1953 pam_systemd = shared_library(
1954 'pam_systemd',
1955 pam_systemd_c,
1956 name_prefix : '',
1957 include_directories : includes,
1958 link_args : ['-shared',
1959 '-Wl,--version-script=' + version_script_arg],
1960 link_with : [libsystemd_static,
1961 libshared_static],
1962 dependencies : [threads,
1963 libpam,
1964 libpam_misc],
1965 link_depends : pam_systemd_sym,
1966 install : true,
1967 install_dir : pamlibdir)
1968
1969 if want_tests != 'false'
1970 test('dlopen-pam_systemd',
1971 test_dlopen,
1972 # path to dlopen must include a slash
1973 args : pam_systemd.full_path())
1974 endif
1975 endif
1976
1977 executable(
1978 'systemd-user-runtime-dir',
1979 user_runtime_dir_sources,
1980 include_directories : includes,
1981 link_with : [libshared],
1982 install_rpath : rootlibexecdir,
1983 install : true,
1984 install_dir : rootlibexecdir)
1985 endif
1986
1987 if conf.get('HAVE_PAM') == 1
1988 executable(
1989 'systemd-user-sessions',
1990 'src/user-sessions/user-sessions.c',
1991 include_directories : includes,
1992 link_with : [libshared],
1993 install_rpath : rootlibexecdir,
1994 install : true,
1995 install_dir : rootlibexecdir)
1996 endif
1997
1998 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1999 public_programs += executable(
2000 'bootctl',
2001 'src/boot/bootctl.c',
2002 include_directories : includes,
2003 link_with : [libshared],
2004 dependencies : [libblkid],
2005 install_rpath : rootlibexecdir,
2006 install : true)
2007
2008 public_programs += executable(
2009 'systemd-bless-boot',
2010 'src/boot/bless-boot.c',
2011 include_directories : includes,
2012 link_with : [libshared],
2013 dependencies : [libblkid],
2014 install_rpath : rootlibexecdir,
2015 install : true,
2016 install_dir : rootlibexecdir)
2017
2018 executable(
2019 'systemd-bless-boot-generator',
2020 'src/boot/bless-boot-generator.c',
2021 include_directories : includes,
2022 link_with : [libshared],
2023 install_rpath : rootlibexecdir,
2024 install : true,
2025 install_dir : systemgeneratordir)
2026 endif
2027
2028 executable(
2029 'systemd-boot-check-no-failures',
2030 'src/boot/boot-check-no-failures.c',
2031 include_directories : includes,
2032 link_with : [libshared],
2033 dependencies : [libblkid],
2034 install_rpath : rootlibexecdir,
2035 install : true,
2036 install_dir : rootlibexecdir)
2037
2038 public_programs += executable(
2039 'systemd-socket-activate',
2040 'src/activate/activate.c',
2041 include_directories : includes,
2042 link_with : [libshared],
2043 dependencies : [threads],
2044 install_rpath : rootlibexecdir,
2045 install : true)
2046
2047 if get_option('link-systemctl-shared')
2048 systemctl_link_with = [libshared]
2049 else
2050 systemctl_link_with = [libsystemd_static,
2051 libshared_static,
2052 libjournal_client,
2053 libbasic_gcrypt]
2054 endif
2055
2056 public_programs += executable(
2057 'systemctl',
2058 'src/systemctl/systemctl.c',
2059 'src/systemctl/sysv-compat.h',
2060 'src/systemctl/sysv-compat.c',
2061 include_directories : includes,
2062 link_with : systemctl_link_with,
2063 dependencies : [threads,
2064 libcap,
2065 libselinux,
2066 libxz,
2067 liblz4,
2068 libzstd],
2069 install_rpath : rootlibexecdir,
2070 install : true,
2071 install_dir : rootbindir)
2072
2073 if conf.get('ENABLE_PORTABLED') == 1
2074 executable(
2075 'systemd-portabled',
2076 systemd_portabled_sources,
2077 include_directories : includes,
2078 link_with : [libshared],
2079 dependencies : [threads],
2080 install_rpath : rootlibexecdir,
2081 install : true,
2082 install_dir : rootlibexecdir)
2083
2084 public_programs += executable(
2085 'portablectl',
2086 'src/portable/portablectl.c',
2087 include_directories : includes,
2088 link_with : [libshared],
2089 dependencies : [threads],
2090 install_rpath : rootlibexecdir,
2091 install : true,
2092 install_dir : rootbindir)
2093 endif
2094
2095 if conf.get('ENABLE_USERDB') == 1
2096 executable(
2097 'systemd-userwork',
2098 systemd_userwork_sources,
2099 include_directories : includes,
2100 link_with : [libshared],
2101 dependencies : [threads],
2102 install_rpath : rootlibexecdir,
2103 install : true,
2104 install_dir : rootlibexecdir)
2105
2106 executable(
2107 'systemd-userdbd',
2108 systemd_userdbd_sources,
2109 include_directories : includes,
2110 link_with : [libshared],
2111 dependencies : [threads],
2112 install_rpath : rootlibexecdir,
2113 install : true,
2114 install_dir : rootlibexecdir)
2115
2116 public_programs += executable(
2117 'userdbctl',
2118 userdbctl_sources,
2119 include_directories : includes,
2120 link_with : [libshared],
2121 dependencies : [threads],
2122 install_rpath : rootlibexecdir,
2123 install : true,
2124 install_dir : rootbindir)
2125 endif
2126
2127 if conf.get('ENABLE_HOMED') == 1
2128 executable(
2129 'systemd-homework',
2130 systemd_homework_sources,
2131 include_directories : includes,
2132 link_with : [libshared],
2133 dependencies : [threads,
2134 libcryptsetup,
2135 libblkid,
2136 libcrypt,
2137 libopenssl,
2138 libfdisk,
2139 libp11kit],
2140 install_rpath : rootlibexecdir,
2141 install : true,
2142 install_dir : rootlibexecdir)
2143
2144 executable(
2145 'systemd-homed',
2146 systemd_homed_sources,
2147 include_directories : includes,
2148 link_with : [libshared],
2149 dependencies : [threads,
2150 libcrypt,
2151 libopenssl,
2152 libpwquality],
2153 install_rpath : rootlibexecdir,
2154 install : true,
2155 install_dir : rootlibexecdir)
2156
2157 public_programs += executable(
2158 'homectl',
2159 homectl_sources,
2160 include_directories : includes,
2161 link_with : [libshared],
2162 dependencies : [threads,
2163 libcrypt,
2164 libopenssl,
2165 libp11kit,
2166 libpwquality],
2167 install_rpath : rootlibexecdir,
2168 install : true,
2169 install_dir : rootbindir)
2170
2171 if conf.get('HAVE_PAM') == 1
2172 version_script_arg = join_paths(project_source_root, pam_systemd_home_sym)
2173 pam_systemd = shared_library(
2174 'pam_systemd_home',
2175 pam_systemd_home_c,
2176 name_prefix : '',
2177 include_directories : includes,
2178 link_args : ['-shared',
2179 '-Wl,--version-script=' + version_script_arg],
2180 link_with : [libsystemd_static,
2181 libshared_static],
2182 dependencies : [threads,
2183 libpam,
2184 libpam_misc,
2185 libcrypt],
2186 link_depends : pam_systemd_home_sym,
2187 install : true,
2188 install_dir : pamlibdir)
2189 endif
2190 endif
2191
2192 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
2193 meson.add_install_script(meson_make_symlink,
2194 join_paths(rootbindir, 'systemctl'),
2195 join_paths(rootsbindir, alias))
2196 endforeach
2197
2198 if conf.get('ENABLE_BACKLIGHT') == 1
2199 executable(
2200 'systemd-backlight',
2201 'src/backlight/backlight.c',
2202 include_directories : includes,
2203 link_with : [libshared],
2204 install_rpath : rootlibexecdir,
2205 install : true,
2206 install_dir : rootlibexecdir)
2207 endif
2208
2209 if conf.get('ENABLE_RFKILL') == 1
2210 executable(
2211 'systemd-rfkill',
2212 'src/rfkill/rfkill.c',
2213 include_directories : includes,
2214 link_with : [libshared],
2215 install_rpath : rootlibexecdir,
2216 install : true,
2217 install_dir : rootlibexecdir)
2218 endif
2219
2220 executable(
2221 'systemd-system-update-generator',
2222 'src/system-update-generator/system-update-generator.c',
2223 include_directories : includes,
2224 link_with : [libshared],
2225 install_rpath : rootlibexecdir,
2226 install : true,
2227 install_dir : systemgeneratordir)
2228
2229 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2230 systemd_cryptsetup_sources = files('''
2231 src/cryptsetup/cryptsetup-pkcs11.h
2232 src/cryptsetup/cryptsetup-util.c
2233 src/cryptsetup/cryptsetup-util.h
2234 src/cryptsetup/cryptsetup.c
2235 '''.split())
2236
2237 if conf.get('HAVE_P11KIT') == 1
2238 systemd_cryptsetup_sources += files('src/cryptsetup/cryptsetup-pkcs11.c')
2239 endif
2240
2241 executable(
2242 'systemd-cryptsetup',
2243 systemd_cryptsetup_sources,
2244 include_directories : includes,
2245 link_with : [libshared],
2246 dependencies : [libcryptsetup,
2247 libp11kit],
2248 install_rpath : rootlibexecdir,
2249 install : true,
2250 install_dir : rootlibexecdir)
2251
2252 executable(
2253 'systemd-cryptsetup-generator',
2254 'src/cryptsetup/cryptsetup-generator.c',
2255 include_directories : includes,
2256 link_with : [libshared],
2257 dependencies : [libcryptsetup],
2258 install_rpath : rootlibexecdir,
2259 install : true,
2260 install_dir : systemgeneratordir)
2261
2262 executable(
2263 'systemd-veritysetup',
2264 'src/veritysetup/veritysetup.c',
2265 include_directories : includes,
2266 link_with : [libshared],
2267 dependencies : [libcryptsetup],
2268 install_rpath : rootlibexecdir,
2269 install : true,
2270 install_dir : rootlibexecdir)
2271
2272 executable(
2273 'systemd-veritysetup-generator',
2274 'src/veritysetup/veritysetup-generator.c',
2275 include_directories : includes,
2276 link_with : [libshared],
2277 dependencies : [libcryptsetup],
2278 install_rpath : rootlibexecdir,
2279 install : true,
2280 install_dir : systemgeneratordir)
2281 endif
2282
2283 if conf.get('HAVE_SYSV_COMPAT') == 1
2284 executable(
2285 'systemd-sysv-generator',
2286 'src/sysv-generator/sysv-generator.c',
2287 include_directories : includes,
2288 link_with : [libshared],
2289 install_rpath : rootlibexecdir,
2290 install : true,
2291 install_dir : systemgeneratordir)
2292
2293 executable(
2294 'systemd-rc-local-generator',
2295 'src/rc-local-generator/rc-local-generator.c',
2296 include_directories : includes,
2297 link_with : [libshared],
2298 install_rpath : rootlibexecdir,
2299 install : true,
2300 install_dir : systemgeneratordir)
2301 endif
2302
2303 if conf.get('ENABLE_HOSTNAMED') == 1
2304 executable(
2305 'systemd-hostnamed',
2306 'src/hostname/hostnamed.c',
2307 include_directories : includes,
2308 link_with : [libshared],
2309 install_rpath : rootlibexecdir,
2310 install : true,
2311 install_dir : rootlibexecdir)
2312
2313 public_programs += executable(
2314 'hostnamectl',
2315 'src/hostname/hostnamectl.c',
2316 include_directories : includes,
2317 link_with : [libshared],
2318 install_rpath : rootlibexecdir,
2319 install : true)
2320 endif
2321
2322 if conf.get('ENABLE_LOCALED') == 1
2323 if conf.get('HAVE_XKBCOMMON') == 1
2324 # logind will load libxkbcommon.so dynamically on its own
2325 deps = [libdl]
2326 else
2327 deps = []
2328 endif
2329
2330 executable(
2331 'systemd-localed',
2332 systemd_localed_sources,
2333 include_directories : includes,
2334 link_with : [libshared],
2335 dependencies : deps,
2336 install_rpath : rootlibexecdir,
2337 install : true,
2338 install_dir : rootlibexecdir)
2339
2340 public_programs += executable(
2341 'localectl',
2342 localectl_sources,
2343 include_directories : includes,
2344 link_with : [libshared],
2345 install_rpath : rootlibexecdir,
2346 install : true)
2347 endif
2348
2349 if conf.get('ENABLE_TIMEDATED') == 1
2350 executable(
2351 'systemd-timedated',
2352 'src/timedate/timedated.c',
2353 include_directories : includes,
2354 link_with : [libshared],
2355 install_rpath : rootlibexecdir,
2356 install : true,
2357 install_dir : rootlibexecdir)
2358 endif
2359
2360 if conf.get('ENABLE_TIMEDATECTL') == 1
2361 public_programs += executable(
2362 'timedatectl',
2363 'src/timedate/timedatectl.c',
2364 include_directories : includes,
2365 install_rpath : rootlibexecdir,
2366 link_with : [libshared],
2367 dependencies : [libm],
2368 install : true)
2369 endif
2370
2371 if conf.get('ENABLE_TIMESYNCD') == 1
2372 if get_option('link-timesyncd-shared')
2373 timesyncd_link_with = [libshared]
2374 else
2375 timesyncd_link_with = [libsystemd_static,
2376 libshared_static,
2377 libjournal_client,
2378 libbasic_gcrypt]
2379 endif
2380
2381 executable(
2382 'systemd-timesyncd',
2383 systemd_timesyncd_sources,
2384 include_directories : includes,
2385 link_with : [timesyncd_link_with],
2386 dependencies : [threads,
2387 libm],
2388 install_rpath : rootlibexecdir,
2389 install : true,
2390 install_dir : rootlibexecdir)
2391
2392 executable(
2393 'systemd-time-wait-sync',
2394 'src/time-wait-sync/time-wait-sync.c',
2395 include_directories : includes,
2396 link_with : [timesyncd_link_with],
2397 install_rpath : rootlibexecdir,
2398 install : true,
2399 install_dir : rootlibexecdir)
2400 endif
2401
2402 if conf.get('ENABLE_MACHINED') == 1
2403 executable(
2404 'systemd-machined',
2405 systemd_machined_sources,
2406 include_directories : includes,
2407 link_with : [libmachine_core,
2408 libshared],
2409 install_rpath : rootlibexecdir,
2410 install : true,
2411 install_dir : rootlibexecdir)
2412
2413 public_programs += executable(
2414 'machinectl',
2415 'src/machine/machinectl.c',
2416 include_directories : includes,
2417 link_with : [libshared],
2418 dependencies : [threads,
2419 libxz,
2420 liblz4,
2421 libzstd],
2422 install_rpath : rootlibexecdir,
2423 install : true,
2424 install_dir : rootbindir)
2425 endif
2426
2427 if conf.get('ENABLE_IMPORTD') == 1
2428 executable(
2429 'systemd-importd',
2430 systemd_importd_sources,
2431 include_directories : includes,
2432 link_with : [libshared],
2433 dependencies : [threads],
2434 install_rpath : rootlibexecdir,
2435 install : true,
2436 install_dir : rootlibexecdir)
2437
2438 systemd_pull = executable(
2439 'systemd-pull',
2440 systemd_pull_sources,
2441 include_directories : includes,
2442 link_with : [libshared],
2443 dependencies : [versiondep,
2444 libcurl,
2445 libz,
2446 libbzip2,
2447 libxz,
2448 libgcrypt],
2449 install_rpath : rootlibexecdir,
2450 install : true,
2451 install_dir : rootlibexecdir)
2452
2453 systemd_import = executable(
2454 'systemd-import',
2455 systemd_import_sources,
2456 include_directories : includes,
2457 link_with : [libshared],
2458 dependencies : [libcurl,
2459 libz,
2460 libbzip2,
2461 libxz],
2462 install_rpath : rootlibexecdir,
2463 install : true,
2464 install_dir : rootlibexecdir)
2465
2466 systemd_import_fs = executable(
2467 'systemd-import-fs',
2468 systemd_import_fs_sources,
2469 include_directories : includes,
2470 link_with : [libshared],
2471 install_rpath : rootlibexecdir,
2472 install : true,
2473 install_dir : rootlibexecdir)
2474
2475 systemd_export = executable(
2476 'systemd-export',
2477 systemd_export_sources,
2478 include_directories : includes,
2479 link_with : [libshared],
2480 dependencies : [libcurl,
2481 libz,
2482 libbzip2,
2483 libxz],
2484 install_rpath : rootlibexecdir,
2485 install : true,
2486 install_dir : rootlibexecdir)
2487
2488 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
2489 endif
2490
2491 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
2492 public_programs += executable(
2493 'systemd-journal-upload',
2494 systemd_journal_upload_sources,
2495 include_directories : includes,
2496 link_with : [libshared],
2497 dependencies : [versiondep,
2498 threads,
2499 libcurl,
2500 libgnutls,
2501 libxz,
2502 liblz4,
2503 libzstd],
2504 install_rpath : rootlibexecdir,
2505 install : true,
2506 install_dir : rootlibexecdir)
2507 endif
2508
2509 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
2510 public_programs += executable(
2511 'systemd-journal-remote',
2512 systemd_journal_remote_sources,
2513 include_directories : includes,
2514 link_with : [libshared,
2515 libsystemd_journal_remote],
2516 dependencies : [threads,
2517 libmicrohttpd,
2518 libgnutls,
2519 libxz,
2520 liblz4,
2521 libzstd],
2522 install_rpath : rootlibexecdir,
2523 install : true,
2524 install_dir : rootlibexecdir)
2525
2526 public_programs += executable(
2527 'systemd-journal-gatewayd',
2528 systemd_journal_gatewayd_sources,
2529 include_directories : includes,
2530 link_with : [libshared],
2531 dependencies : [threads,
2532 libmicrohttpd,
2533 libgnutls,
2534 libxz,
2535 liblz4,
2536 libzstd],
2537 install_rpath : rootlibexecdir,
2538 install : true,
2539 install_dir : rootlibexecdir)
2540 endif
2541
2542 if conf.get('ENABLE_COREDUMP') == 1
2543 executable(
2544 'systemd-coredump',
2545 systemd_coredump_sources,
2546 include_directories : includes,
2547 link_with : [libshared],
2548 dependencies : [threads,
2549 libacl,
2550 libdw,
2551 libxz,
2552 liblz4,
2553 libzstd],
2554 install_rpath : rootlibexecdir,
2555 install : true,
2556 install_dir : rootlibexecdir)
2557
2558 public_programs += executable(
2559 'coredumpctl',
2560 coredumpctl_sources,
2561 include_directories : includes,
2562 link_with : [libshared],
2563 dependencies : [threads,
2564 libxz,
2565 liblz4,
2566 libzstd],
2567 install_rpath : rootlibexecdir,
2568 install : true)
2569 endif
2570
2571 if conf.get('ENABLE_PSTORE') == 1
2572 executable(
2573 'systemd-pstore',
2574 systemd_pstore_sources,
2575 include_directories : includes,
2576 link_with : [libshared],
2577 dependencies : [threads,
2578 libacl,
2579 libdw,
2580 libxz,
2581 liblz4,
2582 libzstd],
2583 install_rpath : rootlibexecdir,
2584 install : true,
2585 install_dir : rootlibexecdir)
2586 endif
2587
2588 if conf.get('ENABLE_BINFMT') == 1
2589 public_programs += executable(
2590 'systemd-binfmt',
2591 'src/binfmt/binfmt.c',
2592 include_directories : includes,
2593 link_with : [libshared],
2594 install_rpath : rootlibexecdir,
2595 install : true,
2596 install_dir : rootlibexecdir)
2597
2598 meson.add_install_script('sh', '-c',
2599 mkdir_p.format(binfmtdir))
2600 meson.add_install_script('sh', '-c',
2601 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2602 endif
2603
2604 if conf.get('ENABLE_REPART') == 1
2605 exe = executable(
2606 'systemd-repart',
2607 systemd_repart_sources,
2608 include_directories : includes,
2609 link_with : [libshared],
2610 dependencies : [threads,
2611 libcryptsetup,
2612 libblkid,
2613 libfdisk,
2614 libopenssl],
2615 install_rpath : rootlibexecdir,
2616 install : true,
2617 install_dir : rootbindir)
2618
2619 if want_tests != 'false'
2620 test('test-repart',
2621 test_repart_sh,
2622 args : exe.full_path())
2623 endif
2624 endif
2625
2626 if conf.get('ENABLE_VCONSOLE') == 1
2627 executable(
2628 'systemd-vconsole-setup',
2629 'src/vconsole/vconsole-setup.c',
2630 include_directories : includes,
2631 link_with : [libshared],
2632 install_rpath : rootlibexecdir,
2633 install : true,
2634 install_dir : rootlibexecdir)
2635 endif
2636
2637 if conf.get('ENABLE_RANDOMSEED') == 1
2638 executable(
2639 'systemd-random-seed',
2640 'src/random-seed/random-seed.c',
2641 include_directories : includes,
2642 link_with : [libshared],
2643 install_rpath : rootlibexecdir,
2644 install : true,
2645 install_dir : rootlibexecdir)
2646 endif
2647
2648 if conf.get('ENABLE_FIRSTBOOT') == 1
2649 executable(
2650 'systemd-firstboot',
2651 'src/firstboot/firstboot.c',
2652 include_directories : includes,
2653 link_with : [libshared],
2654 dependencies : [libcrypt],
2655 install_rpath : rootlibexecdir,
2656 install : true,
2657 install_dir : rootbindir)
2658 endif
2659
2660 executable(
2661 'systemd-remount-fs',
2662 'src/remount-fs/remount-fs.c',
2663 include_directories : includes,
2664 link_with : [libcore_shared,
2665 libshared],
2666 install_rpath : rootlibexecdir,
2667 install : true,
2668 install_dir : rootlibexecdir)
2669
2670 executable(
2671 'systemd-machine-id-setup',
2672 'src/machine-id-setup/machine-id-setup-main.c',
2673 include_directories : includes,
2674 link_with : [libcore_shared,
2675 libshared],
2676 install_rpath : rootlibexecdir,
2677 install : true,
2678 install_dir : rootbindir)
2679
2680 executable(
2681 'systemd-fsck',
2682 'src/fsck/fsck.c',
2683 include_directories : includes,
2684 link_with : [libshared],
2685 install_rpath : rootlibexecdir,
2686 install : true,
2687 install_dir : rootlibexecdir)
2688
2689 executable('systemd-growfs',
2690 'src/partition/growfs.c',
2691 include_directories : includes,
2692 link_with : [libshared],
2693 dependencies : [libcryptsetup],
2694 install_rpath : rootlibexecdir,
2695 install : true,
2696 install_dir : rootlibexecdir)
2697
2698 executable(
2699 'systemd-makefs',
2700 'src/partition/makefs.c',
2701 include_directories : includes,
2702 link_with : [libshared],
2703 install_rpath : rootlibexecdir,
2704 install : true,
2705 install_dir : rootlibexecdir)
2706
2707 executable(
2708 'systemd-sleep',
2709 'src/sleep/sleep.c',
2710 include_directories : includes,
2711 link_with : [libshared],
2712 install_rpath : rootlibexecdir,
2713 install : true,
2714 install_dir : rootlibexecdir)
2715
2716 install_data('src/sleep/sleep.conf',
2717 install_dir : pkgsysconfdir)
2718
2719 public_programs += executable(
2720 'systemd-sysctl',
2721 'src/sysctl/sysctl.c',
2722 include_directories : includes,
2723 link_with : [libshared],
2724 install_rpath : rootlibexecdir,
2725 install : true,
2726 install_dir : rootlibexecdir)
2727
2728 executable(
2729 'systemd-ac-power',
2730 'src/ac-power/ac-power.c',
2731 include_directories : includes,
2732 link_with : [libshared],
2733 install_rpath : rootlibexecdir,
2734 install : true,
2735 install_dir : rootlibexecdir)
2736
2737 public_programs += executable(
2738 'systemd-detect-virt',
2739 'src/detect-virt/detect-virt.c',
2740 include_directories : includes,
2741 link_with : [libshared],
2742 install_rpath : rootlibexecdir,
2743 install : true)
2744
2745 public_programs += executable(
2746 'systemd-delta',
2747 'src/delta/delta.c',
2748 include_directories : includes,
2749 link_with : [libshared],
2750 install_rpath : rootlibexecdir,
2751 install : true)
2752
2753 public_programs += executable(
2754 'systemd-escape',
2755 'src/escape/escape.c',
2756 include_directories : includes,
2757 link_with : [libshared],
2758 install_rpath : rootlibexecdir,
2759 install : true,
2760 install_dir : rootbindir)
2761
2762 public_programs += executable(
2763 'systemd-notify',
2764 'src/notify/notify.c',
2765 include_directories : includes,
2766 link_with : [libshared],
2767 install_rpath : rootlibexecdir,
2768 install : true,
2769 install_dir : rootbindir)
2770
2771 executable(
2772 'systemd-volatile-root',
2773 'src/volatile-root/volatile-root.c',
2774 include_directories : includes,
2775 link_with : [libshared],
2776 install_rpath : rootlibexecdir,
2777 install : conf.get('ENABLE_INITRD') == 1,
2778 install_dir : rootlibexecdir)
2779
2780 executable(
2781 'systemd-cgroups-agent',
2782 'src/cgroups-agent/cgroups-agent.c',
2783 include_directories : includes,
2784 link_with : [libshared],
2785 install_rpath : rootlibexecdir,
2786 install : true,
2787 install_dir : rootlibexecdir)
2788
2789 public_programs += executable(
2790 'systemd-id128',
2791 'src/id128/id128.c',
2792 include_directories : includes,
2793 link_with : [libshared],
2794 install_rpath : rootlibexecdir,
2795 install : true)
2796
2797 public_programs += executable(
2798 'systemd-path',
2799 'src/path/path.c',
2800 include_directories : includes,
2801 link_with : [libshared],
2802 install_rpath : rootlibexecdir,
2803 install : true)
2804
2805 public_programs += executable(
2806 'systemd-ask-password',
2807 'src/ask-password/ask-password.c',
2808 include_directories : includes,
2809 link_with : [libshared],
2810 install_rpath : rootlibexecdir,
2811 install : true,
2812 install_dir : rootbindir)
2813
2814 executable(
2815 'systemd-reply-password',
2816 'src/reply-password/reply-password.c',
2817 include_directories : includes,
2818 link_with : [libshared],
2819 install_rpath : rootlibexecdir,
2820 install : true,
2821 install_dir : rootlibexecdir)
2822
2823 public_programs += executable(
2824 'systemd-tty-ask-password-agent',
2825 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2826 include_directories : includes,
2827 link_with : [libshared],
2828 install_rpath : rootlibexecdir,
2829 install : true,
2830 install_dir : rootbindir)
2831
2832 public_programs += executable(
2833 'systemd-cgls',
2834 'src/cgls/cgls.c',
2835 include_directories : includes,
2836 link_with : [libshared],
2837 install_rpath : rootlibexecdir,
2838 install : true)
2839
2840 public_programs += executable(
2841 'systemd-cgtop',
2842 'src/cgtop/cgtop.c',
2843 include_directories : includes,
2844 link_with : [libshared],
2845 install_rpath : rootlibexecdir,
2846 install : true)
2847
2848 executable(
2849 'systemd-initctl',
2850 'src/initctl/initctl.c',
2851 include_directories : includes,
2852 link_with : [libshared],
2853 install_rpath : rootlibexecdir,
2854 install : true,
2855 install_dir : rootlibexecdir)
2856
2857 public_programs += executable(
2858 'systemd-mount',
2859 'src/mount/mount-tool.c',
2860 include_directories : includes,
2861 link_with : [libshared],
2862 dependencies: [libmount],
2863 install_rpath : rootlibexecdir,
2864 install : true)
2865
2866 meson.add_install_script(meson_make_symlink,
2867 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2868
2869 public_programs += executable(
2870 'systemd-run',
2871 'src/run/run.c',
2872 include_directories : includes,
2873 link_with : [libshared],
2874 install_rpath : rootlibexecdir,
2875 install : true)
2876
2877 public_programs += executable(
2878 'systemd-stdio-bridge',
2879 'src/stdio-bridge/stdio-bridge.c',
2880 include_directories : includes,
2881 link_with : [libshared],
2882 dependencies : [versiondep],
2883 install_rpath : rootlibexecdir,
2884 install : true)
2885
2886 public_programs += executable(
2887 'busctl',
2888 'src/busctl/busctl.c',
2889 'src/busctl/busctl-introspect.c',
2890 'src/busctl/busctl-introspect.h',
2891 include_directories : includes,
2892 link_with : [libshared],
2893 install_rpath : rootlibexecdir,
2894 install : true)
2895
2896 if conf.get('ENABLE_SYSUSERS') == 1
2897 public_programs += executable(
2898 'systemd-sysusers',
2899 'src/sysusers/sysusers.c',
2900 include_directories : includes,
2901 link_with : [libshared],
2902 install_rpath : rootlibexecdir,
2903 install : true,
2904 install_dir : rootbindir)
2905 endif
2906
2907 if conf.get('ENABLE_TMPFILES') == 1
2908 exe = executable(
2909 'systemd-tmpfiles',
2910 'src/tmpfiles/tmpfiles.c',
2911 'src/tmpfiles/offline-passwd.c',
2912 'src/tmpfiles/offline-passwd.h',
2913 include_directories : includes,
2914 link_with : [libshared],
2915 dependencies : [libacl],
2916 install_rpath : rootlibexecdir,
2917 install : true,
2918 install_dir : rootbindir)
2919 public_programs += exe
2920
2921 if want_tests != 'false'
2922 test('test-systemd-tmpfiles',
2923 test_systemd_tmpfiles_py,
2924 # https://github.com/mesonbuild/meson/issues/2681
2925 args : exe.full_path())
2926 endif
2927 endif
2928
2929 if conf.get('ENABLE_HWDB') == 1
2930 public_programs += executable(
2931 'systemd-hwdb',
2932 'src/hwdb/hwdb.c',
2933 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2934 include_directories : includes,
2935 link_with : [libudev_static],
2936 install_rpath : udev_rpath,
2937 install : true,
2938 install_dir : rootbindir)
2939 endif
2940
2941 if conf.get('ENABLE_QUOTACHECK') == 1
2942 executable(
2943 'systemd-quotacheck',
2944 'src/quotacheck/quotacheck.c',
2945 include_directories : includes,
2946 link_with : [libshared],
2947 install_rpath : rootlibexecdir,
2948 install : true,
2949 install_dir : rootlibexecdir)
2950 endif
2951
2952 public_programs += executable(
2953 'systemd-socket-proxyd',
2954 'src/socket-proxy/socket-proxyd.c',
2955 include_directories : includes,
2956 link_with : [libshared],
2957 dependencies : [threads],
2958 install_rpath : rootlibexecdir,
2959 install : true,
2960 install_dir : rootlibexecdir)
2961
2962 public_programs += executable(
2963 'systemd-udevd',
2964 systemd_udevd_sources,
2965 include_directories : includes,
2966 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
2967 link_with : [libudev_core,
2968 libsystemd_network,
2969 libudev_static],
2970 dependencies : [versiondep,
2971 threads,
2972 libkmod,
2973 libidn,
2974 libacl,
2975 libblkid],
2976 install_rpath : udev_rpath,
2977 install : true,
2978 install_dir : rootlibexecdir)
2979
2980 public_programs += executable(
2981 'udevadm',
2982 udevadm_sources,
2983 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
2984 include_directories : includes,
2985 link_with : [libudev_core,
2986 libsystemd_network,
2987 libudev_static],
2988 dependencies : [versiondep,
2989 threads,
2990 libkmod,
2991 libidn,
2992 libacl,
2993 libblkid],
2994 install_rpath : udev_rpath,
2995 install : true,
2996 install_dir : rootbindir)
2997
2998 executable(
2999 'systemd-shutdown',
3000 systemd_shutdown_sources,
3001 include_directories : includes,
3002 link_with : [libcore_shared,
3003 libshared],
3004 dependencies : [libmount],
3005 install_rpath : rootlibexecdir,
3006 install : true,
3007 install_dir : rootlibexecdir)
3008
3009 executable(
3010 'systemd-update-done',
3011 'src/update-done/update-done.c',
3012 include_directories : includes,
3013 link_with : [libshared],
3014 install_rpath : rootlibexecdir,
3015 install : true,
3016 install_dir : rootlibexecdir)
3017
3018 executable(
3019 'systemd-update-utmp',
3020 'src/update-utmp/update-utmp.c',
3021 include_directories : includes,
3022 link_with : [libshared],
3023 dependencies : [libaudit],
3024 install_rpath : rootlibexecdir,
3025 install : true,
3026 install_dir : rootlibexecdir)
3027
3028 if conf.get('HAVE_KMOD') == 1
3029 executable(
3030 'systemd-modules-load',
3031 'src/modules-load/modules-load.c',
3032 include_directories : includes,
3033 link_with : [libshared],
3034 dependencies : [libkmod],
3035 install_rpath : rootlibexecdir,
3036 install : true,
3037 install_dir : rootlibexecdir)
3038
3039 meson.add_install_script('sh', '-c',
3040 mkdir_p.format(modulesloaddir))
3041 meson.add_install_script('sh', '-c',
3042 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
3043 endif
3044
3045 public_programs += executable(
3046 'systemd-nspawn',
3047 systemd_nspawn_sources,
3048 include_directories : includes,
3049 link_with : [libcore_shared,
3050 libnspawn_core,
3051 libshared],
3052 dependencies : [libblkid,
3053 libseccomp],
3054 install_rpath : rootlibexecdir,
3055 install : true)
3056
3057 if conf.get('ENABLE_NETWORKD') == 1
3058 executable(
3059 'systemd-networkd',
3060 systemd_networkd_sources,
3061 include_directories : network_include_dir,
3062 link_with : [libnetworkd_core,
3063 libsystemd_network,
3064 libudev_static,
3065 networkd_link_with],
3066 dependencies : [threads],
3067 install_rpath : rootlibexecdir,
3068 install : true,
3069 install_dir : rootlibexecdir)
3070
3071 executable(
3072 'systemd-networkd-wait-online',
3073 systemd_networkd_wait_online_sources,
3074 include_directories : includes,
3075 link_with : [libnetworkd_core,
3076 networkd_link_with],
3077 install_rpath : rootlibexecdir,
3078 install : true,
3079 install_dir : rootlibexecdir)
3080
3081 public_programs += executable(
3082 'networkctl',
3083 networkctl_sources,
3084 include_directories : includes,
3085 link_with : [libsystemd_network,
3086 networkd_link_with],
3087 install_rpath : rootlibexecdir,
3088 install : true,
3089 install_dir : rootbindir)
3090
3091 exe = executable(
3092 'systemd-network-generator',
3093 network_generator_sources,
3094 include_directories : includes,
3095 link_with : [networkd_link_with],
3096 install_rpath : rootlibexecdir,
3097 install : true,
3098 install_dir : rootlibexecdir)
3099
3100 if want_tests != 'false'
3101 test('test-network-generator-conversion',
3102 test_network_generator_conversion_sh,
3103 # https://github.com/mesonbuild/meson/issues/2681
3104 args : exe.full_path())
3105 endif
3106 endif
3107
3108 executable(
3109 'systemd-sulogin-shell',
3110 ['src/sulogin-shell/sulogin-shell.c'],
3111 include_directories : includes,
3112 link_with : [libshared],
3113 install_rpath : rootlibexecdir,
3114 install : true,
3115 install_dir : rootlibexecdir)
3116
3117 ############################################################
3118
3119 custom_target(
3120 'systemd-runtest.env',
3121 output : 'systemd-runtest.env',
3122 command : ['sh', '-c', '{ ' +
3123 'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(project_source_root, 'test')) +
3124 'echo SYSTEMD_CATALOG_DIR=@0@; '.format(join_paths(project_build_root, 'catalog')) +
3125 '} >@OUTPUT@'],
3126 build_by_default : true)
3127
3128 foreach tuple : tests
3129 sources = tuple[0]
3130 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
3131 dependencies = tuple[2]
3132 condition = tuple.length() >= 4 ? tuple[3] : ''
3133 type = tuple.length() >= 5 ? tuple[4] : ''
3134 defs = tuple.length() >= 6 ? tuple[5] : []
3135 incs = tuple.length() >= 7 ? tuple[6] : includes
3136 timeout = 30
3137
3138 name = sources[0].split('/')[-1].split('.')[0]
3139 if type.startswith('timeout=')
3140 timeout = type.split('=')[1].to_int()
3141 type = ''
3142 endif
3143
3144 if condition == '' or conf.get(condition) == 1
3145 exe = executable(
3146 name,
3147 sources,
3148 include_directories : incs,
3149 link_with : link_with,
3150 dependencies : [versiondep,
3151 dependencies],
3152 c_args : defs,
3153 build_by_default : want_tests != 'false',
3154 install_rpath : rootlibexecdir,
3155 install : install_tests,
3156 install_dir : join_paths(testsdir, type))
3157
3158 if type == 'manual'
3159 message('@0@ is a manual test'.format(name))
3160 elif type == 'unsafe' and want_tests != 'unsafe'
3161 message('@0@ is an unsafe test'.format(name))
3162 elif want_tests != 'false'
3163 test(name, exe,
3164 env : test_env,
3165 timeout : timeout)
3166 endif
3167 else
3168 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3169 endif
3170 endforeach
3171
3172 exe = executable(
3173 'test-libsystemd-sym',
3174 test_libsystemd_sym_c,
3175 include_directories : includes,
3176 link_with : [libsystemd],
3177 build_by_default : want_tests != 'false',
3178 install : install_tests,
3179 install_dir : testsdir)
3180 if want_tests != 'false'
3181 test('test-libsystemd-sym', exe)
3182 endif
3183
3184 exe = executable(
3185 'test-libsystemd-static-sym',
3186 test_libsystemd_sym_c,
3187 include_directories : includes,
3188 link_with : [install_libsystemd_static],
3189 dependencies : [threads], # threads is already included in dependencies on the library,
3190 # but does not seem to get propagated. Add here as a work-around.
3191 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3192 install : install_tests and static_libsystemd_pic,
3193 install_dir : testsdir)
3194 if want_tests != 'false' and static_libsystemd_pic
3195 test('test-libsystemd-static-sym', exe)
3196 endif
3197
3198 exe = executable(
3199 'test-libudev-sym',
3200 test_libudev_sym_c,
3201 include_directories : includes,
3202 c_args : '-Wno-deprecated-declarations',
3203 link_with : [libudev],
3204 build_by_default : want_tests != 'false',
3205 install : install_tests,
3206 install_dir : testsdir)
3207 if want_tests != 'false'
3208 test('test-libudev-sym', exe)
3209 endif
3210
3211 exe = executable(
3212 'test-libudev-static-sym',
3213 test_libudev_sym_c,
3214 include_directories : includes,
3215 c_args : '-Wno-deprecated-declarations',
3216 link_with : [install_libudev_static],
3217 build_by_default : want_tests != 'false' and static_libudev_pic,
3218 install : install_tests and static_libudev_pic,
3219 install_dir : testsdir)
3220 if want_tests != 'false' and static_libudev_pic
3221 test('test-libudev-static-sym', exe)
3222 endif
3223
3224 ############################################################
3225
3226 fuzzer_exes = []
3227
3228 if get_option('tests') != 'false'
3229 foreach tuple : fuzzers
3230 sources = tuple[0]
3231 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
3232 dependencies = tuple[2]
3233 defs = tuple.length() >= 4 ? tuple[3] : []
3234 incs = tuple.length() >= 5 ? tuple[4] : includes
3235 link_args = []
3236
3237 if want_ossfuzz
3238 dependencies += fuzzing_engine
3239 elif want_libfuzzer
3240 if fuzzing_engine.found()
3241 dependencies += fuzzing_engine
3242 else
3243 link_args += ['-fsanitize=fuzzer']
3244 endif
3245 else
3246 sources += 'src/fuzz/fuzz-main.c'
3247 endif
3248
3249 name = sources[0].split('/')[-1].split('.')[0]
3250
3251 fuzzer_exes += executable(
3252 name,
3253 sources,
3254 include_directories : [incs, include_directories('src/fuzz')],
3255 link_with : link_with,
3256 dependencies : dependencies,
3257 c_args : defs,
3258 link_args: link_args,
3259 install : false)
3260 endforeach
3261 endif
3262
3263 run_target(
3264 'fuzzers',
3265 depends : fuzzer_exes,
3266 command : ['true'])
3267
3268 ############################################################
3269
3270 make_directive_index_py = find_program('tools/make-directive-index.py')
3271 make_man_index_py = find_program('tools/make-man-index.py')
3272 xml_helper_py = find_program('tools/xml_helper.py')
3273 hwdb_update_sh = find_program('tools/hwdb-update.sh')
3274 autosuspend_update_sh = find_program('tools/autosuspend-update.sh')
3275
3276 subdir('sysctl.d')
3277 subdir('sysusers.d')
3278 subdir('tmpfiles.d')
3279 subdir('hwdb.d')
3280 subdir('units')
3281 subdir('presets')
3282 subdir('network')
3283 subdir('man')
3284 subdir('shell-completion/bash')
3285 subdir('shell-completion/zsh')
3286 subdir('docs/sysvinit')
3287 subdir('docs/var-log')
3288
3289 install_subdir('factory/etc',
3290 install_dir : factorydir)
3291
3292 install_data('xorg/50-systemd-user.sh',
3293 install_dir : xinitrcdir)
3294 install_data('modprobe.d/systemd.conf',
3295 install_dir : modprobedir)
3296 install_data('LICENSE.GPL2',
3297 'LICENSE.LGPL2.1',
3298 'NEWS',
3299 'README',
3300 'docs/CODING_STYLE.md',
3301 'docs/DISTRO_PORTING.md',
3302 'docs/ENVIRONMENT.md',
3303 'docs/HACKING.md',
3304 'docs/TRANSIENT-SETTINGS.md',
3305 'docs/TRANSLATORS.md',
3306 'docs/UIDS-GIDS.md',
3307 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
3308 install_dir : docdir)
3309
3310 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3311 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3312
3313 ############################################################
3314
3315 check_help = find_program('tools/check-help.sh')
3316
3317 foreach exec : public_programs
3318 name = exec.full_path().split('/')[-1]
3319 if want_tests != 'false'
3320 test('check-help-' + name,
3321 check_help,
3322 args : exec.full_path())
3323 endif
3324 endforeach
3325
3326 ############################################################
3327
3328 check_directives_sh = find_program('tools/check-directives.sh')
3329
3330 if want_tests != 'false'
3331 test('check-directives',
3332 check_directives_sh,
3333 args : project_source_root)
3334 endif
3335
3336 ############################################################
3337
3338 # Enable tests for all supported sanitizers
3339 foreach tuple : sanitizers
3340 sanitizer = tuple[0]
3341 build = tuple[1]
3342
3343 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
3344 prev = ''
3345 foreach p : fuzz_regression_tests
3346 b = p.split('/')[-2]
3347 c = p.split('/')[-1]
3348
3349 name = '@0@:@1@'.format(b, sanitizer)
3350
3351 if name != prev
3352 if want_tests == 'false'
3353 message('Not compiling @0@ because tests is set to false'.format(name))
3354 elif slow_tests or fuzz_tests
3355 exe = custom_target(
3356 name,
3357 output : name,
3358 depends : build,
3359 command : [env, 'ln', '-fs',
3360 join_paths(build.full_path(), b),
3361 '@OUTPUT@'],
3362 build_by_default : true)
3363 else
3364 message('Not compiling @0@ because slow-tests/fuzz-tests is set to false'.format(name))
3365 endif
3366 endif
3367 prev = name
3368
3369 if want_tests != 'false' and (slow_tests or fuzz_tests)
3370 test('@0@:@1@:@2@'.format(b, c, sanitizer),
3371 env,
3372 env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
3373 timeout : 60,
3374 args : [exe.full_path(),
3375 join_paths(project_source_root, p)])
3376 endif
3377 endforeach
3378 endif
3379 endforeach
3380
3381
3382 ############################################################
3383
3384 if git.found()
3385 all_files = run_command(
3386 git,
3387 ['--git-dir=@0@/.git'.format(project_source_root),
3388 'ls-files',
3389 ':/*.[ch]'])
3390 all_files = files(all_files.stdout().split())
3391
3392 custom_target(
3393 'tags',
3394 output : 'tags',
3395 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
3396 run_target(
3397 'ctags',
3398 command : [env, 'ctags', '-o', '@0@/tags'.format(project_source_root)] + all_files)
3399 endif
3400
3401 if git.found()
3402 git_contrib_sh = find_program('tools/git-contrib.sh')
3403 run_target(
3404 'git-contrib',
3405 command : [git_contrib_sh])
3406 endif
3407
3408 if git.found()
3409 git_head = run_command(
3410 git,
3411 ['--git-dir=@0@/.git'.format(project_source_root),
3412 'rev-parse', 'HEAD']).stdout().strip()
3413 git_head_short = run_command(
3414 git,
3415 ['--git-dir=@0@/.git'.format(project_source_root),
3416 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
3417
3418 run_target(
3419 'git-snapshot',
3420 command : ['git', 'archive',
3421 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
3422 git_head_short),
3423 '--prefix', 'systemd-@0@/'.format(git_head),
3424 'HEAD'])
3425 endif
3426
3427 ############################################################
3428
3429 check_api_docs_sh = find_program('tools/check-api-docs.sh')
3430 run_target(
3431 'check-api-docs',
3432 depends : [man, libsystemd, libudev],
3433 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
3434
3435 ############################################################
3436 watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog
3437
3438 status = [
3439 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
3440
3441 'split /usr: @0@'.format(split_usr),
3442 'split bin-sbin: @0@'.format(split_bin),
3443 'prefix directory: @0@'.format(prefixdir),
3444 'rootprefix directory: @0@'.format(rootprefixdir),
3445 'sysconf directory: @0@'.format(sysconfdir),
3446 'include directory: @0@'.format(includedir),
3447 'lib directory: @0@'.format(libdir),
3448 'rootlib directory: @0@'.format(rootlibdir),
3449 'SysV init scripts: @0@'.format(sysvinit_path),
3450 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
3451 'PAM modules directory: @0@'.format(pamlibdir),
3452 'PAM configuration directory: @0@'.format(pamconfdir),
3453 'RPM macros directory: @0@'.format(rpmmacrosdir),
3454 'modprobe.d directory: @0@'.format(modprobedir),
3455 'D-Bus policy directory: @0@'.format(dbuspolicydir),
3456 'D-Bus session directory: @0@'.format(dbussessionservicedir),
3457 'D-Bus system directory: @0@'.format(dbussystemservicedir),
3458 'bash completions directory: @0@'.format(bashcompletiondir),
3459 'zsh completions directory: @0@'.format(zshcompletiondir),
3460 'extra start script: @0@'.format(get_option('rc-local')),
3461 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
3462 get_option('debug-tty')),
3463 'TTY GID: @0@'.format(tty_gid),
3464 'users GID: @0@'.format(substs.get('USERS_GID')),
3465 'maximum system UID: @0@'.format(system_uid_max),
3466 'maximum system GID: @0@'.format(system_gid_max),
3467 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
3468 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
3469 'minimum container UID base: @0@'.format(container_uid_base_min),
3470 'maximum container UID base: @0@'.format(container_uid_base_max),
3471 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
3472 'render group access mode: @0@'.format(get_option('group-render-mode')),
3473 'certificate root directory: @0@'.format(get_option('certificate-root')),
3474 'support URL: @0@'.format(support_url),
3475 'nobody user name: @0@'.format(nobody_user),
3476 'nobody group name: @0@'.format(nobody_group),
3477 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
3478 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
3479
3480 'default DNSSEC mode: @0@'.format(default_dnssec),
3481 'default DNS-over-TLS mode: @0@'.format(default_dns_over_tls),
3482 'default mDNS mode: @0@'.format(default_mdns),
3483 'default LLMNR mode: @0@'.format(default_llmnr),
3484 'default cgroup hierarchy: @0@'.format(default_hierarchy),
3485 'default net.naming-scheme setting: @0@'.format(default_net_naming_scheme),
3486 'default KillUserProcesses setting: @0@'.format(kill_user_processes),
3487 'default locale: @0@'.format(default_locale),
3488 'default user $PATH: @0@'.format(default_user_path_display),
3489 'systemd service watchdog: @0@'.format(watchdog_opt)]
3490
3491 alt_dns_servers = '\n '.join(dns_servers.split(' '))
3492 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
3493 status += [
3494 'default DNS servers: @0@'.format(alt_dns_servers),
3495 'default NTP servers: @0@'.format(alt_ntp_servers)]
3496
3497 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
3498 '@@0@'.format(time_epoch)).stdout().strip()
3499 status += [
3500 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
3501
3502 status += [
3503 'static libsystemd: @0@'.format(static_libsystemd),
3504 'static libudev: @0@'.format(static_libudev)]
3505
3506 # TODO:
3507 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
3508 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
3509 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
3510
3511 if conf.get('ENABLE_EFI') == 1
3512 status += 'efi arch: @0@'.format(efi_arch)
3513
3514 if have_gnu_efi
3515 status += [
3516 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
3517 'EFI CC @0@'.format(' '.join(efi_cc)),
3518 'EFI lds: @0@'.format(efi_lds),
3519 'EFI crt0: @0@'.format(efi_crt0),
3520 'EFI include directory: @0@'.format(efi_incdir)]
3521 endif
3522 endif
3523
3524 found = []
3525 missing = []
3526
3527 foreach tuple : [
3528 ['libcryptsetup'],
3529 ['PAM'],
3530 ['pwquality'],
3531 ['libfdisk'],
3532 ['p11kit'],
3533 ['AUDIT'],
3534 ['IMA'],
3535 ['AppArmor'],
3536 ['SELinux'],
3537 ['SECCOMP'],
3538 ['SMACK'],
3539 ['zlib'],
3540 ['xz'],
3541 ['zstd'],
3542 ['lz4'],
3543 ['bzip2'],
3544 ['ACL'],
3545 ['gcrypt'],
3546 ['qrencode'],
3547 ['microhttpd'],
3548 ['gnutls'],
3549 ['openssl'],
3550 ['libcurl'],
3551 ['idn'],
3552 ['initrd'],
3553 ['libidn2'],
3554 ['libidn'],
3555 ['libiptc'],
3556 ['elfutils'],
3557 ['binfmt'],
3558 ['repart'],
3559 ['vconsole'],
3560 ['quotacheck'],
3561 ['tmpfiles'],
3562 ['environment.d'],
3563 ['sysusers'],
3564 ['firstboot'],
3565 ['randomseed'],
3566 ['backlight'],
3567 ['rfkill'],
3568 ['logind'],
3569 ['machined'],
3570 ['portabled'],
3571 ['userdb'],
3572 ['homed'],
3573 ['importd'],
3574 ['hostnamed'],
3575 ['timedated'],
3576 ['timesyncd'],
3577 ['localed'],
3578 ['networkd'],
3579 ['resolve'],
3580 ['DNS-over-TLS(gnutls)', conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1],
3581 ['DNS-over-TLS(openssl)', conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1],
3582 ['coredump'],
3583 ['pstore'],
3584 ['polkit'],
3585 ['legacy pkla', install_polkit_pkla],
3586 ['efi'],
3587 ['gnu-efi', have_gnu_efi],
3588 ['kmod'],
3589 ['xkbcommon'],
3590 ['pcre2'],
3591 ['blkid'],
3592 ['dbus'],
3593 ['glib'],
3594 ['nss-myhostname'],
3595 ['nss-mymachines'],
3596 ['nss-resolve'],
3597 ['nss-systemd'],
3598 ['hwdb'],
3599 ['tpm'],
3600 ['man pages', want_man],
3601 ['html pages', want_html],
3602 ['man page indices', want_man and have_lxml],
3603 ['SysV compat'],
3604 ['utmp'],
3605 ['ldconfig'],
3606 ['hibernate'],
3607 ['adm group', get_option('adm-group')],
3608 ['wheel group', get_option('wheel-group')],
3609 ['gshadow'],
3610 ['debug hashmap'],
3611 ['debug mmap cache'],
3612 ['debug siphash'],
3613 ['valgrind', conf.get('VALGRIND') == 1],
3614 ['trace logging', conf.get('LOG_TRACE') == 1],
3615 ['install tests', install_tests],
3616 ['link-udev-shared', get_option('link-udev-shared')],
3617 ['link-systemctl-shared', get_option('link-systemctl-shared')],
3618 ['link-networkd-shared', get_option('link-networkd-shared')],
3619 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
3620 ['kernel-install', get_option('kernel-install')],
3621 ['systemd-analyze', get_option('analyze')],
3622 ]
3623
3624 if tuple.length() >= 2
3625 cond = tuple[1]
3626 else
3627 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3628 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
3629 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
3630 endif
3631 if cond
3632 found += tuple[0]
3633 else
3634 missing += tuple[0]
3635 endif
3636 endforeach
3637
3638 status += [
3639 '',
3640 'enabled features: @0@'.format(', '.join(found)),
3641 '',
3642 'disabled features: @0@'.format(', '.join(missing)),
3643 '']
3644 message('\n '.join(status))
3645
3646 if rootprefixdir != rootprefix_default
3647 warning('\n' +
3648 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3649 'systemd used fixed names for unit file directories and other paths, so anything\n' +
3650 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
3651 endif