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

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

all: $(ALL)

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

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

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

%.log: %.binary
	$(SPINSIM) -p $< -b | tee $@ | egrep '^[0-9]+ ticks$$'

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

clean:
	rm -f *~ *.binary *.pasm *.log

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