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