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