# Maintainer: PktSurf <smlinux@pktsurf.in>
app=pciutils
version=3.5.6
build=1sml
homepage="https://mj.ucw.cz/sw/pciutils/"
download="https://mj.ucw.cz/download/linux/pci/pciutils-$version.tar.gz"
desc="PCI bus library and tools"
requires="musl"

prepbuilddir() {
  compileonlyfor x86_64
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  applypatch $srcdir/pciutils-pread.patch
}

build() {
  make CFLAGS+=" -DHAVE_PREAD" \
    LDFLAGS="-llzma" \
    PREFIX="/" \
    SHARED=yes \
    SBINDIR="/bin" \
    DESTDIR="$pkg" \
    STRIP="" all install

  make CFLAGS+=" -DHAVE_PREAD" \
    LDFLAGS="-llzma" \
    PREFIX="/" \
    SHARED=yes \
    SBINDIR="/bin" \
    DESTDIR="$pkg" \
    STRIP="" install-lib

  sed -i '/^Libs:/d' $pkg/lib/pkgconfig/libpci.pc
  sed -i 's/^Libs.private:/Libs: -lpci /' $pkg/lib/pkgconfig/libpci.pc

  cp COPYING $pkgdocs/

  mkfinalpkg
}

sha512sums="
f8afe23b804e32fbc0c66f68e7525a16a23cbad3579aa0d7670eceeed1809ae3aed6f6efeadc68e9430e7f291150401596de24961a4767a5b071b37331b28ed8  pciutils-3.5.6.tar.lz
5e9c64a65f350c569fd6ab0d1d49adcd70519dc2c7c88ccdec33f22fd59f71e16c10103424897182db0e16fa6ebf2e21786cb49dede06cf71d49f5498c72e55a  pciutils-pread.patch
"
