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