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