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