Added: New Hake target for k1om archtecture (Xeon Phi)
[barrelfish] / tools / k1om / build-toolchain.sh
1 #!/usr/bin/env bash
2
3 # C/C++ toolchain build script for Barrelfish.
4 # http://redmine.aluzina.org/projects/barrelfish/wiki/Toolchain_from_sources
5 # http://wiki.barrelfish.org/CrossCompiler
6 #
7 # In order to build a toolchain you will need to install the following packages:
8 #   $ sudo apt-get install gcc g++ make patch bison flex texinfo
9 #
10 # These are also required but will be downloaded automatically during the build:
11 #   libgmp-dev, libmpc-dev, libmpfr-dev
12 #
13 # Optional (for Graphite optimizations): libcloog-ppl-dev.
14
15 set -e  # Die if any command fails.
16 set -x  # Trace each command before execution.
17
18 #-------------------------------------------------------------------------------
19
20 # Modify these versions to match the corresponding patch.
21 BINUTILS=binutils-2.24
22 GCC=gcc-4.8.2
23
24
25 # Cross compiler target.
26 TARGET=x86_64-k1om-barrelfish
27
28 # Directory this shell script is stored in.
29 # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
30 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
31
32 # Paths to patches.
33 BINUTILS_PATCH="${SCRIPT_DIR}/${BINUTILS}-barrelfish.patch"
34 GCC_PATCH="${SCRIPT_DIR}/${GCC}-barrelfish.patch"
35
36
37 # 1. binutils - GNU Binary Utilities
38 #curl -L -O "http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.gz"
39 tar xzvf ${BINUTILS}.tar.gz
40 pushd ${BINUTILS}/
41 patch -p1 < "${BINUTILS_PATCH}"
42 popd  # ${BINUTILS}/
43
44 # 2. GCC - GNU Compiler Collection
45 #curl -L -O "ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/${GCC}/${GCC}.tar.bz2"
46 tar xjvf ${GCC}.tar.bz2
47 pushd ${GCC}/
48 source ./contrib/download_prerequisites
49 # http://stackoverflow.com/questions/407523/escape-a-string-for-sed-search-pattern
50 BF_SOURCE_ESCAPED=$(echo "${BARRELFISH_SOURCE}" | sed -e 's/[\/&]/\\&/g')
51 BF_BUILD_ESCAPED=$(echo "${BARRELFISH_BUILD}" | sed -e 's/[\/&]/\\&/g')
52 sed -r -e "s/\{\{BF_SRC\}\}/${BF_SOURCE_ESCAPED}/g" \
53        -e "s/\{\{BF_BUILD\}\}/${BF_BUILD_ESCAPED}/g" \
54        "${GCC_PATCH}" | patch -p1
55 popd  # ${GCC}/
56
57