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