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