]> git.ipfire.org Git - thirdparty/util-linux.git/blame - meson.build
hardlink: use xcalloc rather than xmalloc
[thirdparty/util-linux.git] / meson.build
CommitLineData
d4c880d5 1project('util-linux', 'c',
e0c1a86b 2 version : run_command('tools/git-version-gen', check: true).stdout(),
c12276dd 3 meson_version: '>=0.60.0',
6240e445
TW
4 license : 'GPLv2+',
5 default_options : [
6 'c_std=c99',
7 'cpp_std=c++11',
8 ])
d4c880d5 9
3e0bbb12 10fs = import('fs')
d4c880d5
ZJS
11pkgconfig = import('pkgconfig')
12
311ea4e7
KZ
13# soname versions; This never change because we use symbols versioing. There is also
14# API version (LIB*_VERSION macros) and it follow package version.
d4c880d5 15libblkid_version = '1.1.0'
50736e49 16libblkid_date = '01-Jun-2021'
d4c880d5 17libuuid_version = '1.3.0'
476c8614 18liblastlog2_version = '2.0.0'
d4c880d5
ZJS
19libmount_version = '1.1.0'
20libsmartcols_version = '1.1.0'
21libfdisk_version = '1.1.0'
22
23prefixdir = get_option('prefix')
24if not prefixdir.startswith('/')
25 error('Prefix is not absolute: "@0@"'.format(prefixdir))
26endif
27bindir = join_paths(prefixdir, get_option('bindir'))
28sbindir = join_paths(prefixdir, get_option('sbindir'))
29sysconfstaticdir = join_paths(prefixdir, 'lib')
12ebed03 30docdir = join_paths(prefixdir, get_option('datadir'), 'doc', 'util-linux')
53b37016 31mandir = join_paths(prefixdir, get_option('mandir'))
d4c880d5 32runstatedir = '/run'
107b2fbe 33localstatedir = '/var'
0eb2a476 34execprefixdir = prefixdir
5e67b421 35sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
0eb2a476
KL
36usrbin_exec_dir = join_paths(execprefixdir, bindir)
37usrsbin_exec_dir = join_paths(execprefixdir, sbindir)
38bb89ee 38bash_completion = dependency('bash-completion', required : get_option('build-bash-completion'))
d4c880d5 39
308a0979
KZ
40vendordir = get_option('vendordir')
41
b1a76c22 42add_project_arguments('-D_GNU_SOURCE', '-fsigned-char', language : 'c')
d4c880d5
ZJS
43
44cc = meson.get_compiler('c')
45
46conf = configuration_data()
3e43f629
RP
47conf.set_quoted('PACKAGE', meson.project_name())
48conf.set_quoted('PACKAGE_VERSION', meson.project_version())
d4c880d5
ZJS
49package_string = '@0@ @1@'.format(meson.project_name(), meson.project_version())
50conf.set_quoted('PACKAGE_STRING', package_string)
d4c880d5 51
d4c880d5 52pc_version = []
922d025a 53pc_version = meson.project_version().split('-')[0].split('.')
54
55if pc_version.length() < 3
56 pc_version += '0'
57endif
58
d4c880d5
ZJS
59pc_version = '.'.join(pc_version)
60
311ea4e7 61conf.set_quoted('LIBBLKID_VERSION', pc_version)
d4c880d5
ZJS
62conf.set_quoted('LIBBLKID_DATE', libblkid_date)
63
64conf.set('bindir', bindir)
65conf.set('sbindir', sbindir)
66conf.set('runstatedir', runstatedir)
107b2fbe 67conf.set('localstatedir', localstatedir)
5e67b421 68conf.set('sysconfdir', sysconfdir)
7c080286 69conf.set('usrbin_execdir', usrbin_exec_dir)
d4c880d5
ZJS
70conf.set('usrsbin_execdir', usrsbin_exec_dir)
71conf.set('docdir', docdir)
72conf.set_quoted('_PATH_SYSCONFSTATICDIR', sysconfstaticdir)
73conf.set_quoted('_PATH_RUNSTATEDIR', runstatedir)
107b2fbe 74conf.set_quoted('_PATH_LOCALSTATEDIR', localstatedir)
d4c880d5
ZJS
75conf.set_quoted('CONFIG_ADJTIME_PATH', '/etc/adjtime')
76conf.set_quoted('ADJTIME_PATH', '/etc/adjtime') # yes, both are used :(
77
308a0979
KZ
78conf.set_quoted('_PATH_VENDORDIR', vendordir)
79conf.set('USE_VENDORDIR', vendordir == '' ? false : 1)
80
efce415c 81build_libblkid = get_option('build-libblkid').allowed()
d4c880d5
ZJS
82conf.set('HAVE_LIBBLKID', build_libblkid ? 1 : false)
83summary('libblkid', build_libblkid ? 'enabled' : 'disabled', section : 'components')
84
85build_libuuid = not get_option('build-libuuid').disabled()
86conf.set('HAVE_LIBUUID', build_libuuid ? 1 : false)
87summary('libuuid', build_libuuid ? 'enabled' : 'disabled', section : 'components')
88
66463f0c
JW
89lib_sqlite3 = dependency('sqlite3', required : get_option('build-liblastlog2'))
90build_liblastlog2 = get_option('build-liblastlog2').require(lib_sqlite3.found()).allowed()
c2e299d0
SS
91conf.set('HAVE_LIBLASTLOG2', build_liblastlog2 ? 1 : false)
92summary('liblastlog2', build_liblastlog2 ? 'enabled' : 'disabled', section : 'components')
93
e8b6e4ea
SS
94login_lastlogin = get_option('login-lastlogin')
95conf.set('USE_LOGIN_LASTLOG', login_lastlogin ? 1 : false)
96summary('login-lastlogin', login_lastlogin ? 'enabled' : 'disabled', section : 'components')
97
e23c3262
KZ
98have_mountfd_api = cc.sizeof('struct mount_attr', prefix : '#include <linux/mount.h>') > 0
99conf.set('HAVE_STRUCT_MOUNT_ATTR', have_mountfd_api ? 1 : false)
100conf.set('HAVE_MOUNTFD_API', have_mountfd_api ? 1 : false)
101
7d679f29 102have_struct_statx = cc.sizeof('struct statx', prefix : '#include <sys/stat.h>') > 0
8bcf89d3
TW
103conf.set('HAVE_STRUCT_STATX', have_struct_statx ? 1 : false)
104
b8b63b36
JW
105have_sys_vfs_header = cc.has_header('sys/vfs.h')
106
107build_libmount = get_option('build-libmount').require(
108 get_option('build-libblkid').allowed() \
109 and have_sys_vfs_header \
110).allowed()
b6799ccb 111
d4c880d5 112conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
375ccf08 113conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
e23c3262 114conf.set('USE_LIBMOUNT_MOUNTFD_SUPPORT', have_mountfd_api ? 1 : false)
d4c880d5
ZJS
115summary('libmount', build_libmount ? 'enabled' : 'disabled', section : 'components')
116
117build_libsmartcols = not get_option('build-libsmartcols').disabled()
118conf.set('HAVE_LIBSMARTCOLS', build_libsmartcols ? 1 : false)
119summary('libsmartcols', build_libsmartcols ? 'enabled' : 'disabled', section : 'components')
120
b6799ccb 121build_libfdisk = not get_option('build-libfdisk').require(get_option('build-libblkid').allowed()).disabled()
d4c880d5
ZJS
122conf.set('HAVE_LIBFDISK', build_libfdisk ? 1 : false)
123summary('libfdisk', build_libfdisk ? 'enabled' : 'disabled', section : 'components')
124
125build_uuidd = not get_option('build-uuidd').disabled()
126conf.set('HAVE_UUIDD', build_uuidd ? 1 : false)
127summary('uuidd', build_uuidd ? 'enabled' : 'disabled', section : 'components')
128
69939195
ZJS
129static_programs = get_option('static-programs')
130need_static_libs = static_programs.length() > 0 # a rough estimate...
131summary('static programs', static_programs)
132
d4c880d5
ZJS
133LINUX = host_machine.system() in ['linux']
134BSD = host_machine.system() in ['dragonfly', 'freebsd', 'netbsd', 'openbsd']
135
136############################################################
137
138code = '''
139#include <wchar.h>
140#include <wctype.h>
141#include <stdio.h>
142#include <stdlib.h>
143int main(void) {
144 wchar_t wc;
145 wint_t w;
146 w = fgetwc(stdin);
147 if (w == WEOF)
148 return 1;
149 wc = w;
150 fputwc(wc,stdout);
151 return 0;
152}
153'''
154have = cc.compiles(code, name : 'wchar_t support')
155if not have and get_option('widechar').enabled()
156 error('widechar support requested but unavailable')
157endif
158if get_option('ncurses').enabled() and get_option('widechar').enabled()
159 error('widechar support is incompatible with non-wide ncurses')
160endif
161conf.set('HAVE_WIDECHAR', have ? 1 : false)
162
163headers = '''
164 byteswap.h
165 crypt.h
166 endian.h
167 err.h
168 errno.h
169 fcntl.h
170 getopt.h
171 inttypes.h
172 langinfo.h
173 lastlog.h
174 libutil.h
175 locale.h
176 mntent.h
177 paths.h
178 pty.h
179 shadow.h
180 stdint.h
181 stdio_ext.h
182 stdlib.h
183 string.h
184 strings.h
185 unistd.h
186 utmp.h
187 utmpx.h
908ac36f
MY
188 asm-generic/fcntl.h
189 asm/fcntl.h
d4c880d5
ZJS
190 asm/io.h
191 linux/blkzoned.h
192 linux/capability.h
193 linux/cdrom.h
194 linux/compiler.h
195 linux/falloc.h
196 linux/fd.h
0e186591 197 linux/fs.h
647f80e4
KZ
198 linux/fiemap.h
199 linux/gsmmux.h
0e186591 200 linux/if_alg.h
ae015d71 201 linux/landlock.h
0e186591 202 linux/kcmp.h
d4c880d5 203 linux/net_namespace.h
647f80e4 204 linux/nsfs.h
241e4a48 205 linux/mount.h
0e186591 206 linux/pr.h
d4c880d5
ZJS
207 linux/securebits.h
208 linux/tiocl.h
209 linux/version.h
210 linux/watchdog.h
211 net/if.h
212 net/if_dl.h
213 netinet/in.h
214 security/openpam.h
215 security/pam_appl.h
216 security/pam_misc.h
6b61e282 217 security/pam_modules.h
d4c880d5
ZJS
218 sys/disk.h
219 sys/disklabel.h
220 sys/endian.h
221 sys/file.h
222 sys/io.h
223 sys/ioccom.h
224 sys/ioctl.h
225 sys/mkdev.h
226 sys/mount.h
227 sys/param.h
aa5adf24 228 sys/pidfd.h
d4c880d5
ZJS
229 sys/prctl.h
230 sys/resource.h
6e92db54 231 sys/sendfile.h
d4c880d5
ZJS
232 sys/signalfd.h
233 sys/socket.h
234 sys/sockio.h
235 sys/stat.h
0e186591 236 sys/statfs.h
d4c880d5
ZJS
237 sys/swap.h
238 sys/syscall.h
239 sys/sysmacros.h
240 sys/time.h
241 sys/timex.h
242 sys/ttydefaults.h
243 sys/types.h
244 sys/ucred.h
245 sys/un.h
0e186591 246 sys/vfs.h
647f80e4 247 sys/xattr.h
d4c880d5
ZJS
248'''.split()
249
250lib_m = cc.find_library('m')
251
252lib_tinfo = dependency(
253 'tinfo',
5f931ae8 254 disabler : true,
d4c880d5
ZJS
255 required : get_option('tinfo'))
256
257lib_ncursesw = dependency(
258 'ncursesw',
259 required : get_option('ncursesw'))
260if lib_ncursesw.found()
261 headers += ['ncursesw/ncurses.h',
262 'ncursesw/term.h',
263 'ncurses.h',
264 'term.h']
265 lib_ncurses = disabler()
266else
267 lib_ncurses = dependency(
268 'ncurses',
d632e5da 269 disabler : true,
d4c880d5
ZJS
270 required : get_option('ncurses'))
271 headers += ['ncurses.h',
272 'term.h']
273endif
274
275conf.set('HAVE_LIBNCURSESW', lib_ncursesw.found())
276conf.set('HAVE_LIBNCURSES', lib_ncurses.found())
277conf.set('HAVE_NCURSES', lib_ncursesw.found() or lib_ncurses.found())
278
279lib_slang = dependency(
280 'slang',
281 required : get_option('slang'))
282if lib_slang.found()
283 headers += ['slang.h',
284 'slang/slang.h',
285 'slcurses.h',
286 'slang/slcurses.h']
287endif
288conf.set('HAVE_SLANG', lib_slang.found())
289
290foreach curses_libs : [lib_slang, lib_ncursesw, lib_ncurses]
291 if curses_libs.found()
6e13cfed
KZ
292 have = cc.has_function('use_default_colors', dependencies : curses_libs)
293 conf.set('HAVE_USE_DEFAULT_COLORS', have ? 1 : false)
294 have = cc.has_function('resizeterm', dependencies : curses_libs)
295 conf.set('HAVE_RESIZETERM', have ? 1 : false)
d4c880d5
ZJS
296 break
297 endif
298endforeach
299
300lib_z = dependency(
301 'zlib',
2c02ce7c 302 disabler : true,
d4c880d5
ZJS
303 required : get_option('zlib'))
304
305lib_readline = dependency(
306 'readline',
307 required : get_option('readline'))
308conf.set('HAVE_LIBREADLINE', lib_readline.found() ? 1 : false)
309
69939195
ZJS
310lib_readline_static = dependency(
311 'readline',
312 static : true,
313 required : need_static_libs ? get_option('readline') : disabler())
314
fc63a3d0
RP
315if meson.version().version_compare('>= 0.59.0')
316 lib_intl = dependency(
317 'intl',
318 required : get_option('nls'))
319 conf.set('ENABLE_NLS', lib_intl.found() ? 1 : false)
320else
321 if get_option('nls').enabled()
322 error('nls is not supported with meson before 0.59.0')
323 endif
324 lib_intl = dependency('', required : false)
325endif
326
d4c880d5
ZJS
327lib_user = dependency(
328 'libuser',
329 version : '>= 0.58',
330 required : get_option('libuser'))
331conf.set('HAVE_LIBUSER', lib_user.found() ? 1 : false)
332
333lib_util = cc.find_library(
334 'util',
335 required : get_option('libutil'))
336conf.set('HAVE_LIBUTIL', lib_util.found() ? 1 : false)
337
338lib_utempter = cc.find_library(
339 'utempter',
340 required : get_option('libutempter'))
341conf.set('HAVE_LIBUTEMPTER', lib_utempter.found() ? 1 : false)
342
343systemd = dependency(
344 'systemd',
345 required : get_option('systemd'))
346
347lib_systemd = dependency(
348 'libsystemd',
349 required : get_option('systemd'))
350conf.set('HAVE_LIBSYSTEMD', lib_systemd.found() ? 1 : false)
0e186591 351conf.set('USE_SYSTEMD', lib_systemd.found() ? 1 : false)
d4c880d5 352
87fcd95a
TK
353have = cc.has_function(
354 'sd_session_get_username',
355 dependencies : lib_systemd)
356conf.set('HAVE_DECL_SD_SESSION_GET_USERNAME', have ? 1 : false)
357
d4c880d5
ZJS
358lib_udev = dependency(
359 'libudev',
360 required : get_option('systemd'))
361conf.set('HAVE_LIBUDEV', lib_udev.found() ? 1 : false)
362
d0a07e7f
JW
363lib_crypt = cc.find_library('crypt', required : get_option('build-newgrp'))
364if not lib_crypt.found()
365 lib_crypt = cc.find_library('crypt', required : get_option('build-sulogin'))
366endif
d4c880d5 367
9e3c5d1b
JW
368lib_pam = cc.find_library(
369 'pam',
370 disabler : true,
371 required : get_option('build-login').enabled() or \
372 get_option('build-chfn-chsh').enabled() or \
373 get_option('build-su').enabled() or \
374 get_option('build-runuser').enabled())
d4c880d5
ZJS
375if lib_pam.found()
376 lib_pam_misc = cc.find_library('pam_misc')
377 lib_pam = [lib_pam, lib_pam_misc]
7bce9496
RP
378else
379 lib_pam_misc = declare_dependency()
d4c880d5
ZJS
380endif
381
382lib_cryptsetup = dependency(
383 'libcryptsetup',
384 required : get_option('cryptsetup'))
385conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
386
c12f8998
ZJS
387cryptsetup_dlopen = not get_option('cryptsetup').disabled() and get_option('cryptsetup-dlopen').enabled()
388if cryptsetup_dlopen
324aa32c
RP
389 if meson.version().version_compare('>= 0.62.0')
390 lib_dl = dependency('dl')
391 else
392 lib_dl = cc.find_library('dl')
393 endif
e6a4b4a1
LB
394 conf.set('CRYPTSETUP_VIA_DLOPEN', 1)
395 summary('cryptsetup support (dlopen)',
396 'enabled',
397 section : 'components')
398else
399 summary('cryptsetup support',
400 lib_cryptsetup.found() ? 'enabled' : 'disabled',
401 section : 'components')
402endif
6e92db54 403
d4c880d5
ZJS
404have = cc.has_function(
405 'crypt_activate_by_signed_key',
406 dependencies : lib_cryptsetup)
5a6e9adf 407conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
d4c880d5
ZJS
408
409lib_cap_ng = dependency(
cd23a433
RP
410 'libcap-ng',
411 required : get_option('build-setpriv'))
512c91a6
TW
412if not lib_cap_ng.found()
413 lib_cap_ng = disabler()
414endif
d4c880d5
ZJS
415
416lib_selinux = dependency(
417 'libselinux',
6e92db54 418 version : '>= 2.5',
d4c880d5
ZJS
419 required : get_option('selinux'))
420conf.set('HAVE_LIBSELINUX', lib_selinux.found() ? 1 : false)
421
6e92db54
KZ
422lib_magic = dependency(
423 'libmagic',
424 required : get_option('magic'))
425conf.set('HAVE_MAGIC', lib_magic.found() ? 1 : false)
426
427lib_econf = dependency(
428 'libeconf',
429 required : get_option('econf'))
430conf.set('HAVE_LIBECONF', lib_econf.found() ? 1 : false)
431
d4c880d5 432lib_audit = dependency(
b2ae39f6 433 'audit',
d4c880d5
ZJS
434 required : get_option('audit'))
435conf.set('HAVE_LIBAUDIT', lib_audit.found() ? 1 : false)
436
437conf.set('HAVE_SMACK', not get_option('smack').disabled())
438
9e970370 439
d4c880d5
ZJS
440foreach header : headers
441 have = cc.has_header(header)
442 conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
443endforeach
444
445header = 'linux/btrfs.h'
446enable_btrfs = cc.has_header(header,
447 required : get_option('btrfs'))
448conf.set('HAVE_' + header.underscorify().to_upper(), enable_btrfs ? 1 : false)
449conf.set('HAVE_BTRFS_SUPPORT', enable_btrfs ? 1 : false)
450
451prefix = conf.get('HAVE_LINUX_COMPILER_H') ? '#include <linux/compiler.h>' : ''
452foreach header : [
453 'linux/blkpg.h',
454 'linux/major.h',
455]
456 have = cc.has_header(header,
457 prefix : prefix)
458 conf.set('HAVE_' + header.underscorify().to_upper(), have ? 1 : false)
459endforeach
460
461have = cc.has_header('sched.h')
462conf.set10('HAVE_DECL_CPU_ALLOC', have)
463# We get -1 if the size cannot be determined
4194bb5b 464have_cpu_set_t = cc.sizeof('cpu_set_t', prefix : '#define _GNU_SOURCE\n#include <sched.h>') > 0
d4c880d5
ZJS
465conf.set('HAVE_CPU_SET_T', have_cpu_set_t ? 1 : false)
466
5afe34ef 467have = cc.has_header_symbol('unistd.h', 'environ', args : '-D_GNU_SOURCE')
640754e2 468conf.set('HAVE_ENVIRON_DECL', have ? 1 : false)
d4c880d5 469
5afe34ef 470have = cc.has_header_symbol('signal.h', 'sighandler_t', args : '-D_GNU_SOURCE')
d4c880d5
ZJS
471conf.set('HAVE_SIGHANDLER_T', have ? 1 : false)
472
f3b9a18e 473have = cc.has_function('strsignal')
d4c880d5
ZJS
474conf.set10('HAVE_STRSIGNAL_DECL', have)
475
476have = cc.sizeof('union semun', prefix : '#include <sys/sem.h>') > 0
477conf.set('HAVE_UNION_SEMUN', have ? 1 : false)
478
1eeabbb4
TW
479have = cc.has_type('loff_t',
480 args : '-D_GNU_SOURCE',
481 prefix : '#include <sys/types.h>')
0e186591
TW
482conf.set('HAVE_LOFF_T', have ? 1 : false)
483
d4c880d5
ZJS
484have = cc.compiles('''
485 #define _GNU_SOURCE 1
486 #include <langinfo.h>
487 int main(void) {
488 char *str;
489 str = nl_langinfo (ALTMON_1);
490 str = nl_langinfo (ALTMON_2);
491 str = nl_langinfo (ALTMON_3);
492 str = nl_langinfo (ALTMON_4);
493 str = nl_langinfo (ALTMON_5);
494 str = nl_langinfo (ALTMON_6);
495 str = nl_langinfo (ALTMON_7);
496 str = nl_langinfo (ALTMON_8);
497 str = nl_langinfo (ALTMON_9);
498 str = nl_langinfo (ALTMON_10);
499 str = nl_langinfo (ALTMON_11);
500 str = nl_langinfo (ALTMON_12);
501 return 0;
502 }
503 ''',
504 name : 'langinfo.h defines ALTMON_x constants')
505conf.set('HAVE_LANGINFO_ALTMON', have ? 1 : false)
506
507have = cc.compiles('''
508 #define _GNU_SOURCE 1
509 #include <langinfo.h>
510 int main(void) {
511 char *str;
512 str = nl_langinfo (_NL_ABALTMON_1);
513 str = nl_langinfo (_NL_ABALTMON_2);
514 str = nl_langinfo (_NL_ABALTMON_3);
515 str = nl_langinfo (_NL_ABALTMON_4);
516 str = nl_langinfo (_NL_ABALTMON_5);
517 str = nl_langinfo (_NL_ABALTMON_6);
518 str = nl_langinfo (_NL_ABALTMON_7);
519 str = nl_langinfo (_NL_ABALTMON_8);
520 str = nl_langinfo (_NL_ABALTMON_9);
521 str = nl_langinfo (_NL_ABALTMON_10);
522 str = nl_langinfo (_NL_ABALTMON_11);
523 str = nl_langinfo (_NL_ABALTMON_12);
524 return 0;
525 }
526 ''',
527 name : 'langinfo.h defines _NL_ABALTMON_x constants')
528conf.set('HAVE_LANGINFO_NL_ABALTMON', have ? 1 : false)
529
17bc58e0
CH
530have = cc.compiles('''
531 #define _GNU_SOURCE 1
532 #include <langinfo.h>
533 int main(void) {
534 char *str;
535 str = nl_langinfo (_NL_TIME_WEEK_1STDAY);
536 return 0;
537 }
538 ''',
539 name : 'langinfo.h defines _NL_TIME_WEEK_1STDAY constant')
540conf.set('HAVE_DECL__NL_TIME_WEEK_1STDAY', have ? 1 : false)
541
d4c880d5 542funcs = '''
c214cbeb 543 cachestat
d4c880d5 544 clearenv
5bd1462d 545 close_range
d4c880d5
ZJS
546 __fpurge
547 fpurge
548 __fpending
549 secure_getenv
550 __secure_getenv
551 eaccess
552 err
553 errx
554 explicit_bzero
d9b022bd 555 fnmatch
d4c880d5 556 fseeko
0120be6f
KZ
557 fsconfig
558 fsmount
559 fsopen
560 fspick
d4c880d5 561 fsync
0e186591 562 getttynam
d4c880d5
ZJS
563 utimensat
564 getdomainname
565 getdtablesize
566 getexecname
567 getmntinfo
568 getrandom
569 getrlimit
570 getsgnam
571 inotify_init
572 jrand48
ae015d71
TW
573 landlock_create_ruleset
574 landlock_add_rule
575 landlock_restrict_self
d4c880d5 576 lchown
6124a6a3
TW
577 lgetxattr
578 llistxattr
d4c880d5 579 llseek
5bd1462d 580 newlocale
d4c880d5 581 mkostemp
10efb9ea
KZ
582 move_mount
583 mount_setattr
d4c880d5
ZJS
584 nanosleep
585 ntp_gettime
10efb9ea 586 open_tree
d4c880d5
ZJS
587 personality
588 pidfd_open
589 pidfd_send_signal
590 posix_fadvise
591 prctl
592 qsort_r
0322c9cd 593 reallocarray
cd094a05 594 renameat2
d4c880d5
ZJS
595 rpmatch
596 scandirat
597 setprogname
5bd1462d 598 sendfile
d4c880d5
ZJS
599 setns
600 setresgid
601 setresuid
602 sched_setattr
603 sched_setscheduler
604 sigqueue
605 srandom
30c59d67 606 statx
d4c880d5
ZJS
607 strnchr
608 strndup
609 strnlen
5bd1462d 610 strtod_l
d4c880d5
ZJS
611 sysconf
612 sysinfo
613 swapon
614 swapoff
615 timegm
616 unshare
617 usleep
5bd1462d
TW
618 uselocale
619 utimensat
d4c880d5
ZJS
620 vwarnx
621 warn
622 warnx
623 prlimit
624
625 openat
626 fstatat
627 unlinkat
628 ioperm
629 iopl
630 futimens
631 inotify_init1
632 open_memstream
633 reboot
634 getusershell
635'''.split()
636
637foreach func: funcs
638 have = cc.has_function(func)
993556aa 639 # For autotools compatibility, use either #define FOO 1 or #undef FOO.
d4c880d5
ZJS
640 # This makes little sense, but is necessary to avoid warnings about
641 # redefined macros from Python.h, which uses this convention.
642 conf.set('HAVE_' + func.to_upper(), have ? 1 : false)
d4c880d5
ZJS
643endforeach
644
2c5a42b3
JW
645have_mempcpy = cc.has_function('mempcpy', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
646conf.set('HAVE_MEMPCPY', have_mempcpy ? 1 : false)
647
d4c880d5
ZJS
648have = conf.get('HAVE_FUTIMENS') in [1] and conf.get('HAVE_INOTIFY_INIT1') in [1]
649conf.set('AGETTY_RELOAD', have ? 1 : false)
650if not have
651 warning('futimens or inotify_init1 not found; agetty(8) will not provide --reload functionality')
652endif
653
654have_dirfd = (cc.has_function('dirfd') or
655 cc.has_header_symbol('dirent.h', 'dirfd',
656 prefix : '#include <sys/types.h>'))
657conf.set('HAVE_DIRFD', have_dirfd ? 1 : false)
658
659have_ddfd = cc.has_member('DIR', 'dd_fd',
660 prefix : '''
661 #include <sys/types.h>
662 #include <dirent.h>
663 ''')
664conf.set('HAVE_DECL_DDFD', have_ddfd ? 1 : false)
665
666have = cc.has_member('struct tm', 'tm_gmtoff',
1eeabbb4 667 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
668 prefix : '''
669 #include <time.h>
670 #include <unistd.h>
671 ''')
672conf.set('HAVE_TM_GMTOFF', have ? 1 : false)
673
10efb9ea 674
10efb9ea 675
0120be6f 676have = cc.sizeof('enum fsconfig_command', prefix : '#include <linux/mount.h>') > 0
e23c3262 677conf.set('HAVE_ENUM_FSCONFIG_COMMAND', have ? 1 : false)
0120be6f 678
d4c880d5
ZJS
679have = cc.has_member('struct termios', 'c_line',
680 prefix : '#include <termios.h>')
681conf.set('HAVE_STRUCT_TERMIOS_C_LINE', have ? 1 : false)
682
683have = cc.has_member('struct stat', 'st_mtim.tv_nsec',
1eeabbb4 684 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
685 prefix : '#include <sys/stat.h>')
686conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', have ? 1 : false)
687
2f82c248 688have = cc.has_member('struct statx', 'stx_mnt_id',
7d679f29 689 prefix : '#include <sys/stat.h>')
2f82c248
KZ
690conf.set('HAVE_STRUCT_STATX_STX_MNT_ID', have ? 1 : false)
691
d4c880d5
ZJS
692# replacement for AC_STRUCT_TIMEZONE
693have = cc.has_member('struct tm', 'tm_zone',
1eeabbb4 694 args : '-D_GNU_SOURCE',
d4c880d5
ZJS
695 prefix : '#include <time.h>')
696conf.set('HAVE_STRUCT_TM_TM_ZONE', have ? 1 : false)
697
5afe34ef 698have = cc.has_header_symbol('time.h', 'tzname', args: '-D_GNU_SOURCE')
d4c880d5
ZJS
699conf.set('HAVE_DECL_TZNAME', have ? 1 : false)
700
0e186591
TW
701have = cc.has_header_symbol('linux/blkzoned.h', 'BLK_ZONE_REP_CAPACITY')
702conf.set('HAVE_DECL_BLK_ZONE_REP_CAPACITY', have ? 1 : false)
703
704have = cc.has_header_symbol('linux/pr.h', 'PR_REP_CAPACITY')
705conf.set('HAVE_DECL_PR_REP_CAPACITY', have ? 1 : false)
706
d4c880d5
ZJS
707code = '''
708#include <time.h>
709#if !@0@
710extern char *tzname[];
711#endif
712int main(void) {
713 return tzname ? 0 : 1;
714}
715'''.format(have ? 1 : 0)
e25db916 716have = cc.compiles(code, name : 'using tzname[]')
d4c880d5
ZJS
717conf.set('HAVE_TZNAME', have ? 1 : false)
718
a31f4c4f
TW
719have = cc.sizeof('time_t', prefix : '#include <time.h>')
720if have < 8
721 add_global_arguments('-D_TIME_BITS=64', language : 'c')
722 have = cc.sizeof('time_t', args : '-D_TIME_BITS=64', prefix : '#include <time.h>')
723 if have < 8
724 if get_option('allow-32bit-time')
725 warning('Could not make time_t 64bits wide')
726 else
727 error('Could not make time_t 64bits wide')
728 endif
729 endif
730endif
731
d4c880d5
ZJS
732socket_libs = []
733if not cc.has_function('socket')
734 socket_libs += cc.find_library('socket', required : true)
735 have = cc.has_function('socket',
736 dependencies : socket_libs)
737 if not have
738 error('socket() function not available')
739 endif
740endif
741
24395027 742lib_rt = cc.find_library('rt', required : false)
d4c880d5
ZJS
743realtime_libs = []
744have = cc.has_function('clock_gettime')
745if not have
06b27058
JW
746 if lib_rt.found()
747 realtime_libs += lib_rt
748 have = cc.has_function('clock_gettime',
749 dependencies : realtime_libs)
750 endif
d4c880d5 751endif
e51565b6 752conf.set('HAVE_CLOCK_GETTIME', have ? 1 : false)
d4c880d5
ZJS
753
754thread_libs = dependency('threads')
755
756have = cc.has_function('timer_create')
757if not have
06b27058
JW
758 if lib_rt.found()
759 realtime_libs = [lib_rt]
760 have = cc.has_function('timer_create',
761 dependencies : realtime_libs)
762 endif
d4c880d5
ZJS
763 if not have
764 realtime_libs += thread_libs
765 have = cc.has_function('timer_create',
766 dependencies : realtime_libs)
767 endif
768endif
769conf.set('HAVE_TIMER_CREATE', have ? 1 : false)
770if not have
771 have = cc.has_function('setitimer')
772 conf.set('HAVE_SETITIMER', have ? 1 : false)
773endif
774
775rtas_libs = cc.find_library('rtas', required : false)
776conf.set('HAVE_LIBRTAS', rtas_libs.found() ? 1 : false)
777
778math_libs = []
77765258 779if not cc.has_header_symbol('math.h', 'isnan')
d4c880d5
ZJS
780 lib = cc.find_library('m', required : true)
781 if (cc.has_function('isnan', dependencies : lib) and
782 cc.has_function('__isnan', dependencies : lib))
783 math_libs += lib
784 endif
785endif
786
787have = cc.has_header_symbol('errno.h', 'program_invocation_short_name',
788 args : '-D_GNU_SOURCE')
789conf.set('HAVE_PROGRAM_INVOCATION_SHORT_NAME', have ? 1 : false)
790
791code = '''
792extern char *__progname;
793int main(void) {
794 return (*__progname != 0);
795}
796'''
e25db916 797have = cc.compiles(code, name : 'using __progname')
d4c880d5
ZJS
798conf.set('HAVE___PROGNAME', have ? 1 : false)
799
941e1d55
TW
800have = conf.get('HAVE_PTY_H').to_string() == '1' \
801 and conf.get('HAVE_SYS_SIGNALFD_H').to_string() == '1'
44475360
ZJS
802conf.set('HAVE_PTY', have ? 1 : false)
803
a0cf9105
LB
804have_opal_get_status= cc.has_header_symbol('linux/sed-opal.h', 'IOC_OPAL_GET_STATUS')
805conf.set('HAVE_OPAL_GET_STATUS', have_opal_get_status ? 1 : false)
806
d4c880d5
ZJS
807build_plymouth_support = get_option('build-plymouth-support')
808have_tiocglcktrmios = cc.has_header_symbol(
809 'sys/ioctl.h', 'TIOCGLCKTRMIOS',
810 required : build_plymouth_support.enabled())
811have_sock_cloexec = cc.has_header_symbol(
812 'sys/socket.h', 'SOCK_CLOEXEC',
813 prefix : '#include <sys/types.h>',
814 required : build_plymouth_support.enabled())
815have_sock_nonblock = cc.has_header_symbol(
816 'sys/socket.h', 'SOCK_NONBLOCK',
817 prefix : '#include <sys/types.h>',
818 required : build_plymouth_support.enabled())
819have_so_passcred = cc.has_header_symbol(
820 'sys/socket.h', 'SO_PASSCRED',
b24dd22d 821 args : ['-D_GNU_SOURCE'],
d4c880d5
ZJS
822 prefix : '#include <sys/types.h>',
823 required : build_plymouth_support.enabled())
824
825build_plymouth_support = (not build_plymouth_support.disabled() and
826 have_tiocglcktrmios and
827 have_sock_cloexec and
828 have_sock_nonblock and
829 have_so_passcred)
830conf.set('ENABLE_PLYMOUTH_SUPPORT', build_plymouth_support ? 1 : false)
831summary('plymouth support',
832 build_plymouth_support ? 'enabled' : 'disabled',
833 section : 'components')
834
835# check for valid fallocate() function
836# with 32 bits glibc 2.10, fallocate() exists but not fallocate64()
837# when _FILE_OFFSET_BITS==64, fallocate() is redirect to fallocate64()
838# and program can't be linked.
839code = '''
840#define _GNU_SOURCE
841#include <unistd.h>
842#include <fcntl.h>
843
844int main(void) {
845 long ret;
846 ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0xfffffffful, 0xfffffffful);
847 return ret == 0 ? 0 : 1;
848}
849'''
850have = cc.links(code, name : 'fallocate() function')
851conf.set('HAVE_FALLOCATE', have ? 1 : false)
852
853code = '''
854#include <unistd.h>
855#include <fcntl.h>
856
857int main(void) {
858 long ret;
859 ret = posix_fallocate(0, 0xfffffffful, 0xfffffffful);
860 return ret == 0 ? 0 : 1;
861}
862'''
863have = cc.links(code, name : 'posix_fallocate() function')
864conf.set('HAVE_POSIX_FALLOCATE', have ? 1 : false)
865
866use_hwclock_cmos = host_machine.cpu_family() in ['x86', 'x86_64']
867message('Use CMOS clock: @0@'.format(use_hwclock_cmos))
868conf.set('USE_HWCLOCK_CMOS', use_hwclock_cmos ? 1 : false)
869
870conf.set('HAVE_TLS', get_option('use-tls') ? 1 : false)
871conf.set('PG_BELL', get_option('pg-bell') ? 1 : false)
e0806c40 872conf.set('USE_COLORS_BY_DEFAULT', get_option('colors-default') ? 1 : false)
d4c880d5 873
8886d84e
TW
874is_glibc = cc.has_header_symbol('limits.h', '__GLIBC__')
875
d4c880d5
ZJS
876############################################################
877
6e92db54 878
d4c880d5
ZJS
879fs_search_path = get_option('fs-search-path')
880fs_search_path_extra = get_option('fs-search-path-extra')
881if fs_search_path_extra != ''
882 fs_search_path = ':'.join(fs_search_path, fs_search_path_extra)
883endif
884conf.set_quoted('FS_SEARCH_PATH', fs_search_path)
885
38b15ca2 886systemdsystemunitdir = ''
fcbcb0cd 887if systemd.found()
e2b4f5be 888 systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
fcbcb0cd 889endif
6e92db54 890
5e67b421
CH
891sysvinit = get_option('sysvinit').enabled()
892sysvinitrcdir = sysconfdir + '/init.d'
893
ba30b89c 894program_tests = get_option('program-tests')
895
d4c880d5
ZJS
896chfn_chsh_password = get_option('chfn-chsh-password') or lib_user.found()
897conf.set('CHFN_CHSH_PASSWORD', chfn_chsh_password ? 1 : false)
898
899have = get_option('chsh-only-listed')
900conf.set('ONLY_LISTED_SHELLS', have ? 1 : false)
901
902have = get_option('use-tty-group')
903conf.set('USE_TTY_GROUP', have ? 1 : false)
904
a4eeda56
KZ
905bison = find_program('bison')
906flex = find_program('flex')
543f991f 907awk = find_program('gawk', 'mawk', 'nawk', 'awk')
a4eeda56 908
d4c880d5 909build_hwclock = not get_option('build-hwclock').disabled()
d4c880d5
ZJS
910bison_gen = generator(
911 bison,
912 output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
913 arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
914
b6799ccb
JW
915python_module = import('python')
916python = python_module.find_installation(
917 get_option('python'),
918 required : true,
919 disabler : true)
920
d4c880d5 921meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
38bb89ee 922meson_make_manpage_stub = meson.current_source_dir() + '/tools/meson-make-manpage-stub.sh'
d4c880d5 923
7da59534 924configure_file(
d4c880d5
ZJS
925 output : 'config.h',
926 configuration : conf)
927
5f2c862a 928add_project_arguments('-include', meson.current_build_dir() / 'config.h', language : 'c')
d4c880d5 929
24b8804b
TW
930compiler_flags = [
931 '-fno-common',
932
933 '-Waddress-of-packed-member',
934 '-Wdiscarded-qualifiers',
935 '-Wembedded-directive',
936 '-Wextra-semi',
937 '-Wformat-security',
938 '-Wimplicit-function-declaration',
939 '-Wmissing-declarations',
940 '-Wmissing-parameter-type',
941 '-Wmissing-prototypes',
942 '-Wnested-externs',
943 '-Wno-missing-field-initializers',
9df5ac34 944 '-Wold-style-definition',
24b8804b
TW
945 '-Wpointer-arith',
946 '-Wredundant-decls',
947 '-Wsign-compare',
948 '-Wstrict-prototypes',
949 '-Wtype-limits',
950 '-Wuninitialized',
951 '-Wunused-but-set-parameter',
952 '-Wunused-but-set-variable',
953 '-Wunused-parameter',
954 '-Wunused-result',
955 '-Wunused-variable',
a52f9bdd 956 '-Wvla',
2a91b213 957 '-Walloca',
24b8804b
TW
958]
959foreach compiler_flag : compiler_flags
960 if cc.has_argument(compiler_flag)
961 add_project_arguments(compiler_flag, language : 'c')
962 endif
963endforeach
964
53b37016 965manadocs = []
38bb89ee 966manlinks = {}
aa519054 967
38bb89ee 968bashcompletions = []
aa519054 969bashcompletionslinks = {}
53b37016 970
d4c880d5
ZJS
971subdir('include')
972subdir('lib')
973subdir('libblkid')
974subdir('libmount')
975subdir('libsmartcols')
976subdir('libuuid')
c2e299d0 977subdir('liblastlog2')
d4c880d5 978subdir('libfdisk')
c2e299d0 979subdir('pam_lastlog2')
d4c880d5
ZJS
980subdir('login-utils')
981subdir('sys-utils')
982subdir('disk-utils')
983subdir('misc-utils')
984subdir('text-utils')
985subdir('term-utils')
ac8be186 986subdir('lsfd-cmd')
d4c880d5
ZJS
987subdir('po')
988
989includes = [dir_include,
d4c880d5 990 dir_libsmartcols,
d4c880d5
ZJS
991 dir_libfdisk,
992 dir_libuuid,
c2e299d0 993 dir_liblastlog2,
d4c880d5
ZJS
994 dir_sys_utils]
995
996exes = []
997
998opt = not get_option('build-chfn-chsh').disabled()
999exe = executable(
1000 'chfn',
1001 chfn_sources,
1002 chfn_chsh_sources,
1003 include_directories : includes,
0333c40b 1004 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1005 dependencies : chfn_chsh_deps,
1006 install_dir : usrbin_exec_dir,
60d457f5 1007 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1008 install : opt,
1009 build_by_default : opt)
38bb89ee 1010
d4c880d5
ZJS
1011exe2 = executable(
1012 'chsh',
1013 'login-utils/chsh.c',
4b724469 1014 'lib/shells.c',
d4c880d5
ZJS
1015 chfn_chsh_sources,
1016 include_directories : includes,
1017 link_with : lib_common,
1018 dependencies : chfn_chsh_deps,
1019 install_dir : usrbin_exec_dir,
a13574b1 1020 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1021 install : opt,
1022 build_by_default : opt)
1023if opt and not is_disabler(exe)
1024 exes += [exe, exe2]
38bb89ee
TW
1025 manadocs += ['login-utils/chfn.1.adoc', 'login-utils/chsh.1.adoc']
1026 bashcompletions += ['chfn', 'chsh']
d4c880d5
ZJS
1027endif
1028
1029exe = executable(
1030 'test_islocal',
1031 test_islocal_sources,
1032 include_directories : includes,
ba30b89c 1033 c_args : '-DTEST_PROGRAM',
1034 build_by_default : program_tests)
d4c880d5
ZJS
1035exes += exe
1036
d4c880d5
ZJS
1037exe = executable(
1038 'test-consoles',
1039 test_consoles_sources,
1040 c_args : ['-DTEST_PROGRAM'],
1041 include_directories : includes,
ba30b89c 1042 link_with : lib_common,
1043 build_by_default : program_tests)
d4c880d5
ZJS
1044exes += exe
1045
1046opt = not get_option('build-last').disabled()
1047exe = executable(
1048 'last',
1049 last_sources,
1050 include_directories : includes,
1051 link_with : [lib_common],
1052 install_dir : usrbin_exec_dir,
1053 install : opt,
1054 build_by_default : opt)
1055if opt and not is_disabler(exe)
1056 exes += exe
1057 meson.add_install_script(meson_make_symlink,
1058 'last',
1059 join_paths(usrbin_exec_dir, 'lastb'))
38bb89ee
TW
1060 manadocs += ['login-utils/last.1.adoc']
1061 manlinks += {'lastb.1': 'last.1'}
1062 bashcompletions += ['last']
aa519054 1063 bashcompletionslinks += {'lastb': 'last'}
d4c880d5
ZJS
1064endif
1065
1066opt = not get_option('build-nologin').disabled()
1067exe = executable(
1068 'nologin',
1069 'login-utils/nologin.c',
1070 include_directories : includes,
1071 install_dir : sbindir,
308a0979 1072 link_with : [lib_common],
d4c880d5
ZJS
1073 install : opt,
1074 build_by_default : opt)
1075if opt and not is_disabler(exe)
1076 exes += exe
38bb89ee 1077 manadocs += ['login-utils/nologin.8.adoc']
d4c880d5
ZJS
1078endif
1079
1080opt = not get_option('build-utmpdump').disabled()
1081exe = executable(
1082 'utmpdump',
1083 'login-utils/utmpdump.c',
1084 include_directories : includes,
1085 link_with : [lib_common],
1086 install_dir : usrbin_exec_dir,
1087 install : opt,
1088 build_by_default : opt)
1089if opt and not is_disabler(exe)
1090 exes += exe
38bb89ee
TW
1091 manadocs += ['login-utils/utmpdump.1.adoc']
1092 bashcompletions += ['utmpdump']
d4c880d5
ZJS
1093endif
1094
1095opt = not get_option('build-su').disabled()
1096exe = executable(
1097 'su',
1098 'login-utils/su.c',
1099 'login-utils/su-common.c',
1100 'login-utils/su-common.h',
4b724469 1101 'lib/shells.c',
d4c880d5
ZJS
1102 pty_session_c,
1103 monotonic_c,
1104 include_directories : includes,
0333c40b 1105 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1106 dependencies : [lib_pam,
1107 lib_pam_misc,
1108 lib_util,
1109 realtime_libs],
fb8c224e 1110 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1111 install : opt,
1112 build_by_default : opt)
1113if opt and not is_disabler(exe)
1114 exes += exe
38bb89ee
TW
1115 manadocs += ['login-utils/su.1.adoc']
1116 bashcompletions += ['su']
d4c880d5
ZJS
1117endif
1118
1119opt = not get_option('build-newgrp').disabled()
1120exe = executable(
1121 'newgrp',
1122 'login-utils/newgrp.c',
1123 include_directories : includes,
1124 dependencies : [lib_crypt],
1125 install_dir : usrbin_exec_dir,
cb3dee5a 1126 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1127 install : opt,
1128 build_by_default : opt)
1129if opt and not is_disabler(exe)
1130 exes += exe
38bb89ee 1131 manadocs += ['login-utils/newgrp.1.adoc']
f265b432 1132 bashcompletions += ['newgrp']
d4c880d5
ZJS
1133endif
1134
1135opt = not get_option('build-lslogins').disabled()
1136exe = executable(
1137 'lslogins',
1138 'login-utils/lslogins.c',
d4c880d5
ZJS
1139 include_directories : includes,
1140 link_with : [lib_common,
0333c40b 1141 lib_smartcols,
13d2fd8f
TW
1142 logindefs_c] +
1143 (build_liblastlog2 ? [lib_lastlog2] : []),
d4c880d5
ZJS
1144 dependencies : [lib_selinux,
1145 lib_systemd],
1146 install_dir : usrbin_exec_dir,
1147 install : opt,
1148 build_by_default : opt)
1149if opt and not is_disabler(exe)
1150 exes += exe
38bb89ee
TW
1151 manadocs += ['login-utils/lslogins.1.adoc']
1152 bashcompletions += ['lslogins']
d4c880d5
ZJS
1153endif
1154
1155opt = not get_option('build-vipw').disabled()
1156exe = executable(
1157 'vipw',
1158 'login-utils/vipw.c',
1159 'login-utils/setpwnam.h',
1160 include_directories : includes,
1161 link_with : [lib_common],
1162 dependencies : [lib_selinux],
1163 install_dir : usrbin_exec_dir,
1164 install : opt,
1165 build_by_default : opt)
1166if opt and not is_disabler(exe)
1167 exes += exe
1168 meson.add_install_script(meson_make_symlink,
1169 'vipw',
1170 join_paths(usrbin_exec_dir, 'vigr'))
38bb89ee 1171 manadocs += ['login-utils/vipw.8.adoc']
f6fb7fa7
CH
1172 meson.add_install_script(meson_make_symlink,
1173 'vipw.8',
1174 join_paths(mandir, 'man8/vigr.8'))
d4c880d5
ZJS
1175endif
1176
1177opt = not get_option('build-runuser').disabled()
1178exe = executable(
1179 'runuser',
1180 'login-utils/runuser.c',
1181 'login-utils/su-common.c',
1182 'login-utils/su-common.h',
4b724469 1183 'lib/shells.c',
d4c880d5
ZJS
1184 pty_session_c,
1185 monotonic_c,
1186 include_directories : includes,
0333c40b 1187 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1188 dependencies : [lib_pam,
1189 lib_pam_misc,
1190 lib_util,
1191 realtime_libs],
1192 install_dir : sbindir,
1193 install : opt,
1194 build_by_default : opt)
1195if opt and not is_disabler(exe)
1196 exes += exe
38bb89ee 1197 manadocs += ['login-utils/runuser.1.adoc']
aa519054 1198 bashcompletionslinks += {'runuser': 'su'}
d4c880d5
ZJS
1199endif
1200
1201############################################################
1202
8886d84e
TW
1203if is_glibc
1204 exe = executable(
1205 'col',
1206 col_sources,
1207 include_directories : includes,
1208 link_with : lib_common,
1209 install_dir : usrbin_exec_dir,
1210 install : true)
1211 exes += exe
1212 manadocs += ['text-utils/col.1.adoc']
1213 bashcompletions += ['col']
1214endif
d4c880d5
ZJS
1215
1216exe = executable(
1217 'colcrt',
1218 colcrt_sources,
1219 include_directories : includes,
1220 install_dir : usrbin_exec_dir,
1221 install : true)
1222exes += exe
38bb89ee
TW
1223manadocs += ['text-utils/colcrt.1.adoc']
1224bashcompletions += ['colcrt']
d4c880d5
ZJS
1225
1226exe = executable(
1227 'colrm',
1228 colrm_sources,
1229 include_directories : includes,
1230 link_with : lib_common,
1231 install_dir : usrbin_exec_dir,
1232 install : true)
1233exes += exe
38bb89ee
TW
1234manadocs += ['text-utils/colrm.1.adoc']
1235bashcompletions += ['colrm']
d4c880d5
ZJS
1236
1237exe = executable(
1238 'rev',
1239 rev_sources,
1240 include_directories : includes,
1241 install_dir : usrbin_exec_dir,
1242 install : true)
1243exes += exe
38bb89ee
TW
1244manadocs += ['text-utils/rev.1.adoc']
1245bashcompletions += ['rev']
d4c880d5
ZJS
1246
1247exe = executable(
1248 'column',
1249 column_sources,
1250 include_directories : includes,
1251 link_with : [lib_common,
1252 lib_smartcols],
1253 install_dir : usrbin_exec_dir,
1254 install : true)
1255if not is_disabler(exe)
1256 exes += exe
38bb89ee
TW
1257 manadocs += ['text-utils/column.1.adoc']
1258 bashcompletions += ['column']
d4c880d5
ZJS
1259endif
1260
1261opt = not get_option('build-line').disabled()
1262exe = executable(
1263 'line',
1264 line_sources,
1265 include_directories : includes,
1266 install_dir : usrbin_exec_dir,
1267 install : opt,
1268 build_by_default : opt)
1269if opt and not is_disabler(exe)
1270 exes += exe
38bb89ee 1271 manadocs += ['text-utils/line.1.adoc']
d4c880d5
ZJS
1272endif
1273
1274opt = not get_option('build-pg').disabled()
1275exe = executable(
1276 'pg',
1277 pg_sources,
1278 link_with : lib_common,
1279 include_directories : includes,
1280 dependencies : [lib_tinfo,
1281 curses_libs],
1282 install_dir : usrbin_exec_dir,
1283 install : opt,
1284 build_by_default : opt)
1285if opt and not is_disabler(exe)
1286 exes += exe
38bb89ee
TW
1287 manadocs += ['text-utils/pg.1.adoc']
1288 bashcompletions += ['pg']
d4c880d5
ZJS
1289endif
1290
1291opt = not get_option('build-ul').disabled()
1292exe = executable(
1293 'ul',
1294 ul_sources,
1295 include_directories : includes,
1296 dependencies : [lib_tinfo,
1297 curses_libs],
1298 install_dir : usrbin_exec_dir,
1299 install : opt,
1300 build_by_default : opt)
1301if opt and not is_disabler(exe)
1302 exes += exe
38bb89ee
TW
1303 manadocs += ['text-utils/ul.1.adoc']
1304 bashcompletions += ['ul']
d4c880d5
ZJS
1305endif
1306
1307opt = not get_option('build-more').disabled()
1308exe = executable(
1309 'more',
1310 more_sources,
308a0979 1311 link_with : [lib_common],
d4c880d5
ZJS
1312 include_directories : includes,
1313 dependencies : [lib_tinfo,
6e92db54
KZ
1314 curses_libs,
1315 lib_magic],
d4c880d5
ZJS
1316 install : opt,
1317 build_by_default : opt)
1318exe2 = executable(
1319 'test_more',
1320 more_sources,
308a0979 1321 link_with : [lib_common],
d4c880d5
ZJS
1322 include_directories : includes,
1323 c_args : '-DTEST_PROGRAM',
1324 dependencies : [lib_tinfo,
6e92db54
KZ
1325 curses_libs,
1326 lib_magic],
ba30b89c 1327 build_by_default : opt and program_tests)
d4c880d5
ZJS
1328exes += exe
1329if opt and not is_disabler(exe)
1330 exes += [exe, exe2]
38bb89ee
TW
1331 manadocs += ['text-utils/more.1.adoc']
1332 bashcompletions += ['more']
d4c880d5
ZJS
1333endif
1334
1335exe = executable(
1336 'hexdump',
1337 hexdump_sources,
1338 include_directories : includes,
1339 link_with : [lib_common,
1340 lib_tcolors],
1341 install_dir : usrbin_exec_dir,
1342 install : true)
1343if not is_disabler(exe)
1344 exes += exe
53b37016 1345 manadocs += ['text-utils/hexdump.1.adoc']
38bb89ee 1346 bashcompletions += ['hexdump']
d4c880d5
ZJS
1347endif
1348
1349opt = not get_option('build-lsmem').disabled()
1350exe = executable(
1351 'lsmem',
1352 lsmem_sources,
1353 include_directories : includes,
1354 link_with : [lib_common,
1355 lib_smartcols],
1356 install_dir : usrbin_exec_dir,
1357 install : opt,
1358 build_by_default : opt)
1359if opt and not is_disabler(exe)
1360 exes += exe
53b37016 1361 manadocs += ['sys-utils/lsmem.1.adoc']
38bb89ee 1362 bashcompletions += ['lsmem']
d4c880d5
ZJS
1363endif
1364
1365opt = not get_option('build-chmem').disabled()
1366exe = executable(
1367 'chmem',
1368 chmem_sources,
1369 include_directories : includes,
1370 link_with : [lib_common],
1371 install_dir : usrbin_exec_dir,
1372 install : opt,
1373 build_by_default : opt)
1374if opt and not is_disabler(exe)
1375 exes += exe
53b37016 1376 manadocs += ['sys-utils/chmem.8.adoc']
38bb89ee 1377 bashcompletions += ['chmem']
d4c880d5
ZJS
1378endif
1379
1380exe = executable(
1381 'choom',
1382 choom_sources,
1383 include_directories : includes,
1384 link_with : [lib_common],
1385 install_dir : usrbin_exec_dir,
1386 install : true)
1387exes += exe
53b37016 1388manadocs += ['sys-utils/choom.1.adoc']
d4c880d5
ZJS
1389
1390exe = executable(
1391 'ipcmk',
1392 ipcmk_sources,
1393 include_directories : includes,
1394 link_with : [lib_common],
1395 install_dir : usrbin_exec_dir,
1396 install : true)
1397exes += exe
53b37016 1398manadocs += ['sys-utils/ipcmk.1.adoc']
38bb89ee 1399bashcompletions += ['ipcmk']
d4c880d5
ZJS
1400
1401exe = executable(
1402 'ipcrm',
1403 ipcrm_sources,
1404 include_directories : includes,
1405 link_with : [lib_common],
1406 install_dir : usrbin_exec_dir,
1407 install : true)
1408exes += exe
53b37016 1409manadocs += ['sys-utils/ipcrm.1.adoc']
38bb89ee 1410bashcompletions += ['ipcrm']
d4c880d5
ZJS
1411
1412opt = not get_option('build-ipcs').disabled()
1413exe = executable(
1414 'ipcs',
1415 ipcs_sources,
1416 include_directories : includes,
1417 link_with : [lib_common],
1418 install_dir : usrbin_exec_dir,
1419 install : opt,
1420 build_by_default : opt)
1421if opt and not is_disabler(exe)
1422 exes += exe
53b37016 1423 manadocs += ['sys-utils/ipcs.1.adoc']
38bb89ee 1424 bashcompletions += ['ipcs']
d4c880d5
ZJS
1425endif
1426
1427opt = not get_option('build-rfkill').disabled()
1428exe = executable(
1429 'rfkill',
1430 rfkill_sources,
1431 include_directories : includes,
1432 link_with : [lib_common,
1433 lib_smartcols],
1434 install_dir : usrsbin_exec_dir,
1435 install : opt,
1436 build_by_default : opt)
1437if opt and not is_disabler(exe)
1438 exes += exe
53b37016 1439 manadocs += ['sys-utils/rfkill.8.adoc']
38bb89ee 1440 bashcompletions += ['rfkill']
d4c880d5
ZJS
1441endif
1442
1443exe = executable(
1444 'renice',
1445 renice_sources,
1446 include_directories : includes,
1447 link_with : [lib_common,
1448 lib_smartcols],
1449 install_dir : usrbin_exec_dir,
1450 install : true)
1451if not is_disabler(exe)
1452 exes += exe
53b37016 1453 manadocs += ['sys-utils/renice.1.adoc']
38bb89ee 1454 bashcompletions += ['renice']
d4c880d5
ZJS
1455endif
1456
f092076f
DDM
1457exe = executable(
1458 'setpgid',
1459 setpgid_sources,
1460 include_directories: includes,
1461 link_with : [lib_common,
1462 lib_smartcols],
1463 install_dir : usrbin_exec_dir,
1464 install : true)
1465if opt and not is_disabler(exe)
1466 exes += exe
1467 manadocs += ['sys-utils/setpgid.1.adoc']
1468 bashcompletions += ['setpgid']
1469endif
1470
d4c880d5
ZJS
1471exe = executable(
1472 'setsid',
1473 setsid_sources,
1474 include_directories : includes,
1475 link_with : [lib_common,
1476 lib_smartcols],
1477 install_dir : usrbin_exec_dir,
1478 install : true)
1479if opt and not is_disabler(exe)
1480 exes += exe
53b37016 1481 manadocs += ['sys-utils/setsid.1.adoc']
38bb89ee 1482 bashcompletions += ['setsid']
d4c880d5
ZJS
1483endif
1484
1485exe = executable(
1486 'readprofile',
1487 readprofile_sources,
1488 include_directories : includes,
1489 link_with : [lib_common,
1490 lib_smartcols],
1491 install_dir : usrsbin_exec_dir,
1492 install : true)
1493if not is_disabler(exe)
1494 exes += exe
53b37016 1495 manadocs += ['sys-utils/readprofile.8.adoc']
38bb89ee 1496 bashcompletions += ['readprofile']
d4c880d5
ZJS
1497endif
1498
1499opt = not get_option('build-tunelp').disabled()
1500exe = executable(
1501 'tunelp',
1502 tunelp_sources,
1503 include_directories : includes,
1504 link_with : [lib_common],
1505 install_dir : usrsbin_exec_dir,
1506 install : opt,
1507 build_by_default : opt)
1508if opt and not is_disabler(exe)
1509 exes += exe
53b37016 1510 manadocs += ['sys-utils/tunelp.8.adoc']
38bb89ee 1511 bashcompletions += ['tunelp']
d4c880d5
ZJS
1512endif
1513
b8b63b36 1514opt = get_option('build-fstrim').require(have_sys_vfs_header).allowed()
d4c880d5
ZJS
1515exe = executable(
1516 'fstrim',
1517 fstrim_sources,
1518 include_directories : includes,
c43b185a
JW
1519 link_with : [lib_common],
1520 dependencies : [mount_dep],
d4c880d5 1521 install_dir : sbindir,
b6799ccb
JW
1522 install : opt,
1523 build_by_default : opt)
1524if opt and not is_disabler(exe)
d4c880d5 1525 exes += exe
53b37016 1526 manadocs += ['sys-utils/fstrim.8.adoc']
38bb89ee 1527 bashcompletions += ['fstrim']
d4c880d5
ZJS
1528endif
1529
1530exe = executable(
1531 'dmesg',
1532 dmesg_sources,
1533 include_directories : includes,
1534 link_with : [lib_common,
1535 lib_tcolors],
1536 install : true)
1537if not is_disabler(exe)
1538 exes += exe
53b37016 1539 manadocs += ['sys-utils/dmesg.1.adoc']
38bb89ee 1540 bashcompletions += ['dmesg']
d4c880d5
ZJS
1541endif
1542
1543exe = executable(
1544 'test_dmesg',
1545 dmesg_sources,
1546 include_directories : dir_include,
1547 c_args : '-DTEST_DMESG',
1548 link_with : [lib_common,
ba30b89c 1549 lib_tcolors],
1550 build_by_default : program_tests)
d4c880d5
ZJS
1551if not is_disabler(exe)
1552 exes += exe
1553endif
1554
1555exe = executable(
1556 'ctrlaltdel',
1557 ctrlaltdel_sources,
1558 include_directories : includes,
1559 link_with : [lib_common],
1560 install_dir : sbindir,
1561 install : true)
1562exes += exe
53b37016 1563manadocs += ['sys-utils/ctrlaltdel.8.adoc']
38bb89ee 1564bashcompletions += ['ctrlaltdel']
d4c880d5
ZJS
1565
1566exe = executable(
1567 'fsfreeze',
1568 fsfreeze_sources,
1569 include_directories : includes,
1570 install_dir : sbindir,
1571 install : true)
1572exes += exe
53b37016 1573manadocs += ['sys-utils/fsfreeze.8.adoc']
38bb89ee 1574bashcompletions += ['fsfreeze']
d4c880d5
ZJS
1575
1576exe = executable(
1577 'blkdiscard',
1578 blkdiscard_sources,
1579 include_directories : includes,
a764efb5
JW
1580 link_with : [lib_common],
1581 dependencies : [blkid_dep],
d4c880d5
ZJS
1582 install_dir : sbindir,
1583 install : true)
1584exes += exe
53b37016 1585manadocs += ['sys-utils/blkdiscard.8.adoc']
38bb89ee 1586bashcompletions += ['blkdiscard']
d4c880d5 1587
1a374511
JW
1588if cc.has_header('linux/blkzoned.h')
1589 exe = executable(
1590 'blkzone',
1591 blkzone_sources,
1592 include_directories : includes,
1593 link_with : [lib_common],
1594 install_dir : sbindir,
1595 install : true)
1596 exes += exe
1597 manadocs += ['sys-utils/blkzone.8.adoc']
1598 bashcompletions += ['blkzone']
1599endif
d4c880d5 1600
1a374511
JW
1601if cc.has_header('linux/pr.h')
1602 exe = executable(
1603 'blkpr',
1604 blkpr_sources,
1605 include_directories : includes,
1606 link_with : [lib_common],
1607 install_dir : sbindir,
1608 install : true)
1609 exes += exe
1610 manadocs += ['sys-utils/blkpr.8.adoc']
1611endif
61c2946d 1612
d4c880d5
ZJS
1613exe = executable(
1614 'ldattach',
1615 ldattach_sources,
1616 include_directories : includes,
1617 link_with : [lib_common],
1618 install_dir : usrsbin_exec_dir,
1619 install : true)
1620exes += exe
53b37016 1621manadocs += ['sys-utils/ldattach.8.adoc']
38bb89ee 1622bashcompletions += ['ldattach']
d4c880d5
ZJS
1623
1624exe = executable(
1625 'rtcwake',
1626 rtcwake_sources,
1627 include_directories : includes,
1628 link_with : [lib_common],
1629 install_dir : usrsbin_exec_dir,
1630 install : true)
1631exes += exe
53b37016 1632manadocs += ['sys-utils/rtcwake.8.adoc']
38bb89ee 1633bashcompletions += ['rtcwake']
d4c880d5
ZJS
1634
1635exe = executable(
1636 'setarch',
1637 setarch_sources,
1638 include_directories : includes,
035fc2d9 1639 link_with : [lib_common],
d4c880d5
ZJS
1640 install_dir : usrbin_exec_dir,
1641 install : true)
1642exes += exe
53b37016 1643manadocs += ['sys-utils/setarch.8.adoc']
38bb89ee 1644bashcompletions += ['setarch']
d4c880d5
ZJS
1645
1646setarch_links = ['uname26', 'linux32', 'linux64']
1647setarch_links_arch = {
1648 's390x' : ['s390', 's390x'],
1649 'x86' : ['i386'],
1650 'x86_64' : ['i386', 'x86_64'],
1651 'ppc64' : ['ppc', 'ppc64', 'ppc32'],
1652 'space64' : ['sparc', 'sparc64', 'sparc32', 'sparc32bash'],
1653 'mips64' : ['mips', 'mips64', 'mips32'],
1654 'ia64' : ['i386', 'ia64'],
1655 'hppa' : ['parisc', 'parisc64', 'parisc32'],
1656}
1657setarch_links += setarch_links_arch.get(host_machine.cpu_family(), [])
1658
1659foreach link: setarch_links
1660 meson.add_install_script(meson_make_symlink,
1661 'setarch',
1662 join_paths(usrbin_exec_dir, link))
38bb89ee 1663 manlinks += {link + '.8': 'setarch.8'}
d4c880d5
ZJS
1664endforeach
1665
1666opt = not get_option('build-eject').disabled()
1667exe = executable(
1668 'eject',
1669 eject_sources,
1670 include_directories : includes,
c43b185a
JW
1671 link_with : [lib_common],
1672 dependencies : [mount_dep],
d4c880d5
ZJS
1673 install_dir : usrbin_exec_dir,
1674 install : opt,
1675 build_by_default : opt)
1676if opt and not is_disabler(exe)
1677 exe = exe
53b37016 1678 manadocs += ['sys-utils/eject.1.adoc']
38bb89ee 1679 bashcompletions += ['eject']
d4c880d5
ZJS
1680endif
1681
1682opt = not get_option('build-losetup').disabled()
1683exe = executable(
1684 'losetup',
1685 losetup_sources,
1686 include_directories : includes,
1687 link_with : [lib_common,
1688 lib_smartcols],
1689 install_dir : sbindir,
1690 install : opt,
1691 build_by_default : opt)
1692if opt and not is_disabler(exe)
53b37016 1693 manadocs += ['sys-utils/losetup.8.adoc']
d4c880d5 1694 exes += exe
38bb89ee 1695 bashcompletions += ['losetup']
d4c880d5
ZJS
1696endif
1697
69939195
ZJS
1698opt = opt and 'losetup' in static_programs
1699exe = executable(
1700 'losetup.static',
1701 losetup_sources,
1702 include_directories : includes,
1703 link_args : ['--static'],
1704 link_with : [lib_common,
1705 lib_smartcols.get_static_lib()],
1706 install_dir : sbindir,
1707 install : opt,
1708 build_by_default : opt)
1709if opt and not is_disabler(exe)
1710 exes += exe
1711endif
1712
d4c880d5
ZJS
1713opt = not get_option('build-zramctl').disabled()
1714exe = executable(
1715 'zramctl',
1716 zramctl_sources,
1717 include_directories : includes,
1718 link_with : [lib_common,
1719 lib_smartcols],
1720 install_dir : sbindir,
1721 install : opt,
1722 build_by_default : opt)
1723if opt and not is_disabler(exe)
1724 exes += exe
53b37016 1725 manadocs += ['sys-utils/zramctl.8.adoc']
38bb89ee 1726 bashcompletions += ['zramctl']
d4c880d5
ZJS
1727endif
1728
1729exe = executable(
1730 'prlimit',
1731 prlimit_sources,
1732 include_directories : includes,
1733 link_with : [lib_common,
1734 lib_smartcols],
1735 install_dir : usrbin_exec_dir,
1736 install : true)
1737if not is_disabler(exe)
1738 exes += exe
53b37016 1739 manadocs += ['sys-utils/prlimit.1.adoc']
38bb89ee 1740 bashcompletions += ['prlimit']
d4c880d5
ZJS
1741endif
1742
b6799ccb 1743opt = not get_option('build-lsns').disabled()
d4c880d5
ZJS
1744exe = executable(
1745 'lsns',
1746 lsns_sources,
1747 include_directories : includes,
1748 link_with : [lib_common,
c43b185a
JW
1749 lib_smartcols],
1750 dependencies : [mount_dep],
d4c880d5 1751 install_dir : usrbin_exec_dir,
b6799ccb
JW
1752 install : opt,
1753 build_by_default : opt)
1754if opt and not is_disabler(exe)
d4c880d5 1755 exes += exe
53b37016 1756 manadocs += ['sys-utils/lsns.8.adoc']
38bb89ee 1757 bashcompletions += ['lsns']
d4c880d5
ZJS
1758endif
1759
1760opt = not get_option('build-mount').disabled()
1761exe = executable(
1762 'mount',
1763 mount_sources,
1764 include_directories : includes,
1765 link_with : [lib_common,
c43b185a
JW
1766 lib_smartcols],
1767 dependencies : [lib_selinux, mount_dep],
8f49b369 1768 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1769 install : opt,
1770 build_by_default : opt)
1771exe2 = executable(
1772 'umount',
1773 umount_sources,
1774 include_directories : includes,
c43b185a
JW
1775 link_with : [lib_common],
1776 dependencies : [mount_dep],
1cb3c90c 1777 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1778 install : opt,
1779 build_by_default : opt)
1780if opt and not is_disabler(exe)
1781 exes += [exe, exe2]
53b37016
KZ
1782 manadocs += ['sys-utils/fstab.5.adoc',
1783 'sys-utils/mount.8.adoc',
1784 'sys-utils/umount.8.adoc']
38bb89ee 1785 bashcompletions += ['mount', 'umount']
d4c880d5
ZJS
1786endif
1787
69939195
ZJS
1788opt2 = opt and 'mount' in static_programs
1789exe = executable(
1790 'mount.static',
1791 mount_sources,
1792 include_directories : includes,
1793 link_args : ['--static'],
1794 link_with : [lib_common,
c43b185a
JW
1795 lib_smartcols_static],
1796 dependencies : [mount_static_dep],
69939195
ZJS
1797 install : opt2,
1798 build_by_default : opt2)
1799if opt2 and not is_disabler(exe)
1800 exes += exe
1801endif
1802
1803opt2 = opt and 'umount' in static_programs
1804exe = executable(
1805 'umount.static',
1806 umount_sources,
1807 include_directories : includes,
1808 link_args : ['--static'],
c43b185a
JW
1809 link_with : [lib_common],
1810 dependencies : [mount_static_dep],
69939195
ZJS
1811 install : opt2,
1812 build_by_default : opt2)
1813if opt2 and not is_disabler(exe)
1814 exes += exe
1815endif
1816
d4c880d5
ZJS
1817# setuid?
1818
b6799ccb 1819opt = not get_option('build-swapon').disabled()
d4c880d5
ZJS
1820exe = executable(
1821 'swapon',
1822 swapon_sources,
1823 include_directories : includes,
1824 link_with : [lib_common,
d4c880d5 1825 lib_smartcols],
a764efb5 1826 dependencies : [blkid_dep, mount_dep],
d4c880d5 1827 install_dir : sbindir,
b6799ccb
JW
1828 install : opt,
1829 build_by_default : opt)
1830if opt and not is_disabler(exe)
d4c880d5 1831 exes += exe
53b37016 1832 manadocs += ['sys-utils/swapon.8.adoc']
38bb89ee 1833 bashcompletions += ['swapon']
d4c880d5
ZJS
1834endif
1835
b6799ccb 1836opt = not get_option('build-swapoff').disabled()
d4c880d5
ZJS
1837exe = executable(
1838 'swapoff',
1839 swapoff_sources,
1840 include_directories : includes,
a764efb5
JW
1841 link_with : [lib_common],
1842 dependencies : [blkid_dep, mount_dep],
d4c880d5 1843 install_dir : sbindir,
b6799ccb
JW
1844 install : opt,
1845 build_by_default : opt)
1846if opt and not is_disabler(exe)
d4c880d5 1847 exes += exe
38bb89ee
TW
1848 manlinks += {'swapoff.8': 'swapon.8'}
1849 bashcompletions += ['swapoff']
d4c880d5
ZJS
1850endif
1851
1852exe = executable(
1853 'lscpu',
1854 lscpu_sources,
1855 include_directories : includes,
1856 link_with : [lib_common,
1857 lib_smartcols],
1858 dependencies : [rtas_libs],
1859 install_dir : usrbin_exec_dir,
1860 install : true)
1861if not is_disabler(exe)
1862 exes += exe
53b37016 1863 manadocs += ['sys-utils/lscpu.1.adoc']
38bb89ee 1864 bashcompletions += ['lscpu']
d4c880d5
ZJS
1865endif
1866
1867exe = executable(
1868 'chcpu',
1869 chcpu_sources,
1870 include_directories : includes,
1871 link_with : [lib_common],
1872 install_dir : sbindir,
1873 install : true)
1874exes += exe
53b37016 1875manadocs += ['sys-utils/chcpu.8.adoc']
38bb89ee 1876bashcompletions += ['chcpu']
d4c880d5
ZJS
1877
1878exe = executable(
1879 'wdctl',
1880 wdctl_sources,
1881 include_directories : includes,
1882 link_with : [lib_common,
1883 lib_smartcols],
1884 install : true)
1885if not is_disabler(exe)
1886 exes += exe
53b37016 1887 manadocs += ['sys-utils/wdctl.8.adoc']
38bb89ee 1888 bashcompletions += ['wdctl']
d4c880d5
ZJS
1889endif
1890
1891opt = not get_option('build-mountpoint').disabled()
1892exe = executable(
1893 'mountpoint',
1894 mountpoint_sources,
1895 include_directories : includes,
c43b185a 1896 dependencies : [mount_dep],
d4c880d5
ZJS
1897 install : opt,
1898 build_by_default : opt)
1899if opt and not is_disabler(exe)
1900 exes += exe
53b37016 1901 manadocs += ['sys-utils/mountpoint.1.adoc']
38bb89ee 1902 bashcompletions += ['mountpoint']
d4c880d5
ZJS
1903endif
1904
1905opt = not get_option('build-fallocate').disabled()
1906exe = executable(
1907 'fallocate',
1908 fallocate_sources,
1909 include_directories : includes,
1910 link_with : [lib_common],
1911 install_dir : usrbin_exec_dir,
1912 install : opt,
1913 build_by_default : opt)
1914if opt and not is_disabler(exe)
1915 exes += exe
53b37016 1916 manadocs += ['sys-utils/fallocate.1.adoc']
38bb89ee 1917 bashcompletions += ['fallocate']
d4c880d5
ZJS
1918endif
1919
1920opt = not get_option('build-pivot_root').disabled()
1921exe = executable(
1922 'pivot_root',
1923 pivot_root_sources,
1924 include_directories : includes,
1925 install_dir : sbindir,
1926 install : opt,
1927 build_by_default : opt)
1928if opt and not is_disabler(exe)
1929 exes += exe
53b37016 1930 manadocs += ['sys-utils/pivot_root.8.adoc']
38bb89ee 1931 bashcompletions += ['pivot_root']
d4c880d5
ZJS
1932endif
1933
1934opt = not get_option('build-switch_root').disabled()
1935if opt and not have_dirfd and not have_ddfd
1936 error('neither dirfd nor ddfd are available')
1937endif
1938exe = executable(
1939 'switch_root',
1940 switch_root_sources,
1941 include_directories : includes,
1942 install_dir : sbindir,
1943 install : opt,
1944 build_by_default : opt)
1945if opt and not is_disabler(exe)
1946 exes += exe
53b37016 1947 manadocs += ['sys-utils/switch_root.8.adoc']
d4c880d5
ZJS
1948endif
1949
1950opt = not get_option('build-unshare').disabled()
1951exe = executable(
1952 'unshare',
1953 unshare_sources,
1954 include_directories : includes,
1955 link_with : [lib_common],
c43b185a 1956 dependencies : [mount_dep],
d4c880d5
ZJS
1957 install_dir : usrbin_exec_dir,
1958 install : opt,
1959 build_by_default : opt)
1960if opt and not is_disabler(exe)
1961 exes += exe
53b37016 1962 manadocs += ['sys-utils/unshare.1.adoc']
38bb89ee 1963 bashcompletions += ['unshare']
d4c880d5
ZJS
1964endif
1965
69939195
ZJS
1966opt = opt and 'unshare' in static_programs
1967exe = executable(
1968 'unshare.static',
1969 unshare_sources,
1970 include_directories : includes,
1971 link_with : [lib_common],
c43b185a 1972 dependencies : [mount_dep],
69939195
ZJS
1973 install_dir : usrbin_exec_dir,
1974 install : opt,
1975 build_by_default : opt)
1976if opt and not is_disabler(exe)
1977 exes += exe
1978endif
1979
d4c880d5
ZJS
1980opt = not get_option('build-nsenter').disabled()
1981exe = executable(
1982 'nsenter',
1983 nsenter_sources,
1984 include_directories : includes,
1985 link_with : [lib_common],
1986 dependencies : [lib_selinux],
1987 install_dir : usrbin_exec_dir,
1988 install : opt,
1989 build_by_default : opt)
1990if opt and not is_disabler(exe)
1991 exes += exe
53b37016 1992 manadocs += ['sys-utils/nsenter.1.adoc']
38bb89ee 1993 bashcompletions += ['nsenter']
d4c880d5
ZJS
1994endif
1995
69939195
ZJS
1996opt = opt and 'nsenter' in static_programs
1997exe = executable(
1998 'nsenter.static',
1999 nsenter_sources,
2000 include_directories : includes,
2001 link_with : [lib_common],
2002 dependencies : [lib_selinux],
2003 install_dir : usrbin_exec_dir,
2004 install : opt,
2005 build_by_default : opt)
2006if opt and not is_disabler(exe)
2007 exes += exe
2008endif
2009
cd23a433 2010opt = not get_option('build-setpriv').disabled() and lib_cap_ng.found()
d4c880d5
ZJS
2011exe = executable(
2012 'setpriv',
2013 setpriv_sources,
2014 include_directories : includes,
2015 link_with : [lib_common],
2016 dependencies : [lib_cap_ng],
2017 install_dir : usrbin_exec_dir,
2018 install : opt,
2019 build_by_default : opt)
2020if opt and not is_disabler(exe)
2021 exes += exe
53b37016 2022 manadocs += ['sys-utils/setpriv.1.adoc']
38bb89ee 2023 bashcompletions += ['setpriv']
d4c880d5
ZJS
2024endif
2025
2026exe = executable(
2027 'flock',
2028 flock_sources,
2029 include_directories : includes,
2030 link_with : [lib_common],
2031 dependencies : realtime_libs,
2032 install_dir : usrbin_exec_dir,
2033 install : true)
2034exes += exe
53b37016 2035manadocs += ['sys-utils/flock.1.adoc']
38bb89ee 2036bashcompletions += ['flock']
d4c880d5 2037
645577c7
KZ
2038opt = not get_option('build-lsirq').disabled()
2039exe = executable(
2040 'lsirq',
2041 lsirq_sources,
2042 include_directories : includes,
2043 link_with : [lib_common,
2044 lib_smartcols],
2045 install_dir : usrbin_exec_dir,
2046 install : opt,
2047 build_by_default : opt)
2048if opt and not is_disabler(exe)
2049 exes += exe
53b37016 2050 manadocs += ['sys-utils/lsirq.1.adoc']
38bb89ee 2051 bashcompletions += ['lsirq']
645577c7
KZ
2052endif
2053
2054opt = not get_option('build-irqtop').disabled()
2055exe = executable(
2056 'irqtop',
2057 irqtop_sources,
2058 include_directories : includes,
2059 dependencies : [realtime_libs, curses_libs],
2060 link_with : [lib_common,
2061 lib_smartcols,
2062 lib_tcolors],
2063 install_dir : usrbin_exec_dir,
2064 install : opt,
2065 build_by_default : opt)
2066if opt and not is_disabler(exe)
2067 exes += exe
53b37016 2068 manadocs += ['sys-utils/irqtop.1.adoc']
38bb89ee 2069 bashcompletions += ['irqtop']
645577c7
KZ
2070endif
2071
d4c880d5
ZJS
2072opt = not get_option('build-ipcs').disabled()
2073exe = executable(
2074 'lsipc',
2075 lsipc_sources,
2076 include_directories : includes,
2077 link_with : [lib_common,
2078 lib_smartcols],
2079 install_dir : usrbin_exec_dir,
2080 install : opt,
2081 build_by_default : opt)
2082if opt and not is_disabler(exe)
2083 exes += exe
53b37016 2084 manadocs += ['sys-utils/lsipc.1.adoc']
38bb89ee 2085 bashcompletions += ['lsipc']
d4c880d5
ZJS
2086endif
2087
2088opt = build_hwclock
2089exe = executable(
2090 'hwclock',
2091 hwclock_sources,
2092 include_directories : includes,
2093 link_with : [lib_common],
2094 dependencies : [lib_m,
2095 lib_audit],
2096 install_dir : sbindir,
2097 install : opt,
2098 build_by_default : opt)
2099if opt and not is_disabler(exe)
2100 exes += exe
38bb89ee
TW
2101 manadocs += ['sys-utils/hwclock.8.adoc', 'sys-utils/adjtime_config.5.adoc']
2102 bashcompletions += ['hwclock']
d4c880d5
ZJS
2103endif
2104
2105exe = executable(
2106 'mkfs',
2107 mkfs_sources,
2108 include_directories : includes,
2109 install_dir : sbindir,
2110 install : true)
2111exes += exe
53b37016 2112manadocs += ['disk-utils/mkfs.8.adoc']
38bb89ee 2113bashcompletions += ['mkfs']
d4c880d5
ZJS
2114
2115opt = not get_option('build-bfs').disabled()
2116exe = executable(
2117 'mkfs.bfs',
2118 mkfs_bfs_sources,
2119 include_directories : includes,
2120 link_with : [lib_common],
2121 install_dir : sbindir,
2122 install : opt,
2123 build_by_default : opt)
2124if opt and not is_disabler(exe)
2125 exes += exe
53b37016 2126 manadocs += ['disk-utils/mkfs.bfs.8.adoc']
38bb89ee 2127 bashcompletions += ['mkfs.bfs']
d4c880d5
ZJS
2128endif
2129
2130exe = executable(
2131 'isosize',
2132 isosize_sources,
2133 include_directories : includes,
2134 link_with : [lib_common],
2135 install_dir : usrbin_exec_dir,
2136 install : true)
2137exes += exe
53b37016 2138manadocs += ['disk-utils/isosize.8.adoc']
38bb89ee 2139bashcompletions += ['isosize']
d4c880d5
ZJS
2140
2141exe = executable(
2142 'mkswap',
2143 mkswap_sources,
2144 include_directories : includes,
2145 link_with : [lib_common,
d4c880d5 2146 lib_uuid],
a764efb5 2147 dependencies: [blkid_dep, lib_selinux],
d4c880d5
ZJS
2148 install_dir : sbindir,
2149 install : true)
765961c3 2150if not is_disabler(exe)
d4c880d5 2151 exes += exe
53b37016 2152 manadocs += ['disk-utils/mkswap.8.adoc']
38bb89ee 2153 bashcompletions += ['mkswap']
d4c880d5
ZJS
2154endif
2155
2156exe = executable(
2157 'swaplabel',
2158 swaplabel_sources,
2159 include_directories : includes,
2160 link_with : [lib_common,
d4c880d5 2161 lib_uuid],
a764efb5 2162 dependencies : [blkid_dep],
d4c880d5
ZJS
2163 install_dir : sbindir,
2164 install : true)
765961c3 2165if not is_disabler(exe)
d4c880d5 2166 exes += exe
53b37016 2167 manadocs += ['disk-utils/swaplabel.8.adoc']
38bb89ee 2168 bashcompletions += ['swaplabel']
d4c880d5
ZJS
2169endif
2170
2171opt = not get_option('build-fsck').disabled()
2172exe = executable(
2173 'fsck',
2174 fsck_sources,
2175 include_directories : includes,
a764efb5
JW
2176 link_with : [lib_common],
2177 dependencies : [blkid_dep, mount_dep, realtime_libs],
d4c880d5
ZJS
2178 install_dir : sbindir,
2179 install : opt,
2180 build_by_default : opt)
2181if opt and not is_disabler(exe)
2182 exes += exe
53b37016 2183 manadocs += ['disk-utils/fsck.8.adoc']
38bb89ee 2184 bashcompletions += ['fsck']
d4c880d5
ZJS
2185endif
2186
2187opt = not get_option('build-minix').disabled()
2188exe = executable(
2189 'mkfs.minix',
2190 mkfs_minix_sources,
2191 include_directories : includes,
2192 link_with : [lib_common],
2193 install_dir : sbindir,
2194 install : opt,
2195 build_by_default : opt)
2196exe2 = executable(
2197 'test_mkfs_minix',
2198 mkfs_minix_sources,
2199 include_directories : includes,
2200 c_args : '-DTEST_SCRIPT',
2201 link_with : [lib_common],
ba30b89c 2202 build_by_default : opt and program_tests)
d4c880d5
ZJS
2203exe3 = executable(
2204 'fsck.minix',
2205 fsck_minix_sources,
2206 include_directories : includes,
2207 link_with : [lib_common],
2208 install_dir : sbindir,
2209 install : opt,
2210 build_by_default : opt)
2211if opt and not is_disabler(exe)
2212 exes += [exe, exe2, exe3]
53b37016 2213 manadocs += ['disk-utils/mkfs.minix.8.adoc','disk-utils/fsck.minix.8.adoc']
38bb89ee 2214 bashcompletions += ['mkfs.minix', 'fsck.minix']
d4c880d5
ZJS
2215endif
2216
2217opt = not get_option('build-cramfs').disabled()
2218exe = executable(
2219 'mkfs.cramfs',
2220 mkfs_cramfs_sources,
2221 include_directories : includes,
2222 link_with : [lib_common],
2223 dependencies : [lib_z],
2224 install_dir : sbindir,
2225 install : opt,
2226 build_by_default : opt)
2227exe2 = executable(
2228 'fsck.cramfs',
2229 fsck_cramfs_sources,
2230 include_directories : includes,
2231 link_with : [lib_common],
2232 dependencies : [lib_z],
2233 install_dir : sbindir,
2234 install : opt,
2235 build_by_default : opt)
2236if not is_disabler(exe)
2237 exes += [exe, exe2]
53b37016 2238 manadocs += ['disk-utils/mkfs.cramfs.8.adoc','disk-utils/fsck.cramfs.8.adoc']
38bb89ee 2239 bashcompletions += ['mkfs.cramfs', 'fsck.cramfs']
d4c880d5
ZJS
2240endif
2241
2242opt = not get_option('build-raw').disabled()
dff176e2 2243if opt
433e4b77 2244 cc.has_header('linux/raw.h', required: opt)
dff176e2 2245endif
d4c880d5
ZJS
2246exe = executable(
2247 'raw',
2248 raw_sources,
2249 include_directories : includes,
2250 install_dir : sbindir,
2251 install : opt,
2252 build_by_default : opt)
2253if opt and not is_disabler(exe)
2254 exes += exe
53b37016 2255 manadocs += ['disk-utils/raw.8.adoc']
38bb89ee 2256 bashcompletions += ['raw']
d4c880d5
ZJS
2257endif
2258
2259opt = not get_option('build-fdformat').disabled()
2260exe = executable(
2261 'fdformat',
2262 fdformat_sources,
2263 include_directories : includes,
2264 link_with : [lib_common],
2265 install_dir : usrsbin_exec_dir,
2266 install : opt,
2267 build_by_default : opt)
2268if opt and not is_disabler(exe)
2269 exes += exe
53b37016 2270 manadocs += ['disk-utils/fdformat.8.adoc']
669071f6 2271 bashcompletions += ['fdformat']
d4c880d5
ZJS
2272endif
2273
2274exe = executable(
2275 'blockdev',
2276 blockdev_sources,
2277 include_directories : includes,
2278 link_with : [lib_common],
2279 install_dir : sbindir,
2280 install : true)
53b37016 2281manadocs += ['disk-utils/blockdev.8.adoc']
38bb89ee 2282bashcompletions += ['blockdev']
d4c880d5
ZJS
2283
2284opt = not get_option('build-fdisks').disabled()
2285if opt and not have_dirfd and not have_ddfd
2286 error('neither dirfd nor ddfd are available')
2287endif
2288exe = executable(
2289 'fdisk',
2290 fdisk_sources,
2291 include_directories : includes,
2292 link_with : [lib_common,
2293 lib_fdisk,
2294 lib_smartcols,
2295 lib_tcolors],
2296 dependencies : [lib_readline],
2297 install_dir : sbindir,
2298 install : opt,
2299 build_by_default : opt)
2300if opt and not is_disabler(exe)
2301 exes += exe
38bb89ee 2302 bashcompletions += ['fdisk']
d4c880d5
ZJS
2303endif
2304
69939195
ZJS
2305opt2 = opt and 'fdisk' in static_programs
2306exe = executable(
2307 'fdisk.static',
2308 fdisk_sources,
2309 link_args : ['--static'],
2310 include_directories : includes,
2311 link_with : [lib_common,
2312 lib_tcolors,
2313 lib_fdisk_static,
2314 lib_smartcols.get_static_lib()],
2315 dependencies : [lib_readline_static],
2316 install_dir : sbindir,
2317 install : opt2,
2318 build_by_default : opt2)
2319if opt2 and not is_disabler(exe)
2320 exes += exe
2321endif
d4c880d5
ZJS
2322
2323exe = executable(
2324 'sfdisk',
2325 sfdisk_sources,
2326 include_directories : includes,
2327 link_with : [lib_common,
2328 lib_fdisk,
2329 lib_smartcols,
2330 lib_tcolors],
2331 dependencies : [lib_readline],
2332 install_dir : sbindir,
2333 install : opt,
2334 build_by_default : opt)
2335if opt and not is_disabler(exe)
2336 exes += exe
38bb89ee 2337 bashcompletions += ['sfdisk']
d4c880d5
ZJS
2338endif
2339
69939195
ZJS
2340opt2 = opt and 'sfdisk' in static_programs
2341exe = executable(
2342 'sfdisk.static',
2343 sfdisk_sources,
2344 include_directories : includes,
2345 link_with : [lib_common,
2346 lib_tcolors,
2347 lib_fdisk_static,
2348 lib_smartcols.get_static_lib()],
2349 dependencies : [lib_readline_static],
2350 install_dir : sbindir,
2351 install : opt2,
2352 build_by_default : opt2)
2353if opt2 and not is_disabler(exe)
2354 exes += exe
2355endif
d4c880d5
ZJS
2356
2357exe = executable(
2358 'cfdisk',
2359 cfdisk_sources,
2360 include_directories : includes,
2361 link_with : [lib_common,
2362 lib_fdisk,
2363 lib_smartcols,
c43b185a
JW
2364 lib_tcolors],
2365 dependencies : [curses_libs, mount_dep],
d4c880d5
ZJS
2366 install_dir : sbindir,
2367 install : opt,
2368 build_by_default : opt)
2369if opt and not is_disabler(exe)
2370 exes += exe
53b37016
KZ
2371 manadocs += ['disk-utils/fdisk.8.adoc',
2372 'disk-utils/sfdisk.8.adoc',
2373 'disk-utils/cfdisk.8.adoc']
38bb89ee 2374 bashcompletions += ['cfdisk']
d4c880d5
ZJS
2375endif
2376
2377opt = not get_option('build-partx').disabled()
2378exe = executable(
2379 'addpart',
2380 addpart_sources,
2381 include_directories : includes,
2382 link_with : [lib_common],
2383 install_dir : usrsbin_exec_dir,
2384 install : opt,
2385 build_by_default : opt)
2386exe2 = executable(
2387 'delpart',
2388 delpart_sources,
2389 include_directories : includes,
2390 link_with : [lib_common],
2391 install_dir : usrsbin_exec_dir,
2392 install : opt,
2393 build_by_default : opt)
2394exe3 = executable(
2395 'resizepart',
2396 resizepart_sources,
2397 include_directories : includes,
2398 link_with : [lib_common],
2399 install_dir : usrsbin_exec_dir,
2400 install : opt,
2401 build_by_default : opt)
2402exe4 = executable(
2403 'partx',
2404 partx_sources,
2405 include_directories : includes,
2406 link_with : [lib_common,
d4c880d5 2407 lib_smartcols],
a764efb5 2408 dependencies : [blkid_dep],
d4c880d5
ZJS
2409 install_dir : usrsbin_exec_dir,
2410 install : opt,
2411 build_by_default : opt)
2412if opt
2413 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
2414 manadocs += ['disk-utils/addpart.8.adoc',
2415 'disk-utils/delpart.8.adoc',
2416 'disk-utils/resizepart.8.adoc',
2417 'disk-utils/partx.8.adoc']
38bb89ee 2418 bashcompletions += ['addpart', 'delpart', 'resizepart', 'partx']
d4c880d5 2419endif
44bf6d80
B
2420opt = opt and 'partx' in static_programs
2421exe = executable(
2422 'addpart.static',
2423 addpart_sources,
2424 include_directories : includes,
2425 link_args : ['--static'],
2426 link_with : [lib_common],
2427 install_dir : usrsbin_exec_dir,
2428 install : opt,
2429 build_by_default : opt)
2430exe2 = executable(
2431 'delpart.static',
2432 delpart_sources,
2433 include_directories : includes,
2434 link_args : ['--static'],
2435 link_with : [lib_common],
2436 install_dir : usrsbin_exec_dir,
2437 install : opt,
2438 build_by_default : opt)
2439exe3 = executable(
2440 'resizepart.static',
2441 resizepart_sources,
2442 include_directories : includes,
2443 link_args : ['--static'],
2444 link_with : [lib_common],
2445 install_dir : usrsbin_exec_dir,
2446 install : opt,
2447 build_by_default : opt)
2448exe4 = executable(
2449 'partx.static',
2450 partx_sources,
2451 include_directories : includes,
2452 link_args : ['--static'],
2453 link_with : [lib_common,
44bf6d80 2454 lib_smartcols.get_static_lib()],
a764efb5 2455 dependencies : [blkid_static_dep],
44bf6d80
B
2456 install_dir : usrsbin_exec_dir,
2457 install : opt,
2458 build_by_default : opt)
2459
2460if opt
2461 exes += [exe, exe2, exe3, exe4]
2462endif
d4c880d5
ZJS
2463
2464############################################################
2465
2466exe = executable(
2467 'script',
2468 script_sources,
2469 include_directories : includes,
2470 link_with : [lib_common],
2471 dependencies : [lib_util,
2472 lib_utempter,
2473 realtime_libs,
2474 math_libs],
2475 install_dir : usrbin_exec_dir,
2476 install : true)
2477exes += exe
53b37016 2478manadocs += ['term-utils/script.1.adoc']
38bb89ee 2479bashcompletions += ['script']
d4c880d5
ZJS
2480
2481exe = executable(
2482 'test_script',
2483 script_sources,
2484 include_directories : includes,
2485 c_args : '-DTEST_SCRIPT',
2486 link_with : [lib_common],
2487 dependencies : [lib_util,
2488 lib_utempter,
2489 realtime_libs,
ba30b89c 2490 math_libs],
2491 build_by_default : program_tests)
d4c880d5
ZJS
2492exes += exe
2493
2494exe = executable(
2495 'scriptlive',
2496 scriptlive_sources,
2497 include_directories : includes,
2498 link_with : [lib_common],
2499 dependencies : [lib_util,
2500 realtime_libs,
2501 math_libs],
2502 install_dir : usrbin_exec_dir,
2503 install : true)
2504exes += exe
53b37016 2505manadocs += ['term-utils/scriptlive.1.adoc']
38bb89ee 2506bashcompletions += ['scriptlive']
d4c880d5
ZJS
2507
2508exe = executable(
2509 'scriptreplay',
2510 scriptreplay_sources,
2511 include_directories : includes,
2512 link_with : [lib_common],
2513 dependencies : [math_libs],
2514 install_dir : usrbin_exec_dir,
2515 install : true)
2516exes += exe
53b37016 2517manadocs += ['term-utils/scriptreplay.1.adoc']
38bb89ee 2518bashcompletions += ['scriptreplay']
d4c880d5
ZJS
2519
2520opt = not get_option('build-agetty').disabled()
2521exe = executable(
2522 'agetty',
2523 agetty_sources,
2524 include_directories : includes,
0333c40b 2525 link_with : [lib_common, logindefs_c],
87fcd95a 2526 dependencies : [BSD ? lib_util : [], lib_systemd],
d4c880d5
ZJS
2527 install_dir : sbindir,
2528 install : opt,
2529 build_by_default : opt)
2530if opt
2531 exes += exe
53b37016 2532 manadocs += ['term-utils/agetty.8.adoc']
d4c880d5
ZJS
2533endif
2534
2535opt = not get_option('build-setterm').disabled()
2536exe = executable(
2537 'setterm',
2538 setterm_sources,
2539 include_directories : includes,
2540 link_with : [lib_common],
2541 dependencies : [curses_libs],
2542 install_dir : usrbin_exec_dir,
2543 install : opt,
2544 build_by_default : opt)
2545if opt
2546 exes += exe
53b37016 2547 manadocs += ['term-utils/setterm.1.adoc']
38bb89ee 2548 bashcompletions += ['setterm']
d4c880d5
ZJS
2549endif
2550
2551opt = not get_option('build-mesg').disabled()
2552exe = executable(
2553 'mesg',
2554 mesg_sources,
2555 include_directories : includes,
2556 link_with : [lib_common],
2557 install_dir : usrbin_exec_dir,
2558 install : opt,
2559 build_by_default : opt)
2560if opt
2561 exes += exe
53b37016 2562 manadocs += ['term-utils/mesg.1.adoc']
38bb89ee 2563 bashcompletions += ['mesg']
d4c880d5
ZJS
2564endif
2565
2566opt = not get_option('build-wall').disabled()
2567exe = executable(
2568 'wall',
2569 wall_sources,
2570 include_directories : includes,
2571 link_with : [lib_common],
87fcd95a 2572 dependencies : [lib_systemd],
d4c880d5 2573 install_dir : usrbin_exec_dir,
5f3359c5 2574 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2575 install : opt,
2576 build_by_default : opt)
2577if opt
2578 exes += exe
53b37016 2579 manadocs += ['term-utils/wall.1.adoc']
38bb89ee 2580 bashcompletions += ['wall']
d4c880d5
ZJS
2581endif
2582
2583# chgrp tty $(DESTDIR)$(usrbin_execdir)/wall
2584# chmod g+s $(DESTDIR)$(usrbin_execdir)/wall
2585
2586opt = not get_option('build-write').disabled()
2587exe = executable(
2588 'write',
2589 write_sources,
2590 include_directories : includes,
2591 link_with : [lib_common],
87fcd95a 2592 dependencies : [lib_systemd],
d4c880d5 2593 install_dir : usrbin_exec_dir,
00f115d8 2594 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2595 install : opt,
2596 build_by_default : opt)
2597if opt
2598 exes += exe
53b37016 2599 manadocs += ['term-utils/write.1.adoc']
e1cd4002 2600 bashcompletions += ['write']
d4c880d5
ZJS
2601endif
2602
2603# chgrp tty $(DESTDIR)$(usrbin_execdir)/write
2604# chmod g+s $(DESTDIR)$(usrbin_execdir)/write
2605
2606opt = not get_option('build-login').disabled()
2607exe = executable(
2608 'login',
2609 login_sources,
2610 include_directories : includes,
0333c40b 2611 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
2612 dependencies : [lib_pam,
2613 lib_audit,
2614 lib_selinux],
2615 install : opt,
2616 build_by_default : opt)
2617if not is_disabler(exe)
2618 exes += exe
53b37016 2619 manadocs += ['login-utils/login.1.adoc']
d4c880d5
ZJS
2620endif
2621
2622opt = not get_option('build-sulogin').disabled()
2623exe = executable(
2624 'sulogin',
2625 sulogin_sources,
2626 include_directories : includes,
2627 link_with : [lib_common],
2628 dependencies : [lib_crypt,
2629 lib_selinux],
2630 install_dir : sbindir,
2631 install : opt,
2632 build_by_default : opt)
2633if not is_disabler(exe)
2634 exes += exe
53b37016 2635 manadocs += ['login-utils/sulogin.8.adoc']
d4c880d5
ZJS
2636endif
2637
2638exe = executable(
2639 'cal',
2640 cal_sources,
2641 include_directories : includes,
2642 link_with : [lib_common,
2643 lib_tcolors],
2644 dependencies : [curses_libs],
2645 install_dir : usrbin_exec_dir,
2646 install : true)
2647exes += exe
53b37016 2648manadocs += ['misc-utils/cal.1.adoc']
38bb89ee 2649bashcompletions += ['cal']
d4c880d5
ZJS
2650
2651opt = not get_option('build-logger').disabled()
2652exe = executable(
2653 'logger',
2654 logger_sources,
2655 include_directories : includes,
dbb9999f 2656 link_with : [lib_common],
d4c880d5
ZJS
2657 dependencies : [lib_systemd],
2658 install_dir : usrbin_exec_dir,
2659 install : opt,
2660 build_by_default : opt)
2661if opt and not is_disabler(exe)
2662 exes += exe
53b37016 2663 manadocs += ['misc-utils/logger.1.adoc']
38bb89ee 2664 bashcompletions += ['logger']
d4c880d5
ZJS
2665endif
2666
2667exe = executable(
2668 'test_logger',
2669 logger_sources,
2670 include_directories : includes,
2671 c_args : '-DTEST_LOGGER',
dbb9999f 2672 link_with : [lib_common],
ba30b89c 2673 dependencies : [lib_systemd],
2674 build_by_default: program_tests)
d4c880d5
ZJS
2675if not is_disabler(exe)
2676 exes += exe
2677endif
2678
2679exe = executable(
2680 'look',
2681 look_sources,
2682 include_directories : includes,
2683 install_dir : usrbin_exec_dir,
2684 install : true)
2685exes += exe
53b37016 2686manadocs += ['misc-utils/look.1.adoc']
38bb89ee 2687bashcompletions += ['look']
d4c880d5
ZJS
2688
2689exe = executable(
2690 'mcookie',
2691 mcookie_sources,
2692 include_directories : includes,
2693 link_with : [lib_common],
2694 install_dir : usrbin_exec_dir,
2695 install : true)
2696exes += exe
53b37016 2697manadocs += ['misc-utils/mcookie.1.adoc']
38bb89ee 2698bashcompletions += ['mcookie']
d4c880d5 2699
c2e299d0
SS
2700if build_liblastlog2
2701 exe = executable(
2702 'lastlog2',
2703 lastlog2_sources,
2704 include_directories : includes,
2705 link_with : [lib_common, lib_lastlog2],
2706 install_dir : usrbin_exec_dir,
2707 install : true)
2708 exes += exe
2709 manadocs += ['misc-utils/lastlog2.8.adoc']
2710 bashcompletions += ['lastlog2']
2711 manadocs += ['liblastlog2/man/lastlog2.3.adoc',
2712 'liblastlog2/man/ll2_write_entry.3.adoc',
2713 'liblastlog2/man/ll2_read_entry.3.adoc',
2714 'liblastlog2/man/ll2_import_lastlog.3.adoc',
2715 'liblastlog2/man/ll2_read_all.3.adoc',
2716 'liblastlog2/man/ll2_remove_entry.3.adoc',
2717 'liblastlog2/man/ll2_rename_user.3.adoc',
2718 'liblastlog2/man/ll2_update_login_time.3.adoc'
2719 ]
2720endif
2721
d4c880d5
ZJS
2722exe = executable(
2723 'namei',
2724 namei_sources,
2725 include_directories : includes,
c07f7b4e 2726 dependencies : [lib_selinux],
d4c880d5
ZJS
2727 install_dir : usrbin_exec_dir,
2728 install : true)
2729exes += exe
53b37016 2730manadocs += ['misc-utils/namei.1.adoc']
38bb89ee 2731bashcompletions += ['namei']
d4c880d5
ZJS
2732
2733exe = executable(
2734 'whereis',
2735 whereis_sources,
2736 include_directories : includes,
2737 link_with : [lib_common],
2738 install_dir : usrbin_exec_dir,
2739 install : true)
2740exes += exe
53b37016 2741manadocs += ['misc-utils/whereis.1.adoc']
38bb89ee 2742bashcompletions += ['whereis']
d4c880d5 2743
b6799ccb 2744opt = not get_option('build-lslocks').disabled()
d4c880d5
ZJS
2745exe = executable(
2746 'lslocks',
2747 lslocks_sources,
2748 include_directories : includes,
2749 link_with : [lib_common,
d4c880d5 2750 lib_smartcols],
c43b185a 2751 dependencies : [mount_dep],
d4c880d5 2752 install_dir : usrbin_exec_dir,
b6799ccb
JW
2753 install : opt,
2754 build_by_default : opt)
2755if opt and not is_disabler(exe)
d4c880d5 2756 exes += exe
53b37016 2757 manadocs += ['misc-utils/lslocks.8.adoc']
38bb89ee 2758 bashcompletions += ['lslocks']
d4c880d5
ZJS
2759endif
2760
b6799ccb 2761opt = not get_option('build-lsblk').disabled()
d4c880d5
ZJS
2762exe = executable(
2763 'lsblk',
2764 lsblk_sources,
2765 include_directories : includes,
2766 link_with : [lib_common,
c3317cdc 2767 lib_tcolors,
d4c880d5 2768 lib_smartcols],
a764efb5 2769 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2770 install : opt,
2771 build_by_default : opt)
2772if opt and not is_disabler(exe)
d4c880d5 2773 exes += exe
53b37016 2774 manadocs += ['misc-utils/lsblk.8.adoc']
38bb89ee 2775 bashcompletions += ['lsblk']
d4c880d5
ZJS
2776endif
2777
a125e2ee
MY
2778errnos_h = custom_target('errnos.h',
2779 input : 'tools/all_errnos',
2780 output : 'errnos.h',
543f991f
TW
2781 command : ['tools/all_errnos', awk.full_path(),
2782 cc.cmd_array(), get_option('c_args')],
a125e2ee
MY
2783)
2784
24395027 2785opt = not get_option('build-lsfd').require(lib_rt.found()).disabled()
ee194909
KZ
2786exe = executable(
2787 'lsfd',
a125e2ee 2788 lsfd_sources, errnos_h,
ee194909
KZ
2789 include_directories : includes,
2790 link_with : [lib_common,
2791 lib_smartcols],
06b27058 2792 dependencies : [lib_rt],
ee194909 2793 install_dir : usrbin_exec_dir,
06b27058
JW
2794 install : opt,
2795 build_by_default : opt)
2796if opt and not is_disabler(exe)
ee194909 2797 exes += exe
ac8be186 2798 manadocs += ['lsfd-cmd/lsfd.1.adoc']
ee194909
KZ
2799endif
2800
d4c880d5
ZJS
2801exe = executable(
2802 'uuidgen',
2803 uuidgen_sources,
2804 include_directories : includes,
06d3a851
KZ
2805 link_with : [lib_common,
2806 lib_uuid],
d4c880d5
ZJS
2807 install_dir : usrbin_exec_dir,
2808 install : true)
2809if not is_disabler(exe)
2810 exes += exe
53b37016 2811 manadocs += ['misc-utils/uuidgen.1.adoc']
38bb89ee 2812 bashcompletions += ['uuidgen']
d4c880d5
ZJS
2813endif
2814
2815exe = executable(
2816 'uuidparse',
2817 uuidparse_sources,
2818 include_directories : includes,
2819 link_with : [lib_common,
2820 lib_uuid,
2821 lib_smartcols],
2822 install_dir : usrbin_exec_dir,
2823 install : true)
2824if not is_disabler(exe)
2825 exes += exe
53b37016 2826 manadocs += ['misc-utils/uuidparse.1.adoc']
38bb89ee 2827 bashcompletions += ['uuidparse']
d4c880d5
ZJS
2828endif
2829
2830opt = build_uuidd
2831exe = executable(
2832 'uuidd',
2833 uuidd_sources,
2834 include_directories : includes,
2835 link_with : [lib_common,
2836 lib_uuid],
2837 dependencies : [realtime_libs,
2838 lib_systemd],
2839 install_dir : usrsbin_exec_dir,
2840 install : opt,
2841 build_by_default : opt)
2842exe2 = executable(
2843 'test_uuidd',
2844 test_uuidd_sources,
2845 include_directories : includes,
2846 link_with : [lib_common,
2847 lib_uuid],
2848 dependencies : thread_libs,
ba30b89c 2849 build_by_default : opt and program_tests)
d4c880d5
ZJS
2850if not is_disabler(exe)
2851 exes += [exe, exe2]
53b37016 2852 manadocs += ['misc-utils/uuidd.8.adoc']
38bb89ee 2853 bashcompletions += ['uuidd']
d4c880d5
ZJS
2854endif
2855
2856opt = build_libblkid
2857exe = executable(
2858 'blkid',
2859 blkid_sources,
2860 include_directories : includes,
a764efb5
JW
2861 link_with : [lib_common],
2862 dependencies : [blkid_dep],
d4c880d5
ZJS
2863 install_dir : sbindir,
2864 install : opt,
2865 build_by_default : opt)
2866if opt and not is_disabler(exe)
2867 exes += exe
53b37016 2868 manadocs += ['misc-utils/blkid.8.adoc']
38bb89ee 2869 bashcompletions += ['blkid']
d4c880d5
ZJS
2870endif
2871
69939195
ZJS
2872opt = opt and 'blkid' in static_programs
2873exe = executable(
2874 'blkid.static',
2875 blkid_sources,
2876 include_directories : includes,
a764efb5
JW
2877 link_with : [lib_common],
2878 dependencies : [blkid_static_dep],
69939195
ZJS
2879 install_dir : sbindir,
2880 install : opt,
2881 build_by_default : opt)
2882if opt and not is_disabler(exe)
2883 exes += exe
2884endif
d4c880d5
ZJS
2885
2886exe = executable(
2887 'sample-mkfs',
2888 'libblkid/samples/mkfs.c',
2889 include_directories : includes,
a764efb5 2890 dependencies : [blkid_dep])
d4c880d5
ZJS
2891if not is_disabler(exe)
2892 exes += exe
2893endif
2894
2895exe = executable(
2896 'sample-partitions',
2897 'libblkid/samples/partitions.c',
2898 include_directories : includes,
a764efb5 2899 dependencies : [blkid_dep])
d4c880d5
ZJS
2900if not is_disabler(exe)
2901 exes += exe
2902endif
2903
2904exe = executable(
2905 'sample-superblocks',
2906 'libblkid/samples/superblocks.c',
2907 include_directories : includes,
a764efb5 2908 dependencies : [blkid_dep])
d4c880d5
ZJS
2909if not is_disabler(exe)
2910 exes += exe
2911endif
2912
2913exe = executable(
2914 'sample-topology',
2915 'libblkid/samples/topology.c',
2916 include_directories : includes,
a764efb5 2917 dependencies : [blkid_dep])
d4c880d5
ZJS
2918if not is_disabler(exe)
2919 exes += exe
2920endif
2921
97e673a0
TW
2922exe = executable(
2923 'test_blkid_fuzz_sample',
2924 'libblkid/src/fuzz.c',
2925 include_directories: includes,
a764efb5 2926 dependencies : [blkid_dep],
ba30b89c 2927 build_by_default: program_tests)
97e673a0
TW
2928if not is_disabler(exe)
2929 exes += exe
2930endif
2931
d4c880d5
ZJS
2932############################################################
2933
2934exe = executable(
2935 'findfs',
2936 findfs_sources,
2937 include_directories : includes,
a764efb5 2938 dependencies : [blkid_dep],
d4c880d5
ZJS
2939 install_dir : sbindir,
2940 install : true)
2941if not is_disabler(exe)
2942 exes += exe
53b37016 2943 manadocs += ['misc-utils/findfs.8.adoc']
38bb89ee 2944 bashcompletions += ['findfs']
d4c880d5
ZJS
2945endif
2946
2947exe = executable(
2948 'wipefs',
2949 wipefs_sources,
2950 include_directories : includes,
2951 link_with : [lib_common,
d4c880d5 2952 lib_smartcols],
a764efb5 2953 dependencies : [blkid_dep],
d4c880d5
ZJS
2954 install_dir : sbindir,
2955 install : true)
2956if not is_disabler(exe)
2957 exes += exe
53b37016 2958 manadocs += ['misc-utils/wipefs.8.adoc']
38bb89ee 2959 bashcompletions += ['wipefs']
d4c880d5
ZJS
2960endif
2961
b6799ccb 2962opt = not get_option('build-findmnt').disabled()
d4c880d5
ZJS
2963exe = executable(
2964 'findmnt',
2965 findmnt_sources,
2966 include_directories : includes,
2967 link_with : [lib_common,
d4c880d5 2968 lib_smartcols],
a764efb5 2969 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2970 install : opt,
2971 build_by_default : opt)
2972if opt and not is_disabler(exe)
d4c880d5 2973 exes += exe
53b37016 2974 manadocs += ['misc-utils/findmnt.8.adoc']
38bb89ee 2975 bashcompletions += ['findmnt']
d4c880d5
ZJS
2976endif
2977
2978exe = executable(
2979 'kill',
2980 kill_sources,
2981 include_directories : includes,
2982 link_with : [lib_common],
2983 install : true)
2984if not is_disabler(exe)
2985 exes += exe
53b37016 2986 manadocs += ['misc-utils/kill.1.adoc']
d4c880d5
ZJS
2987endif
2988
2989opt = not get_option('build-rename').disabled()
2990exe = executable(
2991 'rename',
2992 rename_sources,
2993 include_directories : includes,
2994 install_dir : usrbin_exec_dir,
2995 install : opt,
2996 build_by_default : opt)
2997if opt and not is_disabler(exe)
2998 exes += exe
53b37016 2999 manadocs += ['misc-utils/rename.1.adoc']
38bb89ee 3000 bashcompletions += ['rename']
d4c880d5
ZJS
3001endif
3002
3003exe = executable(
3004 'getopt',
3005 getopt_sources,
3006 include_directories : includes,
308a0979 3007 link_with : [lib_common],
d4c880d5
ZJS
3008 install_dir : usrbin_exec_dir,
3009 install : true)
3010exes += exe
53b37016 3011manadocs += ['misc-utils/getopt.1.adoc']
38bb89ee 3012bashcompletions += ['getopt']
d4c880d5
ZJS
3013
3014exe = executable(
3015 'fincore',
3016 fincore_sources,
3017 include_directories : includes,
3018 link_with : [lib_common,
3019 lib_smartcols],
3020 install_dir : usrbin_exec_dir,
3021 install : true)
3022if not is_disabler(exe)
3023 exes += exe
53b37016 3024 manadocs += ['misc-utils/fincore.1.adoc']
38bb89ee 3025 bashcompletions += ['fincore']
d4c880d5
ZJS
3026endif
3027
3028exe = executable(
3029 'hardlink',
3030 hardlink_sources,
3031 include_directories : includes,
3032 link_with : [lib_common],
d4c880d5
ZJS
3033 install_dir : usrbin_exec_dir,
3034 install : true)
3035if not is_disabler(exe)
3036 exes += exe
53b37016 3037 manadocs += ['misc-utils/hardlink.1.adoc']
38bb89ee 3038 bashcompletions += ['hardlink']
d4c880d5
ZJS
3039endif
3040
c221578e
NS
3041opt = not get_option('build-pipesz').disabled()
3042exe = executable(
3043 'pipesz',
3044 pipesz_sources,
3045 include_directories : includes,
3046 link_with : [lib_common],
3047 install_dir : usrbin_exec_dir,
3048 install : true)
3049if opt and not is_disabler(exe)
3050 exes += exe
62c27bd0 3051 manadocs += ['misc-utils/pipesz.1.adoc']
80af57ed 3052 bashcompletions += ['pipesz']
c221578e
NS
3053endif
3054
d4c880d5
ZJS
3055exe = executable(
3056 'test_cal',
3057 cal_sources,
3058 include_directories : includes,
3059 c_args : '-DTEST_CAL',
3060 link_with : [lib_common,
3061 lib_tcolors],
ba30b89c 3062 dependencies : [curses_libs],
3063 build_by_default: program_tests)
d4c880d5
ZJS
3064if not is_disabler(exe)
3065 exes += exe
3066endif
3067
64bc8ab5
MY
3068exe = executable(
3069 'fadvise',
3070 fadvise_sources,
3071 include_directories : includes,
3072 link_with : [lib_common],
3073 install_dir : usrbin_exec_dir,
3074 install : true)
3075if not is_disabler(exe)
3076 exes += exe
3077 manadocs += ['misc-utils/fadvise.1.adoc']
3078 bashcompletions += ['fadvise']
3079endif
3080
941e1d55 3081if LINUX and conf.get('HAVE_PIDFD_OPEN').to_string() == '1'
334939a1
ZJS
3082 exe = executable(
3083 'waitpid',
3084 waitpid_sources,
3085 include_directories : includes,
3086 link_with : [lib_common],
3087 install_dir : usrbin_exec_dir,
3088 install : true)
3089 if not is_disabler(exe)
3090 exes += exe
3091 manadocs += ['misc-utils/waitpid.1.adoc']
3092 bashcompletions += ['waitpid']
3093 endif
550d32c4
TW
3094endif
3095
69e542bd
TW
3096syscalls_h = custom_target('syscalls.h',
3097 input : 'tools/all_syscalls',
3098 output : 'syscalls.h',
543f991f
TW
3099 command : ['tools/all_syscalls', awk.full_path(),
3100 cc.cmd_array(), get_option('c_args')],
69e542bd
TW
3101)
3102
3e0bbb12
TW
3103if cc.compiles(fs.read('include/audit-arch.h'), name : 'has AUDIT_ARCH_NATIVE')
3104 exe = executable(
3105 'enosys',
ced129dc 3106 'misc-utils/enosys.c', syscalls_h, errnos_h,
3e0bbb12
TW
3107 include_directories : includes,
3108 link_with : [lib_common],
3109 install_dir : usrbin_exec_dir,
3110 install : true)
3111 if not is_disabler(exe)
3112 exes += exe
3113 manadocs += ['misc-utils/enosys.1.adoc']
3114 bashcompletions += ['enosys']
3115 endif
cba52cc1
TW
3116endif
3117
e9ddea79
TW
3118exe = executable(
3119 'lsclocks',
3120 lsclocks_sources,
3121 include_directories : includes,
3122 link_with : [lib_common, lib_smartcols],
3123 install_dir : usrbin_exec_dir,
3124 install : true)
3125if not is_disabler(exe)
3126 exes += exe
3127 manadocs += ['misc-utils/lsclocks.1.adoc']
3128 bashcompletions += ['lsclocks']
3129endif
3130
cd094a05
MY
3131if conf.get('HAVE_RENAMEAT2').to_string() == '1'
3132exe = executable(
3133 'exch',
3134 exch_sources,
3135 include_directories : includes,
3136 link_with : [lib_common],
3137 install_dir : usrbin_exec_dir,
3138 install : true)
3139if not is_disabler(exe)
3140 exes += exe
3141 manadocs += ['misc-utils/exch.1.adoc']
3142 bashcompletions += ['exch']
3143endif
3144endif
3145
d4c880d5
ZJS
3146############################################################
3147
3148opt = not get_option('build-schedutils').disabled()
3149exe = executable(
3150 'chrt',
3151 'schedutils/chrt.c',
3152 include_directories : includes,
3153 link_with : lib_common,
3154 install_dir : usrbin_exec_dir,
3155 install : opt,
3156 build_by_default : opt)
3157
3158exe2 = executable(
3159 'ionice',
3160 'schedutils/ionice.c',
3161 include_directories : includes,
3162 link_with : lib_common,
3163 install_dir : usrbin_exec_dir,
3164 install : opt,
3165 build_by_default : opt)
3166
3167exe3 = executable(
3168 'taskset',
3169 'schedutils/taskset.c',
3170 include_directories : includes,
3171 link_with : lib_common,
3172 install_dir : usrbin_exec_dir,
3173 install : opt,
3174 build_by_default : opt)
3175
6e92db54
KZ
3176exe4 = executable(
3177 'uclampset',
3178 'schedutils/uclampset.c',
3179 include_directories : includes,
3180 link_with : lib_common,
3181 install_dir : usrbin_exec_dir,
3182 install : opt,
3183 build_by_default : opt)
3184
d4c880d5 3185if opt and not is_disabler(exe)
6e92db54 3186 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
3187 manadocs += ['schedutils/chrt.1.adoc',
3188 'schedutils/ionice.1.adoc',
3189 'schedutils/taskset.1.adoc',
3190 'schedutils/uclampset.1.adoc']
38bb89ee 3191 bashcompletions += ['chrt', 'ionice', 'taskset', 'uclampset']
d4c880d5
ZJS
3192endif
3193
3194############################################################
3195
3196# TODO: when autotools compat is not needed, s/_/-/g in file names?
3197
3198exe = executable(
3199 'test_ttyutils',
3200 'lib/ttyutils.c',
3201 c_args : ['-DTEST_PROGRAM_TTYUTILS'],
3202 include_directories : dir_include,
ba30b89c 3203 link_with : lib_common,
3204 build_by_default: program_tests)
d4c880d5
ZJS
3205exes += exe
3206
3207exe = executable(
3208 'test_blkdev',
3209 'lib/blkdev.c',
3210 c_args : ['-DTEST_PROGRAM_BLKDEV'],
3211 include_directories : dir_include,
ba30b89c 3212 link_with : lib_common,
3213 build_by_default: program_tests)
d4c880d5
ZJS
3214exes += exe
3215
3216exe = executable(
3217 'test_ismounted',
3218 'lib/ismounted.c',
3219 c_args : ['-DTEST_PROGRAM_ISMOUNTED'],
3220 include_directories : dir_include,
ba30b89c 3221 link_with : lib_common,
3222 build_by_default: program_tests)
d4c880d5
ZJS
3223exes += exe
3224
3225exe = executable(
3226 'test_mangle',
3227 'lib/mangle.c',
3228 c_args : ['-DTEST_PROGRAM_MANGLE'],
ba30b89c 3229 include_directories : dir_include,
3230 build_by_default: program_tests)
d4c880d5
ZJS
3231exes += exe
3232
3233exe = executable(
3234 'test_strutils',
3235 'lib/strutils.c',
3236 c_args : ['-DTEST_PROGRAM_STRUTILS'],
ba30b89c 3237 include_directories : dir_include,
3238 build_by_default: program_tests)
d4c880d5
ZJS
3239exes += exe
3240
3241exe = executable(
3242 'test_colors',
3243 'lib/colors.c',
3244 'lib/color-names.c',
3245 c_args : ['-DTEST_PROGRAM_COLORS'],
3246 include_directories : dir_include,
ba30b89c 3247 link_with : [lib_common, lib_tcolors],
3248 build_by_default: program_tests)
d4c880d5
ZJS
3249exes += exe
3250
3251exe = executable(
3252 'test_randutils',
3253 'lib/randutils.c',
3254 c_args : ['-DTEST_PROGRAM_RANDUTILS'],
ba30b89c 3255 include_directories : dir_include,
3256 build_by_default: program_tests)
d4c880d5
ZJS
3257exes += exe
3258
941e1d55
TW
3259if conf.get('HAVE_OPENAT').to_string() == '1' \
3260 and conf.get('HAVE_DIRFD').to_string() == '1'
d6418774
ZJS
3261 exe = executable(
3262 'test_procfs',
3263 'lib/procfs.c',
3264 c_args : ['-DTEST_PROGRAM_PROCFS'],
3265 include_directories : dir_include,
ba30b89c 3266 link_with : lib_common,
3267 build_by_default: program_tests)
d6418774 3268 exes += exe
d4c880d5 3269
d6418774
ZJS
3270 exe = executable(
3271 'test_path',
3272 'lib/path.c',
3273 'lib/fileutils.c',
3274 have_cpu_set_t ? 'lib/cpuset.c' : [],
3275 c_args : ['-DTEST_PROGRAM_PATH'],
3276 include_directories : dir_include,
ba30b89c 3277 link_with : lib_common,
3278 build_by_default: program_tests)
d6418774
ZJS
3279 exes += exe
3280endif
d4c880d5 3281
941e1d55 3282if conf.get('HAVE_PTY').to_string() == '1'
44475360
ZJS
3283 exe = executable(
3284 'test_pty',
3285 pty_session_c,
3286 monotonic_c,
3287 c_args : ['-DTEST_PROGRAM_PTY'],
3288 include_directories : dir_include,
3289 link_with : [lib_common],
3290 dependencies : [lib_m,
3291 realtime_libs,
ba30b89c 3292 lib_util],
3293 build_by_default: program_tests)
44475360
ZJS
3294 exes += exe
3295endif
d4c880d5 3296
d6418774
ZJS
3297if LINUX
3298 exe = executable(
3299 'test_cpuset',
3300 'lib/cpuset.c',
3301 c_args : ['-DTEST_PROGRAM_CPUSET'],
ba30b89c 3302 include_directories : dir_include,
3303 build_by_default: program_tests)
d6418774
ZJS
3304 exes += exe
3305endif
d4c880d5
ZJS
3306
3307exe = executable(
3308 'test_sysfs',
3309 'lib/sysfs.c',
3310 'lib/path.c',
35d26ae8 3311 'lib/buffer.c',
fb8493fd 3312 'lib/mbsalign.c',
d4c880d5
ZJS
3313 'lib/fileutils.c',
3314 have_cpu_set_t ? 'lib/cpuset.c' : [],
3315 c_args : ['-DTEST_PROGRAM_SYSFS'],
ba30b89c 3316 include_directories : dir_include,
3317 build_by_default: program_tests)
d4c880d5
ZJS
3318exes += exe
3319
3320exe = executable(
3321 'test_pager',
3322 'lib/pager.c',
3323 c_args : ['-DTEST_PROGRAM_PAGER'],
ba30b89c 3324 include_directories : dir_include,
3325 build_by_default: program_tests)
d4c880d5
ZJS
3326exes += exe
3327
3328exe = executable(
3329 'test_linux_version',
3330 'lib/linux_version.c',
3331 c_args : ['-DTEST_PROGRAM_LINUXVERSION'],
ba30b89c 3332 include_directories : dir_include,
3333 build_by_default: program_tests)
d4c880d5
ZJS
3334exes += exe
3335
3336exe = executable(
3337 'test_fileutils',
3338 'lib/fileutils.c',
3339 c_args : ['-DTEST_PROGRAM_FILEUTILS'],
ba30b89c 3340 include_directories : dir_include,
3341 build_by_default: program_tests)
d4c880d5
ZJS
3342exes += exe
3343
3344exe = executable(
3345 'test_canonicalize',
3346 'lib/canonicalize.c',
3347 c_args : ['-DTEST_PROGRAM_CANONICALIZE'],
ba30b89c 3348 include_directories : dir_include,
3349 build_by_default: program_tests)
d4c880d5
ZJS
3350exes += exe
3351
3352exe = executable(
3353 'test_timeutils',
3354 'lib/timeutils.c',
3355 'lib/strutils.c',
3356 c_args : ['-DTEST_PROGRAM_TIMEUTILS'],
ba30b89c 3357 include_directories : dir_include,
3358 build_by_default: program_tests)
d4c880d5
ZJS
3359exes += exe
3360
3361exe = executable(
3362 'test_pwdutils',
3363 'lib/pwdutils.c',
3364 c_args : ['-DTEST_PROGRAM'],
3365 include_directories : dir_include,
ba30b89c 3366 link_with : lib_common,
3367 build_by_default: program_tests)
d4c880d5
ZJS
3368exes += exe
3369
866d922b
KZ
3370exe = executable(
3371 'test_logindefs',
3372 'lib/logindefs.c',
3373 c_args : ['-DTEST_PROGRAM'],
3374 include_directories : dir_include,
ba30b89c 3375 link_with : [lib_common, logindefs_c],
3376 build_by_default: program_tests)
866d922b
KZ
3377exes += exe
3378
3379
d4c880d5
ZJS
3380############################################################
3381
3382exe = executable(
3383 'test_uuid_parser',
3384 'libuuid/src/test_uuid.c',
3385 include_directories : [dir_include, dir_libuuid],
3386 link_with : lib_uuid,
ba30b89c 3387 dependencies : socket_libs,
3388 build_by_default: program_tests)
d4c880d5
ZJS
3389if not is_disabler(exe)
3390 exes += exe
3391endif
3392
3393############################################################
3394
2a472ae8 3395libfdisk_tests_cflags = ['-DTEST_PROGRAM']
a764efb5
JW
3396libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid]
3397libfdisk_tests_ldadd_deps = [blkid_dep]
d4c880d5
ZJS
3398
3399exe = executable(
3400 'test_fdisk_ask',
3401 'libfdisk/src/ask.c',
3402 c_args : libfdisk_tests_cflags,
3403 include_directories : lib_fdisk_includes,
ba30b89c 3404 link_with : libfdisk_tests_ldadd,
a764efb5 3405 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3406 build_by_default: program_tests)
d4c880d5
ZJS
3407if not is_disabler(exe)
3408 exes += exe
3409endif
3410
3411exe = executable(
3412 'test_fdisk_gpt',
3413 'libfdisk/src/gpt.c',
3414 c_args : libfdisk_tests_cflags,
3415 include_directories : lib_fdisk_includes,
ba30b89c 3416 link_with : libfdisk_tests_ldadd,
a764efb5 3417 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3418 build_by_default: program_tests)
d4c880d5
ZJS
3419if not is_disabler(exe)
3420 exes += exe
3421endif
3422
3423exe = executable(
3424 'test_fdisk_utils',
3425 'libfdisk/src/utils.c',
3426 c_args : libfdisk_tests_cflags,
3427 include_directories : lib_fdisk_includes,
ba30b89c 3428 link_with : libfdisk_tests_ldadd,
a764efb5 3429 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3430 build_by_default: program_tests)
d4c880d5
ZJS
3431if not is_disabler(exe)
3432 exes += exe
3433endif
3434
3435exe = executable(
3436 'test_fdisk_script',
3437 'libfdisk/src/script.c',
3438 c_args : libfdisk_tests_cflags,
3439 include_directories : lib_fdisk_includes,
ba30b89c 3440 link_with : libfdisk_tests_ldadd,
a764efb5 3441 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3442 build_by_default: program_tests)
d4c880d5
ZJS
3443if not is_disabler(exe)
3444 exes += exe
3445endif
3446
3447exe = executable(
3448 'test_fdisk_version',
3449 'libfdisk/src/version.c',
3450 c_args : libfdisk_tests_cflags,
3451 include_directories : lib_fdisk_includes,
ba30b89c 3452 link_with : libfdisk_tests_ldadd,
a764efb5 3453 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3454 build_by_default: program_tests)
d4c880d5
ZJS
3455if not is_disabler(exe)
3456 exes += exe
3457endif
3458
3459exe = executable(
3460 'test_fdisk_item',
3461 'libfdisk/src/item.c',
3462 c_args : libfdisk_tests_cflags,
3463 include_directories : lib_fdisk_includes,
ba30b89c 3464 link_with : libfdisk_tests_ldadd,
a764efb5 3465 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3466 build_by_default: program_tests)
d4c880d5
ZJS
3467if not is_disabler(exe)
3468 exes += exe
3469endif
3470
d4c880d5
ZJS
3471sample_fdisk_ldadd = [lib_common, lib_fdisk]
3472
3473exe = executable(
3474 'sample-fdisk-mkpart',
3475 'libfdisk/samples/mkpart.c',
d4c880d5
ZJS
3476 include_directories : lib_fdisk_includes,
3477 link_with : sample_fdisk_ldadd)
3478if not is_disabler(exe)
3479 exes += exe
3480endif
3481
3482exe = executable(
3483 'sample-fdisk-mkpart-fullspec',
3484 'libfdisk/samples/mkpart-fullspec.c',
d4c880d5
ZJS
3485 include_directories : lib_fdisk_includes,
3486 link_with : sample_fdisk_ldadd)
3487if not is_disabler(exe)
3488 exes += exe
3489endif
3490
3491############################################################
3492
a76299c1
TW
3493exe = executable(
3494 'test_cap',
3495 'tests/helpers/test_cap.c',
3496 include_directories : includes,
3497 dependencies : [lib_cap_ng],
3498 build_by_default: program_tests)
512c91a6
TW
3499if not is_disabler(exe)
3500 exes += exe
3501endif
a76299c1 3502
d4c880d5
ZJS
3503exe = executable(
3504 'test_mbsencode',
3505 'tests/helpers/test_mbsencode.c',
3506 include_directories : includes,
ba30b89c 3507 link_with : lib_common,
3508 build_by_default: program_tests)
d4c880d5
ZJS
3509exes += exe
3510
3511exe = executable(
3512 'test_byteswap',
3513 'tests/helpers/test_byteswap.c',
ba30b89c 3514 include_directories : includes,
3515 build_by_default: program_tests)
d4c880d5
ZJS
3516exes += exe
3517
3518exe = executable(
3519 'test_md5',
3520 'tests/helpers/test_md5.c',
3521 md5_c,
ba30b89c 3522 include_directories : includes,
3523 build_by_default: program_tests)
d4c880d5
ZJS
3524exes += exe
3525
3526exe = executable(
3527 'test_sha1',
3528 'tests/helpers/test_sha1.c',
3529 sha1_c,
ba30b89c 3530 include_directories : includes,
3531 build_by_default: program_tests)
d4c880d5
ZJS
3532exes += exe
3533
3534exe = executable(
3535 'test_pathnames',
3536 'tests/helpers/test_pathnames.c',
ba30b89c 3537 include_directories : includes,
3538 build_by_default: program_tests)
d4c880d5
ZJS
3539exes += exe
3540
3541exe = executable(
3542 'test_strerror',
3543 'tests/helpers/test_strerror.c',
ba30b89c 3544 include_directories : includes,
3545 build_by_default: program_tests)
d4c880d5
ZJS
3546exes += exe
3547
3548exe = executable(
3549 'test_sysinfo',
3550 'tests/helpers/test_sysinfo.c',
ba30b89c 3551 include_directories : includes,
3552 build_by_default: program_tests)
d4c880d5
ZJS
3553exes += exe
3554
3555exe = executable(
3556 'test_sigreceive',
3557 'tests/helpers/test_sigreceive.c',
3558 include_directories : includes,
ba30b89c 3559 link_with : lib_common,
3560 build_by_default: program_tests)
d4c880d5
ZJS
3561exes += exe
3562
3563exe = executable(
3564 'test_tiocsti',
3565 'tests/helpers/test_tiocsti.c',
ba30b89c 3566 include_directories : includes,
3567 build_by_default: program_tests)
d4c880d5
ZJS
3568exes += exe
3569
3570exe = executable(
3571 'test_uuid_namespace',
3572 'tests/helpers/test_uuid_namespace.c',
3573 predefined_c,
3574 unpack_c,
3575 unparse_c,
ba30b89c 3576 include_directories : includes,
3577 build_by_default: program_tests)
d4c880d5
ZJS
3578exes += exe
3579
06b27058 3580if LINUX and lib_rt.found()
d6418774
ZJS
3581 exe = executable(
3582 'test_mkfds',
3583 'tests/helpers/test_mkfds.c',
b2033a32 3584 'tests/helpers/test_mkfds.h',
38ffd1e3 3585 'tests/helpers/test_mkfds_ppoll.c',
d6418774 3586 include_directories : includes,
06b27058 3587 dependencies : [lib_rt],
ba30b89c 3588 build_by_default: program_tests)
d6418774
ZJS
3589 exes += exe
3590endif
f7b41ef8 3591
42900563
TW
3592exe = executable(
3593 'test_enosys',
3594 'tests/helpers/test_enosys.c',
ba30b89c 3595 include_directories : includes,
3596 build_by_default: program_tests)
42900563
TW
3597exes += exe
3598
d4c880d5
ZJS
3599############################################################
3600
941e1d55 3601if conf.get('HAVE_OPENAT').to_string() == '1'
d6418774
ZJS
3602 exe = executable(
3603 'sample-scols-tree',
3604 'libsmartcols/samples/tree.c',
3605 include_directories : includes,
ba30b89c 3606 link_with : [lib_smartcols, lib_common],
3607 build_by_default: program_tests)
d6418774
ZJS
3608 if not is_disabler(exe)
3609 exes += exe
3610 endif
d4c880d5
ZJS
3611endif
3612
3613exe = executable(
3614 'sample-scols-title',
3615 'libsmartcols/samples/title.c',
3616 include_directories : includes,
3617 link_with : [lib_smartcols, lib_common])
3618if not is_disabler(exe)
3619 exes += exe
3620endif
3621
3622exe = executable(
3623 'sample-scols-wrap',
3624 'libsmartcols/samples/wrap.c',
3625 include_directories : includes,
3626 link_with : [lib_smartcols, lib_common])
3627if not is_disabler(exe)
3628 exes += exe
3629endif
3630
3631exe = executable(
3632 'sample-scols-continuous',
3633 'libsmartcols/samples/continuous.c',
3634 include_directories : includes,
3635 link_with : [lib_smartcols, lib_common])
3636if not is_disabler(exe)
3637 exes += exe
3638endif
3639
be597292
TW
3640exe = executable(
3641 'sample-scols-continuous-json',
3642 'libsmartcols/samples/continuous-json.c',
3643 include_directories : includes,
3644 link_with : [lib_smartcols, lib_common])
3645if not is_disabler(exe)
3646 exes += exe
3647endif
3648
d4c880d5
ZJS
3649exe = executable(
3650 'sample-scols-maxout',
3651 'libsmartcols/samples/maxout.c',
3652 include_directories : includes,
3653 link_with : [lib_smartcols, lib_common])
3654if not is_disabler(exe)
3655 exes += exe
3656endif
3657
3658exe = executable(
3659 'sample-scols-fromfile',
3660 'libsmartcols/samples/fromfile.c',
3661 include_directories : includes,
3662 link_with : [lib_smartcols, lib_common])
3663if not is_disabler(exe)
3664 exes += exe
3665endif
3666
3667exe = executable(
3668 'sample-scols-grouping-simple',
3669 'libsmartcols/samples/grouping-simple.c',
3670 include_directories : includes,
3671 link_with : [lib_smartcols, lib_common])
3672if not is_disabler(exe)
3673 exes += exe
3674endif
3675
3676exe = executable(
3677 'sample-scols-grouping-overlay',
3678 'libsmartcols/samples/grouping-overlay.c',
3679 include_directories : includes,
3680 link_with : [lib_smartcols, lib_common])
3681if not is_disabler(exe)
3682 exes += exe
3683endif
48afece8
TW
3684
3685exe = executable(
3686 'test_boilerplate',
3687 'Documentation/boilerplate.c',
3688 include_directories : includes,
3689 build_by_default: program_tests)
3690if not is_disabler(exe)
3691 exes += exe
3692endif
d4c880d5
ZJS
3693
3694############################################################
3695
3696# Let the test runner know whether we're running under asan and export
3697# some paths. We use a file on disk so that it is possible to run the
3698# test scripts from commandline without setting any variables.
3699configure_file(output : 'meson.conf',
3700 capture : true,
3701 command : ['echo',
3702 '''asan=@0@
3703PYTHON=@1@
3704'''.format(get_option('b_sanitize')=='address' ? 'yes' : '',
e2cd7446 3705 python.full_path())])
d4c880d5
ZJS
3706
3707run_sh = find_program('tests/run.sh')
3708run_target(
3709 'check',
3710 command : [run_sh,
3711 '--srcdir=' + meson.current_source_dir(),
3712 '--builddir=' + meson.current_build_dir(),
3713 '--parallel',
3714 '--nonroot'],
3715 depends : exes)
53b37016
KZ
3716
3717
3718manadocs += ['lib/terminal-colors.d.5.adoc']
3719manadocs += ['libblkid/libblkid.3.adoc']
3720
3721if build_libuuid
3722 manadocs += [
3723 'libuuid/man/uuid.3.adoc',
3724 'libuuid/man/uuid_clear.3.adoc',
3725 'libuuid/man/uuid_compare.3.adoc',
3726 'libuuid/man/uuid_copy.3.adoc',
3727 'libuuid/man/uuid_generate.3.adoc',
3728 'libuuid/man/uuid_is_null.3.adoc',
3729 'libuuid/man/uuid_parse.3.adoc',
3730 'libuuid/man/uuid_time.3.adoc',
3731 'libuuid/man/uuid_unparse.3.adoc']
38bb89ee
TW
3732 manlinks += {
3733 'uuid_generate_random.3': 'uuid_generate.3',
3734 'uuid_generate_time.3': 'uuid_generate.3',
3735 'uuid_generate_time_safe.3': 'uuid_generate.3',
3736 }
53b37016
KZ
3737endif
3738
00b8a51f 3739asciidoctor = find_program('asciidoctor', required : false)
53b37016
KZ
3740if asciidoctor.found()
3741 foreach adoc : manadocs
3742 name = adoc.split('/')[-1]
3743 page = name.split('.adoc')[0]
3744 section = page.split('.')[-1]
3745 mandirn = join_paths(mandir, 'man' + section)
3746 input = adoc
3747
3748 custom_target(
3749 page,
3750 command : [ asciidoctor,
3751 '-b', 'manpage',
3752 '-a', 'VERSION=' + meson.project_version(),
38bb89ee 3753 '-a', 'release-version=' + meson.project_version(),
53b37016 3754 '-a', 'ADJTIME_PATH=/etc/adjtime',
38bb89ee 3755 '-a', 'package-docdir=' + docdir,
53b37016
KZ
3756 '--base-dir=' + meson.current_source_dir(),
3757 '--destination-dir=' + meson.current_build_dir(),
adcab835
TW
3758 '--load-path', '@SOURCE_ROOT@/tools',
3759 '--require', 'asciidoctor-includetracker',
53b37016
KZ
3760 '@INPUT@'],
3761 input : input,
3762 output : [page],
adcab835 3763 depfile : page + '.deps',
53b37016
KZ
3764 install: true,
3765 install_dir : mandirn)
3766 endforeach
38bb89ee
TW
3767
3768 foreach link_name, target : manlinks
3769 link_section = link_name.split('.')[-1]
3770 target_section = target.split('.')[-1]
3771 meson.add_install_script(meson_make_manpage_stub,
3772 join_paths('man' + target_section, target),
3773 join_paths(mandir, 'man' + link_section, link_name))
3774 endforeach
3775endif
3776
3777if bash_completion.found()
3778 foreach completion : bashcompletions
3779 install_data(
3780 join_paths('bash-completion', completion),
caa85688 3781 install_dir : bash_completion.get_variable(pkgconfig : 'completionsdir')
38bb89ee
TW
3782 )
3783 endforeach
aa519054
KZ
3784 foreach link_name, target : bashcompletionslinks
3785 meson.add_install_script(meson_make_symlink,
3786 target,
caa85688 3787 join_paths(bash_completion.get_variable(pkgconfig : 'completionsdir'), link_name))
aa519054 3788 endforeach
53b37016 3789endif