forked from black-parrot-sdk/black-parrot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.prog
112 lines (97 loc) · 3.93 KB
/
Makefile.prog
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
perch_dir := $(BP_SDK_DIR)/perch
bootrom_dir := $(BP_SDK_DIR)/bootrom
bp_demos_dir := $(BP_SDK_DIR)/bp-demos
bp_tests_dir := $(BP_SDK_DIR)/bp-tests
riscv_tests_dir := $(BP_SDK_DIR)/riscv-tests
beebs_dir := $(BP_SDK_DIR)/beebs
coremark_dir := $(BP_SDK_DIR)/coremark
spec2000_dir := $(BP_SDK_DIR)/spec2000
spec2006_dir := $(BP_SDK_DIR)/spec2006
spec2017_dir := $(BP_SDK_DIR)/spec2017
riscvdv_dir := $(BP_SDK_DIR)/riscv-dv
linux_dir := $(BP_SDK_DIR)/linux
opcodes_dir := $(BP_SDK_DIR)/riscv-opcodes
define submodule_test_template
$(1)_tag ?= $(addprefix $(1)., $(shell cd $(2); git rev-parse HEAD))
$(BP_TOUCH_DIR)/$$($(1)_tag):
rm -rf $(BP_TOUCH_DIR)/$(1).*
cd $(BP_SDK_DIR); git submodule update --init --recursive $(GIT_SUBMODULE_DEPTH) $(2)
+$(MAKE) $(1)_build
mkdir -p $(BP_SDK_PROG_DIR)/$(1)
find $(2) -name "*.riscv" -exec cp {} $(BP_SDK_PROG_DIR)/$(1)/ \;
touch $(BP_TOUCH_DIR)/$$($(1)_tag)
$(1): | $(BP_TOUCH_DIR)/$$($(1)_tag)
$(1)_manual: $(BP_SDK_LIB_DIR)/libperch.a
+$(MAKE) $(1)_build
mkdir -p $(BP_SDK_PROG_DIR)/$(1)
find $(2) -name "*.riscv" -exec cp {} $(BP_SDK_PROG_DIR)/$(1)/ \;
endef
perch_build: $(BP_SDK_LIB_DIR)/libperch.a
$(BP_SDK_LIB_DIR)/libperch.a:
git submodule update --init $(opcodes_dir)
cp $(opcodes_dir)/encoding.h $(BP_SDK_INCLUDE_DIR)
$(MAKE) -C $(perch_dir) clean perch
mkdir -p $(BP_SDK_LIB_DIR)
mkdir -p $(BP_SDK_INCLUDE_DIR)
cp $(perch_dir)/libperch.a $(BP_SDK_LIB_DIR)
cp $(perch_dir)/libperchbm.a $(BP_SDK_LIB_DIR)
cp $(perch_dir)/*.h $(BP_SDK_INCLUDE_DIR)
bootrom_build:
$(MAKE) -C $(bootrom_dir)
bp-demos_build:
$(MAKE) -C $(bp_demos_dir) clean all
bp-tests_build:
$(MAKE) -C $(bp_tests_dir) clean all
riscv-tests_build:
cd $(riscv_tests_dir); git submodule update --init --recursive
cd $(riscv_tests_dir); ./configure --target=$(RISCV_TARGET)
$(MAKE) -C $(riscv_tests_dir) clean all
beebs_build:
cd $(beebs_dir); ./configure --host=riscv64 --with-chip=black-parrot \
--includedir=$(BP_INCLUDE_DIR) --libdir=$(BP_LIB_DIR)
$(MAKE) -C $(beebs_dir) clean all
@# TODO: We need to change to output .riscv, but the beebs makefiles are a mess
@find $(beebs_dir)/src -type f -executable -exec cp {} {}.riscv \;
coremark_build:
$(MAKE) -C $(coremark_dir)/barebones
spec2000_build:
$(MAKE) -C $(spec2000_dir)
spec2006_build:
$(MAKE) -C $(spec2006_dir)
spec2017_build:
$(MAKE) -C $(spec2017_dir)
riscv-dv_build:
$(MAKE) -C $(riscvdv_dir)
# Default Linux build is single core and terminates immediately
OPENSBI_NCPUS ?= 1
WITH_SHELL ?= $(linux_dir)/cfg/test.sh
linux_build:
$(MAKE) -C $(linux_dir) linux.riscv OPENSBI_NCPUS=$(OPENSBI_NCPUS) WITH_SHELL=$(WITH_SHELL)
.PHONY: perch bootrom bp-demos bp-tests riscv-tests beebs coremark spec2000 spec2006 riscv-dv linux
$(eval $(call submodule_test_template,perch,$(perch_dir)))
$(eval $(call submodule_test_template,bootrom,$(bootrom_dir)))
$(eval $(call submodule_test_template,bp-demos,$(bp_demos_dir)))
$(eval $(call submodule_test_template,bp-tests,$(bp_tests_dir)))
$(eval $(call submodule_test_template,riscv-tests,$(riscv_tests_dir)))
$(eval $(call submodule_test_template,beebs,$(beebs_dir)))
$(eval $(call submodule_test_template,coremark,$(coremark_dir)))
$(eval $(call submodule_test_template,spec2000,$(spec2000_dir)))
$(eval $(call submodule_test_template,spec2006,$(spec2006_dir)))
$(eval $(call submodule_test_template,spec2017,$(spec2017_dir)))
$(eval $(call submodule_test_template,riscv-dv,$(riscvdv_dir)))
$(eval $(call submodule_test_template,linux,$(linux_dir)))
.PHONY: prog_clean
prog_clean:
rm -rf $(BP_SDK_PROG_DIR)
-$(MAKE) -C $(perch_dir) clean
-$(MAKE) -C $(bootrom_dir) clean
-$(MAKE) -C $(bp_demos_dir) clean
-$(MAKE) -C $(bp_tests_dir) clean
-$(MAKE) -C $(riscv_tests_dir) clean
-$(MAKE) -C $(beebs_dir) clean
-$(MAKE) -C $(coremark_dir) clean
-$(MAKE) -C $(spec2000_dir) clean
-$(MAKE) -C $(spec2006_dir) clean
-$(MAKE) -C $(spec2017_dir) clean
-$(MAKE) -C $(riscvdv_dir) clean
-$(MAKE) -C $(linux_dir) clean