#!/bin/bash

# custom configure & build system.

# set some env variables and call configure.pl
BUILDDIR=`pwd`    # not yet used: call it locally!
cd `dirname $0`
SRCDIR=`pwd`


if [ $SRCDIR == $BUILDDIR ]; then
    BUILDDIR=$SRCDIR/build
    echo "Can't build in source dir $SRDCIR."
    echo "Will build in $BUILDDIR instead."
    mkdir -p $BUILDDIR
fi



LOG=$BUILDDIR/build.log

echo "source:  $SRCDIR"
echo "build:   $BUILDDIR"

export SRCDIR
export BUILDDIR

# gather some data
echo >>$LOG
echo -n "ecos configure -- " >>$LOG
date >>$LOG
echo >>$LOG

uname -a >>$LOG
echo >>$LOG

# Build starting point is a single Makefile.
rm -f $BUILDDIR/Makefile
ln -s $SRCDIR/project.mk $BUILDDIR/Makefile

# Build environment
touch $BUILDDIR/env.sh

# execute main configure script
exec perl $SRCDIR/bin/configure.pl $* 2>>$LOG


