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