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