# SliTaz package receipt.

PACKED_SIZE="68.0K"
UNPACKED_SIZE="164.0K"
PACKAGE="ncurses"
VERSION="6.4"
CATEGORY="base-system"
SHORT_DESC="Library of functions to manage display on terminals."
MAINTAINER="pankso@slitaz.org"
LICENSE="MIT"
WEB_SITE="https://invisible-island.net/ncurses/"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL"

DEPENDS="libtic libtinfo ncurses-common"
BUILD_DEPENDS=""
SPLIT="libform libmenu libpanel libtic libtinfo ncurses-common \
	ncurses-dev ncurses-extra ncurses-man"

HOST_ARCH="i486 arm"

# @maintainer: Please update also: libform libmenu libpanel libtic libtinfo

current_version()
{
	wget -O - https://invisible-mirror.net/archives/ncurses/ 2>/dev/null | \
	sed '/ncurses-/!d;s|.*ncurses-||;s|.tar.*||' | sed '$!d'
}

# Rules to configure and make the package.
compile_rules()
{
	# Ncurses need an installed /usr/bin/tic which 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

	mkdir -p $DESTDIR/usr/lib/terminfo

# search string not in file (6.1)
#	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				\
		--with-build-cc="gcc -D_GNU_SOURCE"	\
		--with-termlib				\
		--with-ticlib				\
		--enable-pc-files			\
		$CONFIGURE_ARGS &&
	# 6.2
	sed -i '186s|TICDIR "!= |TICDIR " != |'		\
		misc/run_tic.sh &&
	make &&
	make install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
    mkdir -p $fs/lib
    cp -a $install/lib/libncurses.so*	$fs/lib
}
