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 in the
38 # stage 3 chroot. This must include all the cross-compiled packages
39 # below, and may also include any noarch package we like.
40 STAGE3_PACKAGES = iso-codes \
41 ncurses-devel readline-devel bash coreutils gmp-devel \
42 mpfr-devel mpc-devel binutils gcc gcc-c++ util-linux tar \
43 gzip zlib-devel file-devel popt-devel beecrypt-devel \
44 rpm rpm-build rpm-devel libdb-utils libdb-devel nano \
45 grep less strace bzip2-devel make diffutils findutils \
46 sed patch hostname gettext-devel lua-devel xz-devel
48 # Versions of cross-compiled packages.
49 NCURSES_VERSION = 6.0-20160730
50 READLINE_VERSION = 6.3
52 COREUTILS_VERSION = 8.25
56 BINUTILS_X_VERSION = 2.26
58 UTIL_LINUX_VERSION = 2.28
62 # Needs to match the version of 'file' installed (on host), otherwise:
63 # "Cannot use the installed version of file (xx) to cross-compile file yy"
64 # Also note that 5.25 is definitely broken (segfaults in libmagic:magic_close).
67 BEECRYPT_VERSION = 4.2.1
68 RPM_COMMIT = 95712183458748ea6cafebac1bdd5daa097d9bee
69 RPM_SHORT_COMMIT = 9571218
74 STRACE_COMMIT = f320e1897832fd07a62e18ed288e75d8e79f4c5b
75 STRACE_SHORT_COMMIT = f320e189
78 DIFFUTILS_VERSION = 3.4
79 FINDUTILS_VERSION = 4.6.0
82 HOSTNAME_VERSION = 3.15
83 GETTEXT_VERSION = 0.19
87 all: stage1 stage2 stage3 stage4
91 stage1: stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz \
92 stage1-riscv-qemu/riscv-qemu.spec \
93 stamp-riscv-qemu-installed \
94 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz \
95 stage1-riscv-fesvr/riscv-fesvr.spec \
96 stamp-riscv-fesvr-installed \
97 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz \
98 stage1-riscv-isa-sim/riscv-isa-sim.spec \
99 stamp-riscv-isa-sim-installed
101 stage1-riscv-qemu/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz:
103 wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/$(RISCV_QEMU_COMMIT)/riscv-qemu-$(RISCV_QEMU_SHORTCOMMIT).tar.gz'
106 stage1-riscv-qemu/riscv-qemu.spec: stage1-riscv-qemu/riscv-qemu.spec.in
107 sed -e 's/@COMMIT@/$(RISCV_QEMU_COMMIT)/g' \
108 -e 's/@SHORTCOMMIT@/$(RISCV_QEMU_SHORTCOMMIT)/g' \
112 stamp-riscv-qemu-installed:
114 @rpm -q riscv-qemu >/dev/null || { \
115 echo "ERROR: You must install riscv-qemu:"; \
117 echo " dnf copr enable rjones/riscv"; \
118 echo " dnf install riscv-qemu"; \
120 echo "OR: you can build it yourself from the stage1-riscv-qemu directory."; \
124 @qemu-system-riscv --version || { \
125 echo "ERROR: qemu-system-riscv is not working."; \
126 echo "Make sure you installed the riscv-qemu package."; \
131 stage1-riscv-fesvr/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz:
133 wget -O $@-t 'https://github.com/riscv/riscv-fesvr/archive/$(RISCV_FESVR_COMMIT)/riscv-fesvr-$(RISCV_FESVR_SHORTCOMMIT).tar.gz'
136 stage1-riscv-fesvr/riscv-fesvr.spec: stage1-riscv-fesvr/riscv-fesvr.spec.in
137 sed -e 's/@COMMIT@/$(RISCV_FESVR_COMMIT)/g' \
138 -e 's/@SHORTCOMMIT@/$(RISCV_FESVR_SHORTCOMMIT)/g' \
142 stamp-riscv-fesvr-installed:
144 @rpm -q riscv-fesvr >/dev/null || { \
145 echo "ERROR: You must install riscv-fesvr:"; \
147 echo " dnf copr enable rjones/riscv"; \
148 echo " dnf install riscv-fesvr"; \
150 echo "OR: you can build it yourself from the stage1-riscv-fesvr directory."; \
156 stage1-riscv-isa-sim/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz:
158 wget -O $@-t 'https://github.com/riscv/riscv-isa-sim/archive/$(RISCV_ISA_SIM_COMMIT)/riscv-isa-sim-$(RISCV_ISA_SIM_SHORTCOMMIT).tar.gz'
161 stage1-riscv-isa-sim/riscv-isa-sim.spec: stage1-riscv-isa-sim/riscv-isa-sim.spec.in
162 sed -e 's/@COMMIT@/$(RISCV_ISA_SIM_COMMIT)/g' \
163 -e 's/@SHORTCOMMIT@/$(RISCV_ISA_SIM_SHORTCOMMIT)/g' \
167 stamp-riscv-isa-sim-installed:
169 @rpm -q riscv-isa-sim >/dev/null || { \
170 echo "ERROR: You must install riscv-isa-sim:"; \
172 echo " dnf copr enable rjones/riscv"; \
173 echo " dnf install riscv-isa-sim"; \
175 echo "OR: you can build it yourself from the stage1-riscv-isa-sim directory."; \
183 stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz \
184 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz \
185 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz \
186 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz \
187 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz \
188 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec \
189 stamp-riscv-gnu-toolchain-installed \
190 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz \
191 stage2-riscv-pk/riscv-pk.spec \
192 stamp-riscv-pk-installed
194 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz:
196 wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/$(RISCV_GNU_TOOLCHAIN_COMMIT)/riscv-gnu-toolchain-$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT).tar.gz
199 stage2-riscv-gnu-toolchain/binutils-$(BINUTILS_VERSION).tar.gz:
201 wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz
204 # GCC 5 no longer compiles with GCC 6 unless we patch it.
205 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69959
206 stage2-riscv-gnu-toolchain/gcc-$(GCC_VERSION).tar.gz:
208 wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.gz
210 cd gcc-$(GCC_VERSION) && patch -p0 < ../stage2-riscv-gnu-toolchain/gcc-5-fix-compilation-with-gcc-6.patch
211 tar zcf $@-t gcc-$(GCC_VERSION)
212 rm -r gcc-$(GCC_VERSION)
215 stage2-riscv-gnu-toolchain/glibc-$(GLIBC_VERSION).tar.gz:
217 wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-$(GLIBC_VERSION).tar.gz
220 stage2-riscv-gnu-toolchain/newlib-$(NEWLIB_VERSION).tar.gz:
222 wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
225 stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec.in
226 sed -e 's/@COMMIT@/$(RISCV_GNU_TOOLCHAIN_COMMIT)/g' \
227 -e 's/@SHORTCOMMIT@/$(RISCV_GNU_TOOLCHAIN_SHORTCOMMIT)/g' \
228 -e 's/@BINUTILS_VERSION@/$(BINUTILS_VERSION)/g' \
229 -e 's/@GCC_VERSION@/$(GCC_VERSION)/g' \
230 -e 's/@GLIBC_VERSION@/$(GLIBC_VERSION)/g' \
231 -e 's/@NEWLIB_VERSION@/$(NEWLIB_VERSION)/g' \
235 stamp-riscv-gnu-toolchain-installed:
237 @rpm -q riscv-gnu-toolchain >/dev/null || { \
238 echo "ERROR: You must install riscv-gnu-toolchain:"; \
240 echo " dnf copr enable rjones/riscv"; \
241 echo " dnf install riscv-gnu-toolchain"; \
243 echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
247 @riscv64-unknown-elf-gcc --version || { \
248 echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
249 echo "Make sure you installed the riscv-gnu-toolchain package."; \
254 stage2-riscv-pk/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz:
256 wget -O $@-t https://github.com/lowRISC/riscv-pk/archive/$(RISCV_PK_COMMIT)/riscv-pk-$(RISCV_PK_SHORTCOMMIT).tar.gz
259 stage2-riscv-pk/riscv-pk.spec: stage2-riscv-pk/riscv-pk.spec.in
260 sed -e 's/@COMMIT@/$(RISCV_PK_COMMIT)/g' \
261 -e 's/@SHORTCOMMIT@/$(RISCV_PK_SHORTCOMMIT)/g' \
265 stamp-riscv-pk-installed:
267 @rpm -q riscv-pk >/dev/null || { \
268 echo "ERROR: You must install riscv-pk:"; \
270 echo " dnf copr enable rjones/riscv"; \
271 echo " dnf install riscv-pk"; \
273 echo "OR: you can build it yourself from the stage2-riscv-pk directory."; \
281 stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \
282 stage3-chroot-original/etc/fedora-release \
283 stage3-chroot/etc/fedora-release \
284 stage3-chroot/lib64/libc.so.6 \
285 stage3-chroot/usr/bin/tic \
286 stage3-chroot/usr/lib64/libhistory.so.6 \
287 stage3-chroot/bin/bash \
288 stage3-chroot/bin/ls \
289 stage3-chroot/usr/lib64/libgmp.so.10 \
290 stage3-chroot/usr/lib64/libmpfr.so.4 \
291 stage3-chroot/usr/lib64/libmpc.so.3 \
292 stage3-chroot/usr/bin/as \
293 stage3-chroot/usr/bin/gcc \
294 stage3-chroot/usr/bin/mount \
295 stage3-chroot/usr/bin/tar \
296 stage3-chroot/usr/bin/gzip \
297 stage3-chroot/usr/lib64/libz.so \
298 stage3-chroot/usr/bin/file \
299 stage3-chroot/usr/lib64/libpopt.so \
300 stage3-chroot/usr/lib64/libbeecrypt.so \
301 stage3-chroot/usr/bin/nano \
302 stage3-chroot/usr/bin/grep \
303 stage3-chroot/usr/bin/less \
304 stage3-chroot/usr/bin/strace \
305 stage3-chroot/usr/bin/bzip2 \
306 stage3-chroot/usr/bin/make \
307 stage3-chroot/usr/bin/diff \
308 stage3-chroot/usr/bin/find \
309 stage3-chroot/usr/bin/sed \
310 stage3-chroot/usr/bin/patch \
311 stage3-chroot/usr/bin/hostname \
312 stage3-chroot/usr/bin/gettext \
313 stage3-chroot/usr/bin/lua \
314 stage3-chroot/usr/bin/rpm \
315 stage3-chroot/usr/bin/xz \
319 stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
320 rm -rf stage3-kernel/linux-$(KERNEL_VERSION)
321 cp -a $(LOCAL_LINUX_GIT_COPY) stage3-kernel/linux-$(KERNEL_VERSION) || { \
322 mkdir stage3-kernel/linux-$(KERNEL_VERSION) && \
323 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
326 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
327 git remote add riscv https://github.com/riscv/riscv-linux && \
329 git checkout -f linux-4.1.y-riscv && \
331 make ARCH=riscv defconfig
332 echo CONFIG_CMDLINE=\"root=/dev/htifblk0 init=/init\" >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
333 echo CONFIG_CROSS_COMPILE=riscv64-unknown-elf- >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
334 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
335 make ARCH=riscv olddefconfig
336 cd stage3-kernel/linux-$(KERNEL_VERSION) && \
337 make ARCH=riscv vmlinux
340 # Build an original (x86-64) chroot using supermin. We then aim to
341 # rebuild (using cross-compiled versions) every ELF binary in this
343 stage3-chroot-original/etc/fedora-release:
344 rm -rf stage3-chroot-original tmp-supermin.d
345 supermin --prepare $(STAGE3_PACKAGES) -o tmp-supermin.d
346 supermin --build -f chroot tmp-supermin.d -o stage3-chroot-original
348 @echo -n "Total files in chroot: "
349 @find stage3-chroot-original -type f | wc -l
350 @echo -n "ELF files to be rebuilt: "
351 @find stage3-chroot-original -type f | xargs file -N | grep -E '\bELF.*LSB\b' | wc -l
353 # Copy the original chroot to the final chroot, remove all the ELF
355 stage3-chroot/etc/fedora-release: stage3-chroot-original/etc/fedora-release
357 cp -a stage3-chroot-original stage3-chroot
358 find stage3-chroot -type d -print0 | xargs -0 chmod u+w
359 find stage3-chroot -type f -print0 | xargs -0 chmod u+w
360 find stage3-chroot -type f -print0 | xargs -0 file -N | grep -E '\bELF.*LSB\b' | awk -F: '{print $$1}' | xargs rm -f
361 rm -f stage3-chroot/lib64/libc.so.6
363 # Copy in compiled glibc from the riscv-gnu-toolchain sysroot. Only
364 # copy files and symlinks, leave the target directory structure
366 stage3-chroot/lib64/libc.so.6:
367 mkdir -p stage3-chroot/usr/lib/audit
368 mkdir -p stage3-chroot/usr/lib/gconv
369 for f in `cd /usr/sysroot && find -type f -o -type l`; do \
370 cp -d /usr/sysroot/$$f stage3-chroot/$$f; \
372 cd stage3-chroot/lib64 && for f in ../lib/*; do ln -sf $$f; done
374 # Cross-compile ncurses.
375 stage3-chroot/usr/bin/tic: ncurses-$(NCURSES_VERSION).tgz
377 cd ncurses-$(NCURSES_VERSION) && \
378 PATH=$(ROOT)/fixed-gcc:$$PATH \
379 ./configure --host=riscv64-unknown-linux-gnu \
380 --prefix=/usr --libdir=/usr/lib64 \
382 --with-termlib=tinfo \
384 cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
385 cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
387 ncurses-$(NCURSES_VERSION).tgz:
389 wget -O $@-t ftp://invisible-island.net/ncurses/current/ncurses-$(NCURSES_VERSION).tgz
392 # Cross-compile readline.
393 stage3-chroot/usr/lib64/libhistory.so.6: readline-$(READLINE_VERSION).tar.gz
395 cd readline-$(READLINE_VERSION) && \
396 PATH=$(ROOT)/fixed-gcc:$$PATH \
397 bash_cv_wcwidth_broken=no \
398 ./configure --host=riscv64-unknown-linux-gnu \
399 --prefix=/usr --libdir=/usr/lib64
400 cd readline-$(READLINE_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
401 cd readline-$(READLINE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
402 rm -f stage3-chroot/usr/lib64/*.la
404 readline-$(READLINE_VERSION).tar.gz:
406 wget -O $@-t ftp://ftp.gnu.org/gnu/readline/readline-$(READLINE_VERSION).tar.gz
409 # Cross-compile bash.
410 stage3-chroot/bin/bash: bash-$(BASH_VERSION).tar.gz
412 cd bash-$(BASH_VERSION) && \
413 PATH=$(ROOT)/fixed-gcc:$$PATH \
414 ./configure --host=riscv64-unknown-linux-gnu \
415 --prefix=/usr --libdir=/usr/lib64
416 cd bash-$(BASH_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
417 cd bash-$(BASH_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
419 bash-$(BASH_VERSION).tar.gz:
421 wget -O $@-t ftp://ftp.gnu.org/gnu/bash/bash-$(BASH_VERSION).tar.gz
424 # Cross-compile coreutils. Bleah, coreutils cross-compilation is
425 # known-broken and upstream don't care, hence the 'touch' command.
427 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
429 stage3-chroot/bin/ls: coreutils-$(COREUTILS_VERSION).tar.xz
430 rm -rf coreutils-$(COREUTILS_VERSION)
432 cd coreutils-$(COREUTILS_VERSION) && \
433 PATH=$(ROOT)/fixed-gcc:$$PATH \
434 ./configure --host=riscv64-unknown-linux-gnu \
435 --prefix=/usr --libdir=/usr/lib64
436 -cd coreutils-$(COREUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
437 cd coreutils-$(COREUTILS_VERSION)/man && \
438 for f in $(COREUTILS_PROGRAMS); do touch $$f.1; done
439 cd coreutils-$(COREUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
440 cd coreutils-$(COREUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
442 coreutils-$(COREUTILS_VERSION).tar.xz:
444 wget -O $@-t ftp://ftp.gnu.org/gnu/coreutils/coreutils-$(COREUTILS_VERSION).tar.xz
447 # Cross-compile binutils.
448 stage3-chroot/usr/bin/as: binutils-$(BINUTILS_X_VERSION).tar.gz
449 rm -rf riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)
451 mkdir riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build
452 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && \
453 PATH=$(ROOT)/fixed-gcc:$$PATH \
455 --host=riscv64-unknown-linux-gnu \
456 --prefix=/usr --libdir=/usr/lib64
457 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make
458 cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && make DESTDIR=$(ROOT)/stage3-chroot install
460 binutils-$(BINUTILS_X_VERSION).tar.gz:
462 wget -O $@-t https://github.com/riscv/riscv-binutils-gdb/archive/riscv-binutils-$(BINUTILS_X_VERSION).tar.gz
465 # Cross-compile GMP, MPFR and MPC (deps of GCC).
466 stage3-chroot/usr/lib64/libgmp.so.10: gmp-$(GMP_VERSION).tar.lz
467 rm -rf gmp-$(GMP_VERSION)
468 tar --lzip -xf gmp-$(GMP_VERSION).tar.lz
469 cd gmp-$(GMP_VERSION) && \
470 PATH=$(ROOT)/fixed-gcc:$$PATH \
471 ./configure --host=riscv64-unknown-linux-gnu \
472 --prefix=/usr --libdir=/usr/lib64
473 cd gmp-$(GMP_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
474 cd gmp-$(GMP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
475 cd stage3-chroot/usr/lib && ln -s ../lib64/libgmp.so
477 gmp-$(GMP_VERSION).tar.lz:
479 wget -O $@-t https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.lz
482 stage3-chroot/usr/lib64/libmpfr.so.4: mpfr-$(MPFR_VERSION).tar.gz
483 rm -rf mpfr-$(MPFR_VERSION)
484 tar -zxf mpfr-$(MPFR_VERSION).tar.gz
485 cd mpfr-$(MPFR_VERSION) && \
486 PATH=$(ROOT)/fixed-gcc:$$PATH \
487 ./configure --host=riscv64-unknown-linux-gnu \
488 --prefix=/usr --libdir=/usr/lib64 \
489 --with-gmp=$(ROOT)/stage3-chroot/usr
490 cd mpfr-$(MPFR_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
491 cd mpfr-$(MPFR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
492 cd stage3-chroot/usr/lib && ln -s ../lib64/libmpfr.so
493 rm -f stage3-chroot/usr/lib64/*.la
495 mpfr-$(MPFR_VERSION).tar.gz:
497 wget -O $@-t http://www.mpfr.org/mpfr-current/mpfr-$(MPFR_VERSION).tar.gz
500 stage3-chroot/usr/lib64/libmpc.so.3: mpc-$(MPC_VERSION).tar.gz
501 rm -rf mpc-$(MPC_VERSION)
502 tar -zxf mpc-$(MPC_VERSION).tar.gz
503 cd mpc-$(MPC_VERSION) && \
504 PATH=$(ROOT)/fixed-gcc:$$PATH \
505 ./configure --host=riscv64-unknown-linux-gnu \
506 --prefix=/usr --libdir=/usr/lib64 \
507 --with-gmp=$(ROOT)/stage3-chroot/usr \
508 --with-mpfr=$(ROOT)/stage3-chroot/usr
509 cd mpc-$(MPC_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
510 cd mpc-$(MPC_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
511 cd stage3-chroot/usr/lib && ln -s ../lib64/libmpc.so
512 rm -f stage3-chroot/usr/lib64/*.la
514 mpc-$(MPC_VERSION).tar.gz:
516 wget -O $@-t ftp://ftp.gnu.org/gnu/mpc/mpc-$(MPC_VERSION).tar.gz
520 stage3-chroot/usr/bin/gcc: gcc-$(GCC_X_VERSION).tar.gz
521 rm -rf riscv-gcc-riscv-gcc-$(GCC_X_VERSION)
523 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION) && \
524 patch -p1 < ../0001-HACKS-TO-GET-GCC-TO-COMPILE.patch
525 mkdir riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build
526 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && \
527 PATH=$(ROOT)/fixed-gcc:$$PATH \
529 --host=riscv64-unknown-linux-gnu \
530 --prefix=/usr --libdir=/usr/lib64 \
533 --enable-languages=c,c++ \
534 --disable-libmudflap \
536 --disable-libquadmath \
539 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make
540 cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && make install DESTDIR=$(ROOT)/stage3-chroot
541 rm -f stage3-chroot/usr/lib64/*.la
543 gcc-$(GCC_X_VERSION).tar.gz:
545 wget -O $@-t https://github.com/riscv/riscv-gcc/archive/riscv-gcc-$(GCC_X_VERSION).tar.gz
548 # Cross-compile util-linux.
549 stage3-chroot/usr/bin/mount: util-linux-$(UTIL_LINUX_VERSION).tar.xz
550 rm -rf util-linux-$(UTIL_LINUX_VERSION)
552 cd util-linux-$(UTIL_LINUX_VERSION) && \
553 PATH=$(ROOT)/fixed-gcc:$$PATH \
554 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
556 --host=riscv64-unknown-linux-gnu \
557 --prefix=/usr --libdir=/usr/lib64 \
560 --disable-makeinstall-chown \
561 --enable-static-programs=mount
562 cd util-linux-$(UTIL_LINUX_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
563 cd util-linux-$(UTIL_LINUX_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
564 rm -f stage3-chroot/usr/lib64/*.la
566 util-linux-$(UTIL_LINUX_VERSION).tar.xz:
568 wget -O $@-t ftp://ftp.kernel.org/pub/linux/utils/util-linux/v$(UTIL_LINUX_VERSION)/util-linux-$(UTIL_LINUX_VERSION).tar.xz
571 # Cross-compile GNU tar.
572 stage3-chroot/usr/bin/tar: tar-$(TAR_VERSION).tar.xz
573 rm -rf tar-$(TAR_VERSION)
575 cd tar-$(TAR_VERSION) && \
576 PATH=$(ROOT)/fixed-gcc:$$PATH \
578 --host=riscv64-unknown-linux-gnu \
579 --prefix=/usr --libdir=/usr/lib64
580 cd tar-$(TAR_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
581 cd tar-$(TAR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
583 tar-$(TAR_VERSION).tar.xz:
585 wget -O $@-t https://ftp.gnu.org/gnu/tar/tar-$(TAR_VERSION).tar.xz
588 # Cross-compile GNU gzip.
589 stage3-chroot/usr/bin/gzip: gzip-$(GZIP_VERSION).tar.gz
590 rm -rf gzip-$(GZIP_VERSION)
592 cd gzip-$(GZIP_VERSION) && \
593 PATH=$(ROOT)/fixed-gcc:$$PATH \
595 --host=riscv64-unknown-linux-gnu \
596 --prefix=/usr --libdir=/usr/lib64
597 cd gzip-$(GZIP_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
598 cd gzip-$(GZIP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
600 gzip-$(GZIP_VERSION).tar.gz:
602 wget -O $@-t https://ftp.gnu.org/gnu/gzip/gzip-$(GZIP_VERSION).tar.gz
605 # Cross-compile zlib.
606 stage3-chroot/usr/lib64/libz.so: zlib-$(ZLIB_VERSION).tar.gz
607 rm -rf zlib-$(ZLIB_VERSION)
609 cd zlib-$(ZLIB_VERSION) && \
610 PATH=$(ROOT)/fixed-gcc:$$PATH \
611 CC=riscv64-unknown-linux-gnu-gcc \
612 CFLAGS="-I$(ROOT)/stage3-chroot/usr/include -L$(ROOT)/stage3-chroot/usr/lib" \
614 --prefix=/usr --libdir=/usr/lib64
615 cd zlib-$(ZLIB_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make shared
616 cd zlib-$(ZLIB_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
618 zlib-$(ZLIB_VERSION).tar.gz:
620 wget -O $@-t http://zlib.net/zlib-$(ZLIB_VERSION).tar.gz
623 # Cross-compile file/libmagic.
624 stage3-chroot/usr/bin/file: file-$(FILE_VERSION).tar.gz
625 rm -rf file-$(FILE_VERSION)
627 cd file-$(FILE_VERSION) && \
628 PATH=$(ROOT)/fixed-gcc:$$PATH \
629 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
631 --host=riscv64-unknown-linux-gnu \
632 --prefix=/usr --libdir=/usr/lib64 \
633 --disable-static --enable-shared
634 cd file-$(FILE_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
635 cd file-$(FILE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
636 rm -f stage3-chroot/usr/lib64/*.la
638 file-$(FILE_VERSION).tar.gz:
640 wget -O $@-t ftp://ftp.astron.com/pub/file/file-$(FILE_VERSION).tar.gz
643 # Cross-compile popt.
644 stage3-chroot/usr/lib64/libpopt.so: popt-$(POPT_VERSION).tar.gz
645 rm -rf popt-$(POPT_VERSION)
647 cd popt-$(POPT_VERSION) && \
648 PATH=$(ROOT)/fixed-gcc:$$PATH \
649 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
651 --host=riscv64-unknown-linux-gnu \
652 --prefix=/usr --libdir=/usr/lib64 \
653 --disable-static --enable-shared
654 cd popt-$(POPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
655 cd popt-$(POPT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
656 rm -f stage3-chroot/usr/lib64/*.la
658 popt-$(POPT_VERSION).tar.gz:
660 wget -O $@-t http://rpm5.org/files/popt/popt-$(POPT_VERSION).tar.gz
663 # Cross-compile beecrypt.
664 stage3-chroot/usr/lib64/libbeecrypt.so: beecrypt-$(BEECRYPT_VERSION).tar.gz
665 rm -rf beecrypt-$(BEECRYPT_VERSION)
667 cd beecrypt-$(BEECRYPT_VERSION) && patch -p0 < ../beecrypt-disable-cplusplus.patch
668 cd beecrypt-$(BEECRYPT_VERSION) && autoreconf -i
669 cd beecrypt-$(BEECRYPT_VERSION) && \
670 PATH=$(ROOT)/fixed-gcc:$$PATH \
671 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
673 --host=riscv64-unknown-linux-gnu \
674 --prefix=/usr --libdir=/usr/lib64 \
675 --without-cplusplus \
680 cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
681 cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot V=1
682 chrpath -d stage3-chroot/usr/lib64/libbeecrypt.so.*
683 rm -f stage3-chroot/usr/lib64/*.la
685 beecrypt-$(BEECRYPT_VERSION).tar.gz:
687 wget -O $@-t http://downloads.sourceforge.net/sourceforge/beecrypt/beecrypt-$(BEECRYPT_VERSION).tar.gz
690 # Cross-compile GNU nano (editor).
691 stage3-chroot/usr/bin/nano: nano-$(NANO_VERSION).tar.gz
692 rm -rf nano-$(NANO_VERSION)
694 cd nano-$(NANO_VERSION) && \
695 PATH=$(ROOT)/fixed-gcc:$$PATH \
696 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
698 --host=riscv64-unknown-linux-gnu \
699 --prefix=/usr --libdir=/usr/lib64
700 cd nano-$(NANO_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
701 cd nano-$(NANO_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
703 nano-$(NANO_VERSION).tar.gz:
705 wget -O $@-t https://www.nano-editor.org/dist/v2.6/nano-$(NANO_VERSION).tar.gz
708 # Cross-compile GNU grep.
709 stage3-chroot/usr/bin/grep: grep-$(GREP_VERSION).tar.xz
710 rm -rf grep-$(GREP_VERSION)
712 cd grep-$(GREP_VERSION) && \
713 PATH=$(ROOT)/fixed-gcc:$$PATH \
715 --host=riscv64-unknown-linux-gnu \
716 --prefix=/usr --libdir=/usr/lib64
717 cd grep-$(GREP_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
718 cd grep-$(GREP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
720 grep-$(GREP_VERSION).tar.xz:
722 wget -O $@-t https://ftp.gnu.org/gnu/grep/grep-$(GREP_VERSION).tar.xz
725 # Cross-compile less.
726 stage3-chroot/usr/bin/less: less-$(LESS_VERSION).tar.gz
727 rm -rf less-$(LESS_VERSION)
729 cd less-$(LESS_VERSION) && \
730 PATH=$(ROOT)/fixed-gcc:$$PATH \
731 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
733 --host=riscv64-unknown-linux-gnu \
734 --prefix=/usr --libdir=/usr/lib64
735 cd less-$(LESS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
736 cd less-$(LESS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
738 less-$(LESS_VERSION).tar.gz:
740 wget -O $@-t http://www.greenwoodsoftware.com/less/less-$(LESS_VERSION).tar.gz
743 # Cross-compile strace.
744 # XXX This does not work.
745 stage3-chroot/usr/bin/strace: strace-$(STRACE_SHORT_COMMIT).tar.gz
746 rm -rf strace-$(STRACE_SHORT_COMMIT)
748 cd riscv-strace-$(STRACE_COMMIT) && patch -p1 < ../0001-Update-riscv_regs-for-ptrace.h-from-Linux-4.1.x.patch
749 cd riscv-strace-$(STRACE_COMMIT) && \
750 PATH=$(ROOT)/fixed-gcc:$$PATH \
751 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
753 --host=riscv64-unknown-linux-gnu \
754 --prefix=/usr --libdir=/usr/lib64
755 cd riscv-strace-$(STRACE_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make
756 cd riscv-strace-$(STRACE_COMMIT) && make install DESTDIR=$(ROOT)/stage3-chroot
758 strace-$(STRACE_SHORT_COMMIT).tar.gz:
760 wget -O $@-t 'https://github.com/riscv/riscv-strace/archive/$(STRACE_COMMIT)/riscv-strace-$(STRACE_SHORTCOMMIT).tar.gz'
763 # Cross-compile bzip2.
764 stage3-chroot/usr/bin/bzip2: bzip2-$(BZIP2_VERSION).tar.gz
765 rm -rf bzip2-$(BZIP2_VERSION)
767 cd bzip2-$(BZIP2_VERSION) && \
768 PATH=$(ROOT)/fixed-gcc:$$PATH \
769 make libbz2.a bzip2 bzip2recover \
771 CC=riscv64-unknown-linux-gnu-gcc \
772 AR=riscv64-unknown-linux-gnu-ar \
773 RANLIB=riscv64-unknown-linux-gnu-ranlib \
774 CFLAGS="-Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -fPIC"
775 cd bzip2-$(BZIP2_VERSION) && \
776 make install PREFIX=$(ROOT)/stage3-chroot/usr
778 bzip2-$(BZIP2_VERSION).tar.gz:
780 wget -O $@-t http://www.bzip.org/1.0.6/bzip2-$(BZIP2_VERSION).tar.gz
783 # Cross-compile GNU make.
784 stage3-chroot/usr/bin/make: make-$(MAKE_VERSION).tar.gz
785 rm -rf make-$(MAKE_VERSION)
787 cd make-$(MAKE_VERSION) && \
788 PATH=$(ROOT)/fixed-gcc:$$PATH \
790 --host=riscv64-unknown-linux-gnu \
791 --prefix=/usr --libdir=/usr/lib64
792 cd make-$(MAKE_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
793 cd make-$(MAKE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
795 make-$(MAKE_VERSION).tar.gz:
797 wget -O $@-t https://ftp.gnu.org/gnu/make/make-$(MAKE_VERSION).tar.gz
800 # Cross-compile GNU diffutils.
801 stage3-chroot/usr/bin/diff: diffutils-$(DIFFUTILS_VERSION).tar.xz
802 rm -rf diffutils-$(DIFFUTILS_VERSION)
804 cd diffutils-$(DIFFUTILS_VERSION) && \
805 PATH=$(ROOT)/fixed-gcc:$$PATH \
807 --host=riscv64-unknown-linux-gnu \
808 --prefix=/usr --libdir=/usr/lib64
809 cd diffutils-$(DIFFUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
810 cd diffutils-$(DIFFUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
812 diffutils-$(DIFFUTILS_VERSION).tar.xz:
814 wget -O $@-t https://ftp.gnu.org/gnu/diffutils/diffutils-$(DIFFUTILS_VERSION).tar.xz
817 # Cross-compile GNU findutils.
818 stage3-chroot/usr/bin/find: findutils-$(FINDUTILS_VERSION).tar.gz
819 rm -rf findutils-$(FINDUTILS_VERSION)
821 cd findutils-$(FINDUTILS_VERSION) && \
822 PATH=$(ROOT)/fixed-gcc:$$PATH \
824 --host=riscv64-unknown-linux-gnu \
825 --prefix=/usr --libdir=/usr/lib64
826 cd findutils-$(FINDUTILS_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
827 cd findutils-$(FINDUTILS_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
829 findutils-$(FINDUTILS_VERSION).tar.gz:
831 wget -O $@-t https://ftp.gnu.org/gnu/findutils/findutils-$(FINDUTILS_VERSION).tar.gz
834 # Cross-compile GNU sed.
835 stage3-chroot/usr/bin/sed: sed-$(SED_VERSION).tar.gz
836 rm -rf sed-$(SED_VERSION)
838 cd sed-$(SED_VERSION) && \
839 PATH=$(ROOT)/fixed-gcc:$$PATH \
841 --host=riscv64-unknown-linux-gnu \
842 --prefix=/usr --libdir=/usr/lib64
843 cd sed-$(SED_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
844 cd sed-$(SED_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
846 sed-$(SED_VERSION).tar.gz:
848 wget -O $@-t https://ftp.gnu.org/gnu/sed/sed-$(SED_VERSION).tar.gz
851 # Cross-compile patch.
852 stage3-chroot/usr/bin/patch: patch-$(PATCH_VERSION).tar.gz
853 rm -rf patch-$(PATCH_VERSION)
855 cd patch-$(PATCH_VERSION) && \
856 PATH=$(ROOT)/fixed-gcc:$$PATH \
858 --host=riscv64-unknown-linux-gnu \
859 --prefix=/usr --libdir=/usr/lib64
860 cd patch-$(PATCH_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
861 cd patch-$(PATCH_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
863 patch-$(PATCH_VERSION).tar.gz:
865 wget -O $@-t https://ftp.gnu.org/gnu/patch/patch-$(PATCH_VERSION).tar.gz
868 # Cross-compile hostname.
869 stage3-chroot/usr/bin/hostname: hostname-$(HOSTNAME_VERSION).tar.gz
870 rm -rf hostname-$(HOSTNAME_VERSION)
872 cd hostname && patch -p1 < ../hostname-rh.patch
874 PATH=$(ROOT)/fixed-gcc:$$PATH \
876 CC=riscv64-unknown-linux-gnu-gcc \
878 cd hostname && make install BASEDIR=$(ROOT)/stage3-chroot
880 hostname-$(HOSTNAME_VERSION).tar.gz:
882 wget -O $@-t http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_$(HOSTNAME_VERSION).tar.gz
885 # Cross-compile GNU gettext.
886 stage3-chroot/usr/bin/gettext: gettext-$(GETTEXT_VERSION).tar.gz
887 rm -rf gettext-$(GETTEXT_VERSION)
889 cd gettext-$(GETTEXT_VERSION) && \
890 PATH=$(ROOT)/fixed-gcc:$$PATH \
892 --host=riscv64-unknown-linux-gnu \
893 --prefix=/usr --libdir=/usr/lib64
894 cd gettext-$(GETTEXT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
895 cd gettext-$(GETTEXT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
896 rm -f stage3-chroot/usr/lib64/*.la
898 gettext-$(GETTEXT_VERSION).tar.gz:
900 wget -O $@-t https://ftp.gnu.org/gnu/gettext/gettext-$(GETTEXT_VERSION).tar.gz
904 stage3-chroot/usr/bin/lua: lua-$(LUA_VERSION).tar.gz
905 rm -rf lua-$(LUA_VERSION)
907 cd lua-$(LUA_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make PLAT=linux INSTALL_TOP=/usr CC=riscv64-unknown-linux-gnu-gcc AR="riscv64-unknown-linux-gnu-ar rcu" RANLIB="riscv64-unknown-linux-gnu-ranlib" MYLDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 MYLIBS=-ltinfo MYCFLAGS="-fPIC -DLUA_COMPAT_5_1"
908 cd lua-$(LUA_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install INSTALL_TOP=$(ROOT)/stage3-chroot/usr INSTALL_LIB=$(ROOT)/stage3-chroot/usr/lib64
910 lua-$(LUA_VERSION).tar.gz:
912 wget -O $@-t https://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz
916 stage3-chroot/usr/bin/xz: xz-$(XZ_VERSION).tar.gz
917 rm -rf xz-$(XZ_VERSION)
919 cd xz-$(XZ_VERSION) && \
920 PATH=$(ROOT)/fixed-gcc:$$PATH \
922 --host=riscv64-unknown-linux-gnu \
923 --prefix=/usr --libdir=/usr/lib64
924 cd xz-$(XZ_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
925 cd xz-$(XZ_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
926 rm -f stage3-chroot/usr/lib64/*.la
928 xz-$(XZ_VERSION).tar.gz:
930 wget -O $@-t http://tukaani.org/xz/xz-$(XZ_VERSION).tar.gz
933 # Cross-compile RPM / rpmbuild.
934 # We build this from a git commit, with a few hacks to the configure
936 stage3-chroot/usr/bin/rpm: rpm-$(RPM_SHORT_COMMIT).tar.gz db-$(BDB_VERSION).tar.gz
937 rm -rf rpm-$(RPM_SHORT_COMMIT)
938 tar -zxf rpm-$(RPM_SHORT_COMMIT).tar.gz
939 tar -zxf db-$(BDB_VERSION).tar.gz -C rpm-$(RPM_SHORT_COMMIT)
940 cd rpm-$(RPM_SHORT_COMMIT) && ln -s db-$(BDB_VERSION) db
941 cd rpm-$(RPM_SHORT_COMMIT) && \
942 patch -p1 < ../0001-RISCV-64-bit-riscv64-support.patch && \
943 patch -p1 < ../0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch && \
944 patch -p1 < ../0003-build-fgetc-returns-int-not-char.patch && \
945 patch -p1 < ../0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch
946 cd rpm-$(RPM_SHORT_COMMIT) && autoreconf -i
947 cd rpm-$(RPM_SHORT_COMMIT) && \
948 PATH=$(ROOT)/fixed-gcc:$$PATH \
949 LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
951 --host=riscv64-unknown-linux-gnu \
952 --prefix=/usr --libdir=/usr/lib64 \
954 --with-vendor=redhat \
955 --without-libarchive \
959 --without-external-db \
962 cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
963 cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
964 rm -f stage3-chroot/usr/lib64/*.la
966 rpm-$(RPM_SHORT_COMMIT).tar.gz:
968 wget -O $@-t 'http://rpm.org/gitweb?p=rpm.git;a=snapshot;h=$(RPM_COMMIT);sf=tgz'
971 db-$(BDB_VERSION).tar.gz:
973 wget -O $@-t http://download.oracle.com/berkeley-db/db-$(BDB_VERSION).tar.gz
976 # Create an /init script.
977 stage3-chroot/init: init.sh
978 install -m 0755 $^ $@
980 # Create the stage3 disk image.
981 # Note `-s +...' adds spare space to the disk image.
982 stage3-disk.img: stage3-chroot
983 cd stage3-chroot && virt-make-fs . ../$@ -t ext2 -F raw -s +4G
985 # Upload the compressed disk image.
986 upload-stage3: stage3-disk.img.xz
987 scp $^ tick:public_html/riscv/
988 stage3-disk.img.xz: stage3-disk.img
992 # Helper which boots stage3 disk image in spike.
993 boot-stage3-in-spike: stage3-disk.img stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
994 spike +disk=stage3-disk.img \
995 /usr/bin/bbl stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
997 # Helper which boots stage3 disk image in qemu.
998 boot-stage3-in-qemu: stage3-disk.img stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux
999 qemu-system-riscv -kernel /usr/bin/bbl \
1000 -append ./stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \
1001 -drive file=stage3-disk.img,format=raw -nographic