# git commits (optional).
LOCAL_LINUX_GIT_COPY = $(HOME)/d/linux
-# The root packages (plus their dependencies) that we want to
-# cross-compile into the stage 3 chroot.
-# beecrypt-devel is required to build RPM.
-# Packages for usability: nano, grep, less
-STAGE3_PACKAGES = gcc rpm-build beecrypt-devel nano grep less
+# The root packages (plus their dependencies) that we want to in the
+# stage 3 chroot. This must include all the cross-compiled packages
+# below, and may also include any noarch package we like.
+STAGE3_PACKAGES = ncurses-devel bash coreutils gmp-devel \
+mpfr-devel mpc-devel binutils gcc gcc-c++ util-linux tar \
+gzip zlib-devel file-devel popt-devel beecrypt-devel \
+rpm rpm-build rpm-devel libdb-utils libdb-devel nano \
+grep less strace bzip2-devel make diffutils findutils \
+sed patch hostname gettext-devel
# Versions of cross-compiled packages.
NCURSES_VERSION = 6.0-20160730
SED_VERSION = 4.2
PATCH_VERSION = 2.7.5
HOSTNAME_VERSION = 3.15
+GETTEXT_VERSION = 0.19
all: stage1 stage2 stage3 stage4
stage3-chroot/usr/bin/sed \
stage3-chroot/usr/bin/patch \
stage3-chroot/usr/bin/hostname \
+ stage3-chroot/usr/bin/gettext \
stage3-chroot/usr/bin/rpm \
stage3-chroot/init \
stage3-disk.img
stage3-chroot/etc/fedora-release: stage3-chroot-original/etc/fedora-release
rm -rf stage3-chroot
cp -a stage3-chroot-original stage3-chroot
- find stage3-chroot -type d | xargs chmod u+w
- find stage3-chroot -type f | xargs chmod u+w
- find stage3-chroot -type f | xargs file -N | grep -E '\bELF.*LSB\b' | awk -F: '{print $$1}' | xargs rm -f
+ find stage3-chroot -type d -print0 | xargs -0 chmod u+w
+ find stage3-chroot -type f -print0 | xargs -0 chmod u+w
+ find stage3-chroot -type f -print0 | xargs -0 file -N | grep -E '\bELF.*LSB\b' | awk -F: '{print $$1}' | xargs rm -f
rm -f stage3-chroot/lib64/libc.so.6
# Copy in compiled glibc from the riscv-gnu-toolchain sysroot. Only
stage3-chroot/usr/bin/gcc: gcc-$(GCC_X_VERSION).tar.gz
rm -rf riscv-gcc-riscv-gcc-$(GCC_X_VERSION)
zcat $^ | tar xf -
+ cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION) && \
+ patch -p1 < ../0001-HACKS-TO-GET-GCC-TO-COMPILE.patch
mkdir riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build
cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && \
PATH=$(ROOT)/fixed-gcc:$$PATH \
--disable-libquadmath \
--disable-nls \
--disable-multilib
-# XXX use make all & make install here. However building libgcc
-# fails, see 'broken-gcc.log'.
- cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make all-gcc
- cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && make install-gcc DESTDIR=$(ROOT)/stage3-chroot
+ cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make
+ cd riscv-gcc-riscv-gcc-$(GCC_X_VERSION)/build && make install DESTDIR=$(ROOT)/stage3-chroot
+ rm -f stage3-chroot/usr/lib64/*.la
gcc-$(GCC_X_VERSION).tar.gz:
rm -f $@ $@-t
wget -O $@-t http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_$(HOSTNAME_VERSION).tar.gz
mv $@-t $@
+# Cross-compile GNU gettext.
+stage3-chroot/usr/bin/gettext: gettext-$(GETTEXT_VERSION).tar.gz
+ rm -rf gettext-$(GETTEXT_VERSION)
+ tar -zxf $^
+ cd gettext-$(GETTEXT_VERSION) && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64
+ cd gettext-$(GETTEXT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
+ cd gettext-$(GETTEXT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
+ rm -f stage3-chroot/usr/lib64/*.la
+
+gettext-$(GETTEXT_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t https://ftp.gnu.org/gnu/gettext/gettext-$(GETTEXT_VERSION).tar.gz
+ mv $@-t $@
+
# Cross-compile RPM / rpmbuild.
# We build this from a git commit, with a few hacks to the configure
# script.