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