forked from openhwgroup/cva6-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
137 lines (113 loc) · 4.26 KB
/
Makefile
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Makefile for RISC-V toolchain; run 'make help' for usage.
ROOT := $(patsubst %/,%, $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
RISCV ?= $(PWD)/install
DEST := $(abspath $(RISCV))
PATH := $(DEST)/bin:$(PATH)
NR_CORES := $(shell nproc)
# default configure flags
fesvr-co = --prefix=$(RISCV) --target=riscv64-unknown-linux-gnu
isa-sim-co = --prefix=$(RISCV) --with-fesvr=$(DEST)
gnu-toolchain-co-fast = --prefix=$(RISCV) --disable-gdb# no multilib for fast
pk-co = --prefix=$(RISCV) --host=riscv64-unknown-linux-gnu-elf CC=riscv64-unknown-linux-gnu-gcc OBJDUMP=riscv64-unknown-linux-gnu-objdump
tests-co = --prefix=$(RISCV)/target
# default make flags
fesvr-mk = -j$(NR_CORES)
isa-sim-mk = -j$(NR_CORES)
gnu-toolchain-libc-mk = linux -j$(NR_CORES)
pk-mk = -j$(NR_CORES)
tests-mk = -j$(NR_CORES)
# linux image
buildroot_defconfig = configs/buildroot_defconfig
linux_defconfig = configs/linux_defconfig
busybox_defconfig = configs/busybox.config
install-dir:
mkdir -p $(RISCV)
$(RISCV)/bin/riscv64-unknown-linux-gnu-gcc: gnu-toolchain-no-multilib
cd riscv-gnu-toolchain/build;\
make $(gnu-toolchain-libc-mk);\
cd $(ROOT)
gnu-toolchain-libc: $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc
gnu-toolchain-no-multilib: install-dir
mkdir -p riscv-gnu-toolchain/build
cd riscv-gnu-toolchain/build;\
../configure $(gnu-toolchain-co-fast);\
cd $(ROOT)
fesvr: install-dir $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc
mkdir -p riscv-fesvr/build
cd riscv-fesvr/build;\
../configure $(fesvr-co);\
make $(fesvr-mk);\
make install;\
cd $(ROOT)
isa-sim: install-dir $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc fesvr
mkdir -p riscv-isa-sim/build
cd riscv-isa-sim/build;\
../configure $(isa-sim-co);\
make $(isa-sim-mk);\
make install;\
cd $(ROOT)
tests: install-dir $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc
mkdir -p riscv-tests/build
cd riscv-tests/build;\
autoconf;\
../configure $(tests-co);\
make $(tests-mk);\
make install;\
cd $(ROOT)
pk: install-dir $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc
mkdir -p riscv-pk/build
cd riscv-pk/build;\
../configure $(pk-co);\
make $(pk-mk);\
make install;\
cd $(ROOT)
all: gnu-toolchain-libc fesvr isa-sim tests pk
# benchmark for the cache subsystem
cachetest:
cd ./cachetest/ && $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc cachetest.c -o cachetest.elf
cp ./cachetest/cachetest.elf rootfs/
# cool command-line tetris
rootfs/tetris:
cd ./vitetris/ && make clean && ./configure CC=riscv64-unknown-linux-gnu-gcc && make
cp ./vitetris/tetris $@
vmlinux: $(buildroot_defconfig) $(linux_defconfig) $(busybox_defconfig) $(RISCV)/bin/riscv64-unknown-elf-gcc $(RISCV)/bin/riscv64-unknown-linux-gnu-gcc cachetest rootfs/tetris
mkdir -p build
make -C buildroot defconfig BR2_DEFCONFIG=../$(buildroot_defconfig)
make -C buildroot
cp buildroot/output/images/vmlinux build/vmlinux
cp build/vmlinux vmlinux
bbl: vmlinux
cd build && ../riscv-pk/configure --host=riscv64-unknown-elf CC=riscv64-unknown-linux-gnu-gcc OBJDUMP=riscv64-unknown-linux-gnu-objdump --with-payload=vmlinux --enable-logo --with-logo=../configs/logo.txt
make -C build
cp build/bbl bbl
bbl_binary: bbl
riscv64-unknown-elf-objcopy -O binary bbl bbl_binary
clean:
rm -rf vmlinux bbl riscv-pk/build/vmlinux riscv-pk/build/bbl cachetest/*.elf rootfs/tetris
make -C buildroot distclean
bbl.bin: bbl
riscv64-unknown-elf-objcopy -S -O binary --change-addresses -0x80000000 $< $@
clean-all: clean
rm -rf riscv-fesvr/build riscv-isa-sim/build riscv-gnu-toolchain/build riscv-tests/build riscv-pk/build
.PHONY: cachetest rootfs/tetris
help:
@echo "usage: $(MAKE) [RISCV='<install/here>'] [tool/img] ..."
@echo ""
@echo "install [tool] to \$$RISCV with compiler <flag>'s"
@echo " where tool can be any one of:"
@echo " fesvr isa-sim gnu-toolchain tests pk"
@echo ""
@echo "build linux images for ariane"
@echo " build vmlinux with"
@echo " make vmlinux"
@echo " build bbl (with vmlinux) with"
@echo " make bbl"
@echo ""
@echo "There are two clean targets:"
@echo " Clean only buildroot"
@echo " make clean"
@echo " Clean everything (including toolchain etc)"
@echo " make clean-all"
@echo ""
@echo "defaults:"
@echo " RISCV='$(DEST)'"