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