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