#!/bin/sh

# small backdoor for me :-)
if [ "$LOGNAME" = kraxel -a `hostname` = felix.intern ]; then
  ./configure --prefix=/usr --with-gimp=/usr/src/gimp/plug-ins && make
  exit
fi

########################################################################
# find out system name

SYSTEM=""

# try uname
UNAME=`which uname 2>/dev/null`
if test "$UNAME" != "" -a -f "$UNAME" ; then
    SYSTEM=`$UNAME -m|tr 'A-Z' 'a-z'`'-'`$UNAME -s|tr 'A-Z' 'a-z'`
fi

# anything else
if test "$SYSTEM" = ""; then SYSTEM="unknown"; fi

#########################################################################
# build in a subdirectory

echo
echo "system is $SYSTEM, compiling in "`pwd`"/$SYSTEM"
echo
test -d $SYSTEM || mkdir $SYSTEM
cd $SYSTEM
if test ! -f config.h; then
    ../configure 
fi
if tail -n1 Makefile | grep 'make depend' > /dev/null; then
    make depend
fi
make && echo "build successful" && exit 0
echo "build failed" && exit 1
