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