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