X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=Makefile;h=228d04545c969b76d4ff6ebf70f2fe026c11cf28;hb=27b0c3b575e54ab3e3a6af1fc6e3c844a3fbfd43;hp=787a8200f7a681e36f2ae23fd2024698a9696f49;hpb=0d020d630e61841600265489bfb8272aad14fce9;p=fedora-riscv.git diff --git a/Makefile b/Makefile index 787a820..228d045 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ LOCAL_LINUX_GIT_COPY = $(HOME)/d/linux # The root packages (plus their dependencies) that we want to # cross-compile into the stage 3 chroot. -STAGE3_PACKAGES = gcc rpm-build +# beecrypt-devel is required to build RPM. +STAGE3_PACKAGES = gcc rpm-build beecrypt-devel # Versions of cross-compiled packages. NCURSES_VERSION = 6.0-20160730 @@ -45,8 +46,20 @@ COREUTILS_VERSION = 8.25 GMP_VERSION = 6.1.1 MPFR_VERSION = 3.1.4 MPC_VERSION = 1.0.3 +BINUTILS_X_VERSION = 2.26 GCC_X_VERSION = 6.1.0 UTIL_LINUX_VERSION = 2.28 +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 +BEECRYPT_VERSION = 4.2.1 +RPM_COMMIT = 95712183458748ea6cafebac1bdd5daa097d9bee +RPM_SHORT_COMMIT = 9571218 +BDB_VERSION = 4.5.20 all: stage1 stage2 stage3 stage4 @@ -252,8 +265,16 @@ stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \ stage3-chroot/usr/lib64/libgmp.so.10 \ stage3-chroot/usr/lib64/libmpfr.so.4 \ stage3-chroot/usr/lib64/libmpc.so.3 \ + stage3-chroot/usr/bin/as \ stage3-chroot/usr/bin/gcc \ stage3-chroot/usr/bin/mount \ + 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/usr/lib64/libbeecrypt.so \ + stage3-chroot/usr/bin/rpm \ stage3-chroot/init \ stage3-disk.img @@ -319,10 +340,11 @@ stage3-chroot/usr/bin/tic: ncurses-$(NCURSES_VERSION).tgz PATH=$(ROOT)/fixed-gcc:$$PATH \ ./configure --host=riscv64-unknown-linux-gnu \ --prefix=/usr --libdir=/usr/lib64 \ - --with-shared + --with-shared \ + --with-termlib=tinfo \ + --enable-widec cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make cd ncurses-$(NCURSES_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot - cd $(ROOT)/stage3-chroot/usr/lib64 && ln -sf libtinfo.so.6 libtinfo.so ncurses-$(NCURSES_VERSION).tgz: rm -f $@ $@-t @@ -367,6 +389,24 @@ coreutils-$(COREUTILS_VERSION).tar.xz: wget -O $@-t ftp://ftp.gnu.org/gnu/coreutils/coreutils-$(COREUTILS_VERSION).tar.xz mv $@-t $@ +# Cross-compile binutils. +stage3-chroot/usr/bin/as: binutils-$(BINUTILS_X_VERSION).tar.gz + 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 && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + ../configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 + cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && PATH=$(ROOT)/fixed-gcc:$$PATH make + cd riscv-binutils-gdb-riscv-binutils-$(BINUTILS_X_VERSION)/build && make DESTDIR=$(ROOT)/stage3-chroot install + +binutils-$(BINUTILS_X_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t https://github.com/riscv/riscv-binutils-gdb/archive/riscv-binutils-$(BINUTILS_X_VERSION).tar.gz + mv $@-t $@ + # Cross-compile GMP, MPFR and MPC (deps of GCC). stage3-chroot/usr/lib64/libgmp.so.10: gmp-$(GMP_VERSION).tar.lz rm -rf gmp-$(GMP_VERSION) @@ -395,6 +435,7 @@ stage3-chroot/usr/lib64/libmpfr.so.4: mpfr-$(MPFR_VERSION).tar.gz 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 @@ -413,6 +454,7 @@ stage3-chroot/usr/lib64/libmpc.so.3: mpc-$(MPC_VERSION).tar.gz 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 @@ -437,6 +479,8 @@ stage3-chroot/usr/bin/gcc: gcc-$(GCC_X_VERSION).tar.gz --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 @@ -446,29 +490,187 @@ gcc-$(GCC_X_VERSION).tar.gz: mv $@-t $@ # Cross-compile util-linux. -# XXX Be nice to fix ncurses/tinfo support which in theory should work. stage3-chroot/usr/bin/mount: util-linux-$(UTIL_LINUX_VERSION).tar.xz rm -rf util-linux-$(UTIL_LINUX_VERSION) tar -Jxf $^ cd util-linux-$(UTIL_LINUX_VERSION) && \ PATH=$(ROOT)/fixed-gcc:$$PATH \ + LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \ ./configure \ --host=riscv64-unknown-linux-gnu \ --prefix=/usr --libdir=/usr/lib64 \ --without-python \ - --without-tinfo \ - --without-ncurses \ --without-systemd \ - --disable-makeinstall-chown + --disable-makeinstall-chown \ + --enable-static-programs=mount cd util-linux-$(UTIL_LINUX_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make -# libtool fucks something up here, ignore the failure and continue. - -cd util-linux-$(UTIL_LINUX_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot -j1 -k V=1 + cd util-linux-$(UTIL_LINUX_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot + rm -f stage3-chroot/usr/lib64/*.la util-linux-$(UTIL_LINUX_VERSION).tar.xz: rm -f $@ $@-t wget -O $@-t ftp://ftp.kernel.org/pub/linux/utils/util-linux/v$(UTIL_LINUX_VERSION)/util-linux-$(UTIL_LINUX_VERSION).tar.xz mv $@-t $@ +# Cross-compile GNU tar. +stage3-chroot/usr/bin/tar: tar-$(TAR_VERSION).tar.xz + rm -rf tar-$(TAR_VERSION) + tar -Jxf $^ + cd tar-$(TAR_VERSION) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 + cd tar-$(TAR_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make + cd tar-$(TAR_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot + +tar-$(TAR_VERSION).tar.xz: + rm -f $@ $@-t + wget -O $@-t https://ftp.gnu.org/gnu/tar/tar-$(TAR_VERSION).tar.xz + mv $@-t $@ + +# Cross-compile GNU gzip. +stage3-chroot/usr/bin/gzip: gzip-$(GZIP_VERSION).tar.gz + rm -rf gzip-$(GZIP_VERSION) + tar -zxf $^ + cd gzip-$(GZIP_VERSION) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 + cd gzip-$(GZIP_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make + cd gzip-$(GZIP_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot + +gzip-$(GZIP_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t https://ftp.gnu.org/gnu/gzip/gzip-$(GZIP_VERSION).tar.gz + mv $@-t $@ + +# Cross-compile zlib. +stage3-chroot/usr/lib64/libz.so: zlib-$(ZLIB_VERSION).tar.gz + rm -rf zlib-$(ZLIB_VERSION) + tar -zxf $^ + cd zlib-$(ZLIB_VERSION) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + CC=riscv64-unknown-linux-gnu-gcc \ + 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 + cd zlib-$(ZLIB_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot + +zlib-$(ZLIB_VERSION).tar.gz: + rm -f $@ $@-t + 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 $@ + +# Cross-compile beecrypt. +stage3-chroot/usr/lib64/libbeecrypt.so: beecrypt-$(BEECRYPT_VERSION).tar.gz + rm -rf beecrypt-$(BEECRYPT_VERSION) + tar -zxf $^ + cd beecrypt-$(BEECRYPT_VERSION) && patch -p0 < ../beecrypt-disable-cplusplus.patch + cd beecrypt-$(BEECRYPT_VERSION) && autoreconf -i + cd beecrypt-$(BEECRYPT_VERSION) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 \ + --without-cplusplus \ + --without-java \ + --disable-openmp \ + --disable-static \ + --enable-shared + cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1 + cd beecrypt-$(BEECRYPT_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot V=1 + chrpath -d stage3-chroot/usr/lib64/libbeecrypt.so.* + rm -f stage3-chroot/usr/lib64/*.la + +beecrypt-$(BEECRYPT_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t http://downloads.sourceforge.net/sourceforge/beecrypt/beecrypt-$(BEECRYPT_VERSION).tar.gz + mv $@-t $@ + +# Cross-compile RPM / rpmbuild. +# We build this from a git commit, with a few hacks to the configure +# script. +stage3-chroot/usr/bin/rpm: rpm-$(RPM_SHORT_COMMIT).tar.gz db-$(BDB_VERSION).tar.gz + rm -rf rpm-$(RPM_SHORT_COMMIT) + tar -zxf rpm-$(RPM_SHORT_COMMIT).tar.gz + tar -zxf db-$(BDB_VERSION).tar.gz -C rpm-$(RPM_SHORT_COMMIT) + cd rpm-$(RPM_SHORT_COMMIT) && ln -s db-$(BDB_VERSION) db + cd rpm-$(RPM_SHORT_COMMIT) && patch -p1 < ../rpm-hacks.patch + cd rpm-$(RPM_SHORT_COMMIT) && autoreconf -i + cd rpm-$(RPM_SHORT_COMMIT) && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + LDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 \ + ./configure \ + --host=riscv64-unknown-linux-gnu \ + --prefix=/usr --libdir=/usr/lib64 \ + --disable-rpath \ + --without-libarchive \ + --without-lua \ + --with-beecrypt \ + --without-archive \ + --without-external-db \ + --enable-ndb \ + --disable-plugins + cd rpm-$(RPM_SHORT_COMMIT) && \ + sed -i 's|^sys_lib_dlsearch_path_spec="/lib64|sys_lib_dlsearch_path_spec="$(ROOT)/stage3-chroot/usr/lib64 /lib64|g' libtool + cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make V=1 + cd rpm-$(RPM_SHORT_COMMIT) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot + rm -f stage3-chroot/usr/lib64/*.la + +rpm-$(RPM_SHORT_COMMIT).tar.gz: + rm -f $@ $@-t + wget -O $@-t 'http://rpm.org/gitweb?p=rpm.git;a=snapshot;h=$(RPM_COMMIT);sf=tgz' + mv $@-t $@ + +db-$(BDB_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t http://download.oracle.com/berkeley-db/db-$(BDB_VERSION).tar.gz + mv $@-t $@ + # Create an /init script. stage3-chroot/init: init.sh install -m 0755 $^ $@