SUBDIRS   := tools rv32 fpga
REVISIONS := v1 v2

all clean spotless :
	$(MAKE) local.$@ $(SUBDIRS) goal=$@

prefpga:
	$(MAKE) local.all $(filter-out fpga,$(SUBDIRS)) goal=all

$(REVISIONS): prefpga
	$(MAKE) -C fpga $@

.PHONY: $(SUBDIRS)
$(SUBDIRS):
	$(MAKE) -C $@ $(goal)

rv32: | tools

fpga: | rv32

local.all:

local.clean:
	rm -f *~ ./\#* \# *.bak

local.spotless: local.clean

# Obsolete target, need version
program flash:
	@echo 'Please specify one of: $(foreach rev,$(REVISIONS),$@-$(rev))' 1>&2
	@false

# FPGA-specific targets
program-% flash-%: prefpga
	$(MAKE) -C fpga $@
