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