#! /bin/sh

# $Id: timebuild,v 1.1 2002/05/28 04:17:45 mbp Exp $

# Test building a GNU-style program in the current directory, writing
# output to $1.  Try various compile options etc

if [ -z "$DISTCC_HOSTS" ]
then
    echo "DISTCC_HOSTS not defined" >&2 
    exit 1
fi

if [ -z "$1" ]
then
    echo "usage: timebuild OUTFILE" >&2 
    exit 1
fi

OUTFILE="$1"
> $OUTFILE

for opt in '-pipe' ''
do
    for parallel in '-j3' '' '-j6'
    do
	for compiler in 'distcc gcc' 'gcc'
	do
	    echo "building in `pwd`, compiler='$compiler', opt='$opt', parallel='$parallel'" >> $OUTFILE
	    [ -f Makefile ] && make distclean
	    export CC="$compiler"
	    export CFLAGS="$opt"
	    echo "running configure" >> $OUTFILE
	    /usr/bin/time --append -o $OUTFILE ./configure || exit 2
	    make proto
	    echo "compiling" >> $OUTFILE
	    /usr/bin/time --append -o $OUTFILE make $parallel || exit 2
	done
    done
done

