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