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