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