]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: remove libnss_*.so symlinks after install
[thirdparty/systemd.git] / meson.build
CommitLineData
5c23128d
ZJS
1# -*- mode: meson -*-
2
3project('systemd', 'c',
4 version : '233',
5 license : 'LGPLv2+',
6 default_options: [
7 'c_std=gnu99',
8 'prefix=/usr',
9 'sysconfdir=/etc',
10 'localstatedir=/var',
11 ],
12 meson_version : '>= 0.39.1',
13 )
14
15# We need the same data in three different formats, ugh!
16# Also, for hysterical reasons, we use different variable
17# names, sometimes. Not all variables are included in every
18# set. Ugh, ugh, ugh!
19conf = configuration_data()
20conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version())
21conf.set_quoted('PACKAGE_VERSION', meson.project_version())
22
23substs = configuration_data()
24substs.set('PACKAGE_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
25substs.set('PACKAGE_VERSION', meson.project_version())
26
27m4_defines = []
28
29#####################################################################
30
31if get_option('split-usr')
32 conf.set('HAVE_SPLIT_USR', 1)
33 rootprefixdir = '/'
34else
35 rootprefixdir = '/usr'
36endif
37
38sysvinit_path = get_option('sysvinit-path')
39sysvrcnd_path = get_option('sysvrcnd-path')
40if sysvinit_path != '' or sysvrcnd_path != ''
41 conf.set('HAVE_SYSV_COMPAT', 1,
42 description : 'SysV init scripts and rcN.d links are supported')
43endif
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.
48prefixdir = get_option('prefix')
49if not prefixdir.startswith('/')
50 error('Prefix is not absolute: "@0@"'.format(prefixdir))
51endif
52bindir = join_paths(prefixdir, get_option('bindir'))
53libdir = join_paths(prefixdir, get_option('libdir'))
54sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
55includedir = join_paths(prefixdir, get_option('includedir'))
56datadir = join_paths(prefixdir, get_option('datadir'))
57localstatedir = join_paths('/', get_option('localstatedir'))
58
59rootbindir = join_paths(rootprefixdir, 'bin')
60rootlibexecdir = join_paths(rootprefixdir, 'lib/systemd')
61
62rootlibdir = get_option('rootlibdir')
63if rootlibdir == ''
64 rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
65endif
66
67# Dirs of external packages
68pkgconfigdatadir = datadir + '/pkgconfig'
69pkgconfiglibdir = libdir + '/pkgconfig'
70polkitpolicydir = datadir + '/polkit-1/actions'
71polkitrulesdir = datadir + '/polkit-1/rules.d'
72polkitpkladir = localstatedir + '/lib/polkit-1/localauthority/10-vendor.d'
73varlogdir = localstatedir + '/log'
74xinitrcdir = sysconfdir + '/X11/xinit/xinitrc.d'
75rpmmacrosdir = get_option('rpmmacrosdir')
76
77# Our own paths
78pkgdatadir = datadir + '/systemd'
79environmentdir = prefixdir + '/lib/environment.d'
80pkgsysconfdir = sysconfdir + '/systemd'
81userunitdir = prefixdir + '/lib/systemd/user'
82userpresetdir = prefixdir + '/lib/systemd/user-preset'
83tmpfilesdir = prefixdir + '/lib/tmpfiles.d'
84sysusersdir = prefixdir + '/lib/sysusers.d'
85sysctldir = prefixdir + '/lib/sysctl.d'
86binfmtdir = prefixdir + '/lib/binfmt.d'
87modulesloaddir = prefixdir + '/lib/modules-load.d'
88networkdir = rootprefixdir + '/lib/systemd/network'
89pkgincludedir = includedir + '/systemd'
90systemgeneratordir = rootlibexecdir + '/system-generators'
91usergeneratordir = prefixdir + '/lib/systemd/user-generators'
92systemenvgeneratordir = prefixdir + '/lib/systemd/system-environment-generators'
93userenvgeneratordir = prefixdir + '/lib/systemd/user-environment-generators'
94systemshutdowndir = rootlibexecdir + '/system-shutdown'
95systemsleepdir = rootlibexecdir + '/system-sleep'
96systemunitdir = rootprefixdir + '/lib/systemd/system'
97systempresetdir = rootprefixdir + '/lib/systemd/system-preset'
98udevlibexecdir = rootprefixdir + '/lib/udev'
99udevhomedir = udevlibexecdir + ''
100udevrulesdir = udevlibexecdir + '/rules.d'
101udevhwdbdir = udevlibexecdir + '/hwdb.d'
102catalogdir = prefixdir + '/lib/systemd/catalog'
103kernelinstalldir = prefixdir + '/lib/kernel/install.d'
104factorydir = datadir + '/factory'
105docdir = datadir + '/doc/systemd'
106bootlibdir = prefixdir + '/lib/systemd/boot/efi'
107testsdir = prefixdir + '/lib/systemd/tests'
108systemdstatedir = localstatedir + '/lib/systemd'
109catalogstatedir = systemdstatedir + '/catalog'
110
111dbuspolicydir = get_option('dbuspolicydir')
112if dbuspolicydir == ''
113 dbuspolicydir = datadir + '/dbus-1/system.d'
114endif
115
116dbussessionservicedir = get_option('dbussessionservicedir')
117if dbussessionservicedir == ''
118 dbussessionservicedir = datadir + '/dbus-1/services'
119endif
120
121dbussystemservicedir = get_option('dbussystemservicedir')
122if dbussystemservicedir == ''
123 dbussystemservicedir = datadir + '/dbus-1/system-services'
124endif
125
126pamlibdir = get_option('pamlibdir')
127if pamlibdir == ''
128 pamlibdir = rootlibdir + '/security'
129endif
130
131pamconfdir = get_option('pamconfdir')
132if pamconfdir == ''
133 pamconfdir = sysconfdir + '/pam.d'
134endif
135
136conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
137conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', pkgsysconfdir + '/system')
138conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
139conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
140conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
141conf.set_quoted('USER_CONFIG_UNIT_PATH', pkgsysconfdir + '/user')
142conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
143conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
144conf.set_quoted('CATALOG_DATABASE', catalogstatedir + '/database')
145conf.set_quoted('SYSTEMD_CGROUP_AGENT_PATH', rootlibexecdir + '/systemd-cgroups-agent')
146conf.set_quoted('SYSTEMD_BINARY_PATH', rootlibexecdir + '/systemd')
147conf.set_quoted('SYSTEMD_FSCK_PATH', rootlibexecdir + '/systemd-fsck')
148conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', rootlibexecdir + '/systemd-shutdown')
149conf.set_quoted('SYSTEMD_SLEEP_BINARY_PATH', rootlibexecdir + '/systemd-sleep')
150conf.set_quoted('SYSTEMCTL_BINARY_PATH', rootbindir + '/systemctl')
151conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', rootbindir + '/systemd-tty-ask-password-agent')
152conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', bindir + '/systemd-stdio-bridge')
153conf.set_quoted('ROOTPREFIX', rootprefixdir)
154conf.set_quoted('RANDOM_SEED_DIR', localstatedir + '/lib/systemd/')
155conf.set_quoted('RANDOM_SEED', localstatedir + '/lib/systemd/random-seed')
156conf.set_quoted('SYSTEMD_CRYPTSETUP_PATH', rootlibexecdir + '/systemd-cryptsetup')
157conf.set_quoted('SYSTEM_GENERATOR_PATH', systemgeneratordir)
158conf.set_quoted('USER_GENERATOR_PATH', usergeneratordir)
159conf.set_quoted('SYSTEM_ENV_GENERATOR_PATH', systemenvgeneratordir)
160conf.set_quoted('USER_ENV_GENERATOR_PATH', userenvgeneratordir)
161conf.set_quoted('SYSTEM_SHUTDOWN_PATH', systemshutdowndir)
162conf.set_quoted('SYSTEM_SLEEP_PATH', systemsleepdir)
163conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', pkgdatadir + '/kbd-model-map')
164conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', pkgdatadir + '/language-fallback-map')
165conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
166conf.set_quoted('POLKIT_AGENT_BINARY_PATH', bindir + '/pkttyagent')
167conf.set_quoted('LIBDIR', libdir)
168conf.set_quoted('ROOTLIBDIR', rootlibdir)
169conf.set_quoted('ROOTLIBEXECDIR', rootlibexecdir)
170conf.set_quoted('BOOTLIBDIR', bootlibdir)
171conf.set_quoted('SYSTEMD_PULL_PATH', rootlibexecdir + '/systemd-pull')
172conf.set_quoted('SYSTEMD_IMPORT_PATH', rootlibexecdir + '/systemd-import')
173conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir + '/systemd-export')
174conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir + '/import-pubring.gpg')
175conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir + '/import-pubring.gpg')
176conf.set_quoted('DOCUMENT_ROOT', pkgdatadir + '/gatewayd')
177
178conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
179conf.set_quoted('ABS_SRC_DIR', meson.source_root())
180
181substs.set('prefix', prefixdir)
182substs.set('pkgsysconfdir', pkgsysconfdir)
183substs.set('rootlibexecdir', rootlibexecdir)
184substs.set('systemunitdir', systemunitdir)
185substs.set('userunitdir', userunitdir)
186substs.set('systempresetdir', systempresetdir)
187substs.set('userpresetdir', userpresetdir)
188substs.set('udevhwdbdir', udevhwdbdir)
189substs.set('udevrulesdir', udevrulesdir)
190substs.set('catalogdir', catalogdir)
191substs.set('tmpfilesdir', tmpfilesdir)
192substs.set('sysusersdir', sysusersdir)
193substs.set('sysctldir', sysctldir)
194substs.set('binfmtdir', binfmtdir)
195substs.set('modulesloaddir', modulesloaddir)
196substs.set('systemgeneratordir', systemgeneratordir)
197substs.set('usergeneratordir', usergeneratordir)
198substs.set('systemenvgeneratordir', systemenvgeneratordir)
199substs.set('userenvgeneratordir', userenvgeneratordir)
200substs.set('systemshutdowndir', systemshutdowndir)
201substs.set('systemsleepdir', systemsleepdir)
202
203#####################################################################
204
205cc = meson.get_compiler('c')
206pkgconfig = import('pkgconfig')
207
208foreach arg : ['-Wundef',
209 '-Wlogical-op',
210 '-Wmissing-include-dirs',
211 '-Wold-style-definition',
212 '-Wpointer-arith',
213 '-Winit-self',
214 '-Wdeclaration-after-statement',
215 '-Wfloat-equal',
216 '-Wsuggest-attribute=noreturn',
217 '-Werror=missing-prototypes',
218 '-Werror=implicit-function-declaration',
219 '-Werror=missing-declarations',
220 '-Werror=return-type',
221 '-Werror=incompatible-pointer-types',
222 '-Werror=format=2',
223 '-Wstrict-prototypes',
224 '-Wredundant-decls',
225 '-Wmissing-noreturn',
226 '-Wshadow',
227 '-Wendif-labels',
228 '-Wstrict-aliasing=2',
229 '-Wwrite-strings',
230 '-Wno-unused-parameter',
231 '-Wno-missing-field-initializers',
232 '-Wno-unused-result',
233 '-Wno-format-signedness',
234 '-Werror=overflow',
235 '-Wdate-time',
236 '-Wnested-externs',
237 '-ffast-math',
238 '-fno-common',
239 '-fdiagnostics-show-option',
240 '-fno-strict-aliasing',
241 '-fvisibility=hidden',
242 '-fstack-protector',
243 '-fstack-protector-strong',
244 '-fPIE',
245 '--param=ssp-buffer-size=4',
246 ]
247 if cc.has_argument(arg)
248 add_project_arguments(arg, language : 'c')
249 endif
250endforeach
251
252if cc.compiles('
253 #include <time.h>
254 #include <inttypes.h>
255 typedef uint64_t usec_t;
256 usec_t now(clockid_t clock);
257 int main(void) {
258 struct timespec now;
259 return 0;
260 }
261')
262 # TODO: message?
263 add_project_arguments('-Werror=shadow', language : 'c')
264endif
265
266if cc.get_id() == 'clang'
267 foreach arg : ['-Wno-typedef-redefinition',
268 '-Wno-gnu-variable-sized-type-not-at-end',
269 ]
270 if cc.has_argument(arg)
271 add_project_arguments(arg, language : 'c')
272 endif
273 endforeach
274endif
275
276# --as-needed and --no-undefined are provided by meson by default,
277# run mesonconf to see what is enabled
278foreach arg : ['-Wl,-z,relro',
279 '-Wl,-z,now',
280 '-pie',
281 '-Wl,-fuse-ld=gold',
282 ]
283 if cc.has_argument(arg)
284 add_project_link_arguments(arg, language : 'c')
285 endif
286endforeach
287
288#####################################################################
289# compilation result tests
290
291conf.set('_GNU_SOURCE', 1)
292conf.set('__SANE_USERSPACE_TYPES__', 1)
293
294conf.set('SIZEOF_PID_T', cc.sizeof('pid_t', prefix : '#include <sys/types.h>'))
295conf.set('SIZEOF_UID_T', cc.sizeof('uid_t', prefix : '#include <sys/types.h>'))
296conf.set('SIZEOF_GID_T', cc.sizeof('gid_t', prefix : '#include <sys/types.h>'))
297conf.set('SIZEOF_DEV_T', cc.sizeof('dev_t', prefix : '#include <sys/types.h>'))
298conf.set('SIZEOF_INO_T', cc.sizeof('ino_t', prefix : '#include <sys/types.h>'))
299conf.set('SIZEOF_TIME_T', cc.sizeof('time_t', prefix : '#include <sys/time.h>'))
300conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h>'))
301
302decl_headers = '''
303#include <uchar.h>
304#include <linux/ethtool.h>
305'''
306# FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
307
308foreach decl : ['char16_t',
309 'char32_t',
310 'key_serial_t',
311 'struct ethtool_link_settings',
312 ]
313 if cc.sizeof(decl, prefix : decl_headers) > 0
314 # We get -1 if the size cannot be determined
315 conf.set('HAVE_' + decl.underscorify().to_upper(), 1)
316 endif
317endforeach
318
319foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
320 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
321 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
322 ['IFLA_MACVLAN_FLAGS', 'linux/if_link.h'],
323 ['IFLA_IPVLAN_MODE', 'linux/if_link.h'],
324 ['IFLA_PHYS_PORT_ID', 'linux/if_link.h'],
325 ['IFLA_BOND_AD_INFO', 'linux/if_link.h'],
326 ['IFLA_VLAN_PROTOCOL', 'linux/if_link.h'],
327 ['IFLA_VXLAN_REMCSUM_NOPARTIAL', 'linux/if_link.h'],
328 ['IFLA_VXLAN_GPE', 'linux/if_link.h'],
329 # if_tunnel.h is buggy and cannot be included on its own
330 ['IFLA_VTI_REMOTE', 'linux/if_tunnel.h', '#include <net/if.h>'],
331 ['IFLA_IPTUN_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
332 ['IFLA_GRE_ENCAP_DPORT', 'linux/if_tunnel.h', '#include <net/if.h>'],
333 ['IFLA_BRIDGE_VLAN_INFO', 'linux/if_bridge.h'],
334 ['IFLA_BRPORT_PROXYARP', 'linux/if_link.h'],
335 ['IFLA_BRPORT_LEARNING_SYNC', 'linux/if_link.h'],
336 ['IFLA_BR_VLAN_DEFAULT_PVID', 'linux/if_link.h'],
337 ['NDA_IFINDEX', 'linux/neighbour.h'],
338 ['IFA_FLAGS', 'linux/if_addr.h'],
339 ['LO_FLAGS_PARTSCAN', 'linux/loop.h'],
340 ]
341 prefix = decl.length() > 2 ? decl[2] : ''
342 have = cc.has_header_symbol(decl[1], decl[0], prefix : prefix)
343 conf.set10('HAVE_DECL_' + decl[0], have)
344endforeach
345
346skip = false
347foreach ident : ['secure_getenv', '__secure_getenv']
348 if not skip and cc.has_function(ident)
349 conf.set('HAVE_' + ident.to_upper(), 1)
350 skip = true
351 endif
352endforeach
353
354foreach ident : [
355 ['memfd_create', '''#include <sys/memfd.h>'''],
356 ['gettid', '''#include <sys/types.h>'''],
357 ['pivot_root', '''#include <stdlib.h>'''], # no known header declares pivot_root
358 ['name_to_handle_at', '''#define _GNU_SOURCE
359 #include <sys/types.h>
360 #include <sys/stat.h>
361 #include <fcntl.h>'''],
362 ['setns', '''#define _GNU_SOURCE
363 #include <sched.h>'''],
364 ['getrandom', '''#include <sys/random.h>'''],
365 ['renameat2', '''#include <stdio.h>'''],
366 ['kcmp', '''#include <linux/kcmp.h>'''],
367 ['keyctl', '''#include <sys/types.h>
368 #include <keyutils.h>'''],
369 ['copy_file_range', '''#include <sys/syscall.h>
370 #include <unistd.h>'''],
371 ['explicit_bzero' , '''#include <strings.h>'''],
372 ]
373
374 have = cc.has_function(ident[0], prefix : ident[1])
375 conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
376endforeach
377
378#####################################################################
379
380sed = find_program('sed')
381grep = find_program('grep')
382awk = find_program('awk')
78b68dcb 383m4 = find_program('/usr/bin/m4')
5c23128d 384stat = find_program('stat')
d68b342b
ZJS
385git = find_program('git', required : false)
386etags = find_program('etags', required : false)
5c23128d 387
7b76fce1 388meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
94e75a54
ZJS
389mkdir_p = 'mkdir -p $DESTDIR/@0@'
390
5c23128d
ZJS
391# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
392# /usr/sbin, /sbin, and fall back to the default from middle column.
393progs = [['telinit', '/lib/sysvinit/telinit'],
394 ['quotaon', '/usr/sbin/quotaon' ],
395 ['quotacheck', '/usr/sbin/quotacheck' ],
396 ['kill', '/usr/bin/kill' ],
397 ['kmod', '/usr/bin/kmod' ],
398 ['kexec', '/usr/sbin/kexec' ],
399 ['sulogin', '/usr/sbin/sulogin' ],
400 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
401 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
402 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
403 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
404 ]
405foreach prog : progs
406 path = get_option(prog[0] + '-path')
407 if path != ''
408 message('Using @1@ for @0@'.format(prog[0], path))
409 else
410 exe = find_program(prog[0], '/usr/sbin/' + prog[0], '/sbin/' + prog[0], required: false)
411 path = exe.found() ? exe.path() : prog[1]
412 endif
413 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
414 conf.set_quoted(name, path)
415endforeach
416
417# TODO: add ln --relative check
418# AS_IF([! ln --relative --help > /dev/null 2>&1], [AC_MSG_ERROR([*** ln doesn't support --relative ***])])
419
420############################################################
421
422gperf = find_program('gperf')
423
424gperf_test_format = '''
425#include <string.h>
426const char * in_word_set(const char *, @0@);
427@1@
428'''
429gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
430gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
431gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
432if cc.compiles(gperf_test)
433 gperf_len_type = 'size_t'
434else
435 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
436 if cc.compiles(gperf_test)
437 gperf_len_type = 'unsigned'
438 else
439 error('unable to determine gperf len type')
440 endif
441endif
442message('gperf len type is @0@'.format(gperf_len_type))
443conf.set('GPERF_LEN_TYPE', gperf_len_type, description : 'The type of gperf "len" parameter')
444
445############################################################
446
447if not cc.has_header('sys/capability.h')
448 error('POSIX caps headers not found')
449endif
450foreach header : ['linux/btrfs.h',
451 'linux/memfd.h',
452 'linux/vm_sockets.h',
453 'valgrind/memcheck.h',
454 'valgrind/valgrind.h',
455 ]
456 if cc.has_header(header)
457 conf.set('HAVE_' + header.underscorify().to_upper(), 1)
458 endif
459endforeach
460
461############################################################
462
463conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
464
465default_hierarchy = get_option('default-hierarchy')
466conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
467 description : 'default cgroup hierarchy as string')
468if default_hierarchy == 'legacy'
469 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
470elif default_hierarchy == 'hybrid'
471 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
472else
473 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
474endif
475
476time_epoch = get_option('time-epoch')
477if time_epoch == ''
478 NEWS = files('NEWS')
479 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
480endif
481time_epoch = time_epoch.to_int()
482conf.set('TIME_EPOCH', time_epoch)
483
484system_uid_max = get_option('system-uid-max')
485if system_uid_max == ''
486 system_uid_max = run_command(
487 awk,
488 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
489 '/etc/login.defs').stdout()
490endif
491system_uid_max = system_uid_max.to_int()
492conf.set('SYSTEM_UID_MAX', system_uid_max)
493substs.set('systemuidmax', system_uid_max)
494message('Maximum system UID is @0@'.format(system_uid_max))
495
496conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
497conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
498
499system_gid_max = get_option('system-gid-max')
500if system_gid_max == ''
501 system_gid_max = run_command(
502 awk,
503 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
504 '/etc/login.defs').stdout()
505endif
506system_gid_max = system_gid_max.to_int()
507conf.set('SYSTEM_GID_MAX', system_gid_max)
508substs.set('systemgidmax', system_gid_max)
509message('Maximum system GID is @0@'.format(system_gid_max))
510
511tty_gid = get_option('tty-gid')
512conf.set('TTY_GID', tty_gid)
513m4_defines += ['-DTTY_GID=' + tty_gid]
514
515if get_option('adm-group')
516 m4_defines += ['-DENABLE_ADM_GROUP']
517endif
518
519if get_option('wheel-group')
520 m4_defines += ['-DENABLE_WHEEL_GROUP']
521endif
522
523substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
524
525conf.set10('KILL_USER_PROCESSES', get_option('default-kill-user-processes'))
526
527default_dnssec = get_option('default-dnssec')
528conf.set('DEFAULT_DNSSEC_MODE',
529 'DNSSEC_' + default_dnssec.underscorify().to_upper())
530
531conf.set_quoted('DNS_SERVERS', get_option('dns-servers'))
532
533conf.set_quoted('NTP_SERVERS', get_option('ntp-servers'))
534
535conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
536
537#####################################################################
538
539threads = dependency('threads')
540librt = cc.find_library('rt')
541libm = cc.find_library('m')
542libdl = cc.find_library('dl')
543libcrypt = cc.find_library('crypt')
544
545libcap = dependency('libcap')
546libmount = dependency('mount',
547 version : '>= 2.27')
548
549want_seccomp = get_option('seccomp')
550if want_seccomp != 'no'
551 libseccomp = dependency('libseccomp',
552 required : want_seccomp == 'yes')
553 if libseccomp.found()
554 conf.set('HAVE_SECCOMP', 1)
555 m4_defines += ['-DHAVE_SECCOMP']
556 endif
557else
558 libseccomp = []
559endif
560
561want_selinux = get_option('selinux')
562if want_selinux != 'no'
563 libselinux = dependency('libselinux',
564 version : '>= 2.1.9',
565 required : want_selinux == 'yes')
566 if libselinux.found()
567 conf.set('HAVE_SELINUX', 1)
568 m4_defines += ['-DHAVE_SELINUX']
569 endif
570else
571 libselinux = []
572endif
573
574want_apparmor = get_option('apparmor')
575if want_apparmor != 'no'
576 libapparmor = dependency('libapparmor',
577 required : want_apparmor == 'yes')
578 if libapparmor.found()
579 conf.set('HAVE_APPARMOR', 1)
580 m4_defines += ['-DHAVE_APPARMOR']
581 endif
582else
583 libapparmor = []
584endif
585
586want_smack = get_option('smack')
587if want_smack != 'no'
588 libsmack = dependency('libsmack',
589 required : want_smack == 'yes')
590 if libsmack.found()
591 conf.set('HAVE_SMACK', 1)
592 m4_defines += ['-DHAVE_SMACK']
593 endif
594else
595 libsmack = []
596endif
597
598smack_run_label = get_option('smack-run-label')
599if smack_run_label != ''
600 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
601 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
602endif
603
604want_audit = get_option('audit')
605if want_audit != 'no'
606 libaudit = dependency('audit', required : want_audit == 'yes')
607 if libaudit.found()
608 conf.set('HAVE_AUDIT', 1)
609 endif
610else
611 libaudit = []
612endif
613
614want_blkid = get_option('blkid')
615if want_blkid != 'no'
616 libblkid = dependency('blkid', required : want_blkid == 'yes')
617 if libblkid.found()
618 conf.set('HAVE_BLKID', 1)
619 endif
620else
621 libblkid = []
622endif
623
624want_kmod = get_option('kmod')
625if want_kmod != 'no'
626 libkmod = dependency('libkmod',
627 version : '>= 15',
628 required : want_kmod == 'yes')
629 if libkmod.found()
630 conf.set('HAVE_KMOD', 1)
631 endif
632else
633 libkmod = []
634endif
635
636want_pam = get_option('pam')
637if want_pam != 'no'
638 libpam = cc.find_library('pam', required : want_pam == 'yes')
639 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'yes')
640 if libpam.found() and libpam_misc.found()
641 conf.set('HAVE_PAM', 1)
642 m4_defines += ['-DHAVE_PAM']
643 endif
644else
645 libpam = []
646 libpam_misc = []
647endif
648
649want_microhttpd = get_option('microhttpd')
650if want_microhttpd != 'no'
651 libmicrohttpd = dependency('libmicrohttpd',
652 version : '>= 0.9.33',
653 required : want_microhttpd == 'yes')
654 if libmicrohttpd.found()
655 conf.set('HAVE_MICROHTTPD', 1)
656 m4_defines += ['-DHAVE_MICROHTTPD']
657 endif
658else
659 libmicrohttpd = []
660endif
661
662want_libcryptsetup = get_option('libcryptsetup')
663if want_libcryptsetup != 'no'
664 libcryptsetup = dependency('libcryptsetup',
665 version : '>= 1.6.0',
666 required : want_libcryptsetup == 'yes')
667 if libcryptsetup.found()
668 conf.set('HAVE_LIBCRYPTSETUP', 1)
669 endif
670else
671 libcryptsetup = []
672endif
673
674want_libcurl = get_option('libcurl')
675if want_libcurl != 'no'
676 libcurl = dependency('libcurl',
677 version : '>= 7.32.0',
678 required : want_libcurl == 'yes')
679 if libcurl.found()
680 conf.set('HAVE_LIBCURL', 1)
681 m4_defines += ['-DHAVE_LIBCURL']
682 endif
683else
684 libcurl = []
685endif
686
687want_libidn = get_option('libidn')
688if want_libidn != 'no'
689 libidn = dependency('libidn',
690 required : want_libidn == 'yes')
691 if libidn.found()
692 conf.set('HAVE_LIBIDN', 1)
693 m4_defines += ['-DHAVE_LIBIDN']
694 endif
695else
696 libidn = []
697endif
698
699want_libiptc = get_option('libiptc')
700if want_libiptc != 'no'
701 libiptc = dependency('libiptc',
702 required : want_libiptc == 'yes')
703 if libiptc.found()
704 conf.set('HAVE_LIBIPTC', 1)
705 m4_defines += ['-DHAVE_LIBIPTC']
706 endif
707else
708 libiptc = []
709endif
710
711want_qrencode = get_option('qrencode')
712if want_qrencode != 'no'
713 libqrencode = dependency('libqrencode',
714 required : want_qrencode == 'yes')
715 if libqrencode.found()
716 conf.set('HAVE_QRENCODE', 1)
717 endif
718else
719 libqrencode = []
720endif
721
722want_gnutls = get_option('gnutls')
723if want_gnutls != 'no'
724 libgnutls = dependency('gnutls',
725 version : '>= 3.1.4',
726 required : want_gnutls == 'yes')
727 if libgnutls.found()
728 conf.set('HAVE_GNUTLS', 1)
729 endif
730else
731 libgnutls = []
732endif
733
734want_elfutils = get_option('elfutils')
735if want_elfutils != 'no'
736 libdw = dependency('libdw',
737 required : want_elfutils == 'yes')
738 if libdw.found()
739 conf.set('HAVE_ELFUTILS', 1)
740 endif
741else
742 libdw = []
743endif
744
745want_zlib = get_option('zlib')
746if want_zlib != 'no'
747 libz = dependency('zlib',
748 required : want_zlib == 'yes')
749 if libz.found()
750 conf.set('HAVE_ZLIB', 1)
751 endif
752else
753 libz = []
754endif
755
756want_bzip2 = get_option('bzip2')
757if want_bzip2 != 'no'
758 libbzip2 = cc.find_library('bz2',
759 required : want_bzip2 == 'yes')
760 if libbzip2.found()
761 conf.set('HAVE_BZIP2', 1)
762 endif
763else
764 libbzip2 = []
765endif
766
767want_xz = get_option('xz')
768if want_xz != 'no'
769 libxz = dependency('liblzma',
770 required : want_xz == 'yes')
771 if libxz.found()
772 conf.set('HAVE_XZ', 1)
773 endif
774else
775 libxz = []
776endif
777
778want_lz4 = get_option('lz4')
779if want_lz4 != 'no'
780 liblz4 = dependency('liblz4',
781 required : want_lz4 == 'yes')
782 if liblz4.found()
783 conf.set('HAVE_LZ4', 1)
784 endif
785else
786 liblz4 = []
787endif
788
789libacl = cc.find_library('acl', required : false)
790if libacl.found()
791 conf.set('HAVE_ACL', 1)
792 m4_defines += ['-DHAVE_ACL']
793endif
794
69e96427
ZJS
795want_glib = get_option('glib')
796if want_glib != 'no'
797 libglib = dependency('glib-2.0',
798 version : '>= 2.22.0',
799 required : want_glib == 'yes')
800 libgobject = dependency('gobject-2.0',
801 version : '>= 2.22.0',
802 required : want_glib == 'yes')
803 libgio = dependency('gio-2.0',
804 required : want_glib == 'yes')
805 if libglib.found() and libgobject.found() and libgio.found()
806 conf.set('HAVE_GLIB', 1)
807 endif
808else
809 libglib = []
810 libgobject = []
811 libgio = []
812endif
813
814want_dbus = get_option('dbus')
815if want_dbus != 'no'
816 libdbus = dependency('dbus-1',
817 version : '>= 1.3.2',
818 required : want_dbus == 'yes')
819 if libdbus.found()
820 conf.set('HAVE_DBUS', 1)
821 endif
822else
823 libdbus = []
824endif
825
5c23128d
ZJS
826want_libgcrypt = get_option('libgcrypt')
827if want_libgcrypt != 'no'
828 libgcrypt = cc.find_library('gcrypt', required : want_libgcrypt == 'yes')
829 if libgcrypt.found()
830 conf.set('HAVE_LIBGCRYPT', 1)
831 endif
832else
833 libgcrypt = []
834endif
835
836want_importd = get_option('importd')
837if want_importd != 'no'
838 have_deps = (conf.get('HAVE_LIBCURL', 0) == 1 and
839 conf.get('HAVE_ZLIB', 0) == 1 and
840 conf.get('HAVE_BZIP2', 0) == 1 and
841 conf.get('HAVE_XZ', 0) == 1 and
842 conf.get('HAVE_LZ4', 0) == 1)
843 if have_deps
844 conf.set('ENABLE_IMPORTD', 1)
845 elif want_importd == 'yes'
846 error('importd support was requested, but dependencies are not available')
847 endif
848endif
849
850want_remote = get_option('remote')
851if want_remote != 'no'
852 have_deps = [conf.get('HAVE_MICROHTTPD', 0) == 1,
853 conf.get('HAVE_LIBCURL', 0) == 1]
854 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
855 # it's possible to build one without the other. Complain only if
856 # support was explictly requested. The auxiliary files like sysusers
857 # config should be installed when any of the programs are built.
858 if want_remote == 'yes' and not (have_deps[0] and have_deps[1])
859 error('remote support was requested, but dependencies are not available')
860 endif
861 if have_deps[0] or have_deps[1]
862 conf.set('ENABLE_REMOTE', 1)
863 endif
864endif
865
866foreach pair : [['utmp', 'HAVE_UTMP'],
867 ['hibernate', 'ENABLE_HIBERNATE'],
868 ['environment-d', 'ENABLE_ENVIRONMENT_D'],
869 ['binfmt', 'ENABLE_BINFMT'],
870 ['coredump', 'ENABLE_COREDUMP'],
871 ['resolve', 'ENABLE_RESOLVED'],
872 ['logind', 'ENABLE_LOGIND'],
873 ['hostnamed', 'ENABLE_HOSTNAMED'],
874 ['localed', 'ENABLE_LOCALED'],
875 ['machined', 'ENABLE_MACHINED'],
876 ['networkd', 'ENABLE_NETWORKD'],
877 ['timedated', 'ENABLE_TIMEDATED'],
878 ['timesyncd', 'ENABLE_TIMESYNCD'],
879 ['myhostname', 'HAVE_MYHOSTNAME'],
880 ['firstboot', 'ENABLE_FIRSTBOOT'],
881 ['randomseed', 'ENABLE_RANDOMSEED'],
882 ['backlight', 'ENABLE_BACKLIGHT'],
883 ['vconsole', 'ENABLE_VCONSOLE'],
884 ['quotacheck', 'ENABLE_QUOTACHECK'],
885 ['sysusers', 'ENABLE_SYSUSERS'],
886 ['tmpfiles', 'ENABLE_TMPFILES'],
887 ['hwdb', 'ENABLE_HWDB'],
888 ['rfkill', 'ENABLE_RFKILL'],
889 ['ldconfig', 'ENABLE_LDCONFIG'],
890 ]
891
892 if get_option(pair[0])
893 conf.set(pair[1], 1)
894 endif
895endforeach
896
69e96427 897want_tests = get_option('tests')
572baca1 898install_tests = get_option('install-tests')
69e96427
ZJS
899tests = []
900
5c23128d
ZJS
901#####################################################################
902
903if get_option('efi')
904 efi_arch = host_machine.cpu_family() # TODO: check this works at all
905 if efi_arch == 'ia32'
906 EFI_MACHINE_TYPE_NAME = 'ia32'
907 elif efi_arch == 'x86_64'
908 EFI_MACHINE_TYPE_NAME = 'x64'
909 elif efi_arch == 'aarch64'
910 EFI_MACHINE_TYPE_NAME = 'x64'
911 else
912 EFI_MACHINE_TYPE_NAME = efi_arch
913 endif
914
915 conf.set('ENABLE_EFI', 1)
916 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
917endif
918
919#####################################################################
920
921config_h = configure_file(
922 output : 'config.h',
923 configuration : conf)
924
925includes = include_directories('src/basic',
926 'src/shared',
927 'src/systemd',
928 'src/journal',
929 'src/resolve',
930 'src/timesync',
931 'src/login',
932 'src/udev',
933 'src/libudev',
934 'src/core',
935 'src/libsystemd/sd-bus',
936 'src/libsystemd/sd-device',
937 'src/libsystemd/sd-hwdb',
938 'src/libsystemd/sd-id128',
939 'src/libsystemd/sd-netlink',
940 'src/libsystemd/sd-network',
941 'src/libsystemd-network',
942 )
943
944add_project_arguments('-include', 'config.h', language : 'c')
945
946gcrypt_util_sources = files('src/shared/gcrypt-util.h',
947 'src/shared/gcrypt-util.c')
948
949subdir('po')
950subdir('catalog')
951subdir('src/systemd')
952subdir('src/basic')
953subdir('src/libsystemd')
954subdir('src/libsystemd-network')
5c23128d 955subdir('src/journal')
5c23128d 956subdir('src/login')
5c23128d
ZJS
957
958libjournal_core = static_library(
959 'journal-core',
960 libjournal_core_sources,
961 journald_gperf_c,
962 include_directories : includes,
963 link_with : [libbasic,
964 libsystemd_internal,
965 libsystemd_journal_internal],
966 install : false)
967
6b30f280 968version_script_arg = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d
ZJS
969libsystemd = shared_library(
970 'systemd',
971 libsystemd_internal_sources,
972 version : '0.18.0',
973 include_directories : includes,
974 link_args : ['-shared',
6b30f280 975 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
976 link_with : [libbasic,
977 libsystemd_internal,
978 libsystemd_journal_internal],
979 dependencies : [threads],
6b30f280 980 link_depends : libsystemd_sym,
5c23128d
ZJS
981 install : true,
982 install_dir : rootlibdir)
983
984############################################################
985
986foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME', []],
987 ['systemd', '', []],
988 ['mymachines', 'ENABLE_MACHINED', []],
989 ['resolve', 'ENABLE_RESOLVED', [libdl]]]
990
991 condition = tuple[1] == '' or conf.get(tuple[1], 0) == 1
992 if condition
993 module = tuple[0]
994 extra_deps = tuple[2]
995
6b30f280
ZJS
996 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
997 version_script_arg = join_paths(meson.current_source_dir(), sym)
5c23128d
ZJS
998
999 shared_library(
1000 'nss_' + module,
1001 'src/nss-@0@/nss-@0@.c'.format(module),
1002 version : '2',
1003 include_directories : includes,
1004 link_args : ['-shared',
6b30f280 1005 '-Wl,--version-script=' + version_script_arg,
5c23128d
ZJS
1006 '-Wl,--undefined'],
1007 link_with : [libsystemd_internal,
1008 libbasic],
1009 dependencies : [threads,
1010 librt] + extra_deps,
6b30f280 1011 link_depends : sym,
5c23128d
ZJS
1012 install : true,
1013 install_dir : rootlibdir)
d7148676
ZJS
1014
1015 # We cannot use shared_module because it does not support version suffix.
1016 # Unfortunately shared_library insists on creating the symlink…
1017 meson.add_install_script('sh', '-c',
1018 'rm $DESTDIR@0@/libnss_@1@.so'
1019 .format(rootlibdir, module))
5c23128d
ZJS
1020 endif
1021endforeach
1022
1023############################################################
1024
1025subdir('src/libudev')
1026subdir('src/shared')
1027subdir('src/core')
1028subdir('src/udev')
1029subdir('src/network')
1030
69e96427
ZJS
1031subdir('src/analyze')
1032subdir('src/journal-remote')
1033subdir('src/coredump')
1034subdir('src/hostname')
1035subdir('src/import')
1036subdir('src/kernel-install')
1037subdir('src/locale')
1038subdir('src/machine')
1039subdir('src/nspawn')
1040subdir('src/resolve')
1041subdir('src/timedate')
1042subdir('src/timesync')
1043subdir('src/vconsole')
1044
1045subdir('src/test')
1046
5c23128d
ZJS
1047executable('systemd',
1048 systemd_sources,
1049 include_directories : includes,
1050 link_with : [libcore,
1051 libshared],
1052 dependencies : [threads,
1053 librt,
1054 libseccomp,
1055 libselinux,
f4ee10a2
ZJS
1056 libmount,
1057 libblkid],
5c23128d
ZJS
1058 install : true,
1059 install_dir : rootlibexecdir)
1060
1061executable('systemd-analyze',
1062 systemd_analyze_sources,
1063 include_directories : includes,
1064 link_with : [libcore,
1065 libshared],
1066 dependencies : [threads,
1067 librt,
1068 libseccomp,
1069 libselinux,
f4ee10a2
ZJS
1070 libmount,
1071 libblkid],
5c23128d
ZJS
1072 install : true)
1073
1074executable('systemd-journald',
1075 systemd_journald_sources,
1076 include_directories : includes,
1077 link_with : [libsystemd_journal_internal,
1078 libjournal_core,
1079 libshared,
1080 libudev],
1081 dependencies : [threads,
1082 libxz,
1083 liblz4],
1084 install : true,
1085 install_dir : rootlibexecdir)
1086
1087executable('systemd-cat',
1088 systemd_cat_sources,
1089 include_directories : includes,
1090 link_with : [libjournal_core,
1091 libshared,
1092 libudev],
1093 dependencies : [threads],
1094 install : true)
1095
1096executable('journalctl',
1097 journalctl_sources,
1098 include_directories : includes,
1099 link_with : [libshared,
1100 libudev],
1101 dependencies : [threads,
1102 libqrencode,
1103 libxz,
1104 liblz4],
1105 install : true,
1106 install_dir : rootbindir)
1107
1108executable('systemd-getty-generator',
1109 'src/getty-generator/getty-generator.c',
1110 install : true,
1111 install_dir : systemgeneratordir,
1112 include_directories : includes,
1113 link_with : [libshared])
1114
1115executable('systemd-debug-generator',
1116 'src/debug-generator/debug-generator.c',
1117 install : true,
1118 install_dir : systemgeneratordir,
1119 include_directories : includes,
1120 link_with : [libshared])
1121
1122executable('systemd-fstab-generator',
1123 'src/fstab-generator/fstab-generator.c',
1124 'src/core/mount-setup.c',
1125 install : true,
1126 install_dir : systemgeneratordir,
1127 include_directories : includes,
1128 link_with : [libshared])
1129
1130if conf.get('ENABLE_ENVIRONMENT_D', 0) == 1
1131 executable('30-systemd-environment-d-generator',
1132 'src/environment-d-generator/environment-d-generator.c',
1133 install : true,
1134 install_dir : userenvgeneratordir,
1135 include_directories : includes,
1136 link_with : [libshared])
7b76fce1
ZJS
1137
1138 meson.add_install_script(meson_make_symlink,
1139 sysconfdir + '/environment',
1140 environmentdir + '/99-environment.conf')
5c23128d
ZJS
1141endif
1142
1143if conf.get('ENABLE_HIBERNATE', 0) == 1
1144 executable('systemd-hibernate-resume-generator',
1145 'src/hibernate-resume/hibernate-resume-generator.c',
1146 include_directories : includes,
1147 link_with : [libshared],
1148 install : true,
1149 install_dir : systemgeneratordir)
1150
1151 executable('systemd-hibernate-resume',
1152 'src/hibernate-resume/hibernate-resume.c',
1153 include_directories : includes,
1154 link_with : [libshared],
1155 install : true,
1156 install_dir : rootlibexecdir)
1157endif
1158
1159if conf.get('HAVE_BLKID', 0) == 1
1160 executable('systemd-gpt-auto-generator',
1161 'src/gpt-auto-generator/gpt-auto-generator.c',
1162 'src/basic/blkid-util.h',
1163 install : true,
1164 install_dir : systemgeneratordir,
1165 include_directories : includes,
1166 link_with : libshared,
1167 dependencies : libblkid)
1168
1169 executable('systemd-dissect',
1170 'src/dissect/dissect.c',
1171 include_directories : includes,
1172 link_with : [libshared],
1173 install : true,
1174 install_dir : rootlibexecdir)
1175endif
1176
1177if conf.get('ENABLE_RESOLVED', 0) == 1
1178 executable('systemd-resolved',
1179 systemd_resolved_sources,
1180 include_directories : includes,
1181 link_with : [libshared,
1182 ],
1183 dependencies : [threads,
1184 libm,
1185 libidn],
1186 install : true,
1187 install_dir : rootlibexecdir)
1188
1189 executable('systemd-resolve',
1190 systemd_resolve_sources,
1191 include_directories : includes,
1192 link_with : [libshared,
1193 ],
1194 dependencies : [threads,
1195 libm,
1196 libidn],
1197 install : true)
1198endif
1199
1200if conf.get('ENABLE_LOGIND', 0) == 1
1201 executable('systemd-logind',
1202 systemd_logind_sources,
1203 include_directories : includes,
1204 link_with : [liblogind_core,
1205 libshared],
1206 dependencies : [threads,
1207 libacl],
1208 install : true,
1209 install_dir : rootlibexecdir)
1210
1211 executable('loginctl',
1212 loginctl_sources,
1213 include_directories : includes,
1214 link_with : [libshared],
1215 dependencies : [threads,
1216 liblz4,
1217 libxz],
1218 install : true,
1219 install_dir : rootbindir)
1220
1221 executable('systemd-inhibit',
1222 'src/login/inhibit.c',
1223 include_directories : includes,
1224 link_with : [libshared],
1225 install : true,
1226 install_dir : rootbindir)
1227
1228 if conf.get('HAVE_PAM', 0) == 1
6b30f280 1229 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
5c23128d
ZJS
1230 shared_library(
1231 'pam_systemd',
1232 pam_systemd_c,
1233 name_prefix : '',
1234 include_directories : includes,
1235 link_args : ['-shared',
6b30f280 1236 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
1237 link_with : [libshared],
1238 dependencies : [libpam,
1239 libpam_misc],
6b30f280 1240 link_depends : pam_systemd_sym,
5c23128d
ZJS
1241 install : true,
1242 install_dir : pamlibdir)
1243 endif
1244endif
1245
1246if conf.get('HAVE_PAM', 0) == 1
1247 executable('systemd-user-sessions',
1248 'src/user-sessions/user-sessions.c',
1249 include_directories : includes,
1250 link_with : [libshared],
1251 install : true,
1252 install_dir : rootlibexecdir)
1253endif
1254
1255if conf.get('ENABLE_EFI', 0) == 1
1256 executable('bootctl',
1257 'src/boot/bootctl.c',
1258 include_directories : includes,
1259 link_with : [libshared],
1260 dependencies : [libblkid],
1261 install : true)
1262endif
1263
1264executable('systemd-socket-activate', 'src/activate/activate.c',
1265 include_directories : includes,
1266 link_with : [libshared],
1267 dependencies : [threads],
1268 install : true)
1269
1270executable('systemctl', 'src/systemctl/systemctl.c',
1271 include_directories : includes,
1272 link_with : [libshared],
1273 dependencies : [threads,
1274 libcap,
1275 libselinux,
1276 libxz,
1277 liblz4],
1278 install : true,
1279 install_dir : rootbindir)
1280
1281if conf.get('ENABLE_BACKLIGHT', 0) == 1
1282 executable('systemd-backlight',
1283 'src/backlight/backlight.c',
1284 include_directories : includes,
1285 link_with : [libshared],
1286 install : true,
1287 install_dir : rootlibexecdir)
1288endif
1289
1290if conf.get('ENABLE_RFKILL', 0) == 1
1291 executable('systemd-rfkill',
1292 'src/rfkill/rfkill.c',
1293 include_directories : includes,
1294 link_with : [libshared],
1295 install : true,
1296 install_dir : rootlibexecdir)
1297endif
1298
1299executable('systemd-system-update-generator',
1300 'src/system-update-generator/system-update-generator.c',
1301 include_directories : includes,
1302 link_with : [libshared],
1303 install : true,
1304 install_dir : systemgeneratordir)
1305
1306if conf.get('HAVE_LIBCRYPTSETUP', 0) == 1
1307 executable('systemd-cryptsetup',
1308 'src/cryptsetup/cryptsetup.c',
1309 include_directories : includes,
1310 link_with : [libshared],
1311 dependencies : [libcryptsetup],
1312 install : true,
1313 install_dir : rootlibexecdir)
1314
1315 executable('systemd-cryptsetup-generator',
1316 'src/cryptsetup/cryptsetup-generator.c',
1317 include_directories : includes,
1318 link_with : [libshared],
1319 dependencies : [libcryptsetup],
1320 install : true,
1321 install_dir : systemgeneratordir)
1322
1323 executable('systemd-veritysetup',
1324 'src/veritysetup/veritysetup.c',
1325 include_directories : includes,
1326 link_with : [libshared],
1327 dependencies : [libcryptsetup],
1328 install : true,
1329 install_dir : rootlibexecdir)
1330
1331 executable('systemd-veritysetup-generator',
1332 'src/veritysetup/veritysetup-generator.c',
1333 include_directories : includes,
1334 link_with : [libshared],
1335 dependencies : [libcryptsetup],
1336 install : true,
1337 install_dir : systemgeneratordir)
1338endif
1339
1340if conf.get('HAVE_SYSV_COMPAT', 0) == 1
1341 executable('systemd-sysv-generator',
1342 'src/sysv-generator/sysv-generator.c',
1343 include_directories : includes,
1344 link_with : [libshared],
1345 install : true,
1346 install_dir : systemgeneratordir)
1347
1348 executable('systemd-rc-local-generator',
1349 'src/rc-local-generator/rc-local-generator.c',
1350 include_directories : includes,
1351 link_with : [libshared],
1352 install : true,
1353 install_dir : systemgeneratordir)
1354endif
1355
1356if conf.get('ENABLE_HOSTNAMED', 0) == 1
1357 executable('systemd-hostnamed',
1358 'src/hostname/hostnamed.c',
1359 include_directories : includes,
1360 link_with : [libshared],
1361 install : true,
1362 install_dir : rootlibexecdir)
1363
1364 executable('hostnamectl',
1365 'src/hostname/hostnamectl.c',
1366 include_directories : includes,
1367 link_with : [libshared],
1368 install : true)
1369endif
1370
1371if conf.get('ENABLE_LOCALED', 0) == 1
1372 executable('systemd-localed',
1373 systemd_localed_sources,
1374 include_directories : includes,
1375 link_with : [libshared],
1376 dependencies : [libdl],
1377 install : true,
1378 install_dir : rootlibexecdir)
1379
1380 executable('localectl',
1381 localectl_sources,
1382 include_directories : includes,
1383 link_with : [libshared],
1384 install : true)
1385endif
1386
1387if conf.get('ENABLE_TIMEDATED', 0) == 1
1388 executable('systemd-timedated',
1389 'src/timedate/timedated.c',
1390 include_directories : includes,
1391 link_with : [libshared],
1392 install : true,
1393 install_dir : rootlibexecdir)
1394
1395 executable('timedatectl',
1396 'src/timedate/timedatectl.c',
1397 include_directories : includes,
1398 link_with : [libshared],
1399 install : true)
1400endif
1401
1402if conf.get('ENABLE_TIMESYNCD', 0) == 1
1403 executable('systemd-timesyncd',
1404 systemd_timesyncd_sources,
1405 include_directories : includes,
1406 link_with : [libshared],
1407 dependencies : [threads,
1408 libm],
1409 install : true,
1410 install_dir : rootlibexecdir)
1411endif
1412
1413if conf.get('ENABLE_MACHINED', 0) == 1
1414 executable('systemd-machined',
1415 systemd_machined_sources,
1416 include_directories : includes,
1417 link_with : [libmachine_core,
1418 libshared],
1419 install : true,
1420 install_dir : rootlibexecdir)
1421
1422 executable('machinectl',
1423 'src/machine/machinectl.c',
1424 include_directories : includes,
1425 link_with : [libshared],
1426 dependencies : [threads,
1427 libxz,
1428 liblz4],
1429 install : true,
1430 install_dir : rootbindir)
1431endif
1432
1433if conf.get('ENABLE_IMPORTD', 0) == 1
1434 executable('systemd-importd',
1435 systemd_importd_sources,
1436 include_directories : includes,
1437 link_with : [libshared],
1438 install : true,
1439 install_dir : rootlibexecdir)
1440
1441 executable('systemd-pull',
1442 systemd_pull_sources,
1443 include_directories : includes,
1444 link_with : [libshared],
1445 dependencies : [libcurl,
1446 libz,
1447 libbzip2,
1448 libxz,
1449 libgcrypt],
1450 install : true,
1451 install_dir : rootlibexecdir)
1452
1453 executable('systemd-import',
1454 systemd_import_sources,
1455 include_directories : includes,
1456 link_with : [libshared],
1457 dependencies : [libcurl,
1458 libz,
1459 libbzip2,
1460 libxz],
1461 install : true,
1462 install_dir : rootlibexecdir)
1463
1464 executable('systemd-export',
1465 systemd_export_sources,
1466 include_directories : includes,
1467 link_with : [libshared],
1468 dependencies : [libcurl,
1469 libz,
1470 libbzip2,
1471 libxz],
1472 install : true,
1473 install_dir : rootlibexecdir)
1474endif
1475
1476if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_LIBCURL', 0) == 1
1477 executable('systemd-journal-upload',
1478 systemd_journal_upload_sources,
1479 include_directories : includes,
1480 link_with : [libshared],
1481 dependencies : [threads,
1482 libcurl,
1483 libgnutls,
1484 libxz,
1485 liblz4],
1486 install : true,
1487 install_dir : rootlibexecdir)
1488endif
1489
1490if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_MICROHTTPD', 0) == 1
1491 executable('systemd-journal-remote',
1492 systemd_journal_remote_sources,
1493 include_directories : includes,
1494 link_with : [libshared],
1495 dependencies : [threads,
1496 libmicrohttpd,
1497 libgnutls,
1498 libxz,
1499 liblz4],
1500 install : true,
1501 install_dir : rootlibexecdir)
1502
1503 executable('systemd-journal-gatewayd',
1504 systemd_journal_gatewayd_sources,
1505 include_directories : includes,
1506 link_with : [libshared],
1507 dependencies : [threads,
1508 libmicrohttpd,
1509 libgnutls,
1510 libxz,
1511 liblz4],
1512 install : true,
1513 install_dir : rootlibexecdir)
1514endif
1515
1516if conf.get('ENABLE_COREDUMP', 0) == 1
1517 executable('systemd-coredump',
1518 systemd_coredump_sources,
1519 include_directories : includes,
1520 link_with : [libshared],
1521 dependencies : [threads,
1522 libacl,
1523 libdw,
1524 libxz,
1525 liblz4],
1526 install : true,
1527 install_dir : rootlibexecdir)
1528
1529 executable('coredumpctl',
1530 coredumpctl_sources,
1531 include_directories : includes,
1532 link_with : [libshared],
1533 dependencies : [threads,
1534 libxz,
1535 liblz4],
1536 install : true)
1537endif
1538
1539if conf.get('ENABLE_BINFMT', 0) == 1
1540 executable('systemd-binfmt',
1541 'src/binfmt/binfmt.c',
1542 include_directories : includes,
1543 link_with : [libshared],
1544 install : true,
1545 install_dir : rootlibexecdir)
94e75a54
ZJS
1546
1547 meson.add_install_script('sh', '-c',
1548 mkdir_p.format(binfmtdir))
1549 meson.add_install_script('sh', '-c',
1550 mkdir_p.format(sysconfdir + '/binfmt.d'))
5c23128d
ZJS
1551endif
1552
1553if conf.get('ENABLE_VCONSOLE', 0) == 1
1554 executable('systemd-vconsole-setup',
1555 'src/vconsole/vconsole-setup.c',
1556 include_directories : includes,
1557 link_with : [libshared],
1558 install : true,
1559 install_dir : rootlibexecdir)
1560endif
1561
1562if conf.get('ENABLE_RANDOMSEED', 0) == 1
1563 executable('systemd-random-seed',
1564 'src/random-seed/random-seed.c',
1565 include_directories : includes,
1566 link_with : [libshared],
1567 install : true,
1568 install_dir : rootlibexecdir)
1569endif
1570
1571if conf.get('ENABLE_FIRSTBOOT', 0) == 1
1572 executable('systemd-firstboot',
1573 'src/firstboot/firstboot.c',
1574 include_directories : includes,
1575 link_with : [libshared],
1576 dependencies : [libcrypt],
1577 install : true,
1578 install_dir : rootbindir)
1579endif
1580
1581executable('systemd-remount-fs',
1582 'src/remount-fs/remount-fs.c',
1583 'src/core/mount-setup.c',
1584 'src/core/mount-setup.h',
1585 include_directories : includes,
1586 link_with : [libshared],
1587 install : true,
1588 install_dir : rootlibexecdir)
1589
1590executable('systemd-machine-id-setup',
1591 'src/machine-id-setup/machine-id-setup-main.c',
1592 'src/core/machine-id-setup.c',
1593 'src/core/machine-id-setup.h',
1594 include_directories : includes,
1595 link_with : [libshared],
1596 install : true,
1597 install_dir : rootbindir)
1598
1599executable('systemd-fsck',
1600 'src/fsck/fsck.c',
1601 include_directories : includes,
1602 link_with : [libshared],
1603 install : true,
1604 install_dir : rootlibexecdir)
1605
1606executable('systemd-sleep',
1607 'src/sleep/sleep.c',
1608 include_directories : includes,
1609 link_with : [libshared],
1610 install : true,
1611 install_dir : rootlibexecdir)
1612
1613executable('systemd-sysctl',
1614 'src/sysctl/sysctl.c',
1615 include_directories : includes,
1616 link_with : [libshared],
1617 install : true,
1618 install_dir : rootlibexecdir)
1619
1620executable('systemd-ac-power',
1621 'src/ac-power/ac-power.c',
1622 include_directories : includes,
1623 link_with : [libshared],
1624 install : true,
1625 install_dir : rootlibexecdir)
1626
1627executable('systemd-detect-virt',
1628 'src/detect-virt/detect-virt.c',
1629 include_directories : includes,
1630 link_with : [libshared],
1631 install : true)
1632
1633executable('systemd-delta',
1634 'src/delta/delta.c',
1635 include_directories : includes,
1636 link_with : [libshared],
1637 install : true)
1638
1639executable('systemd-escape',
1640 'src/escape/escape.c',
1641 include_directories : includes,
1642 link_with : [libshared],
1643 install : true,
1644 install_dir : rootbindir)
1645
1646executable('systemd-notify',
1647 'src/notify/notify.c',
1648 include_directories : includes,
1649 link_with : [libshared],
1650 install : true,
1651 install_dir : rootbindir)
1652
1653executable('systemd-volatile-root',
1654 'src/volatile-root/volatile-root.c',
1655 include_directories : includes,
1656 link_with : [libshared],
1657 install : true,
1658 install_dir : rootlibexecdir)
1659
1660executable('systemd-cgroups-agent',
1661 'src/cgroups-agent/cgroups-agent.c',
1662 include_directories : includes,
1663 link_with : [libshared],
1664 install : true,
1665 install_dir : rootlibexecdir)
1666
1667executable('systemd-path',
1668 'src/path/path.c',
1669 include_directories : includes,
1670 link_with : [libshared],
1671 install : true)
1672
1673executable('systemd-ask-password',
1674 'src/ask-password/ask-password.c',
1675 include_directories : includes,
1676 link_with : [libshared],
1677 install : true,
1678 install_dir : rootbindir)
1679
1680executable('systemd-reply-password',
1681 'src/reply-password/reply-password.c',
1682 include_directories : includes,
1683 link_with : [libshared],
1684 install : true,
1685 install_dir : rootlibexecdir)
1686
1687executable('systemd-tty-ask-password-agent',
1688 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1689 include_directories : includes,
1690 link_with : [libshared],
1691 install : true,
1692 install_dir : rootbindir)
1693
1694executable('systemd-cgls',
1695 'src/cgls/cgls.c',
1696 include_directories : includes,
1697 link_with : [libshared],
1698 install : true)
1699
1700executable('systemd-cgtop',
1701 'src/cgtop/cgtop.c',
1702 include_directories : includes,
1703 link_with : [libshared],
1704 install : true)
1705
1706executable('systemd-initctl',
1707 'src/initctl/initctl.c',
1708 include_directories : includes,
1709 link_with : [libshared],
1710 install : true,
1711 install_dir : rootlibexecdir)
1712
1713executable('systemd-mount',
1714 'src/mount/mount-tool.c',
1715 include_directories : includes,
1716 link_with : [libshared],
1717 install : true)
1718
7b76fce1
ZJS
1719meson.add_install_script(meson_make_symlink,
1720 'systemd-mount', bindir + '/systemd-umount')
1721
5c23128d
ZJS
1722executable('systemd-run',
1723 'src/run/run.c',
1724 include_directories : includes,
1725 link_with : [libshared],
1726 install : true)
1727
1728executable('systemd-stdio-bridge',
1729 'src/stdio-bridge/stdio-bridge.c',
1730 include_directories : includes,
1731 link_with : [libshared],
1732 install : true)
1733
1734executable('busctl',
1735 'src/busctl/busctl.c',
1736 'src/busctl/busctl-introspect.c',
1737 'src/busctl/busctl-introspect.h',
1738 include_directories : includes,
1739 link_with : [libshared],
1740 install : true)
1741
1742if conf.get('ENABLE_SYSUSERS', 0) == 1
1743 executable('systemd-sysusers',
1744 'src/sysusers/sysusers.c',
1745 include_directories : includes,
1746 link_with : [libshared],
1747 install : true,
1748 install_dir : rootbindir)
1749endif
1750
1751if conf.get('ENABLE_TMPFILES', 0) == 1
1752 executable('systemd-tmpfiles',
1753 'src/tmpfiles/tmpfiles.c',
1754 include_directories : includes,
1755 link_with : [libshared],
1756 dependencies : [libacl],
1757 install : true,
1758 install_dir : rootbindir)
1759endif
1760
1761if conf.get('ENABLE_HWDB', 0) == 1
1762 executable('systemd-hwdb',
1763 'src/hwdb/hwdb.c',
1764 'src/libsystemd/sd-hwdb/hwdb-internal.h',
1765 include_directories : includes,
1766 link_with : [libshared],
1767 install : true,
1768 install_dir : rootbindir)
1769endif
1770
1771if conf.get('ENABLE_QUOTACHECK', 0) == 1
1772 executable('systemd-quotacheck',
1773 'src/quotacheck/quotacheck.c',
1774 include_directories : includes,
1775 link_with : [libshared],
1776 install : true,
1777 install_dir : rootlibexecdir)
1778endif
1779
1780executable('systemd-socket-proxyd',
1781 'src/socket-proxy/socket-proxyd.c',
1782 include_directories : includes,
1783 link_with : [libshared,
1784 libsystemd],
1785 dependencies : [threads],
1786 install : true,
1787 install_dir : rootlibexecdir)
1788
1789executable('systemd-udevd',
1790 systemd_udevd_sources,
1791 include_directories : includes,
1792 link_with : [libudev_core,
1793 libudev_internal,
1794 libsystemd_network,
1795 libshared],
1796 dependencies : [libkmod,
1797 libidn,
1798 libacl],
1799 install : true,
1800 install_dir : rootlibexecdir)
1801
1802executable('udevadm',
1803 udevadm_sources,
1804 include_directories : includes,
1805 link_with : [libudev_core,
1806 libudev_internal,
1807 libsystemd_network,
1808 libshared],
1809 dependencies : [libkmod,
1810 libidn,
1811 libacl],
1812 install : true,
1813 install_dir : rootbindir)
1814
1815executable('systemd-shutdown',
1816 systemd_shutdown_sources,
1817 include_directories : includes,
1818 link_with : [libshared],
1819 install : true,
1820 install_dir : rootlibexecdir)
1821
1822executable('systemd-update-done',
1823 'src/update-done/update-done.c',
1824 include_directories : includes,
1825 link_with : [libshared],
1826 install : true,
1827 install_dir : rootlibexecdir)
1828
1829executable('systemd-update-utmp',
1830 'src/update-utmp/update-utmp.c',
1831 include_directories : includes,
1832 link_with : [libshared],
1833 dependencies : [libaudit],
1834 install : true,
1835 install_dir : rootlibexecdir)
1836
1837if conf.get('HAVE_KMOD', 0) == 1
1838 executable('systemd-modules-load',
1839 'src/modules-load/modules-load.c',
1840 include_directories : includes,
1841 link_with : [libshared],
1842 dependencies : [libkmod],
1843 install : true,
1844 install_dir : rootlibexecdir)
94e75a54
ZJS
1845
1846 meson.add_install_script('sh', '-c',
1847 mkdir_p.format(modulesloaddir))
1848 meson.add_install_script('sh', '-c',
1849 mkdir_p.format(sysconfdir + '/modules-load.d'))
5c23128d
ZJS
1850endif
1851
1852executable('systemd-nspawn',
1853 systemd_nspawn_sources,
1854 'src/core/mount-setup.c', # FIXME: use a variable?
1855 'src/core/mount-setup.h',
1856 'src/core/loopback-setup.c',
1857 'src/core/loopback-setup.h',
1858 include_directories : [includes, include_directories('src/nspawn')],
1859 link_with : [libfirewall,
1860 libshared],
1861 dependencies : [libacl,
1862 libblkid,
1863 libseccomp,
1864 libselinux],
1865 install : true)
1866
1867executable('systemd-networkd',
1868 systemd_networkd_sources,
1869 include_directories : includes,
1870 link_with : [libnetworkd_core,
1871 libfirewall,
1872 libsystemd_network,
1873 libudev_internal,
1874 libshared],
1875 install : true,
1876 install_dir : rootlibexecdir)
1877
1878executable('systemd-networkd-wait-online',
1879 systemd_networkd_wait_online_sources,
1880 include_directories : includes,
1881 link_with : [libnetworkd_core,
1882 libshared],
1883 install : true,
1884 install_dir : rootlibexecdir)
1885
1886executable('networkctl',
1887 networkctl_sources,
1888 include_directories : includes,
1889 link_with : [libsystemd_network,
1890 libshared],
1891 install : true,
1892 install_dir : rootbindir)
1893
69e96427
ZJS
1894############################################################
1895
1896foreach tuple : tests
1897 sources = tuple[0]
1898 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
1899 dependencies = tuple[2]
1900 condition = tuple.length() >= 4 ? tuple[3] : ''
1901 type = tuple.length() >= 5 ? tuple[4] : ''
1902 defs = tuple.length() >= 6 ? tuple[5] : []
1903 incs = tuple.length() >= 7 ? tuple[6] : includes
1904
1905 name = sources[0].split('/')[-1].split('.')[0]
1906
1907 if condition == '' or conf.get(condition, 0) == 1
572baca1
ZJS
1908 install = install_tests and type == ''
1909
69e96427
ZJS
1910 exe = executable(
1911 name,
1912 sources,
1913 include_directories : incs,
1914 link_with : link_with,
1915 dependencies : dependencies,
572baca1
ZJS
1916 c_args : defs,
1917 install : install,
1918 install_dir : testsdir)
1919
69e96427
ZJS
1920 if type == 'manual'
1921 message('@0@ is a manual test'.format(name))
1922 elif type == 'unsafe' and want_tests != 'unsafe'
1923 message('@0@ is an unsafe test'.format(name))
1924 else
1925 test(name, exe, env : test_env)
1926 endif
1927 else
1928 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
1929 endif
1930endforeach
1931
1932############################################################
5c23128d
ZJS
1933
1934make_directive_index_py = find_program('tools/make-directive-index.py')
1935make_man_index_py = find_program('tools/make-man-index.py')
1936
1937subdir('units')
1938subdir('sysctl.d')
1939subdir('sysusers.d')
1940subdir('tmpfiles.d')
1941subdir('rules')
1942subdir('hwdb')
1943subdir('network')
1944subdir('man')
1945subdir('shell-completion/bash')
1946subdir('shell-completion/zsh')
1947subdir('docs/sysvinit')
1948subdir('docs/var-log')
1949
1950# FIXME: figure out if the warning is true:
1951# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
1952install_subdir('factory/etc',
1953 install_dir : factorydir)
1954
1955
1956install_data('xorg/50-systemd-user.sh',
1957 install_dir : xinitrcdir)
1958install_data('system-preset/90-systemd.preset',
1959 install_dir : systempresetdir)
1960install_data('README',
1961 'NEWS',
1962 'CODING_STYLE',
1963 'DISTRO_PORTING',
1964 'ENVIRONMENT.md',
1965 'LICENSE.GPL2',
1966 'LICENSE.LGPL2.1',
1967 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
1968 install_dir : docdir)
d68b342b 1969
94e75a54
ZJS
1970meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
1971meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
1972
d68b342b
ZJS
1973############################################################
1974
1975if git.found() and etags.found()
1976 all_files = run_command(
1977 git,
1978 ['--git-dir=@0@/.git'.format(meson.source_root()),
1979 'ls-files',
1980 ':/*.[ch]'])
1981 all_files = files(all_files.stdout().split())
1982
1983 custom_target(
1984 'TAGS',
1985 output : 'TAGS',
1986 input : all_files,
1987 command : [etags, '-o', '@OUTPUT@'] + all_files)
1988endif