TAR_VERSION = 1.29
GZIP_VERSION = 1.8
ZLIB_VERSION = 1.2.8
+# Needs to match the installed (on host) version, otherwise:
+# "Cannot use the installed version of file (xx) to cross-compile file yy"
+FILE_VERSION = 5.25
+POPT_VERSION = 1.16
all: stage1 stage2 stage3 stage4
stage3-chroot/usr/bin/tar \
stage3-chroot/usr/bin/gzip \
stage3-chroot/usr/lib64/libz.so \
+ stage3-chroot/usr/bin/file \
+ stage3-chroot/usr/lib64/libpopt.so \
stage3-chroot/init \
stage3-disk.img
# Cross-compile binutils.
stage3-chroot/usr/bin/as: binutils-$(BINUTILS_X_VERSION).tar.gz
- rm -rf binutils-$(BINUTILS_X_VERSION)
+ rm -rf riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)
zcat $^ | tar xf -
mkdir riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build
cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && \
cd mpfr-$(MPFR_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
cd mpfr-$(MPFR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
cd stage3-chroot/usr/lib && ln -s ../lib64/libmpfr.so
+ rm -f stage3-chroot/usr/lib64/*.la
mpfr-$(MPFR_VERSION).tar.gz:
rm -f $@ $@-t
cd mpc-$(MPC_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
cd mpc-$(MPC_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
cd stage3-chroot/usr/lib && ln -s ../lib64/libmpc.so
+ rm -f stage3-chroot/usr/lib64/*.la
mpc-$(MPC_VERSION).tar.gz:
rm -f $@ $@-t
cd zlib-$(ZLIB_VERSION) && \
PATH=$(ROOT)/fixed-gcc:$$PATH \
CC=riscv64-unknown-linux-gnu-gcc \
- CFLAGS="-I/home/rjones/d/fedora-riscv/stage3-chroot/usr/include -L/home/rjones/d/fedora-riscv/stage3-chroot/usr/lib" \
+ CFLAGS="-I$(ROOT)/stage3-chroot/usr/include -L$(ROOT)/stage3-chroot/usr/lib" \
./configure \
--prefix=/usr --libdir=/usr/lib64
cd zlib-$(ZLIB_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make shared
wget -O $@-t http://zlib.net/zlib-$(ZLIB_VERSION).tar.gz
mv $@-t $@
+# Cross-compile file/libmagic.
+stage3-chroot/usr/bin/file: file-$(FILE_VERSION).tar.gz
+ rm -rf file-$(FILE_VERSION)
+ tar -zxf $^
+ cd file-$(FILE_VERSION) && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64 \
+ --disable-static --enable-shared
+ cd file-$(FILE_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
+ cd file-$(FILE_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
+ rm -f stage3-chroot/usr/lib64/*.la
+
+file-$(FILE_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t ftp://ftp.astron.com/pub/file/file-$(FILE_VERSION).tar.gz
+ mv $@-t $@
+
+# Cross-compile popt.
+stage3-chroot/usr/lib64/libpopt.so: popt-$(POPT_VERSION).tar.gz
+ rm -rf popt-$(POPT_VERSION)
+ tar -zxf $^
+ cd popt-$(POPT_VERSION) && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64 \
+ --disable-static --enable-shared
+ cd popt-$(POPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1
+ cd popt-$(POPT_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
+ rm -f stage3-chroot/usr/lib64/*.la
+
+popt-$(POPT_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t http://rpm5.org/files/popt/popt-$(POPT_VERSION).tar.gz
+ mv $@-t $@
+
# Create an /init script.
stage3-chroot/init: init.sh
install -m 0755 $^ $@