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