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