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