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
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).
12 configopts="$*" # e.g., --enable-hc-boot-unregisterised
17 MAKENAMES="gmake make no-make"
18 for make in $MAKENAMES; do
20 $make --version 2>&1 | grep "GNU Make" >/dev/null && break
22 if [ $MAKE = no-make ]; then
23 echo "Fatal error: Cannot find the GNU make utility"
30 *--enable-hc-boot-unregisterised*)
31 cat >mk/build.mk <<END
33 GhcWithNativeCodeGen=NO
37 cat >mk/build.mk <<END
42 echo "*** Building compiler..."
43 ./configure --enable-hc-boot $configopts
45 $MAKE -C glafp-utils boot all
47 $MAKE -C libraries boot all
52 echo "*** Building libraries..."
54 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
55 # with hc bootstrapping disabled.
56 HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/ghc/compiler/ghc-inplace" $configopts
58 PRIMOP_BITS="primop-data-decl.hs-incl \
61 primop-has-side-effects.hs-incl \
62 primop-out-of-line.hs-incl \
63 primop-commutable.hs-incl \
64 primop-needs-wrapper.hs-incl \
65 primop-can-fail.hs-incl \
66 primop-strictness.hs-incl \
67 primop-usage.hs-incl \
68 primop-primop-info.hs-incl"
70 # The reconfigure step updates a few files, which can lead to
71 # unnecessary recompilations. Touch a bunch of things here to avoid
72 # having to recompile stuff that we've already built.
73 (cd ghc/compiler; touch $PRIMOP_BITS parser/hschooks.o prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
75 # Remove the old libraries. Don't use make clean, because we don't
76 # want to delete the .hs files generated from the .hsc files, because
77 # we don't have hsc2hs built yet.
78 find libraries hslibs | grep '\.\(o\|a\)' | xargs rm -f
80 # Do includes and RTS now
81 $MAKE -C ghc/includes boot && $MAKE -C ghc/includes all
82 $MAKE -C ghc/rts boot && $MAKE -C ghc/rts all
84 # Now build a new set of libraries
85 $MAKE -C libraries boot all
87 # Build all of ghc/utils
88 $MAKE -C ghc/utils clean && $MAKE -C ghc/utils boot all
90 # Now we can build hslibs (hsc2hs is required, so must be after ghc/utils)
91 $MAKE -C hslibs boot all
93 # Avoid relinking the compiler during 'make install':
94 (cd ghc/compiler; touch parser/hschooks.o ghc-*)
96 # At this point, the tree should be safe to do 'make install' in.