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
40 cat >>mk/build.mk <<END
46 echo "*** Building compiler..."
47 ./configure --enable-hc-boot $configopts
49 # ToDo: figure out the minimal correct sequence here
50 $MAKE -C utils/mkdependC boot all
51 $MAKE -C utils/unlit boot all
52 $MAKE -C utils/mkdirhier boot all
53 $MAKE -C driver/mangler boot all
54 $MAKE -C includes boot all
56 $MAKE -C libraries boot all GhcBootLibs=YES
57 $MAKE -C compat boot all
58 $MAKE -C utils boot all
59 $MAKE -C compiler boot all
63 echo "*** Building libraries..."
65 # Get rid of --enable-hc-boot-unregisterised in $configotps if we had it
66 configopts=`echo $configopts | sed s/--enable-hc-boot-unregisterised//`
68 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
69 # with hc bootstrapping disabled.
70 HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/compiler/ghc-inplace" $configopts
72 PRIMOP_BITS="primop-data-decl.hs-incl \
75 primop-has-side-effects.hs-incl \
76 primop-out-of-line.hs-incl \
77 primop-commutable.hs-incl \
78 primop-needs-wrapper.hs-incl \
79 primop-can-fail.hs-incl \
80 primop-strictness.hs-incl \
81 primop-usage.hs-incl \
82 primop-primop-info.hs-incl"
84 # Remove the old libraries. Don't use make clean, because we don't
85 # want to delete the .hs files generated from the .hsc files, because
86 # we don't have hsc2hs built yet.
87 find libraries hslibs | grep '\.[oa]$' | xargs rm -f
89 # Do includes and RTS now
90 $MAKE -C includes boot && $MAKE -C includes all
91 $MAKE -C rts boot && $MAKE -C rts all
93 # Now build a new set of libraries (GhcBootLibs only for now)
94 $MAKE -C libraries boot all GhcBootLibs=YES
97 $MAKE -C compat clean && $MAKE -C compat boot all
100 $MAKE -C utils clean && $MAKE -C utils boot all
102 # Build the rest of the libraries
103 $MAKE -C libraries boot all
105 # The reconfigure step updates a few files, which can lead to
106 # unnecessary recompilations. Touch a bunch of things here to avoid
107 # having to recompile stuff that we've already built.
108 (cd compiler; touch $PRIMOP_BITS parser/hschooks.o prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
110 # At this point, the tree should be safe to do 'make install' in.