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