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