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