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