#!/bin/sh
# Compile/Install utility

DEFAULTFILE=config
TMP=/tmp/sast-reply

# get defaults if they exist
if [ -f $DEFAULTFILE ]; then
	source $DEFAULTFILE
else
	echo Cannot file configuration file $DEFAULTFILE, sorry.
	exit
fi

// toggle a variable between YES and NO
function toggle()
{
local RES=`echo echo \$\{$1\} > ${TMP} ; source ${TMP}`
rm -rf ${TMP}

if [ "$RES" = "NO" ]; then
	export ${1}=YES
else
	export ${1}=NO
fi

return
}

while [ 0 ]; do
   dialog --title "Sasteroids compile/installation utility" \
         --menu  "Note: This program doesn't do anything yet :-)" 17 74 9 \
	"Help"	    "What to do now" \
  	"Bin"       "Executable in   : $BINDIR" \
  	"Support"   "Support files in: $VARDIR" \
 	"Joystick"  "Joystick support: $JOYSTICK" \
	"Bitmaps"   "Compiled bitmaps: $COMPILE_BITMAPS" \
	"Backdrops" "Background Images: $BACKDROPS" \
	"Compile"   "Compile sasteroids $VERSION" \
	"Install"   "Install sasteroids $VERSION" \
	"Exit" "Exit" 2> ${TMP}

  if [ $? = 1 -o $? = 255 ]; then
   rm -f ${TMP}
   reset
   exit
  fi
  REPLY="`cat ${TMP}`"
  rm -f ${TMP}
  if [ "$REPLY" = "Exit" ]; then
   reset
   exit
  fi

  if [ "$REPLY" = "Joystick" ]; then
	toggle JOYSTICK
  fi

  if [ "$REPLY" = "Bitmaps" ]; then
	toggle COMPILE_BITMAPS
  fi

  if [ "$REPLY" = "Backdrops" ]; then
	toggle BACKDROPS
  fi
done
