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