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