#!/bin/bash

dsp_file=$1
bin_file=$2

if [ -z "$dsp_file" -o -z "$bin_file" ]; then
	echo "usage:"
	echo "	compile program.dsp program.bin"
	exit 1
fi

if [ ! -f $dsp_file ]; then
	echo "file $dsp_file not found"
	exit 1
fi

sed s/"dsp_file"/$dsp_file/ main.c > tmp.c
gcc tmp.c compiler.o -o tmp

./tmp $bin_file

rm -f tmp tmp.c

exit 0
