]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
rule-test-syntax: modernize syntax and add debug message
[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')
1221subdir('test')
1222
1223############################################################
1224
1225# only static linking apart from libdl, to make sure that the
1226# module is linked to all libraries that it uses.
1227test_dlopen = executable(
37efbbd8
ZJS
1228 'test-dlopen',
1229 test_dlopen_c,
1230 include_directories : includes,
1231 link_with : [libbasic],
1232 dependencies : [libdl])
83b6af36 1233
08cf5b8d 1234foreach tuple : [['myhostname', 'ENABLE_MYHOSTNAME'],
e7e11bbf 1235 ['systemd', 'ENABLE_NSS_SYSTEMD'],
5486a31d 1236 ['mymachines', 'ENABLE_MACHINED'],
1ec57f33 1237 ['resolve', 'ENABLE_RESOLVE']]
5c23128d 1238
349cc4a5 1239 condition = tuple[1] == '' or conf.get(tuple[1]) == 1
37efbbd8
ZJS
1240 if condition
1241 module = tuple[0]
37efbbd8
ZJS
1242
1243 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
1244 version_script_arg = join_paths(meson.current_source_dir(), sym)
1245
1246 nss = shared_library(
1247 'nss_' + module,
1248 'src/nss-@0@/nss-@0@.c'.format(module),
1249 version : '2',
1250 include_directories : includes,
1251 link_args : ['-shared',
1252 '-Wl,--version-script=' + version_script_arg,
1253 '-Wl,--undefined'],
1254 link_with : [libsystemd_internal,
1255 libbasic],
1256 dependencies : [threads,
5486a31d 1257 librt],
37efbbd8
ZJS
1258 link_depends : sym,
1259 install : true,
1260 install_dir : rootlibdir)
1261
1262 # We cannot use shared_module because it does not support version suffix.
1263 # Unfortunately shared_library insists on creating the symlink…
1264 meson.add_install_script('sh', '-c',
1265 'rm $DESTDIR@0@/libnss_@1@.so'
1266 .format(rootlibdir, module))
1267
1268 test('dlopen-nss_' + module,
1269 test_dlopen,
1270 args : [nss.full_path()]) # path to dlopen must include a slash
1271 endif
5c23128d
ZJS
1272endforeach
1273
1274############################################################
1275
5c23128d
ZJS
1276executable('systemd',
1277 systemd_sources,
1278 include_directories : includes,
1279 link_with : [libcore,
34ce0a52 1280 libshared],
5c23128d
ZJS
1281 dependencies : [threads,
1282 librt,
1283 libseccomp,
1284 libselinux,
f4ee10a2
ZJS
1285 libmount,
1286 libblkid],
421f0012 1287 install_rpath : rootlibexecdir,
5c23128d
ZJS
1288 install : true,
1289 install_dir : rootlibexecdir)
1290
005a29f2
ZJS
1291exe = executable('systemd-analyze',
1292 systemd_analyze_sources,
1293 include_directories : includes,
1294 link_with : [libcore,
005a29f2
ZJS
1295 libshared],
1296 dependencies : [threads,
1297 librt,
1298 libseccomp,
1299 libselinux,
1300 libmount,
1301 libblkid],
1302 install_rpath : rootlibexecdir,
1303 install : true)
1304public_programs += [exe]
5c23128d
ZJS
1305
1306executable('systemd-journald',
1307 systemd_journald_sources,
1308 include_directories : includes,
aac26058 1309 link_with : [libjournal_core,
34ce0a52 1310 libshared],
5c23128d
ZJS
1311 dependencies : [threads,
1312 libxz,
aac26058
ZJS
1313 liblz4,
1314 libselinux],
421f0012 1315 install_rpath : rootlibexecdir,
5c23128d
ZJS
1316 install : true,
1317 install_dir : rootlibexecdir)
1318
005a29f2
ZJS
1319exe = executable('systemd-cat',
1320 systemd_cat_sources,
1321 include_directories : includes,
1322 link_with : [libjournal_core,
34ce0a52 1323 libshared],
005a29f2
ZJS
1324 dependencies : [threads],
1325 install_rpath : rootlibexecdir,
1326 install : true)
1327public_programs += [exe]
1328
1329exe = executable('journalctl',
1330 journalctl_sources,
1331 include_directories : includes,
34ce0a52 1332 link_with : [libshared],
005a29f2
ZJS
1333 dependencies : [threads,
1334 libqrencode,
1335 libxz,
1336 liblz4],
1337 install_rpath : rootlibexecdir,
1338 install : true,
1339 install_dir : rootbindir)
1340public_programs += [exe]
5c23128d
ZJS
1341
1342executable('systemd-getty-generator',
1343 'src/getty-generator/getty-generator.c',
5c23128d 1344 include_directories : includes,
b2fc5836
ZJS
1345 link_with : [libshared],
1346 install_rpath : rootlibexecdir,
1347 install : true,
1348 install_dir : systemgeneratordir)
5c23128d
ZJS
1349
1350executable('systemd-debug-generator',
1351 'src/debug-generator/debug-generator.c',
5c23128d 1352 include_directories : includes,
b2fc5836
ZJS
1353 link_with : [libshared],
1354 install_rpath : rootlibexecdir,
1355 install : true,
1356 install_dir : systemgeneratordir)
5c23128d
ZJS
1357
1358executable('systemd-fstab-generator',
1359 'src/fstab-generator/fstab-generator.c',
1360 'src/core/mount-setup.c',
5c23128d 1361 include_directories : includes,
b2fc5836
ZJS
1362 link_with : [libshared],
1363 install_rpath : rootlibexecdir,
1364 install : true,
1365 install_dir : systemgeneratordir)
5c23128d 1366
349cc4a5 1367if conf.get('ENABLE_ENVIRONMENT_D') == 1
37efbbd8
ZJS
1368 executable('30-systemd-environment-d-generator',
1369 'src/environment-d-generator/environment-d-generator.c',
1370 include_directories : includes,
1371 link_with : [libshared],
1372 install_rpath : rootlibexecdir,
1373 install : true,
1374 install_dir : userenvgeneratordir)
7b76fce1 1375
37efbbd8
ZJS
1376 meson.add_install_script(meson_make_symlink,
1377 join_paths(sysconfdir, 'environment'),
1378 join_paths(environmentdir, '99-environment.conf'))
5c23128d
ZJS
1379endif
1380
349cc4a5 1381if conf.get('ENABLE_HIBERNATE') == 1
37efbbd8
ZJS
1382 executable('systemd-hibernate-resume-generator',
1383 'src/hibernate-resume/hibernate-resume-generator.c',
1384 include_directories : includes,
1385 link_with : [libshared],
1386 install_rpath : rootlibexecdir,
1387 install : true,
1388 install_dir : systemgeneratordir)
5c23128d 1389
37efbbd8
ZJS
1390 executable('systemd-hibernate-resume',
1391 'src/hibernate-resume/hibernate-resume.c',
005a29f2
ZJS
1392 include_directories : includes,
1393 link_with : [libshared],
1394 install_rpath : rootlibexecdir,
1395 install : true,
1396 install_dir : rootlibexecdir)
37efbbd8
ZJS
1397endif
1398
349cc4a5 1399if conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1400 executable('systemd-gpt-auto-generator',
1401 'src/gpt-auto-generator/gpt-auto-generator.c',
1402 'src/basic/blkid-util.h',
1403 include_directories : includes,
34ce0a52 1404 link_with : [libshared],
37efbbd8
ZJS
1405 dependencies : libblkid,
1406 install_rpath : rootlibexecdir,
1407 install : true,
1408 install_dir : systemgeneratordir)
1409
1410 exe = executable('systemd-dissect',
1411 'src/dissect/dissect.c',
1412 include_directories : includes,
1413 link_with : [libshared],
1414 install_rpath : rootlibexecdir,
1415 install : true,
1416 install_dir : rootlibexecdir)
1417 public_programs += [exe]
5c23128d
ZJS
1418endif
1419
1ec57f33 1420if conf.get('ENABLE_RESOLVE') == 1
37efbbd8
ZJS
1421 executable('systemd-resolved',
1422 systemd_resolved_sources,
76c87410 1423 gcrypt_util_sources,
005a29f2 1424 include_directories : includes,
aac26058 1425 link_with : [libshared],
005a29f2 1426 dependencies : [threads,
76c87410
MB
1427 libgcrypt,
1428 libgpg_error,
005a29f2
ZJS
1429 libm,
1430 libidn],
1431 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1432 install : true,
1433 install_dir : rootlibexecdir)
1434
1435 exe = executable('systemd-resolve',
1436 systemd_resolve_sources,
76c87410 1437 gcrypt_util_sources,
37efbbd8
ZJS
1438 include_directories : includes,
1439 link_with : [libshared],
1440 dependencies : [threads,
76c87410
MB
1441 libgcrypt,
1442 libgpg_error,
37efbbd8
ZJS
1443 libm,
1444 libidn],
1445 install_rpath : rootlibexecdir,
1446 install : true)
1447 public_programs += [exe]
5c23128d
ZJS
1448endif
1449
349cc4a5 1450if conf.get('ENABLE_LOGIND') == 1
37efbbd8
ZJS
1451 executable('systemd-logind',
1452 systemd_logind_sources,
005a29f2 1453 include_directories : includes,
37efbbd8 1454 link_with : [liblogind_core,
34ce0a52 1455 libshared],
005a29f2 1456 dependencies : [threads,
37efbbd8 1457 libacl],
005a29f2
ZJS
1458 install_rpath : rootlibexecdir,
1459 install : true,
37efbbd8
ZJS
1460 install_dir : rootlibexecdir)
1461
1462 exe = executable('loginctl',
1463 loginctl_sources,
1464 include_directories : includes,
34ce0a52 1465 link_with : [libshared],
37efbbd8
ZJS
1466 dependencies : [threads,
1467 liblz4,
1468 libxz],
1469 install_rpath : rootlibexecdir,
1470 install : true,
1471 install_dir : rootbindir)
1472 public_programs += [exe]
1473
1474 exe = executable('systemd-inhibit',
1475 'src/login/inhibit.c',
1476 include_directories : includes,
1477 link_with : [libshared],
1478 install_rpath : rootlibexecdir,
1479 install : true,
1480 install_dir : rootbindir)
1481 public_programs += [exe]
1482
349cc4a5 1483 if conf.get('HAVE_PAM') == 1
37efbbd8
ZJS
1484 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
1485 pam_systemd = shared_library(
1486 'pam_systemd',
1487 pam_systemd_c,
1488 name_prefix : '',
1489 include_directories : includes,
1490 link_args : ['-shared',
1491 '-Wl,--version-script=' + version_script_arg],
1492 link_with : [libsystemd_internal,
1493 libshared_static],
1494 dependencies : [threads,
1495 libpam,
1496 libpam_misc],
1497 link_depends : pam_systemd_sym,
1498 install : true,
1499 install_dir : pamlibdir)
1500
1501 test('dlopen-pam_systemd',
1502 test_dlopen,
1503 args : [pam_systemd.full_path()]) # path to dlopen must include a slash
1504 endif
1505endif
005a29f2 1506
349cc4a5 1507if conf.get('HAVE_PAM') == 1
37efbbd8
ZJS
1508 executable('systemd-user-sessions',
1509 'src/user-sessions/user-sessions.c',
005a29f2 1510 include_directories : includes,
aac26058 1511 link_with : [libshared],
005a29f2
ZJS
1512 install_rpath : rootlibexecdir,
1513 install : true,
37efbbd8 1514 install_dir : rootlibexecdir)
5c23128d
ZJS
1515endif
1516
349cc4a5 1517if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_BLKID') == 1
37efbbd8
ZJS
1518 exe = executable('bootctl',
1519 'src/boot/bootctl.c',
1520 include_directories : includes,
1521 link_with : [libshared],
1522 dependencies : [libblkid],
1523 install_rpath : rootlibexecdir,
1524 install : true)
1525 public_programs += [exe]
005a29f2
ZJS
1526endif
1527
1528exe = executable('systemd-socket-activate', 'src/activate/activate.c',
1529 include_directories : includes,
1530 link_with : [libshared],
1531 dependencies : [threads],
1532 install_rpath : rootlibexecdir,
1533 install : true)
1534public_programs += [exe]
1535
1536exe = executable('systemctl', 'src/systemctl/systemctl.c',
1537 include_directories : includes,
aac26058 1538 link_with : [libshared],
005a29f2
ZJS
1539 dependencies : [threads,
1540 libcap,
1541 libselinux,
1542 libxz,
1543 liblz4],
1544 install_rpath : rootlibexecdir,
1545 install : true,
1546 install_dir : rootbindir)
1547public_programs += [exe]
5c23128d 1548
349cc4a5 1549if conf.get('ENABLE_BACKLIGHT') == 1
37efbbd8
ZJS
1550 executable('systemd-backlight',
1551 'src/backlight/backlight.c',
1552 include_directories : includes,
34ce0a52 1553 link_with : [libshared],
37efbbd8
ZJS
1554 install_rpath : rootlibexecdir,
1555 install : true,
1556 install_dir : rootlibexecdir)
5c23128d
ZJS
1557endif
1558
349cc4a5 1559if conf.get('ENABLE_RFKILL') == 1
37efbbd8
ZJS
1560 executable('systemd-rfkill',
1561 'src/rfkill/rfkill.c',
1562 include_directories : includes,
34ce0a52 1563 link_with : [libshared],
37efbbd8
ZJS
1564 install_rpath : rootlibexecdir,
1565 install : true,
1566 install_dir : rootlibexecdir)
5c23128d
ZJS
1567endif
1568
1569executable('systemd-system-update-generator',
1570 'src/system-update-generator/system-update-generator.c',
1571 include_directories : includes,
1572 link_with : [libshared],
b2fc5836 1573 install_rpath : rootlibexecdir,
5c23128d
ZJS
1574 install : true,
1575 install_dir : systemgeneratordir)
1576
349cc4a5 1577if conf.get('HAVE_LIBCRYPTSETUP') == 1
37efbbd8
ZJS
1578 executable('systemd-cryptsetup',
1579 'src/cryptsetup/cryptsetup.c',
1580 include_directories : includes,
1581 link_with : [libshared],
1582 dependencies : [libcryptsetup],
1583 install_rpath : rootlibexecdir,
1584 install : true,
1585 install_dir : rootlibexecdir)
1586
1587 executable('systemd-cryptsetup-generator',
1588 'src/cryptsetup/cryptsetup-generator.c',
1589 include_directories : includes,
1590 link_with : [libshared],
1591 dependencies : [libcryptsetup],
1592 install_rpath : rootlibexecdir,
1593 install : true,
1594 install_dir : systemgeneratordir)
1595
1596 executable('systemd-veritysetup',
1597 'src/veritysetup/veritysetup.c',
1598 include_directories : includes,
1599 link_with : [libshared],
1600 dependencies : [libcryptsetup],
1601 install_rpath : rootlibexecdir,
1602 install : true,
1603 install_dir : rootlibexecdir)
1604
1605 executable('systemd-veritysetup-generator',
1606 'src/veritysetup/veritysetup-generator.c',
1607 include_directories : includes,
1608 link_with : [libshared],
1609 dependencies : [libcryptsetup],
1610 install_rpath : rootlibexecdir,
1611 install : true,
1612 install_dir : systemgeneratordir)
5c23128d
ZJS
1613endif
1614
349cc4a5 1615if conf.get('HAVE_SYSV_COMPAT') == 1
37efbbd8
ZJS
1616 executable('systemd-sysv-generator',
1617 'src/sysv-generator/sysv-generator.c',
1618 include_directories : includes,
1619 link_with : [libshared],
1620 install_rpath : rootlibexecdir,
1621 install : true,
1622 install_dir : systemgeneratordir)
1623
1624 executable('systemd-rc-local-generator',
1625 'src/rc-local-generator/rc-local-generator.c',
1626 include_directories : includes,
1627 link_with : [libshared],
1628 install_rpath : rootlibexecdir,
1629 install : true,
1630 install_dir : systemgeneratordir)
5c23128d
ZJS
1631endif
1632
349cc4a5 1633if conf.get('ENABLE_HOSTNAMED') == 1
37efbbd8
ZJS
1634 executable('systemd-hostnamed',
1635 'src/hostname/hostnamed.c',
005a29f2 1636 include_directories : includes,
aac26058 1637 link_with : [libshared],
005a29f2 1638 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1639 install : true,
1640 install_dir : rootlibexecdir)
1641
1642 exe = executable('hostnamectl',
1643 'src/hostname/hostnamectl.c',
1644 include_directories : includes,
1645 link_with : [libshared],
1646 install_rpath : rootlibexecdir,
1647 install : true)
1648 public_programs += [exe]
5c23128d
ZJS
1649endif
1650
349cc4a5
ZJS
1651if conf.get('ENABLE_LOCALED') == 1
1652 if conf.get('HAVE_XKBCOMMON') == 1
37efbbd8
ZJS
1653 # logind will load libxkbcommon.so dynamically on its own
1654 deps = [libdl]
1655 else
1656 deps = []
1657 endif
1658
1659 executable('systemd-localed',
1660 systemd_localed_sources,
005a29f2 1661 include_directories : includes,
aac26058 1662 link_with : [libshared],
37efbbd8 1663 dependencies : deps,
005a29f2 1664 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1665 install : true,
1666 install_dir : rootlibexecdir)
1667
1668 exe = executable('localectl',
1669 localectl_sources,
1670 include_directories : includes,
1671 link_with : [libshared],
1672 install_rpath : rootlibexecdir,
1673 install : true)
1674 public_programs += [exe]
5c23128d
ZJS
1675endif
1676
349cc4a5 1677if conf.get('ENABLE_TIMEDATED') == 1
37efbbd8
ZJS
1678 executable('systemd-timedated',
1679 'src/timedate/timedated.c',
005a29f2 1680 include_directories : includes,
aac26058 1681 link_with : [libshared],
37efbbd8
ZJS
1682 install_rpath : rootlibexecdir,
1683 install : true,
1684 install_dir : rootlibexecdir)
5c23128d 1685
37efbbd8
ZJS
1686 exe = executable('timedatectl',
1687 'src/timedate/timedatectl.c',
1688 include_directories : includes,
1689 install_rpath : rootlibexecdir,
1690 link_with : [libshared],
1691 install : true)
1692 public_programs += [exe]
5c23128d
ZJS
1693endif
1694
349cc4a5 1695if conf.get('ENABLE_TIMESYNCD') == 1
37efbbd8
ZJS
1696 executable('systemd-timesyncd',
1697 systemd_timesyncd_sources,
005a29f2 1698 include_directories : includes,
aac26058 1699 link_with : [libshared],
005a29f2 1700 dependencies : [threads,
37efbbd8 1701 libm],
005a29f2
ZJS
1702 install_rpath : rootlibexecdir,
1703 install : true,
37efbbd8 1704 install_dir : rootlibexecdir)
5c23128d
ZJS
1705endif
1706
349cc4a5 1707if conf.get('ENABLE_MACHINED') == 1
37efbbd8
ZJS
1708 executable('systemd-machined',
1709 systemd_machined_sources,
1710 include_directories : includes,
1711 link_with : [libmachine_core,
1712 libshared],
1713 install_rpath : rootlibexecdir,
1714 install : true,
1715 install_dir : rootlibexecdir)
1716
1717 exe = executable('machinectl',
1718 'src/machine/machinectl.c',
1719 include_directories : includes,
1720 link_with : [libshared],
1721 dependencies : [threads,
1722 libxz,
1723 liblz4],
1724 install_rpath : rootlibexecdir,
1725 install : true,
1726 install_dir : rootbindir)
1727 public_programs += [exe]
5c23128d
ZJS
1728endif
1729
349cc4a5 1730if conf.get('ENABLE_IMPORTD') == 1
37efbbd8
ZJS
1731 executable('systemd-importd',
1732 systemd_importd_sources,
005a29f2 1733 include_directories : includes,
aac26058 1734 link_with : [libshared],
37efbbd8 1735 dependencies : [threads],
005a29f2
ZJS
1736 install_rpath : rootlibexecdir,
1737 install : true,
1738 install_dir : rootlibexecdir)
37efbbd8
ZJS
1739
1740 systemd_pull = executable('systemd-pull',
1741 systemd_pull_sources,
1742 include_directories : includes,
1743 link_with : [libshared],
1744 dependencies : [libcurl,
1745 libz,
1746 libbzip2,
1747 libxz,
1748 libgcrypt],
1749 install_rpath : rootlibexecdir,
1750 install : true,
1751 install_dir : rootlibexecdir)
1752
1753 systemd_import = executable('systemd-import',
1754 systemd_import_sources,
1755 include_directories : includes,
1756 link_with : [libshared],
1757 dependencies : [libcurl,
1758 libz,
1759 libbzip2,
1760 libxz],
1761 install_rpath : rootlibexecdir,
1762 install : true,
1763 install_dir : rootlibexecdir)
1764
1765 systemd_export = executable('systemd-export',
1766 systemd_export_sources,
1767 include_directories : includes,
1768 link_with : [libshared],
1769 dependencies : [libcurl,
1770 libz,
1771 libbzip2,
1772 libxz],
1773 install_rpath : rootlibexecdir,
1774 install : true,
1775 install_dir : rootlibexecdir)
1776 public_programs += [systemd_pull, systemd_import, systemd_export]
1777endif
1778
349cc4a5 1779if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
37efbbd8
ZJS
1780 exe = executable('systemd-journal-upload',
1781 systemd_journal_upload_sources,
1782 include_directories : includes,
1783 link_with : [libshared],
1784 dependencies : [threads,
1785 libcurl,
1786 libgnutls,
1787 libxz,
1788 liblz4],
1789 install_rpath : rootlibexecdir,
1790 install : true,
1791 install_dir : rootlibexecdir)
1792 public_programs += [exe]
5c23128d
ZJS
1793endif
1794
349cc4a5 1795if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
37efbbd8
ZJS
1796 s_j_remote = executable('systemd-journal-remote',
1797 systemd_journal_remote_sources,
1798 include_directories : includes,
1799 link_with : [libshared],
1800 dependencies : [threads,
1801 libmicrohttpd,
1802 libgnutls,
1803 libxz,
1804 liblz4],
1805 install_rpath : rootlibexecdir,
1806 install : true,
1807 install_dir : rootlibexecdir)
1808
1809 s_j_gatewayd = executable('systemd-journal-gatewayd',
1810 systemd_journal_gatewayd_sources,
1811 include_directories : includes,
1812 link_with : [libshared],
1813 dependencies : [threads,
1814 libmicrohttpd,
1815 libgnutls,
1816 libxz,
1817 liblz4],
1818 install_rpath : rootlibexecdir,
1819 install : true,
1820 install_dir : rootlibexecdir)
1821 public_programs += [s_j_remote, s_j_gatewayd]
5c23128d
ZJS
1822endif
1823
349cc4a5 1824if conf.get('ENABLE_COREDUMP') == 1
37efbbd8
ZJS
1825 executable('systemd-coredump',
1826 systemd_coredump_sources,
005a29f2 1827 include_directories : includes,
aac26058 1828 link_with : [libshared],
005a29f2 1829 dependencies : [threads,
37efbbd8
ZJS
1830 libacl,
1831 libdw,
005a29f2
ZJS
1832 libxz,
1833 liblz4],
1834 install_rpath : rootlibexecdir,
37efbbd8
ZJS
1835 install : true,
1836 install_dir : rootlibexecdir)
1837
1838 exe = executable('coredumpctl',
1839 coredumpctl_sources,
1840 include_directories : includes,
1841 link_with : [libshared],
1842 dependencies : [threads,
1843 libxz,
1844 liblz4],
1845 install_rpath : rootlibexecdir,
1846 install : true)
1847 public_programs += [exe]
5c23128d
ZJS
1848endif
1849
349cc4a5 1850if conf.get('ENABLE_BINFMT') == 1
37efbbd8
ZJS
1851 exe = executable('systemd-binfmt',
1852 'src/binfmt/binfmt.c',
1853 include_directories : includes,
1854 link_with : [libshared],
1855 install_rpath : rootlibexecdir,
1856 install : true,
1857 install_dir : rootlibexecdir)
1858 public_programs += [exe]
1859
1860 meson.add_install_script('sh', '-c',
1861 mkdir_p.format(binfmtdir))
1862 meson.add_install_script('sh', '-c',
1863 mkdir_p.format(join_paths(sysconfdir, 'binfmt.d')))
1864endif
1865
349cc4a5 1866if conf.get('ENABLE_VCONSOLE') == 1
37efbbd8
ZJS
1867 executable('systemd-vconsole-setup',
1868 'src/vconsole/vconsole-setup.c',
005a29f2
ZJS
1869 include_directories : includes,
1870 link_with : [libshared],
1871 install_rpath : rootlibexecdir,
1872 install : true,
1873 install_dir : rootlibexecdir)
5c23128d
ZJS
1874endif
1875
349cc4a5 1876if conf.get('ENABLE_RANDOMSEED') == 1
37efbbd8
ZJS
1877 executable('systemd-random-seed',
1878 'src/random-seed/random-seed.c',
1879 include_directories : includes,
1880 link_with : [libshared],
1881 install_rpath : rootlibexecdir,
1882 install : true,
1883 install_dir : rootlibexecdir)
5c23128d
ZJS
1884endif
1885
349cc4a5 1886if conf.get('ENABLE_FIRSTBOOT') == 1
37efbbd8
ZJS
1887 executable('systemd-firstboot',
1888 'src/firstboot/firstboot.c',
1889 include_directories : includes,
1890 link_with : [libshared],
1891 dependencies : [libcrypt],
1892 install_rpath : rootlibexecdir,
1893 install : true,
1894 install_dir : rootbindir)
5c23128d
ZJS
1895endif
1896
1897executable('systemd-remount-fs',
1898 'src/remount-fs/remount-fs.c',
1899 'src/core/mount-setup.c',
1900 'src/core/mount-setup.h',
1901 include_directories : includes,
1902 link_with : [libshared],
b2fc5836 1903 install_rpath : rootlibexecdir,
5c23128d
ZJS
1904 install : true,
1905 install_dir : rootlibexecdir)
1906
1907executable('systemd-machine-id-setup',
1908 'src/machine-id-setup/machine-id-setup-main.c',
1909 'src/core/machine-id-setup.c',
1910 'src/core/machine-id-setup.h',
1911 include_directories : includes,
aac26058 1912 link_with : [libshared],
b2fc5836 1913 install_rpath : rootlibexecdir,
5c23128d
ZJS
1914 install : true,
1915 install_dir : rootbindir)
1916
1917executable('systemd-fsck',
1918 'src/fsck/fsck.c',
1919 include_directories : includes,
aac26058 1920 link_with : [libshared],
421f0012 1921 install_rpath : rootlibexecdir,
5c23128d
ZJS
1922 install : true,
1923 install_dir : rootlibexecdir)
1924
1925executable('systemd-sleep',
1926 'src/sleep/sleep.c',
1927 include_directories : includes,
1928 link_with : [libshared],
421f0012 1929 install_rpath : rootlibexecdir,
5c23128d
ZJS
1930 install : true,
1931 install_dir : rootlibexecdir)
1932
005a29f2
ZJS
1933exe = executable('systemd-sysctl',
1934 'src/sysctl/sysctl.c',
1935 include_directories : includes,
1936 link_with : [libshared],
1937 install_rpath : rootlibexecdir,
1938 install : true,
1939 install_dir : rootlibexecdir)
1940public_programs += [exe]
5c23128d
ZJS
1941
1942executable('systemd-ac-power',
1943 'src/ac-power/ac-power.c',
1944 include_directories : includes,
1945 link_with : [libshared],
421f0012 1946 install_rpath : rootlibexecdir,
5c23128d
ZJS
1947 install : true,
1948 install_dir : rootlibexecdir)
1949
005a29f2
ZJS
1950exe = executable('systemd-detect-virt',
1951 'src/detect-virt/detect-virt.c',
1952 include_directories : includes,
1953 link_with : [libshared],
1954 install_rpath : rootlibexecdir,
1955 install : true)
1956public_programs += [exe]
1957
1958exe = executable('systemd-delta',
1959 'src/delta/delta.c',
1960 include_directories : includes,
1961 link_with : [libshared],
1962 install_rpath : rootlibexecdir,
1963 install : true)
1964public_programs += [exe]
1965
1966exe = executable('systemd-escape',
1967 'src/escape/escape.c',
1968 include_directories : includes,
1969 link_with : [libshared],
1970 install_rpath : rootlibexecdir,
1971 install : true,
1972 install_dir : rootbindir)
1973public_programs += [exe]
1974
1975exe = executable('systemd-notify',
1976 'src/notify/notify.c',
1977 include_directories : includes,
1978 link_with : [libshared],
1979 install_rpath : rootlibexecdir,
1980 install : true,
1981 install_dir : rootbindir)
1982public_programs += [exe]
5c23128d
ZJS
1983
1984executable('systemd-volatile-root',
1985 'src/volatile-root/volatile-root.c',
1986 include_directories : includes,
1987 link_with : [libshared],
421f0012 1988 install_rpath : rootlibexecdir,
5c23128d
ZJS
1989 install : true,
1990 install_dir : rootlibexecdir)
1991
1992executable('systemd-cgroups-agent',
1993 'src/cgroups-agent/cgroups-agent.c',
1994 include_directories : includes,
1995 link_with : [libshared],
421f0012 1996 install_rpath : rootlibexecdir,
5c23128d
ZJS
1997 install : true,
1998 install_dir : rootlibexecdir)
1999
005a29f2
ZJS
2000exe = executable('systemd-path',
2001 'src/path/path.c',
2002 include_directories : includes,
aac26058 2003 link_with : [libshared],
005a29f2
ZJS
2004 install_rpath : rootlibexecdir,
2005 install : true)
2006public_programs += [exe]
2007
2008exe = executable('systemd-ask-password',
2009 'src/ask-password/ask-password.c',
2010 include_directories : includes,
aac26058 2011 link_with : [libshared],
005a29f2
ZJS
2012 install_rpath : rootlibexecdir,
2013 install : true,
2014 install_dir : rootbindir)
2015public_programs += [exe]
5c23128d
ZJS
2016
2017executable('systemd-reply-password',
2018 'src/reply-password/reply-password.c',
2019 include_directories : includes,
aac26058 2020 link_with : [libshared],
421f0012 2021 install_rpath : rootlibexecdir,
5c23128d
ZJS
2022 install : true,
2023 install_dir : rootlibexecdir)
2024
005a29f2
ZJS
2025exe = executable('systemd-tty-ask-password-agent',
2026 'src/tty-ask-password-agent/tty-ask-password-agent.c',
2027 include_directories : includes,
aac26058 2028 link_with : [libshared],
005a29f2
ZJS
2029 install_rpath : rootlibexecdir,
2030 install : true,
2031 install_dir : rootbindir)
2032public_programs += [exe]
2033
2034exe = executable('systemd-cgls',
2035 'src/cgls/cgls.c',
2036 include_directories : includes,
aac26058 2037 link_with : [libshared],
005a29f2
ZJS
2038 install_rpath : rootlibexecdir,
2039 install : true)
2040public_programs += [exe]
2041
2042exe = executable('systemd-cgtop',
2043 'src/cgtop/cgtop.c',
2044 include_directories : includes,
aac26058 2045 link_with : [libshared],
005a29f2
ZJS
2046 install_rpath : rootlibexecdir,
2047 install : true)
2048public_programs += [exe]
5c23128d
ZJS
2049
2050executable('systemd-initctl',
2051 'src/initctl/initctl.c',
2052 include_directories : includes,
aac26058 2053 link_with : [libshared],
421f0012 2054 install_rpath : rootlibexecdir,
5c23128d
ZJS
2055 install : true,
2056 install_dir : rootlibexecdir)
2057
005a29f2
ZJS
2058exe = executable('systemd-mount',
2059 'src/mount/mount-tool.c',
2060 include_directories : includes,
34ce0a52 2061 link_with : [libshared],
005a29f2
ZJS
2062 install_rpath : rootlibexecdir,
2063 install : true)
2064public_programs += [exe]
5c23128d 2065
7b76fce1 2066meson.add_install_script(meson_make_symlink,
e17e5ba9 2067 'systemd-mount', join_paths(bindir, 'systemd-umount'))
7b76fce1 2068
005a29f2
ZJS
2069exe = executable('systemd-run',
2070 'src/run/run.c',
2071 include_directories : includes,
aac26058 2072 link_with : [libshared],
005a29f2
ZJS
2073 install_rpath : rootlibexecdir,
2074 install : true)
2075public_programs += [exe]
2076
2077exe = executable('systemd-stdio-bridge',
2078 'src/stdio-bridge/stdio-bridge.c',
2079 include_directories : includes,
aac26058 2080 link_with : [libshared],
005a29f2
ZJS
2081 install_rpath : rootlibexecdir,
2082 install : true)
2083public_programs += [exe]
2084
2085exe = executable('busctl',
2086 'src/busctl/busctl.c',
2087 'src/busctl/busctl-introspect.c',
2088 'src/busctl/busctl-introspect.h',
2089 include_directories : includes,
aac26058 2090 link_with : [libshared],
005a29f2
ZJS
2091 install_rpath : rootlibexecdir,
2092 install : true)
2093public_programs += [exe]
5c23128d 2094
349cc4a5 2095if conf.get('ENABLE_SYSUSERS') == 1
37efbbd8
ZJS
2096 exe = executable('systemd-sysusers',
2097 'src/sysusers/sysusers.c',
2098 include_directories : includes,
2099 link_with : [libshared],
2100 install_rpath : rootlibexecdir,
2101 install : true,
2102 install_dir : rootbindir)
2103 public_programs += [exe]
5c23128d
ZJS
2104endif
2105
349cc4a5 2106if conf.get('ENABLE_TMPFILES') == 1
37efbbd8
ZJS
2107 exe = executable('systemd-tmpfiles',
2108 'src/tmpfiles/tmpfiles.c',
2109 include_directories : includes,
2110 link_with : [libshared],
2111 dependencies : [libacl],
2112 install_rpath : rootlibexecdir,
2113 install : true,
2114 install_dir : rootbindir)
2115 public_programs += [exe]
5c23128d
ZJS
2116endif
2117
349cc4a5 2118if conf.get('ENABLE_HWDB') == 1
37efbbd8
ZJS
2119 exe = executable('systemd-hwdb',
2120 'src/hwdb/hwdb.c',
2121 'src/libsystemd/sd-hwdb/hwdb-internal.h',
2122 include_directories : includes,
0da6f396
MB
2123 link_with : [libudev_internal],
2124 install_rpath : udev_rpath,
37efbbd8
ZJS
2125 install : true,
2126 install_dir : rootbindir)
2127 public_programs += [exe]
2128endif
2129
349cc4a5 2130if conf.get('ENABLE_QUOTACHECK') == 1
37efbbd8
ZJS
2131 executable('systemd-quotacheck',
2132 'src/quotacheck/quotacheck.c',
005a29f2 2133 include_directories : includes,
aac26058 2134 link_with : [libshared],
005a29f2
ZJS
2135 install_rpath : rootlibexecdir,
2136 install : true,
37efbbd8 2137 install_dir : rootlibexecdir)
5c23128d
ZJS
2138endif
2139
005a29f2
ZJS
2140exe = executable('systemd-socket-proxyd',
2141 'src/socket-proxy/socket-proxyd.c',
2142 include_directories : includes,
aac26058 2143 link_with : [libshared],
005a29f2
ZJS
2144 dependencies : [threads],
2145 install_rpath : rootlibexecdir,
2146 install : true,
2147 install_dir : rootlibexecdir)
2148public_programs += [exe]
2149
2150exe = executable('systemd-udevd',
2151 systemd_udevd_sources,
2152 include_directories : includes,
5c72049f 2153 c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
005a29f2 2154 link_with : [libudev_core,
005a29f2 2155 libsystemd_network,
1aec3ed9 2156 libudev_internal],
3a30f21f
ZJS
2157 dependencies : [threads,
2158 libkmod,
005a29f2 2159 libidn,
aac26058
ZJS
2160 libacl,
2161 libblkid],
1aec3ed9 2162 install_rpath : udev_rpath,
005a29f2
ZJS
2163 install : true,
2164 install_dir : rootlibexecdir)
2165public_programs += [exe]
2166
2167exe = executable('udevadm',
2168 udevadm_sources,
2169 include_directories : includes,
2170 link_with : [libudev_core,
005a29f2 2171 libsystemd_network,
1aec3ed9 2172 libudev_internal],
3a30f21f
ZJS
2173 dependencies : [threads,
2174 libkmod,
005a29f2 2175 libidn,
aac26058
ZJS
2176 libacl,
2177 libblkid],
1aec3ed9 2178 install_rpath : udev_rpath,
005a29f2
ZJS
2179 install : true,
2180 install_dir : rootbindir)
2181public_programs += [exe]
5c23128d
ZJS
2182
2183executable('systemd-shutdown',
2184 systemd_shutdown_sources,
2185 include_directories : includes,
34ce0a52 2186 link_with : [libshared],
421f0012 2187 install_rpath : rootlibexecdir,
5c23128d
ZJS
2188 install : true,
2189 install_dir : rootlibexecdir)
2190
2191executable('systemd-update-done',
2192 'src/update-done/update-done.c',
2193 include_directories : includes,
2194 link_with : [libshared],
421f0012 2195 install_rpath : rootlibexecdir,
5c23128d
ZJS
2196 install : true,
2197 install_dir : rootlibexecdir)
2198
2199executable('systemd-update-utmp',
2200 'src/update-utmp/update-utmp.c',
2201 include_directories : includes,
aac26058 2202 link_with : [libshared],
5c23128d 2203 dependencies : [libaudit],
421f0012 2204 install_rpath : rootlibexecdir,
5c23128d
ZJS
2205 install : true,
2206 install_dir : rootlibexecdir)
2207
349cc4a5 2208if conf.get('HAVE_KMOD') == 1
37efbbd8
ZJS
2209 executable('systemd-modules-load',
2210 'src/modules-load/modules-load.c',
2211 include_directories : includes,
2212 link_with : [libshared],
2213 dependencies : [libkmod],
2214 install_rpath : rootlibexecdir,
2215 install : true,
2216 install_dir : rootlibexecdir)
94e75a54 2217
37efbbd8
ZJS
2218 meson.add_install_script('sh', '-c',
2219 mkdir_p.format(modulesloaddir))
2220 meson.add_install_script('sh', '-c',
2221 mkdir_p.format(join_paths(sysconfdir, 'modules-load.d')))
5c23128d
ZJS
2222endif
2223
005a29f2
ZJS
2224exe = executable('systemd-nspawn',
2225 systemd_nspawn_sources,
2226 'src/core/mount-setup.c', # FIXME: use a variable?
2227 'src/core/mount-setup.h',
2228 'src/core/loopback-setup.c',
2229 'src/core/loopback-setup.h',
2230 include_directories : [includes, include_directories('src/nspawn')],
0bc91152 2231 link_with : [libshared],
005a29f2
ZJS
2232 dependencies : [libacl,
2233 libblkid,
2234 libseccomp,
2235 libselinux],
2236 install_rpath : rootlibexecdir,
2237 install : true)
2238public_programs += [exe]
5c23128d 2239
349cc4a5 2240if conf.get('ENABLE_NETWORKD') == 1
37efbbd8
ZJS
2241 executable('systemd-networkd',
2242 systemd_networkd_sources,
2243 include_directories : includes,
2244 link_with : [libnetworkd_core,
37efbbd8
ZJS
2245 libsystemd_network,
2246 libudev_internal,
2247 libshared],
4b57a272 2248 dependencies : [threads],
37efbbd8
ZJS
2249 install_rpath : rootlibexecdir,
2250 install : true,
2251 install_dir : rootlibexecdir)
2252
2253 executable('systemd-networkd-wait-online',
2254 systemd_networkd_wait_online_sources,
2255 include_directories : includes,
2256 link_with : [libnetworkd_core,
2257 libshared],
2258 install_rpath : rootlibexecdir,
2259 install : true,
2260 install_dir : rootlibexecdir)
5c23128d 2261
dcfe072a
FS
2262 exe = executable('networkctl',
2263 networkctl_sources,
2264 include_directories : includes,
2265 link_with : [libsystemd_network,
aac26058 2266 libshared],
dcfe072a
FS
2267 install_rpath : rootlibexecdir,
2268 install : true,
2269 install_dir : rootbindir)
2270 public_programs += [exe]
2271endif
69e96427
ZJS
2272############################################################
2273
2274foreach tuple : tests
37efbbd8
ZJS
2275 sources = tuple[0]
2276 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
2277 dependencies = tuple[2]
2278 condition = tuple.length() >= 4 ? tuple[3] : ''
2279 type = tuple.length() >= 5 ? tuple[4] : ''
2280 defs = tuple.length() >= 6 ? tuple[5] : []
2281 incs = tuple.length() >= 7 ? tuple[6] : includes
2282 timeout = 30
2283
2284 name = sources[0].split('/')[-1].split('.')[0]
2285 if type.startswith('timeout=')
2286 timeout = type.split('=')[1].to_int()
2287 type = ''
2288 endif
2289
349cc4a5 2290 if condition == '' or conf.get(condition) == 1
37efbbd8
ZJS
2291 exe = executable(
2292 name,
2293 sources,
2294 include_directories : incs,
2295 link_with : link_with,
2296 dependencies : dependencies,
2297 c_args : defs,
2298 install_rpath : rootlibexecdir,
7cdd9783
MB
2299 install : install_tests,
2300 install_dir : join_paths(testsdir, type))
37efbbd8
ZJS
2301
2302 if type == 'manual'
2303 message('@0@ is a manual test'.format(name))
2304 elif type == 'unsafe' and want_tests != 'unsafe'
2305 message('@0@ is an unsafe test'.format(name))
2306 else
2307 test(name, exe,
2308 env : test_env,
2309 timeout : timeout)
2310 endif
2311 else
2312 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
2313 endif
69e96427
ZJS
2314endforeach
2315
37ab1a25 2316test_libsystemd_sym = executable(
37efbbd8
ZJS
2317 'test-libsystemd-sym',
2318 test_libsystemd_sym_c,
2319 include_directories : includes,
2320 link_with : [libsystemd],
2321 install : install_tests,
2322 install_dir : testsdir)
37ab1a25
ZJS
2323test('test-libsystemd-sym',
2324 test_libsystemd_sym)
2325
e0bec52f 2326test_libudev_sym = executable(
37efbbd8
ZJS
2327 'test-libudev-sym',
2328 test_libudev_sym_c,
2329 include_directories : includes,
2330 c_args : ['-Wno-deprecated-declarations'],
2331 link_with : [libudev],
2332 install : install_tests,
2333 install_dir : testsdir)
e0bec52f
ZJS
2334test('test-libudev-sym',
2335 test_libudev_sym)
2336
69e96427 2337############################################################
5c23128d
ZJS
2338
2339make_directive_index_py = find_program('tools/make-directive-index.py')
2340make_man_index_py = find_program('tools/make-man-index.py')
b184e8fe 2341xml_helper_py = find_program('tools/xml_helper.py')
abba22c5 2342hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
5c23128d
ZJS
2343
2344subdir('units')
2345subdir('sysctl.d')
2346subdir('sysusers.d')
2347subdir('tmpfiles.d')
2348subdir('rules')
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))