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