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