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