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