# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=sdl
pkgver=1.2.15+387+gfbfcca32
pkgrel=1
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard"
arch=('x86_64')
url="https://www.libsdl.org"
license=('LGPL')
depends=('glibc' 'libxext' 'libxrender' 'libx11')
makedepends=('alsa-lib' 'mesa' 'libpulse' 'glu' 'git')
optdepends=('alsa-lib: ALSA audio driver'
            'libpulse: PulseAudio audio driver')
options=('staticlibs')
_commit=fbfcca3277a5f13dd78f7d44ffe2dc65d4e2d048  # main
source=("git+https://github.com/libsdl-org/SDL-1.2#commit=$_commit"
        0001-SDL-1.2.15-no-default-backing-store.patch
        0002-x11-Bypass-SetGammaRamp-when-changing-gamma.patch
        0003-sdl-1.2.14-fix-mouse-clicking.patch
        0004-sdl-1.2.14-disable-mmx.patch)
sha256sums=('SKIP'
            'b242b28ab9b2d823d96f0939c6fb2fbaabb110b9e61be754f6cf502a34d57a2f'
            '0a5d00c1f75158b1838706a0733a51c8c1014983528bafb4a477327f7595e135'
            '70e339886440f94f03a320c4b8605a2704f3e3117aa9e998f32b0cebc3e4bc59'
            'a99bb91981e091bb01bbedf5138008ef16155c9a6b24349a771555c9bb57fdcd')
validpgpkeys=('1528635D8053A57F77D1E08630A59377A7763BE6') # Sam Lantinga <slouken@libsdl.org>

pkgver() {
  cd SDL-1.2
  git describe --tags | sed 's/^release-//;s/-/+/g'
}

prepare() {
  cd SDL-1.2

  git apply -3 ../0001-SDL-1.2.15-no-default-backing-store.patch

  # https://bugs.freedesktop.org/show_bug.cgi?id=27222
  git apply -3 ../0002-x11-Bypass-SetGammaRamp-when-changing-gamma.patch

  git apply -3 ../0003-sdl-1.2.14-fix-mouse-clicking.patch
  git apply -3 ../0004-sdl-1.2.14-disable-mmx.patch

  ./autogen.sh
}

build() {
  cd SDL-1.2
  ./configure --prefix=/usr --disable-nasm --enable-alsa \
              --with-x --disable-rpath --disable-static
  make
}

package() {
  cd SDL-1.2
  make DESTDIR="$pkgdir" install
}
