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