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