#!/bin/bash # This version of the script builds: # - x86 gmp 5.0.5, mpfr 3.1.1 and mpc 1.0.1 # - x86->x86 binutils 2.23 and gcc 4.7.3 # - x86->x86_64 binutils 2.23 and gcc 4.7.3 # The script will: # 1) Create x86 and x86_64 sysroots based on the unix-build env # 2) Download the required packages # 3) Apply patches from patches/*: # gcc-4.7.3/gcc-4.6.0bpw.diff - disable a bogus warning (taken from //sw/tools/unix/hosts/Linux-x86/targets/Linux-ARMv7-gnueabi/gcc-4.6.0/gcc-4.6.0bpw.diff, applies with offsets) # 4) Configure, build and install the packages into install_x86 and install_x86_64 # To install the toolchain into //sw/tools you have to uncomment # install_common, install_x86 and install_x86_64 at the end of the script. # REPO and JOBS should be set for your env REPO=/data/p4ws/ JOBS=16 # The rest should just work, but feel free to play with it NV_TOOLS=${REPO}/sw/tools/ NV_TOOLS_TARGETS=$NV_TOOLS/unix/hosts/Linux-x86/targets/ export MAKE=${NV_TOOLS}/linux/gnumake/fc2/gmake #export MAKE=gmake PREFIX=$(readlink -f $(dirname $0)) UTIL_CONFIG_X86=${NV_TOOLS}/unix/hosts/Linux-x86/targets/Linux-x86/configs/gcc-4.1.1as2-with-glibc-2.2.2-10.mk UTIL_PREFIX_X86=GCC_4_1_1_AS2_HOST_Linux_x86_TARGET_Linux_x86_ #UTIL_CONFIG_X86=${NV_TOOLS}/unix/experimental/hosts/Linux-x86/targets/Linux-x86/configs/gcc-4.7.2.mk #UTIL_PREFIX_X86=GCC_4_7_2_HOST_Linux_x86_TARGET_Linux_x86_ UTIL_PREFIX_X86_64=GCC_4_1_1_AS2_HOST_Linux_x86_TARGET_Linux_x86_64_ UTIL_CONFIG_X86_64=${NV_TOOLS}/unix/hosts/Linux-x86/targets/Linux-x86_64/configs/gcc-4.1.1as2.mk X86_64_SYSROOT_DIR=$PREFIX/x86_64-sysroot/ X86_SYSROOT_DIR=$PREFIX/x86-sysroot/ binutils_BASE_SRC="http://ftp.gnu.org/gnu/binutils/" binutils_VER=2.31.1 binutils_PKG_SUF=.tar.gz gmp_VER=5.0.5 gmp_setup() { PKG_SRC="ftp://ftp.gmplib.org/pub/gmp-$gmp_VER/gmp-$gmp_VER.tar.bz2" } mpfr_VER=3.1.1 mpfr_BASE_SRC="http://www.mpfr.org/mpfr-3.1.1/" mpc_VER=1.0.1 mpc_BASE_SRC="https://ftp.gnu.org/gnu/mpc/" mpc_PKG_SUF=".tar.gz" gcc_stage1_VER=4.7.3 gcc_stage2_VER=4.7.3 gcc_setup() { PKG_SRC="http://mirrors.kernel.org/gnu/gcc/gcc-$VER/gcc-$VER.tar.bz2" } die() { echo $@ exit 1 } edo() { echo $@ "$@" || die "$@ failed" } get_config() { local config=$1 prefix=$2 var=$3 #cat <x86 gcc 4.1.1 that we have most likely # has a bug that noone bothered to track down. # http://gcc.gnu.org/ml/gcc-help/2011-03/msg00352.html # Build a minimal gcc first gogo gcc stage1 edo rm -rf $PREFIX/gcc-32-stage1 edo mv $(install_dir gcc) $PREFIX/gcc-32-stage1 export PATH=$PREFIX/gcc-32-stage1/bin:$PATH unset CC unset CXX unset CPP gogo gcc stage2 export PATH=$saved_path export LD_LIBRARY_PATH=$saved_ld_lib } build_gcc_64() { local saved_path=$PATH saved_ld_lib=$LD_LIBRARY_PATH export CC="$X86_CC $X86_CFLAGS $X86_LDFLAGS $X86_BIN_LDFLAGS" export CXX=$X86_CXX export CPP=$X86_CPP set_build 32 32 64 export LD_LIBRARY_PATH=$(install_dir gmp)/lib export PATH=$(install_dir binutils)/bin:$PATH gogo gcc stage2 unset CC unset CXX unset CPP export PATH=$saved_path export LD_LIBRARY_PATH=$saved_ld_lib } clear_and_cp() { local src=$1 dst=$2 if [[ -e $dst ]]; then edo rm -rf $dst fi edo mkdir -p $dst edo cp -a $src/* $dst/ } install_common() { strip_libraries $(install_dir gmp)/lib/ # copy only the versioned libraries edo cp -a $(install_dir gmp)/lib/*.so.* $NV_TOOLS/unix/hosts/Linux-x86/unix-build/lib/ } install_x86() { set_build 32 32 32 clear_and_cp $(install_dir binutils)/bin/ $NV_TOOLS_TARGETS/Linux-x86/binutils-${binutils_VER}/bin/ clear_and_cp $(install_dir binutils)/$TARGET/ $NV_TOOLS_TARGETS/Linux-x86/binutils-${binutils_VER}/$TARGET/ clear_and_cp $(install_dir gcc) $NV_TOOLS_TARGETS/Linux-x86/gcc-${gcc_stage2_VER} cleanup_install_dir $NV_TOOLS_TARGETS/Linux-x86/binutils-${binutils_VER}/ cleanup_install_dir $NV_TOOLS_TARGETS/Linux-x86/gcc-${gcc_stage2_VER}/ } install_x86_64() { set_build 32 32 64 clear_and_cp $(install_dir binutils)/bin/ $NV_TOOLS_TARGETS/Linux-x86_64/binutils-${binutils_VER}/bin/ clear_and_cp $(install_dir binutils)/$TARGET/ $NV_TOOLS_TARGETS/Linux-x86_64/binutils-${binutils_VER}/$TARGET/ clear_and_cp $(install_dir gcc) $NV_TOOLS_TARGETS/Linux-x86_64/gcc-${gcc_stage2_VER}/ cleanup_install_dir $NV_TOOLS_TARGETS/Linux-x86_64/binutils-${binutils_VER}/ cleanup_install_dir $NV_TOOLS_TARGETS/Linux-x86_64/gcc-${gcc_stage2_VER}/ } setup_x86_sysroot setup_x86_64_sysroot build_binutils build_gmm build_gcc_32 build_gcc_64 #install_common #install_x86 #install_x86_64