1629bf3d6a654767e07bd8423b14cede66e2e556
[ghc-hetmet.git] / distrib / hc-build
1 #!/bin/sh -e
2
3 # Manuel M. T. Chakravarty <chak@acm.org>, June 2000
4 # Updated for GHC 5.00, Simon Marlow, March 2001
5 # Updated for GHC 5.04.3, Urban Boquist, March 2003
6 #
7 # Script to build GHC from .hc files (must be run in the fptools/ root
8 # directory into which the source and .hc files must already have been
9 # unpacked).  All options are passed through to ./configure (especially
10 # useful with --prefix).
11
12 configopts="$*"         # e.g., --enable-hc-boot-unregisterised
13 PWD=`pwd`
14
15 # check for GNU make
16 #
17 MAKENAMES="gmake make no-make"
18 for make in $MAKENAMES; do
19   MAKE=$make
20   $make --version 2>&1 | grep "GNU Make" >/dev/null && break
21 done
22 if [ $MAKE = no-make ]; then
23   echo "Fatal error: Cannot find the GNU make utility"
24   exit 1
25 fi
26
27 # build configuration
28 #
29 cat >mk/build.mk <<END
30 # nothing!
31 END
32
33 # touch happy generated files; so that in non-bootstrapping mode for
34 # installation, no attempt is made to call happy
35 #
36 touch ghc/compiler/parser/Parser.hs
37 touch ghc/compiler/main/ParsePkgConf.hs
38 touch hslibs/hssource/HsParser.hs
39
40 # We don't have genprimopcode yet so don't try to use it
41 touch ghc/compiler/prelude/primops.txt
42 touch libraries/base/GHC/PrimopWrappers.hs
43
44 echo "*** Building compiler..."
45 ./configure --enable-hc-boot $configopts
46
47 $MAKE -C glafp-utils boot all
48 $MAKE -C ghc boot
49 $MAKE -C libraries boot all
50 $MAKE -C hslibs boot all
51 $MAKE -C ghc all
52
53 MAKEFLAGS=
54
55 echo "*** Building libraries..."
56
57 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
58 # with hc bootstrapping disabled.
59 HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/ghc/compiler/ghc-inplace" $configopts
60
61 PRIMOP_BITS="primop-data-decl.hs-incl \
62             primop-tag.hs-incl  \
63             primop-list.hs-incl  \
64             primop-has-side-effects.hs-incl  \
65             primop-out-of-line.hs-incl  \
66             primop-commutable.hs-incl  \
67             primop-needs-wrapper.hs-incl  \
68             primop-can-fail.hs-incl  \
69             primop-strictness.hs-incl  \
70             primop-usage.hs-incl  \
71             primop-primop-info.hs-incl"
72
73 # The reconfigure step updates a few files, which can lead to
74 # unnecessary recompilations.  Touch a bunch of things here to avoid
75 # having to recompile stuff that we've already built.
76 (cd ghc/compiler; touch $PRIMOP_BITS parser/hschooks.o prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
77
78 # Remove the old libraries.  Don't use make clean, because we don't
79 # want to delete the .hs files generated from the .hsc files, because
80 # we don't have hsc2hs built yet.
81 find libraries hslibs | grep '\.\(o\|a\)' | xargs rm -f
82
83 # Do includes and RTS now
84 $MAKE -C ghc/includes boot && $MAKE -C ghc/includes all
85 $MAKE -C ghc/rts      boot && $MAKE -C ghc/rts      all
86
87 # Now build a new set of libraries
88 $MAKE -C libraries boot all
89 $MAKE -C hslibs  boot all
90
91 # Finally build all of ghc/utils
92 $MAKE -C ghc/utils clean && $MAKE -C ghc/utils boot all
93
94 # Avoid relinking the compiler during 'make install':
95 (cd ghc/compiler; touch parser/hschooks.o ghc-*)
96
97 # At this point, the tree should be safe to do 'make install' in.