]> git.ipfire.org Git - thirdparty/systemd.git/blame - meson.build
meson: create dirs and touch /usr
[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
94e75a54
ZJS
388mkdir_p = 'mkdir -p $DESTDIR/@0@'
389
5c23128d
ZJS
390# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
391# /usr/sbin, /sbin, and fall back to the default from middle column.
392progs = [['telinit', '/lib/sysvinit/telinit'],
393 ['quotaon', '/usr/sbin/quotaon' ],
394 ['quotacheck', '/usr/sbin/quotacheck' ],
395 ['kill', '/usr/bin/kill' ],
396 ['kmod', '/usr/bin/kmod' ],
397 ['kexec', '/usr/sbin/kexec' ],
398 ['sulogin', '/usr/sbin/sulogin' ],
399 ['mount', '/usr/bin/mount', 'MOUNT_PATH'],
400 ['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
401 ['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
402 ['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
403 ]
404foreach prog : progs
405 path = get_option(prog[0] + '-path')
406 if path != ''
407 message('Using @1@ for @0@'.format(prog[0], path))
408 else
409 exe = find_program(prog[0], '/usr/sbin/' + prog[0], '/sbin/' + prog[0], required: false)
410 path = exe.found() ? exe.path() : prog[1]
411 endif
412 name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
413 conf.set_quoted(name, path)
414endforeach
415
416# TODO: add ln --relative check
417# AS_IF([! ln --relative --help > /dev/null 2>&1], [AC_MSG_ERROR([*** ln doesn't support --relative ***])])
418
419############################################################
420
421gperf = find_program('gperf')
422
423gperf_test_format = '''
424#include <string.h>
425const char * in_word_set(const char *, @0@);
426@1@
427'''
428gperf_snippet_format = 'echo foo,bar | @0@ -L ANSI-C'
429gperf_snippet = run_command('sh', '-c', gperf_snippet_format.format(gperf.path()))
430gperf_test = gperf_test_format.format('size_t', gperf_snippet.stdout())
431if cc.compiles(gperf_test)
432 gperf_len_type = 'size_t'
433else
434 gperf_test = gperf_test_format.format('unsigned', gperf_snippet.stdout())
435 if cc.compiles(gperf_test)
436 gperf_len_type = 'unsigned'
437 else
438 error('unable to determine gperf len type')
439 endif
440endif
441message('gperf len type is @0@'.format(gperf_len_type))
442conf.set('GPERF_LEN_TYPE', gperf_len_type, description : 'The type of gperf "len" parameter')
443
444############################################################
445
446if not cc.has_header('sys/capability.h')
447 error('POSIX caps headers not found')
448endif
449foreach header : ['linux/btrfs.h',
450 'linux/memfd.h',
451 'linux/vm_sockets.h',
452 'valgrind/memcheck.h',
453 'valgrind/valgrind.h',
454 ]
455 if cc.has_header(header)
456 conf.set('HAVE_' + header.underscorify().to_upper(), 1)
457 endif
458endforeach
459
460############################################################
461
462conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
463
464default_hierarchy = get_option('default-hierarchy')
465conf.set_quoted('DEFAULT_HIERARCHY_NAME', default_hierarchy,
466 description : 'default cgroup hierarchy as string')
467if default_hierarchy == 'legacy'
468 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_NONE')
469elif default_hierarchy == 'hybrid'
470 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_SYSTEMD')
471else
472 conf.set('DEFAULT_HIERARCHY', 'CGROUP_UNIFIED_ALL')
473endif
474
475time_epoch = get_option('time-epoch')
476if time_epoch == ''
477 NEWS = files('NEWS')
478 time_epoch = run_command(stat, '-c', '%Y', NEWS).stdout()
479endif
480time_epoch = time_epoch.to_int()
481conf.set('TIME_EPOCH', time_epoch)
482
483system_uid_max = get_option('system-uid-max')
484if system_uid_max == ''
485 system_uid_max = run_command(
486 awk,
487 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
488 '/etc/login.defs').stdout()
489endif
490system_uid_max = system_uid_max.to_int()
491conf.set('SYSTEM_UID_MAX', system_uid_max)
492substs.set('systemuidmax', system_uid_max)
493message('Maximum system UID is @0@'.format(system_uid_max))
494
495conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
496conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
497
498system_gid_max = get_option('system-gid-max')
499if system_gid_max == ''
500 system_gid_max = run_command(
501 awk,
502 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
503 '/etc/login.defs').stdout()
504endif
505system_gid_max = system_gid_max.to_int()
506conf.set('SYSTEM_GID_MAX', system_gid_max)
507substs.set('systemgidmax', system_gid_max)
508message('Maximum system GID is @0@'.format(system_gid_max))
509
510tty_gid = get_option('tty-gid')
511conf.set('TTY_GID', tty_gid)
512m4_defines += ['-DTTY_GID=' + tty_gid]
513
514if get_option('adm-group')
515 m4_defines += ['-DENABLE_ADM_GROUP']
516endif
517
518if get_option('wheel-group')
519 m4_defines += ['-DENABLE_WHEEL_GROUP']
520endif
521
522substs.set('DEV_KVM_MODE', get_option('dev-kvm-mode'))
523
524conf.set10('KILL_USER_PROCESSES', get_option('default-kill-user-processes'))
525
526default_dnssec = get_option('default-dnssec')
527conf.set('DEFAULT_DNSSEC_MODE',
528 'DNSSEC_' + default_dnssec.underscorify().to_upper())
529
530conf.set_quoted('DNS_SERVERS', get_option('dns-servers'))
531
532conf.set_quoted('NTP_SERVERS', get_option('ntp-servers'))
533
534conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
535
536#####################################################################
537
538threads = dependency('threads')
539librt = cc.find_library('rt')
540libm = cc.find_library('m')
541libdl = cc.find_library('dl')
542libcrypt = cc.find_library('crypt')
543
544libcap = dependency('libcap')
545libmount = dependency('mount',
546 version : '>= 2.27')
547
548want_seccomp = get_option('seccomp')
549if want_seccomp != 'no'
550 libseccomp = dependency('libseccomp',
551 required : want_seccomp == 'yes')
552 if libseccomp.found()
553 conf.set('HAVE_SECCOMP', 1)
554 m4_defines += ['-DHAVE_SECCOMP']
555 endif
556else
557 libseccomp = []
558endif
559
560want_selinux = get_option('selinux')
561if want_selinux != 'no'
562 libselinux = dependency('libselinux',
563 version : '>= 2.1.9',
564 required : want_selinux == 'yes')
565 if libselinux.found()
566 conf.set('HAVE_SELINUX', 1)
567 m4_defines += ['-DHAVE_SELINUX']
568 endif
569else
570 libselinux = []
571endif
572
573want_apparmor = get_option('apparmor')
574if want_apparmor != 'no'
575 libapparmor = dependency('libapparmor',
576 required : want_apparmor == 'yes')
577 if libapparmor.found()
578 conf.set('HAVE_APPARMOR', 1)
579 m4_defines += ['-DHAVE_APPARMOR']
580 endif
581else
582 libapparmor = []
583endif
584
585want_smack = get_option('smack')
586if want_smack != 'no'
587 libsmack = dependency('libsmack',
588 required : want_smack == 'yes')
589 if libsmack.found()
590 conf.set('HAVE_SMACK', 1)
591 m4_defines += ['-DHAVE_SMACK']
592 endif
593else
594 libsmack = []
595endif
596
597smack_run_label = get_option('smack-run-label')
598if smack_run_label != ''
599 conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
600 m4_defines += ['-DHAVE_SMACK_RUN_LABEL']
601endif
602
603want_audit = get_option('audit')
604if want_audit != 'no'
605 libaudit = dependency('audit', required : want_audit == 'yes')
606 if libaudit.found()
607 conf.set('HAVE_AUDIT', 1)
608 endif
609else
610 libaudit = []
611endif
612
613want_blkid = get_option('blkid')
614if want_blkid != 'no'
615 libblkid = dependency('blkid', required : want_blkid == 'yes')
616 if libblkid.found()
617 conf.set('HAVE_BLKID', 1)
618 endif
619else
620 libblkid = []
621endif
622
623want_kmod = get_option('kmod')
624if want_kmod != 'no'
625 libkmod = dependency('libkmod',
626 version : '>= 15',
627 required : want_kmod == 'yes')
628 if libkmod.found()
629 conf.set('HAVE_KMOD', 1)
630 endif
631else
632 libkmod = []
633endif
634
635want_pam = get_option('pam')
636if want_pam != 'no'
637 libpam = cc.find_library('pam', required : want_pam == 'yes')
638 libpam_misc = cc.find_library('pam_misc', required : want_pam == 'yes')
639 if libpam.found() and libpam_misc.found()
640 conf.set('HAVE_PAM', 1)
641 m4_defines += ['-DHAVE_PAM']
642 endif
643else
644 libpam = []
645 libpam_misc = []
646endif
647
648want_microhttpd = get_option('microhttpd')
649if want_microhttpd != 'no'
650 libmicrohttpd = dependency('libmicrohttpd',
651 version : '>= 0.9.33',
652 required : want_microhttpd == 'yes')
653 if libmicrohttpd.found()
654 conf.set('HAVE_MICROHTTPD', 1)
655 m4_defines += ['-DHAVE_MICROHTTPD']
656 endif
657else
658 libmicrohttpd = []
659endif
660
661want_libcryptsetup = get_option('libcryptsetup')
662if want_libcryptsetup != 'no'
663 libcryptsetup = dependency('libcryptsetup',
664 version : '>= 1.6.0',
665 required : want_libcryptsetup == 'yes')
666 if libcryptsetup.found()
667 conf.set('HAVE_LIBCRYPTSETUP', 1)
668 endif
669else
670 libcryptsetup = []
671endif
672
673want_libcurl = get_option('libcurl')
674if want_libcurl != 'no'
675 libcurl = dependency('libcurl',
676 version : '>= 7.32.0',
677 required : want_libcurl == 'yes')
678 if libcurl.found()
679 conf.set('HAVE_LIBCURL', 1)
680 m4_defines += ['-DHAVE_LIBCURL']
681 endif
682else
683 libcurl = []
684endif
685
686want_libidn = get_option('libidn')
687if want_libidn != 'no'
688 libidn = dependency('libidn',
689 required : want_libidn == 'yes')
690 if libidn.found()
691 conf.set('HAVE_LIBIDN', 1)
692 m4_defines += ['-DHAVE_LIBIDN']
693 endif
694else
695 libidn = []
696endif
697
698want_libiptc = get_option('libiptc')
699if want_libiptc != 'no'
700 libiptc = dependency('libiptc',
701 required : want_libiptc == 'yes')
702 if libiptc.found()
703 conf.set('HAVE_LIBIPTC', 1)
704 m4_defines += ['-DHAVE_LIBIPTC']
705 endif
706else
707 libiptc = []
708endif
709
710want_qrencode = get_option('qrencode')
711if want_qrencode != 'no'
712 libqrencode = dependency('libqrencode',
713 required : want_qrencode == 'yes')
714 if libqrencode.found()
715 conf.set('HAVE_QRENCODE', 1)
716 endif
717else
718 libqrencode = []
719endif
720
721want_gnutls = get_option('gnutls')
722if want_gnutls != 'no'
723 libgnutls = dependency('gnutls',
724 version : '>= 3.1.4',
725 required : want_gnutls == 'yes')
726 if libgnutls.found()
727 conf.set('HAVE_GNUTLS', 1)
728 endif
729else
730 libgnutls = []
731endif
732
733want_elfutils = get_option('elfutils')
734if want_elfutils != 'no'
735 libdw = dependency('libdw',
736 required : want_elfutils == 'yes')
737 if libdw.found()
738 conf.set('HAVE_ELFUTILS', 1)
739 endif
740else
741 libdw = []
742endif
743
744want_zlib = get_option('zlib')
745if want_zlib != 'no'
746 libz = dependency('zlib',
747 required : want_zlib == 'yes')
748 if libz.found()
749 conf.set('HAVE_ZLIB', 1)
750 endif
751else
752 libz = []
753endif
754
755want_bzip2 = get_option('bzip2')
756if want_bzip2 != 'no'
757 libbzip2 = cc.find_library('bz2',
758 required : want_bzip2 == 'yes')
759 if libbzip2.found()
760 conf.set('HAVE_BZIP2', 1)
761 endif
762else
763 libbzip2 = []
764endif
765
766want_xz = get_option('xz')
767if want_xz != 'no'
768 libxz = dependency('liblzma',
769 required : want_xz == 'yes')
770 if libxz.found()
771 conf.set('HAVE_XZ', 1)
772 endif
773else
774 libxz = []
775endif
776
777want_lz4 = get_option('lz4')
778if want_lz4 != 'no'
779 liblz4 = dependency('liblz4',
780 required : want_lz4 == 'yes')
781 if liblz4.found()
782 conf.set('HAVE_LZ4', 1)
783 endif
784else
785 liblz4 = []
786endif
787
788libacl = cc.find_library('acl', required : false)
789if libacl.found()
790 conf.set('HAVE_ACL', 1)
791 m4_defines += ['-DHAVE_ACL']
792endif
793
69e96427
ZJS
794want_glib = get_option('glib')
795if want_glib != 'no'
796 libglib = dependency('glib-2.0',
797 version : '>= 2.22.0',
798 required : want_glib == 'yes')
799 libgobject = dependency('gobject-2.0',
800 version : '>= 2.22.0',
801 required : want_glib == 'yes')
802 libgio = dependency('gio-2.0',
803 required : want_glib == 'yes')
804 if libglib.found() and libgobject.found() and libgio.found()
805 conf.set('HAVE_GLIB', 1)
806 endif
807else
808 libglib = []
809 libgobject = []
810 libgio = []
811endif
812
813want_dbus = get_option('dbus')
814if want_dbus != 'no'
815 libdbus = dependency('dbus-1',
816 version : '>= 1.3.2',
817 required : want_dbus == 'yes')
818 if libdbus.found()
819 conf.set('HAVE_DBUS', 1)
820 endif
821else
822 libdbus = []
823endif
824
5c23128d
ZJS
825want_libgcrypt = get_option('libgcrypt')
826if want_libgcrypt != 'no'
827 libgcrypt = cc.find_library('gcrypt', required : want_libgcrypt == 'yes')
828 if libgcrypt.found()
829 conf.set('HAVE_LIBGCRYPT', 1)
830 endif
831else
832 libgcrypt = []
833endif
834
835want_importd = get_option('importd')
836if want_importd != 'no'
837 have_deps = (conf.get('HAVE_LIBCURL', 0) == 1 and
838 conf.get('HAVE_ZLIB', 0) == 1 and
839 conf.get('HAVE_BZIP2', 0) == 1 and
840 conf.get('HAVE_XZ', 0) == 1 and
841 conf.get('HAVE_LZ4', 0) == 1)
842 if have_deps
843 conf.set('ENABLE_IMPORTD', 1)
844 elif want_importd == 'yes'
845 error('importd support was requested, but dependencies are not available')
846 endif
847endif
848
849want_remote = get_option('remote')
850if want_remote != 'no'
851 have_deps = [conf.get('HAVE_MICROHTTPD', 0) == 1,
852 conf.get('HAVE_LIBCURL', 0) == 1]
853 # sd-j-remote requires µhttpd, and sd-j-upload requires libcurl, so
854 # it's possible to build one without the other. Complain only if
855 # support was explictly requested. The auxiliary files like sysusers
856 # config should be installed when any of the programs are built.
857 if want_remote == 'yes' and not (have_deps[0] and have_deps[1])
858 error('remote support was requested, but dependencies are not available')
859 endif
860 if have_deps[0] or have_deps[1]
861 conf.set('ENABLE_REMOTE', 1)
862 endif
863endif
864
865foreach pair : [['utmp', 'HAVE_UTMP'],
866 ['hibernate', 'ENABLE_HIBERNATE'],
867 ['environment-d', 'ENABLE_ENVIRONMENT_D'],
868 ['binfmt', 'ENABLE_BINFMT'],
869 ['coredump', 'ENABLE_COREDUMP'],
870 ['resolve', 'ENABLE_RESOLVED'],
871 ['logind', 'ENABLE_LOGIND'],
872 ['hostnamed', 'ENABLE_HOSTNAMED'],
873 ['localed', 'ENABLE_LOCALED'],
874 ['machined', 'ENABLE_MACHINED'],
875 ['networkd', 'ENABLE_NETWORKD'],
876 ['timedated', 'ENABLE_TIMEDATED'],
877 ['timesyncd', 'ENABLE_TIMESYNCD'],
878 ['myhostname', 'HAVE_MYHOSTNAME'],
879 ['firstboot', 'ENABLE_FIRSTBOOT'],
880 ['randomseed', 'ENABLE_RANDOMSEED'],
881 ['backlight', 'ENABLE_BACKLIGHT'],
882 ['vconsole', 'ENABLE_VCONSOLE'],
883 ['quotacheck', 'ENABLE_QUOTACHECK'],
884 ['sysusers', 'ENABLE_SYSUSERS'],
885 ['tmpfiles', 'ENABLE_TMPFILES'],
886 ['hwdb', 'ENABLE_HWDB'],
887 ['rfkill', 'ENABLE_RFKILL'],
888 ['ldconfig', 'ENABLE_LDCONFIG'],
889 ]
890
891 if get_option(pair[0])
892 conf.set(pair[1], 1)
893 endif
894endforeach
895
69e96427 896want_tests = get_option('tests')
572baca1 897install_tests = get_option('install-tests')
69e96427
ZJS
898tests = []
899
5c23128d
ZJS
900#####################################################################
901
902if get_option('efi')
903 efi_arch = host_machine.cpu_family() # TODO: check this works at all
904 if efi_arch == 'ia32'
905 EFI_MACHINE_TYPE_NAME = 'ia32'
906 elif efi_arch == 'x86_64'
907 EFI_MACHINE_TYPE_NAME = 'x64'
908 elif efi_arch == 'aarch64'
909 EFI_MACHINE_TYPE_NAME = 'x64'
910 else
911 EFI_MACHINE_TYPE_NAME = efi_arch
912 endif
913
914 conf.set('ENABLE_EFI', 1)
915 conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
916endif
917
918#####################################################################
919
920config_h = configure_file(
921 output : 'config.h',
922 configuration : conf)
923
924includes = include_directories('src/basic',
925 'src/shared',
926 'src/systemd',
927 'src/journal',
928 'src/resolve',
929 'src/timesync',
930 'src/login',
931 'src/udev',
932 'src/libudev',
933 'src/core',
934 'src/libsystemd/sd-bus',
935 'src/libsystemd/sd-device',
936 'src/libsystemd/sd-hwdb',
937 'src/libsystemd/sd-id128',
938 'src/libsystemd/sd-netlink',
939 'src/libsystemd/sd-network',
940 'src/libsystemd-network',
941 )
942
943add_project_arguments('-include', 'config.h', language : 'c')
944
945gcrypt_util_sources = files('src/shared/gcrypt-util.h',
946 'src/shared/gcrypt-util.c')
947
948subdir('po')
949subdir('catalog')
950subdir('src/systemd')
951subdir('src/basic')
952subdir('src/libsystemd')
953subdir('src/libsystemd-network')
5c23128d 954subdir('src/journal')
5c23128d 955subdir('src/login')
5c23128d
ZJS
956
957libjournal_core = static_library(
958 'journal-core',
959 libjournal_core_sources,
960 journald_gperf_c,
961 include_directories : includes,
962 link_with : [libbasic,
963 libsystemd_internal,
964 libsystemd_journal_internal],
965 install : false)
966
6b30f280 967version_script_arg = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
5c23128d
ZJS
968libsystemd = shared_library(
969 'systemd',
970 libsystemd_internal_sources,
971 version : '0.18.0',
972 include_directories : includes,
973 link_args : ['-shared',
6b30f280 974 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
975 link_with : [libbasic,
976 libsystemd_internal,
977 libsystemd_journal_internal],
978 dependencies : [threads],
6b30f280 979 link_depends : libsystemd_sym,
5c23128d
ZJS
980 install : true,
981 install_dir : rootlibdir)
982
983############################################################
984
985foreach tuple : [['myhostname', 'HAVE_MYHOSTNAME', []],
986 ['systemd', '', []],
987 ['mymachines', 'ENABLE_MACHINED', []],
988 ['resolve', 'ENABLE_RESOLVED', [libdl]]]
989
990 condition = tuple[1] == '' or conf.get(tuple[1], 0) == 1
991 if condition
992 module = tuple[0]
993 extra_deps = tuple[2]
994
6b30f280
ZJS
995 sym = 'src/nss-@0@/nss-@0@.sym'.format(module)
996 version_script_arg = join_paths(meson.current_source_dir(), sym)
5c23128d
ZJS
997
998 shared_library(
999 'nss_' + module,
1000 'src/nss-@0@/nss-@0@.c'.format(module),
1001 version : '2',
1002 include_directories : includes,
1003 link_args : ['-shared',
6b30f280 1004 '-Wl,--version-script=' + version_script_arg,
5c23128d
ZJS
1005 '-Wl,--undefined'],
1006 link_with : [libsystemd_internal,
1007 libbasic],
1008 dependencies : [threads,
1009 librt] + extra_deps,
6b30f280 1010 link_depends : sym,
5c23128d
ZJS
1011 install : true,
1012 install_dir : rootlibdir)
1013 endif
1014endforeach
1015
1016############################################################
1017
1018subdir('src/libudev')
1019subdir('src/shared')
1020subdir('src/core')
1021subdir('src/udev')
1022subdir('src/network')
1023
69e96427
ZJS
1024subdir('src/analyze')
1025subdir('src/journal-remote')
1026subdir('src/coredump')
1027subdir('src/hostname')
1028subdir('src/import')
1029subdir('src/kernel-install')
1030subdir('src/locale')
1031subdir('src/machine')
1032subdir('src/nspawn')
1033subdir('src/resolve')
1034subdir('src/timedate')
1035subdir('src/timesync')
1036subdir('src/vconsole')
1037
1038subdir('src/test')
1039
5c23128d
ZJS
1040executable('systemd',
1041 systemd_sources,
1042 include_directories : includes,
1043 link_with : [libcore,
1044 libshared],
1045 dependencies : [threads,
1046 librt,
1047 libseccomp,
1048 libselinux,
f4ee10a2
ZJS
1049 libmount,
1050 libblkid],
5c23128d
ZJS
1051 install : true,
1052 install_dir : rootlibexecdir)
1053
1054executable('systemd-analyze',
1055 systemd_analyze_sources,
1056 include_directories : includes,
1057 link_with : [libcore,
1058 libshared],
1059 dependencies : [threads,
1060 librt,
1061 libseccomp,
1062 libselinux,
f4ee10a2
ZJS
1063 libmount,
1064 libblkid],
5c23128d
ZJS
1065 install : true)
1066
1067executable('systemd-journald',
1068 systemd_journald_sources,
1069 include_directories : includes,
1070 link_with : [libsystemd_journal_internal,
1071 libjournal_core,
1072 libshared,
1073 libudev],
1074 dependencies : [threads,
1075 libxz,
1076 liblz4],
1077 install : true,
1078 install_dir : rootlibexecdir)
1079
1080executable('systemd-cat',
1081 systemd_cat_sources,
1082 include_directories : includes,
1083 link_with : [libjournal_core,
1084 libshared,
1085 libudev],
1086 dependencies : [threads],
1087 install : true)
1088
1089executable('journalctl',
1090 journalctl_sources,
1091 include_directories : includes,
1092 link_with : [libshared,
1093 libudev],
1094 dependencies : [threads,
1095 libqrencode,
1096 libxz,
1097 liblz4],
1098 install : true,
1099 install_dir : rootbindir)
1100
1101executable('systemd-getty-generator',
1102 'src/getty-generator/getty-generator.c',
1103 install : true,
1104 install_dir : systemgeneratordir,
1105 include_directories : includes,
1106 link_with : [libshared])
1107
1108executable('systemd-debug-generator',
1109 'src/debug-generator/debug-generator.c',
1110 install : true,
1111 install_dir : systemgeneratordir,
1112 include_directories : includes,
1113 link_with : [libshared])
1114
1115executable('systemd-fstab-generator',
1116 'src/fstab-generator/fstab-generator.c',
1117 'src/core/mount-setup.c',
1118 install : true,
1119 install_dir : systemgeneratordir,
1120 include_directories : includes,
1121 link_with : [libshared])
1122
1123if conf.get('ENABLE_ENVIRONMENT_D', 0) == 1
1124 executable('30-systemd-environment-d-generator',
1125 'src/environment-d-generator/environment-d-generator.c',
1126 install : true,
1127 install_dir : userenvgeneratordir,
1128 include_directories : includes,
1129 link_with : [libshared])
1130endif
1131
1132if conf.get('ENABLE_HIBERNATE', 0) == 1
1133 executable('systemd-hibernate-resume-generator',
1134 'src/hibernate-resume/hibernate-resume-generator.c',
1135 include_directories : includes,
1136 link_with : [libshared],
1137 install : true,
1138 install_dir : systemgeneratordir)
1139
1140 executable('systemd-hibernate-resume',
1141 'src/hibernate-resume/hibernate-resume.c',
1142 include_directories : includes,
1143 link_with : [libshared],
1144 install : true,
1145 install_dir : rootlibexecdir)
1146endif
1147
1148if conf.get('HAVE_BLKID', 0) == 1
1149 executable('systemd-gpt-auto-generator',
1150 'src/gpt-auto-generator/gpt-auto-generator.c',
1151 'src/basic/blkid-util.h',
1152 install : true,
1153 install_dir : systemgeneratordir,
1154 include_directories : includes,
1155 link_with : libshared,
1156 dependencies : libblkid)
1157
1158 executable('systemd-dissect',
1159 'src/dissect/dissect.c',
1160 include_directories : includes,
1161 link_with : [libshared],
1162 install : true,
1163 install_dir : rootlibexecdir)
1164endif
1165
1166if conf.get('ENABLE_RESOLVED', 0) == 1
1167 executable('systemd-resolved',
1168 systemd_resolved_sources,
1169 include_directories : includes,
1170 link_with : [libshared,
1171 ],
1172 dependencies : [threads,
1173 libm,
1174 libidn],
1175 install : true,
1176 install_dir : rootlibexecdir)
1177
1178 executable('systemd-resolve',
1179 systemd_resolve_sources,
1180 include_directories : includes,
1181 link_with : [libshared,
1182 ],
1183 dependencies : [threads,
1184 libm,
1185 libidn],
1186 install : true)
1187endif
1188
1189if conf.get('ENABLE_LOGIND', 0) == 1
1190 executable('systemd-logind',
1191 systemd_logind_sources,
1192 include_directories : includes,
1193 link_with : [liblogind_core,
1194 libshared],
1195 dependencies : [threads,
1196 libacl],
1197 install : true,
1198 install_dir : rootlibexecdir)
1199
1200 executable('loginctl',
1201 loginctl_sources,
1202 include_directories : includes,
1203 link_with : [libshared],
1204 dependencies : [threads,
1205 liblz4,
1206 libxz],
1207 install : true,
1208 install_dir : rootbindir)
1209
1210 executable('systemd-inhibit',
1211 'src/login/inhibit.c',
1212 include_directories : includes,
1213 link_with : [libshared],
1214 install : true,
1215 install_dir : rootbindir)
1216
1217 if conf.get('HAVE_PAM', 0) == 1
6b30f280 1218 version_script_arg = join_paths(meson.current_source_dir(), pam_systemd_sym)
5c23128d
ZJS
1219 shared_library(
1220 'pam_systemd',
1221 pam_systemd_c,
1222 name_prefix : '',
1223 include_directories : includes,
1224 link_args : ['-shared',
6b30f280 1225 '-Wl,--version-script=' + version_script_arg],
5c23128d
ZJS
1226 link_with : [libshared],
1227 dependencies : [libpam,
1228 libpam_misc],
6b30f280 1229 link_depends : pam_systemd_sym,
5c23128d
ZJS
1230 install : true,
1231 install_dir : pamlibdir)
1232 endif
1233endif
1234
1235if conf.get('HAVE_PAM', 0) == 1
1236 executable('systemd-user-sessions',
1237 'src/user-sessions/user-sessions.c',
1238 include_directories : includes,
1239 link_with : [libshared],
1240 install : true,
1241 install_dir : rootlibexecdir)
1242endif
1243
1244if conf.get('ENABLE_EFI', 0) == 1
1245 executable('bootctl',
1246 'src/boot/bootctl.c',
1247 include_directories : includes,
1248 link_with : [libshared],
1249 dependencies : [libblkid],
1250 install : true)
1251endif
1252
1253executable('systemd-socket-activate', 'src/activate/activate.c',
1254 include_directories : includes,
1255 link_with : [libshared],
1256 dependencies : [threads],
1257 install : true)
1258
1259executable('systemctl', 'src/systemctl/systemctl.c',
1260 include_directories : includes,
1261 link_with : [libshared],
1262 dependencies : [threads,
1263 libcap,
1264 libselinux,
1265 libxz,
1266 liblz4],
1267 install : true,
1268 install_dir : rootbindir)
1269
1270if conf.get('ENABLE_BACKLIGHT', 0) == 1
1271 executable('systemd-backlight',
1272 'src/backlight/backlight.c',
1273 include_directories : includes,
1274 link_with : [libshared],
1275 install : true,
1276 install_dir : rootlibexecdir)
1277endif
1278
1279if conf.get('ENABLE_RFKILL', 0) == 1
1280 executable('systemd-rfkill',
1281 'src/rfkill/rfkill.c',
1282 include_directories : includes,
1283 link_with : [libshared],
1284 install : true,
1285 install_dir : rootlibexecdir)
1286endif
1287
1288executable('systemd-system-update-generator',
1289 'src/system-update-generator/system-update-generator.c',
1290 include_directories : includes,
1291 link_with : [libshared],
1292 install : true,
1293 install_dir : systemgeneratordir)
1294
1295if conf.get('HAVE_LIBCRYPTSETUP', 0) == 1
1296 executable('systemd-cryptsetup',
1297 'src/cryptsetup/cryptsetup.c',
1298 include_directories : includes,
1299 link_with : [libshared],
1300 dependencies : [libcryptsetup],
1301 install : true,
1302 install_dir : rootlibexecdir)
1303
1304 executable('systemd-cryptsetup-generator',
1305 'src/cryptsetup/cryptsetup-generator.c',
1306 include_directories : includes,
1307 link_with : [libshared],
1308 dependencies : [libcryptsetup],
1309 install : true,
1310 install_dir : systemgeneratordir)
1311
1312 executable('systemd-veritysetup',
1313 'src/veritysetup/veritysetup.c',
1314 include_directories : includes,
1315 link_with : [libshared],
1316 dependencies : [libcryptsetup],
1317 install : true,
1318 install_dir : rootlibexecdir)
1319
1320 executable('systemd-veritysetup-generator',
1321 'src/veritysetup/veritysetup-generator.c',
1322 include_directories : includes,
1323 link_with : [libshared],
1324 dependencies : [libcryptsetup],
1325 install : true,
1326 install_dir : systemgeneratordir)
1327endif
1328
1329if conf.get('HAVE_SYSV_COMPAT', 0) == 1
1330 executable('systemd-sysv-generator',
1331 'src/sysv-generator/sysv-generator.c',
1332 include_directories : includes,
1333 link_with : [libshared],
1334 install : true,
1335 install_dir : systemgeneratordir)
1336
1337 executable('systemd-rc-local-generator',
1338 'src/rc-local-generator/rc-local-generator.c',
1339 include_directories : includes,
1340 link_with : [libshared],
1341 install : true,
1342 install_dir : systemgeneratordir)
1343endif
1344
1345if conf.get('ENABLE_HOSTNAMED', 0) == 1
1346 executable('systemd-hostnamed',
1347 'src/hostname/hostnamed.c',
1348 include_directories : includes,
1349 link_with : [libshared],
1350 install : true,
1351 install_dir : rootlibexecdir)
1352
1353 executable('hostnamectl',
1354 'src/hostname/hostnamectl.c',
1355 include_directories : includes,
1356 link_with : [libshared],
1357 install : true)
1358endif
1359
1360if conf.get('ENABLE_LOCALED', 0) == 1
1361 executable('systemd-localed',
1362 systemd_localed_sources,
1363 include_directories : includes,
1364 link_with : [libshared],
1365 dependencies : [libdl],
1366 install : true,
1367 install_dir : rootlibexecdir)
1368
1369 executable('localectl',
1370 localectl_sources,
1371 include_directories : includes,
1372 link_with : [libshared],
1373 install : true)
1374endif
1375
1376if conf.get('ENABLE_TIMEDATED', 0) == 1
1377 executable('systemd-timedated',
1378 'src/timedate/timedated.c',
1379 include_directories : includes,
1380 link_with : [libshared],
1381 install : true,
1382 install_dir : rootlibexecdir)
1383
1384 executable('timedatectl',
1385 'src/timedate/timedatectl.c',
1386 include_directories : includes,
1387 link_with : [libshared],
1388 install : true)
1389endif
1390
1391if conf.get('ENABLE_TIMESYNCD', 0) == 1
1392 executable('systemd-timesyncd',
1393 systemd_timesyncd_sources,
1394 include_directories : includes,
1395 link_with : [libshared],
1396 dependencies : [threads,
1397 libm],
1398 install : true,
1399 install_dir : rootlibexecdir)
1400endif
1401
1402if conf.get('ENABLE_MACHINED', 0) == 1
1403 executable('systemd-machined',
1404 systemd_machined_sources,
1405 include_directories : includes,
1406 link_with : [libmachine_core,
1407 libshared],
1408 install : true,
1409 install_dir : rootlibexecdir)
1410
1411 executable('machinectl',
1412 'src/machine/machinectl.c',
1413 include_directories : includes,
1414 link_with : [libshared],
1415 dependencies : [threads,
1416 libxz,
1417 liblz4],
1418 install : true,
1419 install_dir : rootbindir)
1420endif
1421
1422if conf.get('ENABLE_IMPORTD', 0) == 1
1423 executable('systemd-importd',
1424 systemd_importd_sources,
1425 include_directories : includes,
1426 link_with : [libshared],
1427 install : true,
1428 install_dir : rootlibexecdir)
1429
1430 executable('systemd-pull',
1431 systemd_pull_sources,
1432 include_directories : includes,
1433 link_with : [libshared],
1434 dependencies : [libcurl,
1435 libz,
1436 libbzip2,
1437 libxz,
1438 libgcrypt],
1439 install : true,
1440 install_dir : rootlibexecdir)
1441
1442 executable('systemd-import',
1443 systemd_import_sources,
1444 include_directories : includes,
1445 link_with : [libshared],
1446 dependencies : [libcurl,
1447 libz,
1448 libbzip2,
1449 libxz],
1450 install : true,
1451 install_dir : rootlibexecdir)
1452
1453 executable('systemd-export',
1454 systemd_export_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)
1463endif
1464
1465if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_LIBCURL', 0) == 1
1466 executable('systemd-journal-upload',
1467 systemd_journal_upload_sources,
1468 include_directories : includes,
1469 link_with : [libshared],
1470 dependencies : [threads,
1471 libcurl,
1472 libgnutls,
1473 libxz,
1474 liblz4],
1475 install : true,
1476 install_dir : rootlibexecdir)
1477endif
1478
1479if conf.get('ENABLE_REMOTE', 0) == 1 and conf.get('HAVE_MICROHTTPD', 0) == 1
1480 executable('systemd-journal-remote',
1481 systemd_journal_remote_sources,
1482 include_directories : includes,
1483 link_with : [libshared],
1484 dependencies : [threads,
1485 libmicrohttpd,
1486 libgnutls,
1487 libxz,
1488 liblz4],
1489 install : true,
1490 install_dir : rootlibexecdir)
1491
1492 executable('systemd-journal-gatewayd',
1493 systemd_journal_gatewayd_sources,
1494 include_directories : includes,
1495 link_with : [libshared],
1496 dependencies : [threads,
1497 libmicrohttpd,
1498 libgnutls,
1499 libxz,
1500 liblz4],
1501 install : true,
1502 install_dir : rootlibexecdir)
1503endif
1504
1505if conf.get('ENABLE_COREDUMP', 0) == 1
1506 executable('systemd-coredump',
1507 systemd_coredump_sources,
1508 include_directories : includes,
1509 link_with : [libshared],
1510 dependencies : [threads,
1511 libacl,
1512 libdw,
1513 libxz,
1514 liblz4],
1515 install : true,
1516 install_dir : rootlibexecdir)
1517
1518 executable('coredumpctl',
1519 coredumpctl_sources,
1520 include_directories : includes,
1521 link_with : [libshared],
1522 dependencies : [threads,
1523 libxz,
1524 liblz4],
1525 install : true)
1526endif
1527
1528if conf.get('ENABLE_BINFMT', 0) == 1
1529 executable('systemd-binfmt',
1530 'src/binfmt/binfmt.c',
1531 include_directories : includes,
1532 link_with : [libshared],
1533 install : true,
1534 install_dir : rootlibexecdir)
94e75a54
ZJS
1535
1536 meson.add_install_script('sh', '-c',
1537 mkdir_p.format(binfmtdir))
1538 meson.add_install_script('sh', '-c',
1539 mkdir_p.format(sysconfdir + '/binfmt.d'))
5c23128d
ZJS
1540endif
1541
1542if conf.get('ENABLE_VCONSOLE', 0) == 1
1543 executable('systemd-vconsole-setup',
1544 'src/vconsole/vconsole-setup.c',
1545 include_directories : includes,
1546 link_with : [libshared],
1547 install : true,
1548 install_dir : rootlibexecdir)
1549endif
1550
1551if conf.get('ENABLE_RANDOMSEED', 0) == 1
1552 executable('systemd-random-seed',
1553 'src/random-seed/random-seed.c',
1554 include_directories : includes,
1555 link_with : [libshared],
1556 install : true,
1557 install_dir : rootlibexecdir)
1558endif
1559
1560if conf.get('ENABLE_FIRSTBOOT', 0) == 1
1561 executable('systemd-firstboot',
1562 'src/firstboot/firstboot.c',
1563 include_directories : includes,
1564 link_with : [libshared],
1565 dependencies : [libcrypt],
1566 install : true,
1567 install_dir : rootbindir)
1568endif
1569
1570executable('systemd-remount-fs',
1571 'src/remount-fs/remount-fs.c',
1572 'src/core/mount-setup.c',
1573 'src/core/mount-setup.h',
1574 include_directories : includes,
1575 link_with : [libshared],
1576 install : true,
1577 install_dir : rootlibexecdir)
1578
1579executable('systemd-machine-id-setup',
1580 'src/machine-id-setup/machine-id-setup-main.c',
1581 'src/core/machine-id-setup.c',
1582 'src/core/machine-id-setup.h',
1583 include_directories : includes,
1584 link_with : [libshared],
1585 install : true,
1586 install_dir : rootbindir)
1587
1588executable('systemd-fsck',
1589 'src/fsck/fsck.c',
1590 include_directories : includes,
1591 link_with : [libshared],
1592 install : true,
1593 install_dir : rootlibexecdir)
1594
1595executable('systemd-sleep',
1596 'src/sleep/sleep.c',
1597 include_directories : includes,
1598 link_with : [libshared],
1599 install : true,
1600 install_dir : rootlibexecdir)
1601
1602executable('systemd-sysctl',
1603 'src/sysctl/sysctl.c',
1604 include_directories : includes,
1605 link_with : [libshared],
1606 install : true,
1607 install_dir : rootlibexecdir)
1608
1609executable('systemd-ac-power',
1610 'src/ac-power/ac-power.c',
1611 include_directories : includes,
1612 link_with : [libshared],
1613 install : true,
1614 install_dir : rootlibexecdir)
1615
1616executable('systemd-detect-virt',
1617 'src/detect-virt/detect-virt.c',
1618 include_directories : includes,
1619 link_with : [libshared],
1620 install : true)
1621
1622executable('systemd-delta',
1623 'src/delta/delta.c',
1624 include_directories : includes,
1625 link_with : [libshared],
1626 install : true)
1627
1628executable('systemd-escape',
1629 'src/escape/escape.c',
1630 include_directories : includes,
1631 link_with : [libshared],
1632 install : true,
1633 install_dir : rootbindir)
1634
1635executable('systemd-notify',
1636 'src/notify/notify.c',
1637 include_directories : includes,
1638 link_with : [libshared],
1639 install : true,
1640 install_dir : rootbindir)
1641
1642executable('systemd-volatile-root',
1643 'src/volatile-root/volatile-root.c',
1644 include_directories : includes,
1645 link_with : [libshared],
1646 install : true,
1647 install_dir : rootlibexecdir)
1648
1649executable('systemd-cgroups-agent',
1650 'src/cgroups-agent/cgroups-agent.c',
1651 include_directories : includes,
1652 link_with : [libshared],
1653 install : true,
1654 install_dir : rootlibexecdir)
1655
1656executable('systemd-path',
1657 'src/path/path.c',
1658 include_directories : includes,
1659 link_with : [libshared],
1660 install : true)
1661
1662executable('systemd-ask-password',
1663 'src/ask-password/ask-password.c',
1664 include_directories : includes,
1665 link_with : [libshared],
1666 install : true,
1667 install_dir : rootbindir)
1668
1669executable('systemd-reply-password',
1670 'src/reply-password/reply-password.c',
1671 include_directories : includes,
1672 link_with : [libshared],
1673 install : true,
1674 install_dir : rootlibexecdir)
1675
1676executable('systemd-tty-ask-password-agent',
1677 'src/tty-ask-password-agent/tty-ask-password-agent.c',
1678 include_directories : includes,
1679 link_with : [libshared],
1680 install : true,
1681 install_dir : rootbindir)
1682
1683executable('systemd-cgls',
1684 'src/cgls/cgls.c',
1685 include_directories : includes,
1686 link_with : [libshared],
1687 install : true)
1688
1689executable('systemd-cgtop',
1690 'src/cgtop/cgtop.c',
1691 include_directories : includes,
1692 link_with : [libshared],
1693 install : true)
1694
1695executable('systemd-initctl',
1696 'src/initctl/initctl.c',
1697 include_directories : includes,
1698 link_with : [libshared],
1699 install : true,
1700 install_dir : rootlibexecdir)
1701
1702executable('systemd-mount',
1703 'src/mount/mount-tool.c',
1704 include_directories : includes,
1705 link_with : [libshared],
1706 install : true)
1707
1708executable('systemd-run',
1709 'src/run/run.c',
1710 include_directories : includes,
1711 link_with : [libshared],
1712 install : true)
1713
1714executable('systemd-stdio-bridge',
1715 'src/stdio-bridge/stdio-bridge.c',
1716 include_directories : includes,
1717 link_with : [libshared],
1718 install : true)
1719
1720executable('busctl',
1721 'src/busctl/busctl.c',
1722 'src/busctl/busctl-introspect.c',
1723 'src/busctl/busctl-introspect.h',
1724 include_directories : includes,
1725 link_with : [libshared],
1726 install : true)
1727
1728if conf.get('ENABLE_SYSUSERS', 0) == 1
1729 executable('systemd-sysusers',
1730 'src/sysusers/sysusers.c',
1731 include_directories : includes,
1732 link_with : [libshared],
1733 install : true,
1734 install_dir : rootbindir)
1735endif
1736
1737if conf.get('ENABLE_TMPFILES', 0) == 1
1738 executable('systemd-tmpfiles',
1739 'src/tmpfiles/tmpfiles.c',
1740 include_directories : includes,
1741 link_with : [libshared],
1742 dependencies : [libacl],
1743 install : true,
1744 install_dir : rootbindir)
1745endif
1746
1747if conf.get('ENABLE_HWDB', 0) == 1
1748 executable('systemd-hwdb',
1749 'src/hwdb/hwdb.c',
1750 'src/libsystemd/sd-hwdb/hwdb-internal.h',
1751 include_directories : includes,
1752 link_with : [libshared],
1753 install : true,
1754 install_dir : rootbindir)
1755endif
1756
1757if conf.get('ENABLE_QUOTACHECK', 0) == 1
1758 executable('systemd-quotacheck',
1759 'src/quotacheck/quotacheck.c',
1760 include_directories : includes,
1761 link_with : [libshared],
1762 install : true,
1763 install_dir : rootlibexecdir)
1764endif
1765
1766executable('systemd-socket-proxyd',
1767 'src/socket-proxy/socket-proxyd.c',
1768 include_directories : includes,
1769 link_with : [libshared,
1770 libsystemd],
1771 dependencies : [threads],
1772 install : true,
1773 install_dir : rootlibexecdir)
1774
1775executable('systemd-udevd',
1776 systemd_udevd_sources,
1777 include_directories : includes,
1778 link_with : [libudev_core,
1779 libudev_internal,
1780 libsystemd_network,
1781 libshared],
1782 dependencies : [libkmod,
1783 libidn,
1784 libacl],
1785 install : true,
1786 install_dir : rootlibexecdir)
1787
1788executable('udevadm',
1789 udevadm_sources,
1790 include_directories : includes,
1791 link_with : [libudev_core,
1792 libudev_internal,
1793 libsystemd_network,
1794 libshared],
1795 dependencies : [libkmod,
1796 libidn,
1797 libacl],
1798 install : true,
1799 install_dir : rootbindir)
1800
1801executable('systemd-shutdown',
1802 systemd_shutdown_sources,
1803 include_directories : includes,
1804 link_with : [libshared],
1805 install : true,
1806 install_dir : rootlibexecdir)
1807
1808executable('systemd-update-done',
1809 'src/update-done/update-done.c',
1810 include_directories : includes,
1811 link_with : [libshared],
1812 install : true,
1813 install_dir : rootlibexecdir)
1814
1815executable('systemd-update-utmp',
1816 'src/update-utmp/update-utmp.c',
1817 include_directories : includes,
1818 link_with : [libshared],
1819 dependencies : [libaudit],
1820 install : true,
1821 install_dir : rootlibexecdir)
1822
1823if conf.get('HAVE_KMOD', 0) == 1
1824 executable('systemd-modules-load',
1825 'src/modules-load/modules-load.c',
1826 include_directories : includes,
1827 link_with : [libshared],
1828 dependencies : [libkmod],
1829 install : true,
1830 install_dir : rootlibexecdir)
94e75a54
ZJS
1831
1832 meson.add_install_script('sh', '-c',
1833 mkdir_p.format(modulesloaddir))
1834 meson.add_install_script('sh', '-c',
1835 mkdir_p.format(sysconfdir + '/modules-load.d'))
5c23128d
ZJS
1836endif
1837
1838executable('systemd-nspawn',
1839 systemd_nspawn_sources,
1840 'src/core/mount-setup.c', # FIXME: use a variable?
1841 'src/core/mount-setup.h',
1842 'src/core/loopback-setup.c',
1843 'src/core/loopback-setup.h',
1844 include_directories : [includes, include_directories('src/nspawn')],
1845 link_with : [libfirewall,
1846 libshared],
1847 dependencies : [libacl,
1848 libblkid,
1849 libseccomp,
1850 libselinux],
1851 install : true)
1852
1853executable('systemd-networkd',
1854 systemd_networkd_sources,
1855 include_directories : includes,
1856 link_with : [libnetworkd_core,
1857 libfirewall,
1858 libsystemd_network,
1859 libudev_internal,
1860 libshared],
1861 install : true,
1862 install_dir : rootlibexecdir)
1863
1864executable('systemd-networkd-wait-online',
1865 systemd_networkd_wait_online_sources,
1866 include_directories : includes,
1867 link_with : [libnetworkd_core,
1868 libshared],
1869 install : true,
1870 install_dir : rootlibexecdir)
1871
1872executable('networkctl',
1873 networkctl_sources,
1874 include_directories : includes,
1875 link_with : [libsystemd_network,
1876 libshared],
1877 install : true,
1878 install_dir : rootbindir)
1879
69e96427
ZJS
1880############################################################
1881
1882foreach tuple : tests
1883 sources = tuple[0]
1884 link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
1885 dependencies = tuple[2]
1886 condition = tuple.length() >= 4 ? tuple[3] : ''
1887 type = tuple.length() >= 5 ? tuple[4] : ''
1888 defs = tuple.length() >= 6 ? tuple[5] : []
1889 incs = tuple.length() >= 7 ? tuple[6] : includes
1890
1891 name = sources[0].split('/')[-1].split('.')[0]
1892
1893 if condition == '' or conf.get(condition, 0) == 1
572baca1
ZJS
1894 install = install_tests and type == ''
1895
69e96427
ZJS
1896 exe = executable(
1897 name,
1898 sources,
1899 include_directories : incs,
1900 link_with : link_with,
1901 dependencies : dependencies,
572baca1
ZJS
1902 c_args : defs,
1903 install : install,
1904 install_dir : testsdir)
1905
69e96427
ZJS
1906 if type == 'manual'
1907 message('@0@ is a manual test'.format(name))
1908 elif type == 'unsafe' and want_tests != 'unsafe'
1909 message('@0@ is an unsafe test'.format(name))
1910 else
1911 test(name, exe, env : test_env)
1912 endif
1913 else
1914 message('Not compiling @0@ because @1@ is not true'.format(name, condition))
1915 endif
1916endforeach
1917
1918############################################################
5c23128d
ZJS
1919
1920make_directive_index_py = find_program('tools/make-directive-index.py')
1921make_man_index_py = find_program('tools/make-man-index.py')
1922
1923subdir('units')
1924subdir('sysctl.d')
1925subdir('sysusers.d')
1926subdir('tmpfiles.d')
1927subdir('rules')
1928subdir('hwdb')
1929subdir('network')
1930subdir('man')
1931subdir('shell-completion/bash')
1932subdir('shell-completion/zsh')
1933subdir('docs/sysvinit')
1934subdir('docs/var-log')
1935
1936# FIXME: figure out if the warning is true:
1937# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
1938install_subdir('factory/etc',
1939 install_dir : factorydir)
1940
1941
1942install_data('xorg/50-systemd-user.sh',
1943 install_dir : xinitrcdir)
1944install_data('system-preset/90-systemd.preset',
1945 install_dir : systempresetdir)
1946install_data('README',
1947 'NEWS',
1948 'CODING_STYLE',
1949 'DISTRO_PORTING',
1950 'ENVIRONMENT.md',
1951 'LICENSE.GPL2',
1952 'LICENSE.LGPL2.1',
1953 'src/libsystemd/sd-bus/GVARIANT-SERIALIZATION',
1954 install_dir : docdir)
d68b342b 1955
94e75a54
ZJS
1956meson.add_install_script('sh', '-c', mkdir_p.format(systemdstatedir))
1957meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
1958
d68b342b
ZJS
1959############################################################
1960
1961if git.found() and etags.found()
1962 all_files = run_command(
1963 git,
1964 ['--git-dir=@0@/.git'.format(meson.source_root()),
1965 'ls-files',
1966 ':/*.[ch]'])
1967 all_files = files(all_files.stdout().split())
1968
1969 custom_target(
1970 'TAGS',
1971 output : 'TAGS',
1972 input : all_files,
1973 command : [etags, '-o', '@OUTPUT@'] + all_files)
1974endif