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