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
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
10 # These are also required but will be downloaded automatically during the build:
11 # libgmp-dev, libmpc-dev, libmpfr-dev
13 # Optional (for Graphite optimizations): libcloog-ppl-dev.
15 set -e # Die if any command fails.
16 set -x # Trace each command before execution.
18 #-------------------------------------------------------------------------------
20 # Modify these versions to match the corresponding patch.
21 BINUTILS=binutils-2.24
25 # Cross compiler target.
26 TARGET=x86_64-k1om-barrelfish
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 )"
33 BINUTILS_PATCH="${SCRIPT_DIR}/${BINUTILS}-barrelfish.patch"
34 GCC_PATCH="${SCRIPT_DIR}/${GCC}-barrelfish.patch"
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
41 patch -p1 < "${BINUTILS_PATCH}"
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
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