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