# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Baptiste Daroussin <baptiste.daroussin@gmail.com>
# Contributor: Grigorios Bouzakis <grbzks[at]gmail[dot]com>
# Contributor: mightyjaym <jm.ambrosino@free.fr>

pkgname=giflib
pkgver=5.2.2
pkgrel=1.1
cross=(nf)
pkgdesc='Library for reading and writing gif images'
url='http://giflib.sourceforge.net/'
license=('MIT')
provides=('libgif.so')
ncxfab_makedepends=('glibc' 'xmlto' 'docbook-xml' 'docbook-xsl' 'base-devel')
source=(https://downloads.sourceforge.net/project/giflib/giflib-${pkgver}.tar.gz
        giflib-5.1.9-fix-missing-quantize-API-symbols.patch
        giflib-5.1.9-make-flags.patch
        giftext.patch)
sha512sums=('0865ab2b1904fa14640c655fdb14bb54244ad18a66e358565c00287875d00912343f9be8bfac7658cc0146200d626f7ec9160d7a339f20ba3be6b9941d73975f'
            '5de1e8724f5221fa3637b4e6a482f650f7608673e2c9200233290018ec8a0bf1beea049b3979b5f57dbf2b2a5fda409324e636e9af10582fd01c71d92d4de3b3'
            '8b8d6f483a18467bf6ad169fec04f9ef61534d3e25e1714d39231620142e64672dc336b347b02c8f74172b30e94b104edc83619b8e156ad18a4af521f65d1e31'
            'SKIP')
options=(!zipman)

prepare() {
  cd giflib-${pkgver}
  patch -Np1 < ../giflib-5.1.9-fix-missing-quantize-API-symbols.patch
  patch -Np1 < ../giflib-5.1.9-make-flags.patch
  patch -Np1 < ../giftext.patch
  sed -e 's|giflib.xml|giflib.7|' -re 's|doc/(.*).xml|doc/\1.1|g' -i Makefile # Install the actual man pages instead of the sources
  sed -e 's|$(MAKE) -C doc|$(MAKE) -C doc manpages|g' -i Makefile # Don't build the html pages
}

build() {
  cd giflib-${pkgver}
  make
}

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

package() {
  ncxfat_depends=('glibc')
  cd giflib-${pkgver}
  make PREFIX=$MPKG_USRPATH DESTDIR="${pkgdir}" install
# Fix giflib man page installation
  install -d "$pkgdir"$MPKG_USRPATH/share/man/man7
  mv "$pkgdir"$MPKG_USRPATH/share/man/man{1/giflib.7,7} 
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
