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