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