APP=pciutils
VERSION=3.5.6
BUILD=1sml
HOMEPAGE='https://mj.ucw.cz/sw/pciutils/'
DOWNLOAD='https://mj.ucw.cz/download/linux/pci/pciutils-3.5.6.tar.gz'
DESC="PCI bus library and tools"
REQUIRES="musl"

build() {
  compileonlyfor x86_64
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions

  patch -p1 < $SRCDIR/pciutils-pread.patch

  make CFLAGS="$CFLAGS -D_GNU_SOURCE -DHAVE_PREAD -fPIC" \
    LDFLAGS="-llzma" \
    PREFIX="/" \
    SHARED=yes \
    SBINDIR="/bin" \
    DESTDIR="$PKG" \
    STRIP="" all install

  make CFLAGS="-D_GNU_SOURCE -DHAVE_PREAD -fPIC" \
    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
"
