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