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