3 ##########################################################################
4 # Copyright (c) 2009, 2011, 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."
32 # Legacy compatibility to avoid breaking the harness...
35 echo "WARNING: old usage of hake.sh (sole argument gives the source directory) is"
36 echo "deprecated: please use --source-dir instead."
44 while [ $# -ne 0 ]; do
46 "-a"|"--architecture")
47 if [ -z "$NEWARCHS" ] ; then
50 NEWARCHS="$NEWARCHS, \"$2\""
70 if [ -z "$INSTALLDIR" ] ; then
71 echo "Install directory defaulting to '.'"
74 echo "Install directory is $INSTALLDIR"
78 if [ -z "$SRCDIR" ] ; then
82 if [ ! -f "$SRCDIR"/hake/Main.hs ] ; then
83 echo "Can't find Hake in the source directory $SRCDIR."
84 echo "Did you specify the source directory correctly?"
87 echo "Source directory is $SRCDIR"
89 if [ ! -z "$NEWARCHS" ]; then
94 echo "Architectures to build: $ARCHS"
96 if [ ! -d hake ] ; then
97 echo "Creating a local hake directory..."
102 echo "Setting up hake build directory..."
103 if [ ! -f hake/Config.hs ]; then
104 cp $SRCDIR/hake/Config.hs.template hake/Config.hs
105 cat >> hake/Config.hs <<EOF
107 -- Automatically added by hake.sh. Do NOT copy these definitions to the defaults
108 source_dir = "$SRCDIR"
109 architectures = [ $ARCHS ]
110 install_dir = "$INSTALLDIR"
113 echo "You already have Config.hs, leaving it as-is."
116 if [ ! -f ./symbolic_targets.mk ]; then
117 echo "Creating new symbolic_targets.mk file."
118 cp "$SRCDIR/hake/symbolic_targets.mk" .
120 echo "You already have symbolic_targets.mk, leaving it as-is."
123 # FIXME: do we really need this; doesn't ghc get the dependencies right? -AB
124 #rm -f hake/*.hi hake/*.o
126 echo "Building hake..."
127 ghc -O --make -XDeriveDataTypeable \
135 $SRCDIR/hake/Main.hs $LDFLAGS || exit 1
137 if [ "$RUN_HAKE" == "No" ] ; then
138 echo "Not running hake as per your request."
142 echo "Running hake..."
143 ./hake/hake --output-filename Makefile --source-dir "$SRCDIR" || exit
146 OK - Hake has bootstrapped. You should now have a Makefile in this
147 directory, and you can type "make" to build a predefined target.
149 To change configuration options, edit the Config.hs file in the hake
150 subdirectory of this directory and run "make rehake".
152 To change the set of symbolic make targets available (for example, to
153 build a different set of modules or architectures for your boot image),
154 edit the local copy of the symbolic_targets.mk in this directory.