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