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