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