[project @ 2005-03-04 14:06:55 by simonmar]
[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 case "$configopts" in
30 *--enable-hc-boot-unregisterised*)
31 cat >>mk/build.mk <<END
32 GhcWithInterpreter=NO
33 GhcWithNativeCodeGen=NO
34 SplitObjs=NO
35 GhcLibWays=
36 END
37 ;;
38
39 *)
40 cat >>mk/build.mk <<END
41 # empty
42 END
43 ;;
44 esac
45
46 echo "*** Building compiler..."
47 ./configure --enable-hc-boot $configopts
48
49 $MAKE -C glafp-utils boot all
50 $MAKE -C ghc boot
51 $MAKE -C libraries boot all GhcBootLibs=YES
52 $MAKE -C ghc all
53
54 MAKEFLAGS=
55
56 echo "*** Building libraries..."
57
58 # Get rid of --enable-hc-boot-unregisterised in $configotps if we had it
59 configopts=`echo $configopts | sed s/--enable-hc-boot-unregisterised//`
60
61 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
62 # with hc bootstrapping disabled.
63 HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/ghc/compiler/ghc-inplace" $configopts
64
65 PRIMOP_BITS="primop-data-decl.hs-incl \
66               primop-tag.hs-incl  \
67               primop-list.hs-incl  \
68               primop-has-side-effects.hs-incl  \
69               primop-out-of-line.hs-incl  \
70               primop-commutable.hs-incl  \
71               primop-needs-wrapper.hs-incl  \
72               primop-can-fail.hs-incl  \
73               primop-strictness.hs-incl  \
74               primop-usage.hs-incl  \
75               primop-primop-info.hs-incl"
76
77 # Remove the old libraries.  Don't use make clean, because we don't
78 # want to delete the .hs files generated from the .hsc files, because
79 # we don't have hsc2hs built yet.
80 find libraries hslibs | grep '\.[oa]$' | xargs rm -f
81
82 # Do includes and RTS now
83 $MAKE -C ghc/includes boot && $MAKE -C ghc/includes all
84 $MAKE -C ghc/rts      boot && $MAKE -C ghc/rts      all
85
86 # Now build a new set of libraries
87 $MAKE -C libraries boot all GhcBootLibs=YES
88
89 # Build all of ghc/lib
90 $MAKE -C ghc/lib clean && $MAKE -C ghc/lib boot all
91
92 # Build all of ghc/utils
93 $MAKE -C ghc/utils clean && $MAKE -C ghc/utils boot all
94
95 # Now we can build hslibs (hsc2hs is required, so must be after ghc/utils)
96 $MAKE -C hslibs  boot all
97
98 # The reconfigure step updates a few files, which can lead to
99 # unnecessary recompilations.  Touch a bunch of things here to avoid
100 # having to recompile stuff that we've already built.
101 (cd ghc/compiler; touch $PRIMOP_BITS parser/hschooks.o prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
102
103 # At this point, the tree should be safe to do 'make install' in.