view build.sh @ 1:3b0540107588

we need ar(1)
author jeffpc@hvfdev
date Sun, 30 Oct 2011 11:57:21 -0400
parents 710c1d3c6036
children b4aea2297716
line wrap: on
line source

#!/bin/sh

GCC_DIR="gcc-4.6.2"
BINUTILS_DIR="binutils-2.21.1"
GMP_DIR="gmp-5.0.2"
MPFR_DIR="mpfr-3.1.0"
MPC_DIR="mpc-0.9"

GCC_TAR="${GCC_DIR}.tar.bz2"
BINUTILS_TAR="${BINUTILS_DIR}.tar.bz2"
GMP_TAR="${GMP_DIR}.tar.bz2"
MPFR_TAR="${MPFR_DIR}.tar.bz2"
MPC_TAR="${MPC_DIR}.tar.gz"

GCC_URL="http://mirrors-us.seosue.com/gcc/releases/gcc-4.6.2/${GCC_TAR}"
BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/${BINUTILS_TAR}"
GMP_URL="ftp://ftp.gnu.org/gnu/gmp/${GMP_TAR}"
MPFR_URL="http://www.mpfr.org/mpfr-current/${MPFR_TAR}"
MPC_URL="http://www.multiprecision.org/mpc/download/${MPC_TAR}"

PREFIX=$HOME/bin/cross
MAKEOPTS=-j6
TARGET=s390x-linux
CHECKING=release
#CHECKING=yes,rtl

BUILD_BINUTILS=true
BUILD_GMP=true
BUILD_MPFR=true
BUILD_MPC=true
BUILD_GCC=true

for x in wget tar patch rm mkdir gmake ar ; do
	which $x 2> /dev/null && continue

	echo "Error: cannot find '$x'"
	exit 1
done

set -e
set -x

if $BUILD_BINUTILS ; then
	[ ! -e "$BINUTILS_TAR" ] && wget "$BINUTILS_URL"
	if [ ! -e "$BINUTILS_DIR" ]; then
		tar xjvf "$BINUTILS_TAR"

		cd "$BINUTILS_DIR"
		patch -p1 < ../binutils.diff
		cd ..
	fi

	rm -rf binutils-objs
	mkdir binutils-objs
	cd binutils-objs
	../${BINUTILS_DIR}/configure --target=$TARGET --prefix=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_GMP ; then
	[ ! -e "$GMP_TAR" ] && wget "$GMP_URL"
	[ ! -e "$GMP_DIR" ] && tar xjvf "$GMP_TAR"

	rm -rf gmp-objs
	mkdir gmp-objs
	cd gmp-objs
	../${GMP_DIR}/configure --prefix=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_MPFR ; then
	[ ! -e "$MPFR_TAR" ] && wget "$MPFR_URL"
	[ ! -e "$MPFR_DIR" ] && tar xjvf "$MPFR_TAR"

	rm -rf mpfr-objs
	mkdir mpfr-objs
	cd mpfr-objs
	../${MPFR_DIR}/configure --prefix=$PREFIX --with-gmp=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_MPC ; then
	[ ! -e "$MPC_TAR" ] && wget "$MPC_URL"
	[ ! -e "$MPC_DIR" ] && tar xjvf "$MPC_TAR"

	rm -rf mpc-objs
	mkdir mpc-objs
	cd mpc-objs
	../${MPC_DIR}/configure --prefix=$PREFIX --with-gmp=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_GCC ; then
	[ ! -e "$GCC_TAR" ] && wget "$GCC_URL"
	[ ! -e "$GCC_DIR" ] && tar xjvf "$GCC_TAR"

	rm -rf gcc-objs
	mkdir gcc-objs
	cd gcc-objs
	../${GCC_DIR}/configure \
		--target=$TARGET --enable-targets=all --prefix=$PREFIX \
		--with-gmp=$PREFIX \
		--with-mpfr=$PREFIX \
		--with-mpc=$PREFIX \
		--enable-languages=c,c++ --without-headers \
		--enable-sjlj-exceptions --with-system-libunwind \
		--disable-nls --disable-threads --disable-shared \
		--disable-libmudflap --disable-libssp --disable-libgomp \
		--disable-decimal-float \
		--enable-checking=$CHECKING 
	LD_LIBRARY_PATH=$PREFIX/lib gmake all-gcc all-target-libgcc $MAKEOPTS
	gmake install-gcc install-target-libgcc
	cd ..
fi