# Maintainer: Eric Belanger <eric@archlinux.org>

pkgname=pingus
pkgver=0.7.6
pkgrel=29
pkgdesc="A Lemmings clone, i.e. a level-based puzzle game."
arch=('x86_64')
url="https://pingus.seul.org"
license=('GPL')
depends=('sdl_image' 'sdl_mixer' 'libgl')
makedepends=('scons' 'boost' 'mesa' 'glu')
source=("$pkgname-$pkgver.tgz::https://github.com/Pingus/pingus/archive/v$pkgver.tar.gz"
        'pingus.desktop'
        'pingus-0.7.6-gcc470-udl.patch'
        'missing-header.patch'
        'pingus-boost-1.69.patch'
         scons-python3.patch
         gcc-13.patch)
sha512sums=('ea0e7fd2cc1f6c23e62e222dffa1eb4764313ccecd716083c516fa4720c19562c9940da1dae4cbc527b85de9c0094f482e4f907212226b39ad044222b477769b'
            '6c2a8da1bcb250217c47d70ad223c02cf12879bab201433e76bf98f5693886ab0d96da295a795bfefe1723596011d41ff615c2262a277414234b88c8e35c64c8'
            'a6d541fc8417e49540f7760d707652d348ff46701e0d9d3df0463b1dfaca9c9781686ac1683b49bceebaca22cd9680652aaf1a65f3834f4e01cca41a002408ce'
            'd2e04c4291c18f1b9d351137bd2143881f4bb5591baeb3c5866b05cbf06db7e6552aac6d00d1ac055e8624bfa4b312e3f5a58d7f29ceefd0dcf0c32ed24e7971'
            '31b0c3a3c309d9f25558ab49ebffc9e9f75acf804c84374ac455476017d0ba280a73f0e347fd7b9304264ca532e3992cae841b1b0c62fd0b9eb49e7d0eb4a738'
            '47af4a5b46ccb1ede6b87bd46d62d115beb42461e0cfdb476f8bf002f83fd659f0e6fdcce56acb6a551f842e6f895ec70149da1f9d2569c02033a0a05d2aa21e'
            'dc3f3f4f5a735aa2979a977c8113ad369679f6879de114a7da9ab6e57fb44dc1d15bcc62992a21ea4485208be972ea675c0fce738921952c1571f3d79d4de5c6')

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

  # fedora patch to fix error due to new standards
  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51282
  patch -Np0 -i "${srcdir}"/pingus-0.7.6-gcc470-udl.patch
  # manpage must be in man6, not man1
  sed -i "s#/man1/#/man6/#g" Makefile
  # missing header
  patch -Np1 -i ../missing-header.patch
  # fix build with boost 1.69
  patch -p0 -i ../pingus-boost-1.69.patch
  # fix build with python3-scons
  patch -p1 -i ../scons-python3.patch
  # fix build with GCC 13
  patch -p1 -i ../gcc-13.patch

  scons prefix=/usr
}

package() {
  cd ${pkgname}-${pkgver}

  make install DESTDIR="${pkgdir}" PREFIX="/usr"

  install -D -m644 "${srcdir}"/pingus.desktop "${pkgdir}"/usr/share/applications/pingus.desktop
}
