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