# Template file for 'ncurses32'
pkgname=ncurses32
version=5.7
distfiles="
http://xbps.nopcode.org/repos/stable/i686/ncurses-libs-${version}_1.i686.xbps
http://xbps.nopcode.org/repos/stable/i686/ncurses-devel-${version}_2.i686.xbps
http://xbps.nopcode.org/repos/stable/i686/ncursesw-${version}_1.i686.xbps
http://xbps.nopcode.org/repos/stable/i686/ncursesw-devel-${version}_1.i686.xbps"
build_style=custom-install
short_desc="A System V Release 4.0 curses emulation library (32 bits)"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum="
0470e12a72e923b8983a314b7f35c909ac3ec6c2ac8467d831d2cb24c506edd2
b0d842501144406ad3f5b761908070058d5467ca976534bbf39dfa8918859cb9
49a906ccec204c543db152e109a09e89d1aa0382c3c473dc791341a93f5aa36b
18777c0f140b3052099d5cae9a96628403322aa9af3b3d11241bb80b40d81603"
long_desc="
 The ncurses (new curses) library is a freeware emulation of System V Release
 4.0 curses. It uses terminfo format, supports pads and color and multiple
 highlights and forms characters and function-key mapping, and has all the
 other SYSV-curses enhancements over BSD curses. The distribution includes
 the library and support utilities, including a terminfo compiler tic, a 
 ecompiler infocmp, clear, tput, tset, and a termcap conversion tool captoinfo.
 Full manual pages are provided for the library and tools.

 This package installs the ncurses and ncursesw 32 bit libraries for
 x86_64 systems."

subpackages="$pkgname-devel"
nostrip=yes
noextract=yes
noverifyrdeps=yes
only_for_archs=x86_64

Add_dependency run glibc32
Add_dependency build bsdtar

do_install()
{
	for f in ${distfiles}; do
		local srcfile="${XBPS_SRCDISTDIR}/$(basename ${f})"
		bsdtar xf ${srcfile} -C ${wrksrc} || return 1
	done

	install -d ${DESTDIR}/lib32 ${DESTDIR}/usr/lib32
	cp -a ${wrksrc}/lib/*.so* ${DESTDIR}/lib32
	cp -a ${wrksrc}/usr/lib/*.{a,so*} ${DESTDIR}/usr/lib32
	mv ${DESTDIR}/usr/lib32/*.so.${version} ${DESTDIR}/lib32
	rm -f ${DESTDIR}/usr/lib32/*.so*
	# Remake the symlinks with proper path to /lib32.
	for f in panel panelw form formw menu menuw ncurses ncursesw; do
		cd ${DESTDIR}/usr/lib32 && \
			ln -sf ../../lib32/lib${f}.so.${version} lib${f}.so && \
			ln -sf ../../lib32/lib${f}.so.${version} lib${f}.so.5
	done
}
