[project @ 2001-07-16 11:43:17 by simonpj]
[ghc-hetmet.git] / ghc / docs / users_guide / installing.sgml
1 <Chapter id="sec-installing-bin-distrib">
2   <Title>Installing GHC</Title>
3 <IndexTerm><Primary>binary installations</Primary></IndexTerm>
4 <IndexTerm><Primary>installation, of binaries</Primary></IndexTerm>
5
6 <Para>
7 Installing from binary distributions is easiest, and recommended!
8 (Why binaries? Because GHC is a Haskell compiler written in Haskell,
9 so you've got to bootstrap it somehow.  We provide machine-generated
10 C-files-from-Haskell for this purpose, but it's really quite a pain to
11 use them.  If you must build GHC from its sources, using a
12 binary-distributed GHC to do so is a sensible way to proceed. For the
13 other <Literal>fptools</Literal> programs, many are written in
14 Haskell, so binary distributions allow you to install them without
15 having a Haskell compiler.)
16 </Para>
17
18 <Para>This guide is in several parts:</para>
19 <itemizedlist>
20 <listitem> Installing on Unix-a-likes (<Xref LinkEnd="sec-unix-a-likes">).  </listitem>
21 <listitem> Installing on Windows  (<Xref LinkEnd="sec-install-windows">).  </listitem>
22 <listitem> The layout of installed files  (<Xref LinkEnd="sec-install-files">).  
23 You don't need to know this to install GHC,
24 but it's useful if you are changing the implementation.   </listitem>
25 <listitem> Installing or building the documentation (<Xref LinkEnd="building-docs">). </listitem>
26 </itemizedlist>
27
28
29   
30   <Sect1 id="sec-unix-a-likes"><Title>Installing on Unix-a-likes</Title>
31
32     <sect2>
33       <title>When a platform-specific package is available</title>
34       
35       <para>For certain platforms, we provide GHC binaries packaged
36       using the native package format for the platform.  This is
37       likely to be by far the best way to install GHC for your
38       platform if one of these packages is available, since
39       dependencies will automatically be handled and the package
40       system normally provides a way to uninstall the package at a
41       later date.</para>
42
43       <para>We generally provide the following packages:</para>
44
45       <variablelist>
46         <varlistentry>
47           <term>RedHat Linux/x86</term>
48           <listitem>
49             <para>RPM source & binary packages for RedHat Linux (x86
50             only) are available for most major releases.</para>
51           </listitem>
52         </varlistentry>
53
54         <varlistentry>
55           <term>Debian Linux/x86</term>
56           <listitem>
57             <para>Debian packages for Linux (x86 only), also for most
58             major releases.</para>
59           </listitem>
60         </varlistentry>
61
62         <varlistentry>
63           <term>FreeBSD/x86</term>
64           <listitem>
65             <para>On FreeBSD/x86, GHC can be installed using either
66             the ports tree (<literal>cd /usr/ports/lang/ghc && make
67             install</literal>) or from a pre-compiled package
68             available from your local FreeBSD mirror.</para>
69           </listitem>
70         </varlistentry>
71       </variablelist>
72       
73       <para>Other platform-specific packages may be available, check
74       the GHC download page for details.</para>
75     </sect2>
76
77 <Sect2>
78 <Title>GHC binary distributions</Title>
79
80 <Para>
81 <IndexTerm><Primary>bundles of binary stuff</Primary></IndexTerm>
82 </Para>
83
84 <Para>
85 Binary distributions come in &ldquo;bundles,&rdquo; one bundle per file called
86 <literal><replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</Literal>.  (See the building guide for the definition of a platform.)  Suppose that you untar a binary-distribution bundle, thus:
87 </Para>
88
89 <Para>
90
91 <Screen>
92 % cd /your/scratch/space
93 % gunzip &#60; ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -</Screen>
94
95 </Para>
96
97 <Para>
98 Then you should find a single directory, <Literal>fptools</Literal>, with the following
99 structure:
100 </Para>
101
102 <Para>
103 <IndexTerm><Primary>binary distribution, layout</Primary></IndexTerm>
104 <IndexTerm><Primary>directory layout (binary distributions)</Primary></IndexTerm>
105 <VariableList>
106
107 <VarListEntry>
108 <Term><Literal>Makefile.in</Literal></Term>
109 <ListItem>
110 <Para>
111 the raw material from which the <Literal>Makefile</Literal>
112 will be made (<Xref LinkEnd="sec-install">).
113 </Para>
114 </ListItem></VarListEntry>
115 <VarListEntry>
116 <Term><Literal>configure</Literal></Term>
117 <ListItem>
118 <Para>
119 the configuration script (<Xref LinkEnd="sec-install">).
120 </Para>
121 </ListItem></VarListEntry>
122 <VarListEntry>
123 <Term><Literal>README</Literal></Term>
124 <ListItem>
125 <Para>
126 Contains this file summary.
127 </Para>
128 </ListItem></VarListEntry>
129 <VarListEntry>
130 <Term><Literal>INSTALL</Literal></Term>
131 <ListItem>
132 <Para>
133 Contains this description of how to install
134 the bundle.
135 </Para>
136 </ListItem></VarListEntry>
137 <VarListEntry>
138 <Term><Literal>ANNOUNCE</Literal></Term>
139 <ListItem>
140 <Para>
141 The announcement message for the bundle.
142 </Para>
143 </ListItem></VarListEntry>
144 <VarListEntry>
145 <Term><Literal>NEWS</Literal></Term>
146 <ListItem>
147 <Para>
148 release notes for the bundle&mdash;a longer version
149 of <Literal>ANNOUNCE</Literal>.  For GHC, the release notes are contained in the User
150 Guide and this file isn't present.
151 </Para>
152 </ListItem></VarListEntry>
153 <VarListEntry>
154             <Term><Literal>bin/<replaceable>platform</replaceable></Literal></Term>
155 <ListItem>
156 <Para>
157 contains platform-specific executable
158 files to be invoked directly by the user.  These are the files that
159 must end up in your path.
160 </Para>
161 </ListItem></VarListEntry>
162 <VarListEntry>
163 <Term><Literal>lib/<replaceable>platform</replaceable>/</Literal></Term>
164 <ListItem>
165 <Para>
166 contains platform-specific support
167 files for the installation.  Typically there is a subdirectory for
168 each <Literal>fptools</Literal> project, whose name is the name of the project with its
169 version number.  For example, for GHC there would be a sub-directory
170 <Literal>ghc-x.xx</Literal>/ where <Literal>x.xx</Literal> is the version number of GHC in the bundle.
171 </Para>
172
173 <Para>
174 These sub-directories have the following general structure:
175 </Para>
176
177 <Para>
178 <VariableList>
179
180 <VarListEntry>
181 <Term><Literal>libHSstd.a</Literal> etc:</Term>
182 <ListItem>
183 <Para>
184 supporting library archives.
185 </Para>
186 </ListItem></VarListEntry>
187 <VarListEntry>
188 <Term><Literal>ghc-iface.prl</Literal> etc:</Term>
189 <ListItem>
190 <Para>
191 support scripts.
192 </Para>
193 </ListItem></VarListEntry>
194 <VarListEntry>
195 <Term><Literal>import/</Literal></Term>
196 <ListItem>
197 <Para>
198 <IndexTerm><Primary>Interface files</Primary></IndexTerm> (<Literal>.hi</Literal>) for the prelude.
199 </Para>
200 </ListItem></VarListEntry>
201 <VarListEntry>
202 <Term><Literal>include/</Literal></Term>
203 <ListItem>
204 <Para>
205 A few C <Literal>&num;include</Literal> files.
206 </Para>
207 </ListItem></VarListEntry>
208 </VariableList>
209 </Para>
210 </ListItem></VarListEntry>
211 <VarListEntry>
212 <Term><Literal>share/</Literal></Term>
213 <ListItem>
214 <Para>
215 contains platform-independent support files
216 for the installation.  Again, there is a sub-directory for each
217 <Literal>fptools</Literal> project.
218 </Para>
219 </ListItem></VarListEntry>
220 <VarListEntry>
221 <Term><Literal>html/</Literal></Term>
222 <ListItem>
223 <Para>
224 contains HTML documentation files (one
225 sub-directory per project).
226 </Para>
227 </ListItem></VarListEntry>
228 <VarListEntry>
229 <Term><Literal>man/</Literal></Term>
230 <ListItem>
231 <Para>
232 contains Unix manual pages.
233 </Para>
234 </ListItem></VarListEntry>
235 </VariableList>
236 </Para>
237
238 <Sect3 id="sec-install">
239 <Title>Installing</Title>
240
241 <Para>
242 OK, so let's assume that you have unpacked your chosen bundles into a
243 scratch directory <Literal>fptools</Literal>. What next? Well, you will at least need
244 to run the <Literal>configure</Literal><IndexTerm><Primary>configure</Primary></IndexTerm> script by changing your
245 directory to <Literal>fptools</Literal> and typing <Literal>./configure</Literal>.  That should convert
246 <Literal>Makefile.in</Literal> to <Literal>Makefile</Literal>.
247 </Para>
248
249 <Para>
250 <IndexTerm><Primary>installing in-place</Primary></IndexTerm>
251 <IndexTerm><Primary>in-place installation</Primary></IndexTerm>
252 You can now either start using the tools <Emphasis>in-situ</Emphasis> without going
253 through any installation process, just type <Literal>make in-place</Literal> to set the
254 tools up for this. You'll also want to add the path which <Literal>make</Literal> will
255 now echo to your <Literal>PATH</Literal> environment variable. This option is useful if
256 you simply want to try out the package and/or you don't have the
257 necessary privileges (or inclination) to properly install the tools
258 locally. Note that if you do decide to install the package `properly'
259 at a later date, you have to go through the installation steps that
260 follows.
261 </Para>
262
263 <Para>
264 To install an <Literal>fptools</Literal> package, you'll have to do the following:
265 </Para>
266
267 <Para>
268
269 <OrderedList>
270 <ListItem>
271
272 <Para>
273  Edit the <Literal>Makefile</Literal> and check the settings of the following variables:
274
275 <IndexTerm><Primary>directories, installation</Primary></IndexTerm>
276 <IndexTerm><Primary>installation directories</Primary></IndexTerm>
277
278 <VariableList>
279
280 <VarListEntry>
281 <Term><Literal>platform</Literal></Term>
282 <ListItem>
283 <Para>
284 the platform you are going to install for.
285 </Para>
286 </ListItem></VarListEntry>
287 <VarListEntry>
288 <Term><Literal>bindir</Literal></Term>
289 <ListItem>
290 <Para>
291 the directory in which to install user-invokable
292 binaries.
293 </Para>
294 </ListItem></VarListEntry>
295 <VarListEntry>
296 <Term><Literal>libdir</Literal></Term>
297 <ListItem>
298 <Para>
299 the directory in which to install
300 platform-dependent support files.
301 </Para>
302 </ListItem></VarListEntry>
303 <VarListEntry>
304 <Term><Literal>datadir</Literal></Term>
305 <ListItem>
306 <Para>
307 the directory in which to install
308 platform-independent support files.
309 </Para>
310 </ListItem></VarListEntry>
311 <VarListEntry>
312 <Term><Literal>infodir</Literal></Term>
313 <ListItem>
314 <Para>
315 the directory in which to install Emacs info
316 files.
317 </Para>
318 </ListItem></VarListEntry>
319 <VarListEntry>
320 <Term><Literal>htmldir</Literal></Term>
321 <ListItem>
322 <Para>
323 the directory in which to install HTML
324 documentation.
325 </Para>
326 </ListItem></VarListEntry>
327 <VarListEntry>
328 <Term><Literal>dvidir</Literal></Term>
329 <ListItem>
330 <Para>
331 the directory in which to install DVI
332 documentation.
333 </Para>
334 </ListItem></VarListEntry>
335 </VariableList>
336
337 The values for these variables can be set through invocation of the
338 <Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm>
339 script that comes with the distribution, but doing an optical diff to
340 see if the values match your expectations is always a Good Idea.
341 </para>
342
343 <para>
344 <Emphasis>Instead of running <Command>configure</Command>, it is
345 perfectly OK to copy <Filename>Makefile.in</Filename> to
346 <Filename>Makefile</Filename> and set all these variables directly
347 yourself.  But do it right!</Emphasis>
348 </Para>
349
350 </ListItem>
351 <ListItem>
352
353 <Para>
354 Run <Literal>make install</Literal>.  This <Emphasis>
355 should</Emphasis> work with ordinary Unix
356 <Literal>make</Literal>&mdash;no need for fancy stuff like GNU
357 <Literal>make</Literal>.
358
359 </Para>
360 </ListItem>
361 <ListItem>
362
363 <Para>
364 <Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
365 stuff in your bin directory.
366
367 </Para>
368 </ListItem>
369 <ListItem>
370
371 <Para>
372  Once done, test your &ldquo;installation&rdquo; as suggested in 
373 <XRef LinkEnd="sec-GHC-test">.  Be sure to use a <Literal>-v</Literal>
374 option, so you can see exactly what pathnames it's using.
375
376 If things don't work as expected, check the list of known pitfalls in
377 the building guide.
378 </Para>
379 </ListItem>
380
381 </OrderedList>
382
383 </Para>
384
385 <Para>
386 <IndexTerm><Primary>link, installed as ghc</Primary></IndexTerm>
387 When installing the user-invokable binaries, this installation
388 procedure will install GHC as <Literal>ghc-x.xx</Literal> where <Literal>x.xx</Literal> is the version
389 number of GHC.  It will also make a link (in the binary installation
390 directory) from <Literal>ghc</Literal> to <Literal>ghc-x.xx</Literal>.  If you install multiple versions
391 of GHC then the last one &ldquo;wins&rdquo;, and &ldquo;<Literal>ghc</Literal>&rdquo; will invoke the last
392 one installed.  You can change this manually if you want.  But
393 regardless, <Literal>ghc-x.xx</Literal> should always invoke GHC version <Literal>x.xx</Literal>.
394 </Para>
395
396 </Sect3>
397
398
399 <Sect3>
400 <Title>What bundles there are</Title>
401
402 <Para>
403 <IndexTerm><Primary>bundles, binary</Primary></IndexTerm> There are
404 plenty of &ldquo;non-basic&rdquo; GHC bundles.  The files for them are
405 called
406 <Literal>ghc-x.xx-<replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</Literal>,
407 where the <replaceable>platform</replaceable> is as above, and
408 <replaceable>bundle</replaceable> is one of these:
409 </Para>
410
411 <Para>
412 <VariableList>
413
414 <VarListEntry>
415 <Term><Literal>prof</Literal>:</Term>
416 <ListItem>
417 <Para>
418 Profiling with cost-centres.  You probably want this.
419 <IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
420 <IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
421 </Para>
422 </ListItem></VarListEntry>
423 <VarListEntry>
424 <Term><Literal>par</Literal>:</Term>
425 <ListItem>
426 <Para>
427 Parallel Haskell features (sits on top of PVM).
428 You'll want this if you're into that kind of thing.
429 <IndexTerm><Primary>parallel bundles</Primary></IndexTerm>
430 <IndexTerm><Primary>bundles, parallel</Primary></IndexTerm>
431 </Para>
432 </ListItem></VarListEntry>
433 <VarListEntry>
434 <Term><Literal>gran</Literal>:</Term>
435 <ListItem>
436 <Para>
437 The &ldquo;GranSim&rdquo; parallel-Haskell simulator
438 (hmm&hellip; mainly for implementors).
439 <IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
440 <IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
441 </Para>
442 </ListItem></VarListEntry>
443 <VarListEntry>
444 <Term><Literal>ticky</Literal>:</Term>
445 <ListItem>
446 <Para>
447 &ldquo;Ticky-ticky&rdquo; profiling; very detailed
448 information about &ldquo;what happened when I ran this program&rdquo;&mdash;really
449 for implementors.
450 <IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
451 <IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
452 </Para>
453 </ListItem></VarListEntry>
454 </VariableList>
455 </Para>
456
457 <Para>
458 One likely scenario is that you will grab <Emphasis>two</Emphasis>
459 binary bundles&mdash;basic, and profiling.  We don't usually make the
460 rest, although you can build them yourself from a source distribution.
461 </Para>
462
463 <para>The various GHC bundles are designed to be unpacked into the
464 same directory; then installing as per the directions above will
465 install the whole lot in one go.  Note: you <emphasis>must</emphasis>
466 at least have the basic GHC binary distribution bundle, these extra
467 bundles won't install on their own.</para>
468
469 </Sect3>
470
471 <Sect3 id="sec-GHC-test">
472 <Title>Testing that GHC seems to be working
473 </Title>
474
475 <Para>
476 <IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
477 </Para>
478
479 <Para>
480 The way to do this is, of course, to compile and run <Emphasis>this</Emphasis> program
481 (in a file <Literal>Main.hs</Literal>):
482 </Para>
483
484 <Para>
485
486 <ProgramListing>
487 main = putStr "Hello, world!\n"
488 </ProgramListing>
489
490 </Para>
491
492 <Para>
493 Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
494 libraries, etc., are being found properly:
495
496 <Screen>
497 % ghc -v -o hello Main.hs</Screen>
498
499 </Para>
500
501 <Para>
502 Now run it:
503
504 <Screen>
505 % ./hello
506 Hello, world!</Screen>
507
508 </Para>
509
510 <Para>
511 Some simple-but-profitable tests are to compile and run the notorious
512 <Literal>nfib</Literal><IndexTerm><Primary>nfib</Primary></IndexTerm> program, using different numeric types.  Start with
513 <Literal>nfib :: Int -&gt; Int</Literal>, and then try <Literal>Integer</Literal>, <Literal>Float</Literal>, <Literal>Double</Literal>,
514 <Literal>Rational</Literal> and perhaps the overloaded version.  Code for this is
515 distributed in <Literal>ghc/misc/examples/nfib/</Literal> in a source distribution.
516 </Para>
517
518 <para>For more information on how to &ldquo;drive&rdquo; GHC, read
519 on...</para>
520
521 </Sect3>
522
523 </Sect2>
524
525 </Sect1>
526
527
528 <Sect1 id="sec-install-windows"><Title>Installing on Windows</Title>
529
530 <Para>
531 Getting the Glasgow Haskell Compiler (GHC) to run on Windows platforms can
532 be a bit of a trying experience. It should be much easier now than in the
533 past, since all the software required to build and use GHC is included in
534 the InstallShield.
535 </Para>
536
537 <Para>
538 An installation of GHC requires about 70M of disk space (which can be
539 reduced by choosing a &ldquo;compact&rdquo; installation).
540 To run GHC comfortably, your machine should have at least
541 64M of memory.
542 </Para>
543
544
545 <Sect2><Title>Installing GHC</Title>
546
547 <Para>
548 Download the latest GHC distribution (ghc-4.08 InstallShield installer, 19M)
549 from <ULink
550 URL="http://www.haskell.org/ghc/download.html">haskell.org</ULink>
551 It is packaged up using an installer that should be familiar-looking to
552 Windows users. The 4.08 InstallShield package comes with some Cygwin
553 binaries, which unfortunately won't work with another Cygwin installation on
554 the same machine, unless it uses exactly the same version of the Cygwin DLL
555 (1.3.1 in this InstallShield).
556 </Para>
557
558 <Para>
559 Note: The Cygwin support for long file names containing
560 spaces is not 100%, so make sure that you install ghc in a directory
561 that has no embedded spaces (i.e., resist the temptation to put it
562 in <Filename>/Program Files/</Filename>!)
563 </Para>
564
565 <Para>
566 When the installer has completed, make sure you add the location of the
567 ghc <Filename>bin/</Filename> directory to your path (e.g.
568 <Filename>/ghc/ghc-4.08/bin</Filename>).
569 You need to do this in order to bring the various GHC binaries into scope.
570 Also, if the directory <Filename>C:/TEMP</Filename> doesn't already exist,
571 you should create it.
572 </Para>
573
574 <Para>
575 To test the fruits of your labour, try now to compile a simple
576 Haskell program:
577 </Para>
578
579 <Screen>
580 bash$ cat main.hs
581 module Main(main) where
582
583 main = putStrLn "Hello, world!"
584 bash$ ghc -o main main.hs
585 ..
586 bash$ ./main
587 Hello, world!
588 bash$ </Screen>
589
590 <Para>
591 OK, assuming that worked, you're all set. Go forth and write useful
592 Haskell programs :-) If not, consult the installation FAQ (<XRef LinkEnd="winfaq">); if that still doesn't help then please report the problems you're experiencing (see <Xref LinkEnd="wrong">).
593 </Para>
594
595 <Para>
596 Further information on using GHC under Windows can be found in <ULink
597 URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbj&oslash;rn Finne's
598 pages</ULink>. Note: ignore the installation instructions, which are rather
599 out of date; the <Emphasis>Miscellaneous</Emphasis> section at the bottom of
600 the page is of most interest, covering topics beyond the scope of this
601 manual.
602 </Para>
603
604 </Sect2>
605
606
607 <Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>
608
609 <QandASet>
610
611 <QandAEntry>
612
613 <Question>
614 <Para>
615 I'm having trouble with symlinks.
616 </Para>
617 </Question>
618
619 <Answer>
620 <Para>
621 Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
622 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
623 work with symlinks.
624 </Para>
625 </Answer>
626
627 </QandAEntry>
628
629 <QandAEntry>
630
631 <Question>
632 <Para>
633 I'm getting &ldquo;permission denied&rdquo; messages from <Command>rm</Command> or
634 <Command>mv</Command>.
635 </Para>
636 </Question>
637
638 <Answer>
639 <Para>
640 This can have various causes: trying to rename a directory when an Explorer
641 window is open on it tends to fail. Closing the window generally cures the
642 problem, but sometimes its cause is more mysterious, and logging off and back
643 on or rebooting may be the quickest cure.
644 </Para>
645 </Answer>
646
647 </QandAEntry>
648
649 <QandAEntry>
650
651 <Question>
652 <Para>
653 I get errors when trying to build GHC 4.08 with GHC 4.05.
654 </Para>
655 </Question>
656
657 <Answer> <Para> This seems to work better if you don't use
658 <Option>-O</Option> in <Constant>GhcHcOpts</Constant>. It's a bug in 4.05,
659 unfortunately. Anyway, better to install 4.08 binaries and use those.
660 </Para> </Answer>
661
662 </QandAEntry>
663
664 </QandASet>
665
666 </Sect2>
667
668 </Sect1>
669
670
671 <Sect1 id="sec-install-files><Title>The layout of installed files</Title>
672
673 <para>
674 This section describes what files get installed where.  You don't need to know it
675 if you are simply installing GHC, but it is vital information if you are changing
676 the implementation.
677 </para>
678 <para> GHC is installed in two directory trees:</para>
679 <variablelist>
680 <varlistentry>
681 <term>Binary directory</term>
682 <listitem> known as <Filename>$(bindir)</Filename>, holds executables that 
683 the user is expected to invoke.  Notably,
684 <Filename>ghc</Filename> and <Filename>ghci</FileName>.  On Unix, this directory
685 is typically something like <Filename>/usr/local/bin</Filename>.  On Windows,
686 however, this directory is always <Filename>$(libdir)/bin</Filename>.
687 </listitem>
688 </varlistentry>
689 <varlistentry>
690 <term>Library directory,</term>
691 <listitem> known as <Filename>$(libdir)</Filename>, holds all the 
692 support files needed to run GHC.  On Unix, this 
693 directory is usually something like <Filename>/usr/lib/ghc/ghc-5.02</Filename>.
694 </listitem>
695 </variablelist>
696
697 <para>
698 When GHC runs, it must know where its library directory is.
699 It finds this out in one of two ways:
700 </para>
701 <itemizedlist>
702 <listitem>
703 <Filename>$(libdir)</Filename> is passed to GHC using the <option>-B</option> flag.
704 On Unix (but not Windows), the installed <filename>ghc</filename> is just a one-line 
705 shell script that invokes the real GHC, passing a suitable <option>-B</option> flag. 
706 [All the user-supplied flags
707 follow, and a later <option>-B</option> flag overrides an earlier one, so a user-supplied
708 one wins.]
709
710 </listitem>
711 <listitem>
712 On Windows (but not Unix), if no <option>-B</option> flag is given, GHC uses a system
713 call to find the directory in which the running GHC executable lives, and derives 
714 <Filename>$(libdir)</Filename> from that. [Unix lacks such a system call.]
715 </listitem>
716 </itemizedlist>
717
718 <sect2> <title>Layout of the library directory</title>
719
720 <para>
721 The layout of the library directory is almost identical on Windows and Unix, 
722 as follows:
723 layout:</para>
724 <programlisting>
725   $(libdir)/
726     package.conf           GHC package configuration
727     
728     bin/                   [Win32 only]  User-visible binaries
729          ghc.exe
730          ghci.bat
731
732     extra-bin/             Support binaries
733          unlit             Remove literate markup
734     
735          touch.exe         [Win32 only]
736          perl.exe          [Win32 only]
737          gcc.exe           [Win32 only]
738     
739          ghc               [Unix only]
740
741          ghc-split         Asm code splitter
742          ghc-asm           Asm code mangler
743
744     gcc-lib/               [Win32 only] Support files for gcc
745         specs              gcc configuration
746  
747         cpp0.exe           gcc support binaries
748         as.exe
749         ld.exe
750
751         crt0.o              Standard
752            ..etc..          binaries
753         
754         libmingw32.a        Standard
755            ..etc..          libraries
756
757         include/*.h         Include files
758
759     imports/                GHC interface files
760         std/*.hi              'std' library
761         lang/*.hi             'lang' library
762         ..etc..
763
764     include/                 C header files
765         StgMacros.h           GHC-specific
766         ..etc...              header files
767
768         mingw/*.h             Mingwin header files
769
770     libHSrts.a              GHC library archives
771     libHSstd.a
772     libHSlang.a
773       ..etc..
774
775     HSstd1.o                GHC library linkables
776     HSstd2.o                  (used by ghci, which does
777     HSlang.o                  not grok .a files yet)
778 </programlisting>
779
780 <para>Note that:</para>
781 <itemizedlist>
782 <listitem>
783 <para>On Win32, the <filename>$(libdir)/bin</filename> directory contains user-visible binaries; 
784 add it to you <filename>PATH</filename>.  The <filename>ghci</filename> executable is a <filename>.bat</filename>
785 file which invokes <filename>ghc</filename>.   </para>
786
787 <para>The GHC executable is the Real Thing (no intervening
788 shell scripts or <filename>.bat</filename> files).  
789 Reason: we sometimes invoke GHC with very long command lines,
790 and <filename>.bat</filename> truncate them.  [We assume people won't invoke ghci with very long
791 command lines.]</para>
792
793 <para>On Unix, the user-invokable <filename>ghc</filename> invokes <filename>$(libdir)/extra-bin/ghc</filename>,
794 passing a suitable <option>-B</option> flag. 
795 </para>
796 </listitem>
797
798 <listitem>
799 <para>  <filename>$(libdir)/extra-bin/</filename> contains support binaries.  These
800 are <emphasis>not</emphasis> expected to be on the user's <filename>PATH</filename>, but
801 and are invoked directly by GHC.  In the Makefile system, this directory is called 
802 <filename>$(libexecdir)</filename>, but <emphasis>you aren't free to change it</emphasis>.  It must
803 be <filename>$(libdir)/extra-bin/</filename>.
804 </para>
805 </listitem>
806
807 <listitem>
808 <para> We distribute <filename>gcc</filename> with the Win32 distribution of GHC, so that users
809 don't need to install <filename>gcc</filename>, nor need to care about which version it is.
810 All <filename>gcc</filename>'s support files are kept in  <filename>$(libdir)/gcc-lib/</filename>.
811 </para> 
812 </listitem>
813
814 <listitem>
815 <para> Similarly, we distribute <filename>perl</filename> and <filename>touch</filename>
816 with the Win32 distribution of GHC. </para> 
817 </listitem>
818
819 <listitem> <para> The support programs <filename>ghc-split</filename> and <filename>ghc-asm</filename>
820 are Perl scripts.  The first line says <literal>#!/bin/perl</literal>; on Unix, the script is
821 indeed invoked as a shell script, which invokes Perl; on Windows, GHC invokes 
822 <filename>$(libdir)/extra-bin/perl</filename>
823 directly,
824 which treats the <literal>#!/bin/perl</literal> as a comment.  Reason: on Windows we want
825 to invoke the Perl distributed with GHC, rather than assume some installed one.
826 </para> 
827 </listitem>
828
829 </itemizelist>
830
831 </sect2>
832
833 </sect1>
834
835
836 <Sect1 id="building-docs">
837 <Title>Building the documentation</Title>
838
839 <Para>
840 We use the DocBook DTD, which is widely used. Most shrink-wrapped
841 distributions seem to be broken in one way or another; thanks to
842 heroic efforts by Sven Panne and Manuel Chakravarty, we now support
843 most of them, plus properly installed versions.
844 </Para>
845
846 <Para>
847 Instructions on installing and configuring the DocBook tools follow.
848 </Para>
849
850 <Sect2>
851 <Title>Installing the DocBook tools from RPMs</Title>
852
853 <Para> If you're using a system that can handle RedHat RPM packages,
854 you can probably use the <ULink
855 URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
856 tools</ULink>, which is the most shrink-wrapped SGML suite that we
857 could find. You need all the RPMs except for psgml (i.e.
858 <Filename>docbook</Filename>, <Filename>jade</Filename>,
859 <Filename>jadetex</Filename>, <Filename>sgmlcommon</Filename> and
860 <Filename>stylesheets</Filename>). Note that most of these RPMs are
861 architecture neutral, so are likely to be found in a
862 <Filename>noarch</Filename> directory. The SuSE RPMs also work; the
863 RedHat ones <Emphasis>don't</Emphasis> in RedHat 6.2 (7.0 and later
864 should be OK), but they are easy to fix: just make a symlink from
865 <Filename>/usr/lib/sgml/stylesheets/nwalsh-modular/lib/dblib.dsl</Filename>
866 to <Filename>/usr/lib/sgml/lib/dblib.dsl</Filename>. </Para>
867
868 </Sect2>
869
870     <sect2>
871       <title>Installing DocBook on FreeBSD</title>
872
873       <para>On FreeBSD systems, the easiest way to get DocBook up and
874       running is to install it from the ports tree or a pre-compiled
875       package (packages are available from your local FreeBSD mirror
876       site).</para>
877
878       <para>To use the ports tree, do this:
879 <screen>
880       $ cd /usr/ports/textproc/docproj
881       $ make install
882 </screen>
883       This installs the FreeBSD documentation project tools, which
884       includes everything needed to format the GHC
885       documentation.</para>
886     </sect2>
887
888 <Sect2>
889 <Title>Installing from binaries on Windows</Title>
890
891 <Para>
892 It's a good idea to use Norman Walsh's <ULink
893 URL="http://nwalsh.com/docbook/dsssl/doc/install.html">installation
894 notes</ULink> as a guide. You should get version 3.1 of DocBook, and note
895 that his file <Filename>test.sgm</Filename> won't work, as it needs version
896 3.0. You should unpack Jade into <Filename>\Jade</Filename>, along with the
897 entities, DocBook into <Filename>\docbook</Filename>, and the DocBook
898 stylesheets into <Filename>\docbook\stylesheets</Filename> (so they actually
899 end up in <Filename>\docbook\stylesheets\docbook</Filename>).
900 </Para>
901
902 </Sect2>
903
904
905 <Sect2>
906 <Title>Installing the DocBook tools from source</Title>
907
908 <Sect3>
909 <Title>Jade</Title>
910
911 <Para>
912 Install <ULink URL="http://openjade.sourceforge.net/">OpenJade</ULink> (Windows binaries are available as well as sources). If you want DVI, PS, or PDF then install JadeTeX from the <Filename>dsssl</Filename>
913 subdirectory. (If you get the error:
914
915 <Screen>
916 ! LaTeX Error: Unknown option implicit=false' for package hyperref'.
917 </Screen>
918
919 your version of <Command>hyperref</Command> is out of date; download it from
920 CTAN (<Filename>macros/latex/contrib/supported/hyperref</Filename>), and
921 make it, ensuring that you have first removed or renamed your old copy. If
922 you start getting file not found errors when making the test for
923 <Command>hyperref</Command>, you can abort at that point and proceed
924 straight to <Command>make install</Command>, or enter them as
925 <Filename>../</Filename><Emphasis>filename</Emphasis>.)
926 </Para>
927
928 <Para>
929 Make links from <Filename>virtex</Filename> to <Filename>jadetex</Filename>
930 and <Filename>pdfvirtex</Filename> to <Filename>pdfjadetex</Filename>
931 (otherwise DVI, PostScript and PDF output will not work). Copy
932 <Filename>dsssl/*.{dtd,dsl}</Filename> and <Filename>catalog</Filename> to <Filename>/usr/[local/]lib/sgml</Filename>.
933 </Para>
934
935 </Sect3>
936
937 <Sect3>
938 <Title>DocBook and the DocBook stylesheets</Title>
939
940 <Para>
941 Get a Zip of <ULink
942 URL="http://www.oasis-open.org/docbook/sgml/3.1/index.html">DocBook</ULink> 
943 and install the contents in <Filename>/usr/[local/]/lib/sgml</Filename>.
944 </Para>
945
946 <Para>
947 Get the <ULink URL="http://nwalsh.com/docbook/dsssl/">DocBook
948 stylesheets</ULink> and install in
949 <Filename>/usr/[local/]lib/sgml/stylesheets</Filename> (thereby creating a
950 subdirectory docbook). For indexing, copy or link <Filename>collateindex.pl</Filename> from the DocBook stylesheets archive in <Filename>bin</Filename> into a directory on your <Constant>PATH</Constant>.
951 </Para>
952
953 <Para>
954 Download the <ULink
955 URL="http://www.oasis-open.org/cover/ISOEnts.zip">ISO
956 entities</ULink> into <Filename>/usr/[local/]lib/sgml</Filename>.
957 </Para>
958
959 </Sect3>
960
961 </Sect2>
962
963 <Sect2>
964 <Title>Configuring the DocBook tools</Title>
965
966 <Para>
967 Once the DocBook tools are installed, the configure script will detect them and set up the build system accordingly. If you have a system that isn't supported, let us know, and we'll try to help.
968 </Para>
969
970 </Sect2>
971
972 <Sect2>
973 <Title>Remaining problems</Title>
974
975 <Para>
976 If you install from source, you'll get a pile of warnings of the form
977
978 <Screen>DTDDECL catalog entries are not supported</Screen>
979
980 every time you build anything. These can safely be ignored, but if you find them tedious you can get rid of them by removing all the <Constant>DTDDECL</Constant> entries from <Filename>docbook.cat</Filename>.
981 </Para>
982
983 </Sect2>
984
985 </Sect1>
986
987 </Chapter>
988
989 <!-- Emacs stuff:
990      ;;; Local Variables: ***
991      ;;; mode: sgml ***
992      ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
993      ;;; End: ***
994  -->