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