</varlistentry>
<varlistentry>
- <term><literal>EXCLUDE_SRCS</literal>
- <indexterm><primary><literal>EXCLUDE_SRCS</literal></primary></indexterm>
+ <term><literal>EXCLUDED_SRCS</literal>
+ <indexterm><primary><literal>EXCLUDED_SRCS</literal></primary></indexterm>
</term>
<listitem>
<para>Set to a list of source files (relative to the
<varlistentry>
<term><literal>EXTRA_SRCS</literal>
- <indexterm><primary><literal>EXCLUDE_SRCS</literal></primary></indexterm>
+ <indexterm><primary><literal>EXTRA_SRCS</literal></primary></indexterm>
</term>
<listitem>
<para>Set to a list of extra source files (perhaps
ones in <filename>boilerplate.mk</filename>.</para>
</sect2>
+ <sect2 id="sec-platforms">
+ <title>Platform settings</title>
+ <indexterm><primary>Platform settings</primary>
+ </indexterm>
+
+ <para>There are three platforms of interest when building GHC:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term>The <emphasis>build</emphasis> platform</term>
+ <listitem>
+ <para>The platform on which we are doing this build.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>The <emphasis>host</emphasis> platform</term>
+ <listitem>
+ <para>The platform on which these binaries will run.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>The <emphasis>target</emphasis> platform</term>
+ <listitem>
+ <para>The platform for which this compiler will generate code.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
+ <para>These platforms are set when running the
+ <literal>configure</literal> script, using the
+ <option>--build</option>, <option>--host</option>, and
+ <option>--target</option> options. The <filename>mk/config.mk</filename>
+ file defines several symbols related to the platform settings (see
+ <filename>mk/config.mk</filename> for details).</para>
+
+ <para>We don't currently support build & host being different, because
+ the build process creates binaries that are both run during the build,
+ and also installed.</para>
+
+ <para>If host and target are different, then we are building a
+ cross-compiler. For GHC, this means a compiler
+ which will generate intermediate .hc files to port to the target
+ architecture for bootstrapping. The libraries and stage 2 compiler
+ will be built as HC files for the target system (see <xref
+ linkend="sec-porting-ghc" /> for details.</para>
+
+ <para>More details on when to use BUILD, HOST or TARGET can be found in
+ the comments in <filename>config.mk</filename>.</para>
+ </sect2>
+
<sect2 id="sec-suffix">
<title>Pattern rules and options</title>
<indexterm><primary>Pattern rules</primary></indexterm>
<para>Bootstrapping GHC on a system without GHC already
installed is achieved by taking the intermediate C files (known
- as HC files) from a GHC compilation on a supported system to the
- target machine, and compiling them using gcc to get a working
- GHC.</para>
+ as HC files) from another GHC compilation, compiling them using gcc to
+ get a working GHC.</para>
<para><emphasis>NOTE: GHC versions 5.xx were hard to bootstrap
from C. We recommend using GHC 6.0.1 or
later.</emphasis></para>
<para>HC files are platform-dependent, so you have to get a set
- that were generated on similar hardware. There may be some
- supplied on the GHC download page, otherwise you'll have to
- compile some up yourself, or start from
- <emphasis>unregisterised</emphasis> HC files - see <xref
- linkend="unregisterised-porting"/>.</para>
+ that were generated on <emphasis>the same platform</emphasis>. There
+ may be some supplied on the GHC download page, otherwise you'll have to
+ compile some up yourself, or start from
+ <emphasis>unregisterised</emphasis> HC files - see <xref
+ linkend="unregisterised-porting"/>.</para>
<para>The following steps should result in a working GHC build
with full libraries:</para>
<listitem>
<screen>$ cd <replaceable>T</replaceable>/ghc/includes
-$ make ghcconfig.h</screen>
+$ make</screen>
</listitem>
</itemizedlist>
</listitem>
<programlisting>GhcUnregisterised = YES
GhcLibHcOpts = -O -fvia-C -keep-hc-files
+GhcRtsHcOpts = -keep-hc-files
GhcLibWays =
SplitObjs = NO
GhcWithNativeCodeGen = NO
GhcWithInterpreter = NO
GhcStage1HcOpts = -O -fasm
-GhcStage2HcOpts = -O -fvia-C -keep-hc-files</programlisting>
+GhcStage2HcOpts = -O -fvia-C -keep-hc-files
SRC_HC_OPTS += -H32m
-GhcBootLibs = YES
+GhcBootLibs = YES</programlisting>
</listitem>
<listitem>
<listitem>
<para>Copy
- <filename><replaceable>T</replaceable>/ghc/includes/ghcconfig.h</filename>
+ <filename><replaceable>T</replaceable>/ghc/includes/ghcautoconf.h</filename>, <filename><replaceable>T</replaceable>/ghc/includes/DerivedConstants.h</filename>, and <filename><replaceable>T</replaceable>/ghc/includes/GHCConstants.h</filename>
to
<filename><replaceable>H</replaceable>/ghc/includes</filename>.
Note that we are building on the host machine, using the
- target machine's <literal>config.h</literal> file. This
+ target machine's configuration files. This
is so that the intermediate C files generated here will
be suitable for compiling on the target system.</para>
-
</listitem>
<listitem>
- <para>Touch <literal>ghcconfig.h</literal>, just to make
- sure it doesn't get replaced during the build:</para>
-<screen>$ touch <replaceable>H</replaceable>/ghc/includes/ghcconfig.h</screen>
+ <para>Touch the generated configuration files, just to make
+ sure they don't get replaced during the build:</para>
+<screen>$ touch <filename><replaceable>H</replaceable></filename>/ghc/includes/{ghcautoconf.h,DerivedConstants.h.GHCConstants.h.mkDerivedConstants.c,mkDerivedConstantsHdr,mkDerivedConstants.o,mkGHCConstants,mkGHCConstants.o}</screen>
</listitem>
<listitem>
</listitem>
<listitem>
-<screen>$ cd <replaceable>H</replaceable>/ghc/utils
+<screen>$ cd <replaceable>H</replaceable>/ghc/lib
$ make clean
-$ make -k HC=<replaceable>H</replaceable>/ghc/compiler/stage1/ghc-inplace \
- EXTRA_HC_OPTS='-O -fvia-C -keep-hc-files'</screen>
+$ make -k UseStage1=YES EXTRA_HC_OPTS='-O -fvia-C -keep-hc-files'
+$ cd <replaceable>H</replaceable>/ghc/utils
+$ make clean
+$ make -k UseStage1=YES EXTRA_HC_OPTS='-O -fvia-C -keep-hc-files'</screen>
</listitem>
<listitem>
</para>
</listitem>
+ <listitem>
+ <para>You might want to install GLUT in your MSYS/Cygwin
+ installation, otherwise the GLUT package will not be built with
+ GHC.</para>
+ </listitem>
<listitem>
<para> Finally, check out a copy of GHC sources from