#-------------------------------------------------------------------------------

ALL  = mb.spin2cpp.c.log
ALL += mb.spin2cpp.cpp.log
ALL += mb.spin2pasm.cog.log
ALL += mb.spin2pasm.hub.log
ALL += mb.openspin.log

DEPS = Makefile FullDuplexSerial.spin

#-------------------------------------------------------------------------------

OPENSPIN = /opt/openspin/bin/openspin
SPIN2CPP = /opt/spin2cpp/bin/spin2cpp
SPINSIM  = /opt/spinsim/bin/spinsim
PARALLAX = /opt/parallax

export PATH := $(PARALLAX)/bin:$(PATH)

#-------------------------------------------------------------------------------
all: $(ALL)
	awk -F: '/ticks/ { printf "%20s ... %s\n",$$0,FILENAME | "sort -n" }' $(ALL)

%.spin2cpp.c.binary: %.spin $(DEPS)
	$(SPIN2CPP) --ccode --binary -Dcogstop0 -o $@ $<

%.spin2cpp.cpp.binary: %.spin $(DEPS)
	$(SPIN2CPP) --binary -Dcogstop0 -o $@ $<

%.openspin.binary: %.spin $(DEPS)
	$(OPENSPIN) -u -o $@ $<

%.spin2pasm.cog.binary: %.spin $(DEPS)
	$(SPIN2CPP) --asm --code=cog --binary -o $@ $<

%.spin2pasm.hub.binary: %.spin $(DEPS)
	$(SPIN2CPP) --asm --code=hub --binary -o $@ $<

%.log: %.binary
	$(SPINSIM) -p $< -b | tee $@

#-------------------------------------------------------------------------------

clean:
	rm -f *~ *.binary *.c *.cpp *.h *.pasm *.log

#-------------------------------------------------------------------------------
