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