#!/bin/bash

dsp_file=$1
bin_file=$2

CFLAGS="-g -O2 -Wall"

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 $CFLAGS tmp.c compiler.o -o tmp

if [ -x ./tmp ] ; then
	./tmp $bin_file
	rm -f tmp tmp.c
fi

exit 0
