# This is a semi-automatic script for building the binary packages.
# It is designed to be run on Cygwin,
# but it should run fine on Linux and other GNU environments.

set -x

ARCHIVES_DIR="/cygdrive/i/Compilations GNU/Sources GCC/unzip"
BUILD_DIR=$HOME/compil
INSTALL_DIR=/usr
PACKAGENAME=unzip
VERSION=-6.0
VERSION2=`echo $VERSION |tr -d '.-'`
VERSIONPATCH=
VERSIONBIN=-bin-mintv4e
VERSIONBUILD=-`date +%Y%m%d`

cd $BUILD_DIR
tar zxvf "$ARCHIVES_DIR/$PACKAGENAME$VERSION2.tar.gz"

cd $PACKAGENAME$VERSION2

sed -i "s:CFLAGS_OPT='-O3':CFLAGS_OPT='-O3 -fomit-frame-pointer':g" unix/configure
make -f unix/Makefile generic CC='m68k-atari-mint-gcc -mcpu=5475' CF='$(CFLAGS) $(CF_NOOPT) -fomit-frame-pointer'

make -f unix/Makefile install prefix=$PWD/binary-package$INSTALL_DIR MANDIR='$(prefix)/share/man/man$(manext)' INSTALL=install INSTALL_D="install -d"
cd binary-package
gzip -9 ${INSTALL_DIR#/}/share/man/*/*

tar --owner=0 --group=0 -jcvf $PACKAGENAME$VERSION$VERSIONPATCH$VERSIONBIN$VERSIONBUILD.tar.bz2 ${INSTALL_DIR#/}
