[project @ 2004-08-08 17:26:26 by krasimir]
[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 &amp; 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 &amp;&amp; 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 On Windows, all of GHC's files are installed in a single directory.
552 If you choose ``Custom'' from the list of install options, you will be given a 
553 choice about where this directory is; otherwise it will be installed 
554 in <filename>c:/ghc/<replaceable>ghc-version</replaceable></filename>.
555 The executable binary for GHC will be installed in the <filename>bin/</filename> sub-directory
556 of the installation directory you choose.
557 </para>
558 <para>(If you have already installed the same version of GHC, Installshield will offer to "modify", 
559 or "remove" GHC.  Choose "remove"; then run <filename>setup.exe</filename> a
560 second time.  This time it should offer to install.)
561 </para>
562 <para>
563 When installation is complete, you should find GHCi and the GHC documentation are 
564 available in your Start menu under "Start/Programs/Glasgow Haskell Compiler".
565 </para>
566 </listitem>
567
568 <listitem><para>
569 The final dialogue box from the install process reminds you where the GHC binary 
570 has been installed (usually <filename>c:/ghc/<replaceable>ghc-version</replaceable>/bin/</filename>.  
571 If you want to invoke GHC from a command line, add this 
572 to your PATH environment variable.  
573 </para></listitem>
574
575 <listitem><para>
576 GHC needs a directory in which to create, and later delete, temporary files.
577 It uses the standard Windows procedure <literal>GetTempPath()</literal> to
578 find a suitable directory.  This procedure returns:
579 <itemizedlist>
580 <listitem><para>The path in environment variable TMP, 
581 if TMP is set.</para></listitem>
582 <listitem><para>Otherwise, the path in environment variable TEMP, 
583 if TEMP is set.</para></listitem>
584 <listitem><para>Otherwise, there is a per-user default which varies
585 between versions of Windows. On NT and XP-ish versions, it might 
586 be:
587 <filename>c:\Documents and Settings\&lt;username&gt;\Local Settings\Temp</filename>
588 </para></listitem>
589 </itemizedlist>
590 The main point is that if you don't do anything GHC will work fine;
591 but if you want to control where the directory is, you can do so by
592 setting TMP or TEMP.
593 </para></listitem>
594
595 <listitem>
596 <para>
597 To test the fruits of your labour, try now to compile a simple
598 Haskell program:
599 </para>
600
601 <screen>
602 bash$ cat main.hs
603 module Main(main) where
604
605 main = putStrLn "Hello, world!"
606 bash$ ghc -o main main.hs
607 ..
608 bash$ ./main
609 Hello, world!
610 bash$ </screen>
611 </listitem>
612 </itemizedlist>
613
614 <para>
615 You do <emphasis>not</emphasis> need the Cygwin toolchain, or anything
616 else, to install and run GHC.
617 </para>
618 <para>
619 An installation of GHC requires about 140M of disk space.
620 To run GHC comfortably, your machine should have at least
621 64M of memory.
622 </para>
623 </sect2>
624
625 <sect2><title>Moving GHC around</title>
626 <para>
627 At the moment, GHC installs in a fixed place (<filename>c:/ghc/ghc-x.yy</filename>,
628 but once it is installed, you can freely move the entire GHC tree just by copying
629 the <filename>ghc-x.yy</filename> directory.   (You may need to fix up 
630 the links in "Start/Programs/Glasgow Haskell Compiler" if you do this.)
631 </para>
632 <para>
633 It is OK to put GHC tree in a directory whose path involves spaces.  However,
634 don't do this if you use want to use GHC with the Cygwin tools, 
635 because Cygwin can get confused when this happpens.
636 We havn't quite got to the bottom of this, but so far as we know it's not 
637 a problem with GHC itself.  Nevertheless, just to keep life simple we usually
638 put GHC in a place with a space-free path.
639 </para>
640 </sect2>
641
642 <sect2 id="winfaq">
643 <title>Installing ghc-win32 FAQ</title>
644
645 <qandaset>
646
647 <qandaentry>
648
649 <question>
650 <para>
651 I'm having trouble with symlinks.
652 </para>
653 </question>
654
655 <answer>
656 <para>
657 Symlinks only work under Cygwin (<xref linkend="sec-install"/>), so binaries
658 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
659 work with symlinks.
660 </para>
661 </answer>
662
663 </qandaentry>
664
665 <qandaentry>
666
667 <question>
668 <para>
669 I'm getting &ldquo;permission denied&rdquo; messages from the <command>rm</command> or
670 <command>mv</command>.
671 </para>
672 </question>
673
674 <answer>
675 <para>
676 This can have various causes: trying to rename a directory when an Explorer
677 window is open on it tends to fail. Closing the window generally cures the
678 problem, but sometimes its cause is more mysterious, and logging off and back
679 on or rebooting may be the quickest cure.
680 </para>
681 </answer>
682
683 </qandaentry>
684
685 </qandaset>
686
687 <!-- doesn't add much value any longer; leave out [sof 7/2002].
688 <para>
689 Further information on using GHC under Windows can be found in <ulink
690 URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbj&oslash;rn Finne's
691 pages</ulink>. Note: ignore the installation instructions, which are rather
692 out of date; the <emphasis>Miscellaneous</emphasis> section at the bottom of
693 the page is of most interest, covering topics beyond the scope of this
694 manual.
695 </para>
696 -->
697 </sect2>
698
699 </sect1>
700
701
702 <sect1 id="sec-install-files"><title>The layout of installed files</title>
703
704 <para>
705 This section describes what files get installed where.  You don't need to know it
706 if you are simply installing GHC, but it is vital information if you are changing
707 the implementation.
708 </para>
709 <para> GHC is installed in two directory trees:</para>
710 <variablelist>
711 <varlistentry>
712 <term>Library directory,</term>
713 <listitem> <para> known as <filename>$(libdir)</filename>, holds all the 
714 support files needed to run GHC.  On Unix, this 
715 directory is usually something like <filename>/usr/lib/ghc/ghc-5.02</filename>. </para>
716 </listitem>
717 </varlistentry>
718 <varlistentry>
719 <term>Binary directory</term>
720 <listitem> <para> known as <filename>$(bindir)</filename>, holds executables that 
721 the user is expected to invoke.
722 Notably, it contains
723 <filename>ghc</filename> and <filename>ghci</filename>.  On Unix, this directory
724 can be anywhere, but is typically something like <filename>/usr/local/bin</filename>.  On Windows,
725 however, this directory <emphasis>must be</emphasis> <filename>$(libdir)/bin</filename>.
726 </para>
727 </listitem>
728 </varlistentry>
729 </variablelist>
730
731 <para>
732 When GHC runs, it must know where its library directory is.
733 It finds this out in one of two ways:
734 </para>
735 <itemizedlist>
736 <listitem>
737 <para>
738 <filename>$(libdir)</filename> is passed to GHC using the <option>-B</option> flag.
739 On Unix (but not Windows), the installed <filename>ghc</filename> is just a one-line 
740 shell script that invokes the real GHC, passing a suitable <option>-B</option> flag. 
741 [All the user-supplied flags
742 follow, and a later <option>-B</option> flag overrides an earlier one, so a user-supplied
743 one wins.]
744 </para>
745 </listitem>
746 <listitem>
747 <para> On Windows (but not Unix), if no <option>-B</option> flag is given, GHC uses a system
748 call to find the directory in which the running GHC executable lives, and derives 
749 <filename>$(libdir)</filename> from that. [Unix lacks such a system call.]
750 That is why <filename>$(bindir)</filename> must be <filename>$(libdir)/bin</filename>.
751 </para>
752 </listitem>
753 </itemizedlist>
754
755 <sect2> <title>The binary directory</title>
756
757 <para>The binary directory, <filename>$(bindir)</filename> contains user-visible
758 executables, notably <filename>ghc</filename> and <filename>ghci</filename>.
759 You should add it to your <literal>$PATH</literal>
760 </para>
761
762 <para>On Unix, the user-invokable <filename>ghc</filename> invokes <filename>$(libdir)/ghc-<replaceable>version</replaceable></filename>,
763 passing a suitable <option>-B</option> flag to tell <filename>ghc-<replaceable>version</replaceable></filename> where
764 <filename>$(libdir)</filename> is.
765 Similarly <filename>ghci</filename>, except the extra flag <literal>--interactive</literal> is passed.
766 </para>
767
768 <para>On Win32, the user-invokable <filename>ghc</filename> binary 
769 is the Real Thing (no intervening
770 shell scripts or <filename>.bat</filename> files). 
771 Reason: we sometimes invoke GHC with very long command lines,
772 and <filename>cmd.exe</filename> (which executes <filename>.bat</filename> files)
773 truncates them.  Similarly <filename>ghci</filename> is a C wrapper program that invokes <filename>ghc --interactive</filename>
774 (passing on all other arguments), not a <filename>.bat</filename> file.
775 </para>
776
777
778 </sect2>
779
780 <sect2> <title>The library directory</title>
781
782 <para>The layout of the library directory, <filename>$(libdir)</filename> is almost identical on
783 Windows and Unix, as follows.  Differences between Windows and Unix
784 are noted thus <literal>[Win32 only]</literal> and are commented below.</para>
785
786 <programlisting>
787   $(libdir)/
788     package.conf           GHC package configuration
789     ghc-usage.txt          Message displayed by ghc &ndash;&ndash;help
790     
791     bin/                   [Win32 only]  User-visible binaries
792          ghc.exe
793          ghci.exe
794
795     unlit                  Remove literate markup
796     
797     touchy.exe             [Win32 only]
798     perl.exe               [Win32 only]
799     gcc.exe                [Win32 only]
800    
801     ghc-x.xx               GHC executable [Unix only]
802    
803     ghc-split              Asm code splitter
804     ghc-asm                Asm code mangler
805
806     gcc-lib/               [Win32 only] Support files for gcc
807         specs              gcc configuration
808  
809         cpp0.exe           gcc support binaries
810         as.exe
811         ld.exe
812
813         crt0.o              Standard
814            ..etc..          binaries
815         
816         libmingw32.a        Standard
817            ..etc..          libraries
818
819         *.h                 Include files
820
821     imports/                GHC interface files
822         std/*.hi              'std' library
823         lang/*.hi             'lang' library
824         ..etc..
825
826     include/                 C header files
827         StgMacros.h           GHC-specific
828         ..etc...              header files
829
830         mingw/*.h            [Win32 only] Mingwin header files
831
832     libHSrts.a              GHC library archives
833     libHSstd.a
834     libHSlang.a
835       ..etc..
836
837     HSstd1.o                GHC library linkables
838     HSstd2.o                  (used by ghci, which does
839     HSlang.o                  not grok .a files yet)
840 </programlisting>
841
842 <para>Note that:
843 <itemizedlist>
844
845         <listitem>
846           <para><filename>$(libdir)</filename> also contains support
847           binaries.  These are <emphasis>not</emphasis> expected to be
848           on the user's <filename>PATH</filename>, but and are invoked
849           directly by GHC.  In the Makefile system, this directory is
850           also called <filename>$(libexecdir)</filename>, but
851           <emphasis>you are not free to change it</emphasis>.  It must
852           be the same as <filename>$(libdir)</filename>.</para>
853         </listitem>
854
855 <listitem>
856 <para>We distribute <filename>gcc</filename> with the Win32 distribution of GHC, so that users
857 don't need to install <filename>gcc</filename>, nor need to care about which version it is.
858 All <filename>gcc</filename>'s support files are kept in  <filename>$(libdir)/gcc-lib/</filename>.
859 </para> 
860 </listitem>
861
862 <listitem>
863 <para>Similarly, we distribute <filename>perl</filename> and a <filename>touch</filename> 
864 replacement (<filename>touchy.exe</filename>)
865 with the Win32 distribution of GHC. </para> 
866 </listitem>
867
868         <listitem>
869           <para>The support programs <filename>ghc-split</filename>
870           and <filename>ghc-asm</filename> are Perl scripts.  The
871           first line says <literal>#!/bin/perl</literal>; on Unix, the
872           script is indeed invoked as a shell script, which invokes
873           Perl; on Windows, GHC invokes
874           <filename>$(libdir)/perl.exe</filename> directly, which
875           treats the <literal>#!/bin/perl</literal> as a comment.
876           Reason: on Windows we want to invoke the Perl distributed
877           with GHC, rather than assume some installed one.  </para>
878         </listitem>
879 </itemizedlist>
880 </para>
881
882 </sect2>
883
884 </sect1>
885
886 </chapter>
887
888 <!-- Emacs stuff:
889      ;;; Local Variables: ***
890      ;;; mode: sgml ***
891      ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
892      ;;; End: ***
893  -->