# Maintainer: Dinosaur <ancient dash dinosaurus at proton dot me>
# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

_pkgname=xf86-video-sisusb
pkgname=$_pkgname-enhanced
pkgver=0.9.7
pkgrel=6
pkgdesc="X.org SiS USB video driver - enhanced"
arch=(x86_64)
url="https://xorg.freedesktop.org/"
license=('BSD-3-Clause')
depends=('glibc')
makedepends=('xorg-server-devel-enhanced' 'X-ABI-VIDEODRV_VERSION=28.0')
conflicts=('xorg-server<26.0.0.901' 'X-ABI-VIDEODRV_VERSION<28' 'X-ABI-VIDEODRV_VERSION>=29' "${_pkgname}")
provides=("${_pkgname}")
source=(${url}/releases/individual/driver/${_pkgname}-${pkgver}.tar.bz2)
sha256sums=('f4400416b920cd1136d60d36b99d33f245cdeaf2ad6c1340936c7c0987761424')

prepare() {
  cd ${_pkgname}-${pkgver}
  autoreconf -vfi  
}

build() {
  cd ${_pkgname}-${pkgver}

  # Since pacman 5.0.2-2, hardened flags are now enabled in makepkg.conf
  # With them, module fail to load with undefined symbol.
  # See https://bugs.archlinux.org/task/55102 / https://bugs.archlinux.org/task/54845
  export CFLAGS=${CFLAGS/-fno-plt}
  export CXXFLAGS=${CXXFLAGS/-fno-plt}
  export LDFLAGS=${LDFLAGS/-Wl,-z,now}

  ./configure --prefix=/usr
  make
}

package() {
  cd ${_pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -m755 -d "${pkgdir}/usr/share/licenses/${_pkgname}"
  install -m644 COPYING "${pkgdir}/usr/share/licenses/${_pkgname}/"
}
