]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
resolved: TCP fast open connections
[thirdparty/systemd.git] / meson.build
CommitLineData
3a726fcd
ZJS
1# SPDX-License-Identifier: LGPL-2.1+
2#
3# Copyright 2017 Zbigniew Jędrzejewski-Szmek
3a726fcd 4
5c23128d 5project('systemd', 'c',
ad6a0853 6 version : '238',
5c23128d
ZJS
7 license : 'LGPLv2+',
8 default_options: [
37efbbd8
ZJS
9 'c_std=gnu99',
10 'prefix=/usr',
11 'sysconfdir=/etc',
12 'localstatedir=/var',
5c23128d 13 ],
8ea9fad7 14 meson_version : '>= 0.44',
5c23128d
ZJS
15 )
16
ad6a0853
ZJS
17libsystemd_version = '0.22.0'
18libudev_version = '1.6.10'
56d50ab1 19
348b4437 20# We need the same data in two different formats, ugh!
5c23128d
ZJS
21# Also, for hysterical reasons, we use different variable
22# names, sometimes. Not all variables are included in every
23# set. Ugh, ugh, ugh!
24conf = configuration_data()
25conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
26conf.set_quoted('PACKAGE_VERSION', meson.project_version())
27
28substs = configuration_data()
29substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
30substs.set('PACKAGE_VERSION', meson.project_version())
31
5c23128d
ZJS
32#####################################################################
33
003c8879
ZJS
34# Try to install the git pre-commit hook
35git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
36if git_hook.returncode() == 0
37 message(git_hook.stdout().strip())
38endif
39
40#####################################################################
41
2675413e
ZJS
42if get_option('split-usr') == 'auto'
43 split_usr = run_command('test', '-L', '/bin').returncode() != 0
44else
45 split_usr = get_option('split-usr') == 'true'
46endif
671f0f8d
ZJS
47conf.set10('HAVE_SPLIT_USR', split_usr,
48 description : '/usr/bin and /bin directories are separate')
9a8e64b0 49
157baa87
ZJS
50if get_option('split-bin') == 'auto'
51 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
52else
53 split_bin = get_option('split-bin') == 'true'
54endif
671f0f8d
ZJS
55conf.set10('HAVE_SPLIT_BIN', split_bin,
56 description : 'bin and sbin directories are separate')
157baa87 57
74344a17 58rootprefixdir = get_option('rootprefix')
74344a17
ZJS
59# Unusual rootprefixdir values are used by some distros
60# (see https://github.com/systemd/systemd/pull/7461).
ba7f4ae6 61rootprefix_default = split_usr ? '/' : '/usr'
9a8e64b0
ZJS
62if rootprefixdir == ''
63 rootprefixdir = rootprefix_default
74344a17 64endif
5c23128d
ZJS
65
66sysvinit_path = get_option('sysvinit-path')
67sysvrcnd_path = get_option('sysvrcnd-path')
348b4437 68conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
349cc4a5 69 description : 'SysV init scripts and rcN.d links are supported')
5c23128d
ZJS
70
71# join_paths ignore the preceding arguments if an absolute component is
72# encountered, so this should canonicalize various paths when they are
73# absolute or relative.
74prefixdir = get_option('prefix')
75if not prefixdir.startswith('/')
37efbbd8 76 error('Prefix is not absolute: "@0@"'.format(prefixdir))
5c23128d
ZJS
77endif
78bindir = join_paths(prefixdir, get_option('bindir'))
79libdir = join_paths(prefixdir, get_option('libdir'))
80sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
81includedir = join_paths(prefixdir, get_option('includedir'))
82datadir = join_paths(prefixdir, get_option('datadir'))
83localstatedir = join_paths('/', get_option('localstatedir'))
84
85rootbindir = join_paths(rootprefixdir, 'bin')
157baa87 86rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
5c23128d
ZJS
87rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
88
89rootlibdir = get_option('rootlibdir')
90if rootlibdir == ''
37efbbd8 91 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
5c23128d
ZJS
92endif
93
94# Dirs of external packages
e17e5ba9
MB
95pkgconfigdatadir = join_paths(datadir, 'pkgconfig')
96pkgconfiglibdir = join_paths(libdir, 'pkgconfig')
97polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
98polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
99polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
100varlogdir = join_paths(localstatedir, 'log')
101xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
8a38aac3
YW
102rpmmacrosdir = get_option('rpmmacrosdir')
103if rpmmacrosdir != 'no'
104 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
105endif
02fa054d 106modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
5c23128d
ZJS
107
108# Our own paths
e17e5ba9
MB
109pkgdatadir = join_paths(datadir, 'systemd')
110environmentdir = join_paths(prefixdir, 'lib/environment.d')
111pkgsysconfdir = join_paths(sysconfdir, 'systemd')
112userunitdir = join_paths(prefixdir, 'lib/systemd/user')
113userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
114tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
115sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
116sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
117binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
118modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
119networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
120pkgincludedir = join_paths(includedir, 'systemd')
121systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
122usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
123systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
124userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
125systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
126systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
127systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
128systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
129udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
130udevhomedir = udevlibexecdir
131udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
132udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
133catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
134kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
135factorydir = join_paths(datadir, 'factory')
e17e5ba9
MB
136bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
137testsdir = join_paths(prefixdir, 'lib/systemd/tests')
138systemdstatedir = join_paths(localstatedir, 'lib/systemd')
139catalogstatedir = join_paths(systemdstatedir, 'catalog')
140randomseeddir = join_paths(localstatedir, 'lib/systemd')
61d0578b 141profiledir = join_paths(rootlibexecdir, 'portable', 'profile')
5c23128d 142
75aaade1
TB
143docdir = get_option('docdir')
144if docdir == ''
145 docdir = join_paths(datadir, 'doc/systemd')
146endif
147
5c23128d
ZJS
148dbuspolicydir = get_option('dbuspolicydir')
149if dbuspolicydir == ''
37efbbd8 150 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
5c23128d
ZJS
151endif
152
153dbussessionservicedir = get_option('dbussessionservicedir')
154if dbussessionservicedir == ''
37efbbd8 155 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
5c23128d
ZJS
156endif
157
158dbussystemservicedir = get_option('dbussystemservicedir')
159if dbussystemservicedir == ''
37efbbd8 160 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
5c23128d
ZJS
161endif
162
163pamlibdir = get_option('pamlibdir')
164if pamlibdir == ''
37efbbd8 165 pamlibdir = join_paths(rootlibdir, 'security')
5c23128d
ZJS
166endif
167
168pamconfdir = get_option('pamconfdir')
169if pamconfdir == ''
37efbbd8 170 pamconfdir = join_paths(sysconfdir, 'pam.d')
5c23128d
ZJS
171endif
172
444d5863
ZJS
173memory_accounting_default = get_option('memory-accounting-default')
174
5c23128d 175conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
e17e5ba9 176conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'system'))
5c23128d
ZJS
177conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
178conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
179conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
2a4c156d
ZJS
180conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
181conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
96164a39 182
f7c5427c 183conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
96164a39 184
e17e5ba9 185conf.set_quoted('USER_CONFIG_UNIT_PATH', join_paths(pkgsysconfdir, 'user'))
5c23128d
ZJS
186conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
187conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
e17e5ba9
MB
188conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
189conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
190conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
191conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
da495a03 192conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
7f2806d5 193conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
e17e5ba9
MB
194conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
195conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-sleep'))
196conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
197conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
198conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
74344a17 199conf.set_quoted('ROOTPREFIX', rootprefixdir)
3131bfe3 200conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
e17e5ba9
MB
201conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
202conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
5c23128d
ZJS
203conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
204conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
205conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
206conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
207conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
208conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
e17e5ba9
MB
209conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
210conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
5c23128d 211conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
e17e5ba9 212conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
5c23128d
ZJS
213conf.set_quoted('LIBDIR', libdir)
214conf.set_quoted('ROOTLIBDIR', rootlibdir)
215conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
216conf.set_quoted('BOOTLIBDIR', bootlibdir)
e17e5ba9
MB
217conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
218conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
219conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
220conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
221conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
222conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
444d5863 223conf.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'true' : 'false')
7f672e86 224conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
5c23128d
ZJS
225
226conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
227conf.set_quoted('ABS_SRC_DIR', meson.source_root())
228
229substs.set('prefix', prefixdir)
3131bfe3
ZJS
230substs.set('exec_prefix', prefixdir)
231substs.set('libdir', libdir)
232substs.set('rootlibdir', rootlibdir)
233substs.set('includedir', includedir)
5c23128d 234substs.set('pkgsysconfdir', pkgsysconfdir)
3131bfe3
ZJS
235substs.set('bindir', bindir)
236substs.set('rootbindir', rootbindir)
5c23128d
ZJS
237substs.set('rootlibexecdir', rootlibexecdir)
238substs.set('systemunitdir', systemunitdir)
239substs.set('userunitdir', userunitdir)
240substs.set('systempresetdir', systempresetdir)
241substs.set('userpresetdir', userpresetdir)
242substs.set('udevhwdbdir', udevhwdbdir)
243substs.set('udevrulesdir', udevrulesdir)
3131bfe3 244substs.set('udevlibexecdir', udevlibexecdir)
424e80b4 245substs.set('environmentdir', environmentdir)
5c23128d
ZJS
246substs.set('catalogdir', catalogdir)
247substs.set('tmpfilesdir', tmpfilesdir)
248substs.set('sysusersdir', sysusersdir)
249substs.set('sysctldir', sysctldir)
250substs.set('binfmtdir', binfmtdir)
251substs.set('modulesloaddir', modulesloaddir)
424e80b4 252substs.set('modprobedir', modprobedir)
5c23128d
ZJS
253substs.set('systemgeneratordir', systemgeneratordir)
254substs.set('usergeneratordir', usergeneratordir)
255substs.set('systemenvgeneratordir', systemenvgeneratordir)
256substs.set('userenvgeneratordir', userenvgeneratordir)
257substs.set('systemshutdowndir', systemshutdowndir)
258substs.set('systemsleepdir', systemsleepdir)
2a4c156d
ZJS
259substs.set('VARLOGDIR', varlogdir)
260substs.set('CERTIFICATEROOT', get_option('certificate-root'))
e17e5ba9
MB
261substs.set('SYSTEMCTL', join_paths(rootbindir, 'systemctl'))
262substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
2a4c156d
ZJS
263substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
264substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
265substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
266substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
444d5863 267substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
5c23128d
ZJS
268
269#####################################################################
270
271cc = meson.get_compiler('c')
272pkgconfig = import('pkgconfig')
6e2afb1c 273check_compilation_sh = find_program('tools/meson-check-compilation.sh')
b68dfb9e 274meson_build_sh = find_program('tools/meson-build.sh')
5c23128d 275
08318a2c
AD
276if get_option('tests') != 'false'
277 cxx = find_program('c++', required : false)
278 if cxx.found()
279 # Used only for tests
280 add_languages('cpp')
281 endif
94e2523b
ZJS
282endif
283
31e57a35
JR
284want_ossfuzz = get_option('oss-fuzz')
285want_libfuzzer = get_option('llvm-fuzz')
286fuzzer_build = want_ossfuzz or want_libfuzzer
287if want_ossfuzz and want_libfuzzer
288 error('only one of oss-fuzz and llvm-fuzz can be specified')
289endif
290if want_libfuzzer
291 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
292endif
293if want_ossfuzz
7db7d5b7
JR
294 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
295endif
296
30a4ddff
YW
297possible_cc_flags = [
298 '-Wextra',
299 '-Werror=undef',
300 '-Wlogical-op',
301 '-Wmissing-include-dirs',
302 '-Wold-style-definition',
303 '-Wpointer-arith',
304 '-Winit-self',
30a4ddff
YW
305 '-Wfloat-equal',
306 '-Wsuggest-attribute=noreturn',
307 '-Werror=missing-prototypes',
308 '-Werror=implicit-function-declaration',
309 '-Werror=missing-declarations',
310 '-Werror=return-type',
311 '-Werror=incompatible-pointer-types',
312 '-Werror=format=2',
313 '-Wstrict-prototypes',
314 '-Wredundant-decls',
315 '-Wmissing-noreturn',
316 '-Wimplicit-fallthrough=5',
317 '-Wshadow',
318 '-Wendif-labels',
319 '-Wstrict-aliasing=2',
320 '-Wwrite-strings',
321 '-Werror=overflow',
b05ecb8c 322 '-Werror=shift-count-overflow',
d28b67d4 323 '-Werror=shift-overflow=2',
30a4ddff
YW
324 '-Wdate-time',
325 '-Wnested-externs',
326 '-ffast-math',
327 '-fno-common',
328 '-fdiagnostics-show-option',
329 '-fno-strict-aliasing',
330 '-fvisibility=hidden',
331 '-fstack-protector',
332 '-fstack-protector-strong',
333 '--param=ssp-buffer-size=4',
334]
335
336# --as-needed and --no-undefined are provided by meson by default,
337# run mesonconf to see what is enabled
338possible_link_flags = [
339 '-Wl,-z,relro',
340 '-Wl,-z,now',
341]
5c23128d 342
7db7d5b7
JR
343# the oss-fuzz fuzzers are not built with -fPIE, so don't
344# enable it when we are linking against them
31e57a35 345if not fuzzer_build
30a4ddff
YW
346 possible_cc_flags += '-fPIE'
347 possible_link_flags += '-pie'
7db7d5b7
JR
348endif
349
30a4ddff
YW
350if cc.get_id() == 'clang'
351 possible_cc_flags += [
352 '-Wno-typedef-redefinition',
353 '-Wno-gnu-variable-sized-type-not-at-end',
354 ]
355endif
356
357if get_option('buildtype') != 'debug'
358 possible_cc_flags += [
359 '-ffunction-sections',
360 '-fdata-sections',
361 ]
362
363 possible_link_flags += '-Wl,--gc-sections'
364endif
365
366add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
367
2c5434ad 368# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
d40f5cc4 369# arguments, just emits a warning. So test for the "positive" version instead.
2c5434ad
ZJS
370foreach arg : ['unused-parameter',
371 'missing-field-initializers',
372 'unused-result',
fb1b5882
ZJS
373 'format-signedness',
374 'error=nonnull', # work-around for gcc 7.1 turning this on on its own
375 ]
2c5434ad
ZJS
376 if cc.has_argument('-W' + arg)
377 add_project_arguments('-Wno-' + arg, language : 'c')
378 endif
379endforeach
380
9e70f2f8 381if cc.compiles('''
5c23128d
ZJS
382 #include <time.h>
383 #include <inttypes.h>
384 typedef uint64_t usec_t;
385 usec_t now(clockid_t clock);
386 int main(void) {
387 struct timespec now;
388 return 0;
389 }
9e70f2f8 390''', name : '-Werror=shadow with local shadowing')
37efbbd8 391 add_project_arguments('-Werror=shadow', language : 'c')
5c23128d
ZJS
392endif
393
6e2afb1c
ZJS
394link_test_c = files('tools/meson-link-test.c')
395
30a4ddff 396foreach arg : possible_link_flags
6e2afb1c
ZJS
397 have = run_command(check_compilation_sh,
398 cc.cmd_array(), '-x', 'c', arg,
399 '-include', link_test_c).returncode() == 0
400 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
30a4ddff 401 if have
37efbbd8
ZJS
402 add_project_link_arguments(arg, language : 'c')
403 endif
5c23128d
ZJS
404endforeach
405
9cc0e6e9
ZJS
406cpp = ' '.join(cc.cmd_array()) + ' -E'
407
5c23128d
ZJS
408#####################################################################
409# compilation result tests
410
2c201c21
ZJS
411conf.set('_GNU_SOURCE', true)
412conf.set('__SANE_USERSPACE_TYPES__', true)
5c23128d
ZJS
413
414conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
415conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
416conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
417conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
418conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
419conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
420conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
421
422decl_headers = '''
423#include <uchar.h>
424#include <linux/ethtool.h>
bce67bbe 425#include <linux/fib_rules.h>
4c2e1b39
LP
426#include <linux/stat.h>
427#include <sys/stat.h>
5c23128d
ZJS
428'''
429# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
430
431foreach decl : ['char16_t',
432 'char32_t',
433 'key_serial_t',
434 'struct ethtool_link_settings',
bce67bbe 435 'struct fib_rule_uid_range',
4c2e1b39 436 'struct statx',
5c23128d 437 ]
2c201c21
ZJS
438
439 # We get -1 if the size cannot be determined
440 have = cc.sizeof(decl, prefix : decl_headers) > 0
349cc4a5 441 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
5c23128d
ZJS
442endforeach
443
444foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
445 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
446 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
447 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
d384826f 448 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
5c23128d
ZJS
449 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
450 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
451 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
452 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
453 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
9dfed8dd 454 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
5c23128d
ZJS
455 # if_tunnel.h is buggy and cannot be included on its own
456 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
457 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
458 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
459 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
460 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
461 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
462 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
d384826f 463 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
5c23128d
ZJS
464 ['NDA_IFINDEX', 'linux/neighbour.h'],
465 ['IFA_FLAGS', 'linux/if_addr.h'],
bce67bbe 466 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
5c23128d 467 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
d6df583c 468 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
5c23128d 469 ]
37efbbd8
ZJS
470 prefix = decl.length() > 2 ? decl[2] : ''
471 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
4b9545f1 472 conf.set10('HAVE_' + decl[0], have)
5c23128d
ZJS
473endforeach
474
5c23128d 475foreach ident : ['secure_getenv', '__secure_getenv']
349cc4a5 476 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
5c23128d
ZJS
477endforeach
478
479foreach ident : [
85db59b7 480 ['memfd_create', '''#include <sys/mman.h>'''],
7b961e40
LP
481 ['gettid', '''#include <sys/types.h>
482 #include <unistd.h>'''],
3c042add
LP
483 ['pivot_root', '''#include <stdlib.h>
484 #include <unistd.h>'''], # no known header declares pivot_root
85db59b7 485 ['name_to_handle_at', '''#include <sys/types.h>
37efbbd8
ZJS
486 #include <sys/stat.h>
487 #include <fcntl.h>'''],
85db59b7 488 ['setns', '''#include <sched.h>'''],
2acfd0ff
LP
489 ['renameat2', '''#include <stdio.h>
490 #include <fcntl.h>'''],
37efbbd8
ZJS
491 ['kcmp', '''#include <linux/kcmp.h>'''],
492 ['keyctl', '''#include <sys/types.h>
493 #include <keyutils.h>'''],
85db59b7 494 ['copy_file_range', '''#include <sys/syscall.h>
37efbbd8 495 #include <unistd.h>'''],
71e5200f
DM
496 ['bpf', '''#include <sys/syscall.h>
497 #include <unistd.h>'''],
4c2e1b39
LP
498 ['statx', '''#include <sys/types.h>
499 #include <sys/stat.h>
500 #include <unistd.h>'''],
aa484f35
ZJS
501 ['explicit_bzero' , '''#include <string.h>'''],
502 ['reallocarray', '''#include <malloc.h>'''],
37efbbd8
ZJS
503]
504
85db59b7 505 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
4b9545f1 506 conf.set10('HAVE_' + ident[0].to_upper(), have)
5c23128d
ZJS
507endforeach
508
85db59b7 509if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
349cc4a5 510 conf.set10('USE_SYS_RANDOM_H', true)
4b9545f1 511 conf.set10('HAVE_GETRANDOM', true)
4984c8be
ZJS
512else
513 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
349cc4a5 514 conf.set10('USE_SYS_RANDOM_H', false)
4b9545f1 515 conf.set10('HAVE_GETRANDOM', have)
4984c8be
ZJS
516endif
517
5c23128d
ZJS
518#####################################################################
519
520sed = find_program('sed')
5c23128d 521awk = find_program('awk')
d730e2d1 522m4 = find_program('m4')
5c23128d 523stat = find_program('stat')
d68b342b 524git = find_program('git', required : false)
b68dfb9e 525env = find_program('env')
b1ffacb6 526perl = find_program('perl', required : false)
5c23128d 527
7b76fce1 528meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
94e75a54 529mkdir_p = 'mkdir -p $DESTDIR/@0@'
d83f4f50
ZJS
530test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
531splash_bmp = files('test/splash.bmp')
94e75a54 532
5c23128d
ZJS
533# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
534# /usr/sbin, /sbin, and fall back to the default from middle column.
2fa645f1 535progs = [['quotaon', '/usr/sbin/quotaon' ],
5c23128d 536 ['quotacheck', '/usr/sbin/quotacheck' ],
5c23128d
ZJS
537 ['kmod', '/usr/bin/kmod' ],
538 ['kexec', '/usr/sbin/kexec' ],
539 ['sulogin', '/usr/sbin/sulogin' ],
540 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
541 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
542 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
543 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
544 ]
545foreach prog : progs
37efbbd8
ZJS
546 path = get_option(prog[0] + '-path')
547 if path != ''
548 message('Using @1@ for @0@'.format(prog[0], path))
549 else
550 exe = find_program(prog[0],
551 '/usr/sbin/' + prog[0],
552 '/sbin/' + prog[0],
553 required: false)
554 path = exe.found() ? exe.path() : prog[1]
555 endif
556 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
557 conf.set_quoted(name, path)
558 substs.set(name, path)
5c23128d
ZJS
559endforeach
560
2fa645f1
MG
561conf.set_quoted('TELINIT', get_option('telinit-path'))
562
1276a9f6 563if run_command('ln', '--relative', '--help').returncode() != 0
cd001016 564 error('ln does not support --relative (added in coreutils 8.16)')
1276a9f6 565endif
5c23128d
ZJS
566
567############################################################
568
569gperf = find_program('gperf')
570
571gperf_test_format = '''
572#include <string.h>
573const char * in_word_set(const char *, @0@);
574@1@
575'''
576gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
577gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
578gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
579if cc.compiles(gperf_test)
37efbbd8 580 gperf_len_type = 'size_t'
5c23128d 581else
37efbbd8
ZJS
582 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
583 if cc.compiles(gperf_test)
584 gperf_len_type = 'unsigned'
585 else
586 error('unable to determine gperf len type')
587 endif
5c23128d
ZJS
588endif
589message('gperf len type is @0@'.format(gperf_len_type))
37efbbd8
ZJS
590conf.set('GPERF_LEN_TYPE', gperf_len_type,
591 description : 'The type of gperf "len" parameter')
5c23128d
ZJS
592
593############################################################
594
595if not cc.has_header('sys/capability.h')
37efbbd8 596 error('POSIX caps headers not found')
5c23128d 597endif
9f555bba
BE
598foreach header : ['crypt.h',
599 'linux/btrfs.h',
5c23128d
ZJS
600 'linux/memfd.h',
601 'linux/vm_sockets.h',
af8786b1 602 'sys/auxv.h',
5c23128d
ZJS
603 'valgrind/memcheck.h',
604 'valgrind/valgrind.h',
605 ]
2c201c21 606
349cc4a5
ZJS
607 conf.set10('HAVE_' + header.underscorify().to_upper(),
608 cc.has_header(header))
5c23128d
ZJS
609endforeach
610
611############################################################
612
613conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
5248e7e1
ZJS
614conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
615gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
5c23128d
ZJS
616
617default_hierarchy = get_option('default-hierarchy')
618conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
619 description : 'default cgroup hierarchy as string')
620if default_hierarchy == 'legacy'
37efbbd8 621 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
5c23128d 622elif default_hierarchy == 'hybrid'
37efbbd8 623 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
5c23128d 624else
37efbbd8 625 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
5c23128d
ZJS
626endif
627
628time_epoch = get_option('time-epoch')
629if time_epoch == ''
37efbbd8
ZJS
630 NEWS = files('NEWS')
631 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
5c23128d
ZJS
632endif
633time_epoch = time_epoch.to_int()
634conf.set('TIME_EPOCH', time_epoch)
635
636system_uid_max = get_option('system-uid-max')
637if system_uid_max == ''
37efbbd8
ZJS
638 system_uid_max = run_command(
639 awk,
2f62cf35
CMOF
640 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
641 '/etc/login.defs').stdout().strip()
642 if system_uid_max == ''
643 system_uid_max = '999'
644 endif
5c23128d
ZJS
645endif
646system_uid_max = system_uid_max.to_int()
647conf.set('SYSTEM_UID_MAX', system_uid_max)
648substs.set('systemuidmax', system_uid_max)
7572aa80 649message('maximum system UID is @0@'.format(system_uid_max))
5c23128d 650
5c23128d
ZJS
651system_gid_max = get_option('system-gid-max')
652if system_gid_max == ''
37efbbd8
ZJS
653 system_gid_max = run_command(
654 awk,
2f62cf35
CMOF
655 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
656 '/etc/login.defs').stdout().strip()
657 if system_gid_max == ''
658 system_gid_max = '999'
659 endif
5c23128d
ZJS
660endif
661system_gid_max = system_gid_max.to_int()
662conf.set('SYSTEM_GID_MAX', system_gid_max)
663substs.set('systemgidmax', system_gid_max)
7572aa80 664message('maximum system GID is @0@'.format(system_gid_max))
5c23128d 665
87d5e4f2
LP
666dynamic_uid_min = get_option('dynamic-uid-min').to_int()
667dynamic_uid_max = get_option('dynamic-uid-max').to_int()
668conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
669conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
670substs.set('dynamicuidmin', dynamic_uid_min)
671substs.set('dynamicuidmax', dynamic_uid_max)
672
673container_uid_base_min = get_option('container-uid-base-min').to_int()
674container_uid_base_max = get_option('container-uid-base-max').to_int()
675conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
676conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
677substs.set('containeruidbasemin', container_uid_base_min)
678substs.set('containeruidbasemax', container_uid_base_max)
679
afde4574
LP
680nobody_user = get_option('nobody-user')
681nobody_group = get_option('nobody-group')
682
683getent_result = run_command('getent', 'passwd', '65534')
684if getent_result.returncode() == 0
685 name = getent_result.stdout().split(':')[0]
686 if name != nobody_user
8ea9fad7
YW
687 warning('\n' +
688 '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) +
689 'Your build will result in an user table setup that is incompatible with the local system.')
afde4574
LP
690 endif
691endif
692id_result = run_command('id', '-u', nobody_user)
693if id_result.returncode() == 0
694 id = id_result.stdout().to_int()
695 if id != 65534
8ea9fad7
YW
696 warning('\n' +
697 '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) +
698 'Your build will result in an user table setup that is incompatible with the local system.')
afde4574
LP
699 endif
700endif
701
702getent_result = run_command('getent', 'group', '65534')
703if getent_result.returncode() == 0
704 name = getent_result.stdout().split(':')[0]
705 if name != nobody_group
8ea9fad7
YW
706 warning('\n' +
707 '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) +
708 'Your build will result in an group table setup that is incompatible with the local system.')
afde4574
LP
709 endif
710endif
711id_result = run_command('id', '-g', nobody_group)
712if id_result.returncode() == 0
713 id = id_result.stdout().to_int()
714 if id != 65534
8ea9fad7
YW
715 warning('\n' +
716 '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) +
717 'Your build will result in an group table setup that is incompatible with the local system.')
afde4574
LP
718 endif
719endif
8374cc62 720if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
8ea9fad7
YW
721 warning('\n' +
722 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
723 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
8374cc62 724endif
afde4574
LP
725
726conf.set_quoted('NOBODY_USER_NAME', nobody_user)
727conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
60712021
YW
728substs.set('NOBODY_USER_NAME', nobody_user)
729substs.set('NOBODY_GROUP_NAME', nobody_group)
87d5e4f2 730
5c23128d
ZJS
731tty_gid = get_option('tty-gid')
732conf.set('TTY_GID', tty_gid)
2a4c156d 733substs.set('TTY_GID', tty_gid)
5c23128d 734
84786b8e
ID
735# Ensure provided GID argument is numeric, otherwise fallback to default assignment
736if get_option('users-gid') != ''
d6806870 737 users_gid = get_option('users-gid').to_int()
84786b8e 738else
d6806870 739 users_gid = '-'
84786b8e
ID
740endif
741substs.set('USERS_GID', users_gid)
742
348b4437
YW
743conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
744conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
5c23128d
ZJS
745
746substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
4e15a734 747substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
5c23128d 748
2a4c156d
ZJS
749kill_user_processes = get_option('default-kill-user-processes')
750conf.set10('KILL_USER_PROCESSES', kill_user_processes)
c7f7e859 751conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
2a4c156d 752substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
5c23128d 753
829257d1
ZJS
754dns_servers = get_option('dns-servers')
755conf.set_quoted('DNS_SERVERS', dns_servers)
756substs.set('DNS_SERVERS', dns_servers)
5c23128d 757
829257d1
ZJS
758ntp_servers = get_option('ntp-servers')
759conf.set_quoted('NTP_SERVERS', ntp_servers)
760substs.set('NTP_SERVERS', ntp_servers)
5c23128d
ZJS
761
762conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
763
3131bfe3
ZJS
764substs.set('SUSHELL', get_option('debug-shell'))
765substs.set('DEBUGTTY', get_option('debug-tty'))
766
349cc4a5
ZJS
767enable_debug_hashmap = false
768enable_debug_mmap_cache = false
ad7aa760
YW
769foreach name : get_option('debug')
770 if name == 'hashmap'
771 enable_debug_hashmap = true
772 elif name == 'mmap-cache'
773 enable_debug_mmap_cache = true
774 else
775 message('unknown debug option "@0@", ignoring'.format(name))
776 endif
777endforeach
349cc4a5
ZJS
778conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
779conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
671677da 780
d18cb393
ZJS
781conf.set10('VALGRIND', get_option('valgrind'))
782
5c23128d
ZJS
783#####################################################################
784
785threads = dependency('threads')
786librt = cc.find_library('rt')
787libm = cc.find_library('m')
788libdl = cc.find_library('dl')
789libcrypt = cc.find_library('crypt')
790
1800cc85
ZJS
791libcap = dependency('libcap', required : false)
792if not libcap.found()
793 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
794 libcap = cc.find_library('cap')
795endif
796
5c23128d 797libmount = dependency('mount',
c0b4b0f8 798 version : fuzzer_build ? '>= 0' : '>= 2.30')
5c23128d
ZJS
799
800want_seccomp = get_option('seccomp')
31e57a35 801if want_seccomp != 'false' and not fuzzer_build
37efbbd8 802 libseccomp = dependency('libseccomp',
9f0e9c01 803 version : '>= 2.3.1',
37efbbd8 804 required : want_seccomp == 'true')
349cc4a5 805 have = libseccomp.found()
5c23128d 806else
349cc4a5 807 have = false
37efbbd8 808 libseccomp = []
5c23128d 809endif
349cc4a5 810conf.set10('HAVE_SECCOMP', have)
5c23128d
ZJS
811
812want_selinux = get_option('selinux')
31e57a35 813if want_selinux != 'false' and not fuzzer_build
37efbbd8
ZJS
814 libselinux = dependency('libselinux',
815 version : '>= 2.1.9',
816 required : want_selinux == 'true')
349cc4a5 817 have = libselinux.found()
5c23128d 818else
349cc4a5 819 have = false
37efbbd8 820 libselinux = []
5c23128d 821endif
349cc4a5 822conf.set10('HAVE_SELINUX', have)
5c23128d
ZJS
823
824want_apparmor = get_option('apparmor')
31e57a35 825if want_apparmor != 'false' and not fuzzer_build
37efbbd8
ZJS
826 libapparmor = dependency('libapparmor',
827 required : want_apparmor == 'true')
349cc4a5 828 have = libapparmor.found()
5c23128d 829else
349cc4a5 830 have = false
37efbbd8 831 libapparmor = []
5c23128d 832endif
349cc4a5 833conf.set10('HAVE_APPARMOR', have)
5c23128d 834
5c23128d
ZJS
835smack_run_label = get_option('smack-run-label')
836if smack_run_label != ''
37efbbd8 837 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
5c23128d
ZJS
838endif
839
3ca0cb73
ZJS
840want_polkit = get_option('polkit')
841install_polkit = false
842install_polkit_pkla = false
31e57a35 843if want_polkit != 'false' and not fuzzer_build
37efbbd8 844 install_polkit = true
3ca0cb73 845
37efbbd8
ZJS
846 libpolkit = dependency('polkit-gobject-1',
847 required : false)
848 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
849 message('Old polkit detected, will install pkla files')
850 install_polkit_pkla = true
851 endif
3ca0cb73 852endif
349cc4a5 853conf.set10('ENABLE_POLKIT', install_polkit)
3ca0cb73 854
36f0387e 855want_acl = get_option('acl')
31e57a35 856if want_acl != 'false' and not fuzzer_build
36f0387e 857 libacl = cc.find_library('acl', required : want_acl == 'true')
349cc4a5 858 have = libacl.found()
36f0387e 859else
349cc4a5 860 have = false
36f0387e
ZJS
861 libacl = []
862endif
349cc4a5 863conf.set10('HAVE_ACL', have)
36f0387e 864
5c23128d 865want_audit = get_option('audit')
31e57a35 866if want_audit != 'false' and not fuzzer_build
37efbbd8 867 libaudit = dependency('audit', required : want_audit == 'true')
349cc4a5 868 have = libaudit.found()
5c23128d 869else
349cc4a5 870 have = false
37efbbd8 871 libaudit = []
5c23128d 872endif
349cc4a5 873conf.set10('HAVE_AUDIT', have)
5c23128d
ZJS
874
875want_blkid = get_option('blkid')
31e57a35 876if want_blkid != 'false' and not fuzzer_build
37efbbd8 877 libblkid = dependency('blkid', required : want_blkid == 'true')
349cc4a5 878 have = libblkid.found()
5c23128d 879else
349cc4a5 880 have = false
37efbbd8 881 libblkid = []
5c23128d 882endif
349cc4a5 883conf.set10('HAVE_BLKID', have)
5c23128d
ZJS
884
885want_kmod = get_option('kmod')
31e57a35 886if want_kmod != 'false' and not fuzzer_build
37efbbd8
ZJS
887 libkmod = dependency('libkmod',
888 version : '>= 15',
889 required : want_kmod == 'true')
349cc4a5 890 have = libkmod.found()
5c23128d 891else
349cc4a5 892 have = false
37efbbd8 893 libkmod = []
5c23128d 894endif
349cc4a5 895conf.set10('HAVE_KMOD', have)
5c23128d
ZJS
896
897want_pam = get_option('pam')
31e57a35 898if want_pam != 'false' and not fuzzer_build
37efbbd8
ZJS
899 libpam = cc.find_library('pam', required : want_pam == 'true')
900 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
349cc4a5 901 have = libpam.found() and libpam_misc.found()
5c23128d 902else
349cc4a5 903 have = false
37efbbd8
ZJS
904 libpam = []
905 libpam_misc = []
5c23128d 906endif
349cc4a5 907conf.set10('HAVE_PAM', have)
5c23128d
ZJS
908
909want_microhttpd = get_option('microhttpd')
31e57a35 910if want_microhttpd != 'false' and not fuzzer_build
37efbbd8
ZJS
911 libmicrohttpd = dependency('libmicrohttpd',
912 version : '>= 0.9.33',
913 required : want_microhttpd == 'true')
349cc4a5 914 have = libmicrohttpd.found()
5c23128d 915else
349cc4a5 916 have = false
37efbbd8 917 libmicrohttpd = []
5c23128d 918endif
349cc4a5 919conf.set10('HAVE_MICROHTTPD', have)
5c23128d
ZJS
920
921want_libcryptsetup = get_option('libcryptsetup')
31e57a35 922if want_libcryptsetup != 'false' and not fuzzer_build
37efbbd8
ZJS
923 libcryptsetup = dependency('libcryptsetup',
924 version : '>= 1.6.0',
925 required : want_libcryptsetup == 'true')
349cc4a5 926 have = libcryptsetup.found()
5c23128d 927else
349cc4a5 928 have = false
37efbbd8 929 libcryptsetup = []
5c23128d 930endif
349cc4a5 931conf.set10('HAVE_LIBCRYPTSETUP', have)
5c23128d
ZJS
932
933want_libcurl = get_option('libcurl')
31e57a35 934if want_libcurl != 'false' and not fuzzer_build
37efbbd8
ZJS
935 libcurl = dependency('libcurl',
936 version : '>= 7.32.0',
937 required : want_libcurl == 'true')
349cc4a5 938 have = libcurl.found()
5c23128d 939else
349cc4a5 940 have = false
37efbbd8 941 libcurl = []
5c23128d 942endif
349cc4a5 943conf.set10('HAVE_LIBCURL', have)
5c23128d
ZJS
944
945want_libidn = get_option('libidn')
87057e24
ZJS
946want_libidn2 = get_option('libidn2')
947if want_libidn == 'true' and want_libidn2 == 'true'
948 error('libidn and libidn2 cannot be requested simultaneously')
949endif
950
31e57a35 951if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
7f7ab228
ZJS
952 libidn = dependency('libidn',
953 required : want_libidn == 'true')
349cc4a5 954 have = libidn.found()
87057e24 955else
349cc4a5 956 have = false
87057e24
ZJS
957 libidn = []
958endif
349cc4a5 959conf.set10('HAVE_LIBIDN', have)
31e57a35 960if not have and want_libidn2 != 'false' and not fuzzer_build
7f7ab228
ZJS
961 # libidn is used for both libidn and libidn2 objects
962 libidn = dependency('libidn2',
963 required : want_libidn2 == 'true')
349cc4a5
ZJS
964 have = libidn.found()
965else
966 have = false
5c23128d 967endif
349cc4a5 968conf.set10('HAVE_LIBIDN2', have)
5c23128d
ZJS
969
970want_libiptc = get_option('libiptc')
31e57a35 971if want_libiptc != 'false' and not fuzzer_build
37efbbd8
ZJS
972 libiptc = dependency('libiptc',
973 required : want_libiptc == 'true')
349cc4a5 974 have = libiptc.found()
5c23128d 975else
349cc4a5 976 have = false
37efbbd8 977 libiptc = []
5c23128d 978endif
349cc4a5 979conf.set10('HAVE_LIBIPTC', have)
5c23128d
ZJS
980
981want_qrencode = get_option('qrencode')
31e57a35 982if want_qrencode != 'false' and not fuzzer_build
37efbbd8
ZJS
983 libqrencode = dependency('libqrencode',
984 required : want_qrencode == 'true')
349cc4a5 985 have = libqrencode.found()
5c23128d 986else
349cc4a5 987 have = false
37efbbd8 988 libqrencode = []
5c23128d 989endif
349cc4a5 990conf.set10('HAVE_QRENCODE', have)
5c23128d 991
a44fb601 992want_gcrypt = get_option('gcrypt')
31e57a35 993if want_gcrypt != 'false' and not fuzzer_build
a44fb601
ZJS
994 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
995 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
349cc4a5 996 have = libgcrypt.found() and libgpg_error.found()
a44fb601 997else
349cc4a5
ZJS
998 have = false
999endif
1000if not have
1001 # link to neither of the libs if one is not found
a44fb601
ZJS
1002 libgcrypt = []
1003 libgpg_error = []
1004endif
349cc4a5 1005conf.set10('HAVE_GCRYPT', have)
a44fb601 1006
5c23128d 1007want_gnutls = get_option('gnutls')
31e57a35 1008if want_gnutls != 'false' and not fuzzer_build
37efbbd8
ZJS
1009 libgnutls = dependency('gnutls',
1010 version : '>= 3.1.4',
1011 required : want_gnutls == 'true')
349cc4a5 1012 have = libgnutls.found()
5c23128d 1013else
349cc4a5 1014 have = false
37efbbd8 1015 libgnutls = []
5c23128d 1016endif
349cc4a5 1017conf.set10('HAVE_GNUTLS', have)
5c23128d
ZJS
1018
1019want_elfutils = get_option('elfutils')
31e57a35 1020if want_elfutils != 'false' and not fuzzer_build
37efbbd8
ZJS
1021 libdw = dependency('libdw',
1022 required : want_elfutils == 'true')
349cc4a5 1023 have = libdw.found()
5c23128d 1024else
349cc4a5 1025 have = false
37efbbd8 1026 libdw = []
5c23128d 1027endif
349cc4a5 1028conf.set10('HAVE_ELFUTILS', have)
5c23128d
ZJS
1029
1030want_zlib = get_option('zlib')
31e57a35 1031if want_zlib != 'false' and not fuzzer_build
37efbbd8
ZJS
1032 libz = dependency('zlib',
1033 required : want_zlib == 'true')
349cc4a5 1034 have = libz.found()
5c23128d 1035else
349cc4a5 1036 have = false
37efbbd8 1037 libz = []
5c23128d 1038endif
349cc4a5 1039conf.set10('HAVE_ZLIB', have)
5c23128d
ZJS
1040
1041want_bzip2 = get_option('bzip2')
31e57a35 1042if want_bzip2 != 'false' and not fuzzer_build
37efbbd8
ZJS
1043 libbzip2 = cc.find_library('bz2',
1044 required : want_bzip2 == 'true')
349cc4a5 1045 have = libbzip2.found()
5c23128d 1046else
349cc4a5 1047 have = false
37efbbd8 1048 libbzip2 = []
5c23128d 1049endif
349cc4a5 1050conf.set10('HAVE_BZIP2', have)
5c23128d
ZJS
1051
1052want_xz = get_option('xz')
31e57a35 1053if want_xz != 'false' and not fuzzer_build
37efbbd8
ZJS
1054 libxz = dependency('liblzma',
1055 required : want_xz == 'true')
349cc4a5 1056 have = libxz.found()
5c23128d 1057else
349cc4a5 1058 have = false
37efbbd8 1059 libxz = []
5c23128d 1060endif
349cc4a5 1061conf.set10('HAVE_XZ', have)
5c23128d
ZJS
1062
1063want_lz4 = get_option('lz4')
31e57a35 1064if want_lz4 != 'false' and not fuzzer_build
37efbbd8
ZJS
1065 liblz4 = dependency('liblz4',
1066 required : want_lz4 == 'true')
349cc4a5 1067 have = liblz4.found()
5c23128d 1068else
349cc4a5 1069 have = false
37efbbd8 1070 liblz4 = []
5c23128d 1071endif
349cc4a5 1072conf.set10('HAVE_LZ4', have)
5c23128d 1073
a44fb601 1074want_xkbcommon = get_option('xkbcommon')
31e57a35 1075if want_xkbcommon != 'false' and not fuzzer_build
a44fb601
ZJS
1076 libxkbcommon = dependency('xkbcommon',
1077 version : '>= 0.3.0',
1078 required : want_xkbcommon == 'true')
349cc4a5 1079 have = libxkbcommon.found()
a44fb601 1080else
349cc4a5 1081 have = false
a44fb601
ZJS
1082 libxkbcommon = []
1083endif
349cc4a5 1084conf.set10('HAVE_XKBCOMMON', have)
a44fb601 1085
c4c978a0
ZJS
1086want_pcre2 = get_option('pcre2')
1087if want_pcre2 != 'false'
1088 libpcre2 = dependency('libpcre2-8',
1089 required : want_pcre2 == 'true')
1090 have = libpcre2.found()
1091else
1092 have = false
1093 libpcre2 = []
1094endif
1095conf.set10('HAVE_PCRE2', have)
1096
69e96427 1097want_glib = get_option('glib')
31e57a35 1098if want_glib != 'false' and not fuzzer_build
37efbbd8
ZJS
1099 libglib = dependency('glib-2.0',
1100 version : '>= 2.22.0',
1101 required : want_glib == 'true')
1102 libgobject = dependency('gobject-2.0',
1103 version : '>= 2.22.0',
1104 required : want_glib == 'true')
1105 libgio = dependency('gio-2.0',
1106 required : want_glib == 'true')
2c201c21 1107 have = libglib.found() and libgobject.found() and libgio.found()
69e96427 1108else
349cc4a5 1109 have = false
37efbbd8
ZJS
1110 libglib = []
1111 libgobject = []
1112 libgio = []
69e96427 1113endif
349cc4a5 1114conf.set10('HAVE_GLIB', have)
69e96427
ZJS
1115
1116want_dbus = get_option('dbus')
31e57a35 1117if want_dbus != 'false' and not fuzzer_build
37efbbd8
ZJS
1118 libdbus = dependency('dbus-1',
1119 version : '>= 1.3.2',
1120 required : want_dbus == 'true')
349cc4a5 1121 have = libdbus.found()
69e96427 1122else
349cc4a5 1123 have = false
37efbbd8 1124 libdbus = []
69e96427 1125endif
349cc4a5 1126conf.set10('HAVE_DBUS', have)
69e96427 1127
42303dcb 1128default_dnssec = get_option('default-dnssec')
31e57a35 1129if fuzzer_build
b4081f3e
JR
1130 default_dnssec = 'no'
1131endif
349cc4a5 1132if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
42303dcb
YW
1133 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1134 default_dnssec = 'no'
1135endif
1136conf.set('DEFAULT_DNSSEC_MODE',
1137 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1138substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1139
5c23128d 1140want_importd = get_option('importd')
4390be30 1141if want_importd != 'false'
349cc4a5
ZJS
1142 have = (conf.get('HAVE_LIBCURL') == 1 and
1143 conf.get('HAVE_ZLIB') == 1 and
1144 conf.get('HAVE_BZIP2') == 1 and
1145 conf.get('HAVE_XZ') == 1 and
1146 conf.get('HAVE_GCRYPT') == 1)
1147 if want_importd == 'true' and not have
37efbbd8
ZJS
1148 error('importd support was requested, but dependencies are not available')
1149 endif
349cc4a5
ZJS
1150else
1151 have = false
5c23128d 1152endif
349cc4a5 1153conf.set10('ENABLE_IMPORTD', have)
5c23128d
ZJS
1154
1155want_remote = get_option('remote')
4390be30 1156if want_remote != 'false'
349cc4a5
ZJS
1157 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1158 conf.get('HAVE_LIBCURL') == 1]
37efbbd8
ZJS
1159 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1160 # it's possible to build one without the other. Complain only if
1161 # support was explictly requested. The auxiliary files like sysusers
1162 # config should be installed when any of the programs are built.
1163 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1164 error('remote support was requested, but dependencies are not available')
1165 endif
349cc4a5
ZJS
1166 have = have_deps[0] or have_deps[1]
1167else
1168 have = false
5c23128d 1169endif
349cc4a5 1170conf.set10('ENABLE_REMOTE', have)
5c23128d 1171
a9149d87
ZJS
1172foreach term : ['utmp',
1173 'hibernate',
1174 'environment-d',
1175 'binfmt',
1176 'coredump',
1177 'resolve',
1178 'logind',
1179 'hostnamed',
1180 'localed',
1181 'machined',
61d0578b 1182 'portabled',
a9149d87
ZJS
1183 'networkd',
1184 'timedated',
1185 'timesyncd',
1186 'myhostname',
1187 'firstboot',
1188 'randomseed',
1189 'backlight',
1190 'vconsole',
1191 'quotacheck',
1192 'sysusers',
1193 'tmpfiles',
1194 'hwdb',
1195 'rfkill',
1196 'ldconfig',
1197 'efi',
1198 'tpm',
1199 'ima',
1200 'smack',
1201 'gshadow',
1202 'idn',
1203 'nss-systemd']
1204 have = get_option(term)
1205 name = 'ENABLE_' + term.underscorify().to_upper()
1206 conf.set10(name, have)
5c23128d
ZJS
1207endforeach
1208
348b4437 1209conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
6129ec85 1210
69e96427 1211want_tests = get_option('tests')
572baca1 1212install_tests = get_option('install-tests')
b68dfb9e 1213slow_tests = get_option('slow-tests')
69e96427 1214tests = []
7db7d5b7 1215fuzzers = []
69e96427 1216
b68dfb9e 1217conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
00d82c81 1218
5c23128d
ZJS
1219#####################################################################
1220
1221if get_option('efi')
37efbbd8 1222 efi_arch = host_machine.cpu_family()
b710072d 1223
6800fe7f 1224 if efi_arch == 'x86'
37efbbd8 1225 EFI_MACHINE_TYPE_NAME = 'ia32'
6800fe7f 1226 gnu_efi_arch = 'ia32'
37efbbd8
ZJS
1227 elif efi_arch == 'x86_64'
1228 EFI_MACHINE_TYPE_NAME = 'x64'
6800fe7f 1229 gnu_efi_arch = 'x86_64'
37efbbd8
ZJS
1230 elif efi_arch == 'arm'
1231 EFI_MACHINE_TYPE_NAME = 'arm'
6800fe7f 1232 gnu_efi_arch = 'arm'
37efbbd8
ZJS
1233 elif efi_arch == 'aarch64'
1234 EFI_MACHINE_TYPE_NAME = 'aa64'
6800fe7f 1235 gnu_efi_arch = 'aarch64'
37efbbd8
ZJS
1236 else
1237 EFI_MACHINE_TYPE_NAME = ''
6800fe7f 1238 gnu_efi_arch = ''
37efbbd8 1239 endif
5c23128d 1240
349cc4a5 1241 have = true
37efbbd8 1242 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
80c6fce8
ZJS
1243
1244 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
349cc4a5
ZJS
1245else
1246 have = false
5c23128d 1247endif
349cc4a5 1248conf.set10('ENABLE_EFI', have)
5c23128d
ZJS
1249
1250#####################################################################
1251
1252config_h = configure_file(
37efbbd8
ZJS
1253 output : 'config.h',
1254 configuration : conf)
5c23128d 1255
348b4437
YW
1256meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1257
5c23128d
ZJS
1258includes = include_directories('src/basic',
1259 'src/shared',
1260 'src/systemd',
1261 'src/journal',
a38f7fec 1262 'src/journal-remote',
97d90615 1263 'src/nspawn',
5c23128d
ZJS
1264 'src/resolve',
1265 'src/timesync',
5c3376ef 1266 'src/time-wait-sync',
5c23128d
ZJS
1267 'src/login',
1268 'src/udev',
1269 'src/libudev',
1270 'src/core',
1271 'src/libsystemd/sd-bus',
1272 'src/libsystemd/sd-device',
1273 'src/libsystemd/sd-hwdb',
1274 'src/libsystemd/sd-id128',
1275 'src/libsystemd/sd-netlink',
1276 'src/libsystemd/sd-network',
1277 'src/libsystemd-network',
2d4ceca8 1278 '.')
5c23128d
ZJS
1279
1280add_project_arguments('-include', 'config.h', language : 'c')
1281
5c23128d
ZJS
1282subdir('po')
1283subdir('catalog')
1284subdir('src/systemd')
1285subdir('src/basic')
1286subdir('src/libsystemd')
1287subdir('src/libsystemd-network')
5c23128d 1288subdir('src/journal')
5c23128d 1289subdir('src/login')
5c23128d
ZJS
1290
1291libjournal_core = static_library(
37efbbd8
ZJS
1292 'journal-core',
1293 libjournal_core_sources,
1294 journald_gperf_c,
1295 include_directories : includes,
1296 install : false)
5c23128d 1297
37ab1a25 1298libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d 1299libsystemd = shared_library(
37efbbd8 1300 'systemd',
7f1ea2cc 1301 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
56d50ab1 1302 version : libsystemd_version,
37efbbd8
ZJS
1303 include_directories : includes,
1304 link_args : ['-shared',
1305 '-Wl,--version-script=' + libsystemd_sym_path],
34e221a5
ZJS
1306 link_with : [libbasic,
1307 libbasic_gcrypt],
5e3cec87
ZJS
1308 link_whole : [libsystemd_static,
1309 libjournal_client],
37efbbd8
ZJS
1310 dependencies : [threads,
1311 librt,
1312 libxz,
1313 liblz4],
1314 link_depends : libsystemd_sym,
1315 install : true,
1316 install_dir : rootlibdir)
5c23128d 1317
70848ecf
DC
1318static_libsystemd = get_option('static-libsystemd')
1319static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1320
1321install_libsystemd_static = static_library(
1322 'systemd',
1323 libsystemd_sources,
1324 journal_client_sources,
975464e0
ZJS
1325 basic_sources,
1326 basic_gcrypt_sources,
70848ecf 1327 include_directories : includes,
70848ecf
DC
1328 build_by_default : static_libsystemd != 'false',
1329 install : static_libsystemd != 'false',
1330 install_dir : rootlibdir,
1331 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1332 dependencies : [threads,
1333 librt,
1334 libxz,
1335 liblz4,
975464e0
ZJS
1336 libcap,
1337 libblkid,
1338 libmount,
1339 libselinux,
70848ecf
DC
1340 libgcrypt],
1341 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1342
5c23128d
ZJS
1343############################################################
1344
83b6af36
ZJS
1345# binaries that have --help and are intended for use by humans,
1346# usually, but not always, installed in /bin.
1347public_programs = []
1348
1349subdir('src/libudev')
1350subdir('src/shared')
1351subdir('src/core')
1352subdir('src/udev')
1353subdir('src/network')
1354
1355subdir('src/analyze')
1356subdir('src/journal-remote')
1357subdir('src/coredump')
1358subdir('src/hostname')
1359subdir('src/import')
1360subdir('src/kernel-install')
1361subdir('src/locale')
1362subdir('src/machine')
61d0578b 1363subdir('src/portable')
83b6af36
ZJS
1364subdir('src/nspawn')
1365subdir('src/resolve')
1366subdir('src/timedate')
1367subdir('src/timesync')
1368subdir('src/vconsole')
83b6af36
ZJS
1369subdir('src/boot/efi')
1370
1371subdir('src/test')
7db7d5b7 1372subdir('src/fuzz')
6b97bf22 1373subdir('rules')
83b6af36
ZJS
1374subdir('test')
1375
1376############################################################
1377
1378# only static linking apart from libdl, to make sure that the
1379# module is linked to all libraries that it uses.
1380test_dlopen = executable(
37efbbd8
ZJS
1381 'test-dlopen',
1382 test_dlopen_c,
1383 include_directories : includes,
1384 link_with : [libbasic],
1385 dependencies : [libdl])
83b6af36 1386
08cf5b8d 1387foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
e7e11bbf 1388 ['systemd', 'ENABLE_NSS_SYSTEMD'],
5486a31d 1389 ['mymachines', 'ENABLE_MACHINED'],
1ec57f33 1390 ['resolve', 'ENABLE_RESOLVE']]
5c23128d 1391
349cc4a5 1392 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
1393 if condition
1394 module = tuple[0]
37efbbd8
ZJS
1395
1396 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1397 version_script_arg = join_paths(meson.current_source_dir(), sym)
1398
1399 nss = shared_library(
1400 'nss_' + module,
1401 'src/nss-@0@/nss-@0@.c'.format(module),
1402 version : '2',
1403 include_directories : includes,
b4b36f44
LP
1404 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1405 link_args : ['-Wl,-z,nodelete',
1406 '-shared',
37efbbd8
ZJS
1407 '-Wl,--version-script=' + version_script_arg,
1408 '-Wl,--undefined'],
37e4d7a8 1409 link_with : [libsystemd_static,
37efbbd8
ZJS
1410 libbasic],
1411 dependencies : [threads,
5486a31d 1412 librt],
37efbbd8
ZJS
1413 link_depends : sym,
1414 install : true,
1415 install_dir : rootlibdir)
1416
1417 # We cannot use shared_module because it does not support version suffix.
1418 # Unfortunately shared_library insists on creating the symlink…
1419 meson.add_install_script('sh', '-c',
1420 'rm $DESTDIR@0@/libnss_@1@.so'
1421 .format(rootlibdir, module))
1422
1423 test('dlopen-nss_' + module,
1424 test_dlopen,
1425 args : [nss.full_path()]) # path to dlopen must include a slash
1426 endif
5c23128d
ZJS
1427endforeach
1428
1429############################################################
1430
5c23128d
ZJS
1431executable('systemd',
1432 systemd_sources,
1433 include_directories : includes,
1434 link_with : [libcore,
34ce0a52 1435 libshared],
5c23128d
ZJS
1436 dependencies : [threads,
1437 librt,
1438 libseccomp,
1439 libselinux,
f4ee10a2
ZJS
1440 libmount,
1441 libblkid],
421f0012 1442 install_rpath : rootlibexecdir,
5c23128d
ZJS
1443 install : true,
1444 install_dir : rootlibexecdir)
1445
ba7f4ae6
ZJS
1446meson.add_install_script(meson_make_symlink,
1447 join_paths(rootlibexecdir, 'systemd'),
1448 join_paths(rootsbindir, 'init'))
1449
005a29f2
ZJS
1450exe = executable('systemd-analyze',
1451 systemd_analyze_sources,
1452 include_directories : includes,
1453 link_with : [libcore,
005a29f2
ZJS
1454 libshared],
1455 dependencies : [threads,
1456 librt,
1457 libseccomp,
1458 libselinux,
1459 libmount,
1460 libblkid],
1461 install_rpath : rootlibexecdir,
1462 install : true)
1463public_programs += [exe]
5c23128d
ZJS
1464
1465executable('systemd-journald',
1466 systemd_journald_sources,
1467 include_directories : includes,
aac26058 1468 link_with : [libjournal_core,
34ce0a52 1469 libshared],
5c23128d
ZJS
1470 dependencies : [threads,
1471 libxz,
aac26058
ZJS
1472 liblz4,
1473 libselinux],
421f0012 1474 install_rpath : rootlibexecdir,
5c23128d
ZJS
1475 install : true,
1476 install_dir : rootlibexecdir)
1477
005a29f2
ZJS
1478exe = executable('systemd-cat',
1479 systemd_cat_sources,
1480 include_directories : includes,
1481 link_with : [libjournal_core,
34ce0a52 1482 libshared],
005a29f2
ZJS
1483 dependencies : [threads],
1484 install_rpath : rootlibexecdir,
1485 install : true)
1486public_programs += [exe]
1487
1488exe = executable('journalctl',
1489 journalctl_sources,
1490 include_directories : includes,
34ce0a52 1491 link_with : [libshared],
005a29f2
ZJS
1492 dependencies : [threads,
1493 libqrencode,
1494 libxz,
6becf48c
ZJS
1495 liblz4,
1496 libpcre2],
005a29f2
ZJS
1497 install_rpath : rootlibexecdir,
1498 install : true,
1499 install_dir : rootbindir)
1500public_programs += [exe]
5c23128d
ZJS
1501
1502executable('systemd-getty-generator',
1503 'src/getty-generator/getty-generator.c',
5c23128d 1504 include_directories : includes,
b2fc5836
ZJS
1505 link_with : [libshared],
1506 install_rpath : rootlibexecdir,
1507 install : true,
1508 install_dir : systemgeneratordir)
5c23128d
ZJS
1509
1510executable('systemd-debug-generator',
1511 'src/debug-generator/debug-generator.c',
5c23128d 1512 include_directories : includes,
b2fc5836
ZJS
1513 link_with : [libshared],
1514 install_rpath : rootlibexecdir,
1515 install : true,
1516 install_dir : systemgeneratordir)
5c23128d
ZJS
1517
1518executable('systemd-fstab-generator',
1519 'src/fstab-generator/fstab-generator.c',
1520 'src/core/mount-setup.c',
5c23128d 1521 include_directories : includes,
b2fc5836
ZJS
1522 link_with : [libshared],
1523 install_rpath : rootlibexecdir,
1524 install : true,
1525 install_dir : systemgeneratordir)
5c23128d 1526
349cc4a5 1527if conf.get('ENABLE_ENVIRONMENT_D') == 1
37efbbd8
ZJS
1528 executable('30-systemd-environment-d-generator',
1529 'src/environment-d-generator/environment-d-generator.c',
1530 include_directories : includes,
1531 link_with : [libshared],
1532 install_rpath : rootlibexecdir,
1533 install : true,
1534 install_dir : userenvgeneratordir)
7b76fce1 1535
37efbbd8
ZJS
1536 meson.add_install_script(meson_make_symlink,
1537 join_paths(sysconfdir, 'environment'),
1538 join_paths(environmentdir, '99-environment.conf'))
5c23128d
ZJS
1539endif
1540
349cc4a5 1541if conf.get('ENABLE_HIBERNATE') == 1
37efbbd8
ZJS
1542 executable('systemd-hibernate-resume-generator',
1543 'src/hibernate-resume/hibernate-resume-generator.c',
1544 include_directories : includes,
1545 link_with : [libshared],
1546 install_rpath : rootlibexecdir,
1547 install : true,
1548 install_dir : systemgeneratordir)
5c23128d 1549
37efbbd8
ZJS
1550 executable('systemd-hibernate-resume',
1551 'src/hibernate-resume/hibernate-resume.c',
005a29f2
ZJS
1552 include_directories : includes,
1553 link_with : [libshared],
1554 install_rpath : rootlibexecdir,
1555 install : true,
1556 install_dir : rootlibexecdir)
37efbbd8
ZJS
1557endif
1558
349cc4a5 1559if conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1560 executable('systemd-gpt-auto-generator',
1561 'src/gpt-auto-generator/gpt-auto-generator.c',
1562 'src/basic/blkid-util.h',
1563 include_directories : includes,
34ce0a52 1564 link_with : [libshared],
37efbbd8
ZJS
1565 dependencies : libblkid,
1566 install_rpath : rootlibexecdir,
1567 install : true,
1568 install_dir : systemgeneratordir)
1569
1570 exe = executable('systemd-dissect',
1571 'src/dissect/dissect.c',
1572 include_directories : includes,
1573 link_with : [libshared],
1574 install_rpath : rootlibexecdir,
1575 install : true,
1576 install_dir : rootlibexecdir)
1577 public_programs += [exe]
5c23128d
ZJS
1578endif
1579
1ec57f33 1580if conf.get('ENABLE_RESOLVE') == 1
37efbbd8
ZJS
1581 executable('systemd-resolved',
1582 systemd_resolved_sources,
005a29f2 1583 include_directories : includes,
34e221a5 1584 link_with : [libshared,
568a4ff8
ZJS
1585 libbasic_gcrypt,
1586 libsystemd_resolve_core],
005a29f2 1587 dependencies : [threads,
76c87410 1588 libgpg_error,
005a29f2
ZJS
1589 libm,
1590 libidn],
1591 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1592 install : true,
1593 install_dir : rootlibexecdir)
1594
c2e84cab
YW
1595 exe = executable('resolvectl',
1596 resolvectl_sources,
37efbbd8 1597 include_directories : includes,
34e221a5 1598 link_with : [libshared,
568a4ff8
ZJS
1599 libbasic_gcrypt,
1600 libsystemd_resolve_core],
37efbbd8 1601 dependencies : [threads,
76c87410 1602 libgpg_error,
37efbbd8
ZJS
1603 libm,
1604 libidn],
1605 install_rpath : rootlibexecdir,
1606 install : true)
1607 public_programs += [exe]
088c1363
LP
1608
1609 meson.add_install_script(meson_make_symlink,
c2e84cab 1610 join_paths(bindir, 'resolvectl'),
088c1363 1611 join_paths(rootsbindir, 'resolvconf'))
c2e84cab
YW
1612
1613 meson.add_install_script(meson_make_symlink,
1614 join_paths(bindir, 'resolvectl'),
1615 join_paths(bindir, 'systemd-resolve'))
5c23128d
ZJS
1616endif
1617
349cc4a5 1618if conf.get('ENABLE_LOGIND') == 1
37efbbd8
ZJS
1619 executable('systemd-logind',
1620 systemd_logind_sources,
005a29f2 1621 include_directories : includes,
37efbbd8 1622 link_with : [liblogind_core,
34ce0a52 1623 libshared],
005a29f2 1624 dependencies : [threads,
37efbbd8 1625 libacl],
005a29f2
ZJS
1626 install_rpath : rootlibexecdir,
1627 install : true,
37efbbd8
ZJS
1628 install_dir : rootlibexecdir)
1629
1630 exe = executable('loginctl',
1631 loginctl_sources,
1632 include_directories : includes,
34ce0a52 1633 link_with : [libshared],
37efbbd8
ZJS
1634 dependencies : [threads,
1635 liblz4,
1636 libxz],
1637 install_rpath : rootlibexecdir,
1638 install : true,
1639 install_dir : rootbindir)
1640 public_programs += [exe]
1641
1642 exe = executable('systemd-inhibit',
1643 'src/login/inhibit.c',
1644 include_directories : includes,
1645 link_with : [libshared],
1646 install_rpath : rootlibexecdir,
1647 install : true,
1648 install_dir : rootbindir)
1649 public_programs += [exe]
1650
349cc4a5 1651 if conf.get('HAVE_PAM') == 1
37efbbd8
ZJS
1652 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1653 pam_systemd = shared_library(
1654 'pam_systemd',
1655 pam_systemd_c,
1656 name_prefix : '',
1657 include_directories : includes,
1658 link_args : ['-shared',
1659 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 1660 link_with : [libsystemd_static,
37efbbd8
ZJS
1661 libshared_static],
1662 dependencies : [threads,
1663 libpam,
1664 libpam_misc],
1665 link_depends : pam_systemd_sym,
1666 install : true,
1667 install_dir : pamlibdir)
1668
1669 test('dlopen-pam_systemd',
1670 test_dlopen,
1671 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1672 endif
1673endif
005a29f2 1674
a9f0f5e5
ZJS
1675executable('systemd-user-runtime-dir',
1676 user_runtime_dir_sources,
1677 include_directories : includes,
1678 link_with : [libshared, liblogind_core],
1679 install_rpath : rootlibexecdir,
1680 install : true,
1681 install_dir : rootlibexecdir)
1682
349cc4a5 1683if conf.get('HAVE_PAM') == 1
37efbbd8
ZJS
1684 executable('systemd-user-sessions',
1685 'src/user-sessions/user-sessions.c',
005a29f2 1686 include_directories : includes,
aac26058 1687 link_with : [libshared],
005a29f2
ZJS
1688 install_rpath : rootlibexecdir,
1689 install : true,
37efbbd8 1690 install_dir : rootlibexecdir)
5c23128d
ZJS
1691endif
1692
349cc4a5 1693if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1694 exe = executable('bootctl',
1695 'src/boot/bootctl.c',
1696 include_directories : includes,
1697 link_with : [libshared],
1698 dependencies : [libblkid],
1699 install_rpath : rootlibexecdir,
1700 install : true)
1701 public_programs += [exe]
005a29f2
ZJS
1702endif
1703
1704exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1705 include_directories : includes,
1706 link_with : [libshared],
1707 dependencies : [threads],
1708 install_rpath : rootlibexecdir,
1709 install : true)
1710public_programs += [exe]
1711
f3794366
FS
1712
1713if get_option('link-systemctl-shared')
1714 systemctl_link_with = [libshared]
1715else
1716 systemctl_link_with = [libsystemd_static,
1717 libshared_static,
1718 libjournal_client,
1719 libbasic_gcrypt]
1720endif
1721
005a29f2
ZJS
1722exe = executable('systemctl', 'src/systemctl/systemctl.c',
1723 include_directories : includes,
f3794366 1724 link_with : systemctl_link_with,
005a29f2
ZJS
1725 dependencies : [threads,
1726 libcap,
1727 libselinux,
1728 libxz,
1729 liblz4],
1730 install_rpath : rootlibexecdir,
1731 install : true,
1732 install_dir : rootbindir)
1733public_programs += [exe]
5c23128d 1734
61d0578b
LP
1735if conf.get('ENABLE_PORTABLED') == 1
1736 executable('systemd-portabled',
1737 systemd_portabled_sources,
1738 include_directories : includes,
1739 link_with : [libshared],
1740 dependencies : [threads],
1741 install_rpath : rootlibexecdir,
1742 install : true,
1743 install_dir : rootlibexecdir)
1744
1745 exe = executable('portablectl', 'src/portable/portablectl.c',
1746 include_directories : includes,
1747 link_with : [libshared],
1748 dependencies : [threads],
1749 install_rpath : rootlibexecdir,
1750 install : true,
1751 install_dir : rootlibexecdir)
1752 public_programs += [exe]
1753endif
1754
ba7f4ae6
ZJS
1755foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1756 meson.add_install_script(meson_make_symlink,
1757 join_paths(rootbindir, 'systemctl'),
1758 join_paths(rootsbindir, alias))
1759endforeach
1760
349cc4a5 1761if conf.get('ENABLE_BACKLIGHT') == 1
37efbbd8
ZJS
1762 executable('systemd-backlight',
1763 'src/backlight/backlight.c',
1764 include_directories : includes,
34ce0a52 1765 link_with : [libshared],
37efbbd8
ZJS
1766 install_rpath : rootlibexecdir,
1767 install : true,
1768 install_dir : rootlibexecdir)
5c23128d
ZJS
1769endif
1770
349cc4a5 1771if conf.get('ENABLE_RFKILL') == 1
37efbbd8
ZJS
1772 executable('systemd-rfkill',
1773 'src/rfkill/rfkill.c',
1774 include_directories : includes,
34ce0a52 1775 link_with : [libshared],
37efbbd8
ZJS
1776 install_rpath : rootlibexecdir,
1777 install : true,
1778 install_dir : rootlibexecdir)
5c23128d
ZJS
1779endif
1780
1781executable('systemd-system-update-generator',
1782 'src/system-update-generator/system-update-generator.c',
1783 include_directories : includes,
1784 link_with : [libshared],
b2fc5836 1785 install_rpath : rootlibexecdir,
5c23128d
ZJS
1786 install : true,
1787 install_dir : systemgeneratordir)
1788
349cc4a5 1789if conf.get('HAVE_LIBCRYPTSETUP') == 1
37efbbd8
ZJS
1790 executable('systemd-cryptsetup',
1791 'src/cryptsetup/cryptsetup.c',
1792 include_directories : includes,
1793 link_with : [libshared],
1794 dependencies : [libcryptsetup],
1795 install_rpath : rootlibexecdir,
1796 install : true,
1797 install_dir : rootlibexecdir)
1798
1799 executable('systemd-cryptsetup-generator',
1800 'src/cryptsetup/cryptsetup-generator.c',
1801 include_directories : includes,
1802 link_with : [libshared],
1803 dependencies : [libcryptsetup],
1804 install_rpath : rootlibexecdir,
1805 install : true,
1806 install_dir : systemgeneratordir)
1807
1808 executable('systemd-veritysetup',
1809 'src/veritysetup/veritysetup.c',
1810 include_directories : includes,
1811 link_with : [libshared],
1812 dependencies : [libcryptsetup],
1813 install_rpath : rootlibexecdir,
1814 install : true,
1815 install_dir : rootlibexecdir)
1816
1817 executable('systemd-veritysetup-generator',
1818 'src/veritysetup/veritysetup-generator.c',
1819 include_directories : includes,
1820 link_with : [libshared],
1821 dependencies : [libcryptsetup],
1822 install_rpath : rootlibexecdir,
1823 install : true,
1824 install_dir : systemgeneratordir)
5c23128d
ZJS
1825endif
1826
349cc4a5 1827if conf.get('HAVE_SYSV_COMPAT') == 1
37efbbd8
ZJS
1828 executable('systemd-sysv-generator',
1829 'src/sysv-generator/sysv-generator.c',
1830 include_directories : includes,
1831 link_with : [libshared],
1832 install_rpath : rootlibexecdir,
1833 install : true,
1834 install_dir : systemgeneratordir)
1835
1836 executable('systemd-rc-local-generator',
1837 'src/rc-local-generator/rc-local-generator.c',
1838 include_directories : includes,
1839 link_with : [libshared],
1840 install_rpath : rootlibexecdir,
1841 install : true,
1842 install_dir : systemgeneratordir)
5c23128d
ZJS
1843endif
1844
349cc4a5 1845if conf.get('ENABLE_HOSTNAMED') == 1
37efbbd8
ZJS
1846 executable('systemd-hostnamed',
1847 'src/hostname/hostnamed.c',
005a29f2 1848 include_directories : includes,
aac26058 1849 link_with : [libshared],
005a29f2 1850 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1851 install : true,
1852 install_dir : rootlibexecdir)
1853
1854 exe = executable('hostnamectl',
1855 'src/hostname/hostnamectl.c',
1856 include_directories : includes,
1857 link_with : [libshared],
1858 install_rpath : rootlibexecdir,
1859 install : true)
1860 public_programs += [exe]
5c23128d
ZJS
1861endif
1862
349cc4a5
ZJS
1863if conf.get('ENABLE_LOCALED') == 1
1864 if conf.get('HAVE_XKBCOMMON') == 1
37efbbd8
ZJS
1865 # logind will load libxkbcommon.so dynamically on its own
1866 deps = [libdl]
1867 else
1868 deps = []
1869 endif
1870
1871 executable('systemd-localed',
1872 systemd_localed_sources,
005a29f2 1873 include_directories : includes,
aac26058 1874 link_with : [libshared],
37efbbd8 1875 dependencies : deps,
005a29f2 1876 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1877 install : true,
1878 install_dir : rootlibexecdir)
1879
1880 exe = executable('localectl',
1881 localectl_sources,
1882 include_directories : includes,
1883 link_with : [libshared],
1884 install_rpath : rootlibexecdir,
1885 install : true)
1886 public_programs += [exe]
5c23128d
ZJS
1887endif
1888
349cc4a5 1889if conf.get('ENABLE_TIMEDATED') == 1
37efbbd8
ZJS
1890 executable('systemd-timedated',
1891 'src/timedate/timedated.c',
005a29f2 1892 include_directories : includes,
aac26058 1893 link_with : [libshared],
37efbbd8
ZJS
1894 install_rpath : rootlibexecdir,
1895 install : true,
1896 install_dir : rootlibexecdir)
6129ec85 1897endif
5c23128d 1898
6129ec85 1899if conf.get('ENABLE_TIMEDATECTL') == 1
37efbbd8
ZJS
1900 exe = executable('timedatectl',
1901 'src/timedate/timedatectl.c',
1902 include_directories : includes,
1903 install_rpath : rootlibexecdir,
1904 link_with : [libshared],
6129ec85 1905 dependencies : [libm],
37efbbd8
ZJS
1906 install : true)
1907 public_programs += [exe]
5c23128d
ZJS
1908endif
1909
349cc4a5 1910if conf.get('ENABLE_TIMESYNCD') == 1
37efbbd8
ZJS
1911 executable('systemd-timesyncd',
1912 systemd_timesyncd_sources,
005a29f2 1913 include_directories : includes,
aac26058 1914 link_with : [libshared],
005a29f2 1915 dependencies : [threads,
37efbbd8 1916 libm],
005a29f2
ZJS
1917 install_rpath : rootlibexecdir,
1918 install : true,
37efbbd8 1919 install_dir : rootlibexecdir)
5c3376ef
PB
1920
1921 executable('systemd-time-wait-sync',
1922 'src/time-wait-sync/time-wait-sync.c',
1923 include_directories : includes,
1924 link_with : [libshared],
1925 install_rpath : rootlibexecdir,
1926 install : true,
1927 install_dir : rootlibexecdir)
5c23128d
ZJS
1928endif
1929
349cc4a5 1930if conf.get('ENABLE_MACHINED') == 1
37efbbd8
ZJS
1931 executable('systemd-machined',
1932 systemd_machined_sources,
1933 include_directories : includes,
1934 link_with : [libmachine_core,
1935 libshared],
1936 install_rpath : rootlibexecdir,
1937 install : true,
1938 install_dir : rootlibexecdir)
1939
1940 exe = executable('machinectl',
1941 'src/machine/machinectl.c',
1942 include_directories : includes,
1943 link_with : [libshared],
1944 dependencies : [threads,
1945 libxz,
1946 liblz4],
1947 install_rpath : rootlibexecdir,
1948 install : true,
1949 install_dir : rootbindir)
1950 public_programs += [exe]
5c23128d
ZJS
1951endif
1952
349cc4a5 1953if conf.get('ENABLE_IMPORTD') == 1
37efbbd8
ZJS
1954 executable('systemd-importd',
1955 systemd_importd_sources,
005a29f2 1956 include_directories : includes,
aac26058 1957 link_with : [libshared],
37efbbd8 1958 dependencies : [threads],
005a29f2
ZJS
1959 install_rpath : rootlibexecdir,
1960 install : true,
1961 install_dir : rootlibexecdir)
37efbbd8
ZJS
1962
1963 systemd_pull = executable('systemd-pull',
1964 systemd_pull_sources,
1965 include_directories : includes,
1966 link_with : [libshared],
1967 dependencies : [libcurl,
1968 libz,
1969 libbzip2,
1970 libxz,
1971 libgcrypt],
1972 install_rpath : rootlibexecdir,
1973 install : true,
1974 install_dir : rootlibexecdir)
1975
1976 systemd_import = executable('systemd-import',
1977 systemd_import_sources,
1978 include_directories : includes,
1979 link_with : [libshared],
1980 dependencies : [libcurl,
1981 libz,
1982 libbzip2,
1983 libxz],
1984 install_rpath : rootlibexecdir,
1985 install : true,
1986 install_dir : rootlibexecdir)
1987
1988 systemd_export = executable('systemd-export',
1989 systemd_export_sources,
1990 include_directories : includes,
1991 link_with : [libshared],
1992 dependencies : [libcurl,
1993 libz,
1994 libbzip2,
1995 libxz],
1996 install_rpath : rootlibexecdir,
1997 install : true,
1998 install_dir : rootlibexecdir)
1999 public_programs += [systemd_pull, systemd_import, systemd_export]
2000endif
2001
349cc4a5 2002if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
37efbbd8
ZJS
2003 exe = executable('systemd-journal-upload',
2004 systemd_journal_upload_sources,
2005 include_directories : includes,
2006 link_with : [libshared],
2007 dependencies : [threads,
2008 libcurl,
2009 libgnutls,
2010 libxz,
2011 liblz4],
2012 install_rpath : rootlibexecdir,
2013 install : true,
2014 install_dir : rootlibexecdir)
2015 public_programs += [exe]
5c23128d
ZJS
2016endif
2017
349cc4a5 2018if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
37efbbd8
ZJS
2019 s_j_remote = executable('systemd-journal-remote',
2020 systemd_journal_remote_sources,
2021 include_directories : includes,
c064d8db
ZJS
2022 link_with : [libshared,
2023 libsystemd_journal_remote],
37efbbd8
ZJS
2024 dependencies : [threads,
2025 libmicrohttpd,
2026 libgnutls,
2027 libxz,
2028 liblz4],
2029 install_rpath : rootlibexecdir,
2030 install : true,
2031 install_dir : rootlibexecdir)
2032
2033 s_j_gatewayd = executable('systemd-journal-gatewayd',
2034 systemd_journal_gatewayd_sources,
2035 include_directories : includes,
2036 link_with : [libshared],
2037 dependencies : [threads,
2038 libmicrohttpd,
2039 libgnutls,
2040 libxz,
2041 liblz4],
2042 install_rpath : rootlibexecdir,
2043 install : true,
2044 install_dir : rootlibexecdir)
2045 public_programs += [s_j_remote, s_j_gatewayd]
5c23128d
ZJS
2046endif
2047
349cc4a5 2048if conf.get('ENABLE_COREDUMP') == 1
37efbbd8
ZJS
2049 executable('systemd-coredump',
2050 systemd_coredump_sources,
005a29f2 2051 include_directories : includes,
aac26058 2052 link_with : [libshared],
005a29f2 2053 dependencies : [threads,
37efbbd8
ZJS
2054 libacl,
2055 libdw,
005a29f2
ZJS
2056 libxz,
2057 liblz4],
2058 install_rpath : rootlibexecdir,
37efbbd8
ZJS
2059 install : true,
2060 install_dir : rootlibexecdir)
2061
2062 exe = executable('coredumpctl',
2063 coredumpctl_sources,
2064 include_directories : includes,
2065 link_with : [libshared],
2066 dependencies : [threads,
2067 libxz,
2068 liblz4],
2069 install_rpath : rootlibexecdir,
2070 install : true)
2071 public_programs += [exe]
5c23128d
ZJS
2072endif
2073
349cc4a5 2074if conf.get('ENABLE_BINFMT') == 1
37efbbd8
ZJS
2075 exe = executable('systemd-binfmt',
2076 'src/binfmt/binfmt.c',
2077 include_directories : includes,
2078 link_with : [libshared],
2079 install_rpath : rootlibexecdir,
2080 install : true,
2081 install_dir : rootlibexecdir)
2082 public_programs += [exe]
2083
2084 meson.add_install_script('sh', '-c',
2085 mkdir_p.format(binfmtdir))
2086 meson.add_install_script('sh', '-c',
2087 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2088endif
2089
349cc4a5 2090if conf.get('ENABLE_VCONSOLE') == 1
37efbbd8
ZJS
2091 executable('systemd-vconsole-setup',
2092 'src/vconsole/vconsole-setup.c',
005a29f2
ZJS
2093 include_directories : includes,
2094 link_with : [libshared],
2095 install_rpath : rootlibexecdir,
2096 install : true,
2097 install_dir : rootlibexecdir)
5c23128d
ZJS
2098endif
2099
349cc4a5 2100if conf.get('ENABLE_RANDOMSEED') == 1
37efbbd8
ZJS
2101 executable('systemd-random-seed',
2102 'src/random-seed/random-seed.c',
2103 include_directories : includes,
2104 link_with : [libshared],
2105 install_rpath : rootlibexecdir,
2106 install : true,
2107 install_dir : rootlibexecdir)
5c23128d
ZJS
2108endif
2109
349cc4a5 2110if conf.get('ENABLE_FIRSTBOOT') == 1
37efbbd8
ZJS
2111 executable('systemd-firstboot',
2112 'src/firstboot/firstboot.c',
2113 include_directories : includes,
2114 link_with : [libshared],
2115 dependencies : [libcrypt],
2116 install_rpath : rootlibexecdir,
2117 install : true,
2118 install_dir : rootbindir)
5c23128d
ZJS
2119endif
2120
2121executable('systemd-remount-fs',
2122 'src/remount-fs/remount-fs.c',
2123 'src/core/mount-setup.c',
2124 'src/core/mount-setup.h',
2125 include_directories : includes,
2126 link_with : [libshared],
b2fc5836 2127 install_rpath : rootlibexecdir,
5c23128d
ZJS
2128 install : true,
2129 install_dir : rootlibexecdir)
2130
2131executable('systemd-machine-id-setup',
2132 'src/machine-id-setup/machine-id-setup-main.c',
2133 'src/core/machine-id-setup.c',
2134 'src/core/machine-id-setup.h',
2135 include_directories : includes,
aac26058 2136 link_with : [libshared],
b2fc5836 2137 install_rpath : rootlibexecdir,
5c23128d
ZJS
2138 install : true,
2139 install_dir : rootbindir)
2140
2141executable('systemd-fsck',
2142 'src/fsck/fsck.c',
2143 include_directories : includes,
aac26058 2144 link_with : [libshared],
421f0012 2145 install_rpath : rootlibexecdir,
5c23128d
ZJS
2146 install : true,
2147 install_dir : rootlibexecdir)
2148
80750adb
ZJS
2149executable('systemd-growfs',
2150 'src/partition/growfs.c',
2151 include_directories : includes,
2152 link_with : [libshared],
c34b75a1 2153 dependencies : [libcryptsetup],
80750adb
ZJS
2154 install_rpath : rootlibexecdir,
2155 install : true,
2156 install_dir : rootlibexecdir)
2157
b7f28ac5
ZJS
2158executable('systemd-makefs',
2159 'src/partition/makefs.c',
2160 include_directories : includes,
2161 link_with : [libshared],
2162 install_rpath : rootlibexecdir,
2163 install : true,
2164 install_dir : rootlibexecdir)
2165
5c23128d
ZJS
2166executable('systemd-sleep',
2167 'src/sleep/sleep.c',
2168 include_directories : includes,
2169 link_with : [libshared],
421f0012 2170 install_rpath : rootlibexecdir,
5c23128d
ZJS
2171 install : true,
2172 install_dir : rootlibexecdir)
2173
005a29f2
ZJS
2174exe = executable('systemd-sysctl',
2175 'src/sysctl/sysctl.c',
2176 include_directories : includes,
2177 link_with : [libshared],
2178 install_rpath : rootlibexecdir,
2179 install : true,
2180 install_dir : rootlibexecdir)
2181public_programs += [exe]
5c23128d
ZJS
2182
2183executable('systemd-ac-power',
2184 'src/ac-power/ac-power.c',
2185 include_directories : includes,
2186 link_with : [libshared],
421f0012 2187 install_rpath : rootlibexecdir,
5c23128d
ZJS
2188 install : true,
2189 install_dir : rootlibexecdir)
2190
005a29f2
ZJS
2191exe = executable('systemd-detect-virt',
2192 'src/detect-virt/detect-virt.c',
2193 include_directories : includes,
2194 link_with : [libshared],
2195 install_rpath : rootlibexecdir,
2196 install : true)
2197public_programs += [exe]
2198
2199exe = executable('systemd-delta',
2200 'src/delta/delta.c',
2201 include_directories : includes,
2202 link_with : [libshared],
2203 install_rpath : rootlibexecdir,
2204 install : true)
2205public_programs += [exe]
2206
2207exe = executable('systemd-escape',
2208 'src/escape/escape.c',
2209 include_directories : includes,
2210 link_with : [libshared],
2211 install_rpath : rootlibexecdir,
2212 install : true,
2213 install_dir : rootbindir)
2214public_programs += [exe]
2215
2216exe = executable('systemd-notify',
2217 'src/notify/notify.c',
2218 include_directories : includes,
2219 link_with : [libshared],
2220 install_rpath : rootlibexecdir,
2221 install : true,
2222 install_dir : rootbindir)
2223public_programs += [exe]
5c23128d
ZJS
2224
2225executable('systemd-volatile-root',
2226 'src/volatile-root/volatile-root.c',
2227 include_directories : includes,
2228 link_with : [libshared],
421f0012 2229 install_rpath : rootlibexecdir,
5c23128d
ZJS
2230 install : true,
2231 install_dir : rootlibexecdir)
2232
2233executable('systemd-cgroups-agent',
2234 'src/cgroups-agent/cgroups-agent.c',
2235 include_directories : includes,
2236 link_with : [libshared],
421f0012 2237 install_rpath : rootlibexecdir,
5c23128d
ZJS
2238 install : true,
2239 install_dir : rootlibexecdir)
2240
005a29f2
ZJS
2241exe = executable('systemd-path',
2242 'src/path/path.c',
2243 include_directories : includes,
aac26058 2244 link_with : [libshared],
005a29f2
ZJS
2245 install_rpath : rootlibexecdir,
2246 install : true)
2247public_programs += [exe]
2248
2249exe = executable('systemd-ask-password',
2250 'src/ask-password/ask-password.c',
2251 include_directories : includes,
aac26058 2252 link_with : [libshared],
005a29f2
ZJS
2253 install_rpath : rootlibexecdir,
2254 install : true,
2255 install_dir : rootbindir)
2256public_programs += [exe]
5c23128d
ZJS
2257
2258executable('systemd-reply-password',
2259 'src/reply-password/reply-password.c',
2260 include_directories : includes,
aac26058 2261 link_with : [libshared],
421f0012 2262 install_rpath : rootlibexecdir,
5c23128d
ZJS
2263 install : true,
2264 install_dir : rootlibexecdir)
2265
005a29f2
ZJS
2266exe = executable('systemd-tty-ask-password-agent',
2267 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2268 include_directories : includes,
aac26058 2269 link_with : [libshared],
005a29f2
ZJS
2270 install_rpath : rootlibexecdir,
2271 install : true,
2272 install_dir : rootbindir)
2273public_programs += [exe]
2274
2275exe = executable('systemd-cgls',
2276 'src/cgls/cgls.c',
2277 include_directories : includes,
aac26058 2278 link_with : [libshared],
005a29f2
ZJS
2279 install_rpath : rootlibexecdir,
2280 install : true)
2281public_programs += [exe]
2282
2283exe = executable('systemd-cgtop',
2284 'src/cgtop/cgtop.c',
2285 include_directories : includes,
aac26058 2286 link_with : [libshared],
005a29f2
ZJS
2287 install_rpath : rootlibexecdir,
2288 install : true)
2289public_programs += [exe]
5c23128d
ZJS
2290
2291executable('systemd-initctl',
2292 'src/initctl/initctl.c',
2293 include_directories : includes,
aac26058 2294 link_with : [libshared],
421f0012 2295 install_rpath : rootlibexecdir,
5c23128d
ZJS
2296 install : true,
2297 install_dir : rootlibexecdir)
2298
005a29f2
ZJS
2299exe = executable('systemd-mount',
2300 'src/mount/mount-tool.c',
2301 include_directories : includes,
34ce0a52 2302 link_with : [libshared],
005a29f2
ZJS
2303 install_rpath : rootlibexecdir,
2304 install : true)
2305public_programs += [exe]
5c23128d 2306
7b76fce1 2307meson.add_install_script(meson_make_symlink,
e17e5ba9 2308 'systemd-mount', join_paths(bindir, 'systemd-umount'))
7b76fce1 2309
005a29f2
ZJS
2310exe = executable('systemd-run',
2311 'src/run/run.c',
2312 include_directories : includes,
aac26058 2313 link_with : [libshared],
005a29f2
ZJS
2314 install_rpath : rootlibexecdir,
2315 install : true)
2316public_programs += [exe]
2317
2318exe = executable('systemd-stdio-bridge',
2319 'src/stdio-bridge/stdio-bridge.c',
2320 include_directories : includes,
aac26058 2321 link_with : [libshared],
005a29f2
ZJS
2322 install_rpath : rootlibexecdir,
2323 install : true)
2324public_programs += [exe]
2325
2326exe = executable('busctl',
2327 'src/busctl/busctl.c',
2328 'src/busctl/busctl-introspect.c',
2329 'src/busctl/busctl-introspect.h',
2330 include_directories : includes,
aac26058 2331 link_with : [libshared],
005a29f2
ZJS
2332 install_rpath : rootlibexecdir,
2333 install : true)
2334public_programs += [exe]
5c23128d 2335
349cc4a5 2336if conf.get('ENABLE_SYSUSERS') == 1
37efbbd8
ZJS
2337 exe = executable('systemd-sysusers',
2338 'src/sysusers/sysusers.c',
2339 include_directories : includes,
2340 link_with : [libshared],
2341 install_rpath : rootlibexecdir,
2342 install : true,
2343 install_dir : rootbindir)
2344 public_programs += [exe]
5c23128d
ZJS
2345endif
2346
349cc4a5 2347if conf.get('ENABLE_TMPFILES') == 1
37efbbd8
ZJS
2348 exe = executable('systemd-tmpfiles',
2349 'src/tmpfiles/tmpfiles.c',
2350 include_directories : includes,
2351 link_with : [libshared],
2352 dependencies : [libacl],
2353 install_rpath : rootlibexecdir,
2354 install : true,
2355 install_dir : rootbindir)
2356 public_programs += [exe]
d9daae55
ZJS
2357
2358 test('test-systemd-tmpfiles',
2359 test_systemd_tmpfiles_py,
2360 args : exe.full_path())
2361 # https://github.com/mesonbuild/meson/issues/2681
5c23128d
ZJS
2362endif
2363
349cc4a5 2364if conf.get('ENABLE_HWDB') == 1
37efbbd8
ZJS
2365 exe = executable('systemd-hwdb',
2366 'src/hwdb/hwdb.c',
2367 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2368 include_directories : includes,
0c06b506 2369 link_with : [libudev_static],
0da6f396 2370 install_rpath : udev_rpath,
37efbbd8
ZJS
2371 install : true,
2372 install_dir : rootbindir)
2373 public_programs += [exe]
2374endif
2375
349cc4a5 2376if conf.get('ENABLE_QUOTACHECK') == 1
37efbbd8
ZJS
2377 executable('systemd-quotacheck',
2378 'src/quotacheck/quotacheck.c',
005a29f2 2379 include_directories : includes,
aac26058 2380 link_with : [libshared],
005a29f2
ZJS
2381 install_rpath : rootlibexecdir,
2382 install : true,
37efbbd8 2383 install_dir : rootlibexecdir)
5c23128d
ZJS
2384endif
2385
005a29f2
ZJS
2386exe = executable('systemd-socket-proxyd',
2387 'src/socket-proxy/socket-proxyd.c',
2388 include_directories : includes,
aac26058 2389 link_with : [libshared],
005a29f2
ZJS
2390 dependencies : [threads],
2391 install_rpath : rootlibexecdir,
2392 install : true,
2393 install_dir : rootlibexecdir)
2394public_programs += [exe]
2395
2396exe = executable('systemd-udevd',
2397 systemd_udevd_sources,
2398 include_directories : includes,
5c72049f 2399 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
005a29f2 2400 link_with : [libudev_core,
005a29f2 2401 libsystemd_network,
0c06b506 2402 libudev_static],
3a30f21f
ZJS
2403 dependencies : [threads,
2404 libkmod,
005a29f2 2405 libidn,
aac26058
ZJS
2406 libacl,
2407 libblkid],
1aec3ed9 2408 install_rpath : udev_rpath,
005a29f2
ZJS
2409 install : true,
2410 install_dir : rootlibexecdir)
2411public_programs += [exe]
2412
2413exe = executable('udevadm',
2414 udevadm_sources,
6671e818 2415 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
005a29f2
ZJS
2416 include_directories : includes,
2417 link_with : [libudev_core,
005a29f2 2418 libsystemd_network,
0c06b506 2419 libudev_static],
3a30f21f
ZJS
2420 dependencies : [threads,
2421 libkmod,
005a29f2 2422 libidn,
aac26058
ZJS
2423 libacl,
2424 libblkid],
1aec3ed9 2425 install_rpath : udev_rpath,
005a29f2
ZJS
2426 install : true,
2427 install_dir : rootbindir)
2428public_programs += [exe]
5c23128d
ZJS
2429
2430executable('systemd-shutdown',
2431 systemd_shutdown_sources,
2432 include_directories : includes,
34ce0a52 2433 link_with : [libshared],
95b862b0 2434 dependencies : [libmount],
421f0012 2435 install_rpath : rootlibexecdir,
5c23128d
ZJS
2436 install : true,
2437 install_dir : rootlibexecdir)
2438
2439executable('systemd-update-done',
2440 'src/update-done/update-done.c',
2441 include_directories : includes,
2442 link_with : [libshared],
421f0012 2443 install_rpath : rootlibexecdir,
5c23128d
ZJS
2444 install : true,
2445 install_dir : rootlibexecdir)
2446
2447executable('systemd-update-utmp',
2448 'src/update-utmp/update-utmp.c',
2449 include_directories : includes,
aac26058 2450 link_with : [libshared],
5c23128d 2451 dependencies : [libaudit],
421f0012 2452 install_rpath : rootlibexecdir,
5c23128d
ZJS
2453 install : true,
2454 install_dir : rootlibexecdir)
2455
349cc4a5 2456if conf.get('HAVE_KMOD') == 1
37efbbd8
ZJS
2457 executable('systemd-modules-load',
2458 'src/modules-load/modules-load.c',
2459 include_directories : includes,
2460 link_with : [libshared],
2461 dependencies : [libkmod],
2462 install_rpath : rootlibexecdir,
2463 install : true,
2464 install_dir : rootlibexecdir)
94e75a54 2465
37efbbd8
ZJS
2466 meson.add_install_script('sh', '-c',
2467 mkdir_p.format(modulesloaddir))
2468 meson.add_install_script('sh', '-c',
2469 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
5c23128d
ZJS
2470endif
2471
005a29f2
ZJS
2472exe = executable('systemd-nspawn',
2473 systemd_nspawn_sources,
2474 'src/core/mount-setup.c', # FIXME: use a variable?
2475 'src/core/mount-setup.h',
2476 'src/core/loopback-setup.c',
2477 'src/core/loopback-setup.h',
97d90615
ZJS
2478 include_directories : includes,
2479 link_with : [libnspawn_core,
2480 libshared],
2481 dependencies : [libblkid],
005a29f2
ZJS
2482 install_rpath : rootlibexecdir,
2483 install : true)
2484public_programs += [exe]
5c23128d 2485
349cc4a5 2486if conf.get('ENABLE_NETWORKD') == 1
37efbbd8
ZJS
2487 executable('systemd-networkd',
2488 systemd_networkd_sources,
2489 include_directories : includes,
2490 link_with : [libnetworkd_core,
37efbbd8 2491 libsystemd_network,
0c06b506 2492 libudev_static,
37efbbd8 2493 libshared],
4b57a272 2494 dependencies : [threads],
37efbbd8
ZJS
2495 install_rpath : rootlibexecdir,
2496 install : true,
2497 install_dir : rootlibexecdir)
2498
2499 executable('systemd-networkd-wait-online',
2500 systemd_networkd_wait_online_sources,
2501 include_directories : includes,
2502 link_with : [libnetworkd_core,
2503 libshared],
2504 install_rpath : rootlibexecdir,
2505 install : true,
2506 install_dir : rootlibexecdir)
5c23128d 2507
dcfe072a
FS
2508 exe = executable('networkctl',
2509 networkctl_sources,
2510 include_directories : includes,
2511 link_with : [libsystemd_network,
aac26058 2512 libshared],
dcfe072a
FS
2513 install_rpath : rootlibexecdir,
2514 install : true,
2515 install_dir : rootbindir)
2516 public_programs += [exe]
2517endif
e821f6a9
ZJS
2518
2519executable('systemd-sulogin-shell',
2520 ['src/sulogin-shell/sulogin-shell.c'],
2521 include_directories : includes,
2522 link_with : [libshared],
2523 install_rpath : rootlibexecdir,
2524 install : true,
2525 install_dir : rootlibexecdir)
2526
69e96427
ZJS
2527############################################################
2528
2529foreach tuple : tests
37efbbd8
ZJS
2530 sources = tuple[0]
2531 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2532 dependencies = tuple[2]
2533 condition = tuple.length() >= 4 ? tuple[3] : ''
2534 type = tuple.length() >= 5 ? tuple[4] : ''
2535 defs = tuple.length() >= 6 ? tuple[5] : []
2536 incs = tuple.length() >= 7 ? tuple[6] : includes
2537 timeout = 30
2538
2539 name = sources[0].split('/')[-1].split('.')[0]
2540 if type.startswith('timeout=')
2541 timeout = type.split('=')[1].to_int()
2542 type = ''
2543 endif
08318a2c
AD
2544 if want_tests == 'false'
2545 message('Not compiling @0@ because tests is set to false'.format(name))
2546 elif condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
2547 exe = executable(
2548 name,
2549 sources,
2550 include_directories : incs,
2551 link_with : link_with,
2552 dependencies : dependencies,
2553 c_args : defs,
2554 install_rpath : rootlibexecdir,
7cdd9783
MB
2555 install : install_tests,
2556 install_dir : join_paths(testsdir, type))
37efbbd8
ZJS
2557
2558 if type == 'manual'
2559 message('@0@ is a manual test'.format(name))
2560 elif type == 'unsafe' and want_tests != 'unsafe'
2561 message('@0@ is an unsafe test'.format(name))
2562 else
2563 test(name, exe,
2564 env : test_env,
2565 timeout : timeout)
2566 endif
2567 else
2568 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2569 endif
69e96427
ZJS
2570endforeach
2571
0632b4cd 2572exe = executable(
37efbbd8
ZJS
2573 'test-libsystemd-sym',
2574 test_libsystemd_sym_c,
2575 include_directories : includes,
2576 link_with : [libsystemd],
2577 install : install_tests,
2578 install_dir : testsdir)
0632b4cd 2579test('test-libsystemd-sym', exe)
37ab1a25 2580
0632b4cd
ZJS
2581exe = executable(
2582 'test-libsystemd-static-sym',
2583 test_libsystemd_sym_c,
2584 include_directories : includes,
0632b4cd
ZJS
2585 link_with : [install_libsystemd_static],
2586 dependencies : [threads], # threads is already included in dependencies on the library,
2587 # but does not seem to get propagated. Add here as a work-around.
20f3d32d
DC
2588 build_by_default : static_libsystemd_pic,
2589 install : install_tests and static_libsystemd_pic,
0632b4cd 2590 install_dir : testsdir)
20f3d32d 2591if static_libsystemd_pic
0632b4cd
ZJS
2592 test('test-libsystemd-static-sym', exe)
2593endif
37ab1a25 2594
0632b4cd 2595exe = executable(
37efbbd8
ZJS
2596 'test-libudev-sym',
2597 test_libudev_sym_c,
2598 include_directories : includes,
2599 c_args : ['-Wno-deprecated-declarations'],
2600 link_with : [libudev],
2601 install : install_tests,
2602 install_dir : testsdir)
0632b4cd
ZJS
2603test('test-libudev-sym', exe)
2604
2605exe = executable(
2606 'test-libudev-static-sym',
2607 test_libudev_sym_c,
2608 include_directories : includes,
20f3d32d 2609 c_args : ['-Wno-deprecated-declarations'],
0632b4cd 2610 link_with : [install_libudev_static],
20f3d32d
DC
2611 build_by_default : static_libudev_pic,
2612 install : install_tests and static_libudev_pic,
0632b4cd 2613 install_dir : testsdir)
20f3d32d 2614if static_libudev_pic
0632b4cd
ZJS
2615 test('test-libudev-static-sym', exe)
2616endif
e0bec52f 2617
69e96427 2618############################################################
5c23128d 2619
7db7d5b7
JR
2620fuzzer_exes = []
2621
2622foreach tuple : fuzzers
2623 sources = tuple[0]
2624 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2625 dependencies = tuple[2]
2626 defs = tuple.length() >= 4 ? tuple[3] : []
2627 incs = tuple.length() >= 5 ? tuple[4] : includes
2628
31e57a35 2629 if fuzzer_build
7db7d5b7
JR
2630 dependencies += fuzzing_engine
2631 else
2632 sources += 'src/fuzz/fuzz-main.c'
2633 endif
2634
2635 name = sources[0].split('/')[-1].split('.')[0]
2636
2637 fuzzer_exes += executable(
2638 name,
2639 sources,
2640 include_directories : [incs, include_directories('src/fuzz')],
2641 link_with : link_with,
2642 dependencies : dependencies,
2643 c_args : defs,
2644 install : false)
2645endforeach
2646
2647run_target('fuzzers',
2648 depends : fuzzer_exes,
2649 command : ['true'])
2650
2651############################################################
2652
5c23128d
ZJS
2653make_directive_index_py = find_program('tools/make-directive-index.py')
2654make_man_index_py = find_program('tools/make-man-index.py')
b184e8fe 2655xml_helper_py = find_program('tools/xml_helper.py')
abba22c5 2656hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
5c23128d
ZJS
2657
2658subdir('units')
2659subdir('sysctl.d')
2660subdir('sysusers.d')
2661subdir('tmpfiles.d')
e783f957 2662subdir('presets')
5c23128d
ZJS
2663subdir('hwdb')
2664subdir('network')
2665subdir('man')
2666subdir('shell-completion/bash')
2667subdir('shell-completion/zsh')
2d684e65
LP
2668subdir('doc/sysvinit')
2669subdir('doc/var-log')
5c23128d
ZJS
2670
2671# FIXME: figure out if the warning is true:
2672# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2673install_subdir('factory/etc',
2674 install_dir : factorydir)
2675
2676
2677install_data('xorg/50-systemd-user.sh',
2678 install_dir : xinitrcdir)
582faeb4
DJL
2679install_data('modprobe.d/systemd.conf',
2680 install_dir : modprobedir)
f09eb768 2681install_data('LICENSE.GPL2',
5c23128d 2682 'LICENSE.LGPL2.1',
f09eb768
LP
2683 'NEWS',
2684 'README',
2685 'doc/CODING_STYLE',
2686 'doc/DISTRO_PORTING',
2687 'doc/ENVIRONMENT.md',
2688 'doc/HACKING',
2689 'doc/TRANSIENT-SETTINGS.md',
2690 'doc/TRANSLATORS',
2691 'doc/UIDS-GIDS.md',
5c23128d
ZJS
2692 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2693 install_dir : docdir)
d68b342b 2694
94e75a54
ZJS
2695meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2696meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2697
d68b342b
ZJS
2698############################################################
2699
005a29f2
ZJS
2700meson_check_help = find_program('tools/meson-check-help.sh')
2701
2702foreach exec : public_programs
37efbbd8
ZJS
2703 name = exec.full_path().split('/')[-1]
2704 test('check-help-' + name,
2705 meson_check_help,
2706 args : [exec.full_path()])
005a29f2
ZJS
2707endforeach
2708
2709############################################################
2710
52d4d1d3
ZJS
2711# Enable tests for all supported sanitizers
2712foreach tuple : sanitizers
2713 sanitizer = tuple[0]
2714 build = tuple[1]
b68dfb9e 2715
52d4d1d3
ZJS
2716 have = run_command(check_compilation_sh,
2717 cc.cmd_array(), '-x', 'c',
2718 '-fsanitize=@0@'.format(sanitizer),
2719 '-include', link_test_c).returncode() == 0
2720 message('@0@ sanitizer supported: @1@'.format(sanitizer, have ? 'yes' : 'no'))
b68dfb9e 2721
52d4d1d3
ZJS
2722 if have
2723 prev = ''
2724 foreach p : fuzz_regression_tests
2725 b = p.split('/')[-2]
2726 c = p.split('/')[-1]
2727
2728 name = '@0@:@1@'.format(b, sanitizer)
2729
2730 if name != prev
2731 if want_tests == 'false'
2732 message('Not compiling @0@ because tests is set to false'.format(name))
2733 elif slow_tests
2734 exe = custom_target(
2735 name,
2736 output : name,
2737 depends : build,
2738 command : [env, 'ln', '-fs',
2739 join_paths(build.full_path(), b),
2740 '@OUTPUT@'],
2741 build_by_default : true)
2742 else
2743 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2744 endif
2745 endif
2746 prev = name
2747
2748 if want_tests != 'false' and slow_tests
2749 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2750 env,
2751 args : [exe.full_path(),
2752 join_paths(meson.source_root(),
2753 'test/fuzz-regressions',
2754 p)])
2755 endif
2756 endforeach
b68dfb9e
ZJS
2757 endif
2758endforeach
2759
52d4d1d3 2760
b68dfb9e
ZJS
2761############################################################
2762
0700e8ba 2763if git.found()
37efbbd8
ZJS
2764 all_files = run_command(
2765 git,
450b60ba 2766 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
37efbbd8
ZJS
2767 'ls-files',
2768 ':/*.[ch]'])
2769 all_files = files(all_files.stdout().split())
d68b342b 2770
e85a690b 2771 custom_target(
0700e8ba 2772 'tags',
e85a690b 2773 output : 'tags',
25a82102 2774 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
2f09974f 2775 run_target(
0700e8ba 2776 'ctags',
25a82102 2777 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
d68b342b 2778endif
177929c2
ZJS
2779
2780if git.found()
37efbbd8 2781 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
a923e085 2782 run_target(
37efbbd8 2783 'git-contrib',
37efbbd8 2784 command : [meson_git_contrib_sh])
177929c2 2785endif
dd6ab3df
ZJS
2786
2787if git.found()
2788 git_head = run_command(
2789 git,
450b60ba 2790 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
dd6ab3df
ZJS
2791 'rev-parse', 'HEAD']).stdout().strip()
2792 git_head_short = run_command(
2793 git,
450b60ba 2794 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
dd6ab3df
ZJS
2795 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2796
2797 run_target(
2798 'git-snapshot',
2799 command : ['git', 'archive',
450b60ba 2800 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
dd6ab3df
ZJS
2801 git_head_short),
2802 '--prefix', 'systemd-@0@/'.format(git_head),
2803 'HEAD'])
2804endif
829257d1
ZJS
2805
2806############################################################
2807
51b13863
LP
2808meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2809run_target(
2810 'check-api-docs',
2811 depends : [man, libsystemd, libudev],
2812 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2813
2814############################################################
2815
829257d1
ZJS
2816status = [
2817 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2818
2675413e 2819 'split /usr: @0@'.format(split_usr),
157baa87 2820 'split bin-sbin: @0@'.format(split_bin),
359b496f
YW
2821 'prefix directory: @0@'.format(prefixdir),
2822 'rootprefix directory: @0@'.format(rootprefixdir),
2823 'sysconf directory: @0@'.format(sysconfdir),
2824 'include directory: @0@'.format(includedir),
2825 'lib directory: @0@'.format(libdir),
2826 'rootlib directory: @0@'.format(rootlibdir),
829257d1
ZJS
2827 'SysV init scripts: @0@'.format(sysvinit_path),
2828 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
359b496f
YW
2829 'PAM modules directory: @0@'.format(pamlibdir),
2830 'PAM configuration directory: @0@'.format(pamconfdir),
2831 'RPM macros directory: @0@'.format(rpmmacrosdir),
2832 'modprobe.d directory: @0@'.format(modprobedir),
2833 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2834 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2835 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2836 'bash completions directory: @0@'.format(bashcompletiondir),
2837 'zsh completions directory: @0@'.format(zshcompletiondir),
829257d1
ZJS
2838 'extra start script: @0@'.format(get_option('rc-local')),
2839 'extra stop script: @0@'.format(get_option('halt-local')),
2840 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
2841 get_option('debug-tty')),
2842 'TTY GID: @0@'.format(tty_gid),
84786b8e 2843 'users GID: @0@'.format(users_gid),
829257d1
ZJS
2844 'maximum system UID: @0@'.format(system_uid_max),
2845 'maximum system GID: @0@'.format(system_gid_max),
87d5e4f2
LP
2846 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
2847 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
2848 'minimum container UID base: @0@'.format(container_uid_base_min),
2849 'maximum container UID base: @0@'.format(container_uid_base_max),
829257d1 2850 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
4e15a734 2851 'render group access mode: @0@'.format(get_option('group-render-mode')),
359b496f 2852 'certificate root directory: @0@'.format(get_option('certificate-root')),
829257d1 2853 'support URL: @0@'.format(support_url),
afde4574
LP
2854 'nobody user name: @0@'.format(nobody_user),
2855 'nobody group name: @0@'.format(nobody_group),
829257d1 2856 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
5248e7e1 2857 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
829257d1
ZJS
2858
2859 'default DNSSEC mode: @0@'.format(default_dnssec),
2860 'default cgroup hierarchy: @0@'.format(default_hierarchy),
2861 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
2862
2863alt_dns_servers = '\n '.join(dns_servers.split(' '))
2864alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
2865status += [
2866 'default DNS servers: @0@'.format(alt_dns_servers),
2867 'default NTP servers: @0@'.format(alt_ntp_servers)]
2868
2869alt_time_epoch = run_command('date', '-Is', '-u', '-d',
2870 '@@0@'.format(time_epoch)).stdout().strip()
2871status += [
2872 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
2873
2874# TODO:
2875# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
2876# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
2877# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
2878
349cc4a5 2879if conf.get('ENABLE_EFI') == 1
829257d1
ZJS
2880 status += [
2881 'efi arch: @0@'.format(efi_arch)]
2882
2883 if have_gnu_efi
2884 status += [
2885 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
2886 'EFI CC @0@'.format(efi_cc),
359b496f
YW
2887 'EFI lib directory: @0@'.format(efi_libdir),
2888 'EFI lds directory: @0@'.format(efi_ldsdir),
2889 'EFI include directory: @0@'.format(efi_incdir)]
829257d1
ZJS
2890 endif
2891endif
2892
2893found = []
2894missing = []
2895
2896foreach tuple : [
2897 ['libcryptsetup'],
2898 ['PAM'],
2899 ['AUDIT'],
2900 ['IMA'],
2901 ['AppArmor'],
2902 ['SELinux'],
2903 ['SECCOMP'],
2904 ['SMACK'],
2905 ['zlib'],
2906 ['xz'],
2907 ['lz4'],
2908 ['bzip2'],
2909 ['ACL'],
2910 ['gcrypt'],
2911 ['qrencode'],
2912 ['microhttpd'],
2913 ['gnutls'],
2914 ['libcurl'],
d1bf5675 2915 ['idn'],
87057e24 2916 ['libidn2'],
829257d1 2917 ['libidn'],
e7e11bbf 2918 ['nss-systemd'],
829257d1
ZJS
2919 ['libiptc'],
2920 ['elfutils'],
2921 ['binfmt'],
2922 ['vconsole'],
2923 ['quotacheck'],
2924 ['tmpfiles'],
2925 ['environment.d'],
2926 ['sysusers'],
2927 ['firstboot'],
2928 ['randomseed'],
2929 ['backlight'],
2930 ['rfkill'],
2931 ['logind'],
2932 ['machined'],
61d0578b 2933 ['portabled'],
829257d1
ZJS
2934 ['importd'],
2935 ['hostnamed'],
2936 ['timedated'],
2937 ['timesyncd'],
2938 ['localed'],
2939 ['networkd'],
a7456af5 2940 ['resolve'],
829257d1
ZJS
2941 ['coredump'],
2942 ['polkit'],
2943 ['legacy pkla', install_polkit_pkla],
2944 ['efi'],
2945 ['gnu-efi', have_gnu_efi],
2946 ['kmod'],
2947 ['xkbcommon'],
c4c978a0 2948 ['pcre2'],
829257d1
ZJS
2949 ['blkid'],
2950 ['dbus'],
2951 ['glib'],
08cf5b8d 2952 ['nss-myhostname', conf.get('ENABLE_MYHOSTNAME') == 1],
829257d1
ZJS
2953 ['hwdb'],
2954 ['tpm'],
2955 ['man pages', want_man],
2956 ['html pages', want_html],
2957 ['man page indices', want_man and have_lxml],
829257d1
ZJS
2958 ['SysV compat'],
2959 ['utmp'],
2960 ['ldconfig'],
2961 ['hibernate'],
2962 ['adm group', get_option('adm-group')],
2963 ['wheel group', get_option('wheel-group')],
b14e1b43 2964 ['gshadow'],
829257d1
ZJS
2965 ['debug hashmap'],
2966 ['debug mmap cache'],
d18cb393 2967 ['valgrind', conf.get('VALGRIND') == 1],
829257d1
ZJS
2968]
2969
af4d7860
ZJS
2970 if tuple.length() >= 2
2971 cond = tuple[1]
2972 else
829257d1
ZJS
2973 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
2974 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 2975 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
2976 endif
2977 if cond
2978 found += [tuple[0]]
2979 else
2980 missing += [tuple[0]]
2981 endif
2982endforeach
2983
2984status += [
9d39c1bf 2985 '',
829257d1 2986 'enabled features: @0@'.format(', '.join(found)),
9d39c1bf
ZJS
2987 '',
2988 'disabled features: @0@'.format(', '.join(missing)),
2989 '']
829257d1 2990message('\n '.join(status))
9a8e64b0
ZJS
2991
2992if rootprefixdir != rootprefix_default
8ea9fad7
YW
2993 warning('\n' +
2994 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
2995 'systemd used fixed names for unit file directories and other paths, so anything\n' +
2996 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
9a8e64b0 2997endif