#!/bin/sh
file=config.tmp
read c1 < ./.1
read c2 < ./.2
read c5 < ./.5
read c6 < ./.6
read c7 < ./.7

if [ -f ./sacdrt_term/Makefile ]; then
  /bin/rm ./sacdrt_term/Makefile
fi

echo "SACDRT V3.0 Configuration: "
echo "please tell us the following things"

echo "###############################################################################" >  $file
echo "#                                                                             #" >> $file
echo "#                          Makefile for SACDRT                                #" >> $file
echo "#                                                                             #" >> $file
echo "#  vdmeer@cs.tu-berlin.de                                                     #" >> $file
echo "###############################################################################" >> $file

echo "1. Where is the ncurses library installed?"
echo "   (default is: " $c1 ")"
read ans
if [ "$ans" != "" ]; then
  echo $ans > ./.1
  echo "NCURSES_LIB   = " $ans >> $file
else
  echo "NCURSES_LIB   = " $c1 >> $file
fi
echo ""

echo "2. Where are the includes for ncurses?"
echo "   (default is: " $c2 ")"
echo ""
read ans
if [ "$ans" != "" ]; then
  echo $ans > ./.2
  echo "NCURSES_INC   = " $ans >> $file
else
  echo "NCURSES_INC   = " $c2 >> $file
fi
echo ""

echo "No wx version included in this package"
echo "so question 3 and 4 will be not asked!"
echo ""

echo "5. Where should we install the sacdrt?"
echo "   (default is: " $c5 ")"
echo ""
read ans
if [ "$ans" != "" ]; then
  echo $ans > ./.5
  echo "INSTALLDIR    = " $ans >> $file
else
  echo "INSTALLDIR    = " $c5 >> $file
fi
echo ""

echo "6. Where do you wish to have the manpage copied?"
echo "   (default is: " $c6 ")"
echo ""
read ans
if [ "$ans" != "" ]; then
  echo $ans > ./.6
  echo "MANDIR        = " $ans >> $file
else
  echo "MANDIR        = " $c6 >> $file
fi
echo ""


echo "7. Which C-Compiler should we use?"
echo "   (default is: " $c7 ")"
echo ""
read ans
if [ "$ans" != "" ]; then
  echo $ans > ./.7
  echo "CC            = " $ans >> $file
else
  echo "CC            = " $c7 >> $file
fi
echo ""

echo "8. Is this a Linux system?"
echo "   (y|n)"
echo ""
read iflinux
echo ""

echo "9. Some additional CFLAGS?"
echo "   (leave it empty if not)"
read newcflags

if [ $iflinux = y ]; then
  echo "SACDRT_FLAGS  =  -O6 -ansi -Wall -m486 -DLINUX" $newcflags >> $file
else
  echo "SACDRT_FLAGS  =  -O6 -ansi -Wall" $newcflags >> $file
fi
echo ""

echo "10. Is terminfo compiled with ncurses data ?"
echo "    (when not we can't use ACS char's from ncurses, please see"
echo "     README for further information)"
echo "    (y|n)"
read termquest

if [ $termquest = y ]; then
  echo "TERMINFO_FLAG =  -DTERMINFO_COMPILED" >> $file
else
  echo "TERMINFO_FLAG ="  >> $file
fi
echo""


cat $file                     >> sacdrt_term/Makefile
cat sacdrt_term/Makefile.dist >> sacdrt_term/Makefile

/bin/rm $file
