Last active
August 29, 2015 14:08
-
-
Save dadeba/45631a382c6fb12a2a64 to your computer and use it in GitHub Desktop.
Makefile for a new Chisel project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SBT ?= sbt | |
SBT_FLAGS ?= -Dsbt.log.noformat=true | |
.SHELLFLAGS := -e -o pipefail | |
# If a chiselVersion is defined, use that. | |
ifneq (,$(chiselVersion)) | |
CHISEL_SMOKE_VERSION := $(chiselVersion) | |
CHISEL_CHECK_VERSION := $(chiselVersion) | |
CHISEL_DEFAULT_VERSION := $(chiselVersion) | |
else | |
CHISEL_SMOKE_VERSION ?= 2.3-SNAPSHOT | |
CHISEL_CHECK_VERSION ?= 2.3-SNAPSHOT | |
CHISEL_DEFAULT_VERSION ?= latest.release | |
endif | |
CHISEL_FLAGS := | |
top_srcdir ?= .. | |
srcdir ?= . | |
executables := $(filter-out solutions problems examples Image Sound,\ | |
$(notdir $(basename $(wildcard $(srcdir)/*.scala)))) | |
tut_outs := $(addsuffix .out, $(executables)) | |
default: SBT_FLAGS += -DchiselVersion="$(CHISEL_DEFAULT_VERSION)" | |
default: all | |
all: emulator verilog # dreamer | |
check: SBT_FLAGS += -DchiselVersion="$(CHISEL_CHECK_VERSION)" | |
check: test-solutions.xml | |
clean: | |
-rm -f out.im24 out.wav *.h *.hex *.flo *.cpp *.o *.out *.v *.vcd $(executables) | |
-rm -rf project/target/ target/ | |
emulator: $(tut_outs) | |
dreamer: $(addsuffix .hex, $(executables)) | |
verilog: $(addsuffix .v, $(executables)) | |
test-solutions.xml: $(tut_outs) | |
$(top_srcdir)/sbt/check $(tut_outs) > $@ | |
%.out: %.scala | |
set -e -o pipefail; $(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --genHarness --compile --test --backend c $(CHISEL_FLAGS)" | tee $@ | |
%.hex: %.scala | |
$(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --backend flo --genHarness --compile --test $(CHISEL_FLAGS)" | |
%.v: %.scala | |
$(SBT) $(SBT_FLAGS) "run $(notdir $(basename $<)) --genHarness --backend v $(CHISEL_FLAGS)" | |
smoke: SBT_FLAGS += -DchiselVersion="$(CHISEL_SMOKE_VERSION)" | |
smoke: | |
$(SBT) $(SBT_FLAGS) compile | |
.PHONY: all check clean emulator verilog smoke |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment