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