1 # Refer to the README file to understand how Fedora on RISC-V is
4 # Absolute path to the current directory.
7 # Note these are chosen very specifically to ensure the different
8 # versions work together. Don't blindly update to the latest
10 # https://github.com/riscv/riscv-pk/issues/18#issuecomment-206115996
11 RISCV_QEMU_COMMIT = 94f5eb73091fb4fe272db3e943f173ecc0f78ffd
12 RISCV_QEMU_SHORTCOMMIT = 94f5eb73
13 RISCV_FESVR_COMMIT = 0f34d7ad311f78455a674224225f5b3056efba1d
14 RISCV_FESVR_SHORTCOMMIT = 0f34d7ad
15 RISCV_ISA_SIM_COMMIT = 3bfc00ef2a1b1f0b0472a39a866261b00f67027e
16 RISCV_ISA_SIM_SHORTCOMMIT = 3bfc00ef
17 RISCV_GNU_TOOLCHAIN_COMMIT = 728afcddcb0526a0f6560c4032da82805f054d58
18 RISCV_GNU_TOOLCHAIN_SHORTCOMMIT = 728afcdd
19 RISCV_PK_COMMIT = 85ae17aa149b9ea114bdd70cc30ea7e73813fb48
20 RISCV_PK_SHORTCOMMIT = 85ae17aa
22 # For the correct versions, see
23 # riscv-gnu-toolchain/Makefile.in *_version variables
24 BINUTILS_VERSION = 2.25.1
27 NEWLIB_VERSION = 2.2.0
29 # See linux-4.1.y-riscv branch of
30 # https://github.com/riscv/riscv-linux
31 KERNEL_VERSION = 4.1.26
33 # A local copy of Linux git repo so you don't have to keep downloading
34 # git commits (optional).
35 LOCAL_LINUX_GIT_COPY = $(HOME)/d/linux
37 # The root packages (plus their dependencies) that we want to
38 # cross-compile into the stage 3 chroot.
39 STAGE3_PACKAGES = gcc rpm-build
41 # Versions of cross-compiled packages.
42 NCURSES_VERSION = 6.0-20160730
44 COREUTILS_VERSION = 8.25
48 BINUTILS_X_VERSION = 2.26
50 UTIL_LINUX_VERSION = 2.28
52 all: stage1 stage2 stage3 stage4
56 stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
57 stage1-riscv-qemu/riscv-qemu.spec \
58 stamp-riscv-qemu-installed \
59 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz \
60 stage1-riscv-fesvr/riscv-fesvr.spec \
61 stamp-riscv-fesvr-installed \
62 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz \
63 stage1-riscv-isa-sim/riscv-isa-sim.spec \
64 stamp-riscv-isa-sim-installed
66 stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
68 wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
71 stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
72 sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
73 -e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
77 stamp-riscv-qemu-installed:
79 @rpm -q riscv-qemu >/dev/null || { \
80 echo "ERROR: You must install riscv-qemu:"; \
82 echo " dnf copr enable rjones/riscv"; \
83 echo " dnf install riscv-qemu"; \
85 echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
89 @qemu-system-riscv --version || { \
90 echo "ERROR: qemu-system-riscv is not working."; \
91 echo "Make sure you installed the riscv-qemu package."; \
96 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz:
98 wget -O $@-t 'https://github.com/riscv/riscv-fesvr/archive/$(RISCV_FESVR_COMMIT)/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz'
101 stage1-riscv-fesvr/riscv-fesvr.spec: stage1-riscv-fesvr/riscv-fesvr.spec.in
102 sed -e 's/@COMMIT@/$(RISCV_FESVR_COMMIT)/g' \
103 -e 's/@SHORTCOMMIT@/$(RISCV_FESVR_SHORTCOMMIT)/g' \
107 stamp-riscv-fesvr-installed:
109 @rpm -q riscv-fesvr >/dev/null || { \
110 echo "ERROR: You must install riscv-fesvr:"; \
112 echo " dnf copr enable rjones/riscv"; \
113 echo " dnf install riscv-fesvr"; \
115 echo "OR: you can build it yourself from the stage1-riscv-fesvr directory."; \
121 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz:
123 wget -O $@-t 'https://github.com/riscv/riscv-isa-sim/archive/$(RISCV_ISA_SIM_COMMIT)/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz'
126 stage1-riscv-isa-sim/riscv-isa-sim.spec: stage1-riscv-isa-sim/riscv-isa-sim.spec.in
127 sed -e 's/@COMMIT@/$(RISCV_ISA_SIM_COMMIT)/g' \
128 -e 's/@SHORTCOMMIT@/$(RISCV_ISA_SIM_SHORTCOMMIT)/g' \
132 stamp-riscv-isa-sim-installed:
134 @rpm -q riscv-isa-sim >/dev/null || { \
135 echo "ERROR: You must install riscv-isa-sim:"; \
137 echo " dnf copr enable rjones/riscv"; \
138 echo " dnf install riscv-isa-sim"; \
140 echo "OR: you can build it yourself from the stage1-riscv-isa-sim directory."; \
148 stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz \
149 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz \
150 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz \
151 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz \
152 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz \
153 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec \
154 stamp-riscv-gnu-toolchain-installed \
155 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz \
156 stage2-riscv-pk/riscv-pk.spec \
157 stamp-riscv-pk-installed
159 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz:
161 wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/$(RISCV_GNU_TOOLCHAIN_COMMIT)/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz
164 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz:
166 wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz
169 # GCC 5 no longer compiles with GCC 6 unless we patch it.
170 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959
171 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz:
173 wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.gz
175 cd gcc-$(GCC_VERSION) && patch -p0 < ../stage2-riscv-gnu-toolchain/gcc-5-fix-compilation-with-gcc-6.patch
176 tar zcf $@-t gcc-$(GCC_VERSION)
177 rm -r gcc-$(GCC_VERSION)
180 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz:
182 wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-$(GLIBC_VERSION).tar.gz
185 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz:
187 wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
190 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec.in
191 sed -e 's/@COMMIT@/$(RISCV_GNU_TOOLCHAIN_COMMIT)/g' \
192 -e 's/@SHORTCOMMIT@/$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT)/g' \
193 -e 's/@BINUTILS_VERSION@/$(BINUTILS_VERSION)/g' \
194 -e 's/@GCC_VERSION@/$(GCC_VERSION)/g' \
195 -e 's/@GLIBC_VERSION@/$(GLIBC_VERSION)/g' \
196 -e 's/@NEWLIB_VERSION@/$(NEWLIB_VERSION)/g' \
200 stamp-riscv-gnu-toolchain-installed:
202 @rpm -q riscv-gnu-toolchain >/dev/null || { \
203 echo "ERROR: You must install riscv-gnu-toolchain:"; \
205 echo " dnf copr enable rjones/riscv"; \
206 echo " dnf install riscv-gnu-toolchain"; \
208 echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
212 @riscv64-unknown-elf-gcc --version || { \
213 echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
214 echo "Make sure you installed the riscv-gnu-toolchain package."; \
219 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz:
221 wget -O $@-t https://github.com/lowRISC/riscv-pk/archive/$(RISCV_PK_COMMIT)/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz
224 stage2-riscv-pk/riscv-pk.spec: stage2-riscv-pk/riscv-pk.spec.in
225 sed -e 's/@COMMIT@/$(RISCV_PK_COMMIT)/g' \
226 -e 's/@SHORTCOMMIT@/$(RISCV_PK_SHORTCOMMIT)/g' \
230 stamp-riscv-pk-installed:
232 @rpm -q riscv-pk >/dev/null || { \
233 echo "ERROR: You must install riscv-pk:"; \
235 echo " dnf copr enable rjones/riscv"; \
236 echo " dnf install riscv-pk"; \
238 echo "OR: you can build it yourself from the stage2-riscv-pk directory."; \
246 stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \
247 stage3-chroot-original/etc/fedora-release \
248 stage3-chroot/etc/fedora-release \
249 stage3-chroot/lib64/libc.so.6 \
250 stage3-chroot/usr/bin/tic \
251 stage3-chroot/bin/bash \
252 stage3-chroot/bin/ls \
253 stage3-chroot/usr/lib64/libgmp.so.10 \
254 stage3-chroot/usr/lib64/libmpfr.so.4 \
255 stage3-chroot/usr/lib64/libmpc.so.3 \
256 stage3-chroot/usr/bin/as \
257 stage3-chroot/usr/bin/gcc \
258 stage3-chroot/usr/bin/mount \
262 stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
263 rm -rf stage3-kernel/linux-$(KERNEL_VERSION)
264 cp -a $(LOCAL_LINUX_GIT_COPY) stage3-kernel/linux-$(KERNEL_VERSION) || { \
265 mkdir stage3-kernel/linux-$(KERNEL_VERSION) && \
266 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
269 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
270 git remote add riscv https://github.com/riscv/riscv-linux && \
272 git checkout -f linux-4.1.y-riscv && \
274 make ARCH=riscv defconfig
275 echo CONFIG_CMDLINE=\"root=/dev/htifblk0 init=/init\" >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
276 echo CONFIG_CROSS_COMPILE=riscv64-unknown-elf- >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
277 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
278 make ARCH=riscv olddefconfig
279 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
280 make ARCH=riscv vmlinux
283 # Build an original (x86-64) chroot using supermin. We then aim to
284 # rebuild (using cross-compiled versions) every ELF binary in this
286 stage3-chroot-original/etc/fedora-release:
287 rm -rf stage3-chroot-original tmp-supermin.d
288 supermin --prepare $(STAGE3_PACKAGES) -o tmp-supermin.d
289 supermin --build -f chroot tmp-supermin.d -o stage3-chroot-original
291 @echo -n "Total files in chroot: "
292 @find stage3-chroot-original -type f | wc -l
293 @echo -n "ELF files to be rebuilt: "
294 @find stage3-chroot-original -type f | xargs file -N | grep -E '\bELF.*LSB\b' | wc -l
296 # Copy the original chroot to the final chroot, remove all the ELF
298 stage3-chroot/etc/fedora-release: stage3-chroot-original/etc/fedora-release
300 cp -a stage3-chroot-original stage3-chroot
301 find stage3-chroot -type d | xargs chmod u+w
302 find stage3-chroot -type f | xargs chmod u+w
303 find stage3-chroot -type f | xargs file -N | grep -E '\bELF.*LSB\b' | awk -F: '{print $$1}' | xargs rm -f
304 rm -f stage3-chroot/lib64/libc.so.6
306 # Copy in compiled glibc from the riscv-gnu-toolchain sysroot. Only
307 # copy files and symlinks, leave the target directory structure
309 stage3-chroot/lib64/libc.so.6:
310 mkdir -p stage3-chroot/usr/lib/audit
311 mkdir -p stage3-chroot/usr/lib/gconv
312 for f in `cd /usr/sysroot && find -type f -o -type l`; do \
313 cp -d /usr/sysroot/$$f stage3-chroot/$$f; \
315 cd stage3-chroot/lib64 && for f in ../lib/*; do ln -sf $$f; done
317 # Cross-compile ncurses.
318 stage3-chroot/usr/bin/tic: ncurses-$(NCURSES_VERSION).tgz
320 cd ncurses-$(NCURSES_VERSION) && \
321 PATH=$(ROOT)/fixed-gcc:$$PATH \
322 ./configure --host=riscv64-unknown-linux-gnu \
323 --prefix=/usr --libdir=/usr/lib64 \
325 cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
326 cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
327 cd $(ROOT)/stage3-chroot/usr/lib64 && ln -sf libtinfo.so.6 libtinfo.so
329 ncurses-$(NCURSES_VERSION).tgz:
331 wget -O $@-t ftp://invisible-island.net/ncurses/current/ncurses-$(NCURSES_VERSION).tgz
334 # Cross-compile bash.
335 stage3-chroot/bin/bash: bash-$(BASH_VERSION).tar.gz
337 cd bash-$(BASH_VERSION) && \
338 PATH=$(ROOT)/fixed-gcc:$$PATH \
339 ./configure --host=riscv64-unknown-linux-gnu \
340 --prefix=/usr --libdir=/usr/lib64
341 cd bash-$(BASH_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
342 cd bash-$(BASH_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
344 bash-$(BASH_VERSION).tar.gz:
346 wget -O $@-t ftp://ftp.gnu.org/gnu/bash/bash-$(BASH_VERSION).tar.gz
349 # Cross-compile coreutils. Bleah, coreutils cross-compilation is
350 # known-broken and upstream don't care, hence the 'touch' command.
352 COREUTILS_PROGRAMS = arch base32 base64 basename cat chcon chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold ginstall groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty sum sync tac tail tee test timeout touch tr true truncate tsort tty uname unexpand uniq unlink uptime users vdir wc who whoami yes
354 stage3-chroot/bin/ls: coreutils-$(COREUTILS_VERSION).tar.xz
355 rm -rf coreutils-$(COREUTILS_VERSION)
357 cd coreutils-$(COREUTILS_VERSION) && \
358 PATH=$(ROOT)/fixed-gcc:$$PATH \
359 ./configure --host=riscv64-unknown-linux-gnu \
360 --prefix=/usr --libdir=/usr/lib64
361 -cd coreutils-$(COREUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
362 cd coreutils-$(COREUTILS_VERSION)/man && \
363 for f in $(COREUTILS_PROGRAMS); do touch $$f.1; done
364 cd coreutils-$(COREUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
365 cd coreutils-$(COREUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
367 coreutils-$(COREUTILS_VERSION).tar.xz:
369 wget -O $@-t ftp://ftp.gnu.org/gnu/coreutils/coreutils-$(COREUTILS_VERSION).tar.xz
372 # Cross-compile binutils.
373 stage3-chroot/usr/bin/as: binutils-$(BINUTILS_X_VERSION).tar.gz
374 rm -rf binutils-$(BINUTILS_X_VERSION)
376 mkdir riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build
377 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && \
378 PATH=$(ROOT)/fixed-gcc:$$PATH \
380 --host=riscv64-unknown-linux-gnu \
381 --prefix=/usr --libdir=/usr/lib64
382 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make
383 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && make DESTDIR=$(ROOT)/stage3-chroot install
385 binutils-$(BINUTILS_X_VERSION).tar.gz:
387 wget -O $@-t https://github.com/riscv/riscv-binutils-gdb/archive/riscv-binutils-$(BINUTILS_X_VERSION).tar.gz
390 # Cross-compile GMP, MPFR and MPC (deps of GCC).
391 stage3-chroot/usr/lib64/libgmp.so.10: gmp-$(GMP_VERSION).tar.lz
392 rm -rf gmp-$(GMP_VERSION)
393 tar --lzip -xf gmp-$(GMP_VERSION).tar.lz
394 cd gmp-$(GMP_VERSION) && \
395 PATH=$(ROOT)/fixed-gcc:$$PATH \
396 ./configure --host=riscv64-unknown-linux-gnu \
397 --prefix=/usr --libdir=/usr/lib64
398 cd gmp-$(GMP_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
399 cd gmp-$(GMP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
400 cd stage3-chroot/usr/lib && ln -s ../lib64/libgmp.so
402 gmp-$(GMP_VERSION).tar.lz:
404 wget -O $@-t https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.lz
407 stage3-chroot/usr/lib64/libmpfr.so.4: mpfr-$(MPFR_VERSION).tar.gz
408 rm -rf mpfr-$(MPFR_VERSION)
409 tar -zxf mpfr-$(MPFR_VERSION).tar.gz
410 cd mpfr-$(MPFR_VERSION) && \
411 PATH=$(ROOT)/fixed-gcc:$$PATH \
412 ./configure --host=riscv64-unknown-linux-gnu \
413 --prefix=/usr --libdir=/usr/lib64 \
414 --with-gmp=$(ROOT)/stage3-chroot/usr
415 cd mpfr-$(MPFR_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
416 cd mpfr-$(MPFR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
417 cd stage3-chroot/usr/lib && ln -s ../lib64/libmpfr.so
419 mpfr-$(MPFR_VERSION).tar.gz:
421 wget -O $@-t http://www.mpfr.org/mpfr-current/mpfr-$(MPFR_VERSION).tar.gz
424 stage3-chroot/usr/lib64/libmpc.so.3: mpc-$(MPC_VERSION).tar.gz
425 rm -rf mpc-$(MPC_VERSION)
426 tar -zxf mpc-$(MPC_VERSION).tar.gz
427 cd mpc-$(MPC_VERSION) && \
428 PATH=$(ROOT)/fixed-gcc:$$PATH \
429 ./configure --host=riscv64-unknown-linux-gnu \
430 --prefix=/usr --libdir=/usr/lib64 \
431 --with-gmp=$(ROOT)/stage3-chroot/usr \
432 --with-mpfr=$(ROOT)/stage3-chroot/usr
433 cd mpc-$(MPC_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
434 cd mpc-$(MPC_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
435 cd stage3-chroot/usr/lib && ln -s ../lib64/libmpc.so
437 mpc-$(MPC_VERSION).tar.gz:
439 wget -O $@-t ftp://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VERSION).tar.gz
443 stage3-chroot/usr/bin/gcc: gcc-$(GCC_X_VERSION).tar.gz
444 rm -rf riscv-gcc-riscv-gcc-$(GCC_X_VERSION)
446 mkdir riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build
447 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && \
448 PATH=$(ROOT)/fixed-gcc:$$PATH \
450 --host=riscv64-unknown-linux-gnu \
451 --prefix=/usr --libdir=/usr/lib64 \
454 --enable-languages=c,c++ \
455 --disable-libmudflap \
457 --disable-libquadmath \
460 # XXX use make all & make install here. However building libgcc
461 # fails, see 'broken-gcc.log'.
462 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make all-gcc
463 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && make install-gcc DESTDIR=$(ROOT)/stage3-chroot
465 gcc-$(GCC_X_VERSION).tar.gz:
467 wget -O $@-t https://github.com/riscv/riscv-gcc/archive/riscv-gcc-$(GCC_X_VERSION).tar.gz
470 # Cross-compile util-linux.
471 # XXX Be nice to fix ncurses/tinfo support which in theory should work.
472 stage3-chroot/usr/bin/mount: util-linux-$(UTIL_LINUX_VERSION).tar.xz
473 rm -rf util-linux-$(UTIL_LINUX_VERSION)
475 cd util-linux-$(UTIL_LINUX_VERSION) && \
476 PATH=$(ROOT)/fixed-gcc:$$PATH \
478 --host=riscv64-unknown-linux-gnu \
479 --prefix=/usr --libdir=/usr/lib64 \
484 --disable-makeinstall-chown
485 cd util-linux-$(UTIL_LINUX_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
486 # libtool fucks something up here, ignore the failure and continue.
487 -cd util-linux-$(UTIL_LINUX_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot -j1 -k V=1
489 util-linux-$(UTIL_LINUX_VERSION).tar.xz:
491 wget -O $@-t ftp://ftp.kernel.org/pub/linux/utils/util-linux/v$(UTIL_LINUX_VERSION)/util-linux-$(UTIL_LINUX_VERSION).tar.xz
494 # Create an /init script.
495 stage3-chroot/init: init.sh
496 install -m 0755 $^ $@
498 # Create the stage3 disk image.
499 # Note `-s +...' adds spare space to the disk image.
500 stage3-disk.img: stage3-chroot
501 cd stage3-chroot && virt-make-fs . ../$@ -t ext2 -F raw -s +4G
503 # Upload the compressed disk image.
504 upload-stage3: stage3-disk.img.xz
505 scp $^ tick:public_html/riscv/
506 stage3-disk.img.xz: stage3-disk.img
510 # Helper which boots stage3 disk image in spike.
511 boot-stage3-in-spike: stage3-disk.img stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
512 spike +disk=stage3-disk.img \
513 /usr/bin/bbl stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
515 # Helper which boots stage3 disk image in qemu.
516 boot-stage3-in-qemu: stage3-disk.img stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
517 qemu-system-riscv -kernel /usr/bin/bbl \
518 -append ./stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \
519 -drive file=stage3-disk.img,format=raw -nographic