#!/bin/sh
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

: ${CC:=gcc}
: ${CFLAGS:=-O2}

source ./ncurses.info

set -ex

rm -rf $PKGNAME-$PKGVERSION
tar xvaf $PKGNAME-$PKGVERSION.tar.gz
pushd $PKGNAME-$PKGVERSION

# wide version
mkdir wide-build && pushd wide-build
CC="$CC" CFLAGS="$CFLAGS" ../configure \
	--enable-pc-files \
	--enable-widec \
	--prefix=/usr \
	--without-ada \
	--with-pkg-config-libdir=/usr/lib/pkgconfig \
	--with-shared \
	--without-debug
make
make install DESTDIR=$DESTDIR
rm -f $DESTDIR/usr/lib/lib{menuw,ncursesw,panelw,formw}.a
popd

# normal version
mkdir normal-build && pushd normal-build
CC="$CC" CFLAGS="$CFLAGS" ../configure \
	--enable-pc-files \
	--prefix=/usr \
	--without-ada \
	--with-pkg-config-libdir=/usr/lib/pkgconfig \
	--with-shared \
	--without-debug
make
make install DESTDIR=$DESTDIR
rm -f $DESTDIR/usr/lib/lib{menu,ncurses,panel,form}.a
ln -sf libncurses.so $DESTDIR/usr/lib/libcurses.so
popd

popd
rm -rf $PKGNAME-$PKGVERSION
