]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - meson.build
Merge branch 'uuid-time64_t' of https://github.com/thkukuk/util-linux
[thirdparty/util-linux.git] / meson.build
index 6c6dc527b28f078e10bcd39f7b48702d6b47c417..331d7582987b32dff25450f3c2b349357a6b0990 100644 (file)
@@ -1,7 +1,11 @@
 project('util-linux', 'c',
         version : run_command('tools/git-version-gen', check: true).stdout(),
-        meson_version: '>=0.57.0',
-        license : 'GPLv2+')
+        meson_version: '>=0.60.0',
+        license : 'GPLv2+',
+        default_options : [
+          'c_std=c99',
+          'cpp_std=c++11',
+        ])
 
 fs = import('fs')
 pkgconfig = import('pkgconfig')
@@ -41,16 +45,13 @@ conf.set_quoted('PACKAGE_VERSION', meson.project_version())
 package_string = '@0@ @1@'.format(meson.project_name(), meson.project_version())
 conf.set_quoted('PACKAGE_STRING', package_string)
 
-codes = [''' {print $1}  ''',
-         ''' {sub("-.*","",$2); print $2} ''',
-         ''' {sub("-.*","",$3); print $3 ~ /^[0-9]+$/ ? $3 : 0} ''']
 pc_version = []
-foreach code : codes
-  res = run_command('bash', '-c',
-                    '''echo '@0@' | awk -F. '@1@' '''.format(
-                      meson.project_version(), code), check: true)
-  pc_version += res.stdout().strip()
-endforeach
+pc_version = meson.project_version().split('-')[0].split('.')
+
+if pc_version.length() < 3
+    pc_version += '0'
+endif
+
 pc_version = '.'.join(pc_version)
 
 conf.set_quoted('LIBBLKID_VERSION', libblkid_version)
