# Template build file for 'bzip2'.
pkgname=bzip2
version=1.0.6
revision=6
homepage="http://www.bzip.org"
distfiles="http://www.bzip.org/$version/$pkgname-$version.tar.gz"
short_desc="The bzip2 compression library"
license="BSD"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd

do_build() {
	make ${makejobs} -f Makefile-libbz2_so
	make ${makejobs} bzip2recover libbz2.a
}

do_install() {
	vinstall bzip2-shared 755 usr/bin bzip2
	vinstall bzip2recover 755 usr/bin
	ln -sf bzip2 ${DESTDIR}/usr/bin/bunzip2
	ln -sf bzip2 ${DESTDIR}/usr/bin/bzcat
	install -m755 bzdiff bzgrep bzmore ${DESTDIR}/usr/bin

	vinstall libbz2.so.${version} 755 usr/lib
	ln -s libbz2.so.${version} ${DESTDIR}/usr/lib/libbz2.so
	ln -s libbz2.so.${version} ${DESTDIR}/usr/lib/libbz2.so.1
	ln -s libbz2.so.${version} ${DESTDIR}/usr/lib/libbz2.so.1.0

	vinstall libbz2.a 644 usr/lib
	vinstall bzlib.h 644 usr/include

	vinstall bzip2.1 644 usr/share/man/man1
	ln -sf bzip2.1 ${DESTDIR}/usr/share/man/man1/bunzip2.1
	ln -sf bzip2.1 ${DESTDIR}/usr/share/man/man1/bzcat.1
	ln -sf bzip2.1 ${DESTDIR}/usr/share/man/man1/bzip2recover.1

	vinstall LICENSE 644 usr/share/licenses/bzip2
}

bzip2-devel_package() {
	depends="bzip2>=${version}"
	short_desc+=" -- development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
	}
}

bzip2_package() {
	conflicts="chroot-bzip2>=0"
	pkg_install() {
		vmove usr
	}
}