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