#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgbase=zlib
pkgname=(zlib minizip)
epoch=1
pkgver=1.2.13
pkgrel=03
url="https://www.zlib.net/"
depends=('glibc')
makedepends=('automake' 'autoconf')
options=('staticlibs')  # needed by binutils testsuite
#options=('staticlibs' 'debug')   ## uncomment this to have the debug pkg produced
source=("https://zlib.net/zlib-${pkgver}.tar.gz"{,.asc})

prepare() {
  cd $pkgbase-$pkgver/contrib/minizip
  cp Makefile Makefile.orig
  cp ../README.contrib readme.txt
  autoreconf -fiv

}

build() {
  cd $pkgbase-$pkgver
  CFLAGS+=" -ffat-lto-objects"
  ./configure --prefix=/usr
  make

  cd contrib/minizip
  ./configure --prefix=/usr --enable-static=no
  make
}

check() {
  make test -C $pkgbase-$pkgver
  make -f Makefile.orig test -C $pkgbase-$pkgver/contrib/minizip
}

package_zlib() {
  pkgdesc='Compression library implementing the deflate compression method found in gzip and PKZIP'
  provides=('libz.so')
  make install DESTDIR="${pkgdir}" -C $pkgbase-$pkgver
  install -D -m644 $pkgbase-$pkgver/LICENSE -t "${pkgdir}/usr/share/licenses/$pkgname/"
}

package_minizip() {
  pkgdesc='Mini zip and unzip based on zlib'
  depends=('zlib')
  make install DESTDIR="${pkgdir}" -C $pkgbase-$pkgver/contrib/$pkgname
  install -D -m644 $pkgbase-$pkgver/LICENSE -t "${pkgdir}/usr/share/licenses/$pkgname/"
  # https://github.com/madler/zlib/pull/229
  rm "${pkgdir}/usr/include/minizip/crypt.h"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('custom')

validpgpkeys=('5ED46A6721D365587791E2AA783FCD8E58BCAFBA')

sha256sums=(b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30  # zlib-1.2.13.tar.gz
	1263ec60e148a1cf8de3894418df79a6c8bc95f211af92731da0f04170f8b0ac) # zlib-1.2.13.tar.gz.asc

##  e46172298b68e56b19b38cdfb57187b0e6690d00033297fe3c710e175e9ab6ec  minizip-1:1.2.13-03-x86_64.pkg.tar.lz
##  69cb255bc9ae0a31ea470a95371b25afb957bf97d4c874916ef93b386a24e827  zlib-1:1.2.13-03-x86_64.pkg.tar.lz

