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