#!/bin/sh
rm -rf Dist
if [ $# -ge 1 ]; then
	ARCH=$1
else
	ARCH=x86
fi

if [ $# -ge 2 ]; then
	PLATFORM=$2
	PSUFFIX=-$2
else
	PLATFORM=default
	PSUFFIX=""
fi

mkdir -p Releases/
BUILD_DIST=y ARCH=$ARCH make clean all-install
while [ $# -ge 2 ]; do
	BUILD_DIST=y ARCH=$ARCH PLATFORM=$2 make
	shift
done
tar --transform="s|Dist/($ARCH/)*|Acess/|x" -zcf Releases/Acess2_latest_${ARCH}$PSUFFIX_bin.tar.gz Dist/$ARCH Dist/Acess2.$ARCH$PSUFFIX.gz
IMGNAME=AcessRelease.img
./Tools/BootFloppy/MakeDiskImage $IMGNAME
mcopy -i $IMGNAME -s Dist/$ARCH/ ::/Acess2
mcopy -i $IMGNAME Dist/Acess2.$ARCH$PSUFFIX.gz ::/Acess2/Acess2.gz
gzip -c AcessRelease.img > Releases/Acess2_latest_${ARCH}$PSUFFIX.img.gz
