<Abstract>
-<Para>
+<para>
This guide is intended for people who want to build or modify
programs from the Glasgow <Literal>fptools</Literal> suite (as distinct from those
who merely want to <Emphasis>run</Emphasis> them). Installation instructions are now provided in the user guide.
-</Para>
+</para>
-<Para>
+<para>
The bulk of this guide applies to building on Unix systems; see <XRef LinkEnd="winbuild"> for Windows notes.
-</Para>
+</para>
</Abstract>
<Title>Getting the Glasgow <Literal>fptools</Literal> suite
</Title>
-<Para>
+<para>
Building the Glasgow tools <Emphasis>can</Emphasis> be complicated, mostly because
there are so many permutations of what/why/how, e.g., ``Build Happy
with HBC, everything else with GHC, leave out profiling, and test it
all on the `real' NoFib programs.'' Yeeps!
-</Para>
+</para>
-<Para>
+<para>
Happily, such complications don't apply to most people. A few common
``strategies'' serve most purposes. Pick one and proceed
as suggested:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<Term><IndexTerm><Primary>Binary distribution</Primary></IndexTerm>Binary distribution.</Term>
<ListItem>
-<Para>
+<para>
If your only purpose is to install some of the <Literal>fptools</Literal> suite then the easiest thing to do is to get a binary distribution. In the
binary distribution everything is pre-compiled for your particular
machine architecture and operating system, so all you should have to
do is install the binaries and libraries in suitable places. The user guide
describes how to do this.
-</Para>
+</para>
-<Para>
+<para>
A binary distribution may not work for you for two reasons. First, we
may not have built the suite for the particular architecture/OS
platform you want. That may be due to lack of time and energy (in
below). Alternatively, it may be because we haven't yet ported the
suite to your architecture, in which case you are considerably worse
off.
-</Para>
+</para>
-<Para>
+<para>
The second reason a binary distribution may not be what you want is
if you want to read or modify the souce code.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><IndexTerm><Primary>Source distribution</Primary></IndexTerm>Source distribution.</Term>
<ListItem>
-<Para>
+<para>
You have a supported
platform, but (a) you like the warm fuzzy feeling of compiling things
yourself; (b) you want to build something ``extra''—e.g., a set of
libraries with strictness-analysis turned off; or (c) you want to hack
on GHC yourself.
-</Para>
+</para>
-<Para>
+<para>
A source distribution contains complete sources for one or more
-projects in the <Literal>fptools</Literal> suite. Not only that, but the more awkward
-machine-independent steps are done for you. For example, if you don't
-have <Command>flex</Command><IndexTerm><Primary>flex</Primary></IndexTerm> you'll find it convenient that the source
-distribution contains the result of running <Command>flex</Command> on the lexical
-analyser specification. If you don't want to alter the lexical
-analyser then this saves you having to find and install <Command>flex</Command>. You
-will still need a working version of GHC on your machine in order to
-compile (most of) the sources, however.
-</Para>
-
-<Para>
-We make source distributions more frequently than binary
-distributions; a release that comes with pre-compiled binaries
-is considered a major release, i.e., a release that we have some
-confidence will work well by having tested it (more) thoroughly.
-</Para>
-
-<Para>
-Source-only distributions are either bugfix releases or snapshots of
-current state of development. The release has undergone some testing.
-Source releases of GHC 4.xx can be compiled up using GHC 2.10 or
-later.
-</Para>
+projects in the <Literal>fptools</Literal> suite. Not only that, but
+the more awkward machine-independent steps are done for you. For
+example, if you don't have
+<Command>happy</Command><IndexTerm><Primary>happy</Primary></IndexTerm>
+you'll find it convenient that the source distribution contains the
+result of running <Command>happy</Command> on the parser
+specifications. If you don't want to alter the parser then this saves
+you having to find and install <Command>happy</Command>. You will
+still need a working version of GHC (preferably version 4.08+) on your
+machine in order to compile (most of) the sources, however.
+</para>
+
</ListItem></VarListEntry>
<VarListEntry>
<Term>Build GHC from intermediate C <Filename>.hc</Filename> files<IndexTerm><Primary>hc files</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
You
need a working GHC to use a source distribution. What if you don't
have a working GHC? Then you have no choice but to ``bootstrap'' up
from the intermediate C (<Filename>.hc</Filename>) files that we provide. Building GHC
on an unsupported platform falls into this category. Please see
<Xref LinkEnd="sec-booting-from-C">.
-</Para>
+</para>
-<Para>
+<para>
Once you have built GHC, you can build the other Glasgow tools with
it.
-</Para>
+</para>
-<Para>
+<para>
In theory, you can (could?) build GHC with another Haskell compiler
(e.g., HBC). We haven't tried to do this for ages and it almost
certainly doesn't work any more (for tedious reasons).
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term>The CVS repository.</Term>
<ListItem>
-<Para>
-We make source distributions slightly more often than binary
-distributions; but still infrequently. If you want more up-to-the
-minute (but less tested) source code then you need to get access to
-our CVS repository.
-</Para>
-
-<Para>
-All the <Literal>fptools</Literal> source code is held in a CVS repository. CVS is a
-pretty good source-code control system, and best of all it works over
-the network.
-</Para>
-
-<Para>
-The repository holds source code only. It holds no mechanically
+<para>
+We make releases infrequently. If you want more up-to-the minute (but
+less tested) source code then you need to get access to our CVS
+repository.
+</para>
+
+<para>All the <Literal>fptools</Literal> source code is held in a CVS
+repository. CVS is a pretty good source-code control system, and best
+of all it works over the network.</para>
+
+<para>The repository holds source code only. It holds no mechanically
generated files at all. So if you check out a source tree from CVS
you will need to install every utility so that you can build all the
-derived files from scratch.
-</Para>
-
-<Para>
-More information about our CVS repository is available in the <ULink
-URL="http://www.haskell.org/ghc/cvs-cheat-sheet.html" >FPTools CVS
-Cheat Sheet</ULink >.
-</Para>
+derived files from scratch.</para>
+
+<para>More information about our CVS repository is available in the
+<ULink URL="http://www.haskell.org/ghc/cvs-cheat-sheet.html">fptools
+CVS Cheat Sheet</ULink>.</para>
+
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
-If you are going to do any building from sources (either from a source
-distribution or the CVS repository) then you need to read all of this
-manual in detail.
-</Para>
+<para>If you are going to do any building from sources (either from a
+source distribution or the CVS repository) then you need to read all
+of this manual in detail.</para>
</Sect1>
<Sect1 id="sec-build-checks">
<Title>Things to check before you start typing</Title>
-<Para>
+<para>
Here's a list of things to check before you get started.
<OrderedList>
<ListItem>
-<Para>
+<para>
<IndexTerm><Primary>Disk space needed</Primary></IndexTerm>
Disk space needed: About 40MB (one tenth of one hamburger's worth) of disk
space for the most basic binary distribution of GHC; more for some
over 100MB (say, one fifth a hamburger's worth) if you need to build the
basic stuff from scratch. All of the above are
<Emphasis>estimates</Emphasis> of disk-space needs. (Note: our benchmark hamburger is a standard Double Whopper with Cheese, with an RRP of UKP2.99.)
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-Use an appropriate machine, compilers, and things.
-SPARC boxes, and PCs running Linux, FreeBSD, NetBSD, or Solaris are
-all fully supported. Win32 and HP boxes are in pretty good shape.
-DEC Alphas running OSF/1, Linux or some BSD variant, MIPS and AIX
-boxes will need some minimal porting effort before they work (as of
-4.06). <Xref LinkEnd="sec-port-info"> gives the full run-down on
-ports or lack thereof.
-</Para>
+<para>
+Use an appropriate machine, compilers, and things. SPARC boxes, and
+PCs running Linux, BSD (any variant), or Solaris are all fully
+supported. Win32 and HP boxes are in pretty good shape. DEC Alphas
+running OSF/1, Linux or some BSD variant, MIPS and AIX boxes will need
+some minimal porting effort before they work (as of 4.06). <Xref
+LinkEnd="sec-port-info"> gives the full run-down on ports or lack
+thereof.
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Be sure that the ``pre-supposed'' utilities are installed.
<Xref LinkEnd="sec-pre-supposed"> elaborates.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
If you have any problem when building or installing the Glasgow
tools, please check the ``known pitfalls'' (<Xref
LinkEnd="sec-build-pitfalls">). Also check the FAQ for the version
If in doubt, please send a message to
<Email>glasgow-haskell-bugs@haskell.org</Email>.
<IndexTerm><Primary>bugs, mailing list</Primary></IndexTerm>
-</Para>
+</para>
</ListItem>
</OrderedList>
-</Para>
+</para>
</Sect1>
<Title>What machines the Glasgow tools run on
</Title>
-<Para>
+<para>
<IndexTerm><Primary>ports, GHC</Primary></IndexTerm>
<IndexTerm><Primary>GHC ports</Primary></IndexTerm>
<IndexTerm><Primary>supported platforms</Primary></IndexTerm>
<IndexTerm><Primary>platforms, supported</Primary></IndexTerm>
The main question is whether or not the Haskell compiler (GHC) runs on
your platform.
-</Para>
+</para>
-<Para>
+<para>
A ``platform'' is a architecture/manufacturer/operating-system
combination, such as <Literal>sparc-sun-solaris2</Literal>. Other common ones are
<Literal>alpha-dec-osf2</Literal>, <Literal>hppa1.1-hp-hpux9</Literal>, <Literal>i386-unknown-linux</Literal>,
<Literal>i386-unknown-solaris2</Literal>, <Literal>i386-unknown-freebsd</Literal>,
<Literal>i386-unknown-cygwin32</Literal>, <Literal>m68k-sun-sunos4</Literal>, <Literal>mips-sgi-irix5</Literal>,
<Literal>sparc-sun-sunos4</Literal>, <Literal>sparc-sun-solaris2</Literal>, <Literal>powerpc-ibm-aix</Literal>.
-</Para>
+</para>
-<Para>
+<para>
Bear in mind that certain ``bundles'', e.g. parallel Haskell, may not
work on all machines for which basic Haskell compiling is supported.
-</Para>
+</para>
-<Para>
+<para>
Some libraries may only work on a limited number of platforms; for
example, a sockets library is of no use unless the operating system
supports the underlying BSDisms.
-</Para>
+</para>
<Sect2>
<Title>What platforms the Haskell compiler (GHC) runs on</Title>
-<Para>
+<para>
<IndexTerm><Primary>fully-supported platforms</Primary></IndexTerm>
<IndexTerm><Primary>native-code generator</Primary></IndexTerm>
<IndexTerm><Primary>registerised ports</Primary></IndexTerm>
generator; (b) next best is a ``registerised''
port; (c) the bare minimum is an ``unregisterised'' port.
(``Unregisterised'' is so terrible that we won't say more about it).
-</Para>
-
-<Para>
-The native code generator is currently non-functional (as of GHC
-version 4.06), but we're actively working on getting it going again.
-</Para>
+</para>
-<Para>
+<para>
We use Sparcs running Solaris 2.7 and x86 boxes running FreeBSD and
Linux, so those are the best supported platforms, unsurprisingly.
-</Para>
+</para>
-<Para>
+<para>
Here's everything that's known about GHC ports. We identify platforms
by their ``canonical'' CPU/Manufacturer/OS triple.
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<IndexTerm><Primary>alpha-dec-netbsd</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Currently non-working. The last working version (osf[1-3]) is GHC
3.02. A small amount of porting effort will be required to get Alpha
support into GHC 4.xx, but we don't have easy access to machines right
now, and there hasn't been a massive demand for support, so Alphas
remain unsupported for the time being. Please get in touch if you
either need Alpha support and/or can provide access to boxes.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>sparc-sun-sunos4</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Probably works with minor tweaks, hasn't been tested for a while.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>sparc-sun-solaris2</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Fully supported, including native-code generator.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>hppa1.1-hp-hpux</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Works registerised. No native-code generator.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>i386-*-linux</Primary></IndexTerm>
<ListItem>
-<Para>
-GHC works registerised. You <Emphasis>must</Emphasis> have GCC 2.7.x
-or later. NOTE about <literal>glibc</literal> versions: GHC binaries
-built on a system running <literal>glibc 2.0</literal> won't work on a
-system running <literal>glibc 2.1</literal>, and vice version. In
-general, don't expect compatibility between <literal>glibc</literal>
-versions, even if the shared library version hasn't changed.
-</Para>
+<para>GHC works registerised, has a native code generator. You
+<Emphasis>must</Emphasis> have GCC 2.7.x or later. NOTE about
+<literal>glibc</literal> versions: GHC binaries built on a system
+running <literal>glibc 2.0</literal> won't work on a system running
+<literal>glibc 2.1</literal>, and vice versa. In general, don't
+expect compatibility between <literal>glibc</literal> versions, even
+if the shared library version hasn't changed.
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>i386-unknown-openbsd</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
GHC works registerised. These systems provide ready-built packages of
GHC, so if you just need binaries you're better off just installing
the package.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>i386-unknown-cygwin32</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Fully supported under Win9x/NT, including a native code
generator. Requires the <Literal>cygwin32</Literal> compatibility
library and a healthy collection of GNU tools (i.e., gcc, GNU ld, bash
etc.).
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>mips-sgi-irix[5-6]</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Port currently doesn't work, needs some minimal porting effort. As
usual, we don't have access to machines and there hasn't been an
overwhelming demand for this port, but feel free to get in touch.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term>powerpc-ibm-aix:</Term>
<ListItem>
-<Para>
+<para>
<IndexTerm><Primary>powerpc-ibm-aix</Primary></IndexTerm>
Port currently doesn't work, needs some minimal porting effort. As
usual, we don't have access to machines and there hasn't been an
overwhelming demand for this port, but feel free to get in touch.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
<para>
Various other systems have had GHC ported to them in the distant past,
<Sect2>
<Title>What machines the other tools run on</Title>
-<Para>
+<para>
Unless you hear otherwise, the other tools work if GHC works.
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>pre-supposed utilities</Primary></IndexTerm>
<IndexTerm><Primary>utilities, pre-supposed</Primary></IndexTerm></Title>
-<Para>
+<para>
Here are the gory details about some utility programs you may need;
<Command>perl</Command>, <Command>gcc</Command> and
<command>happy</command> are the only important
if you're going for Parallel Haskell.) The
<Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm>
script will tell you if you are missing something.
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<IndexTerm><Primary>pre-supposed: Perl</Primary></IndexTerm>
<IndexTerm><Primary>Perl, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
<Emphasis>You have to have Perl to proceed!</Emphasis> Perl is a
language quite good for doing shell-scripty tasks that involve lots of
text processing. It is pretty easy to install.
-</Para>
+</para>
-<Para>
+<para>
Perl 5 is required. For Win32 platforms, we strongly suggest you
pick up a port of Perl 5 for <Literal>cygwin32</Literal>, as the
common Hip/ActiveWare port of Perl is Not Cool Enough for our
purposes.
-</Para>
+</para>
-<Para>
+<para>
Perl should be put somewhere so that it can be invoked by the
<Literal>#!</Literal> script-invoking mechanism. (I believe
<Filename>/usr/bin/perl</Filename> is preferred; we use
<Filename>/usr/local/bin/perl</Filename> at Glasgow.) The full
pathname should may need to be less than 32 characters long on some
systems.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>GCC (GNU C compiler), pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
We recommend using GCC version 2.95.2 on all platforms. Failing that,
version 2.7.2 is stable on most platforms. Earlier versions of GCC
can be assumed not to work, and versions in between 2.7.2 and 2.95.2
(including <command>egcs</command>) have varying degrees of stability
depending on the platform.
-</Para>
+</para>
-<Para>
+<para>
If your GCC dies with ``internal error'' on some GHC source file,
please let us know, so we can report it and get things improved.
(Exception: on iX86 boxes—you may need to fiddle with GHC's
<Option>-monly-N-regs</Option> option; see the User's Guide)
-</Para>
+</para>
</ListItem></VarListEntry>
<varlistentry>
<IndexTerm><Primary>pre-supposed: Autoconf</Primary></IndexTerm>
<IndexTerm><Primary>Autoconf, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
GNU Autoconf is needed if you intend to build from the CVS sources, it
is <Emphasis>not</Emphasis> needed if you just intend to build a
standard source distribution.
-</Para>
+</para>
-<Para>
+<para>
Autoconf builds the <Command>configure</Command> script from
<Filename>configure.in</Filename> and <Filename>aclocal.m4</Filename>.
If you modify either of these files, you'll need
<command>autoconf</command> to rebuild <Filename>configure</Filename>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>pre-supposed: sed</Primary></IndexTerm>
<IndexTerm><Primary>sed, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
You need a working <Command>sed</Command> if you are going to build
from sources. The build-configuration stuff needs it. GNU sed
version 2.0.4 is no good! It has a bug in it that is tickled by the
build-configuration. 2.0.5 is OK. Others are probably OK too
(assuming we don't create too elaborate configure scripts.)
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
One <Literal>fptools</Literal> project is worth a quick note at this
point, because it is useful for all the others:
<Literal>glafp-utils</Literal> contains several utilities which aren't
particularly Glasgow-ish, but Occasionally Indispensable. Like
<Command>lndir</Command> for creating symbolic link trees.
-</Para>
+</para>
<Sect2 id="pre-supposed-gph-tools">
<Title>Tools for building parallel GHC (GPH)
</Title>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<IndexTerm><Primary>PVM3 (Parallel Virtual Machine), pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
PVM is the Parallel Virtual Machine on which Parallel Haskell programs
run. (You only need this if you plan to run Parallel Haskell.
Concurent Haskell, which runs concurrent threads on a uniprocessor
doesn't need it.) Underneath PVM, you can have (for example) a
network of workstations (slow) or a multiprocessor box (faster).
-</Para>
+</para>
-<Para>
+<para>
The current version of PVM is 3.3.11; we use 3.3.7. It is readily
available on the net; I think I got it from
<Literal>research.att.com</Literal>, in <Filename>netlib</Filename>.
-</Para>
+</para>
-<Para>
+<para>
A PVM installation is slightly quirky, but easy to do. Just follow
the <Filename>Readme</Filename> instructions.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Command>bash</Command>:</Term>
<IndexTerm><Primary>bash, presupposed (Parallel Haskell only)</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
Sadly, the <Command>gr2ps</Command> script, used to convert ``parallelism profiles''
to PostScript, is written in Bash (GNU's Bourne Again shell).
This bug will be fixed (someday).
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
</Sect2>
<Title>Tools for building the Documentation
</Title>
-<Para>
+<para>
The following additional tools are required if you want to format the
documentation that comes with the <Literal>fptools</Literal> projects:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<IndexTerm><Primary>pre-supposed: DocBook</Primary></IndexTerm>
<IndexTerm><Primary>DocBook, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
All our documentation is written in SGML, using the DocBook DTD.
Instructions on installing and configuring the DocBook tools are in the
installation guide (in the GHC user guide).
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<IndexTerm><Primary>pre-supposed: TeX</Primary></IndexTerm>
<IndexTerm><Primary>TeX, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
A decent TeX distribution is required if you want to produce printable
documentation. We recomment teTeX, which includes just about
everything you need.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>flex, pre-supposed</Primary></IndexTerm>
<ListItem>
-<Para>
+<para>
This is a quite-a-bit-better-than-Lex lexer. Used to build a couple
of utilities in <Literal>glafp-utils</Literal>. Depending on your
operating system, the supplied <Command>lex</Command> may or may not
work; you should get the GNU version.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
<IndexTerm><Primary>Building from source</Primary></IndexTerm>
<IndexTerm><Primary>Source, building from</Primary></IndexTerm></Title>
-<Para>
+<para>
You've been rash enough to want to build some of
the Glasgow Functional Programming tools (GHC, Happy,
nofib, etc.) from source. You've slurped the source,
from the CVS repository or from a source distribution, and
now you're sitting looking at a huge mound of bits, wondering
what to do next.
-</Para>
+</para>
-<Para>
+<para>
Gingerly, you type <Command>make</Command>. Wrong already!
-</Para>
+</para>
-<Para>
+<para>
This rest of this guide is intended for duffers like me, who aren't
really interested in Makefiles and systems configurations, but who
need a mental model of the interlocking pieces so that they can make
them work, extend them consistently when adding new software, and lay
hands on them gently when they don't work.
-</Para>
+</para>
<Sect2 id="sec-source-tree">
<Title>Your source tree
</Title>
-<Para>
+<para>
The source code is held in your <Emphasis>source tree</Emphasis>.
The root directory of your source tree <Emphasis>must</Emphasis>
contain the following directories and files:
-</Para>
+</para>
-<Para>
+<para>
<ItemizedList>
<ListItem>
-<Para>
+<para>
<Filename>Makefile</Filename>: the root Makefile.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
<Filename>mk/</Filename>: the directory that contains the
main Makefile code, shared by all the
<Literal>fptools</Literal> software.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
<Filename>configure.in</Filename>, <Filename>config.sub</Filename>, <Filename>config.guess</Filename>:
these files support the configuration process.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
<Filename>install-sh</Filename>.
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
-<Para>
+<para>
All the other directories are individual <Emphasis>projects</Emphasis> of the
<Literal>fptools</Literal> system—for example, the Glasgow Haskell Compiler
(<Literal>ghc</Literal>), the Happy parser generator (<Literal>happy</Literal>), the <Literal>nofib</Literal> benchmark
suite, and so on. You can have zero or more of these. Needless to
say, some of them are needed to build others.
-</Para>
+</para>
-<Para>
+<para>
The important thing to remember is that even if you want only one
project (<Literal>happy</Literal>, say), you must have a source tree whose root
directory contains <Filename>Makefile</Filename>, <Filename>mk/</Filename>, <Filename>configure.in</Filename>, and the
project(s) you want (<Filename>happy/</Filename> in this case). You cannot get by with
just the <Filename>happy/</Filename> directory.
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>build trees</Primary></IndexTerm>
<IndexTerm><Primary>link trees, for building</Primary></IndexTerm></Title>
-<Para>
+<para>
While you can build a system in the source tree, we don't recommend it.
We often want to build multiple versions of our software
for different architectures, or with different options (e.g. profiling).
It's very desirable to share a single copy of the source code among
all these builds.
-</Para>
+</para>
-<Para>
+<para>
So for every source tree we have zero or more <Emphasis>build trees</Emphasis>. Each
build tree is initially an exact copy of the source tree, except that
each file is a symbolic link to the source file, rather than being a
<Command>lndir</Command><IndexTerm><Primary>lndir</Primary></IndexTerm>, <Command>mkshadowdir</Command><IndexTerm><Primary>mkshadowdir</Primary></IndexTerm> are two (If you
don't have either, the source distribution includes sources for the
X11 <Command>lndir</Command>—check out <Filename>fptools/glafp-utils/lndir</Filename>). See <Xref LinkEnd="sec-storysofar"> for a typical invocation.
-</Para>
+</para>
-<Para>
+<para>
The build tree does not need to be anywhere near the source tree in
the file system. Indeed, one advantage of separating the build tree
from the source is that the build tree can be placed in a
link to the source tree, or else is mechanically generated</Emphasis>.
It should be perfectly OK for your build tree to vanish overnight; an
hour or two compiling and you're on the road again.
-</Para>
+</para>
-<Para>
+<para>
You need to be a bit careful, though, that any new files you create
(if you do any development work) are in the source tree, not a build tree!
-</Para>
+</para>
-<Para>
+<para>
Remember, that the source files in the build tree are <Emphasis>symbolic
links</Emphasis> to the files in the source tree. (The build tree soon
accumulates lots of built files like <Filename>Foo.o</Filename>, as well.) You
file unchanged; but the danger is that you think you've edited the
source file whereas actually all you've done is edit the build-tree
copy. More commonly you do want to edit the source file.)
-</Para>
+</para>
-<Para>
+<para>
Like the source tree, the top level of your build tree must be (a
linked copy of) the root directory of the <Literal>fptools</Literal> suite. Inside
Makefiles, the root of your build tree is called
names are relative to <Constant>$(FPTOOLS_TOP)</Constant> unless otherwise stated. For
example, the file <Filename>ghc/mk/target.mk</Filename> is actually
<Filename><Constant>$(FPTOOLS_TOP)</Constant>/ghc/mk/target.mk</Filename>.
-</Para>
+</para>
</Sect2>
<Title>Getting the build you want
</Title>
-<Para>
+<para>
When you build <Literal>fptools</Literal> you will be compiling code on a particular
<Emphasis>host platform</Emphasis>, to run on a particular <Emphasis>target platform</Emphasis>
(usually the same as the host platform)<IndexTerm><Primary>platform</Primary></IndexTerm>. The
for each. There are some big differences too: for a different
architecture we need to build GHC with a different native-code
generator.
-</Para>
+</para>
-<Para>
+<para>
There are also knobs you can turn to control how the <Literal>fptools</Literal>
software is built. For example, you might want to build GHC optimised
(so that it runs fast) or unoptimised (so that you can compile it fast
after you've modified it. Or, you might want to compile it with
debugging on (so that extra consistency-checking code gets included)
or off. And so on.
-</Para>
+</para>
-<Para>
+<para>
All of this stuff is called the <Emphasis>configuration</Emphasis> of your build.
You set the configuration using a three-step process.
<VariableList>
<Filename><Constant>$(FPTOOLS_TOP)</Constant>/configure.in</Filename>
to a shell script called
<Filename><Constant>$(FPTOOLS_TOP)</Constant>/configure</Filename>.
- </Para>
+ </para>
<para>Some projects, including GHC, have their own
configure script. If there's an
<Command>configure</Command>, and
<Filename>mk/config.h.in</Filename>, are long.</para>
- <Para>In case you don't have <Command>autoconf</Command>
+ <para>In case you don't have <Command>autoconf</Command>
we distribute the results, <Command>configure</Command>,
and <Filename>mk/config.h.in</Filename>, with the source
distribution. They aren't kept in the repository,
- though.</Para>
+ though.</para>
</listitem>
</varlistentry>
<VarListEntry>
<Term>Step 3: build configuration.</Term>
<ListItem>
-<Para>
+<para>
Next, you say how this build of <Literal>fptools</Literal> is to differ from the
standard defaults by creating a new file <Filename>mk/build.mk</Filename><IndexTerm><Primary>build.mk</Primary></IndexTerm>
<Emphasis>in the build tree</Emphasis>. This file is the one and only file you edit
<Filename>mk/build.mk</Filename> never exists in the source tree—you create one in
each build tree from the template. We'll discuss what to put in it
shortly.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
And that's it for configuration. Simple, eh?
-</Para>
-
-<Para>
-What do you put in your build-specific configuration file
-<Filename>mk/build.mk</Filename>? <Emphasis>For almost all purposes all you will do is put
-make variable definitions that override those in</Emphasis> <Filename>mk/config.mk.in</Filename>.
-The whole point of <Filename>mk/config.mk.in</Filename>—and its derived counterpart
-<Filename>mk/config.mk</Filename>—is to define the build configuration. It is heavily
-commented, as you will see if you look at it. So generally, what you
-do is look at <Filename>mk/config.mk.in</Filename>, and add definitions in <Filename>mk/build.mk</Filename>
-that override any of the <Filename>config.mk</Filename> definitions that you want to
-change. (The override occurs because the main boilerplate file,
-<Filename>mk/boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>, includes <Filename>build.mk</Filename> after
-<Filename>config.mk</Filename>.)
-</Para>
-
-<Para>
-For example, <Filename>config.mk.in</Filename> contains the definition:
-</Para>
-
-<Para>
+</para>
+
+ <para>What do you put in your build-specific configuration file
+ <filename>mk/build.mk</filename>? <Emphasis>For almost all
+ purposes all you will do is put make variable definitions that
+ override those in</Emphasis>
+ <filename>mk/config.mk.in</filename>. The whole point of
+ <filename>mk/config.mk.in</filename>—and its derived
+ counterpart <filename>mk/config.mk</filename>—is to define
+ the build configuration. It is heavily commented, as you will
+ see if you look at it. So generally, what you do is look at
+ <filename>mk/config.mk.in</filename>, and add definitions in
+ <filename>mk/build.mk</filename> that override any of the
+ <filename>config.mk</filename> definitions that you want to
+ change. (The override occurs because the main boilerplate file,
+ <filename>mk/boilerplate.mk</filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>,
+ includes <filename>build.mk</filename> after
+ <filename>config.mk</filename>.)</para>
+
+ <para>For example, <filename>config.mk.in</filename> contains
+ the definition:</para>
<ProgramListing>
-ProjectsToBuild = glafp-utils ghc hslibs
+GhcHcOpts=-O -Rghc-timing
</ProgramListing>
-</Para>
+ <para>The accompanying comment explains that this is the list of
+ flags passed to GHC when building GHC itself. For doing
+ development, it is wise to add <literal>-DDEBUG</literal>, to
+ enable debugging code. So you would add the following to
+ <filename>build.mk</filename>:</para>
-<Para>
-The accompanying comment explains that this is the list of enabled
-projects; that is, if (after configuring) you type <Command>gmake all</Command> in
-<Constant>FPTOOLS_TOP</Constant> three specified projects will be made. If you want to
-add <Command>green-card</Command>, you can add this line to <Filename>build.mk</Filename>:
-</Para>
-
-<Para>
+ <para>or, if you prefer,</para>
<ProgramListing>
-ProjectsToBuild += green-card
+GhcHcOpts += -DDEBUG
</ProgramListing>
-</Para>
-
-<Para>
-or, if you prefer,
-</Para>
+ <para>GNU <Command>make</Command> allows existing definitions to
+ have new text appended using the ``<Literal>+=</Literal>''
+ operator, which is quite a convenient feature.)</para>
-<Para>
+ <para>If you want to remove the <literal>-O</literal> as well (a
+ good idea when developing, because the turn-around cycle gets a
+ lot quicker), you can just override
+ <literal>GhcLibHcOpts</literal> altogether:</para>
<ProgramListing>
-ProjectsToBuild = glafp-utils ghc green-card
+GhcHcOpts=-DDEBUG -Rghc-timing
</ProgramListing>
-</Para>
-
-<Para>
-(GNU <Command>make</Command> allows existing definitions to have new text appended
-using the ``<Literal>+=</Literal>'' operator, which is quite a convenient feature.)
-</Para>
-
-<Para>
-When reading <Filename>config.mk.in</Filename>, remember that anything between
-``@...@'' signs is going to be substituted by <Command>configure</Command>
-later. You <Emphasis>can</Emphasis> override the resulting definition if you want,
-but you need to be a bit surer what you are doing. For example,
-there's a line that says:
-</Para>
-
-<Para>
+ <para>When reading <filename>config.mk.in</filename>, remember
+ that anything between ``@...@'' signs is going to be substituted
+ by <Command>configure</Command> later. You
+ <Emphasis>can</Emphasis> override the resulting definition if
+ you want, but you need to be a bit surer what you are doing.
+ For example, there's a line that says:</para>
<ProgramListing>
YACC = @YaccCmd@
</ProgramListing>
-</Para>
-
-<Para>
-This defines the Make variables <Constant>YACC</Constant> to the pathname for a <Command>yacc</Command> that
-<Command>configure</Command> finds somewhere. If you have your own pet <Command>yacc</Command> you want
-to use instead, that's fine. Just add this line to <Filename>mk/build.mk</Filename>:
-</Para>
-
-<Para>
+ <para>This defines the Make variables <Constant>YACC</Constant>
+ to the pathname for a <Command>yacc</Command> that
+ <Command>configure</Command> finds somewhere. If you have your
+ own pet <Command>yacc</Command> you want to use instead, that's
+ fine. Just add this line to <filename>mk/build.mk</filename>:</para>
<ProgramListing>
YACC = myyacc
</ProgramListing>
-</Para>
-
-<Para>
-You do not <Emphasis>have</Emphasis> to have a <Filename>mk/build.mk</Filename> file at all; if you
-don't, you'll get all the default settings from <Filename>mk/config.mk.in</Filename>.
-</Para>
-
-<Para>
-You can also use <Filename>build.mk</Filename> to override anything that <Command>configure</Command> got
-wrong. One place where this happens often is with the definition of
-<Constant>FPTOOLS_TOP_ABS</Constant>: this variable is supposed to be the canonical path
-to the top of your source tree, but if your system uses an automounter
-then the correct directory is hard to find automatically. If you find
-that <Command>configure</Command> has got it wrong, just put the correct definition in
-<Filename>build.mk</Filename>.
-</Para>
+ <para>You do not <Emphasis>have</Emphasis> to have a
+ <filename>mk/build.mk</filename> file at all; if you don't,
+ you'll get all the default settings from
+ <filename>mk/config.mk.in</filename>.</para>
+
+ <para>You can also use <filename>build.mk</filename> to override
+ anything that <Command>configure</Command> got wrong. One place
+ where this happens often is with the definition of
+ <Constant>FPTOOLS_TOP_ABS</Constant>: this
+ variable is supposed to be the canonical path to the top of your
+ source tree, but if your system uses an automounter then the
+ correct directory is hard to find automatically. If you find
+ that <Command>configure</Command> has got it wrong, just put the
+ correct definition in <filename>build.mk</filename>.</para>
</Sect2>
<Sect2 id="sec-storysofar">
<Title>The story so far</Title>
-<Para>
+<para>
Let's summarise the steps you need to carry to get yourself
a fully-configured build tree from scratch.
-</Para>
+</para>
-<Para>
+<para>
<OrderedList>
<ListItem>
-<Para>
+<para>
Get your source tree from somewhere (CVS repository or source
-distribution). Say you call the root directory <Filename>myfptools</Filename> (it
-does not have to be called <Filename>fptools</Filename>). Make sure that you have
+distribution). Say you call the root directory <filename>myfptools</filename> (it
+does not have to be called <filename>fptools</filename>). Make sure that you have
the essential files (see <XRef LinkEnd="sec-source-tree">).
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Use <Command>lndir</Command> or <Command>mkshadowdir</Command> to create a build tree.
<ProgramListing>
suggests its main defining characteristic (in your mind at least),
in case you later add others.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Change directory to the build tree. Everything is going
to happen there now.
cd /scratch/joe-bloggs/myfptools-sun4
</ProgramListing>
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Prepare for system configuration:
<ProgramListing>
</ProgramListing>
(You can skip this step if you are starting from a source distribution,
-and you already have <Filename>configure</Filename> and <Filename>mk/config.h.in</Filename>.)
+and you already have <filename>configure</filename> and <filename>mk/config.h.in</filename>.)
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Do system configuration:
<ProgramListing>
</ProgramListing>
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- Create the file <Filename>mk/build.mk</Filename>,
+<para>
+ Create the file <filename>mk/build.mk</filename>,
adding definitions for your desired configuration options.
<ProgramListing>
emacs mk/build.mk
</ProgramListing>
-</Para>
+</para>
</ListItem>
</OrderedList>
-You can make subsequent changes to <Filename>mk/build.mk</Filename> as often
+You can make subsequent changes to <filename>mk/build.mk</filename> as often
as you like. You do not have to run any further configuration
programs to make these changes take effect.
In theory you should, however, say <Command>gmake clean</Command>, <Command>gmake all</Command>,
because configuration option changes could affect anything—but in practice you are likely to know what's affected.
-</Para>
+</para>
</Sect2>
-<Sect2>
-<Title>Making things</Title>
+ <Sect2>
+ <Title>Making things</Title>
-<Para>
-At this point you have made yourself a fully-configured build tree,
-so you are ready to start building real things.
-</Para>
+ <para>At this point you have made yourself a fully-configured
+ build tree, so you are ready to start building real
+ things.</para>
-<Para>
-The first thing you need to know is that
-<Emphasis>you must use GNU <Command>make</Command>, usually called <Command>gmake</Command>, not standard Unix <Command>make</Command></Emphasis>.
-If you use standard Unix <Command>make</Command> you will get all sorts of error messages
-(but no damage) because the <Literal>fptools</Literal> <Command>Makefiles</Command> use GNU <Command>make</Command>'s facilities
-extensively.
-</Para>
+ <para>The first thing you need to know is that <Emphasis>you
+ must use GNU <Command>make</Command>, usually called
+ <Command>gmake</Command>, not standard Unix
+ <Command>make</Command></Emphasis>. If you use standard Unix
+ <Command>make</Command> you will get all sorts of error messages
+ (but no damage) because the <Literal>fptools</Literal>
+ <Command>Makefiles</Command> use GNU <Command>make</Command>'s
+ facilities extensively.</para>
-</Sect2>
+ <para>To just build the whole thing, <command>cd</command> to
+ the top of your <literal>fptools</literal> tree and type
+ <command>gmake</command>. This will prepare the tree and build
+ the various projects in the correct order.</para>
+
+ </Sect2>
-<Sect2 id="sec-standard-targets">
-<Title>Standard Targets
+ <Sect2 id="sec-standard-targets">
+ <Title>Standard Targets</title>
+ <IndexTerm><Primary>targets, standard makefile</Primary></IndexTerm>
+ <IndexTerm><Primary>makefile targets</Primary></IndexTerm>
-<IndexTerm><Primary>targets, standard makefile</Primary></IndexTerm>
-<IndexTerm><Primary>makefile targets</Primary></IndexTerm></Title>
+ <para>In any directory you should be able to make the following:
-<Para>
-In any directory you should be able to make the following:
<VariableList>
<VarListEntry>
<Term><Literal>boot</Literal>:</Term>
<ListItem>
-<Para>
-does the one-off preparation required to get ready for the real work.
-Notably, it does <Command>gmake depend</Command> in all directories that contain
-programs. It also builds the necessary tools for compilation to proceed.
-</Para>
-
-<Para>
-You should say <Command>gmake boot</Command> right after configuring your build tree,
-but note that this is a one-off, i.e., there's no need to re-do
-<Command>gmake boot</Command> if you should re-configure your build tree at a later
-stage (no harm caused if you do though). Notably, you should say
-<Command>gmake boot</Command> before you say <Command>gmake clean</Command>.
-</Para>
+<para>does the one-off preparation required to get ready for the real
+work. Notably, it does <Command>gmake depend</Command> in all
+directories that contain programs. It also builds the necessary tools
+for compilation to proceed.</para>
+
+<para>Invoking the <literal>boot</literal> target explicitly is not
+normally necessary. From the top-level <literal>fptools</literal>
+directory, invoking <literal>gmake</literal> causes <literal>gmake
+boot all</literal> to be invoked in each of the project
+subdirectories, in the order specified by
+<literal>$(AllTargets)</literal> in
+<literal>config.mk</literal>.</para>
+
+<para>If you're working in a subdirectory somewhere and need to update
+the dependencies, <literal>gmake boot</literal> is a good way to do it.</para>
+
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>all</Literal>:</Term>
<ListItem>
-<Para>
+<para>
makes all the final target(s) for this Makefile.
Depending on which directory you are in a ``final target'' may be an
executable program, a library archive, a shell script, or a Postscript
file. Typing <Command>gmake</Command> alone is generally the same as typing <Command>gmake all</Command>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>install</Literal>:</Term>
<ListItem>
-<Para>
+<para>
installs the things built by <Literal>all</Literal>. Where does it
install them? That is specified by
-<Filename>mk/config.mk.in</Filename>; you can override it in
-<Filename>mk/build.mk</Filename>, or by running
+<filename>mk/config.mk.in</filename>; you can override it in
+<filename>mk/build.mk</filename>, or by running
<command>configure</command> with command-line arguments like
<literal>--bindir=/home/simonpj/bin</literal>; see <literal>./configure
--help</literal> for the full details.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>uninstall</Literal>:</Term>
<ListItem>
-<Para>
+<para>
reverses the effect of <Literal>install</Literal>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>clean</Literal>:</Term>
<ListItem>
-<Para>
+<para>
Delete all files from the current directory that are normally created
by building the program. Don't delete the files that record the
configuration, or files generated by <Command>gmake boot</Command>.
<VarListEntry>
<Term><Literal>maintainer-clean</Literal>:</Term>
<ListItem>
-<Para>
+<para>
Delete everything from the current directory that can be reconstructed
with this Makefile. This typically includes everything deleted by
<literal>distclean</literal>, plus more: C source files produced by
<VarListEntry>
<Term><Literal>check</Literal>:</Term>
<ListItem>
-<Para>
+<para>
run the test suite.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
All of these standard targets automatically recurse into
sub-directories. Certain other standard targets do not:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<Term><Literal>configure</Literal>:</Term>
<ListItem>
-<Para>
+<para>
is only available in the root directory
<Constant>$(FPTOOLS_TOP)</Constant>; it has been discussed in <XRef LinkEnd="sec-build-config">.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>depend</Literal>:</Term>
<ListItem>
-<Para>
-make a <Filename>.depend</Filename> file in each directory that needs
-it. This <Filename>.depend</Filename> file contains mechanically-generated dependency
+<para>
+make a <filename>.depend</filename> file in each directory that needs
+it. This <filename>.depend</filename> file contains mechanically-generated dependency
information; for example, suppose a directory contains a Haskell
-source module <Filename>Foo.lhs</Filename> which imports another module <Literal>Baz</Literal>.
-Then the generated <Filename>.depend</Filename> file will contain the dependency:
-</Para>
+source module <filename>Foo.lhs</filename> which imports another module <Literal>Baz</Literal>.
+Then the generated <filename>.depend</filename> file will contain the dependency:
+</para>
-<Para>
+<para>
<ProgramListing>
Foo.o : Baz.hi
</ProgramListing>
-</Para>
+</para>
-<Para>
-which says that the object file <Filename>Foo.o</Filename> depends on the interface file
-<Filename>Baz.hi</Filename> generated by compiling module <Literal>Baz</Literal>. The <Filename>.depend</Filename> file is
+<para>
+which says that the object file <filename>Foo.o</filename> depends on the interface file
+<filename>Baz.hi</filename> generated by compiling module <Literal>Baz</Literal>. The <filename>.depend</filename> file is
automatically included by every Makefile.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>binary-dist</Literal>:</Term>
<ListItem>
-<Para>
+<para>
make a binary distribution. This is the
target we use to build the binary distributions of GHC and Happy.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>dist</Literal>:</Term>
<ListItem>
-<Para>
-make a source distribution. You must be in a
-linked build tree to make this target.
-</Para>
+<para>
+make a source distribution. Note that this target does “make
+distclean” as part of its work; don't use it if you want to keep
+what you've built.
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
-Most <Filename>Makefile</Filename>s have targets other than these. You can discover them by looking in the <Filename>Makefile</Filename> itself.
-</Para>
+<para>
+Most <filename>Makefile</filename>s have targets other than these. You can discover them by looking in the <filename>Makefile</filename> itself.
+</para>
</Sect2>
If you want to build GHC (say) and just use it direct from the build
tree without doing <literal>make install</literal> first, you can run
the in-place driver script:
-<filename>ghc/driver/ghc-inplace</filename>.
+<filename>ghc/compiler/ghc-inplace</filename>.
</para>
<para> Do <emphasis>NOT</emphasis> use
-<filename>ghc/driver/ghc</filename>, or
-<filename>ghc/driver/ghc-4.xx</filename>, as these are the scripts
+<filename>ghc/compiler/ghc</filename>, or
+<filename>ghc/compiler/ghc-5.xx</filename>, as these are the scripts
intended for installation, and contain hard-wired paths to the
installed libraries, rather than the libraries in the build tree.
</para>
<IndexTerm><Primary>FAST, makefile
variable</Primary></IndexTerm></Title>
-<Para>
+<para>
Sometimes the dependencies get in the way: if you've made a small
change to one file, and you're absolutely sure that it won't affect
anything else, but you know that <Command>make</Command> is going to rebuild everything
anyway, the following hack may be useful:
-</Para>
+</para>
-<Para>
+<para>
<ProgramListing>
gmake FAST=YES
</ProgramListing>
-</Para>
+</para>
-<Para>
+<para>
This tells the make system to ignore dependencies and just build what
you tell it to. In other words, it's equivalent to temporarily
-removing the <Filename>.depend</Filename> file in the current directory (where
+removing the <filename>.depend</filename> file in the current directory (where
<Command>mkdependHS</Command> and friends store their dependency information).
-</Para>
+</para>
-<Para>
+<para>
A bit of history: GHC used to come with a <Command>fastmake</Command> script that did
the above job, but GNU make provides the features we need to do it
without resorting to a script. Also, we've found that fastmaking is
less useful since the advent of GHC's recompilation checker (see the
User's Guide section on "Separate Compilation").
-</Para>
+</para>
</Sect2>
</Sect1>
<Sect1 id="sec-makefile-arch">
-<Title>The <Filename>Makefile</Filename> architecture
+<Title>The <filename>Makefile</filename> architecture
<IndexTerm><Primary>makefile architecture</Primary></IndexTerm></Title>
-<Para>
+<para>
<Command>make</Command> is great if everything works—you type <Command>gmake install</Command> and
lo! the right things get compiled and installed in the right places.
Our goal is to make this happen often, but somehow it often doesn't;
instead some weird error message eventually emerges from the bowels of
a directory you didn't know existed.
-</Para>
+</para>
-<Para>
+<para>
The purpose of this section is to give you a road-map to help you figure
out what is going right and what is going wrong.
-</Para>
+</para>
<Sect2>
<Title>A small project</Title>
-<Para>
-To get started, let us look at the <Filename>Makefile</Filename> for an imaginary small
+<para>
+To get started, let us look at the <filename>Makefile</filename> for an imaginary small
<Literal>fptools</Literal> project, <Literal>small</Literal>. Each project in <Literal>fptools</Literal> has its own
directory in <Constant>FPTOOLS_TOP</Constant>, so the <Literal>small</Literal> project will have its own
-directory <Constant>FPOOLS_TOP/small/</Constant>. Inside the <Filename>small/</Filename> directory there
-will be a <Filename>Makefile</Filename>, looking something like this:
-</Para>
+directory <Constant>FPOOLS_TOP/small/</Constant>. Inside the <filename>small/</filename> directory there
+will be a <filename>Makefile</filename>, looking something like this:
+</para>
-<Para>
+<para>
<IndexTerm><Primary>Makefile, minimal</Primary></IndexTerm>
<ProgramListing>
include $(TOP)/target.mk
</ProgramListing>
-</Para>
+</para>
-<Para>
-This <Filename>Makefile</Filename> has three sections:
-</Para>
+<para>
+This <filename>Makefile</filename> has three sections:
+</para>
-<Para>
+<para>
<OrderedList>
<ListItem>
-<Para>
+<para>
The first section includes
<FOOTNOTE>
-<Para>
+<para>
One of the most important
-features of GNU <Command>make</Command> that we use is the ability for a <Filename>Makefile</Filename> to
+features of GNU <Command>make</Command> that we use is the ability for a <filename>Makefile</filename> to
include another named file, very like <Command>cpp</Command>'s <Literal>#include</Literal>
directive.
-</Para>
+</para>
</FOOTNOTE>
a file of ``boilerplate'' code from the level
above (which in this case will be
-<Filename><Constant>FPTOOLS_TOP</Constant>/mk/boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>). As its name
-suggests, <Filename>boilerplate.mk</Filename> consists of a large quantity of standard
-<Filename>Makefile</Filename> code. We discuss this boilerplate in more detail in
+<filename><Constant>FPTOOLS_TOP</Constant>/mk/boilerplate.mk</filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>). As its name
+suggests, <filename>boilerplate.mk</filename> consists of a large quantity of standard
+<filename>Makefile</filename> code. We discuss this boilerplate in more detail in
<XRef LinkEnd="sec-boiler">.
<IndexTerm><Primary>include, directive in Makefiles</Primary></IndexTerm>
<IndexTerm><Primary>Makefile inclusion</Primary></IndexTerm>
Before the <Literal>include</Literal> statement, you must define the <Command>make</Command> variable
-<Constant>TOP</Constant><IndexTerm><Primary>TOP</Primary></IndexTerm> to be the directory containing the <Filename>mk</Filename> directory in
-which the <Filename>boilerplate.mk</Filename> file is. It is <Emphasis>not</Emphasis> OK to simply say
+<Constant>TOP</Constant><IndexTerm><Primary>TOP</Primary></IndexTerm> to be the directory containing the <filename>mk</filename> directory in
+which the <filename>boilerplate.mk</filename> file is. It is <Emphasis>not</Emphasis> OK to simply say
<ProgramListing>
</ProgramListing>
-Why? Because the <Filename>boilerplate.mk</Filename> file needs to know where it is, so
+Why? Because the <filename>boilerplate.mk</filename> file needs to know where it is, so
that it can, in turn, <Literal>include</Literal> other files. (Unfortunately, when an
<Literal>include</Literal>d file does an <Literal>include</Literal>, the filename is treated relative to
the directory in which <Command>gmake</Command> is being run, not the directory in
-which the <Literal>include</Literal>d sits.) In general, <Emphasis>every file <Filename>foo.mk</Filename>
-assumes that <Filename><Constant>$(TOP)</Constant>/mk/foo.mk</Filename> refers to itself.</Emphasis> It is up to the
-<Filename>Makefile</Filename> doing the <Literal>include</Literal> to ensure this is the case.
+which the <Literal>include</Literal>d sits.) In general, <Emphasis>every file <filename>foo.mk</filename>
+assumes that <filename><Constant>$(TOP)</Constant>/mk/foo.mk</filename> refers to itself.</Emphasis> It is up to the
+<filename>Makefile</filename> doing the <Literal>include</Literal> to ensure this is the case.
-Files intended for inclusion in other <Filename>Makefile</Filename>s are written to have
-the following property: <Emphasis>after <Filename>foo.mk</Filename> is <Literal>include</Literal>d, it leaves
+Files intended for inclusion in other <filename>Makefile</filename>s are written to have
+the following property: <Emphasis>after <filename>foo.mk</filename> is <Literal>include</Literal>d, it leaves
<Constant>TOP</Constant> containing the same value as it had just before the <Literal>include</Literal>
statement</Emphasis>. In our example, this invariant guarantees that the
-<Literal>include</Literal> for <Filename>target.mk</Filename> will look in the same directory as that for
-<Filename>boilerplate.mk</Filename>.
+<Literal>include</Literal> for <filename>target.mk</filename> will look in the same directory as that for
+<filename>boilerplate.mk</filename>.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
The second section defines the following standard <Command>make</Command>
variables: <Constant>SRCS</Constant><IndexTerm><Primary>SRCS</Primary></IndexTerm> (the source files from which is to be
built), and <Constant>HS_PROG</Constant><IndexTerm><Primary>HS_PROG</Primary></IndexTerm> (the executable binary to be
The definition for <Constant>SRCS</Constant> uses the useful GNU <Command>make</Command> construct
<Literal>$(wildcard $pat$)</Literal><IndexTerm><Primary>wildcard</Primary></IndexTerm>, which expands to a list of all
the files matching the pattern <Literal>pat</Literal> in the current directory. In
-this example, <Constant>SRCS</Constant> is set to the list of all the <Filename>.lhs</Filename> and <Filename>.c</Filename>
+this example, <Constant>SRCS</Constant> is set to the list of all the <filename>.lhs</filename> and <filename>.c</filename>
files in the directory. (Let's suppose there is one of each,
-<Filename>Foo.lhs</Filename> and <Filename>Baz.c</Filename>.)
+<filename>Foo.lhs</filename> and <filename>Baz.c</filename>.)
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
The last section includes a second file of standard code,
-called <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm>. It contains the rules that tell
+called <filename>target.mk</filename><IndexTerm><Primary>target.mk</Primary></IndexTerm>. It contains the rules that tell
<Command>gmake</Command> how to make the standard targets (<Xref LinkEnd="sec-standard-targets">). Why, you ask,
-can't this standard code be part of <Filename>boilerplate.mk</Filename>? Good question.
+can't this standard code be part of <filename>boilerplate.mk</filename>? Good question.
We discuss the reason later, in <Xref LinkEnd="sec-boiler-arch">.
-You do not <Emphasis>have</Emphasis> to <Literal>include</Literal> the <Filename>target.mk</Filename> file. Instead, you
+You do not <Emphasis>have</Emphasis> to <Literal>include</Literal> the <filename>target.mk</filename> file. Instead, you
can write rules of your own for all the standard targets. Usually,
though, you will find quite a big payoff from using the canned rules
-in <Filename>target.mk</Filename>; the price tag is that you have to understand what
+in <filename>target.mk</filename>; the price tag is that you have to understand what
canned rules get enabled, and what they do (<Xref LinkEnd="sec-targets">).
-</Para>
+</para>
</ListItem>
</OrderedList>
-</Para>
+</para>
-<Para>
-In our example <Filename>Makefile</Filename>, most of the work is done by the two
+<para>
+In our example <filename>Makefile</filename>, most of the work is done by the two
<Literal>include</Literal>d files. When you say <Command>gmake all</Command>, the following things
happen:
-</Para>
+</para>
-<Para>
+<para>
<ItemizedList>
<ListItem>
-<Para>
- <Command>gmake</Command> figures out that the object files are <Filename>Foo.o</Filename> and
-<Filename>Baz.o</Filename>.
+<para>
+ <Command>gmake</Command> figures out that the object files are <filename>Foo.o</filename> and
+<filename>Baz.o</filename>.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- It uses a boilerplate pattern rule to compile <Filename>Foo.lhs</Filename> to
-<Filename>Foo.o</Filename> using a Haskell compiler. (Which one? That is set in the
+<para>
+ It uses a boilerplate pattern rule to compile <filename>Foo.lhs</filename> to
+<filename>Foo.o</filename> using a Haskell compiler. (Which one? That is set in the
build configuration.)
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- It uses another standard pattern rule to compile <Filename>Baz.c</Filename> to
-<Filename>Baz.o</Filename>, using a C compiler. (Ditto.)
+<para>
+ It uses another standard pattern rule to compile <filename>Baz.c</filename> to
+<filename>Baz.o</filename>, using a C compiler. (Ditto.)
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- It links the resulting <Filename>.o</Filename> files together to make <Literal>small</Literal>,
+<para>
+ It links the resulting <filename>.o</filename> files together to make <Literal>small</Literal>,
using the Haskell compiler to do the link step. (Why not use <Command>ld</Command>?
Because the Haskell compiler knows what standard libraries to link in.
How did <Command>gmake</Command> know to use the Haskell compiler to do the link,
rather than the C compiler? Because we set the variable <Constant>HS_PROG</Constant>
rather than <Constant>C_PROG</Constant>.)
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
-<Para>
-All <Filename>Makefile</Filename>s should follow the above three-section format.
-</Para>
+<para>
+All <filename>Makefile</filename>s should follow the above three-section format.
+</para>
</Sect2>
<Sect2>
<Title>A larger project</Title>
-<Para>
+<para>
Larger projects are usually structured into a number of sub-directories,
-each of which has its own <Filename>Makefile</Filename>. (In very large projects, this
+each of which has its own <filename>Makefile</filename>. (In very large projects, this
sub-structure might be iterated recursively, though that is rare.)
To give you the idea, here's part of the directory structure for
the (rather large) GHC project:
-</Para>
+</para>
-<Para>
+<para>
<Screen>
$(FPTOOLS_TOP)/ghc/
...etc...
</Screen>
-</Para>
-
-<Para>
-The sub-directories <Filename>docs</Filename>, <Filename>driver</Filename>, <Filename>compiler</Filename>, and so on, each
-contains a sub-component of GHC, and each has its own <Filename>Makefile</Filename>.
-There must also be a <Filename>Makefile</Filename> in <Filename><Constant>$(FPTOOLS_TOP)</Constant>/ghc</Filename>. It does most
-of its work by recursively invoking <Command>gmake</Command> on the <Filename>Makefile</Filename>s in the
-sub-directories. We say that <Filename>ghc/Makefile</Filename> is a <Emphasis>non-leaf
-<Filename>Makefile</Filename></Emphasis>, because it does little except organise its children,
-while the <Filename>Makefile</Filename>s in the sub-directories are all <Emphasis>leaf
-<Filename>Makefile</Filename>s</Emphasis>. (In principle the sub-directories might themselves
-contain a non-leaf <Filename>Makefile</Filename> and several sub-sub-directories, but
+</para>
+
+<para>
+The sub-directories <filename>docs</filename>, <filename>driver</filename>, <filename>compiler</filename>, and so on, each
+contains a sub-component of GHC, and each has its own <filename>Makefile</filename>.
+There must also be a <filename>Makefile</filename> in <filename><Constant>$(FPTOOLS_TOP)</Constant>/ghc</filename>. It does most
+of its work by recursively invoking <Command>gmake</Command> on the <filename>Makefile</filename>s in the
+sub-directories. We say that <filename>ghc/Makefile</filename> is a <Emphasis>non-leaf
+<filename>Makefile</filename></Emphasis>, because it does little except organise its children,
+while the <filename>Makefile</filename>s in the sub-directories are all <Emphasis>leaf
+<filename>Makefile</filename>s</Emphasis>. (In principle the sub-directories might themselves
+contain a non-leaf <filename>Makefile</filename> and several sub-sub-directories, but
that does not happen in GHC.)
-</Para>
+</para>
-<Para>
-The <Filename>Makefile</Filename> in <Filename>ghc/compiler</Filename> is considered a leaf <Filename>Makefile</Filename> even
-though the <Filename>ghc/compiler</Filename> has sub-directories, because these sub-directories
-do not themselves have <Filename>Makefile</Filename>s in them. They are just used to structure
+<para>
+The <filename>Makefile</filename> in <filename>ghc/compiler</filename> is considered a leaf <filename>Makefile</filename> even
+though the <filename>ghc/compiler</filename> has sub-directories, because these sub-directories
+do not themselves have <filename>Makefile</filename>s in them. They are just used to structure
the collection of modules that make up GHC, but all are managed by the
-single <Filename>Makefile</Filename> in <Filename>ghc/compiler</Filename>.
-</Para>
+single <filename>Makefile</filename> in <filename>ghc/compiler</filename>.
+</para>
-<Para>
-You will notice that <Filename>ghc/</Filename> also contains a directory <Filename>ghc/mk/</Filename>. It
-contains GHC-specific <Filename>Makefile</Filename> boilerplate code. More precisely:
-</Para>
+<para>
+You will notice that <filename>ghc/</filename> also contains a directory <filename>ghc/mk/</filename>. It
+contains GHC-specific <filename>Makefile</filename> boilerplate code. More precisely:
+</para>
-<Para>
+<para>
<ItemizedList>
<ListItem>
-<Para>
- <Filename>ghc/mk/boilerplate.mk</Filename> is included at the top of
-<Filename>ghc/Makefile</Filename>, and of all the leaf <Filename>Makefile</Filename>s in the
+<para>
+ <filename>ghc/mk/boilerplate.mk</filename> is included at the top of
+<filename>ghc/Makefile</filename>, and of all the leaf <filename>Makefile</filename>s in the
sub-directories. It in turn <Literal>include</Literal>s the main boilerplate file
-<Filename>mk/boilerplate.mk</Filename>.
+<filename>mk/boilerplate.mk</filename>.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- <Filename>ghc/mk/target.mk</Filename> is <Literal>include</Literal>d at the bottom of
-<Filename>ghc/Makefile</Filename>, and of all the leaf <Filename>Makefile</Filename>s in the
-sub-directories. It in turn <Literal>include</Literal>s the file <Filename>mk/target.mk</Filename>.
+<para>
+ <filename>ghc/mk/target.mk</filename> is <Literal>include</Literal>d at the bottom of
+<filename>ghc/Makefile</filename>, and of all the leaf <filename>Makefile</filename>s in the
+sub-directories. It in turn <Literal>include</Literal>s the file <filename>mk/target.mk</filename>.
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
-<Para>
+<para>
So these two files are the place to look for GHC-wide customisation
of the standard boilerplate.
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>boilerplate architecture</Primary></IndexTerm>
</Title>
-<Para>
-Every <Filename>Makefile</Filename> includes a <Filename>boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm> file
-at the top, and <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> file at the bottom. In
+<para>
+Every <filename>Makefile</filename> includes a <filename>boilerplate.mk</filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm> file
+at the top, and <filename>target.mk</filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> file at the bottom. In
this section we discuss what is in these files, and why there have to
be two of them. In general:
-</Para>
+</para>
-<Para>
+<para>
<ItemizedList>
<ListItem>
-<Para>
- <Filename>boilerplate.mk</Filename> consists of:
+<para>
+ <filename>boilerplate.mk</filename> consists of:
<ItemizedList>
<ListItem>
-<Para>
+<para>
<Emphasis>Definitions of millions of <Command>make</Command> variables</Emphasis> that
collectively specify the build configuration. Examples:
<Constant>HC_OPTS</Constant><IndexTerm><Primary>HC_OPTS</Primary></IndexTerm>, the options to feed to the Haskell compiler;
<Constant>NoFibSubDirs</Constant><IndexTerm><Primary>NoFibSubDirs</Primary></IndexTerm>, the sub-directories to enable within the
<Literal>nofib</Literal> project; <Constant>GhcWithHc</Constant><IndexTerm><Primary>GhcWithHc</Primary></IndexTerm>, the name of the Haskell
compiler to use when compiling GHC in the <Literal>ghc</Literal> project.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
<Emphasis>Standard pattern rules</Emphasis> that tell <Command>gmake</Command> how to construct one
file from another.
-</Para>
+</para>
</ListItem>
</ItemizedList>
-<Filename>boilerplate.mk</Filename> needs to be <Literal>include</Literal>d at the <Emphasis>top</Emphasis>
-of each <Filename>Makefile</Filename>, so that the user can replace the
+<filename>boilerplate.mk</filename> needs to be <Literal>include</Literal>d at the <Emphasis>top</Emphasis>
+of each <filename>Makefile</filename>, so that the user can replace the
boilerplate definitions or pattern rules by simply giving a new
-definition or pattern rule in the <Filename>Makefile</Filename>. <Command>gmake</Command>
+definition or pattern rule in the <filename>Makefile</filename>. <Command>gmake</Command>
simply takes the last definition as the definitive one.
Instead of <Emphasis>replacing</Emphasis> boilerplate definitions, it is also quite
-common to <Emphasis>augment</Emphasis> them. For example, a <Filename>Makefile</Filename> might say:
+common to <Emphasis>augment</Emphasis> them. For example, a <filename>Makefile</filename> might say:
<ProgramListing>
thereby adding ``<Option>-O</Option>'' to the end of <Constant>SRC_HC_OPTS</Constant><IndexTerm><Primary>SRC_HC_OPTS</Primary></IndexTerm>.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- <Filename>target.mk</Filename> contains <Command>make</Command> rules for the standard
+<para>
+ <filename>target.mk</filename> contains <Command>make</Command> rules for the standard
targets described in <Xref LinkEnd="sec-standard-targets">. These rules are selectively included,
depending on the setting of certain <Command>make</Command> variables. These
variables are usually set in the middle section of the
-<Filename>Makefile</Filename> between the two <Literal>include</Literal>s.
+<filename>Makefile</filename> between the two <Literal>include</Literal>s.
-<Filename>target.mk</Filename> must be included at the end (rather than being part of
-<Filename>boilerplate.mk</Filename>) for several tiresome reasons:
+<filename>target.mk</filename> must be included at the end (rather than being part of
+<filename>boilerplate.mk</filename>) for several tiresome reasons:
<ItemizedList>
<ListItem>
-<Para>
+<para>
<Command>gmake</Command> commits target and dependency lists earlier than
it should. For example, <FIlename>target.mk</FIlename> has a rule that looks like
this:
</ProgramListing>
-If this rule was in <Filename>boilerplate.mk</Filename> then <Constant>$(HS_PROG)</Constant><IndexTerm><Primary>HS_PROG</Primary></IndexTerm>
+If this rule was in <filename>boilerplate.mk</filename> then <Constant>$(HS_PROG)</Constant><IndexTerm><Primary>HS_PROG</Primary></IndexTerm>
and <Constant>$(OBJS)</Constant><IndexTerm><Primary>OBJS</Primary></IndexTerm> would not have their final values at the
moment <Command>gmake</Command> encountered the rule. Alas, <Command>gmake</Command> takes a snapshot
of their current values, and wires that snapshot into the rule. (In
contrast, the commands executed when the rule ``fires'' are only
substituted at the moment of firing.) So, the rule must follow the
-definitions given in the <Filename>Makefile</Filename> itself.
+definitions given in the <filename>Makefile</filename> itself.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Unlike pattern rules, ordinary rules cannot be overriden or
replaced by subsequent rules for the same target (at least, not without an
-error message). Including ordinary rules in <Filename>boilerplate.mk</Filename> would
+error message). Including ordinary rules in <filename>boilerplate.mk</filename> would
prevent the user from writing rules for specific targets in specific cases.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
There are a couple of other reasons I've forgotten, but it doesn't
matter too much.
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
</Sect2>
<Sect2 id="sec-boiler">
-<Title>The main <Filename>mk/boilerplate.mk</Filename> file
+<Title>The main <filename>mk/boilerplate.mk</filename> file
<IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm></Title>
-<Para>
-If you look at <Filename><Constant>$(FPTOOLS_TOP)</Constant>/mk/boilerplate.mk</Filename> you will find
+<para>
+If you look at <filename><Constant>$(FPTOOLS_TOP)</Constant>/mk/boilerplate.mk</filename> you will find
that it consists of the following sections, each held in a separate
file:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
-<Term><Filename>config.mk</Filename><IndexTerm><Primary>config.mk</Primary></IndexTerm></Term>
+<Term><filename>config.mk</filename><IndexTerm><Primary>config.mk</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
is the build configuration file we
discussed at length in <Xref LinkEnd="sec-build-config">.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
-<Term><Filename>paths.mk</Filename><IndexTerm><Primary>paths.mk</Primary></IndexTerm></Term>
+<Term><filename>paths.mk</filename><IndexTerm><Primary>paths.mk</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
defines <Command>make</Command> variables for
pathnames and file lists. In particular, it gives definitions for:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<Term><Constant>SRCS</Constant><IndexTerm><Primary>SRCS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
all source files in the current directory.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>HS_SRCS</Constant><IndexTerm><Primary>HS_SRCS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
all Haskell source files in the current directory.
It is derived from <Constant>$(SRCS)</Constant>, so if you override <Constant>SRCS</Constant> with a new value
<Constant>HS_SRCS</Constant> will follow suit.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>C_SRCS</Constant><IndexTerm><Primary>C_SRCS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
similarly for C source files.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>HS_OBJS</Constant><IndexTerm><Primary>HS_OBJS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
-the <Filename>.o</Filename> files derived from <Constant>$(HS_SRCS)</Constant>.
-</Para>
+<para>
+the <filename>.o</filename> files derived from <Constant>$(HS_SRCS)</Constant>.
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>C_OBJS</Constant><IndexTerm><Primary>C_OBJS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
similarly for <Constant>$(C_SRCS)</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>OBJS</Constant><IndexTerm><Primary>OBJS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
the concatenation of <Constant>$(HS_OBJS)</Constant> and <Constant>$(C_OBJS)</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
Any or all of these definitions can easily be overriden by giving new
-definitions in your <Filename>Makefile</Filename>. For example, if there are things in
+definitions in your <filename>Makefile</filename>. For example, if there are things in
the current directory that look like source files but aren't, then
-you'll need to set <Constant>SRCS</Constant> manually in your <Filename>Makefile</Filename>. The other
+you'll need to set <Constant>SRCS</Constant> manually in your <filename>Makefile</filename>. The other
definitions will then work from this new definition.
-</Para>
+</para>
-<Para>
-What, exactly, does <Filename>paths.mk</Filename> consider a ``source file'' to be? It's
-based on the file's suffix (e.g. <Filename>.hs</Filename>, <Filename>.lhs</Filename>, <Filename>.c</Filename>, <Filename>.lc</Filename>, etc), but
+<para>
+What, exactly, does <filename>paths.mk</filename> consider a ``source file'' to be? It's
+based on the file's suffix (e.g. <filename>.hs</filename>, <filename>.lhs</filename>, <filename>.c</filename>, <filename>.lc</filename>, etc), but
this is the kind of detail that changes, so rather than
enumerate the source suffices here the best thing to do is to look in
-<Filename>paths.mk</Filename>.
-</Para>
+<filename>paths.mk</filename>.
+</para>
</ListItem></VarListEntry>
<VarListEntry>
-<Term><Filename>opts.mk</Filename><IndexTerm><Primary>opts.mk</Primary></IndexTerm></Term>
+<Term><filename>opts.mk</filename><IndexTerm><Primary>opts.mk</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
defines <Command>make</Command> variables for option
strings to pass to each program. For example, it defines
<Constant>HC_OPTS</Constant><IndexTerm><Primary>HC_OPTS</Primary></IndexTerm>, the option strings to pass to the Haskell
compiler. See <Xref LinkEnd="sec-suffix">.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
-<Term><Filename>suffix.mk</Filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm></Term>
+<Term><filename>suffix.mk</filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
defines standard pattern rules—see <Xref LinkEnd="sec-suffix">.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
Any of the variables and pattern rules defined by the boilerplate file
-can easily be overridden in any particular <Filename>Makefile</Filename>, because the
+can easily be overridden in any particular <filename>Makefile</filename>, because the
boilerplate <Literal>include</Literal> comes first. Definitions after this <Literal>include</Literal>
-directive simply override the default ones in <Filename>boilerplate.mk</Filename>.
-</Para>
+directive simply override the default ones in <filename>boilerplate.mk</filename>.
+</para>
</Sect2>
<IndexTerm><Primary>Pattern rules</Primary></IndexTerm></Title>
-<Para>
-The file <Filename>suffix.mk</Filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm> defines standard <Emphasis>pattern
+<para>
+The file <filename>suffix.mk</filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm> defines standard <Emphasis>pattern
rules</Emphasis> that say how to build one kind of file from another, for
-example, how to build a <Filename>.o</Filename> file from a <Filename>.c</Filename> file. (GNU <Command>make</Command>'s
+example, how to build a <filename>.o</filename> file from a <filename>.c</filename> file. (GNU <Command>make</Command>'s
<Emphasis>pattern rules</Emphasis> are more powerful and easier to use than Unix
<Command>make</Command>'s <Emphasis>suffix rules</Emphasis>.)
-</Para>
+</para>
-<Para>
+<para>
Almost all the rules look something like this:
-</Para>
+</para>
-<Para>
+<para>
<ProgramListing>
%.o : %.c
$(CC) $(CC_OPTS) -c $< -o $@
</ProgramListing>
-</Para>
+</para>
-<Para>
+<para>
Here's how to understand the rule. It says that
-<Emphasis>something</Emphasis><Filename>.o</Filename> (say <Filename>Foo.o</Filename>) can be built from
-<Emphasis>something</Emphasis><Filename>.c</Filename> (<Filename>Foo.c</Filename>), by invoking the C compiler
+<Emphasis>something</Emphasis><filename>.o</filename> (say <filename>Foo.o</filename>) can be built from
+<Emphasis>something</Emphasis><filename>.c</filename> (<filename>Foo.c</filename>), by invoking the C compiler
(path name held in <Constant>$(CC)</Constant>), passing to it the options
<Constant>$(CC_OPTS)</Constant> and the rule's dependent file of the rule
-<Literal>$<</Literal> (<Filename>Foo.c</Filename> in this case), and putting the result in
-the rule's target <Literal>$@</Literal> (<Filename>Foo.o</Filename> in this case).
-</Para>
+<Literal>$<</Literal> (<filename>Foo.c</filename> in this case), and putting the result in
+the rule's target <Literal>$@</Literal> (<filename>Foo.o</filename> in this case).
+</para>
-<Para>
+<para>
Every program is held in a <Command>make</Command> variable defined in
-<Filename>mk/config.mk</Filename>—look in <Filename>mk/config.mk</Filename> for the
+<filename>mk/config.mk</filename>—look in <filename>mk/config.mk</filename> for the
complete list. One important one is the Haskell compiler, which is
called <Constant>$(HC)</Constant>.
-</Para>
+</para>
-<Para>
+<para>
Every program's options are are held in a <Command>make</Command> variables called
<Constant><prog>_OPTS</Constant>. the <Constant><prog>_OPTS</Constant> variables are defined in
-<Filename>mk/opts.mk</Filename>. Almost all of them are defined like this:
-</Para>
+<filename>mk/opts.mk</filename>. Almost all of them are defined like this:
+</para>
-<Para>
+<para>
<ProgramListing>
CC_OPTS = $(SRC_CC_OPTS) $(WAY$(_way)_CC_OPTS) $($*_CC_OPTS) $(EXTRA_CC_OPTS)
</ProgramListing>
-</Para>
+</para>
-<Para>
+<para>
The four variables from which <Constant>CC_OPTS</Constant> is built have the following meaning:
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<Term><Constant>SRC_CC_OPTS</Constant><IndexTerm><Primary>SRC_CC_OPTS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
options passed to all C
compilations.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>WAY_<way>_CC_OPTS</Constant>:</Term>
<ListItem>
-<Para>
+<para>
options passed to C
compilations for way <Literal><way></Literal>. For example,
<Constant>WAY_mp_CC_OPTS</Constant> gives options to pass to the C compiler when
options to pass to the C compiler when compiling the standard way.
(<Xref LinkEnd="sec-ways"> dicusses multi-way
compilation.)
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant><module>_CC_OPTS</Constant>:</Term>
<ListItem>
-<Para>
+<para>
options to
pass to the C compiler that are specific to module <Literal><module></Literal>. For example, <Constant>SMap_CC_OPTS</Constant> gives the specific options
-to pass to the C compiler when compiling <Filename>SMap.c</Filename>.
-</Para>
+to pass to the C compiler when compiling <filename>SMap.c</filename>.
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>EXTRA_CC_OPTS</Constant><IndexTerm><Primary>EXTRA_CC_OPTS</Primary></IndexTerm>:</Term>
<ListItem>
-<Para>
+<para>
extra options to pass to all
C compilations. This is intended for command line use, thus:
-</Para>
+</para>
-<Para>
+<para>
<ProgramListing>
gmake libHS.a EXTRA_CC_OPTS="-v"
</ProgramListing>
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
</Sect2>
<Sect2 id="sec-targets">
-<Title>The main <Filename>mk/target.mk</Filename> file
+<Title>The main <filename>mk/target.mk</filename> file
<IndexTerm><Primary>target.mk</Primary></IndexTerm></Title>
-<Para>
-<Filename>target.mk</Filename> contains canned rules for all the standard targets
+<para>
+<filename>target.mk</filename> contains canned rules for all the standard targets
described in <Xref LinkEnd="sec-standard-targets">. It is complicated by the fact that you don't want all of
-these rules to be active in every <Filename>Makefile</Filename>. Rather than have a
+these rules to be active in every <filename>Makefile</filename>. Rather than have a
plethora of tiny files which you can include selectively, there is a
-single file, <Filename>target.mk</Filename>, which selectively includes rules based on
-whether you have defined certain variables in your <Filename>Makefile</Filename>. This
+single file, <filename>target.mk</filename>, which selectively includes rules based on
+whether you have defined certain variables in your <filename>Makefile</filename>. This
section explains what rules you get, what variables control them, and
what the rules do. Hopefully, you will also get enough of an idea of
what is supposed to happen that you can read and understand any weird
special cases yourself.
-</Para>
+</para>
-<Para>
+<para>
<VariableList>
<VarListEntry>
<Term><Constant>HS_PROG</Constant><IndexTerm><Primary>HS_PROG</Primary></IndexTerm>.</Term>
<ListItem>
-<Para>
+<para>
If <Constant>HS_PROG</Constant> is defined, you get
rules with the following targets:
<VariableList>
<VarListEntry>
-<Term><Filename>HS_PROG</Filename><IndexTerm><Primary>HS_PROG</Primary></IndexTerm></Term>
+<Term><filename>HS_PROG</filename><IndexTerm><Primary>HS_PROG</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
itself. This rule links <Constant>$(OBJS)</Constant>
with the Haskell runtime system to get an executable called
<Constant>$(HS_PROG)</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>install</Literal><IndexTerm><Primary>install</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
installs <Constant>$(HS_PROG)</Constant>
in <Constant>$(bindir)</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>C_PROG</Constant><IndexTerm><Primary>C_PROG</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
is similar to <Constant>HS_PROG</Constant>, except that
the link step links <Constant>$(C_OBJS)</Constant> with the C runtime system.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>LIBRARY</Constant><IndexTerm><Primary>LIBRARY</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
is similar to <Constant>HS_PROG</Constant>, except that
it links <Constant>$(LIB_OBJS)</Constant> to make the library archive <Constant>$(LIBRARY)</Constant>, and
<Literal>install</Literal> installs it in <Constant>$(libdir)</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>LIB_DATA</Constant><IndexTerm><Primary>LIB_DATA</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
…
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>LIB_EXEC</Constant><IndexTerm><Primary>LIB_EXEC</Primary></IndexTerm></Term>
<ListItem>
-<Para>
+<para>
…
-</Para>
+</para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Constant>HS_SRCS</Constant><IndexTerm><Primary>HS_SRCS</Primary></IndexTerm>, <Constant>C_SRCS</Constant><IndexTerm><Primary>C_SRCS</Primary></IndexTerm>.</Term>
<ListItem>
-<Para>
+<para>
If <Constant>HS_SRCS</Constant>
is defined and non-empty, a rule for the target <Literal>depend</Literal> is included,
which generates dependency information for Haskell programs.
Similarly for <Constant>C_SRCS</Constant>.
-</Para>
+</para>
</ListItem></VarListEntry>
</VariableList>
-</Para>
+</para>
-<Para>
+<para>
All of these rules are ``double-colon'' rules, thus
-</Para>
+</para>
-<Para>
+<para>
<ProgramListing>
install :: $(HS_PROG)
...how to install it...
</ProgramListing>
-</Para>
+</para>
-<Para>
+<para>
GNU <Command>make</Command> treats double-colon rules as separate entities. If there
are several double-colon rules for the same target it takes each in
turn and fires it if its dependencies say to do so. This means that
generate two rules for <Literal>install</Literal>. When you type <Command>gmake install</Command> both
rules will be fired, and both the program and the library will be
installed, just as you wanted.
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>recursion, in makefiles</Primary></IndexTerm>
<IndexTerm><Primary>Makefile, recursing into subdirectories</Primary></IndexTerm></Title>
-<Para>
-In leaf <Filename>Makefile</Filename>s the variable <Constant>SUBDIRS</Constant><IndexTerm><Primary>SUBDIRS</Primary></IndexTerm> is undefined.
-In non-leaf <Filename>Makefile</Filename>s, <Constant>SUBDIRS</Constant> is set to the list of
-sub-directories that contain subordinate <Filename>Makefile</Filename>s. <Emphasis>It is up to
-you to set <Constant>SUBDIRS</Constant> in the <Filename>Makefile</Filename>.</Emphasis> There is no automation here—<Constant>SUBDIRS</Constant> is too important to automate.
-</Para>
+<para>
+In leaf <filename>Makefile</filename>s the variable <Constant>SUBDIRS</Constant><IndexTerm><Primary>SUBDIRS</Primary></IndexTerm> is undefined.
+In non-leaf <filename>Makefile</filename>s, <Constant>SUBDIRS</Constant> is set to the list of
+sub-directories that contain subordinate <filename>Makefile</filename>s. <Emphasis>It is up to
+you to set <Constant>SUBDIRS</Constant> in the <filename>Makefile</filename>.</Emphasis> There is no automation here—<Constant>SUBDIRS</Constant> is too important to automate.
+</para>
-<Para>
-When <Constant>SUBDIRS</Constant> is defined, <Filename>target.mk</Filename> includes a rather
+<para>
+When <Constant>SUBDIRS</Constant> is defined, <filename>target.mk</filename> includes a rather
neat rule for the standard targets (<Xref LinkEnd="sec-standard-targets"> that simply invokes
<Command>make</Command> recursively in each of the sub-directories.
-</Para>
+</para>
-<Para>
+<para>
<Emphasis>These recursive invocations are guaranteed to occur in the order
in which the list of directories is specified in <Constant>SUBDIRS</Constant>. </Emphasis>This
guarantee can be important. For example, when you say <Command>gmake boot</Command> it
in one sub-directory (the include files, say) before another (the
source files). Generally, put the most independent sub-directory
first, and the most dependent last.
-</Para>
+</para>
</Sect2>
<IndexTerm><Primary>way management</Primary></IndexTerm></Title>
-<Para>
+<para>
We sometimes want to build essentially the same system in several
different ``ways''. For example, we want to build GHC's <Literal>Prelude</Literal>
libraries with and without profiling, with and without concurrency,
have a completely separate build tree for each such ``way'', but it
would be horribly bureaucratic, especially since often only parts of
the build tree need to be constructed in multiple ways.
-</Para>
+</para>
-<Para>
-Instead, the <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> contains some clever magic to
+<para>
+Instead, the <filename>target.mk</filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> contains some clever magic to
allow you to build several versions of a system; and to control
locally how many versions are built and how they differ. This section
explains the magic.
-</Para>
+</para>
-<Para>
+<para>
The files for a particular way are distinguished by munging the
suffix. The ``normal way'' is always built, and its files have the
-standard suffices <Filename>.o</Filename>, <Filename>.hi</Filename>, and so on. In addition, you can build
+standard suffices <filename>.o</filename>, <filename>.hi</filename>, and so on. In addition, you can build
one or more extra ways, each distinguished by a <Emphasis>way tag</Emphasis>. The
object files and interface files for one of these extra ways are
distinguished by their suffix. For example, way <Literal>mp</Literal> has files
-<Filename>.mp_o</Filename> and <Filename>.mp_hi</Filename>. Library archives have their way tag the other
-side of the dot, for boring reasons; thus, <Filename>libHS_mp.a</Filename>.
-</Para>
+<filename>.mp_o</filename> and <filename>.mp_hi</filename>. Library archives have their way tag the other
+side of the dot, for boring reasons; thus, <filename>libHS_mp.a</filename>.
+</para>
-<Para>
+<para>
A <Command>make</Command> variable called <Constant>way</Constant> holds the current way tag. <Emphasis><Constant>way</Constant>
is only ever set on the command line of a recursive invocation of
-<Command>gmake</Command>.</Emphasis> It is never set inside a <Filename>Makefile</Filename>. So it is a global
+<Command>gmake</Command>.</Emphasis> It is never set inside a <filename>Makefile</filename>. So it is a global
constant for any one invocation of <Command>gmake</Command>. Two other <Command>make</Command>
variables, <Constant>way_</Constant> and <Constant>_way</Constant> are immediately derived from <Constant>$(way)</Constant> and
never altered. If <Constant>way</Constant> is not set, then neither are <Constant>way_</Constant> and
For example, if <Constant>$(way)</Constant> is ``<Literal>mp</Literal>'', then <Constant>way_</Constant> is set to ``<Literal>mp_</Literal>''
and <Constant>_way</Constant> is set to ``<Literal>_mp</Literal>''. These three variables are then used
when constructing file names.
-</Para>
+</para>
-<Para>
+<para>
So how does <Command>make</Command> ever get recursively invoked with <Constant>way</Constant> set? There
are two ways in which this happens:
-</Para>
+</para>
-<Para>
+<para>
<ItemizedList>
<ListItem>
-<Para>
+<para>
For some (but not all) of the standard targets, when in a leaf
sub-directory, <Command>make</Command> is recursively invoked for each way tag in
<Constant>$(WAYS)</Constant>. You set <Constant>WAYS</Constant> to the list of way tags you want these
targets built for. The mechanism here is very much like the recursive
invocation of <Command>make</Command> in sub-directories (<Xref LinkEnd="sec-subdirs">).
-It is up to you to set <Constant>WAYS</Constant> in your <Filename>Makefile</Filename>; this is how you
+It is up to you to set <Constant>WAYS</Constant> in your <filename>Makefile</filename>; this is how you
control what ways will get built.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
For a useful collection of
-targets (such as <Filename>libHS_mp.a</Filename>, <Filename>Foo.mp_o</Filename>) there is a rule which
+targets (such as <filename>libHS_mp.a</filename>, <filename>Foo.mp_o</filename>) there is a rule which
recursively invokes <Command>make</Command> to make the specified target, setting the
<Constant>way</Constant> variable. So if you say <Command>gmake Foo.mp_o</Command> you should see a
recursive invocation <Command>gmake Foo.mp_o way=mp</Command>, and <Emphasis>in this
recursive invocation the pattern rule for compiling a Haskell file
-into a <Filename>.o</Filename> file will match</Emphasis>. The key pattern rules (in <Filename>suffix.mk</Filename>)
+into a <filename>.o</filename> file will match</Emphasis>. The key pattern rules (in <filename>suffix.mk</filename>)
look like this:
Neat, eh?
-</Para>
+</para>
</ListItem>
</ItemizedList>
-</Para>
+</para>
</Sect2>
<Sect2>
<Title>When the canned rule isn't right</Title>
-<Para>
+<para>
Sometimes the canned rule just doesn't do the right thing. For
example, in the <Literal>nofib</Literal> suite we want the link step to print out
timing information. The thing to do here is <Emphasis>not</Emphasis> to define
<Constant>HS_PROG</Constant> or <Constant>C_PROG</Constant>, and instead define a special purpose rule in
-your own <Filename>Makefile</Filename>. By using different variable names you will avoid
+your own <filename>Makefile</filename>. By using different variable names you will avoid
the canned rules being included, and conflicting with yours.
-</Para>
+</para>
</Sect2>
</Sect1>
<Sect1 id="sec-booting-from-C">
-<Title>Booting/porting from C (<Filename>.hc</Filename>) files
+<Title>Booting/porting from C (<filename>.hc</filename>) files
<IndexTerm><Primary>building GHC from .hc files</Primary></IndexTerm>
<IndexTerm><Primary>booting GHC from .hc files</Primary></IndexTerm>
<IndexTerm><Primary>porting GHC</Primary></IndexTerm></Title>
-<Para>
+<para>
This section is for people trying to get GHC going by using the supplied
-intermediate C (<Filename>.hc</Filename>) files. This would probably be
+intermediate C (<filename>.hc</filename>) files. This would probably be
because no binaries have been provided, or because the machine is not ``fully
supported''.
-</Para>
+</para>
-<Para>
+<para>
The intermediate C files are normally made available together with a source
release, please check the announce message for exact directions of where to
find them. If we haven't made them available or you can't find them, please
ask.
-</Para>
+</para>
-<Para>
+<para>
Assuming you've got them, unpack them on top of a fresh source tree. This
-will place matching <Filename>.hc</Filename> files next to the corresponding
-Haskell source in the compiler subdirectory <Filename>ghc</Filename> and in
-the language package of hslibs (i.e., in <Filename>hslibs/lang</Filename>).
+will place matching <filename>.hc</filename> files next to the corresponding
+Haskell source in the compiler subdirectory <filename>ghc</filename> and in
+the language package of hslibs (i.e., in <filename>hslibs/lang</filename>).
Then follow the `normal' instructions in <Xref
LinkEnd="sec-building-from-source"> for setting up a build tree.
-</Para>
+</para>
-<Para>
+<para>
The actual build process is fully automated by the
-<Filename>hc-build</Filename> script located in the
-<Filename>distrib</Filename> directory. If you eventually want to install GHC
-into the directory <Filename>INSTALL_DIRECTORY</Filename>, the following
+<filename>hc-build</filename> script located in the
+<filename>distrib</filename> directory. If you eventually want to install GHC
+into the directory <filename>INSTALL_DIRECTORY</filename>, the following
command will execute the whole build process (it won't install yet):
-</Para>
+</para>
<Screen>
foo% distrib/hc-build --prefix=INSTALL_DIRECTORY
</Screen>
<IndexTerm><Primary>--hc-build</Primary></IndexTerm>
-<Para>
-By default, the installation directory is <Filename>/usr/local</Filename>. If
+<para>
+By default, the installation directory is <filename>/usr/local</filename>. If
that is what you want, you may omit the argument to
-<Filename>hc-build</Filename>. Generally, any option given to
-<Filename>hc-build</Filename> is passed through to the configuration script
-<Filename>configure</Filename>. If <Filename>hc-build</Filename>
+<filename>hc-build</filename>. Generally, any option given to
+<filename>hc-build</filename> is passed through to the configuration script
+<filename>configure</filename>. If <filename>hc-build</filename>
successfully completes the build process, you can install the resulting
system, as normal, with
-</Para>
+</para>
<Screen>
foo% make install
</Screen>
-<Para>
+<para>
That's the mechanics of the boot process, but, of course, if you're
trying to boot on a platform that is not supported and significantly
`different' from any of the supported ones, this is only the start of
the adventure…(ToDo: porting tips—stuff to look out for, etc.)
-</Para>
+</para>
</Sect1>
<IndexTerm><Primary>pitfalls, in building</Primary></IndexTerm>
<IndexTerm><Primary>building pitfalls</Primary></IndexTerm></Title>
-<Para>
+<para>
WARNINGS about pitfalls and known ``problems'':
-</Para>
+</para>
-<Para>
+<para>
<OrderedList>
<ListItem>
-<Para>
+<para>
One difficulty that comes up from time to time is running out of space
-in <Filename>/tmp</Filename>. (It is impossible for the configuration stuff to
+in <filename>/tmp</filename>. (It is impossible for the configuration stuff to
compensate for the vagaries of different sysadmin approaches to temp
space.)
<IndexTerm><Primary>tmp, running out of space in</Primary></IndexTerm>
export TMPDIR=<dir>
</ProgramListing>
-in your <Filename>build.mk</Filename> file.
+in your <filename>build.mk</filename> file.
Then GHC and the other <Literal>fptools</Literal> programs will use the appropriate directory
in all cases.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-In compiling some support-code bits, e.g., in <Filename>ghc/rts/gmp</Filename> and even
-in <Filename>ghc/lib</Filename>, you may get a few C-compiler warnings. We think these
+<para>
+In compiling some support-code bits, e.g., in <filename>ghc/rts/gmp</filename> and even
+in <filename>ghc/lib</filename>, you may get a few C-compiler warnings. We think these
are OK.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
When compiling via C, you'll sometimes get ``warning: assignment from
incompatible pointer type'' out of GCC. Harmless.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Similarly, <Command>ar</Command>chiving warning messages like the following are not
a problem:
</Screen>
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- In compiling the compiler proper (in <Filename>compiler/</Filename>), you <Emphasis>may</Emphasis>
+<para>
+ In compiling the compiler proper (in <filename>compiler/</filename>), you <Emphasis>may</Emphasis>
get an ``Out of heap space'' error message. These can vary with the
vagaries of different systems, it seems. The solution is simple:
<ItemizedList>
<ListItem>
-<Para>
+<para>
If you're compiling with GHC 4.00 or later, then the
<Emphasis>maximum</Emphasis> heap size must have been reached. This
is somewhat unlikely, since the maximum is set to 64M by default.
<Option>-optCrts-M<size></Option> flag (add this flag to
<Constant><module>_HC_OPTS</Constant>
<Command>make</Command> variable in the appropriate
-<Filename>Makefile</Filename>).
+<filename>Makefile</filename>).
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
- For GHC < 4.00, add a suitable <Option>-H</Option> flag to the <Filename>Makefile</Filename>, as
+<para>
+ For GHC < 4.00, add a suitable <Option>-H</Option> flag to the <filename>Makefile</filename>, as
above.
-</Para>
+</para>
</ListItem>
</ItemizedList>
</Screen>
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
If you try to compile some Haskell, and you get errors from GCC about
-lots of things from <Filename>/usr/include/math.h</Filename>, then your GCC was
+lots of things from <filename>/usr/include/math.h</filename>, then your GCC was
mis-installed. <Command>fixincludes</Command> wasn't run when it should've been.
As <Command>fixincludes</Command> is now automagically run as part of GCC installation,
this bug also suggests that you have an old GCC.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
You <Emphasis>may</Emphasis> need to re-<Command>ranlib</Command><IndexTerm><Primary>ranlib</Primary></IndexTerm> your libraries (on Sun4s).
We'd be interested to know if this is still necessary.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
GHC's sources go through <Command>cpp</Command> before being compiled, and <Command>cpp</Command> varies
a bit from one Unix to another. One particular gotcha is macro calls
like this:
Alas, <Command>cpp</Command> doesn't tell you the offending file!
Workaround: don't put weird things in string args to <Command>cpp</Command> macros.
-</Para>
+</para>
</ListItem>
</OrderedList>
-</Para>
+</para>
</Sect1>
<Sect1 id="winbuild"><Title>Notes for building under Windows</Title>
-<Para>
+<para>
This section summarises how to get the utilities you need on your
Win95/98/NT/2000 machine to use CVS and build GHC. Similar notes for
installing and running GHC may be found in the user guide. In general,
largely on detailed advice from Sigbjørn Finne. You should read the
GHC installation guide sections on Windows (in the user guide) before
continuing to read these notes.
-</Para>
+</para>
<Sect2><Title>Installing ssh</Title>
<ItemizedList>
<ListItem>
-<Para>
-Extract the whole of <ULink URL="http://research.microsoft.com/~simonpj/ssh-1_2_26-cygwinb19.tar.gz">the ssh archive</ULink> into your <Filename>C:\</Filename> directory, and use the ``All files'' and ``User folder names'' options in WinZip extract dialogue box. This populates your <Filename>C:\usr\local</Filename> tree.
-</Para>
+<para>
+Extract the whole of <ULink URL="http://research.microsoft.com/~simonpj/ssh-1_2_26-cygwinb19.tar.gz">the ssh archive</ULink> into your <filename>C:\</filename> directory, and use the ``All files'' and ``User folder names'' options in WinZip extract dialogue box. This populates your <filename>C:\usr\local</filename> tree.
+</para>
</ListItem>
<ListItem>
-<Para>
-Extract <ULink URL="http://research.microsoft.com/~simonpj/cygwinb19.dll.zip">cygwinb19.dll</ULink> into <Filename>/usr/local/bin</Filename>. The current version
+<para>
+Extract <ULink URL="http://research.microsoft.com/~simonpj/cygwinb19.dll.zip">cygwinb19.dll</ULink> into <filename>/usr/local/bin</filename>. The current version
of Cywin is b20, but this version of ssh was compiled with b19.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
On a Win2k machine, open up a bash and do
-</Para>
+</para>
<Screen>
foo$ cd /etc
foo$ mkpasswd -l > passwd
</Screen>
-<Para>
+<para>
Check that your login entry is on the first line
of that file. If not, move it to the top. It's OK
for 'Administrator' to be the first entry, assuming you are one.
-</Para>
+</para>
-<Para>
+<para>
However, Win9x doesn't support the calls that <Command>mkpasswd</Command> relies on
(e.g., <Function>NetUserEnum</Function>). If you run <Command>mkpasswd</Command> you
get errors like:
-</Para>
+</para>
<Screen>
linked to missing export netapi32.dll:NetUserEnum
</Screen>
-<Para>
+<para>
The passwd file is used
by ssh in a fairly rudimentary manner, so I'd simply
-synthesise/copy an existing Unix <Filename>/etc/passwd</Filename>, i.e., create
-an <Filename>/etc/passwd</Filename> file containing the line
-</Para>
+synthesise/copy an existing Unix <filename>/etc/passwd</filename>, i.e., create
+an <filename>/etc/passwd</filename> file containing the line
+</para>
<Screen>
<login>::500:513:::/bin/sh
</Screen>
-<Para>
+<para>
where <Literal><login></Literal> is your login id.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-Generate a key, by running <Filename>c:/user/local/bin/ssh-keygen1</Filename>.
- This generates a public key in <Filename>.ssh/identity.pub</Filename>, and a
- private key in <Filename>.ssh/identity</Filename>
-</Para>
+<para>
+Generate a key, by running <filename>c:/user/local/bin/ssh-keygen1</filename>.
+ This generates a public key in <filename>.ssh/identity.pub</filename>, and a
+ private key in <filename>.ssh/identity</filename>
+</para>
-<Para>
+<para>
In response to the 'Enter passphrase' question, just hit
return (i.e. use an empty passphrase). The passphrase is
a password that protects your private key. But it's a pain
to type this passphrase everytime you use <Command>ssh</Command>, so the best
- thing to do is simply to protect your <Filename>.ssh</Filename> directory, and
- <Filename>.ssh/identity</Filename> from access by anyone else. To do this
- right-click your <Filename>.ssh</Filename> directory, and select Properties.
+ thing to do is simply to protect your <filename>.ssh</filename> directory, and
+ <filename>.ssh/identity</filename> from access by anyone else. To do this
+ right-click your <filename>.ssh</filename> directory, and select Properties.
If you are not on the access control list, add yourself, and
give yourself full permissions (the second panel).
Remove everyone else from the access control list. (Don't
leave them there but deny them access, because 'they' may be
a list that includes you!)
-</Para>
+</para>
-<Para>
+<para>
If you have problems running <Command>ssh-keygen1</Command>
- from within <Command>bash</Command>, start up <Filename>cmd.exe</Filename> and run it as follows:
-</Para>
+ from within <Command>bash</Command>, start up <filename>cmd.exe</filename> and run it as follows:
+</para>
<Screen>
c:\tmp> set CYGWIN32=tty
</ListItem>
<ListItem>
-<Para>
+<para>
If you don't have an account on <Literal>cvs.haskell.org</Literal>, send
- your <Filename>.ssh/identity.pub</Filename> to the CVS repository administrator
+ your <filename>.ssh/identity.pub</filename> to the CVS repository administrator
(currently Jeff Lewis <Email>jlewis@cse.ogi.edu</Email>). He will set up
your account.
-</Para>
+</para>
-<Para>
+<para>
If you do have an account on <Literal>cvs.haskell.org</Literal>, use TeraTerm
to logon to it. Once in, copy the
- key that <Command>ssh-keygen1</Command> deposited in <Filename>/.ssh/identity.pub</Filename> into
- your <Filename>~/.ssh/authorized_keys</Filename>. Make sure that the new version
- of <Filename>authorized_keys</Filename> still has 600 file permission.
-</Para>
+ key that <Command>ssh-keygen1</Command> deposited in <filename>/.ssh/identity.pub</filename> into
+ your <filename>~/.ssh/authorized_keys</filename>. Make sure that the new version
+ of <filename>authorized_keys</filename> still has 600 file permission.
+</para>
</ListItem>
</ItemizedList>
<ItemizedList>
<ListItem>
-<Para>
+<para>
Unpack
<ULink URL="http://research.microsoft.com/~simonpj/cvs-1_10-win.zip">
-CVS</ULink> and, following the instructions in the <Filename>README</Filename>, copy the
-appropriate files into <Filename>/usr/local/bin</Filename>.
-</Para>
+CVS</ULink> and, following the instructions in the <filename>README</filename>, copy the
+appropriate files into <filename>/usr/local/bin</filename>.
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
From the System control panel,
set the following <Emphasis>user</Emphasis> environment variables (see the GHC user guide)
-</Para>
+</para>
<ItemizedList>
<ListItem>
-<Para>
+<para>
<Constant>HOME</Constant>: points to your home directory. This is where CVS
-will look for its <Filename>.cvsrc</Filename> file.
-</Para>
+will look for its <filename>.cvsrc</filename> file.
+</para>
</ListItem>
<ListItem>
-<Para>
-<Constant>CVS_RSH</Constant>: <Filename>c:/usr/local/bin/ssh1</Filename>
-</Para>
+<para>
+<Constant>CVS_RSH</Constant>: <filename>c:/usr/local/bin/ssh1</filename>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
<Constant>CVSROOT</Constant>: <Literal>:ext:username@cvs.haskell.org:/home/cvs/root</Literal>,
where <Literal>username</Literal> is your userid
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-<Constant>CVSEDITOR</Constant>: <Filename>bin/gnuclient.exe</Filename> if you want to use an Emacs buffer for typing in those long commit messages.
-</Para>
+<para>
+<Constant>CVSEDITOR</Constant>: <filename>bin/gnuclient.exe</filename> if you want to use an Emacs buffer for typing in those long commit messages.
+</para>
</ListItem>
</ItemizedList>
</ListItem>
<ListItem>
-<Para>
-Put the following in <Filename>$HOME/.cvsrc</Filename>:
-</Para>
+<para>
+Put the following in <filename>$HOME/.cvsrc</filename>:
+</para>
<ProgramListing>
checkout -P
diff -u
</ProgramListing>
-<Para>
+<para>
These are the default options for the specified CVS commands,
and represent better defaults than the usual ones. (Feel
free to change them.)
-</Para>
+</para>
-<Para>
-Filenames starting with "<Filename>.</Filename>" were illegal in
+<para>
+Filenames starting with "<filename>.</filename>" were illegal in
the 8.3 DOS filesystem, but that restriction should have
been lifted by now (i.e., you're using VFAT or later filesystems.) If
-you're still having problems creating it, don't worry; <Filename>.cvsrc</Filename> is entirely
+you're still having problems creating it, don't worry; <filename>.cvsrc</filename> is entirely
optional.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Try doing <Command>cvs co fpconfig</Command>. All being well, bytes should
-start to trickle through, leaving a directory <Filename>fptools</Filename>
+start to trickle through, leaving a directory <filename>fptools</filename>
in your current directory. (You can <Command>rm</Command> it if you don't want to keep it.) The following messages appear to be harmless:
-</Para>
+</para>
<Screen>
setsockopt IPTOS_LOWDELAY: Invalid argument
setsockopt IPTOS_THROUGHPUT: Invalid argument
</Screen>
-<Para>
+<para>
At this point I found that CVS tried to invoke a little dialogue with
me (along the lines of `do you want to talk to this host'), but
somehow bombed out. This was from a bash shell running in emacs.
I solved this by invoking a Cygnus shell, and running CVS from there.
Once things are dialogue free, it seems to work OK from within emacs.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
If you want to check out part of large tree, proceed as follows:
-</Para>
+</para>
<ProgramListing>
cvs -f checkout -l papers
cvs update cpr
</ProgramListing>
-<Para>
+<para>
This sequence checks out the <Literal>papers</Literal> module, but none
of its sub-directories.
The "<Option>-l</Option>" flag says not to check out sub-directories.
-The "<Option>-f</Option>" flag says not to read the <Filename>.cvsrc</Filename> file
+The "<Option>-f</Option>" flag says not to read the <filename>.cvsrc</filename> file
whose <Option>-P</Option> default (don't check out empty directories) is
in this case bogus.
-</Para>
+</para>
-<Para>
+<para>
The <Command>cvs update</Command> command sucks in a named sub-directory.
-</Para>
+</para>
</ListItem>
</ItemizedList>
-<Para>
+<para>
There is a very nice graphical front-end to CVS for Win32 platforms,
with a UI that people will be familiar with, at
<ULink URL="http://www.wincvs.org/">wincvs.org</ULink>.
I have not tried it yet.
-</Para>
+</para>
</Sect2>
<Sect2><Title>Installing autoconf</Title>
-<Para>
+<para>
Only required if you are doing builds from GHC's sources
checked out from the CVS tree.
-</Para>
+</para>
<ItemizedList>
<ListItem>
-<Para>
+<para>
Fetch the (standard, Unix) <Command>autoconf</Command> distribution from
<ULink URL="ftp://ftp.gnu.org/gnu/autoconf">ftp.gnu.org</ULink>.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
+<para>
Unpack it into an arbitrary directory.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-Make sure that the directory <Filename>/usr/local/bin</Filename> exists.
-</Para>
+<para>
+Make sure that the directory <filename>/usr/local/bin</filename> exists.
+</para>
</ListItem>
<ListItem>
-<Para>
-Say "<Filename>./configure</Filename>".
-</Para>
+<para>
+Say "<filename>./configure</filename>".
+</para>
</ListItem>
<ListItem>
-<Para>
-Now <Command>make install</Command>. This should put <Filename>autoheader</Filename>
-and <Filename>autoconf</Filename> in <Filename>/usr/local/bin</Filename>.
-</Para>
+<para>
+Now <Command>make install</Command>. This should put <filename>autoheader</filename>
+and <filename>autoconf</filename> in <filename>/usr/local/bin</filename>.
+</para>
</ListItem>
</ItemizedList>
-<Para>
+<para>
<Command>autoheader</Command> doesn't seem to work, but you don't need it
for GHC.
-</Para>
+</para>
</Sect2>
<ItemizedList>
<ListItem>
-<Para>
-In the <Filename>./configure</Filename> output, ignore
+<para>
+In the <filename>./configure</filename> output, ignore
"<Literal>
checking whether #! works in shell scripts...
./configure: ./conftest: No such file or directory</Literal>",
and "<Literal>not updating unwritable cache ./config.cache</Literal>".
Nobody knows why these happen, but they seem to be harmless.
-</Para>
+</para>
</ListItem>
<ListItem>
-<Para>
-You have to run <Command>autoconf</Command> both in <Filename>fptools</Filename>
-and in <Filename>fptools/ghc</Filename>. If you omit the latter step you'll
-get an error when you run <Filename>./configure</Filename>:
-</Para>
+<para>
+You have to run <Command>autoconf</Command> both in <filename>fptools</filename>
+and in <filename>fptools/ghc</filename>. If you omit the latter step you'll
+get an error when you run <filename>./configure</filename>:
+</para>
<Screen>
...lots of stuff...
</ListItem>
<ListItem>
-<Para>
-You need <Filename>ghc</Filename> to be in your <Constant>PATH</Constant> before you run
+<para>
+You need <filename>ghc</filename> to be in your <Constant>PATH</Constant> before you run
<Command>configure</Command>. The default GHC InstallShield creates only
-<Filename>ghc-4.08</Filename>, so you may need to duplicate this file as <Filename>ghc</Filename>
+<filename>ghc-4.08</filename>, so you may need to duplicate this file as <filename>ghc</filename>
in the same directory, in order that <Command>configure</Command> will see it (or
-just rename <Filename>ghc-4.08</Filename> to <Filename>ghc</Filename>.
+just rename <filename>ghc-4.08</filename> to <filename>ghc</filename>.
And make sure that the directory is in your path.
-</Para>
+</para>
</ListItem>
</ItemizedList>