#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=xf86-video-openchrome
_commit=0c752742e54fa34140386547947c81a832c9cad1 # master 2022-09-21 // v0.6.602
pkgver=0.6.0.r798.g0c75274
pkgrel=02
pkgdesc="X.Org Openchrome drivers"
url="https://www.freedesktop.org/wiki/Openchrome/"
depends=('libdrm' 'libxvmc')
makedepends=('xorg-server-devel' 'X-ABI-VIDEODRV_VERSION=25.2' 'libxv'
             'git')
conflicts=('xorg-server<21.1.1' 'X-ABI-VIDEODRV_VERSION<25' 'X-ABI-VIDEODRV_VERSION>=26'
           'xf86-video-via' 'xf86-video-unichrome' 'openchrome')
replaces=('openchrome' 'xf86-video-via')
groups=('xorg-drivers')
options=('!emptydirs')
#source=(https://xorg.freedesktop.org/archive/individual/driver/${pkgname}-${pkgver}.tar.bz2{,.sig})
#source=("git://anongit.freedesktop.org/openchrome/xf86-video-openchrome#commit=${_commit}")
source=("git+https://anongit.freedesktop.org/git/openchrome/xf86-video-openchrome#commit=${_commit}")

pkgver() {
  cd $pkgname
  #git describe --long | sed 's/-/+/g'
  git describe --long | sed 's/^xf86-video-openchrome-//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd $pkgname
  NOCONFIGURE=1 ./autogen.sh
}

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}/"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('custom')

validpgpkeys=(CDA92E38A7A7A82237E9AB61C922784178BFFDB0) # "Kevin Brace <kevinbrace@gmx.com>"

sha256sums=(SKIP)

##  13fd6b6223556321c152904877935034b5af41b244fcdfe9ad79940a1846c4bc  xf86-video-openchrome-0.6.0.r798.g0c75274-02-x86_64.pkg.tar.lz

