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