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