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