#!/bin/sh
# (C) Raphael Langerhorst, August 2004
# see file LICENSE.BSD for the license

checkreturn()
{
retvalue=$1
if [ ! $retvalue -eq 0 ]
then
  echo ""
  echo "Operation failed with error code $retvalue,"
  echo "please take a look at the output to see what went wrong."
  echo ""
  echo "If the problem persists, try \"./scripts/cleancompile\"."
  echo ""
  exit $retvalue
fi
}

echo ""
echo "This script does a normal compilation, if it fails, try ./scripts/cleancompile"
echo ""
sleep 1

# let's see if we can set KDEDIR with kde-config --prefix
if [ -z $KDEDIR ]
then
  echo "KDEDIR environment variable not set, using kde-config."
  which kde-config > /dev/null 2>&1
  if [ $? -eq 0 ]
  then
    KDEDIR=`kde-config --prefix`
  else
    echo "kde-config could not be found!"
  fi
fi

if [ -z $KDEDIR ]
then
  echo "Warning: KDEDIR environment variable not set!"
else
  echo "KDEDIR set to $KDEDIR"
fi

export KDEDIR

if [ -e Makefile ]
then
  echo "Makefile exists."
else
  echo "No Makefile present, proceeding with Makefile generation."
  qmake
  checkreturn $?
fi

echo ""
echo "Starting build process with \"make\"."
echo ""

make
checkreturn $?

echo ""
echo "Compilation finished!"
echo "In order to install G System, type \"./scripts/makeinstall\"."
echo "You might need super user privileges for installation,"
echo "type \"su\" to switch to the root user."
echo "Don't forget to exit from the root shell after installing."
echo ""
echo "Please report bugs or comments to the mailing list or forum."
echo ""
echo "Take a look at the README file to find out how to use the G System."
echo ""
echo "ENJOY!!"
echo ""


syntax highlighted by Code2HTML, v. 0.9.1