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