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