# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=libpng
pkgver=1.6.44
pkgrel=1
pkgdesc='A collection of routines used to create PNG format graphics files'
arch=('x86_64')
url='http://www.libpng.org/pub/png/libpng.html'
license=('custom')
depends=('zlib' 'sh')
makedepends=('git')
provides=('libpng16.so')
source=("git+https://github.com/pnggroup/libpng.git?signed#tag=v${pkgver}")
sha256sums=('56d285e5bdc6a7ef5a46b987d62fc88b199cfdf1cb1dad19df10b361ef6613ce')
validpgpkeys=('F57A55036A4D45837074FD92C9E384533403C2F8') # Cosmin Truta

prepare() {
  cd $pkgname

  autoreconf -fiv
}

build() {
  cd $pkgname

  ./configure \
    --prefix=/usr \
    --disable-static
  make
}

check() {
  cd $pkgname

  make check
}

package() {
  cd $pkgname

  make DESTDIR="$pkgdir" install

  install -D -m0644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cd contrib/pngminus
  make PNGLIB_SHARED="-L$pkgdir/usr/lib -lpng" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" png2pnm pnm2png
  install -m0755 png2pnm pnm2png "$pkgdir/usr/bin/"
}
