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