#!/bin/bash
# This code was written by Darren Hakimi and Keir Lauritzen

CARLC="./carlc"
CARL_ENGINE="carl_engine.o"
ARRAY_LIB="wrapper.o"
TMP_STALE="./stale"
TESTDIR="./tests"

if [ ! -d ./tmp ];
then
    mkdir ./tmp
fi

if [ ! -f $CARLC ] || [ ! -f $CARL_ENGINE ];
then
    ./buildcarl
fi

echo "#######  Testing $1";
clang -S -emit-llvm $1.c
llc $1.ll #Converts LLVM to assembly .s file
gcc -c $1.s -o $1.o

g++ -o $1.test $CARL_ENGINE $ARRAY_LIB $1.o
