PREFIX=/usr/local/OPEN_R_SDK
INSTALLDIR?=../MS
CXX=$(PREFIX)/bin/mipsel-linux-g++
STRIP=$(PREFIX)/bin/mipsel-linux-strip
MKBIN=$(PREFIX)/OPEN_R/bin/mkbin
STUBGEN=$(PREFIX)/OPEN_R/bin/stubgen2
MKBINFLAGS=-p $(PREFIX)
LIBS=-L$(PREFIX)/OPEN_R/lib -lObjectComm -lOPENR
CXXFLAGS= \
	-g \
	-O2 \
	-I. \
	-I$(PREFIX)/OPEN_R/include/R4000 \
	-I$(PREFIX)/OPEN_R/include \
	-I../common/include

#
# When OPENR_DEBUG is defined, OSYSDEBUG() is available.
#
#CXXFLAGS+= -DOPENR_DEBUG

.PHONY: all install clean

all: soundComm.bin

%.o: %.cc
	$(CXX) $(CXXFLAGS) $(DEFS) -o $@ -c $^

SoundCommStub.cc: stub.cfg
	$(STUBGEN) stub.cfg	

soundComm.bin: SoundCommStub.o SoundComm.o soundComm.ocf \
	PlaySound.o FFT.o \
	ProcessDTMF.o
# ProcessSound.o or ProcessDTMF.o
	$(MKBIN) $(MKBINFLAGS) -o $@ $^ $(LIBS)
	$(STRIP) $@

install: soundComm.bin
	gzip -c soundComm.bin > $(INSTALLDIR)/OPEN-R/MW/OBJS/SNDCOMM.BIN

clean:
	rm -f *.o *.bin *.elf *.snap.cc
	rm -f SoundCommStub.h SoundCommStub.cc def.h entry.h
	rm -f $(INSTALLDIR)/OPEN-R/MW/OBJS/SNDCOMM.BIN

