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