# SliTaz package receipt.

PACKED_SIZE="132.0K"
UNPACKED_SIZE="412.0K"
PACKAGE="ncursesw"
VERSION="5.9"
SOURCE="ncurses"
CATEGORY="base-system"
SHORT_DESC="Library of functions to manage display on terminals."
MAINTAINER="pankso@slitaz.org"
LICENSE="MIT"
TARBALL="$SOURCE-$VERSION.tar.gz"
WEB_SITE="http://invisible-island.net/ncurses/"
WGET_URL="ftp://invisible-island.net/ncurses/$TARBALL"
HOST_ARCH="i486 arm"

DEPENDS="ncurses-common"
BUILD_DEPENDS="gcc"

case "$ARCH" in
	arm) BUILD_DEPENDS="" ;;
esac

# Rules to configure and make the package.
compile_rules()
{
	# Ncurses need an installed /usr/bin/tic witch is in ncursesw-extra. And
	# when cross compiling we can't use the freshly cooked binary. See cook log:
	#
	#** Building terminfo database, please wait...
	#Running /usr/bin/tic to install /home/slitaz/wok/ncurses/install/usr/share/terminfo
	#
	if [ ! -d "/var/lib/tazpkg/installed/ncursesw-extra" ]; then
		echo "Installing: ncursesw-extra"
		tazpkg get-install ncursesw-extra 2>/dev/null 1>/dev/null
	fi
	cd $src
	mkdir -p $DESTDIR/usr/lib/terminfo
	sed -i 's|\tsh $(srcdir)/MKhashsize.sh|\tash $(srcdir)/MKhashsize.sh|' \
		include/Makefile.in
	./configure \
		--libdir=/lib \
		--sysconfdir=/etc \
		--with-shared \
		--without-debug \
		--without-ada \
		--enable-widec \
		--with-build-cc="gcc -D_GNU_SOURCE" \
		$CONFIGURE_ARGS &&
	make && make install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/lib $fs/usr/bin

	# Libs.
	cp -a $install/lib/libncursesw.so* $fs/lib

	# Base progs.
	cp $install/usr/bin/clear $fs/usr/bin
	cp $install/usr/bin/tset $fs/usr/bin
	cp $install/usr/bin/reset $fs/usr/bin
}

# Overlap busybox
pre_install()
{
	rm -f $root/usr/bin/clear
	rm -f $root/usr/bin/reset
}

post_remove()
{
	ln -s /bin/busybox $root/usr/bin/clear
	ln -s /bin/busybox $root/usr/bin/reset
}
