# SliTaz package receipt.

# Boost is a set of two types of libraries. Most of them are just
# headers with inline functions, these are included in this package
# named libboost-dev. Some few set of libraries require build and 
# installation steps. These will be relocated and have their own two 
# packages : libboost-name and libboost-name-dev.

# We have to do it this way because of the underscores
# to get a package with the slitaz version numbering
PACKAGE="libboost-dev"
SOURCE="boost"
VERSION="1.45.0"
WGET_SOURCE="boost_1_45_0"

CATEGORY="development"
SHORT_DESC="Free peer-reviewed portable C++ source libraries."
MAINTAINER="chadi.elahmad@gmail.com"

TARBALL="$WGET_SOURCE.tar.bz2"
WEB_SITE="http://www.boost.org/"
WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL"

DEPENDS="gcc-lib-base"
BUILD_DEPENDS="python python-dev expat-dev expat zlib-dev bzip2-dev"
RELOCATE_LIBS="{ date_time filesystem graph iostreams \
	math program_options python regex serialization \
	signal system test thread tr1 wave }"


# Rules to configure and make the package.
# Uses boost:build building tool for the compilation:
#   Doesn't use DESTDIR.
#   Doesn't recognize the $CONFIGURE_ARGS, gives an error back
#   Have to add some params to get static libs compiled too
compile_rules()
{
	# Determine if TOOLPREFIX has been defined in tazwok.conf as it should
	if [ -z "$TOOLPREFIX" ] ; then
		# Provide a default TOOLPREFIX value
		TOOLPREFIX=i486-pc-linux-gnu-
	fi

	cd $src
	./bootstrap.sh \
		--prefix=$DESTDIR/usr \
		--exec-prefix=$DESTDIR/usr \
		--libdir=$DESTDIR/usr/lib \
		--includedir=$DESTDIR/usr/include \
		--without-icu &&
	EXPAT_INCLUDE=/usr/include \
	EXPAT_LIBPATH=/usr/lib \
	./bjam \
		--prefix=$DESTDIR/usr \
		--exec-prefix=$DESTDIR/usr \
		--libdir=$DESTDIR/usr/lib \
		--includedir=$DESTDIR/usr/include \
		--build-type=minimal \
		install
	
	# create the missing links to the shared libs
	cd $DESTDIR/usr/lib
	for i in `ls *-mt.so`; do
	   boost_tmp=`echo $i | sed s/-gcc.*-mt//g`
	   boost_tmp_mt=`echo $i | sed s/-gcc.*-mt/-mt/g`
	   ln -s $i $boost_tmp
	   ln -s $i $boost_tmp_mt
	done
	for i in `ls *-mt.a`; do
	   boost_tmp=`echo $i | sed s/-gcc.*-mt//g`
	   boost_tmp_mt=`echo $i | sed s/-gcc.*-mt/-mt/g`
	   ln -s $i $boost_tmp
	   ln -s $i $boost_tmp_mt
	done
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr
	cp -a $_pkg/usr/lib $fs/usr
	cp -a $_pkg/usr/include $fs/usr
	for i in $RELOCATE_LIBS; do
		rm -f $fs/usr/lib/*$i*
		rm -r -f $fs/usr/include/boost/*$i*
	done
}