#!/bin/bash

SCRIPTDIR=`dirname $0`

grep -l "TEST_BEGIN" *.cc > tmp

echo -n "TESTFILES="
while read LINE
do
		FILE=$LINE
		NAME=`echo $FILE | cut -d'.' -f1`
		TEST=test_$NAME
		echo -ne "$TEST "
done < tmp
echo ""
echo ""

while read LINE
do
		FILE=$LINE
		NAME=`echo $FILE | cut -d'.' -f1`
		DEPS=`cat $FILE | grep "deps:" | cut -d':' -f2`
		LIBS=`cat $FILE | grep "libs:" | cut -d':' -f2`
		CFLAGS=`cat $FILE | grep "cflags:" | cut -d':' -f2`
		TEST=test_$NAME
		echo "$TEST: $FILE $DEPS"
		echo -e "\t@${SCRIPTDIR}/test $FILE $DEPS $CFLAGS $LIBS"
		echo ""
done < tmp

rm -f tmp