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