]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: add option for debugging udev
[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
8a716f26
YW
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'],
456 ['IFLA_IPVLAN_FLAGS', 'linux/if_link.h'],
457 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
458 ['IFLA_BOND_AD_ACTOR_SYSTEM', 'linux/if_link.h'],
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'],
462 ['IFLA_GENEVE_LABEL', 'linux/if_link.h'],
5c23128d 463 # if_tunnel.h is buggy and cannot be included on its own
8a716f26
YW
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'],
471 ['IPVLAN_F_PRIVATE', 'linux/if_link.h'],
472 ['NDA_IFINDEX', 'linux/neighbour.h'],
473 ['IFA_FLAGS', 'linux/if_addr.h'],
474 ['FRA_UID_RANGE', 'linux/fib_rules.h'],
475 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
476 ['VXCAN_INFO_PEER', 'linux/can/vxcan.h'],
477 ['FOU_ATTR_REMCSUM_NOPARTIAL', 'linux/fou.h'],
478 ['FOU_CMD_GET', 'linux/fou.h'],
479 ['ETHTOOL_LINK_MODE_10baseT_Half_BIT', 'linux/ethtool.h'],
480 ['ETHTOOL_LINK_MODE_25000baseCR_Full_BIT', 'linux/ethtool.h'],
481 ['ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT', 'linux/ethtool.h'],
482 ['ETHTOOL_LINK_MODE_1000baseX_Full_BIT', 'linux/ethtool.h'],
483 ['ETHTOOL_LINK_MODE_2500baseT_Full_BIT', 'linux/ethtool.h'],
484 ['ETHTOOL_LINK_MODE_FEC_NONE_BIT', 'linux/ethtool.h'],
5c23128d 485 ]
37efbbd8
ZJS
486 prefix = decl.length() > 2 ? decl[2] : ''
487 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
4b9545f1 488 conf.set10('HAVE_' + decl[0], have)
5c23128d
ZJS
489endforeach
490
5c23128d 491foreach ident : ['secure_getenv', '__secure_getenv']
349cc4a5 492 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
5c23128d
ZJS
493endforeach
494
495foreach ident : [
85db59b7 496 ['memfd_create', '''#include <sys/mman.h>'''],
7b961e40
LP
497 ['gettid', '''#include <sys/types.h>
498 #include <unistd.h>'''],
3c042add
LP
499 ['pivot_root', '''#include <stdlib.h>
500 #include <unistd.h>'''], # no known header declares pivot_root
85db59b7 501 ['name_to_handle_at', '''#include <sys/types.h>
37efbbd8
ZJS
502 #include <sys/stat.h>
503 #include <fcntl.h>'''],
85db59b7 504 ['setns', '''#include <sched.h>'''],
2acfd0ff
LP
505 ['renameat2', '''#include <stdio.h>
506 #include <fcntl.h>'''],
37efbbd8
ZJS
507 ['kcmp', '''#include <linux/kcmp.h>'''],
508 ['keyctl', '''#include <sys/types.h>
509 #include <keyutils.h>'''],
85db59b7 510 ['copy_file_range', '''#include <sys/syscall.h>
37efbbd8 511 #include <unistd.h>'''],
71e5200f
DM
512 ['bpf', '''#include <sys/syscall.h>
513 #include <unistd.h>'''],
4c2e1b39
LP
514 ['statx', '''#include <sys/types.h>
515 #include <sys/stat.h>
516 #include <unistd.h>'''],
aa484f35
ZJS
517 ['explicit_bzero' , '''#include <string.h>'''],
518 ['reallocarray', '''#include <malloc.h>'''],
37efbbd8
ZJS
519]
520
85db59b7 521 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
4b9545f1 522 conf.set10('HAVE_' + ident[0].to_upper(), have)
5c23128d
ZJS
523endforeach
524
85db59b7 525if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
349cc4a5 526 conf.set10('USE_SYS_RANDOM_H', true)
4b9545f1 527 conf.set10('HAVE_GETRANDOM', true)
4984c8be
ZJS
528else
529 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
349cc4a5 530 conf.set10('USE_SYS_RANDOM_H', false)
4b9545f1 531 conf.set10('HAVE_GETRANDOM', have)
4984c8be
ZJS
532endif
533
5c23128d
ZJS
534#####################################################################
535
536sed = find_program('sed')
5c23128d 537awk = find_program('awk')
d730e2d1 538m4 = find_program('m4')
5c23128d 539stat = find_program('stat')
d68b342b 540git = find_program('git', required : false)
b68dfb9e 541env = find_program('env')
b1ffacb6 542perl = find_program('perl', required : false)
5c23128d 543
7b76fce1 544meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
94e75a54 545mkdir_p = 'mkdir -p $DESTDIR/@0@'
d83f4f50
ZJS
546test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
547splash_bmp = files('test/splash.bmp')
94e75a54 548
5c23128d
ZJS
549# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
550# /usr/sbin, /sbin, and fall back to the default from middle column.
2fa645f1 551progs = [['quotaon', '/usr/sbin/quotaon' ],
5c23128d 552 ['quotacheck', '/usr/sbin/quotacheck' ],
5c23128d
ZJS
553 ['kmod', '/usr/bin/kmod' ],
554 ['kexec', '/usr/sbin/kexec' ],
555 ['sulogin', '/usr/sbin/sulogin' ],
556 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
557 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
558 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
559 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
560 ]
561foreach prog : progs
37efbbd8
ZJS
562 path = get_option(prog[0] + '-path')
563 if path != ''
564 message('Using @1@ for @0@'.format(prog[0], path))
565 else
566 exe = find_program(prog[0],
567 '/usr/sbin/' + prog[0],
568 '/sbin/' + prog[0],
569 required: false)
570 path = exe.found() ? exe.path() : prog[1]
571 endif
572 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
573 conf.set_quoted(name, path)
574 substs.set(name, path)
5c23128d
ZJS
575endforeach
576
2fa645f1
MG
577conf.set_quoted('TELINIT', get_option('telinit-path'))
578
1276a9f6 579if run_command('ln', '--relative', '--help').returncode() != 0
cd001016 580 error('ln does not support --relative (added in coreutils 8.16)')
1276a9f6 581endif
5c23128d
ZJS
582
583############################################################
584
585gperf = find_program('gperf')
586
587gperf_test_format = '''
588#include <string.h>
589const char * in_word_set(const char *, @0@);
590@1@
591'''
592gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
593gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
594gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
595if cc.compiles(gperf_test)
37efbbd8 596 gperf_len_type = 'size_t'
5c23128d 597else
37efbbd8
ZJS
598 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
599 if cc.compiles(gperf_test)
600 gperf_len_type = 'unsigned'
601 else
602 error('unable to determine gperf len type')
603 endif
5c23128d
ZJS
604endif
605message('gperf len type is @0@'.format(gperf_len_type))
37efbbd8
ZJS
606conf.set('GPERF_LEN_TYPE', gperf_len_type,
607 description : 'The type of gperf "len" parameter')
5c23128d
ZJS
608
609############################################################
610
611if not cc.has_header('sys/capability.h')
37efbbd8 612 error('POSIX caps headers not found')
5c23128d 613endif
9f555bba
BE
614foreach header : ['crypt.h',
615 'linux/btrfs.h',
80df8f25 616 'linux/fou.h',
5c23128d
ZJS
617 'linux/memfd.h',
618 'linux/vm_sockets.h',
af8786b1 619 'sys/auxv.h',
5c23128d
ZJS
620 'valgrind/memcheck.h',
621 'valgrind/valgrind.h',
622 ]
2c201c21 623
349cc4a5
ZJS
624 conf.set10('HAVE_' + header.underscorify().to_upper(),
625 cc.has_header(header))
5c23128d
ZJS
626endforeach
627
628############################################################
629
630conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
5248e7e1
ZJS
631conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
632gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
5c23128d
ZJS
633
634default_hierarchy = get_option('default-hierarchy')
635conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
636 description : 'default cgroup hierarchy as string')
637if default_hierarchy == 'legacy'
37efbbd8 638 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
5c23128d 639elif default_hierarchy == 'hybrid'
37efbbd8 640 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
5c23128d 641else
37efbbd8 642 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
5c23128d
ZJS
643endif
644
645time_epoch = get_option('time-epoch')
ac09340e 646if time_epoch == -1
37efbbd8 647 NEWS = files('NEWS')
ac09340e 648 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout().to_int()
5c23128d 649endif
5c23128d
ZJS
650conf.set('TIME_EPOCH', time_epoch)
651
652system_uid_max = get_option('system-uid-max')
ac09340e 653if system_uid_max == -1
37efbbd8
ZJS
654 system_uid_max = run_command(
655 awk,
2f62cf35
CMOF
656 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
657 '/etc/login.defs').stdout().strip()
658 if system_uid_max == ''
ac09340e
YW
659 system_uid_max = 999
660 else
661 system_uid_max = system_uid_max.to_int()
2f62cf35 662 endif
5c23128d 663endif
5c23128d
ZJS
664conf.set('SYSTEM_UID_MAX', system_uid_max)
665substs.set('systemuidmax', system_uid_max)
5c23128d 666
5c23128d 667system_gid_max = get_option('system-gid-max')
ac09340e 668if system_gid_max == -1
37efbbd8
ZJS
669 system_gid_max = run_command(
670 awk,
2f62cf35
CMOF
671 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
672 '/etc/login.defs').stdout().strip()
673 if system_gid_max == ''
ac09340e
YW
674 system_gid_max = 999
675 else
676 system_gid_max = system_gid_max.to_int()
2f62cf35 677 endif
5c23128d 678endif
5c23128d
ZJS
679conf.set('SYSTEM_GID_MAX', system_gid_max)
680substs.set('systemgidmax', system_gid_max)
5c23128d 681
ac09340e
YW
682dynamic_uid_min = get_option('dynamic-uid-min')
683dynamic_uid_max = get_option('dynamic-uid-max')
87d5e4f2
LP
684conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
685conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
686substs.set('dynamicuidmin', dynamic_uid_min)
687substs.set('dynamicuidmax', dynamic_uid_max)
688
ac09340e
YW
689container_uid_base_min = get_option('container-uid-base-min')
690container_uid_base_max = get_option('container-uid-base-max')
87d5e4f2
LP
691conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
692conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
693substs.set('containeruidbasemin', container_uid_base_min)
694substs.set('containeruidbasemax', container_uid_base_max)
695
afde4574
LP
696nobody_user = get_option('nobody-user')
697nobody_group = get_option('nobody-group')
698
2484bff3
CQ
699if not meson.is_cross_build()
700 getent_result = run_command('getent', 'passwd', '65534')
701 if getent_result.returncode() == 0
702 name = getent_result.stdout().split(':')[0]
703 if name != nobody_user
704 warning('\n' +
705 '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) +
706 'Your build will result in an user table setup that is incompatible with the local system.')
707 endif
afde4574 708 endif
2484bff3
CQ
709 id_result = run_command('id', '-u', nobody_user)
710 if id_result.returncode() == 0
711 id = id_result.stdout().to_int()
712 if id != 65534
713 warning('\n' +
714 '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) +
715 'Your build will result in an user table setup that is incompatible with the local system.')
716 endif
afde4574 717 endif
afde4574 718
2484bff3
CQ
719 getent_result = run_command('getent', 'group', '65534')
720 if getent_result.returncode() == 0
721 name = getent_result.stdout().split(':')[0]
722 if name != nobody_group
723 warning('\n' +
724 '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) +
725 'Your build will result in an group table setup that is incompatible with the local system.')
726 endif
afde4574 727 endif
2484bff3
CQ
728 id_result = run_command('id', '-g', nobody_group)
729 if id_result.returncode() == 0
730 id = id_result.stdout().to_int()
731 if id != 65534
732 warning('\n' +
733 '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) +
734 'Your build will result in an group table setup that is incompatible with the local system.')
735 endif
afde4574
LP
736 endif
737endif
8374cc62 738if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
8ea9fad7
YW
739 warning('\n' +
740 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
741 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
8374cc62 742endif
afde4574
LP
743
744conf.set_quoted('NOBODY_USER_NAME', nobody_user)
745conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
60712021
YW
746substs.set('NOBODY_USER_NAME', nobody_user)
747substs.set('NOBODY_GROUP_NAME', nobody_group)
87d5e4f2 748
5c23128d
ZJS
749tty_gid = get_option('tty-gid')
750conf.set('TTY_GID', tty_gid)
2a4c156d 751substs.set('TTY_GID', tty_gid)
5c23128d 752
84786b8e 753# Ensure provided GID argument is numeric, otherwise fallback to default assignment
ac09340e
YW
754users_gid = get_option('users-gid')
755substs.set('USERS_GID', users_gid < 0 ? '-' : users_gid)
84786b8e 756
348b4437
YW
757conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
758conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
5c23128d 759
ace5e311
MB
760dev_kvm_mode = get_option('dev-kvm-mode')
761substs.set('DEV_KVM_MODE', dev_kvm_mode)
762conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
4e15a734 763substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
5c23128d 764
2a4c156d
ZJS
765kill_user_processes = get_option('default-kill-user-processes')
766conf.set10('KILL_USER_PROCESSES', kill_user_processes)
c7f7e859 767conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
2a4c156d 768substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
5c23128d 769
829257d1
ZJS
770dns_servers = get_option('dns-servers')
771conf.set_quoted('DNS_SERVERS', dns_servers)
772substs.set('DNS_SERVERS', dns_servers)
5c23128d 773
829257d1
ZJS
774ntp_servers = get_option('ntp-servers')
775conf.set_quoted('NTP_SERVERS', ntp_servers)
776substs.set('NTP_SERVERS', ntp_servers)
5c23128d
ZJS
777
778conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
779
3131bfe3
ZJS
780substs.set('SUSHELL', get_option('debug-shell'))
781substs.set('DEBUGTTY', get_option('debug-tty'))
782
349cc4a5
ZJS
783enable_debug_hashmap = false
784enable_debug_mmap_cache = false
20e97dd3 785enable_debug_udev = false
8f6b442a 786foreach name : get_option('debug-extra')
ad7aa760
YW
787 if name == 'hashmap'
788 enable_debug_hashmap = true
789 elif name == 'mmap-cache'
790 enable_debug_mmap_cache = true
20e97dd3
YW
791 elif name == 'udev'
792 enable_debug_udev = true
ad7aa760
YW
793 else
794 message('unknown debug option "@0@", ignoring'.format(name))
795 endif
796endforeach
349cc4a5
ZJS
797conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
798conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
20e97dd3 799conf.set10('ENABLE_DEBUG_UDEV', enable_debug_udev)
671677da 800
d18cb393 801conf.set10('VALGRIND', get_option('valgrind'))
fd5dec9a 802conf.set10('LOG_TRACE', get_option('log-trace'))
d18cb393 803
5c23128d
ZJS
804#####################################################################
805
806threads = dependency('threads')
807librt = cc.find_library('rt')
808libm = cc.find_library('m')
809libdl = cc.find_library('dl')
810libcrypt = cc.find_library('crypt')
811
1800cc85
ZJS
812libcap = dependency('libcap', required : false)
813if not libcap.found()
814 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
815 libcap = cc.find_library('cap')
816endif
817
5c23128d 818libmount = dependency('mount',
c0b4b0f8 819 version : fuzzer_build ? '>= 0' : '>= 2.30')
5c23128d
ZJS
820
821want_seccomp = get_option('seccomp')
31e57a35 822if want_seccomp != 'false' and not fuzzer_build
37efbbd8 823 libseccomp = dependency('libseccomp',
9f0e9c01 824 version : '>= 2.3.1',
37efbbd8 825 required : want_seccomp == 'true')
349cc4a5 826 have = libseccomp.found()
5c23128d 827else
349cc4a5 828 have = false
37efbbd8 829 libseccomp = []
5c23128d 830endif
349cc4a5 831conf.set10('HAVE_SECCOMP', have)
5c23128d
ZJS
832
833want_selinux = get_option('selinux')
31e57a35 834if want_selinux != 'false' and not fuzzer_build
37efbbd8
ZJS
835 libselinux = dependency('libselinux',
836 version : '>= 2.1.9',
837 required : want_selinux == 'true')
349cc4a5 838 have = libselinux.found()
5c23128d 839else
349cc4a5 840 have = false
37efbbd8 841 libselinux = []
5c23128d 842endif
349cc4a5 843conf.set10('HAVE_SELINUX', have)
5c23128d
ZJS
844
845want_apparmor = get_option('apparmor')
31e57a35 846if want_apparmor != 'false' and not fuzzer_build
37efbbd8
ZJS
847 libapparmor = dependency('libapparmor',
848 required : want_apparmor == 'true')
349cc4a5 849 have = libapparmor.found()
5c23128d 850else
349cc4a5 851 have = false
37efbbd8 852 libapparmor = []
5c23128d 853endif
349cc4a5 854conf.set10('HAVE_APPARMOR', have)
5c23128d 855
5c23128d
ZJS
856smack_run_label = get_option('smack-run-label')
857if smack_run_label != ''
37efbbd8 858 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
5c23128d
ZJS
859endif
860
3ca0cb73
ZJS
861want_polkit = get_option('polkit')
862install_polkit = false
863install_polkit_pkla = false
31e57a35 864if want_polkit != 'false' and not fuzzer_build
37efbbd8 865 install_polkit = true
3ca0cb73 866
37efbbd8
ZJS
867 libpolkit = dependency('polkit-gobject-1',
868 required : false)
869 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
870 message('Old polkit detected, will install pkla files')
871 install_polkit_pkla = true
872 endif
3ca0cb73 873endif
349cc4a5 874conf.set10('ENABLE_POLKIT', install_polkit)
3ca0cb73 875
36f0387e 876want_acl = get_option('acl')
31e57a35 877if want_acl != 'false' and not fuzzer_build
36f0387e 878 libacl = cc.find_library('acl', required : want_acl == 'true')
349cc4a5 879 have = libacl.found()
36f0387e 880else
349cc4a5 881 have = false
36f0387e
ZJS
882 libacl = []
883endif
349cc4a5 884conf.set10('HAVE_ACL', have)
36f0387e 885
5c23128d 886want_audit = get_option('audit')
31e57a35 887if want_audit != 'false' and not fuzzer_build
37efbbd8 888 libaudit = dependency('audit', required : want_audit == 'true')
349cc4a5 889 have = libaudit.found()
5c23128d 890else
349cc4a5 891 have = false
37efbbd8 892 libaudit = []
5c23128d 893endif
349cc4a5 894conf.set10('HAVE_AUDIT', have)
5c23128d
ZJS
895
896want_blkid = get_option('blkid')
31e57a35 897if want_blkid != 'false' and not fuzzer_build
37efbbd8 898 libblkid = dependency('blkid', required : want_blkid == 'true')
349cc4a5 899 have = libblkid.found()
5c23128d 900else
349cc4a5 901 have = false
37efbbd8 902 libblkid = []
5c23128d 903endif
349cc4a5 904conf.set10('HAVE_BLKID', have)
5c23128d
ZJS
905
906want_kmod = get_option('kmod')
31e57a35 907if want_kmod != 'false' and not fuzzer_build
37efbbd8
ZJS
908 libkmod = dependency('libkmod',
909 version : '>= 15',
910 required : want_kmod == 'true')
349cc4a5 911 have = libkmod.found()
5c23128d 912else
349cc4a5 913 have = false
37efbbd8 914 libkmod = []
5c23128d 915endif
349cc4a5 916conf.set10('HAVE_KMOD', have)
5c23128d
ZJS
917
918want_pam = get_option('pam')
31e57a35 919if want_pam != 'false' and not fuzzer_build
37efbbd8
ZJS
920 libpam = cc.find_library('pam', required : want_pam == 'true')
921 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
349cc4a5 922 have = libpam.found() and libpam_misc.found()
5c23128d 923else
349cc4a5 924 have = false
37efbbd8
ZJS
925 libpam = []
926 libpam_misc = []
5c23128d 927endif
349cc4a5 928conf.set10('HAVE_PAM', have)
5c23128d
ZJS
929
930want_microhttpd = get_option('microhttpd')
31e57a35 931if want_microhttpd != 'false' and not fuzzer_build
37efbbd8
ZJS
932 libmicrohttpd = dependency('libmicrohttpd',
933 version : '>= 0.9.33',
934 required : want_microhttpd == 'true')
349cc4a5 935 have = libmicrohttpd.found()
5c23128d 936else
349cc4a5 937 have = false
37efbbd8 938 libmicrohttpd = []
5c23128d 939endif
349cc4a5 940conf.set10('HAVE_MICROHTTPD', have)
5c23128d
ZJS
941
942want_libcryptsetup = get_option('libcryptsetup')
31e57a35 943if want_libcryptsetup != 'false' and not fuzzer_build
37efbbd8
ZJS
944 libcryptsetup = dependency('libcryptsetup',
945 version : '>= 1.6.0',
946 required : want_libcryptsetup == 'true')
349cc4a5 947 have = libcryptsetup.found()
a9fc6406
DJL
948 have_sector = cc.has_member(
949 'struct crypt_params_plain',
950 'sector_size',
951 prefix : '#include <libcryptsetup.h>')
5c23128d 952else
349cc4a5 953 have = false
a9fc6406 954 have_sector = false
37efbbd8 955 libcryptsetup = []
5c23128d 956endif
349cc4a5 957conf.set10('HAVE_LIBCRYPTSETUP', have)
a9fc6406 958conf.set10('HAVE_LIBCRYPTSETUP_SECTOR_SIZE', have_sector)
5c23128d
ZJS
959
960want_libcurl = get_option('libcurl')
31e57a35 961if want_libcurl != 'false' and not fuzzer_build
37efbbd8
ZJS
962 libcurl = dependency('libcurl',
963 version : '>= 7.32.0',
964 required : want_libcurl == 'true')
349cc4a5 965 have = libcurl.found()
5c23128d 966else
349cc4a5 967 have = false
37efbbd8 968 libcurl = []
5c23128d 969endif
349cc4a5 970conf.set10('HAVE_LIBCURL', have)
5c23128d
ZJS
971
972want_libidn = get_option('libidn')
87057e24
ZJS
973want_libidn2 = get_option('libidn2')
974if want_libidn == 'true' and want_libidn2 == 'true'
975 error('libidn and libidn2 cannot be requested simultaneously')
976endif
977
31e57a35 978if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
7f7ab228
ZJS
979 libidn = dependency('libidn',
980 required : want_libidn == 'true')
349cc4a5 981 have = libidn.found()
87057e24 982else
349cc4a5 983 have = false
87057e24
ZJS
984 libidn = []
985endif
349cc4a5 986conf.set10('HAVE_LIBIDN', have)
31e57a35 987if not have and want_libidn2 != 'false' and not fuzzer_build
7f7ab228
ZJS
988 # libidn is used for both libidn and libidn2 objects
989 libidn = dependency('libidn2',
990 required : want_libidn2 == 'true')
349cc4a5
ZJS
991 have = libidn.found()
992else
993 have = false
5c23128d 994endif
349cc4a5 995conf.set10('HAVE_LIBIDN2', have)
5c23128d
ZJS
996
997want_libiptc = get_option('libiptc')
31e57a35 998if want_libiptc != 'false' and not fuzzer_build
37efbbd8
ZJS
999 libiptc = dependency('libiptc',
1000 required : want_libiptc == 'true')
349cc4a5 1001 have = libiptc.found()
5c23128d 1002else
349cc4a5 1003 have = false
37efbbd8 1004 libiptc = []
5c23128d 1005endif
349cc4a5 1006conf.set10('HAVE_LIBIPTC', have)
5c23128d
ZJS
1007
1008want_qrencode = get_option('qrencode')
31e57a35 1009if want_qrencode != 'false' and not fuzzer_build
37efbbd8
ZJS
1010 libqrencode = dependency('libqrencode',
1011 required : want_qrencode == 'true')
349cc4a5 1012 have = libqrencode.found()
5c23128d 1013else
349cc4a5 1014 have = false
37efbbd8 1015 libqrencode = []
5c23128d 1016endif
349cc4a5 1017conf.set10('HAVE_QRENCODE', have)
5c23128d 1018
a44fb601 1019want_gcrypt = get_option('gcrypt')
31e57a35 1020if want_gcrypt != 'false' and not fuzzer_build
a44fb601
ZJS
1021 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1022 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
349cc4a5 1023 have = libgcrypt.found() and libgpg_error.found()
a44fb601 1024else
349cc4a5
ZJS
1025 have = false
1026endif
1027if not have
1028 # link to neither of the libs if one is not found
a44fb601
ZJS
1029 libgcrypt = []
1030 libgpg_error = []
1031endif
349cc4a5 1032conf.set10('HAVE_GCRYPT', have)
a44fb601 1033
5c23128d 1034want_gnutls = get_option('gnutls')
31e57a35 1035if want_gnutls != 'false' and not fuzzer_build
37efbbd8
ZJS
1036 libgnutls = dependency('gnutls',
1037 version : '>= 3.1.4',
1038 required : want_gnutls == 'true')
349cc4a5 1039 have = libgnutls.found()
5c23128d 1040else
349cc4a5 1041 have = false
37efbbd8 1042 libgnutls = []
5c23128d 1043endif
349cc4a5 1044conf.set10('HAVE_GNUTLS', have)
5c23128d 1045
096cbdce
IT
1046want_openssl = get_option('openssl')
1047if want_openssl != 'false' and not fuzzer_build
1048 libopenssl = dependency('openssl',
1049 version : '>= 1.1.0',
1050 required : want_openssl == 'true')
1051 have = libopenssl.found()
1052else
1053 have = false
1054 libopenssl = []
1055endif
1056conf.set10('HAVE_OPENSSL', have)
1057
5c23128d 1058want_elfutils = get_option('elfutils')
31e57a35 1059if want_elfutils != 'false' and not fuzzer_build
37efbbd8
ZJS
1060 libdw = dependency('libdw',
1061 required : want_elfutils == 'true')
349cc4a5 1062 have = libdw.found()
5c23128d 1063else
349cc4a5 1064 have = false
37efbbd8 1065 libdw = []
5c23128d 1066endif
349cc4a5 1067conf.set10('HAVE_ELFUTILS', have)
5c23128d
ZJS
1068
1069want_zlib = get_option('zlib')
31e57a35 1070if want_zlib != 'false' and not fuzzer_build
37efbbd8
ZJS
1071 libz = dependency('zlib',
1072 required : want_zlib == 'true')
349cc4a5 1073 have = libz.found()
5c23128d 1074else
349cc4a5 1075 have = false
37efbbd8 1076 libz = []
5c23128d 1077endif
349cc4a5 1078conf.set10('HAVE_ZLIB', have)
5c23128d
ZJS
1079
1080want_bzip2 = get_option('bzip2')
31e57a35 1081if want_bzip2 != 'false' and not fuzzer_build
37efbbd8
ZJS
1082 libbzip2 = cc.find_library('bz2',
1083 required : want_bzip2 == 'true')
349cc4a5 1084 have = libbzip2.found()
5c23128d 1085else
349cc4a5 1086 have = false
37efbbd8 1087 libbzip2 = []
5c23128d 1088endif
349cc4a5 1089conf.set10('HAVE_BZIP2', have)
5c23128d
ZJS
1090
1091want_xz = get_option('xz')
31e57a35 1092if want_xz != 'false' and not fuzzer_build
37efbbd8
ZJS
1093 libxz = dependency('liblzma',
1094 required : want_xz == 'true')
349cc4a5 1095 have = libxz.found()
5c23128d 1096else
349cc4a5 1097 have = false
37efbbd8 1098 libxz = []
5c23128d 1099endif
349cc4a5 1100conf.set10('HAVE_XZ', have)
5c23128d
ZJS
1101
1102want_lz4 = get_option('lz4')
31e57a35 1103if want_lz4 != 'false' and not fuzzer_build
37efbbd8 1104 liblz4 = dependency('liblz4',
e0a1d4b0 1105 version : '>= 1.3.0',
37efbbd8 1106 required : want_lz4 == 'true')
349cc4a5 1107 have = liblz4.found()
5c23128d 1108else
349cc4a5 1109 have = false
37efbbd8 1110 liblz4 = []
5c23128d 1111endif
349cc4a5 1112conf.set10('HAVE_LZ4', have)
5c23128d 1113
a44fb601 1114want_xkbcommon = get_option('xkbcommon')
31e57a35 1115if want_xkbcommon != 'false' and not fuzzer_build
a44fb601
ZJS
1116 libxkbcommon = dependency('xkbcommon',
1117 version : '>= 0.3.0',
1118 required : want_xkbcommon == 'true')
349cc4a5 1119 have = libxkbcommon.found()
a44fb601 1120else
349cc4a5 1121 have = false
a44fb601
ZJS
1122 libxkbcommon = []
1123endif
349cc4a5 1124conf.set10('HAVE_XKBCOMMON', have)
a44fb601 1125
c4c978a0
ZJS
1126want_pcre2 = get_option('pcre2')
1127if want_pcre2 != 'false'
1128 libpcre2 = dependency('libpcre2-8',
1129 required : want_pcre2 == 'true')
1130 have = libpcre2.found()
1131else
1132 have = false
1133 libpcre2 = []
1134endif
1135conf.set10('HAVE_PCRE2', have)
1136
69e96427 1137want_glib = get_option('glib')
31e57a35 1138if want_glib != 'false' and not fuzzer_build
37efbbd8
ZJS
1139 libglib = dependency('glib-2.0',
1140 version : '>= 2.22.0',
1141 required : want_glib == 'true')
1142 libgobject = dependency('gobject-2.0',
1143 version : '>= 2.22.0',
1144 required : want_glib == 'true')
1145 libgio = dependency('gio-2.0',
1146 required : want_glib == 'true')
2c201c21 1147 have = libglib.found() and libgobject.found() and libgio.found()
69e96427 1148else
349cc4a5 1149 have = false
37efbbd8
ZJS
1150 libglib = []
1151 libgobject = []
1152 libgio = []
69e96427 1153endif
349cc4a5 1154conf.set10('HAVE_GLIB', have)
69e96427
ZJS
1155
1156want_dbus = get_option('dbus')
31e57a35 1157if want_dbus != 'false' and not fuzzer_build
37efbbd8
ZJS
1158 libdbus = dependency('dbus-1',
1159 version : '>= 1.3.2',
1160 required : want_dbus == 'true')
349cc4a5 1161 have = libdbus.found()
69e96427 1162else
349cc4a5 1163 have = false
37efbbd8 1164 libdbus = []
69e96427 1165endif
349cc4a5 1166conf.set10('HAVE_DBUS', have)
69e96427 1167
42303dcb 1168default_dnssec = get_option('default-dnssec')
31e57a35 1169if fuzzer_build
b4081f3e
JR
1170 default_dnssec = 'no'
1171endif
349cc4a5 1172if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
42303dcb
YW
1173 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1174 default_dnssec = 'no'
1175endif
1176conf.set('DEFAULT_DNSSEC_MODE',
1177 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1178substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1179
56ddbf10
YW
1180dns_over_tls = get_option('dns-over-tls')
1181if dns_over_tls != 'false'
096cbdce
IT
1182 if dns_over_tls == 'openssl'
1183 have_gnutls = false
1184 else
1185 have_gnutls = (conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.5.3'))
1186 if dns_over_tls == 'gnutls' and not have_gnutls
1187 error('DNS-over-TLS support was requested with gnutls, but dependencies are not available')
1188 endif
56ddbf10 1189 endif
096cbdce
IT
1190 if dns_over_tls == 'gnutls' or have_gnutls
1191 have_openssl = false
1192 else
1193 have_openssl = conf.get('HAVE_OPENSSL') == 1
1194 if dns_over_tls != 'auto' and not have_openssl
1195 str = dns_over_tls == 'openssl' ? ' with openssl' : ''
1196 error('DNS-over-TLS support was requested$0$, but dependencies are not available'.format(str))
1197 endif
1198 endif
1199 have = have_gnutls or have_openssl
56ddbf10 1200else
be5536a6
MO
1201 have = false
1202 have_gnutls = false
1203 have_openssl = false
56ddbf10
YW
1204endif
1205conf.set10('ENABLE_DNS_OVER_TLS', have)
096cbdce
IT
1206conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1207conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
56ddbf10 1208
c9299be2 1209default_dns_over_tls = get_option('default-dns-over-tls')
5d67a7ae 1210if fuzzer_build
c9299be2 1211 default_dns_over_tls = 'no'
5d67a7ae 1212endif
56ddbf10
YW
1213if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1214 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 1215 default_dns_over_tls = 'no'
5d67a7ae 1216endif
c9299be2
IT
1217conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1218 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1219substs.set('DEFAULT_DNS_OVER_TLS_MODE', default_dns_over_tls)
5d67a7ae 1220
5c23128d 1221want_importd = get_option('importd')
4390be30 1222if want_importd != 'false'
349cc4a5
ZJS
1223 have = (conf.get('HAVE_LIBCURL') == 1 and
1224 conf.get('HAVE_ZLIB') == 1 and
349cc4a5
ZJS
1225 conf.get('HAVE_XZ') == 1 and
1226 conf.get('HAVE_GCRYPT') == 1)
1227 if want_importd == 'true' and not have
37efbbd8
ZJS
1228 error('importd support was requested, but dependencies are not available')
1229 endif
349cc4a5
ZJS
1230else
1231 have = false
5c23128d 1232endif
349cc4a5 1233conf.set10('ENABLE_IMPORTD', have)
5c23128d
ZJS
1234
1235want_remote = get_option('remote')
4390be30 1236if want_remote != 'false'
349cc4a5
ZJS
1237 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1238 conf.get('HAVE_LIBCURL') == 1]
37efbbd8
ZJS
1239 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1240 # it's possible to build one without the other. Complain only if
1241 # support was explictly requested. The auxiliary files like sysusers
1242 # config should be installed when any of the programs are built.
1243 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1244 error('remote support was requested, but dependencies are not available')
1245 endif
349cc4a5
ZJS
1246 have = have_deps[0] or have_deps[1]
1247else
1248 have = false
5c23128d 1249endif
349cc4a5 1250conf.set10('ENABLE_REMOTE', have)
5c23128d 1251
a9149d87
ZJS
1252foreach term : ['utmp',
1253 'hibernate',
1254 'environment-d',
1255 'binfmt',
1256 'coredump',
1257 'resolve',
1258 'logind',
1259 'hostnamed',
1260 'localed',
1261 'machined',
61d0578b 1262 'portabled',
a9149d87
ZJS
1263 'networkd',
1264 'timedated',
1265 'timesyncd',
a9149d87
ZJS
1266 'firstboot',
1267 'randomseed',
1268 'backlight',
1269 'vconsole',
1270 'quotacheck',
1271 'sysusers',
1272 'tmpfiles',
1273 'hwdb',
1274 'rfkill',
1275 'ldconfig',
1276 'efi',
1277 'tpm',
1278 'ima',
1279 'smack',
1280 'gshadow',
1281 'idn',
08540a95 1282 'nss-myhostname',
a9149d87
ZJS
1283 'nss-systemd']
1284 have = get_option(term)
1285 name = 'ENABLE_' + term.underscorify().to_upper()
1286 conf.set10(name, have)
5c23128d
ZJS
1287endforeach
1288
08540a95
YW
1289foreach tuple : [['nss-mymachines', 'machined'],
1290 ['nss-resolve', 'resolve']]
1291 want = get_option(tuple[0])
1292 if want != 'false'
1293 have = get_option(tuple[1])
1294 if want == 'true' and not have
1295 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1296 endif
1297 else
1298 have = false
1299 endif
1300 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1301 conf.set10(name, have)
1302endforeach
1303
1304enable_nss = false
1305foreach term : ['ENABLE_NSS_MYHOSTNAME',
1306 'ENABLE_NSS_MYMACHINES',
1307 'ENABLE_NSS_RESOLVE',
1308 'ENABLE_NSS_SYSTEMD']
1309 if conf.get(term) == 1
1310 enable_nss = true
1311 endif
1312endforeach
1313conf.set10('ENABLE_NSS', enable_nss)
1314
348b4437 1315conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
6129ec85 1316
69e96427 1317tests = []
7db7d5b7 1318fuzzers = []
69e96427 1319
b68dfb9e 1320conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
00d82c81 1321
5c23128d
ZJS
1322#####################################################################
1323
1324if get_option('efi')
37efbbd8 1325 efi_arch = host_machine.cpu_family()
b710072d 1326
6800fe7f 1327 if efi_arch == 'x86'
37efbbd8 1328 EFI_MACHINE_TYPE_NAME = 'ia32'
6800fe7f 1329 gnu_efi_arch = 'ia32'
37efbbd8
ZJS
1330 elif efi_arch == 'x86_64'
1331 EFI_MACHINE_TYPE_NAME = 'x64'
6800fe7f 1332 gnu_efi_arch = 'x86_64'
37efbbd8
ZJS
1333 elif efi_arch == 'arm'
1334 EFI_MACHINE_TYPE_NAME = 'arm'
6800fe7f 1335 gnu_efi_arch = 'arm'
37efbbd8
ZJS
1336 elif efi_arch == 'aarch64'
1337 EFI_MACHINE_TYPE_NAME = 'aa64'
6800fe7f 1338 gnu_efi_arch = 'aarch64'
37efbbd8
ZJS
1339 else
1340 EFI_MACHINE_TYPE_NAME = ''
6800fe7f 1341 gnu_efi_arch = ''
37efbbd8 1342 endif
5c23128d 1343
349cc4a5 1344 have = true
37efbbd8 1345 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
80c6fce8 1346
ac09340e 1347 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
349cc4a5
ZJS
1348else
1349 have = false
5c23128d 1350endif
349cc4a5 1351conf.set10('ENABLE_EFI', have)
5c23128d
ZJS
1352
1353#####################################################################
1354
1355config_h = configure_file(
37efbbd8
ZJS
1356 output : 'config.h',
1357 configuration : conf)
5c23128d 1358
348b4437
YW
1359meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1360
5c23128d
ZJS
1361includes = include_directories('src/basic',
1362 'src/shared',
1363 'src/systemd',
1364 'src/journal',
a38f7fec 1365 'src/journal-remote',
97d90615 1366 'src/nspawn',
5c23128d
ZJS
1367 'src/resolve',
1368 'src/timesync',
5c3376ef 1369 'src/time-wait-sync',
5c23128d
ZJS
1370 'src/login',
1371 'src/udev',
1372 'src/libudev',
1373 'src/core',
1374 'src/libsystemd/sd-bus',
1375 'src/libsystemd/sd-device',
a137a1c3 1376 'src/libsystemd/sd-event',
5c23128d
ZJS
1377 'src/libsystemd/sd-hwdb',
1378 'src/libsystemd/sd-id128',
1379 'src/libsystemd/sd-netlink',
1380 'src/libsystemd/sd-network',
1381 'src/libsystemd-network',
2d4ceca8 1382 '.')
5c23128d
ZJS
1383
1384add_project_arguments('-include', 'config.h', language : 'c')
1385
5c23128d
ZJS
1386subdir('po')
1387subdir('catalog')
1388subdir('src/systemd')
1389subdir('src/basic')
1390subdir('src/libsystemd')
1391subdir('src/libsystemd-network')
5c23128d 1392subdir('src/journal')
5c23128d 1393subdir('src/login')
5c23128d
ZJS
1394
1395libjournal_core = static_library(
37efbbd8
ZJS
1396 'journal-core',
1397 libjournal_core_sources,
1398 journald_gperf_c,
1399 include_directories : includes,
1400 install : false)
5c23128d 1401
37ab1a25 1402libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d 1403libsystemd = shared_library(
37efbbd8 1404 'systemd',
a5d8835c 1405 disable_mempool_c,
56d50ab1 1406 version : libsystemd_version,
37efbbd8
ZJS
1407 include_directories : includes,
1408 link_args : ['-shared',
1409 '-Wl,--version-script=' + libsystemd_sym_path],
34e221a5
ZJS
1410 link_with : [libbasic,
1411 libbasic_gcrypt],
5e3cec87
ZJS
1412 link_whole : [libsystemd_static,
1413 libjournal_client],
37efbbd8
ZJS
1414 dependencies : [threads,
1415 librt,
1416 libxz,
1417 liblz4],
1418 link_depends : libsystemd_sym,
1419 install : true,
1420 install_dir : rootlibdir)
5c23128d 1421
70848ecf
DC
1422static_libsystemd = get_option('static-libsystemd')
1423static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1424
1425install_libsystemd_static = static_library(
1426 'systemd',
1427 libsystemd_sources,
1428 journal_client_sources,
975464e0
ZJS
1429 basic_sources,
1430 basic_gcrypt_sources,
be44b572 1431 disable_mempool_c,
70848ecf 1432 include_directories : includes,
70848ecf
DC
1433 build_by_default : static_libsystemd != 'false',
1434 install : static_libsystemd != 'false',
1435 install_dir : rootlibdir,
1436 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1437 dependencies : [threads,
1438 librt,
1439 libxz,
1440 liblz4,
975464e0
ZJS
1441 libcap,
1442 libblkid,
1443 libmount,
1444 libselinux,
70848ecf
DC
1445 libgcrypt],
1446 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1447
5c23128d
ZJS
1448############################################################
1449
83b6af36
ZJS
1450# binaries that have --help and are intended for use by humans,
1451# usually, but not always, installed in /bin.
1452public_programs = []
1453
1454subdir('src/libudev')
1455subdir('src/shared')
1456subdir('src/core')
1457subdir('src/udev')
1458subdir('src/network')
1459
1460subdir('src/analyze')
1461subdir('src/journal-remote')
1462subdir('src/coredump')
1463subdir('src/hostname')
1464subdir('src/import')
1465subdir('src/kernel-install')
1466subdir('src/locale')
1467subdir('src/machine')
61d0578b 1468subdir('src/portable')
83b6af36
ZJS
1469subdir('src/nspawn')
1470subdir('src/resolve')
1471subdir('src/timedate')
1472subdir('src/timesync')
1473subdir('src/vconsole')
83b6af36
ZJS
1474subdir('src/boot/efi')
1475
1476subdir('src/test')
7db7d5b7 1477subdir('src/fuzz')
6b97bf22 1478subdir('rules')
83b6af36
ZJS
1479subdir('test')
1480
1481############################################################
1482
1483# only static linking apart from libdl, to make sure that the
1484# module is linked to all libraries that it uses.
1485test_dlopen = executable(
37efbbd8
ZJS
1486 'test-dlopen',
1487 test_dlopen_c,
a5d8835c 1488 disable_mempool_c,
37efbbd8
ZJS
1489 include_directories : includes,
1490 link_with : [libbasic],
fd1939fb
YW
1491 dependencies : [libdl],
1492 build_by_default : want_tests != 'false')
83b6af36 1493
08540a95 1494foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
e7e11bbf 1495 ['systemd', 'ENABLE_NSS_SYSTEMD'],
08540a95
YW
1496 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
1497 ['resolve', 'ENABLE_NSS_RESOLVE']]
5c23128d 1498
349cc4a5 1499 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
1500 if condition
1501 module = tuple[0]
37efbbd8
ZJS
1502
1503 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
243e5cec 1504 version_script_arg = join_paths(meson.source_root(), sym)
37efbbd8
ZJS
1505
1506 nss = shared_library(
1507 'nss_' + module,
1508 'src/nss-@0@/nss-@0@.c'.format(module),
a5d8835c 1509 disable_mempool_c,
37efbbd8
ZJS
1510 version : '2',
1511 include_directories : includes,
b4b36f44
LP
1512 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1513 link_args : ['-Wl,-z,nodelete',
1514 '-shared',
37efbbd8
ZJS
1515 '-Wl,--version-script=' + version_script_arg,
1516 '-Wl,--undefined'],
37e4d7a8 1517 link_with : [libsystemd_static,
37efbbd8
ZJS
1518 libbasic],
1519 dependencies : [threads,
5486a31d 1520 librt],
37efbbd8
ZJS
1521 link_depends : sym,
1522 install : true,
1523 install_dir : rootlibdir)
1524
1525 # We cannot use shared_module because it does not support version suffix.
1526 # Unfortunately shared_library insists on creating the symlink…
1527 meson.add_install_script('sh', '-c',
1528 'rm $DESTDIR@0@/libnss_@1@.so'
1529 .format(rootlibdir, module))
1530
938be089
ZJS
1531 if want_tests != 'false'
1532 test('dlopen-nss_' + module,
1533 test_dlopen,
1534 # path to dlopen must include a slash
1535 args : nss.full_path())
1536 endif
37efbbd8 1537 endif
5c23128d
ZJS
1538endforeach
1539
1540############################################################
1541
5c23128d
ZJS
1542executable('systemd',
1543 systemd_sources,
1544 include_directories : includes,
1545 link_with : [libcore,
34ce0a52 1546 libshared],
5c23128d
ZJS
1547 dependencies : [threads,
1548 librt,
1549 libseccomp,
1550 libselinux,
f4ee10a2
ZJS
1551 libmount,
1552 libblkid],
421f0012 1553 install_rpath : rootlibexecdir,
5c23128d
ZJS
1554 install : true,
1555 install_dir : rootlibexecdir)
1556
ba7f4ae6
ZJS
1557meson.add_install_script(meson_make_symlink,
1558 join_paths(rootlibexecdir, 'systemd'),
1559 join_paths(rootsbindir, 'init'))
1560
005a29f2
ZJS
1561exe = executable('systemd-analyze',
1562 systemd_analyze_sources,
1563 include_directories : includes,
1564 link_with : [libcore,
005a29f2
ZJS
1565 libshared],
1566 dependencies : [threads,
1567 librt,
1568 libseccomp,
1569 libselinux,
1570 libmount,
1571 libblkid],
1572 install_rpath : rootlibexecdir,
1573 install : true)
5a8b1640 1574public_programs += exe
5c23128d
ZJS
1575
1576executable('systemd-journald',
1577 systemd_journald_sources,
1578 include_directories : includes,
aac26058 1579 link_with : [libjournal_core,
34ce0a52 1580 libshared],
5c23128d
ZJS
1581 dependencies : [threads,
1582 libxz,
aac26058
ZJS
1583 liblz4,
1584 libselinux],
421f0012 1585 install_rpath : rootlibexecdir,
5c23128d
ZJS
1586 install : true,
1587 install_dir : rootlibexecdir)
1588
005a29f2
ZJS
1589exe = executable('systemd-cat',
1590 systemd_cat_sources,
1591 include_directories : includes,
1592 link_with : [libjournal_core,
34ce0a52 1593 libshared],
005a29f2
ZJS
1594 dependencies : [threads],
1595 install_rpath : rootlibexecdir,
1596 install : true)
5a8b1640 1597public_programs += exe
005a29f2
ZJS
1598
1599exe = executable('journalctl',
1600 journalctl_sources,
1601 include_directories : includes,
34ce0a52 1602 link_with : [libshared],
005a29f2
ZJS
1603 dependencies : [threads,
1604 libqrencode,
1605 libxz,
6becf48c
ZJS
1606 liblz4,
1607 libpcre2],
005a29f2
ZJS
1608 install_rpath : rootlibexecdir,
1609 install : true,
1610 install_dir : rootbindir)
5a8b1640 1611public_programs += exe
5c23128d
ZJS
1612
1613executable('systemd-getty-generator',
1614 'src/getty-generator/getty-generator.c',
5c23128d 1615 include_directories : includes,
b2fc5836
ZJS
1616 link_with : [libshared],
1617 install_rpath : rootlibexecdir,
1618 install : true,
1619 install_dir : systemgeneratordir)
5c23128d
ZJS
1620
1621executable('systemd-debug-generator',
1622 'src/debug-generator/debug-generator.c',
5c23128d 1623 include_directories : includes,
b2fc5836
ZJS
1624 link_with : [libshared],
1625 install_rpath : rootlibexecdir,
1626 install : true,
1627 install_dir : systemgeneratordir)
5c23128d
ZJS
1628
1629executable('systemd-fstab-generator',
1630 'src/fstab-generator/fstab-generator.c',
1631 'src/core/mount-setup.c',
5c23128d 1632 include_directories : includes,
b2fc5836
ZJS
1633 link_with : [libshared],
1634 install_rpath : rootlibexecdir,
1635 install : true,
1636 install_dir : systemgeneratordir)
5c23128d 1637
349cc4a5 1638if conf.get('ENABLE_ENVIRONMENT_D') == 1
37efbbd8
ZJS
1639 executable('30-systemd-environment-d-generator',
1640 'src/environment-d-generator/environment-d-generator.c',
1641 include_directories : includes,
1642 link_with : [libshared],
1643 install_rpath : rootlibexecdir,
1644 install : true,
1645 install_dir : userenvgeneratordir)
7b76fce1 1646
37efbbd8
ZJS
1647 meson.add_install_script(meson_make_symlink,
1648 join_paths(sysconfdir, 'environment'),
1649 join_paths(environmentdir, '99-environment.conf'))
5c23128d
ZJS
1650endif
1651
349cc4a5 1652if conf.get('ENABLE_HIBERNATE') == 1
37efbbd8
ZJS
1653 executable('systemd-hibernate-resume-generator',
1654 'src/hibernate-resume/hibernate-resume-generator.c',
1655 include_directories : includes,
1656 link_with : [libshared],
1657 install_rpath : rootlibexecdir,
1658 install : true,
1659 install_dir : systemgeneratordir)
5c23128d 1660
37efbbd8
ZJS
1661 executable('systemd-hibernate-resume',
1662 'src/hibernate-resume/hibernate-resume.c',
005a29f2
ZJS
1663 include_directories : includes,
1664 link_with : [libshared],
1665 install_rpath : rootlibexecdir,
1666 install : true,
1667 install_dir : rootlibexecdir)
37efbbd8
ZJS
1668endif
1669
349cc4a5 1670if conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1671 executable('systemd-gpt-auto-generator',
1672 'src/gpt-auto-generator/gpt-auto-generator.c',
d284b82b 1673 'src/shared/blkid-util.h',
37efbbd8 1674 include_directories : includes,
34ce0a52 1675 link_with : [libshared],
37efbbd8
ZJS
1676 dependencies : libblkid,
1677 install_rpath : rootlibexecdir,
1678 install : true,
1679 install_dir : systemgeneratordir)
1680
1681 exe = executable('systemd-dissect',
1682 'src/dissect/dissect.c',
1683 include_directories : includes,
1684 link_with : [libshared],
1685 install_rpath : rootlibexecdir,
1686 install : true,
1687 install_dir : rootlibexecdir)
5a8b1640 1688 public_programs += exe
5c23128d
ZJS
1689endif
1690
1ec57f33 1691if conf.get('ENABLE_RESOLVE') == 1
37efbbd8
ZJS
1692 executable('systemd-resolved',
1693 systemd_resolved_sources,
005a29f2 1694 include_directories : includes,
34e221a5 1695 link_with : [libshared,
568a4ff8
ZJS
1696 libbasic_gcrypt,
1697 libsystemd_resolve_core],
56ddbf10 1698 dependencies : systemd_resolved_dependencies,
005a29f2 1699 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1700 install : true,
1701 install_dir : rootlibexecdir)
1702
c2e84cab
YW
1703 exe = executable('resolvectl',
1704 resolvectl_sources,
37efbbd8 1705 include_directories : includes,
34e221a5 1706 link_with : [libshared,
568a4ff8
ZJS
1707 libbasic_gcrypt,
1708 libsystemd_resolve_core],
37efbbd8 1709 dependencies : [threads,
76c87410 1710 libgpg_error,
37efbbd8
ZJS
1711 libm,
1712 libidn],
1713 install_rpath : rootlibexecdir,
1714 install : true)
5a8b1640 1715 public_programs += exe
088c1363
LP
1716
1717 meson.add_install_script(meson_make_symlink,
c2e84cab 1718 join_paths(bindir, 'resolvectl'),
088c1363 1719 join_paths(rootsbindir, 'resolvconf'))
c2e84cab
YW
1720
1721 meson.add_install_script(meson_make_symlink,
1722 join_paths(bindir, 'resolvectl'),
1723 join_paths(bindir, 'systemd-resolve'))
5c23128d
ZJS
1724endif
1725
349cc4a5 1726if conf.get('ENABLE_LOGIND') == 1
37efbbd8
ZJS
1727 executable('systemd-logind',
1728 systemd_logind_sources,
005a29f2 1729 include_directories : includes,
37efbbd8 1730 link_with : [liblogind_core,
34ce0a52 1731 libshared],
005a29f2 1732 dependencies : [threads,
37efbbd8 1733 libacl],
005a29f2
ZJS
1734 install_rpath : rootlibexecdir,
1735 install : true,
37efbbd8
ZJS
1736 install_dir : rootlibexecdir)
1737
1738 exe = executable('loginctl',
1739 loginctl_sources,
1740 include_directories : includes,
34ce0a52 1741 link_with : [libshared],
37efbbd8
ZJS
1742 dependencies : [threads,
1743 liblz4,
1744 libxz],
1745 install_rpath : rootlibexecdir,
1746 install : true,
1747 install_dir : rootbindir)
5a8b1640 1748 public_programs += exe
37efbbd8
ZJS
1749
1750 exe = executable('systemd-inhibit',
1751 'src/login/inhibit.c',
1752 include_directories : includes,
1753 link_with : [libshared],
1754 install_rpath : rootlibexecdir,
1755 install : true,
1756 install_dir : rootbindir)
5a8b1640 1757 public_programs += exe
37efbbd8 1758
349cc4a5 1759 if conf.get('HAVE_PAM') == 1
243e5cec 1760 version_script_arg = join_paths(meson.source_root(), pam_systemd_sym)
37efbbd8
ZJS
1761 pam_systemd = shared_library(
1762 'pam_systemd',
1763 pam_systemd_c,
1764 name_prefix : '',
1765 include_directories : includes,
1766 link_args : ['-shared',
1767 '-Wl,--version-script=' + version_script_arg],
37e4d7a8 1768 link_with : [libsystemd_static,
37efbbd8
ZJS
1769 libshared_static],
1770 dependencies : [threads,
1771 libpam,
1772 libpam_misc],
1773 link_depends : pam_systemd_sym,
1774 install : true,
1775 install_dir : pamlibdir)
1776
938be089
ZJS
1777 if want_tests != 'false'
1778 test('dlopen-pam_systemd',
1779 test_dlopen,
1780 # path to dlopen must include a slash
c1cd6743 1781 args : pam_systemd.full_path())
938be089 1782 endif
37efbbd8 1783 endif
005a29f2 1784
07ee5adb
LP
1785 executable('systemd-user-runtime-dir',
1786 user_runtime_dir_sources,
1787 include_directories : includes,
1788 link_with : [libshared],
1789 install_rpath : rootlibexecdir,
1790 install : true,
1791 install_dir : rootlibexecdir)
1792endif
a9f0f5e5 1793
349cc4a5 1794if conf.get('HAVE_PAM') == 1
37efbbd8
ZJS
1795 executable('systemd-user-sessions',
1796 'src/user-sessions/user-sessions.c',
005a29f2 1797 include_directories : includes,
aac26058 1798 link_with : [libshared],
005a29f2
ZJS
1799 install_rpath : rootlibexecdir,
1800 install : true,
37efbbd8 1801 install_dir : rootlibexecdir)
5c23128d
ZJS
1802endif
1803
349cc4a5 1804if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1805 exe = executable('bootctl',
1806 'src/boot/bootctl.c',
1807 include_directories : includes,
1808 link_with : [libshared],
1809 dependencies : [libblkid],
1810 install_rpath : rootlibexecdir,
1811 install : true)
5a8b1640 1812 public_programs += exe
36695e88
LP
1813
1814 executable('systemd-bless-boot',
1815 'src/boot/bless-boot.c',
1816 include_directories : includes,
1817 link_with : [libshared],
1818 dependencies : [libblkid],
1819 install_rpath : rootlibexecdir,
1820 install : true,
1821 install_dir : rootlibexecdir)
8d16ed07
LP
1822
1823 executable('systemd-bless-boot-generator',
1824 'src/boot/bless-boot-generator.c',
1825 include_directories : includes,
1826 link_with : [libshared],
1827 install_rpath : rootlibexecdir,
1828 install : true,
1829 install_dir : systemgeneratordir)
005a29f2
ZJS
1830endif
1831
f876f537
LP
1832executable('systemd-boot-check-no-failures',
1833 'src/boot/boot-check-no-failures.c',
1834 include_directories : includes,
1835 link_with : [libshared],
1836 dependencies : [libblkid],
1837 install_rpath : rootlibexecdir,
1838 install : true,
1839 install_dir : rootlibexecdir)
1840
005a29f2
ZJS
1841exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1842 include_directories : includes,
1843 link_with : [libshared],
1844 dependencies : [threads],
1845 install_rpath : rootlibexecdir,
1846 install : true)
5a8b1640 1847public_programs += exe
005a29f2 1848
f3794366
FS
1849
1850if get_option('link-systemctl-shared')
1851 systemctl_link_with = [libshared]
1852else
1853 systemctl_link_with = [libsystemd_static,
1854 libshared_static,
1855 libjournal_client,
1856 libbasic_gcrypt]
1857endif
1858
005a29f2
ZJS
1859exe = executable('systemctl', 'src/systemctl/systemctl.c',
1860 include_directories : includes,
f3794366 1861 link_with : systemctl_link_with,
005a29f2
ZJS
1862 dependencies : [threads,
1863 libcap,
1864 libselinux,
1865 libxz,
1866 liblz4],
1867 install_rpath : rootlibexecdir,
1868 install : true,
1869 install_dir : rootbindir)
5a8b1640 1870public_programs += exe
5c23128d 1871
61d0578b
LP
1872if conf.get('ENABLE_PORTABLED') == 1
1873 executable('systemd-portabled',
1874 systemd_portabled_sources,
1875 include_directories : includes,
1876 link_with : [libshared],
1877 dependencies : [threads],
1878 install_rpath : rootlibexecdir,
1879 install : true,
1880 install_dir : rootlibexecdir)
1881
1882 exe = executable('portablectl', 'src/portable/portablectl.c',
1883 include_directories : includes,
1884 link_with : [libshared],
1885 dependencies : [threads],
1886 install_rpath : rootlibexecdir,
1887 install : true,
80f39b81 1888 install_dir : rootbindir)
5a8b1640 1889 public_programs += exe
61d0578b
LP
1890endif
1891
ba7f4ae6
ZJS
1892foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
1893 meson.add_install_script(meson_make_symlink,
1894 join_paths(rootbindir, 'systemctl'),
1895 join_paths(rootsbindir, alias))
1896endforeach
1897
349cc4a5 1898if conf.get('ENABLE_BACKLIGHT') == 1
37efbbd8
ZJS
1899 executable('systemd-backlight',
1900 'src/backlight/backlight.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
349cc4a5 1908if conf.get('ENABLE_RFKILL') == 1
37efbbd8
ZJS
1909 executable('systemd-rfkill',
1910 'src/rfkill/rfkill.c',
1911 include_directories : includes,
34ce0a52 1912 link_with : [libshared],
37efbbd8
ZJS
1913 install_rpath : rootlibexecdir,
1914 install : true,
1915 install_dir : rootlibexecdir)
5c23128d
ZJS
1916endif
1917
1918executable('systemd-system-update-generator',
1919 'src/system-update-generator/system-update-generator.c',
1920 include_directories : includes,
1921 link_with : [libshared],
b2fc5836 1922 install_rpath : rootlibexecdir,
5c23128d
ZJS
1923 install : true,
1924 install_dir : systemgeneratordir)
1925
349cc4a5 1926if conf.get('HAVE_LIBCRYPTSETUP') == 1
37efbbd8
ZJS
1927 executable('systemd-cryptsetup',
1928 'src/cryptsetup/cryptsetup.c',
1929 include_directories : includes,
1930 link_with : [libshared],
1931 dependencies : [libcryptsetup],
1932 install_rpath : rootlibexecdir,
1933 install : true,
1934 install_dir : rootlibexecdir)
1935
1936 executable('systemd-cryptsetup-generator',
1937 'src/cryptsetup/cryptsetup-generator.c',
1938 include_directories : includes,
1939 link_with : [libshared],
1940 dependencies : [libcryptsetup],
1941 install_rpath : rootlibexecdir,
1942 install : true,
1943 install_dir : systemgeneratordir)
1944
1945 executable('systemd-veritysetup',
1946 'src/veritysetup/veritysetup.c',
1947 include_directories : includes,
1948 link_with : [libshared],
1949 dependencies : [libcryptsetup],
1950 install_rpath : rootlibexecdir,
1951 install : true,
1952 install_dir : rootlibexecdir)
1953
1954 executable('systemd-veritysetup-generator',
1955 'src/veritysetup/veritysetup-generator.c',
1956 include_directories : includes,
1957 link_with : [libshared],
1958 dependencies : [libcryptsetup],
1959 install_rpath : rootlibexecdir,
1960 install : true,
1961 install_dir : systemgeneratordir)
5c23128d
ZJS
1962endif
1963
349cc4a5 1964if conf.get('HAVE_SYSV_COMPAT') == 1
37efbbd8
ZJS
1965 executable('systemd-sysv-generator',
1966 'src/sysv-generator/sysv-generator.c',
1967 include_directories : includes,
1968 link_with : [libshared],
1969 install_rpath : rootlibexecdir,
1970 install : true,
1971 install_dir : systemgeneratordir)
1972
1973 executable('systemd-rc-local-generator',
1974 'src/rc-local-generator/rc-local-generator.c',
1975 include_directories : includes,
1976 link_with : [libshared],
1977 install_rpath : rootlibexecdir,
1978 install : true,
1979 install_dir : systemgeneratordir)
5c23128d
ZJS
1980endif
1981
349cc4a5 1982if conf.get('ENABLE_HOSTNAMED') == 1
37efbbd8
ZJS
1983 executable('systemd-hostnamed',
1984 'src/hostname/hostnamed.c',
005a29f2 1985 include_directories : includes,
aac26058 1986 link_with : [libshared],
005a29f2 1987 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1988 install : true,
1989 install_dir : rootlibexecdir)
1990
1991 exe = executable('hostnamectl',
1992 'src/hostname/hostnamectl.c',
1993 include_directories : includes,
1994 link_with : [libshared],
1995 install_rpath : rootlibexecdir,
1996 install : true)
5a8b1640 1997 public_programs += exe
5c23128d
ZJS
1998endif
1999
349cc4a5
ZJS
2000if conf.get('ENABLE_LOCALED') == 1
2001 if conf.get('HAVE_XKBCOMMON') == 1
37efbbd8
ZJS
2002 # logind will load libxkbcommon.so dynamically on its own
2003 deps = [libdl]
2004 else
2005 deps = []
2006 endif
2007
2008 executable('systemd-localed',
2009 systemd_localed_sources,
005a29f2 2010 include_directories : includes,
aac26058 2011 link_with : [libshared],
37efbbd8 2012 dependencies : deps,
005a29f2 2013 install_rpath : rootlibexecdir,
37efbbd8
ZJS
2014 install : true,
2015 install_dir : rootlibexecdir)
2016
2017 exe = executable('localectl',
2018 localectl_sources,
2019 include_directories : includes,
2020 link_with : [libshared],
2021 install_rpath : rootlibexecdir,
2022 install : true)
5a8b1640 2023 public_programs += exe
5c23128d
ZJS
2024endif
2025
349cc4a5 2026if conf.get('ENABLE_TIMEDATED') == 1
37efbbd8
ZJS
2027 executable('systemd-timedated',
2028 'src/timedate/timedated.c',
005a29f2 2029 include_directories : includes,
aac26058 2030 link_with : [libshared],
37efbbd8
ZJS
2031 install_rpath : rootlibexecdir,
2032 install : true,
2033 install_dir : rootlibexecdir)
6129ec85 2034endif
5c23128d 2035
6129ec85 2036if conf.get('ENABLE_TIMEDATECTL') == 1
37efbbd8
ZJS
2037 exe = executable('timedatectl',
2038 'src/timedate/timedatectl.c',
2039 include_directories : includes,
2040 install_rpath : rootlibexecdir,
2041 link_with : [libshared],
6129ec85 2042 dependencies : [libm],
37efbbd8 2043 install : true)
5a8b1640 2044 public_programs += exe
5c23128d
ZJS
2045endif
2046
349cc4a5 2047if conf.get('ENABLE_TIMESYNCD') == 1
37efbbd8
ZJS
2048 executable('systemd-timesyncd',
2049 systemd_timesyncd_sources,
005a29f2 2050 include_directories : includes,
aac26058 2051 link_with : [libshared],
005a29f2 2052 dependencies : [threads,
37efbbd8 2053 libm],
005a29f2
ZJS
2054 install_rpath : rootlibexecdir,
2055 install : true,
37efbbd8 2056 install_dir : rootlibexecdir)
5c3376ef
PB
2057
2058 executable('systemd-time-wait-sync',
2059 'src/time-wait-sync/time-wait-sync.c',
2060 include_directories : includes,
2061 link_with : [libshared],
2062 install_rpath : rootlibexecdir,
2063 install : true,
2064 install_dir : rootlibexecdir)
5c23128d
ZJS
2065endif
2066
349cc4a5 2067if conf.get('ENABLE_MACHINED') == 1
37efbbd8
ZJS
2068 executable('systemd-machined',
2069 systemd_machined_sources,
2070 include_directories : includes,
2071 link_with : [libmachine_core,
2072 libshared],
2073 install_rpath : rootlibexecdir,
2074 install : true,
2075 install_dir : rootlibexecdir)
2076
2077 exe = executable('machinectl',
2078 'src/machine/machinectl.c',
2079 include_directories : includes,
2080 link_with : [libshared],
2081 dependencies : [threads,
2082 libxz,
2083 liblz4],
2084 install_rpath : rootlibexecdir,
2085 install : true,
2086 install_dir : rootbindir)
5a8b1640 2087 public_programs += exe
5c23128d
ZJS
2088endif
2089
349cc4a5 2090if conf.get('ENABLE_IMPORTD') == 1
37efbbd8
ZJS
2091 executable('systemd-importd',
2092 systemd_importd_sources,
005a29f2 2093 include_directories : includes,
aac26058 2094 link_with : [libshared],
37efbbd8 2095 dependencies : [threads],
005a29f2
ZJS
2096 install_rpath : rootlibexecdir,
2097 install : true,
2098 install_dir : rootlibexecdir)
37efbbd8
ZJS
2099
2100 systemd_pull = executable('systemd-pull',
2101 systemd_pull_sources,
2102 include_directories : includes,
2103 link_with : [libshared],
2104 dependencies : [libcurl,
2105 libz,
2106 libbzip2,
2107 libxz,
2108 libgcrypt],
2109 install_rpath : rootlibexecdir,
2110 install : true,
2111 install_dir : rootlibexecdir)
2112
2113 systemd_import = executable('systemd-import',
2114 systemd_import_sources,
2115 include_directories : includes,
2116 link_with : [libshared],
2117 dependencies : [libcurl,
2118 libz,
2119 libbzip2,
2120 libxz],
2121 install_rpath : rootlibexecdir,
2122 install : true,
2123 install_dir : rootlibexecdir)
2124
2125 systemd_export = executable('systemd-export',
2126 systemd_export_sources,
2127 include_directories : includes,
2128 link_with : [libshared],
2129 dependencies : [libcurl,
2130 libz,
2131 libbzip2,
2132 libxz],
2133 install_rpath : rootlibexecdir,
2134 install : true,
2135 install_dir : rootlibexecdir)
2136 public_programs += [systemd_pull, systemd_import, systemd_export]
2137endif
2138
349cc4a5 2139if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
37efbbd8
ZJS
2140 exe = executable('systemd-journal-upload',
2141 systemd_journal_upload_sources,
2142 include_directories : includes,
2143 link_with : [libshared],
2144 dependencies : [threads,
2145 libcurl,
2146 libgnutls,
2147 libxz,
2148 liblz4],
2149 install_rpath : rootlibexecdir,
2150 install : true,
2151 install_dir : rootlibexecdir)
5a8b1640 2152 public_programs += exe
5c23128d
ZJS
2153endif
2154
349cc4a5 2155if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
37efbbd8
ZJS
2156 s_j_remote = executable('systemd-journal-remote',
2157 systemd_journal_remote_sources,
2158 include_directories : includes,
c064d8db
ZJS
2159 link_with : [libshared,
2160 libsystemd_journal_remote],
37efbbd8
ZJS
2161 dependencies : [threads,
2162 libmicrohttpd,
2163 libgnutls,
2164 libxz,
2165 liblz4],
2166 install_rpath : rootlibexecdir,
2167 install : true,
2168 install_dir : rootlibexecdir)
2169
2170 s_j_gatewayd = executable('systemd-journal-gatewayd',
2171 systemd_journal_gatewayd_sources,
2172 include_directories : includes,
2173 link_with : [libshared],
2174 dependencies : [threads,
2175 libmicrohttpd,
2176 libgnutls,
2177 libxz,
2178 liblz4],
2179 install_rpath : rootlibexecdir,
2180 install : true,
2181 install_dir : rootlibexecdir)
2182 public_programs += [s_j_remote, s_j_gatewayd]
5c23128d
ZJS
2183endif
2184
349cc4a5 2185if conf.get('ENABLE_COREDUMP') == 1
37efbbd8
ZJS
2186 executable('systemd-coredump',
2187 systemd_coredump_sources,
005a29f2 2188 include_directories : includes,
aac26058 2189 link_with : [libshared],
005a29f2 2190 dependencies : [threads,
37efbbd8
ZJS
2191 libacl,
2192 libdw,
005a29f2
ZJS
2193 libxz,
2194 liblz4],
2195 install_rpath : rootlibexecdir,
37efbbd8
ZJS
2196 install : true,
2197 install_dir : rootlibexecdir)
2198
2199 exe = executable('coredumpctl',
2200 coredumpctl_sources,
2201 include_directories : includes,
2202 link_with : [libshared],
2203 dependencies : [threads,
2204 libxz,
2205 liblz4],
2206 install_rpath : rootlibexecdir,
2207 install : true)
5a8b1640 2208 public_programs += exe
5c23128d
ZJS
2209endif
2210
349cc4a5 2211if conf.get('ENABLE_BINFMT') == 1
37efbbd8
ZJS
2212 exe = executable('systemd-binfmt',
2213 'src/binfmt/binfmt.c',
2214 include_directories : includes,
2215 link_with : [libshared],
2216 install_rpath : rootlibexecdir,
2217 install : true,
2218 install_dir : rootlibexecdir)
5a8b1640 2219 public_programs += exe
37efbbd8
ZJS
2220
2221 meson.add_install_script('sh', '-c',
2222 mkdir_p.format(binfmtdir))
2223 meson.add_install_script('sh', '-c',
2224 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2225endif
2226
349cc4a5 2227if conf.get('ENABLE_VCONSOLE') == 1
37efbbd8
ZJS
2228 executable('systemd-vconsole-setup',
2229 'src/vconsole/vconsole-setup.c',
005a29f2
ZJS
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_RANDOMSEED') == 1
37efbbd8
ZJS
2238 executable('systemd-random-seed',
2239 'src/random-seed/random-seed.c',
2240 include_directories : includes,
2241 link_with : [libshared],
2242 install_rpath : rootlibexecdir,
2243 install : true,
2244 install_dir : rootlibexecdir)
5c23128d
ZJS
2245endif
2246
349cc4a5 2247if conf.get('ENABLE_FIRSTBOOT') == 1
37efbbd8
ZJS
2248 executable('systemd-firstboot',
2249 'src/firstboot/firstboot.c',
2250 include_directories : includes,
2251 link_with : [libshared],
2252 dependencies : [libcrypt],
2253 install_rpath : rootlibexecdir,
2254 install : true,
2255 install_dir : rootbindir)
5c23128d
ZJS
2256endif
2257
2258executable('systemd-remount-fs',
2259 'src/remount-fs/remount-fs.c',
2260 'src/core/mount-setup.c',
2261 'src/core/mount-setup.h',
2262 include_directories : includes,
2263 link_with : [libshared],
b2fc5836 2264 install_rpath : rootlibexecdir,
5c23128d
ZJS
2265 install : true,
2266 install_dir : rootlibexecdir)
2267
2268executable('systemd-machine-id-setup',
2269 'src/machine-id-setup/machine-id-setup-main.c',
2270 'src/core/machine-id-setup.c',
2271 'src/core/machine-id-setup.h',
2272 include_directories : includes,
aac26058 2273 link_with : [libshared],
b2fc5836 2274 install_rpath : rootlibexecdir,
5c23128d
ZJS
2275 install : true,
2276 install_dir : rootbindir)
2277
2278executable('systemd-fsck',
2279 'src/fsck/fsck.c',
2280 include_directories : includes,
aac26058 2281 link_with : [libshared],
421f0012 2282 install_rpath : rootlibexecdir,
5c23128d
ZJS
2283 install : true,
2284 install_dir : rootlibexecdir)
2285
80750adb
ZJS
2286executable('systemd-growfs',
2287 'src/partition/growfs.c',
2288 include_directories : includes,
2289 link_with : [libshared],
c34b75a1 2290 dependencies : [libcryptsetup],
80750adb
ZJS
2291 install_rpath : rootlibexecdir,
2292 install : true,
2293 install_dir : rootlibexecdir)
2294
b7f28ac5
ZJS
2295executable('systemd-makefs',
2296 'src/partition/makefs.c',
2297 include_directories : includes,
2298 link_with : [libshared],
2299 install_rpath : rootlibexecdir,
2300 install : true,
2301 install_dir : rootlibexecdir)
2302
5c23128d
ZJS
2303executable('systemd-sleep',
2304 'src/sleep/sleep.c',
2305 include_directories : includes,
2306 link_with : [libshared],
421f0012 2307 install_rpath : rootlibexecdir,
5c23128d
ZJS
2308 install : true,
2309 install_dir : rootlibexecdir)
2310
005a29f2
ZJS
2311exe = executable('systemd-sysctl',
2312 'src/sysctl/sysctl.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootlibexecdir,
2316 install : true,
2317 install_dir : rootlibexecdir)
5a8b1640 2318public_programs += exe
5c23128d
ZJS
2319
2320executable('systemd-ac-power',
2321 'src/ac-power/ac-power.c',
2322 include_directories : includes,
2323 link_with : [libshared],
421f0012 2324 install_rpath : rootlibexecdir,
5c23128d
ZJS
2325 install : true,
2326 install_dir : rootlibexecdir)
2327
005a29f2
ZJS
2328exe = executable('systemd-detect-virt',
2329 'src/detect-virt/detect-virt.c',
2330 include_directories : includes,
2331 link_with : [libshared],
2332 install_rpath : rootlibexecdir,
2333 install : true)
5a8b1640 2334public_programs += exe
005a29f2
ZJS
2335
2336exe = executable('systemd-delta',
2337 'src/delta/delta.c',
2338 include_directories : includes,
2339 link_with : [libshared],
2340 install_rpath : rootlibexecdir,
2341 install : true)
5a8b1640 2342public_programs += exe
005a29f2
ZJS
2343
2344exe = executable('systemd-escape',
2345 'src/escape/escape.c',
2346 include_directories : includes,
2347 link_with : [libshared],
2348 install_rpath : rootlibexecdir,
2349 install : true,
2350 install_dir : rootbindir)
5a8b1640 2351public_programs += exe
005a29f2
ZJS
2352
2353exe = executable('systemd-notify',
2354 'src/notify/notify.c',
2355 include_directories : includes,
2356 link_with : [libshared],
2357 install_rpath : rootlibexecdir,
2358 install : true,
2359 install_dir : rootbindir)
5a8b1640 2360public_programs += exe
5c23128d
ZJS
2361
2362executable('systemd-volatile-root',
2363 'src/volatile-root/volatile-root.c',
2364 include_directories : includes,
2365 link_with : [libshared],
421f0012 2366 install_rpath : rootlibexecdir,
5c23128d
ZJS
2367 install : true,
2368 install_dir : rootlibexecdir)
2369
2370executable('systemd-cgroups-agent',
2371 'src/cgroups-agent/cgroups-agent.c',
2372 include_directories : includes,
2373 link_with : [libshared],
421f0012 2374 install_rpath : rootlibexecdir,
5c23128d
ZJS
2375 install : true,
2376 install_dir : rootlibexecdir)
2377
0d1d512f
ZJS
2378exe = executable('systemd-id128',
2379 'src/id128/id128.c',
2380 include_directories : includes,
2381 link_with : [libshared],
2382 install_rpath : rootlibexecdir,
2383 install : true)
2384public_programs += exe
2385
005a29f2
ZJS
2386exe = executable('systemd-path',
2387 'src/path/path.c',
2388 include_directories : includes,
aac26058 2389 link_with : [libshared],
005a29f2
ZJS
2390 install_rpath : rootlibexecdir,
2391 install : true)
5a8b1640 2392public_programs += exe
005a29f2
ZJS
2393
2394exe = executable('systemd-ask-password',
2395 'src/ask-password/ask-password.c',
2396 include_directories : includes,
aac26058 2397 link_with : [libshared],
005a29f2
ZJS
2398 install_rpath : rootlibexecdir,
2399 install : true,
2400 install_dir : rootbindir)
5a8b1640 2401public_programs += exe
5c23128d
ZJS
2402
2403executable('systemd-reply-password',
2404 'src/reply-password/reply-password.c',
2405 include_directories : includes,
aac26058 2406 link_with : [libshared],
421f0012 2407 install_rpath : rootlibexecdir,
5c23128d
ZJS
2408 install : true,
2409 install_dir : rootlibexecdir)
2410
005a29f2
ZJS
2411exe = executable('systemd-tty-ask-password-agent',
2412 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2413 include_directories : includes,
aac26058 2414 link_with : [libshared],
005a29f2
ZJS
2415 install_rpath : rootlibexecdir,
2416 install : true,
2417 install_dir : rootbindir)
5a8b1640 2418public_programs += exe
005a29f2
ZJS
2419
2420exe = executable('systemd-cgls',
2421 'src/cgls/cgls.c',
2422 include_directories : includes,
aac26058 2423 link_with : [libshared],
005a29f2
ZJS
2424 install_rpath : rootlibexecdir,
2425 install : true)
5a8b1640 2426public_programs += exe
005a29f2
ZJS
2427
2428exe = executable('systemd-cgtop',
2429 'src/cgtop/cgtop.c',
2430 include_directories : includes,
aac26058 2431 link_with : [libshared],
005a29f2
ZJS
2432 install_rpath : rootlibexecdir,
2433 install : true)
5a8b1640 2434public_programs += exe
5c23128d
ZJS
2435
2436executable('systemd-initctl',
2437 'src/initctl/initctl.c',
2438 include_directories : includes,
aac26058 2439 link_with : [libshared],
421f0012 2440 install_rpath : rootlibexecdir,
5c23128d
ZJS
2441 install : true,
2442 install_dir : rootlibexecdir)
2443
005a29f2
ZJS
2444exe = executable('systemd-mount',
2445 'src/mount/mount-tool.c',
2446 include_directories : includes,
34ce0a52 2447 link_with : [libshared],
005a29f2
ZJS
2448 install_rpath : rootlibexecdir,
2449 install : true)
5a8b1640 2450public_programs += exe
5c23128d 2451
7b76fce1 2452meson.add_install_script(meson_make_symlink,
e17e5ba9 2453 'systemd-mount', join_paths(bindir, 'systemd-umount'))
7b76fce1 2454
005a29f2
ZJS
2455exe = executable('systemd-run',
2456 'src/run/run.c',
2457 include_directories : includes,
aac26058 2458 link_with : [libshared],
005a29f2
ZJS
2459 install_rpath : rootlibexecdir,
2460 install : true)
5a8b1640 2461public_programs += exe
005a29f2
ZJS
2462
2463exe = executable('systemd-stdio-bridge',
2464 'src/stdio-bridge/stdio-bridge.c',
2465 include_directories : includes,
aac26058 2466 link_with : [libshared],
005a29f2
ZJS
2467 install_rpath : rootlibexecdir,
2468 install : true)
5a8b1640 2469public_programs += exe
005a29f2
ZJS
2470
2471exe = executable('busctl',
2472 'src/busctl/busctl.c',
2473 'src/busctl/busctl-introspect.c',
2474 'src/busctl/busctl-introspect.h',
2475 include_directories : includes,
aac26058 2476 link_with : [libshared],
005a29f2
ZJS
2477 install_rpath : rootlibexecdir,
2478 install : true)
5a8b1640 2479public_programs += exe
5c23128d 2480
349cc4a5 2481if conf.get('ENABLE_SYSUSERS') == 1
37efbbd8
ZJS
2482 exe = executable('systemd-sysusers',
2483 'src/sysusers/sysusers.c',
2484 include_directories : includes,
2485 link_with : [libshared],
2486 install_rpath : rootlibexecdir,
2487 install : true,
2488 install_dir : rootbindir)
5a8b1640 2489 public_programs += exe
5c23128d
ZJS
2490endif
2491
349cc4a5 2492if conf.get('ENABLE_TMPFILES') == 1
37efbbd8
ZJS
2493 exe = executable('systemd-tmpfiles',
2494 'src/tmpfiles/tmpfiles.c',
2495 include_directories : includes,
2496 link_with : [libshared],
2497 dependencies : [libacl],
2498 install_rpath : rootlibexecdir,
2499 install : true,
2500 install_dir : rootbindir)
5a8b1640 2501 public_programs += exe
d9daae55 2502
938be089
ZJS
2503 if want_tests != 'false'
2504 test('test-systemd-tmpfiles',
2505 test_systemd_tmpfiles_py,
2506 # https://github.com/mesonbuild/meson/issues/2681
2507 args : exe.full_path())
2508 endif
5c23128d
ZJS
2509endif
2510
349cc4a5 2511if conf.get('ENABLE_HWDB') == 1
37efbbd8
ZJS
2512 exe = executable('systemd-hwdb',
2513 'src/hwdb/hwdb.c',
2514 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2515 include_directories : includes,
0c06b506 2516 link_with : [libudev_static],
0da6f396 2517 install_rpath : udev_rpath,
37efbbd8
ZJS
2518 install : true,
2519 install_dir : rootbindir)
5a8b1640 2520 public_programs += exe
37efbbd8
ZJS
2521endif
2522
349cc4a5 2523if conf.get('ENABLE_QUOTACHECK') == 1
37efbbd8
ZJS
2524 executable('systemd-quotacheck',
2525 'src/quotacheck/quotacheck.c',
005a29f2 2526 include_directories : includes,
aac26058 2527 link_with : [libshared],
005a29f2
ZJS
2528 install_rpath : rootlibexecdir,
2529 install : true,
37efbbd8 2530 install_dir : rootlibexecdir)
5c23128d
ZJS
2531endif
2532
005a29f2
ZJS
2533exe = executable('systemd-socket-proxyd',
2534 'src/socket-proxy/socket-proxyd.c',
2535 include_directories : includes,
aac26058 2536 link_with : [libshared],
005a29f2
ZJS
2537 dependencies : [threads],
2538 install_rpath : rootlibexecdir,
2539 install : true,
2540 install_dir : rootlibexecdir)
5a8b1640 2541public_programs += exe
005a29f2
ZJS
2542
2543exe = executable('systemd-udevd',
2544 systemd_udevd_sources,
2545 include_directories : includes,
c1cd6743 2546 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
005a29f2 2547 link_with : [libudev_core,
005a29f2 2548 libsystemd_network,
0c06b506 2549 libudev_static],
3a30f21f
ZJS
2550 dependencies : [threads,
2551 libkmod,
005a29f2 2552 libidn,
aac26058
ZJS
2553 libacl,
2554 libblkid],
1aec3ed9 2555 install_rpath : udev_rpath,
005a29f2
ZJS
2556 install : true,
2557 install_dir : rootlibexecdir)
5a8b1640 2558public_programs += exe
005a29f2
ZJS
2559
2560exe = executable('udevadm',
2561 udevadm_sources,
c1cd6743 2562 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
005a29f2
ZJS
2563 include_directories : includes,
2564 link_with : [libudev_core,
005a29f2 2565 libsystemd_network,
0c06b506 2566 libudev_static],
3a30f21f
ZJS
2567 dependencies : [threads,
2568 libkmod,
005a29f2 2569 libidn,
aac26058
ZJS
2570 libacl,
2571 libblkid],
1aec3ed9 2572 install_rpath : udev_rpath,
005a29f2
ZJS
2573 install : true,
2574 install_dir : rootbindir)
5a8b1640 2575public_programs += exe
5c23128d
ZJS
2576
2577executable('systemd-shutdown',
2578 systemd_shutdown_sources,
2579 include_directories : includes,
34ce0a52 2580 link_with : [libshared],
95b862b0 2581 dependencies : [libmount],
421f0012 2582 install_rpath : rootlibexecdir,
5c23128d
ZJS
2583 install : true,
2584 install_dir : rootlibexecdir)
2585
2586executable('systemd-update-done',
2587 'src/update-done/update-done.c',
2588 include_directories : includes,
2589 link_with : [libshared],
421f0012 2590 install_rpath : rootlibexecdir,
5c23128d
ZJS
2591 install : true,
2592 install_dir : rootlibexecdir)
2593
2594executable('systemd-update-utmp',
2595 'src/update-utmp/update-utmp.c',
2596 include_directories : includes,
aac26058 2597 link_with : [libshared],
5c23128d 2598 dependencies : [libaudit],
421f0012 2599 install_rpath : rootlibexecdir,
5c23128d
ZJS
2600 install : true,
2601 install_dir : rootlibexecdir)
2602
349cc4a5 2603if conf.get('HAVE_KMOD') == 1
37efbbd8
ZJS
2604 executable('systemd-modules-load',
2605 'src/modules-load/modules-load.c',
2606 include_directories : includes,
2607 link_with : [libshared],
2608 dependencies : [libkmod],
2609 install_rpath : rootlibexecdir,
2610 install : true,
2611 install_dir : rootlibexecdir)
94e75a54 2612
37efbbd8
ZJS
2613 meson.add_install_script('sh', '-c',
2614 mkdir_p.format(modulesloaddir))
2615 meson.add_install_script('sh', '-c',
2616 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
5c23128d
ZJS
2617endif
2618
005a29f2
ZJS
2619exe = executable('systemd-nspawn',
2620 systemd_nspawn_sources,
2621 'src/core/mount-setup.c', # FIXME: use a variable?
2622 'src/core/mount-setup.h',
2623 'src/core/loopback-setup.c',
2624 'src/core/loopback-setup.h',
97d90615
ZJS
2625 include_directories : includes,
2626 link_with : [libnspawn_core,
2627 libshared],
2628 dependencies : [libblkid],
005a29f2
ZJS
2629 install_rpath : rootlibexecdir,
2630 install : true)
5a8b1640 2631public_programs += exe
5c23128d 2632
349cc4a5 2633if conf.get('ENABLE_NETWORKD') == 1
37efbbd8
ZJS
2634 executable('systemd-networkd',
2635 systemd_networkd_sources,
2636 include_directories : includes,
2637 link_with : [libnetworkd_core,
37efbbd8 2638 libsystemd_network,
0c06b506 2639 libudev_static,
37efbbd8 2640 libshared],
4b57a272 2641 dependencies : [threads],
37efbbd8
ZJS
2642 install_rpath : rootlibexecdir,
2643 install : true,
2644 install_dir : rootlibexecdir)
2645
2646 executable('systemd-networkd-wait-online',
2647 systemd_networkd_wait_online_sources,
2648 include_directories : includes,
2649 link_with : [libnetworkd_core,
2650 libshared],
2651 install_rpath : rootlibexecdir,
2652 install : true,
2653 install_dir : rootlibexecdir)
5c23128d 2654
dcfe072a
FS
2655 exe = executable('networkctl',
2656 networkctl_sources,
2657 include_directories : includes,
2658 link_with : [libsystemd_network,
aac26058 2659 libshared],
dcfe072a
FS
2660 install_rpath : rootlibexecdir,
2661 install : true,
2662 install_dir : rootbindir)
5a8b1640 2663 public_programs += exe
dcfe072a 2664endif
e821f6a9
ZJS
2665
2666executable('systemd-sulogin-shell',
2667 ['src/sulogin-shell/sulogin-shell.c'],
2668 include_directories : includes,
2669 link_with : [libshared],
2670 install_rpath : rootlibexecdir,
2671 install : true,
2672 install_dir : rootlibexecdir)
2673
69e96427
ZJS
2674############################################################
2675
e2d41370
FB
2676custom_target(
2677 'systemd-runtest.env',
2678 output : 'systemd-runtest.env',
2679 command : ['sh', '-c', '{ ' +
2680 'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(meson.current_source_dir(), 'test')) +
49cdae63 2681 'echo SYSTEMD_CATALOG_DIR=@0@; '.format(join_paths(meson.current_build_dir(), 'catalog')) +
e2d41370
FB
2682 '} >@OUTPUT@'],
2683 build_by_default : true)
2684
69e96427 2685foreach tuple : tests
37efbbd8
ZJS
2686 sources = tuple[0]
2687 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2688 dependencies = tuple[2]
2689 condition = tuple.length() >= 4 ? tuple[3] : ''
2690 type = tuple.length() >= 5 ? tuple[4] : ''
2691 defs = tuple.length() >= 6 ? tuple[5] : []
2692 incs = tuple.length() >= 7 ? tuple[6] : includes
2693 timeout = 30
2694
2695 name = sources[0].split('/')[-1].split('.')[0]
2696 if type.startswith('timeout=')
2697 timeout = type.split('=')[1].to_int()
2698 type = ''
2699 endif
3b2bdd62
ZJS
2700
2701 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
2702 exe = executable(
2703 name,
2704 sources,
2705 include_directories : incs,
2706 link_with : link_with,
2707 dependencies : dependencies,
2708 c_args : defs,
3b2bdd62 2709 build_by_default : want_tests != 'false',
37efbbd8 2710 install_rpath : rootlibexecdir,
7cdd9783
MB
2711 install : install_tests,
2712 install_dir : join_paths(testsdir, type))
37efbbd8
ZJS
2713
2714 if type == 'manual'
2715 message('@0@ is a manual test'.format(name))
2716 elif type == 'unsafe' and want_tests != 'unsafe'
2717 message('@0@ is an unsafe test'.format(name))
3b2bdd62 2718 elif want_tests != 'false'
37efbbd8
ZJS
2719 test(name, exe,
2720 env : test_env,
2721 timeout : timeout)
2722 endif
2723 else
2724 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2725 endif
69e96427
ZJS
2726endforeach
2727
0632b4cd 2728exe = executable(
37efbbd8
ZJS
2729 'test-libsystemd-sym',
2730 test_libsystemd_sym_c,
2731 include_directories : includes,
2732 link_with : [libsystemd],
fd1939fb 2733 build_by_default : want_tests != 'false',
37efbbd8
ZJS
2734 install : install_tests,
2735 install_dir : testsdir)
938be089
ZJS
2736if want_tests != 'false'
2737 test('test-libsystemd-sym', exe)
2738endif
37ab1a25 2739
0632b4cd
ZJS
2740exe = executable(
2741 'test-libsystemd-static-sym',
2742 test_libsystemd_sym_c,
2743 include_directories : includes,
0632b4cd
ZJS
2744 link_with : [install_libsystemd_static],
2745 dependencies : [threads], # threads is already included in dependencies on the library,
2746 # but does not seem to get propagated. Add here as a work-around.
fd1939fb 2747 build_by_default : want_tests != 'false' and static_libsystemd_pic,
20f3d32d 2748 install : install_tests and static_libsystemd_pic,
0632b4cd 2749 install_dir : testsdir)
938be089 2750if want_tests != 'false' and static_libsystemd_pic
0632b4cd
ZJS
2751 test('test-libsystemd-static-sym', exe)
2752endif
37ab1a25 2753
0632b4cd 2754exe = executable(
37efbbd8
ZJS
2755 'test-libudev-sym',
2756 test_libudev_sym_c,
2757 include_directories : includes,
c1cd6743 2758 c_args : '-Wno-deprecated-declarations',
37efbbd8 2759 link_with : [libudev],
fd1939fb 2760 build_by_default : want_tests != 'false',
37efbbd8
ZJS
2761 install : install_tests,
2762 install_dir : testsdir)
938be089
ZJS
2763if want_tests != 'false'
2764 test('test-libudev-sym', exe)
2765endif
0632b4cd
ZJS
2766
2767exe = executable(
2768 'test-libudev-static-sym',
2769 test_libudev_sym_c,
2770 include_directories : includes,
c1cd6743 2771 c_args : '-Wno-deprecated-declarations',
0632b4cd 2772 link_with : [install_libudev_static],
fd1939fb 2773 build_by_default : want_tests != 'false' and static_libudev_pic,
20f3d32d 2774 install : install_tests and static_libudev_pic,
0632b4cd 2775 install_dir : testsdir)
938be089 2776if want_tests != 'false' and static_libudev_pic
0632b4cd
ZJS
2777 test('test-libudev-static-sym', exe)
2778endif
e0bec52f 2779
69e96427 2780############################################################
5c23128d 2781
7db7d5b7
JR
2782fuzzer_exes = []
2783
5996740a 2784if get_option('tests') != 'false'
7db7d5b7
JR
2785foreach tuple : fuzzers
2786 sources = tuple[0]
2787 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2788 dependencies = tuple[2]
2789 defs = tuple.length() >= 4 ? tuple[3] : []
2790 incs = tuple.length() >= 5 ? tuple[4] : includes
2791
31e57a35 2792 if fuzzer_build
7db7d5b7
JR
2793 dependencies += fuzzing_engine
2794 else
2795 sources += 'src/fuzz/fuzz-main.c'
2796 endif
2797
2798 name = sources[0].split('/')[-1].split('.')[0]
2799
2800 fuzzer_exes += executable(
2801 name,
2802 sources,
2803 include_directories : [incs, include_directories('src/fuzz')],
2804 link_with : link_with,
2805 dependencies : dependencies,
2806 c_args : defs,
2807 install : false)
2808endforeach
5996740a 2809endif
7db7d5b7
JR
2810
2811run_target('fuzzers',
2812 depends : fuzzer_exes,
2813 command : ['true'])
2814
2815############################################################
2816
5c23128d
ZJS
2817make_directive_index_py = find_program('tools/make-directive-index.py')
2818make_man_index_py = find_program('tools/make-man-index.py')
b184e8fe 2819xml_helper_py = find_program('tools/xml_helper.py')
abba22c5 2820hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
5c23128d
ZJS
2821
2822subdir('units')
2823subdir('sysctl.d')
2824subdir('sysusers.d')
2825subdir('tmpfiles.d')
e783f957 2826subdir('presets')
5c23128d
ZJS
2827subdir('hwdb')
2828subdir('network')
2829subdir('man')
2830subdir('shell-completion/bash')
2831subdir('shell-completion/zsh')
9e825ebf
FB
2832subdir('docs/sysvinit')
2833subdir('docs/var-log')
5c23128d 2834
5c23128d
ZJS
2835install_subdir('factory/etc',
2836 install_dir : factorydir)
2837
5c23128d
ZJS
2838install_data('xorg/50-systemd-user.sh',
2839 install_dir : xinitrcdir)
582faeb4
DJL
2840install_data('modprobe.d/systemd.conf',
2841 install_dir : modprobedir)
f09eb768 2842install_data('LICENSE.GPL2',
5c23128d 2843 'LICENSE.LGPL2.1',
f09eb768
LP
2844 'NEWS',
2845 'README',
eea98402 2846 'docs/CODING_STYLE.md',
1d1cb168 2847 'docs/DISTRO_PORTING.md',
9e825ebf 2848 'docs/ENVIRONMENT.md',
eea98402 2849 'docs/HACKING.md',
9e825ebf 2850 'docs/TRANSIENT-SETTINGS.md',
b6dc0d7d 2851 'docs/TRANSLATORS.md',
9e825ebf 2852 'docs/UIDS-GIDS.md',
5c23128d
ZJS
2853 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2854 install_dir : docdir)
d68b342b 2855
94e75a54
ZJS
2856meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2857meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2858
d68b342b
ZJS
2859############################################################
2860
005a29f2
ZJS
2861meson_check_help = find_program('tools/meson-check-help.sh')
2862
2863foreach exec : public_programs
37efbbd8 2864 name = exec.full_path().split('/')[-1]
938be089
ZJS
2865 if want_tests != 'false'
2866 test('check-help-' + name,
2867 meson_check_help,
c1cd6743 2868 args : exec.full_path())
938be089 2869 endif
005a29f2
ZJS
2870endforeach
2871
2872############################################################
2873
52d4d1d3
ZJS
2874# Enable tests for all supported sanitizers
2875foreach tuple : sanitizers
2876 sanitizer = tuple[0]
2877 build = tuple[1]
b68dfb9e 2878
7a6397d2 2879 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
52d4d1d3
ZJS
2880 prev = ''
2881 foreach p : fuzz_regression_tests
2882 b = p.split('/')[-2]
2883 c = p.split('/')[-1]
2884
2885 name = '@0@:@1@'.format(b, sanitizer)
2886
2887 if name != prev
2888 if want_tests == 'false'
2889 message('Not compiling @0@ because tests is set to false'.format(name))
2890 elif slow_tests
2891 exe = custom_target(
2892 name,
2893 output : name,
2894 depends : build,
2895 command : [env, 'ln', '-fs',
2896 join_paths(build.full_path(), b),
2897 '@OUTPUT@'],
2898 build_by_default : true)
2899 else
2900 message('Not compiling @0@ because slow-tests is set to false'.format(name))
2901 endif
2902 endif
2903 prev = name
2904
2905 if want_tests != 'false' and slow_tests
2906 test('@0@:@1@:@2@'.format(b, c, sanitizer),
2907 env,
2908 args : [exe.full_path(),
e6bad674 2909 join_paths(meson.source_root(), p)])
52d4d1d3
ZJS
2910 endif
2911 endforeach
b68dfb9e
ZJS
2912 endif
2913endforeach
2914
52d4d1d3 2915
b68dfb9e
ZJS
2916############################################################
2917
0700e8ba 2918if git.found()
37efbbd8
ZJS
2919 all_files = run_command(
2920 git,
243e5cec 2921 ['--git-dir=@0@/.git'.format(meson.source_root()),
37efbbd8
ZJS
2922 'ls-files',
2923 ':/*.[ch]'])
2924 all_files = files(all_files.stdout().split())
d68b342b 2925
e85a690b 2926 custom_target(
0700e8ba 2927 'tags',
e85a690b 2928 output : 'tags',
243e5cec 2929 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.source_root())] + all_files)
2f09974f 2930 run_target(
0700e8ba 2931 'ctags',
243e5cec 2932 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.source_root())] + all_files)
d68b342b 2933endif
177929c2
ZJS
2934
2935if git.found()
37efbbd8 2936 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
a923e085 2937 run_target(
37efbbd8 2938 'git-contrib',
37efbbd8 2939 command : [meson_git_contrib_sh])
177929c2 2940endif
dd6ab3df
ZJS
2941
2942if git.found()
2943 git_head = run_command(
2944 git,
243e5cec 2945 ['--git-dir=@0@/.git'.format(meson.source_root()),
dd6ab3df
ZJS
2946 'rev-parse', 'HEAD']).stdout().strip()
2947 git_head_short = run_command(
2948 git,
243e5cec 2949 ['--git-dir=@0@/.git'.format(meson.source_root()),
dd6ab3df
ZJS
2950 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
2951
2952 run_target(
2953 'git-snapshot',
2954 command : ['git', 'archive',
243e5cec 2955 '-o', '@0@/systemd-@1@.tar.gz'.format(meson.source_root(),
dd6ab3df
ZJS
2956 git_head_short),
2957 '--prefix', 'systemd-@0@/'.format(git_head),
2958 'HEAD'])
2959endif
829257d1
ZJS
2960
2961############################################################
2962
51b13863
LP
2963meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
2964run_target(
2965 'check-api-docs',
2966 depends : [man, libsystemd, libudev],
2967 command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
2968
0bc7a22d
LP
2969run_target(
2970 'make-index-md',
2971 command : ['sh', '@0@/tools/make-index-md.sh'.format(meson.source_root()), meson.source_root()])
2972
51b13863
LP
2973############################################################
2974
829257d1
ZJS
2975status = [
2976 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
2977
2675413e 2978 'split /usr: @0@'.format(split_usr),
157baa87 2979 'split bin-sbin: @0@'.format(split_bin),
359b496f
YW
2980 'prefix directory: @0@'.format(prefixdir),
2981 'rootprefix directory: @0@'.format(rootprefixdir),
2982 'sysconf directory: @0@'.format(sysconfdir),
2983 'include directory: @0@'.format(includedir),
2984 'lib directory: @0@'.format(libdir),
2985 'rootlib directory: @0@'.format(rootlibdir),
829257d1
ZJS
2986 'SysV init scripts: @0@'.format(sysvinit_path),
2987 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
359b496f
YW
2988 'PAM modules directory: @0@'.format(pamlibdir),
2989 'PAM configuration directory: @0@'.format(pamconfdir),
2990 'RPM macros directory: @0@'.format(rpmmacrosdir),
2991 'modprobe.d directory: @0@'.format(modprobedir),
2992 'D-Bus policy directory: @0@'.format(dbuspolicydir),
2993 'D-Bus session directory: @0@'.format(dbussessionservicedir),
2994 'D-Bus system directory: @0@'.format(dbussystemservicedir),
2995 'bash completions directory: @0@'.format(bashcompletiondir),
2996 'zsh completions directory: @0@'.format(zshcompletiondir),
829257d1
ZJS
2997 'extra start script: @0@'.format(get_option('rc-local')),
2998 'extra stop script: @0@'.format(get_option('halt-local')),
2999 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
3000 get_option('debug-tty')),
3001 'TTY GID: @0@'.format(tty_gid),
ac09340e 3002 'users GID: @0@'.format(substs.get('USERS_GID')),
829257d1
ZJS
3003 'maximum system UID: @0@'.format(system_uid_max),
3004 'maximum system GID: @0@'.format(system_gid_max),
87d5e4f2
LP
3005 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
3006 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
3007 'minimum container UID base: @0@'.format(container_uid_base_min),
3008 'maximum container UID base: @0@'.format(container_uid_base_max),
829257d1 3009 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
4e15a734 3010 'render group access mode: @0@'.format(get_option('group-render-mode')),
359b496f 3011 'certificate root directory: @0@'.format(get_option('certificate-root')),
829257d1 3012 'support URL: @0@'.format(support_url),
afde4574
LP
3013 'nobody user name: @0@'.format(nobody_user),
3014 'nobody group name: @0@'.format(nobody_group),
829257d1 3015 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
5248e7e1 3016 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
829257d1
ZJS
3017
3018 'default DNSSEC mode: @0@'.format(default_dnssec),
c9299be2 3019 'default DNS-over-TLS mode: @0@'.format(default_dns_over_tls),
829257d1
ZJS
3020 'default cgroup hierarchy: @0@'.format(default_hierarchy),
3021 'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
3022
3023alt_dns_servers = '\n '.join(dns_servers.split(' '))
3024alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
3025status += [
3026 'default DNS servers: @0@'.format(alt_dns_servers),
3027 'default NTP servers: @0@'.format(alt_ntp_servers)]
3028
3029alt_time_epoch = run_command('date', '-Is', '-u', '-d',
3030 '@@0@'.format(time_epoch)).stdout().strip()
3031status += [
3032 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
3033
19d8c9c9 3034status += [
abc8caf7
ZJS
3035 'static libsystemd: @0@'.format(static_libsystemd),
3036 'static libudev: @0@'.format(static_libudev)]
19d8c9c9 3037
829257d1
ZJS
3038# TODO:
3039# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
3040# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
3041# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
3042
349cc4a5 3043if conf.get('ENABLE_EFI') == 1
5a8b1640 3044 status += 'efi arch: @0@'.format(efi_arch)
829257d1
ZJS
3045
3046 if have_gnu_efi
3047 status += [
3048 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
3049 'EFI CC @0@'.format(efi_cc),
359b496f
YW
3050 'EFI lib directory: @0@'.format(efi_libdir),
3051 'EFI lds directory: @0@'.format(efi_ldsdir),
3052 'EFI include directory: @0@'.format(efi_incdir)]
829257d1
ZJS
3053 endif
3054endif
3055
3056found = []
3057missing = []
3058
3059foreach tuple : [
3060 ['libcryptsetup'],
3061 ['PAM'],
3062 ['AUDIT'],
3063 ['IMA'],
3064 ['AppArmor'],
3065 ['SELinux'],
3066 ['SECCOMP'],
3067 ['SMACK'],
3068 ['zlib'],
3069 ['xz'],
3070 ['lz4'],
3071 ['bzip2'],
3072 ['ACL'],
3073 ['gcrypt'],
3074 ['qrencode'],
3075 ['microhttpd'],
3076 ['gnutls'],
096cbdce 3077 ['openssl'],
829257d1 3078 ['libcurl'],
d1bf5675 3079 ['idn'],
87057e24 3080 ['libidn2'],
829257d1
ZJS
3081 ['libidn'],
3082 ['libiptc'],
3083 ['elfutils'],
3084 ['binfmt'],
3085 ['vconsole'],
3086 ['quotacheck'],
3087 ['tmpfiles'],
3088 ['environment.d'],
3089 ['sysusers'],
3090 ['firstboot'],
3091 ['randomseed'],
3092 ['backlight'],
3093 ['rfkill'],
3094 ['logind'],
3095 ['machined'],
61d0578b 3096 ['portabled'],
829257d1
ZJS
3097 ['importd'],
3098 ['hostnamed'],
3099 ['timedated'],
3100 ['timesyncd'],
3101 ['localed'],
3102 ['networkd'],
a7456af5 3103 ['resolve'],
096cbdce
IT
3104 ['DNS-over-TLS(gnutls)', conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1],
3105 ['DNS-over-TLS(openssl)', conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1],
829257d1
ZJS
3106 ['coredump'],
3107 ['polkit'],
3108 ['legacy pkla', install_polkit_pkla],
3109 ['efi'],
3110 ['gnu-efi', have_gnu_efi],
3111 ['kmod'],
3112 ['xkbcommon'],
c4c978a0 3113 ['pcre2'],
829257d1
ZJS
3114 ['blkid'],
3115 ['dbus'],
3116 ['glib'],
6bd2bc8e
ZJS
3117 ['nss-myhostname'],
3118 ['nss-mymachines'],
3119 ['nss-resolve'],
3120 ['nss-systemd'],
829257d1
ZJS
3121 ['hwdb'],
3122 ['tpm'],
3123 ['man pages', want_man],
3124 ['html pages', want_html],
3125 ['man page indices', want_man and have_lxml],
829257d1
ZJS
3126 ['SysV compat'],
3127 ['utmp'],
3128 ['ldconfig'],
3129 ['hibernate'],
3130 ['adm group', get_option('adm-group')],
3131 ['wheel group', get_option('wheel-group')],
b14e1b43 3132 ['gshadow'],
829257d1
ZJS
3133 ['debug hashmap'],
3134 ['debug mmap cache'],
20e97dd3 3135 ['debug udev'],
d18cb393 3136 ['valgrind', conf.get('VALGRIND') == 1],
fd5dec9a 3137 ['trace logging', conf.get('LOG_TRACE') == 1],
19d8c9c9
LP
3138 ['link-udev-shared', get_option('link-udev-shared')],
3139 ['link-systemctl-shared', get_option('link-systemctl-shared')],
829257d1
ZJS
3140]
3141
af4d7860
ZJS
3142 if tuple.length() >= 2
3143 cond = tuple[1]
3144 else
829257d1
ZJS
3145 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3146 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
349cc4a5 3147 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
829257d1
ZJS
3148 endif
3149 if cond
5a8b1640 3150 found += tuple[0]
829257d1 3151 else
5a8b1640 3152 missing += tuple[0]
829257d1
ZJS
3153 endif
3154endforeach
3155
3156status += [
9d39c1bf 3157 '',
829257d1 3158 'enabled features: @0@'.format(', '.join(found)),
9d39c1bf
ZJS
3159 '',
3160 'disabled features: @0@'.format(', '.join(missing)),
3161 '']
829257d1 3162message('\n '.join(status))
9a8e64b0
ZJS
3163
3164if rootprefixdir != rootprefix_default
8ea9fad7
YW
3165 warning('\n' +
3166 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3167 'systemd used fixed names for unit file directories and other paths, so anything\n' +
3168 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
9a8e64b0 3169endif