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