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