6 * Send hunks #3 and #4 of patch-aclocal.m4 to the upstream.
7 * Send patch-configure.ac to the upstream.
8 * Send patch-libraries-integer-gmp_configure.ac to the upstream.
9 * Send patch-rules_hs-suffix-rules-srcdir.mk to the upstream.
10 * Modify configure.ac and rules/build-package-data.mk to allow
11 ``--with-curses-{includes,libraries}`` to be passed to the top-level
12 ``configure``, and send a patch to the upstream.
13 * Explain about files/bootstrap-main.c and files/capi-wrappers-*.c
14 in this guide, and fix the upstream to throw them away.
15 * Build more bootstrapping HC archives to support more platforms.
18 How to build an HC archive
19 --------------------------
21 A preferred, automated way
22 ^^^^^^^^^^^^^^^^^^^^^^^^^^
24 I've written an automation tool to build one: `build-hc-pkg
25 <http://git.cielonegro.org/gitweb.cgi?p=build-hc-pkg.git>`_
27 To use it, clone the repository, run ``./build-hc-pkg``, and then
28 follow the instruction it shows::
30 $ git clone git://git.cielonegro.org/build-hc-pkg.git
35 This is build-hc-pkg, running on powerpc-apple-darwin9.8.0 with 2 processors.
36 Enter the file path to ghc-x.y.z-src.tar.bz2: _
38 Note that you need Bash, Automake, GNU make, GNU sed, and GNU tar to
45 It's basically the same as the `Porting Guide
46 <http://hackage.haskell.org/trac/ghc/wiki/Building/Porting>`_, plus
49 Extract the source archive and duplicate the source tree, one for
50 ``-target`` and one for ``-host``::
52 $ tar jxf ghc-{VERSION}-src.tar.bz2
53 $ cp -r ghc-{VERSION} ghc-{VERSION}-target
54 $ mv ghc-{VERSION} ghc-{VERSION}-host
56 Build some configuration files::
58 $ cd ghc-{VERSION}-target
59 $ ./configure --enable-hc-boot
60 $ echo "INTEGER_LIBRARY = integer-simple" > mk/build.mk
61 $ gmake bootstrapping-files
64 Run ``./configure`` on the host tree::
66 $ cd ghc-{VERSION}-host
68 --with-iconv-includes=/usr/pkg/include \
69 --with-iconv-libraries=/usr/pkg/lib
71 Then create ``ghc-{VERSION}-host/mk/build.mk`` with the following
75 GhcUnregisterised = YES
76 GhcLibHcOpts = -O -fvia-C -keep-hc-files
77 GhcRtsHcOpts = -keep-hc-files
81 GhcWithNativeCodeGen = NO
82 GhcWithInterpreter = NO
84 GhcStage2HcOpts = -O -fvia-C -keep-hc-files
87 utils/ghc-pkg_dist-install_v_HC_OPTS += -keep-hc-files
89 INTEGER_LIBRARY = integer-simple
90 libraries/terminfo_CONFIGURE_OPTS += \
91 --configure-option=--with-curses-includes=/usr/pkg/include \
92 --configure-option=--with-curses-libraries=/usr/pkg/lib
94 Copy some configuration files from the ``-target`` tree::
96 $ cp -r ../ghc-{VERSION}-target/includes/dist-{ghcconstants,derivedconstants} includes/
97 $ cp ../ghc-{VERSION}-target/includes/ghcautoconf.h includes/
103 Create an intermediate tarball::
105 $ rm -f list mkfiles boot.tar.gz
106 $ find . -name "*.hi" >> list
107 $ find . -name "*.hc" >> list
108 $ find . -name "*_stub.c" >> list
109 $ find . -name "*_stub.h" >> list
110 $ find . -name package-data.mk >> list
111 $ find . -name package.conf.d >> list
112 $ find . -name package.conf.inplace >> list
113 $ ls compiler/stage?/build/Config.hs >> list
114 $ echo compiler/prelude/primops.txt >> list
115 $ ls compiler/primop-*.hs-incl >> list
116 $ find . -name .depend | sed -e 's/^/mkdir -p `dirname /' -e 's/$/`/' >> mkfiles
117 $ find . -name .depend | sed "s/^/touch /" >> mkfiles
118 $ echo mkfiles >> list
119 $ tar -zcf boot.tar.gz -T list
121 Then extract it again, in a different directory::
123 $ mkdir ghc-{VERSION}
125 $ tar zxf ../boot.tar.gz
127 Modify hard-coded paths in inplace ``.conf`` files, and then
128 re-archive the HC tree::
131 -e 's#/usr/pkg#[[PREFIX]]#g' \
132 -e 's#'`dirname \`pwd\``'#[[GHC_SOURCE_PATH]]#g' \
133 inplace/lib/package.conf.d/*.conf \
134 */package.conf.inplace \
135 */*/package-data.mk \
136 */*/*/package-data.mk \
137 */*/*/*/package-data.mk
139 $ tar jcvf ghc-{VERSION}-boot-{PLATFORM}.tar.bz2 ghc-{VERSION}
141 Done. Upload the archive to some host and add it to the ``Makefile``.