[project @ 2000-05-08 14:54:57 by rrt]
[ghc-hetmet.git] / docs / building.sgml
1 <!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
2
3 <Article>
4
5 <ArtHeader>
6
7 <Title>Building the Glasgow Functional Programming Tools Suite</Title>
8 <Author><OtherName>The GHC Team</OtherName></Author>
9 <Address><Email>glasgow-haskell-&lcub;users,bugs&rcub;@haskell.org</Email></Address>
10 <PubDate>January 2000</PubDate>
11
12 <Abstract>
13
14 <Para>
15 This guide is intended for people who want to build or modify
16 programs from the Glasgow <Literal>fptools</Literal> suite (as distinct from those
17 who merely want to <Emphasis>run</Emphasis> them). Installation instructions are now provided in the user guide.
18 </Para>
19
20 <Para>
21 The bulk of this guide applies to building on Unix systems; see <XRef LinkEnd="winbuild"> for Windows notes.
22 </Para>
23
24 </Abstract>
25
26 </ArtHeader>
27
28
29 <Sect1 id="sec-getting">
30 <Title>Getting the Glasgow <Literal>fptools</Literal> suite
31 </Title>
32
33 <Para>
34 Building the Glasgow tools <Emphasis>can</Emphasis> be complicated, mostly because
35 there are so many permutations of what/why/how, e.g., ``Build Happy
36 with HBC, everything else with GHC, leave out profiling, and test it
37 all on the `real' NoFib programs.''  Yeeps!
38 </Para>
39
40 <Para>
41 Happily, such complications don't apply to most people.  A few common
42 ``strategies'' serve most purposes.  Pick one and proceed
43 as suggested:
44 </Para>
45
46 <Para>
47 <VariableList>
48
49 <VarListEntry>
50 <Term><IndexTerm><Primary>Binary distribution</Primary></IndexTerm>Binary distribution.</Term>
51 <ListItem>
52 <Para>
53 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
54 binary distribution everything is pre-compiled for your particular
55 machine architecture and operating system, so all you should have to
56 do is install the binaries and libraries in suitable places. The user guide
57 describes how to do this.
58 </Para>
59
60 <Para>
61 A binary distribution may not work for you for two reasons.  First, we
62 may not have built the suite for the particular architecture/OS
63 platform you want. That may be due to lack of time and energy (in
64 which case you can get a source distribution and build from it; see
65 below).  Alternatively, it may be because we haven't yet ported the
66 suite to your architecture, in which case you are considerably worse
67 off.
68 </Para>
69
70 <Para>
71 The second reason a binary distribution may not be what you want is
72 if you want to read or modify the souce code.
73 </Para>
74 </ListItem></VarListEntry>
75 <VarListEntry>
76 <Term><IndexTerm><Primary>Source distribution</Primary></IndexTerm>Source distribution.</Term>
77 <ListItem>
78 <Para>
79 You have a supported
80 platform, but (a)&nbsp;you like the warm fuzzy feeling of compiling things
81 yourself; (b)&nbsp;you want to build something ``extra''&mdash;e.g., a set of
82 libraries with strictness-analysis turned off; or (c)&nbsp;you want to hack
83 on GHC yourself.
84 </Para>
85
86 <Para>
87 A source distribution contains complete sources for one or more
88 projects in the <Literal>fptools</Literal> suite.  Not only that, but the more awkward
89 machine-independent steps are done for you.  For example, if you don't
90 have <Command>flex</Command><IndexTerm><Primary>flex</Primary></IndexTerm> you'll find it convenient that the source
91 distribution contains the result of running <Command>flex</Command> on the lexical
92 analyser specification.  If you don't want to alter the lexical
93 analyser then this saves you having to find and install <Command>flex</Command>. You
94 will still need a working version of GHC on your machine in order to
95 compile (most of) the sources, however.
96 </Para>
97
98 <Para>
99 We make source distributions more frequently than binary
100 distributions; a release that comes with pre-compiled binaries
101 is considered a major release, i.e., a release that we have some
102 confidence will work well by having tested it (more) thoroughly.
103 </Para>
104
105 <Para>
106 Source-only distributions are either bugfix releases or snapshots of
107 current state of development. The release has undergone some testing.
108 Source releases of GHC 4.xx can be compiled up using GHC 2.10 or
109 later.
110 </Para>
111 </ListItem></VarListEntry>
112 <VarListEntry>
113 <Term>Build GHC from intermediate C <Filename>.hc</Filename> files<IndexTerm><Primary>hc files</Primary></IndexTerm>:</Term>
114 <ListItem>
115 <Para>
116 You
117 need a working GHC to use a source distribution. What if you don't
118 have a working GHC? Then you have no choice but to ``bootstrap'' up
119 from the intermediate C (<Filename>.hc</Filename>) files that we provide.  Building GHC
120 on an unsupported platform falls into this category.  Please see
121 <Xref LinkEnd="sec-booting-from-C">.
122 </Para>
123
124 <Para>
125 Once you have built GHC, you can build the other Glasgow tools with
126 it.
127 </Para>
128
129 <Para>
130 In theory, you can (could?) build GHC with another Haskell compiler
131 (e.g., HBC). We haven't tried to do this for ages and it almost
132 certainly doesn't work any more (for tedious reasons).
133 </Para>
134 </ListItem></VarListEntry>
135 <VarListEntry>
136 <Term>The CVS repository.</Term>
137 <ListItem>
138 <Para>
139 We make source distributions slightly more often than binary
140 distributions; but still infrequently.  If you want more up-to-the
141 minute (but less tested) source code then you need to get access to
142 our CVS repository.
143 </Para>
144
145 <Para>
146 All the <Literal>fptools</Literal> source code is held in a CVS repository. CVS is a
147 pretty good source-code control system, and best of all it works over
148 the network.
149 </Para>
150
151 <Para>
152 The repository holds source code only. It holds no mechanically
153 generated files at all.  So if you check out a source tree from CVS
154 you will need to install every utility so that you can build all the
155 derived files from scratch.
156 </Para>
157
158 <Para>
159 More information about our CVS repository is available in the <ULink
160 URL="http://www.haskell.org/ghc/cvs-cheat-sheet.html" >FPTools CVS
161 Cheat Sheet</ULink >.
162 </Para>
163 </ListItem></VarListEntry>
164 </VariableList>
165 </Para>
166
167 <Para>
168 If you are going to do any building from sources (either from a source
169 distribution or the CVS repository) then you need to read all of this
170 manual in detail.
171 </Para>
172
173 </Sect1>
174
175 <Sect1>
176 <Title>Things to check before you start typing</Title>
177
178 <Para>
179 Here's a list of things to check before you get started.
180
181 <OrderedList>
182 <ListItem>
183
184 <Para>
185 <IndexTerm><Primary>Disk space needed</Primary></IndexTerm>Disk space needed: About 30MB (five hamburgers' worth) of disk space
186 for the most basic binary distribution of GHC; more for some
187 platforms, e.g., Alphas.  An extra ``bundle'' (e.g., concurrent
188 Haskell libraries) might take you to 8&ndash;10 hamburgers.
189
190 You'll need over 100MB (say, 20 hamburgers' worth) if you need to
191 build the basic stuff from scratch.
192
193
194 All of the above are <Emphasis>estimates</Emphasis> of disk-space needs. (I don't yet
195 know the disk requirements for the non-GHC tools).
196
197 </Para>
198 </ListItem>
199 <ListItem>
200
201 <Para>
202 Use an appropriate machine, compilers, and things.
203
204 SPARC boxes, and PCs running Linux, FreeBSD, NetBSD, or Solaris are
205 all fully supported.  Win32 and HP boxes are in pretty good shape.
206 DEC Alphas running OSF/1, Linux or some BSD variant, MIPS and AIX
207 boxes will need some minimal porting effort before they work (as of
208 4.06).  <Xref LinkEnd="sec-port-info"> gives the full run-down on
209 ports or lack thereof.
210
211 </Para>
212 </ListItem>
213 <ListItem>
214
215 <Para>
216  Be sure that the ``pre-supposed'' utilities are installed.
217 <Xref LinkEnd="sec-pre-supposed"> elaborates.
218
219 </Para>
220 </ListItem>
221 <ListItem>
222
223 <Para>
224  If you have any problem when building or installing the Glasgow
225 tools, please check the ``known pitfalls'' (<Xref
226 LinkEnd="sec-build-pitfalls">).  Also check the FAQ for the version
227 you're building, which should be available from the relevant download
228 page on the <ULink URL="http://www.haskell.org/ghc/" >GHC web
229 site</ULink>.
230
231 <IndexTerm><Primary>known bugs</Primary></IndexTerm>
232 <IndexTerm><Primary>bugs, known</Primary></IndexTerm>
233
234 If you feel there is still some shortcoming in our procedure or
235 instructions, please report it.
236
237 For GHC, please see the bug-reporting section of the GHC Users' Guide
238 (separate document), to maximise the usefulness of your report.
239 <IndexTerm><Primary>bugs, reporting</Primary></IndexTerm>
240
241 If in doubt, please send a message to
242 <Email>glasgow-haskell-bugs@haskell.org</Email>.
243 <IndexTerm><Primary>bugs, mailing list</Primary></IndexTerm>
244 </Para>
245 </ListItem>
246
247 </OrderedList>
248
249 </Para>
250
251 </Sect1>
252
253 <Sect1 id="sec-port-info">
254 <Title>What machines the Glasgow tools run on
255 </Title>
256
257 <Para>
258 <IndexTerm><Primary>ports, GHC</Primary></IndexTerm>
259 <IndexTerm><Primary>GHC ports</Primary></IndexTerm>
260 <IndexTerm><Primary>supported platforms</Primary></IndexTerm>
261 <IndexTerm><Primary>platforms, supported</Primary></IndexTerm>
262 The main question is whether or not the Haskell compiler (GHC) runs on
263 your platform.
264 </Para>
265
266 <Para>
267 A ``platform'' is a architecture/manufacturer/operating-system
268 combination, such as <Literal>sparc-sun-solaris2</Literal>.  Other common ones are
269 <Literal>alpha-dec-osf2</Literal>, <Literal>hppa1.1-hp-hpux9</Literal>, <Literal>i386-unknown-linux</Literal>,
270 <Literal>i386-unknown-solaris2</Literal>, <Literal>i386-unknown-freebsd</Literal>,
271 <Literal>i386-unknown-cygwin32</Literal>, <Literal>m68k-sun-sunos4</Literal>, <Literal>mips-sgi-irix5</Literal>,
272 <Literal>sparc-sun-sunos4</Literal>, <Literal>sparc-sun-solaris2</Literal>, <Literal>powerpc-ibm-aix</Literal>.
273 </Para>
274
275 <Para>
276 Bear in mind that certain ``bundles'', e.g. parallel Haskell, may not
277 work on all machines for which basic Haskell compiling is supported.
278 </Para>
279
280 <Para>
281 Some libraries may only work on a limited number of platforms; for
282 example, a sockets library is of no use unless the operating system
283 supports the underlying BSDisms.
284 </Para>
285
286 <Sect2>
287 <Title>What platforms the Haskell compiler (GHC) runs on</Title>
288
289 <Para>
290 <IndexTerm><Primary>fully-supported platforms</Primary></IndexTerm>
291 <IndexTerm><Primary>native-code generator</Primary></IndexTerm>
292 <IndexTerm><Primary>registerised ports</Primary></IndexTerm>
293 <IndexTerm><Primary>unregisterised ports</Primary></IndexTerm>
294 The GHC hierarchy of Porting Goodness: (a)&nbsp;Best is a native-code
295 generator; (b)&nbsp;next best is a ``registerised''
296 port; (c)&nbsp;the bare minimum is an ``unregisterised'' port.
297 (``Unregisterised'' is so terrible that we won't say more about it).
298 </Para>
299
300 <Para>
301 The native code generator is currently non-functional (as of GHC
302 version 4.06), but we're actively working on getting it going again.
303 </Para>
304
305 <Para>
306 We use Sparcs running Solaris 2.7 and x86 boxes running FreeBSD and
307 Linux, so those are the best supported platforms, unsurprisingly.
308 </Para>
309
310 <Para>
311 Here's everything that's known about GHC ports.  We identify platforms
312 by their ``canonical'' CPU/Manufacturer/OS triple.
313 </Para>
314
315 <Para>
316 <VariableList>
317
318 <VarListEntry>
319 <Term>alpha-dec-{osf,linux,freebsd,openbsd,netbsd}:</Term>
320 <IndexTerm><Primary>alpha-dec-osf</Primary></IndexTerm>
321 <IndexTerm><Primary>alpha-dec-linux</Primary></IndexTerm>
322 <IndexTerm><Primary>alpha-dec-freebsd</Primary></IndexTerm>
323 <IndexTerm><Primary>alpha-dec-openbsd</Primary></IndexTerm>
324 <IndexTerm><Primary>alpha-dec-netbsd</Primary></IndexTerm>
325 <ListItem>
326
327 <Para>
328 Currently non-working.  The last working version (osf[1-3]) is GHC
329 3.02.  A small amount of porting effort will be required to get Alpha
330 support into GHC 4.xx, but we don't have easy access to machines right
331 now, and there hasn't been a massive demand for support, so Alphas
332 remain unsupported for the time being.  Please get in touch if you
333 either need Alpha support and/or can provide access to boxes.
334 </Para>
335
336 </ListItem></VarListEntry>
337 <VarListEntry>
338 <Term>sparc-sun-sunos4:</Term>
339 <IndexTerm><Primary>sparc-sun-sunos4</Primary></IndexTerm>
340 <ListItem>
341
342 <Para>
343 Probably works with minor tweaks, hasn't been tested for a while.
344 </Para>
345
346 </ListItem></VarListEntry>
347 <VarListEntry>
348 <Term>sparc-sun-solaris2:</Term>
349 <IndexTerm><Primary>sparc-sun-solaris2</Primary></IndexTerm>
350 <ListItem>
351
352 <Para>
353 Fully supported, including native-code generator.
354 </Para>
355
356 </ListItem></VarListEntry>
357 <VarListEntry>
358 <Term>hppa1.1-hp-hpux (HP-PA boxes running HPUX 9.x)</Term>
359 <IndexTerm><Primary>hppa1.1-hp-hpux</Primary></IndexTerm>
360 <ListItem>
361
362 <Para>
363 Works registerised.  No native-code generator.
364 </Para>
365
366 </ListItem></VarListEntry>
367 <VarListEntry>
368 <Term>i386-unknown-linux (PCs running Linux&mdash;ELF binary format):</Term>
369 <IndexTerm><Primary>i386-*-linux</Primary></IndexTerm>
370 <ListItem>
371
372 <Para>
373 GHC works registerised.  You <Emphasis>must</Emphasis> have GCC 2.7.x
374 or later.  NOTE about <literal>glibc</literal> versions: GHC binaries
375 built on a system running <literal>glibc 2.0</literal> won't work on a
376 system running <literal>glibc 2.1</literal>, and vice version.  In
377 general, don't expect compatibility between <literal>glibc</literal>
378 versions, even if the shared library version hasn't changed.
379 </Para>
380
381 </ListItem></VarListEntry>
382 <VarListEntry>
383 <Term>i386-unknown-{freebsd,netbsd,openbsd) (PCs running FreeBSD 2.2
384 or higher, NetBSD, and possibly OpenBSD):</Term>
385 <IndexTerm><Primary>i386-unknown-freebsd</Primary></IndexTerm> 
386 <IndexTerm><Primary>i386-unknown-netbsd</Primary></IndexTerm> 
387 <IndexTerm><Primary>i386-unknown-openbsd</Primary></IndexTerm> 
388 <ListItem>
389
390 <Para>
391 GHC works registerised.  These systems provide ready-built packages of
392 GHC, so if you just need binaries you're better off just installing
393 the package.
394 </Para>
395
396 </ListItem></VarListEntry>
397 <VarListEntry>
398 <Term>i386-unknown-cygwin32:</Term>
399 <IndexTerm><Primary>i386-unknown-cygwin32</Primary></IndexTerm>
400 <ListItem>
401
402 <Para>
403 Fully supported under Win9x/NT, including a native code
404 generator. Requires the <Literal>cygwin32</Literal> compatibility
405 library and a healthy collection of GNU tools (i.e., gcc, GNU ld, bash
406 etc.).
407 </Para>
408
409 </ListItem></VarListEntry>
410 <VarListEntry>
411 <Term>mips-sgi-irix5:</Term>
412 <IndexTerm><Primary>mips-sgi-irix[5-6]</Primary></IndexTerm>
413 <ListItem>
414
415 <Para>
416 Port currently doesn't work, needs some minimal porting effort.  As
417 usual, we don't have access to machines and there hasn't been an
418 overwhelming demand for this port, but feel free to get in touch.
419 </Para>
420 </ListItem></VarListEntry>
421
422 <VarListEntry>
423 <Term>powerpc-ibm-aix:</Term>
424 <ListItem>
425 <Para>
426 <IndexTerm><Primary>powerpc-ibm-aix</Primary></IndexTerm>
427 Port currently doesn't work, needs some minimal porting effort.  As
428 usual, we don't have access to machines and there hasn't been an
429 overwhelming demand for this port, but feel free to get in touch.
430 </Para>
431 </ListItem></VarListEntry>
432
433 </VariableList>
434 </Para>
435
436 <para>
437 Various other systems have had GHC ported to them in the distant past,
438 including various Motorola 68k boxes.  The 68k support still remains,
439 but porting to one of these systems will certainly be a non-trivial
440 task.
441 </para>
442
443 </Sect2>
444
445 <Sect2>
446 <Title>What machines the other tools run on</Title>
447
448 <Para>
449 Unless you hear otherwise, the other tools work if GHC works.
450 </Para>
451
452 </Sect2>
453
454 </Sect1>
455
456
457 <Sect1 id="sec-pre-supposed">
458 <Title>Installing pre-supposed utilities
459
460 <IndexTerm><Primary>pre-supposed utilities</Primary></IndexTerm>
461 <IndexTerm><Primary>utilities, pre-supposed</Primary></IndexTerm></Title>
462
463 <Para>
464 Here are the gory details about some utility programs you may need;
465 <Command>perl</Command>, <Command>gcc</Command> and
466 <command>happy</command> are the only important
467 ones. (PVM<IndexTerm><Primary>PVM</Primary></IndexTerm> is important
468 if you're going for Parallel Haskell.)  The
469 <Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm>
470 script will tell you if you are missing something.
471 </Para>
472
473 <Para>
474 <VariableList>
475
476 <VarListEntry>
477 <Term>Perl:</Term>
478 <IndexTerm><Primary>pre-supposed: Perl</Primary></IndexTerm>
479 <IndexTerm><Primary>Perl, pre-supposed</Primary></IndexTerm>
480 <ListItem>
481 <Para>
482 <Emphasis>You have to have Perl to proceed!</Emphasis> Perl is a
483 language quite good for doing shell-scripty tasks that involve lots of
484 text processing.  It is pretty easy to install.
485 </Para>
486
487 <Para>
488 Perl&nbsp;5 is required.  For Win32 platforms, we strongly suggest you
489 pick up a port of Perl&nbsp;5 for <Literal>cygwin32</Literal>, as the
490 common Hip/ActiveWare port of Perl is Not Cool Enough for our
491 purposes.
492 </Para>
493
494 <Para>
495 Perl should be put somewhere so that it can be invoked by the
496 <Literal>&num;!</Literal> script-invoking mechanism. (I believe
497 <Filename>/usr/bin/perl</Filename> is preferred; we use
498 <Filename>/usr/local/bin/perl</Filename> at Glasgow.)  The full
499 pathname should may need to be less than 32 characters long on some
500 systems.
501 </Para>
502
503 </ListItem></VarListEntry>
504 <VarListEntry>
505 <Term>GNU C (<Command>gcc</Command>):</Term>
506 <IndexTerm><Primary>pre-supposed: GCC (GNU C compiler)</Primary></IndexTerm>
507 <IndexTerm><Primary>GCC (GNU C compiler), pre-supposed</Primary></IndexTerm>
508 <ListItem>
509
510 <Para>
511 We recommend using GCC version 2.95.2 on all platforms.  Failing that,
512 version 2.7.2 is stable on most platforms.  Earlier versions of GCC
513 can be assumed not to work, and versions in between 2.7.2 and 2.95.2
514 (including <command>egcs</command>) have varying degrees of stability
515 depending on the platform.
516 </Para>
517
518 <Para>
519 If your GCC dies with ``internal error'' on some GHC source file,
520 please let us know, so we can report it and get things improved.
521 (Exception: on iX86 boxes&mdash;you may need to fiddle with GHC's
522 <Option>-monly-N-regs</Option> option; see the User's Guide)
523 </Para>
524 </ListItem></VarListEntry>
525
526 <varlistentry>
527 <term>Happy:</term>
528 <indexterm><primary>Happy</primary></indexterm>
529 <listitem>
530 <para>Happy is a parser generator tool for Haskell, and is used to
531 generate GHC's parsers.  Happy is written in Haskell, and is a project
532 in the CVS repository (<literal>fptools/happy</literal>).  It can be
533 built from source, but bear in mind that you'll need GHC installed in
534 order to build it.  To avoid the chicken/egg problem, install a binary
535 distribtion of either Happy or GHC to get started.  Happy
536 distributions are available from <ulink
537 url="http://www.haskell.org/happy/">Happy's Web Page</ulink>.
538 </para>
539 </listitem>
540 </varlistentry>
541
542 <VarListEntry>
543 <Term>Autoconf:</Term>
544 <IndexTerm><Primary>pre-supposed: Autoconf</Primary></IndexTerm>
545 <IndexTerm><Primary>Autoconf, pre-supposed</Primary></IndexTerm>
546 <ListItem>
547 <Para>
548 GNU Autoconf is needed if you intend to build from the CVS sources, it
549 is <Emphasis>not</Emphasis> needed if you just intend to build a
550 standard source distribution.
551 </Para>
552
553 <Para>
554 Autoconf builds the <Command>configure</Command> script from
555 <Filename>configure.in</Filename> and <Filename>aclocal.m4</Filename>.
556 If you modify either of these files, you'll need Autoconf to rebuild
557 <Filename>configure</Filename>.
558 </Para>
559
560 </ListItem></VarListEntry>
561 <VarListEntry>
562 <Term><Command>sed</Command></Term>
563 <IndexTerm><Primary>pre-supposed: sed</Primary></IndexTerm>
564 <IndexTerm><Primary>sed, pre-supposed</Primary></IndexTerm>
565 <ListItem>
566 <Para>
567 You need a working <Command>sed</Command> if you are going to build
568 from sources.  The build-configuration stuff needs it.  GNU sed
569 version 2.0.4 is no good!  It has a bug in it that is tickled by the
570 build-configuration.  2.0.5 is OK. Others are probably OK too
571 (assuming we don't create too elaborate configure scripts.)
572 </Para>
573 </ListItem></VarListEntry>
574 </VariableList>
575 </Para>
576
577 <Para>
578 One <Literal>fptools</Literal> project is worth a quick note at this
579 point, because it is useful for all the others:
580 <Literal>glafp-utils</Literal> contains several utilities which aren't
581 particularly Glasgow-ish, but Occasionally Indispensable.  Like
582 <Command>lndir</Command> for creating symbolic link trees.
583 </Para>
584
585 <Sect2 id="pre-supposed-gph-tools">
586 <Title>Tools for building parallel GHC (GPH)
587 </Title>
588
589 <Para>
590 <VariableList>
591
592 <VarListEntry>
593 <Term>PVM version 3:</Term>
594 <IndexTerm><Primary>pre-supposed: PVM3 (Parallel Virtual Machine)</Primary></IndexTerm>
595 <IndexTerm><Primary>PVM3 (Parallel Virtual Machine), pre-supposed</Primary></IndexTerm>
596 <ListItem>
597
598 <Para>
599 PVM is the Parallel Virtual Machine on which Parallel Haskell programs
600 run.  (You only need this if you plan to run Parallel Haskell.
601 Concurent Haskell, which runs concurrent threads on a uniprocessor
602 doesn't need it.)  Underneath PVM, you can have (for example) a
603 network of workstations (slow) or a multiprocessor box (faster).
604 </Para>
605
606 <Para>
607 The current version of PVM is 3.3.11; we use 3.3.7.  It is readily
608 available on the net; I think I got it from
609 <Literal>research.att.com</Literal>, in <Filename>netlib</Filename>.
610 </Para>
611
612 <Para>
613 A PVM installation is slightly quirky, but easy to do.  Just follow
614 the <Filename>Readme</Filename> instructions.
615 </Para>
616 </ListItem></VarListEntry>
617 <VarListEntry>
618 <Term><Command>bash</Command>:</Term>
619 <IndexTerm><Primary>bash, presupposed (Parallel Haskell only)</Primary></IndexTerm>
620 <ListItem>
621 <Para>
622 Sadly, the <Command>gr2ps</Command> script, used to convert ``parallelism profiles''
623 to PostScript, is written in Bash (GNU's Bourne Again shell).
624 This bug will be fixed (someday).
625 </Para>
626 </ListItem></VarListEntry>
627 </VariableList>
628 </Para>
629
630 </Sect2>
631
632 <Sect2 id="pre-supposed-doc-tools">
633 <Title>Tools for building the Documentation
634 </Title>
635
636 <Para>
637 The following additional tools are required if you want to format the
638 documentation that comes with the <Literal>fptools</Literal> projects:
639 </Para>
640
641 <Para>
642 <VariableList>
643
644 <VarListEntry>
645 <Term>DocBook:</Term>
646 <IndexTerm><Primary>pre-supposed: DocBook</Primary></IndexTerm>
647 <IndexTerm><Primary>DocBook, pre-supposed</Primary></IndexTerm>
648 <ListItem>
649 <Para>
650 All our documentation is written in SGML, using the DocBook DTD and
651 processed using the <ULink
652 URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
653 tools</ULink>, which is the most shrink-wrapped SGML suite that we
654 could find. You need all the RPMs except for psgml (i.e. docbook, jade,
655 jadetex, sgmlcommon and stylesheets). Unfortunately, it's only packaged as
656 RPMs. You can use it to generate HTML, DVI (and hence PDF and Postscript)
657 and RTF from any DocBook source file (including this manual). N.B. The
658 <Emphasis>Cygnus</Emphasis> version of the tools is assumed. Others, such as
659 the SuSE version, may not work. Note that most of these RPMs are
660 architecture neutral, so are likely to be found in a <file>noarch</file>
661 directory.
662 </Para>
663 </ListItem></VarListEntry>
664 <VarListEntry>
665 <Term>TeX:</Term>
666 <IndexTerm><Primary>pre-supposed: TeX</Primary></IndexTerm>
667 <IndexTerm><Primary>TeX, pre-supposed</Primary></IndexTerm>
668 <ListItem>
669 <Para>
670 A decent TeX distribution is required if you want to produce printable
671 documentation.  We recomment teTeX, which includes just about
672 everything you need.
673 </Para>
674 </ListItem></VarListEntry>
675 </VariableList>
676 </Para>
677
678 </Sect2>
679
680 <Sect2 id="pre-supposed-other-tools">
681 <Title>Other useful tools
682 </Title>
683
684 <VariableList>
685 <VarListEntry>
686 <Term>Flex:</Term>
687 <IndexTerm><Primary>pre-supposed: flex</Primary></IndexTerm> 
688 <IndexTerm><Primary>flex, pre-supposed</Primary></IndexTerm>
689 <ListItem>
690
691 <Para>
692 This is a quite-a-bit-better-than-Lex lexer.  Used to build a couple
693 of utilities in <Literal>glafp-utils</Literal>.  Depending on your
694 operating system, the supplied <Command>lex</Command> may or may not
695 work; you should get the GNU version.
696 </Para>
697 </ListItem></VarListEntry>
698 </VariableList>
699
700 </Sect2>
701
702 </Sect1>
703
704 <Sect1 id="sec-building-from-source">
705 <Title>Building from source
706
707 <IndexTerm><Primary>Building from source</Primary></IndexTerm>
708 <IndexTerm><Primary>Source, building from</Primary></IndexTerm></Title>
709
710 <Para>
711 You've been rash enough to want to build some of
712 the Glasgow Functional Programming tools (GHC, Happy,
713 nofib, etc.) from source.  You've slurped the source,
714 from the CVS repository or from a source distribution, and
715 now you're sitting looking at a huge mound of bits, wondering
716 what to do next.
717 </Para>
718
719 <Para>
720 Gingerly, you type <Command>make</Command>.  Wrong already!
721 </Para>
722
723 <Para>
724 This rest of this guide is intended for duffers like me, who aren't
725 really interested in Makefiles and systems configurations, but who
726 need a mental model of the interlocking pieces so that they can make
727 them work, extend them consistently when adding new software, and lay
728 hands on them gently when they don't work.
729 </Para>
730
731 <Sect2 id="sec-source-tree">
732 <Title>Your source tree
733 </Title>
734
735 <Para>
736 The source code is held in your <Emphasis>source tree</Emphasis>.
737 The root directory of your source tree <Emphasis>must</Emphasis>
738 contain the following directories and files:
739 </Para>
740
741 <Para>
742
743 <ItemizedList>
744 <ListItem>
745
746 <Para>
747 <Filename>Makefile</Filename>: the root Makefile.
748 </Para>
749 </ListItem>
750 <ListItem>
751
752 <Para>
753 <Filename>mk/</Filename>: the directory that contains the
754 main Makefile code, shared by all the
755 <Literal>fptools</Literal> software.
756 </Para>
757 </ListItem>
758 <ListItem>
759
760 <Para>
761  <Filename>configure.in</Filename>, <Filename>config.sub</Filename>, <Filename>config.guess</Filename>:
762 these files support the configuration process.
763 </Para>
764 </ListItem>
765 <ListItem>
766
767 <Para>
768  <Filename>install-sh</Filename>.
769 </Para>
770 </ListItem>
771
772 </ItemizedList>
773
774 </Para>
775
776 <Para>
777 All the other directories are individual <Emphasis>projects</Emphasis> of the
778 <Literal>fptools</Literal> system&mdash;for example, the Glasgow Haskell Compiler
779 (<Literal>ghc</Literal>), the Happy parser generator (<Literal>happy</Literal>), the <Literal>nofib</Literal> benchmark
780 suite, and so on.  You can have zero or more of these.  Needless to
781 say, some of them are needed to build others.
782 </Para>
783
784 <Para>
785 The important thing to remember is that even if you want only one
786 project (<Literal>happy</Literal>, say), you must have a source tree whose root
787 directory contains <Filename>Makefile</Filename>, <Filename>mk/</Filename>, <Filename>configure.in</Filename>, and the
788 project(s) you want (<Filename>happy/</Filename> in this case).  You cannot get by with
789 just the <Filename>happy/</Filename> directory.
790 </Para>
791
792 </Sect2>
793
794 <Sect2>
795 <Title>Build trees
796 <IndexTerm><Primary>build trees</Primary></IndexTerm>
797 <IndexTerm><Primary>link trees, for building</Primary></IndexTerm></Title>
798
799 <Para>
800 While you can build a system in the source tree, we don't recommend it.
801 We often want to build multiple versions of our software
802 for different architectures, or with different options (e.g. profiling).
803 It's very desirable to share a single copy of the source code among
804 all these builds.
805 </Para>
806
807 <Para>
808 So for every source tree we have zero or more <Emphasis>build trees</Emphasis>.  Each
809 build tree is initially an exact copy of the source tree, except that
810 each file is a symbolic link to the source file, rather than being a
811 copy of the source file.  There are ``standard'' Unix utilities that
812 make such copies, so standard that they go by different names:
813 <Command>lndir</Command><IndexTerm><Primary>lndir</Primary></IndexTerm>, <Command>mkshadowdir</Command><IndexTerm><Primary>mkshadowdir</Primary></IndexTerm> are two (If you
814 don't have either, the source distribution includes sources for the
815 X11 <Command>lndir</Command>&mdash;check out <Filename>fptools/glafp-utils/lndir</Filename>). See <Xref LinkEnd="sec-storysofar"> for a typical invocation.
816 </Para>
817
818 <Para>
819 The build tree does not need to be anywhere near the source tree in
820 the file system.  Indeed, one advantage of separating the build tree
821 from the source is that the build tree can be placed in a
822 non-backed-up partition, saving your systems support people from
823 backing up untold megabytes of easily-regenerated, and
824 rapidly-changing, gubbins.  The golden rule is that (with a single
825 exception&mdash;<XRef LinkEnd="sec-build-config">)
826 <Emphasis>absolutely everything in the build tree is either a symbolic
827 link to the source tree, or else is mechanically generated</Emphasis>.
828 It should be perfectly OK for your build tree to vanish overnight; an
829 hour or two compiling and you're on the road again.
830 </Para>
831
832 <Para>
833 You need to be a bit careful, though, that any new files you create
834 (if you do any development work) are in the source tree, not a build tree!
835 </Para>
836
837 <Para>
838 Remember, that the source files in the build tree are <Emphasis>symbolic
839 links</Emphasis> to the files in the source tree.  (The build tree soon
840 accumulates lots of built files like <Filename>Foo.o</Filename>, as well.)  You
841 can <Emphasis>delete</Emphasis> a source file from the build tree without affecting
842 the source tree (though it's an odd thing to do).  On the other hand,
843 if you <Emphasis>edit</Emphasis> a source file from the build tree, you'll edit the
844 source-tree file directly.  (You can set up Emacs so that if you edit
845 a source file from the build tree, Emacs will silently create an
846 edited copy of the source file in the build tree, leaving the source
847 file unchanged; but the danger is that you think you've edited the
848 source file whereas actually all you've done is edit the build-tree
849 copy.  More commonly you do want to edit the source file.)
850 </Para>
851
852 <Para>
853 Like the source tree, the top level of your build tree must be (a
854 linked copy of) the root directory of the <Literal>fptools</Literal> suite.  Inside
855 Makefiles, the root of your build tree is called
856 <Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant><IndexTerm><Primary>FPTOOLS&lowbar;TOP</Primary></IndexTerm>.  In the rest of this document path
857 names are relative to <Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant> unless otherwise stated.  For
858 example, the file <Filename>ghc/mk/target.mk</Filename> is actually
859 <Filename><Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>/ghc/mk/target.mk</Filename>.
860 </Para>
861
862 </Sect2>
863
864 <Sect2 id="sec-build-config">
865 <Title>Getting the build you want
866 </Title>
867
868 <Para>
869 When you build <Literal>fptools</Literal> you will be compiling code on a particular
870 <Emphasis>host platform</Emphasis>, to run on a particular <Emphasis>target platform</Emphasis>
871 (usually the same as the host platform)<IndexTerm><Primary>platform</Primary></IndexTerm>.  The
872 difficulty is that there are minor differences between different
873 platforms; minor, but enough that the code needs to be a bit different
874 for each.  There are some big differences too: for a different
875 architecture we need to build GHC with a different native-code
876 generator.
877 </Para>
878
879 <Para>
880 There are also knobs you can turn to control how the <Literal>fptools</Literal>
881 software is built.  For example, you might want to build GHC optimised
882 (so that it runs fast) or unoptimised (so that you can compile it fast
883 after you've modified it.  Or, you might want to compile it with
884 debugging on (so that extra consistency-checking code gets included)
885 or off.  And so on.
886 </Para>
887
888 <Para>
889 All of this stuff is called the <Emphasis>configuration</Emphasis> of your build.
890 You set the configuration using a three-step process.
891 <VariableList>
892
893 <VarListEntry>
894 <Term>Step 1: get ready for configuration.</Term>
895 <ListItem>
896 <Para>
897 Change directory to
898 <Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant> and issue the command <Command>autoconf</Command><IndexTerm><Primary>autoconf</Primary></IndexTerm> (with
899 no arguments). This GNU program converts <Filename><Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>/configure.in</Filename>
900 to a shell script called <Filename><Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>/configure</Filename>.
901 </Para>
902
903 <para>
904 Some projects, including GHC, have their own configure script.  If
905 there's an
906 <Constant>&dollar;(FPTOOLS&lowbar;TOP)/&lt;project&gt;/configure.in</Constant>,
907 then you need to run <command>autoconf</command> in that directory too.
908 </para>
909
910 <Para>
911 Both these steps are completely platform-independent; they just mean
912 that the human-written file (<Filename>configure.in</Filename>) can be short, although
913 the resulting shell script, <Command>configure</Command>, and <Filename>mk/config.h.in</Filename>, are
914 long.
915 </Para>
916
917 <Para>
918 In case you don't have <Command>autoconf</Command> we distribute the results,
919 <Command>configure</Command>, and <Filename>mk/config.h.in</Filename>, with the source distribution.  They
920 aren't kept in the repository, though.
921 </Para>
922 </ListItem></VarListEntry>
923 <VarListEntry>
924 <Term>Step 2: system configuration.</Term>
925 <ListItem>
926 <Para>
927 Runs the newly-created <Command>configure</Command> script, thus:
928
929 <ProgramListing>
930 ./configure
931 </ProgramListing>
932
933 <Command>configure</Command>'s mission is to scurry round your
934 computer working out what architecture it has, what operating system,
935 whether it has the <Function>vfork</Function> system call, where
936 <Command>yacc</Command> is kept, whether <Command>gcc</Command> is
937 available, where various obscure <Literal>&num;include</Literal> files
938 are, whether it's a leap year, and what the systems manager had for
939 lunch.  It communicates these snippets of information in two ways:
940 </Para>
941
942 <Para>
943
944 <ItemizedList>
945 <ListItem>
946
947 <Para>
948  It translates <Filename>mk/config.mk.in</Filename><IndexTerm><Primary>config.mk.in</Primary></IndexTerm> to
949 <Filename>mk/config.mk</Filename><IndexTerm><Primary>config.mk</Primary></IndexTerm>, substituting for things between
950 ``<Literal>@</Literal>'' brackets.  So, ``<Literal>@HaveGcc@</Literal>'' will be replaced by
951 ``<Literal>YES</Literal>'' or ``<Literal>NO</Literal>'' depending on what <Command>configure</Command> finds.
952 <Filename>mk/config.mk</Filename> is included by every Makefile (directly or indirectly),
953 so the configuration information is thereby communicated to all
954 Makefiles.
955
956 </Para>
957 </ListItem>
958 <ListItem>
959
960 <Para>
961  It translates <Filename>mk/config.h.in</Filename><IndexTerm><Primary>config.h.in</Primary></IndexTerm> to
962 <Filename>mk/config.h</Filename><IndexTerm><Primary>config.h</Primary></IndexTerm>.  The latter is <Literal>&num;include</Literal>d by various C
963 programs, which can thereby make use of configuration information.
964
965 </Para>
966 </ListItem>
967
968 </ItemizedList>
969
970 </Para>
971
972 <Para>
973 <Command>configure</Command> caches the results of its run in <Filename>config.cache</Filename>.  Quite
974 often you don't want that; you're running <Command>configure</Command> a second time
975 because something has changed.  In that case, simply delete
976 <Filename>config.cache</Filename>.
977 </Para>
978 </ListItem></VarListEntry>
979 <VarListEntry>
980 <Term>Step 3: build configuration.</Term>
981 <ListItem>
982 <Para>
983 Next, you say how this build of <Literal>fptools</Literal> is to differ from the
984 standard defaults by creating a new file <Filename>mk/build.mk</Filename><IndexTerm><Primary>build.mk</Primary></IndexTerm>
985 <Emphasis>in the build tree</Emphasis>.  This file is the one and only file you edit
986 in the build tree, precisely because it says how this build differs
987 from the source.  (Just in case your build tree does die, you might
988 want to keep a private directory of <Filename>build.mk</Filename> files, and use a
989 symbolic link in each build tree to point to the appropriate one.)  So
990 <Filename>mk/build.mk</Filename> never exists in the source tree&mdash;you create one in
991 each build tree from the template.  We'll discuss what to put in it
992 shortly.  
993 </Para>
994 </ListItem></VarListEntry>
995 </VariableList>
996 </Para>
997
998 <Para>
999 And that's it for configuration. Simple, eh?
1000 </Para>
1001
1002 <Para>
1003 What do you put in your build-specific configuration file
1004 <Filename>mk/build.mk</Filename>?  <Emphasis>For almost all purposes all you will do is put
1005 make variable definitions that override those in</Emphasis> <Filename>mk/config.mk.in</Filename>.
1006 The whole point of <Filename>mk/config.mk.in</Filename>&mdash;and its derived counterpart
1007 <Filename>mk/config.mk</Filename>&mdash;is to define the build configuration. It is heavily
1008 commented, as you will see if you look at it.  So generally, what you
1009 do is look at <Filename>mk/config.mk.in</Filename>, and add definitions in <Filename>mk/build.mk</Filename>
1010 that override any of the <Filename>config.mk</Filename> definitions that you want to
1011 change.  (The override occurs because the main boilerplate file,
1012 <Filename>mk/boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>, includes <Filename>build.mk</Filename> after
1013 <Filename>config.mk</Filename>.)
1014 </Para>
1015
1016 <Para>
1017 For example, <Filename>config.mk.in</Filename> contains the definition:
1018 </Para>
1019
1020 <Para>
1021
1022 <ProgramListing>
1023 ProjectsToBuild = glafp-utils ghc hslibs
1024 </ProgramListing>
1025
1026 </Para>
1027
1028 <Para>
1029 The accompanying comment explains that this is the list of enabled
1030 projects; that is, if (after configuring) you type <Command>gmake all</Command> in
1031 <Constant>FPTOOLS&lowbar;TOP</Constant> three specified projects will be made.  If you want to
1032 add <Command>green-card</Command>, you can add this line to <Filename>build.mk</Filename>:
1033 </Para>
1034
1035 <Para>
1036
1037 <ProgramListing>
1038 ProjectsToBuild += green-card
1039 </ProgramListing>
1040
1041 </Para>
1042
1043 <Para>
1044 or, if you prefer,
1045 </Para>
1046
1047 <Para>
1048
1049 <ProgramListing>
1050 ProjectsToBuild = glafp-utils ghc green-card
1051 </ProgramListing>
1052
1053 </Para>
1054
1055 <Para>
1056 (GNU <Command>make</Command> allows existing definitions to have new text appended
1057 using the ``<Literal>+=</Literal>'' operator, which is quite a convenient feature.)
1058 </Para>
1059
1060 <Para>
1061 When reading <Filename>config.mk.in</Filename>, remember that anything between
1062 ``@...@'' signs is going to be substituted by <Command>configure</Command>
1063 later.  You <Emphasis>can</Emphasis> override the resulting definition if you want,
1064 but you need to be a bit surer what you are doing.  For example,
1065 there's a line that says: 
1066 </Para>
1067
1068 <Para>
1069
1070 <ProgramListing>
1071 YACC = @YaccCmd@
1072 </ProgramListing>
1073
1074 </Para>
1075
1076 <Para>
1077 This defines the Make variables <Constant>YACC</Constant> to the pathname for a <Command>yacc</Command> that
1078 <Command>configure</Command> finds somewhere.  If you have your own pet <Command>yacc</Command> you want
1079 to use instead, that's fine. Just add this line to <Filename>mk/build.mk</Filename>:
1080 </Para>
1081
1082 <Para>
1083
1084 <ProgramListing>
1085 YACC = myyacc
1086 </ProgramListing>
1087
1088 </Para>
1089
1090 <Para>
1091 You do not <Emphasis>have</Emphasis> to have a <Filename>mk/build.mk</Filename> file at all; if you
1092 don't, you'll get all the default settings from <Filename>mk/config.mk.in</Filename>.
1093 </Para>
1094
1095 <Para>
1096 You can also use <Filename>build.mk</Filename> to override anything that <Command>configure</Command> got
1097 wrong.  One place where this happens often is with the definition of
1098 <Constant>FPTOOLS&lowbar;TOP&lowbar;ABS</Constant>: this variable is supposed to be the canonical path
1099 to the top of your source tree, but if your system uses an automounter
1100 then the correct directory is hard to find automatically.  If you find
1101 that <Command>configure</Command> has got it wrong, just put the correct definition in
1102 <Filename>build.mk</Filename>.
1103 </Para>
1104
1105 </Sect2>
1106
1107 <Sect2 id="sec-storysofar">
1108 <Title>The story so far</Title>
1109
1110 <Para>
1111 Let's summarise the steps you need to carry to get yourself
1112 a fully-configured build tree from scratch.
1113 </Para>
1114
1115 <Para>
1116
1117 <OrderedList>
1118 <ListItem>
1119
1120 <Para>
1121  Get your source tree from somewhere (CVS repository or source
1122 distribution).  Say you call the root directory <Filename>myfptools</Filename> (it
1123 does not have to be called <Filename>fptools</Filename>).  Make sure that you have
1124 the essential files (see <XRef LinkEnd="sec-source-tree">).
1125
1126 </Para>
1127 </ListItem>
1128 <ListItem>
1129
1130 <Para>
1131  Use <Command>lndir</Command> or <Command>mkshadowdir</Command> to create a build tree.
1132
1133 <ProgramListing>
1134 cd myfptools
1135 mkshadowdir . /scratch/joe-bloggs/myfptools-sun4
1136 </ProgramListing>
1137
1138 (N.B. <Command>mkshadowdir</Command>'s first argument is taken relative to its second.) You probably want to give the build tree a name that
1139 suggests its main defining characteristic (in your mind at least),
1140 in case you later add others.
1141
1142 </Para>
1143 </ListItem>
1144 <ListItem>
1145
1146 <Para>
1147  Change directory to the build tree.  Everything is going
1148 to happen there now.
1149
1150 <ProgramListing>
1151 cd /scratch/joe-bloggs/myfptools-sun4
1152 </ProgramListing>
1153
1154 </Para>
1155 </ListItem>
1156 <ListItem>
1157
1158 <Para>
1159  Prepare for system configuration:
1160
1161 <ProgramListing>
1162 autoconf
1163 </ProgramListing>
1164
1165 (You can skip this step if you are starting from a source distribution,
1166 and you already have <Filename>configure</Filename> and <Filename>mk/config.h.in</Filename>.)
1167
1168 </Para>
1169 </ListItem>
1170 <ListItem>
1171
1172 <Para>
1173  Do system configuration:
1174
1175 <ProgramListing>
1176 ./configure
1177 </ProgramListing>
1178
1179
1180 </Para>
1181 </ListItem>
1182 <ListItem>
1183
1184 <Para>
1185  Create the file <Filename>mk/build.mk</Filename>, 
1186 adding definitions for your desired configuration options.
1187
1188 <ProgramListing>
1189 emacs mk/build.mk
1190 </ProgramListing>
1191
1192 </Para>
1193 </ListItem>
1194
1195 </OrderedList>
1196
1197 You can make subsequent changes to <Filename>mk/build.mk</Filename> as often 
1198 as you like.  You do not have to run any further configuration 
1199 programs to make these changes take effect.
1200 In theory you should, however, say <Command>gmake clean</Command>, <Command>gmake all</Command>,
1201 because configuration option changes could affect anything&mdash;but in practice you are likely to know what's affected.
1202 </Para>
1203
1204 </Sect2>
1205
1206 <Sect2>
1207 <Title>Making things</Title>
1208
1209 <Para>
1210 At this point you have made yourself a fully-configured build tree,
1211 so you are ready to start building real things.
1212 </Para>
1213
1214 <Para>
1215 The first thing you need to know is that 
1216 <Emphasis>you must use GNU <Command>make</Command>, usually called <Command>gmake</Command>, not standard Unix <Command>make</Command></Emphasis>.
1217 If you use standard Unix <Command>make</Command> you will get all sorts of error messages
1218 (but no damage) because the <Literal>fptools</Literal> <Command>Makefiles</Command> use GNU <Command>make</Command>'s facilities
1219 extensively.
1220 </Para>
1221
1222 </Sect2>
1223
1224 <Sect2 id="sec-standard-targets">
1225 <Title>Standard Targets
1226
1227 <IndexTerm><Primary>targets, standard makefile</Primary></IndexTerm>
1228 <IndexTerm><Primary>makefile targets</Primary></IndexTerm></Title>
1229
1230 <Para>
1231 In any directory you should be able to make the following:
1232 <VariableList>
1233
1234 <VarListEntry>
1235 <Term><Literal>boot</Literal>:</Term>
1236 <ListItem>
1237 <Para>
1238 does the one-off preparation required to get ready for the real work.
1239 Notably, it does <Command>gmake depend</Command> in all directories that contain
1240 programs.  It also builds the necessary tools for compilation to proceed.
1241 </Para>
1242
1243 <Para>
1244 You should say <Command>gmake boot</Command> right after configuring your build tree,
1245 but note that this is a one-off, i.e., there's no need to re-do
1246 <Command>gmake boot</Command> if you should re-configure your build tree at a later
1247 stage (no harm caused if you do though).
1248 </Para>
1249 </ListItem></VarListEntry>
1250 <VarListEntry>
1251 <Term><Literal>all</Literal>:</Term>
1252 <ListItem>
1253 <Para>
1254 makes all the final target(s) for this Makefile.
1255 Depending on which directory you are in a ``final target'' may be an
1256 executable program, a library archive, a shell script, or a Postscript
1257 file.  Typing <Command>gmake</Command> alone is generally the same as typing <Command>gmake all</Command>.
1258 </Para>
1259 </ListItem></VarListEntry>
1260 <VarListEntry>
1261 <Term><Literal>install</Literal>:</Term>
1262 <ListItem>
1263 <Para>
1264 installs the things built by <Literal>all</Literal>.  Where does it
1265 install them?  That is specified by
1266 <Filename>mk/config.mk.in</Filename>; you can override it in
1267 <Filename>mk/build.mk</Filename>, or by running
1268 <command>configure</command> with command-line arguments like
1269 <literal>--bindir=/home/simonpj/bin</literal>;  see <literal>./configure
1270 --help</literal> for the full details.
1271 </Para>
1272 </ListItem></VarListEntry>
1273 <VarListEntry>
1274 <Term><Literal>uninstall</Literal>:</Term>
1275 <ListItem>
1276 <Para>
1277 reverses the effect of <Literal>install</Literal>.
1278 </Para>
1279 </ListItem></VarListEntry>
1280
1281 <VarListEntry>
1282 <Term><Literal>clean</Literal>:</Term>
1283 <ListItem>
1284 <Para>
1285 Delete all files from the current directory that are normally
1286 created by building the program.  Don't delete the files that
1287 record the configuration. Also preserve files that could be made
1288 by building, but normally aren't because the distribution comes
1289 with them.</para>
1290 </ListItem></VarListEntry>
1291
1292 <varlistentry>
1293 <term><literal>distclean</literal>:</term>
1294 <listitem>
1295 <para>Delete all files from the current directory that are created by
1296 configuring or building the program. If you have unpacked the source
1297 and built the program without creating any other files, <literal>make
1298 distclean</literal> should leave only the files that were in the
1299 distribution.</para>
1300 </listitem>
1301 </varlistentry>
1302
1303 <varlistentry>
1304 <term><literal>mostlyclean</literal>:</term>
1305 <listitem>
1306 <para>Like <literal>clean</literal>, but may refrain from deleting a
1307 few files that people normally don't want to recompile.</para>
1308 </listitem>
1309 </varlistentry>
1310
1311 <VarListEntry>
1312 <Term><Literal>maintainer-clean</Literal>:</Term>
1313 <ListItem>
1314 <Para>
1315 Delete everything from the current directory that can be reconstructed
1316 with this Makefile.  This typically includes everything deleted by
1317 <literal>distclean</literal>, plus more: C source files produced by
1318 Bison, tags tables, Info files, and so on.</para>
1319
1320 <para>One exception, however: <literal>make maintainer-clean</literal>
1321 should not delete <filename>configure</filename> even if
1322 <filename>configure</filename> can be remade using a rule in the
1323 <filename>Makefile</filename>. More generally, <literal>make
1324 maintainer-clean</literal> should not delete anything that needs to
1325 exist in order to run <filename>configure</filename> and then begin to
1326 build the program.</para>
1327 </listitem>
1328 </varlistentry>
1329
1330 <VarListEntry>
1331 <Term><Literal>check</Literal>:</Term>
1332 <ListItem>
1333 <Para>
1334 run the test suite.
1335 </Para>
1336 </ListItem></VarListEntry>
1337 </VariableList>
1338 </Para>
1339
1340 <Para>
1341 All of these standard targets automatically recurse into
1342 sub-directories.  Certain other standard targets do not:
1343 </Para>
1344
1345 <Para>
1346 <VariableList>
1347
1348 <VarListEntry>
1349 <Term><Literal>configure</Literal>:</Term>
1350 <ListItem>
1351 <Para>
1352 is only available in the root directory
1353 <Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>; it has been discussed in <XRef LinkEnd="sec-build-config">.
1354 </Para>
1355 </ListItem></VarListEntry>
1356 <VarListEntry>
1357 <Term><Literal>depend</Literal>:</Term>
1358 <ListItem>
1359 <Para>
1360 make a <Filename>.depend</Filename> file in each directory that needs
1361 it. This <Filename>.depend</Filename> file contains mechanically-generated dependency
1362 information; for example, suppose a directory contains a Haskell 
1363 source module <Filename>Foo.lhs</Filename> which imports another module <Literal>Baz</Literal>.
1364 Then the generated <Filename>.depend</Filename> file will contain the dependency:
1365 </Para>
1366
1367 <Para>
1368
1369 <ProgramListing>
1370 Foo.o : Baz.hi
1371 </ProgramListing>
1372
1373 </Para>
1374
1375 <Para>
1376 which says that the object file <Filename>Foo.o</Filename> depends on the interface file
1377 <Filename>Baz.hi</Filename> generated by compiling module <Literal>Baz</Literal>.  The <Filename>.depend</Filename> file is
1378 automatically included by every Makefile.
1379 </Para>
1380 </ListItem></VarListEntry>
1381 <VarListEntry>
1382 <Term><Literal>binary-dist</Literal>:</Term>
1383 <ListItem>
1384 <Para>
1385 make a binary distribution.  This is the
1386 target we use to build the binary distributions of GHC and Happy.
1387 </Para>
1388 </ListItem></VarListEntry>
1389 <VarListEntry>
1390 <Term><Literal>dist</Literal>:</Term>
1391 <ListItem>
1392 <Para>
1393 make a source distribution.  You must be in a
1394 linked build tree to make this target.
1395 </Para>
1396 </ListItem></VarListEntry>
1397 </VariableList>
1398 </Para>
1399
1400 <Para>
1401 Most <Filename>Makefile</Filename>s have targets other than these.  You can discover them by looking in the <Filename>Makefile</Filename> itself.
1402 </Para>
1403
1404 </Sect2>
1405
1406 <sect2>
1407 <title>Using a project from the build tree</title>
1408 <para>
1409 If you want to build GHC (say) and just use it direct from the build
1410 tree without doing <literal>make install</literal> first, you can run
1411 the in-place driver script:
1412 <filename>ghc/driver/ghc-inplace</filename>.
1413 </para>
1414
1415 <para> Do <emphasis>NOT</emphasis> use
1416 <filename>ghc/driver/ghc</filename>, or
1417 <filename>ghc/driver/ghc-4.xx</filename>, as these are the scripts
1418 intended for installation, and contain hard-wired paths to the
1419 installed libraries, rather than the libraries in the build tree.
1420 </para>
1421
1422 <para>
1423 Happy can similarly be run from the build tree, using
1424 <filename>happy/src/happy-inplace</filename>.
1425 </para>
1426 </sect2>
1427
1428 <Sect2>
1429 <Title>Fast Making <IndexTerm><Primary>fastmake</Primary></IndexTerm>
1430 <IndexTerm><Primary>dependencies, omitting</Primary></IndexTerm>
1431 <IndexTerm><Primary>FAST, makefile
1432 variable</Primary></IndexTerm></Title>
1433
1434 <Para>
1435 Sometimes the dependencies get in the way: if you've made a small
1436 change to one file, and you're absolutely sure that it won't affect
1437 anything else, but you know that <Command>make</Command> is going to rebuild everything
1438 anyway, the following hack may be useful:
1439 </Para>
1440
1441 <Para>
1442
1443 <ProgramListing>
1444 gmake FAST=YES 
1445 </ProgramListing>
1446
1447 </Para>
1448
1449 <Para>
1450 This tells the make system to ignore dependencies and just build what
1451 you tell it to.  In other words, it's equivalent to temporarily
1452 removing the <Filename>.depend</Filename> file in the current directory (where
1453 <Command>mkdependHS</Command> and friends store their dependency information).
1454 </Para>
1455
1456 <Para>
1457 A bit of history: GHC used to come with a <Command>fastmake</Command> script that did
1458 the above job, but GNU make provides the features we need to do it
1459 without resorting to a script.  Also, we've found that fastmaking is
1460 less useful since the advent of GHC's recompilation checker (see the
1461 User's Guide section on "Separate Compilation").
1462 </Para>
1463
1464 </Sect2>
1465
1466 </Sect1>
1467
1468 <Sect1>
1469 <Title>The <Filename>Makefile</Filename> architecture
1470 <IndexTerm><Primary>makefile architecture</Primary></IndexTerm></Title>
1471
1472 <Para>
1473 <Command>make</Command> is great if everything works&mdash;you type <Command>gmake install</Command> and
1474 lo! the right things get compiled and installed in the right places.
1475 Our goal is to make this happen often, but somehow it often doesn't;
1476 instead some weird error message eventually emerges from the bowels of
1477 a directory you didn't know existed.
1478 </Para>
1479
1480 <Para>
1481 The purpose of this section is to give you a road-map to help you figure
1482 out what is going right and what is going wrong.
1483 </Para>
1484
1485 <Sect2>
1486 <Title>A small project</Title>
1487
1488 <Para>
1489 To get started, let us look at the <Filename>Makefile</Filename> for an imaginary small
1490 <Literal>fptools</Literal> project, <Literal>small</Literal>.  Each project in <Literal>fptools</Literal> has its own
1491 directory in <Constant>FPTOOLS&lowbar;TOP</Constant>, so the <Literal>small</Literal> project will have its own
1492 directory <Constant>FPOOLS&lowbar;TOP/small/</Constant>.  Inside the <Filename>small/</Filename> directory there
1493 will be a <Filename>Makefile</Filename>, looking something like this:
1494 </Para>
1495
1496 <Para>
1497 <IndexTerm><Primary>Makefile, minimal</Primary></IndexTerm>
1498
1499 <ProgramListing>
1500 #     Makefile for fptools project "small"
1501
1502 TOP = ..
1503 include $(TOP)/mk/boilerplate.mk
1504
1505 SRCS = $(wildcard *.lhs) $(wildcard *.c)
1506 HS_PROG = small
1507
1508 include $(TOP)/target.mk
1509 </ProgramListing>
1510
1511 </Para>
1512
1513 <Para>
1514 This <Filename>Makefile</Filename> has three sections:
1515 </Para>
1516
1517 <Para>
1518
1519 <OrderedList>
1520 <ListItem>
1521
1522 <Para>
1523  The first section includes
1524 <FOOTNOTE>
1525
1526 <Para>
1527 One of the most important
1528 features of GNU <Command>make</Command> that we use is the ability for a <Filename>Makefile</Filename> to
1529 include another named file, very like <Command>cpp</Command>'s <Literal>&num;include</Literal>
1530 directive.
1531 </Para>
1532
1533 </FOOTNOTE>
1534  a file of ``boilerplate'' code from the level
1535 above (which in this case will be
1536 <Filename><Constant>FPTOOLS&lowbar;TOP</Constant>/mk/boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm>).  As its name
1537 suggests, <Filename>boilerplate.mk</Filename> consists of a large quantity of standard
1538 <Filename>Makefile</Filename> code.  We discuss this boilerplate in more detail in
1539 <XRef LinkEnd="sec-boiler">.
1540 <IndexTerm><Primary>include, directive in Makefiles</Primary></IndexTerm>
1541 <IndexTerm><Primary>Makefile inclusion</Primary></IndexTerm>
1542
1543 Before the <Literal>include</Literal> statement, you must define the <Command>make</Command> variable
1544 <Constant>TOP</Constant><IndexTerm><Primary>TOP</Primary></IndexTerm> to be the directory containing the <Filename>mk</Filename> directory in
1545 which the <Filename>boilerplate.mk</Filename> file is.  It is <Emphasis>not</Emphasis> OK to simply say
1546
1547
1548 <ProgramListing>
1549 include ../mk/boilerplate.mk  # NO NO NO
1550 </ProgramListing>
1551
1552
1553 Why?  Because the <Filename>boilerplate.mk</Filename> file needs to know where it is, so
1554 that it can, in turn, <Literal>include</Literal> other files.  (Unfortunately, when an
1555 <Literal>include</Literal>d file does an <Literal>include</Literal>, the filename is treated relative to
1556 the directory in which <Command>gmake</Command> is being run, not the directory in
1557 which the <Literal>include</Literal>d sits.)  In general, <Emphasis>every file <Filename>foo.mk</Filename>
1558 assumes that <Filename><Constant>&dollar;(TOP)</Constant>/mk/foo.mk</Filename> refers to itself.</Emphasis> It is up to the
1559 <Filename>Makefile</Filename> doing the <Literal>include</Literal> to ensure this is the case.
1560
1561 Files intended for inclusion in other <Filename>Makefile</Filename>s are written to have
1562 the following property: <Emphasis>after <Filename>foo.mk</Filename> is <Literal>include</Literal>d, it leaves
1563 <Constant>TOP</Constant> containing the same value as it had just before the <Literal>include</Literal>
1564 statement</Emphasis>.  In our example, this invariant guarantees that the
1565 <Literal>include</Literal> for <Filename>target.mk</Filename> will look in the same directory as that for
1566 <Filename>boilerplate.mk</Filename>.
1567
1568 </Para>
1569 </ListItem>
1570 <ListItem>
1571
1572 <Para>
1573  The second section defines the following standard <Command>make</Command>
1574 variables: <Constant>SRCS</Constant><IndexTerm><Primary>SRCS</Primary></IndexTerm> (the source files from which is to be
1575 built), and <Constant>HS&lowbar;PROG</Constant><IndexTerm><Primary>HS&lowbar;PROG</Primary></IndexTerm> (the executable binary to be
1576 built).  We will discuss in more detail what the ``standard
1577 variables'' are, and how they affect what happens, in <XRef LinkEnd="sec-targets">.
1578
1579 The definition for <Constant>SRCS</Constant> uses the useful GNU <Command>make</Command> construct
1580 <Literal>&dollar;(wildcard&nbsp;$pat$)</Literal><IndexTerm><Primary>wildcard</Primary></IndexTerm>, which expands to a list of all
1581 the files matching the pattern <Literal>pat</Literal> in the current directory.  In
1582 this example, <Constant>SRCS</Constant> is set to the list of all the <Filename>.lhs</Filename> and <Filename>.c</Filename>
1583 files in the directory.  (Let's suppose there is one of each,
1584 <Filename>Foo.lhs</Filename> and <Filename>Baz.c</Filename>.)
1585
1586 </Para>
1587 </ListItem>
1588 <ListItem>
1589
1590 <Para>
1591  The last section includes a second file of standard code,
1592 called <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm>.  It contains the rules that tell
1593 <Command>gmake</Command> how to make the standard targets (<Xref LinkEnd="sec-standard-targets">).  Why, you ask,
1594 can't this standard code be part of <Filename>boilerplate.mk</Filename>?  Good question.
1595 We discuss the reason later, in <Xref LinkEnd="sec-boiler-arch">.
1596
1597 You do not <Emphasis>have</Emphasis> to <Literal>include</Literal> the <Filename>target.mk</Filename> file.  Instead, you
1598 can write rules of your own for all the standard targets.  Usually,
1599 though, you will find quite a big payoff from using the canned rules
1600 in <Filename>target.mk</Filename>; the price tag is that you have to understand what
1601 canned rules get enabled, and what they do (<Xref LinkEnd="sec-targets">).
1602
1603 </Para>
1604 </ListItem>
1605
1606 </OrderedList>
1607
1608 </Para>
1609
1610 <Para>
1611 In our example <Filename>Makefile</Filename>, most of the work is done by the two
1612 <Literal>include</Literal>d files.  When you say <Command>gmake all</Command>, the following things
1613 happen:
1614 </Para>
1615
1616 <Para>
1617
1618 <ItemizedList>
1619 <ListItem>
1620
1621 <Para>
1622  <Command>gmake</Command> figures out that the object files are <Filename>Foo.o</Filename> and
1623 <Filename>Baz.o</Filename>.
1624
1625 </Para>
1626 </ListItem>
1627 <ListItem>
1628
1629 <Para>
1630  It uses a boilerplate pattern rule to compile <Filename>Foo.lhs</Filename> to
1631 <Filename>Foo.o</Filename> using a Haskell compiler.  (Which one?  That is set in the
1632 build configuration.)
1633
1634 </Para>
1635 </ListItem>
1636 <ListItem>
1637
1638 <Para>
1639  It uses another standard pattern rule to compile <Filename>Baz.c</Filename> to
1640 <Filename>Baz.o</Filename>, using a C compiler.  (Ditto.)
1641
1642 </Para>
1643 </ListItem>
1644 <ListItem>
1645
1646 <Para>
1647  It links the resulting <Filename>.o</Filename> files together to make <Literal>small</Literal>,
1648 using the Haskell compiler to do the link step.  (Why not use <Command>ld</Command>?
1649 Because the Haskell compiler knows what standard libraries to link in.
1650 How did <Command>gmake</Command> know to use the Haskell compiler to do the link,
1651 rather than the C compiler?  Because we set the variable <Constant>HS&lowbar;PROG</Constant>
1652 rather than <Constant>C&lowbar;PROG</Constant>.)
1653
1654 </Para>
1655 </ListItem>
1656
1657 </ItemizedList>
1658
1659 </Para>
1660
1661 <Para>
1662 All <Filename>Makefile</Filename>s should follow the above three-section format.
1663 </Para>
1664
1665 </Sect2>
1666
1667 <Sect2>
1668 <Title>A larger project</Title>
1669
1670 <Para>
1671 Larger projects are usually structured into a number of sub-directories,
1672 each of which has its own <Filename>Makefile</Filename>.  (In very large projects, this
1673 sub-structure might be iterated recursively, though that is rare.)
1674 To give you the idea, here's part of the directory structure for
1675 the (rather large) GHC project:
1676 </Para>
1677
1678 <Para>
1679
1680 <Screen>
1681 $(FPTOOLS_TOP)/ghc/
1682   Makefile
1683   mk/
1684     boilerplate.mk
1685     rules.mk
1686    docs/
1687     Makefile
1688     ...source files for documentation...
1689    driver/
1690     Makefile
1691     ...source files for driver...
1692    compiler/
1693     Makefile
1694     parser/...source files for parser...
1695     renamer/...source files for renamer...
1696     ...etc...
1697 </Screen>
1698
1699 </Para>
1700
1701 <Para>
1702 The sub-directories <Filename>docs</Filename>, <Filename>driver</Filename>, <Filename>compiler</Filename>, and so on, each
1703 contains a sub-component of GHC, and each has its own <Filename>Makefile</Filename>.
1704 There must also be a <Filename>Makefile</Filename> in <Filename><Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>/ghc</Filename>.  It does most
1705 of its work by recursively invoking <Command>gmake</Command> on the <Filename>Makefile</Filename>s in the
1706 sub-directories.  We say that <Filename>ghc/Makefile</Filename> is a <Emphasis>non-leaf
1707 <Filename>Makefile</Filename></Emphasis>, because it does little except organise its children,
1708 while the <Filename>Makefile</Filename>s in the sub-directories are all <Emphasis>leaf
1709 <Filename>Makefile</Filename>s</Emphasis>.  (In principle the sub-directories might themselves
1710 contain a non-leaf <Filename>Makefile</Filename> and several sub-sub-directories, but
1711 that does not happen in GHC.)
1712 </Para>
1713
1714 <Para>
1715 The <Filename>Makefile</Filename> in <Filename>ghc/compiler</Filename> is considered a leaf <Filename>Makefile</Filename> even
1716 though the <Filename>ghc/compiler</Filename> has sub-directories, because these sub-directories
1717 do not themselves have <Filename>Makefile</Filename>s in them.  They are just used to structure
1718 the collection of modules that make up GHC, but all are managed by the
1719 single <Filename>Makefile</Filename> in <Filename>ghc/compiler</Filename>.
1720 </Para>
1721
1722 <Para>
1723 You will notice that <Filename>ghc/</Filename> also contains a directory <Filename>ghc/mk/</Filename>.  It
1724 contains GHC-specific <Filename>Makefile</Filename> boilerplate code.  More precisely:
1725 </Para>
1726
1727 <Para>
1728
1729 <ItemizedList>
1730 <ListItem>
1731
1732 <Para>
1733  <Filename>ghc/mk/boilerplate.mk</Filename> is included at the top of
1734 <Filename>ghc/Makefile</Filename>, and of all the leaf <Filename>Makefile</Filename>s in the
1735 sub-directories.  It in turn <Literal>include</Literal>s the main boilerplate file
1736 <Filename>mk/boilerplate.mk</Filename>.
1737
1738
1739 </Para>
1740 </ListItem>
1741 <ListItem>
1742
1743 <Para>
1744  <Filename>ghc/mk/target.mk</Filename> is <Literal>include</Literal>d at the bottom of
1745 <Filename>ghc/Makefile</Filename>, and of all the leaf <Filename>Makefile</Filename>s in the
1746 sub-directories.  It in turn <Literal>include</Literal>s the file <Filename>mk/target.mk</Filename>.
1747
1748 </Para>
1749 </ListItem>
1750
1751 </ItemizedList>
1752
1753 </Para>
1754
1755 <Para>
1756 So these two files are the place to look for GHC-wide customisation
1757 of the standard boilerplate.
1758 </Para>
1759
1760 </Sect2>
1761
1762 <Sect2 id="sec-boiler-arch">
1763 <Title>Boilerplate architecture
1764 <IndexTerm><Primary>boilerplate architecture</Primary></IndexTerm>
1765 </Title>
1766
1767 <Para>
1768 Every <Filename>Makefile</Filename> includes a <Filename>boilerplate.mk</Filename><IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm> file
1769 at the top, and <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> file at the bottom.  In
1770 this section we discuss what is in these files, and why there have to
1771 be two of them.  In general:
1772 </Para>
1773
1774 <Para>
1775
1776 <ItemizedList>
1777 <ListItem>
1778
1779 <Para>
1780  <Filename>boilerplate.mk</Filename> consists of:
1781
1782 <ItemizedList>
1783 <ListItem>
1784
1785 <Para>
1786  <Emphasis>Definitions of millions of <Command>make</Command> variables</Emphasis> that
1787 collectively specify the build configuration.  Examples:
1788 <Constant>HC&lowbar;OPTS</Constant><IndexTerm><Primary>HC&lowbar;OPTS</Primary></IndexTerm>, the options to feed to the Haskell compiler;
1789 <Constant>NoFibSubDirs</Constant><IndexTerm><Primary>NoFibSubDirs</Primary></IndexTerm>, the sub-directories to enable within the
1790 <Literal>nofib</Literal> project; <Constant>GhcWithHc</Constant><IndexTerm><Primary>GhcWithHc</Primary></IndexTerm>, the name of the Haskell
1791 compiler to use when compiling GHC in the <Literal>ghc</Literal> project.  
1792 </Para>
1793 </ListItem>
1794 <ListItem>
1795
1796 <Para>
1797 <Emphasis>Standard pattern rules</Emphasis> that tell <Command>gmake</Command> how to construct one
1798 file from another.
1799 </Para>
1800 </ListItem>
1801
1802 </ItemizedList>
1803
1804
1805 <Filename>boilerplate.mk</Filename> needs to be <Literal>include</Literal>d at the <Emphasis>top</Emphasis>
1806 of each <Filename>Makefile</Filename>, so that the user can replace the
1807 boilerplate definitions or pattern rules by simply giving a new
1808 definition or pattern rule in the <Filename>Makefile</Filename>.  <Command>gmake</Command>
1809 simply takes the last definition as the definitive one.
1810
1811 Instead of <Emphasis>replacing</Emphasis> boilerplate definitions, it is also quite
1812 common to <Emphasis>augment</Emphasis> them. For example, a <Filename>Makefile</Filename> might say:
1813
1814
1815 <ProgramListing>
1816 SRC_HC_OPTS += -O
1817 </ProgramListing>
1818
1819
1820 thereby adding ``<Option>-O</Option>'' to the end of <Constant>SRC&lowbar;HC&lowbar;OPTS</Constant><IndexTerm><Primary>SRC&lowbar;HC&lowbar;OPTS</Primary></IndexTerm>.
1821
1822 </Para>
1823 </ListItem>
1824 <ListItem>
1825
1826 <Para>
1827  <Filename>target.mk</Filename> contains <Command>make</Command> rules for the standard
1828 targets described in <Xref LinkEnd="sec-standard-targets">.  These rules are selectively included,
1829 depending on the setting of certain <Command>make</Command> variables.  These
1830 variables are usually set in the middle section of the
1831 <Filename>Makefile</Filename> between the two <Literal>include</Literal>s.
1832
1833 <Filename>target.mk</Filename> must be included at the end (rather than being part of
1834 <Filename>boilerplate.mk</Filename>) for several tiresome reasons:
1835
1836
1837 <ItemizedList>
1838 <ListItem>
1839
1840 <Para>
1841  <Command>gmake</Command> commits target and dependency lists earlier than
1842 it should.  For example, <FIlename>target.mk</FIlename> has a rule that looks like
1843 this: 
1844
1845
1846 <ProgramListing>
1847 $(HS_PROG) : $(OBJS)
1848       $(HC) $(LD_OPTS) $&#60; -o $@
1849 </ProgramListing>
1850
1851
1852 If this rule was in <Filename>boilerplate.mk</Filename> then <Constant>&dollar;(HS&lowbar;PROG)</Constant><IndexTerm><Primary>HS&lowbar;PROG</Primary></IndexTerm>
1853 and <Constant>&dollar;(OBJS)</Constant><IndexTerm><Primary>OBJS</Primary></IndexTerm> would not have their final values at the
1854 moment <Command>gmake</Command> encountered the rule.  Alas, <Command>gmake</Command> takes a snapshot
1855 of their current values, and wires that snapshot into the rule.  (In
1856 contrast, the commands executed when the rule ``fires'' are only
1857 substituted at the moment of firing.)  So, the rule must follow the
1858 definitions given in the <Filename>Makefile</Filename> itself.
1859
1860 </Para>
1861 </ListItem>
1862 <ListItem>
1863
1864 <Para>
1865  Unlike pattern rules, ordinary rules cannot be overriden or
1866 replaced by subsequent rules for the same target (at least, not without an
1867 error message).  Including ordinary rules in <Filename>boilerplate.mk</Filename> would
1868 prevent the user from writing rules for specific targets in specific cases.
1869
1870 </Para>
1871 </ListItem>
1872 <ListItem>
1873
1874 <Para>
1875  There are a couple of other reasons I've forgotten, but it doesn't
1876 matter too much.
1877 </Para>
1878 </ListItem>
1879
1880 </ItemizedList>
1881
1882 </Para>
1883 </ListItem>
1884
1885 </ItemizedList>
1886
1887 </Para>
1888
1889 </Sect2>
1890
1891 <Sect2 id="sec-boiler">
1892 <Title>The main <Filename>mk/boilerplate.mk</Filename> file
1893
1894 <IndexTerm><Primary>boilerplate.mk</Primary></IndexTerm></Title>
1895
1896 <Para>
1897 If you look at <Filename><Constant>&dollar;(FPTOOLS&lowbar;TOP)</Constant>/mk/boilerplate.mk</Filename> you will find
1898 that it consists of the following sections, each held in a separate
1899 file: 
1900 </Para>
1901
1902 <Para>
1903 <VariableList>
1904
1905 <VarListEntry>
1906 <Term><Filename>config.mk</Filename><IndexTerm><Primary>config.mk</Primary></IndexTerm></Term>
1907 <ListItem>
1908 <Para>
1909 is the build configuration file we
1910 discussed at length in <Xref LinkEnd="sec-build-config">.
1911 </Para>
1912 </ListItem></VarListEntry>
1913 <VarListEntry>
1914 <Term><Filename>paths.mk</Filename><IndexTerm><Primary>paths.mk</Primary></IndexTerm></Term>
1915 <ListItem>
1916 <Para>
1917 defines <Command>make</Command> variables for
1918 pathnames and file lists.  In particular, it gives definitions for:
1919 </Para>
1920
1921 <Para>
1922 <VariableList>
1923
1924 <VarListEntry>
1925 <Term><Constant>SRCS</Constant><IndexTerm><Primary>SRCS</Primary></IndexTerm>:</Term>
1926 <ListItem>
1927 <Para>
1928 all source files in the current directory.
1929 </Para>
1930 </ListItem></VarListEntry>
1931 <VarListEntry>
1932 <Term><Constant>HS&lowbar;SRCS</Constant><IndexTerm><Primary>HS&lowbar;SRCS</Primary></IndexTerm>:</Term>
1933 <ListItem>
1934 <Para>
1935 all Haskell source files in the current directory.
1936 It is derived from <Constant>&dollar;(SRCS)</Constant>, so if you override <Constant>SRCS</Constant> with a new value
1937 <Constant>HS&lowbar;SRCS</Constant> will follow suit.
1938 </Para>
1939 </ListItem></VarListEntry>
1940 <VarListEntry>
1941 <Term><Constant>C&lowbar;SRCS</Constant><IndexTerm><Primary>C&lowbar;SRCS</Primary></IndexTerm>:</Term>
1942 <ListItem>
1943 <Para>
1944 similarly for C source files.
1945 </Para>
1946 </ListItem></VarListEntry>
1947 <VarListEntry>
1948 <Term><Constant>HS&lowbar;OBJS</Constant><IndexTerm><Primary>HS&lowbar;OBJS</Primary></IndexTerm>:</Term>
1949 <ListItem>
1950 <Para>
1951 the <Filename>.o</Filename> files derived from <Constant>&dollar;(HS&lowbar;SRCS)</Constant>.
1952 </Para>
1953 </ListItem></VarListEntry>
1954 <VarListEntry>
1955 <Term><Constant>C&lowbar;OBJS</Constant><IndexTerm><Primary>C&lowbar;OBJS</Primary></IndexTerm>:</Term>
1956 <ListItem>
1957 <Para>
1958 similarly for <Constant>&dollar;(C&lowbar;SRCS)</Constant>.
1959 </Para>
1960 </ListItem></VarListEntry>
1961 <VarListEntry>
1962 <Term><Constant>OBJS</Constant><IndexTerm><Primary>OBJS</Primary></IndexTerm>:</Term>
1963 <ListItem>
1964 <Para>
1965 the concatenation of <Constant>&dollar;(HS&lowbar;OBJS)</Constant> and <Constant>&dollar;(C&lowbar;OBJS)</Constant>.
1966 </Para>
1967 </ListItem></VarListEntry>
1968 </VariableList>
1969 </Para>
1970
1971 <Para>
1972 Any or all of these definitions can easily be overriden by giving new
1973 definitions in your <Filename>Makefile</Filename>.  For example, if there are things in
1974 the current directory that look like source files but aren't, then
1975 you'll need to set <Constant>SRCS</Constant> manually in your <Filename>Makefile</Filename>.  The other
1976 definitions will then work from this new definition.
1977 </Para>
1978
1979 <Para>
1980 What, exactly, does <Filename>paths.mk</Filename> consider a ``source file'' to be?  It's
1981 based on the file's suffix (e.g. <Filename>.hs</Filename>, <Filename>.lhs</Filename>, <Filename>.c</Filename>, <Filename>.lc</Filename>, etc), but
1982 this is the kind of detail that changes, so rather than
1983 enumerate the source suffices here the best thing to do is to look in
1984 <Filename>paths.mk</Filename>.
1985 </Para>
1986 </ListItem></VarListEntry>
1987 <VarListEntry>
1988 <Term><Filename>opts.mk</Filename><IndexTerm><Primary>opts.mk</Primary></IndexTerm></Term>
1989 <ListItem>
1990 <Para>
1991 defines <Command>make</Command> variables for option
1992 strings to pass to each program. For example, it defines
1993 <Constant>HC&lowbar;OPTS</Constant><IndexTerm><Primary>HC&lowbar;OPTS</Primary></IndexTerm>, the option strings to pass to the Haskell
1994 compiler.  See <Xref LinkEnd="sec-suffix">.
1995 </Para>
1996 </ListItem></VarListEntry>
1997 <VarListEntry>
1998 <Term><Filename>suffix.mk</Filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm></Term>
1999 <ListItem>
2000 <Para>
2001 defines standard pattern rules&mdash;see <Xref LinkEnd="sec-suffix">.
2002 </Para>
2003 </ListItem></VarListEntry>
2004 </VariableList>
2005 </Para>
2006
2007 <Para>
2008 Any of the variables and pattern rules defined by the boilerplate file
2009 can easily be overridden in any particular <Filename>Makefile</Filename>, because the
2010 boilerplate <Literal>include</Literal> comes first.  Definitions after this <Literal>include</Literal>
2011 directive simply override the default ones in <Filename>boilerplate.mk</Filename>.
2012 </Para>
2013
2014 </Sect2>
2015
2016 <Sect2 id="sec-suffix">
2017 <Title>Pattern rules and options
2018
2019 <IndexTerm><Primary>Pattern rules</Primary></IndexTerm></Title>
2020
2021 <Para>
2022 The file <Filename>suffix.mk</Filename><IndexTerm><Primary>suffix.mk</Primary></IndexTerm> defines standard <Emphasis>pattern
2023 rules</Emphasis> that say how to build one kind of file from another, for
2024 example, how to build a <Filename>.o</Filename> file from a <Filename>.c</Filename> file.  (GNU <Command>make</Command>'s
2025 <Emphasis>pattern rules</Emphasis> are more powerful and easier to use than Unix
2026 <Command>make</Command>'s <Emphasis>suffix rules</Emphasis>.)
2027 </Para>
2028
2029 <Para>
2030 Almost all the rules look something like this:
2031 </Para>
2032
2033 <Para>
2034
2035 <ProgramListing>
2036 %.o : %.c
2037       $(RM) $@
2038       $(CC) $(CC_OPTS) -c $&#60; -o $@
2039 </ProgramListing>
2040
2041 </Para>
2042
2043 <Para>
2044 Here's how to understand the rule.  It says that
2045 <Emphasis>something</Emphasis><Filename>.o</Filename> (say <Filename>Foo.o</Filename>) can be built from
2046 <Emphasis>something</Emphasis><Filename>.c</Filename> (<Filename>Foo.c</Filename>), by invoking the C compiler
2047 (path name held in <Constant>&dollar;(CC)</Constant>), passing to it the options
2048 <Constant>&dollar;(CC&lowbar;OPTS)</Constant> and the rule's dependent file of the rule
2049 <Literal>&dollar;&lt;</Literal> (<Filename>Foo.c</Filename> in this case), and putting the result in
2050 the rule's target <Literal>&dollar;@</Literal> (<Filename>Foo.o</Filename> in this case).
2051 </Para>
2052
2053 <Para>
2054 Every program is held in a <Command>make</Command> variable defined in
2055 <Filename>mk/config.mk</Filename>&mdash;look in <Filename>mk/config.mk</Filename> for the
2056 complete list.  One important one is the Haskell compiler, which is
2057 called <Constant>&dollar;(HC)</Constant>.
2058 </Para>
2059
2060 <Para>
2061 Every program's options are are held in a <Command>make</Command> variables called
2062 <Constant>&lt;prog&gt;&lowbar;OPTS</Constant>.  the <Constant>&lt;prog&gt;&lowbar;OPTS</Constant> variables are defined in
2063 <Filename>mk/opts.mk</Filename>.  Almost all of them are defined like this:
2064 </Para>
2065
2066 <Para>
2067
2068 <ProgramListing>
2069 CC_OPTS = $(SRC_CC_OPTS) $(WAY$(_way)_CC_OPTS) $($*_CC_OPTS) $(EXTRA_CC_OPTS)
2070 </ProgramListing>
2071
2072 </Para>
2073
2074 <Para>
2075 The four variables from which <Constant>CC&lowbar;OPTS</Constant> is built have the following meaning:
2076 </Para>
2077
2078 <Para>
2079 <VariableList>
2080
2081 <VarListEntry>
2082 <Term><Constant>SRC&lowbar;CC&lowbar;OPTS</Constant><IndexTerm><Primary>SRC&lowbar;CC&lowbar;OPTS</Primary></IndexTerm>:</Term>
2083 <ListItem>
2084 <Para>
2085 options passed to all C
2086 compilations.
2087 </Para>
2088 </ListItem></VarListEntry>
2089 <VarListEntry>
2090 <Term><Constant>WAY&lowbar;&lt;way&gt;&lowbar;CC&lowbar;OPTS</Constant>:</Term>
2091 <ListItem>
2092 <Para>
2093 options passed to C
2094 compilations for way <Literal>&lt;way&gt;</Literal>. For example,
2095 <Constant>WAY&lowbar;mp&lowbar;CC&lowbar;OPTS</Constant> gives options to pass to the C compiler when
2096 compiling way <Literal>mp</Literal>.  The variable <Constant>WAY&lowbar;CC&lowbar;OPTS</Constant> holds
2097 options to pass to the C compiler when compiling the standard way.
2098 (<Xref LinkEnd="sec-ways"> dicusses multi-way
2099 compilation.)  
2100 </Para>
2101 </ListItem></VarListEntry>
2102 <VarListEntry>
2103 <Term><Constant>&lt;module&gt;&lowbar;CC&lowbar;OPTS</Constant>:</Term>
2104 <ListItem>
2105 <Para>
2106 options to
2107 pass to the C compiler that are specific to module <Literal>&lt;module&gt;</Literal>.  For example, <Constant>SMap&lowbar;CC&lowbar;OPTS</Constant> gives the specific options
2108 to pass to the C compiler when compiling <Filename>SMap.c</Filename>.
2109 </Para>
2110 </ListItem></VarListEntry>
2111 <VarListEntry>
2112 <Term><Constant>EXTRA&lowbar;CC&lowbar;OPTS</Constant><IndexTerm><Primary>EXTRA&lowbar;CC&lowbar;OPTS</Primary></IndexTerm>:</Term>
2113 <ListItem>
2114 <Para>
2115 extra options to pass to all
2116 C compilations.  This is intended for command line use, thus:
2117 </Para>
2118
2119 <Para>
2120
2121 <ProgramListing>
2122 gmake libHS.a EXTRA_CC_OPTS="-v"
2123 </ProgramListing>
2124
2125 </Para>
2126 </ListItem></VarListEntry>
2127 </VariableList>
2128 </Para>
2129
2130 </Sect2>
2131
2132 <Sect2 id="sec-targets">
2133 <Title>The main <Filename>mk/target.mk</Filename> file
2134
2135 <IndexTerm><Primary>target.mk</Primary></IndexTerm></Title>
2136
2137 <Para>
2138 <Filename>target.mk</Filename> contains canned rules for all the standard targets
2139 described in <Xref LinkEnd="sec-standard-targets">.  It is complicated by the fact that you don't want all of
2140 these rules to be active in every <Filename>Makefile</Filename>.  Rather than have a
2141 plethora of tiny files which you can include selectively, there is a
2142 single file, <Filename>target.mk</Filename>, which selectively includes rules based on
2143 whether you have defined certain variables in your <Filename>Makefile</Filename>.  This
2144 section explains what rules you get, what variables control them, and
2145 what the rules do.  Hopefully, you will also get enough of an idea of
2146 what is supposed to happen that you can read and understand any weird
2147 special cases yourself.
2148 </Para>
2149
2150 <Para>
2151 <VariableList>
2152
2153 <VarListEntry>
2154 <Term><Constant>HS&lowbar;PROG</Constant><IndexTerm><Primary>HS&lowbar;PROG</Primary></IndexTerm>.</Term>
2155 <ListItem>
2156 <Para>
2157 If <Constant>HS&lowbar;PROG</Constant> is defined, you get
2158 rules with the following targets:
2159 <VariableList>
2160
2161 <VarListEntry>
2162 <Term><Filename>HS&lowbar;PROG</Filename><IndexTerm><Primary>HS&lowbar;PROG</Primary></IndexTerm></Term>
2163 <ListItem>
2164 <Para>
2165 itself.  This rule links <Constant>&dollar;(OBJS)</Constant>
2166 with the Haskell runtime system to get an executable called
2167 <Constant>&dollar;(HS&lowbar;PROG)</Constant>.
2168 </Para>
2169 </ListItem></VarListEntry>
2170 <VarListEntry>
2171 <Term><Literal>install</Literal><IndexTerm><Primary>install</Primary></IndexTerm></Term>
2172 <ListItem>
2173 <Para>
2174 installs <Constant>&dollar;(HS&lowbar;PROG)</Constant>
2175 in <Constant>&dollar;(bindir)</Constant>.
2176 </Para>
2177 </ListItem></VarListEntry>
2178 </VariableList>
2179 </Para>
2180 </ListItem></VarListEntry>
2181 <VarListEntry>
2182 <Term><Constant>C&lowbar;PROG</Constant><IndexTerm><Primary>C&lowbar;PROG</Primary></IndexTerm></Term>
2183 <ListItem>
2184 <Para>
2185 is similar to <Constant>HS&lowbar;PROG</Constant>, except that
2186 the link step links <Constant>&dollar;(C&lowbar;OBJS)</Constant> with the C runtime system.
2187 </Para>
2188 </ListItem></VarListEntry>
2189 <VarListEntry>
2190 <Term><Constant>LIBRARY</Constant><IndexTerm><Primary>LIBRARY</Primary></IndexTerm></Term>
2191 <ListItem>
2192 <Para>
2193 is similar to <Constant>HS&lowbar;PROG</Constant>, except that
2194 it links <Constant>&dollar;(LIB&lowbar;OBJS)</Constant> to make the library archive <Constant>&dollar;(LIBRARY)</Constant>, and
2195 <Literal>install</Literal> installs it in <Constant>&dollar;(libdir)</Constant>.
2196 </Para>
2197 </ListItem></VarListEntry>
2198 <VarListEntry>
2199 <Term><Constant>LIB&lowbar;DATA</Constant><IndexTerm><Primary>LIB&lowbar;DATA</Primary></IndexTerm></Term>
2200 <ListItem>
2201 <Para>
2202 &hellip;
2203 </Para>
2204 </ListItem></VarListEntry>
2205 <VarListEntry>
2206 <Term><Constant>LIB&lowbar;EXEC</Constant><IndexTerm><Primary>LIB&lowbar;EXEC</Primary></IndexTerm></Term>
2207 <ListItem>
2208 <Para>
2209 &hellip;
2210 </Para>
2211 </ListItem></VarListEntry>
2212 <VarListEntry>
2213 <Term><Constant>HS&lowbar;SRCS</Constant><IndexTerm><Primary>HS&lowbar;SRCS</Primary></IndexTerm>, <Constant>C&lowbar;SRCS</Constant><IndexTerm><Primary>C&lowbar;SRCS</Primary></IndexTerm>.</Term>
2214 <ListItem>
2215 <Para>
2216 If <Constant>HS&lowbar;SRCS</Constant>
2217 is defined and non-empty, a rule for the target <Literal>depend</Literal> is included,
2218 which generates dependency information for Haskell programs.
2219 Similarly for <Constant>C&lowbar;SRCS</Constant>.
2220 </Para>
2221 </ListItem></VarListEntry>
2222 </VariableList>
2223 </Para>
2224
2225 <Para>
2226 All of these rules are ``double-colon'' rules, thus
2227 </Para>
2228
2229 <Para>
2230
2231 <ProgramListing>
2232 install :: $(HS_PROG)
2233       ...how to install it...
2234 </ProgramListing>
2235
2236 </Para>
2237
2238 <Para>
2239 GNU <Command>make</Command> treats double-colon rules as separate entities.  If there
2240 are several double-colon rules for the same target it takes each in
2241 turn and fires it if its dependencies say to do so.  This means that
2242 you can, for example, define both <Constant>HS&lowbar;PROG</Constant> and <Constant>LIBRARY</Constant>, which will
2243 generate two rules for <Literal>install</Literal>.  When you type <Command>gmake install</Command> both
2244 rules will be fired, and both the program and the library will be
2245 installed, just as you wanted.
2246 </Para>
2247
2248 </Sect2>
2249
2250 <Sect2 id="sec-subdirs">
2251 <Title>Recursion
2252
2253 <IndexTerm><Primary>recursion, in makefiles</Primary></IndexTerm>
2254 <IndexTerm><Primary>Makefile, recursing into subdirectories</Primary></IndexTerm></Title>
2255
2256 <Para>
2257 In leaf <Filename>Makefile</Filename>s the variable <Constant>SUBDIRS</Constant><IndexTerm><Primary>SUBDIRS</Primary></IndexTerm> is undefined.
2258 In non-leaf <Filename>Makefile</Filename>s, <Constant>SUBDIRS</Constant> is set to the list of
2259 sub-directories that contain subordinate <Filename>Makefile</Filename>s.  <Emphasis>It is up to
2260 you to set <Constant>SUBDIRS</Constant> in the <Filename>Makefile</Filename>.</Emphasis> There is no automation here&mdash;<Constant>SUBDIRS</Constant> is too important to automate.
2261 </Para>
2262
2263 <Para>
2264 When <Constant>SUBDIRS</Constant> is defined, <Filename>target.mk</Filename> includes a rather
2265 neat rule for the standard targets (<Xref LinkEnd="sec-standard-targets"> that simply invokes
2266 <Command>make</Command> recursively in each of the sub-directories.
2267 </Para>
2268
2269 <Para>
2270 <Emphasis>These recursive invocations are guaranteed to occur in the order
2271 in which the list of directories is specified in <Constant>SUBDIRS</Constant>. </Emphasis>This
2272 guarantee can be important.  For example, when you say <Command>gmake boot</Command> it
2273 can be important that the recursive invocation of <Command>make boot</Command> is done
2274 in one sub-directory (the include files, say) before another (the
2275 source files).  Generally, put the most independent sub-directory
2276 first, and the most dependent last.
2277 </Para>
2278
2279 </Sect2>
2280
2281 <Sect2 id="sec-ways">
2282 <Title>Way management
2283
2284 <IndexTerm><Primary>way management</Primary></IndexTerm></Title>
2285
2286 <Para>
2287 We sometimes want to build essentially the same system in several
2288 different ``ways''.  For example, we want to build GHC's <Literal>Prelude</Literal>
2289 libraries with and without profiling, with and without concurrency,
2290 and so on, so that there is an appropriately-built library archive to
2291 link with when the user compiles his program.  It would be possible to
2292 have a completely separate build tree for each such ``way'', but it
2293 would be horribly bureaucratic, especially since often only parts of
2294 the build tree need to be constructed in multiple ways.
2295 </Para>
2296
2297 <Para>
2298 Instead, the <Filename>target.mk</Filename><IndexTerm><Primary>target.mk</Primary></IndexTerm> contains some clever magic to
2299 allow you to build several versions of a system; and to control
2300 locally how many versions are built and how they differ.  This section
2301 explains the magic.
2302 </Para>
2303
2304 <Para>
2305 The files for a particular way are distinguished by munging the
2306 suffix.  The ``normal way'' is always built, and its files have the
2307 standard suffices <Filename>.o</Filename>, <Filename>.hi</Filename>, and so on.  In addition, you can build
2308 one or more extra ways, each distinguished by a <Emphasis>way tag</Emphasis>.  The
2309 object files and interface files for one of these extra ways are
2310 distinguished by their suffix.  For example, way <Literal>mp</Literal> has files
2311 <Filename>.mp&lowbar;o</Filename> and <Filename>.mp&lowbar;hi</Filename>.  Library archives have their way tag the other
2312 side of the dot, for boring reasons; thus, <Filename>libHS&lowbar;mp.a</Filename>.
2313 </Para>
2314
2315 <Para>
2316 A <Command>make</Command> variable called <Constant>way</Constant> holds the current way tag.  <Emphasis><Constant>way</Constant>
2317 is only ever set on the command line of a recursive invocation of
2318 <Command>gmake</Command>.</Emphasis> It is never set inside a <Filename>Makefile</Filename>.  So it is a global
2319 constant for any one invocation of <Command>gmake</Command>.  Two other <Command>make</Command>
2320 variables, <Constant>way&lowbar;</Constant> and <Constant>&lowbar;way</Constant> are immediately derived from <Constant>&dollar;(way)</Constant> and
2321 never altered.  If <Constant>way</Constant> is not set, then neither are <Constant>way&lowbar;</Constant> and
2322 <Constant>&lowbar;way</Constant>, and the invocation of <Command>make</Command> will build the ``normal way''.
2323 If <Constant>way</Constant> is set, then the other two variables are set in sympathy.
2324 For example, if <Constant>&dollar;(way)</Constant> is ``<Literal>mp</Literal>'', then <Constant>way&lowbar;</Constant> is set to ``<Literal>mp&lowbar;</Literal>''
2325 and <Constant>&lowbar;way</Constant> is set to ``<Literal>&lowbar;mp</Literal>''.  These three variables are then used
2326 when constructing file names.
2327 </Para>
2328
2329 <Para>
2330 So how does <Command>make</Command> ever get recursively invoked with <Constant>way</Constant> set?  There
2331 are two ways in which this happens:
2332 </Para>
2333
2334 <Para>
2335
2336 <ItemizedList>
2337 <ListItem>
2338
2339 <Para>
2340  For some (but not all) of the standard targets, when in a leaf
2341 sub-directory, <Command>make</Command> is recursively invoked for each way tag in
2342 <Constant>&dollar;(WAYS)</Constant>.  You set <Constant>WAYS</Constant> to the list of way tags you want these
2343 targets built for.  The mechanism here is very much like the recursive
2344 invocation of <Command>make</Command> in sub-directories (<Xref LinkEnd="sec-subdirs">).
2345
2346 It is up to you to set <Constant>WAYS</Constant> in your <Filename>Makefile</Filename>; this is how you
2347 control what ways will get built.  
2348 </Para>
2349 </ListItem>
2350 <ListItem>
2351
2352 <Para>
2353  For a useful collection of
2354 targets (such as <Filename>libHS&lowbar;mp.a</Filename>, <Filename>Foo.mp&lowbar;o</Filename>) there is a rule which
2355 recursively invokes <Command>make</Command> to make the specified target, setting the
2356 <Constant>way</Constant> variable.  So if you say <Command>gmake Foo.mp&lowbar;o</Command> you should see a
2357 recursive invocation <Command>gmake Foo.mp&lowbar;o way=mp</Command>, and <Emphasis>in this
2358 recursive invocation the pattern rule for compiling a Haskell file
2359 into a <Filename>.o</Filename> file will match</Emphasis>.  The key pattern rules (in <Filename>suffix.mk</Filename>)
2360 look like this:
2361
2362
2363 <ProgramListing>
2364 %.$(way_)o : %.lhs
2365       $(HC) $(HC_OPTS) $&#60; -o $@
2366 </ProgramListing>
2367
2368
2369 Neat, eh?
2370 </Para>
2371 </ListItem>
2372
2373 </ItemizedList>
2374
2375 </Para>
2376
2377 </Sect2>
2378
2379 <Sect2>
2380 <Title>When the canned rule isn't right</Title>
2381
2382 <Para>
2383 Sometimes the canned rule just doesn't do the right thing.  For
2384 example, in the <Literal>nofib</Literal> suite we want the link step to print out
2385 timing information.  The thing to do here is <Emphasis>not</Emphasis> to define
2386 <Constant>HS&lowbar;PROG</Constant> or <Constant>C&lowbar;PROG</Constant>, and instead define a special purpose rule in
2387 your own <Filename>Makefile</Filename>.  By using different variable names you will avoid
2388 the canned rules being included, and conflicting with yours.
2389 </Para>
2390
2391 </Sect2>
2392
2393 </Sect1>
2394
2395 <Sect1 id="sec-booting-from-C">
2396 <Title>Booting/porting from C (<Filename>.hc</Filename>) files
2397
2398 <IndexTerm><Primary>building GHC from .hc files</Primary></IndexTerm>
2399 <IndexTerm><Primary>booting GHC from .hc files</Primary></IndexTerm>
2400 <IndexTerm><Primary>porting GHC</Primary></IndexTerm></Title>
2401
2402 <Para>
2403 This section is for people trying to get GHC going by using the
2404 supplied intermediate C (<Filename>.hc</Filename>) files.  This would probably be because
2405 no binaries have been provided, or because the machine is not ``fully
2406 supported''.
2407 </Para>
2408
2409 <Para>
2410 The intermediate C files are normally made available together with a
2411 source release, please check the announce message for exact directions
2412 of where to find them. If we haven't made them available or you
2413 can't find them, please ask.
2414 </Para>
2415
2416 <Para>
2417 Assuming you've got them, unpack them on top of a fresh source tree.
2418 Then follow the `normal' instructions in <Xref LinkEnd="sec-building-from-source"> for setting
2419 up a build tree. When you invoke the configure script, you'll have
2420 to tell the script about your intentions:
2421 </Para>
2422
2423 <Para>
2424
2425 <Screen>
2426 foo% ./configure --enable-hc-boot
2427 </Screen>
2428
2429 <IndexTerm><Primary>--enable-hc-boot</Primary></IndexTerm>
2430 <IndexTerm><Primary>--disable-hc-boot</Primary></IndexTerm>
2431 </Para>
2432
2433 <Para>
2434 Assuming it configures OK and you don't need to create <Filename>mk/build.mk</Filename>
2435 for any other purposes, the next step is to proceed with a <Command>make boot</Command>
2436 followed by <Command>make all</Command>. At the successful completion of <Command>make all</Command>,
2437 you should end up with a binary of the compiler proper,
2438 <Filename>ghc/compiler/hsc</Filename>, plus archives (but no <Filename>.hi</Filename> files!) of the prelude
2439 libraries. To generate the Prelude interface files (and test drive the
2440 bootstrapped compiler), re-run the <Command>configure</Command> script, but this time
2441 without the <Option>--enable-hc-boot</Option> option. After that re-create the
2442 contents of <Filename>ghc/lib</Filename>:
2443 </Para>
2444
2445 <Para>
2446
2447 <Screen>
2448 foo% ./configure
2449  ....
2450 foo% cd ghc/lib
2451 foo% make clean
2452 foo% make boot
2453 foo% make all
2454 </Screen>
2455
2456 </Para>
2457
2458 <Para>
2459 That's the mechanics of the boot process, but, of course, if you're
2460 trying to boot on a platform that is not supported and significantly
2461 `different' from any of the supported ones, this is only the start of
2462 the adventure&hellip;(ToDo: porting tips&mdash;stuff to look out for, etc.)
2463 </Para>
2464
2465 </Sect1>
2466
2467 <Sect1 id="sec-build-pitfalls">
2468 <Title>Known pitfalls in building Glasgow Haskell
2469
2470 <IndexTerm><Primary>problems, building</Primary></IndexTerm>
2471 <IndexTerm><Primary>pitfalls, in building</Primary></IndexTerm>
2472 <IndexTerm><Primary>building pitfalls</Primary></IndexTerm></Title>
2473
2474 <Para>
2475 WARNINGS about pitfalls and known ``problems'':
2476 </Para>
2477
2478 <Para>
2479
2480 <OrderedList>
2481 <ListItem>
2482
2483 <Para>
2484 One difficulty that comes up from time to time is running out of space
2485 in <Filename>/tmp</Filename>.  (It is impossible for the configuration stuff to
2486 compensate for the vagaries of different sysadmin approaches to temp
2487 space.)
2488 <IndexTerm><Primary>tmp, running out of space in</Primary></IndexTerm>
2489
2490 The quickest way around it is <Command>setenv TMPDIR /usr/tmp</Command><IndexTerm><Primary>TMPDIR</Primary></IndexTerm> or
2491 even <Command>setenv TMPDIR .</Command> (or the equivalent incantation with your shell
2492 of choice).
2493
2494 The best way around it is to say
2495
2496 <ProgramListing>
2497 export TMPDIR=&#60;dir&#62;
2498 </ProgramListing>
2499
2500 in your <Filename>build.mk</Filename> file.
2501 Then GHC and the other <Literal>fptools</Literal> programs will use the appropriate directory
2502 in all cases.
2503
2504
2505 </Para>
2506 </ListItem>
2507 <ListItem>
2508
2509 <Para>
2510 In compiling some support-code bits, e.g., in <Filename>ghc/rts/gmp</Filename> and even
2511 in <Filename>ghc/lib</Filename>, you may get a few C-compiler warnings.  We think these
2512 are OK.
2513
2514 </Para>
2515 </ListItem>
2516 <ListItem>
2517
2518 <Para>
2519 When compiling via C, you'll sometimes get ``warning: assignment from
2520 incompatible pointer type'' out of GCC.  Harmless.
2521
2522 </Para>
2523 </ListItem>
2524 <ListItem>
2525
2526 <Para>
2527 Similarly, <Command>ar</Command>chiving warning messages like the following are not
2528 a problem:
2529
2530 <Screen>
2531 ar: filename GlaIOMonad__1_2s.o truncated to GlaIOMonad_
2532 ar: filename GlaIOMonad__2_2s.o truncated to GlaIOMonad_
2533 ...
2534 </Screen>
2535
2536
2537 </Para>
2538 </ListItem>
2539 <ListItem>
2540
2541 <Para>
2542  In compiling the compiler proper (in <Filename>compiler/</Filename>), you <Emphasis>may</Emphasis>
2543 get an ``Out of heap space'' error message.  These can vary with the
2544 vagaries of different systems, it seems.  The solution is simple:
2545
2546
2547 <ItemizedList>
2548 <ListItem>
2549
2550 <Para>
2551  If you're compiling with GHC 4.00 or later, then the
2552 <Emphasis>maximum</Emphasis> heap size must have been reached.  This
2553 is somewhat unlikely, since the maximum is set to 64M by default.
2554 Anyway, you can raise it with the
2555 <Option>-optCrts-M&lt;size&gt;</Option> flag (add this flag to
2556 <Constant>&lt;module&gt;&lowbar;HC&lowbar;OPTS</Constant>
2557 <Command>make</Command> variable in the appropriate
2558 <Filename>Makefile</Filename>).
2559
2560 </Para>
2561 </ListItem>
2562 <ListItem>
2563
2564 <Para>
2565  For GHC &#60; 4.00, add a suitable <Option>-H</Option> flag to the <Filename>Makefile</Filename>, as
2566 above.
2567
2568 </Para>
2569 </ListItem>
2570
2571 </ItemizedList>
2572
2573
2574 and try again: <Command>gmake</Command>.  (see <Xref LinkEnd="sec-suffix"> for information about
2575 <Constant>&lt;module&gt;&lowbar;HC&lowbar;OPTS</Constant>.)
2576
2577 Alternatively, just cut to the chase:
2578
2579 <Screen>
2580 % cd ghc/compiler
2581 % make EXTRA_HC_OPTS=-optCrts-M128M
2582 </Screen>
2583
2584
2585 </Para>
2586 </ListItem>
2587 <ListItem>
2588
2589 <Para>
2590 If you try to compile some Haskell, and you get errors from GCC about
2591 lots of things from <Filename>/usr/include/math.h</Filename>, then your GCC was
2592 mis-installed.  <Command>fixincludes</Command> wasn't run when it should've been.
2593
2594 As <Command>fixincludes</Command> is now automagically run as part of GCC installation,
2595 this bug also suggests that you have an old GCC.
2596
2597
2598 </Para>
2599 </ListItem>
2600 <ListItem>
2601
2602 <Para>
2603 You <Emphasis>may</Emphasis> need to re-<Command>ranlib</Command><IndexTerm><Primary>ranlib</Primary></IndexTerm> your libraries (on Sun4s).
2604
2605
2606 <Screen>
2607 % cd $(libdir)/ghc-x.xx/sparc-sun-sunos4
2608 % foreach i ( `find . -name '*.a' -print` ) # or other-shell equiv...
2609 ?    ranlib $i
2610 ?    # or, on some machines: ar s $i
2611 ? end
2612 </Screen>
2613
2614
2615 We'd be interested to know if this is still necessary.
2616
2617
2618 </Para>
2619 </ListItem>
2620 <ListItem>
2621
2622 <Para>
2623 GHC's sources go through <Command>cpp</Command> before being compiled, and <Command>cpp</Command> varies
2624 a bit from one Unix to another.  One particular gotcha is macro calls
2625 like this:
2626
2627
2628 <ProgramListing>
2629 SLIT("Hello, world")
2630 </ProgramListing>
2631
2632
2633 Some <Command>cpp</Command>s treat the comma inside the string as separating two macro
2634 arguments, so you get
2635
2636
2637 <Screen>
2638 :731: macro `SLIT' used with too many (2) args
2639 </Screen>
2640
2641
2642 Alas, <Command>cpp</Command> doesn't tell you the offending file!
2643
2644 Workaround: don't put weird things in string args to <Command>cpp</Command> macros.
2645 </Para>
2646 </ListItem>
2647
2648 </OrderedList>
2649
2650 </Para>
2651
2652 </Sect1>
2653
2654
2655 <Sect1 id="winbuild"><Title>Notes for building under Windows</Title>
2656
2657 <Para>
2658 This section summarises how to get the utilities you need on your
2659 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, Win95/Win98 behave the same, and WinNT/Win2k behave the same. It is based largely on detailed advice from Sigbj&oslash;rn Finne.
2660 </Para>
2661
2662
2663 <Sect2><Title>Installing ssh</Title>
2664
2665 <ItemizedList>
2666
2667 <ListItem>
2668 <Para>
2669 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.
2670 </Para>
2671 </ListItem>
2672
2673 <ListItem>
2674 <Para>
2675 Extract <ULink URL="http://research.microsoft.com/~simonpj/cygwinb19.dll.zip">cygwinb19.dll</ULink> into <Filename>/usr/local/bin</Filename>.  The current version
2676 of Cywin is b20, but this version of ssh was compiled with b19.
2677 </Para>
2678 </ListItem>
2679
2680 <ListItem>
2681 <Para>
2682 On a Win2k machine, open up a bash and do 
2683 </Para>
2684
2685 <Screen>
2686 foo$ cd /etc
2687 foo$ mkpasswd -l > passwd
2688 </Screen>
2689
2690 <Para>
2691 Check that your login entry is on the first line
2692 of that file. If not, move it to the top.  It's OK
2693 for 'Administrator' to be the first entry, assuming you are one.
2694 </Para>
2695
2696 <Para>
2697 However, Win9x doesn't support the calls that <Command>mkpasswd</Command> relies on
2698 (e.g., <Function>NetUserEnum</Function>). If you run <Command>mkpasswd</Command> you
2699 get errors like:
2700 </Para>
2701
2702 <Screen>
2703 linked to missing export netapi32.dll:NetUserEnum
2704 </Screen>
2705
2706 <Para>
2707 The passwd file is used
2708 by ssh in a fairly rudimentary manner, so I'd simply 
2709 synthesise/copy an existing Unix <Filename>/etc/passwd</Filename>, i.e., create
2710 an <Filename>/etc/passwd</Filename> file containing the line
2711 </Para>
2712
2713 <Screen>
2714 &lt;login&gt;::500:513:::/bin/sh
2715 </Screen>
2716
2717 <Para>
2718 where <Literal>&lt;login&gt;</Literal> is your login id.
2719 </Para>
2720 </ListItem>
2721
2722 <ListItem>
2723 <Para>
2724 Generate a key, by running <Filename>c:/user/local/bin/ssh-keygen1</Filename>.
2725   This generates a public key in <Filename>.ssh/identity.pub</Filename>, and a
2726   private key in <Filename>.ssh/identity</Filename>
2727 </Para>
2728
2729 <Para>
2730   In response to the 'Enter passphrase' question, just hit
2731   return (i.e. use an empty passphrase).  The passphrase is
2732   a password that protects your private key.  But it's a pain
2733   to type this passphrase everytime you use <Command>ssh</Command>, so the best
2734   thing to do is simply to protect your <Filename>.ssh</Filename> directory, and
2735   <Filename>.ssh/identity</Filename> from access by anyone else.  To do this 
2736   right-click your <Filename>.ssh</Filename> directory, and select Properties.
2737   If you are not on the access control list, add yourself, and
2738   give yourself full permissions (the second panel).  
2739   Remove everyone else from the access control list.  (Don't
2740   leave them there but deny them access, because 'they' may be
2741   a list that includes you!)
2742 </Para>
2743
2744 <Para>
2745   If you have problems running <Command>ssh-keygen1</Command>
2746   from within <Command>bash</Command>, start up <Filename>cmd.exe</Filename> and run it as follows:
2747 </Para>
2748
2749 <Screen>
2750 c:\tmp> set CYGWIN32=tty
2751 c:\tmp> c:/user/local/bin/ssh-keygen1
2752 </Screen>
2753 </ListItem>
2754
2755 <ListItem>
2756 <Para>
2757 If you don't have an account on <Literal>cvs.haskell.org</Literal>, send 
2758   your <Filename>.ssh/identity.pub</Filename> to the CVS repository administrator
2759   (currently Jeff Lewis <Email>jlewis@cse.ogi.edu</Email>).  He will set up
2760   your account.
2761 </Para>
2762
2763 <Para>
2764   If you do have an account on <Literal>cvs.haskell.org</Literal>, use TeraTerm
2765   to logon to it. Once in, copy the
2766   key that <Command>ssh-keygen1</Command> deposited in <Filename>/.ssh/identity.pub</Filename> into
2767   your <Filename>~/.ssh/authorized_keys</Filename>. Make sure that the new version
2768   of <Filename>authorized_keys</Filename> still has 600 file permission.
2769 </Para>
2770 </ListItem>
2771
2772 </ItemizedList>
2773
2774 </Sect2>
2775
2776
2777 <Sect2><Title>Installing CVS</Title>
2778
2779 <ItemizedList>
2780
2781 <ListItem>
2782 <Para>
2783 Unpack 
2784 <ULink URL="http://research.microsoft.com/~simonpj/cvs-1_10-win.zip">
2785 CVS</ULink> and, following the instructions in the <Filename>README</Filename>, copy the
2786 appropriate files into <Filename>/usr/local/bin</Filename>.
2787 </Para>
2788 </ListItem>
2789
2790 <ListItem>
2791 <Para>
2792 From the System control panel,
2793 set the following <Emphasis>user</Emphasis> environment variables (see the GHC user guide)
2794 </Para>
2795
2796 <ItemizedList>
2797 <ListItem>
2798 <Para>
2799 <Constant>HOME</Constant>: points to your home directory.  This is where CVS
2800 will look for its <Filename>.cvsrc</Filename> file.
2801 </Para>
2802 </ListItem>
2803
2804 <ListItem>
2805 <Para>
2806 <Constant>CVS_RSH</Constant>: <Filename>c:/usr/local/bin/ssh1</Filename>
2807 </Para>
2808 </ListItem>
2809
2810 <ListItem>
2811 <Para>
2812 <Constant>CVSROOT</Constant>: <Literal>:ext:username@cvs.haskell.org:/home/cvs/root</Literal>,
2813 where <Literal>username</Literal> is your userid
2814 </Para>
2815 </ListItem>
2816
2817 <ListItem>
2818 <Para>
2819 <Constant>CVSEDITOR</Constant>: <Filename>bin/gnuclient.exe</Filename> if you want to use an Emacs buffer for typing in those long commit messages.
2820 </Para>
2821 </ListItem>
2822 </ItemizedList>
2823 </ListItem>
2824
2825 <ListItem>
2826 <Para>
2827 Put the following in <Filename>$HOME/.cvsrc</Filename>:
2828 </Para>
2829
2830 <ProgramListing>
2831 checkout -P
2832 release -d
2833 update -P
2834 diff -u
2835 </ProgramListing>
2836
2837 <Para>
2838 These are the default options for the specified CVS commands,
2839 and represent better defaults than the usual ones.  (Feel
2840 free to change them.)
2841 </Para>
2842
2843 <Para>
2844 Filenames starting with "<Filename>.</Filename>" were illegal in 
2845 the 8.3 DOS filesystem, but that restriction should have
2846 been lifted by now (i.e., you're using VFAT or later filesystems.) If
2847 you're still having problems creating it, don't worry; <Filename>.cvsrc</Filename> is entirely
2848 optional.
2849 </Para>
2850 </ListItem>
2851
2852 <ListItem>
2853 <Para>
2854 Try doing <Command>cvs co fpconfig</Command>. All being well, bytes should
2855 start to trickle through, leaving a directory <Filename>fptools</Filename>
2856 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:
2857 </Para>
2858
2859 <Screen>
2860 setsockopt IPTOS_LOWDELAY: Invalid argument
2861 setsockopt IPTOS_THROUGHPUT: Invalid argument
2862 </Screen>
2863
2864 <Para>
2865 At this point I found that CVS tried to invoke a little dialogue with
2866 me (along the lines of `do you want to talk to this host'), but
2867 somehow bombed out.  This was from a bash shell running in emacs.
2868 I solved this by invoking a Cygnus shell, and running CVS from there.
2869 Once things are dialogue free, it seems to work OK from within emacs.
2870 </Para>
2871 </ListItem>
2872
2873 <ListItem>
2874 <Para>
2875 If you want to check out part of large tree, proceed as follows:
2876 </Para>
2877
2878 <ProgramListing>
2879 cvs -f checkout -l papers
2880 cd papers
2881 cvs update cpr
2882 </ProgramListing>
2883
2884 <Para>
2885 This sequence checks out the <Literal>papers</Literal> module, but none
2886 of its sub-directories.
2887 The "<Option>-l</Option>" flag says not to check out sub-directories.
2888 The "<Option>-f</Option>" flag says not to read the <Filename>.cvsrc</Filename> file
2889 whose <Option>-P</Option> default (don't check out empty directories) is
2890 in this case bogus.
2891 </Para>
2892
2893 <Para>
2894 The <Command>cvs update</Command> command sucks in a named sub-directory.
2895 </Para>
2896 </ListItem>
2897
2898 </ItemizedList>
2899
2900 <Para>
2901 There is a very nice graphical front-end to CVS for Win32 platforms,
2902 with a UI that people will be familiar with, at 
2903 <ULink URL="http://www.wincvs.org/">wincvs.org</ULink>.
2904 I have not tried it yet.
2905 </Para>
2906
2907 </Sect2>
2908
2909
2910 <Sect2><Title>Installing autoconf</Title>
2911
2912 <Para>
2913 Only required if you are doing builds from GHC's sources
2914 checked out from the CVS tree.
2915 </Para>
2916
2917 <ItemizedList>
2918 <ListItem>
2919 <Para>
2920 Fetch the (standard, Unix) <Command>autoconf</Command> distribution from
2921 <ULink URL="ftp://ftp.gnu.org/gnu/autoconf">ftp.gnu.org</ULink>.
2922 </Para>
2923 </ListItem>
2924 <ListItem>
2925 <Para>
2926 Unpack it into an arbitrary directory.
2927 </Para>
2928 </ListItem>
2929 <ListItem>
2930 <Para>
2931 Make sure that the directory <Filename>/usr/local/bin</Filename> exists.
2932 </Para>
2933 </ListItem>
2934 <ListItem>
2935 <Para>
2936 Say "<Filename>./configure</Filename>".
2937 </Para>
2938 </ListItem>
2939 <ListItem>
2940 <Para>
2941 Now <Command>make install</Command>.  This should put <Filename>autoheader</Filename>
2942 and <Filename>autoconf</Filename> in <Filename>/usr/local/bin</Filename>.
2943 </Para>
2944 </ListItem>
2945 </ItemizedList>
2946
2947 <Para>
2948 <Command>autoheader</Command> doesn't seem to work, but you don't need it
2949 for GHC.
2950 </Para>
2951
2952 </Sect2>
2953
2954
2955 <Sect2><Title>Building GHC</Title>
2956
2957 <ItemizedList>
2958
2959 <ListItem>
2960 <Para>
2961 In the <Filename>./configure</Filename> output, ignore 
2962 "<Literal>
2963 checking whether #! works in shell scripts... 
2964 ./configure: ./conftest: No such file or directory</Literal>", 
2965 and "<Literal>not updating unwritable cache ./config.cache</Literal>".
2966 Nobody knows why these happen, but they seem to be harmless.
2967 </Para>
2968 </ListItem>
2969
2970 <ListItem>
2971 <Para>
2972 You have to run <Command>autoconf</Command> both in <Filename>fptools</Filename>
2973 and in <Filename>fptools/ghc</Filename>.  If you omit the latter step you'll
2974 get an error when you run <Filename>./configure</Filename>:
2975 </Para>
2976
2977 <Screen>
2978 ...lots of stuff...
2979 creating mk/config.h
2980 mk/config.h is unchanged
2981 configuring in ghc
2982 running /bin/sh ./configure  --cache-file=.././config.cache --srcdir=.
2983 ./configure: ./configure: No such file or directory
2984 configure: error: ./configure failed for ghc
2985 </Screen>
2986 </ListItem>
2987
2988 <ListItem>
2989 <Para>
2990 You need <Filename>ghc</Filename> to be in your <Constant>PATH</Constant> before you run
2991 <Command>configure</Command>.  The default GHC InstallShield creates only
2992 <Filename>ghc-4.05</Filename>, so you may need to duplicate this file as <Filename>ghc</Filename>
2993 in the same directory, in order that <Command>configure</Command> will see it (or
2994 just rename <Filename>ghc-4.05</Filename> to <Filename>ghc</Filename>.
2995 And make sure that the directory is in your path.
2996 </Para>
2997 </ListItem>
2998
2999 <ListItem>
3000 <Para>
3001 Compile <Command>happy</Command> and <Command>ghc</Command> 
3002 with <Option>-static</Option>.  To do this, set
3003 </Para>
3004
3005 <ProgramListing>
3006 GhcHcOpts=-static
3007 HappyHcOpts=-static
3008 </ProgramListing>
3009
3010 <Para>
3011 in your <Filename>build.mk</Filename> file.
3012 [Actually, I successfully compiled Happy without <Option>-static</Option> on Win2k, but not GHC.]
3013 </Para>
3014 </ListItem>
3015
3016 </ItemizedList>
3017
3018 </Sect2>
3019
3020 </Sect1>
3021
3022 </Article>