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