#!/bin/sh

. /etc/flenv

mkdir -p $flinstpath

targetdir=`find $srcpath -maxdepth 1 -type d -name bzip2-\*`
if [ -z "$targetdir" ] || [ ! -d "$targetdir" ]; then
	echo "ERROR: target source directory not found"
	exit 1
fi

pushd $targetdir

if [ ! -f Makefile.org ]; then
	cp Makefile Makefile.org
fi
sed -e '/chmod/d' Makefile.org > Makefile

make install PREFIX=$flinstpath \
|| { echo "ERROR: make failed" ; popd; exit 1 ; }

popd

echo "INFO: bzip2 is now installed"
