#!/bin/sh
#
# This script is used to compile yabasic
#

# remove files, that might interfere
rm -f ./yabasic config.cache config.log config.status

# get version from yabasic.c
echo "---version from yabasic.c" >runme.log
grep "#define BASIC_VERSION" yabasic.c >>runme.log

# get host information
echo "---output of uname -a" >>runme.log
uname -a 2>&1 >>runme.log

# list current file
echo "---files in current directory" >>runme.log
ls -l >>runme.log

echo "---running configure ..." | tee -a runme.log
./configure >>runme.log 2>&1
# sucess ?
if [ $? -eq 0 ]
then 
  echo "---trying to make yabasic ..." | tee -a runme.log
  make >>runme.log 2>&1
  # sucess ?
  if [ $? -eq 0 ] 
  # sucess ?
  then
     echo "---success, you may now start yabasic !" \
	  | tee -a runme.log
  else
    echo "---sorry, could not make yabasic !" | tee -a runme.log
  fi
else
   echo "---configure failed, could not make yabasic" | tee -a runme.log
fi

# append config.log to runme.log
echo "---config.log:" >>runme.log
touch config.log
cat config.log >>runme.log

#delete config.log, config.status and config.cache
rm -f config.log config.status config.cache
