]> git.ipfire.org Git - thirdparty/util-linux.git/blame - meson.build
Merge branch 'getwc' of https://github.com/t-8ch/util-linux
[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')
986subdir('po')
987
988includes = [dir_include,
d4c880d5 989 dir_libsmartcols,
d4c880d5
ZJS
990 dir_libfdisk,
991 dir_libuuid,
c2e299d0 992 dir_liblastlog2,
d4c880d5
ZJS
993 dir_sys_utils]
994
995exes = []
996
997opt = not get_option('build-chfn-chsh').disabled()
998exe = executable(
999 'chfn',
1000 chfn_sources,
1001 chfn_chsh_sources,
1002 include_directories : includes,
0333c40b 1003 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1004 dependencies : chfn_chsh_deps,
1005 install_dir : usrbin_exec_dir,
60d457f5 1006 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1007 install : opt,
1008 build_by_default : opt)
38bb89ee 1009
d4c880d5
ZJS
1010exe2 = executable(
1011 'chsh',
1012 'login-utils/chsh.c',
4b724469 1013 'lib/shells.c',
d4c880d5
ZJS
1014 chfn_chsh_sources,
1015 include_directories : includes,
1016 link_with : lib_common,
1017 dependencies : chfn_chsh_deps,
1018 install_dir : usrbin_exec_dir,
a13574b1 1019 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1020 install : opt,
1021 build_by_default : opt)
1022if opt and not is_disabler(exe)
1023 exes += [exe, exe2]
38bb89ee
TW
1024 manadocs += ['login-utils/chfn.1.adoc', 'login-utils/chsh.1.adoc']
1025 bashcompletions += ['chfn', 'chsh']
d4c880d5
ZJS
1026endif
1027
1028exe = executable(
1029 'test_islocal',
1030 test_islocal_sources,
1031 include_directories : includes,
ba30b89c 1032 c_args : '-DTEST_PROGRAM',
1033 build_by_default : program_tests)
d4c880d5
ZJS
1034exes += exe
1035
d4c880d5
ZJS
1036exe = executable(
1037 'test-consoles',
1038 test_consoles_sources,
1039 c_args : ['-DTEST_PROGRAM'],
1040 include_directories : includes,
ba30b89c 1041 link_with : lib_common,
1042 build_by_default : program_tests)
d4c880d5
ZJS
1043exes += exe
1044
1045opt = not get_option('build-last').disabled()
1046exe = executable(
1047 'last',
1048 last_sources,
1049 include_directories : includes,
1050 link_with : [lib_common],
1051 install_dir : usrbin_exec_dir,
1052 install : opt,
1053 build_by_default : opt)
1054if opt and not is_disabler(exe)
1055 exes += exe
1056 meson.add_install_script(meson_make_symlink,
1057 'last',
1058 join_paths(usrbin_exec_dir, 'lastb'))
38bb89ee
TW
1059 manadocs += ['login-utils/last.1.adoc']
1060 manlinks += {'lastb.1': 'last.1'}
1061 bashcompletions += ['last']
aa519054 1062 bashcompletionslinks += {'lastb': 'last'}
d4c880d5
ZJS
1063endif
1064
1065opt = not get_option('build-nologin').disabled()
1066exe = executable(
1067 'nologin',
1068 'login-utils/nologin.c',
1069 include_directories : includes,
1070 install_dir : sbindir,
308a0979 1071 link_with : [lib_common],
d4c880d5
ZJS
1072 install : opt,
1073 build_by_default : opt)
1074if opt and not is_disabler(exe)
1075 exes += exe
38bb89ee 1076 manadocs += ['login-utils/nologin.8.adoc']
d4c880d5
ZJS
1077endif
1078
1079opt = not get_option('build-utmpdump').disabled()
1080exe = executable(
1081 'utmpdump',
1082 'login-utils/utmpdump.c',
1083 include_directories : includes,
1084 link_with : [lib_common],
1085 install_dir : usrbin_exec_dir,
1086 install : opt,
1087 build_by_default : opt)
1088if opt and not is_disabler(exe)
1089 exes += exe
38bb89ee
TW
1090 manadocs += ['login-utils/utmpdump.1.adoc']
1091 bashcompletions += ['utmpdump']
d4c880d5
ZJS
1092endif
1093
1094opt = not get_option('build-su').disabled()
1095exe = executable(
1096 'su',
1097 'login-utils/su.c',
1098 'login-utils/su-common.c',
1099 'login-utils/su-common.h',
4b724469 1100 'lib/shells.c',
d4c880d5
ZJS
1101 pty_session_c,
1102 monotonic_c,
1103 include_directories : includes,
0333c40b 1104 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1105 dependencies : [lib_pam,
1106 lib_pam_misc,
1107 lib_util,
1108 realtime_libs],
fb8c224e 1109 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1110 install : opt,
1111 build_by_default : opt)
1112if opt and not is_disabler(exe)
1113 exes += exe
38bb89ee
TW
1114 manadocs += ['login-utils/su.1.adoc']
1115 bashcompletions += ['su']
d4c880d5
ZJS
1116endif
1117
1118opt = not get_option('build-newgrp').disabled()
1119exe = executable(
1120 'newgrp',
1121 'login-utils/newgrp.c',
1122 include_directories : includes,
1123 dependencies : [lib_crypt],
1124 install_dir : usrbin_exec_dir,
cb3dee5a 1125 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1126 install : opt,
1127 build_by_default : opt)
1128if opt and not is_disabler(exe)
1129 exes += exe
38bb89ee 1130 manadocs += ['login-utils/newgrp.1.adoc']
f265b432 1131 bashcompletions += ['newgrp']
d4c880d5
ZJS
1132endif
1133
1134opt = not get_option('build-lslogins').disabled()
1135exe = executable(
1136 'lslogins',
1137 'login-utils/lslogins.c',
d4c880d5
ZJS
1138 include_directories : includes,
1139 link_with : [lib_common,
0333c40b 1140 lib_smartcols,
13d2fd8f
TW
1141 logindefs_c] +
1142 (build_liblastlog2 ? [lib_lastlog2] : []),
d4c880d5
ZJS
1143 dependencies : [lib_selinux,
1144 lib_systemd],
1145 install_dir : usrbin_exec_dir,
1146 install : opt,
1147 build_by_default : opt)
1148if opt and not is_disabler(exe)
1149 exes += exe
38bb89ee
TW
1150 manadocs += ['login-utils/lslogins.1.adoc']
1151 bashcompletions += ['lslogins']
d4c880d5
ZJS
1152endif
1153
1154opt = not get_option('build-vipw').disabled()
1155exe = executable(
1156 'vipw',
1157 'login-utils/vipw.c',
1158 'login-utils/setpwnam.h',
1159 include_directories : includes,
1160 link_with : [lib_common],
1161 dependencies : [lib_selinux],
1162 install_dir : usrbin_exec_dir,
1163 install : opt,
1164 build_by_default : opt)
1165if opt and not is_disabler(exe)
1166 exes += exe
1167 meson.add_install_script(meson_make_symlink,
1168 'vipw',
1169 join_paths(usrbin_exec_dir, 'vigr'))
38bb89ee 1170 manadocs += ['login-utils/vipw.8.adoc']
f6fb7fa7
CH
1171 meson.add_install_script(meson_make_symlink,
1172 'vipw.8',
1173 join_paths(mandir, 'man8/vigr.8'))
d4c880d5
ZJS
1174endif
1175
1176opt = not get_option('build-runuser').disabled()
1177exe = executable(
1178 'runuser',
1179 'login-utils/runuser.c',
1180 'login-utils/su-common.c',
1181 'login-utils/su-common.h',
4b724469 1182 'lib/shells.c',
d4c880d5
ZJS
1183 pty_session_c,
1184 monotonic_c,
1185 include_directories : includes,
0333c40b 1186 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
1187 dependencies : [lib_pam,
1188 lib_pam_misc,
1189 lib_util,
1190 realtime_libs],
1191 install_dir : sbindir,
1192 install : opt,
1193 build_by_default : opt)
1194if opt and not is_disabler(exe)
1195 exes += exe
38bb89ee 1196 manadocs += ['login-utils/runuser.1.adoc']
aa519054 1197 bashcompletionslinks += {'runuser': 'su'}
d4c880d5
ZJS
1198endif
1199
1200############################################################
1201
8886d84e
TW
1202if is_glibc
1203 exe = executable(
1204 'col',
1205 col_sources,
1206 include_directories : includes,
1207 link_with : lib_common,
1208 install_dir : usrbin_exec_dir,
1209 install : true)
1210 exes += exe
1211 manadocs += ['text-utils/col.1.adoc']
1212 bashcompletions += ['col']
1213endif
d4c880d5
ZJS
1214
1215exe = executable(
1216 'colcrt',
1217 colcrt_sources,
1218 include_directories : includes,
1219 install_dir : usrbin_exec_dir,
1220 install : true)
1221exes += exe
38bb89ee
TW
1222manadocs += ['text-utils/colcrt.1.adoc']
1223bashcompletions += ['colcrt']
d4c880d5
ZJS
1224
1225exe = executable(
1226 'colrm',
1227 colrm_sources,
1228 include_directories : includes,
1229 link_with : lib_common,
1230 install_dir : usrbin_exec_dir,
1231 install : true)
1232exes += exe
38bb89ee
TW
1233manadocs += ['text-utils/colrm.1.adoc']
1234bashcompletions += ['colrm']
d4c880d5
ZJS
1235
1236exe = executable(
1237 'rev',
1238 rev_sources,
1239 include_directories : includes,
1240 install_dir : usrbin_exec_dir,
1241 install : true)
1242exes += exe
38bb89ee
TW
1243manadocs += ['text-utils/rev.1.adoc']
1244bashcompletions += ['rev']
d4c880d5
ZJS
1245
1246exe = executable(
1247 'column',
1248 column_sources,
1249 include_directories : includes,
1250 link_with : [lib_common,
1251 lib_smartcols],
1252 install_dir : usrbin_exec_dir,
1253 install : true)
1254if not is_disabler(exe)
1255 exes += exe
38bb89ee
TW
1256 manadocs += ['text-utils/column.1.adoc']
1257 bashcompletions += ['column']
d4c880d5
ZJS
1258endif
1259
1260opt = not get_option('build-line').disabled()
1261exe = executable(
1262 'line',
1263 line_sources,
1264 include_directories : includes,
1265 install_dir : usrbin_exec_dir,
1266 install : opt,
1267 build_by_default : opt)
1268if opt and not is_disabler(exe)
1269 exes += exe
38bb89ee 1270 manadocs += ['text-utils/line.1.adoc']
d4c880d5
ZJS
1271endif
1272
1273opt = not get_option('build-pg').disabled()
1274exe = executable(
1275 'pg',
1276 pg_sources,
1277 link_with : lib_common,
1278 include_directories : includes,
1279 dependencies : [lib_tinfo,
1280 curses_libs],
1281 install_dir : usrbin_exec_dir,
1282 install : opt,
1283 build_by_default : opt)
1284if opt and not is_disabler(exe)
1285 exes += exe
38bb89ee
TW
1286 manadocs += ['text-utils/pg.1.adoc']
1287 bashcompletions += ['pg']
d4c880d5
ZJS
1288endif
1289
1290opt = not get_option('build-ul').disabled()
1291exe = executable(
1292 'ul',
1293 ul_sources,
1294 include_directories : includes,
1295 dependencies : [lib_tinfo,
1296 curses_libs],
1297 install_dir : usrbin_exec_dir,
1298 install : opt,
1299 build_by_default : opt)
1300if opt and not is_disabler(exe)
1301 exes += exe
38bb89ee
TW
1302 manadocs += ['text-utils/ul.1.adoc']
1303 bashcompletions += ['ul']
d4c880d5
ZJS
1304endif
1305
1306opt = not get_option('build-more').disabled()
1307exe = executable(
1308 'more',
1309 more_sources,
308a0979 1310 link_with : [lib_common],
d4c880d5
ZJS
1311 include_directories : includes,
1312 dependencies : [lib_tinfo,
6e92db54
KZ
1313 curses_libs,
1314 lib_magic],
d4c880d5
ZJS
1315 install : opt,
1316 build_by_default : opt)
1317exe2 = executable(
1318 'test_more',
1319 more_sources,
308a0979 1320 link_with : [lib_common],
d4c880d5
ZJS
1321 include_directories : includes,
1322 c_args : '-DTEST_PROGRAM',
1323 dependencies : [lib_tinfo,
6e92db54
KZ
1324 curses_libs,
1325 lib_magic],
ba30b89c 1326 build_by_default : opt and program_tests)
d4c880d5
ZJS
1327exes += exe
1328if opt and not is_disabler(exe)
1329 exes += [exe, exe2]
38bb89ee
TW
1330 manadocs += ['text-utils/more.1.adoc']
1331 bashcompletions += ['more']
d4c880d5
ZJS
1332endif
1333
1334exe = executable(
1335 'hexdump',
1336 hexdump_sources,
1337 include_directories : includes,
1338 link_with : [lib_common,
1339 lib_tcolors],
1340 install_dir : usrbin_exec_dir,
1341 install : true)
1342if not is_disabler(exe)
1343 exes += exe
53b37016 1344 manadocs += ['text-utils/hexdump.1.adoc']
38bb89ee 1345 bashcompletions += ['hexdump']
d4c880d5
ZJS
1346endif
1347
1348opt = not get_option('build-lsmem').disabled()
1349exe = executable(
1350 'lsmem',
1351 lsmem_sources,
1352 include_directories : includes,
1353 link_with : [lib_common,
1354 lib_smartcols],
1355 install_dir : usrbin_exec_dir,
1356 install : opt,
1357 build_by_default : opt)
1358if opt and not is_disabler(exe)
1359 exes += exe
53b37016 1360 manadocs += ['sys-utils/lsmem.1.adoc']
38bb89ee 1361 bashcompletions += ['lsmem']
d4c880d5
ZJS
1362endif
1363
1364opt = not get_option('build-chmem').disabled()
1365exe = executable(
1366 'chmem',
1367 chmem_sources,
1368 include_directories : includes,
1369 link_with : [lib_common],
1370 install_dir : usrbin_exec_dir,
1371 install : opt,
1372 build_by_default : opt)
1373if opt and not is_disabler(exe)
1374 exes += exe
53b37016 1375 manadocs += ['sys-utils/chmem.8.adoc']
38bb89ee 1376 bashcompletions += ['chmem']
d4c880d5
ZJS
1377endif
1378
1379exe = executable(
1380 'choom',
1381 choom_sources,
1382 include_directories : includes,
1383 link_with : [lib_common],
1384 install_dir : usrbin_exec_dir,
1385 install : true)
1386exes += exe
53b37016 1387manadocs += ['sys-utils/choom.1.adoc']
d4c880d5
ZJS
1388
1389exe = executable(
1390 'ipcmk',
1391 ipcmk_sources,
1392 include_directories : includes,
1393 link_with : [lib_common],
1394 install_dir : usrbin_exec_dir,
1395 install : true)
1396exes += exe
53b37016 1397manadocs += ['sys-utils/ipcmk.1.adoc']
38bb89ee 1398bashcompletions += ['ipcmk']
d4c880d5
ZJS
1399
1400exe = executable(
1401 'ipcrm',
1402 ipcrm_sources,
1403 include_directories : includes,
1404 link_with : [lib_common],
1405 install_dir : usrbin_exec_dir,
1406 install : true)
1407exes += exe
53b37016 1408manadocs += ['sys-utils/ipcrm.1.adoc']
38bb89ee 1409bashcompletions += ['ipcrm']
d4c880d5
ZJS
1410
1411opt = not get_option('build-ipcs').disabled()
1412exe = executable(
1413 'ipcs',
1414 ipcs_sources,
1415 include_directories : includes,
1416 link_with : [lib_common],
1417 install_dir : usrbin_exec_dir,
1418 install : opt,
1419 build_by_default : opt)
1420if opt and not is_disabler(exe)
1421 exes += exe
53b37016 1422 manadocs += ['sys-utils/ipcs.1.adoc']
38bb89ee 1423 bashcompletions += ['ipcs']
d4c880d5
ZJS
1424endif
1425
1426opt = not get_option('build-rfkill').disabled()
1427exe = executable(
1428 'rfkill',
1429 rfkill_sources,
1430 include_directories : includes,
1431 link_with : [lib_common,
1432 lib_smartcols],
1433 install_dir : usrsbin_exec_dir,
1434 install : opt,
1435 build_by_default : opt)
1436if opt and not is_disabler(exe)
1437 exes += exe
53b37016 1438 manadocs += ['sys-utils/rfkill.8.adoc']
38bb89ee 1439 bashcompletions += ['rfkill']
d4c880d5
ZJS
1440endif
1441
1442exe = executable(
1443 'renice',
1444 renice_sources,
1445 include_directories : includes,
1446 link_with : [lib_common,
1447 lib_smartcols],
1448 install_dir : usrbin_exec_dir,
1449 install : true)
1450if not is_disabler(exe)
1451 exes += exe
53b37016 1452 manadocs += ['sys-utils/renice.1.adoc']
38bb89ee 1453 bashcompletions += ['renice']
d4c880d5
ZJS
1454endif
1455
f092076f
DDM
1456exe = executable(
1457 'setpgid',
1458 setpgid_sources,
1459 include_directories: includes,
1460 link_with : [lib_common,
1461 lib_smartcols],
1462 install_dir : usrbin_exec_dir,
1463 install : true)
1464if opt and not is_disabler(exe)
1465 exes += exe
1466 manadocs += ['sys-utils/setpgid.1.adoc']
1467 bashcompletions += ['setpgid']
1468endif
1469
d4c880d5
ZJS
1470exe = executable(
1471 'setsid',
1472 setsid_sources,
1473 include_directories : includes,
1474 link_with : [lib_common,
1475 lib_smartcols],
1476 install_dir : usrbin_exec_dir,
1477 install : true)
1478if opt and not is_disabler(exe)
1479 exes += exe
53b37016 1480 manadocs += ['sys-utils/setsid.1.adoc']
38bb89ee 1481 bashcompletions += ['setsid']
d4c880d5
ZJS
1482endif
1483
1484exe = executable(
1485 'readprofile',
1486 readprofile_sources,
1487 include_directories : includes,
1488 link_with : [lib_common,
1489 lib_smartcols],
1490 install_dir : usrsbin_exec_dir,
1491 install : true)
1492if not is_disabler(exe)
1493 exes += exe
53b37016 1494 manadocs += ['sys-utils/readprofile.8.adoc']
38bb89ee 1495 bashcompletions += ['readprofile']
d4c880d5
ZJS
1496endif
1497
1498opt = not get_option('build-tunelp').disabled()
1499exe = executable(
1500 'tunelp',
1501 tunelp_sources,
1502 include_directories : includes,
1503 link_with : [lib_common],
1504 install_dir : usrsbin_exec_dir,
1505 install : opt,
1506 build_by_default : opt)
1507if opt and not is_disabler(exe)
1508 exes += exe
53b37016 1509 manadocs += ['sys-utils/tunelp.8.adoc']
38bb89ee 1510 bashcompletions += ['tunelp']
d4c880d5
ZJS
1511endif
1512
b8b63b36 1513opt = get_option('build-fstrim').require(have_sys_vfs_header).allowed()
d4c880d5
ZJS
1514exe = executable(
1515 'fstrim',
1516 fstrim_sources,
1517 include_directories : includes,
c43b185a
JW
1518 link_with : [lib_common],
1519 dependencies : [mount_dep],
d4c880d5 1520 install_dir : sbindir,
b6799ccb
JW
1521 install : opt,
1522 build_by_default : opt)
1523if opt and not is_disabler(exe)
d4c880d5 1524 exes += exe
53b37016 1525 manadocs += ['sys-utils/fstrim.8.adoc']
38bb89ee 1526 bashcompletions += ['fstrim']
d4c880d5
ZJS
1527endif
1528
1529exe = executable(
1530 'dmesg',
1531 dmesg_sources,
1532 include_directories : includes,
1533 link_with : [lib_common,
1534 lib_tcolors],
1535 install : true)
1536if not is_disabler(exe)
1537 exes += exe
53b37016 1538 manadocs += ['sys-utils/dmesg.1.adoc']
38bb89ee 1539 bashcompletions += ['dmesg']
d4c880d5
ZJS
1540endif
1541
1542exe = executable(
1543 'test_dmesg',
1544 dmesg_sources,
1545 include_directories : dir_include,
1546 c_args : '-DTEST_DMESG',
1547 link_with : [lib_common,
ba30b89c 1548 lib_tcolors],
1549 build_by_default : program_tests)
d4c880d5
ZJS
1550if not is_disabler(exe)
1551 exes += exe
1552endif
1553
1554exe = executable(
1555 'ctrlaltdel',
1556 ctrlaltdel_sources,
1557 include_directories : includes,
1558 link_with : [lib_common],
1559 install_dir : sbindir,
1560 install : true)
1561exes += exe
53b37016 1562manadocs += ['sys-utils/ctrlaltdel.8.adoc']
38bb89ee 1563bashcompletions += ['ctrlaltdel']
d4c880d5
ZJS
1564
1565exe = executable(
1566 'fsfreeze',
1567 fsfreeze_sources,
1568 include_directories : includes,
1569 install_dir : sbindir,
1570 install : true)
1571exes += exe
53b37016 1572manadocs += ['sys-utils/fsfreeze.8.adoc']
38bb89ee 1573bashcompletions += ['fsfreeze']
d4c880d5
ZJS
1574
1575exe = executable(
1576 'blkdiscard',
1577 blkdiscard_sources,
1578 include_directories : includes,
a764efb5
JW
1579 link_with : [lib_common],
1580 dependencies : [blkid_dep],
d4c880d5
ZJS
1581 install_dir : sbindir,
1582 install : true)
1583exes += exe
53b37016 1584manadocs += ['sys-utils/blkdiscard.8.adoc']
38bb89ee 1585bashcompletions += ['blkdiscard']
d4c880d5 1586
1a374511
JW
1587if cc.has_header('linux/blkzoned.h')
1588 exe = executable(
1589 'blkzone',
1590 blkzone_sources,
1591 include_directories : includes,
1592 link_with : [lib_common],
1593 install_dir : sbindir,
1594 install : true)
1595 exes += exe
1596 manadocs += ['sys-utils/blkzone.8.adoc']
1597 bashcompletions += ['blkzone']
1598endif
d4c880d5 1599
1a374511
JW
1600if cc.has_header('linux/pr.h')
1601 exe = executable(
1602 'blkpr',
1603 blkpr_sources,
1604 include_directories : includes,
1605 link_with : [lib_common],
1606 install_dir : sbindir,
1607 install : true)
1608 exes += exe
1609 manadocs += ['sys-utils/blkpr.8.adoc']
1610endif
61c2946d 1611
d4c880d5
ZJS
1612exe = executable(
1613 'ldattach',
1614 ldattach_sources,
1615 include_directories : includes,
1616 link_with : [lib_common],
1617 install_dir : usrsbin_exec_dir,
1618 install : true)
1619exes += exe
53b37016 1620manadocs += ['sys-utils/ldattach.8.adoc']
38bb89ee 1621bashcompletions += ['ldattach']
d4c880d5
ZJS
1622
1623exe = executable(
1624 'rtcwake',
1625 rtcwake_sources,
1626 include_directories : includes,
1627 link_with : [lib_common],
1628 install_dir : usrsbin_exec_dir,
1629 install : true)
1630exes += exe
53b37016 1631manadocs += ['sys-utils/rtcwake.8.adoc']
38bb89ee 1632bashcompletions += ['rtcwake']
d4c880d5
ZJS
1633
1634exe = executable(
1635 'setarch',
1636 setarch_sources,
1637 include_directories : includes,
035fc2d9 1638 link_with : [lib_common],
d4c880d5
ZJS
1639 install_dir : usrbin_exec_dir,
1640 install : true)
1641exes += exe
53b37016 1642manadocs += ['sys-utils/setarch.8.adoc']
38bb89ee 1643bashcompletions += ['setarch']
d4c880d5
ZJS
1644
1645setarch_links = ['uname26', 'linux32', 'linux64']
1646setarch_links_arch = {
1647 's390x' : ['s390', 's390x'],
1648 'x86' : ['i386'],
1649 'x86_64' : ['i386', 'x86_64'],
1650 'ppc64' : ['ppc', 'ppc64', 'ppc32'],
1651 'space64' : ['sparc', 'sparc64', 'sparc32', 'sparc32bash'],
1652 'mips64' : ['mips', 'mips64', 'mips32'],
1653 'ia64' : ['i386', 'ia64'],
1654 'hppa' : ['parisc', 'parisc64', 'parisc32'],
1655}
1656setarch_links += setarch_links_arch.get(host_machine.cpu_family(), [])
1657
1658foreach link: setarch_links
1659 meson.add_install_script(meson_make_symlink,
1660 'setarch',
1661 join_paths(usrbin_exec_dir, link))
38bb89ee 1662 manlinks += {link + '.8': 'setarch.8'}
d4c880d5
ZJS
1663endforeach
1664
1665opt = not get_option('build-eject').disabled()
1666exe = executable(
1667 'eject',
1668 eject_sources,
1669 include_directories : includes,
c43b185a
JW
1670 link_with : [lib_common],
1671 dependencies : [mount_dep],
d4c880d5
ZJS
1672 install_dir : usrbin_exec_dir,
1673 install : opt,
1674 build_by_default : opt)
1675if opt and not is_disabler(exe)
1676 exe = exe
53b37016 1677 manadocs += ['sys-utils/eject.1.adoc']
38bb89ee 1678 bashcompletions += ['eject']
d4c880d5
ZJS
1679endif
1680
1681opt = not get_option('build-losetup').disabled()
1682exe = executable(
1683 'losetup',
1684 losetup_sources,
1685 include_directories : includes,
1686 link_with : [lib_common,
1687 lib_smartcols],
1688 install_dir : sbindir,
1689 install : opt,
1690 build_by_default : opt)
1691if opt and not is_disabler(exe)
53b37016 1692 manadocs += ['sys-utils/losetup.8.adoc']
d4c880d5 1693 exes += exe
38bb89ee 1694 bashcompletions += ['losetup']
d4c880d5
ZJS
1695endif
1696
69939195
ZJS
1697opt = opt and 'losetup' in static_programs
1698exe = executable(
1699 'losetup.static',
1700 losetup_sources,
1701 include_directories : includes,
1702 link_args : ['--static'],
1703 link_with : [lib_common,
1704 lib_smartcols.get_static_lib()],
1705 install_dir : sbindir,
1706 install : opt,
1707 build_by_default : opt)
1708if opt and not is_disabler(exe)
1709 exes += exe
1710endif
1711
d4c880d5
ZJS
1712opt = not get_option('build-zramctl').disabled()
1713exe = executable(
1714 'zramctl',
1715 zramctl_sources,
1716 include_directories : includes,
1717 link_with : [lib_common,
1718 lib_smartcols],
1719 install_dir : sbindir,
1720 install : opt,
1721 build_by_default : opt)
1722if opt and not is_disabler(exe)
1723 exes += exe
53b37016 1724 manadocs += ['sys-utils/zramctl.8.adoc']
38bb89ee 1725 bashcompletions += ['zramctl']
d4c880d5
ZJS
1726endif
1727
1728exe = executable(
1729 'prlimit',
1730 prlimit_sources,
1731 include_directories : includes,
1732 link_with : [lib_common,
1733 lib_smartcols],
1734 install_dir : usrbin_exec_dir,
1735 install : true)
1736if not is_disabler(exe)
1737 exes += exe
53b37016 1738 manadocs += ['sys-utils/prlimit.1.adoc']
38bb89ee 1739 bashcompletions += ['prlimit']
d4c880d5
ZJS
1740endif
1741
b6799ccb 1742opt = not get_option('build-lsns').disabled()
d4c880d5
ZJS
1743exe = executable(
1744 'lsns',
1745 lsns_sources,
1746 include_directories : includes,
1747 link_with : [lib_common,
c43b185a
JW
1748 lib_smartcols],
1749 dependencies : [mount_dep],
d4c880d5 1750 install_dir : usrbin_exec_dir,
b6799ccb
JW
1751 install : opt,
1752 build_by_default : opt)
1753if opt and not is_disabler(exe)
d4c880d5 1754 exes += exe
53b37016 1755 manadocs += ['sys-utils/lsns.8.adoc']
38bb89ee 1756 bashcompletions += ['lsns']
d4c880d5
ZJS
1757endif
1758
1759opt = not get_option('build-mount').disabled()
1760exe = executable(
1761 'mount',
1762 mount_sources,
1763 include_directories : includes,
1764 link_with : [lib_common,
c43b185a
JW
1765 lib_smartcols],
1766 dependencies : [lib_selinux, mount_dep],
8f49b369 1767 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1768 install : opt,
1769 build_by_default : opt)
1770exe2 = executable(
1771 'umount',
1772 umount_sources,
1773 include_directories : includes,
c43b185a
JW
1774 link_with : [lib_common],
1775 dependencies : [mount_dep],
1cb3c90c 1776 install_mode : 'rwsr-xr-x',
d4c880d5
ZJS
1777 install : opt,
1778 build_by_default : opt)
1779if opt and not is_disabler(exe)
1780 exes += [exe, exe2]
53b37016
KZ
1781 manadocs += ['sys-utils/fstab.5.adoc',
1782 'sys-utils/mount.8.adoc',
1783 'sys-utils/umount.8.adoc']
38bb89ee 1784 bashcompletions += ['mount', 'umount']
d4c880d5
ZJS
1785endif
1786
69939195
ZJS
1787opt2 = opt and 'mount' in static_programs
1788exe = executable(
1789 'mount.static',
1790 mount_sources,
1791 include_directories : includes,
1792 link_args : ['--static'],
1793 link_with : [lib_common,
c43b185a
JW
1794 lib_smartcols_static],
1795 dependencies : [mount_static_dep],
69939195
ZJS
1796 install : opt2,
1797 build_by_default : opt2)
1798if opt2 and not is_disabler(exe)
1799 exes += exe
1800endif
1801
1802opt2 = opt and 'umount' in static_programs
1803exe = executable(
1804 'umount.static',
1805 umount_sources,
1806 include_directories : includes,
1807 link_args : ['--static'],
c43b185a
JW
1808 link_with : [lib_common],
1809 dependencies : [mount_static_dep],
69939195
ZJS
1810 install : opt2,
1811 build_by_default : opt2)
1812if opt2 and not is_disabler(exe)
1813 exes += exe
1814endif
1815
d4c880d5
ZJS
1816# setuid?
1817
b6799ccb 1818opt = not get_option('build-swapon').disabled()
d4c880d5
ZJS
1819exe = executable(
1820 'swapon',
1821 swapon_sources,
1822 include_directories : includes,
1823 link_with : [lib_common,
d4c880d5 1824 lib_smartcols],
a764efb5 1825 dependencies : [blkid_dep, mount_dep],
d4c880d5 1826 install_dir : sbindir,
b6799ccb
JW
1827 install : opt,
1828 build_by_default : opt)
1829if opt and not is_disabler(exe)
d4c880d5 1830 exes += exe
53b37016 1831 manadocs += ['sys-utils/swapon.8.adoc']
38bb89ee 1832 bashcompletions += ['swapon']
d4c880d5
ZJS
1833endif
1834
b6799ccb 1835opt = not get_option('build-swapoff').disabled()
d4c880d5
ZJS
1836exe = executable(
1837 'swapoff',
1838 swapoff_sources,
1839 include_directories : includes,
a764efb5
JW
1840 link_with : [lib_common],
1841 dependencies : [blkid_dep, mount_dep],
d4c880d5 1842 install_dir : sbindir,
b6799ccb
JW
1843 install : opt,
1844 build_by_default : opt)
1845if opt and not is_disabler(exe)
d4c880d5 1846 exes += exe
38bb89ee
TW
1847 manlinks += {'swapoff.8': 'swapon.8'}
1848 bashcompletions += ['swapoff']
d4c880d5
ZJS
1849endif
1850
1851exe = executable(
1852 'lscpu',
1853 lscpu_sources,
1854 include_directories : includes,
1855 link_with : [lib_common,
1856 lib_smartcols],
1857 dependencies : [rtas_libs],
1858 install_dir : usrbin_exec_dir,
1859 install : true)
1860if not is_disabler(exe)
1861 exes += exe
53b37016 1862 manadocs += ['sys-utils/lscpu.1.adoc']
38bb89ee 1863 bashcompletions += ['lscpu']
d4c880d5
ZJS
1864endif
1865
1866exe = executable(
1867 'chcpu',
1868 chcpu_sources,
1869 include_directories : includes,
1870 link_with : [lib_common],
1871 install_dir : sbindir,
1872 install : true)
1873exes += exe
53b37016 1874manadocs += ['sys-utils/chcpu.8.adoc']
38bb89ee 1875bashcompletions += ['chcpu']
d4c880d5
ZJS
1876
1877exe = executable(
1878 'wdctl',
1879 wdctl_sources,
1880 include_directories : includes,
1881 link_with : [lib_common,
1882 lib_smartcols],
1883 install : true)
1884if not is_disabler(exe)
1885 exes += exe
53b37016 1886 manadocs += ['sys-utils/wdctl.8.adoc']
38bb89ee 1887 bashcompletions += ['wdctl']
d4c880d5
ZJS
1888endif
1889
1890opt = not get_option('build-mountpoint').disabled()
1891exe = executable(
1892 'mountpoint',
1893 mountpoint_sources,
1894 include_directories : includes,
c43b185a 1895 dependencies : [mount_dep],
d4c880d5
ZJS
1896 install : opt,
1897 build_by_default : opt)
1898if opt and not is_disabler(exe)
1899 exes += exe
53b37016 1900 manadocs += ['sys-utils/mountpoint.1.adoc']
38bb89ee 1901 bashcompletions += ['mountpoint']
d4c880d5
ZJS
1902endif
1903
1904opt = not get_option('build-fallocate').disabled()
1905exe = executable(
1906 'fallocate',
1907 fallocate_sources,
1908 include_directories : includes,
1909 link_with : [lib_common],
1910 install_dir : usrbin_exec_dir,
1911 install : opt,
1912 build_by_default : opt)
1913if opt and not is_disabler(exe)
1914 exes += exe
53b37016 1915 manadocs += ['sys-utils/fallocate.1.adoc']
38bb89ee 1916 bashcompletions += ['fallocate']
d4c880d5
ZJS
1917endif
1918
1919opt = not get_option('build-pivot_root').disabled()
1920exe = executable(
1921 'pivot_root',
1922 pivot_root_sources,
1923 include_directories : includes,
1924 install_dir : sbindir,
1925 install : opt,
1926 build_by_default : opt)
1927if opt and not is_disabler(exe)
1928 exes += exe
53b37016 1929 manadocs += ['sys-utils/pivot_root.8.adoc']
38bb89ee 1930 bashcompletions += ['pivot_root']
d4c880d5
ZJS
1931endif
1932
1933opt = not get_option('build-switch_root').disabled()
1934if opt and not have_dirfd and not have_ddfd
1935 error('neither dirfd nor ddfd are available')
1936endif
1937exe = executable(
1938 'switch_root',
1939 switch_root_sources,
1940 include_directories : includes,
1941 install_dir : sbindir,
1942 install : opt,
1943 build_by_default : opt)
1944if opt and not is_disabler(exe)
1945 exes += exe
53b37016 1946 manadocs += ['sys-utils/switch_root.8.adoc']
d4c880d5
ZJS
1947endif
1948
1949opt = not get_option('build-unshare').disabled()
1950exe = executable(
1951 'unshare',
1952 unshare_sources,
1953 include_directories : includes,
1954 link_with : [lib_common],
c43b185a 1955 dependencies : [mount_dep],
d4c880d5
ZJS
1956 install_dir : usrbin_exec_dir,
1957 install : opt,
1958 build_by_default : opt)
1959if opt and not is_disabler(exe)
1960 exes += exe
53b37016 1961 manadocs += ['sys-utils/unshare.1.adoc']
38bb89ee 1962 bashcompletions += ['unshare']
d4c880d5
ZJS
1963endif
1964
69939195
ZJS
1965opt = opt and 'unshare' in static_programs
1966exe = executable(
1967 'unshare.static',
1968 unshare_sources,
1969 include_directories : includes,
1970 link_with : [lib_common],
c43b185a 1971 dependencies : [mount_dep],
69939195
ZJS
1972 install_dir : usrbin_exec_dir,
1973 install : opt,
1974 build_by_default : opt)
1975if opt and not is_disabler(exe)
1976 exes += exe
1977endif
1978
d4c880d5
ZJS
1979opt = not get_option('build-nsenter').disabled()
1980exe = executable(
1981 'nsenter',
1982 nsenter_sources,
1983 include_directories : includes,
1984 link_with : [lib_common],
1985 dependencies : [lib_selinux],
1986 install_dir : usrbin_exec_dir,
1987 install : opt,
1988 build_by_default : opt)
1989if opt and not is_disabler(exe)
1990 exes += exe
53b37016 1991 manadocs += ['sys-utils/nsenter.1.adoc']
38bb89ee 1992 bashcompletions += ['nsenter']
d4c880d5
ZJS
1993endif
1994
69939195
ZJS
1995opt = opt and 'nsenter' in static_programs
1996exe = executable(
1997 'nsenter.static',
1998 nsenter_sources,
1999 include_directories : includes,
2000 link_with : [lib_common],
2001 dependencies : [lib_selinux],
2002 install_dir : usrbin_exec_dir,
2003 install : opt,
2004 build_by_default : opt)
2005if opt and not is_disabler(exe)
2006 exes += exe
2007endif
2008
cd23a433 2009opt = not get_option('build-setpriv').disabled() and lib_cap_ng.found()
d4c880d5
ZJS
2010exe = executable(
2011 'setpriv',
2012 setpriv_sources,
2013 include_directories : includes,
2014 link_with : [lib_common],
2015 dependencies : [lib_cap_ng],
2016 install_dir : usrbin_exec_dir,
2017 install : opt,
2018 build_by_default : opt)
2019if opt and not is_disabler(exe)
2020 exes += exe
53b37016 2021 manadocs += ['sys-utils/setpriv.1.adoc']
38bb89ee 2022 bashcompletions += ['setpriv']
d4c880d5
ZJS
2023endif
2024
2025exe = executable(
2026 'flock',
2027 flock_sources,
2028 include_directories : includes,
2029 link_with : [lib_common],
2030 dependencies : realtime_libs,
2031 install_dir : usrbin_exec_dir,
2032 install : true)
2033exes += exe
53b37016 2034manadocs += ['sys-utils/flock.1.adoc']
38bb89ee 2035bashcompletions += ['flock']
d4c880d5 2036
645577c7
KZ
2037opt = not get_option('build-lsirq').disabled()
2038exe = executable(
2039 'lsirq',
2040 lsirq_sources,
2041 include_directories : includes,
2042 link_with : [lib_common,
2043 lib_smartcols],
2044 install_dir : usrbin_exec_dir,
2045 install : opt,
2046 build_by_default : opt)
2047if opt and not is_disabler(exe)
2048 exes += exe
53b37016 2049 manadocs += ['sys-utils/lsirq.1.adoc']
38bb89ee 2050 bashcompletions += ['lsirq']
645577c7
KZ
2051endif
2052
2053opt = not get_option('build-irqtop').disabled()
2054exe = executable(
2055 'irqtop',
2056 irqtop_sources,
2057 include_directories : includes,
2058 dependencies : [realtime_libs, curses_libs],
2059 link_with : [lib_common,
2060 lib_smartcols,
2061 lib_tcolors],
2062 install_dir : usrbin_exec_dir,
2063 install : opt,
2064 build_by_default : opt)
2065if opt and not is_disabler(exe)
2066 exes += exe
53b37016 2067 manadocs += ['sys-utils/irqtop.1.adoc']
38bb89ee 2068 bashcompletions += ['irqtop']
645577c7
KZ
2069endif
2070
d4c880d5
ZJS
2071opt = not get_option('build-ipcs').disabled()
2072exe = executable(
2073 'lsipc',
2074 lsipc_sources,
2075 include_directories : includes,
2076 link_with : [lib_common,
2077 lib_smartcols],
2078 install_dir : usrbin_exec_dir,
2079 install : opt,
2080 build_by_default : opt)
2081if opt and not is_disabler(exe)
2082 exes += exe
53b37016 2083 manadocs += ['sys-utils/lsipc.1.adoc']
38bb89ee 2084 bashcompletions += ['lsipc']
d4c880d5
ZJS
2085endif
2086
2087opt = build_hwclock
2088exe = executable(
2089 'hwclock',
2090 hwclock_sources,
2091 include_directories : includes,
2092 link_with : [lib_common],
2093 dependencies : [lib_m,
2094 lib_audit],
2095 install_dir : sbindir,
2096 install : opt,
2097 build_by_default : opt)
2098if opt and not is_disabler(exe)
2099 exes += exe
38bb89ee
TW
2100 manadocs += ['sys-utils/hwclock.8.adoc', 'sys-utils/adjtime_config.5.adoc']
2101 bashcompletions += ['hwclock']
d4c880d5
ZJS
2102endif
2103
2104exe = executable(
2105 'mkfs',
2106 mkfs_sources,
2107 include_directories : includes,
2108 install_dir : sbindir,
2109 install : true)
2110exes += exe
53b37016 2111manadocs += ['disk-utils/mkfs.8.adoc']
38bb89ee 2112bashcompletions += ['mkfs']
d4c880d5
ZJS
2113
2114opt = not get_option('build-bfs').disabled()
2115exe = executable(
2116 'mkfs.bfs',
2117 mkfs_bfs_sources,
2118 include_directories : includes,
2119 link_with : [lib_common],
2120 install_dir : sbindir,
2121 install : opt,
2122 build_by_default : opt)
2123if opt and not is_disabler(exe)
2124 exes += exe
53b37016 2125 manadocs += ['disk-utils/mkfs.bfs.8.adoc']
38bb89ee 2126 bashcompletions += ['mkfs.bfs']
d4c880d5
ZJS
2127endif
2128
2129exe = executable(
2130 'isosize',
2131 isosize_sources,
2132 include_directories : includes,
2133 link_with : [lib_common],
2134 install_dir : usrbin_exec_dir,
2135 install : true)
2136exes += exe
53b37016 2137manadocs += ['disk-utils/isosize.8.adoc']
38bb89ee 2138bashcompletions += ['isosize']
d4c880d5
ZJS
2139
2140exe = executable(
2141 'mkswap',
2142 mkswap_sources,
2143 include_directories : includes,
2144 link_with : [lib_common,
d4c880d5 2145 lib_uuid],
a764efb5 2146 dependencies: [blkid_dep, lib_selinux],
d4c880d5
ZJS
2147 install_dir : sbindir,
2148 install : true)
765961c3 2149if not is_disabler(exe)
d4c880d5 2150 exes += exe
53b37016 2151 manadocs += ['disk-utils/mkswap.8.adoc']
38bb89ee 2152 bashcompletions += ['mkswap']
d4c880d5
ZJS
2153endif
2154
2155exe = executable(
2156 'swaplabel',
2157 swaplabel_sources,
2158 include_directories : includes,
2159 link_with : [lib_common,
d4c880d5 2160 lib_uuid],
a764efb5 2161 dependencies : [blkid_dep],
d4c880d5
ZJS
2162 install_dir : sbindir,
2163 install : true)
765961c3 2164if not is_disabler(exe)
d4c880d5 2165 exes += exe
53b37016 2166 manadocs += ['disk-utils/swaplabel.8.adoc']
38bb89ee 2167 bashcompletions += ['swaplabel']
d4c880d5
ZJS
2168endif
2169
2170opt = not get_option('build-fsck').disabled()
2171exe = executable(
2172 'fsck',
2173 fsck_sources,
2174 include_directories : includes,
a764efb5
JW
2175 link_with : [lib_common],
2176 dependencies : [blkid_dep, mount_dep, realtime_libs],
d4c880d5
ZJS
2177 install_dir : sbindir,
2178 install : opt,
2179 build_by_default : opt)
2180if opt and not is_disabler(exe)
2181 exes += exe
53b37016 2182 manadocs += ['disk-utils/fsck.8.adoc']
38bb89ee 2183 bashcompletions += ['fsck']
d4c880d5
ZJS
2184endif
2185
2186opt = not get_option('build-minix').disabled()
2187exe = executable(
2188 'mkfs.minix',
2189 mkfs_minix_sources,
2190 include_directories : includes,
2191 link_with : [lib_common],
2192 install_dir : sbindir,
2193 install : opt,
2194 build_by_default : opt)
2195exe2 = executable(
2196 'test_mkfs_minix',
2197 mkfs_minix_sources,
2198 include_directories : includes,
2199 c_args : '-DTEST_SCRIPT',
2200 link_with : [lib_common],
ba30b89c 2201 build_by_default : opt and program_tests)
d4c880d5
ZJS
2202exe3 = executable(
2203 'fsck.minix',
2204 fsck_minix_sources,
2205 include_directories : includes,
2206 link_with : [lib_common],
2207 install_dir : sbindir,
2208 install : opt,
2209 build_by_default : opt)
2210if opt and not is_disabler(exe)
2211 exes += [exe, exe2, exe3]
53b37016 2212 manadocs += ['disk-utils/mkfs.minix.8.adoc','disk-utils/fsck.minix.8.adoc']
38bb89ee 2213 bashcompletions += ['mkfs.minix', 'fsck.minix']
d4c880d5
ZJS
2214endif
2215
2216opt = not get_option('build-cramfs').disabled()
2217exe = executable(
2218 'mkfs.cramfs',
2219 mkfs_cramfs_sources,
2220 include_directories : includes,
2221 link_with : [lib_common],
2222 dependencies : [lib_z],
2223 install_dir : sbindir,
2224 install : opt,
2225 build_by_default : opt)
2226exe2 = executable(
2227 'fsck.cramfs',
2228 fsck_cramfs_sources,
2229 include_directories : includes,
2230 link_with : [lib_common],
2231 dependencies : [lib_z],
2232 install_dir : sbindir,
2233 install : opt,
2234 build_by_default : opt)
2235if not is_disabler(exe)
2236 exes += [exe, exe2]
53b37016 2237 manadocs += ['disk-utils/mkfs.cramfs.8.adoc','disk-utils/fsck.cramfs.8.adoc']
38bb89ee 2238 bashcompletions += ['mkfs.cramfs', 'fsck.cramfs']
d4c880d5
ZJS
2239endif
2240
2241opt = not get_option('build-raw').disabled()
dff176e2 2242if opt
433e4b77 2243 cc.has_header('linux/raw.h', required: opt)
dff176e2 2244endif
d4c880d5
ZJS
2245exe = executable(
2246 'raw',
2247 raw_sources,
2248 include_directories : includes,
2249 install_dir : sbindir,
2250 install : opt,
2251 build_by_default : opt)
2252if opt and not is_disabler(exe)
2253 exes += exe
53b37016 2254 manadocs += ['disk-utils/raw.8.adoc']
38bb89ee 2255 bashcompletions += ['raw']
d4c880d5
ZJS
2256endif
2257
2258opt = not get_option('build-fdformat').disabled()
2259exe = executable(
2260 'fdformat',
2261 fdformat_sources,
2262 include_directories : includes,
2263 link_with : [lib_common],
2264 install_dir : usrsbin_exec_dir,
2265 install : opt,
2266 build_by_default : opt)
2267if opt and not is_disabler(exe)
2268 exes += exe
53b37016 2269 manadocs += ['disk-utils/fdformat.8.adoc']
669071f6 2270 bashcompletions += ['fdformat']
d4c880d5
ZJS
2271endif
2272
2273exe = executable(
2274 'blockdev',
2275 blockdev_sources,
2276 include_directories : includes,
2277 link_with : [lib_common],
2278 install_dir : sbindir,
2279 install : true)
53b37016 2280manadocs += ['disk-utils/blockdev.8.adoc']
38bb89ee 2281bashcompletions += ['blockdev']
d4c880d5
ZJS
2282
2283opt = not get_option('build-fdisks').disabled()
2284if opt and not have_dirfd and not have_ddfd
2285 error('neither dirfd nor ddfd are available')
2286endif
2287exe = executable(
2288 'fdisk',
2289 fdisk_sources,
2290 include_directories : includes,
2291 link_with : [lib_common,
2292 lib_fdisk,
2293 lib_smartcols,
2294 lib_tcolors],
2295 dependencies : [lib_readline],
2296 install_dir : sbindir,
2297 install : opt,
2298 build_by_default : opt)
2299if opt and not is_disabler(exe)
2300 exes += exe
38bb89ee 2301 bashcompletions += ['fdisk']
d4c880d5
ZJS
2302endif
2303
69939195
ZJS
2304opt2 = opt and 'fdisk' in static_programs
2305exe = executable(
2306 'fdisk.static',
2307 fdisk_sources,
2308 link_args : ['--static'],
2309 include_directories : includes,
2310 link_with : [lib_common,
2311 lib_tcolors,
2312 lib_fdisk_static,
2313 lib_smartcols.get_static_lib()],
2314 dependencies : [lib_readline_static],
2315 install_dir : sbindir,
2316 install : opt2,
2317 build_by_default : opt2)
2318if opt2 and not is_disabler(exe)
2319 exes += exe
2320endif
d4c880d5
ZJS
2321
2322exe = executable(
2323 'sfdisk',
2324 sfdisk_sources,
2325 include_directories : includes,
2326 link_with : [lib_common,
2327 lib_fdisk,
2328 lib_smartcols,
2329 lib_tcolors],
2330 dependencies : [lib_readline],
2331 install_dir : sbindir,
2332 install : opt,
2333 build_by_default : opt)
2334if opt and not is_disabler(exe)
2335 exes += exe
38bb89ee 2336 bashcompletions += ['sfdisk']
d4c880d5
ZJS
2337endif
2338
69939195
ZJS
2339opt2 = opt and 'sfdisk' in static_programs
2340exe = executable(
2341 'sfdisk.static',
2342 sfdisk_sources,
2343 include_directories : includes,
2344 link_with : [lib_common,
2345 lib_tcolors,
2346 lib_fdisk_static,
2347 lib_smartcols.get_static_lib()],
2348 dependencies : [lib_readline_static],
2349 install_dir : sbindir,
2350 install : opt2,
2351 build_by_default : opt2)
2352if opt2 and not is_disabler(exe)
2353 exes += exe
2354endif
d4c880d5
ZJS
2355
2356exe = executable(
2357 'cfdisk',
2358 cfdisk_sources,
2359 include_directories : includes,
2360 link_with : [lib_common,
2361 lib_fdisk,
2362 lib_smartcols,
c43b185a
JW
2363 lib_tcolors],
2364 dependencies : [curses_libs, mount_dep],
d4c880d5
ZJS
2365 install_dir : sbindir,
2366 install : opt,
2367 build_by_default : opt)
2368if opt and not is_disabler(exe)
2369 exes += exe
53b37016
KZ
2370 manadocs += ['disk-utils/fdisk.8.adoc',
2371 'disk-utils/sfdisk.8.adoc',
2372 'disk-utils/cfdisk.8.adoc']
38bb89ee 2373 bashcompletions += ['cfdisk']
d4c880d5
ZJS
2374endif
2375
2376opt = not get_option('build-partx').disabled()
2377exe = executable(
2378 'addpart',
2379 addpart_sources,
2380 include_directories : includes,
2381 link_with : [lib_common],
2382 install_dir : usrsbin_exec_dir,
2383 install : opt,
2384 build_by_default : opt)
2385exe2 = executable(
2386 'delpart',
2387 delpart_sources,
2388 include_directories : includes,
2389 link_with : [lib_common],
2390 install_dir : usrsbin_exec_dir,
2391 install : opt,
2392 build_by_default : opt)
2393exe3 = executable(
2394 'resizepart',
2395 resizepart_sources,
2396 include_directories : includes,
2397 link_with : [lib_common],
2398 install_dir : usrsbin_exec_dir,
2399 install : opt,
2400 build_by_default : opt)
2401exe4 = executable(
2402 'partx',
2403 partx_sources,
2404 include_directories : includes,
2405 link_with : [lib_common,
d4c880d5 2406 lib_smartcols],
a764efb5 2407 dependencies : [blkid_dep],
d4c880d5
ZJS
2408 install_dir : usrsbin_exec_dir,
2409 install : opt,
2410 build_by_default : opt)
2411if opt
2412 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
2413 manadocs += ['disk-utils/addpart.8.adoc',
2414 'disk-utils/delpart.8.adoc',
2415 'disk-utils/resizepart.8.adoc',
2416 'disk-utils/partx.8.adoc']
38bb89ee 2417 bashcompletions += ['addpart', 'delpart', 'resizepart', 'partx']
d4c880d5 2418endif
44bf6d80
B
2419opt = opt and 'partx' in static_programs
2420exe = executable(
2421 'addpart.static',
2422 addpart_sources,
2423 include_directories : includes,
2424 link_args : ['--static'],
2425 link_with : [lib_common],
2426 install_dir : usrsbin_exec_dir,
2427 install : opt,
2428 build_by_default : opt)
2429exe2 = executable(
2430 'delpart.static',
2431 delpart_sources,
2432 include_directories : includes,
2433 link_args : ['--static'],
2434 link_with : [lib_common],
2435 install_dir : usrsbin_exec_dir,
2436 install : opt,
2437 build_by_default : opt)
2438exe3 = executable(
2439 'resizepart.static',
2440 resizepart_sources,
2441 include_directories : includes,
2442 link_args : ['--static'],
2443 link_with : [lib_common],
2444 install_dir : usrsbin_exec_dir,
2445 install : opt,
2446 build_by_default : opt)
2447exe4 = executable(
2448 'partx.static',
2449 partx_sources,
2450 include_directories : includes,
2451 link_args : ['--static'],
2452 link_with : [lib_common,
44bf6d80 2453 lib_smartcols.get_static_lib()],
a764efb5 2454 dependencies : [blkid_static_dep],
44bf6d80
B
2455 install_dir : usrsbin_exec_dir,
2456 install : opt,
2457 build_by_default : opt)
2458
2459if opt
2460 exes += [exe, exe2, exe3, exe4]
2461endif
d4c880d5
ZJS
2462
2463############################################################
2464
2465exe = executable(
2466 'script',
2467 script_sources,
2468 include_directories : includes,
2469 link_with : [lib_common],
2470 dependencies : [lib_util,
2471 lib_utempter,
2472 realtime_libs,
2473 math_libs],
2474 install_dir : usrbin_exec_dir,
2475 install : true)
2476exes += exe
53b37016 2477manadocs += ['term-utils/script.1.adoc']
38bb89ee 2478bashcompletions += ['script']
d4c880d5
ZJS
2479
2480exe = executable(
2481 'test_script',
2482 script_sources,
2483 include_directories : includes,
2484 c_args : '-DTEST_SCRIPT',
2485 link_with : [lib_common],
2486 dependencies : [lib_util,
2487 lib_utempter,
2488 realtime_libs,
ba30b89c 2489 math_libs],
2490 build_by_default : program_tests)
d4c880d5
ZJS
2491exes += exe
2492
2493exe = executable(
2494 'scriptlive',
2495 scriptlive_sources,
2496 include_directories : includes,
2497 link_with : [lib_common],
2498 dependencies : [lib_util,
2499 realtime_libs,
2500 math_libs],
2501 install_dir : usrbin_exec_dir,
2502 install : true)
2503exes += exe
53b37016 2504manadocs += ['term-utils/scriptlive.1.adoc']
38bb89ee 2505bashcompletions += ['scriptlive']
d4c880d5
ZJS
2506
2507exe = executable(
2508 'scriptreplay',
2509 scriptreplay_sources,
2510 include_directories : includes,
2511 link_with : [lib_common],
2512 dependencies : [math_libs],
2513 install_dir : usrbin_exec_dir,
2514 install : true)
2515exes += exe
53b37016 2516manadocs += ['term-utils/scriptreplay.1.adoc']
38bb89ee 2517bashcompletions += ['scriptreplay']
d4c880d5
ZJS
2518
2519opt = not get_option('build-agetty').disabled()
2520exe = executable(
2521 'agetty',
2522 agetty_sources,
2523 include_directories : includes,
0333c40b 2524 link_with : [lib_common, logindefs_c],
87fcd95a 2525 dependencies : [BSD ? lib_util : [], lib_systemd],
d4c880d5
ZJS
2526 install_dir : sbindir,
2527 install : opt,
2528 build_by_default : opt)
2529if opt
2530 exes += exe
53b37016 2531 manadocs += ['term-utils/agetty.8.adoc']
d4c880d5
ZJS
2532endif
2533
2534opt = not get_option('build-setterm').disabled()
2535exe = executable(
2536 'setterm',
2537 setterm_sources,
2538 include_directories : includes,
2539 link_with : [lib_common],
2540 dependencies : [curses_libs],
2541 install_dir : usrbin_exec_dir,
2542 install : opt,
2543 build_by_default : opt)
2544if opt
2545 exes += exe
53b37016 2546 manadocs += ['term-utils/setterm.1.adoc']
38bb89ee 2547 bashcompletions += ['setterm']
d4c880d5
ZJS
2548endif
2549
2550opt = not get_option('build-mesg').disabled()
2551exe = executable(
2552 'mesg',
2553 mesg_sources,
2554 include_directories : includes,
2555 link_with : [lib_common],
2556 install_dir : usrbin_exec_dir,
2557 install : opt,
2558 build_by_default : opt)
2559if opt
2560 exes += exe
53b37016 2561 manadocs += ['term-utils/mesg.1.adoc']
38bb89ee 2562 bashcompletions += ['mesg']
d4c880d5
ZJS
2563endif
2564
2565opt = not get_option('build-wall').disabled()
2566exe = executable(
2567 'wall',
2568 wall_sources,
2569 include_directories : includes,
2570 link_with : [lib_common],
87fcd95a 2571 dependencies : [lib_systemd],
d4c880d5 2572 install_dir : usrbin_exec_dir,
5f3359c5 2573 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2574 install : opt,
2575 build_by_default : opt)
2576if opt
2577 exes += exe
53b37016 2578 manadocs += ['term-utils/wall.1.adoc']
38bb89ee 2579 bashcompletions += ['wall']
d4c880d5
ZJS
2580endif
2581
2582# chgrp tty $(DESTDIR)$(usrbin_execdir)/wall
2583# chmod g+s $(DESTDIR)$(usrbin_execdir)/wall
2584
2585opt = not get_option('build-write').disabled()
2586exe = executable(
2587 'write',
2588 write_sources,
2589 include_directories : includes,
2590 link_with : [lib_common],
87fcd95a 2591 dependencies : [lib_systemd],
d4c880d5 2592 install_dir : usrbin_exec_dir,
00f115d8 2593 install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
d4c880d5
ZJS
2594 install : opt,
2595 build_by_default : opt)
2596if opt
2597 exes += exe
53b37016 2598 manadocs += ['term-utils/write.1.adoc']
e1cd4002 2599 bashcompletions += ['write']
d4c880d5
ZJS
2600endif
2601
2602# chgrp tty $(DESTDIR)$(usrbin_execdir)/write
2603# chmod g+s $(DESTDIR)$(usrbin_execdir)/write
2604
2605opt = not get_option('build-login').disabled()
2606exe = executable(
2607 'login',
2608 login_sources,
2609 include_directories : includes,
0333c40b 2610 link_with : [lib_common, logindefs_c],
d4c880d5
ZJS
2611 dependencies : [lib_pam,
2612 lib_audit,
2613 lib_selinux],
2614 install : opt,
2615 build_by_default : opt)
2616if not is_disabler(exe)
2617 exes += exe
53b37016 2618 manadocs += ['login-utils/login.1.adoc']
d4c880d5
ZJS
2619endif
2620
2621opt = not get_option('build-sulogin').disabled()
2622exe = executable(
2623 'sulogin',
2624 sulogin_sources,
2625 include_directories : includes,
2626 link_with : [lib_common],
2627 dependencies : [lib_crypt,
2628 lib_selinux],
2629 install_dir : sbindir,
2630 install : opt,
2631 build_by_default : opt)
2632if not is_disabler(exe)
2633 exes += exe
53b37016 2634 manadocs += ['login-utils/sulogin.8.adoc']
d4c880d5
ZJS
2635endif
2636
2637exe = executable(
2638 'cal',
2639 cal_sources,
2640 include_directories : includes,
2641 link_with : [lib_common,
2642 lib_tcolors],
2643 dependencies : [curses_libs],
2644 install_dir : usrbin_exec_dir,
2645 install : true)
2646exes += exe
53b37016 2647manadocs += ['misc-utils/cal.1.adoc']
38bb89ee 2648bashcompletions += ['cal']
d4c880d5
ZJS
2649
2650opt = not get_option('build-logger').disabled()
2651exe = executable(
2652 'logger',
2653 logger_sources,
2654 include_directories : includes,
dbb9999f 2655 link_with : [lib_common],
d4c880d5
ZJS
2656 dependencies : [lib_systemd],
2657 install_dir : usrbin_exec_dir,
2658 install : opt,
2659 build_by_default : opt)
2660if opt and not is_disabler(exe)
2661 exes += exe
53b37016 2662 manadocs += ['misc-utils/logger.1.adoc']
38bb89ee 2663 bashcompletions += ['logger']
d4c880d5
ZJS
2664endif
2665
2666exe = executable(
2667 'test_logger',
2668 logger_sources,
2669 include_directories : includes,
2670 c_args : '-DTEST_LOGGER',
dbb9999f 2671 link_with : [lib_common],
ba30b89c 2672 dependencies : [lib_systemd],
2673 build_by_default: program_tests)
d4c880d5
ZJS
2674if not is_disabler(exe)
2675 exes += exe
2676endif
2677
2678exe = executable(
2679 'look',
2680 look_sources,
2681 include_directories : includes,
2682 install_dir : usrbin_exec_dir,
2683 install : true)
2684exes += exe
53b37016 2685manadocs += ['misc-utils/look.1.adoc']
38bb89ee 2686bashcompletions += ['look']
d4c880d5
ZJS
2687
2688exe = executable(
2689 'mcookie',
2690 mcookie_sources,
2691 include_directories : includes,
2692 link_with : [lib_common],
2693 install_dir : usrbin_exec_dir,
2694 install : true)
2695exes += exe
53b37016 2696manadocs += ['misc-utils/mcookie.1.adoc']
38bb89ee 2697bashcompletions += ['mcookie']
d4c880d5 2698
c2e299d0
SS
2699if build_liblastlog2
2700 exe = executable(
2701 'lastlog2',
2702 lastlog2_sources,
2703 include_directories : includes,
2704 link_with : [lib_common, lib_lastlog2],
2705 install_dir : usrbin_exec_dir,
2706 install : true)
2707 exes += exe
2708 manadocs += ['misc-utils/lastlog2.8.adoc']
2709 bashcompletions += ['lastlog2']
2710 manadocs += ['liblastlog2/man/lastlog2.3.adoc',
2711 'liblastlog2/man/ll2_write_entry.3.adoc',
2712 'liblastlog2/man/ll2_read_entry.3.adoc',
2713 'liblastlog2/man/ll2_import_lastlog.3.adoc',
2714 'liblastlog2/man/ll2_read_all.3.adoc',
2715 'liblastlog2/man/ll2_remove_entry.3.adoc',
2716 'liblastlog2/man/ll2_rename_user.3.adoc',
2717 'liblastlog2/man/ll2_update_login_time.3.adoc'
2718 ]
2719endif
2720
d4c880d5
ZJS
2721exe = executable(
2722 'namei',
2723 namei_sources,
2724 include_directories : includes,
c07f7b4e 2725 dependencies : [lib_selinux],
d4c880d5
ZJS
2726 install_dir : usrbin_exec_dir,
2727 install : true)
2728exes += exe
53b37016 2729manadocs += ['misc-utils/namei.1.adoc']
38bb89ee 2730bashcompletions += ['namei']
d4c880d5
ZJS
2731
2732exe = executable(
2733 'whereis',
2734 whereis_sources,
2735 include_directories : includes,
2736 link_with : [lib_common],
2737 install_dir : usrbin_exec_dir,
2738 install : true)
2739exes += exe
53b37016 2740manadocs += ['misc-utils/whereis.1.adoc']
38bb89ee 2741bashcompletions += ['whereis']
d4c880d5 2742
b6799ccb 2743opt = not get_option('build-lslocks').disabled()
d4c880d5
ZJS
2744exe = executable(
2745 'lslocks',
2746 lslocks_sources,
2747 include_directories : includes,
2748 link_with : [lib_common,
d4c880d5 2749 lib_smartcols],
c43b185a 2750 dependencies : [mount_dep],
d4c880d5 2751 install_dir : usrbin_exec_dir,
b6799ccb
JW
2752 install : opt,
2753 build_by_default : opt)
2754if opt and not is_disabler(exe)
d4c880d5 2755 exes += exe
53b37016 2756 manadocs += ['misc-utils/lslocks.8.adoc']
38bb89ee 2757 bashcompletions += ['lslocks']
d4c880d5
ZJS
2758endif
2759
b6799ccb 2760opt = not get_option('build-lsblk').disabled()
d4c880d5
ZJS
2761exe = executable(
2762 'lsblk',
2763 lsblk_sources,
2764 include_directories : includes,
2765 link_with : [lib_common,
c3317cdc 2766 lib_tcolors,
d4c880d5 2767 lib_smartcols],
a764efb5 2768 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2769 install : opt,
2770 build_by_default : opt)
2771if opt and not is_disabler(exe)
d4c880d5 2772 exes += exe
53b37016 2773 manadocs += ['misc-utils/lsblk.8.adoc']
38bb89ee 2774 bashcompletions += ['lsblk']
d4c880d5
ZJS
2775endif
2776
a125e2ee
MY
2777errnos_h = custom_target('errnos.h',
2778 input : 'tools/all_errnos',
2779 output : 'errnos.h',
543f991f
TW
2780 command : ['tools/all_errnos', awk.full_path(),
2781 cc.cmd_array(), get_option('c_args')],
a125e2ee
MY
2782)
2783
24395027 2784opt = not get_option('build-lsfd').require(lib_rt.found()).disabled()
ee194909
KZ
2785exe = executable(
2786 'lsfd',
a125e2ee 2787 lsfd_sources, errnos_h,
ee194909
KZ
2788 include_directories : includes,
2789 link_with : [lib_common,
2790 lib_smartcols],
06b27058 2791 dependencies : [lib_rt],
ee194909 2792 install_dir : usrbin_exec_dir,
06b27058
JW
2793 install : opt,
2794 build_by_default : opt)
2795if opt and not is_disabler(exe)
ee194909
KZ
2796 exes += exe
2797 manadocs += ['misc-utils/lsfd.1.adoc']
2798endif
2799
d4c880d5
ZJS
2800exe = executable(
2801 'uuidgen',
2802 uuidgen_sources,
2803 include_directories : includes,
06d3a851
KZ
2804 link_with : [lib_common,
2805 lib_uuid],
d4c880d5
ZJS
2806 install_dir : usrbin_exec_dir,
2807 install : true)
2808if not is_disabler(exe)
2809 exes += exe
53b37016 2810 manadocs += ['misc-utils/uuidgen.1.adoc']
38bb89ee 2811 bashcompletions += ['uuidgen']
d4c880d5
ZJS
2812endif
2813
2814exe = executable(
2815 'uuidparse',
2816 uuidparse_sources,
2817 include_directories : includes,
2818 link_with : [lib_common,
2819 lib_uuid,
2820 lib_smartcols],
2821 install_dir : usrbin_exec_dir,
2822 install : true)
2823if not is_disabler(exe)
2824 exes += exe
53b37016 2825 manadocs += ['misc-utils/uuidparse.1.adoc']
38bb89ee 2826 bashcompletions += ['uuidparse']
d4c880d5
ZJS
2827endif
2828
2829opt = build_uuidd
2830exe = executable(
2831 'uuidd',
2832 uuidd_sources,
2833 include_directories : includes,
2834 link_with : [lib_common,
2835 lib_uuid],
2836 dependencies : [realtime_libs,
2837 lib_systemd],
2838 install_dir : usrsbin_exec_dir,
2839 install : opt,
2840 build_by_default : opt)
2841exe2 = executable(
2842 'test_uuidd',
2843 test_uuidd_sources,
2844 include_directories : includes,
2845 link_with : [lib_common,
2846 lib_uuid],
2847 dependencies : thread_libs,
ba30b89c 2848 build_by_default : opt and program_tests)
d4c880d5
ZJS
2849if not is_disabler(exe)
2850 exes += [exe, exe2]
53b37016 2851 manadocs += ['misc-utils/uuidd.8.adoc']
38bb89ee 2852 bashcompletions += ['uuidd']
d4c880d5
ZJS
2853endif
2854
2855opt = build_libblkid
2856exe = executable(
2857 'blkid',
2858 blkid_sources,
2859 include_directories : includes,
a764efb5
JW
2860 link_with : [lib_common],
2861 dependencies : [blkid_dep],
d4c880d5
ZJS
2862 install_dir : sbindir,
2863 install : opt,
2864 build_by_default : opt)
2865if opt and not is_disabler(exe)
2866 exes += exe
53b37016 2867 manadocs += ['misc-utils/blkid.8.adoc']
38bb89ee 2868 bashcompletions += ['blkid']
d4c880d5
ZJS
2869endif
2870
69939195
ZJS
2871opt = opt and 'blkid' in static_programs
2872exe = executable(
2873 'blkid.static',
2874 blkid_sources,
2875 include_directories : includes,
a764efb5
JW
2876 link_with : [lib_common],
2877 dependencies : [blkid_static_dep],
69939195
ZJS
2878 install_dir : sbindir,
2879 install : opt,
2880 build_by_default : opt)
2881if opt and not is_disabler(exe)
2882 exes += exe
2883endif
d4c880d5
ZJS
2884
2885exe = executable(
2886 'sample-mkfs',
2887 'libblkid/samples/mkfs.c',
2888 include_directories : includes,
a764efb5 2889 dependencies : [blkid_dep])
d4c880d5
ZJS
2890if not is_disabler(exe)
2891 exes += exe
2892endif
2893
2894exe = executable(
2895 'sample-partitions',
2896 'libblkid/samples/partitions.c',
2897 include_directories : includes,
a764efb5 2898 dependencies : [blkid_dep])
d4c880d5
ZJS
2899if not is_disabler(exe)
2900 exes += exe
2901endif
2902
2903exe = executable(
2904 'sample-superblocks',
2905 'libblkid/samples/superblocks.c',
2906 include_directories : includes,
a764efb5 2907 dependencies : [blkid_dep])
d4c880d5
ZJS
2908if not is_disabler(exe)
2909 exes += exe
2910endif
2911
2912exe = executable(
2913 'sample-topology',
2914 'libblkid/samples/topology.c',
2915 include_directories : includes,
a764efb5 2916 dependencies : [blkid_dep])
d4c880d5
ZJS
2917if not is_disabler(exe)
2918 exes += exe
2919endif
2920
97e673a0
TW
2921exe = executable(
2922 'test_blkid_fuzz_sample',
2923 'libblkid/src/fuzz.c',
2924 include_directories: includes,
a764efb5 2925 dependencies : [blkid_dep],
ba30b89c 2926 build_by_default: program_tests)
97e673a0
TW
2927if not is_disabler(exe)
2928 exes += exe
2929endif
2930
d4c880d5
ZJS
2931############################################################
2932
2933exe = executable(
2934 'findfs',
2935 findfs_sources,
2936 include_directories : includes,
a764efb5 2937 dependencies : [blkid_dep],
d4c880d5
ZJS
2938 install_dir : sbindir,
2939 install : true)
2940if not is_disabler(exe)
2941 exes += exe
53b37016 2942 manadocs += ['misc-utils/findfs.8.adoc']
38bb89ee 2943 bashcompletions += ['findfs']
d4c880d5
ZJS
2944endif
2945
2946exe = executable(
2947 'wipefs',
2948 wipefs_sources,
2949 include_directories : includes,
2950 link_with : [lib_common,
d4c880d5 2951 lib_smartcols],
a764efb5 2952 dependencies : [blkid_dep],
d4c880d5
ZJS
2953 install_dir : sbindir,
2954 install : true)
2955if not is_disabler(exe)
2956 exes += exe
53b37016 2957 manadocs += ['misc-utils/wipefs.8.adoc']
38bb89ee 2958 bashcompletions += ['wipefs']
d4c880d5
ZJS
2959endif
2960
b6799ccb 2961opt = not get_option('build-findmnt').disabled()
d4c880d5
ZJS
2962exe = executable(
2963 'findmnt',
2964 findmnt_sources,
2965 include_directories : includes,
2966 link_with : [lib_common,
d4c880d5 2967 lib_smartcols],
a764efb5 2968 dependencies : [blkid_dep, lib_udev, mount_dep],
b6799ccb
JW
2969 install : opt,
2970 build_by_default : opt)
2971if opt and not is_disabler(exe)
d4c880d5 2972 exes += exe
53b37016 2973 manadocs += ['misc-utils/findmnt.8.adoc']
38bb89ee 2974 bashcompletions += ['findmnt']
d4c880d5
ZJS
2975endif
2976
2977exe = executable(
2978 'kill',
2979 kill_sources,
2980 include_directories : includes,
2981 link_with : [lib_common],
2982 install : true)
2983if not is_disabler(exe)
2984 exes += exe
53b37016 2985 manadocs += ['misc-utils/kill.1.adoc']
d4c880d5
ZJS
2986endif
2987
2988opt = not get_option('build-rename').disabled()
2989exe = executable(
2990 'rename',
2991 rename_sources,
2992 include_directories : includes,
2993 install_dir : usrbin_exec_dir,
2994 install : opt,
2995 build_by_default : opt)
2996if opt and not is_disabler(exe)
2997 exes += exe
53b37016 2998 manadocs += ['misc-utils/rename.1.adoc']
38bb89ee 2999 bashcompletions += ['rename']
d4c880d5
ZJS
3000endif
3001
3002exe = executable(
3003 'getopt',
3004 getopt_sources,
3005 include_directories : includes,
308a0979 3006 link_with : [lib_common],
d4c880d5
ZJS
3007 install_dir : usrbin_exec_dir,
3008 install : true)
3009exes += exe
53b37016 3010manadocs += ['misc-utils/getopt.1.adoc']
38bb89ee 3011bashcompletions += ['getopt']
d4c880d5
ZJS
3012
3013exe = executable(
3014 'fincore',
3015 fincore_sources,
3016 include_directories : includes,
3017 link_with : [lib_common,
3018 lib_smartcols],
3019 install_dir : usrbin_exec_dir,
3020 install : true)
3021if not is_disabler(exe)
3022 exes += exe
53b37016 3023 manadocs += ['misc-utils/fincore.1.adoc']
38bb89ee 3024 bashcompletions += ['fincore']
d4c880d5
ZJS
3025endif
3026
3027exe = executable(
3028 'hardlink',
3029 hardlink_sources,
3030 include_directories : includes,
3031 link_with : [lib_common],
d4c880d5
ZJS
3032 install_dir : usrbin_exec_dir,
3033 install : true)
3034if not is_disabler(exe)
3035 exes += exe
53b37016 3036 manadocs += ['misc-utils/hardlink.1.adoc']
38bb89ee 3037 bashcompletions += ['hardlink']
d4c880d5
ZJS
3038endif
3039
c221578e
NS
3040opt = not get_option('build-pipesz').disabled()
3041exe = executable(
3042 'pipesz',
3043 pipesz_sources,
3044 include_directories : includes,
3045 link_with : [lib_common],
3046 install_dir : usrbin_exec_dir,
3047 install : true)
3048if opt and not is_disabler(exe)
3049 exes += exe
62c27bd0 3050 manadocs += ['misc-utils/pipesz.1.adoc']
80af57ed 3051 bashcompletions += ['pipesz']
c221578e
NS
3052endif
3053
d4c880d5
ZJS
3054exe = executable(
3055 'test_cal',
3056 cal_sources,
3057 include_directories : includes,
3058 c_args : '-DTEST_CAL',
3059 link_with : [lib_common,
3060 lib_tcolors],
ba30b89c 3061 dependencies : [curses_libs],
3062 build_by_default: program_tests)
d4c880d5
ZJS
3063if not is_disabler(exe)
3064 exes += exe
3065endif
3066
64bc8ab5
MY
3067exe = executable(
3068 'fadvise',
3069 fadvise_sources,
3070 include_directories : includes,
3071 link_with : [lib_common],
3072 install_dir : usrbin_exec_dir,
3073 install : true)
3074if not is_disabler(exe)
3075 exes += exe
3076 manadocs += ['misc-utils/fadvise.1.adoc']
3077 bashcompletions += ['fadvise']
3078endif
3079
941e1d55 3080if LINUX and conf.get('HAVE_PIDFD_OPEN').to_string() == '1'
334939a1
ZJS
3081 exe = executable(
3082 'waitpid',
3083 waitpid_sources,
3084 include_directories : includes,
3085 link_with : [lib_common],
3086 install_dir : usrbin_exec_dir,
3087 install : true)
3088 if not is_disabler(exe)
3089 exes += exe
3090 manadocs += ['misc-utils/waitpid.1.adoc']
3091 bashcompletions += ['waitpid']
3092 endif
550d32c4
TW
3093endif
3094
69e542bd
TW
3095syscalls_h = custom_target('syscalls.h',
3096 input : 'tools/all_syscalls',
3097 output : 'syscalls.h',
543f991f
TW
3098 command : ['tools/all_syscalls', awk.full_path(),
3099 cc.cmd_array(), get_option('c_args')],
69e542bd
TW
3100)
3101
3e0bbb12
TW
3102if cc.compiles(fs.read('include/audit-arch.h'), name : 'has AUDIT_ARCH_NATIVE')
3103 exe = executable(
3104 'enosys',
ced129dc 3105 'misc-utils/enosys.c', syscalls_h, errnos_h,
3e0bbb12
TW
3106 include_directories : includes,
3107 link_with : [lib_common],
3108 install_dir : usrbin_exec_dir,
3109 install : true)
3110 if not is_disabler(exe)
3111 exes += exe
3112 manadocs += ['misc-utils/enosys.1.adoc']
3113 bashcompletions += ['enosys']
3114 endif
cba52cc1
TW
3115endif
3116
e9ddea79
TW
3117exe = executable(
3118 'lsclocks',
3119 lsclocks_sources,
3120 include_directories : includes,
3121 link_with : [lib_common, lib_smartcols],
3122 install_dir : usrbin_exec_dir,
3123 install : true)
3124if not is_disabler(exe)
3125 exes += exe
3126 manadocs += ['misc-utils/lsclocks.1.adoc']
3127 bashcompletions += ['lsclocks']
3128endif
3129
cd094a05
MY
3130if conf.get('HAVE_RENAMEAT2').to_string() == '1'
3131exe = executable(
3132 'exch',
3133 exch_sources,
3134 include_directories : includes,
3135 link_with : [lib_common],
3136 install_dir : usrbin_exec_dir,
3137 install : true)
3138if not is_disabler(exe)
3139 exes += exe
3140 manadocs += ['misc-utils/exch.1.adoc']
3141 bashcompletions += ['exch']
3142endif
3143endif
3144
d4c880d5
ZJS
3145############################################################
3146
3147opt = not get_option('build-schedutils').disabled()
3148exe = executable(
3149 'chrt',
3150 'schedutils/chrt.c',
3151 include_directories : includes,
3152 link_with : lib_common,
3153 install_dir : usrbin_exec_dir,
3154 install : opt,
3155 build_by_default : opt)
3156
3157exe2 = executable(
3158 'ionice',
3159 'schedutils/ionice.c',
3160 include_directories : includes,
3161 link_with : lib_common,
3162 install_dir : usrbin_exec_dir,
3163 install : opt,
3164 build_by_default : opt)
3165
3166exe3 = executable(
3167 'taskset',
3168 'schedutils/taskset.c',
3169 include_directories : includes,
3170 link_with : lib_common,
3171 install_dir : usrbin_exec_dir,
3172 install : opt,
3173 build_by_default : opt)
3174
6e92db54
KZ
3175exe4 = executable(
3176 'uclampset',
3177 'schedutils/uclampset.c',
3178 include_directories : includes,
3179 link_with : lib_common,
3180 install_dir : usrbin_exec_dir,
3181 install : opt,
3182 build_by_default : opt)
3183
d4c880d5 3184if opt and not is_disabler(exe)
6e92db54 3185 exes += [exe, exe2, exe3, exe4]
53b37016
KZ
3186 manadocs += ['schedutils/chrt.1.adoc',
3187 'schedutils/ionice.1.adoc',
3188 'schedutils/taskset.1.adoc',
3189 'schedutils/uclampset.1.adoc']
38bb89ee 3190 bashcompletions += ['chrt', 'ionice', 'taskset', 'uclampset']
d4c880d5
ZJS
3191endif
3192
3193############################################################
3194
3195# TODO: when autotools compat is not needed, s/_/-/g in file names?
3196
3197exe = executable(
3198 'test_ttyutils',
3199 'lib/ttyutils.c',
3200 c_args : ['-DTEST_PROGRAM_TTYUTILS'],
3201 include_directories : dir_include,
ba30b89c 3202 link_with : lib_common,
3203 build_by_default: program_tests)
d4c880d5
ZJS
3204exes += exe
3205
3206exe = executable(
3207 'test_blkdev',
3208 'lib/blkdev.c',
3209 c_args : ['-DTEST_PROGRAM_BLKDEV'],
3210 include_directories : dir_include,
ba30b89c 3211 link_with : lib_common,
3212 build_by_default: program_tests)
d4c880d5
ZJS
3213exes += exe
3214
3215exe = executable(
3216 'test_ismounted',
3217 'lib/ismounted.c',
3218 c_args : ['-DTEST_PROGRAM_ISMOUNTED'],
3219 include_directories : dir_include,
ba30b89c 3220 link_with : lib_common,
3221 build_by_default: program_tests)
d4c880d5
ZJS
3222exes += exe
3223
3224exe = executable(
3225 'test_mangle',
3226 'lib/mangle.c',
3227 c_args : ['-DTEST_PROGRAM_MANGLE'],
ba30b89c 3228 include_directories : dir_include,
3229 build_by_default: program_tests)
d4c880d5
ZJS
3230exes += exe
3231
3232exe = executable(
3233 'test_strutils',
3234 'lib/strutils.c',
3235 c_args : ['-DTEST_PROGRAM_STRUTILS'],
ba30b89c 3236 include_directories : dir_include,
3237 build_by_default: program_tests)
d4c880d5
ZJS
3238exes += exe
3239
3240exe = executable(
3241 'test_colors',
3242 'lib/colors.c',
3243 'lib/color-names.c',
3244 c_args : ['-DTEST_PROGRAM_COLORS'],
3245 include_directories : dir_include,
ba30b89c 3246 link_with : [lib_common, lib_tcolors],
3247 build_by_default: program_tests)
d4c880d5
ZJS
3248exes += exe
3249
3250exe = executable(
3251 'test_randutils',
3252 'lib/randutils.c',
3253 c_args : ['-DTEST_PROGRAM_RANDUTILS'],
ba30b89c 3254 include_directories : dir_include,
3255 build_by_default: program_tests)
d4c880d5
ZJS
3256exes += exe
3257
941e1d55
TW
3258if conf.get('HAVE_OPENAT').to_string() == '1' \
3259 and conf.get('HAVE_DIRFD').to_string() == '1'
d6418774
ZJS
3260 exe = executable(
3261 'test_procfs',
3262 'lib/procfs.c',
3263 c_args : ['-DTEST_PROGRAM_PROCFS'],
3264 include_directories : dir_include,
ba30b89c 3265 link_with : lib_common,
3266 build_by_default: program_tests)
d6418774 3267 exes += exe
d4c880d5 3268
d6418774
ZJS
3269 exe = executable(
3270 'test_path',
3271 'lib/path.c',
3272 'lib/fileutils.c',
3273 have_cpu_set_t ? 'lib/cpuset.c' : [],
3274 c_args : ['-DTEST_PROGRAM_PATH'],
3275 include_directories : dir_include,
ba30b89c 3276 link_with : lib_common,
3277 build_by_default: program_tests)
d6418774
ZJS
3278 exes += exe
3279endif
d4c880d5 3280
941e1d55 3281if conf.get('HAVE_PTY').to_string() == '1'
44475360
ZJS
3282 exe = executable(
3283 'test_pty',
3284 pty_session_c,
3285 monotonic_c,
3286 c_args : ['-DTEST_PROGRAM_PTY'],
3287 include_directories : dir_include,
3288 link_with : [lib_common],
3289 dependencies : [lib_m,
3290 realtime_libs,
ba30b89c 3291 lib_util],
3292 build_by_default: program_tests)
44475360
ZJS
3293 exes += exe
3294endif
d4c880d5 3295
d6418774
ZJS
3296if LINUX
3297 exe = executable(
3298 'test_cpuset',
3299 'lib/cpuset.c',
3300 c_args : ['-DTEST_PROGRAM_CPUSET'],
ba30b89c 3301 include_directories : dir_include,
3302 build_by_default: program_tests)
d6418774
ZJS
3303 exes += exe
3304endif
d4c880d5
ZJS
3305
3306exe = executable(
3307 'test_sysfs',
3308 'lib/sysfs.c',
3309 'lib/path.c',
35d26ae8 3310 'lib/buffer.c',
fb8493fd 3311 'lib/mbsalign.c',
d4c880d5
ZJS
3312 'lib/fileutils.c',
3313 have_cpu_set_t ? 'lib/cpuset.c' : [],
3314 c_args : ['-DTEST_PROGRAM_SYSFS'],
ba30b89c 3315 include_directories : dir_include,
3316 build_by_default: program_tests)
d4c880d5
ZJS
3317exes += exe
3318
3319exe = executable(
3320 'test_pager',
3321 'lib/pager.c',
3322 c_args : ['-DTEST_PROGRAM_PAGER'],
ba30b89c 3323 include_directories : dir_include,
3324 build_by_default: program_tests)
d4c880d5
ZJS
3325exes += exe
3326
3327exe = executable(
3328 'test_linux_version',
3329 'lib/linux_version.c',
3330 c_args : ['-DTEST_PROGRAM_LINUXVERSION'],
ba30b89c 3331 include_directories : dir_include,
3332 build_by_default: program_tests)
d4c880d5
ZJS
3333exes += exe
3334
3335exe = executable(
3336 'test_fileutils',
3337 'lib/fileutils.c',
3338 c_args : ['-DTEST_PROGRAM_FILEUTILS'],
ba30b89c 3339 include_directories : dir_include,
3340 build_by_default: program_tests)
d4c880d5
ZJS
3341exes += exe
3342
3343exe = executable(
3344 'test_canonicalize',
3345 'lib/canonicalize.c',
3346 c_args : ['-DTEST_PROGRAM_CANONICALIZE'],
ba30b89c 3347 include_directories : dir_include,
3348 build_by_default: program_tests)
d4c880d5
ZJS
3349exes += exe
3350
3351exe = executable(
3352 'test_timeutils',
3353 'lib/timeutils.c',
3354 'lib/strutils.c',
3355 c_args : ['-DTEST_PROGRAM_TIMEUTILS'],
ba30b89c 3356 include_directories : dir_include,
3357 build_by_default: program_tests)
d4c880d5
ZJS
3358exes += exe
3359
3360exe = executable(
3361 'test_pwdutils',
3362 'lib/pwdutils.c',
3363 c_args : ['-DTEST_PROGRAM'],
3364 include_directories : dir_include,
ba30b89c 3365 link_with : lib_common,
3366 build_by_default: program_tests)
d4c880d5
ZJS
3367exes += exe
3368
866d922b
KZ
3369exe = executable(
3370 'test_logindefs',
3371 'lib/logindefs.c',
3372 c_args : ['-DTEST_PROGRAM'],
3373 include_directories : dir_include,
ba30b89c 3374 link_with : [lib_common, logindefs_c],
3375 build_by_default: program_tests)
866d922b
KZ
3376exes += exe
3377
3378
d4c880d5
ZJS
3379############################################################
3380
3381exe = executable(
3382 'test_uuid_parser',
3383 'libuuid/src/test_uuid.c',
3384 include_directories : [dir_include, dir_libuuid],
3385 link_with : lib_uuid,
ba30b89c 3386 dependencies : socket_libs,
3387 build_by_default: program_tests)
d4c880d5
ZJS
3388if not is_disabler(exe)
3389 exes += exe
3390endif
3391
3392############################################################
3393
2a472ae8 3394libfdisk_tests_cflags = ['-DTEST_PROGRAM']
a764efb5
JW
3395libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid]
3396libfdisk_tests_ldadd_deps = [blkid_dep]
d4c880d5
ZJS
3397
3398exe = executable(
3399 'test_fdisk_ask',
3400 'libfdisk/src/ask.c',
3401 c_args : libfdisk_tests_cflags,
3402 include_directories : lib_fdisk_includes,
ba30b89c 3403 link_with : libfdisk_tests_ldadd,
a764efb5 3404 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3405 build_by_default: program_tests)
d4c880d5
ZJS
3406if not is_disabler(exe)
3407 exes += exe
3408endif
3409
3410exe = executable(
3411 'test_fdisk_gpt',
3412 'libfdisk/src/gpt.c',
3413 c_args : libfdisk_tests_cflags,
3414 include_directories : lib_fdisk_includes,
ba30b89c 3415 link_with : libfdisk_tests_ldadd,
a764efb5 3416 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3417 build_by_default: program_tests)
d4c880d5
ZJS
3418if not is_disabler(exe)
3419 exes += exe
3420endif
3421
3422exe = executable(
3423 'test_fdisk_utils',
3424 'libfdisk/src/utils.c',
3425 c_args : libfdisk_tests_cflags,
3426 include_directories : lib_fdisk_includes,
ba30b89c 3427 link_with : libfdisk_tests_ldadd,
a764efb5 3428 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3429 build_by_default: program_tests)
d4c880d5
ZJS
3430if not is_disabler(exe)
3431 exes += exe
3432endif
3433
3434exe = executable(
3435 'test_fdisk_script',
3436 'libfdisk/src/script.c',
3437 c_args : libfdisk_tests_cflags,
3438 include_directories : lib_fdisk_includes,
ba30b89c 3439 link_with : libfdisk_tests_ldadd,
a764efb5 3440 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3441 build_by_default: program_tests)
d4c880d5
ZJS
3442if not is_disabler(exe)
3443 exes += exe
3444endif
3445
3446exe = executable(
3447 'test_fdisk_version',
3448 'libfdisk/src/version.c',
3449 c_args : libfdisk_tests_cflags,
3450 include_directories : lib_fdisk_includes,
ba30b89c 3451 link_with : libfdisk_tests_ldadd,
a764efb5 3452 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3453 build_by_default: program_tests)
d4c880d5
ZJS
3454if not is_disabler(exe)
3455 exes += exe
3456endif
3457
3458exe = executable(
3459 'test_fdisk_item',
3460 'libfdisk/src/item.c',
3461 c_args : libfdisk_tests_cflags,
3462 include_directories : lib_fdisk_includes,
ba30b89c 3463 link_with : libfdisk_tests_ldadd,
a764efb5 3464 dependencies : libfdisk_tests_ldadd_deps,
ba30b89c 3465 build_by_default: program_tests)
d4c880d5
ZJS
3466if not is_disabler(exe)
3467 exes += exe
3468endif
3469
d4c880d5
ZJS
3470sample_fdisk_ldadd = [lib_common, lib_fdisk]
3471
3472exe = executable(
3473 'sample-fdisk-mkpart',
3474 'libfdisk/samples/mkpart.c',
d4c880d5
ZJS
3475 include_directories : lib_fdisk_includes,
3476 link_with : sample_fdisk_ldadd)
3477if not is_disabler(exe)
3478 exes += exe
3479endif
3480
3481exe = executable(
3482 'sample-fdisk-mkpart-fullspec',
3483 'libfdisk/samples/mkpart-fullspec.c',
d4c880d5
ZJS
3484 include_directories : lib_fdisk_includes,
3485 link_with : sample_fdisk_ldadd)
3486if not is_disabler(exe)
3487 exes += exe
3488endif
3489
3490############################################################
3491
a76299c1
TW
3492exe = executable(
3493 'test_cap',
3494 'tests/helpers/test_cap.c',
3495 include_directories : includes,
3496 dependencies : [lib_cap_ng],
3497 build_by_default: program_tests)
512c91a6
TW
3498if not is_disabler(exe)
3499 exes += exe
3500endif
a76299c1 3501
d4c880d5
ZJS
3502exe = executable(
3503 'test_mbsencode',
3504 'tests/helpers/test_mbsencode.c',
3505 include_directories : includes,
ba30b89c 3506 link_with : lib_common,
3507 build_by_default: program_tests)
d4c880d5
ZJS
3508exes += exe
3509
3510exe = executable(
3511 'test_byteswap',
3512 'tests/helpers/test_byteswap.c',
ba30b89c 3513 include_directories : includes,
3514 build_by_default: program_tests)
d4c880d5
ZJS
3515exes += exe
3516
3517exe = executable(
3518 'test_md5',
3519 'tests/helpers/test_md5.c',
3520 md5_c,
ba30b89c 3521 include_directories : includes,
3522 build_by_default: program_tests)
d4c880d5
ZJS
3523exes += exe
3524
3525exe = executable(
3526 'test_sha1',
3527 'tests/helpers/test_sha1.c',
3528 sha1_c,
ba30b89c 3529 include_directories : includes,
3530 build_by_default: program_tests)
d4c880d5
ZJS
3531exes += exe
3532
3533exe = executable(
3534 'test_pathnames',
3535 'tests/helpers/test_pathnames.c',
ba30b89c 3536 include_directories : includes,
3537 build_by_default: program_tests)
d4c880d5
ZJS
3538exes += exe
3539
3540exe = executable(
3541 'test_strerror',
3542 'tests/helpers/test_strerror.c',
ba30b89c 3543 include_directories : includes,
3544 build_by_default: program_tests)
d4c880d5
ZJS
3545exes += exe
3546
3547exe = executable(
3548 'test_sysinfo',
3549 'tests/helpers/test_sysinfo.c',
ba30b89c 3550 include_directories : includes,
3551 build_by_default: program_tests)
d4c880d5
ZJS
3552exes += exe
3553
3554exe = executable(
3555 'test_sigreceive',
3556 'tests/helpers/test_sigreceive.c',
3557 include_directories : includes,
ba30b89c 3558 link_with : lib_common,
3559 build_by_default: program_tests)
d4c880d5
ZJS
3560exes += exe
3561
3562exe = executable(
3563 'test_tiocsti',
3564 'tests/helpers/test_tiocsti.c',
ba30b89c 3565 include_directories : includes,
3566 build_by_default: program_tests)
d4c880d5
ZJS
3567exes += exe
3568
3569exe = executable(
3570 'test_uuid_namespace',
3571 'tests/helpers/test_uuid_namespace.c',
3572 predefined_c,
3573 unpack_c,
3574 unparse_c,
ba30b89c 3575 include_directories : includes,
3576 build_by_default: program_tests)
d4c880d5
ZJS
3577exes += exe
3578
06b27058 3579if LINUX and lib_rt.found()
d6418774
ZJS
3580 exe = executable(
3581 'test_mkfds',
3582 'tests/helpers/test_mkfds.c',
b2033a32 3583 'tests/helpers/test_mkfds.h',
38ffd1e3 3584 'tests/helpers/test_mkfds_ppoll.c',
d6418774 3585 include_directories : includes,
06b27058 3586 dependencies : [lib_rt],
ba30b89c 3587 build_by_default: program_tests)
d6418774
ZJS
3588 exes += exe
3589endif
f7b41ef8 3590
42900563
TW
3591exe = executable(
3592 'test_enosys',
3593 'tests/helpers/test_enosys.c',
ba30b89c 3594 include_directories : includes,
3595 build_by_default: program_tests)
42900563
TW
3596exes += exe
3597
d4c880d5
ZJS
3598############################################################
3599
941e1d55 3600if conf.get('HAVE_OPENAT').to_string() == '1'
d6418774
ZJS
3601 exe = executable(
3602 'sample-scols-tree',
3603 'libsmartcols/samples/tree.c',
3604 include_directories : includes,
ba30b89c 3605 link_with : [lib_smartcols, lib_common],
3606 build_by_default: program_tests)
d6418774
ZJS
3607 if not is_disabler(exe)
3608 exes += exe
3609 endif
d4c880d5
ZJS
3610endif
3611
3612exe = executable(
3613 'sample-scols-title',
3614 'libsmartcols/samples/title.c',
3615 include_directories : includes,
3616 link_with : [lib_smartcols, lib_common])
3617if not is_disabler(exe)
3618 exes += exe
3619endif
3620
3621exe = executable(
3622 'sample-scols-wrap',
3623 'libsmartcols/samples/wrap.c',
3624 include_directories : includes,
3625 link_with : [lib_smartcols, lib_common])
3626if not is_disabler(exe)
3627 exes += exe
3628endif
3629
3630exe = executable(
3631 'sample-scols-continuous',
3632 'libsmartcols/samples/continuous.c',
3633 include_directories : includes,
3634 link_with : [lib_smartcols, lib_common])
3635if not is_disabler(exe)
3636 exes += exe
3637endif
3638
be597292
TW
3639exe = executable(
3640 'sample-scols-continuous-json',
3641 'libsmartcols/samples/continuous-json.c',
3642 include_directories : includes,
3643 link_with : [lib_smartcols, lib_common])
3644if not is_disabler(exe)
3645 exes += exe
3646endif
3647
d4c880d5
ZJS
3648exe = executable(
3649 'sample-scols-maxout',
3650 'libsmartcols/samples/maxout.c',
3651 include_directories : includes,
3652 link_with : [lib_smartcols, lib_common])
3653if not is_disabler(exe)
3654 exes += exe
3655endif
3656
3657exe = executable(
3658 'sample-scols-fromfile',
3659 'libsmartcols/samples/fromfile.c',
3660 include_directories : includes,
3661 link_with : [lib_smartcols, lib_common])
3662if not is_disabler(exe)
3663 exes += exe
3664endif
3665
3666exe = executable(
3667 'sample-scols-grouping-simple',
3668 'libsmartcols/samples/grouping-simple.c',
3669 include_directories : includes,
3670 link_with : [lib_smartcols, lib_common])
3671if not is_disabler(exe)
3672 exes += exe
3673endif
3674
3675exe = executable(
3676 'sample-scols-grouping-overlay',
3677 'libsmartcols/samples/grouping-overlay.c',
3678 include_directories : includes,
3679 link_with : [lib_smartcols, lib_common])
3680if not is_disabler(exe)
3681 exes += exe
3682endif
48afece8
TW
3683
3684exe = executable(
3685 'test_boilerplate',
3686 'Documentation/boilerplate.c',
3687 include_directories : includes,
3688 build_by_default: program_tests)
3689if not is_disabler(exe)
3690 exes += exe
3691endif
d4c880d5
ZJS
3692
3693############################################################
3694
3695# Let the test runner know whether we're running under asan and export
3696# some paths. We use a file on disk so that it is possible to run the
3697# test scripts from commandline without setting any variables.
3698configure_file(output : 'meson.conf',
3699 capture : true,
3700 command : ['echo',
3701 '''asan=@0@
3702PYTHON=@1@
3703'''.format(get_option('b_sanitize')=='address' ? 'yes' : '',
e2cd7446 3704 python.full_path())])
d4c880d5
ZJS
3705
3706run_sh = find_program('tests/run.sh')
3707run_target(
3708 'check',
3709 command : [run_sh,
3710 '--srcdir=' + meson.current_source_dir(),
3711 '--builddir=' + meson.current_build_dir(),
3712 '--parallel',
3713 '--nonroot'],
3714 depends : exes)
53b37016
KZ
3715
3716
3717manadocs += ['lib/terminal-colors.d.5.adoc']
3718manadocs += ['libblkid/libblkid.3.adoc']
3719
3720if build_libuuid
3721 manadocs += [
3722 'libuuid/man/uuid.3.adoc',
3723 'libuuid/man/uuid_clear.3.adoc',
3724 'libuuid/man/uuid_compare.3.adoc',
3725 'libuuid/man/uuid_copy.3.adoc',
3726 'libuuid/man/uuid_generate.3.adoc',
3727 'libuuid/man/uuid_is_null.3.adoc',
3728 'libuuid/man/uuid_parse.3.adoc',
3729 'libuuid/man/uuid_time.3.adoc',
3730 'libuuid/man/uuid_unparse.3.adoc']
38bb89ee
TW
3731 manlinks += {
3732 'uuid_generate_random.3': 'uuid_generate.3',
3733 'uuid_generate_time.3': 'uuid_generate.3',
3734 'uuid_generate_time_safe.3': 'uuid_generate.3',
3735 }
53b37016
KZ
3736endif
3737
00b8a51f 3738asciidoctor = find_program('asciidoctor', required : false)
53b37016
KZ
3739if asciidoctor.found()
3740 foreach adoc : manadocs
3741 name = adoc.split('/')[-1]
3742 page = name.split('.adoc')[0]
3743 section = page.split('.')[-1]
3744 mandirn = join_paths(mandir, 'man' + section)
3745 input = adoc
3746
3747 custom_target(
3748 page,
3749 command : [ asciidoctor,
3750 '-b', 'manpage',
3751 '-a', 'VERSION=' + meson.project_version(),
38bb89ee 3752 '-a', 'release-version=' + meson.project_version(),
53b37016 3753 '-a', 'ADJTIME_PATH=/etc/adjtime',
38bb89ee 3754 '-a', 'package-docdir=' + docdir,
53b37016
KZ
3755 '--base-dir=' + meson.current_source_dir(),
3756 '--destination-dir=' + meson.current_build_dir(),
adcab835
TW
3757 '--load-path', '@SOURCE_ROOT@/tools',
3758 '--require', 'asciidoctor-includetracker',
53b37016
KZ
3759 '@INPUT@'],
3760 input : input,
3761 output : [page],
adcab835 3762 depfile : page + '.deps',
53b37016
KZ
3763 install: true,
3764 install_dir : mandirn)
3765 endforeach
38bb89ee
TW
3766
3767 foreach link_name, target : manlinks
3768 link_section = link_name.split('.')[-1]
3769 target_section = target.split('.')[-1]
3770 meson.add_install_script(meson_make_manpage_stub,
3771 join_paths('man' + target_section, target),
3772 join_paths(mandir, 'man' + link_section, link_name))
3773 endforeach
3774endif
3775
3776if bash_completion.found()
3777 foreach completion : bashcompletions
3778 install_data(
3779 join_paths('bash-completion', completion),
caa85688 3780 install_dir : bash_completion.get_variable(pkgconfig : 'completionsdir')
38bb89ee
TW
3781 )
3782 endforeach
aa519054
KZ
3783 foreach link_name, target : bashcompletionslinks
3784 meson.add_install_script(meson_make_symlink,
3785 target,
caa85688 3786 join_paths(bash_completion.get_variable(pkgconfig : 'completionsdir'), link_name))
aa519054 3787 endforeach
53b37016 3788endif