[project @ 1997-03-24 06:53:05 by sof]
[ghc-hetmet.git] / docs / installing.lit
1 %       Building and installing the Glasgow Functional Programming Tools Suite
2 %
3 %                               Version 2.02
4 %                               Feb 1997
5                         
6
7 \begin{onlystandalone}
8 \documentstyle[11pt,literate]{article}
9 \begin{document}
10 \title{Building and installing the Glasgow Functional Programming Tools Suite\\
11 Version~2.02}
12 \author{The GHC Team\\
13 Department of Computing Science\\
14 University of Glasgow\\
15 Glasgow, Scotland\\
16 G12 8QQ\\
17 \\
18 Email: glasgow-haskell-\{users,bugs\}\@dcs.gla.ac.uk}
19 \maketitle
20 \begin{rawlatex}
21 \tableofcontents
22 \end{rawlatex}
23 \clearpage
24 \end{onlystandalone}
25
26 This guide is intended for people who want to install or modify
27 programs from the Glasgow @fptools@ suite (as distinct from those
28 who merely want to {\em run} them).
29
30 The whole install-and-make system has been completely re-done
31 between GHC 2.01 and 2.02, so it will be worth your while to re-read this guide
32 even if you have done so before.
33
34 \section{Getting the Glasgow @fptools@ suite}
35
36 Building the Glasgow tools {\em can} be complicated, mostly because
37 there are so many permutations of what/why/how, e.g., ``Build Happy
38 with HBC, everything else with GHC, leave out profiling, and test it
39 all on the `real' NoFib programs.''  Yeeps!
40
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
45 \begin{description}
46 \item[Binary distribution.]  If your only purpose is to install
47 some of the @fptools@ suite then the easiest thing to do is to
48 get a binary distribution.  In the binary distribution everything is
49 pre-compiled for your particular machine architecture and operating
50 system, so all you should have to do is install the binaries and libraries
51 in suitable places.  {\em Need pointer to info about doing binary installation.}
52
53 A binary distribution may not work for you for two reasons.  
54 First, we may not have built the suite for the particular
55 architecture/OS platform you want.  That may be due to lack of time and
56 energy (in which case you can get a source distribution and build from it;
57 see below).  Alternatively, it may be because we havn't yet ported the
58 suite to your architecture, in which case you are considerably worse off.
59
60 The second reason a binary distribution may not be what you want is
61 if you want to read or modify the souce code.
62
63 \item[Source distribution.]
64 You have a supported
65 platform, but (a)~you like the warm fuzzy feeling of compiling things
66 yourself; (b)~you want to build something ``extra''---e.g., a set of
67 libraries with strictness-analysis turned off; or (c)~you want to hack
68 on GHC yourself.
69
70 A source distribution contains complete sources for the @fptools@ suite.
71 Not only that, but the more awkward machine-independent steps are done
72 for you.  For example, if you don't have @flex@ you'll it convenient that
73 the source distribution contains the result of running @flex@ on the
74 lexical analyser specification.  If you don't want to alter the lexical
75 analyser then this saves you having to find and install @flex@.
76 You will still need a working version of GHC on your machine in order to 
77 compile (most of) the sources, however.
78
79
80 \item[Build GHC from intermediate C \tr{.hc} files:] 
81 You need a working GHC to use a source distribution. What if you don't have a working GHC?
82 Then you have no choice but to ``bootstrap'' up from the
83 intermediate C (\tr{.hc}) files that we provide.
84 Building GHC on an unsupported platform falls into this category.
85 Please see \sectionref{booting-from-C}.
86
87 NB: For GHC~2.01, bootstrapping from \tr{.hc} files means you will get
88 an all-2.01 system---possibly unduly slow.  Building with GHC~0.29
89 will get you a faster compiler...
90
91 Once you have built GHC, you can build the other Glasgow tools with
92 it.
93
94 In theory, you can build GHC with another Haskell compiler (e.g.,
95 HBC).  We havn't tried to do this for ages and it almost certainly
96 doesn't work any more.
97
98 \item[The CVS repository.]
99 We make source distributions at the same time as binary distributions;
100 i.e. infrequently.  They should, however, be pretty throughly tested.
101 If you want more up-to-the minute (but less tested) source code then you 
102 need to get access to our CVS repository.
103
104 All the @fptools@ source code is held in a CVS repository.
105 CVS is a pretty good source-code control system, and best of all it works over the network.
106
107 The repository holds source code only.  It holds no mechanically generated
108 files at all.  So if you check out a source tree from CVS you will need
109 to install every utility so that you can build all the derived files
110 from scratch.
111
112 Giving you access to the repository entails some systems administration
113 at our end; and we are a bit nervous about being submerged in bug reports
114 about our current working copy (which is, by definition, in flux).  So
115 we are a bit cautious about offering CVS access.  Feel free to ask though!
116 \end{description} 
117
118 If you are going to do any building from sources (either from a source
119 distribution or the CVS repository) then you need to read all of this manual in detail.
120
121
122 %************************************************************************
123 %*                                                                      *
124 \section{Things to check before you start typing}
125 %*                                                                      *
126 %************************************************************************
127
128 Here's a list of things to check before you get started.
129 \begin{enumerate}
130 \item
131 \index{disk space needed}
132 Disk space needed: About 30MB (five hamburgers' worth) of disk space
133 for the most basic binary distribution of GHC; more for some
134 platforms, e.g., Alphas.  An extra ``bundle'' (e.g., concurrent
135 Haskell libraries) might take you to 8--10 hamburgers.
136
137 You'll need over 100MB (say, 20 hamburgers' worth) if you need to
138 build the basic stuff from scratch.
139
140 I don't yet know the disk requirements for the non-GHC tools.
141
142 All of the above are {\em estimates} of disk-space needs.
143
144 \item
145 Use an appropriate machine, compilers, and things.
146
147 SPARC boxes and DEC Alphas running OSF/1 are fully supported.
148 Linux, MIPS, and HP boxes are in pretty good shape.
149 \Sectionref{port-info} gives the full run-down on ports or lack
150 thereof.
151
152 \item
153 Be sure that the ``pre-supposed'' utilities are installed.
154 Section~\ref{sect_std-utils} elaborates.
155
156 \item
157 If you have any problem when building or installing the Glasgow tools,
158 please check the ``known pitfalls'' (\sectionref{build-pitfalls}).  If
159 you feel there is still some shortcoming in our procedure or
160 instructions, please report it.
161
162 For GHC, please see the bug-reporting section of the User's guide
163 (separate document), to maximise the usefulness of your report.
164
165 If in doubt, please send a message to
166 \tr{glasgow-haskell-bugs@dcs.gla.ac.uk}.
167 \end{enumerate}
168
169
170 %************************************************************************
171 %*                                                                      *
172 \section[port-info]{What machines the Glasgow tools, version~2.01, run on}
173 \index{ports, GHC}
174 \index{GHC ports}
175 \index{supported platforms}
176 \index{platforms, supported}
177 %*                                                                      *
178 %************************************************************************
179
180 The main question is whether or not the Haskell compiler (GHC) runs on
181 your platform.
182
183 A ``platform'' is a
184 architecture/manufacturer/operating-system combination,
185 such as @sparc-sun-solaris2.5.1@.  Other common ones are
186 @alpha-dec-osf2@, @hppa1.1-hp-hpux9@, @i386-unknown-linux@,
187 @i386-unknown-solaris2@, @i386-unknown-freebsd@,
188 @m68k-sun-sunos4@, @mips-sgi-irix5@,
189 @sparc-sun-sunos4@, @sparc-sun-solaris2@.
190
191 Bear in mind that certain ``bundles'', e.g. parallel Haskell, may not
192 work on all machines for which basic Haskell compiling is supported.
193
194 Some libraries may only work on a limited number of platforms; for
195 example, a sockets library is of no use unless the operating system
196 supports the underlying BSDisms.
197
198 %************************************************************************
199 %*                                                                      *
200 \subsection{What platforms the Haskell compiler (GHC) runs on}
201 %*                                                                      *
202 %************************************************************************
203 \index{fully-supported platforms}
204 \index{native-code generator}
205 \index{registerised ports}
206 \index{unregisterised ports}
207
208 The GHC hierarchy of Porting Goodness: (a)~Best is a native-code
209 generator; (b)~next best is a ``registerised''
210 port; (c)~the bare minimum is an ``unregisterised'' port.
211 ``Unregisterised'' is so terrible that we won't say more about it.
212
213 We use Sun4s running SunOS~4.1.3 and Solaris 2.5, and DEC~Alphas
214 running OSF/1~V2.0, so those are the ``fully-supported'' platforms,
215 unsurprisingly.  Both have native-code generators, for quicker
216 compilations.  The native-code generator for iX86 platforms (e.g.,
217 Linux ELF) is {\em nearly} working; but is not turned on by default.
218
219 Here's everything that's known about GHC ports, as of 2.01. We
220 identify platforms by their ``canonical GNU-style'' names.
221
222 Note that some ports are fussy about which GCC version you use; or
223 require GAS; or ...
224
225 \begin{description}
226 %-------------------------------------------------------------------
227 \item[\tr{alpha-dec-osf1}:]
228 \index{alpha-dec-osf1: fully supported}
229 (We have OSF/1 V2.0.) Fully supported, including native-code generator.
230 We recommend GCC 2.6.x or later.
231
232 %-------------------------------------------------------------------
233 \item[\tr{sparc-sun-sunos4}:]
234 \index{sparc-sun-sunos4: fully supported}
235 Fully supported, including native-code generator.
236
237 %-------------------------------------------------------------------
238 \item[\tr{sparc-sun-solaris2}:]
239 \index{sparc-sun-solaris2: fully supported}
240 Fully supported, including native-code generator.  A couple of quirks,
241 though: (a)~the profiling libraries are bizarrely huge; (b)~the
242 default \tr{xargs} program is atrociously bad for building GHC
243 libraries (see \sectionref{Pre-supposed} for details).
244
245 %-------------------------------------------------------------------
246 \item[HP-PA box running HP/UX 9.x:]
247 \index{hppa1.1-hp-hpux: registerised port}
248 Works registerised.  No native-code generator.
249 For GCC, you're best off with one of the Utah releases of
250 GCC~2.6.3 (`u3' or later), from \tr{jaguar.cs.utah.edu}.
251 We think a straight GCC 2.7.x works, too.
252
253 Concurrent/Parallel Haskell probably don't work (yet).
254 \index{hppa1.1-hp-hpux: concurrent---no}
255 \index{hppa1.1-hp-hpux: parallel---no}
256
257 %-------------------------------------------------------------------
258 \item[\tr{i386-*-linux} (PCs running Linux---ELF format):]
259 \index{i386-*-linux: registerised port}
260 GHC~2.01 works registerised.
261 You {\em must} have GCC 2.7.x or later.
262 The iX86 native-code generator is {\em nearly} there, but it
263 isn't turned on by default.
264
265 Profiling works, and Concurrent Haskell works.
266 \index{i386-*-linux: profiling---yes}
267 \index{i386-*-linux: concurrent---yes}
268 Parallel Haskell probably works.
269 \index{i386-*-linux: parallel---maybe}
270
271 On old Linux a.out systems: should be the same.
272 \index{i386-*-linuxaout: registerised port}
273
274 %-------------------------------------------------------------------
275 \item[\tr{i386-*-*bsd} (PCs running FreeBSD (and NetBSD?):]
276 \index{i386-*-freebsd: registerised port}
277 GHC~2.01 works registerised. Supports same set of bundles
278 as the above.
279
280 \index{i386-*-freebsd: profiling---yes}
281 \index{i386-*-freebsd: concurrent---yes}
282 \index{i386-*-freebsd: parallel---maybe}
283
284 %-------------------------------------------------------------------
285 \item[\tr{i386-unknown-cygwin32}:]
286 \index{i386-unknown-cygwin32: fully supported}
287 Fully supported under Win95/NT, including a native
288 code generator. Requires the @cygwin32@ compatibility library and
289 a healthy collection of GNU tools (i.e., gcc, GNU ld, bash etc.)
290 Profiling works, so does Concurrent Haskell. 
291 \index{i386-*-cygwin32: profiling---yes}
292 \index{i386-*-cygwin32: concurrent---yes}
293
294 % ToDo: more documentation on this is reqd here.
295
296 %-------------------------------------------------------------------
297 \item[\tr{mips-sgi-irix5}:]
298 \index{mips-sgi-irix5: registerised port}
299 GHC~2.01 works registerised (no native-code generator).
300 I suspect any GCC~2.6.x (or later) is OK.  The GCC that I used
301 was built with \tr{--with-gnu-as}; turns out that is important!
302
303 Concurrent/Parallel Haskell probably don't work (yet).
304 Profiling might work, but it is untested.
305 \index{mips-sgi-irix5: concurrent---no}
306 \index{mips-sgi-irix5: parallel---no}
307 \index{mips-sgi-irix5: profiling---maybe}
308
309 %-------------------------------------------------------------------
310 \item[\tr{m68k-apple-macos7} (Mac, using MPW):]
311 \index{m68k-apple-macos7: historically ported}
312 Once upon a time, David Wright in Tasmania has actually
313 gotten GHC to run on a Macintosh.  Ditto James Thomson here at Glasgow.
314 You may be able to get Thomson's from here.  (Not sure that it will
315 excite you to death, but...)
316
317 No particularly recent GHC is known to work on a Mac.
318
319 %-------------------------------------------------------------------
320 \item[\tr{m68k-next-nextstep3}:]
321 \index{m68k-next-nextstep3: historically ported}
322 Carsten Schultz succeeded with a ``registerised'' port of GHC~0.19.
323 There's probably a little bit-rot since then, but otherwise it should
324 still be fine.  Had a report that things were basically OK at 0.22.
325
326 Concurrent/Parallel Haskell probably won't work (yet).
327 \index{m68k-next-nextstep3: concurrent---no}
328 \index{m68k-next-nextstep3: parallel---no}
329
330 %-------------------------------------------------------------------
331 \item[\tr{m68k-sun-sunos4} (Sun3):]
332 \index{m68k-sun-sunos4: registerised port}
333 GHC~2.01 hasn't been tried on a Sun3.  GHC~0.26 worked registerised.
334 No native-code generator.
335
336 Concurrent/Parallel Haskell probably don't work (yet).
337 \index{m68k-sun-sunos4: concurrent---no}
338 \index{m68k-sun-sunos4: parallel---no}
339 \end{description}
340
341 %************************************************************************
342 %*                                                                      *
343 \subsection{What machines the other tools run on}
344 %*                                                                      *
345 %************************************************************************
346
347 Unless you hear otherwise, the other tools work if GHC works.
348
349 Haggis requires Concurrent Haskell to work.
350 \index{Haggis, Concurrent Haskell}
351
352
353 %************************************************************************
354 %*                                                                      *
355 \section[installing-bin-distrib]{Installing from binary distributions}
356 \index{binary installations}
357 \index{installation, of binaries}
358 %*                                                                      *
359 %************************************************************************
360
361 Installing from binary distributions is easiest, and recommended!
362 (Why binaries?  Because GHC is a Haskell compiler written in Haskell,
363 so you've got to ``bootstrap'' it, somehow.  We provide
364 machine-generated C-files-from-Haskell for this purpose, but it's
365 really quite a pain to use them.  If you must build GHC from its
366 sources, using a binary-distributed GHC to do so is a sensible way to
367 proceed. For the other @fptools@ programs, many are written in Haskell,
368 so binary distributions allow you to install them without having a Haskell compiler.)
369
370
371 \subsection{Bundle structure}
372
373 Binary distributions come in ``bundles,''\index{bundles of binary stuff}
374 one bundle per file called \tr{<bundle>-<platform>.tar.gz}.
375 (See Section~\ref{port-info} for what a platform is.)
376 Suppose that you untar a binary-distribution bundle, thus:
377 \begin{verbatim}
378   % cd /your/scratch/space
379   % gunzip < ghc-2.02-sun-sparc-solaris2.tar.gz | tar xvf -
380 \end{verbatim}
381 Then you should find a single directory, @fptools@, with the following
382 structure:
383 \begin{description}
384 \item[@Makefile.in@] the raw material from which the @Makefile@ will be made (\sectionref{sect_install}).
385 \item[@configure@] the configuration script (\sectionref{sect_install}).
386 \item[@README@] Contains this file summary.
387 \item[@INSTALL@] Contains this description of how to install the bundle.
388 \item[@ANNOUNCE-<bundle>@] The announcement message for the bundle.
389 \item[@NEWS-<bundle>@] release notes for the bundle -- a longer version of @ANNOUNCE@.
390 \item[@bin/<platform>/@] contains platform-specific executable files to be invoked
391 directly by the user.  These are the files that must end up in your path.
392 \item[@lib/<platform>@] contains platform-specific support files for the installation.
393 Typically there is a subdirectory for each @fptools@ project, whose name is
394 the name of the project with its version number.
395 For example, for GHC 2.02 there would be a sub-directory @ghc-2.02/@.
396
397 These sub-directories have the following general structure:
398 \begin{description}
399 \item[@libHS.a@ etc:] supporting library archives.
400 \item[@ghc-iface.prl@ etc:] support scripts.
401 \item[@import/@] Interface files (@.hi@) for the prelude.
402 \item[@include/@] A few C @#include@ files.
403 \end{description}
404
405 \item[@share/@] contains platform-independent support files for the installation.
406 Again, there is a sub-directory for each @fptools@ project.
407
408 \item[@info/@] contains Emacs info documentation files (one sub-directory per project).
409 \item[@html/@] contains HTML documentation files (one sub-directory per project).
410 \item[@man/@] contains Unix manual pages.
411 \end{description}
412 This structure is designed so that you can unpack multiple bundles (including
413 ones from different releases or platforms) into a single @fptools@ directory:
414 \begin{verbatim}
415   % cd /your/scratch/space
416   % gunzip < ghc-2.02-sun-sparc-solaris2.tar.gz | tar xvf -
417   % gunzip < happy-1.09-sun-sparc-sunos4.tar.gz | tar xvf -
418 \end{verbatim}
419 When you do multiple unpacks like this, the top level @Makefile@, @README@,
420 and @INSTALL@ get overwritten each time.  That's fine -- they should be the same.
421 Likewise, the @ANNOUNCE-<bundle>@ and @NEWS-<bundle>@ files will be duplicated
422 across multiple platforms, so they will be harmlessly overwritten when you do 
423 multiple unpacks.
424 Finally, the @share/@ stuff will get harmlessly overwritten when you do multiple
425 unpacks for one bundle on different platforms.
426
427 \subsection[sect_install]{Installing}
428
429 OK, so let's assume that you have unpacked your chosen bundles into
430 a scratch directory @fptools@. What next? Well, you will at least need
431 to run the @configure@ script by changing your directory to @fptools@.
432 That should convert @Makefile.in@ to @Makefile@.
433
434 You can now either start using the tools {\em in-situ} without going
435 through any installation process, just type @make config@ to set the
436 tools up for this (you have to be in the @fptools@ directory). You'll
437 also want to add the path which @make@ echoes to your @PATH@
438 environment variable. This option is useful if you simply want to try
439 out the package or you don't have the necessary priviledges (or
440 inclination) to properly install the tools locally. Note that if you
441 do decide to install the package `properly' at a later date, you have
442 to go through the installation steps that 
443 follows.
444
445 To install an @fptools@ package, you'll have to do the following:
446
447 \begin{enumerate}
448 \item Edit the @Makefile@ and check the settings of the following variables:
449 \begin{description}
450 \item[@platform@] the platform you are going to install for.
451 \item[@bindir@] the directory in which to install user-invokable binaries.
452 \item[@libdir@] the directory in which to install platform-dependent support files.
453 \item[@datadir@] the directory in which to install platform-independent support files. 
454 \item[@infodir@] the directory in which to install Emacs info files.
455 \item[@htmldir@] the directory in which to install HTML documentation.
456 \item[@dvidir@] the directory in which to install DVI documentation.
457 \end{description}
458 The values for these variables can be set through invocation of the
459 @configure@ script that comes with the distribution, but doing an optical
460 diff to see if the values match your expectations is always a Good Idea. 
461
462 {\em Instead of running @configure@, it is perfectly OK to copy
463 @Makefile.in@ to @Makefile@ and set all these variables directly
464 yourself.  But do it right!}
465
466 \item Run @make install@.  This {\em  should} works with ordinary Unix
467 @make@ -- no need for fancy stuff like GNU @make@. 
468
469 \item \tr{rehash} (t?csh users), so your shell will see the new stuff
470 in your bin directory.
471
472 \item
473 Once done, test your ``installation'' as suggested in
474 \sectionref{GHC_test}.  Be sure to use a \tr{-v} option, so you
475 can see exactly what pathnames it's using.
476
477 If things don't work as expected, check the list of know pitfalls
478 \sectionref{build-pitfalls}. 
479 \end{enumerate}
480
481 When installing the user-invokable binaries, this installation
482 procedure will install, say, @GHC@ version 2.02 as @ghc-2.02@.  It
483 will also make a link (in the binary installation directory) from
484 @ghc@ to @ghc-2.02@.  If you install multiple versions of GHC then the
485 last one ``wins'', and ``@ghc@'' will invoke the last one installed.
486 You can change this manually if you want.  But regardless, @ghc-2.02@
487 should always invoke @GHC@ version 2.02.
488
489 \subsection{What bundles there are}
490
491 There are plenty of ``non-basic'' GHC bundles.  The files for them are
492 called \tr{ghc-2.01-<bundle>-<platform>.tar.gz}, where the
493 \tr{<platform>} is as above, and \tr{<bundle>} is one of these:
494 \begin{description}
495 \item[\tr{prof}:]  Profiling with cost-centres.  You probably want this.
496
497 \item[\tr{conc}:] Concurrent Haskell features.  You may want this.
498
499 \item[\tr{par}:] Parallel Haskell features (sits on top of PVM).
500 You'll want this if you're into that kind of thing.
501
502 \item[\tr{gran}:] The ``GranSim'' parallel-Haskell simulator
503 (hmm... mainly for implementors).
504
505 \item[\tr{ticky}:] ``Ticky-ticky'' profiling; very detailed
506 information about ``what happened when I ran this program''---really
507 for implementors.
508
509 \item[\tr{prof-conc}:] Cost-centre profiling for Concurrent Haskell.
510
511 \item[\tr{prof-ticky}:]  Ticky-ticky profiling for Concurrent Haskell.
512 \end{description}
513
514 One likely scenario is that you will grab {\em three} binary
515 bundles---basic, profiling, and concurrent. 
516
517
518
519 %************************************************************************
520 %*                                                                      *
521 \subsection[GHC_test]{Test that GHC seems to be working}
522 \index{testing a new GHC}
523 %*                                                                      *
524 %************************************************************************
525
526 The way to do this is, of course, to compile and run {\em this} program
527 (in a file \tr{Main.hs}):
528 \begin{verbatim}
529 main = putStr "Hello, world!\n"
530 \end{verbatim}
531
532 First, give yourself a convenient way to execute the driver script
533 \tr{ghc/driver/ghc}, perhaps something like...
534 \begin{verbatim}
535 % ln -s /local/src/ghc-2.01/ghc/driver/ghc ~/bin/alpha/ghc
536 % rehash
537 \end{verbatim}
538
539 Compile the program, using the \tr{-v} (verbose) flag to verify that
540 libraries, etc., are being found properly:
541 \begin{verbatim}
542 % ghc -v -o hello Main.hs
543 \end{verbatim}
544
545 Now run it:
546 \begin{verbatim}
547 % ./hello
548 Hello, world!
549 \end{verbatim}
550
551 Some simple-but-profitable tests are to compile and run the
552 notorious \tr{nfib} program, using different numeric types.  Start
553 with \tr{nfib :: Int -> Int}, and then try \tr{Integer}, \tr{Float},
554 \tr{Double}, \tr{Rational} and maybe \tr{Complex Float}.  Code
555 for this is distributed in \tr{ghc/misc/examples/nfib/}.
556
557 For more information on how to ``drive'' GHC,
558 either do \tr{ghc -help} or consult the User's Guide (distributed in
559 \tr{ghc/docs/users_guide}).
560
561
562 %************************************************************************
563 %*                                                                      *
564 \section[Pre-supposed]{Installing pre-supposed utilities}
565 \index{pre-supposed utilities}
566 \index{utilities, pre-supposed}
567 %*                                                                      *
568 %************************************************************************
569
570 \label{sect_std-utils}
571
572 Here are the gory details about some utility programs you may need;
573 \tr{perl} and \tr{gcc} are the only important ones. (PVM is important
574 if you're going for Parallel Haskell.) The \tr{configure} script will
575 tell you if you are missing something.
576
577 \begin{description}
578 \item[Perl:]
579 \index{pre-supposed: Perl}
580 \index{Perl, pre-supposed}
581 {\em You have to have Perl to proceed!} Perl is a language quite good
582 for doing shell-scripty tasks that involve lots of text processing.
583 It is pretty easy to install.
584
585 Perl~5 is the current version; GHC should be Perl~4 friendly though.
586 For Win32 platforms, Perl~5 is recommended, we even strongly suggest
587 you pick up a port of Perl~5 for \tr{cygwin32}, as the common
588 Hip/ActiveWare port of Perl is not Cool Enough for our purposes.
589
590 Perl should be put somewhere so that it can be invoked by the \tr{#!}
591 script-invoking mechanism. (I believe \tr{/usr/bin/perl} is preferred;
592 we use \tr{/usr/local/bin/perl} at Glasgow.)  The full pathname should
593 be less than 32 characters long.
594
595 \item[GNU C (\tr{gcc}):]
596 \index{pre-supposed: GCC (GNU C compiler)}
597 \index{GCC (GNU C compiler), pre-supposed}
598 The current version is 2.7.2.  It has a bug that it ticked if you
599 compile the @gmp@ library without the @-O@ flag.  So the Makefile in
600 there has the @-O@ flag switched on!  Otherwise, 2.7.2 has no problems that we know of.
601
602 If your GCC dies with ``internal error'' on some GHC source file,
603 please let us know, so we can report it and get things improved.
604 (Exception: on \tr{iX86} boxes---you may need to fiddle with GHC's
605 \tr{-monly-N-regs} option; ask if confused...)
606
607 \item[PVM version 3:]
608 \index{pre-supposed: PVM3 (Parallel Virtual Machine)}
609 \index{PVM3 (Parallel Virtual Machine), pre-supposed}
610 PVM is the Parallel Virtual Machine on which Parallel Haskell programs
611 run.  (You only need this if you plan to run Parallel Haskell.  
612 Concurent Haskell, which runs concurrent threads on a uniprocessor)
613 doesn't need it.)
614 Underneath PVM, you can have (for example) a network of
615 workstations (slow) or a multiprocessor box (faster).
616
617 The current version of PVM is 3.3.11; we use 3.3.7.  It is readily available on
618 the net; I think I got it from \tr{research.att.com}, in \tr{netlib}.
619
620 A PVM installation is slightly quirky, but easy to do.  Just follow
621 the \tr{Readme} instructions.
622
623 \item[\tr{xargs} on Solaris2:]
624 \index{xargs, presupposed (Solaris only)}
625 \index{Solaris: alternative xargs}
626 The GHC libraries are put together with something like:
627 \begin{verbatim}
628 find bunch-of-dirs -name '*.o' -print | xargs ar q ...
629 \end{verbatim}
630 Unfortunately the Solaris \tr{xargs} (the shell-script equivalent
631 of \tr{map}) only ``bites off'' the \tr{.o} files a few at a
632 time---with near-infinite rebuilding of the symbol table in
633 the \tr{.a} file.
634
635 The best solution is to install a sane \tr{xargs} from the GNU
636 findutils distribution.  You can unpack, build, and install the GNU
637 version in the time the Solaris \tr{xargs} mangles just one GHC
638 library.
639
640 \item[\tr{bash} (Parallel Haskell only):]
641 \index{bash, presupposed (Parallel Haskell only)}
642 Sadly, the \tr{gr2ps} script, used to convert ``parallelism profiles''
643 to PostScript, is written in Bash (GNU's Bourne Again shell).
644 This bug will be fixed (someday).
645
646 \item[Makeindex:]
647 \index{pre-supposed: makeindex}
648 \index{makeindex, pre-supposed}
649 You won't need this unless you are re-making our documents.  Makeindex
650 normally comes with a \TeX{} distribution, but if not, we can provide
651 the latest and greatest.
652
653 \item[Tgrind:]
654 \index{pre-supposed: tgrind}
655 \index{tgrind, pre-supposed}
656 This is required only if you remake lots of our documents {\em and}
657 you use the \tr{-t tgrind} option with \tr{lit2latex} (also literate
658 programming), to do ``fancy'' typesetting of your code.  {\em
659 Unlikely.}
660
661 \item[Flex:]
662 \index{pre-supposed: flex}
663 \index{flex, pre-supposed}
664 This is a quite-a-bit-better-than-Lex lexer.  Used in the
665 literate-programming stuff.  You won't need it unless you're hacking
666 on some of our more obscure stuff.
667
668 \item[Yacc:]
669 \index{pre-supposed: non-worthless Yacc}
670 \index{Yacc, pre-supposed}
671 If you mess with the Haskell parser, you'll need a Yacc that can cope.
672 The unbundled \tr{/usr/lang/yacc} is OK; the GNU \tr{bison} is OK;
673 Berkeley yacc, \tr{byacc}, is not OK.
674
675 \item[@sed@]
676 \index{pre-supposed: sed}
677 \index{sed, pre-supposed}
678 You need a working @sed@ if you are going to build from sources.
679 The build-configuration stuff needs it.
680 GNU sed version 2.0.4 is no good! It has a bug in it that is tickled by the
681 build-configuration.  2.0.5 is ok. Others are probably ok too
682 (assuming we don't create too elaborate configure scripts..)
683 \end{description}
684
685 Two @fptools@ projects are worth a quick note at this point, because
686 they are useful for all the others:
687 \begin{itemize}
688 \item @glafp-utils@ contains several utilities which aren't
689 particularly Glasgow-ish, but Occasionally Indispensable.
690
691
692 \item @literate@ contains the Glasgow-built tools for generating
693 documentation.  (The unoriginal idea is to be able to generate @latex@, @info@,
694 and program code from a single source file.) To get anywhere you'll
695 need at least @lit2pgm@, either from the @literate@ project, or
696 because it's already installed on your system. 
697 \end{itemize}
698
699
700
701
702 %************************************************************************
703 %*                                                                      *
704 \section{Building from source}
705 %*                                                                      *
706 %************************************************************************
707
708 You've been rash enough to want to build some of
709 the Glasgow Functional Programming tools (GHC, Happy,
710 nofib, etc) from source.  You've slurped the source,
711 from the CVS repository or from a source distribution, and
712 now you're sitting looking at a huge mound of bits, wondering
713 what to do next.
714
715 Gingerly, you type @make all@.  Wrong already!
716
717 This rest of this guide is intended for duffers like me, who aren't really
718 interested in Makefiles and systems configurations, but who need
719 a mental model of the interlocking pieces so that they can 
720 make them work, extend them consistently when adding new
721 software, and lay hands on them gently when they don't work.
722
723 \subsection{Your source tree}
724
725 The source code is held in your {\em source tree}.
726 The root directory of your source tree {\em must}
727 contain the following directories and files:
728 \begin{itemize}
729 \item @Makefile@: the root Makefile.
730 \item @mk/@: the directory that contains the
731 main Makefile code, shared by all the
732 @fptools@ software.
733 \item @configure.in@: a file that tells the GNU configuration 
734 tools what @fptools@ needs to know about the host platform and
735 operating system. 
736 \end{itemize}
737 All the other directories are individual {\em projects} of the
738 @fptools@ system --- for example, the Glasgow Haskell Compiler (@ghc@),
739 the Happy parser generator (@happy@), the @nofib@ benchmark suite, 
740 and so on.
741 You can have zero or more of these.  Needless to say, some of them
742 are needed to build others.  For example, you need @happy@ to build
743 @ghc@.  You can either grab @happy@ too, or else you can use
744 a version of @happy@ that's already installed on your system, or 
745 grab a binary distribution of @happy@ and install it.
746
747 The important thing to remember is that even if you want only
748 one project (@happy@, say), you must have a source tree
749 whose root directory contains @Makefile@, 
750 @mk/@, @configure.in@, and the project(s) you 
751 want (@happy/@ in this case).  You cannot get by with 
752 just the @happy/@ directory.
753
754 \subsection{Build trees}
755
756 While you can build a system in the source tree, we don't recommend it.
757 We often want to build multiple versions of our software
758 for different architectures, or with different options (e.g. profiling).
759 It's very desirable to share a single copy of the source code among
760 all these builds.
761
762 So for every source tree we have zero or more {\em build trees}.
763 Each build tree is initially an exact copy of the source tree,
764 except that each file is a symbolic link to the source file, 
765 rather than being a copy of the source file.  There are ``standard''
766 Unix utilities that make such copies, so standard that they go by
767 different names: @lndir@, @mkshadowdir@ are two.  
768
769 The build
770 tree does not need to be anywhere near the source tree in the
771 file system.
772 Indeed, one advantage of separating the build tree from the source
773 is that the build tree can be placed in a non-backed-up partition,
774 saving your systems support people from backing up untold megabytes 
775 of easily-regenerated, and rapidly-changing, gubbins.  The golden rule is 
776 that (with a single exception -- Section~\ref{sect_build-config})
777 {\em absolutely
778 everything in the build tree is either a symbolic link to the source
779 tree, or else is mechanically generated}.  It should be perfectly 
780 OK for your build tree to vanish overnight; an hour or two compiling 
781 and you're on the road again.
782
783 You need to be a bit careful, though, that any new files you create
784 (if you do any development work) are in the source tree, not a build tree!
785
786 Remember, that the source files in the build tree are {\em symbolic
787 links} to the files in the source tree.  (The build tree soon
788 accumulates lots of built files like @Foo.o@, as well.)  You can {\em
789 delete} a source file from the build tree without affecting the source
790 tree (though it's an odd thing to do).  On the other hand, if you {\em
791 edit} a source file from the build tree, you'll edit the source-tree
792 file directly.  (You can set up Emacs so that if you edit a source
793 file from the build tree, Emacs will silently create an edited copy of
794 the source file in the build tree, leaving the source file unchanged;
795 but the danger is that you think you've edited the source file whereas
796 actually all you've done is edit the build-tree copy.  More commonly
797 you do want to edit the source file.)
798
799 Like the source tree, the top level of your build tree must (a linked copy of)
800 the root directory of the @fptools@ suite.
801 Inside Makefiles, the root of your build tree is called @$(FPTOOLS_TOP)@.
802 In the rest of this document path names are relative to @$(FPTOOLS_TOP)@ 
803 unless otherwise stated.  For example, the file @ghc/mk/target.mk@ is
804 actually @$(FPTOOLS_TOP)/ghc/mk/target.mk@.
805
806
807 \subsection{Getting the build you want}
808 \label{sect_build-config}
809
810 When you build @fptools@ you will be compiling code 
811 on a particular {\em host platform},
812 to run on a particular {\em target platform} (usually the same
813 as the host platform)\index{platform}.   The difficulty is 
814 that there are minor differences between different platforms;
815 minor, but enough that the code needs to be a bit different
816 for each.  There are some big differences too: for
817 a different architecture we need to build GHC with a different
818 native-code generator.
819
820 There are also knobs you can turn to control how the @fptools@
821 software is built.  For example, you might want to build GHC
822 optimised (so that it runs fast) or unoptimised (so that you can
823 compile it fast after you've modified it.
824 Or, you might want to compile it with debugging on (so that
825 extra consistency-checking code gets included) or off.  And so on.
826
827 All of this stuff is called the {\em configuration} of your build.
828 You set the configuration using an exciting three-step process.
829 \begin{description}
830 \item[Step 1: get ready for configuration.]
831 Change directory to @$(FPTOOLS)@ and issue the following two commands (with no arguments):
832 \begin{enumerate}
833 \item @autoconf@. This GNU program
834 converts @$(FPTOOLS)/configure.in@ to a shell script 
835 called @$(FPTOOLS)/configure@.
836
837 \item @autoheader@.  This second GNU program converts
838 @$(FPTOOLS)/configure.in@ to @$(FPTOOLS)/mk/config.h.in@.
839 \end{enumerate}
840 Both these steps are completely platform-independent; they just mean
841 that the human-written file (@configure.in@) can be short, although
842 the resulting shell script, @configure@, and @mk/config.h.in@, are long.
843
844 In case you don't have @autoconf@ and @autoheader@ we distribute
845 the results, @configure@, and @mk/config.h.in@, with the source distribution.
846 They aren't kept in the repository, though.
847
848 \item[Step 2: system configuration.]
849 Runs the newly-created @configure@ script, thus:
850 \begin{verbatim}
851   ./configure
852 \end{verbatim}
853 @configure@'s mission
854 is to scurry round your computer working out what architecture it has,
855 what operating system, whether it has the @vfork@ system call,
856 where @yacc@ is kept, whether @gcc@ is available, where various
857 obscure @#include@ files are, whether it's a leap year, and
858 what the systems manager had for lunch.
859 It communicates these snippets of information in two ways:
860 \begin{itemize}
861 \item It translates @mk/config.mk.in@ to @mk/config.mk@,
862 substituting for things between ``{\tt @@@@}'' brackets.  So,
863 ``{\tt @@HaveGcc@@}'' will be replaced by ``@YES@'' or ``@NO@''
864 depending on what @configure@ finds.
865 @mk/config.mk@ is included by every Makefile (directly or indirectly),
866 so the configuration information is thereby communicated to
867 all Makefiles.
868
869 \item It translates @mk/config.h.in@ to @mk/config.h@.
870 The latter is @#include@d by various C programs, which
871 can thereby make use of configuration information.
872 \end{itemize}
873
874
875 \item[Step 3: build configuration.] Next, you say how this build
876 of @fptools@ is to differ from the standard defaults by creating a new 
877 file @mk/build.mk@
878 {\em in the build tree}.  This file is the one and only
879 file you edit in the build tree, precisely because it says how
880 this build differs from the source.  (Just in case your build tree
881 does die, you might want to keep a private directory of @build.mk@ files,
882 and use a symbolic link in each build tree to point to the appropriate one.)
883 So @mk/build.mk@ never
884 exists in the source tree --- you create one in each build tree
885 from the template.  We'll discuss what to put in it shortly.
886 \end{description}
887 And that's it for configuration. Simple, eh?
888
889 What do you put in your build-specific configuration
890 file @mk/build.mk@?  {\em For almost all purposes all you will do is
891 put make variable definitions that override those in @mk/config.mk.in@}.
892 The whole point of @mk/config.mk.in@ --- and its derived 
893 counterpart @mk/config.mk@ --- is to define the build configuration. It is heavily
894 commented, as you will see if you look at it.
895 So generally, what you do is edit @mk/config.mk.in@ (read-only), and add definitions
896 in @mk/build.mk@ that override any of the @config.mk@ definitions that you
897 want to change.  (The override occurs because the main boilerplate file,
898 @mk/boilerplate.mk@, includes @build.mk@ after @config.mk@.)
899
900 For example, @config.mk.in@ contains the definition:
901 \begin{verbatim}
902   ProjectsToBuild = glafp-utils literate ghc hslibs
903 \end{verbatim}
904 The accompanying comment explains that this is the list of enabled
905 projects; that is, if (after configuring) you type @gmake all@
906 in @FPTOOLS_TOP@ three specified projects will be made.
907 If you want to add @happy@, you can add this line to @build.mk@:
908 \begin{verbatim}
909   ProjectsToBuild += happy
910 \end{verbatim}
911 or, if you prefer,
912 \begin{verbatim}
913   ProjectsToBuild = glafp-utils literate ghc hslibs happy
914 \end{verbatim}
915 (GNU @make@ allows existing definitions to have new text appended using
916 the ``@+=@'' operator, which is quite a convenient feature.)
917
918 When reading @config.mk.in@, remember that anything between ``{\tt @@...@@}'' signs
919 is going to be substituted by @configure@ later.  You {\em can} override
920 the resulting definition if you want, 
921 but you need to be a bit surer what you are doing.
922 For example, there's a line that says:
923 \begin{verbatim}
924   YACC = @Yacc@
925 \end{verbatim}
926 This defines the Make variables @YACC@ to the pathname for a Yacc that
927 @configure@ finds somewhere.  If you have your own pet Yacc you want
928 to use instead, that's fine. Just add this line to @mk/build.mk@:
929 \begin{verbatim}
930   YACC = myyacc
931 \end{verbatim}
932 You do not {\em have} to have a @mk/build.mk@ file at all; if you don't,
933 you'll get all the default settings from @mk/config.mk.in@.
934
935
936 \subsection{The story so far}
937
938 Let's summarise the steps you need to carry to get yourself
939 a fully-configured build tree from scratch.
940
941 \begin{enumerate}
942 \item Get your source tree from somewhere (CVS repository or
943 source distribution).  Say you call the root directory
944 @myfptools@ (it does not have to be called @fptools@).
945
946 \item Use @lndir@ or @mkshadowdir@ to create a build tree.
947 \begin{verbatim}
948     cd myfptools
949     mkshadowdir . /scratch/joe-bloggs/myfptools-sun4
950 \end{verbatim}
951 You probably want to give the build tree a name that
952 suggests its main defining characteristic (in your mind at least),
953 in case you later add others.
954
955 \item Change directory to the build tree.  Everything is going
956 to happen there now.
957 \begin{verbatim}
958     cd /scratch/joe-bloggs/myfptools-sun4
959 \end{verbatim}
960 \item Prepare for system configuration:
961 \begin{verbatim}
962     autoconf
963     autoheader
964 \end{verbatim}
965 (You can skip this step if you are starting from a source distribution,
966 and you already have @configure@ and @mk/config.h.in@.)
967
968 \item Do system configuration:
969 \begin{verbatim}
970     ./configure
971 \end{verbatim}
972
973 \item Create the file @mk/build.mk@, 
974 adding definitions for your desired configuration options.
975 \begin{verbatim}
976     emacs mk/build.mk
977 \end{verbatim}
978 \end{enumerate}
979 You can make subsequent changes to @mk/build.mk@ as often 
980 as you like.  You do not have to run any further configuration 
981 programs to make these changes take effect.
982 In theory you should, however, say @gmake clean@, @gmake all@,
983 because configuration option changes could affect anything --- but in practice you are likely to know what's affected.
984
985 \subsection{Making things}
986
987 At this point you have made yourself a fully-configured build tree,
988 so you are ready to start building real things.
989
990 The first thing you need to know is that 
991 {\em you must use GNU @make@, usually called @gmake@, not standard Unix @make@}.
992 If you use standard Unix @make@ you will get all sorts of error messages
993 (but no damage) because the @fptools@ @Makefiles@ use GNU @make@'s facilities
994 extensively.
995
996 \subsection[sect_standard-targets]{Standard targets}
997
998 In any directory you should be able to make the following:
999 \begin{description}
1000 \item[@boot@:] does the one-off preparation required to get ready
1001 for the real work.  Notably, it does @gmake depend@ in all directories
1002 that contain programs.  But @boot@ does more.  For example, you can't
1003 do @gmake depend@ in a directory of C program until you have converted
1004 the literate @.lh@ header files into standard @.h@ header files.  Similarly, you convert a literate file to illiterate
1005 form until you have built the @literate@ tools.  @boot@ takes care of these
1006 inter-directory dependencies.
1007
1008 You should say @gmake boot@ right after configuring your build tree.
1009
1010 \item[@all@:] makes all the final target(s) for this Makefile.
1011 Depending on which directory you are in a ``final target''
1012 may be an executable program, a library archive, a shell script,
1013 or a Postscript file.
1014 Typing @gmake@ alone is generally the same as typing @gmake all@.
1015
1016 \item[@install@:] installs the things built by @all@.  Where does it
1017 install them?  That is specified by @mk/config.mk.in@; you can 
1018 override it in @mk/build.mk@.
1019
1020 \item[@uninstall@:] reverses the effect of @install@.
1021
1022 \item[@clean@:] remove all easily-rebuilt files.
1023
1024 \item[@veryclean@:] remove all files that can be rebuilt at all.
1025 There's a danger here that you may remove a file that needs a more
1026 obscure 
1027 utility to rebuild it (especially if you started from a source
1028 distribution).
1029
1030 \item[@check@:] run the test suite.
1031 \end{description}
1032 All of these standard targets
1033 automatically recurse into sub-directories.
1034 Certain other standard targets do not:
1035 \begin{description}
1036 \item[@configure@:] is only available in the root directory @$(FPTOOLS)@;
1037 it has been discussed in Section~\ref{sect_build-config}.
1038
1039 \item[@depend@:] make a @.depend@ file in each directory that needs
1040 it. This @.depend@ file contains mechanically-generated dependency
1041 information; for example, suppose a directory contains a Haskell 
1042 source module @Foo.lhs@ which imports another module @Baz@.
1043 Then the generated @.depend@ file will contain the dependency:
1044 \begin{verbatim}
1045   Foo.o : Baz.hi
1046 \end{verbatim}
1047 which says that the object file @Foo.o@ depends on the interface
1048 file @Baz.hi@ generated by compiling module @Baz@.
1049 The @.depend@ file is automatically included by every Makefile.
1050
1051 \item[@binary-dist@:] make a binary distribution.
1052
1053 \item[@dist@:] make a source distribution.
1054 \end{description}
1055
1056 \subsection{Other targets}
1057
1058 Most @Makefiles@ have targets other than these.  You can find
1059 this out by looking in the @Makefile@ itself.
1060
1061
1062
1063
1064 %************************************************************************
1065 %*                                                                      *
1066 \section{The @Makefile@ architecture}
1067 %*                                                                      *
1068 %************************************************************************
1069
1070
1071 @make@ is great if everything works --- you type @gmake install@ and, lo,
1072 the right things get compiled and installed in the right places.
1073 Our goal is to make this happen often, but somehow it often doesn't;
1074 instead
1075 some wierd error message eventually emerges from the bowels of a directory
1076 you didn't know existed.
1077
1078 The purpose of this section is to give you a road-map to help you figure
1079 out what is going right and what is going wrong.
1080
1081 \subsection{A small project}
1082
1083 To get started, let us look at the @Makefile@ for an imaginary small
1084 @fptools@ project, @small@.  Each project in @fptools@ has its own
1085 directory in @FPTOOLS_TOP@, so the @small@ project will have its own
1086 directory @FPOOLS_TOP/small/@.  Inside the @small/@ directory there
1087 will be a @Makefile@, looking something like this:
1088 \begin{verbatim}
1089   #     Makefile for fptools project "small"
1090
1091   TOP = ..
1092   include $(TOP)/mk/boilerplate.mk
1093
1094   SRCS = $(wildcard *.lhs) $(wildcard *.c)
1095   HS_PROG = small
1096
1097   include $(TOP)/target.mk
1098 \end{verbatim}
1099 This @Makefile@ has three sections:
1100 \begin{enumerate}
1101 \item The first section includes\footnote{One of the
1102 most important features of GNU @make@ that we use is the ability
1103 for a @Makefile@ to include another named file, very like @cpp@'s @#include@ directive.}
1104 a file of ``boilerplate'' code from the
1105 level above (which in this case will be @FPTOOLS_TOP/mk/boilerplate.mk@).
1106 As its name suggests, @boilerplate.mk@ consists of a large quantity of standard
1107 @Makefile@ code.  We discuss this boilerplate in more detail in Section~\ref{sect_boiler}.
1108
1109 Before the @include@ statement, you must define the @make@ variable
1110 @TOP@ to be the directory containing the @mk@ directory in which
1111 the @boilerplate.mk@ file is.
1112 It is {\em not} OK to simply say
1113 \begin{verbatim}
1114   include ../mk/boilerplate.mk  # NO NO NO
1115 \end{verbatim}
1116 Why?  Because the @boilerplate.mk@ file needs to know where it is,
1117 so that it can, in turn, @include@ other files.
1118 (Unfortunately, when an @include@d file does an
1119 @include@, the filename is treated
1120 relative to the directory in which @gmake@ is being run, not
1121 the directory in which the @included@ sits.) 
1122 In general,
1123 {\em every file @foo.mk@ 
1124 assumes that @$(TOP)/mk/foo.mk@ refers to itself.}  
1125 It is up to the @Makefile@ doing the @include@ to ensure this
1126 is the case.
1127
1128 Files intended for inclusion in other @Makefile@s are written to have
1129 the following property:
1130 {\em after @foo.mk@ is @include@d, it leaves @TOP@ containing the same
1131 value as it had just before the @include@ statement}.
1132 In our example, this invariant guarantees that the @include@
1133 for @target.mk@ will look in the same directory as that for
1134 @boilerplate.mk@.
1135
1136 \item The second section 
1137 defines the following standard @make@ variables: @SRCS@ (the source files from
1138 which is to be built), and @HS_PROG@ (the
1139 executable binary to be built).  
1140 We will discuss in more detail what the ``standard variables'' are,
1141 and how they affect what happens, in Section~\ref{sect_targets}.
1142
1143 The definition for @SRCS@ uses the useful GNU @make@
1144 construct @$(wildcard@~$pat$@)@, which expands to a list of all the
1145 files matching the pattern $pat$ in the current directory.
1146 In this example, @SRCS@ is set to the list of all the @.lhs@ and @.c@ files
1147 in the directory.  (Let's suppose there is one of each, @Foo.lhs@
1148 and @Baz.c@.)
1149
1150 \item The last section includes a second file of standard code,
1151 called @target.mk@.  It contains the rules that tell @gmake@
1152 how to make the standard targets
1153 (Section~\ref{sect_standard-targets}).
1154 Why, you ask, can't this standard code
1155 be part of @boilerplate.mk@?  Good question.
1156 We discuss the reason later, in Section~\ref{sect_boiler-arch}.
1157
1158 You do not {\em have} to @include@ the @target.mk@ file.  Instead,
1159 you can write rules of your own for all the standard targets.
1160 Usually, though, you will find quite a big payoff from using
1161 the canned rules in
1162 @target.mk@; the price tag is that you have to understand
1163 what canned rules get enabled, and what they do (Section~\ref{sect_targets}).
1164 \end{enumerate}
1165
1166 In our example @Makefile@, most of the work is done 
1167 by the two @include@d files.  When you say @gmake all@,
1168 the following things happen:
1169 \begin{itemize}
1170 \item @gmake@ figures out that the object files are @Foo.o@ and @Baz.o@.
1171 \item It uses a boilerplate pattern rule to compile 
1172 @Foo.lhs@ to @Foo.o@ using
1173 a Haskell compiler.  (Which one?  That is set in the build configuration.)
1174 \item It uses another standard pattern rule to compile @Baz.c@ to @Baz.o@,
1175 using a C compiler.  (Ditto.)
1176 \item It links the resulting @.o@ files together to make @small@,
1177 using the Haskell compiler to do the link step.  (Why not use @ld@?  Because
1178 the Haskell compiler knows what standard librarise to link in.  How did @gmake@
1179 know to use the Haskell compiler to do the link, rather than the C compiler?
1180 Because we set the variable @HS_PROG@ rather than @C_PROG@.)
1181 \end{itemize}
1182 All @Makefile@s should follow the above three-section format.
1183
1184 \subsection{A larger project}
1185
1186 Larger projects are usually structured into a nummber of sub-directories,
1187 each of which has its own @Makefile@.  (In very large projects, this
1188 sub-structure might be iterated recursively, though that is rare.)
1189 To give you the idea, here's part of the directory structure for
1190 the (rather large) @ghc@ project:
1191 \begin{verbatim}
1192   $(FPTOOLS_TOP)/ghc/
1193     Makefile
1194
1195     mk/
1196       boilerplate.mk
1197       rules.mk
1198
1199     docs/
1200       Makefile
1201       ...source files for documentation...
1202
1203     driver/
1204       Makefile
1205       ...source files for driver...
1206
1207     compiler/
1208       Makefile
1209       parser/...source files for parser...
1210       renamer/...source files for renamer...
1211       ...etc...
1212 \end{verbatim}
1213 The sub-directories @docs@, @driver@, @compiler@, and so on, each contains
1214 a sub-component of @ghc@, and each has its own @Makefile@.
1215 There must also be a @Makefile@ in @$(FPTOOLS_TOP)/ghc@.
1216 It does most of its work by recursively invoking @gmake@
1217 on the @Makefile@s in the sub-directories.
1218 We say that @ghc/Makefile@ is a {\em non-leaf @Makefile@},
1219 because it does little except organise its children, while the @Makefile@s
1220 in the sub-directories are all {\em leaf @Makefile@s}.  (In principle
1221 the sub-directories might themselves contain a non-leaf @Makefile@ and
1222 several sub-sub-directories, but that does not happen in @ghc@.)
1223
1224 The @Makefile@ in @ghc/compiler@ is considered a leaf @Makefile@ even
1225 though the @ghc/compiler@ has sub-directories, because these sub-directories
1226 do not themselves have @Makefile@ in them.  They are just used to structure
1227 the collection of modules that make up @ghc@, but all are managed by the
1228 single @Makefile@ in @ghc/compiler@.
1229
1230 You will notice that @ghc/@ also contains a directory @ghc/mk/@.
1231 It contains @ghc@-specific @Makefile@ boilerplate code.
1232 More precisely:
1233 \begin{itemize}
1234 \item @ghc/mk/boilerplate.mk@ is included at the top of @ghc/Makefile@,
1235 and of all the leaf @Makefile@s in the sub-directories.
1236 It in turn @include@s the main boilerplate file @mk/boilerplate.mk@.
1237
1238 \item @ghc/mk/target.mk@ is @include@d at the bottom of @ghc/Makefile@,
1239 and of all the leaf @Makefiles@ in the sub-directories.
1240 It in turn @include@s the file @mk/target.mk@.
1241 \end{itemize}
1242 So these two files are the place to look for @ghc@-wide customisation
1243 of the standard boilerplate.
1244
1245
1246
1247 \subsection{Boilerplate architecture}
1248 \label{sect_boiler-arch}
1249
1250 Every @Makefile@ includes a @boilerplate.mk@ file at the top,
1251 and @target.mk@ file at the bottom.  In this section we discuss
1252 what is in these files, and why there have to be two of them.
1253 In general:
1254 \begin{itemize}
1255 \item @boilerplate.mk@ consists of:
1256 \begin{itemize}
1257 \item {\em Definitions of millions of @make@ variables} that collectively
1258 specify the build configuration.  Examples: @HC_OPTS@, the options to
1259 feed to the Haskell compiler; @NoFibSubDirs@, the sub-directories to
1260 enable within the @nofib@ project; @GhcWithHc@, the name of the
1261 Haskell compiler to use when compiling @GHC@ in the @ghc@ project.
1262 \item {\em Standard pattern rules} that tell @gmake@ how to construct
1263 one file from another.  
1264 \end{itemize}
1265 @boilerplate.mk@ needs to be @include@d at the {\em top} of each 
1266 @Makefile@, so that the 
1267 user can replace the boilerplate definitions or pattern rules by simply 
1268 giving a new definition or pattern rule in the @Makefile@.  @gmake@ simply
1269 takes the last definition as the definitive one.
1270
1271 Instead of {\em replacing} boilerplate definitions, it is also quite
1272 common to {\em augment} them. For example, a @Makefile@ might say:
1273 \begin{verbatim}
1274   SRC_HC_OPTS += -O
1275 \end{verbatim}
1276 thereby adding ``@-O@'' to the end of @SRC_HC_OPTS@. 
1277
1278 \item @target.mk@ contains @make@ rules for the standard targets described
1279 in Section~\ref{sect_standard-targets}.
1280 These rules are selectively included, depending on the setting of
1281 certain @make@ variables.  These variables are usually set in the middle
1282 section of the @Makefile@ between the two @include@s.
1283
1284 @target.mk@ must be included at the end (rather than being part of @boilerplate.mk@)
1285 for several tiresome reasons:
1286 \begin{itemize}
1287 \item @gmake@ commits target and dependency lists earlier than it should.
1288 For example, @target.mk@ has a rule that looks like this:
1289 \begin{verbatim}
1290   $(HS_PROG) : $(OBJS)
1291         $(HC) $(LD_OPTS) $< -o $@
1292 \end{verbatim}
1293 If this rule was in @boilerplate.mk@ then @$(HS_PROG)@ and @$(OBJS)@
1294 would not have their final values at the moment @gmake@ encountered the
1295 rule.  Alas, @gmake@ takes a snapshot of their current values, and 
1296 wires that snapshot into the rule.
1297 (In contrast, the commands executed when the rule ``fires'' are
1298 only substituted at the moment of firing.)
1299 So, the rule must follow the definitions given in the @Makefile@ itself.
1300
1301 \item Unlike pattern rules, ordinary rules cannot be overriden or
1302 replaced by subsequent rules for the same target (at least not without an
1303 error message).  Including ordinary rules in @boilerplate.mk@ would
1304 prevent the user from writing rules for specific targets in specific cases.
1305
1306 \item There are a couple of other reasons I've forgotten, but it doesn't
1307 matter too much.
1308 \end{itemize}
1309 \end{itemize}
1310
1311 \subsection{The main @mk/boilerplate.mk@ file}
1312 \label{sect_boiler}
1313
1314 If you look at @$(FPTOOLS_TOP)/mk/boilerplate.mk@ you will find that
1315 it consists of the following sections, each held in a separate file:
1316 \begin{description}
1317 \item[@config.mk@] is the build configuration file we discussed at length
1318 in Section~\ref{sect_build-config}.
1319
1320 \item[@paths.mk@] defines @make@ variables for pathnames and file
1321 lists.  In particular, it gives definitions for:
1322 \begin{description}
1323 \item[@SRCS@:] all source files in the current directory.
1324 \item[@HS_SRCS@:] all Haskell source files in the current directory.
1325 It is derived from @$(SRCS)@, so if you override @SRCS@ with a new value
1326 @HS_SRCS@ will follow suit.
1327 \item[@C_SRCS@:] similarly for C source files.
1328 \item[@HS_OBJS@:] the @.o@ files derived from @$(HS_SRCS)@.
1329 \item[@C_OBJS@:] similarly for @$(C_SRCS)@.
1330 \item[@OBJS@:] the concatenation of @$(HS_OBJS)@ and @$(C_OBJS)@.
1331 \end{description}
1332 Any or all of these definitions can easily be overriden by giving new
1333 definitions in your @Makefile@.  For example, 
1334 if there are things in the current directory that look like source files
1335 but aren't, then you'll need to set @SRCS@ manually in your @Makefile@.
1336 The other definitions will then work from this new definition.
1337
1338 What, exactly, does @paths.mk@ consider a ``source file'' to be.
1339 It's based the file's suffix (e.g. @.hs@, @.lhs@, @.c@, @.lc@, etc), 
1340 but this is the kind of detail that changes
1341 more rapidly, so rather than enumerate the source suffices here the best thing
1342 to do is to look in @paths.mk@.
1343
1344 \item[@opts.mk@] defines @make@ variables for option strings to
1345 pass to each program. For example, it defines @HC_OPTS@, the
1346 option strings to pass to the Haskell compiler.  See  \sectionref{sect_suffix}.
1347
1348 \item[@suffix.mk@] defines standard pattern rules -- see \sectionref{sect_suffix}
1349 \end{description}
1350 Any of the variables and pattern rules defined by the boilerplate file
1351 can easily be overridden in any particular @Makefile@, because
1352 the boilerplace @include@ comes first.  Definitions after this
1353 @include@ directive simply override the default ones in @boilerplate.mk@.
1354
1355 \subsection[sect_suffix]{Pattern rules and options}
1356
1357 The file @suffix.mk@ defines standard {\em pattern rules} that say how to build one kind
1358 of file from another, for example, how to build a @.o@ file from a @.c@ file.
1359 (GNU @make@'s {\em pattern rules} are more powerful and easier to use than
1360 Unix @make@'s {\em suffix rules}.)
1361
1362 Almost all the rules look something like this:
1363 \begin{verbatim}
1364 %.o : %.c
1365         @$(RM) $@
1366         $(CC) $(CC_OPTS) -c $< -o $@
1367 \end{verbatim}
1368 Here's how to understand the rule.  It says that $something@.o@$ (say @Foo.o@)
1369 can be built from $something@.c@$ (@Foo.c@), by invoking the C compiler
1370 (path name held in @$(CC)@), passing to it the options @$(CC_OPTS)@ and the rule's 
1371 dependent
1372 file of the rule @$<@ (@Foo.c@ in this case), and putting the result in
1373 the rule's target @$@@@ (@Foo.o@ in this case).
1374
1375 Every program is held in a @make@ variable defined in @mk/config.mk@ --- look in @mk/config.mk@ for
1376 the complete list.  One important one is the Haskell compiler, which is called @$(HC)@.
1377
1378 Every programs options are are held in a @make@ variables called @<prog>_OPTS@.
1379 the @<prog>_OPTS@ variables are defined in @mk/opts.mk@.  Almost all of them are defined
1380 like this:
1381 \begin{verbatim}
1382   CC_OPTS = $(SRC_CC_OPTS) $(WAY$(_way)_CC_OPTS) $($*_CC_OPTS) $(EXTRA_CC_OPTS)
1383 \end{verbatim}
1384 The four variables from which @CC_OPTS@ is built have the following meaning:
1385 \begin{description}
1386 \item[@SRC_CC_OPTS@:] options passed to all C compilations.
1387 \item[@WAY_<way>_CC_OPTS@:] options passed to C compilations for way @<way>@. For example,
1388 @WAY_mp_CC_OPTS@ gives options to pass to the C compiler when compiling way @mp@.
1389 The variable @WAY_CC_OPTS@ holds options to pass to the C compiler when compiling the standard way.
1390 (Section~\ref{sect_ways} dicusses multi-way compilation.)
1391 \item[@<module>_CC_OPTS@:] options to pass to the C compiler that are specific to module @<module>@.
1392 For example, @SMap_CC_OPTS@ gives the specific options to pass to the C compiler when compiling
1393 @SMap.c@.
1394 \item[@EXTRA_CC_OPTS@:] extra options to pass to all C compilations.  This is intended for command
1395 line use, thus;
1396 \begin{verbatim}
1397   gmake libHS.a EXTRA_CC_OPTS="-v"
1398 \end{verbatim}
1399 \end{description}
1400
1401
1402 \subsection{The main @mk/target.mk@ file}
1403 \label{sect_targets}
1404
1405 @target.mk@ contains canned rules for all the standard targets described in
1406 Section~\ref{sect_standard-targets}.  It is complicated by the fact
1407 that you don't want all of these rules to be active in every @Makefile@.
1408 Rather than have a plethora of tiny files which you can include selectively,
1409 there is a single file, @target.mk@, which selectively includes rules 
1410 based on whether you have defined certain variables in your @Makefile@.
1411 This section explains what rules you get, what variables control them, and 
1412 what the rules do.  Hopefully, you will also get enough of an idea of what is supposed
1413 to happen that you can read and understand any wierd special cases yourself.
1414
1415 \begin{description}
1416 \item{@HS_PROG@.}  If @HS_PROG@ is defined, you get rules with the
1417 following targets:
1418 \begin{description}
1419 \item[@HS_PROG@] itself.  This rule links @$(OBJS)@ with the Haskell
1420 runtime system to get an executable called @$(HS_PROG)@.
1421 \item[@install@] installs @$(HS_PROG)@ in @$(bindir)@ with the execute bit set.
1422 \end{description}
1423
1424 \item[@C_PROG@] is similar to @HS_PROG@, except that the link step
1425 links @$(C_OBJS)@ with the C runtime system.
1426
1427 \item[@LIBRARY@] is similar to @HS_PROG@, except
1428 that it links @$(LIB_OBJS)@ to make the library archive @$(LIBRARY)@,
1429 and @install@ installs it in @$(libdir)@, with the execute bit not set.
1430
1431 \item[@LIB_DATA@] ...
1432 \item[@LIB_EXEC@] ...
1433
1434 \item[@HS_SRCS@, @C_SRCS@.] If @HS_SRCS@ is defined and non-empty, a rule for
1435 the target @depend@ is included, which generates dependency information for
1436 Haskell programs.  Similarly for @C_SRCS@.
1437 \end{description}
1438
1439 All of these rules are ``double-colon'' rules, thus
1440 \begin{verbatim}
1441   install :: $(HS_PROG)
1442         ...how to install it...
1443 \end{verbatim}
1444 GNU @make@ treats double-colon rules as separate entities.  If there
1445 are several double-colon rules for the same target it takes each in turn
1446 and fires it if its dependencies say to do so.  This means that you can,
1447 for example, define both @HS_PROG@ and @LIBRARY@, which will generate two
1448 rules for @install@.  When you type @gmake install@ both rules will be fired,
1449 and both the program and the library will be installed, just as you wanted.
1450
1451 \subsection{Recursion}
1452 \label{sect_subdirs}
1453
1454 In leaf @Makefiles@ the variable @SUBDIRS@ is undefined.  In non-leaf
1455 @Makefiles@, @SUBDIRS@ is set to the list of sub-directories that contain subordinate
1456 @Makefile@s.  {\em It is up to you to set @SUBDIRS@ in the @Makefile@.}
1457 There is no automation here --- @SUBDIRS@ is too important automate.
1458
1459 When @SUBDIRS@ is defined, @target.mk@ includes a rather neat rule for
1460 the standard targets (Section~\ref{sect_standard-targets}) that 
1461 simply invokes @make@ recursively in each of the sub-directories.
1462
1463 {\em These recursive invocations are guaranteed to occur in the order in 
1464 which the list of directories is specified in @SUBDIRS@.}  This guarantee can
1465 be important.  For example, when you say @gmake boot@ it can be important
1466 that the recursive invocation of @make boot@ is done in one sub-directory (the include
1467 files, say) before another (the source files).
1468 Generally, put the most independent sub-directory first, and the most dependent
1469 last.
1470
1471 \subsection{Way management}
1472 \label{sect_ways}
1473
1474 We sometimes want to build essentially the same system in several different
1475 ``ways''.  For example, we want to build @ghc@'s @Prelude@ libraries with
1476 and without profiling, with and without concurrency, and so on, so that
1477 there is an appropriately-built library archive to link with when the user compiles
1478 his program.
1479 It would be possible to have a completely separate build tree for each such ``way'',
1480 but it would be horribly bureaucratic, especially since often only parts of the
1481 build tree need to be constructed in multiple ways.
1482
1483 Instead, the @template.mk@ contains some clever magic to allow you to build
1484 several versions of a system; and to control locally how many versions are built
1485 and how they differ.  This section explains the magic.
1486
1487 The files for a particular way are distinguished by munging the suffix.
1488 The ``normal way'' is always built, and its files have the standard suffices
1489 @.o@, @.hi@, and so on.  In addition, you can build one or more extra ways,
1490 each distinguished by a {\em way tag}.  The object files and interface files
1491 for one of these extra ways are distinguished by their suffix.  For example,
1492 way @mp@ has files @.mp_o@ and @.mp_hi@.  Library archives have their way
1493 tag the other side of the dot, for boring reasons; thus, @libHS_mp.a@.
1494
1495 A @make@ variable called @way@ holds the current way tag.  {\em @way@ is only ever
1496 set on the command line of a recursive invocation of @gmake@.}  It is
1497 never set inside a @Makefile@.  So it is a global constant for any one invocation
1498 of @gmake@.  Two other @make@ variables, @way_@ and @_way@ are immediately derived
1499 from @$(way)@ and never altered.  If @way@ is not set, then neither are @way_@
1500 and @_way@, and the invocation of @make@ will build the ``normal way''.
1501 If @way@ is set, then the other two variables are set in sympathy. 
1502 For example, if @$(way)@ is ``@mp@'', then @way_@ is set to ``@mp_@''
1503 and @_way@ is set to ``@_mp@''.   These three variables are then used
1504 when constructing file names.
1505
1506 So how does @make@ ever get recursively invoked with @way@ set?  There
1507 are two ways in which this happens:
1508 \begin{itemize}
1509 \item For some (but not all) of the standard targets, when in a leaf sub-directory,
1510 @make@ is recursively invoked for each way tag in @$(WAYS)@.  You set @WAYS@ to
1511 the list of way tags you want these targets built for.  The mechanism here is
1512 very much like the recursive invocation of @make@ in sub-directories
1513 (Section~\ref{sect_subdirs}).
1514
1515 It is up to you to set @WAYS@ in your @Makefile@; this is how you control
1516 what ways will get built.
1517 \item For a useful collection of targets (such as @libHS_mp.a@, @Foo.mp_o@)
1518 there is a rule which recursively invokes @make@ to make the specified
1519 target, setting the @way@ variable.  So if you say @gmake Foo.mp_o@
1520 you should see a recursive invocation @gmake Foo.mp_o way=mp@,
1521 and {\em in this recursive invocation the pattern rule for compiling a Haskell
1522 file into a @.o@ file will match}.  The key pattern rules (in @suffix.mk@)
1523 look like this:
1524 \begin{verbatim}
1525   %.$(way_)o : %.lhs
1526         $(HC) $(HC_OPTS) $< -o $@
1527 \end{verbatim}
1528 Neat, eh?
1529 \end{itemize}
1530
1531
1532 \subsection{When the canned rule isn't right}
1533
1534 Sometimes the canned rule just doesn't do the right thing.  For example, in 
1535 the @nofib@ suite we want the link step to print out timing information.
1536 The thing to do here is {\em not} to define @HS_PROG@ or @C_PROG@, and instead
1537 define a special purpose rule in your own @Makefile@.
1538 By using different variable names you will avoid the canned rules being included,
1539 and conflicting with yours.
1540
1541
1542 %************************************************************************
1543 %*                                                                      *
1544 \section[booting-from-C]{Booting/porting from C (\tr{.hc}) files}
1545 \index{building GHC from .hc files}
1546 \index{booting GHC from .hc files}
1547 %*                                                                      *
1548 %************************************************************************
1549
1550 This section is for people trying to get GHC going by using the
1551 supplied intermediate C (\tr{.hc}) files.  This would probably be
1552 because no binaries have been provided, or because the machine
1553 is not ``fully supported.''
1554
1555 THIS SECTION HASN'T BEEN UPDATED YET.  Please let us know if you want to use this
1556 route. Unless someone does, this section may never get written, and the
1557 .hc files distribution may not get built!
1558
1559
1560 %************************************************************************
1561 %*                                                                      *
1562 \section[build-pitfalls]{Known pitfalls in building Glasgow Haskell}
1563 \index{problems, building}
1564 \index{pitfalls, in building}
1565 \index{building pitfalls}
1566 %*                                                                      *
1567 %************************************************************************
1568
1569 WARNINGS about pitfalls and known ``problems'':
1570
1571 \begin{enumerate}
1572 %------------------------------------------------------------------------
1573 \item
1574 One difficulty that comes up from time to time is running out of space
1575 in \tr{/tmp}.  (It is impossible for the configuration stuff to
1576 compensate for the vagaries of different sysadmin approaches re temp
1577 space.)
1578
1579 The quickest way around it is \tr{setenv TMPDIR /usr/tmp} or
1580 even \tr{setenv TMPDIR .} (or the equivalent incantation with the
1581 shell of your choice).
1582
1583 The best way around it is to say
1584 \begin{verbatim}
1585   TMPDIR=<dir>
1586 \end{verbatim}
1587 in your @build.mk@ file.
1588 Then GHC and the other @fptools@ programs will use the appropriate directory
1589 in all cases.
1590
1591 %------------------------------------------------------------------------
1592 \item
1593 In compiling some support-code bits, e.g., in \tr{ghc/runtime/gmp} and
1594 even in \tr{ghc/lib}, you may get a few C-compiler warnings.  We think
1595 these are OK.
1596
1597 %------------------------------------------------------------------------
1598 \item
1599 When compiling via C, you'll sometimes get ``warning:
1600 assignment from incompatible pointer type'' out of GCC.  Harmless.
1601
1602 %------------------------------------------------------------------------
1603 \item
1604 Similarly, \tr{ar}chiving warning messages like the following are not
1605 a problem:
1606 \begin{verbatim}
1607 ar: filename GlaIOMonad__1_2s.o truncated to GlaIOMonad_
1608 ar: filename GlaIOMonad__2_2s.o truncated to GlaIOMonad_
1609 ...
1610 \end{verbatim}
1611
1612 %------------------------------------------------------------------------
1613 \item
1614 Also harmless are some specialisation messages that you may see when
1615 compiling GHC; e.g.:
1616 \begin{verbatim}
1617 SPECIALISATION MESSAGES (Desirable):
1618 *** INSTANCES
1619 {-# SPECIALIZE instance Eq [Class] #-}
1620 {-# SPECIALIZE instance Eq (Class, [Class]) #-}
1621 {-# SPECIALIZE instance Outputable [ClassOp] #-}
1622 {-# SPECIALIZE instance Outputable [Id] #-}
1623 \end{verbatim}
1624
1625 %------------------------------------------------------------------------
1626 \item
1627 In compiling the compiler proper (in \tr{compiler/}), you {\em may} get an
1628 ``Out of heap space'' error message.  These
1629 can vary with the vagaries of different systems, it seems.  The
1630 solution is simple: (1)~add a suitable \tr{-H} flag to the @<module>_HC_OPTS@
1631 @make@ variable in the appropriate @Makefile@;
1632 (2)~try again: \tr{gmake}.
1633 (Section~\ref{sect_suffix}.)
1634
1635 Alternatively, just cut to the chase scene:
1636 \begin{verbatim}
1637 % cd ghc/compiler
1638 % make EXTRA_HC_OPTS=-H32m  # or some nice big number
1639 \end{verbatim}
1640
1641 %------------------------------------------------------------------------
1642 \item
1643 Not too long into the build process, you may get a huge complaint
1644 of the form:
1645 \begin{verbatim}
1646 Giant error 'do'ing getopts.pl:  at ./lit2pgm.BOOT line 27.
1647 \end{verbatim}
1648 This indicates that your \tr{perl} was mis-installed; the binary is
1649 unable to find the files for its ``built-in'' library.  Speak to your
1650 perl installer, then re-try.
1651
1652 %------------------------------------------------------------------------
1653 \item
1654 If you try to compile some Haskell, and you get errors from GCC
1655 about lots of things from \tr{/usr/include/math.h}, then your GCC
1656 was mis-installed.  \tr{fixincludes} wasn't run when it should've
1657 been.
1658
1659 As \tr{fixincludes} is now automagically run as part of GCC
1660 installation, this bug also suggests that you have an old GCC.
1661
1662
1663 %------------------------------------------------------------------------
1664 \item
1665 You {\em may} need to re-\tr{ranlib} your libraries (on Sun4s).
1666 \begin{verbatim}
1667 % cd $(libdir)/ghc-2.01/sparc-sun-sunos4
1668 % foreach i ( `find . -name '*.a' -print` ) # or other-shell equiv...
1669 ?    ranlib $i
1670 ?    # or, on some machines: ar s $i
1671 ? end
1672 \end{verbatim}
1673 We'd be interested to know if this is still necessary.
1674
1675 %------------------------------------------------------------------------
1676 \item
1677 If you end up making documents that involve (La)TeX and/or \tr{tib}
1678 (Simon's favourite), the odds are that something about your/our setup
1679 will reach out and bite you.  Yes, please complain; meanwhile,
1680 you can do \tr{make -n whatever.dvi} to see the intended commands,
1681 then try to muddle through, doing them by hand.
1682
1683 \end{enumerate}
1684
1685
1686
1687 % ====================================================================
1688 Here follow pitfalls that apply to pre-2.02 releases.  They should not
1689 happen any more If they do crop up with 2.02 or later, please let us
1690 know.
1691
1692 \begin{enumerate}
1693 %------------------------------------------------------------------------
1694 \item
1695 When configuring the support code (mkworld, glafp-utils, etc.), you
1696 will see mention of \tr{NO_SPECIFIC_PROJECT} and
1697 \tr{NO_SPECIFIC_VERSION}.  This is cool.
1698
1699
1700 %------------------------------------------------------------------------
1701 \item
1702 Sooner or later in your ``make-worlding'' life you will do and see
1703 something like:
1704 \begin{verbatim}
1705 % make Makefile
1706         rm -f Makefile.bak; mv Makefile Makefile.bak
1707 ../.././mkworld/jmake -P ghc -S std -I../.././mkworld -DTopDir=../../. -DTopDir=...
1708 ../.././mkworld/jrestoredeps
1709 ==== The new Makefile is for: ====
1710 make: Fatal error in reader: Makefile, line 850: Unexpected end of line seen
1711 Current working directory /export/users/fp/grasp/ghc-0.26/ghc/runtimes/standard
1712 *** Error code 1
1713 make: Fatal error: Command failed for target `Makefile'
1714 \end{verbatim}
1715
1716 Don't panic!  It should restore your previous \tr{Makefile}, and
1717 leave the junk one in \tr{Makefile.bad}.  Snoop around at your leisure.
1718
1719 % ------------------------------------------------------------------------
1720 \item
1721 If you do corrupt a \tr{Makefile} totally, or you need to glue a new
1722 directory into the directory structure (in \tr{newdir}---which must
1723 have a \tr{Jmakefile}, even if empty), here's a neat trick:
1724 \begin{verbatim}
1725 #
1726 # move to the directory just above the one where you want a Makefile...
1727 cd ..
1728 #
1729 # make Makefiles, but lie about the directories below...
1730 make Makefiles SUBDIRS=newdir
1731 \end{verbatim}
1732
1733 This will create a \tr{Makefile} {\em ex nihilo} in \tr{newdir}, and
1734 it will be properly wired into the general make-world structure.
1735
1736 % ------------------------------------------------------------------------
1737 \item
1738 Don't configure/build/install using a variety of machines.  A
1739 mistake we've made is to do \tr{make Makefiles} on a Sun4, then try to
1740 build GHC (\tr{make all}) on a Sun3.
1741
1742 %------------------------------------------------------------------------
1743 %\item
1744 %If you build an ``unregisterised'' build, you will get bazillions of
1745 %warnings about `ANSI C forbids braced-groups within expressions'.
1746 %Especially in \tr{ghc/lib}.  These are OK.
1747
1748 \end{enumerate}
1749
1750
1751 \begin{onlystandalone}
1752 \printindex
1753 \end{document}
1754 \end{onlystandalone}
1755