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