#Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=xf86-video-fbdev
pkgver=0.5.0
pkgrel=3
pkgdesc="X.org framebuffer video driver"
arch=(x86_64)
license=('custom')
url="https://xorg.freedesktop.org/"
depends=('glibc')
makedepends=('xorg-server-devel' 'X-ABI-VIDEODRV_VERSION=25.2') # git)
conflicts=('xorg-server<21.1.1' 'X-ABI-VIDEODRV_VERSION<25' 'X-ABI-VIDEODRV_VERSION>=26')
groups=('xorg-drivers')
source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2{,.sig}
        gcc8.diff)
sha256sums=('dcc3d85f378022180e437a9ec00a59b6cb7680ff79c40394d695060af2374699'
            'SKIP'
            '050db537aae39b6deb1b2531b0064d62e2725f92b6c5c8ee6ade32e73cd3d5e8')
validpgpkeys=('995ED5C8A6138EB0961F18474C09DD83CAAA50B2')

prepare() {
  cd $pkgname-$pkgver
  patch -Np0 -i ../gcc8.diff
}

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/,-z,now}

  ./configure --prefix=/usr
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

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


