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