# Maintainer: David P. <megver83@parabola.nu>
# Maintainer (Arch): David Runge <dvzrv@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgname=libusb
pkgver=1.0.30
pkgrel=1
pkgrel+=.nonsystemd1
pkgdesc="Library that provides generic access to USB devices"
arch=(x86_64)
arch+=(i686 armv7h)
url="https://libusb.info/"
_url="https://github.com/libusb/libusb"
license=(LGPL-2.1-or-later)
depends=(glibc)
makedepends=(
  git
  udev
)
provides=(libusb-1.0.so)
source=(git+$_url.git#tag=v$pkgver)
sha512sums=('d21fae358ebef28a733d69af9c361b853a437295230d57fe662b1a57a46480e459d49de4147d8d3297066dcf54f9e28fde28311a50eeec53a7453b71ae8077c6')
b2sums=('5e5f8ae594acf3808fba8b0fc01e94317d16fb3d3f25b9b8484d30ca922a75b2c00441a94f49cd2b03aff53f73f46ba88f1f31f065cf7041cf8f968d48ad8869')

prepare() {
  cd $pkgname
  autoreconf -fiv
}

build() {
  cd $pkgname
  ./configure --prefix=/usr
  # prevent excessive overlinking due to libtool
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  make -k check -C $pkgname
}

package () {
  depends+=(
    libudev libudev.so
  )

  make DESTDIR="$pkgdir" install -C $pkgname
  install -vDm 644 $pkgname/{AUTHORS,ChangeLog,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}
