aboutsummaryrefslogtreecommitdiff
path: root/Makefile.test
blob: 0d9850c82271240f3d3081b96b95735360bdc813 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This Makefile is to be included by Makefile of each test

ifndef PROJ_DIR
PROJ_DIR := ../../
endif

IVFLAGS += -I$(PROJ_DIR)/include/ -DSIMULATION
# The macroassembly header file is somewhat different thing, but I don't know
# what place would be more suitable for it than include/ dir
MACROASM_FLAGS += -I$(PROJ_DIR)/include/ -E

include $(PROJ_DIR)/Makefile.config
include $(PROJ_DIR)/Makefile.util
include $(PROJ_DIR)/tools/Makefile.tools

ifdef DEBUG
IVFLAGS += -DDEBUG
DBG&SAVE = tee "$(1)"
else
DBG&SAVE = cat > "$(1)" # putting cat through pipe - what an animal cruelty!
endif

vpath %.v $(PROJ_DIR):$(PROJ_DIR)/design/:$(PROJ_DIR)/models/:.
vpath %.vh $(PROJ_DIR)/include:.

ifdef QUICK_TEST
ifdef VGA_TEST
SKIPPING = 1
endif
endif

ifdef SKIPPING
test :
	@echo Skipping >&2
else
ifdef VGA_TEST
test : VGAdump.ppm VGAdump_expected.ppm
endif
test : report.log
	! grep error $< >&2
ifdef VGA_TEST
	diff VGAdump.ppm VGAdump_expected.ppm
endif
endif

TOOLS_TARGETS = $(addprefix $(PROJ_DIR)/tools/,$(TOOLS))

$(TOOLS_TARGETS) : $(PROJ_DIR)/% :
	$(MAKE) -C $(PROJ_DIR) $*

%.mem : %.memv
	$(IV) $(MACROASM_FLAGS) $^ -o $@

%.vvp : %.v $(DEPENDS)
	$(IV) $(IVFLAGS) -s $(TOP) $(filter %.v,$^) -o $@


ifdef VGA_TEST
report.log VGAdump.mem : $(PROJ_DIR)/design/font.mem
endif
report.log VGAdump.mem : test.vvp
	vvp $< | $(call DBG&SAVE,report.log)

VGAdump.ppm : $(PROJ_DIR)/tools/VGAdump2ppm VGAdump.mem
	grep -v // < VGAdump.mem | $< > $@

GENERATED_MEM_FILES := $(shell find . -name "*.s.tcl")
GENERATED_MEM_FILES := $(basename $(basename $(GENERATED_MEM_FILES)))
GENERATED_MEM_FILES += $(basename $(shell find . -name "*.memv"))
GENERATED_MEM_FILES += $(basename $(shell find . -name "*.wat"))
GENERATED_MEM_FILES := $(addsuffix .mem,$(GENERATED_MEM_FILES))

clean :
	rm $(GENERATED_MEM_FILES) *.vvp *.wasm report.log VGAdump.mem \
		VGAdump.ppm 2>/dev/null || true

.PHONY : test clean $(TOOLS_TARGETS)

.SECONDARY : $(TOOLS_TARGETS)