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