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