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\""
16 echo "Usage: $0 <options>"
17 echo " -s|--source-dir: path to source tree (required)"
18 echo " -i|--install-dir: path to install directory (defaults to \`pwd\`)"
19 echo " -a|--architecture: specify archtitecture to build for (can be"
20 echo " given multiple times, default architectures are"
22 echo " -n|--no-hake: just rebuild hake itself, don't run it (only useful"
23 echo " for debugging hake)"
25 echo " The way you use this script is to create a new directory for your"
26 echo " build tree, cd into it, and run this script with the --source-dir"
27 echo " argument specifying the top of the source tree."
29 echo " Known architectures may include: "
30 echo " x86_64 x86_32 armv5 arm11mp xscale armv7 armv7-m k10m"
35 # Legacy compatibility to avoid breaking the harness...
38 echo "WARNING: old usage of hake.sh (sole argument gives the source directory) is"
39 echo "deprecated: please use --source-dir instead."
47 while [ $# -ne 0 ]; do
49 "-a"|"--architecture")
50 if [ -z "$NEWARCHS" ] ; then
53 NEWARCHS="$NEWARCHS, \"$2\""
73 if [ -z "$INSTALLDIR" ] ; then
74 echo "Install directory defaulting to '.'"
77 echo "Install directory is $INSTALLDIR"
81 if [ -z "$SRCDIR" ] ; then
85 if [ ! -f "$SRCDIR"/hake/Main.hs ] ; then
86 echo "Can't find Hake in the source directory $SRCDIR."
87 echo "Did you specify the source directory correctly?"
90 echo "Source directory is $SRCDIR"
92 if [ ! -z "$NEWARCHS" ]; then
97 echo "Architectures to build: $ARCHS"
99 if [ ! -d hake ] ; then
100 echo "Creating a local hake directory..."
105 echo "Setting up hake build directory..."
106 if [ ! -f hake/Config.hs ]; then
107 cp $SRCDIR/hake/Config.hs.template hake/Config.hs
108 cat >> hake/Config.hs <<EOF
110 -- Automatically added by hake.sh. Do NOT copy these definitions to the defaults
111 source_dir = "$SRCDIR"
112 architectures = [ $ARCHS ]
113 install_dir = "$INSTALLDIR"
116 echo "You already have Config.hs, leaving it as-is."
119 if [ ! -f ./symbolic_targets.mk ]; then
120 echo "Creating new symbolic_targets.mk file."
121 cp "$SRCDIR/hake/symbolic_targets.mk" .
123 echo "You already have symbolic_targets.mk, leaving it as-is."
126 # FIXME: do we really need this; doesn't ghc get the dependencies right? -AB
127 #rm -f hake/*.hi hake/*.o
129 echo "Building hake..."
130 ghc -O --make -XDeriveDataTypeable \
139 -with-rtsopts="-K32m" \
140 $SRCDIR/hake/Main.hs $LDFLAGS || exit 1
144 if [ "$RUN_HAKE" == "No" ] ; then
145 echo "Not running hake as per your request."
149 echo "Running hake..."
150 #./hake/hake --output-filename Makefile --source-dir "$SRCDIR" +RTS -s -N -K64M -A64M -ls -lf || exit
151 ./hake/hake --output-filename Makefile --source-dir "$SRCDIR" +RTS -N -K64M -A64M || exit
153 echo "Now running initial make to build dependencies."
154 echo " (remove the '-j 4' if your system has trouble handling this"