#!/bin/bash
# Copyright (c) 2000-2015 Synology Inc. All rights reserved.

case ${MakeClean} in
	[Yy][Ee][Ss])
		rm -rf ncurses{,w}-build
		;;
esac

case ${CleanOnly} in
	[Yy][Ee][Ss])
		return
		;;
esac

mkdir ncurses{,w}-build

srcdir=$PWD

ncursesconfig=" \
	--exec-prefix=/usr \
	--with-fallbacks=vt102,vt100,linux,screen \
	--without-cxx \
	--without-ada \
	--without-manpages \
	--without-progs \
	--without-tests \
	--enable-static=yes \
	--with-normal \
	--disable-stripping \
	--without-debug \
	"

cd ${srcdir}/ncursesw-build
env	CC=${CC} LD=${LD} AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
	CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
	../configure ${ConfigOpt} \
		--prefix=/usr \
		--with-pkg-config=/usr/bin/pkg-config \
		${ncursesconfig} \
		--enable-pc-files \
		--enable-widec

make ${MAKE_FLAGS}

# libraries for external binary support
cd ${srcdir}/ncurses-build
env	CC=${CC} LD=${LD} AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
	CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
	../configure ${ConfigOpt} \
		--with-pkg-config=/usr/bin/pkg-config \
		${ncursesconfig}

make ${MAKE_FLAGS}
