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