#!/bin/sh

CHAP=8
APPNAME=ncurses
VER=6.2
TARGET=$APPNAME-$VER
TARGETBALL=$TARGET.tar.gz
TARGETDIR=$TARGET

echo $TARGET

. ./_lfsset.sh

cd $SRC

echo \ \ Removing old directory...
rm -fr $TARGETDIR

. $WRK/_extract.sh

TimeStart

cd $TARGETDIR

sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in

echo \ \ Configuring...
./configure --prefix=/usr           \
            --mandir=/usr/share/man \
            --with-shared           \
            --without-debug         \
            --without-normal        \
            --enable-pc-files       \
            --enable-widec          \
	1> $LOG/$CHAP.$TARGET.1_conf.log 2>&1 || exit 1

echo \ \ Making...
make \
	1> $LOG/$CHAP.$TARGET.2_make.log 2>&1 || exit 1

echo \ \ Installing...
porg -lp  $TARGET -E`pwd` "make install" \
	1> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1

porg -lp+ $TARGET "\
mv -v /usr/lib/libncursesw.so.6* /lib" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1

porg -lp+ $TARGET "\
ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1

for lib in ncurses form panel menu ; do
    porg -lp+ $TARGET "\
    rm -f                     /usr/lib/lib${lib}.so" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1
    porg -lp+ $TARGET "\
    echo \"INPUT(-l${lib}w)\" > /usr/lib/lib${lib}.so" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1
    porg -lp+ $TARGET "\
    ln -sfv ${lib}w.pc        /usr/lib/pkgconfig/${lib}.pc" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1
done || exit 1

porg -lp+ $TARGET "\
rm -vf /usr/lib/libcursesw.so" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1
porg -lp+ $TARGET 'echo "INPUT(-lncursesw)" >/usr/lib/libcursesw.so' \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1
porg -lp+ $TARGET "ln -sfv libncurses.so /usr/lib/libcurses.so" \
	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1

#mkdir /usr/share/doc/ncurses-$VER
#porg -lp+ $TARGET "cp -v -R doc/* /usr/share/doc/ncurses-$VER" \
#	1>> $LOG/$CHAP.$TARGET.3_install.log 2>&1 || exit 1

TimeEnd chap8

echo \ \ Removing directory...
cd ..
rm -fr $TARGETDIR

echo -n \ \ Porging:\   && porg $TARGET || echo none

echo \ \ Done.
