3 ##########################################################################
4 # Copyright (c) 2009, 2011, 2013, ETH Zurich.
7 # This file is distributed under the terms in the attached LICENSE file.
8 # If you do not find this file, copies can be found by writing to:
9 # ETH Zurich D-INFK, Universitätstasse 6, CH-8092 Zurich. Attn: Systems Group.
10 ##########################################################################
12 DFLTARCHS="\"x86_64\""
18 echo "Usage: $0 <options>"
19 echo " -s|--source-dir: path to source tree (required)"
20 echo " -i|--install-dir: path to install directory (defaults to \`pwd\`)"
21 echo " -a|--architecture: specify archtitecture to build for (can be"
22 echo " given multiple times, default architectures are"
24 echo " -n|--no-hake: just rebuild hake itself, don't run it (only useful"
25 echo " for debugging hake)"
26 echo " -t|--toolchain: toolchain to use when bootstrapping a new"
27 echo " build tree (-t list for available options)."
29 echo " The way you use this script is to create a new directory for your"
30 echo " build tree, cd into it, and run this script with the --source-dir"
31 echo " argument specifying the top of the source tree."
33 echo " Known architectures may include: "
34 echo " x86_64 x86_32 armv5 arm11mp xscale armv7 armv7-m k10m"
39 TOOLCHAINS=$(ls ${HAKEDIR}/Config.hs.* | sed s/.*Config\.hs\.//)
40 echo "Available toolchains:"
41 for tc in ${TOOLCHAINS}; do
48 # Legacy compatibility to avoid breaking the harness...
51 echo "WARNING: old usage of hake.sh (sole argument gives the source directory) is"
52 echo "deprecated: please use --source-dir instead."
60 while [ $# -ne 0 ]; do
62 "-a"|"--architecture")
63 if [ -z "$NEWARCHS" ] ; then
66 NEWARCHS="$NEWARCHS, \"$2\""
84 if [ "${TOOLCHAIN}" == "list" ]; then
87 if [ ! -f ${HAKEDIR}/Config.hs.${TOOLCHAIN} ]; then
88 echo "Unknown toolchain \"${TOOLCHAIN}\""
99 if [ -z "$INSTALLDIR" ] ; then
100 echo "Install directory defaulting to '.'"
103 echo "Install directory is $INSTALLDIR"
107 if [ -z "$SRCDIR" ] ; then
111 if [ ! -f "$SRCDIR"/hake/Main.hs ] ; then
112 echo "Can't find Hake in the source directory $SRCDIR."
113 echo "Did you specify the source directory correctly?"
116 echo "Source directory is $SRCDIR"
118 if [ ! -z "$NEWARCHS" ]; then
123 echo "Architectures to build: $ARCHS"
125 if [ ! -d hake ] ; then
126 echo "Creating a local hake directory..."
131 echo "Setting up hake build directory..."
132 if [ ! -f hake/Config.hs ]; then
133 echo "Bootstrapping with toolchain \"${TOOLCHAIN}\""
134 cp $SRCDIR/hake/Config.hs.${TOOLCHAIN} hake/Config.hs
135 cat >> hake/Config.hs <<EOF
137 -- Automatically added by hake.sh. Do NOT copy these definitions to the defaults
138 source_dir = "$SRCDIR"
139 architectures = [ $ARCHS ]
140 install_dir = "$INSTALLDIR"
143 echo "You already have Config.hs, leaving it as-is."
146 if [ ! -f ./symbolic_targets.mk ]; then
147 echo "Creating new symbolic_targets.mk file."
148 cp "$SRCDIR/hake/symbolic_targets.mk" .
150 echo "You already have symbolic_targets.mk, leaving it as-is."
153 # FIXME: do we really need this; doesn't ghc get the dependencies right? -AB
154 #rm -f hake/*.hi hake/*.o
156 echo "Building hake..."
157 ghc -O --make -XDeriveDataTypeable \
167 $SRCDIR/hake/Main.hs $LDFLAGS || exit 1
171 if [ "$RUN_HAKE" == "No" ] ; then
172 echo "Not running hake as per your request."
176 echo "Running hake..."
177 #./hake/hake --output-filename Makefile --source-dir "$SRCDIR" +RTS -s -N -K64M -A64M -ls -lf || exit
178 #./hake/hake --output-filename Makefile --source-dir "$SRCDIR" +RTS -N -K64M -A64M || exit
179 ./hake/hake --output-filename Makefile --source-dir "$SRCDIR" +RTS -T || exit
181 echo "Now running initial make to build dependencies."
182 echo " (remove the '-j 4' if your system has trouble handling this"