]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: check string.h not strings.h for explicit_bzero
[thirdparty/systemd.git] / meson.build
CommitLineData
5c23128d
ZJS
1project('systemd', 'c',
2 version : '233',
3 license : 'LGPLv2+',
4 default_options: [
37efbbd8
ZJS
5 'c_std=gnu99',
6 'prefix=/usr',
7 'sysconfdir=/etc',
8 'localstatedir=/var',
5c23128d
ZJS
9 ],
10 meson_version : '>= 0.39.1',
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')
37efbbd8
ZJS
31 conf.set('HAVE_SPLIT_USR', 1)
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 != ''
37efbbd8
ZJS
40 conf.set('HAVE_SYSV_COMPAT', 1,
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')
225
226foreach arg : ['-Wundef',
227 '-Wlogical-op',
228 '-Wmissing-include-dirs',
229 '-Wold-style-definition',
230 '-Wpointer-arith',
231 '-Winit-self',
232 '-Wdeclaration-after-statement',
233 '-Wfloat-equal',
234 '-Wsuggest-attribute=noreturn',
235 '-Werror=missing-prototypes',
236 '-Werror=implicit-function-declaration',
237 '-Werror=missing-declarations',
238 '-Werror=return-type',
239 '-Werror=incompatible-pointer-types',
240 '-Werror=format=2',
241 '-Wstrict-prototypes',
242 '-Wredundant-decls',
243 '-Wmissing-noreturn',
244 '-Wshadow',
245 '-Wendif-labels',
246 '-Wstrict-aliasing=2',
247 '-Wwrite-strings',
248 '-Wno-unused-parameter',
249 '-Wno-missing-field-initializers',
250 '-Wno-unused-result',
251 '-Wno-format-signedness',
252 '-Werror=overflow',
253 '-Wdate-time',
254 '-Wnested-externs',
255 '-ffast-math',
256 '-fno-common',
257 '-fdiagnostics-show-option',
258 '-fno-strict-aliasing',
259 '-fvisibility=hidden',
260 '-fstack-protector',
261 '-fstack-protector-strong',
262 '-fPIE',
263 '--param=ssp-buffer-size=4',
264 ]
37efbbd8
ZJS
265 if cc.has_argument(arg)
266 add_project_arguments(arg, language : 'c')
267 endif
5c23128d
ZJS
268endforeach
269
270if cc.compiles('
271 #include <time.h>
272 #include <inttypes.h>
273 typedef uint64_t usec_t;
274 usec_t now(clockid_t clock);
275 int main(void) {
276 struct timespec now;
277 return 0;
278 }
279')
37efbbd8
ZJS
280 # TODO: message?
281 add_project_arguments('-Werror=shadow', language : 'c')
5c23128d
ZJS
282endif
283
284if cc.get_id() == 'clang'
37efbbd8
ZJS
285 foreach arg : ['-Wno-typedef-redefinition',
286 '-Wno-gnu-variable-sized-type-not-at-end',
287 ]
288 if cc.has_argument(arg)
289 add_project_arguments(arg, language : 'c')
290 endif
291 endforeach
5c23128d
ZJS
292endif
293
294# --as-needed and --no-undefined are provided by meson by default,
295# run mesonconf to see what is enabled
296foreach arg : ['-Wl,-z,relro',
297 '-Wl,-z,now',
298 '-pie',
299 '-Wl,-fuse-ld=gold',
300 ]
37efbbd8
ZJS
301 if cc.has_argument(arg)
302 add_project_link_arguments(arg, language : 'c')
303 endif
5c23128d
ZJS
304endforeach
305
9cc0e6e9
ZJS
306cpp = ' '.join(cc.cmd_array()) + ' -E'
307
5c23128d
ZJS
308#####################################################################
309# compilation result tests
310
311conf.set('_GNU_SOURCE', 1)
312conf.set('__SANE_USERSPACE_TYPES__', 1)
313
314conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
315conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
316conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
317conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
318conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
319conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
320conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
321
322decl_headers = '''
323#include <uchar.h>
324#include <linux/ethtool.h>
325'''
326# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
327
328foreach decl : ['char16_t',
329 'char32_t',
330 'key_serial_t',
331 'struct ethtool_link_settings',
332 ]
37efbbd8
ZJS
333 if cc.sizeof(decl, prefix : decl_headers) > 0
334 # We get -1 if the size cannot be determined
335 conf.set('HAVE_' + decl.underscorify().to_upper(), 1)
336 endif
5c23128d
ZJS
337endforeach
338
339foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
340 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
341 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
342 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
343 ['IFLA_IPVLAN_MODE', 'linux/if_link.h'],
344 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
345 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
346 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
347 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
348 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
349 # if_tunnel.h is buggy and cannot be included on its own
350 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
351 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
352 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
353 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
354 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
355 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
356 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
357 ['NDA_IFINDEX', 'linux/neighbour.h'],
358 ['IFA_FLAGS', 'linux/if_addr.h'],
359 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
360 ]
37efbbd8
ZJS
361 prefix = decl.length() > 2 ? decl[2] : ''
362 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
363 conf.set10('HAVE_DECL_' + decl[0], have)
5c23128d
ZJS
364endforeach
365
366skip = false
367foreach ident : ['secure_getenv', '__secure_getenv']
37efbbd8
ZJS
368 if not skip and cc.has_function(ident)
369 conf.set('HAVE_' + ident.to_upper(), 1)
370 skip = true
371 endif
5c23128d
ZJS
372endforeach
373
374foreach ident : [
37efbbd8
ZJS
375 ['memfd_create', '''#include <sys/memfd.h>'''],
376 ['gettid', '''#include <sys/types.h>'''],
377 ['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root
378 ['name_to_handle_at', '''#define _GNU_SOURCE
379 #include <sys/types.h>
380 #include <sys/stat.h>
381 #include <fcntl.h>'''],
382 ['setns', '''#define _GNU_SOURCE
383 #include <sched.h>'''],
384 ['getrandom', '''#include <sys/random.h>'''],
385 ['renameat2', '''#include <stdio.h>'''],
386 ['kcmp', '''#include <linux/kcmp.h>'''],
387 ['keyctl', '''#include <sys/types.h>
388 #include <keyutils.h>'''],
389 ['copy_file_range', '''#include <sys/syscall.h>
390 #include <unistd.h>'''],
38f1ae0f 391 ['explicit_bzero' , '''#include <string.h>'''],
37efbbd8
ZJS
392]
393
394 have = cc.has_function(ident[0], prefix : ident[1])
395 conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
5c23128d
ZJS
396endforeach
397
398#####################################################################
399
400sed = find_program('sed')
401grep = find_program('grep')
402awk = find_program('awk')
78b68dcb 403m4 = find_program('/usr/bin/m4')
5c23128d 404stat = find_program('stat')
d68b342b
ZJS
405git = find_program('git', required : false)
406etags = find_program('etags', required : false)
5c23128d 407
7b76fce1 408meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
94e75a54 409mkdir_p = 'mkdir -p $DESTDIR/@0@'
fdd147a8 410check_compilation_sh = find_program('tools/meson-check-compilation.sh')
d83f4f50
ZJS
411test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
412splash_bmp = files('test/splash.bmp')
94e75a54 413
5c23128d
ZJS
414# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
415# /usr/sbin, /sbin, and fall back to the default from middle column.
416progs = [['telinit', '/lib/sysvinit/telinit'],
417 ['quotaon', '/usr/sbin/quotaon' ],
418 ['quotacheck', '/usr/sbin/quotacheck' ],
419 ['kill', '/usr/bin/kill' ],
420 ['kmod', '/usr/bin/kmod' ],
421 ['kexec', '/usr/sbin/kexec' ],
422 ['sulogin', '/usr/sbin/sulogin' ],
423 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
424 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
425 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
426 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
427 ]
428foreach prog : progs
37efbbd8
ZJS
429 path = get_option(prog[0] + '-path')
430 if path != ''
431 message('Using @1@ for @0@'.format(prog[0], path))
432 else
433 exe = find_program(prog[0],
434 '/usr/sbin/' + prog[0],
435 '/sbin/' + prog[0],
436 required: false)
437 path = exe.found() ? exe.path() : prog[1]
438 endif
439 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
440 conf.set_quoted(name, path)
441 substs.set(name, path)
5c23128d
ZJS
442endforeach
443
1276a9f6
ZJS
444if run_command('ln', '--relative', '--help').returncode() != 0
445 error('ln does not support --relative')
446endif
5c23128d
ZJS
447
448############################################################
449
450gperf = find_program('gperf')
451
452gperf_test_format = '''
453#include <string.h>
454const char * in_word_set(const char *, @0@);
455@1@
456'''
457gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
458gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
459gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
460if cc.compiles(gperf_test)
37efbbd8 461 gperf_len_type = 'size_t'
5c23128d 462else
37efbbd8
ZJS
463 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
464 if cc.compiles(gperf_test)
465 gperf_len_type = 'unsigned'
466 else
467 error('unable to determine gperf len type')
468 endif
5c23128d
ZJS
469endif
470message('gperf len type is @0@'.format(gperf_len_type))
37efbbd8
ZJS
471conf.set('GPERF_LEN_TYPE', gperf_len_type,
472 description : 'The type of gperf "len" parameter')
5c23128d
ZJS
473
474############################################################
475
476if not cc.has_header('sys/capability.h')
37efbbd8 477 error('POSIX caps headers not found')
5c23128d
ZJS
478endif
479foreach header : ['linux/btrfs.h',
480 'linux/memfd.h',
481 'linux/vm_sockets.h',
482 'valgrind/memcheck.h',
483 'valgrind/valgrind.h',
484 ]
37efbbd8
ZJS
485 if cc.has_header(header)
486 conf.set('HAVE_' + header.underscorify().to_upper(), 1)
487 endif
5c23128d
ZJS
488endforeach
489
490############################################################
491
492conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
493
494default_hierarchy = get_option('default-hierarchy')
495conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
496 description : 'default cgroup hierarchy as string')
497if default_hierarchy == 'legacy'
37efbbd8 498 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
5c23128d 499elif default_hierarchy == 'hybrid'
37efbbd8 500 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
5c23128d 501else
37efbbd8 502 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
5c23128d
ZJS
503endif
504
505time_epoch = get_option('time-epoch')
506if time_epoch == ''
37efbbd8
ZJS
507 NEWS = files('NEWS')
508 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
5c23128d
ZJS
509endif
510time_epoch = time_epoch.to_int()
511conf.set('TIME_EPOCH', time_epoch)
512
513system_uid_max = get_option('system-uid-max')
514if system_uid_max == ''
37efbbd8
ZJS
515 system_uid_max = run_command(
516 awk,
517 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
518 '/etc/login.defs').stdout()
5c23128d
ZJS
519endif
520system_uid_max = system_uid_max.to_int()
521conf.set('SYSTEM_UID_MAX', system_uid_max)
522substs.set('systemuidmax', system_uid_max)
523message('Maximum system UID is @0@'.format(system_uid_max))
524
525conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
526conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
527
528system_gid_max = get_option('system-gid-max')
529if system_gid_max == ''
37efbbd8
ZJS
530 system_gid_max = run_command(
531 awk,
532 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
533 '/etc/login.defs').stdout()
5c23128d
ZJS
534endif
535system_gid_max = system_gid_max.to_int()
536conf.set('SYSTEM_GID_MAX', system_gid_max)
537substs.set('systemgidmax', system_gid_max)
538message('Maximum system GID is @0@'.format(system_gid_max))
539
540tty_gid = get_option('tty-gid')
541conf.set('TTY_GID', tty_gid)
2a4c156d 542substs.set('TTY_GID', tty_gid)
5c23128d
ZJS
543
544if get_option('adm-group')
37efbbd8 545 m4_defines += ['-DENABLE_ADM_GROUP']
5c23128d
ZJS
546endif
547
548if get_option('wheel-group')
37efbbd8 549 m4_defines += ['-DENABLE_WHEEL_GROUP']
5c23128d
ZJS
550endif
551
552substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
553
2a4c156d
ZJS
554kill_user_processes = get_option('default-kill-user-processes')
555conf.set10('KILL_USER_PROCESSES', kill_user_processes)
556substs.set('KILL_USER_PROCESSES', kill_user_processes ? 'yes' : 'no')
5c23128d
ZJS
557
558default_dnssec = get_option('default-dnssec')
559conf.set('DEFAULT_DNSSEC_MODE',
560 'DNSSEC_' + default_dnssec.underscorify().to_upper())
2a4c156d 561substs.set('DEFAULT_DNSSEC_MODE', default_dnssec)
5c23128d
ZJS
562
563conf.set_quoted('DNS_SERVERS', get_option('dns-servers'))
2a4c156d 564substs.set('DNS_SERVERS', get_option('dns-servers'))
5c23128d
ZJS
565
566conf.set_quoted('NTP_SERVERS', get_option('ntp-servers'))
2a4c156d 567substs.set('NTP_SERVERS', get_option('ntp-servers'))
5c23128d
ZJS
568
569conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
570
3131bfe3
ZJS
571substs.set('SUSHELL', get_option('debug-shell'))
572substs.set('DEBUGTTY', get_option('debug-tty'))
573
5c23128d
ZJS
574#####################################################################
575
576threads = dependency('threads')
577librt = cc.find_library('rt')
578libm = cc.find_library('m')
579libdl = cc.find_library('dl')
580libcrypt = cc.find_library('crypt')
581
582libcap = dependency('libcap')
583libmount = dependency('mount',
584 version : '>= 2.27')
585
586want_seccomp = get_option('seccomp')
4390be30 587if want_seccomp != 'false'
37efbbd8
ZJS
588 libseccomp = dependency('libseccomp',
589 required : want_seccomp == 'true')
590 if libseccomp.found()
591 conf.set('HAVE_SECCOMP', 1)
592 m4_defines += ['-DHAVE_SECCOMP']
593 endif
5c23128d 594else
37efbbd8 595 libseccomp = []
5c23128d
ZJS
596endif
597
598want_selinux = get_option('selinux')
4390be30 599if want_selinux != 'false'
37efbbd8
ZJS
600 libselinux = dependency('libselinux',
601 version : '>= 2.1.9',
602 required : want_selinux == 'true')
603 if libselinux.found()
604 conf.set('HAVE_SELINUX', 1)
605 m4_defines += ['-DHAVE_SELINUX']
606 endif
5c23128d 607else
37efbbd8 608 libselinux = []
5c23128d
ZJS
609endif
610
611want_apparmor = get_option('apparmor')
4390be30 612if want_apparmor != 'false'
37efbbd8
ZJS
613 libapparmor = dependency('libapparmor',
614 required : want_apparmor == 'true')
615 if libapparmor.found()
616 conf.set('HAVE_APPARMOR', 1)
617 m4_defines += ['-DHAVE_APPARMOR']
618 endif
5c23128d 619else
37efbbd8 620 libapparmor = []
5c23128d
ZJS
621endif
622
623want_smack = get_option('smack')
4390be30 624if want_smack != 'false'
37efbbd8
ZJS
625 libsmack = dependency('libsmack',
626 required : want_smack == 'true')
627 if libsmack.found()
628 conf.set('HAVE_SMACK', 1)
629 m4_defines += ['-DHAVE_SMACK']
630 endif
5c23128d 631else
37efbbd8 632 libsmack = []
5c23128d
ZJS
633endif
634
635smack_run_label = get_option('smack-run-label')
636if smack_run_label != ''
37efbbd8
ZJS
637 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
638 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
5c23128d
ZJS
639endif
640
3ca0cb73
ZJS
641want_polkit = get_option('polkit')
642install_polkit = false
643install_polkit_pkla = false
4390be30 644if want_polkit != 'false'
37efbbd8
ZJS
645 conf.set('ENABLE_POLKIT', 1)
646 install_polkit = true
3ca0cb73 647
37efbbd8
ZJS
648 libpolkit = dependency('polkit-gobject-1',
649 required : false)
650 if libpolkit.found() and libpolkit.version().version_compare('< 0.106')
651 message('Old polkit detected, will install pkla files')
652 install_polkit_pkla = true
653 endif
3ca0cb73
ZJS
654endif
655
5c23128d 656want_audit = get_option('audit')
4390be30 657if want_audit != 'false'
37efbbd8
ZJS
658 libaudit = dependency('audit', required : want_audit == 'true')
659 if libaudit.found()
660 conf.set('HAVE_AUDIT', 1)
661 endif
5c23128d 662else
37efbbd8 663 libaudit = []
5c23128d
ZJS
664endif
665
666want_blkid = get_option('blkid')
4390be30 667if want_blkid != 'false'
37efbbd8
ZJS
668 libblkid = dependency('blkid', required : want_blkid == 'true')
669 if libblkid.found()
670 conf.set('HAVE_BLKID', 1)
671 endif
5c23128d 672else
37efbbd8 673 libblkid = []
5c23128d
ZJS
674endif
675
676want_kmod = get_option('kmod')
4390be30 677if want_kmod != 'false'
37efbbd8
ZJS
678 libkmod = dependency('libkmod',
679 version : '>= 15',
680 required : want_kmod == 'true')
681 if libkmod.found()
682 conf.set('HAVE_KMOD', 1)
683 endif
5c23128d 684else
37efbbd8 685 libkmod = []
5c23128d
ZJS
686endif
687
688want_pam = get_option('pam')
4390be30 689if want_pam != 'false'
37efbbd8
ZJS
690 libpam = cc.find_library('pam', required : want_pam == 'true')
691 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
692 if libpam.found() and libpam_misc.found()
693 conf.set('HAVE_PAM', 1)
694 m4_defines += ['-DHAVE_PAM']
695 endif
5c23128d 696else
37efbbd8
ZJS
697 libpam = []
698 libpam_misc = []
5c23128d
ZJS
699endif
700
701want_microhttpd = get_option('microhttpd')
4390be30 702if want_microhttpd != 'false'
37efbbd8
ZJS
703 libmicrohttpd = dependency('libmicrohttpd',
704 version : '>= 0.9.33',
705 required : want_microhttpd == 'true')
706 if libmicrohttpd.found()
707 conf.set('HAVE_MICROHTTPD', 1)
708 m4_defines += ['-DHAVE_MICROHTTPD']
709 endif
5c23128d 710else
37efbbd8 711 libmicrohttpd = []
5c23128d
ZJS
712endif
713
714want_libcryptsetup = get_option('libcryptsetup')
4390be30 715if want_libcryptsetup != 'false'
37efbbd8
ZJS
716 libcryptsetup = dependency('libcryptsetup',
717 version : '>= 1.6.0',
718 required : want_libcryptsetup == 'true')
719 if libcryptsetup.found()
720 conf.set('HAVE_LIBCRYPTSETUP', 1)
721 endif
5c23128d 722else
37efbbd8 723 libcryptsetup = []
5c23128d
ZJS
724endif
725
726want_libcurl = get_option('libcurl')
4390be30 727if want_libcurl != 'false'
37efbbd8
ZJS
728 libcurl = dependency('libcurl',
729 version : '>= 7.32.0',
730 required : want_libcurl == 'true')
731 if libcurl.found()
732 conf.set('HAVE_LIBCURL', 1)
733 m4_defines += ['-DHAVE_LIBCURL']
734 endif
5c23128d 735else
37efbbd8 736 libcurl = []
5c23128d
ZJS
737endif
738
739want_libidn = get_option('libidn')
4390be30 740if want_libidn != 'false'
37efbbd8
ZJS
741 libidn = dependency('libidn',
742 required : want_libidn == 'true')
743 if libidn.found()
744 conf.set('HAVE_LIBIDN', 1)
745 m4_defines += ['-DHAVE_LIBIDN']
746 endif
5c23128d 747else
37efbbd8 748 libidn = []
5c23128d
ZJS
749endif
750
751want_libiptc = get_option('libiptc')
4390be30 752if want_libiptc != 'false'
37efbbd8
ZJS
753 libiptc = dependency('libiptc',
754 required : want_libiptc == 'true')
755 if libiptc.found()
756 conf.set('HAVE_LIBIPTC', 1)
757 m4_defines += ['-DHAVE_LIBIPTC']
758 endif
5c23128d 759else
37efbbd8 760 libiptc = []
5c23128d
ZJS
761endif
762
763want_qrencode = get_option('qrencode')
4390be30 764if want_qrencode != 'false'
37efbbd8
ZJS
765 libqrencode = dependency('libqrencode',
766 required : want_qrencode == 'true')
767 if libqrencode.found()
768 conf.set('HAVE_QRENCODE', 1)
769 endif
5c23128d 770else
37efbbd8 771 libqrencode = []
5c23128d
ZJS
772endif
773
774want_gnutls = get_option('gnutls')
4390be30 775if want_gnutls != 'false'
37efbbd8
ZJS
776 libgnutls = dependency('gnutls',
777 version : '>= 3.1.4',
778 required : want_gnutls == 'true')
779 if libgnutls.found()
780 conf.set('HAVE_GNUTLS', 1)
781 endif
5c23128d 782else
37efbbd8 783 libgnutls = []
5c23128d
ZJS
784endif
785
786want_elfutils = get_option('elfutils')
4390be30 787if want_elfutils != 'false'
37efbbd8
ZJS
788 libdw = dependency('libdw',
789 required : want_elfutils == 'true')
790 if libdw.found()
791 conf.set('HAVE_ELFUTILS', 1)
792 endif
5c23128d 793else
37efbbd8 794 libdw = []
5c23128d
ZJS
795endif
796
797want_zlib = get_option('zlib')
4390be30 798if want_zlib != 'false'
37efbbd8
ZJS
799 libz = dependency('zlib',
800 required : want_zlib == 'true')
801 if libz.found()
802 conf.set('HAVE_ZLIB', 1)
803 endif
5c23128d 804else
37efbbd8 805 libz = []
5c23128d
ZJS
806endif
807
808want_bzip2 = get_option('bzip2')
4390be30 809if want_bzip2 != 'false'
37efbbd8
ZJS
810 libbzip2 = cc.find_library('bz2',
811 required : want_bzip2 == 'true')
812 if libbzip2.found()
813 conf.set('HAVE_BZIP2', 1)
814 endif
5c23128d 815else
37efbbd8 816 libbzip2 = []
5c23128d
ZJS
817endif
818
819want_xz = get_option('xz')
4390be30 820if want_xz != 'false'
37efbbd8
ZJS
821 libxz = dependency('liblzma',
822 required : want_xz == 'true')
823 if libxz.found()
824 conf.set('HAVE_XZ', 1)
825 endif
5c23128d 826else
37efbbd8 827 libxz = []
5c23128d
ZJS
828endif
829
830want_lz4 = get_option('lz4')
4390be30 831if want_lz4 != 'false'
37efbbd8
ZJS
832 liblz4 = dependency('liblz4',
833 required : want_lz4 == 'true')
834 if liblz4.found()
835 conf.set('HAVE_LZ4', 1)
836 endif
5c23128d 837else
37efbbd8 838 liblz4 = []
5c23128d
ZJS
839endif
840
841libacl = cc.find_library('acl', required : false)
842if libacl.found()
37efbbd8
ZJS
843 conf.set('HAVE_ACL', 1)
844 m4_defines += ['-DHAVE_ACL']
5c23128d
ZJS
845endif
846
69e96427 847want_glib = get_option('glib')
4390be30 848if want_glib != 'false'
37efbbd8
ZJS
849 libglib = dependency('glib-2.0',
850 version : '>= 2.22.0',
851 required : want_glib == 'true')
852 libgobject = dependency('gobject-2.0',
853 version : '>= 2.22.0',
854 required : want_glib == 'true')
855 libgio = dependency('gio-2.0',
856 required : want_glib == 'true')
857 if libglib.found() and libgobject.found() and libgio.found()
858 conf.set('HAVE_GLIB', 1)
859 endif
69e96427 860else
37efbbd8
ZJS
861 libglib = []
862 libgobject = []
863 libgio = []
69e96427
ZJS
864endif
865
1eeb43f5 866want_xkbcommon = get_option('xkbcommon')
4390be30 867if want_xkbcommon != 'false'
37efbbd8
ZJS
868 libxkbcommon = dependency('xkbcommon',
869 version : '>= 0.3.0',
870 required : want_xkbcommon == 'true')
871 if libxkbcommon.found()
872 conf.set('HAVE_XKBCOMMON', 1)
873 endif
1eeb43f5 874else
37efbbd8 875 libxkbcommon = []
1eeb43f5
ZJS
876endif
877
69e96427 878want_dbus = get_option('dbus')
4390be30 879if want_dbus != 'false'
37efbbd8
ZJS
880 libdbus = dependency('dbus-1',
881 version : '>= 1.3.2',
882 required : want_dbus == 'true')
883 if libdbus.found()
884 conf.set('HAVE_DBUS', 1)
885 endif
69e96427 886else
37efbbd8 887 libdbus = []
69e96427
ZJS
888endif
889
5c23128d 890want_libgcrypt = get_option('libgcrypt')
4390be30 891if want_libgcrypt != 'false'
37efbbd8
ZJS
892 libgcrypt = cc.find_library('gcrypt', required : want_libgcrypt == 'true')
893 if libgcrypt.found()
894 conf.set('HAVE_LIBGCRYPT', 1)
895 endif
5c23128d 896else
37efbbd8 897 libgcrypt = []
5c23128d
ZJS
898endif
899
900want_importd = get_option('importd')
4390be30 901if want_importd != 'false'
37efbbd8
ZJS
902 have_deps = (conf.get('HAVE_LIBCURL', 0) == 1 and
903 conf.get('HAVE_ZLIB', 0) == 1 and
904 conf.get('HAVE_BZIP2', 0) == 1 and
905 conf.get('HAVE_XZ', 0) == 1 and
906 conf.get('HAVE_LIBGCRYPT', 0) == 1)
907 if have_deps
908 conf.set('ENABLE_IMPORTD', 1)
909 elif want_importd == 'true'
910 error('importd support was requested, but dependencies are not available')
911 endif
5c23128d
ZJS
912endif
913
914want_remote = get_option('remote')
4390be30 915if want_remote != 'false'
37efbbd8
ZJS
916 have_deps = [conf.get('HAVE_MICROHTTPD', 0) == 1,
917 conf.get('HAVE_LIBCURL', 0) == 1]
918 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
919 # it's possible to build one without the other. Complain only if
920 # support was explictly requested. The auxiliary files like sysusers
921 # config should be installed when any of the programs are built.
922 if want_remote == 'true' and not (have_deps[0] and have_deps[1])
923 error('remote support was requested, but dependencies are not available')
924 endif
925 if have_deps[0] or have_deps[1]
926 conf.set('ENABLE_REMOTE', 1)
927 endif
5c23128d
ZJS
928endif
929
930foreach pair : [['utmp', 'HAVE_UTMP'],
931 ['hibernate', 'ENABLE_HIBERNATE'],
932 ['environment-d', 'ENABLE_ENVIRONMENT_D'],
933 ['binfmt', 'ENABLE_BINFMT'],
934 ['coredump', 'ENABLE_COREDUMP'],
935 ['resolve', 'ENABLE_RESOLVED'],
936 ['logind', 'ENABLE_LOGIND'],
937 ['hostnamed', 'ENABLE_HOSTNAMED'],
938 ['localed', 'ENABLE_LOCALED'],
939 ['machined', 'ENABLE_MACHINED'],
940 ['networkd', 'ENABLE_NETWORKD'],
941 ['timedated', 'ENABLE_TIMEDATED'],
942 ['timesyncd', 'ENABLE_TIMESYNCD'],
943 ['myhostname', 'HAVE_MYHOSTNAME'],
944 ['firstboot', 'ENABLE_FIRSTBOOT'],
945 ['randomseed', 'ENABLE_RANDOMSEED'],
946 ['backlight', 'ENABLE_BACKLIGHT'],
947 ['vconsole', 'ENABLE_VCONSOLE'],
948 ['quotacheck', 'ENABLE_QUOTACHECK'],
949 ['sysusers', 'ENABLE_SYSUSERS'],
950 ['tmpfiles', 'ENABLE_TMPFILES'],
951 ['hwdb', 'ENABLE_HWDB'],
952 ['rfkill', 'ENABLE_RFKILL'],
953 ['ldconfig', 'ENABLE_LDCONFIG'],
b710072d 954 ['efi', 'ENABLE_EFI'],
2895c8ee 955 ['ima', 'HAVE_IMA'],
5c23128d
ZJS
956 ]
957
37efbbd8
ZJS
958 if get_option(pair[0])
959 conf.set(pair[1], 1)
960 m4_defines += ['-D' + pair[1]]
961 endif
5c23128d
ZJS
962endforeach
963
69e96427 964want_tests = get_option('tests')
572baca1 965install_tests = get_option('install-tests')
69e96427
ZJS
966tests = []
967
5c23128d
ZJS
968#####################################################################
969
970if get_option('efi')
37efbbd8 971 efi_arch = host_machine.cpu_family()
b710072d 972
37efbbd8
ZJS
973 if efi_arch == 'ia32'
974 EFI_MACHINE_TYPE_NAME = 'ia32'
975 elif efi_arch == 'x86_64'
976 EFI_MACHINE_TYPE_NAME = 'x64'
977 elif efi_arch == 'arm'
978 EFI_MACHINE_TYPE_NAME = 'arm'
979 elif efi_arch == 'aarch64'
980 EFI_MACHINE_TYPE_NAME = 'aa64'
981 else
982 EFI_MACHINE_TYPE_NAME = ''
983 endif
5c23128d 984
37efbbd8
ZJS
985 conf.set('ENABLE_EFI', 1)
986 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
5c23128d
ZJS
987endif
988
989#####################################################################
990
991config_h = configure_file(
37efbbd8
ZJS
992 output : 'config.h',
993 configuration : conf)
5c23128d
ZJS
994
995includes = include_directories('src/basic',
996 'src/shared',
997 'src/systemd',
998 'src/journal',
999 'src/resolve',
1000 'src/timesync',
1001 'src/login',
1002 'src/udev',
1003 'src/libudev',
1004 'src/core',
1005 'src/libsystemd/sd-bus',
1006 'src/libsystemd/sd-device',
1007 'src/libsystemd/sd-hwdb',
1008 'src/libsystemd/sd-id128',
1009 'src/libsystemd/sd-netlink',
1010 'src/libsystemd/sd-network',
1011 'src/libsystemd-network',
1012 )
1013
1014add_project_arguments('-include', 'config.h', language : 'c')
1015
1016gcrypt_util_sources = files('src/shared/gcrypt-util.h',
1017 'src/shared/gcrypt-util.c')
1018
1019subdir('po')
1020subdir('catalog')
1021subdir('src/systemd')
1022subdir('src/basic')
1023subdir('src/libsystemd')
1024subdir('src/libsystemd-network')
5c23128d 1025subdir('src/journal')
5c23128d 1026subdir('src/login')
5c23128d
ZJS
1027
1028libjournal_core = static_library(
37efbbd8
ZJS
1029 'journal-core',
1030 libjournal_core_sources,
1031 journald_gperf_c,
1032 include_directories : includes,
1033 install : false)
5c23128d 1034
37ab1a25 1035libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d 1036libsystemd = shared_library(
37efbbd8
ZJS
1037 'systemd',
1038 libsystemd_internal_sources,
1039 journal_internal_sources,
1040 version : '0.18.0',
1041 include_directories : includes,
1042 link_args : ['-shared',
1043 '-Wl,--version-script=' + libsystemd_sym_path],
1044 link_with : [libbasic],
1045 dependencies : [threads,
1046 librt,
1047 libxz,
1048 liblz4],
1049 link_depends : libsystemd_sym,
1050 install : true,
1051 install_dir : rootlibdir)
5c23128d
ZJS
1052
1053############################################################
1054
83b6af36
ZJS
1055# binaries that have --help and are intended for use by humans,
1056# usually, but not always, installed in /bin.
1057public_programs = []
1058
1059subdir('src/libudev')
1060subdir('src/shared')
1061subdir('src/core')
1062subdir('src/udev')
1063subdir('src/network')
1064
1065subdir('src/analyze')
1066subdir('src/journal-remote')
1067subdir('src/coredump')
1068subdir('src/hostname')
1069subdir('src/import')
1070subdir('src/kernel-install')
1071subdir('src/locale')
1072subdir('src/machine')
1073subdir('src/nspawn')
1074subdir('src/resolve')
1075subdir('src/timedate')
1076subdir('src/timesync')
1077subdir('src/vconsole')
1078subdir('src/sulogin-shell')
1079subdir('src/boot/efi')
1080
1081subdir('src/test')
1082subdir('test')
1083
1084############################################################
1085
1086# only static linking apart from libdl, to make sure that the
1087# module is linked to all libraries that it uses.
1088test_dlopen = executable(
37efbbd8
ZJS
1089 'test-dlopen',
1090 test_dlopen_c,
1091 include_directories : includes,
1092 link_with : [libbasic],
1093 dependencies : [libdl])
83b6af36 1094
5c23128d
ZJS
1095foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME', []],
1096 ['systemd', '', []],
1097 ['mymachines', 'ENABLE_MACHINED', []],
1098 ['resolve', 'ENABLE_RESOLVED', [libdl]]]
1099
37efbbd8
ZJS
1100 condition = tuple[1] == '' or conf.get(tuple[1], 0) == 1
1101 if condition
1102 module = tuple[0]
1103 extra_deps = tuple[2]
1104
1105 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1106 version_script_arg = join_paths(meson.current_source_dir(), sym)
1107
1108 nss = shared_library(
1109 'nss_' + module,
1110 'src/nss-@0@/nss-@0@.c'.format(module),
1111 version : '2',
1112 include_directories : includes,
1113 link_args : ['-shared',
1114 '-Wl,--version-script=' + version_script_arg,
1115 '-Wl,--undefined'],
1116 link_with : [libsystemd_internal,
1117 libbasic],
1118 dependencies : [threads,
1119 librt] + extra_deps,
1120 link_depends : sym,
1121 install : true,
1122 install_dir : rootlibdir)
1123
1124 # We cannot use shared_module because it does not support version suffix.
1125 # Unfortunately shared_library insists on creating the symlink…
1126 meson.add_install_script('sh', '-c',
1127 'rm $DESTDIR@0@/libnss_@1@.so'
1128 .format(rootlibdir, module))
1129
1130 test('dlopen-nss_' + module,
1131 test_dlopen,
1132 args : [nss.full_path()]) # path to dlopen must include a slash
1133 endif
5c23128d
ZJS
1134endforeach
1135
1136############################################################
1137
5c23128d
ZJS
1138executable('systemd',
1139 systemd_sources,
1140 include_directories : includes,
1141 link_with : [libcore,
826472ce 1142 libshared,
aac26058 1143 libudev],
5c23128d
ZJS
1144 dependencies : [threads,
1145 librt,
1146 libseccomp,
1147 libselinux,
f4ee10a2
ZJS
1148 libmount,
1149 libblkid],
421f0012 1150 install_rpath : rootlibexecdir,
5c23128d
ZJS
1151 install : true,
1152 install_dir : rootlibexecdir)
1153
005a29f2
ZJS
1154exe = executable('systemd-analyze',
1155 systemd_analyze_sources,
1156 include_directories : includes,
1157 link_with : [libcore,
1158 libudev,
005a29f2
ZJS
1159 libshared],
1160 dependencies : [threads,
1161 librt,
1162 libseccomp,
1163 libselinux,
1164 libmount,
1165 libblkid],
1166 install_rpath : rootlibexecdir,
1167 install : true)
1168public_programs += [exe]
5c23128d
ZJS
1169
1170executable('systemd-journald',
1171 systemd_journald_sources,
1172 include_directories : includes,
aac26058 1173 link_with : [libjournal_core,
5c23128d
ZJS
1174 libshared,
1175 libudev],
1176 dependencies : [threads,
1177 libxz,
aac26058
ZJS
1178 liblz4,
1179 libselinux],
421f0012 1180 install_rpath : rootlibexecdir,
5c23128d
ZJS
1181 install : true,
1182 install_dir : rootlibexecdir)
1183
005a29f2
ZJS
1184exe = executable('systemd-cat',
1185 systemd_cat_sources,
1186 include_directories : includes,
1187 link_with : [libjournal_core,
1188 libshared,
1189 libudev],
1190 dependencies : [threads],
1191 install_rpath : rootlibexecdir,
1192 install : true)
1193public_programs += [exe]
1194
1195exe = executable('journalctl',
1196 journalctl_sources,
1197 include_directories : includes,
aac26058
ZJS
1198 link_with : [libshared,
1199 libudev],
005a29f2
ZJS
1200 dependencies : [threads,
1201 libqrencode,
1202 libxz,
1203 liblz4],
1204 install_rpath : rootlibexecdir,
1205 install : true,
1206 install_dir : rootbindir)
1207public_programs += [exe]
5c23128d
ZJS
1208
1209executable('systemd-getty-generator',
1210 'src/getty-generator/getty-generator.c',
5c23128d 1211 include_directories : includes,
b2fc5836
ZJS
1212 link_with : [libshared],
1213 install_rpath : rootlibexecdir,
1214 install : true,
1215 install_dir : systemgeneratordir)
5c23128d
ZJS
1216
1217executable('systemd-debug-generator',
1218 'src/debug-generator/debug-generator.c',
5c23128d 1219 include_directories : includes,
b2fc5836
ZJS
1220 link_with : [libshared],
1221 install_rpath : rootlibexecdir,
1222 install : true,
1223 install_dir : systemgeneratordir)
5c23128d
ZJS
1224
1225executable('systemd-fstab-generator',
1226 'src/fstab-generator/fstab-generator.c',
1227 'src/core/mount-setup.c',
5c23128d 1228 include_directories : includes,
b2fc5836
ZJS
1229 link_with : [libshared],
1230 install_rpath : rootlibexecdir,
1231 install : true,
1232 install_dir : systemgeneratordir)
5c23128d
ZJS
1233
1234if conf.get('ENABLE_ENVIRONMENT_D', 0) == 1
37efbbd8
ZJS
1235 executable('30-systemd-environment-d-generator',
1236 'src/environment-d-generator/environment-d-generator.c',
1237 include_directories : includes,
1238 link_with : [libshared],
1239 install_rpath : rootlibexecdir,
1240 install : true,
1241 install_dir : userenvgeneratordir)
7b76fce1 1242
37efbbd8
ZJS
1243 meson.add_install_script(meson_make_symlink,
1244 join_paths(sysconfdir, 'environment'),
1245 join_paths(environmentdir, '99-environment.conf'))
5c23128d
ZJS
1246endif
1247
1248if conf.get('ENABLE_HIBERNATE', 0) == 1
37efbbd8
ZJS
1249 executable('systemd-hibernate-resume-generator',
1250 'src/hibernate-resume/hibernate-resume-generator.c',
1251 include_directories : includes,
1252 link_with : [libshared],
1253 install_rpath : rootlibexecdir,
1254 install : true,
1255 install_dir : systemgeneratordir)
5c23128d 1256
37efbbd8
ZJS
1257 executable('systemd-hibernate-resume',
1258 'src/hibernate-resume/hibernate-resume.c',
005a29f2
ZJS
1259 include_directories : includes,
1260 link_with : [libshared],
1261 install_rpath : rootlibexecdir,
1262 install : true,
1263 install_dir : rootlibexecdir)
37efbbd8
ZJS
1264endif
1265
1266if conf.get('HAVE_BLKID', 0) == 1
1267 executable('systemd-gpt-auto-generator',
1268 'src/gpt-auto-generator/gpt-auto-generator.c',
1269 'src/basic/blkid-util.h',
1270 include_directories : includes,
1271 link_with : [libshared,
1272 libudev],
1273 dependencies : libblkid,
1274 install_rpath : rootlibexecdir,
1275 install : true,
1276 install_dir : systemgeneratordir)
1277
1278 exe = executable('systemd-dissect',
1279 'src/dissect/dissect.c',
1280 include_directories : includes,
1281 link_with : [libshared],
1282 install_rpath : rootlibexecdir,
1283 install : true,
1284 install_dir : rootlibexecdir)
1285 public_programs += [exe]
5c23128d
ZJS
1286endif
1287
1288if conf.get('ENABLE_RESOLVED', 0) == 1
37efbbd8
ZJS
1289 executable('systemd-resolved',
1290 systemd_resolved_sources,
005a29f2 1291 include_directories : includes,
aac26058 1292 link_with : [libshared],
005a29f2
ZJS
1293 dependencies : [threads,
1294 libm,
1295 libidn],
1296 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1297 install : true,
1298 install_dir : rootlibexecdir)
1299
1300 exe = executable('systemd-resolve',
1301 systemd_resolve_sources,
1302 include_directories : includes,
1303 link_with : [libshared],
1304 dependencies : [threads,
1305 libm,
1306 libidn],
1307 install_rpath : rootlibexecdir,
1308 install : true)
1309 public_programs += [exe]
5c23128d
ZJS
1310endif
1311
1312if conf.get('ENABLE_LOGIND', 0) == 1
37efbbd8
ZJS
1313 executable('systemd-logind',
1314 systemd_logind_sources,
005a29f2 1315 include_directories : includes,
37efbbd8
ZJS
1316 link_with : [liblogind_core,
1317 libshared,
aac26058 1318 libudev],
005a29f2 1319 dependencies : [threads,
37efbbd8 1320 libacl],
005a29f2
ZJS
1321 install_rpath : rootlibexecdir,
1322 install : true,
37efbbd8
ZJS
1323 install_dir : rootlibexecdir)
1324
1325 exe = executable('loginctl',
1326 loginctl_sources,
1327 include_directories : includes,
1328 link_with : [libshared,
1329 libudev],
1330 dependencies : [threads,
1331 liblz4,
1332 libxz],
1333 install_rpath : rootlibexecdir,
1334 install : true,
1335 install_dir : rootbindir)
1336 public_programs += [exe]
1337
1338 exe = executable('systemd-inhibit',
1339 'src/login/inhibit.c',
1340 include_directories : includes,
1341 link_with : [libshared],
1342 install_rpath : rootlibexecdir,
1343 install : true,
1344 install_dir : rootbindir)
1345 public_programs += [exe]
1346
1347 if conf.get('HAVE_PAM', 0) == 1
1348 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1349 pam_systemd = shared_library(
1350 'pam_systemd',
1351 pam_systemd_c,
1352 name_prefix : '',
1353 include_directories : includes,
1354 link_args : ['-shared',
1355 '-Wl,--version-script=' + version_script_arg],
1356 link_with : [libsystemd_internal,
1357 libshared_static],
1358 dependencies : [threads,
1359 libpam,
1360 libpam_misc],
1361 link_depends : pam_systemd_sym,
1362 install : true,
1363 install_dir : pamlibdir)
1364
1365 test('dlopen-pam_systemd',
1366 test_dlopen,
1367 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1368 endif
1369endif
005a29f2 1370
37efbbd8
ZJS
1371if conf.get('HAVE_PAM', 0) == 1
1372 executable('systemd-user-sessions',
1373 'src/user-sessions/user-sessions.c',
005a29f2 1374 include_directories : includes,
aac26058 1375 link_with : [libshared],
005a29f2
ZJS
1376 install_rpath : rootlibexecdir,
1377 install : true,
37efbbd8 1378 install_dir : rootlibexecdir)
5c23128d
ZJS
1379endif
1380
8191c594 1381if conf.get('ENABLE_EFI', 0) == 1 and conf.get('HAVE_BLKID', 0) == 1
37efbbd8
ZJS
1382 exe = executable('bootctl',
1383 'src/boot/bootctl.c',
1384 include_directories : includes,
1385 link_with : [libshared],
1386 dependencies : [libblkid],
1387 install_rpath : rootlibexecdir,
1388 install : true)
1389 public_programs += [exe]
005a29f2
ZJS
1390endif
1391
1392exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1393 include_directories : includes,
1394 link_with : [libshared],
1395 dependencies : [threads],
1396 install_rpath : rootlibexecdir,
1397 install : true)
1398public_programs += [exe]
1399
1400exe = executable('systemctl', 'src/systemctl/systemctl.c',
1401 include_directories : includes,
aac26058 1402 link_with : [libshared],
005a29f2
ZJS
1403 dependencies : [threads,
1404 libcap,
1405 libselinux,
1406 libxz,
1407 liblz4],
1408 install_rpath : rootlibexecdir,
1409 install : true,
1410 install_dir : rootbindir)
1411public_programs += [exe]
5c23128d
ZJS
1412
1413if conf.get('ENABLE_BACKLIGHT', 0) == 1
37efbbd8
ZJS
1414 executable('systemd-backlight',
1415 'src/backlight/backlight.c',
1416 include_directories : includes,
1417 link_with : [libshared,
1418 libudev],
1419 install_rpath : rootlibexecdir,
1420 install : true,
1421 install_dir : rootlibexecdir)
5c23128d
ZJS
1422endif
1423
1424if conf.get('ENABLE_RFKILL', 0) == 1
37efbbd8
ZJS
1425 executable('systemd-rfkill',
1426 'src/rfkill/rfkill.c',
1427 include_directories : includes,
1428 link_with : [libshared,
1429 libudev],
1430 install_rpath : rootlibexecdir,
1431 install : true,
1432 install_dir : rootlibexecdir)
5c23128d
ZJS
1433endif
1434
1435executable('systemd-system-update-generator',
1436 'src/system-update-generator/system-update-generator.c',
1437 include_directories : includes,
1438 link_with : [libshared],
b2fc5836 1439 install_rpath : rootlibexecdir,
5c23128d
ZJS
1440 install : true,
1441 install_dir : systemgeneratordir)
1442
1443if conf.get('HAVE_LIBCRYPTSETUP', 0) == 1
37efbbd8
ZJS
1444 executable('systemd-cryptsetup',
1445 'src/cryptsetup/cryptsetup.c',
1446 include_directories : includes,
1447 link_with : [libshared],
1448 dependencies : [libcryptsetup],
1449 install_rpath : rootlibexecdir,
1450 install : true,
1451 install_dir : rootlibexecdir)
1452
1453 executable('systemd-cryptsetup-generator',
1454 'src/cryptsetup/cryptsetup-generator.c',
1455 include_directories : includes,
1456 link_with : [libshared],
1457 dependencies : [libcryptsetup],
1458 install_rpath : rootlibexecdir,
1459 install : true,
1460 install_dir : systemgeneratordir)
1461
1462 executable('systemd-veritysetup',
1463 'src/veritysetup/veritysetup.c',
1464 include_directories : includes,
1465 link_with : [libshared],
1466 dependencies : [libcryptsetup],
1467 install_rpath : rootlibexecdir,
1468 install : true,
1469 install_dir : rootlibexecdir)
1470
1471 executable('systemd-veritysetup-generator',
1472 'src/veritysetup/veritysetup-generator.c',
1473 include_directories : includes,
1474 link_with : [libshared],
1475 dependencies : [libcryptsetup],
1476 install_rpath : rootlibexecdir,
1477 install : true,
1478 install_dir : systemgeneratordir)
5c23128d
ZJS
1479endif
1480
1481if conf.get('HAVE_SYSV_COMPAT', 0) == 1
37efbbd8
ZJS
1482 executable('systemd-sysv-generator',
1483 'src/sysv-generator/sysv-generator.c',
1484 include_directories : includes,
1485 link_with : [libshared],
1486 install_rpath : rootlibexecdir,
1487 install : true,
1488 install_dir : systemgeneratordir)
1489
1490 executable('systemd-rc-local-generator',
1491 'src/rc-local-generator/rc-local-generator.c',
1492 include_directories : includes,
1493 link_with : [libshared],
1494 install_rpath : rootlibexecdir,
1495 install : true,
1496 install_dir : systemgeneratordir)
5c23128d
ZJS
1497endif
1498
1499if conf.get('ENABLE_HOSTNAMED', 0) == 1
37efbbd8
ZJS
1500 executable('systemd-hostnamed',
1501 'src/hostname/hostnamed.c',
005a29f2 1502 include_directories : includes,
aac26058 1503 link_with : [libshared],
005a29f2 1504 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1505 install : true,
1506 install_dir : rootlibexecdir)
1507
1508 exe = executable('hostnamectl',
1509 'src/hostname/hostnamectl.c',
1510 include_directories : includes,
1511 link_with : [libshared],
1512 install_rpath : rootlibexecdir,
1513 install : true)
1514 public_programs += [exe]
5c23128d
ZJS
1515endif
1516
1517if conf.get('ENABLE_LOCALED', 0) == 1
37efbbd8
ZJS
1518 if conf.get('HAVE_XKBCOMMON', 0) == 1
1519 # logind will load libxkbcommon.so dynamically on its own
1520 deps = [libdl]
1521 else
1522 deps = []
1523 endif
1524
1525 executable('systemd-localed',
1526 systemd_localed_sources,
005a29f2 1527 include_directories : includes,
aac26058 1528 link_with : [libshared],
37efbbd8 1529 dependencies : deps,
005a29f2 1530 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1531 install : true,
1532 install_dir : rootlibexecdir)
1533
1534 exe = executable('localectl',
1535 localectl_sources,
1536 include_directories : includes,
1537 link_with : [libshared],
1538 install_rpath : rootlibexecdir,
1539 install : true)
1540 public_programs += [exe]
5c23128d
ZJS
1541endif
1542
1543if conf.get('ENABLE_TIMEDATED', 0) == 1
37efbbd8
ZJS
1544 executable('systemd-timedated',
1545 'src/timedate/timedated.c',
005a29f2 1546 include_directories : includes,
aac26058 1547 link_with : [libshared],
37efbbd8
ZJS
1548 install_rpath : rootlibexecdir,
1549 install : true,
1550 install_dir : rootlibexecdir)
5c23128d 1551
37efbbd8
ZJS
1552 exe = executable('timedatectl',
1553 'src/timedate/timedatectl.c',
1554 include_directories : includes,
1555 install_rpath : rootlibexecdir,
1556 link_with : [libshared],
1557 install : true)
1558 public_programs += [exe]
5c23128d
ZJS
1559endif
1560
37efbbd8
ZJS
1561if conf.get('ENABLE_TIMESYNCD', 0) == 1
1562 executable('systemd-timesyncd',
1563 systemd_timesyncd_sources,
005a29f2 1564 include_directories : includes,
aac26058 1565 link_with : [libshared],
005a29f2 1566 dependencies : [threads,
37efbbd8 1567 libm],
005a29f2
ZJS
1568 install_rpath : rootlibexecdir,
1569 install : true,
37efbbd8 1570 install_dir : rootlibexecdir)
5c23128d
ZJS
1571endif
1572
37efbbd8
ZJS
1573if conf.get('ENABLE_MACHINED', 0) == 1
1574 executable('systemd-machined',
1575 systemd_machined_sources,
1576 include_directories : includes,
1577 link_with : [libmachine_core,
1578 libshared],
1579 install_rpath : rootlibexecdir,
1580 install : true,
1581 install_dir : rootlibexecdir)
1582
1583 exe = executable('machinectl',
1584 'src/machine/machinectl.c',
1585 include_directories : includes,
1586 link_with : [libshared],
1587 dependencies : [threads,
1588 libxz,
1589 liblz4],
1590 install_rpath : rootlibexecdir,
1591 install : true,
1592 install_dir : rootbindir)
1593 public_programs += [exe]
5c23128d
ZJS
1594endif
1595
37efbbd8
ZJS
1596if conf.get('ENABLE_IMPORTD', 0) == 1
1597 executable('systemd-importd',
1598 systemd_importd_sources,
005a29f2 1599 include_directories : includes,
aac26058 1600 link_with : [libshared],
37efbbd8 1601 dependencies : [threads],
005a29f2
ZJS
1602 install_rpath : rootlibexecdir,
1603 install : true,
1604 install_dir : rootlibexecdir)
37efbbd8
ZJS
1605
1606 systemd_pull = executable('systemd-pull',
1607 systemd_pull_sources,
1608 include_directories : includes,
1609 link_with : [libshared],
1610 dependencies : [libcurl,
1611 libz,
1612 libbzip2,
1613 libxz,
1614 libgcrypt],
1615 install_rpath : rootlibexecdir,
1616 install : true,
1617 install_dir : rootlibexecdir)
1618
1619 systemd_import = executable('systemd-import',
1620 systemd_import_sources,
1621 include_directories : includes,
1622 link_with : [libshared],
1623 dependencies : [libcurl,
1624 libz,
1625 libbzip2,
1626 libxz],
1627 install_rpath : rootlibexecdir,
1628 install : true,
1629 install_dir : rootlibexecdir)
1630
1631 systemd_export = executable('systemd-export',
1632 systemd_export_sources,
1633 include_directories : includes,
1634 link_with : [libshared],
1635 dependencies : [libcurl,
1636 libz,
1637 libbzip2,
1638 libxz],
1639 install_rpath : rootlibexecdir,
1640 install : true,
1641 install_dir : rootlibexecdir)
1642 public_programs += [systemd_pull, systemd_import, systemd_export]
1643endif
1644
1645if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_LIBCURL', 0) == 1
1646 exe = executable('systemd-journal-upload',
1647 systemd_journal_upload_sources,
1648 include_directories : includes,
1649 link_with : [libshared],
1650 dependencies : [threads,
1651 libcurl,
1652 libgnutls,
1653 libxz,
1654 liblz4],
1655 install_rpath : rootlibexecdir,
1656 install : true,
1657 install_dir : rootlibexecdir)
1658 public_programs += [exe]
5c23128d
ZJS
1659endif
1660
1661if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_MICROHTTPD', 0) == 1
37efbbd8
ZJS
1662 s_j_remote = executable('systemd-journal-remote',
1663 systemd_journal_remote_sources,
1664 include_directories : includes,
1665 link_with : [libshared],
1666 dependencies : [threads,
1667 libmicrohttpd,
1668 libgnutls,
1669 libxz,
1670 liblz4],
1671 install_rpath : rootlibexecdir,
1672 install : true,
1673 install_dir : rootlibexecdir)
1674
1675 s_j_gatewayd = executable('systemd-journal-gatewayd',
1676 systemd_journal_gatewayd_sources,
1677 include_directories : includes,
1678 link_with : [libshared],
1679 dependencies : [threads,
1680 libmicrohttpd,
1681 libgnutls,
1682 libxz,
1683 liblz4],
1684 install_rpath : rootlibexecdir,
1685 install : true,
1686 install_dir : rootlibexecdir)
1687 public_programs += [s_j_remote, s_j_gatewayd]
5c23128d
ZJS
1688endif
1689
1690if conf.get('ENABLE_COREDUMP', 0) == 1
37efbbd8
ZJS
1691 executable('systemd-coredump',
1692 systemd_coredump_sources,
005a29f2 1693 include_directories : includes,
aac26058 1694 link_with : [libshared],
005a29f2 1695 dependencies : [threads,
37efbbd8
ZJS
1696 libacl,
1697 libdw,
005a29f2
ZJS
1698 libxz,
1699 liblz4],
1700 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1701 install : true,
1702 install_dir : rootlibexecdir)
1703
1704 exe = executable('coredumpctl',
1705 coredumpctl_sources,
1706 include_directories : includes,
1707 link_with : [libshared],
1708 dependencies : [threads,
1709 libxz,
1710 liblz4],
1711 install_rpath : rootlibexecdir,
1712 install : true)
1713 public_programs += [exe]
5c23128d
ZJS
1714endif
1715
1716if conf.get('ENABLE_BINFMT', 0) == 1
37efbbd8
ZJS
1717 exe = executable('systemd-binfmt',
1718 'src/binfmt/binfmt.c',
1719 include_directories : includes,
1720 link_with : [libshared],
1721 install_rpath : rootlibexecdir,
1722 install : true,
1723 install_dir : rootlibexecdir)
1724 public_programs += [exe]
1725
1726 meson.add_install_script('sh', '-c',
1727 mkdir_p.format(binfmtdir))
1728 meson.add_install_script('sh', '-c',
1729 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
1730endif
1731
1732if conf.get('ENABLE_VCONSOLE', 0) == 1
1733 executable('systemd-vconsole-setup',
1734 'src/vconsole/vconsole-setup.c',
005a29f2
ZJS
1735 include_directories : includes,
1736 link_with : [libshared],
1737 install_rpath : rootlibexecdir,
1738 install : true,
1739 install_dir : rootlibexecdir)
5c23128d
ZJS
1740endif
1741
1742if conf.get('ENABLE_RANDOMSEED', 0) == 1
37efbbd8
ZJS
1743 executable('systemd-random-seed',
1744 'src/random-seed/random-seed.c',
1745 include_directories : includes,
1746 link_with : [libshared],
1747 install_rpath : rootlibexecdir,
1748 install : true,
1749 install_dir : rootlibexecdir)
5c23128d
ZJS
1750endif
1751
1752if conf.get('ENABLE_FIRSTBOOT', 0) == 1
37efbbd8
ZJS
1753 executable('systemd-firstboot',
1754 'src/firstboot/firstboot.c',
1755 include_directories : includes,
1756 link_with : [libshared],
1757 dependencies : [libcrypt],
1758 install_rpath : rootlibexecdir,
1759 install : true,
1760 install_dir : rootbindir)
5c23128d
ZJS
1761endif
1762
1763executable('systemd-remount-fs',
1764 'src/remount-fs/remount-fs.c',
1765 'src/core/mount-setup.c',
1766 'src/core/mount-setup.h',
1767 include_directories : includes,
1768 link_with : [libshared],
b2fc5836 1769 install_rpath : rootlibexecdir,
5c23128d
ZJS
1770 install : true,
1771 install_dir : rootlibexecdir)
1772
1773executable('systemd-machine-id-setup',
1774 'src/machine-id-setup/machine-id-setup-main.c',
1775 'src/core/machine-id-setup.c',
1776 'src/core/machine-id-setup.h',
1777 include_directories : includes,
aac26058 1778 link_with : [libshared],
b2fc5836 1779 install_rpath : rootlibexecdir,
5c23128d
ZJS
1780 install : true,
1781 install_dir : rootbindir)
1782
1783executable('systemd-fsck',
1784 'src/fsck/fsck.c',
1785 include_directories : includes,
aac26058 1786 link_with : [libshared],
421f0012 1787 install_rpath : rootlibexecdir,
5c23128d
ZJS
1788 install : true,
1789 install_dir : rootlibexecdir)
1790
1791executable('systemd-sleep',
1792 'src/sleep/sleep.c',
1793 include_directories : includes,
1794 link_with : [libshared],
421f0012 1795 install_rpath : rootlibexecdir,
5c23128d
ZJS
1796 install : true,
1797 install_dir : rootlibexecdir)
1798
005a29f2
ZJS
1799exe = executable('systemd-sysctl',
1800 'src/sysctl/sysctl.c',
1801 include_directories : includes,
1802 link_with : [libshared],
1803 install_rpath : rootlibexecdir,
1804 install : true,
1805 install_dir : rootlibexecdir)
1806public_programs += [exe]
5c23128d
ZJS
1807
1808executable('systemd-ac-power',
1809 'src/ac-power/ac-power.c',
1810 include_directories : includes,
1811 link_with : [libshared],
421f0012 1812 install_rpath : rootlibexecdir,
5c23128d
ZJS
1813 install : true,
1814 install_dir : rootlibexecdir)
1815
005a29f2
ZJS
1816exe = executable('systemd-detect-virt',
1817 'src/detect-virt/detect-virt.c',
1818 include_directories : includes,
1819 link_with : [libshared],
1820 install_rpath : rootlibexecdir,
1821 install : true)
1822public_programs += [exe]
1823
1824exe = executable('systemd-delta',
1825 'src/delta/delta.c',
1826 include_directories : includes,
1827 link_with : [libshared],
1828 install_rpath : rootlibexecdir,
1829 install : true)
1830public_programs += [exe]
1831
1832exe = executable('systemd-escape',
1833 'src/escape/escape.c',
1834 include_directories : includes,
1835 link_with : [libshared],
1836 install_rpath : rootlibexecdir,
1837 install : true,
1838 install_dir : rootbindir)
1839public_programs += [exe]
1840
1841exe = executable('systemd-notify',
1842 'src/notify/notify.c',
1843 include_directories : includes,
1844 link_with : [libshared],
1845 install_rpath : rootlibexecdir,
1846 install : true,
1847 install_dir : rootbindir)
1848public_programs += [exe]
5c23128d
ZJS
1849
1850executable('systemd-volatile-root',
1851 'src/volatile-root/volatile-root.c',
1852 include_directories : includes,
1853 link_with : [libshared],
421f0012 1854 install_rpath : rootlibexecdir,
5c23128d
ZJS
1855 install : true,
1856 install_dir : rootlibexecdir)
1857
1858executable('systemd-cgroups-agent',
1859 'src/cgroups-agent/cgroups-agent.c',
1860 include_directories : includes,
1861 link_with : [libshared],
421f0012 1862 install_rpath : rootlibexecdir,
5c23128d
ZJS
1863 install : true,
1864 install_dir : rootlibexecdir)
1865
005a29f2
ZJS
1866exe = executable('systemd-path',
1867 'src/path/path.c',
1868 include_directories : includes,
aac26058 1869 link_with : [libshared],
005a29f2
ZJS
1870 install_rpath : rootlibexecdir,
1871 install : true)
1872public_programs += [exe]
1873
1874exe = executable('systemd-ask-password',
1875 'src/ask-password/ask-password.c',
1876 include_directories : includes,
aac26058 1877 link_with : [libshared],
005a29f2
ZJS
1878 install_rpath : rootlibexecdir,
1879 install : true,
1880 install_dir : rootbindir)
1881public_programs += [exe]
5c23128d
ZJS
1882
1883executable('systemd-reply-password',
1884 'src/reply-password/reply-password.c',
1885 include_directories : includes,
aac26058 1886 link_with : [libshared],
421f0012 1887 install_rpath : rootlibexecdir,
5c23128d
ZJS
1888 install : true,
1889 install_dir : rootlibexecdir)
1890
005a29f2
ZJS
1891exe = executable('systemd-tty-ask-password-agent',
1892 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1893 include_directories : includes,
aac26058 1894 link_with : [libshared],
005a29f2
ZJS
1895 install_rpath : rootlibexecdir,
1896 install : true,
1897 install_dir : rootbindir)
1898public_programs += [exe]
1899
1900exe = executable('systemd-cgls',
1901 'src/cgls/cgls.c',
1902 include_directories : includes,
aac26058 1903 link_with : [libshared],
005a29f2
ZJS
1904 install_rpath : rootlibexecdir,
1905 install : true)
1906public_programs += [exe]
1907
1908exe = executable('systemd-cgtop',
1909 'src/cgtop/cgtop.c',
1910 include_directories : includes,
aac26058 1911 link_with : [libshared],
005a29f2
ZJS
1912 install_rpath : rootlibexecdir,
1913 install : true)
1914public_programs += [exe]
5c23128d
ZJS
1915
1916executable('systemd-initctl',
1917 'src/initctl/initctl.c',
1918 include_directories : includes,
aac26058 1919 link_with : [libshared],
421f0012 1920 install_rpath : rootlibexecdir,
5c23128d
ZJS
1921 install : true,
1922 install_dir : rootlibexecdir)
1923
005a29f2
ZJS
1924exe = executable('systemd-mount',
1925 'src/mount/mount-tool.c',
1926 include_directories : includes,
1927 link_with : [libshared,
005a29f2
ZJS
1928 libudev],
1929 install_rpath : rootlibexecdir,
1930 install : true)
1931public_programs += [exe]
5c23128d 1932
7b76fce1 1933meson.add_install_script(meson_make_symlink,
e17e5ba9 1934 'systemd-mount', join_paths(bindir, 'systemd-umount'))
7b76fce1 1935
005a29f2
ZJS
1936exe = executable('systemd-run',
1937 'src/run/run.c',
1938 include_directories : includes,
aac26058 1939 link_with : [libshared],
005a29f2
ZJS
1940 install_rpath : rootlibexecdir,
1941 install : true)
1942public_programs += [exe]
1943
1944exe = executable('systemd-stdio-bridge',
1945 'src/stdio-bridge/stdio-bridge.c',
1946 include_directories : includes,
aac26058 1947 link_with : [libshared],
005a29f2
ZJS
1948 install_rpath : rootlibexecdir,
1949 install : true)
1950public_programs += [exe]
1951
1952exe = executable('busctl',
1953 'src/busctl/busctl.c',
1954 'src/busctl/busctl-introspect.c',
1955 'src/busctl/busctl-introspect.h',
1956 include_directories : includes,
aac26058 1957 link_with : [libshared],
005a29f2
ZJS
1958 install_rpath : rootlibexecdir,
1959 install : true)
1960public_programs += [exe]
5c23128d
ZJS
1961
1962if conf.get('ENABLE_SYSUSERS', 0) == 1
37efbbd8
ZJS
1963 exe = executable('systemd-sysusers',
1964 'src/sysusers/sysusers.c',
1965 include_directories : includes,
1966 link_with : [libshared],
1967 install_rpath : rootlibexecdir,
1968 install : true,
1969 install_dir : rootbindir)
1970 public_programs += [exe]
5c23128d
ZJS
1971endif
1972
1973if conf.get('ENABLE_TMPFILES', 0) == 1
37efbbd8
ZJS
1974 exe = executable('systemd-tmpfiles',
1975 'src/tmpfiles/tmpfiles.c',
1976 include_directories : includes,
1977 link_with : [libshared],
1978 dependencies : [libacl],
1979 install_rpath : rootlibexecdir,
1980 install : true,
1981 install_dir : rootbindir)
1982 public_programs += [exe]
5c23128d
ZJS
1983endif
1984
1985if conf.get('ENABLE_HWDB', 0) == 1
37efbbd8
ZJS
1986 exe = executable('systemd-hwdb',
1987 'src/hwdb/hwdb.c',
1988 'src/libsystemd/sd-hwdb/hwdb-internal.h',
1989 include_directories : includes,
1990 link_with : [libshared],
1991 install_rpath : rootlibexecdir,
1992 install : true,
1993 install_dir : rootbindir)
1994 public_programs += [exe]
1995endif
1996
1997if conf.get('ENABLE_QUOTACHECK', 0) == 1
1998 executable('systemd-quotacheck',
1999 'src/quotacheck/quotacheck.c',
005a29f2 2000 include_directories : includes,
aac26058 2001 link_with : [libshared],
005a29f2
ZJS
2002 install_rpath : rootlibexecdir,
2003 install : true,
37efbbd8 2004 install_dir : rootlibexecdir)
5c23128d
ZJS
2005endif
2006
005a29f2
ZJS
2007exe = executable('systemd-socket-proxyd',
2008 'src/socket-proxy/socket-proxyd.c',
2009 include_directories : includes,
aac26058 2010 link_with : [libshared],
005a29f2
ZJS
2011 dependencies : [threads],
2012 install_rpath : rootlibexecdir,
2013 install : true,
2014 install_dir : rootlibexecdir)
2015public_programs += [exe]
2016
2017exe = executable('systemd-udevd',
2018 systemd_udevd_sources,
2019 include_directories : includes,
2020 link_with : [libudev_core,
005a29f2 2021 libsystemd_network,
1aec3ed9 2022 libudev_internal],
3a30f21f
ZJS
2023 dependencies : [threads,
2024 libkmod,
005a29f2 2025 libidn,
aac26058
ZJS
2026 libacl,
2027 libblkid],
1aec3ed9 2028 install_rpath : udev_rpath,
005a29f2
ZJS
2029 install : true,
2030 install_dir : rootlibexecdir)
2031public_programs += [exe]
2032
2033exe = executable('udevadm',
2034 udevadm_sources,
2035 include_directories : includes,
2036 link_with : [libudev_core,
005a29f2 2037 libsystemd_network,
1aec3ed9 2038 libudev_internal],
3a30f21f
ZJS
2039 dependencies : [threads,
2040 libkmod,
005a29f2 2041 libidn,
aac26058
ZJS
2042 libacl,
2043 libblkid],
1aec3ed9 2044 install_rpath : udev_rpath,
005a29f2
ZJS
2045 install : true,
2046 install_dir : rootbindir)
2047public_programs += [exe]
5c23128d
ZJS
2048
2049executable('systemd-shutdown',
2050 systemd_shutdown_sources,
2051 include_directories : includes,
826472ce
ZJS
2052 link_with : [libshared,
2053 libudev],
421f0012 2054 install_rpath : rootlibexecdir,
5c23128d
ZJS
2055 install : true,
2056 install_dir : rootlibexecdir)
2057
2058executable('systemd-update-done',
2059 'src/update-done/update-done.c',
2060 include_directories : includes,
2061 link_with : [libshared],
421f0012 2062 install_rpath : rootlibexecdir,
5c23128d
ZJS
2063 install : true,
2064 install_dir : rootlibexecdir)
2065
2066executable('systemd-update-utmp',
2067 'src/update-utmp/update-utmp.c',
2068 include_directories : includes,
aac26058 2069 link_with : [libshared],
5c23128d 2070 dependencies : [libaudit],
421f0012 2071 install_rpath : rootlibexecdir,
5c23128d
ZJS
2072 install : true,
2073 install_dir : rootlibexecdir)
2074
2075if conf.get('HAVE_KMOD', 0) == 1
37efbbd8
ZJS
2076 executable('systemd-modules-load',
2077 'src/modules-load/modules-load.c',
2078 include_directories : includes,
2079 link_with : [libshared],
2080 dependencies : [libkmod],
2081 install_rpath : rootlibexecdir,
2082 install : true,
2083 install_dir : rootlibexecdir)
94e75a54 2084
37efbbd8
ZJS
2085 meson.add_install_script('sh', '-c',
2086 mkdir_p.format(modulesloaddir))
2087 meson.add_install_script('sh', '-c',
2088 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
5c23128d
ZJS
2089endif
2090
005a29f2
ZJS
2091exe = executable('systemd-nspawn',
2092 systemd_nspawn_sources,
2093 'src/core/mount-setup.c', # FIXME: use a variable?
2094 'src/core/mount-setup.h',
2095 'src/core/loopback-setup.c',
2096 'src/core/loopback-setup.h',
2097 include_directories : [includes, include_directories('src/nspawn')],
2098 link_with : [libfirewall,
2099 libshared,
aac26058 2100 libudev],
005a29f2
ZJS
2101 dependencies : [libacl,
2102 libblkid,
2103 libseccomp,
2104 libselinux],
2105 install_rpath : rootlibexecdir,
2106 install : true)
2107public_programs += [exe]
5c23128d 2108
f0bd7cc7 2109if conf.get('ENABLE_NETWORKD', 0) == 1
37efbbd8
ZJS
2110 executable('systemd-networkd',
2111 systemd_networkd_sources,
2112 include_directories : includes,
2113 link_with : [libnetworkd_core,
2114 libfirewall,
2115 libsystemd_network,
2116 libudev_internal,
2117 libshared],
2118 install_rpath : rootlibexecdir,
2119 install : true,
2120 install_dir : rootlibexecdir)
2121
2122 executable('systemd-networkd-wait-online',
2123 systemd_networkd_wait_online_sources,
2124 include_directories : includes,
2125 link_with : [libnetworkd_core,
2126 libshared],
2127 install_rpath : rootlibexecdir,
2128 install : true,
2129 install_dir : rootlibexecdir)
f0bd7cc7 2130endif
5c23128d 2131
005a29f2
ZJS
2132exe = executable('networkctl',
2133 networkctl_sources,
2134 include_directories : includes,
2135 link_with : [libsystemd_network,
aac26058 2136 libshared],
005a29f2
ZJS
2137 install_rpath : rootlibexecdir,
2138 install : true,
2139 install_dir : rootbindir)
2140public_programs += [exe]
5c23128d 2141
69e96427
ZJS
2142############################################################
2143
2144foreach tuple : tests
37efbbd8
ZJS
2145 sources = tuple[0]
2146 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2147 dependencies = tuple[2]
2148 condition = tuple.length() >= 4 ? tuple[3] : ''
2149 type = tuple.length() >= 5 ? tuple[4] : ''
2150 defs = tuple.length() >= 6 ? tuple[5] : []
2151 incs = tuple.length() >= 7 ? tuple[6] : includes
2152 timeout = 30
2153
2154 name = sources[0].split('/')[-1].split('.')[0]
2155 if type.startswith('timeout=')
2156 timeout = type.split('=')[1].to_int()
2157 type = ''
2158 endif
2159
2160 if condition == '' or conf.get(condition, 0) == 1
2161 install = install_tests and type == ''
2162
2163 exe = executable(
2164 name,
2165 sources,
2166 include_directories : incs,
2167 link_with : link_with,
2168 dependencies : dependencies,
2169 c_args : defs,
2170 install_rpath : rootlibexecdir,
2171 install : install,
2172 install_dir : testsdir)
2173
2174 if type == 'manual'
2175 message('@0@ is a manual test'.format(name))
2176 elif type == 'unsafe' and want_tests != 'unsafe'
2177 message('@0@ is an unsafe test'.format(name))
2178 else
2179 test(name, exe,
2180 env : test_env,
2181 timeout : timeout)
2182 endif
2183 else
2184 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2185 endif
69e96427
ZJS
2186endforeach
2187
37ab1a25 2188test_libsystemd_sym = executable(
37efbbd8
ZJS
2189 'test-libsystemd-sym',
2190 test_libsystemd_sym_c,
2191 include_directories : includes,
2192 link_with : [libsystemd],
2193 install : install_tests,
2194 install_dir : testsdir)
37ab1a25
ZJS
2195test('test-libsystemd-sym',
2196 test_libsystemd_sym)
2197
e0bec52f 2198test_libudev_sym = executable(
37efbbd8
ZJS
2199 'test-libudev-sym',
2200 test_libudev_sym_c,
2201 include_directories : includes,
2202 c_args : ['-Wno-deprecated-declarations'],
2203 link_with : [libudev],
2204 install : install_tests,
2205 install_dir : testsdir)
e0bec52f
ZJS
2206test('test-libudev-sym',
2207 test_libudev_sym)
2208
69e96427 2209############################################################
5c23128d
ZJS
2210
2211make_directive_index_py = find_program('tools/make-directive-index.py')
2212make_man_index_py = find_program('tools/make-man-index.py')
b184e8fe 2213xml_helper_py = find_program('tools/xml_helper.py')
abba22c5 2214hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
5c23128d
ZJS
2215
2216subdir('units')
2217subdir('sysctl.d')
2218subdir('sysusers.d')
2219subdir('tmpfiles.d')
2220subdir('rules')
2221subdir('hwdb')
2222subdir('network')
2223subdir('man')
2224subdir('shell-completion/bash')
2225subdir('shell-completion/zsh')
2226subdir('docs/sysvinit')
2227subdir('docs/var-log')
2228
2229# FIXME: figure out if the warning is true:
2230# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
2231install_subdir('factory/etc',
2232 install_dir : factorydir)
2233
2234
2235install_data('xorg/50-systemd-user.sh',
2236 install_dir : xinitrcdir)
2237install_data('system-preset/90-systemd.preset',
2238 install_dir : systempresetdir)
2239install_data('README',
2240 'NEWS',
2241 'CODING_STYLE',
2242 'DISTRO_PORTING',
2243 'ENVIRONMENT.md',
2244 'LICENSE.GPL2',
2245 'LICENSE.LGPL2.1',
2246 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
2247 install_dir : docdir)
d68b342b 2248
94e75a54
ZJS
2249meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
2250meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
2251
d68b342b
ZJS
2252############################################################
2253
005a29f2
ZJS
2254meson_check_help = find_program('tools/meson-check-help.sh')
2255
2256foreach exec : public_programs
37efbbd8
ZJS
2257 name = exec.full_path().split('/')[-1]
2258 test('check-help-' + name,
2259 meson_check_help,
2260 args : [exec.full_path()])
005a29f2
ZJS
2261endforeach
2262
2263############################################################
2264
d68b342b 2265if git.found() and etags.found()
37efbbd8
ZJS
2266 all_files = run_command(
2267 git,
2268 ['--git-dir=@0@/.git'.format(meson.source_root()),
2269 'ls-files',
2270 ':/*.[ch]'])
2271 all_files = files(all_files.stdout().split())
d68b342b 2272
37efbbd8
ZJS
2273 custom_target(
2274 'TAGS',
2275 output : 'TAGS',
2276 input : all_files,
2277 command : [etags, '-o', '@OUTPUT@'] + all_files)
d68b342b 2278endif
177929c2
ZJS
2279
2280if git.found()
37efbbd8 2281 meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
a923e085 2282 run_target(
37efbbd8 2283 'git-contrib',
37efbbd8 2284 command : [meson_git_contrib_sh])
177929c2 2285endif