hc-build 3.14 KB
Newer Older
1
#!/bin/sh -e
chak's avatar
chak committed
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
chak's avatar
chak committed
6 7 8 9 10 11
#
# Script to build GHC from .hc files (must be run in the fptools/ root
# directory into which the source and .hc files must already have been
# unpacked).  All options are passed through to ./configure (especially
# useful with --prefix).

ken's avatar
ken committed
12
configopts="$*"         # e.g., --enable-hc-boot-unregisterised
sof's avatar
sof committed
13
PWD=`pwd`
chak's avatar
chak committed
14

chak's avatar
chak committed
15 16 17 18 19 20 21 22 23 24 25 26
# check for GNU make
#
MAKENAMES="gmake make no-make"
for make in $MAKENAMES; do
  MAKE=$make
  $make --version 2>&1 | grep "GNU Make" >/dev/null && break
done
if [ $MAKE = no-make ]; then
  echo "Fatal error: Cannot find the GNU make utility"
  exit 1
fi

chak's avatar
chak committed
27 28
# build configuration
#
29
case "$configopts" in
30
*--enable-hc-boot-unregisterised*)
dons's avatar
dons committed
31
cat >>mk/build.mk <<END
32
GhcUnregisterised=YES
33 34
GhcWithInterpreter=NO
GhcWithNativeCodeGen=NO
35
GhcLibWays=
36
GhcWithSMP=NO
37 38 39
END
;;

40
*)
dons's avatar
dons committed
41
cat >>mk/build.mk <<END
42 43 44
# empty
END
;;
45
esac
sof's avatar
sof committed
46

47
echo "*** Building compiler..."
48
./configure --enable-hc-boot $configopts
49

Simon Marlow's avatar
Simon Marlow committed
50
# ToDo: figure out the minimal correct sequence here
51
$MAKE -C utils/mkdependC boot all
Simon Marlow's avatar
Simon Marlow committed
52 53 54
$MAKE -C utils/unlit boot all
$MAKE -C utils/mkdirhier boot all
$MAKE -C driver/mangler boot all
55 56
$MAKE -C includes boot all
$MAKE -C rts boot all
57
$MAKE -C libraries boot all GhcBootLibs=YES
58 59 60
$MAKE -C compat boot all
$MAKE -C utils boot all
$MAKE -C compiler boot all
chak's avatar
chak committed
61

62 63
MAKEFLAGS=

64 65
echo "*** Building libraries..."

66 67 68
# Get rid of --enable-hc-boot-unregisterised in $configotps if we had it
configopts=`echo $configopts | sed s/--enable-hc-boot-unregisterised//`

69 70
# Reconfigure, using the newly-build ghc binary as our $(GHC), and
# with hc bootstrapping disabled.
71
HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/compiler/ghc-inplace" $configopts
72

73
PRIMOP_BITS="primop-data-decl.hs-incl \
74 75 76 77 78 79 80 81 82 83
	      primop-tag.hs-incl  \
	      primop-list.hs-incl  \
	      primop-has-side-effects.hs-incl  \
	      primop-out-of-line.hs-incl  \
	      primop-commutable.hs-incl  \
	      primop-needs-wrapper.hs-incl  \
	      primop-can-fail.hs-incl  \
	      primop-strictness.hs-incl  \
	      primop-usage.hs-incl  \
	      primop-primop-info.hs-incl"
84 85 86 87

# Remove the old libraries.  Don't use make clean, because we don't
# want to delete the .hs files generated from the .hsc files, because
# we don't have hsc2hs built yet.
dons's avatar
dons committed
88
find libraries hslibs | grep '\.[oa]$' | xargs rm -f
89 90

# Do includes and RTS now
91 92
$MAKE -C includes boot && $MAKE -C includes all
$MAKE -C rts      boot && $MAKE -C rts      all
93

94
# Now build a new set of libraries (GhcBootLibs only for now)
95
$MAKE -C libraries boot all GhcBootLibs=YES
96

97 98
# Build all of compat
$MAKE -C compat clean && $MAKE -C compat boot all
99

100 101
# Build all of utils
$MAKE -C utils clean && $MAKE -C utils boot all
102

103 104 105
# Build the rest of the libraries
$MAKE -C libraries boot all

106 107 108
# The reconfigure step updates a few files, which can lead to
# unnecessary recompilations.  Touch a bunch of things here to avoid
# having to recompile stuff that we've already built.
Ian Lynagh's avatar
Ian Lynagh committed
109 110 111 112
(cd compiler; touch main/Config.hs $PRIMOP_BITS stage1/*/*.o stage1/ghc-* ghc-*)

echo hc-build done
echo The tree should be safe to do 'make install stage=1' in.
113