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