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