view build.sh @ 6:4b740bf0d945

update
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 04 Aug 2014 17:40:23 -0400
parents adc0911de0f7
children 5e1cc2b09530
line wrap: on
line source

#!/bin/sh

BINUTILS_DIR="binutils-2.24"
GMP_DIR="gmp-5.1.3"
MPFR_DIR="mpfr-3.1.2"
MPC_DIR="mpc-1.0.1"
GCC_DIR="gcc-4.8.2"
GDB_DIR="gdb-7.3.1"
CMAKE_DIR="cmake-2.8.6"
HERCULES_DIR="hercules-390"

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"
GDB_TAR="${GDB_DIR}.tar.bz2"
CMAKE_TAR="${CMAKE_DIR}.tar.gz"

GCC_URL="http://gcc.parentingamerica.com/releases/${GCC_DIR}/${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}"
GDB_URL="http://ftp.gnu.org/gnu/gdb/${GDB_TAR}"
CMAKE_URL="http://www.cmake.org/files/v2.8/${CMAKE_TAR}"
HERCULES_REPO="git://github.com/hercules-390/hyperion.git"

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

BUILD_BINUTILS=false
BUILD_GMP=false
BUILD_MPFR=false
BUILD_MPC=false
BUILD_GCC=false
BUILD_GDB=false
BUILD_CMAKE=false
BUILD_HERCULES=true

# needed:
#   pkg:/developer/versioning/mercurial
#   pkg:/developer/versioning/subversion
#   pkg:/developer/build/gnu-make
#   pkg:/developer/build/automake-110
#   pkg:/developer/build/autoconf
#   pkg:/developer/macro/gnu-m4
#   pkg:/developer/gnu-binutils
#   pkg:/text/gnu-patch
#   pkg:/text/gnu-grep
#   pkg:/file/gnu-coreutils
#   pkg:/web/wget
#
# also needed:
#   pkg:/runtime/gcc
#   pkg:/developer/library/lint
#   pkg:/system/header
#   pkg:/system/library/math/header-math
for x in wget tar patch rm mkdir gmake ar git grep aclocal-1.10 autoheader \
		automake-1.10 autoconf ; 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"
	[ ! -e "$BINUTILS_DIR" ] && tar xjvf "$BINUTILS_TAR"

	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 xzvf "$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
	#\
	#	CFLAGS=-m32
	LD_LIBRARY_PATH=$PREFIX/lib gmake all-gcc all-target-libgcc $MAKEOPTS
	gmake install-gcc install-target-libgcc
	cd ..
fi

if $BUILD_GDB ; then
	[ ! -e "$GDB_TAR" ] && wget "$GDB_URL"
	[ ! -e "$GDB_DIR" ] && tar xjvf "$GDB_TAR"

	rm -rf gdb-objs
	mkdir gdb-objs
	cd gdb-objs
	LDFLAGS="-L/usr/gnu/lib -R/usr/gnu/lib -lncurses" \
	../${GDB_DIR}/configure \
		--target=$TARGET --prefix=$PREFIX \
		--with-gmp=$PREFIX \
		--with-mpfr=$PREFIX \
		--with-mpc=$PREFIX \
		--with-system-readline=no \
		--with-x=no \
		--with-ncurses
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_CMAKE ; then
	[ ! -e "$CMAKE_TAR" ] && wget "$CMAKE_URL"
	[ ! -e "$CMAKE_DIR" ] && tar xjvf "$CMAKE_TAR"

	rm -rf cmake-objs
	mkdir cmake-objs
	cd cmake-objs
	../${CMAKE_DIR}/configure \
		--prefix=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi

if $BUILD_HERCULES ; then
	if [ ! -e "$HERCULES_DIR" ]; then
		git clone $HERCULES_REPO $HERCULES_DIR

		cd $HERCULES_DIR
		patch -p1 < ../hercules.patch
		sh ./autogen.sh
		cd ..
	fi

	rm -rf hercules-objs
	mkdir hercules-objs
	cd hercules-objs
	../${HERCULES_DIR}/configure \
		--disable-ipv6 \
		--prefix=$PREFIX
	gmake $MAKEOPTS
	gmake install
	cd ..
fi