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