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