#!/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 \
	--datadir=/usr/share \
	--without-cxx \
	--without-ada \
	--without-manpages \
	--without-tests \
	--with-shared \
	--with-normal \
	--without-debug \
	--disable-stripping \
	--program-transform-name= \
	"

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

make ${MAKE_FLAGS} SYNO_ENABLE_PROGS="yes"

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

make ${MAKE_FLAGS} SYNO_ENABLE_PROGS="yes"
