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