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