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, Haldeneggsteig 4, 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 scc 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
154 OK - Hake has bootstrapped. You should now have a Makefile in this
155 directory, and you can type "make" to build a predefined target.
157 To change configuration options, edit the Config.hs file in the hake
158 subdirectory of this directory and run "make rehake".
160 To change the set of symbolic make targets available (for example, to
161 build a different set of modules or architectures for your boot image),
162 edit the local copy of the symbolic_targets.mk in this directory.