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