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