# Template build file for 'chroot-bzip2'.
pkgname=chroot-bzip2
version=1.0.6
revision=1
wrksrc="bzip2-${version}"
homepage="http://www.bzip.org"
distfiles="http://www.bzip.org/$version/bzip2-$version.tar.gz"
short_desc="The bzip2 compression library"
license="BSD"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd
long_desc="
 bzip2 is a freely available, patent free, high-quality data compressor.
 It typically compresses files to within 10%% to 15%% of the best available
 techniques, whilst being around twice as fast at compression and six times
 faster at decompression.

 bzip2 compresses files using the Burrows-Wheeler block-sorting text
 compression algorithm, and Huffman coding. Compression is generally
 considerably better than that achieved by more conventional LZ77/LZ78-based
 compressors, and approaches the performance of the PPM family of statistical
 compressors.

 The archive file format of bzip2 (.bz2) is incompatible with that of its
 predecessor, bzip (.bz).

 This package is only meant to be used by xbps-src, don't install it manually."

noverifyrdeps=yes
bootstrap=yes
provides="bzip2-${version} bzip2-devel-${version}"
conflicts="bzip2>=0"

do_build() {
	# Add large-file support
	sed -e 's/^CFLAGS=\(.*\)$/CFLAGS=\1 \$(BIGFILES)/' -i Makefile-libbz2_so

	# use our optimization
	sed -i "s|-O2|${CFLAGS}|g" Makefile
	sed -i "s|-O2|${CFLAGS}|g" Makefile-libbz2_so

	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
}
