OPENRSDK_ROOT?=/usr/local/OPEN_R_SDK
CP=cp
INSTALLDIR=MS
STRIP=strip
MKBIN=g++
STUBGEN=$(OPENRSDK_ROOT)/RP_OPEN_R/bin/rp-openr-stubgen2
MKBINFLAGS=
OPENRCONFIG=$(OPENRSDK_ROOT)/RP_OPEN_R/bin/rp-openr-config
LIBS=`$(OPENRCONFIG) --libs`
CXXFLAGS= \
	-O2 \
	-g \
	-I. \
	-I.. \
	`$(OPENRCONFIG) --cflags`
OCF=

.PHONY: all install clean

all: remoteProcess.bin

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

RemoteProcessStub.cc: stub.cfg
	$(STUBGEN) $^

remoteProcess.bin: RemoteProcessStub.o RemoteProcess.o $(OCF)
	$(MKBIN) $(MKBINFLAGS) -o $@ $^ $(LIBS)
	$(STRIP) $@

install: remoteProcess.bin
	$(CP) $^ $(INSTALLDIR)/OPEN-R/MW/OBJS/RPROCESS.BIN

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