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