forked from black-parrot-sdk/black-parrot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.tools
61 lines (53 loc) · 2.1 KB
/
Makefile.tools
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
gnu_dir :=$(BP_SDK_DIR)/riscv-gnu-toolchain
gnudramfs_dir:=$(gnu_dir)
gnulinux_dir :=$(gnu_dir)
dromajo_dir :=$(BP_SDK_DIR)/dromajo
bedrock_dir :=$(BP_SDK_DIR)/bedrock
define submodule_tool_template
$(1)_tag ?= $(addprefix $(1)., $(shell cd $(2); git rev-parse HEAD))
$(BP_SDK_TOUCH_DIR)/$$($(1)_tag):
rm -rf $(BP_SDK_TOUCH_DIR)/$(1).*
cd $(BP_SDK_DIR); git submodule update --init --recursive $(GIT_SUBMODULE_DEPTH) $(2)
+$(MAKE) $(1)_build
touch $(BP_SDK_TOUCH_DIR)/$$($(1)_tag)
$(1): | $(BP_SDK_TOUCH_DIR)/$$($(1)_tag)
$(1)_manual:
+$(MAKE) $(1)_build
endef
# gnu target builds the entire toolchain
gnu: gnulinux
gnulinux: gnudramfs
gnulinux_build:
cd $(gnu_dir); \
./configure --prefix=$(BP_SDK_INSTALL_DIR) --with-arch=rv64imafd --with-abi=lp64 --with-cmodel=medany --disable-gdb
$(MAKE) -C $(gnu_dir) linux
$(MAKE) -C $(gnu_dir) install
gnudramfs_build:
cd $(gnu_dir); \
./configure --prefix=$(BP_SDK_INSTALL_DIR) --with-arch=rv64imafd --with-abi=lp64 --with-cmodel=medany --disable-gdb
$(MAKE) -C $(gnu_dir)
$(MAKE) -C $(gnu_dir) install
cp $(BP_SDK_INSTALL_DIR)/riscv64-unknown-elf-dramfs/bin/dramfs_mklfs $(BP_SDK_BIN_DIR)
dromajo_build:
mkdir -p $(dromajo_dir)/build
$(CMAKE) -S $(dromajo_dir) -B $(dromajo_dir)/build -DCMAKE_BUILD_TYPE=Release
$(MAKE) -C $(dromajo_dir)/build
cp $(dromajo_dir)/build/dromajo $(BP_SDK_BIN_DIR)
cp $(dromajo_dir)/build/libdromajo_cosim.a $(BP_SDK_LIB_DIR)
cp $(dromajo_dir)/include/dromajo_cosim.h $(BP_SDK_INCLUDE_DIR)
bedrock_build:
mkdir -p $(BP_UCODE_DIR)
$(MAKE) -C $(bedrock_dir) bins
cp $(bedrock_dir)/roms/*.bin $(BP_UCODE_DIR)/
cp $(bedrock_dir)/roms/*.addr $(BP_UCODE_DIR)/
cp $(bedrock_dir)/roms/*.mem $(BP_UCODE_DIR)/
.PHONY: gnu dromajo bedrock panic_room
$(eval $(call submodule_tool_template,gnudramfs,$(gnudramfs_dir)))
$(eval $(call submodule_tool_template,gnulinux,$(gnulinux_dir)))
$(eval $(call submodule_tool_template,dromajo,$(dromajo_dir)))
$(eval $(call submodule_tool_template,bedrock,$(bedrock_dir)))
.PHONY: tools_clean
tools_clean:
-$(MAKE) -C $(bedrock_dir) clean
-$(MAKE) -C $(dromajo_dir)/build clean
-$(MAKE) -C $(gnu_dir) clean