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