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