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