update submodules for GHC.HetMet.GArrow -> Control.GArrow renaming
[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 GhcUnregisterised=YES
33 GhcWithInterpreter=NO
34 GhcWithNativeCodeGen=NO
35 SplitObjs=NO
36 GhcLibWays=
37 GhcWithSMP=NO
38 END
39 ;;
40
41 *)
42 cat >>mk/build.mk <<END
43 # empty
44 END
45 ;;
46 esac
47
48 echo "*** Building compiler..."
49 ./configure --enable-hc-boot $configopts
50
51 # ToDo: figure out the minimal correct sequence here
52 $MAKE -C utils/mkdependC boot all
53 $MAKE -C utils/unlit boot all
54 $MAKE -C utils/mkdirhier boot all
55 $MAKE -C driver/mangler boot all
56 $MAKE -C includes boot all
57 $MAKE -C rts boot all
58 $MAKE -C libraries boot all GhcBootLibs=YES
59 $MAKE -C compat boot all
60 $MAKE -C utils boot all
61 $MAKE -C compiler boot all
62
63 MAKEFLAGS=
64
65 echo "*** Building libraries..."
66
67 # Get rid of --enable-hc-boot-unregisterised in $configotps if we had it
68 configopts=`echo $configopts | sed s/--enable-hc-boot-unregisterised//`
69
70 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
71 # with hc bootstrapping disabled.
72 HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/compiler/ghc-inplace" $configopts
73
74 PRIMOP_BITS="primop-data-decl.hs-incl \
75               primop-tag.hs-incl  \
76               primop-list.hs-incl  \
77               primop-has-side-effects.hs-incl  \
78               primop-out-of-line.hs-incl  \
79               primop-commutable.hs-incl  \
80               primop-needs-wrapper.hs-incl  \
81               primop-can-fail.hs-incl  \
82               primop-strictness.hs-incl  \
83               primop-usage.hs-incl  \
84               primop-primop-info.hs-incl"
85
86 # Remove the old libraries.  Don't use make clean, because we don't
87 # want to delete the .hs files generated from the .hsc files, because
88 # we don't have hsc2hs built yet.
89 find libraries hslibs | grep '\.[oa]$' | xargs rm -f
90
91 # Do includes and RTS now
92 $MAKE -C includes boot && $MAKE -C includes all
93 $MAKE -C rts      boot && $MAKE -C rts      all
94
95 # Now build a new set of libraries (GhcBootLibs only for now)
96 $MAKE -C libraries boot all GhcBootLibs=YES
97
98 # Build all of compat
99 $MAKE -C compat clean && $MAKE -C compat boot all
100
101 # Build all of utils
102 $MAKE -C utils clean && $MAKE -C utils boot all
103
104 # Build the rest of the libraries
105 $MAKE -C libraries boot all
106
107 # The reconfigure step updates a few files, which can lead to
108 # unnecessary recompilations.  Touch a bunch of things here to avoid
109 # having to recompile stuff that we've already built.
110 (cd compiler; touch main/Config.hs $PRIMOP_BITS stage1/*/*.o stage1/ghc-* ghc-*)
111
112 echo hc-build done
113 echo The tree should be safe to do 'make install stage=1' in.
114