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