### this file is sourced not run
PKGVER=1.0.6
PKGBUILD=1
PKGARCH=i686

TARBALL=bzip2-1.0.6.tar.gz
MD5SUM=00b516f4704d4a7cb50a1d97e6e8e15b
SRC_URL=http://distro.ibiblio.org/fatdog/source/710/clfs-packages-3.0.0.tar
BUNDLE=clfs-packages-3.0.0.tar

SLACKREQ=
SLACKDESC='bzip2_32: bzip2_32 1.0.6 (File compressor)  
bzip2_32:  
bzip2_32: This package contains programs for compressing and decompressing files 
bzip2_32: using BWT compression method. Compressing text files with bzip2 yields 
bzip2_32: a much better compression percentage than with the traditional gzip.  
bzip2_32: 
bzip2_32: This package contains the 32-bit library.
bzip2_32: 
bzip2_32: 
bzip2_32: 
bzip2_32:
'


### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### prepare 
pkg_prepare() {
	if pkg_prepare_default; then
		cd tmp/bzip2-1.0.6
		# LFs 7.5 docs related patches
		patch -Np1 -i $SRC_DIR/bzip2-1.0.6-install_docs-1.patch
		sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
		sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
	else
		return 1
	fi
}
### default pkg_package
### build
pkg_build() {
	cd /tmp/bzip2*
	
	# CLFS 3.0.0 relative symlink
	sed -i -e 's:ln -s -f $(PREFIX)/bin/:ln -s :' Makefile &&
	sed -i 's@X)/man@X)/share/man@g' ./Makefile && # manpage location patch

	make -f Makefile-libbz2_so CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" &&
	make clean &&
	make CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}" libbz2.a &&

	cp -v libbz2.a /usr/lib &&
	cp -av libbz2.so* /lib &&
	ln -sfv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so &&
	ln -sfv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so.1 &&
	
	pkg_build_slackdesc
}
