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