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= \
	-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: effectorComm.bin

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

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

effectorComm.bin: EffectorCommStub.o EffectorComm.o Effector.o effectorComm.ocf
	$(MKBIN) $(MKBINFLAGS) -o $@ $^ $(LIBS)
	$(STRIP) $@

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

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