]> git.ipfire.org Git - thirdparty/systemd.git/blob - meson.build
bus-message: immediately reject messages with invalid type
[thirdparty/systemd.git] / meson.build
1 # SPDX-License-Identifier: LGPL-2.1+
2
3 project('systemd', 'c',
4 version : '245',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu99',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 'warning_level=2',
12 ],
13 meson_version : '>= 0.46',
14 )
15
16 libsystemd_version = '0.28.0'
17 libudev_version = '1.6.17'
18
19 # We need the same data in two different formats, ugh!
20 # Also, for hysterical reasons, we use different variable
21 # names, sometimes. Not all variables are included in every
22 # set. Ugh, ugh, ugh!
23 conf = configuration_data()
24 conf.set('PROJECT_VERSION', meson.project_version(),
25 description : 'Numerical project version (used where a simple number is expected)')
26
27 substs = configuration_data()
28 substs.set('PROJECT_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
29 substs.set('PROJECT_VERSION', meson.project_version(),
30 description : 'Numerical project version (used where a simple number is expected)')
31
32 # This is to be used instead of meson.source_root(), as the latter will return
33 # the wrong result when systemd is being built as a meson subproject
34 project_source_root = meson.current_source_dir()
35 project_build_root = meson.current_build_dir()
36 relative_source_path = run_command('realpath',
37 '--relative-to=@0@'.format(project_build_root),
38 project_source_root).stdout().strip()
39 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
40
41 want_ossfuzz = get_option('oss-fuzz')
42 want_libfuzzer = get_option('llvm-fuzz')
43 if want_ossfuzz + want_libfuzzer > 1
44 error('only one of oss-fuzz or llvm-fuzz can be specified')
45 endif
46
47 skip_deps = want_ossfuzz or want_libfuzzer
48 fuzzer_build = want_ossfuzz or want_libfuzzer
49
50 #####################################################################
51
52 # Try to install the git pre-commit hook
53 add_git_hook_sh = find_program('tools/add-git-hook.sh', required : false)
54 if add_git_hook_sh.found()
55 git_hook = run_command(add_git_hook_sh)
56 if git_hook.returncode() == 0
57 message(git_hook.stdout().strip())
58 endif
59 endif
60
61 #####################################################################
62
63 if get_option('split-usr') == 'auto'
64 split_usr = run_command('test', '-L', '/bin').returncode() != 0
65 else
66 split_usr = get_option('split-usr') == 'true'
67 endif
68 conf.set10('HAVE_SPLIT_USR', split_usr,
69 description : '/usr/bin and /bin directories are separate')
70
71 if get_option('split-bin') == 'auto'
72 split_bin = run_command('test', '-L', '/usr/sbin').returncode() != 0
73 else
74 split_bin = get_option('split-bin') == 'true'
75 endif
76 conf.set10('HAVE_SPLIT_BIN', split_bin,
77 description : 'bin and sbin directories are separate')
78
79 rootprefixdir = get_option('rootprefix')
80 # Unusual rootprefixdir values are used by some distros
81 # (see https://github.com/systemd/systemd/pull/7461).
82 rootprefix_default = split_usr ? '/' : '/usr'
83 if rootprefixdir == ''
84 rootprefixdir = rootprefix_default
85 endif
86 rootprefixdir_noslash = rootprefixdir == '/' ? '' : rootprefixdir
87
88 sysvinit_path = get_option('sysvinit-path')
89 sysvrcnd_path = get_option('sysvrcnd-path')
90 conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
91 description : 'SysV init scripts and rcN.d links are supported')
92
93 if get_option('hibernate') and not get_option('initrd')
94 error('hibernate depends on initrd')
95 endif
96
97 conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
98 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open'))
99 conf.set('HIGH_RLIMIT_NOFILE', 512*1024)
100
101 # join_paths ignores the preceding arguments if an absolute component is
102 # encountered, so this should canonicalize various paths when they are
103 # absolute or relative.
104 prefixdir = get_option('prefix')
105 if not prefixdir.startswith('/')
106 error('Prefix is not absolute: "@0@"'.format(prefixdir))
107 endif
108 bindir = join_paths(prefixdir, get_option('bindir'))
109 libdir = join_paths(prefixdir, get_option('libdir'))
110 sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
111 includedir = join_paths(prefixdir, get_option('includedir'))
112 datadir = join_paths(prefixdir, get_option('datadir'))
113 localstatedir = join_paths('/', get_option('localstatedir'))
114
115 rootbindir = join_paths(rootprefixdir, 'bin')
116 rootsbindir = join_paths(rootprefixdir, split_bin ? 'sbin' : 'bin')
117 rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
118
119 rootlibdir = get_option('rootlibdir')
120 if rootlibdir == ''
121 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
122 endif
123
124 # Dirs of external packages
125 pkgconfigdatadir = get_option('pkgconfigdatadir') == '' ? join_paths(datadir, 'pkgconfig') : get_option('pkgconfigdatadir')
126 pkgconfiglibdir = get_option('pkgconfiglibdir') == '' ? join_paths(libdir, 'pkgconfig') : get_option('pkgconfiglibdir')
127 polkitpolicydir = join_paths(datadir, 'polkit-1/actions')
128 polkitrulesdir = join_paths(datadir, 'polkit-1/rules.d')
129 polkitpkladir = join_paths(localstatedir, 'lib/polkit-1/localauthority/10-vendor.d')
130 xinitrcdir = join_paths(sysconfdir, 'X11/xinit/xinitrc.d')
131 rpmmacrosdir = get_option('rpmmacrosdir')
132 if rpmmacrosdir != 'no'
133 rpmmacrosdir = join_paths(prefixdir, rpmmacrosdir)
134 endif
135 modprobedir = join_paths(rootprefixdir, 'lib/modprobe.d')
136
137 # Our own paths
138 pkgdatadir = join_paths(datadir, 'systemd')
139 environmentdir = join_paths(prefixdir, 'lib/environment.d')
140 pkgsysconfdir = join_paths(sysconfdir, 'systemd')
141 userunitdir = join_paths(prefixdir, 'lib/systemd/user')
142 userpresetdir = join_paths(prefixdir, 'lib/systemd/user-preset')
143 tmpfilesdir = join_paths(prefixdir, 'lib/tmpfiles.d')
144 sysusersdir = join_paths(prefixdir, 'lib/sysusers.d')
145 sysctldir = join_paths(prefixdir, 'lib/sysctl.d')
146 binfmtdir = join_paths(prefixdir, 'lib/binfmt.d')
147 modulesloaddir = join_paths(prefixdir, 'lib/modules-load.d')
148 networkdir = join_paths(rootprefixdir, 'lib/systemd/network')
149 pkgincludedir = join_paths(includedir, 'systemd')
150 systemgeneratordir = join_paths(rootlibexecdir, 'system-generators')
151 usergeneratordir = join_paths(prefixdir, 'lib/systemd/user-generators')
152 systemenvgeneratordir = join_paths(prefixdir, 'lib/systemd/system-environment-generators')
153 userenvgeneratordir = join_paths(prefixdir, 'lib/systemd/user-environment-generators')
154 systemshutdowndir = join_paths(rootlibexecdir, 'system-shutdown')
155 systemsleepdir = join_paths(rootlibexecdir, 'system-sleep')
156 systemunitdir = join_paths(rootprefixdir, 'lib/systemd/system')
157 systempresetdir = join_paths(rootprefixdir, 'lib/systemd/system-preset')
158 udevlibexecdir = join_paths(rootprefixdir, 'lib/udev')
159 udevrulesdir = join_paths(udevlibexecdir, 'rules.d')
160 udevhwdbdir = join_paths(udevlibexecdir, 'hwdb.d')
161 catalogdir = join_paths(prefixdir, 'lib/systemd/catalog')
162 kernelinstalldir = join_paths(prefixdir, 'lib/kernel/install.d')
163 factorydir = join_paths(datadir, 'factory')
164 bootlibdir = join_paths(prefixdir, 'lib/systemd/boot/efi')
165 testsdir = join_paths(prefixdir, 'lib/systemd/tests')
166 systemdstatedir = join_paths(localstatedir, 'lib/systemd')
167 catalogstatedir = join_paths(systemdstatedir, 'catalog')
168 randomseeddir = join_paths(localstatedir, 'lib/systemd')
169 profiledir = join_paths(rootlibexecdir, 'portable', 'profile')
170 ntpservicelistdir = join_paths(rootprefixdir, 'lib/systemd/ntp-units.d')
171
172 docdir = get_option('docdir')
173 if docdir == ''
174 docdir = join_paths(datadir, 'doc/systemd')
175 endif
176
177 dbuspolicydir = get_option('dbuspolicydir')
178 if dbuspolicydir == ''
179 dbuspolicydir = join_paths(datadir, 'dbus-1/system.d')
180 endif
181
182 dbussessionservicedir = get_option('dbussessionservicedir')
183 if dbussessionservicedir == ''
184 dbussessionservicedir = join_paths(datadir, 'dbus-1/services')
185 endif
186
187 dbussystemservicedir = get_option('dbussystemservicedir')
188 if dbussystemservicedir == ''
189 dbussystemservicedir = join_paths(datadir, 'dbus-1/system-services')
190 endif
191
192 pamlibdir = get_option('pamlibdir')
193 if pamlibdir == ''
194 pamlibdir = join_paths(rootlibdir, 'security')
195 endif
196
197 pamconfdir = get_option('pamconfdir')
198 if pamconfdir == ''
199 pamconfdir = join_paths(sysconfdir, 'pam.d')
200 endif
201
202 memory_accounting_default = get_option('memory-accounting-default')
203 status_unit_format_default = get_option('status-unit-format-default')
204
205 conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
206 conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', join_paths(pkgsysconfdir, 'system'))
207 conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
208 conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
209 conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
210 conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
211
212 conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
213
214 conf.set_quoted('USER_CONFIG_UNIT_DIR', join_paths(pkgsysconfdir, 'user'))
215 conf.set_quoted('USER_DATA_UNIT_DIR', userunitdir)
216 conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
217 conf.set_quoted('CATALOG_DATABASE', join_paths(catalogstatedir, 'database'))
218 conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', join_paths(rootlibexecdir, 'systemd-cgroups-agent'))
219 conf.set_quoted('SYSTEMD_BINARY_PATH', join_paths(rootlibexecdir, 'systemd'))
220 conf.set_quoted('SYSTEMD_FSCK_PATH', join_paths(rootlibexecdir, 'systemd-fsck'))
221 conf.set_quoted('SYSTEMD_MAKEFS_PATH', join_paths(rootlibexecdir, 'systemd-makefs'))
222 conf.set_quoted('SYSTEMD_GROWFS_PATH', join_paths(rootlibexecdir, 'systemd-growfs'))
223 conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlibexecdir, 'systemd-shutdown'))
224 conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
225 conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
226 conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
227 conf.set_quoted('ROOTPREFIX', rootprefixdir)
228 conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
229 conf.set_quoted('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
230 conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', join_paths(rootlibexecdir, 'systemd-cryptsetup'))
231 conf.set_quoted('SYSTEM_GENERATOR_DIR', systemgeneratordir)
232 conf.set_quoted('USER_GENERATOR_DIR', usergeneratordir)
233 conf.set_quoted('SYSTEM_ENV_GENERATOR_DIR', systemenvgeneratordir)
234 conf.set_quoted('USER_ENV_GENERATOR_DIR', userenvgeneratordir)
235 conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
236 conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
237 conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdatadir, 'kbd-model-map'))
238 conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
239 conf.set_quoted('SYSTEMD_TEST_DATA', join_paths(testsdir, 'testdata'))
240 conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
241 conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
242 conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
243 conf.set_quoted('LIBDIR', libdir)
244 conf.set_quoted('ROOTLIBDIR', rootlibdir)
245 conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
246 conf.set_quoted('BOOTLIBDIR', bootlibdir)
247 conf.set_quoted('SYSTEMD_PULL_PATH', join_paths(rootlibexecdir, 'systemd-pull'))
248 conf.set_quoted('SYSTEMD_IMPORT_PATH', join_paths(rootlibexecdir, 'systemd-import'))
249 conf.set_quoted('SYSTEMD_IMPORT_FS_PATH', join_paths(rootlibexecdir, 'systemd-import-fs'))
250 conf.set_quoted('SYSTEMD_EXPORT_PATH', join_paths(rootlibexecdir, 'systemd-export'))
251 conf.set_quoted('VENDOR_KEYRING_PATH', join_paths(rootlibexecdir, 'import-pubring.gpg'))
252 conf.set_quoted('USER_KEYRING_PATH', join_paths(pkgsysconfdir, 'import-pubring.gpg'))
253 conf.set_quoted('DOCUMENT_ROOT', join_paths(pkgdatadir, 'gatewayd'))
254 conf.set_quoted('SYSTEMD_HOMEWORK_PATH', join_paths(rootlibexecdir, 'systemd-homework'))
255 conf.set_quoted('SYSTEMD_USERWORK_PATH', join_paths(rootlibexecdir, 'systemd-userwork'))
256 conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default)
257 conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_YES_NO', memory_accounting_default ? 'yes' : 'no')
258 conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper())
259
260 substs.set('prefix', prefixdir)
261 substs.set('rootprefix', rootprefixdir)
262 substs.set('rootprefix_noslash', rootprefixdir_noslash)
263 substs.set('exec_prefix', prefixdir)
264 substs.set('libdir', libdir)
265 substs.set('rootlibdir', rootlibdir)
266 substs.set('includedir', includedir)
267 substs.set('sysconfdir', sysconfdir)
268 substs.set('bindir', bindir)
269 substs.set('rootbindir', rootbindir)
270 substs.set('rootlibexecdir', rootlibexecdir)
271 substs.set('systemunitdir', systemunitdir)
272 substs.set('userunitdir', userunitdir)
273 substs.set('systempresetdir', systempresetdir)
274 substs.set('userpresetdir', userpresetdir)
275 substs.set('udevhwdbdir', udevhwdbdir)
276 substs.set('udevrulesdir', udevrulesdir)
277 substs.set('udevlibexecdir', udevlibexecdir)
278 substs.set('environmentdir', environmentdir)
279 substs.set('catalogdir', catalogdir)
280 substs.set('tmpfilesdir', tmpfilesdir)
281 substs.set('sysusersdir', sysusersdir)
282 substs.set('sysctldir', sysctldir)
283 substs.set('binfmtdir', binfmtdir)
284 substs.set('modulesloaddir', modulesloaddir)
285 substs.set('modprobedir', modprobedir)
286 substs.set('systemgeneratordir', systemgeneratordir)
287 substs.set('usergeneratordir', usergeneratordir)
288 substs.set('systemenvgeneratordir', systemenvgeneratordir)
289 substs.set('userenvgeneratordir', userenvgeneratordir)
290 substs.set('systemshutdowndir', systemshutdowndir)
291 substs.set('systemsleepdir', systemsleepdir)
292 substs.set('CERTIFICATEROOT', get_option('certificate-root'))
293 substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
294 substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
295 substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
296 substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
297 substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
298 substs.set('STATUS_UNIT_FORMAT_DEFAULT', status_unit_format_default)
299 substs.set('HIGH_RLIMIT_NOFILE', conf.get('HIGH_RLIMIT_NOFILE'))
300 substs.set('BUILD_ROOT', project_build_root)
301
302 #####################################################################
303
304 cc = meson.get_compiler('c')
305 pkgconfig = import('pkgconfig')
306 check_compilation_sh = find_program('tools/check-compilation.sh')
307 meson_build_sh = find_program('tools/meson-build.sh')
308
309 want_tests = get_option('tests')
310 slow_tests = want_tests != 'false' and get_option('slow-tests')
311 install_tests = get_option('install-tests')
312
313 if add_languages('cpp', required : fuzzer_build)
314 # Used only for tests
315 cxx = meson.get_compiler('cpp')
316 cxx_cmd = ' '.join(cxx.cmd_array())
317 else
318 cxx_cmd = ''
319 endif
320
321 if want_libfuzzer
322 fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
323 if fuzzing_engine.found()
324 add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
325 elif cc.has_argument('-fsanitize=fuzzer-no-link')
326 add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
327 else
328 error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
329 endif
330 elif want_ossfuzz
331 fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
332 endif
333
334 # Those generate many false positives, and we do not want to change the code to
335 # avoid them.
336 basic_disabled_warnings = [
337 '-Wno-unused-parameter',
338 '-Wno-missing-field-initializers',
339 '-Wno-unused-result',
340 '-Wno-format-signedness',
341 ]
342
343 possible_cc_flags = [
344 '-Werror=undef',
345 '-Wlogical-op',
346 '-Wmissing-include-dirs',
347 '-Wold-style-definition',
348 '-Wpointer-arith',
349 '-Winit-self',
350 '-Wfloat-equal',
351 '-Wsuggest-attribute=noreturn',
352 '-Werror=missing-prototypes',
353 '-Werror=implicit-function-declaration',
354 '-Werror=missing-declarations',
355 '-Werror=return-type',
356 '-Werror=incompatible-pointer-types',
357 '-Werror=format=2',
358 '-Wstrict-prototypes',
359 '-Wredundant-decls',
360 '-Wmissing-noreturn',
361 '-Wimplicit-fallthrough=5',
362 '-Wshadow',
363 '-Wendif-labels',
364 '-Wstrict-aliasing=2',
365 '-Wwrite-strings',
366 '-Werror=overflow',
367 '-Werror=shift-count-overflow',
368 '-Werror=shift-overflow=2',
369 '-Wdate-time',
370 '-Wnested-externs',
371
372 # negative arguments are correctly detected starting with meson 0.46.
373 '-Wno-error=#warnings', # clang
374 '-Wno-string-plus-int', # clang
375
376 # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
377 # optimizations enabled, producing essentially false positives.
378 '-Wno-maybe-uninitialized',
379
380 '-ffast-math',
381 '-fno-common',
382 '-fdiagnostics-show-option',
383 '-fno-strict-aliasing',
384 '-fvisibility=hidden',
385 '-fstack-protector',
386 '-fstack-protector-strong',
387 '--param=ssp-buffer-size=4',
388 ]
389
390 # --as-needed and --no-undefined are provided by meson by default,
391 # run mesonconf to see what is enabled
392 possible_link_flags = [
393 '-Wl,-z,relro',
394 '-Wl,-z,now',
395 '-fstack-protector',
396 ]
397
398 if cc.get_id() == 'clang'
399 possible_cc_flags += [
400 '-Wno-typedef-redefinition',
401 '-Wno-gnu-variable-sized-type-not-at-end',
402 ]
403 endif
404
405 if get_option('buildtype') != 'debug'
406 possible_cc_flags += [
407 '-ffunction-sections',
408 '-fdata-sections',
409 ]
410
411 possible_link_flags += '-Wl,--gc-sections'
412 endif
413
414 add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
415 add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
416 add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
417
418 have = cc.has_argument('-Wzero-length-bounds')
419 conf.set10('HAVE_ZERO_LENGTH_BOUNDS', have)
420
421 if cc.compiles('''
422 #include <time.h>
423 #include <inttypes.h>
424 typedef uint64_t usec_t;
425 usec_t now(clockid_t clock);
426 int main(void) {
427 struct timespec now;
428 return 0;
429 }
430 ''', args: '-Werror=shadow', name : '-Werror=shadow with local shadowing')
431 add_project_arguments('-Werror=shadow', language : 'c')
432 endif
433
434 if cxx_cmd != ''
435 add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
436 endif
437
438 cpp = ' '.join(cc.cmd_array()) + ' -E'
439
440 has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
441
442 #####################################################################
443 # compilation result tests
444
445 conf.set('_GNU_SOURCE', true)
446 conf.set('__SANE_USERSPACE_TYPES__', true)
447 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)
448
449 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
450 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
451 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
452 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
453
454 decl_headers = '''
455 #include <uchar.h>
456 #include <sys/stat.h>
457 '''
458
459 foreach decl : ['char16_t',
460 'char32_t',
461 'struct statx',
462 ]
463
464 # We get -1 if the size cannot be determined
465 have = cc.sizeof(decl, prefix : decl_headers, args : '-D_GNU_SOURCE') > 0
466
467 if decl == 'struct statx'
468 if have
469 want_linux_stat_h = false
470 else
471 have = cc.sizeof(decl,
472 prefix : decl_headers + '#include <linux/stat.h>',
473 args : '-D_GNU_SOURCE') > 0
474 want_linux_stat_h = have
475 endif
476 endif
477
478 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
479 endforeach
480
481 conf.set10('WANT_LINUX_STAT_H', want_linux_stat_h)
482
483 foreach ident : ['secure_getenv', '__secure_getenv']
484 conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
485 endforeach
486
487 foreach ident : [
488 ['memfd_create', '''#include <sys/mman.h>'''],
489 ['gettid', '''#include <sys/types.h>
490 #include <unistd.h>'''],
491 ['pivot_root', '''#include <stdlib.h>
492 #include <unistd.h>'''], # no known header declares pivot_root
493 ['name_to_handle_at', '''#include <sys/types.h>
494 #include <sys/stat.h>
495 #include <fcntl.h>'''],
496 ['setns', '''#include <sched.h>'''],
497 ['renameat2', '''#include <stdio.h>
498 #include <fcntl.h>'''],
499 ['kcmp', '''#include <linux/kcmp.h>'''],
500 ['keyctl', '''#include <sys/types.h>
501 #include <keyutils.h>'''],
502 ['copy_file_range', '''#include <sys/syscall.h>
503 #include <unistd.h>'''],
504 ['bpf', '''#include <sys/syscall.h>
505 #include <unistd.h>'''],
506 ['statx', '''#include <sys/types.h>
507 #include <sys/stat.h>
508 #include <unistd.h>'''],
509 ['explicit_bzero' , '''#include <string.h>'''],
510 ['reallocarray', '''#include <malloc.h>'''],
511 ['set_mempolicy', '''#include <stdlib.h>
512 #include <unistd.h>'''],
513 ['get_mempolicy', '''#include <stdlib.h>
514 #include <unistd.h>'''],
515 ['pidfd_send_signal', '''#include <stdlib.h>
516 #include <unistd.h>
517 #include <signal.h>
518 #include <sys/wait.h>'''],
519 ['pidfd_open', '''#include <stdlib.h>
520 #include <unistd.h>
521 #include <signal.h>
522 #include <sys/wait.h>'''],
523 ['rt_sigqueueinfo', '''#include <stdlib.h>
524 #include <unistd.h>
525 #include <signal.h>
526 #include <sys/wait.h>'''],
527 ]
528
529 have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
530 conf.set10('HAVE_' + ident[0].to_upper(), have)
531 endforeach
532
533 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
534 conf.set10('USE_SYS_RANDOM_H', true)
535 conf.set10('HAVE_GETRANDOM', true)
536 else
537 have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
538 conf.set10('USE_SYS_RANDOM_H', false)
539 conf.set10('HAVE_GETRANDOM', have)
540 endif
541
542 #####################################################################
543
544 vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh',
545 project_source_root,
546 get_option('version-tag'),
547 meson.project_version()]
548
549 version_h = vcs_tag(
550 input : 'src/version/version.h.in',
551 output : 'version.h',
552 command: vcs_tagger)
553
554 versiondep = declare_dependency(sources: version_h)
555
556 sed = find_program('sed')
557 awk = find_program('awk')
558 m4 = find_program('m4')
559 stat = find_program('stat')
560 git = find_program('git', required : false)
561 env = find_program('env')
562 perl = find_program('perl', required : false)
563
564 meson_make_symlink = project_source_root + '/tools/meson-make-symlink.sh'
565 mkdir_p = 'mkdir -p $DESTDIR/@0@'
566 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
567 splash_bmp = files('test/splash.bmp')
568
569 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
570 # /usr/sbin, /sbin, and fall back to the default from middle column.
571 progs = [['quotaon', '/usr/sbin/quotaon' ],
572 ['quotacheck', '/usr/sbin/quotacheck' ],
573 ['kmod', '/usr/bin/kmod' ],
574 ['kexec', '/usr/sbin/kexec' ],
575 ['sulogin', '/usr/sbin/sulogin' ],
576 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
577 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
578 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
579 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
580 ['nologin', '/usr/sbin/nologin', ],
581 ]
582 foreach prog : progs
583 path = get_option(prog[0] + '-path')
584 if path != ''
585 message('Using @1@ for @0@'.format(prog[0], path))
586 else
587 exe = find_program(prog[0],
588 '/usr/sbin/' + prog[0],
589 '/sbin/' + prog[0],
590 required: false)
591 path = exe.found() ? exe.path() : prog[1]
592 endif
593 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
594 conf.set_quoted(name, path)
595 substs.set(name, path)
596 endforeach
597
598 conf.set_quoted('TELINIT', get_option('telinit-path'))
599
600 if run_command('ln', '--relative', '--help').returncode() != 0
601 error('ln does not support --relative (added in coreutils 8.16)')
602 endif
603
604 ############################################################
605
606 gperf = find_program('gperf')
607
608 gperf_test_format = '''
609 #include <string.h>
610 const char * in_word_set(const char *, @0@);
611 @1@
612 '''
613 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
614 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
615 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
616 if cc.compiles(gperf_test)
617 gperf_len_type = 'size_t'
618 else
619 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
620 if cc.compiles(gperf_test)
621 gperf_len_type = 'unsigned'
622 else
623 error('unable to determine gperf len type')
624 endif
625 endif
626 message('gperf len type is @0@'.format(gperf_len_type))
627 conf.set('GPERF_LEN_TYPE', gperf_len_type,
628 description : 'The type of gperf "len" parameter')
629
630 ############################################################
631
632 if not cc.has_header('sys/capability.h')
633 error('POSIX caps headers not found')
634 endif
635 foreach header : ['crypt.h',
636 'linux/memfd.h',
637 'linux/vm_sockets.h',
638 'sys/auxv.h',
639 'valgrind/memcheck.h',
640 'valgrind/valgrind.h',
641 ]
642
643 conf.set10('HAVE_' + header.underscorify().to_upper(),
644 cc.has_header(header))
645 endforeach
646
647 ############################################################
648
649 fallback_hostname = get_option('fallback-hostname')
650 if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
651 error('Invalid fallback-hostname configuration')
652 # A more extensive test is done in test-hostname-util. Let's catch
653 # the most obvious errors here so we don't fail with an assert later.
654 endif
655 conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
656
657 conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
658 gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
659
660 default_hierarchy = get_option('default-hierarchy')
661 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
662 description : 'default cgroup hierarchy as string')
663 if default_hierarchy == 'legacy'
664 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
665 elif default_hierarchy == 'hybrid'
666 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
667 else
668 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
669 endif
670
671 default_net_naming_scheme = get_option('default-net-naming-scheme')
672 conf.set_quoted('DEFAULT_NET_NAMING_SCHEME', default_net_naming_scheme)
673
674 time_epoch = get_option('time-epoch')
675 if time_epoch == -1
676 source_date_epoch = run_command('sh', ['-c', 'echo "$SOURCE_DATE_EPOCH"']).stdout().strip()
677 if source_date_epoch != ''
678 time_epoch = source_date_epoch.to_int()
679 else
680 NEWS = files('NEWS')
681 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout().to_int()
682 endif
683 endif
684 conf.set('TIME_EPOCH', time_epoch)
685
686 system_uid_max = get_option('system-uid-max')
687 if system_uid_max == -1
688 system_uid_max = run_command(
689 awk,
690 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
691 '/etc/login.defs').stdout().strip()
692 if system_uid_max == ''
693 system_uid_max = 999
694 else
695 system_uid_max = system_uid_max.to_int()
696 endif
697 endif
698 conf.set('SYSTEM_UID_MAX', system_uid_max)
699 substs.set('systemuidmax', system_uid_max)
700
701 system_gid_max = get_option('system-gid-max')
702 if system_gid_max == -1
703 system_gid_max = run_command(
704 awk,
705 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
706 '/etc/login.defs').stdout().strip()
707 if system_gid_max == ''
708 system_gid_max = 999
709 else
710 system_gid_max = system_gid_max.to_int()
711 endif
712 endif
713 conf.set('SYSTEM_GID_MAX', system_gid_max)
714 substs.set('systemgidmax', system_gid_max)
715
716 dynamic_uid_min = get_option('dynamic-uid-min')
717 dynamic_uid_max = get_option('dynamic-uid-max')
718 conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
719 conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
720 substs.set('dynamicuidmin', dynamic_uid_min)
721 substs.set('dynamicuidmax', dynamic_uid_max)
722
723 container_uid_base_min = get_option('container-uid-base-min')
724 container_uid_base_max = get_option('container-uid-base-max')
725 conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
726 conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
727 substs.set('containeruidbasemin', container_uid_base_min)
728 substs.set('containeruidbasemax', container_uid_base_max)
729
730 nobody_user = get_option('nobody-user')
731 nobody_group = get_option('nobody-group')
732
733 if not meson.is_cross_build()
734 getent_result = run_command('getent', 'passwd', '65534')
735 if getent_result.returncode() == 0
736 name = getent_result.stdout().split(':')[0]
737 if name != nobody_user
738 warning('\n' +
739 '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) +
740 'Your build will result in an user table setup that is incompatible with the local system.')
741 endif
742 endif
743 id_result = run_command('id', '-u', nobody_user)
744 if id_result.returncode() == 0
745 id = id_result.stdout().to_int()
746 if id != 65534
747 warning('\n' +
748 '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) +
749 'Your build will result in an user table setup that is incompatible with the local system.')
750 endif
751 endif
752
753 getent_result = run_command('getent', 'group', '65534')
754 if getent_result.returncode() == 0
755 name = getent_result.stdout().split(':')[0]
756 if name != nobody_group
757 warning('\n' +
758 '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) +
759 'Your build will result in an group table setup that is incompatible with the local system.')
760 endif
761 endif
762 id_result = run_command('id', '-g', nobody_group)
763 if id_result.returncode() == 0
764 id = id_result.stdout().to_int()
765 if id != 65534
766 warning('\n' +
767 '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) +
768 'Your build will result in an group table setup that is incompatible with the local system.')
769 endif
770 endif
771 endif
772 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
773 warning('\n' +
774 'The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
775 'Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
776 endif
777
778 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
779 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
780 substs.set('NOBODY_USER_NAME', nobody_user)
781 substs.set('NOBODY_GROUP_NAME', nobody_group)
782
783 tty_gid = get_option('tty-gid')
784 conf.set('TTY_GID', tty_gid)
785 substs.set('TTY_GID', tty_gid)
786
787 # Ensure provided GID argument is numeric, otherwise fallback to default assignment
788 users_gid = get_option('users-gid')
789 substs.set('USERS_GID', users_gid < 0 ? '-' : users_gid)
790
791 conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
792 conf.set10('ENABLE_WHEEL_GROUP', get_option('wheel-group'))
793
794 dev_kvm_mode = get_option('dev-kvm-mode')
795 substs.set('DEV_KVM_MODE', dev_kvm_mode)
796 conf.set10('DEV_KVM_UACCESS', dev_kvm_mode != '0666')
797 group_render_mode = get_option('group-render-mode')
798 substs.set('GROUP_RENDER_MODE', group_render_mode)
799 conf.set10('GROUP_RENDER_UACCESS', group_render_mode != '0666')
800
801 kill_user_processes = get_option('default-kill-user-processes')
802 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
803 conf.set_quoted('KILL_USER_PROCESSES_YES_NO', kill_user_processes ? 'yes' : 'no')
804 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
805
806 dns_servers = get_option('dns-servers')
807 conf.set_quoted('DNS_SERVERS', dns_servers)
808 substs.set('DNS_SERVERS', dns_servers)
809
810 ntp_servers = get_option('ntp-servers')
811 conf.set_quoted('NTP_SERVERS', ntp_servers)
812 substs.set('NTP_SERVERS', ntp_servers)
813
814 default_locale = get_option('default-locale')
815 if default_locale == ''
816 if not meson.is_cross_build()
817 choose_default_locale_sh = find_program('tools/choose-default-locale.sh')
818 default_locale = run_command(choose_default_locale_sh).stdout().strip()
819 else
820 default_locale = 'C.UTF-8'
821 endif
822 endif
823 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
824
825 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
826
827 service_watchdog = get_option('service-watchdog')
828 watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
829 substs.set('SERVICE_WATCHDOG', watchdog_value)
830
831 substs.set('SUSHELL', get_option('debug-shell'))
832 substs.set('DEBUGTTY', get_option('debug-tty'))
833 conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
834
835 enable_debug_hashmap = false
836 enable_debug_mmap_cache = false
837 enable_debug_siphash = false
838 foreach name : get_option('debug-extra')
839 if name == 'hashmap'
840 enable_debug_hashmap = true
841 elif name == 'mmap-cache'
842 enable_debug_mmap_cache = true
843 elif name == 'siphash'
844 enable_debug_siphash = true
845 else
846 message('unknown debug option "@0@", ignoring'.format(name))
847 endif
848 endforeach
849 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
850 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
851 conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
852
853 conf.set10('VALGRIND', get_option('valgrind'))
854 conf.set10('LOG_TRACE', get_option('log-trace'))
855
856 default_user_path = get_option('user-path')
857 if default_user_path != ''
858 conf.set_quoted('DEFAULT_USER_PATH', default_user_path)
859 default_user_path_display = default_user_path
860 else
861 # meson 0.49 fails when ?: is used in .format()
862 default_user_path_display = '(same as system services)'
863 endif
864
865
866 #####################################################################
867
868 threads = dependency('threads')
869 librt = cc.find_library('rt')
870 libm = cc.find_library('m')
871 libdl = cc.find_library('dl')
872 libcrypt = cc.find_library('crypt')
873
874 libcap = dependency('libcap', required : false)
875 if not libcap.found()
876 # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
877 libcap = cc.find_library('cap')
878 endif
879
880 libmount = dependency('mount',
881 version : fuzzer_build ? '>= 0' : '>= 2.30')
882
883 want_libfdisk = get_option('fdisk')
884 if want_libfdisk != 'false' and not skip_deps
885 libfdisk = dependency('fdisk',
886 required : want_libfdisk == 'true')
887 have = libfdisk.found()
888 else
889 have = false
890 libfdisk = []
891 endif
892 conf.set10('HAVE_LIBFDISK', have)
893
894 want_pwquality = get_option('pwquality')
895 if want_pwquality != 'false' and not skip_deps
896 libpwquality = dependency('pwquality', required : want_pwquality == 'true')
897 have = libpwquality.found()
898 else
899 have = false
900 libpwquality = []
901 endif
902 conf.set10('HAVE_PWQUALITY', have)
903
904 want_seccomp = get_option('seccomp')
905 if want_seccomp != 'false' and not skip_deps
906 libseccomp = dependency('libseccomp',
907 version : '>= 2.3.1',
908 required : want_seccomp == 'true')
909 have = libseccomp.found()
910 else
911 have = false
912 libseccomp = []
913 endif
914 conf.set10('HAVE_SECCOMP', have)
915
916 want_selinux = get_option('selinux')
917 if want_selinux != 'false' and not skip_deps
918 libselinux = dependency('libselinux',
919 version : '>= 2.1.9',
920 required : want_selinux == 'true')
921 have = libselinux.found()
922 else
923 have = false
924 libselinux = []
925 endif
926 conf.set10('HAVE_SELINUX', have)
927
928 want_apparmor = get_option('apparmor')
929 if want_apparmor != 'false' and not skip_deps
930 libapparmor = dependency('libapparmor',
931 required : want_apparmor == 'true')
932 have = libapparmor.found()
933 else
934 have = false
935 libapparmor = []
936 endif
937 conf.set10('HAVE_APPARMOR', have)
938
939 smack_run_label = get_option('smack-run-label')
940 if smack_run_label != ''
941 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
942 endif
943
944 want_polkit = get_option('polkit')
945 install_polkit = false
946 install_polkit_pkla = false
947 if want_polkit != 'false' and not skip_deps
948 install_polkit = true
949
950 libpolkit = dependency('polkit-gobject-1',
951 required : false)
952 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
953 message('Old polkit detected, will install pkla files')
954 install_polkit_pkla = true
955 endif
956 endif
957 conf.set10('ENABLE_POLKIT', install_polkit)
958
959 want_acl = get_option('acl')
960 if want_acl != 'false' and not skip_deps
961 libacl = cc.find_library('acl', required : want_acl == 'true')
962 have = libacl.found()
963 else
964 have = false
965 libacl = []
966 endif
967 conf.set10('HAVE_ACL', have)
968
969 want_audit = get_option('audit')
970 if want_audit != 'false' and not skip_deps
971 libaudit = dependency('audit', required : want_audit == 'true')
972 have = libaudit.found()
973 else
974 have = false
975 libaudit = []
976 endif
977 conf.set10('HAVE_AUDIT', have)
978
979 want_blkid = get_option('blkid')
980 if want_blkid != 'false' and not skip_deps
981 libblkid = dependency('blkid', required : want_blkid == 'true')
982 have = libblkid.found()
983 else
984 have = false
985 libblkid = []
986 endif
987 conf.set10('HAVE_BLKID', have)
988
989 want_kmod = get_option('kmod')
990 if want_kmod != 'false' and not skip_deps
991 libkmod = dependency('libkmod',
992 version : '>= 15',
993 required : want_kmod == 'true')
994 have = libkmod.found()
995 else
996 have = false
997 libkmod = []
998 endif
999 conf.set10('HAVE_KMOD', have)
1000
1001 want_pam = get_option('pam')
1002 if want_pam != 'false' and not skip_deps
1003 libpam = cc.find_library('pam', required : want_pam == 'true')
1004 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1005 have = libpam.found() and libpam_misc.found()
1006 else
1007 have = false
1008 libpam = []
1009 libpam_misc = []
1010 endif
1011 conf.set10('HAVE_PAM', have)
1012
1013 want_microhttpd = get_option('microhttpd')
1014 if want_microhttpd != 'false' and not skip_deps
1015 libmicrohttpd = dependency('libmicrohttpd',
1016 version : '>= 0.9.33',
1017 required : want_microhttpd == 'true')
1018 have = libmicrohttpd.found()
1019 else
1020 have = false
1021 libmicrohttpd = []
1022 endif
1023 conf.set10('HAVE_MICROHTTPD', have)
1024
1025 want_libcryptsetup = get_option('libcryptsetup')
1026 if want_libcryptsetup != 'false' and not skip_deps
1027 libcryptsetup = dependency('libcryptsetup',
1028 version : '>= 2.0.1',
1029 required : want_libcryptsetup == 'true')
1030 have = libcryptsetup.found()
1031
1032 conf.set10('HAVE_CRYPT_SET_METADATA_SIZE',
1033 have and cc.has_function('crypt_set_metadata_size', dependencies : libcryptsetup))
1034 else
1035 have = false
1036 libcryptsetup = []
1037 endif
1038 conf.set10('HAVE_LIBCRYPTSETUP', have)
1039
1040 want_libcurl = get_option('libcurl')
1041 if want_libcurl != 'false' and not skip_deps
1042 libcurl = dependency('libcurl',
1043 version : '>= 7.32.0',
1044 required : want_libcurl == 'true')
1045 have = libcurl.found()
1046 else
1047 have = false
1048 libcurl = []
1049 endif
1050 conf.set10('HAVE_LIBCURL', have)
1051
1052 want_libidn = get_option('libidn')
1053 want_libidn2 = get_option('libidn2')
1054 if want_libidn == 'true' and want_libidn2 == 'true'
1055 error('libidn and libidn2 cannot be requested simultaneously')
1056 endif
1057
1058 if want_libidn2 != 'false' and want_libidn != 'true' and not skip_deps
1059 libidn = dependency('libidn2',
1060 required : want_libidn2 == 'true')
1061 have = libidn.found()
1062 else
1063 have = false
1064 libidn = []
1065 endif
1066 conf.set10('HAVE_LIBIDN2', have)
1067 if not have and want_libidn != 'false' and not skip_deps
1068 # libidn is used for both libidn and libidn2 objects
1069 libidn = dependency('libidn',
1070 required : want_libidn == 'true')
1071 have = libidn.found()
1072 else
1073 have = false
1074 endif
1075 conf.set10('HAVE_LIBIDN', have)
1076
1077 want_libiptc = get_option('libiptc')
1078 if want_libiptc != 'false' and not skip_deps
1079 libiptc = dependency('libiptc',
1080 required : want_libiptc == 'true')
1081 have = libiptc.found()
1082 else
1083 have = false
1084 libiptc = []
1085 endif
1086 conf.set10('HAVE_LIBIPTC', have)
1087
1088 want_qrencode = get_option('qrencode')
1089 if want_qrencode != 'false' and not skip_deps
1090 libqrencode = dependency('libqrencode',
1091 required : want_qrencode == 'true')
1092 have = libqrencode.found()
1093 else
1094 have = false
1095 libqrencode = []
1096 endif
1097 conf.set10('HAVE_QRENCODE', have)
1098
1099 want_gcrypt = get_option('gcrypt')
1100 if want_gcrypt != 'false' and not skip_deps
1101 libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1102 libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1103 have = libgcrypt.found() and libgpg_error.found()
1104 else
1105 have = false
1106 endif
1107 if not have
1108 # link to neither of the libs if one is not found
1109 libgcrypt = []
1110 libgpg_error = []
1111 endif
1112 conf.set10('HAVE_GCRYPT', have)
1113
1114 want_gnutls = get_option('gnutls')
1115 if want_gnutls != 'false' and not skip_deps
1116 libgnutls = dependency('gnutls',
1117 version : '>= 3.1.4',
1118 required : want_gnutls == 'true')
1119 have = libgnutls.found()
1120 else
1121 have = false
1122 libgnutls = []
1123 endif
1124 conf.set10('HAVE_GNUTLS', have)
1125
1126 want_openssl = get_option('openssl')
1127 if want_openssl != 'false' and not skip_deps
1128 libopenssl = dependency('openssl',
1129 version : '>= 1.1.0',
1130 required : want_openssl == 'true')
1131 have = libopenssl.found()
1132 else
1133 have = false
1134 libopenssl = []
1135 endif
1136 conf.set10('HAVE_OPENSSL', have)
1137
1138 want_p11kit = get_option('p11kit')
1139 if want_p11kit != 'false' and not skip_deps
1140 libp11kit = dependency('p11-kit-1',
1141 version : '>= 0.23.3',
1142 required : want_p11kit == 'true')
1143 have = libp11kit.found()
1144 else
1145 have = false
1146 libp11kit = []
1147 endif
1148 conf.set10('HAVE_P11KIT', have)
1149
1150 want_elfutils = get_option('elfutils')
1151 if want_elfutils != 'false' and not skip_deps
1152 libdw = dependency('libdw',
1153 required : want_elfutils == 'true')
1154 have = libdw.found()
1155 else
1156 have = false
1157 libdw = []
1158 endif
1159 conf.set10('HAVE_ELFUTILS', have)
1160
1161 want_zlib = get_option('zlib')
1162 if want_zlib != 'false' and not skip_deps
1163 libz = dependency('zlib',
1164 required : want_zlib == 'true')
1165 have = libz.found()
1166 else
1167 have = false
1168 libz = []
1169 endif
1170 conf.set10('HAVE_ZLIB', have)
1171
1172 want_bzip2 = get_option('bzip2')
1173 if want_bzip2 != 'false' and not skip_deps
1174 libbzip2 = cc.find_library('bz2',
1175 required : want_bzip2 == 'true')
1176 have = libbzip2.found()
1177 else
1178 have = false
1179 libbzip2 = []
1180 endif
1181 conf.set10('HAVE_BZIP2', have)
1182
1183 want_xz = get_option('xz')
1184 if want_xz != 'false' and not skip_deps
1185 libxz = dependency('liblzma',
1186 required : want_xz == 'true')
1187 have = libxz.found()
1188 else
1189 have = false
1190 libxz = []
1191 endif
1192 conf.set10('HAVE_XZ', have)
1193
1194 want_lz4 = get_option('lz4')
1195 if want_lz4 != 'false' and not skip_deps
1196 liblz4 = dependency('liblz4',
1197 version : '>= 1.3.0',
1198 required : want_lz4 == 'true')
1199 have = liblz4.found()
1200 else
1201 have = false
1202 liblz4 = []
1203 endif
1204 conf.set10('HAVE_LZ4', have)
1205
1206 want_zstd = get_option('zstd')
1207 if want_zstd != 'false' and not skip_deps
1208 libzstd = dependency('libzstd',
1209 required : want_zstd == 'true',
1210 version : '>= 1.4.0')
1211 have = libzstd.found()
1212 else
1213 have = false
1214 libzstd = []
1215 endif
1216 conf.set10('HAVE_ZSTD', have)
1217
1218 want_xkbcommon = get_option('xkbcommon')
1219 if want_xkbcommon != 'false' and not skip_deps
1220 libxkbcommon = dependency('xkbcommon',
1221 version : '>= 0.3.0',
1222 required : want_xkbcommon == 'true')
1223 have = libxkbcommon.found()
1224 else
1225 have = false
1226 libxkbcommon = []
1227 endif
1228 conf.set10('HAVE_XKBCOMMON', have)
1229
1230 want_pcre2 = get_option('pcre2')
1231 if want_pcre2 != 'false'
1232 libpcre2 = dependency('libpcre2-8',
1233 required : want_pcre2 == 'true')
1234 have = libpcre2.found()
1235 else
1236 have = false
1237 libpcre2 = []
1238 endif
1239 conf.set10('HAVE_PCRE2', have)
1240
1241 want_glib = get_option('glib')
1242 if want_glib != 'false' and not skip_deps
1243 libglib = dependency('glib-2.0',
1244 version : '>= 2.22.0',
1245 required : want_glib == 'true')
1246 libgobject = dependency('gobject-2.0',
1247 version : '>= 2.22.0',
1248 required : want_glib == 'true')
1249 libgio = dependency('gio-2.0',
1250 required : want_glib == 'true')
1251 have = libglib.found() and libgobject.found() and libgio.found()
1252 else
1253 have = false
1254 libglib = []
1255 libgobject = []
1256 libgio = []
1257 endif
1258 conf.set10('HAVE_GLIB', have)
1259
1260 want_dbus = get_option('dbus')
1261 if want_dbus != 'false' and not skip_deps
1262 libdbus = dependency('dbus-1',
1263 version : '>= 1.3.2',
1264 required : want_dbus == 'true')
1265 have = libdbus.found()
1266 else
1267 have = false
1268 libdbus = []
1269 endif
1270 conf.set10('HAVE_DBUS', have)
1271
1272 default_dnssec = get_option('default-dnssec')
1273 if skip_deps
1274 default_dnssec = 'no'
1275 endif
1276 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1277 message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1278 default_dnssec = 'no'
1279 endif
1280 conf.set('DEFAULT_DNSSEC_MODE',
1281 'DNSSEC_' + default_dnssec.underscorify().to_upper())
1282 substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1283
1284 dns_over_tls = get_option('dns-over-tls')
1285 if dns_over_tls != 'false'
1286 if dns_over_tls == 'openssl'
1287 have_gnutls = false
1288 else
1289 have_gnutls = (conf.get('HAVE_GNUTLS') == 1 and libgnutls.version().version_compare('>= 3.6.0'))
1290 if dns_over_tls == 'gnutls' and not have_gnutls
1291 error('DNS-over-TLS support was requested with gnutls, but dependencies are not available')
1292 endif
1293 endif
1294 if dns_over_tls == 'gnutls' or have_gnutls
1295 have_openssl = false
1296 else
1297 have_openssl = conf.get('HAVE_OPENSSL') == 1
1298 if dns_over_tls != 'auto' and not have_openssl
1299 str = dns_over_tls == 'openssl' ? ' with openssl' : ''
1300 error('DNS-over-TLS support was requested@0@, but dependencies are not available'.format(str))
1301 endif
1302 endif
1303 have = have_gnutls or have_openssl
1304 else
1305 have = false
1306 have_gnutls = false
1307 have_openssl = false
1308 endif
1309 conf.set10('ENABLE_DNS_OVER_TLS', have)
1310 conf.set10('DNS_OVER_TLS_USE_GNUTLS', have_gnutls)
1311 conf.set10('DNS_OVER_TLS_USE_OPENSSL', have_openssl)
1312
1313 default_dns_over_tls = get_option('default-dns-over-tls')
1314 if skip_deps
1315 default_dns_over_tls = 'no'
1316 endif
1317 if default_dns_over_tls != 'no' and conf.get('ENABLE_DNS_OVER_TLS') == 0
1318 message('default-dns-over-tls cannot be enabled or set to opportunistic when DNS-over-TLS support is disabled. Setting default-dns-over-tls to no.')
1319 default_dns_over_tls = 'no'
1320 endif
1321 conf.set('DEFAULT_DNS_OVER_TLS_MODE',
1322 'DNS_OVER_TLS_' + default_dns_over_tls.underscorify().to_upper())
1323 substs.set('DEFAULT_DNS_OVER_TLS_MODE', default_dns_over_tls)
1324
1325 default_mdns = get_option('default-mdns')
1326 conf.set('DEFAULT_MDNS_MODE',
1327 'RESOLVE_SUPPORT_' + default_mdns.to_upper())
1328 substs.set('DEFAULT_MDNS_MODE', default_mdns)
1329
1330 default_llmnr = get_option('default-llmnr')
1331 conf.set('DEFAULT_LLMNR_MODE',
1332 'RESOLVE_SUPPORT_' + default_llmnr.to_upper())
1333 substs.set('DEFAULT_LLMNR_MODE', default_llmnr)
1334
1335 want_repart = get_option('repart')
1336 if want_repart != 'false'
1337 have = (conf.get('HAVE_OPENSSL') == 1 and
1338 conf.get('HAVE_LIBFDISK') == 1)
1339 if want_repart == 'true' and not have
1340 error('repart support was requested, but dependencies are not available')
1341 endif
1342 else
1343 have = false
1344 endif
1345 conf.set10('ENABLE_REPART', have)
1346
1347 want_importd = get_option('importd')
1348 if want_importd != 'false'
1349 have = (conf.get('HAVE_LIBCURL') == 1 and
1350 conf.get('HAVE_ZLIB') == 1 and
1351 conf.get('HAVE_XZ') == 1 and
1352 conf.get('HAVE_GCRYPT') == 1)
1353 if want_importd == 'true' and not have
1354 error('importd support was requested, but dependencies are not available')
1355 endif
1356 else
1357 have = false
1358 endif
1359 conf.set10('ENABLE_IMPORTD', have)
1360
1361 want_homed = get_option('homed')
1362 if want_homed != 'false'
1363 have = (conf.get('HAVE_OPENSSL') == 1 and
1364 conf.get('HAVE_LIBFDISK') == 1 and
1365 conf.get('HAVE_LIBCRYPTSETUP') == 1)
1366 if want_homed == 'true' and not have
1367 error('homed support was requested, but dependencies are not available')
1368 endif
1369 else
1370 have = false
1371 endif
1372 conf.set10('ENABLE_HOMED', have)
1373
1374 have = have and conf.get('HAVE_PAM') == 1
1375 conf.set10('ENABLE_PAM_HOME', have)
1376
1377 want_remote = get_option('remote')
1378 if want_remote != 'false'
1379 have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1380 conf.get('HAVE_LIBCURL') == 1]
1381 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
1382 # it's possible to build one without the other. Complain only if
1383 # support was explicitly requested. The auxiliary files like sysusers
1384 # config should be installed when any of the programs are built.
1385 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1386 error('remote support was requested, but dependencies are not available')
1387 endif
1388 have = have_deps[0] or have_deps[1]
1389 else
1390 have = false
1391 endif
1392 conf.set10('ENABLE_REMOTE', have)
1393
1394 foreach term : ['utmp',
1395 'hibernate',
1396 'environment-d',
1397 'binfmt',
1398 'coredump',
1399 'pstore',
1400 'resolve',
1401 'logind',
1402 'hostnamed',
1403 'localed',
1404 'machined',
1405 'portabled',
1406 'userdb',
1407 'networkd',
1408 'timedated',
1409 'timesyncd',
1410 'firstboot',
1411 'randomseed',
1412 'backlight',
1413 'vconsole',
1414 'quotacheck',
1415 'sysusers',
1416 'tmpfiles',
1417 'hwdb',
1418 'rfkill',
1419 'ldconfig',
1420 'efi',
1421 'tpm',
1422 'ima',
1423 'smack',
1424 'gshadow',
1425 'idn',
1426 'initrd',
1427 'nss-myhostname',
1428 'nss-systemd']
1429 have = get_option(term)
1430 name = 'ENABLE_' + term.underscorify().to_upper()
1431 conf.set10(name, have)
1432 endforeach
1433
1434 foreach tuple : [['nss-mymachines', 'machined'],
1435 ['nss-resolve', 'resolve']]
1436 want = get_option(tuple[0])
1437 if want != 'false'
1438 have = get_option(tuple[1])
1439 if want == 'true' and not have
1440 error('@0@ is requested but @1@ is disabled'.format(tuple[0], tuple[1]))
1441 endif
1442 else
1443 have = false
1444 endif
1445 name = 'ENABLE_' + tuple[0].underscorify().to_upper()
1446 conf.set10(name, have)
1447 endforeach
1448
1449 enable_nss = false
1450 foreach term : ['ENABLE_NSS_MYHOSTNAME',
1451 'ENABLE_NSS_MYMACHINES',
1452 'ENABLE_NSS_RESOLVE',
1453 'ENABLE_NSS_SYSTEMD']
1454 if conf.get(term) == 1
1455 enable_nss = true
1456 endif
1457 endforeach
1458 conf.set10('ENABLE_NSS', enable_nss)
1459
1460 conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesyncd'))
1461
1462 tests = []
1463 fuzzers = []
1464
1465 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1466
1467 #####################################################################
1468
1469 if get_option('efi')
1470 efi_arch = host_machine.cpu_family()
1471
1472 if efi_arch == 'x86'
1473 EFI_MACHINE_TYPE_NAME = 'ia32'
1474 gnu_efi_arch = 'ia32'
1475 elif efi_arch == 'x86_64'
1476 EFI_MACHINE_TYPE_NAME = 'x64'
1477 gnu_efi_arch = 'x86_64'
1478 elif efi_arch == 'arm'
1479 EFI_MACHINE_TYPE_NAME = 'arm'
1480 gnu_efi_arch = 'arm'
1481 elif efi_arch == 'aarch64'
1482 EFI_MACHINE_TYPE_NAME = 'aa64'
1483 gnu_efi_arch = 'aarch64'
1484 else
1485 EFI_MACHINE_TYPE_NAME = ''
1486 gnu_efi_arch = ''
1487 endif
1488
1489 have = true
1490 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1491
1492 conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
1493 else
1494 have = false
1495 endif
1496 conf.set10('ENABLE_EFI', have)
1497
1498 #####################################################################
1499
1500 config_h = configure_file(
1501 output : 'config.h',
1502 configuration : conf)
1503
1504 meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
1505
1506 includes = include_directories('src/basic',
1507 'src/boot',
1508 'src/home',
1509 'src/shared',
1510 'src/systemd',
1511 'src/journal',
1512 'src/journal-remote',
1513 'src/nspawn',
1514 'src/resolve',
1515 'src/timesync',
1516 'src/time-wait-sync',
1517 'src/login',
1518 'src/udev',
1519 'src/libudev',
1520 'src/core',
1521 'src/shutdown',
1522 'src/libsystemd/sd-bus',
1523 'src/libsystemd/sd-device',
1524 'src/libsystemd/sd-event',
1525 'src/libsystemd/sd-hwdb',
1526 'src/libsystemd/sd-id128',
1527 'src/libsystemd/sd-netlink',
1528 'src/libsystemd/sd-network',
1529 'src/libsystemd/sd-resolve',
1530 'src/libsystemd-network',
1531 '.')
1532
1533 add_project_arguments('-include', 'config.h', language : 'c')
1534
1535 generate_gperfs = find_program('tools/generate-gperfs.py')
1536
1537 subdir('po')
1538 subdir('catalog')
1539 subdir('src/systemd')
1540 subdir('src/basic')
1541 subdir('src/libsystemd')
1542 subdir('src/libsystemd-network')
1543 subdir('src/journal')
1544 subdir('src/login')
1545
1546 libjournal_core = static_library(
1547 'journal-core',
1548 libjournal_core_sources,
1549 journald_gperf_c,
1550 include_directories : includes,
1551 install : false)
1552
1553 libsystemd_sym_path = '@0@/@1@'.format(project_source_root, libsystemd_sym)
1554 libsystemd = shared_library(
1555 'systemd',
1556 disable_mempool_c,
1557 version : libsystemd_version,
1558 include_directories : includes,
1559 link_args : ['-shared',
1560 '-Wl,--version-script=' + libsystemd_sym_path],
1561 link_with : [libbasic,
1562 libbasic_gcrypt],
1563 link_whole : [libsystemd_static,
1564 libjournal_client],
1565 dependencies : [threads,
1566 librt,
1567 libxz,
1568 libzstd,
1569 liblz4],
1570 link_depends : libsystemd_sym,
1571 install : true,
1572 install_dir : rootlibdir)
1573
1574 static_libsystemd = get_option('static-libsystemd')
1575 static_libsystemd_pic = static_libsystemd == 'true' or static_libsystemd == 'pic'
1576
1577 install_libsystemd_static = static_library(
1578 'systemd',
1579 libsystemd_sources,
1580 journal_client_sources,
1581 basic_sources,
1582 basic_gcrypt_sources,
1583 disable_mempool_c,
1584 include_directories : includes,
1585 build_by_default : static_libsystemd != 'false',
1586 install : static_libsystemd != 'false',
1587 install_dir : rootlibdir,
1588 pic : static_libsystemd == 'true' or static_libsystemd == 'pic',
1589 dependencies : [threads,
1590 librt,
1591 libxz,
1592 libzstd,
1593 liblz4,
1594 libcap,
1595 libblkid,
1596 libmount,
1597 libselinux,
1598 libgcrypt],
1599 c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
1600
1601 # Generate autosuspend rules
1602 make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
1603
1604 ############################################################
1605
1606 # binaries that have --help and are intended for use by humans,
1607 # usually, but not always, installed in /bin.
1608 public_programs = []
1609
1610 subdir('src/libudev')
1611 subdir('src/shared')
1612 subdir('src/core')
1613 subdir('src/shutdown')
1614 subdir('src/udev')
1615 subdir('src/network')
1616
1617 subdir('src/analyze')
1618 subdir('src/journal-remote')
1619 subdir('src/coredump')
1620 subdir('src/pstore')
1621 subdir('src/hostname')
1622 subdir('src/import')
1623 subdir('src/partition')
1624 subdir('src/kernel-install')
1625 subdir('src/locale')
1626 subdir('src/machine')
1627 subdir('src/portable')
1628 subdir('src/userdb')
1629 subdir('src/home')
1630 subdir('src/nspawn')
1631 subdir('src/resolve')
1632 subdir('src/timedate')
1633 subdir('src/timesync')
1634 subdir('src/vconsole')
1635 subdir('src/boot/efi')
1636
1637 subdir('src/test')
1638 subdir('src/fuzz')
1639 subdir('rules.d')
1640 subdir('test')
1641
1642 ############################################################
1643
1644 # only static linking apart from libdl, to make sure that the
1645 # module is linked to all libraries that it uses.
1646 test_dlopen = executable(
1647 'test-dlopen',
1648 test_dlopen_c,
1649 disable_mempool_c,
1650 include_directories : includes,
1651 link_with : [libbasic],
1652 dependencies : [libdl],
1653 build_by_default : want_tests != 'false')
1654
1655 foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
1656 ['systemd', 'ENABLE_NSS_SYSTEMD', 'src/nss-systemd/userdb-glue.c src/nss-systemd/userdb-glue.h'],
1657 ['mymachines', 'ENABLE_NSS_MYMACHINES'],
1658 ['resolve', 'ENABLE_NSS_RESOLVE']]
1659
1660 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1661 if condition
1662 module = tuple[0]
1663
1664 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1665 version_script_arg = join_paths(project_source_root, sym)
1666
1667 sources = ['src/nss-@0@/nss-@0@.c'.format(module)]
1668 if tuple.length() > 2
1669 sources += tuple[2].split()
1670 endif
1671
1672 nss = shared_library(
1673 'nss_' + module,
1674 sources,
1675 disable_mempool_c,
1676 version : '2',
1677 include_directories : includes,
1678 # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1679 link_args : ['-Wl,-z,nodelete',
1680 '-shared',
1681 '-Wl,--version-script=' + version_script_arg],
1682 link_with : [libsystemd_static,
1683 libshared_static,
1684 libbasic],
1685 dependencies : [threads,
1686 librt],
1687 link_depends : sym,
1688 install : true,
1689 install_dir : rootlibdir)
1690
1691 # We cannot use shared_module because it does not support version suffix.
1692 # Unfortunately shared_library insists on creating the symlink…
1693 meson.add_install_script('sh', '-c',
1694 'rm $DESTDIR@0@/libnss_@1@.so'
1695 .format(rootlibdir, module))
1696
1697 if want_tests != 'false'
1698 test('dlopen-nss_' + module,
1699 test_dlopen,
1700 # path to dlopen must include a slash
1701 args : nss.full_path())
1702 endif
1703 endif
1704 endforeach
1705
1706 ############################################################
1707
1708 executable(
1709 'systemd',
1710 systemd_sources,
1711 include_directories : includes,
1712 link_with : [libcore,
1713 libshared],
1714 dependencies : [versiondep,
1715 threads,
1716 librt,
1717 libseccomp,
1718 libselinux,
1719 libmount,
1720 libblkid],
1721 install_rpath : rootlibexecdir,
1722 install : true,
1723 install_dir : rootlibexecdir)
1724
1725 meson.add_install_script(meson_make_symlink,
1726 join_paths(rootlibexecdir, 'systemd'),
1727 join_paths(rootsbindir, 'init'))
1728
1729 public_programs += executable(
1730 'systemd-analyze',
1731 systemd_analyze_sources,
1732 include_directories : includes,
1733 link_with : [libcore,
1734 libshared],
1735 dependencies : [versiondep,
1736 threads,
1737 librt,
1738 libseccomp,
1739 libselinux,
1740 libmount,
1741 libblkid],
1742 install_rpath : rootlibexecdir,
1743 install : get_option('analyze'))
1744
1745 executable(
1746 'systemd-journald',
1747 systemd_journald_sources,
1748 include_directories : includes,
1749 link_with : [libjournal_core,
1750 libshared],
1751 dependencies : [threads,
1752 libxz,
1753 liblz4,
1754 libselinux,
1755 libzstd],
1756 install_rpath : rootlibexecdir,
1757 install : true,
1758 install_dir : rootlibexecdir)
1759
1760 public_programs += executable(
1761 'systemd-cat',
1762 systemd_cat_sources,
1763 include_directories : includes,
1764 link_with : [libjournal_core,
1765 libshared],
1766 dependencies : [threads],
1767 install_rpath : rootlibexecdir,
1768 install : true)
1769
1770 public_programs += executable(
1771 'journalctl',
1772 journalctl_sources,
1773 include_directories : includes,
1774 link_with : [libshared],
1775 dependencies : [threads,
1776 libqrencode,
1777 libxz,
1778 liblz4,
1779 libpcre2,
1780 libzstd],
1781 install_rpath : rootlibexecdir,
1782 install : true,
1783 install_dir : rootbindir)
1784
1785 executable(
1786 'systemd-getty-generator',
1787 'src/getty-generator/getty-generator.c',
1788 include_directories : includes,
1789 link_with : [libshared],
1790 install_rpath : rootlibexecdir,
1791 install : true,
1792 install_dir : systemgeneratordir)
1793
1794 executable(
1795 'systemd-debug-generator',
1796 'src/debug-generator/debug-generator.c',
1797 include_directories : includes,
1798 link_with : [libshared],
1799 install_rpath : rootlibexecdir,
1800 install : true,
1801 install_dir : systemgeneratordir)
1802
1803 executable(
1804 'systemd-run-generator',
1805 'src/run-generator/run-generator.c',
1806 include_directories : includes,
1807 link_with : [libshared],
1808 install_rpath : rootlibexecdir,
1809 install : true,
1810 install_dir : systemgeneratordir)
1811
1812 executable(
1813 'systemd-fstab-generator',
1814 'src/fstab-generator/fstab-generator.c',
1815 include_directories : includes,
1816 link_with : [libcore_shared,
1817 libshared],
1818 install_rpath : rootlibexecdir,
1819 install : true,
1820 install_dir : systemgeneratordir)
1821
1822 if conf.get('ENABLE_ENVIRONMENT_D') == 1
1823 executable(
1824 '30-systemd-environment-d-generator',
1825 'src/environment-d-generator/environment-d-generator.c',
1826 include_directories : includes,
1827 link_with : [libshared],
1828 install_rpath : rootlibexecdir,
1829 install : true,
1830 install_dir : userenvgeneratordir)
1831
1832 meson.add_install_script(meson_make_symlink,
1833 join_paths(sysconfdir, 'environment'),
1834 join_paths(environmentdir, '99-environment.conf'))
1835 endif
1836
1837 if conf.get('ENABLE_HIBERNATE') == 1
1838 executable(
1839 'systemd-hibernate-resume-generator',
1840 'src/hibernate-resume/hibernate-resume-generator.c',
1841 include_directories : includes,
1842 link_with : [libshared],
1843 install_rpath : rootlibexecdir,
1844 install : true,
1845 install_dir : systemgeneratordir)
1846
1847 executable(
1848 'systemd-hibernate-resume',
1849 'src/hibernate-resume/hibernate-resume.c',
1850 include_directories : includes,
1851 link_with : [libshared],
1852 install_rpath : rootlibexecdir,
1853 install : true,
1854 install_dir : rootlibexecdir)
1855 endif
1856
1857 if conf.get('HAVE_BLKID') == 1
1858 executable(
1859 'systemd-gpt-auto-generator',
1860 'src/gpt-auto-generator/gpt-auto-generator.c',
1861 'src/shared/blkid-util.h',
1862 include_directories : includes,
1863 link_with : [libshared],
1864 dependencies : libblkid,
1865 install_rpath : rootlibexecdir,
1866 install : true,
1867 install_dir : systemgeneratordir)
1868
1869 public_programs += executable(
1870 'systemd-dissect',
1871 'src/dissect/dissect.c',
1872 include_directories : includes,
1873 link_with : [libshared],
1874 install_rpath : rootlibexecdir,
1875 install : true,
1876 install_dir : rootlibexecdir)
1877 endif
1878
1879 if conf.get('ENABLE_RESOLVE') == 1
1880 executable(
1881 'systemd-resolved',
1882 systemd_resolved_sources,
1883 include_directories : includes,
1884 link_with : [libshared,
1885 libbasic_gcrypt,
1886 libsystemd_resolve_core],
1887 dependencies : systemd_resolved_dependencies,
1888 install_rpath : rootlibexecdir,
1889 install : true,
1890 install_dir : rootlibexecdir)
1891
1892 public_programs += executable(
1893 'resolvectl',
1894 resolvectl_sources,
1895 include_directories : includes,
1896 link_with : [libshared,
1897 libbasic_gcrypt,
1898 libsystemd_resolve_core],
1899 dependencies : [threads,
1900 libgpg_error,
1901 libm,
1902 libidn],
1903 install_rpath : rootlibexecdir,
1904 install : true)
1905
1906 meson.add_install_script(meson_make_symlink,
1907 join_paths(bindir, 'resolvectl'),
1908 join_paths(rootsbindir, 'resolvconf'))
1909
1910 meson.add_install_script(meson_make_symlink,
1911 join_paths(bindir, 'resolvectl'),
1912 join_paths(bindir, 'systemd-resolve'))
1913 endif
1914
1915 if conf.get('ENABLE_LOGIND') == 1
1916 executable(
1917 'systemd-logind',
1918 systemd_logind_sources,
1919 include_directories : includes,
1920 link_with : [liblogind_core,
1921 libshared],
1922 dependencies : [threads,
1923 libacl],
1924 install_rpath : rootlibexecdir,
1925 install : true,
1926 install_dir : rootlibexecdir)
1927
1928 public_programs += executable(
1929 'loginctl',
1930 loginctl_sources,
1931 include_directories : includes,
1932 link_with : [libshared],
1933 dependencies : [threads,
1934 liblz4,
1935 libxz,
1936 libzstd],
1937 install_rpath : rootlibexecdir,
1938 install : true,
1939 install_dir : rootbindir)
1940
1941 public_programs += executable(
1942 'systemd-inhibit',
1943 'src/login/inhibit.c',
1944 include_directories : includes,
1945 link_with : [libshared],
1946 install_rpath : rootlibexecdir,
1947 install : true,
1948 install_dir : rootbindir)
1949
1950 if conf.get('HAVE_PAM') == 1
1951 version_script_arg = join_paths(project_source_root, pam_systemd_sym)
1952 pam_systemd = shared_library(
1953 'pam_systemd',
1954 pam_systemd_c,
1955 name_prefix : '',
1956 include_directories : includes,
1957 link_args : ['-shared',
1958 '-Wl,--version-script=' + version_script_arg],
1959 link_with : [libsystemd_static,
1960 libshared_static],
1961 dependencies : [threads,
1962 libpam,
1963 libpam_misc],
1964 link_depends : pam_systemd_sym,
1965 install : true,
1966 install_dir : pamlibdir)
1967
1968 if want_tests != 'false'
1969 test('dlopen-pam_systemd',
1970 test_dlopen,
1971 # path to dlopen must include a slash
1972 args : pam_systemd.full_path())
1973 endif
1974 endif
1975
1976 executable(
1977 'systemd-user-runtime-dir',
1978 user_runtime_dir_sources,
1979 include_directories : includes,
1980 link_with : [libshared],
1981 install_rpath : rootlibexecdir,
1982 install : true,
1983 install_dir : rootlibexecdir)
1984 endif
1985
1986 if conf.get('HAVE_PAM') == 1
1987 executable(
1988 'systemd-user-sessions',
1989 'src/user-sessions/user-sessions.c',
1990 include_directories : includes,
1991 link_with : [libshared],
1992 install_rpath : rootlibexecdir,
1993 install : true,
1994 install_dir : rootlibexecdir)
1995 endif
1996
1997 if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1998 public_programs += executable(
1999 'bootctl',
2000 'src/boot/bootctl.c',
2001 include_directories : includes,
2002 link_with : [libshared],
2003 dependencies : [libblkid],
2004 install_rpath : rootlibexecdir,
2005 install : true)
2006
2007 public_programs += executable(
2008 'systemd-bless-boot',
2009 'src/boot/bless-boot.c',
2010 include_directories : includes,
2011 link_with : [libshared],
2012 dependencies : [libblkid],
2013 install_rpath : rootlibexecdir,
2014 install : true,
2015 install_dir : rootlibexecdir)
2016
2017 executable(
2018 'systemd-bless-boot-generator',
2019 'src/boot/bless-boot-generator.c',
2020 include_directories : includes,
2021 link_with : [libshared],
2022 install_rpath : rootlibexecdir,
2023 install : true,
2024 install_dir : systemgeneratordir)
2025 endif
2026
2027 executable(
2028 'systemd-boot-check-no-failures',
2029 'src/boot/boot-check-no-failures.c',
2030 include_directories : includes,
2031 link_with : [libshared],
2032 dependencies : [libblkid],
2033 install_rpath : rootlibexecdir,
2034 install : true,
2035 install_dir : rootlibexecdir)
2036
2037 public_programs += executable(
2038 'systemd-socket-activate',
2039 'src/activate/activate.c',
2040 include_directories : includes,
2041 link_with : [libshared],
2042 dependencies : [threads],
2043 install_rpath : rootlibexecdir,
2044 install : true)
2045
2046 if get_option('link-systemctl-shared')
2047 systemctl_link_with = [libshared]
2048 else
2049 systemctl_link_with = [libsystemd_static,
2050 libshared_static,
2051 libjournal_client,
2052 libbasic_gcrypt]
2053 endif
2054
2055 public_programs += executable(
2056 'systemctl',
2057 'src/systemctl/systemctl.c',
2058 'src/systemctl/sysv-compat.h',
2059 'src/systemctl/sysv-compat.c',
2060 include_directories : includes,
2061 link_with : systemctl_link_with,
2062 dependencies : [threads,
2063 libcap,
2064 libselinux,
2065 libxz,
2066 liblz4,
2067 libzstd],
2068 install_rpath : rootlibexecdir,
2069 install : true,
2070 install_dir : rootbindir)
2071
2072 if conf.get('ENABLE_PORTABLED') == 1
2073 executable(
2074 'systemd-portabled',
2075 systemd_portabled_sources,
2076 include_directories : includes,
2077 link_with : [libshared],
2078 dependencies : [threads],
2079 install_rpath : rootlibexecdir,
2080 install : true,
2081 install_dir : rootlibexecdir)
2082
2083 public_programs += executable(
2084 'portablectl',
2085 'src/portable/portablectl.c',
2086 include_directories : includes,
2087 link_with : [libshared],
2088 dependencies : [threads],
2089 install_rpath : rootlibexecdir,
2090 install : true,
2091 install_dir : rootbindir)
2092 endif
2093
2094 if conf.get('ENABLE_USERDB') == 1
2095 executable(
2096 'systemd-userwork',
2097 systemd_userwork_sources,
2098 include_directories : includes,
2099 link_with : [libshared],
2100 dependencies : [threads],
2101 install_rpath : rootlibexecdir,
2102 install : true,
2103 install_dir : rootlibexecdir)
2104
2105 executable(
2106 'systemd-userdbd',
2107 systemd_userdbd_sources,
2108 include_directories : includes,
2109 link_with : [libshared],
2110 dependencies : [threads],
2111 install_rpath : rootlibexecdir,
2112 install : true,
2113 install_dir : rootlibexecdir)
2114
2115 public_programs += executable(
2116 'userdbctl',
2117 userdbctl_sources,
2118 include_directories : includes,
2119 link_with : [libshared],
2120 dependencies : [threads],
2121 install_rpath : rootlibexecdir,
2122 install : true,
2123 install_dir : rootbindir)
2124 endif
2125
2126 if conf.get('ENABLE_HOMED') == 1
2127 executable(
2128 'systemd-homework',
2129 systemd_homework_sources,
2130 include_directories : includes,
2131 link_with : [libshared],
2132 dependencies : [threads,
2133 libcryptsetup,
2134 libblkid,
2135 libcrypt,
2136 libopenssl,
2137 libfdisk,
2138 libp11kit],
2139 install_rpath : rootlibexecdir,
2140 install : true,
2141 install_dir : rootlibexecdir)
2142
2143 executable(
2144 'systemd-homed',
2145 systemd_homed_sources,
2146 include_directories : includes,
2147 link_with : [libshared],
2148 dependencies : [threads,
2149 libcrypt,
2150 libopenssl,
2151 libpwquality],
2152 install_rpath : rootlibexecdir,
2153 install : true,
2154 install_dir : rootlibexecdir)
2155
2156 public_programs += executable(
2157 'homectl',
2158 homectl_sources,
2159 include_directories : includes,
2160 link_with : [libshared],
2161 dependencies : [threads,
2162 libcrypt,
2163 libopenssl,
2164 libp11kit,
2165 libpwquality],
2166 install_rpath : rootlibexecdir,
2167 install : true,
2168 install_dir : rootbindir)
2169
2170 if conf.get('HAVE_PAM') == 1
2171 version_script_arg = join_paths(project_source_root, pam_systemd_home_sym)
2172 pam_systemd = shared_library(
2173 'pam_systemd_home',
2174 pam_systemd_home_c,
2175 name_prefix : '',
2176 include_directories : includes,
2177 link_args : ['-shared',
2178 '-Wl,--version-script=' + version_script_arg],
2179 link_with : [libsystemd_static,
2180 libshared_static],
2181 dependencies : [threads,
2182 libpam,
2183 libpam_misc,
2184 libcrypt],
2185 link_depends : pam_systemd_home_sym,
2186 install : true,
2187 install_dir : pamlibdir)
2188 endif
2189 endif
2190
2191 foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
2192 meson.add_install_script(meson_make_symlink,
2193 join_paths(rootbindir, 'systemctl'),
2194 join_paths(rootsbindir, alias))
2195 endforeach
2196
2197 if conf.get('ENABLE_BACKLIGHT') == 1
2198 executable(
2199 'systemd-backlight',
2200 'src/backlight/backlight.c',
2201 include_directories : includes,
2202 link_with : [libshared],
2203 install_rpath : rootlibexecdir,
2204 install : true,
2205 install_dir : rootlibexecdir)
2206 endif
2207
2208 if conf.get('ENABLE_RFKILL') == 1
2209 executable(
2210 'systemd-rfkill',
2211 'src/rfkill/rfkill.c',
2212 include_directories : includes,
2213 link_with : [libshared],
2214 install_rpath : rootlibexecdir,
2215 install : true,
2216 install_dir : rootlibexecdir)
2217 endif
2218
2219 executable(
2220 'systemd-system-update-generator',
2221 'src/system-update-generator/system-update-generator.c',
2222 include_directories : includes,
2223 link_with : [libshared],
2224 install_rpath : rootlibexecdir,
2225 install : true,
2226 install_dir : systemgeneratordir)
2227
2228 if conf.get('HAVE_LIBCRYPTSETUP') == 1
2229 systemd_cryptsetup_sources = files('''
2230 src/cryptsetup/cryptsetup.c
2231 src/cryptsetup/cryptsetup-pkcs11.h
2232 '''.split())
2233
2234 if conf.get('HAVE_P11KIT') == 1
2235 systemd_cryptsetup_sources += files('src/cryptsetup/cryptsetup-pkcs11.c')
2236 endif
2237
2238 executable(
2239 'systemd-cryptsetup',
2240 systemd_cryptsetup_sources,
2241 include_directories : includes,
2242 link_with : [libshared],
2243 dependencies : [libcryptsetup,
2244 libp11kit],
2245 install_rpath : rootlibexecdir,
2246 install : true,
2247 install_dir : rootlibexecdir)
2248
2249 executable(
2250 'systemd-cryptsetup-generator',
2251 'src/cryptsetup/cryptsetup-generator.c',
2252 include_directories : includes,
2253 link_with : [libshared],
2254 dependencies : [libcryptsetup],
2255 install_rpath : rootlibexecdir,
2256 install : true,
2257 install_dir : systemgeneratordir)
2258
2259 executable(
2260 'systemd-veritysetup',
2261 'src/veritysetup/veritysetup.c',
2262 include_directories : includes,
2263 link_with : [libshared],
2264 dependencies : [libcryptsetup],
2265 install_rpath : rootlibexecdir,
2266 install : true,
2267 install_dir : rootlibexecdir)
2268
2269 executable(
2270 'systemd-veritysetup-generator',
2271 'src/veritysetup/veritysetup-generator.c',
2272 include_directories : includes,
2273 link_with : [libshared],
2274 dependencies : [libcryptsetup],
2275 install_rpath : rootlibexecdir,
2276 install : true,
2277 install_dir : systemgeneratordir)
2278 endif
2279
2280 if conf.get('HAVE_SYSV_COMPAT') == 1
2281 executable(
2282 'systemd-sysv-generator',
2283 'src/sysv-generator/sysv-generator.c',
2284 include_directories : includes,
2285 link_with : [libshared],
2286 install_rpath : rootlibexecdir,
2287 install : true,
2288 install_dir : systemgeneratordir)
2289
2290 executable(
2291 'systemd-rc-local-generator',
2292 'src/rc-local-generator/rc-local-generator.c',
2293 include_directories : includes,
2294 link_with : [libshared],
2295 install_rpath : rootlibexecdir,
2296 install : true,
2297 install_dir : systemgeneratordir)
2298 endif
2299
2300 if conf.get('ENABLE_HOSTNAMED') == 1
2301 executable(
2302 'systemd-hostnamed',
2303 'src/hostname/hostnamed.c',
2304 include_directories : includes,
2305 link_with : [libshared],
2306 install_rpath : rootlibexecdir,
2307 install : true,
2308 install_dir : rootlibexecdir)
2309
2310 public_programs += executable(
2311 'hostnamectl',
2312 'src/hostname/hostnamectl.c',
2313 include_directories : includes,
2314 link_with : [libshared],
2315 install_rpath : rootlibexecdir,
2316 install : true)
2317 endif
2318
2319 if conf.get('ENABLE_LOCALED') == 1
2320 if conf.get('HAVE_XKBCOMMON') == 1
2321 # logind will load libxkbcommon.so dynamically on its own
2322 deps = [libdl]
2323 else
2324 deps = []
2325 endif
2326
2327 executable(
2328 'systemd-localed',
2329 systemd_localed_sources,
2330 include_directories : includes,
2331 link_with : [libshared],
2332 dependencies : deps,
2333 install_rpath : rootlibexecdir,
2334 install : true,
2335 install_dir : rootlibexecdir)
2336
2337 public_programs += executable(
2338 'localectl',
2339 localectl_sources,
2340 include_directories : includes,
2341 link_with : [libshared],
2342 install_rpath : rootlibexecdir,
2343 install : true)
2344 endif
2345
2346 if conf.get('ENABLE_TIMEDATED') == 1
2347 executable(
2348 'systemd-timedated',
2349 'src/timedate/timedated.c',
2350 include_directories : includes,
2351 link_with : [libshared],
2352 install_rpath : rootlibexecdir,
2353 install : true,
2354 install_dir : rootlibexecdir)
2355 endif
2356
2357 if conf.get('ENABLE_TIMEDATECTL') == 1
2358 public_programs += executable(
2359 'timedatectl',
2360 'src/timedate/timedatectl.c',
2361 include_directories : includes,
2362 install_rpath : rootlibexecdir,
2363 link_with : [libshared],
2364 dependencies : [libm],
2365 install : true)
2366 endif
2367
2368 if conf.get('ENABLE_TIMESYNCD') == 1
2369 if get_option('link-timesyncd-shared')
2370 timesyncd_link_with = [libshared]
2371 else
2372 timesyncd_link_with = [libsystemd_static,
2373 libshared_static,
2374 libjournal_client,
2375 libbasic_gcrypt]
2376 endif
2377
2378 executable(
2379 'systemd-timesyncd',
2380 systemd_timesyncd_sources,
2381 include_directories : includes,
2382 link_with : [timesyncd_link_with],
2383 dependencies : [threads,
2384 libm],
2385 install_rpath : rootlibexecdir,
2386 install : true,
2387 install_dir : rootlibexecdir)
2388
2389 executable(
2390 'systemd-time-wait-sync',
2391 'src/time-wait-sync/time-wait-sync.c',
2392 include_directories : includes,
2393 link_with : [timesyncd_link_with],
2394 install_rpath : rootlibexecdir,
2395 install : true,
2396 install_dir : rootlibexecdir)
2397 endif
2398
2399 if conf.get('ENABLE_MACHINED') == 1
2400 executable(
2401 'systemd-machined',
2402 systemd_machined_sources,
2403 include_directories : includes,
2404 link_with : [libmachine_core,
2405 libshared],
2406 install_rpath : rootlibexecdir,
2407 install : true,
2408 install_dir : rootlibexecdir)
2409
2410 public_programs += executable(
2411 'machinectl',
2412 'src/machine/machinectl.c',
2413 include_directories : includes,
2414 link_with : [libshared],
2415 dependencies : [threads,
2416 libxz,
2417 liblz4,
2418 libzstd],
2419 install_rpath : rootlibexecdir,
2420 install : true,
2421 install_dir : rootbindir)
2422 endif
2423
2424 if conf.get('ENABLE_IMPORTD') == 1
2425 executable(
2426 'systemd-importd',
2427 systemd_importd_sources,
2428 include_directories : includes,
2429 link_with : [libshared],
2430 dependencies : [threads],
2431 install_rpath : rootlibexecdir,
2432 install : true,
2433 install_dir : rootlibexecdir)
2434
2435 systemd_pull = executable(
2436 'systemd-pull',
2437 systemd_pull_sources,
2438 include_directories : includes,
2439 link_with : [libshared],
2440 dependencies : [versiondep,
2441 libcurl,
2442 libz,
2443 libbzip2,
2444 libxz,
2445 libgcrypt],
2446 install_rpath : rootlibexecdir,
2447 install : true,
2448 install_dir : rootlibexecdir)
2449
2450 systemd_import = executable(
2451 'systemd-import',
2452 systemd_import_sources,
2453 include_directories : includes,
2454 link_with : [libshared],
2455 dependencies : [libcurl,
2456 libz,
2457 libbzip2,
2458 libxz],
2459 install_rpath : rootlibexecdir,
2460 install : true,
2461 install_dir : rootlibexecdir)
2462
2463 systemd_import_fs = executable(
2464 'systemd-import-fs',
2465 systemd_import_fs_sources,
2466 include_directories : includes,
2467 link_with : [libshared],
2468 install_rpath : rootlibexecdir,
2469 install : true,
2470 install_dir : rootlibexecdir)
2471
2472 systemd_export = executable(
2473 'systemd-export',
2474 systemd_export_sources,
2475 include_directories : includes,
2476 link_with : [libshared],
2477 dependencies : [libcurl,
2478 libz,
2479 libbzip2,
2480 libxz],
2481 install_rpath : rootlibexecdir,
2482 install : true,
2483 install_dir : rootlibexecdir)
2484
2485 public_programs += [systemd_pull, systemd_import, systemd_import_fs, systemd_export]
2486 endif
2487
2488 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
2489 public_programs += executable(
2490 'systemd-journal-upload',
2491 systemd_journal_upload_sources,
2492 include_directories : includes,
2493 link_with : [libshared],
2494 dependencies : [versiondep,
2495 threads,
2496 libcurl,
2497 libgnutls,
2498 libxz,
2499 liblz4,
2500 libzstd],
2501 install_rpath : rootlibexecdir,
2502 install : true,
2503 install_dir : rootlibexecdir)
2504 endif
2505
2506 if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
2507 public_programs += executable(
2508 'systemd-journal-remote',
2509 systemd_journal_remote_sources,
2510 include_directories : includes,
2511 link_with : [libshared,
2512 libsystemd_journal_remote],
2513 dependencies : [threads,
2514 libmicrohttpd,
2515 libgnutls,
2516 libxz,
2517 liblz4,
2518 libzstd],
2519 install_rpath : rootlibexecdir,
2520 install : true,
2521 install_dir : rootlibexecdir)
2522
2523 public_programs += executable(
2524 'systemd-journal-gatewayd',
2525 systemd_journal_gatewayd_sources,
2526 include_directories : includes,
2527 link_with : [libshared],
2528 dependencies : [threads,
2529 libmicrohttpd,
2530 libgnutls,
2531 libxz,
2532 liblz4,
2533 libzstd],
2534 install_rpath : rootlibexecdir,
2535 install : true,
2536 install_dir : rootlibexecdir)
2537 endif
2538
2539 if conf.get('ENABLE_COREDUMP') == 1
2540 executable(
2541 'systemd-coredump',
2542 systemd_coredump_sources,
2543 include_directories : includes,
2544 link_with : [libshared],
2545 dependencies : [threads,
2546 libacl,
2547 libdw,
2548 libxz,
2549 liblz4,
2550 libzstd],
2551 install_rpath : rootlibexecdir,
2552 install : true,
2553 install_dir : rootlibexecdir)
2554
2555 public_programs += executable(
2556 'coredumpctl',
2557 coredumpctl_sources,
2558 include_directories : includes,
2559 link_with : [libshared],
2560 dependencies : [threads,
2561 libxz,
2562 liblz4,
2563 libzstd],
2564 install_rpath : rootlibexecdir,
2565 install : true)
2566 endif
2567
2568 if conf.get('ENABLE_PSTORE') == 1
2569 executable(
2570 'systemd-pstore',
2571 systemd_pstore_sources,
2572 include_directories : includes,
2573 link_with : [libshared],
2574 dependencies : [threads,
2575 libacl,
2576 libdw,
2577 libxz,
2578 liblz4,
2579 libzstd],
2580 install_rpath : rootlibexecdir,
2581 install : true,
2582 install_dir : rootlibexecdir)
2583 endif
2584
2585 if conf.get('ENABLE_BINFMT') == 1
2586 public_programs += executable(
2587 'systemd-binfmt',
2588 'src/binfmt/binfmt.c',
2589 include_directories : includes,
2590 link_with : [libshared],
2591 install_rpath : rootlibexecdir,
2592 install : true,
2593 install_dir : rootlibexecdir)
2594
2595 meson.add_install_script('sh', '-c',
2596 mkdir_p.format(binfmtdir))
2597 meson.add_install_script('sh', '-c',
2598 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
2599 endif
2600
2601 if conf.get('ENABLE_REPART') == 1
2602 exe = executable(
2603 'systemd-repart',
2604 systemd_repart_sources,
2605 include_directories : includes,
2606 link_with : [libshared],
2607 dependencies : [threads,
2608 libcryptsetup,
2609 libblkid,
2610 libfdisk,
2611 libopenssl],
2612 install_rpath : rootlibexecdir,
2613 install : true,
2614 install_dir : rootbindir)
2615
2616 if want_tests != 'false'
2617 test('test-repart',
2618 test_repart_sh,
2619 args : exe.full_path())
2620 endif
2621 endif
2622
2623 if conf.get('ENABLE_VCONSOLE') == 1
2624 executable(
2625 'systemd-vconsole-setup',
2626 'src/vconsole/vconsole-setup.c',
2627 include_directories : includes,
2628 link_with : [libshared],
2629 install_rpath : rootlibexecdir,
2630 install : true,
2631 install_dir : rootlibexecdir)
2632 endif
2633
2634 if conf.get('ENABLE_RANDOMSEED') == 1
2635 executable(
2636 'systemd-random-seed',
2637 'src/random-seed/random-seed.c',
2638 include_directories : includes,
2639 link_with : [libshared],
2640 install_rpath : rootlibexecdir,
2641 install : true,
2642 install_dir : rootlibexecdir)
2643 endif
2644
2645 if conf.get('ENABLE_FIRSTBOOT') == 1
2646 executable(
2647 'systemd-firstboot',
2648 'src/firstboot/firstboot.c',
2649 include_directories : includes,
2650 link_with : [libshared],
2651 dependencies : [libcrypt],
2652 install_rpath : rootlibexecdir,
2653 install : true,
2654 install_dir : rootbindir)
2655 endif
2656
2657 executable(
2658 'systemd-remount-fs',
2659 'src/remount-fs/remount-fs.c',
2660 include_directories : includes,
2661 link_with : [libcore_shared,
2662 libshared],
2663 install_rpath : rootlibexecdir,
2664 install : true,
2665 install_dir : rootlibexecdir)
2666
2667 executable(
2668 'systemd-machine-id-setup',
2669 'src/machine-id-setup/machine-id-setup-main.c',
2670 include_directories : includes,
2671 link_with : [libcore_shared,
2672 libshared],
2673 install_rpath : rootlibexecdir,
2674 install : true,
2675 install_dir : rootbindir)
2676
2677 executable(
2678 'systemd-fsck',
2679 'src/fsck/fsck.c',
2680 include_directories : includes,
2681 link_with : [libshared],
2682 install_rpath : rootlibexecdir,
2683 install : true,
2684 install_dir : rootlibexecdir)
2685
2686 executable('systemd-growfs',
2687 'src/partition/growfs.c',
2688 include_directories : includes,
2689 link_with : [libshared],
2690 dependencies : [libcryptsetup],
2691 install_rpath : rootlibexecdir,
2692 install : true,
2693 install_dir : rootlibexecdir)
2694
2695 executable(
2696 'systemd-makefs',
2697 'src/partition/makefs.c',
2698 include_directories : includes,
2699 link_with : [libshared],
2700 install_rpath : rootlibexecdir,
2701 install : true,
2702 install_dir : rootlibexecdir)
2703
2704 executable(
2705 'systemd-sleep',
2706 'src/sleep/sleep.c',
2707 include_directories : includes,
2708 link_with : [libshared],
2709 install_rpath : rootlibexecdir,
2710 install : true,
2711 install_dir : rootlibexecdir)
2712
2713 install_data('src/sleep/sleep.conf',
2714 install_dir : pkgsysconfdir)
2715
2716 public_programs += executable(
2717 'systemd-sysctl',
2718 'src/sysctl/sysctl.c',
2719 include_directories : includes,
2720 link_with : [libshared],
2721 install_rpath : rootlibexecdir,
2722 install : true,
2723 install_dir : rootlibexecdir)
2724
2725 executable(
2726 'systemd-ac-power',
2727 'src/ac-power/ac-power.c',
2728 include_directories : includes,
2729 link_with : [libshared],
2730 install_rpath : rootlibexecdir,
2731 install : true,
2732 install_dir : rootlibexecdir)
2733
2734 public_programs += executable(
2735 'systemd-detect-virt',
2736 'src/detect-virt/detect-virt.c',
2737 include_directories : includes,
2738 link_with : [libshared],
2739 install_rpath : rootlibexecdir,
2740 install : true)
2741
2742 public_programs += executable(
2743 'systemd-delta',
2744 'src/delta/delta.c',
2745 include_directories : includes,
2746 link_with : [libshared],
2747 install_rpath : rootlibexecdir,
2748 install : true)
2749
2750 public_programs += executable(
2751 'systemd-escape',
2752 'src/escape/escape.c',
2753 include_directories : includes,
2754 link_with : [libshared],
2755 install_rpath : rootlibexecdir,
2756 install : true,
2757 install_dir : rootbindir)
2758
2759 public_programs += executable(
2760 'systemd-notify',
2761 'src/notify/notify.c',
2762 include_directories : includes,
2763 link_with : [libshared],
2764 install_rpath : rootlibexecdir,
2765 install : true,
2766 install_dir : rootbindir)
2767
2768 executable(
2769 'systemd-volatile-root',
2770 'src/volatile-root/volatile-root.c',
2771 include_directories : includes,
2772 link_with : [libshared],
2773 install_rpath : rootlibexecdir,
2774 install : conf.get('ENABLE_INITRD') == 1,
2775 install_dir : rootlibexecdir)
2776
2777 executable(
2778 'systemd-cgroups-agent',
2779 'src/cgroups-agent/cgroups-agent.c',
2780 include_directories : includes,
2781 link_with : [libshared],
2782 install_rpath : rootlibexecdir,
2783 install : true,
2784 install_dir : rootlibexecdir)
2785
2786 public_programs += executable(
2787 'systemd-id128',
2788 'src/id128/id128.c',
2789 include_directories : includes,
2790 link_with : [libshared],
2791 install_rpath : rootlibexecdir,
2792 install : true)
2793
2794 public_programs += executable(
2795 'systemd-path',
2796 'src/path/path.c',
2797 include_directories : includes,
2798 link_with : [libshared],
2799 install_rpath : rootlibexecdir,
2800 install : true)
2801
2802 public_programs += executable(
2803 'systemd-ask-password',
2804 'src/ask-password/ask-password.c',
2805 include_directories : includes,
2806 link_with : [libshared],
2807 install_rpath : rootlibexecdir,
2808 install : true,
2809 install_dir : rootbindir)
2810
2811 executable(
2812 'systemd-reply-password',
2813 'src/reply-password/reply-password.c',
2814 include_directories : includes,
2815 link_with : [libshared],
2816 install_rpath : rootlibexecdir,
2817 install : true,
2818 install_dir : rootlibexecdir)
2819
2820 public_programs += executable(
2821 'systemd-tty-ask-password-agent',
2822 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2823 include_directories : includes,
2824 link_with : [libshared],
2825 install_rpath : rootlibexecdir,
2826 install : true,
2827 install_dir : rootbindir)
2828
2829 public_programs += executable(
2830 'systemd-cgls',
2831 'src/cgls/cgls.c',
2832 include_directories : includes,
2833 link_with : [libshared],
2834 install_rpath : rootlibexecdir,
2835 install : true)
2836
2837 public_programs += executable(
2838 'systemd-cgtop',
2839 'src/cgtop/cgtop.c',
2840 include_directories : includes,
2841 link_with : [libshared],
2842 install_rpath : rootlibexecdir,
2843 install : true)
2844
2845 executable(
2846 'systemd-initctl',
2847 'src/initctl/initctl.c',
2848 include_directories : includes,
2849 link_with : [libshared],
2850 install_rpath : rootlibexecdir,
2851 install : true,
2852 install_dir : rootlibexecdir)
2853
2854 public_programs += executable(
2855 'systemd-mount',
2856 'src/mount/mount-tool.c',
2857 include_directories : includes,
2858 link_with : [libshared],
2859 dependencies: [libmount],
2860 install_rpath : rootlibexecdir,
2861 install : true)
2862
2863 meson.add_install_script(meson_make_symlink,
2864 'systemd-mount', join_paths(bindir, 'systemd-umount'))
2865
2866 public_programs += executable(
2867 'systemd-run',
2868 'src/run/run.c',
2869 include_directories : includes,
2870 link_with : [libshared],
2871 install_rpath : rootlibexecdir,
2872 install : true)
2873
2874 public_programs += executable(
2875 'systemd-stdio-bridge',
2876 'src/stdio-bridge/stdio-bridge.c',
2877 include_directories : includes,
2878 link_with : [libshared],
2879 dependencies : [versiondep],
2880 install_rpath : rootlibexecdir,
2881 install : true)
2882
2883 public_programs += executable(
2884 'busctl',
2885 'src/busctl/busctl.c',
2886 'src/busctl/busctl-introspect.c',
2887 'src/busctl/busctl-introspect.h',
2888 include_directories : includes,
2889 link_with : [libshared],
2890 install_rpath : rootlibexecdir,
2891 install : true)
2892
2893 if conf.get('ENABLE_SYSUSERS') == 1
2894 public_programs += executable(
2895 'systemd-sysusers',
2896 'src/sysusers/sysusers.c',
2897 include_directories : includes,
2898 link_with : [libshared],
2899 install_rpath : rootlibexecdir,
2900 install : true,
2901 install_dir : rootbindir)
2902 endif
2903
2904 if conf.get('ENABLE_TMPFILES') == 1
2905 exe = executable(
2906 'systemd-tmpfiles',
2907 'src/tmpfiles/tmpfiles.c',
2908 'src/tmpfiles/offline-passwd.c',
2909 'src/tmpfiles/offline-passwd.h',
2910 include_directories : includes,
2911 link_with : [libshared],
2912 dependencies : [libacl],
2913 install_rpath : rootlibexecdir,
2914 install : true,
2915 install_dir : rootbindir)
2916 public_programs += exe
2917
2918 if want_tests != 'false'
2919 test('test-systemd-tmpfiles',
2920 test_systemd_tmpfiles_py,
2921 # https://github.com/mesonbuild/meson/issues/2681
2922 args : exe.full_path())
2923 endif
2924 endif
2925
2926 if conf.get('ENABLE_HWDB') == 1
2927 public_programs += executable(
2928 'systemd-hwdb',
2929 'src/hwdb/hwdb.c',
2930 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2931 include_directories : includes,
2932 link_with : [libudev_static],
2933 install_rpath : udev_rpath,
2934 install : true,
2935 install_dir : rootbindir)
2936 endif
2937
2938 if conf.get('ENABLE_QUOTACHECK') == 1
2939 executable(
2940 'systemd-quotacheck',
2941 'src/quotacheck/quotacheck.c',
2942 include_directories : includes,
2943 link_with : [libshared],
2944 install_rpath : rootlibexecdir,
2945 install : true,
2946 install_dir : rootlibexecdir)
2947 endif
2948
2949 public_programs += executable(
2950 'systemd-socket-proxyd',
2951 'src/socket-proxy/socket-proxyd.c',
2952 include_directories : includes,
2953 link_with : [libshared],
2954 dependencies : [threads],
2955 install_rpath : rootlibexecdir,
2956 install : true,
2957 install_dir : rootlibexecdir)
2958
2959 public_programs += executable(
2960 'systemd-udevd',
2961 systemd_udevd_sources,
2962 include_directories : includes,
2963 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
2964 link_with : [libudev_core,
2965 libsystemd_network,
2966 libudev_static],
2967 dependencies : [versiondep,
2968 threads,
2969 libkmod,
2970 libidn,
2971 libacl,
2972 libblkid],
2973 install_rpath : udev_rpath,
2974 install : true,
2975 install_dir : rootlibexecdir)
2976
2977 public_programs += executable(
2978 'udevadm',
2979 udevadm_sources,
2980 c_args : '-DLOG_REALM=LOG_REALM_UDEV',
2981 include_directories : includes,
2982 link_with : [libudev_core,
2983 libsystemd_network,
2984 libudev_static],
2985 dependencies : [versiondep,
2986 threads,
2987 libkmod,
2988 libidn,
2989 libacl,
2990 libblkid],
2991 install_rpath : udev_rpath,
2992 install : true,
2993 install_dir : rootbindir)
2994
2995 executable(
2996 'systemd-shutdown',
2997 systemd_shutdown_sources,
2998 include_directories : includes,
2999 link_with : [libcore_shared,
3000 libshared],
3001 dependencies : [libmount],
3002 install_rpath : rootlibexecdir,
3003 install : true,
3004 install_dir : rootlibexecdir)
3005
3006 executable(
3007 'systemd-update-done',
3008 'src/update-done/update-done.c',
3009 include_directories : includes,
3010 link_with : [libshared],
3011 install_rpath : rootlibexecdir,
3012 install : true,
3013 install_dir : rootlibexecdir)
3014
3015 executable(
3016 'systemd-update-utmp',
3017 'src/update-utmp/update-utmp.c',
3018 include_directories : includes,
3019 link_with : [libshared],
3020 dependencies : [libaudit],
3021 install_rpath : rootlibexecdir,
3022 install : true,
3023 install_dir : rootlibexecdir)
3024
3025 if conf.get('HAVE_KMOD') == 1
3026 executable(
3027 'systemd-modules-load',
3028 'src/modules-load/modules-load.c',
3029 include_directories : includes,
3030 link_with : [libshared],
3031 dependencies : [libkmod],
3032 install_rpath : rootlibexecdir,
3033 install : true,
3034 install_dir : rootlibexecdir)
3035
3036 meson.add_install_script('sh', '-c',
3037 mkdir_p.format(modulesloaddir))
3038 meson.add_install_script('sh', '-c',
3039 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
3040 endif
3041
3042 public_programs += executable(
3043 'systemd-nspawn',
3044 systemd_nspawn_sources,
3045 include_directories : includes,
3046 link_with : [libcore_shared,
3047 libnspawn_core,
3048 libshared],
3049 dependencies : [libblkid,
3050 libseccomp],
3051 install_rpath : rootlibexecdir,
3052 install : true)
3053
3054 if conf.get('ENABLE_NETWORKD') == 1
3055 executable(
3056 'systemd-networkd',
3057 systemd_networkd_sources,
3058 include_directories : network_include_dir,
3059 link_with : [libnetworkd_core,
3060 libsystemd_network,
3061 libudev_static,
3062 networkd_link_with],
3063 dependencies : [threads],
3064 install_rpath : rootlibexecdir,
3065 install : true,
3066 install_dir : rootlibexecdir)
3067
3068 executable(
3069 'systemd-networkd-wait-online',
3070 systemd_networkd_wait_online_sources,
3071 include_directories : includes,
3072 link_with : [libnetworkd_core,
3073 networkd_link_with],
3074 install_rpath : rootlibexecdir,
3075 install : true,
3076 install_dir : rootlibexecdir)
3077
3078 public_programs += executable(
3079 'networkctl',
3080 networkctl_sources,
3081 include_directories : includes,
3082 link_with : [libsystemd_network,
3083 networkd_link_with],
3084 install_rpath : rootlibexecdir,
3085 install : true,
3086 install_dir : rootbindir)
3087
3088 exe = executable(
3089 'systemd-network-generator',
3090 network_generator_sources,
3091 include_directories : includes,
3092 link_with : [networkd_link_with],
3093 install_rpath : rootlibexecdir,
3094 install : true,
3095 install_dir : rootlibexecdir)
3096
3097 if want_tests != 'false'
3098 test('test-network-generator-conversion',
3099 test_network_generator_conversion_sh,
3100 # https://github.com/mesonbuild/meson/issues/2681
3101 args : exe.full_path())
3102 endif
3103 endif
3104
3105 executable(
3106 'systemd-sulogin-shell',
3107 ['src/sulogin-shell/sulogin-shell.c'],
3108 include_directories : includes,
3109 link_with : [libshared],
3110 install_rpath : rootlibexecdir,
3111 install : true,
3112 install_dir : rootlibexecdir)
3113
3114 ############################################################
3115
3116 custom_target(
3117 'systemd-runtest.env',
3118 output : 'systemd-runtest.env',
3119 command : ['sh', '-c', '{ ' +
3120 'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(project_source_root, 'test')) +
3121 'echo SYSTEMD_CATALOG_DIR=@0@; '.format(join_paths(project_build_root, 'catalog')) +
3122 '} >@OUTPUT@'],
3123 build_by_default : true)
3124
3125 foreach tuple : tests
3126 sources = tuple[0]
3127 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
3128 dependencies = tuple[2]
3129 condition = tuple.length() >= 4 ? tuple[3] : ''
3130 type = tuple.length() >= 5 ? tuple[4] : ''
3131 defs = tuple.length() >= 6 ? tuple[5] : []
3132 incs = tuple.length() >= 7 ? tuple[6] : includes
3133 timeout = 30
3134
3135 name = sources[0].split('/')[-1].split('.')[0]
3136 if type.startswith('timeout=')
3137 timeout = type.split('=')[1].to_int()
3138 type = ''
3139 endif
3140
3141 if condition == '' or conf.get(condition) == 1
3142 exe = executable(
3143 name,
3144 sources,
3145 include_directories : incs,
3146 link_with : link_with,
3147 dependencies : [versiondep,
3148 dependencies],
3149 c_args : defs,
3150 build_by_default : want_tests != 'false',
3151 install_rpath : rootlibexecdir,
3152 install : install_tests,
3153 install_dir : join_paths(testsdir, type))
3154
3155 if type == 'manual'
3156 message('@0@ is a manual test'.format(name))
3157 elif type == 'unsafe' and want_tests != 'unsafe'
3158 message('@0@ is an unsafe test'.format(name))
3159 elif want_tests != 'false'
3160 test(name, exe,
3161 env : test_env,
3162 timeout : timeout)
3163 endif
3164 else
3165 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
3166 endif
3167 endforeach
3168
3169 exe = executable(
3170 'test-libsystemd-sym',
3171 test_libsystemd_sym_c,
3172 include_directories : includes,
3173 link_with : [libsystemd],
3174 build_by_default : want_tests != 'false',
3175 install : install_tests,
3176 install_dir : testsdir)
3177 if want_tests != 'false'
3178 test('test-libsystemd-sym', exe)
3179 endif
3180
3181 exe = executable(
3182 'test-libsystemd-static-sym',
3183 test_libsystemd_sym_c,
3184 include_directories : includes,
3185 link_with : [install_libsystemd_static],
3186 dependencies : [threads], # threads is already included in dependencies on the library,
3187 # but does not seem to get propagated. Add here as a work-around.
3188 build_by_default : want_tests != 'false' and static_libsystemd_pic,
3189 install : install_tests and static_libsystemd_pic,
3190 install_dir : testsdir)
3191 if want_tests != 'false' and static_libsystemd_pic
3192 test('test-libsystemd-static-sym', exe)
3193 endif
3194
3195 exe = executable(
3196 'test-libudev-sym',
3197 test_libudev_sym_c,
3198 include_directories : includes,
3199 c_args : '-Wno-deprecated-declarations',
3200 link_with : [libudev],
3201 build_by_default : want_tests != 'false',
3202 install : install_tests,
3203 install_dir : testsdir)
3204 if want_tests != 'false'
3205 test('test-libudev-sym', exe)
3206 endif
3207
3208 exe = executable(
3209 'test-libudev-static-sym',
3210 test_libudev_sym_c,
3211 include_directories : includes,
3212 c_args : '-Wno-deprecated-declarations',
3213 link_with : [install_libudev_static],
3214 build_by_default : want_tests != 'false' and static_libudev_pic,
3215 install : install_tests and static_libudev_pic,
3216 install_dir : testsdir)
3217 if want_tests != 'false' and static_libudev_pic
3218 test('test-libudev-static-sym', exe)
3219 endif
3220
3221 ############################################################
3222
3223 fuzzer_exes = []
3224
3225 if get_option('tests') != 'false'
3226 foreach tuple : fuzzers
3227 sources = tuple[0]
3228 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
3229 dependencies = tuple[2]
3230 defs = tuple.length() >= 4 ? tuple[3] : []
3231 incs = tuple.length() >= 5 ? tuple[4] : includes
3232 link_args = []
3233
3234 if want_ossfuzz
3235 dependencies += fuzzing_engine
3236 elif want_libfuzzer
3237 if fuzzing_engine.found()
3238 dependencies += fuzzing_engine
3239 else
3240 link_args += ['-fsanitize=fuzzer']
3241 endif
3242 else
3243 sources += 'src/fuzz/fuzz-main.c'
3244 endif
3245
3246 name = sources[0].split('/')[-1].split('.')[0]
3247
3248 fuzzer_exes += executable(
3249 name,
3250 sources,
3251 include_directories : [incs, include_directories('src/fuzz')],
3252 link_with : link_with,
3253 dependencies : dependencies,
3254 c_args : defs,
3255 link_args: link_args,
3256 install : false)
3257 endforeach
3258 endif
3259
3260 run_target(
3261 'fuzzers',
3262 depends : fuzzer_exes,
3263 command : ['true'])
3264
3265 ############################################################
3266
3267 make_directive_index_py = find_program('tools/make-directive-index.py')
3268 make_man_index_py = find_program('tools/make-man-index.py')
3269 xml_helper_py = find_program('tools/xml_helper.py')
3270 hwdb_update_sh = find_program('tools/hwdb-update.sh')
3271 autosuspend_update_sh = find_program('tools/autosuspend-update.sh')
3272
3273 subdir('sysctl.d')
3274 subdir('sysusers.d')
3275 subdir('tmpfiles.d')
3276 subdir('hwdb.d')
3277 subdir('units')
3278 subdir('presets')
3279 subdir('network')
3280 subdir('man')
3281 subdir('shell-completion/bash')
3282 subdir('shell-completion/zsh')
3283 subdir('docs/sysvinit')
3284 subdir('docs/var-log')
3285
3286 install_subdir('factory/etc',
3287 install_dir : factorydir)
3288
3289 install_data('xorg/50-systemd-user.sh',
3290 install_dir : xinitrcdir)
3291 install_data('modprobe.d/systemd.conf',
3292 install_dir : modprobedir)
3293 install_data('LICENSE.GPL2',
3294 'LICENSE.LGPL2.1',
3295 'NEWS',
3296 'README',
3297 'docs/CODING_STYLE.md',
3298 'docs/DISTRO_PORTING.md',
3299 'docs/ENVIRONMENT.md',
3300 'docs/HACKING.md',
3301 'docs/TRANSIENT-SETTINGS.md',
3302 'docs/TRANSLATORS.md',
3303 'docs/UIDS-GIDS.md',
3304 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
3305 install_dir : docdir)
3306
3307 meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
3308 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
3309
3310 ############################################################
3311
3312 check_help = find_program('tools/check-help.sh')
3313
3314 foreach exec : public_programs
3315 name = exec.full_path().split('/')[-1]
3316 if want_tests != 'false'
3317 test('check-help-' + name,
3318 check_help,
3319 args : exec.full_path())
3320 endif
3321 endforeach
3322
3323 ############################################################
3324
3325 check_directives_sh = find_program('tools/check-directives.sh')
3326
3327 if want_tests != 'false'
3328 test('check-directives',
3329 check_directives_sh,
3330 args : project_source_root)
3331 endif
3332
3333 ############################################################
3334
3335 # Enable tests for all supported sanitizers
3336 foreach tuple : sanitizers
3337 sanitizer = tuple[0]
3338 build = tuple[1]
3339
3340 if cc.has_link_argument('-fsanitize=@0@'.format(sanitizer))
3341 prev = ''
3342 foreach p : fuzz_regression_tests
3343 b = p.split('/')[-2]
3344 c = p.split('/')[-1]
3345
3346 name = '@0@:@1@'.format(b, sanitizer)
3347
3348 if name != prev
3349 if want_tests == 'false'
3350 message('Not compiling @0@ because tests is set to false'.format(name))
3351 elif slow_tests
3352 exe = custom_target(
3353 name,
3354 output : name,
3355 depends : build,
3356 command : [env, 'ln', '-fs',
3357 join_paths(build.full_path(), b),
3358 '@OUTPUT@'],
3359 build_by_default : true)
3360 else
3361 message('Not compiling @0@ because slow-tests is set to false'.format(name))
3362 endif
3363 endif
3364 prev = name
3365
3366 if want_tests != 'false' and slow_tests
3367 test('@0@:@1@:@2@'.format(b, c, sanitizer),
3368 env,
3369 args : [exe.full_path(),
3370 join_paths(project_source_root, p)])
3371 endif
3372 endforeach
3373 endif
3374 endforeach
3375
3376
3377 ############################################################
3378
3379 if git.found()
3380 all_files = run_command(
3381 git,
3382 ['--git-dir=@0@/.git'.format(project_source_root),
3383 'ls-files',
3384 ':/*.[ch]'])
3385 all_files = files(all_files.stdout().split())
3386
3387 custom_target(
3388 'tags',
3389 output : 'tags',
3390 command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
3391 run_target(
3392 'ctags',
3393 command : [env, 'ctags', '-o', '@0@/tags'.format(project_source_root)] + all_files)
3394 endif
3395
3396 if git.found()
3397 git_contrib_sh = find_program('tools/git-contrib.sh')
3398 run_target(
3399 'git-contrib',
3400 command : [git_contrib_sh])
3401 endif
3402
3403 if git.found()
3404 git_head = run_command(
3405 git,
3406 ['--git-dir=@0@/.git'.format(project_source_root),
3407 'rev-parse', 'HEAD']).stdout().strip()
3408 git_head_short = run_command(
3409 git,
3410 ['--git-dir=@0@/.git'.format(project_source_root),
3411 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
3412
3413 run_target(
3414 'git-snapshot',
3415 command : ['git', 'archive',
3416 '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root,
3417 git_head_short),
3418 '--prefix', 'systemd-@0@/'.format(git_head),
3419 'HEAD'])
3420 endif
3421
3422 ############################################################
3423
3424 check_api_docs_sh = find_program('tools/check-api-docs.sh')
3425 run_target(
3426 'check-api-docs',
3427 depends : [man, libsystemd, libudev],
3428 command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
3429
3430 ############################################################
3431 watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog
3432
3433 status = [
3434 '@0@ @1@'.format(meson.project_name(), meson.project_version()),
3435
3436 'split /usr: @0@'.format(split_usr),
3437 'split bin-sbin: @0@'.format(split_bin),
3438 'prefix directory: @0@'.format(prefixdir),
3439 'rootprefix directory: @0@'.format(rootprefixdir),
3440 'sysconf directory: @0@'.format(sysconfdir),
3441 'include directory: @0@'.format(includedir),
3442 'lib directory: @0@'.format(libdir),
3443 'rootlib directory: @0@'.format(rootlibdir),
3444 'SysV init scripts: @0@'.format(sysvinit_path),
3445 'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
3446 'PAM modules directory: @0@'.format(pamlibdir),
3447 'PAM configuration directory: @0@'.format(pamconfdir),
3448 'RPM macros directory: @0@'.format(rpmmacrosdir),
3449 'modprobe.d directory: @0@'.format(modprobedir),
3450 'D-Bus policy directory: @0@'.format(dbuspolicydir),
3451 'D-Bus session directory: @0@'.format(dbussessionservicedir),
3452 'D-Bus system directory: @0@'.format(dbussystemservicedir),
3453 'bash completions directory: @0@'.format(bashcompletiondir),
3454 'zsh completions directory: @0@'.format(zshcompletiondir),
3455 'extra start script: @0@'.format(get_option('rc-local')),
3456 'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
3457 get_option('debug-tty')),
3458 'TTY GID: @0@'.format(tty_gid),
3459 'users GID: @0@'.format(substs.get('USERS_GID')),
3460 'maximum system UID: @0@'.format(system_uid_max),
3461 'maximum system GID: @0@'.format(system_gid_max),
3462 'minimum dynamic UID: @0@'.format(dynamic_uid_min),
3463 'maximum dynamic UID: @0@'.format(dynamic_uid_max),
3464 'minimum container UID base: @0@'.format(container_uid_base_min),
3465 'maximum container UID base: @0@'.format(container_uid_base_max),
3466 '/dev/kvm access mode: @0@'.format(get_option('dev-kvm-mode')),
3467 'render group access mode: @0@'.format(get_option('group-render-mode')),
3468 'certificate root directory: @0@'.format(get_option('certificate-root')),
3469 'support URL: @0@'.format(support_url),
3470 'nobody user name: @0@'.format(nobody_user),
3471 'nobody group name: @0@'.format(nobody_group),
3472 'fallback hostname: @0@'.format(get_option('fallback-hostname')),
3473 'symbolic gateway hostnames: @0@'.format(', '.join(gateway_hostnames)),
3474
3475 'default DNSSEC mode: @0@'.format(default_dnssec),
3476 'default DNS-over-TLS mode: @0@'.format(default_dns_over_tls),
3477 'default mDNS mode: @0@'.format(default_mdns),
3478 'default LLMNR mode: @0@'.format(default_llmnr),
3479 'default cgroup hierarchy: @0@'.format(default_hierarchy),
3480 'default net.naming-scheme setting: @0@'.format(default_net_naming_scheme),
3481 'default KillUserProcesses setting: @0@'.format(kill_user_processes),
3482 'default locale: @0@'.format(default_locale),
3483 'default user $PATH: @0@'.format(default_user_path_display),
3484 'systemd service watchdog: @0@'.format(watchdog_opt)]
3485
3486 alt_dns_servers = '\n '.join(dns_servers.split(' '))
3487 alt_ntp_servers = '\n '.join(ntp_servers.split(' '))
3488 status += [
3489 'default DNS servers: @0@'.format(alt_dns_servers),
3490 'default NTP servers: @0@'.format(alt_ntp_servers)]
3491
3492 alt_time_epoch = run_command('date', '-Is', '-u', '-d',
3493 '@@0@'.format(time_epoch)).stdout().strip()
3494 status += [
3495 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
3496
3497 status += [
3498 'static libsystemd: @0@'.format(static_libsystemd),
3499 'static libudev: @0@'.format(static_libudev)]
3500
3501 # TODO:
3502 # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
3503 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
3504 # LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
3505
3506 if conf.get('ENABLE_EFI') == 1
3507 status += 'efi arch: @0@'.format(efi_arch)
3508
3509 if have_gnu_efi
3510 status += [
3511 'EFI machine type: @0@'.format(EFI_MACHINE_TYPE_NAME),
3512 'EFI CC @0@'.format(' '.join(efi_cc)),
3513 'EFI lds: @0@'.format(efi_lds),
3514 'EFI crt0: @0@'.format(efi_crt0),
3515 'EFI include directory: @0@'.format(efi_incdir)]
3516 endif
3517 endif
3518
3519 found = []
3520 missing = []
3521
3522 foreach tuple : [
3523 ['libcryptsetup'],
3524 ['PAM'],
3525 ['pwquality'],
3526 ['libfdisk'],
3527 ['p11kit'],
3528 ['AUDIT'],
3529 ['IMA'],
3530 ['AppArmor'],
3531 ['SELinux'],
3532 ['SECCOMP'],
3533 ['SMACK'],
3534 ['zlib'],
3535 ['xz'],
3536 ['zstd'],
3537 ['lz4'],
3538 ['bzip2'],
3539 ['ACL'],
3540 ['gcrypt'],
3541 ['qrencode'],
3542 ['microhttpd'],
3543 ['gnutls'],
3544 ['openssl'],
3545 ['libcurl'],
3546 ['idn'],
3547 ['initrd'],
3548 ['libidn2'],
3549 ['libidn'],
3550 ['libiptc'],
3551 ['elfutils'],
3552 ['binfmt'],
3553 ['repart'],
3554 ['vconsole'],
3555 ['quotacheck'],
3556 ['tmpfiles'],
3557 ['environment.d'],
3558 ['sysusers'],
3559 ['firstboot'],
3560 ['randomseed'],
3561 ['backlight'],
3562 ['rfkill'],
3563 ['logind'],
3564 ['machined'],
3565 ['portabled'],
3566 ['userdb'],
3567 ['homed'],
3568 ['importd'],
3569 ['hostnamed'],
3570 ['timedated'],
3571 ['timesyncd'],
3572 ['localed'],
3573 ['networkd'],
3574 ['resolve'],
3575 ['DNS-over-TLS(gnutls)', conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1],
3576 ['DNS-over-TLS(openssl)', conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1],
3577 ['coredump'],
3578 ['pstore'],
3579 ['polkit'],
3580 ['legacy pkla', install_polkit_pkla],
3581 ['efi'],
3582 ['gnu-efi', have_gnu_efi],
3583 ['kmod'],
3584 ['xkbcommon'],
3585 ['pcre2'],
3586 ['blkid'],
3587 ['dbus'],
3588 ['glib'],
3589 ['nss-myhostname'],
3590 ['nss-mymachines'],
3591 ['nss-resolve'],
3592 ['nss-systemd'],
3593 ['hwdb'],
3594 ['tpm'],
3595 ['man pages', want_man],
3596 ['html pages', want_html],
3597 ['man page indices', want_man and have_lxml],
3598 ['SysV compat'],
3599 ['utmp'],
3600 ['ldconfig'],
3601 ['hibernate'],
3602 ['adm group', get_option('adm-group')],
3603 ['wheel group', get_option('wheel-group')],
3604 ['gshadow'],
3605 ['debug hashmap'],
3606 ['debug mmap cache'],
3607 ['debug siphash'],
3608 ['valgrind', conf.get('VALGRIND') == 1],
3609 ['trace logging', conf.get('LOG_TRACE') == 1],
3610 ['install tests', install_tests],
3611 ['link-udev-shared', get_option('link-udev-shared')],
3612 ['link-systemctl-shared', get_option('link-systemctl-shared')],
3613 ['link-networkd-shared', get_option('link-networkd-shared')],
3614 ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
3615 ['kernel-install', get_option('kernel-install')],
3616 ['systemd-analyze', get_option('analyze')],
3617 ]
3618
3619 if tuple.length() >= 2
3620 cond = tuple[1]
3621 else
3622 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3623 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
3624 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
3625 endif
3626 if cond
3627 found += tuple[0]
3628 else
3629 missing += tuple[0]
3630 endif
3631 endforeach
3632
3633 status += [
3634 '',
3635 'enabled features: @0@'.format(', '.join(found)),
3636 '',
3637 'disabled features: @0@'.format(', '.join(missing)),
3638 '']
3639 message('\n '.join(status))
3640
3641 if rootprefixdir != rootprefix_default
3642 warning('\n' +
3643 'Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3644 'systemd used fixed names for unit file directories and other paths, so anything\n' +
3645 'except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
3646 endif