1 # Refer to the README file to understand how Fedora on RISC-V is
4 # Note these are chosen very specifically to ensure the different
5 # versions work together. Don't blindly update to the latest
7 # https://github.com/riscv/riscv-pk/issues/18#issuecomment-206115996
8 RISCV_QEMU_COMMIT = 94f5eb73091fb4fe272db3e943f173ecc0f78ffd
9 RISCV_QEMU_SHORTCOMMIT = 94f5eb73
10 RISCV_FESVR_COMMIT = 0f34d7ad311f78455a674224225f5b3056efba1d
11 RISCV_FESVR_SHORTCOMMIT = 0f34d7ad
12 RISCV_ISA_SIM_COMMIT = 3bfc00ef2a1b1f0b0472a39a866261b00f67027e
13 RISCV_ISA_SIM_SHORTCOMMIT = 3bfc00ef
14 RISCV_GNU_TOOLCHAIN_COMMIT = 728afcddcb0526a0f6560c4032da82805f054d58
15 RISCV_GNU_TOOLCHAIN_SHORTCOMMIT = 728afcdd
16 RISCV_PK_COMMIT = 85ae17aa149b9ea114bdd70cc30ea7e73813fb48
17 RISCV_PK_SHORTCOMMIT = 85ae17aa
19 # For the correct versions, see
20 # riscv-gnu-toolchain/Makefile.in *_version variables
21 BINUTILS_VERSION = 2.25.1
24 NEWLIB_VERSION = 2.2.0
26 all: stage1 stage2 stage3 stage4
30 stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
31 stage1-riscv-qemu/riscv-qemu.spec \
32 stamp-riscv-qemu-installed \
33 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz \
34 stage1-riscv-fesvr/riscv-fesvr.spec \
35 stamp-riscv-fesvr-installed \
36 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz \
37 stage1-riscv-isa-sim/riscv-isa-sim.spec \
38 stamp-riscv-isa-sim-installed
40 stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
42 wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
45 stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
46 sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
47 -e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
51 stamp-riscv-qemu-installed:
53 @rpm -q riscv-qemu >/dev/null || { \
54 echo "ERROR: You must install riscv-qemu:"; \
56 echo " dnf copr enable rjones/riscv"; \
57 echo " dnf install riscv-qemu"; \
59 echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
63 @qemu-system-riscv --version || { \
64 echo "ERROR: qemu-system-riscv is not working."; \
65 echo "Make sure you installed the riscv-qemu package."; \
70 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz:
72 wget -O $@-t 'https://github.com/riscv/riscv-fesvr/archive/$(RISCV_FESVR_COMMIT)/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz'
75 stage1-riscv-fesvr/riscv-fesvr.spec: stage1-riscv-fesvr/riscv-fesvr.spec.in
76 sed -e 's/@COMMIT@/$(RISCV_FESVR_COMMIT)/g' \
77 -e 's/@SHORTCOMMIT@/$(RISCV_FESVR_SHORTCOMMIT)/g' \
81 stamp-riscv-fesvr-installed:
83 @rpm -q riscv-fesvr >/dev/null || { \
84 echo "ERROR: You must install riscv-fesvr:"; \
86 echo " dnf copr enable rjones/riscv"; \
87 echo " dnf install riscv-fesvr"; \
89 echo "OR: you can build it yourself from the stage1-riscv-fesvr directory."; \
95 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz:
97 wget -O $@-t 'https://github.com/riscv/riscv-isa-sim/archive/$(RISCV_ISA_SIM_COMMIT)/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz'
100 stage1-riscv-isa-sim/riscv-isa-sim.spec: stage1-riscv-isa-sim/riscv-isa-sim.spec.in
101 sed -e 's/@COMMIT@/$(RISCV_ISA_SIM_COMMIT)/g' \
102 -e 's/@SHORTCOMMIT@/$(RISCV_ISA_SIM_SHORTCOMMIT)/g' \
106 stamp-riscv-isa-sim-installed:
108 @rpm -q riscv-isa-sim >/dev/null || { \
109 echo "ERROR: You must install riscv-isa-sim:"; \
111 echo " dnf copr enable rjones/riscv"; \
112 echo " dnf install riscv-isa-sim"; \
114 echo "OR: you can build it yourself from the stage1-riscv-isa-sim directory."; \
122 stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz \
123 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz \
124 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz \
125 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz \
126 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz \
127 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec \
128 stamp-riscv-gnu-toolchain-installed \
129 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz \
130 stage2-riscv-pk/riscv-pk.spec \
131 stamp-riscv-pk-installed
133 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz:
135 wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/$(RISCV_GNU_TOOLCHAIN_COMMIT)/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz
138 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz:
140 wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz
143 # GCC 5 no longer compiles with GCC 6 unless we patch it.
144 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959
145 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz:
147 wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.gz
149 cd gcc-$(GCC_VERSION) && patch -p0 < ../stage2-riscv-gnu-toolchain/gcc-5-fix-compilation-with-gcc-6.patch
150 tar zcf $@-t gcc-$(GCC_VERSION)
151 rm -r gcc-$(GCC_VERSION)
154 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz:
156 wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-$(GLIBC_VERSION).tar.gz
159 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz:
161 wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
164 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec.in
165 sed -e 's/@COMMIT@/$(RISCV_GNU_TOOLCHAIN_COMMIT)/g' \
166 -e 's/@SHORTCOMMIT@/$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT)/g' \
167 -e 's/@BINUTILS_VERSION@/$(BINUTILS_VERSION)/g' \
168 -e 's/@GCC_VERSION@/$(GCC_VERSION)/g' \
169 -e 's/@GLIBC_VERSION@/$(GLIBC_VERSION)/g' \
170 -e 's/@NEWLIB_VERSION@/$(NEWLIB_VERSION)/g' \
174 stamp-riscv-gnu-toolchain-installed:
176 @rpm -q riscv-gnu-toolchain >/dev/null || { \
177 echo "ERROR: You must install riscv-gnu-toolchain:"; \
179 echo " dnf copr enable rjones/riscv"; \
180 echo " dnf install riscv-gnu-toolchain"; \
182 echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
186 @riscv64-unknown-elf-gcc --version || { \
187 echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
188 echo "Make sure you installed the riscv-gnu-toolchain package."; \
193 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz:
195 wget -O $@-t https://github.com/lowRISC/riscv-pk/archive/$(RISCV_PK_COMMIT)/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz
198 stage2-riscv-pk/riscv-pk.spec: stage2-riscv-pk/riscv-pk.spec.in
199 sed -e 's/@COMMIT@/$(RISCV_PK_COMMIT)/g' \
200 -e 's/@SHORTCOMMIT@/$(RISCV_PK_SHORTCOMMIT)/g' \
204 stamp-riscv-pk-installed:
206 @rpm -q riscv-pk >/dev/null || { \
207 echo "ERROR: You must install riscv-pk:"; \
209 echo " dnf copr enable rjones/riscv"; \
210 echo " dnf install riscv-pk"; \
212 echo "OR: you can build it yourself from the stage2-riscv-pk directory."; \
220 stage3: stage3-kernel/linux-4.6.2.tar.xz \
221 stage3-kernel/linux-4.6.2/vmlinux
223 stage3-kernel/linux-4.6.2.tar.xz:
225 wget -O $@-t https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.6.2.tar.xz
228 stage3-kernel/linux-4.6.2/vmlinux:
229 rm -rf stage3-kernel/linux-4.6.2
230 cat stage3-kernel/linux-4.6.2.tar.xz | tar -x --xz -C stage3-kernel
231 cd stage3-kernel/linux-4.6.2 && \
233 cd stage3-kernel/linux-4.6.2 && \
234 git remote add origin https://github.com/lowrisc/riscv-linux.git
235 cd stage3-kernel/linux-4.6.2 && \
237 cd stage3-kernel/linux-4.6.2 && \
238 git checkout -f -t origin/debug-v0.3
239 cd stage3-kernel/linux-4.6.2 && \
240 patch -p1 < spi_sd_power_hack.patch
241 cd stage3-kernel/linux-4.6.2 && \
242 make ARCH=riscv defconfig
243 cd stage3-kernel/linux-4.6.2 && \
244 make ARCH=riscv CONFIG_CROSS_COMPILE=riscv64-unknown-elf- vmlinux