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