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