# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gzip
pkgver=1.8
pkgrel=0
pkgdesc="A popular data compression program"
subpackages="$pkgname-doc"
url="https://www.gnu.org/software/gzip/"
arch="all"
license="GPL-2.0"
depends=
makedepends=
install=
source="http://ftp.gnu.org/gnu/gzip/gzip-$pkgver.tar.gz"

_builddir="$srcdir"/$pkgname-$pkgver
build() {
	cd "$_builddir"

	# avoid text relocation
	export DEFS="NO_ASM"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR=$pkgdir install

	rm -rf "$pkgdir"/usr/lib/charset.alias
	rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true

	mkdir -p "$pkgdir"/bin
	mv "$pkgdir"/usr/bin/gzip "$pkgdir"/usr/bin/gunzip "$pkgdir"/bin/
	ln -s /bin/gzip "$pkgdir"/usr/bin/gzip
	ln -s /bin/gunzip "$pkgdir"/usr/bin/gunzip

	# http://bugs.alpinelinux.org/issues/4011
	ln -sf /bin/gunzip "$pkgdir"/usr/bin/uncompress
}
md5sums="732553152814b22dc35aa0267df5286c  gzip-1.8.tar.gz"
sha256sums="1ff7aedb3d66a0d73f442f6261e4b3860df6fd6c94025c2cb31a202c9c60fe0e  gzip-1.8.tar.gz"
sha512sums="cedac265cfd243a6c9cc5ef824a91c489d875447aeed12ef020b7e05fec571525a6a440c7b5b9713a7e23bb76202106785158bd20e6522a227eb3571f13d7948  gzip-1.8.tar.gz"
