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