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