#! /bin/bash # This script can be used to generate some unregisterised .hc files # for bootstrapping GHC on a new/unsupported platform. It involves a # two-stage bootstrap: the first stage builds an unregisterised set of # libraries & RTS, and the second stage builds an unregisterised # compiler. # Take the .hc files from the libraries of stage 1, and the compiler # of stage 2, to the target system and bootstrap from these to get a # working (unregisterised) compiler. set -e base=`pwd` # set this to the location of your source tree fptools_dir=/home/igloo/ghc6/m68k/ghc-6.0.1 arch=m68k-unknown-linux-gnu cp configure $fptools_dir if [ ! -f b1-stamp ]; then mkdir b1 cd b1 lndir $fptools_dir ######################## ./configure cd glafp-utils make boot make cd .. cd ghc/includes make config.h cd ../utils make boot make cd ../.. ######################## ./configure --target=$arch --host=$arch --build=$arch cd ghc/rts make package.conf.inplace cd ../.. rm ghc/rts/Makefile || true echo "boot: package.conf.inplace" > ghc/rts/Makefile echo "all:" >> ghc/rts/Makefile echo " ../../ghc/utils/ghc-pkg/ghc-pkg-inplace --update-package < package.conf.inplace" >> ghc/rts/Makefile echo "clean:" >> ghc/rts/Makefile # Needed for at least libraries/base/GHC/Float.hc rm libraries/mk/boilerplate.mk || true cp ../libraries-boilerplate.mk libraries/mk/boilerplate.mk rm hslibs/mk/boilerplate.mk || true cp ../hslibs-boilerplate.mk hslibs/mk/boilerplate.mk # For cross-compilation, at this stage you may want to set up a source # tree on the target machine, run the configure script there, and bring # the resulting mk/config.h file back into this tree before building # the libraries. rm mk/config.h cp ../config.h mk touch mk/build.mk echo "GhcUnregisterised = YES" >> mk/build.mk echo "GhcLibHcOpts = -O -H32m -fvia-C -keep-hc-files" >> mk/build.mk echo "GhcLibWays =" >> mk/build.mk echo "SplitObjs = NO" >> mk/build.mk echo "GhcWithNativeCodeGen=NO" >> mk/build.mk # We could optimise slightly by not building hslibs here. Also, building # the RTS is not necessary (and might not be desirable if we're using # a config.h from the target system). make stage1 cd .. touch b1-stamp fi # exit 0 if [ ! -f b2-stamp ]; then mkdir b2 cd b2 lndir $fptools_dir #rm -rf glafp-utils ghc/utils #ln -s ../b0/glafp-utils glafp-utils #ln -s ../../b0/ghc/utils ghc/utils ######################## ./configure cd glafp-utils make boot make cd .. cd ghc/includes make config.h cd ../utils make boot make cd ../.. ######################## ./configure --with-ghc="$base/b1/ghc/compiler/stage1/ghc-inplace" --target=$arch --host=$arch --build=$arch mv ghc/mk/boilerplate.mk ghc/mk/boilerplate.mk.aswas cp ../ghc-boilerplate.mk ghc/mk/boilerplate.mk rm mk/config.h cp ../config.h mk rm ghc/compiler/Makefile cp ../Makefile ghc/compiler touch mk/build.mk #echo "GhcHcOpts = -O -H32m -fvia-C -keep-hc-files" >> mk/build.mk echo "GhcUnregisterised = YES" >> mk/build.mk echo "SRC_HC_OPTS += -keep-hc-file -fvia-C" >> mk/build.mk echo "GhcWithNativeCodeGen = NO" >> mk/build.mk echo "GhcWithInterpreter = NO" >> mk/build.mk #echo "WhatGccIsCalled = /bin/true" >> mk/build.mk # we just need to build the compiler... cd ghc make boot cd .. cd ghc/compiler make stage=1 cd ../.. mkdir ../b2-unwanted mv libraries ../b2-unwanted mv hslibs ../b2-unwanted ln -s ../b1/libraries . ln -s ../b1/hslibs . make hc-file-bundle Project=Ghc cd .. touch b2-stamp fi