# Obarun        : 66 init/supervisor
# Maintainer    : Eric Vidal <eric@obarun.org>
# Maintainer    : Jean-Michel T.Dydak <jean-michel@obarun.org>
# Maintainer    : YianIris <yianiris At disroot Dot org>
# Obarun PkgSrc : https://git.obarun.org/pkg/obextra/xf86-video-intel
#----------------
#--------------------------------------------------------------
# DESCRIPTION ]

pkgname=xf86-video-intel
pkgver=2.99.917+916+g31486f40
pkgrel=3
epoch=1
pkgdesc="X.org Intel i810/i830/i915/945G/G965+ video drivers"

url='https://01.org/linuxgraphics'

track=commit
target=31486f40f8e8f8923ca0799aea84b58799754564 # refs/heads/master

source=(
    git+https://anongit.freedesktop.org/git/xorg/driver/xf86-video-intel#$track=$target
)

#----------------------
# BUILD CONFIGURATION ]

makedepends=(
    'xorg-server-devel'
    'X-ABI-VIDEODRV_VERSION=25.2'
    'libx11'
    'libxrender'
    # additional deps for intel-virtual-output
    'libxrandr'
    'libxinerama'
    'libxcursor'
    'libxtst'
    'libxss'
    'libxv'
    # additional for git snapshot
    'git'
)

#------------------------
# INSTALL CONFIGURATION ]

depends=(
    'mesa'
    'libxvmc'
    'pixman'
    'xcb-util>=0.3.9'
)

optdepends=(
    'libxrandr: for intel-virtual-output'
    'libxinerama: for intel-virtual-output'
    'libxcursor: for intel-virtual-output'
    'libxtst: for intel-virtual-output'
    'libxss: for intel-virtual-output'
)

conflicts=(
    'xorg-server<21.1.1'
    'X-ABI-VIDEODRV_VERSION<25'
    'X-ABI-VIDEODRV_VERSION>=26'
    'xf86-video-intel-sna'
    'xf86-video-intel-uxa'
    'xf86-video-i810'
    'xf86-video-intel-legacy'
)

provides=(
    'xf86-video-intel-uxa'
    'xf86-video-intel-sna'
)

replaces=(
    'xf86-video-intel-uxa'
    'xf86-video-intel-sna'
)

groups=(
    'xorg-drivers'
)

install=$pkgname.install


#----------------
# BUILD PREPARE ]

pkgver() {
    cd $pkgname
    git describe --tags | sed 's/-/+/g'
}

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

#--------
# BUILD ]

build() {
    cd $pkgname

    ## 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 \
        --libexecdir=/usr/lib \
        --with-default-dri=3 \
        --enable-udev
    make
}

#--------
# CHECK ]

check() {
    cd $pkgname
    make check
}

#----------
# PACKAGE ]

package() {
    cd $pkgname

    make DESTDIR="$pkgdir" install

    install -m755 -d "$pkgdir/usr/share/licenses/$pkgname"
    install -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/"
}


#---------------------------
# LICENSE AND VERIFICATION ]

arch=(x86_64)
license=(custom)

sha512sums=(' ')
