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