chiark / gitweb /
Prep v238: Make a real distinction between 'halt' and 'poweroff'.
[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.20.0'
35 #endif // 0
36
37 # We need the same data in three different formats, ugh!
38 # Also, for hysterical reasons, we use different variable
39 # names, sometimes. Not all variables are included in every
40 # set. Ugh, ugh, ugh!
41 conf = configuration_data()
42 conf.set_quoted('PACKAGE_STRING',  meson.project_name() + ' ' + meson.project_version())
43 conf.set_quoted('PACKAGE_VERSION', meson.project_version())
44
45 substs = configuration_data()
46 #if 0 /// Set elogind Package PACKAGE_URL
47 # substs.set('PACKAGE_URL',          'https://www.freedesktop.org/wiki/Software/systemd')
48 #else
49 substs.set('PACKAGE_URL',          'https://github.com/elogind/elogind')
50 #endif // 0
51 substs.set('PACKAGE_VERSION',      meson.project_version())
52
53 m4_defines = []
54
55 #####################################################################
56 #if 0 /// elogind does not need this
57 #
58 # # Try to install the git pre-commit hook
59 # git_hook = run_command(join_paths(meson.source_root(), 'tools/add-git-hook.sh'))
60 # if git_hook.returncode() == 0
61 #         message(git_hook.stdout().strip())
62 # endif
63 #else
64 # elogind Note: We use precompiler masks for two reasons:
65 #               1) The masking is consistent with the sources
66 #               2) The git patch creator we use for preparing upstream patches
67 #                  manipulates commits to not take those masks out. Therefore
68 #                  it can be used to add commits updating the meson files, too.
69 #endif // 0
70
71 #####################################################################
72
73 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 # conf.set_quoted('MEMORY_ACCOUNTING_DEFAULT_ON_OFF',           memory_accounting_default ? 'on' : 'off')
300 #endif // 0
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 # Check if various sanitizers are supported
486 sanitizers = []
487 foreach arg : ['address']
488
489         have = run_command(check_compilation_sh,
490                            cc.cmd_array(), '-x', 'c',
491                            '-fsanitize=@0@'.format(arg),
492                            '-include', link_test_c).returncode() == 0
493         message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no'))
494         if have
495                 sanitizers += arg
496         endif
497 endforeach
498
499 if get_option('buildtype') != 'debug'
500         foreach arg : ['-ffunction-sections',
501                        '-fdata-sections']
502                 if cc.has_argument(arg,
503                                    name : '@0@ is supported'.format(arg))
504                         add_project_arguments(arg, language : 'c')
505                 endif
506         endforeach
507
508         foreach arg : ['-Wl,--gc-sections']
509                 have = run_command(check_compilation_sh,
510                                    cc.cmd_array(), '-x', 'c', arg,
511                                    '-include', link_test_c).returncode() == 0
512                 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
513                 if have
514                         add_project_link_arguments(arg, language : 'c')
515                 endif
516         endforeach
517 endif
518
519 cpp = ' '.join(cc.cmd_array()) + ' -E'
520
521 #####################################################################
522 # compilation result tests
523
524 conf.set('_GNU_SOURCE', true)
525 conf.set('__SANE_USERSPACE_TYPES__', true)
526
527 conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
528 conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
529 conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
530 conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
531 conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
532 conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
533 conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
534
535 decl_headers = '''
536 #include <uchar.h>
537 #include <linux/ethtool.h>
538 #include <linux/fib_rules.h>
539 //#include <linux/stat.h>
540 //#include <sys/stat.h>
541 '''
542 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
543
544 foreach decl : ['char16_t',
545                 'char32_t',
546                 'key_serial_t',
547                 'struct ethtool_link_settings',
548                 'struct fib_rule_uid_range',
549                 'struct statx',
550                ]
551
552         # We get -1 if the size cannot be determined
553         have = cc.sizeof(decl, prefix : decl_headers) > 0
554         conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
555 endforeach
556
557 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE',         'linux/if_link.h'],
558                 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
559                 ['IFLA_VRF_TABLE',                   'linux/if_link.h'],
560                 ['IFLA_MACVLAN_FLAGS',               'linux/if_link.h'],
561                 ['IFLA_IPVLAN_FLAGS',                'linux/if_link.h'],
562                 ['IFLA_PHYS_PORT_ID',                'linux/if_link.h'],
563                 ['IFLA_BOND_AD_INFO',                'linux/if_link.h'],
564                 ['IFLA_VLAN_PROTOCOL',               'linux/if_link.h'],
565                 ['IFLA_VXLAN_REMCSUM_NOPARTIAL',     'linux/if_link.h'],
566                 ['IFLA_VXLAN_GPE',                   'linux/if_link.h'],
567                 ['IFLA_GENEVE_LABEL',                'linux/if_link.h'],
568                 # if_tunnel.h is buggy and cannot be included on its own
569                 ['IFLA_VTI_REMOTE',                  'linux/if_tunnel.h', '#include <net/if.h>'],
570                 ['IFLA_IPTUN_ENCAP_DPORT',           'linux/if_tunnel.h', '#include <net/if.h>'],
571                 ['IFLA_GRE_ENCAP_DPORT',             'linux/if_tunnel.h', '#include <net/if.h>'],
572                 ['IFLA_BRIDGE_VLAN_INFO',            'linux/if_bridge.h'],
573                 ['IFLA_BRPORT_PROXYARP',             'linux/if_link.h'],
574                 ['IFLA_BRPORT_LEARNING_SYNC',        'linux/if_link.h'],
575                 ['IFLA_BR_VLAN_DEFAULT_PVID',        'linux/if_link.h'],
576                 ['IPVLAN_F_PRIVATE',                 'linux/if_link.h'],
577                 ['NDA_IFINDEX',                      'linux/neighbour.h'],
578                 ['IFA_FLAGS',                        'linux/if_addr.h'],
579                 ['FRA_UID_RANGE',                    'linux/fib_rules.h'],
580                 ['LO_FLAGS_PARTSCAN',                'linux/loop.h'],
581                 ['VXCAN_INFO_PEER',                  'linux/can/vxcan.h'],
582                ]
583         prefix = decl.length() > 2 ? decl[2] : ''
584         have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
585         conf.set10('HAVE_' + decl[0], have)
586 endforeach
587
588 foreach ident : ['secure_getenv', '__secure_getenv']
589         conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
590 endforeach
591
592 foreach ident : [
593         ['memfd_create',      '''#include <sys/mman.h>'''],
594         ['gettid',            '''#include <sys/types.h>
595                                  #include <unistd.h>'''],
596         ['pivot_root',        '''#include <stdlib.h>
597                                  #include <unistd.h>'''],     # no known header declares pivot_root
598         ['name_to_handle_at', '''#include <sys/types.h>
599                                  #include <sys/stat.h>
600                                  #include <fcntl.h>'''],
601         ['setns',             '''#include <sched.h>'''],
602         ['renameat2',         '''#include <stdio.h>
603 //                                 #include <fcntl.h>'''],
604         ['kcmp',              '''#include <linux/kcmp.h>'''],
605         ['keyctl',            '''#include <sys/types.h>
606                                  #include <keyutils.h>'''],
607         ['copy_file_range',   '''#include <sys/syscall.h>
608                                  #include <unistd.h>'''],
609         ['bpf',               '''#include <sys/syscall.h>
610                                  #include <unistd.h>'''],
611         ['statx',             '''#include <sys/types.h>
612                                  #include <sys/stat.h>
613 //                                 #include <unistd.h>'''],
614         ['explicit_bzero' ,   '''#include <string.h>'''],
615         ['reallocarray',      '''#include <malloc.h>'''],
616 ]
617
618         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
619         conf.set10('HAVE_' + ident[0].to_upper(), have)
620 endforeach
621
622 if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''', args : '-D_GNU_SOURCE')
623         conf.set10('USE_SYS_RANDOM_H', true)
624         conf.set10('HAVE_GETRANDOM', true)
625 else
626         have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
627         conf.set10('USE_SYS_RANDOM_H', false)
628         conf.set10('HAVE_GETRANDOM', have)
629 endif
630
631 #####################################################################
632
633 sed = find_program('sed')
634 awk = find_program('awk')
635 m4 = find_program('m4')
636 stat = find_program('stat')
637 git = find_program('git', required : false)
638 env = find_program('env')
639
640 #if 0 /// elogind does not use this but needs a tool to symlink its installed headers.
641 # meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
642 #else /// Needed by elogind
643 meson_symlink_headers = meson.source_root() + '/tools/meson-symlink_headers.sh'
644 #endif // 1
645 mkdir_p = 'mkdir -p $DESTDIR/@0@'
646 #if 0 /// unneeded by elogind
647 # test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
648 # splash_bmp = files('test/splash.bmp')
649 #endif // 0
650
651 # if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
652 # /usr/sbin, /sbin, and fall back to the default from middle column.
653 #if 0 /// elogind has a bit different list and some adaptions
654 # progs = [['quotaon',    '/usr/sbin/quotaon'    ],
655 #          ['quotacheck', '/usr/sbin/quotacheck' ],
656 #          ['kill',       '/usr/bin/kill'        ],
657 #          ['kmod',       '/usr/bin/kmod'        ],
658 #          ['kexec',      '/usr/sbin/kexec'      ],
659 #          ['sulogin',    '/usr/sbin/sulogin'    ],
660 #          ['mount',      '/usr/bin/mount',      'MOUNT_PATH'],
661 #          ['umount',     '/usr/bin/umount',     'UMOUNT_PATH'],
662 #          ['loadkeys',   '/usr/bin/loadkeys',   'KBD_LOADKEYS'],
663 #          ['setfont',    '/usr/bin/setfont',    'KBD_SETFONT'],
664 #         ]
665 #else
666 progs = [['halt',       '/sbin/halt',          'HALT'],
667          ['kexec',      '/usr/sbin/kexec',     'KEXEC'],
668          ['poweroff',   '/sbin/poweroff',      'POWEROFF'],
669          ['reboot',     '/sbin/reboot',        'REBOOT'],
670         ]
671 #endif // 0
672 foreach prog : progs
673         path = get_option(prog[0] + '-path')
674         if path != ''
675                 message('Using @1@ for @0@'.format(prog[0], path))
676         else
677                 exe = find_program(prog[0],
678                                    '/usr/sbin/' + prog[0],
679                                    '/sbin/' + prog[0],
680                                    required: false)
681                 path = exe.found() ? exe.path() : prog[1]
682         endif
683         name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
684         conf.set_quoted(name, path)
685         substs.set(name, path)
686 endforeach
687
688 #if 0 /// unneeded by elogind
689 # conf.set_quoted('TELINIT', get_option('telinit-path'))
690 # if run_command('ln', '--relative', '--help').returncode() != 0
691 #         error('ln does not support --relative')
692 # endif
693 #endif // 0
694
695 ############################################################
696
697 gperf = find_program('gperf')
698
699 gperf_test_format = '''
700 #include <string.h>
701 const char * in_word_set(const char *, @0@);
702 @1@
703 '''
704 gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
705 gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
706 gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
707 if cc.compiles(gperf_test)
708         gperf_len_type = 'size_t'
709 else
710         gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
711         if cc.compiles(gperf_test)
712                 gperf_len_type = 'unsigned'
713         else
714                 error('unable to determine gperf len type')
715         endif
716 endif
717 message('gperf len type is @0@'.format(gperf_len_type))
718 conf.set('GPERF_LEN_TYPE', gperf_len_type,
719          description : 'The type of gperf "len" parameter')
720
721 ############################################################
722
723 if not cc.has_header('sys/capability.h')
724         error('POSIX caps headers not found')
725 endif
726 foreach header : ['crypt.h',
727                   'linux/btrfs.h',
728                   'linux/memfd.h',
729                   'linux/vm_sockets.h',
730                   'sys/auxv.h',
731                   'valgrind/memcheck.h',
732                   'valgrind/valgrind.h',
733                  ]
734
735         conf.set10('HAVE_' + header.underscorify().to_upper(),
736                    cc.has_header(header))
737 endforeach
738
739 ############################################################
740
741 conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
742 #if 0 /// UNNEEDED by elogind
743 # conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
744 # gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
745 #endif // 0
746
747 default_hierarchy = get_option('default-hierarchy')
748 conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
749                 description : 'default cgroup hierarchy as string')
750 if default_hierarchy == 'legacy'
751         conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
752 elif default_hierarchy == 'hybrid'
753         conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
754 else
755         conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
756 endif
757
758 #if 0 /// UNNEEDED by elogind
759 # time_epoch = get_option('time-epoch')
760 # if time_epoch == ''
761 #         NEWS = files('NEWS')
762 #         time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
763 # endif
764 # time_epoch = time_epoch.to_int()
765 # conf.set('TIME_EPOCH', time_epoch)
766 #else
767 ############################################################
768 # elogind needs to know which cgroups controller to follow.
769 get_cg_ctrl_sh = find_program('tools/meson-get-cg-controller.sh')
770 with_cgroupctrl = get_option('cgroup-controller')
771 if with_cgroupctrl == '' or with_cgroupctrl == 'auto'
772         with_cgroupctrl = run_command(get_cg_ctrl_sh, []).stdout().strip()
773 elif with_cgroupctrl == 'none'
774         with_cgroupctrl = 'elogind'
775 endif
776
777 # No controller now is a problem:
778 if with_cgroupctrl == ''
779         error('Unable to determine cgroup controller, but cgroups support is mandatory!')
780 endif
781
782 conf.set_quoted('SYSTEMD_CGROUP_CONTROLLER', '_'.join(['',with_cgroupctrl]),
783                 description : 'name of the cgroup controller to use')
784 conf.set_quoted('SYSTEMD_CGROUP_CONTROLLER_LEGACY',
785                 '='.join(['name', with_cgroupctrl]))
786 conf.set_quoted('SYSTEMD_CGROUP_CONTROLLER_HYBRID',
787                 '='.join(['name', with_cgroupctrl]))
788 ############################################################
789 #endif // 0
790
791 system_uid_max = get_option('system-uid-max')
792 if system_uid_max == ''
793         system_uid_max = run_command(
794                 awk,
795                 '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
796                 '/etc/login.defs').stdout().strip()
797         if system_uid_max == ''
798                 system_uid_max = '999'
799         endif
800 endif
801 system_uid_max = system_uid_max.to_int()
802 conf.set('SYSTEM_UID_MAX', system_uid_max)
803 substs.set('systemuidmax', system_uid_max)
804 message('maximum system UID is @0@'.format(system_uid_max))
805
806 system_gid_max = get_option('system-gid-max')
807 if system_gid_max == ''
808         system_gid_max = run_command(
809                 awk,
810                 '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
811                 '/etc/login.defs').stdout().strip()
812         if system_gid_max == ''
813                 system_gid_max = '999'
814         endif
815 endif
816 system_gid_max = system_gid_max.to_int()
817 conf.set('SYSTEM_GID_MAX', system_gid_max)
818 substs.set('systemgidmax', system_gid_max)
819 message('maximum system GID is @0@'.format(system_gid_max))
820
821 #if 0 /// UNNEEDED by elogind
822 # dynamic_uid_min = get_option('dynamic-uid-min').to_int()
823 # dynamic_uid_max = get_option('dynamic-uid-max').to_int()
824 # conf.set('DYNAMIC_UID_MIN', dynamic_uid_min)
825 # conf.set('DYNAMIC_UID_MAX', dynamic_uid_max)
826 # substs.set('dynamicuidmin', dynamic_uid_min)
827 # substs.set('dynamicuidmax', dynamic_uid_max)
828 #
829 # container_uid_base_min = get_option('container-uid-base-min').to_int()
830 # container_uid_base_max = get_option('container-uid-base-max').to_int()
831 # conf.set('CONTAINER_UID_BASE_MIN', container_uid_base_min)
832 # conf.set('CONTAINER_UID_BASE_MAX', container_uid_base_max)
833 # substs.set('containeruidbasemin', container_uid_base_min)
834 # substs.set('containeruidbasemax', container_uid_base_max)
835 #endif // 0
836
837 nobody_user = get_option('nobody-user')
838 nobody_group = get_option('nobody-group')
839
840 getent_result = run_command('getent', 'passwd', '65534')
841 if getent_result.returncode() == 0
842         name = getent_result.stdout().split(':')[0]
843         if name != nobody_user
844                 message('WARNING:\n' +
845                         '        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) +
846                         '        Your build will result in an user table setup that is incompatible with the local system.')
847         endif
848 endif
849 id_result = run_command('id', '-u', nobody_user)
850 if id_result.returncode() == 0
851         id = id_result.stdout().to_int()
852         if id != 65534
853                 message('WARNING:\n' +
854                         '        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) +
855                         '        Your build will result in an user table setup that is incompatible with the local system.')
856         endif
857 endif
858
859 getent_result = run_command('getent', 'group', '65534')
860 if getent_result.returncode() == 0
861         name = getent_result.stdout().split(':')[0]
862         if name != nobody_group
863                 message('WARNING:\n' +
864                         '        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) +
865                         '        Your build will result in an group table setup that is incompatible with the local system.')
866         endif
867 endif
868 id_result = run_command('id', '-g', nobody_group)
869 if id_result.returncode() == 0
870         id = id_result.stdout().to_int()
871         if id != 65534
872                 message('WARNING:\n' +
873                         '        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) +
874                         '        Your build will result in an group table setup that is incompatible with the local system.')
875         endif
876 endif
877 if nobody_user != nobody_group and not (nobody_user == 'nobody' and nobody_group == 'nogroup')
878         message('WARNING:\n' +
879                 '        The configured user name "@0@" and group name "@0@" of the nobody user/group are not equivalent.\n'.format(nobody_user, nobody_group) +
880                 '        Please re-check that both "nobody-user" and "nobody-group" options are correctly set.')
881 endif
882
883 conf.set_quoted('NOBODY_USER_NAME', nobody_user)
884 conf.set_quoted('NOBODY_GROUP_NAME', nobody_group)
885 substs.set('NOBODY_USER_NAME', nobody_user)
886 substs.set('NOBODY_GROUP_NAME', nobody_group)
887
888 tty_gid = get_option('tty-gid')
889 conf.set('TTY_GID', tty_gid)
890 substs.set('TTY_GID', tty_gid)
891
892 #if 0 /// UNNEEDED by elogind
893 # # Ensure provided GID argument is numeric, otherwise fallback to default assignment
894 # if get_option('users-gid') != ''
895 #         users_gid = get_option('users-gid').to_int()
896 # else
897 #         users_gid = '-'
898 # endif
899 # substs.set('USERS_GID', users_gid)
900 #
901 # if get_option('adm-group')
902 #         m4_defines += ['-DENABLE_ADM_GROUP']
903 # endif
904 #
905 # if get_option('wheel-group')
906 #         m4_defines += ['-DENABLE_WHEEL_GROUP']
907 # endif
908 #
909 # substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
910 # substs.set('GROUP_RENDER_MODE', get_option('group-render-mode'))
911 #endif // 0
912
913 kill_user_processes = get_option('default-kill-user-processes')
914 conf.set10('KILL_USER_PROCESSES', kill_user_processes)
915 substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
916
917 #if 0 /// UNNEEDED by elogind
918 # dns_servers = get_option('dns-servers')
919 # conf.set_quoted('DNS_SERVERS', dns_servers)
920 # substs.set('DNS_SERVERS', dns_servers)
921 #
922 # ntp_servers = get_option('ntp-servers')
923 # conf.set_quoted('NTP_SERVERS', ntp_servers)
924 # substs.set('NTP_SERVERS', ntp_servers)
925 #endif // 0
926
927 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
928
929 #if 0 /// UNNEEDED by elogind
930 # substs.set('SUSHELL', get_option('debug-shell'))
931 # substs.set('DEBUGTTY', get_option('debug-tty'))
932 #endif // 0
933
934 debug = get_option('debug')
935 enable_debug_hashmap = false
936 enable_debug_mmap_cache = false
937 #if 1 /// additional elogind debug mode
938 enable_debug_elogind = false
939 #endif // 1
940 if debug != ''
941         foreach name : debug.split(',')
942                 if name == 'hashmap'
943                         enable_debug_hashmap = true
944                 elif name == 'mmap-cache'
945                         enable_debug_mmap_cache = true
946 #if 1 /// additional elogind debug mode
947                 elif name == 'elogind'
948                         enable_debug_elogind = true
949 #endif // 1
950                 else
951                         message('unknown debug option "@0@", ignoring'.format(name))
952                 endif
953         endforeach
954 endif
955 conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
956 conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
957 #if 1 /// additional elogind debug mode
958 conf.set10('ENABLE_DEBUG_ELOGIND', enable_debug_elogind)
959 #endif // 1
960
961 #####################################################################
962
963 threads = dependency('threads')
964 librt = cc.find_library('rt')
965 libm = cc.find_library('m')
966 libdl = cc.find_library('dl')
967 libcrypt = cc.find_library('crypt')
968
969 libcap = dependency('libcap', required : false)
970 if not libcap.found()
971         # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
972         libcap = cc.find_library('cap')
973 endif
974
975 #if 0 /// UNNEEDED by elogind
976 # libmount = dependency('mount',
977 #                       version : '>= 2.30',
978 #                       required : not fuzzer_build)
979 #
980 # want_seccomp = get_option('seccomp')
981 # if want_seccomp != 'false' and not fuzzer_build
982 #         libseccomp = dependency('libseccomp',
983 #                                 version : '>= 2.3.1',
984 #                                 required : want_seccomp == 'true')
985 #         have = libseccomp.found()
986 # else
987 #         have = false
988 #         libseccomp = []
989 # endif
990 #else
991 libseccomp = []
992 #endif // 0
993 conf.set10('HAVE_SECCOMP', have)
994 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
995
996 want_selinux = get_option('selinux')
997 if want_selinux != 'false' and not fuzzer_build
998         libselinux = dependency('libselinux',
999                                 version : '>= 2.1.9',
1000                                 required : want_selinux == 'true')
1001         have = libselinux.found()
1002 else
1003         have = false
1004         libselinux = []
1005 endif
1006 conf.set10('HAVE_SELINUX', have)
1007 m4_defines += have ? ['-DHAVE_SELINUX'] : []
1008
1009 #if 0 /// UNNEEDED by elogind
1010 # want_apparmor = get_option('apparmor')
1011 # if want_apparmor != 'false' and not fuzzer_build
1012 #         libapparmor = dependency('libapparmor',
1013 #                                  required : want_apparmor == 'true')
1014 #         have = libapparmor.found()
1015 # else
1016 #         have = false
1017 #         libapparmor = []
1018 # endif
1019 #else
1020 libapparmor = []
1021 #endif // 0
1022 conf.set10('HAVE_APPARMOR', have)
1023 m4_defines += have ? ['-DHAVE_APPARMOR'] : []
1024
1025 smack_run_label = get_option('smack-run-label')
1026 if smack_run_label != ''
1027         conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
1028         m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
1029 endif
1030
1031 want_polkit = get_option('polkit')
1032 install_polkit = false
1033 install_polkit_pkla = false
1034 if want_polkit != 'false' and not fuzzer_build
1035         install_polkit = true
1036
1037         libpolkit = dependency('polkit-gobject-1',
1038                                required : false)
1039         if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
1040                 message('Old polkit detected, will install pkla files')
1041                 install_polkit_pkla = true
1042         endif
1043 endif
1044 conf.set10('ENABLE_POLKIT', install_polkit)
1045
1046 want_acl = get_option('acl')
1047 if want_acl != 'false' and not fuzzer_build
1048         libacl = cc.find_library('acl', required : want_acl == 'true')
1049         have = libacl.found()
1050 else
1051         have = false
1052         libacl = []
1053 endif
1054 conf.set10('HAVE_ACL', have)
1055 m4_defines += have ? ['-DHAVE_ACL'] : []
1056
1057 want_audit = get_option('audit')
1058 if want_audit != 'false' and not fuzzer_build
1059         libaudit = dependency('audit', required : want_audit == 'true')
1060         have = libaudit.found()
1061 else
1062         have = false
1063         libaudit = []
1064 endif
1065 conf.set10('HAVE_AUDIT', have)
1066
1067 #if 0 /// UNNEEDED by elogind
1068 # want_blkid = get_option('blkid')
1069 # if want_blkid != 'false' and not fuzzer_build
1070 #         libblkid = dependency('blkid', required : want_blkid == 'true')
1071 #         have = libblkid.found()
1072 # else
1073 #         have = false
1074 #         libblkid = []
1075 # endif
1076 # conf.set10('HAVE_BLKID', have)
1077 #
1078 # want_kmod = get_option('kmod')
1079 # if want_kmod != 'false' and not fuzzer_build
1080 #         libkmod = dependency('libkmod',
1081 #                              version : '>= 15',
1082 #                              required : want_kmod == 'true')
1083 #         have = libkmod.found()
1084 # else
1085 #         have = false
1086 #         libkmod = []
1087 # endif
1088 # conf.set10('HAVE_KMOD', have)
1089 #else
1090 libblkid = []
1091 libkmod = []
1092 #endif // 0
1093
1094 want_pam = get_option('pam')
1095 if want_pam != 'false' and not fuzzer_build
1096         libpam = cc.find_library('pam', required : want_pam == 'true')
1097         libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1098         have = libpam.found() and libpam_misc.found()
1099 else
1100         have = false
1101         libpam = []
1102         libpam_misc = []
1103 endif
1104 conf.set10('HAVE_PAM', have)
1105 m4_defines += have ? ['-DHAVE_PAM'] : []
1106
1107 #if 0 /// UNNEEDED by elogind
1108 # want_microhttpd = get_option('microhttpd')
1109 # if want_microhttpd != 'false' and not fuzzer_build
1110 #         libmicrohttpd = dependency('libmicrohttpd',
1111 #                                    version : '>= 0.9.33',
1112 #                                    required : want_microhttpd == 'true')
1113 #         have = libmicrohttpd.found()
1114 # else
1115 #         have = false
1116 #         libmicrohttpd = []
1117 # endif
1118 # conf.set10('HAVE_MICROHTTPD', have)
1119 # m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
1120 #
1121 # want_libcryptsetup = get_option('libcryptsetup')
1122 # if want_libcryptsetup != 'false' and not fuzzer_build
1123 #         libcryptsetup = dependency('libcryptsetup',
1124 #                                    version : '>= 1.6.0',
1125 #                                    required : want_libcryptsetup == 'true')
1126 #         have = libcryptsetup.found()
1127 # else
1128 #         have = false
1129 #         libcryptsetup = []
1130 # endif
1131 # conf.set10('HAVE_LIBCRYPTSETUP', have)
1132 #
1133 # want_libcurl = get_option('libcurl')
1134 # if want_libcurl != 'false' and not fuzzer_build
1135 #         libcurl = dependency('libcurl',
1136 #                              version : '>= 7.32.0',
1137 #                              required : want_libcurl == 'true')
1138 #         have = libcurl.found()
1139 # else
1140 #         have = false
1141 #         libcurl = []
1142 # endif
1143 # conf.set10('HAVE_LIBCURL', have)
1144 # m4_defines += have ? ['-DHAVE_LIBCURL'] : []
1145 #
1146 # want_libidn = get_option('libidn')
1147 # want_libidn2 = get_option('libidn2')
1148 # if want_libidn == 'true' and want_libidn2 == 'true'
1149 #         error('libidn and libidn2 cannot be requested simultaneously')
1150 # endif
1151 #
1152 # if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
1153 #         libidn = dependency('libidn',
1154 #                             required : want_libidn == 'true')
1155 #         have = libidn.found()
1156 # else
1157 #         have = false
1158 #         libidn = []
1159 # endif
1160 # conf.set10('HAVE_LIBIDN', have)
1161 # m4_defines += have ? ['-DHAVE_LIBIDN'] : []
1162 # if not have and want_libidn2 != 'false' and not fuzzer_build
1163 #         # libidn is used for both libidn and libidn2 objects
1164 #         libidn = dependency('libidn2',
1165 #                             required : want_libidn2 == 'true')
1166 #         have = libidn.found()
1167 # else
1168 #         have = false
1169 # endif
1170 # conf.set10('HAVE_LIBIDN2', have)
1171 # m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
1172 #
1173 # want_libiptc = get_option('libiptc')
1174 # if want_libiptc != 'false' and not fuzzer_build
1175 #         libiptc = dependency('libiptc',
1176 #                              required : want_libiptc == 'true')
1177 #         have = libiptc.found()
1178 # else
1179 #         have = false
1180 #         libiptc = []
1181 # endif
1182 # conf.set10('HAVE_LIBIPTC', have)
1183 # m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
1184 #
1185 # want_qrencode = get_option('qrencode')
1186 # if want_qrencode != 'false' and not fuzzer_build
1187 #         libqrencode = dependency('libqrencode',
1188 #                                  required : want_qrencode == 'true')
1189 #         have = libqrencode.found()
1190 # else
1191 #         have = false
1192 #         libqrencode = []
1193 # endif
1194 # conf.set10('HAVE_QRENCODE', have)
1195 #
1196 # want_gcrypt = get_option('gcrypt')
1197 # if want_gcrypt != 'false' and not fuzzer_build
1198 #         libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1199 #         libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1200 #         have = libgcrypt.found() and libgpg_error.found()
1201 # else
1202 #         have = false
1203 # endif
1204 # if not have
1205 #         # link to neither of the libs if one is not found
1206 #         libgcrypt = []
1207 #         libgpg_error = []
1208 # endif
1209 # conf.set10('HAVE_GCRYPT', have)
1210 #
1211 # want_gnutls = get_option('gnutls')
1212 # if want_gnutls != 'false' and not fuzzer_build
1213 #         libgnutls = dependency('gnutls',
1214 #                                version : '>= 3.1.4',
1215 #                                required : want_gnutls == 'true')
1216 #         have = libgnutls.found()
1217 # else
1218 #         have = false
1219 #         libgnutls = []
1220 # endif
1221 # conf.set10('HAVE_GNUTLS', have)
1222 #
1223 # want_elfutils = get_option('elfutils')
1224 # if want_elfutils != 'false' and not fuzzer_build
1225 #         libdw = dependency('libdw',
1226 #                            required : want_elfutils == 'true')
1227 #         have = libdw.found()
1228 # else
1229 #         have = false
1230 #         libdw = []
1231 # endif
1232 # conf.set10('HAVE_ELFUTILS', have)
1233 #
1234 # want_zlib = get_option('zlib')
1235 # if want_zlib != 'false' and not fuzzer_build
1236 #         libz = dependency('zlib',
1237 #                           required : want_zlib == 'true')
1238 #         have = libz.found()
1239 # else
1240 #         have = false
1241 #         libz = []
1242 # endif
1243 # conf.set10('HAVE_ZLIB', have)
1244 #
1245 # want_bzip2 = get_option('bzip2')
1246 # if want_bzip2 != 'false' and not fuzzer_build
1247 #         libbzip2 = cc.find_library('bz2',
1248 #                                    required : want_bzip2 == 'true')
1249 #         have = libbzip2.found()
1250 # else
1251 #         have = false
1252 #         libbzip2 = []
1253 # endif
1254 # conf.set10('HAVE_BZIP2', have)
1255 #
1256 # want_xz = get_option('xz')
1257 # if want_xz != 'false' and not fuzzer_build
1258 #         libxz = dependency('liblzma',
1259 #                            required : want_xz == 'true')
1260 #         have = libxz.found()
1261 # else
1262 #         have = false
1263 #         libxz = []
1264 # endif
1265 # conf.set10('HAVE_XZ', have)
1266 #
1267 # want_lz4 = get_option('lz4')
1268 # if want_lz4 != 'false' and not fuzzer_build
1269 #         liblz4 = dependency('liblz4',
1270 #                             required : want_lz4 == 'true')
1271 #         have = liblz4.found()
1272 # else
1273 #         have = false
1274 #         liblz4 = []
1275 # endif
1276 # conf.set10('HAVE_LZ4', have)
1277 #
1278 # want_xkbcommon = get_option('xkbcommon')
1279 # if want_xkbcommon != 'false' and not fuzzer_build
1280 #         libxkbcommon = dependency('xkbcommon',
1281 #                                   version : '>= 0.3.0',
1282 #                                   required : want_xkbcommon == 'true')
1283 #         have = libxkbcommon.found()
1284 # else
1285 #         have = false
1286 #         libxkbcommon = []
1287 # endif
1288 #else
1289 libmicrohttpd = []
1290 libcryptsetup = []
1291 libcurl = []
1292 libidn = []
1293 libiptc = []
1294 libqrencode = []
1295 libgcrypt = []
1296 libgpg_error = []
1297 libgnutls = []
1298 libdw = []
1299 libz = []
1300 libbzip2 = []
1301 libxz = []
1302 liblz4 = []
1303 libxkbcommon = []
1304 #endif // 0
1305 conf.set10('HAVE_XKBCOMMON', have)
1306
1307 want_pcre2 = get_option('pcre2')
1308 if want_pcre2 != 'false'
1309         libpcre2 = dependency('libpcre2-8',
1310                               required : want_pcre2 == 'true')
1311         have = libpcre2.found()
1312 else
1313         have = false
1314         libpcre2 = []
1315 endif
1316 conf.set10('HAVE_PCRE2', have)
1317
1318 want_glib = get_option('glib')
1319 if want_glib != 'false' and not fuzzer_build
1320         libglib =    dependency('glib-2.0',
1321                                 version : '>= 2.22.0',
1322                                 required : want_glib == 'true')
1323         libgobject = dependency('gobject-2.0',
1324                                 version : '>= 2.22.0',
1325                                 required : want_glib == 'true')
1326         libgio =     dependency('gio-2.0',
1327                                 required : want_glib == 'true')
1328         have = libglib.found() and libgobject.found() and libgio.found()
1329 else
1330         have = false
1331         libglib = []
1332         libgobject = []
1333         libgio = []
1334 endif
1335 conf.set10('HAVE_GLIB', have)
1336
1337 want_dbus = get_option('dbus')
1338 if want_dbus != 'false' and not fuzzer_build
1339         libdbus = dependency('dbus-1',
1340                              version : '>= 1.3.2',
1341                              required : want_dbus == 'true')
1342         have = libdbus.found()
1343 else
1344         have = false
1345         libdbus = []
1346 endif
1347 conf.set10('HAVE_DBUS', have)
1348
1349 #if 0 /// UNNEEDED by elogind
1350 # default_dnssec = get_option('default-dnssec')
1351 # if fuzzer_build
1352 #         default_dnssec = 'no'
1353 # endif
1354 # if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
1355 #         message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
1356 #         default_dnssec = 'no'
1357 # endif
1358 # conf.set('DEFAULT_DNSSEC_MODE',
1359 #          'DNSSEC_' + default_dnssec.underscorify().to_upper())
1360 # substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
1361 #
1362 # want_importd = get_option('importd')
1363 # if want_importd != 'false'
1364 #         have = (conf.get('HAVE_LIBCURL') == 1 and
1365 #                 conf.get('HAVE_ZLIB') == 1 and
1366 #                 conf.get('HAVE_BZIP2') == 1 and
1367 #                 conf.get('HAVE_XZ') == 1 and
1368 #                 conf.get('HAVE_GCRYPT') == 1)
1369 #         if want_importd == 'true' and not have
1370 #                 error('importd support was requested, but dependencies are not available')
1371 #         endif
1372 # else
1373 #         have = false
1374 # endif
1375 # conf.set10('ENABLE_IMPORTD', have)
1376 #
1377 # want_remote = get_option('remote')
1378 # if want_remote != 'false'
1379 #         have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
1380 #                      conf.get('HAVE_LIBCURL') == 1]
1381 #         # sd-j-remote requires Âµhttpd, and sd-j-upload requires libcurl, so
1382 #         # it's possible to build one without the other. Complain only if
1383 #         # support was explictly requested. The auxiliary files like sysusers
1384 #         # config should be installed when any of the programs are built.
1385 #         if want_remote == 'true' and not (have_deps[0] and have_deps[1])
1386 #                 error('remote support was requested, but dependencies are not available')
1387 #         endif
1388 #         have = have_deps[0] or have_deps[1]
1389 # else
1390 #         have = false
1391 # endif
1392 #endif // 0
1393 conf.set10('ENABLE_REMOTE', have)
1394
1395 foreach term : ['utmp',
1396 #if 0 /// UNNEEDED by elogind
1397 #                 'hibernate',
1398 #                 'environment-d',
1399 #                 'binfmt',
1400 #                 'coredump',
1401 #                 'resolve',
1402 #                 'logind',
1403 #                 'hostnamed',
1404 #                 'localed',
1405 #                 'machined',
1406 #                 'networkd',
1407 #                 'timedated',
1408 #                 'timesyncd',
1409 #                 'myhostname',
1410 #                 'firstboot',
1411 #                 'randomseed',
1412 #                 'backlight',
1413 #                 'vconsole',
1414 #                 'quotacheck',
1415 #                 'sysusers',
1416 #                 'tmpfiles',
1417 #                 'hwdb',
1418 #                 'rfkill',
1419 #                 'ldconfig',
1420 #                 'efi',
1421 #                 'tpm',
1422 #                 'ima',
1423 #                 'smack',
1424 #                 'gshadow',
1425 #                 'idn',
1426 #                 'nss-systemd']
1427 #else
1428                 'smack']
1429 #endif // 0
1430         have = get_option(term)
1431         name = 'ENABLE_' + term.underscorify().to_upper()
1432         conf.set10(name, have)
1433         m4_defines += have ? ['-D' + name] : []
1434 endforeach
1435
1436 want_tests = get_option('tests')
1437 install_tests = get_option('install-tests')
1438 slow_tests = get_option('slow-tests')
1439 tests = []
1440 fuzzers = []
1441
1442 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
1443
1444 #####################################################################
1445
1446 #if 0 /// UNNEEDED by elogind
1447 # if get_option('efi')
1448 #         efi_arch = host_machine.cpu_family()
1449 #
1450 #         if efi_arch == 'x86'
1451 #                 EFI_MACHINE_TYPE_NAME = 'ia32'
1452 #                 gnu_efi_arch = 'ia32'
1453 #         elif efi_arch == 'x86_64'
1454 #                 EFI_MACHINE_TYPE_NAME = 'x64'
1455 #                 gnu_efi_arch = 'x86_64'
1456 #         elif efi_arch == 'arm'
1457 #                 EFI_MACHINE_TYPE_NAME = 'arm'
1458 #                 gnu_efi_arch = 'arm'
1459 #         elif efi_arch == 'aarch64'
1460 #                 EFI_MACHINE_TYPE_NAME = 'aa64'
1461 #                 gnu_efi_arch = 'aarch64'
1462 #         else
1463 #                 EFI_MACHINE_TYPE_NAME = ''
1464 #                 gnu_efi_arch = ''
1465 #         endif
1466 #
1467 #         have = true
1468 #         conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
1469 #
1470 #         conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
1471 # else
1472 #         have = false
1473 # endif
1474 #endif // 0
1475 conf.set10('ENABLE_EFI', have)
1476
1477 #####################################################################
1478
1479 config_h = configure_file(
1480         output : 'config.h',
1481         configuration : conf)
1482
1483 includes = include_directories('src/basic',
1484                                'src/shared',
1485                                'src/systemd',
1486 #if 0 /// UNNEEDED by elogind
1487 #                                'src/journal',
1488 #                                'src/resolve',
1489 #                                'src/timesync',
1490 #endif // 0
1491                                'src/login',
1492 #if 0 /// UNNEEDED by elogind
1493 #                                'src/udev',
1494 #                                'src/libudev',
1495 #endif // 0
1496                                'src/core',
1497 #if 0 /// elogind has a different list
1498 #                                'src/libsystemd/sd-bus',
1499 #                                'src/libsystemd/sd-device',
1500 #                                'src/libsystemd/sd-hwdb',
1501 #                                'src/libsystemd/sd-id128',
1502 #                                'src/libsystemd/sd-netlink',
1503 #                                'src/libsystemd/sd-network',
1504 #                                'src/libsystemd-network',
1505 #else
1506                                'src/libelogind/sd-bus',
1507                                'src/libelogind/sd-id128',
1508                                'src/sleep',
1509                                'src/update-utmp',
1510 #endif // 0
1511                                '.')
1512
1513 add_project_arguments('-include', 'config.h', language : 'c')
1514
1515 subdir('po')
1516 #if 0 /// UNNEEDED by elogind
1517 # subdir('catalog')
1518 #endif // 0
1519 subdir('src/systemd')
1520 subdir('src/basic')
1521 #if 0 /// UNNEEDED by elogind
1522 # subdir('src/libsystemd')
1523 # subdir('src/libsystemd-network')
1524 # subdir('src/journal')
1525 #else
1526 subdir('src/core')
1527 subdir('src/libelogind')
1528 subdir('src/sleep')
1529 subdir('src/update-utmp')
1530 #endif // 0
1531 subdir('src/login')
1532
1533 #if 0 /// UNNEEDED by elogind
1534 # libjournal_core = static_library(
1535 #         'journal-core',
1536 #         libjournal_core_sources,
1537 #         journald_gperf_c,
1538 #         include_directories : includes,
1539 #         install : false)
1540 #endif // 0
1541
1542 libelogind_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libelogind_sym)
1543 libelogind = shared_library(
1544         'elogind',
1545         'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
1546         version : libelogind_version,
1547         include_directories : includes,
1548         link_args : ['-shared',
1549                      '-Wl,--version-script=' + libelogind_sym_path],
1550 #if 0 /// elogind does not need gcrypt or libjournal_client, only threads.
1551 #         link_with : [libbasic,
1552 #                      libbasic_gcrypt],
1553 #         link_whole : [libsystemd_static,
1554 #                       libjournal_client],
1555 #         dependencies : [threads,
1556 #                         librt,
1557 #                         libxz,
1558 #                         liblz4],
1559 #         link_depends : libsystemd_sym,
1560 #else
1561         link_with : [libbasic],
1562         link_whole : [libelogind_static],
1563         dependencies : [threads],
1564         link_depends : libelogind_sym,
1565 #endif // 0
1566         install : true,
1567         install_dir : rootlibdir)
1568
1569 ############################################################
1570
1571 # binaries that have --help and are intended for use by humans,
1572 # usually, but not always, installed in /bin.
1573 public_programs = []
1574
1575 #if 0 /// UNNEEDED by elogind
1576 # subdir('src/libudev')
1577 #else
1578 # elogind depends on external libudev:
1579 libudev = dependency('libudev', required : true)
1580 #endif // 0
1581 subdir('src/shared')
1582 #if 0 /// UNNEEDED by elogind
1583 # subdir('src/core')
1584 # subdir('src/udev')
1585 # subdir('src/network')
1586 #
1587 # subdir('src/analyze')
1588 # subdir('src/journal-remote')
1589 # subdir('src/coredump')
1590 # subdir('src/hostname')
1591 # subdir('src/import')
1592 # subdir('src/kernel-install')
1593 # subdir('src/locale')
1594 # subdir('src/machine')
1595 # subdir('src/nspawn')
1596 # subdir('src/resolve')
1597 # subdir('src/timedate')
1598 # subdir('src/timesync')
1599 # subdir('src/vconsole')
1600 # subdir('src/boot/efi')
1601 #endif // 0
1602
1603 subdir('src/test')
1604 #if 0 /// UNNEEDED by elogind
1605 # subdir('src/fuzz')
1606 # subdir('rules')
1607 # subdir('test')
1608 #endif // 0
1609
1610 ############################################################
1611
1612 # only static linking apart from libdl, to make sure that the
1613 # module is linked to all libraries that it uses.
1614 test_dlopen = executable(
1615         'test-dlopen',
1616         test_dlopen_c,
1617         include_directories : includes,
1618         link_with : [libbasic],
1619         dependencies : [libdl])
1620
1621 #if 0 /// UNNEEDED by elogind
1622 # foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
1623 #                  ['systemd',    'ENABLE_NSS_SYSTEMD'],
1624 #                  ['mymachines', 'ENABLE_MACHINED'],
1625 #                  ['resolve',    'ENABLE_RESOLVE']]
1626 #
1627 #         condition = tuple[1] == '' or conf.get(tuple[1]) == 1
1628 #         if condition
1629 #                 module = tuple[0]
1630 #
1631 #                 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1632 #                 version_script_arg = join_paths(meson.current_source_dir(), sym)
1633 #
1634 #                 nss = shared_library(
1635 #                         'nss_' + module,
1636 #                         'src/nss-@0@/nss-@0@.c'.format(module),
1637 #                         version : '2',
1638 #                         include_directories : includes,
1639 #                         # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
1640 #                         link_args : ['-Wl,-z,nodelete',
1641 #                                      '-shared',
1642 #                                      '-Wl,--version-script=' + version_script_arg,
1643 #                                      '-Wl,--undefined'],
1644 #                         link_with : [libsystemd_static,
1645 #                                      libbasic],
1646 #                         dependencies : [threads,
1647 #                                         librt],
1648 #                         link_depends : sym,
1649 #                         install : true,
1650 #                         install_dir : rootlibdir)
1651 #
1652 #                 # We cannot use shared_module because it does not support version suffix.
1653 #                 # Unfortunately shared_library insists on creating the symlink…
1654 #                 meson.add_install_script('sh', '-c',
1655 #                                          'rm $DESTDIR@0@/libnss_@1@.so'
1656 #                                          .format(rootlibdir, module))
1657 #
1658 #                 test('dlopen-nss_' + module,
1659 #                      test_dlopen,
1660 #                      args : [nss.full_path()]) # path to dlopen must include a slash
1661 #         endif
1662 # endforeach
1663 #endif // 0
1664
1665 ############################################################
1666
1667 #if 0 /// UNNEEDED by elogind
1668 # executable('systemd',
1669 #            systemd_sources,
1670 #            include_directories : includes,
1671 #            link_with : [libcore,
1672 #                         libshared],
1673 #            dependencies : [threads,
1674 #                            librt,
1675 #                            libseccomp,
1676 #                            libselinux,
1677 #                            libmount,
1678 #                            libblkid],
1679 #            install_rpath : rootlibexecdir,
1680 #            install : true,
1681 #            install_dir : rootlibexecdir)
1682 #
1683 # meson.add_install_script(meson_make_symlink,
1684 #                          join_paths(rootlibexecdir, 'systemd'),
1685 #                          join_paths(rootsbindir, 'init'))
1686 #
1687 # exe = executable('systemd-analyze',
1688 #                  systemd_analyze_sources,
1689 #                  include_directories : includes,
1690 #                  link_with : [libcore,
1691 #                               libshared],
1692 #                  dependencies : [threads,
1693 #                                  librt,
1694 #                                  libseccomp,
1695 #                                  libselinux,
1696 #                                  libmount,
1697 #                                  libblkid],
1698 #                  install_rpath : rootlibexecdir,
1699 #                  install : true)
1700 # public_programs += [exe]
1701 #
1702 # executable('systemd-journald',
1703 #            systemd_journald_sources,
1704 #            include_directories : includes,
1705 #            link_with : [libjournal_core,
1706 #                         libshared],
1707 #            dependencies : [threads,
1708 #                            libxz,
1709 #                            liblz4,
1710 #                            libselinux],
1711 #            install_rpath : rootlibexecdir,
1712 #            install : true,
1713 #            install_dir : rootlibexecdir)
1714 #
1715 # exe = executable('systemd-cat',
1716 #                  systemd_cat_sources,
1717 #                  include_directories : includes,
1718 #                  link_with : [libjournal_core,
1719 #                               libshared],
1720 #                  dependencies : [threads],
1721 #                  install_rpath : rootlibexecdir,
1722 #                  install : true)
1723 # public_programs += [exe]
1724 #
1725 # exe = executable('journalctl',
1726 #                  journalctl_sources,
1727 #                  include_directories : includes,
1728 #                  link_with : [libshared],
1729 #                  dependencies : [threads,
1730 #                                  libqrencode,
1731 #                                  libxz,
1732 #                                  liblz4,
1733 #                                  libpcre2],
1734 #                  install_rpath : rootlibexecdir,
1735 #                  install : true,
1736 #                  install_dir : rootbindir)
1737 # public_programs += [exe]
1738 #
1739 # executable('systemd-getty-generator',
1740 #            'src/getty-generator/getty-generator.c',
1741 #            include_directories : includes,
1742 #            link_with : [libshared],
1743 #            install_rpath : rootlibexecdir,
1744 #            install : true,
1745 #            install_dir : systemgeneratordir)
1746 #
1747 # executable('systemd-debug-generator',
1748 #            'src/debug-generator/debug-generator.c',
1749 #            include_directories : includes,
1750 #            link_with : [libshared],
1751 #            install_rpath : rootlibexecdir,
1752 #            install : true,
1753 #            install_dir : systemgeneratordir)
1754 #
1755 # executable('systemd-fstab-generator',
1756 #            'src/fstab-generator/fstab-generator.c',
1757 #            'src/core/mount-setup.c',
1758 #            include_directories : includes,
1759 #            link_with : [libshared],
1760 #            install_rpath : rootlibexecdir,
1761 #            install : true,
1762 #            install_dir : systemgeneratordir)
1763 #
1764 # if conf.get('ENABLE_ENVIRONMENT_D') == 1
1765 #         executable('30-systemd-environment-d-generator',
1766 #                    'src/environment-d-generator/environment-d-generator.c',
1767 #                    include_directories : includes,
1768 #                    link_with : [libshared],
1769 #                    install_rpath : rootlibexecdir,
1770 #                    install : true,
1771 #                    install_dir : userenvgeneratordir)
1772 #
1773 #         meson.add_install_script(meson_make_symlink,
1774 #                                  join_paths(sysconfdir, 'environment'),
1775 #                                  join_paths(environmentdir, '99-environment.conf'))
1776 # endif
1777 #
1778 # if conf.get('ENABLE_HIBERNATE') == 1
1779 #         executable('systemd-hibernate-resume-generator',
1780 #                    'src/hibernate-resume/hibernate-resume-generator.c',
1781 #                    include_directories : includes,
1782 #                    link_with : [libshared],
1783 #                    install_rpath : rootlibexecdir,
1784 #                    install : true,
1785 #                    install_dir : systemgeneratordir)
1786 #
1787 #         executable('systemd-hibernate-resume',
1788 #                    'src/hibernate-resume/hibernate-resume.c',
1789 #                    include_directories : includes,
1790 #                    link_with : [libshared],
1791 #                    install_rpath : rootlibexecdir,
1792 #                    install : true,
1793 #                    install_dir : rootlibexecdir)
1794 # endif
1795 #
1796 # if conf.get('HAVE_BLKID') == 1
1797 #         executable('systemd-gpt-auto-generator',
1798 #                    'src/gpt-auto-generator/gpt-auto-generator.c',
1799 #                    'src/basic/blkid-util.h',
1800 #                    include_directories : includes,
1801 #                    link_with : [libshared],
1802 #                    dependencies : libblkid,
1803 #                    install_rpath : rootlibexecdir,
1804 #                    install : true,
1805 #                    install_dir : systemgeneratordir)
1806 #
1807 #         exe = executable('systemd-dissect',
1808 #                          'src/dissect/dissect.c',
1809 #                          include_directories : includes,
1810 #                          link_with : [libshared],
1811 #                          install_rpath : rootlibexecdir,
1812 #                          install : true,
1813 #                          install_dir : rootlibexecdir)
1814 #         public_programs += [exe]
1815 # endif
1816 #
1817 # if conf.get('ENABLE_RESOLVE') == 1
1818 #         executable('systemd-resolved',
1819 #                    systemd_resolved_sources,
1820 #                    include_directories : includes,
1821 #                    link_with : [libshared,
1822 #                                 libbasic_gcrypt,
1823 #                                 libsystemd_resolve_core],
1824 #                    dependencies : [threads,
1825 #                                    libgpg_error,
1826 #                                    libm,
1827 #                                    libidn],
1828 #                    install_rpath : rootlibexecdir,
1829 #                    install : true,
1830 #                    install_dir : rootlibexecdir)
1831 #
1832 #         exe = executable('systemd-resolve',
1833 #                          systemd_resolve_sources,
1834 #                          include_directories : includes,
1835 #                          link_with : [libshared,
1836 #                                       libbasic_gcrypt,
1837 #                                       libsystemd_resolve_core],
1838 #                          dependencies : [threads,
1839 #                                          libgpg_error,
1840 #                                          libm,
1841 #                                          libidn],
1842 #                          install_rpath : rootlibexecdir,
1843 #                          install : true)
1844 #         public_programs += [exe]
1845 # endif
1846 #
1847 # if conf.get('ENABLE_LOGIND') == 1
1848 #         executable('systemd-logind',
1849 #                    systemd_logind_sources,
1850 #                    include_directories : includes,
1851 #                    link_with : [liblogind_core,
1852 #                                 libshared],
1853 #                    dependencies : [threads,
1854 #                                    libacl],
1855 #                    install_rpath : rootlibexecdir,
1856 #                    install : true,
1857 #                    install_dir : rootlibexecdir)
1858 #
1859 #         exe = executable('loginctl',
1860 #                          loginctl_sources,
1861 #                          include_directories : includes,
1862 #                          link_with : [libshared],
1863 #                          dependencies : [threads,
1864 #                                          liblz4,
1865 #                                          libxz],
1866 #                          install_rpath : rootlibexecdir,
1867 #                          install : true,
1868 #                          install_dir : rootbindir)
1869 #         public_programs += [exe]
1870 #
1871 #         exe = executable('systemd-inhibit',
1872 #                          'src/login/inhibit.c',
1873 #                          include_directories : includes,
1874 #                          link_with : [libshared],
1875 #                          install_rpath : rootlibexecdir,
1876 #                          install : true,
1877 #                          install_dir : rootbindir)
1878 #         public_programs += [exe]
1879 #
1880 #         if conf.get('HAVE_PAM') == 1
1881 #                 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1882 #                 pam_systemd = shared_library(
1883 #                         'pam_systemd',
1884 #                         pam_systemd_c,
1885 #                         name_prefix : '',
1886 #                         include_directories : includes,
1887 #                         link_args : ['-shared',
1888 #                                      '-Wl,--version-script=' + version_script_arg],
1889 #                         link_with : [libsystemd_static,
1890 #                                      libshared_static],
1891 #                         dependencies : [threads,
1892 #                                         libpam,
1893 #                                         libpam_misc],
1894 #                         link_depends : pam_systemd_sym,
1895 #                         install : true,
1896 #                         install_dir : pamlibdir)
1897 #
1898 #                 test('dlopen-pam_systemd',
1899 #                      test_dlopen,
1900 #                      args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1901 #         endif
1902 # endif
1903 #else
1904
1905 executable('elogind',
1906                 elogind_sources,
1907                 include_directories : includes,
1908                 link_with : [liblogind_core,
1909                              libshared],
1910                 dependencies : [threads,
1911                                 libacl,
1912                                 libudev],
1913                 install_rpath : rootlibexecdir,
1914                 install : true,
1915                 install_dir : rootlibexecdir)
1916
1917 exe = executable('loginctl',
1918                         loginctl_sources,
1919                         include_directories : includes,
1920                         link_with : [libshared],
1921                         dependencies : [threads,
1922                                         libudev],
1923                         install_rpath : rootlibexecdir,
1924                         install : true,
1925                         install_dir : rootbindir)
1926 public_programs += [exe]
1927
1928 exe = executable('elogind-inhibit',
1929                         'src/login/inhibit.c',
1930                         include_directories : includes,
1931                         link_with : [libshared],
1932                         dependencies : [threads],
1933                         install_rpath : rootlibexecdir,
1934                         install : true,
1935                         install_dir : rootbindir)
1936 public_programs += [exe]
1937
1938 if conf.get('HAVE_PAM') == 1
1939         version_script_arg = join_paths(meson.current_source_dir(), pam_elogind_sym)
1940         pam_elogind = shared_library(
1941                 'pam_elogind',
1942                 pam_elogind_c,
1943                 name_prefix : '',
1944                 include_directories : includes,
1945                 link_args : ['-shared',
1946                                 '-Wl,--version-script=' + version_script_arg],
1947                 link_with : [libelogind_static,
1948                              libshared_static],
1949                 dependencies : [threads,
1950                                 libpam,
1951                                 libpam_misc],
1952                 link_depends : pam_elogind_sym,
1953                 install : true,
1954                 install_dir : pamlibdir)
1955
1956         test('dlopen-pam_elogind',
1957              test_dlopen,
1958              args : [pam_elogind.full_path()]) # path to dlopen must include a slash
1959 endif
1960 #endif // 0
1961 #if 0 /// UNNEEDED by elogind
1962 #         executable('systemd-user-sessions',
1963 #                    'src/user-sessions/user-sessions.c',
1964 #                    include_directories : includes,
1965 #                    link_with : [libshared],
1966 #                    install_rpath : rootlibexecdir,
1967 #                    install : true,
1968 #                    install_dir : rootlibexecdir)
1969 # endif
1970 #
1971 # if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
1972 #         exe = executable('bootctl',
1973 #                          'src/boot/bootctl.c',
1974 #                          include_directories : includes,
1975 #                          link_with : [libshared],
1976 #                          dependencies : [libblkid],
1977 #                          install_rpath : rootlibexecdir,
1978 #                          install : true)
1979 #         public_programs += [exe]
1980 # endif
1981 #
1982 # exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1983 #                  include_directories : includes,
1984 #                  link_with : [libshared],
1985 #                  dependencies : [threads],
1986 #                  install_rpath : rootlibexecdir,
1987 #                  install : true)
1988 # public_programs += [exe]
1989 #
1990 # exe = executable('systemctl', 'src/systemctl/systemctl.c',
1991 #                  include_directories : includes,
1992 #                  link_with : [libshared],
1993 #                  dependencies : [threads,
1994 #                                  libcap,
1995 #                                  libselinux,
1996 #                                  libxz,
1997 #                                  liblz4],
1998 #                  install_rpath : rootlibexecdir,
1999 #                  install : true,
2000 #                  install_dir : rootbindir)
2001 # public_programs += [exe]
2002 #
2003 # foreach alias : ['halt', 'poweroff', 'reboot', 'runlevel', 'shutdown', 'telinit']
2004 #         meson.add_install_script(meson_make_symlink,
2005 #                                  join_paths(rootbindir, 'systemctl'),
2006 #                                  join_paths(rootsbindir, alias))
2007 # endforeach
2008 #
2009 # if conf.get('ENABLE_BACKLIGHT') == 1
2010 #         executable('systemd-backlight',
2011 #                    'src/backlight/backlight.c',
2012 #                    include_directories : includes,
2013 #                    link_with : [libshared],
2014 #                    install_rpath : rootlibexecdir,
2015 #                    install : true,
2016 #                    install_dir : rootlibexecdir)
2017 # endif
2018 #
2019 # if conf.get('ENABLE_RFKILL') == 1
2020 #         executable('systemd-rfkill',
2021 #                    'src/rfkill/rfkill.c',
2022 #                    include_directories : includes,
2023 #                    link_with : [libshared],
2024 #                    install_rpath : rootlibexecdir,
2025 #                    install : true,
2026 #                    install_dir : rootlibexecdir)
2027 # endif
2028 #
2029 # executable('systemd-system-update-generator',
2030 #            'src/system-update-generator/system-update-generator.c',
2031 #            include_directories : includes,
2032 #            link_with : [libshared],
2033 #            install_rpath : rootlibexecdir,
2034 #            install : true,
2035 #            install_dir : systemgeneratordir)
2036 #
2037 # if conf.get('HAVE_LIBCRYPTSETUP') == 1
2038 #         executable('systemd-cryptsetup',
2039 #                    'src/cryptsetup/cryptsetup.c',
2040 #                    include_directories : includes,
2041 #                    link_with : [libshared],
2042 #                    dependencies : [libcryptsetup],
2043 #                    install_rpath : rootlibexecdir,
2044 #                    install : true,
2045 #                    install_dir : rootlibexecdir)
2046 #
2047 #         executable('systemd-cryptsetup-generator',
2048 #                    'src/cryptsetup/cryptsetup-generator.c',
2049 #                    include_directories : includes,
2050 #                    link_with : [libshared],
2051 #                    dependencies : [libcryptsetup],
2052 #                    install_rpath : rootlibexecdir,
2053 #                    install : true,
2054 #                    install_dir : systemgeneratordir)
2055 #
2056 #         executable('systemd-veritysetup',
2057 #                    'src/veritysetup/veritysetup.c',
2058 #                    include_directories : includes,
2059 #                    link_with : [libshared],
2060 #                    dependencies : [libcryptsetup],
2061 #                    install_rpath : rootlibexecdir,
2062 #                    install : true,
2063 #                    install_dir : rootlibexecdir)
2064 #
2065 #         executable('systemd-veritysetup-generator',
2066 #                    'src/veritysetup/veritysetup-generator.c',
2067 #                    include_directories : includes,
2068 #                    link_with : [libshared],
2069 #                    dependencies : [libcryptsetup],
2070 #                    install_rpath : rootlibexecdir,
2071 #                    install : true,
2072 #                    install_dir : systemgeneratordir)
2073 # endif
2074 #
2075 # if conf.get('HAVE_SYSV_COMPAT') == 1
2076 #         executable('systemd-sysv-generator',
2077 #                    'src/sysv-generator/sysv-generator.c',
2078 #                    include_directories : includes,
2079 #                    link_with : [libshared],
2080 #                    install_rpath : rootlibexecdir,
2081 #                    install : true,
2082 #                    install_dir : systemgeneratordir)
2083 #
2084 #         executable('systemd-rc-local-generator',
2085 #                    'src/rc-local-generator/rc-local-generator.c',
2086 #                    include_directories : includes,
2087 #                    link_with : [libshared],
2088 #                    install_rpath : rootlibexecdir,
2089 #                    install : true,
2090 #                    install_dir : systemgeneratordir)
2091 # endif
2092 #
2093 # if conf.get('ENABLE_HOSTNAMED') == 1
2094 #         executable('systemd-hostnamed',
2095 #                    'src/hostname/hostnamed.c',
2096 #                    include_directories : includes,
2097 #                    link_with : [libshared],
2098 #                    install_rpath : rootlibexecdir,
2099 #                    install : true,
2100 #                    install_dir : rootlibexecdir)
2101 #
2102 #         exe = executable('hostnamectl',
2103 #                          'src/hostname/hostnamectl.c',
2104 #                          include_directories : includes,
2105 #                          link_with : [libshared],
2106 #                          install_rpath : rootlibexecdir,
2107 #                          install : true)
2108 #         public_programs += [exe]
2109 # endif
2110 #
2111 # if conf.get('ENABLE_LOCALED') == 1
2112 #         if conf.get('HAVE_XKBCOMMON') == 1
2113 #                 # logind will load libxkbcommon.so dynamically on its own
2114 #                 deps = [libdl]
2115 #         else
2116 #                 deps = []
2117 #         endif
2118 #
2119 #         executable('systemd-localed',
2120 #                    systemd_localed_sources,
2121 #                    include_directories : includes,
2122 #                    link_with : [libshared],
2123 #                    dependencies : deps,
2124 #                    install_rpath : rootlibexecdir,
2125 #                    install : true,
2126 #                    install_dir : rootlibexecdir)
2127 #
2128 #         exe = executable('localectl',
2129 #                          localectl_sources,
2130 #                          include_directories : includes,
2131 #                          link_with : [libshared],
2132 #                          install_rpath : rootlibexecdir,
2133 #                          install : true)
2134 #         public_programs += [exe]
2135 # endif
2136 #
2137 # if conf.get('ENABLE_TIMEDATED') == 1
2138 #         executable('systemd-timedated',
2139 #                    'src/timedate/timedated.c',
2140 #                    include_directories : includes,
2141 #                    link_with : [libshared],
2142 #                    install_rpath : rootlibexecdir,
2143 #                    install : true,
2144 #                    install_dir : rootlibexecdir)
2145 #
2146 #         exe = executable('timedatectl',
2147 #                          'src/timedate/timedatectl.c',
2148 #                          include_directories : includes,
2149 #                          install_rpath : rootlibexecdir,
2150 #                          link_with : [libshared],
2151 #                          install : true)
2152 #         public_programs += [exe]
2153 # endif
2154 #
2155 # if conf.get('ENABLE_TIMESYNCD') == 1
2156 #         executable('systemd-timesyncd',
2157 #                    systemd_timesyncd_sources,
2158 #                    include_directories : includes,
2159 #                    link_with : [libshared],
2160 #                    dependencies : [threads,
2161 #                                    libm],
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 #            install_rpath : rootlibexecdir,
2681 #            install : true,
2682 #            install_dir : rootlibexecdir)
2683 #
2684 # executable('systemd-update-done',
2685 #            'src/update-done/update-done.c',
2686 #            include_directories : includes,
2687 #            link_with : [libshared],
2688 #            install_rpath : rootlibexecdir,
2689 #            install : true,
2690 #            install_dir : rootlibexecdir)
2691 #
2692 # executable('systemd-update-utmp',
2693 #            'src/update-utmp/update-utmp.c',
2694 #            include_directories : includes,
2695 #            link_with : [libshared],
2696 #            dependencies : [libaudit],
2697 #            install_rpath : rootlibexecdir,
2698 #            install : true,
2699 #            install_dir : rootlibexecdir)
2700 #
2701 # if conf.get('HAVE_KMOD') == 1
2702 #         executable('systemd-modules-load',
2703 #                    'src/modules-load/modules-load.c',
2704 #                    include_directories : includes,
2705 #                    link_with : [libshared],
2706 #                    dependencies : [libkmod],
2707 #                    install_rpath : rootlibexecdir,
2708 #                    install : true,
2709 #                    install_dir : rootlibexecdir)
2710 #
2711 #         meson.add_install_script('sh', '-c',
2712 #                                  mkdir_p.format(modulesloaddir))
2713 #         meson.add_install_script('sh', '-c',
2714 #                                  mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
2715 # endif
2716 #
2717 # exe = executable('systemd-nspawn',
2718 #                  systemd_nspawn_sources,
2719 #                  'src/core/mount-setup.c', # FIXME: use a variable?
2720 #                  'src/core/mount-setup.h',
2721 #                  'src/core/loopback-setup.c',
2722 #                  'src/core/loopback-setup.h',
2723 #                  include_directories : [includes, include_directories('src/nspawn')],
2724 #                  link_with : [libshared],
2725 #                  dependencies : [libacl,
2726 #                                  libblkid,
2727 #                                  libseccomp,
2728 #                                  libselinux],
2729 #                  install_rpath : rootlibexecdir,
2730 #                  install : true)
2731 # public_programs += [exe]
2732 #
2733 # if conf.get('ENABLE_NETWORKD') == 1
2734 #         executable('systemd-networkd',
2735 #                    systemd_networkd_sources,
2736 #                    include_directories : includes,
2737 #                    link_with : [libnetworkd_core,
2738 #                                 libsystemd_network,
2739 #                                 libudev_static,
2740 #                                 libshared],
2741 #                    dependencies : [threads],
2742 #                    install_rpath : rootlibexecdir,
2743 #                    install : true,
2744 #                    install_dir : rootlibexecdir)
2745 #
2746 #         executable('systemd-networkd-wait-online',
2747 #                    systemd_networkd_wait_online_sources,
2748 #                    include_directories : includes,
2749 #                    link_with : [libnetworkd_core,
2750 #                                 libshared],
2751 #                    install_rpath : rootlibexecdir,
2752 #                    install : true,
2753 #                    install_dir : rootlibexecdir)
2754 #
2755 #         exe = executable('networkctl',
2756 #                    networkctl_sources,
2757 #                    include_directories : includes,
2758 #                    link_with : [libsystemd_network,
2759 #                               libshared],
2760 #                    install_rpath : rootlibexecdir,
2761 #                    install : true,
2762 #                    install_dir : rootbindir)
2763 #         public_programs += [exe]
2764 # endif
2765 #
2766 # executable('systemd-sulogin-shell',
2767 #            ['src/sulogin-shell/sulogin-shell.c'],
2768 #            include_directories : includes,
2769 #            link_with : [libshared],
2770 #            install_rpath : rootlibexecdir,
2771 #            install : true,
2772 #            install_dir : rootlibexecdir)
2773 #else
2774 executable('elogind-uaccess-command',
2775            'src/uaccess-command/uaccess-command.c',
2776            include_directories : includes,
2777            link_with : [liblogind_core,
2778                         libshared],
2779            dependencies: [libacl,
2780                           libudev],
2781            install_rpath : rootlibexecdir,
2782            install : true,
2783            install_dir : rootlibexecdir)
2784 #endif // 0
2785
2786 ############################################################
2787
2788 foreach tuple : tests
2789         sources = tuple[0]
2790         link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2791         dependencies = tuple[2]
2792         condition = tuple.length() >= 4 ? tuple[3] : ''
2793         type = tuple.length() >= 5 ? tuple[4] : ''
2794         defs = tuple.length() >= 6 ? tuple[5] : []
2795         incs = tuple.length() >= 7 ? tuple[6] : includes
2796         timeout = 30
2797
2798         name = sources[0].split('/')[-1].split('.')[0]
2799         if type.startswith('timeout=')
2800                 timeout = type.split('=')[1].to_int()
2801                 type = ''
2802         endif
2803         if want_tests == 'false'
2804                 message('Not compiling @0@ because tests is set to false'.format(name))
2805         elif condition == '' or conf.get(condition) == 1
2806                 exe = executable(
2807                         name,
2808                         sources,
2809                         include_directories : incs,
2810                         link_with : link_with,
2811                         dependencies : dependencies,
2812                         c_args : defs,
2813                         install_rpath : rootlibexecdir,
2814                         install : install_tests,
2815                         install_dir : join_paths(testsdir, type))
2816
2817                 if type == 'manual'
2818                         message('@0@ is a manual test'.format(name))
2819                 elif type == 'unsafe' and want_tests != 'unsafe'
2820                         message('@0@ is an unsafe test'.format(name))
2821                 else
2822                         test(name, exe,
2823                              env : test_env,
2824                              timeout : timeout)
2825                 endif
2826         else
2827                 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2828         endif
2829 endforeach
2830
2831 #if 0 /// UNNEEDED by elogind
2832 # test_libsystemd_sym = executable(
2833 #         'test-libsystemd-sym',
2834 #         test_libsystemd_sym_c,
2835 #         include_directories : includes,
2836 #         link_with : [libsystemd],
2837 #         install : install_tests,
2838 #         install_dir : testsdir)
2839 # test('test-libsystemd-sym',
2840 #      test_libsystemd_sym)
2841 #
2842 # test_libudev_sym = executable(
2843 #         'test-libudev-sym',
2844 #         test_libudev_sym_c,
2845 #         include_directories : includes,
2846 #         c_args : ['-Wno-deprecated-declarations'],
2847 #         link_with : [libudev],
2848 #         install : install_tests,
2849 #         install_dir : testsdir)
2850 # test('test-libudev-sym',
2851 #      test_libudev_sym)
2852 #
2853 # ############################################################
2854 #
2855 # fuzzer_exes = []
2856 #
2857 # foreach tuple : fuzzers
2858 #         sources = tuple[0]
2859 #         link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2860 #         dependencies = tuple[2]
2861 #         defs = tuple.length() >= 4 ? tuple[3] : []
2862 #         incs = tuple.length() >= 5 ? tuple[4] : includes
2863 #
2864 #         if fuzzer_build
2865 #                 dependencies += fuzzing_engine
2866 #         else
2867 #                 sources += 'src/fuzz/fuzz-main.c'
2868 #         endif
2869 #
2870 #         name = sources[0].split('/')[-1].split('.')[0]
2871 #
2872 #         fuzzer_exes += executable(
2873 #                 name,
2874 #                 sources,
2875 #                 include_directories : [incs, include_directories('src/fuzz')],
2876 #                 link_with : link_with,
2877 #                 dependencies : dependencies,
2878 #                 c_args : defs,
2879 #                 install : false)
2880 # endforeach
2881 #
2882 # run_target('fuzzers',
2883 #         depends : fuzzer_exes,
2884 #         command : ['true'])
2885 #
2886 # ############################################################
2887 #
2888 #else
2889 test_libelogind_sym = executable(
2890         'test-libelogind-sym',
2891         test_libelogind_sym_c,
2892         include_directories : includes,
2893         link_with : [libelogind],
2894         install : install_tests,
2895         install_dir : testsdir)
2896 test('test-libelogind-sym',
2897      test_libelogind_sym)
2898 #endif // 0
2899 make_directive_index_py = find_program('tools/make-directive-index.py')
2900 make_man_index_py = find_program('tools/make-man-index.py')
2901 xml_helper_py = find_program('tools/xml_helper.py')
2902 #if 0 /// UNNEEDED by elogind
2903 # hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
2904 #
2905 # subdir('units')
2906 # subdir('sysctl.d')
2907 # subdir('sysusers.d')
2908 # subdir('tmpfiles.d')
2909 # subdir('presets')
2910 # subdir('hwdb')
2911 # subdir('network')
2912 #endif // 0
2913 subdir('man')
2914 subdir('shell-completion/bash')
2915 subdir('shell-completion/zsh')
2916 #if 0 /// UNNEEDED by elogind
2917 # subdir('docs/sysvinit')
2918 # subdir('docs/var-log')
2919 #endif // 0
2920
2921 # FIXME: figure out if the warning is true:
2922 # https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2923 install_subdir('factory/etc',
2924                install_dir : factorydir)
2925
2926
2927 #if 0 /// UNNEEDED by elogind
2928 # install_data('xorg/50-systemd-user.sh',
2929 #              install_dir : xinitrcdir)
2930 # install_data('modprobe.d/systemd.conf',
2931 #              install_dir : modprobedir)
2932 #endif // 0
2933 install_data('LICENSE.GPL2',
2934              'LICENSE.LGPL2.1',
2935              'NEWS',
2936              'README',
2937              'doc/CODING_STYLE',
2938 #if 0 /// irrelevant for elogind
2939 #              'doc/DISTRO_PORTING',
2940 #              'doc/ENVIRONMENT.md',
2941 #              'doc/HACKING',
2942 #              'doc/TRANSIENT-SETTINGS.md',
2943 #              'doc/TRANSLATORS',
2944 #              'doc/UIDS-GIDS.md',
2945 #endif // 0
2946              'src/libelogind/sd-bus/GVARIANT-SERIALIZATION',
2947              install_dir : docdir)
2948
2949 #if 0 /// UNNEEDED by elogind
2950 # meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2951 #endif // 0
2952 meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2953
2954 ############################################################
2955
2956 meson_check_help = find_program('tools/meson-check-help.sh')
2957
2958 foreach exec : public_programs
2959         name = exec.full_path().split('/')[-1]
2960         test('check-help-' + name,
2961              meson_check_help,
2962              args : [exec.full_path()])
2963 endforeach
2964
2965 ############################################################
2966
2967 #if 0 /// fuzz regression tests are not supported by elogind
2968 # prev = ''
2969 # foreach p : fuzz_regression_tests
2970 #         a = p.split('/')[-3]
2971 #         b = p.split('/')[-2]
2972 #         c = p.split('/')[-1]
2973 #
2974 #         if a == 'address'
2975 #                 build = sanitize_address
2976 #         else
2977 #                 error('unknown sanitizer @0@'.format(a))
2978 #         endif
2979 #
2980 #         name = '@1@:@0@'.format(a, b)
2981 #
2982 #         if name != prev
2983 #                 if want_tests == 'false'
2984 #                         message('Not compiling @0@ because tests is set to false'.format(name))
2985 #                 elif not sanitizers.contains(a)
2986 #                         message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a))
2987 #                 elif slow_tests
2988 #                         exe = custom_target(
2989 #                                 name,
2990 #                                 output : name,
2991 #                                 depends : build,
2992 #                                 command : [env, 'ln', '-fs',
2993 #                                            join_paths(build.full_path(), b),
2994 #                                            '@OUTPUT@'],
2995 #                                 build_by_default : true)
2996 #                 else
2997 #                         message('Not compiling @0@ because slow-tests is set to false'.format(name))
2998 #                 endif
2999 #         endif
3000 #         prev = name
3001 #
3002 #         if want_tests != 'false' and slow_tests
3003 #                 test(c, env, args : [exe.full_path(),
3004 #                                      join_paths(meson.source_root(),
3005 #                                                 'test/fuzz-regressions',
3006 #                                                 p)])
3007 #         endif
3008 # endforeach
3009 #endif // 0
3010
3011 ############################################################
3012
3013 if git.found()
3014         all_files = run_command(
3015                 git,
3016                 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
3017                  'ls-files',
3018                  ':/*.[ch]'])
3019         all_files = files(all_files.stdout().split())
3020
3021         custom_target(
3022                 'tags',
3023                 output : 'tags',
3024                 command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files)
3025         custom_target(
3026                 'ctags',
3027                 output : 'ctags',
3028                 command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files)
3029 endif
3030
3031 #if 0 /// UNNEEDED by elogind
3032 # if git.found()
3033 #         meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
3034 #         run_target(
3035 #                 'git-contrib',
3036 #                 command : [meson_git_contrib_sh])
3037 # endif
3038 #endif // 0
3039
3040 if git.found()
3041         git_head = run_command(
3042                 git,
3043                 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
3044                  'rev-parse', 'HEAD']).stdout().strip()
3045         git_head_short = run_command(
3046                 git,
3047                 ['--git-dir=@0@/.git'.format(meson.current_source_dir()),
3048                  'rev-parse', '--short=7', 'HEAD']).stdout().strip()
3049
3050         run_target(
3051                 'git-snapshot',
3052                 command : ['git', 'archive',
3053                            '-o', '@0@/systemd-@1@.tar.gz'.format(meson.current_source_dir(),
3054                                                                  git_head_short),
3055                            '--prefix', 'systemd-@0@/'.format(git_head),
3056                            'HEAD'])
3057 endif
3058
3059 ############################################################
3060
3061 meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
3062 run_target(
3063         'check-api-docs',
3064 #if 0 /// libudev is external, elogind does not need to document it.
3065 #         depends : [man, libsystemd, libudev],
3066 #         command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
3067 #else
3068         depends : [man, libelogind],
3069         command : [meson_check_api_docs_sh, libelogind.full_path()])
3070 #endif // 0
3071
3072 ############################################################
3073
3074 status = [
3075         '@0@ @1@'.format(meson.project_name(), meson.project_version()),
3076
3077         'split /usr:                        @0@'.format(split_usr),
3078         'split bin-sbin:                    @0@'.format(split_bin),
3079 #if 0 /// UNSUPPORTED by elogind
3080 #         'prefix directory:                  @0@'.format(prefixdir),
3081 #         'rootprefix directory:              @0@'.format(rootprefixdir),
3082 #         'sysconf directory:                 @0@'.format(sysconfdir),
3083 #         'include directory:                 @0@'.format(includedir),
3084 #         'lib directory:                     @0@'.format(libdir),
3085 #         'rootlib directory:                 @0@'.format(rootlibdir),
3086 #         'SysV init scripts:                 @0@'.format(sysvinit_path),
3087 #         'SysV rc?.d directories:            @0@'.format(sysvrcnd_path),
3088 #else
3089         'rootexeclib dir:                   @0@'.format(rootlibexecdir),
3090 #endif // 0
3091 #if 0 /// UNSUPPORTED by elogind
3092 #         'PAM modules directory:             @0@'.format(pamlibdir),
3093 #         'PAM configuration directory:       @0@'.format(pamconfdir),
3094 #         'RPM macros directory:              @0@'.format(rpmmacrosdir),
3095 #         'modprobe.d directory:              @0@'.format(modprobedir),
3096 #         'D-Bus policy directory:            @0@'.format(dbuspolicydir),
3097 #         'D-Bus session directory:           @0@'.format(dbussessionservicedir),
3098 #         'D-Bus system directory:            @0@'.format(dbussystemservicedir),
3099 #         'bash completions directory:        @0@'.format(bashcompletiondir),
3100 #         'zsh completions directory:         @0@'.format(zshcompletiondir),
3101 #         'extra start script:                @0@'.format(get_option('rc-local')),
3102 #         'extra stop script:                 @0@'.format(get_option('halt-local')),
3103 #         'debug shell:                       @0@ @ @1@'.format(get_option('debug-shell'),
3104 #                                                               get_option('debug-tty')),
3105 #endif // 0
3106         'TTY GID:                           @0@'.format(tty_gid),
3107 #if 0 /// UNSUPPORTED by elogind
3108 #         'users GID:                         @0@'.format(users_gid),
3109 #endif // 0
3110         'maximum system UID:                @0@'.format(system_uid_max),
3111         'maximum system GID:                @0@'.format(system_gid_max),
3112 #if 0 /// UNSUPPORTED by elogind
3113 #         'minimum dynamic UID:               @0@'.format(dynamic_uid_min),
3114 #         'maximum dynamic UID:               @0@'.format(dynamic_uid_max),
3115 #         'minimum container UID base:        @0@'.format(container_uid_base_min),
3116 #         'maximum container UID base:        @0@'.format(container_uid_base_max),
3117 #         '/dev/kvm access mode:              @0@'.format(get_option('dev-kvm-mode')),
3118 #         'render group access mode:          @0@'.format(get_option('group-render-mode')),
3119 #         'certificate root directory:        @0@'.format(get_option('certificate-root')),
3120 #         'support URL:                       @0@'.format(support_url),
3121 #         'nobody user name:                  @0@'.format(nobody_user),
3122 #         'nobody group name:                 @0@'.format(nobody_group),
3123 #         'fallback hostname:                 @0@'.format(get_option('fallback-hostname')),
3124 #         'symbolic gateway hostnames:        @0@'.format(', '.join(gateway_hostnames)),
3125 #
3126 #         'default DNSSEC mode:               @0@'.format(default_dnssec),
3127 #         'default cgroup hierarchy:          @0@'.format(default_hierarchy),
3128 #endif // 0
3129         'default KillUserProcesses setting: @0@'.format(kill_user_processes)]
3130
3131 #if 0 /// UNSUPPORTED by elogind
3132 # alt_dns_servers = '\n                                            '.join(dns_servers.split(' '))
3133 # alt_ntp_servers = '\n                                            '.join(ntp_servers.split(' '))
3134 # status += [
3135 #         'default DNS servers:               @0@'.format(alt_dns_servers),
3136 #         'default NTP servers:               @0@'.format(alt_ntp_servers)]
3137 #
3138 # alt_time_epoch = run_command('date', '-Is', '-u', '-d',
3139 #                              '@@0@'.format(time_epoch)).stdout().strip()
3140 # status += [
3141 #         'time epoch:                        @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
3142 #endif // 0
3143
3144 # TODO:
3145 # CFLAGS:   ${OUR_CFLAGS} ${CFLAGS}
3146 # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
3147 # LDFLAGS:  ${OUR_LDFLAGS} ${LDFLAGS}
3148
3149 #if 0 /// UNNEEDED by elogind
3150 # if conf.get('ENABLE_EFI') == 1
3151 #         status += [
3152 #                 'efi arch:                          @0@'.format(efi_arch)]
3153 #
3154 #         if have_gnu_efi
3155 #                 status += [
3156 #                         'EFI machine type:                  @0@'.format(EFI_MACHINE_TYPE_NAME),
3157 #                         'EFI CC                             @0@'.format(efi_cc),
3158 #                         'EFI lib directory:                 @0@'.format(efi_libdir),
3159 #                         'EFI lds directory:                 @0@'.format(efi_ldsdir),
3160 #                         'EFI include directory:             @0@'.format(efi_incdir)]
3161 #         endif
3162 # endif
3163 #endif // 0
3164
3165 found = []
3166 missing = []
3167
3168 foreach tuple : [
3169 #if 0 /// UNNEEDED by elogind
3170 #         ['libcryptsetup'],
3171 #endif // 0
3172         ['PAM'],
3173         ['AUDIT'],
3174 #if 0 /// UNNEEDED by elogind
3175 #         ['IMA'],
3176 #         ['AppArmor'],
3177 #endif // 0
3178         ['SELinux'],
3179 #if 0 /// UNNEEDED by elogind
3180 #         ['SECCOMP'],
3181 #endif // 0
3182         ['SMACK'],
3183 #if 0 /// UNNEEDED by elogind
3184 #         ['zlib'],
3185 #         ['xz'],
3186 #         ['lz4'],
3187 #         ['bzip2'],
3188 #endif // 0
3189         ['ACL'],
3190 #if 0 /// UNNEEDED by elogind
3191 #         ['gcrypt'],
3192 #         ['qrencode'],
3193 #         ['microhttpd'],
3194 #         ['gnutls'],
3195 #         ['libcurl'],
3196 #         ['idn'],
3197 #         ['libidn2'],
3198 #         ['libidn'],
3199 #         ['nss-systemd'],
3200 #         ['libiptc'],
3201 #         ['elfutils'],
3202 #         ['binfmt'],
3203 #         ['vconsole'],
3204 #         ['quotacheck'],
3205 #         ['tmpfiles'],
3206 #         ['environment.d'],
3207 #         ['sysusers'],
3208 #         ['firstboot'],
3209 #         ['randomseed'],
3210 #         ['backlight'],
3211 #         ['rfkill'],
3212 #         ['logind'],
3213 #         ['machined'],
3214 #         ['importd'],
3215 #         ['hostnamed'],
3216 #         ['timedated'],
3217 #         ['timesyncd'],
3218 #         ['localed'],
3219 #         ['networkd'],
3220 #         ['resolve'],
3221 #         ['coredump'],
3222 #endif // 0
3223         ['polkit'],
3224         ['legacy pkla',      install_polkit_pkla],
3225 #if 0 /// UNNEEDED by elogind
3226 #         ['efi'],
3227 #         ['gnu-efi',          have_gnu_efi],
3228 #         ['kmod'],
3229 #         ['xkbcommon'],
3230 #         ['pcre2'],
3231 #         ['blkid'],
3232 #endif // 0
3233         ['dbus'],
3234         ['glib'],
3235 #if 0 /// UNNEEDED by elogind
3236 #         ['nss-myhostname',   conf.get('ENABLE_MYHOSTNAME') == 1],
3237 #         ['hwdb'],
3238 #         ['tpm'],
3239 #endif // 0
3240         ['man pages',        want_man],
3241         ['html pages',       want_html],
3242         ['man page indices', want_man and have_lxml],
3243 #if 0 /// UNNEEDED by elogind
3244 #         ['SysV compat'],
3245 #endif // 0
3246         ['utmp'],
3247 #if 0 /// UNNEEDED by elogind
3248 #         ['ldconfig'],
3249 #         ['hibernate'],
3250 #         ['adm group',        get_option('adm-group')],
3251 #         ['wheel group',      get_option('wheel-group')],
3252 #         ['gshadow'],
3253 #else
3254         ['debug elogind'],
3255 #endif // 0
3256         ['debug hashmap'],
3257         ['debug mmap cache'],
3258 ]
3259
3260         cond = tuple.get(1, false)
3261         if cond == false
3262                 ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
3263                 ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
3264                 cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
3265         endif
3266         if cond
3267                 found += [tuple[0]]
3268         else
3269                 missing += [tuple[0]]
3270         endif
3271 endforeach
3272
3273 status += [
3274         '',
3275         'enabled features: @0@'.format(', '.join(found)),
3276         '',
3277         'disabled features: @0@'.format(', '.join(missing)),
3278         '']
3279 message('\n         '.join(status))
3280
3281 if rootprefixdir != rootprefix_default
3282         message('WARNING:\n' +
3283                 '        Note that the installation prefix was changed to "@0@".\n'.format(rootprefixdir) +
3284                 '        elogind used fixed names for unit file directories and other paths, so anything\n' +
3285                 '        except the default ("@0@") is strongly discouraged.'.format(rootprefix_default))
3286 endif