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