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