#!/bin/sh
#
# Generated by ./mkrelease

if [ ! -d Mem ]; then
  echo "$0: missing Mem application"
  exit 1
fi

echo "Compiling Mem 1.1.1"
if Mem/AppRun --compile; then
  echo Compiled
else
  echo "$0: Mem failed to compile!"
  exit 2
fi

echo "Where do you want to install it?"
echo "1) /usr/local/apps"
echo "2) $HOME/Apps"
read ans

case $ans in
  1) install=/usr/local/apps;;
  2) install=$HOME/Apps;;
  *) echo "Cancelling install"
     exit 0;;
esac

(cd Mem/src; make clean)
echo "Installing Mem in $install"
if [ ! -d $install ]; then
  mkdir -p $install
fi

if [ -f "$install/Mem" ]; then
  mv $install/Mem $install/Mem.old
fi

tar cf - Mem | ( cd $install ; tar xfp -)

if [ -f "$install/Mem.old" ]; then
  /bin/rm -rf $install/Mem.old
fi

