update submodules for GHC.HetMet.GArrow -> Control.GArrow renaming
[ghc-hetmet.git] / distrib / cross-port
1 #! /bin/bash
2
3 # This script can be used to generate some unregisterised .hc files
4 # for bootstrapping GHC on a new/unsupported platform.  It involves a
5 # two-stage bootstrap: the first stage builds an unregisterised set of
6 # libraries & RTS, and the second stage builds an unregisterised
7 # compiler.  
8
9 # Take the .hc files from the libraries of stage 1, and the compiler
10 # of stage 2, to the target system and bootstrap from these to get a
11 # working (unregisterised) compiler.
12
13 set -e
14
15 base=`pwd`
16
17 # set this to the location of your source tree
18 fptools_dir=$HOME/fptools
19
20 if [ ! -f b1-stamp ]; then
21   mkdir b1
22   cd b1
23   lndir $fptools_dir
24   cd ..
25
26   cd b1
27    ./configure
28
29    # For cross-compilation, at this stage you may want to set up a source
30    # tree on the target machine, run the configure script there, and bring
31    # the resulting mk/config.h file back into this tree before building
32    # the libraries.
33
34    touch mk/build.mk
35    echo "GhcUnregisterised = YES" >> mk/build.mk
36    echo "GhcLibHcOpts = -O -H32m -fvia-C -keep-hc-files" >> mk/build.mk
37    echo "GhcLibWays =" >> mk/build.mk
38    echo "SplitObjs = NO" >> mk/build.mk
39
40    # We could optimise slightly by not building hslibs here.  Also, building
41    # the RTS is not necessary (and might not be desirable if we're using
42    # a config.h from the target system).
43    make stage1
44
45   cd ..
46
47   touch b1-stamp
48 fi
49
50 # exit 0
51
52 if [ ! -f b2-stamp ]; then
53   mkdir b2
54   cd b2
55   lndir $fptools_dir
56   cd ..
57
58   cd b2
59    ./configure --with-ghc=$base/b1/ghc/compiler/stage1/ghc-inplace
60
61    touch mk/build.mk
62    # The bootstrapped compiler should probably generate unregisterised
63    # code too.  If you don't want it to, then comment out this line:
64    echo "GhcUnregisterised = YES" >> mk/build.mk
65    echo "SRC_HC_OPTS += -keep-hc-file -fvia-C" >> mk/build.mk
66    echo "GhcWithNativeCodeGen = NO" >> mk/build.mk
67    echo "GhcWithInterpreter = NO" >> mk/build.mk
68
69    # we just need to build the compiler and utils...
70    (cd glafp-utils && make boot && make)
71    (cd ghc && make boot)
72    (cd ghc/utils && make)
73    (cd ghc/compiler && make stage=1)
74   cd ..
75
76   touch b2-stamp
77 fi