0db2ec12c5
This commit introduces a new PCI library and associated tools for inspecting and modifying PCI configuration space via Linux sysfs. The following changes were made: - Implemented `pci.c` and `pci.h` for PCI device management, including enumeration, attribute reading, and configuration space access. - Added `setpci` command-line utility for reading and writing PCI configuration registers, with support for filtering devices by vendor, device, and slot. - Created manual pages for `setpci` to document its usage and options. - Developed test scripts for both `lspci` and `setpci` to ensure functionality and correctness of the new features. These additions enhance the ability to interact with PCI devices, providing a robust framework for device management and configuration.
203 lines
4.4 KiB
Meson
203 lines
4.4 KiB
Meson
project('vx', 'c',
|
|
version : '0.1.0',
|
|
default_options : [
|
|
'c_std=c11',
|
|
'warning_level=2',
|
|
],
|
|
)
|
|
|
|
# --- Portability shim for building BSD userland on Linux ---
|
|
compat_inc = include_directories('src/compat-headers')
|
|
|
|
compat_src = files(
|
|
'src/compat-headers/fgetln.c',
|
|
'src/compat-headers/strlcpy.c',
|
|
'src/compat-headers/reallocf.c',
|
|
'src/compat-headers/strtonum.c',
|
|
'src/compat-headers/expand_number.c',
|
|
'src/compat-headers/strmode.c',
|
|
'src/compat-headers/ugid.c',
|
|
'src/compat-headers/setmode.c',
|
|
)
|
|
|
|
# Force-include compat.h before every translation unit so that
|
|
# _GNU_SOURCE and type shims are always available.
|
|
compat_args = ['-include', 'compat.h']
|
|
|
|
patch_src = files(
|
|
'src/patch/patch.c',
|
|
'src/patch/pch.c',
|
|
'src/patch/inp.c',
|
|
'src/patch/util.c',
|
|
'src/patch/backupfile.c',
|
|
'src/patch/mkpath.c',
|
|
)
|
|
|
|
diff_src = files(
|
|
'src/diff/diff.c',
|
|
'src/diff/diffdir.c',
|
|
'src/diff/diffreg.c',
|
|
'src/diff/pr.c',
|
|
'src/diff/xmalloc.c',
|
|
)
|
|
|
|
cmp_src = files(
|
|
'src/cmp/cmp.c',
|
|
'src/cmp/link.c',
|
|
'src/cmp/misc.c',
|
|
'src/cmp/regular.c',
|
|
'src/cmp/special.c',
|
|
)
|
|
|
|
diff3_src = files(
|
|
'src/diff3/diff3.c',
|
|
)
|
|
|
|
sdiff_src = files(
|
|
'src/sdiff/sdiff.c',
|
|
'src/sdiff/edit.c',
|
|
)
|
|
|
|
which_src = files(
|
|
'src/which/which.c',
|
|
)
|
|
|
|
gzip_src = files(
|
|
'src/gzip/gzip.c',
|
|
)
|
|
|
|
gzip_inc = include_directories('src/gzip')
|
|
|
|
grep_src = files(
|
|
'src/grep/grep.c',
|
|
'src/grep/file.c',
|
|
'src/grep/queue.c',
|
|
'src/grep/util.c',
|
|
)
|
|
|
|
grep_inc = include_directories('src/grep')
|
|
|
|
# --- yacc generator for find's getdate.y ---
|
|
yacc = find_program('yacc', 'bison')
|
|
getdate_gen = custom_target('getdate',
|
|
input : 'src/find/getdate.y',
|
|
output : 'getdate.c',
|
|
command : [yacc, '-o', '@OUTPUT@', '@INPUT@'],
|
|
)
|
|
|
|
find_src = files(
|
|
'src/find/find.c',
|
|
'src/find/function.c',
|
|
'src/find/ls.c',
|
|
'src/find/main.c',
|
|
'src/find/misc.c',
|
|
'src/find/operator.c',
|
|
'src/find/option.c',
|
|
)
|
|
|
|
find_inc = include_directories('src/find')
|
|
|
|
xargs_src = files(
|
|
'src/xargs/xargs.c',
|
|
'src/xargs/strnsubst.c',
|
|
)
|
|
|
|
xargs_inc = include_directories('src/xargs')
|
|
|
|
pci_src = files(
|
|
'src/pci/pci.c',
|
|
'src/pci/lspci.c',
|
|
'src/pci/setpci.c',
|
|
)
|
|
|
|
pci_inc = include_directories('src/pci')
|
|
|
|
gzip_defines = [
|
|
'-DNO_BZIP2_SUPPORT',
|
|
'-DNO_ZSTD_SUPPORT',
|
|
]
|
|
|
|
cc = meson.get_compiler('c')
|
|
libm = cc.find_library('m', required : false)
|
|
libz = dependency('zlib')
|
|
liblzma = dependency('liblzma')
|
|
libacl = cc.find_library('acl', required : true)
|
|
|
|
vx = executable('vx',
|
|
'src/main.c',
|
|
patch_src,
|
|
diff_src,
|
|
cmp_src,
|
|
diff3_src,
|
|
sdiff_src,
|
|
which_src,
|
|
gzip_src,
|
|
grep_src,
|
|
find_src,
|
|
getdate_gen,
|
|
xargs_src,
|
|
pci_src,
|
|
compat_src,
|
|
include_directories : [compat_inc, gzip_inc, grep_inc, find_inc, xargs_inc, pci_inc],
|
|
c_args : compat_args + gzip_defines,
|
|
dependencies : [libm, libz, liblzma, libacl],
|
|
install : true,
|
|
)
|
|
|
|
# Create symlinks for all applets pointing to the vx binary
|
|
bindir = get_option('bindir')
|
|
foreach name : ['patch', 'diff', 'cmp', 'diff3', 'sdiff', 'which', 'gzip', 'gunzip', 'zcat', 'uncompress', 'grep', 'egrep', 'fgrep', 'rgrep', 'find', 'xargs', 'lspci', 'setpci']
|
|
meson.add_install_script('sh', '-c',
|
|
'ln -sf vx "$MESON_INSTALL_DESTDIR_PREFIX/' + bindir + '/' + name + '"',
|
|
)
|
|
endforeach
|
|
|
|
# --- Manpages ---
|
|
install_man(
|
|
'src/patch/patch.1',
|
|
'src/diff/diff.1',
|
|
'src/cmp/cmp.1',
|
|
'src/diff3/diff3.1',
|
|
'src/sdiff/sdiff.1',
|
|
'src/which/which.1',
|
|
'src/gzip/gzip.1',
|
|
'src/gzip/gzexe.1',
|
|
'src/gzip/zdiff.1',
|
|
'src/gzip/zforce.1',
|
|
'src/gzip/zmore.1',
|
|
'src/gzip/znew.1',
|
|
'src/gzip/zgrep.1',
|
|
'src/grep/grep.1',
|
|
'src/find/find.1',
|
|
'src/xargs/xargs.1',
|
|
'src/pci/lspci.8',
|
|
'src/pci/setpci.8',
|
|
)
|
|
|
|
# --- Gzip shell script utilities ---
|
|
foreach s : ['zdiff', 'zforce', 'zmore', 'znew', 'gzexe', 'zgrep', 'zless']
|
|
install_data('src/gzip/' + s,
|
|
install_dir : get_option('bindir'),
|
|
install_mode : 'rwxr-xr-x',
|
|
)
|
|
endforeach
|
|
|
|
# Install symlinks for script aliases
|
|
foreach pair : [['zcmp', 'zdiff'], ['zegrep', 'zgrep'], ['zfgrep', 'zgrep']]
|
|
meson.add_install_script('sh', '-c',
|
|
'ln -sf ' + pair[1] + ' "$MESON_INSTALL_DESTDIR_PREFIX/' + bindir + '/' + pair[0] + '"',
|
|
)
|
|
endforeach
|
|
|
|
# --- Tests ---
|
|
test_env = environment()
|
|
test_env.set('VX', vx.full_path())
|
|
|
|
foreach t : ['test_patch', 'test_diff', 'test_cmp', 'test_diff3', 'test_sdiff', 'test_which', 'test_gzip', 'test_grep', 'test_find', 'test_xargs', 'test_lspci', 'test_setpci']
|
|
test(t, find_program('tests/' + t + '.sh'),
|
|
env : test_env,
|
|
depends : vx,
|
|
workdir : meson.project_source_root(),
|
|
)
|
|
endforeach
|