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