a7e43517f3e958d07bb65f4934979af3114e5f67
[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    echo "GhcUnregisterised = YES" >> mk/config.mk
35    echo "GhcLibHcOpts = -O -H32m -fvia-C -keep-hc-files" >> mk/config.mk
36    echo "GhcLibWays =" >> mk/config.mk
37    echo "SplitObjs = NO" >> mk/config.mk
38
39    # We could optimise slightly by not building hslibs here.  Also, building
40    # the RTS is not necessary (and might not be desirable if we're using
41    # a config.h from the target system).
42    make stage1
43
44   cd ..
45
46   touch b1-stamp
47 fi
48
49 # exit 0
50
51 if [ ! -f b2-stamp ]; then
52   mkdir b2
53   cd b2
54   lndir $fptools_dir
55   cd ..
56
57   cd b2
58    ./configure --with-ghc=$base/b1/ghc/compiler/stage1/ghc-inplace
59
60    echo "GhcHcOpts = -O -H32m -fvia-C -keep-hc-files" >> mk/config.mk
61    echo "GhcWithNativeCodeGen = NO" >> mk/config.mk
62
63    # we just need to build the compiler...
64    (cd glafp-utils && make boot && make)
65    (cd ghc && make boot)
66    (cd ghc/compiler && make stage=1)
67   cd ..
68
69   touch b2-stamp
70 fi