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