@@ -82,6 +83,9 @@ have_mountfd_api = cc.sizeof('struct mount_attr', prefix : '#include <linux/moun
 conf.set('HAVE_STRUCT_MOUNT_ATTR', have_mountfd_api ? 1 : false)
 conf.set('HAVE_MOUNTFD_API', have_mountfd_api ? 1 : false)
 
+have_struct_statx = cc.sizeof('struct statx', prefix : '#include <sys/stat.h>') > 0
+conf.set('HAVE_STRUCT_STATX', have_struct_statx ? 1 : false)
+
 build_libmount = not get_option('build-libmount').disabled()
 conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
 conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
@@ -175,8 +179,8 @@ headers = '''
         linux/kcmp.h
         linux/net_namespace.h
         linux/nsfs.h
+        linux/mount.h
         linux/pr.h
-        linux/stat.h
         linux/securebits.h
         linux/tiocl.h
         linux/version.h
@@ -319,6 +323,11 @@ lib_systemd = dependency(
 conf.set('HAVE_LIBSYSTEMD', lib_systemd.found() ? 1 : false)
 conf.set('USE_SYSTEMD', lib_systemd.found() ? 1 : false)
 
+have = cc.has_function(
+  'sd_session_get_username',
+  dependencies : lib_systemd)
+conf.set('HAVE_DECL_SD_SESSION_GET_USERNAME', have ? 1 : false)
+
 lib_udev = dependency(
   'libudev',
   required : get_option('systemd'))
@@ -372,6 +381,9 @@ conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
 lib_cap_ng = dependency(
   'libcap-ng',
   required : get_option('build-setpriv'))
+if not lib_cap_ng.found()
+  lib_cap_ng = disabler()
+endif
 
 lib_selinux = dependency(
   'libselinux',
@@ -497,6 +509,7 @@ have = cc.compiles('''
 conf.set('HAVE_DECL__NL_TIME_WEEK_1STDAY', have ? 1 : false)
 
 funcs = '''
+        cachestat
         clearenv
         close_range
         __fpurge
@@ -544,6 +557,7 @@ funcs = '''
         posix_fadvise
         prctl
         qsort_r
+        reallocarray
         rpmatch
         scandirat
         setprogname
@@ -632,6 +646,10 @@ have = cc.has_member('struct stat', 'st_mtim.tv_nsec',
                      prefix : '#include <sys/stat.h>')
 conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', have ? 1 : false)
 
+have = cc.has_member('struct statx', 'stx_mnt_id',
+                     prefix : '#include <sys/stat.h>')
+conf.set('HAVE_STRUCT_STATX_STX_MNT_ID', have ? 1 : false)
+
 # replacement for AC_STRUCT_TIMEZONE
 have = cc.has_member('struct tm', 'tm_zone',
                      prefix : '#include <time.h>')
@@ -721,7 +739,8 @@ int main(void) {
 have = cc.compiles(code, name : 'using __progname')
 conf.set('HAVE___PROGNAME', have ? 1 : false)
 
-have = conf.get('HAVE_PTY_H') != false and conf.get('HAVE_SYS_SIGNALFD_H') != false
+have = conf.get('HAVE_PTY_H').to_string() == '1' \
+       and conf.get('HAVE_SYS_SIGNALFD_H').to_string() == '1'
 conf.set('HAVE_PTY', have ? 1 : false)
 
 have_opal_get_status= cc.has_header_symbol('linux/sed-opal.h', 'IOC_OPAL_GET_STATUS')
@@ -793,6 +812,8 @@ conf.set('HAVE_TLS', get_option('use-tls') ? 1 : false)
 conf.set('PG_BELL', get_option('pg-bell') ? 1 : false)
 conf.set('USE_COLORS_BY_DEFAULT', get_option('colors-default') ? 1 : false)
 
+is_glibc = cc.has_header_symbol('limits.h', '__GLIBC__')
+
 ############################################################
 
 
@@ -811,6 +832,8 @@ endif
 sysvinit = get_option('sysvinit').enabled()
 sysvinitrcdir = sysconfdir + '/init.d'
 
+program_tests = get_option('program-tests')
+
 chfn_chsh_password = get_option('chfn-chsh-password') or lib_user.found()
 conf.set('CHFN_CHSH_PASSWORD', chfn_chsh_password ? 1 : false)
 
@@ -820,15 +843,15 @@ conf.set('ONLY_LISTED_SHELLS', have ? 1 : false)
 have = get_option('use-tty-group')
 conf.set('USE_TTY_GROUP', have ? 1 : false)
 
+bison = find_program('bison')
+flex = find_program('flex')
+
 build_hwclock = not get_option('build-hwclock').disabled()
-bison = find_program('bison', required: build_hwclock)
 bison_gen = generator(
   bison,
   output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
   arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
 
-
-
 meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
 meson_make_manpage_stub = meson.current_source_dir() + '/tools/meson-make-manpage-stub.sh'
 
@@ -864,6 +887,8 @@ compiler_flags = [
   '-Wunused-parameter',
   '-Wunused-result',
   '-Wunused-variable',
+  '-Wvla',
+  '-Walloca',
 ]
 foreach compiler_flag : compiler_flags
   if cc.has_argument(compiler_flag)
@@ -937,7 +962,8 @@ exe = executable(
   'test_islocal',
   test_islocal_sources,
   include_directories : includes,
-  c_args : '-DTEST_PROGRAM')
+  c_args : '-DTEST_PROGRAM',
+  build_by_default : program_tests)
 exes += exe
 
 exe = executable(
@@ -945,7 +971,8 @@ exe = executable(
   test_consoles_sources,
   c_args : ['-DTEST_PROGRAM'],
   include_directories : includes,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default : program_tests)
 exes += exe
 
 opt = not get_option('build-last').disabled()
@@ -1104,16 +1131,18 @@ endif
 
 ############################################################
 
-exe = executable(
-  'col',
-  col_sources,
-  include_directories : includes,
-  link_with : lib_common,
-  install_dir : usrbin_exec_dir,
-  install : true)
-exes += exe
-manadocs += ['text-utils/col.1.adoc']
-bashcompletions += ['col']
+if is_glibc
+  exe = executable(
+    'col',
+    col_sources,
+    include_directories : includes,
+    link_with : lib_common,
+    install_dir : usrbin_exec_dir,
+    install : true)
+  exes += exe
+  manadocs += ['text-utils/col.1.adoc']
+  bashcompletions += ['col']
+endif
 
 exe = executable(
   'colcrt',
@@ -1226,7 +1255,7 @@ exe2 = executable(
   dependencies : [lib_tinfo,
                   curses_libs,
                  lib_magic],
-  build_by_default : opt)
+  build_by_default : opt and program_tests)
 exes += exe
 if opt and not is_disabler(exe)
   exes += [exe, exe2]
@@ -1356,6 +1385,20 @@ if not is_disabler(exe)
   bashcompletions += ['renice']
 endif
 
+exe = executable(
+  'setpgid',
+  setpgid_sources,
+  include_directories: includes,
+  link_with : [lib_common,
+               lib_smartcols],
+  install_dir : usrbin_exec_dir,
+  install : true)
+if opt and not is_disabler(exe)
+  exes += exe
+  manadocs += ['sys-utils/setpgid.1.adoc']
+  bashcompletions += ['setpgid']
+endif
+
 exe = executable(
   'setsid',
   setsid_sources,
@@ -1432,7 +1475,8 @@ exe = executable(
   include_directories : dir_include,
   c_args : '-DTEST_DMESG',
   link_with : [lib_common,
-               lib_tcolors])
+               lib_tcolors],
+  build_by_default : program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -2078,7 +2122,7 @@ exe2 = executable(
   include_directories : includes,
   c_args : '-DTEST_SCRIPT',
   link_with : [lib_common],
-  build_by_default : opt)
+  build_by_default : opt and program_tests)
 exe3 = executable(
   'fsck.minix',
   fsck_minix_sources,
@@ -2323,7 +2367,8 @@ exe = executable(
   dependencies : [lib_util,
                   lib_utempter,
                   realtime_libs,
-                  math_libs])
+                  math_libs],
+  build_by_default : program_tests)
 exes += exe
 
 exe = executable(
@@ -2358,7 +2403,7 @@ exe = executable(
   agetty_sources,
   include_directories : includes,
   link_with : [lib_common, logindefs_c],
-  dependencies : BSD ? lib_util : [],
+  dependencies : [BSD ? lib_util : [], lib_systemd],
   install_dir : sbindir,
   install : opt,
   build_by_default : opt)
@@ -2404,8 +2449,9 @@ exe = executable(
   wall_sources,
   include_directories : includes,
   link_with : [lib_common],
+  dependencies : [lib_systemd],
   install_dir : usrbin_exec_dir,
-  install_mode : 'rwxr-sr-x',
+  install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
   install : opt,
   build_by_default : opt)
 if opt
@@ -2423,8 +2469,9 @@ exe = executable(
   write_sources,
   include_directories : includes,
   link_with : [lib_common],
+  dependencies : [lib_systemd],
   install_dir : usrbin_exec_dir,
-  install_mode : 'rwxr-sr-x',
+  install_mode : [ 'rwxr-sr-x', 'root', 'tty' ],
   install : opt,
   build_by_default : opt)
 if opt
@@ -2503,7 +2550,8 @@ exe = executable(
   include_directories : includes,
   c_args : '-DTEST_LOGGER',
   link_with : [lib_common],
-  dependencies : [lib_systemd])
+  dependencies : [lib_systemd],
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -2573,6 +2621,7 @@ exe = executable(
   link_with : [lib_common,
                lib_blkid,
                lib_mount,
+               lib_tcolors,
                lib_smartcols],
   dependencies : lib_udev,
   install : true)
@@ -2582,12 +2631,16 @@ if not is_disabler(exe)
   bashcompletions += ['lsblk']
 endif
 
+mq_libs = []
+mq_libs += cc.find_library('rt', required : true)
+
 exe = executable(
   'lsfd',
   lsfd_sources,
   include_directories : includes,
   link_with : [lib_common,
                lib_smartcols],
+  dependencies : mq_libs,
   install_dir : usrbin_exec_dir,
   install : true)
 if not is_disabler(exe)
@@ -2599,7 +2652,8 @@ exe = executable(
   'uuidgen',
   uuidgen_sources,
   include_directories : includes,
-  link_with : [lib_uuid],
+  link_with : [lib_common,
+               lib_uuid],
   install_dir : usrbin_exec_dir,
   install : true)
 if not is_disabler(exe)
@@ -2642,7 +2696,7 @@ exe2 = executable(
   link_with : [lib_common,
                lib_uuid],
   dependencies : thread_libs,
-  build_by_default : opt)
+  build_by_default : opt and program_tests)
 if not is_disabler(exe)
   exes += [exe, exe2]
   manadocs += ['misc-utils/uuidd.8.adoc']
@@ -2719,7 +2773,8 @@ exe = executable(
   'test_blkid_fuzz_sample',
   'libblkid/src/fuzz.c',
   include_directories: includes,
-  link_with: lib_blkid)
+  link_with: lib_blkid,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -2854,7 +2909,8 @@ exe = executable(
   c_args : '-DTEST_CAL',
   link_with : [lib_common,
                lib_tcolors],
-  dependencies : [curses_libs])
+  dependencies : [curses_libs],
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -2872,7 +2928,7 @@ if not is_disabler(exe)
   bashcompletions += ['fadvise']
 endif
 
-if LINUX and conf.get('HAVE_PIDFD_OPEN') != false
+if LINUX and conf.get('HAVE_PIDFD_OPEN').to_string() == '1'
   exe = executable(
     'waitpid',
     waitpid_sources,
@@ -2890,7 +2946,7 @@ endif
 syscalls_h = custom_target('syscalls.h',
   input : 'tools/all_syscalls',
   output : 'syscalls.h',
-  command : ['bash', '@INPUT@', cc.cmd_array()],
+  command : ['tools/all_syscalls', cc.cmd_array()] 
 )
 
 if cc.compiles(fs.read('include/audit-arch.h'), name : 'has AUDIT_ARCH_NATIVE')
@@ -2978,7 +3034,8 @@ exe = executable(
   'lib/ttyutils.c',
   c_args : ['-DTEST_PROGRAM_TTYUTILS'],
   include_directories : dir_include,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -2986,7 +3043,8 @@ exe = executable(
   'lib/blkdev.c',
   c_args : ['-DTEST_PROGRAM_BLKDEV'],
   include_directories : dir_include,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -2994,21 +3052,24 @@ exe = executable(
   'lib/ismounted.c',
   c_args : ['-DTEST_PROGRAM_ISMOUNTED'],
   include_directories : dir_include,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_mangle',
   'lib/mangle.c',
   c_args : ['-DTEST_PROGRAM_MANGLE'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_strutils',
   'lib/strutils.c',
   c_args : ['-DTEST_PROGRAM_STRUTILS'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -3017,23 +3078,27 @@ exe = executable(
   'lib/color-names.c',
   c_args : ['-DTEST_PROGRAM_COLORS'],
   include_directories : dir_include,
-  link_with : [lib_common, lib_tcolors])
+  link_with : [lib_common, lib_tcolors],
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_randutils',
   'lib/randutils.c',
   c_args : ['-DTEST_PROGRAM_RANDUTILS'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
-if conf.get('HAVE_OPENAT') != false and conf.get('HAVE_DIRFD') != false
+if conf.get('HAVE_OPENAT').to_string() == '1' \
+   and conf.get('HAVE_DIRFD').to_string() == '1'
   exe = executable(
     'test_procfs',
     'lib/procfs.c',
     c_args : ['-DTEST_PROGRAM_PROCFS'],
     include_directories : dir_include,
-    link_with : lib_common)
+    link_with : lib_common,
+    build_by_default: program_tests)
   exes += exe
 
   exe = executable(
@@ -3043,11 +3108,12 @@ if conf.get('HAVE_OPENAT') != false and conf.get('HAVE_DIRFD') != false
     have_cpu_set_t ? 'lib/cpuset.c' : [],
     c_args : ['-DTEST_PROGRAM_PATH'],
     include_directories : dir_include,
-    link_with : lib_common)
+    link_with : lib_common,
+    build_by_default: program_tests)
   exes += exe
 endif
 
-if conf.get('HAVE_PTY') != false
+if conf.get('HAVE_PTY').to_string() == '1'
   exe = executable(
     'test_pty',
     pty_session_c,
@@ -3057,7 +3123,8 @@ if conf.get('HAVE_PTY') != false
     link_with : [lib_common],
     dependencies : [lib_m,
                     realtime_libs,
-                    lib_util])
+                    lib_util],
+    build_by_default: program_tests)
   exes += exe
 endif
 
@@ -3066,7 +3133,8 @@ if LINUX
     'test_cpuset',
     'lib/cpuset.c',
     c_args : ['-DTEST_PROGRAM_CPUSET'],
-    include_directories : dir_include)
+    include_directories : dir_include,
+    build_by_default: program_tests)
   exes += exe
 endif
 
@@ -3079,35 +3147,40 @@ exe = executable(
   'lib/fileutils.c',
   have_cpu_set_t ? 'lib/cpuset.c' : [],
   c_args : ['-DTEST_PROGRAM_SYSFS'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_pager',
   'lib/pager.c',
   c_args : ['-DTEST_PROGRAM_PAGER'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_linux_version',
   'lib/linux_version.c',
   c_args : ['-DTEST_PROGRAM_LINUXVERSION'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_fileutils',
   'lib/fileutils.c',
   c_args : ['-DTEST_PROGRAM_FILEUTILS'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_canonicalize',
   'lib/canonicalize.c',
   c_args : ['-DTEST_PROGRAM_CANONICALIZE'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -3115,7 +3188,8 @@ exe = executable(
   'lib/timeutils.c',
   'lib/strutils.c',
   c_args : ['-DTEST_PROGRAM_TIMEUTILS'],
-  include_directories : dir_include)
+  include_directories : dir_include,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -3123,7 +3197,8 @@ exe = executable(
   'lib/pwdutils.c',
   c_args : ['-DTEST_PROGRAM'],
   include_directories : dir_include,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -3131,7 +3206,8 @@ exe = executable(
   'lib/logindefs.c',
   c_args : ['-DTEST_PROGRAM'],
   include_directories : dir_include,
-  link_with : [lib_common, logindefs_c])
+  link_with : [lib_common, logindefs_c],
+  build_by_default: program_tests)
 exes += exe
 
 
@@ -3142,15 +3218,15 @@ exe = executable(
   'libuuid/src/test_uuid.c',
   include_directories : [dir_include, dir_libuuid],
   link_with : lib_uuid,
-  dependencies : socket_libs)
+  dependencies : socket_libs,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
 
 ############################################################
 
-libfdisk_tests_cflags = ['-DTEST_PROGRAM',
-                         '-Wno-unused']
+libfdisk_tests_cflags = ['-DTEST_PROGRAM']
 libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid, lib_blkid]
 
 exe = executable(
@@ -3158,7 +3234,8 @@ exe = executable(
   'libfdisk/src/ask.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -3168,7 +3245,8 @@ exe = executable(
   'libfdisk/src/gpt.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -3178,7 +3256,8 @@ exe = executable(
   'libfdisk/src/utils.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -3188,7 +3267,8 @@ exe = executable(
   'libfdisk/src/script.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -3198,7 +3278,8 @@ exe = executable(
   'libfdisk/src/version.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
@@ -3208,18 +3289,17 @@ exe = executable(
   'libfdisk/src/item.c',
   c_args : libfdisk_tests_cflags,
   include_directories : lib_fdisk_includes,
-  link_with : libfdisk_tests_ldadd)
+  link_with : libfdisk_tests_ldadd,
+  build_by_default: program_tests)
 if not is_disabler(exe)
   exes += exe
 endif
 
-sample_fdisk_cflags = ['-Wno-unused']
 sample_fdisk_ldadd = [lib_common, lib_fdisk]
 
 exe = executable(
   'sample-fdisk-mkpart',
   'libfdisk/samples/mkpart.c',
-  c_args : sample_fdisk_cflags,
   include_directories : lib_fdisk_includes,
   link_with : sample_fdisk_ldadd)
 if not is_disabler(exe)
@@ -3229,7 +3309,6 @@ endif
 exe = executable(
   'sample-fdisk-mkpart-fullspec',
   'libfdisk/samples/mkpart-fullspec.c',
-  c_args : sample_fdisk_cflags,
   include_directories : lib_fdisk_includes,
   link_with : sample_fdisk_ldadd)
 if not is_disabler(exe)
@@ -3238,62 +3317,81 @@ endif
 
 ############################################################
 
+exe = executable(
+  'test_cap',
+  'tests/helpers/test_cap.c',
+  include_directories : includes,
+  dependencies : [lib_cap_ng],
+  build_by_default: program_tests)
+if not is_disabler(exe)
+  exes += exe
+endif
+
 exe = executable(
   'test_mbsencode',
   'tests/helpers/test_mbsencode.c',
   include_directories : includes,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_byteswap',
   'tests/helpers/test_byteswap.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_md5',
   'tests/helpers/test_md5.c',
   md5_c,
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_sha1',
   'tests/helpers/test_sha1.c',
   sha1_c,
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_pathnames',
   'tests/helpers/test_pathnames.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_strerror',
   'tests/helpers/test_strerror.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_sysinfo',
   'tests/helpers/test_sysinfo.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_sigreceive',
   'tests/helpers/test_sigreceive.c',
   include_directories : includes,
-  link_with : lib_common)
+  link_with : lib_common,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
   'test_tiocsti',
   'tests/helpers/test_tiocsti.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 exe = executable(
@@ -3302,35 +3400,38 @@ exe = executable(
   predefined_c,
   unpack_c,
   unparse_c,
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
-mq_libs = []
-mq_libs += cc.find_library('rt', required : true)
-
 if LINUX
   exe = executable(
     'test_mkfds',
     'tests/helpers/test_mkfds.c',
+    'tests/helpers/test_mkfds.h',
+    'tests/helpers/test_mkfds_ppoll.c',
     include_directories : includes,
-    dependencies : mq_libs)
+    dependencies : mq_libs,
+    build_by_default: program_tests)
   exes += exe
 endif
 
 exe = executable(
   'test_enosys',
   'tests/helpers/test_enosys.c',
-  include_directories : includes)
+  include_directories : includes,
+  build_by_default: program_tests)
 exes += exe
 
 ############################################################
 
-if conf.get('HAVE_OPENAT') != false
+if conf.get('HAVE_OPENAT').to_string() == '1'
   exe = executable(
     'sample-scols-tree',
     'libsmartcols/samples/tree.c',
     include_directories : includes,
-    link_with : [lib_smartcols, lib_common])
+    link_with : [lib_smartcols, lib_common],
+    build_by_default: program_tests)
   if not is_disabler(exe)
     exes += exe
   endif