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 # See linux-4.1.y-riscv branch of
27 # https://github.com/riscv/riscv-linux
28 KERNEL_VERSION = 4.1.26
30 # A local copy of Linux git repo so you don't have to keep downloading
31 # git commits (optional).
32 LOCAL_LINUX_GIT_COPY = $(HOME)/d/linux
34 all: stage1 stage2 stage3 stage4
38 stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
39 stage1-riscv-qemu/riscv-qemu.spec \
40 stamp-riscv-qemu-installed \
41 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz \
42 stage1-riscv-fesvr/riscv-fesvr.spec \
43 stamp-riscv-fesvr-installed \
44 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz \
45 stage1-riscv-isa-sim/riscv-isa-sim.spec \
46 stamp-riscv-isa-sim-installed
48 stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
50 wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
53 stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
54 sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
55 -e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
59 stamp-riscv-qemu-installed:
61 @rpm -q riscv-qemu >/dev/null || { \
62 echo "ERROR: You must install riscv-qemu:"; \
64 echo " dnf copr enable rjones/riscv"; \
65 echo " dnf install riscv-qemu"; \
67 echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
71 @qemu-system-riscv --version || { \
72 echo "ERROR: qemu-system-riscv is not working."; \
73 echo "Make sure you installed the riscv-qemu package."; \
78 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz:
80 wget -O $@-t 'https://github.com/riscv/riscv-fesvr/archive/$(RISCV_FESVR_COMMIT)/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz'
83 stage1-riscv-fesvr/riscv-fesvr.spec: stage1-riscv-fesvr/riscv-fesvr.spec.in
84 sed -e 's/@COMMIT@/$(RISCV_FESVR_COMMIT)/g' \
85 -e 's/@SHORTCOMMIT@/$(RISCV_FESVR_SHORTCOMMIT)/g' \
89 stamp-riscv-fesvr-installed:
91 @rpm -q riscv-fesvr >/dev/null || { \
92 echo "ERROR: You must install riscv-fesvr:"; \
94 echo " dnf copr enable rjones/riscv"; \
95 echo " dnf install riscv-fesvr"; \
97 echo "OR: you can build it yourself from the stage1-riscv-fesvr directory."; \
103 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz:
105 wget -O $@-t 'https://github.com/riscv/riscv-isa-sim/archive/$(RISCV_ISA_SIM_COMMIT)/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz'
108 stage1-riscv-isa-sim/riscv-isa-sim.spec: stage1-riscv-isa-sim/riscv-isa-sim.spec.in
109 sed -e 's/@COMMIT@/$(RISCV_ISA_SIM_COMMIT)/g' \
110 -e 's/@SHORTCOMMIT@/$(RISCV_ISA_SIM_SHORTCOMMIT)/g' \
114 stamp-riscv-isa-sim-installed:
116 @rpm -q riscv-isa-sim >/dev/null || { \
117 echo "ERROR: You must install riscv-isa-sim:"; \
119 echo " dnf copr enable rjones/riscv"; \
120 echo " dnf install riscv-isa-sim"; \
122 echo "OR: you can build it yourself from the stage1-riscv-isa-sim directory."; \
130 stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz \
131 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz \
132 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz \
133 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz \
134 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz \
135 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec \
136 stamp-riscv-gnu-toolchain-installed \
137 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz \
138 stage2-riscv-pk/riscv-pk.spec \
139 stamp-riscv-pk-installed
141 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz:
143 wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/$(RISCV_GNU_TOOLCHAIN_COMMIT)/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz
146 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz:
148 wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz
151 # GCC 5 no longer compiles with GCC 6 unless we patch it.
152 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959
153 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz:
155 wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.gz
157 cd gcc-$(GCC_VERSION) && patch -p0 < ../stage2-riscv-gnu-toolchain/gcc-5-fix-compilation-with-gcc-6.patch
158 tar zcf $@-t gcc-$(GCC_VERSION)
159 rm -r gcc-$(GCC_VERSION)
162 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz:
164 wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-$(GLIBC_VERSION).tar.gz
167 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz:
169 wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
172 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec.in
173 sed -e 's/@COMMIT@/$(RISCV_GNU_TOOLCHAIN_COMMIT)/g' \
174 -e 's/@SHORTCOMMIT@/$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT)/g' \
175 -e 's/@BINUTILS_VERSION@/$(BINUTILS_VERSION)/g' \
176 -e 's/@GCC_VERSION@/$(GCC_VERSION)/g' \
177 -e 's/@GLIBC_VERSION@/$(GLIBC_VERSION)/g' \
178 -e 's/@NEWLIB_VERSION@/$(NEWLIB_VERSION)/g' \
182 stamp-riscv-gnu-toolchain-installed:
184 @rpm -q riscv-gnu-toolchain >/dev/null || { \
185 echo "ERROR: You must install riscv-gnu-toolchain:"; \
187 echo " dnf copr enable rjones/riscv"; \
188 echo " dnf install riscv-gnu-toolchain"; \
190 echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
194 @riscv64-unknown-elf-gcc --version || { \
195 echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
196 echo "Make sure you installed the riscv-gnu-toolchain package."; \
201 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz:
203 wget -O $@-t https://github.com/lowRISC/riscv-pk/archive/$(RISCV_PK_COMMIT)/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz
206 stage2-riscv-pk/riscv-pk.spec: stage2-riscv-pk/riscv-pk.spec.in
207 sed -e 's/@COMMIT@/$(RISCV_PK_COMMIT)/g' \
208 -e 's/@SHORTCOMMIT@/$(RISCV_PK_SHORTCOMMIT)/g' \
212 stamp-riscv-pk-installed:
214 @rpm -q riscv-pk >/dev/null || { \
215 echo "ERROR: You must install riscv-pk:"; \
217 echo " dnf copr enable rjones/riscv"; \
218 echo " dnf install riscv-pk"; \
220 echo "OR: you can build it yourself from the stage2-riscv-pk directory."; \
228 stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
230 stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
231 rm -rf stage3-kernel/linux-$(KERNEL_VERSION)
232 cp -a $(LOCAL_LINUX_GIT_COPY) stage3-kernel/linux-$(KERNEL_VERSION) || { \
233 mkdir stage3-kernel/linux-$(KERNEL_VERSION) && \
234 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
237 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
238 git remote add riscv https://github.com/riscv/riscv-linux && \
240 git checkout -f linux-4.1.y-riscv && \
242 make ARCH=riscv defconfig && \
243 make ARCH=riscv CONFIG_CROSS_COMPILE=riscv64-unknown-elf- vmlinux