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