b37f9a13bb6399c7c92f55e0439c7a7cbc966ba8
[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 file type.
599 </Para>
600 </ListItem>
601
602 <ListItem>
603 <Para>
604 Create <Filename>C:/Temp</Filename> if it doesn't already exist; substitute
605 the drive you installed Cygwin on for <Filename>C:</Filename>.
606 </Para>
607 </ListItem>
608
609 <ListItem>
610 <Para>
611 If you're an Emacs user and want to be able to run <Command>bash</Command>
612 from within a shell buffer, see the <ULink URL="http://www.cs.washington.edu/homes/voelker/ntemacs.html">NT Emacs home page</ULink> for
613 instructions on how to set this up.
614 </Para>
615 </ListItem>
616
617 </ItemizedList>
618
619 </Sect3>
620
621
622 <Sect3><Title>Environment variables</Title>
623
624 <Para>
625 In case you don't already know how to set environment variables on a Windows
626 machine, here's how. On WinNT/Win2k, to edit your <Constant>PATH</Constant>
627 variable (for example), do the following:
628 </Para>
629
630 <ItemizedList>
631 <ListItem><Para>Press Start/Settings/Control Panels</Para></ListItem>
632 <ListItem><Para>Double-click System</Para></ListItem>
633 <ListItem><Para>Press Advanced</Para></ListItem>
634 <ListItem><Para>Press Environment Variables</Para></ListItem>
635 <ListItem><Para>Under System Variables, select <Constant>PATH</Constant></Para></ListItem>
636 <ListItem><Para>Press Edit</Para></ListItem>
637 <ListItem><Para>Add "<Filename>;C:\whatever</Filename>" to the end of the string (for example)</Para></ListItem>
638 <ListItem><Para>Press OK</Para></ListItem>
639 </ItemizedList>
640
641 <Para>
642 Some environment variables are &ldquo;user variables&rdquo; and
643 some are &ldquo;system variables&rdquo;.  I'm not sure of the difference
644 but both are changed though the same dialogue.
645 </Para>
646
647 <Para>
648 In addition, when running <Command>bash</Command>
649 you can set environment variables in your <Filename>.bashrc</Filename> file.
650 But it is better to set your environment variables from the
651 control panel (they get inherited by bash) because then they are visible
652 to applications that aren't started by bash.  For example,
653 when you're invoking CVS (and ssh) via Emacs keybindings;
654 it invokes <Filename>cvs.exe</Filename> without going via bash.
655 </Para>
656
657 <Para>
658 On a Win9x machine you need to edit <Filename>autoexec.bat</Filename> using
659 <Filename>Windows/System/Sysedit</Filename>.  You must reboot to make
660 the new settings take effect.
661 </Para>
662
663 <Para>
664 The following environment variables must be set:
665 </Para>
666
667 <Para>
668 <InformalTable>
669 <TGroup cols="2">
670 <ColSpec Align="Left" Colsep="0">
671 <ColSpec Align="Left" Colsep="0">
672 <TBody>
673
674 <Row>
675 <Entry><Constant>PATH</Constant></Entry>
676 <Entry>System</Entry>
677 <Entry><Para>
678 Add <Filename>C:\usr\bin</Filename>.
679 This should come <Emphasis>before</Emphasis> the Windows system directories
680 (e.g. <Filename>\WINNT\system32</Filename>).
681 </Para></Entry>
682 </Row>
683
684 <Row>
685 <Entry><Constant>SHELL</Constant></Entry>
686 <Entry>User</Entry>
687 <Entry><Para>
688 <Filename>C:/usr/bin/bash</Filename>.
689 </Para></Entry>
690 </Row>
691
692 <Row>
693 <Entry><Constant>HOME</Constant></Entry>
694 <Entry>User</Entry>
695 <Entry><Para>
696 Set to point to your home directory (normally under
697 <Filename>C:/WINNT/Profiles</Filename> on Win2k).  This is where, for example,
698 <Command>bash</Command> will look for your <Filename>.bashrc</Filename>
699 file.
700 </Para></Entry>
701 </Row>
702
703 <Row>
704 <Entry><Constant>MAKE_MODE</Constant></Entry>
705 <Entry>User</Entry>
706 <Entry><Para>
707 Set to <Literal>UNIX</Literal>.  If you don't do
708 this you get very weird messages when you type <Command>make</Command>, such as:
709 </Para><Screen>
710 /c: /c: No such file or directory</Screen></Entry>
711 </Row>
712
713 <Row>
714 <Entry><Constant>TMPDIR</Constant></Entry>
715 <Entry>User</Entry>
716 <Entry><Para>
717 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.
718 </Para><Para>
719 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:
720 <Screen>
721 does not exist
722 Action: openFile
723 Reason: file does not exist /Temp/ghc11068.cpp</Screen>
724 We think this is due to a bug in Cygwin.
725 </Para></Entry>
726 </Row>
727 </TBody>
728
729 </TGroup>
730 </InformalTable>
731 </Para>
732
733 <Para>
734 In addition, we've had problems in the past with certain environment
735 variables being set that seem to have bad effects on GHC. If you have
736 installed other systems ported from Unix, you might too. If you get weird
737 inexplicable failures to build GHC, then it might be worth weeding out unused
738 environment variables. Known culprits from the past include
739 <Constant>GCC_EXEC_PREFIX</Constant> and <Constant>INCLUDE</Constant>.
740 </Para>
741
742 </Sect3>
743
744 </Sect2>  <!-- Reqd software -->
745
746
747 <Sect2><Title>Installing GHC</Title>
748
749 <Para>
750 Download the latest GHC distribution:
751 </Para>
752
753 <VariableList>
754
755 <VarListEntry>
756 <Term>ghc-4.08 InstallShield installer, 15M: <ULink
757 URL="http://www.haskell.org/ghc/download.html">http</ULink>
758 </Term>
759
760 <ListItem>
761 <Para>
762 It is packaged up using an installer that should be familiar-looking to
763 Windows users.
764 </Para>
765
766 <Para>
767 Note: The cygwin support for long file names containing
768 spaces is not 100%, so make sure that you install ghc in a directory
769 that has no embedded spaces (i.e., resist the temptation to put it
770 in <Filename>/Program Files/</Filename>!)
771 </Para>
772
773 <Para>
774 When the installer has completed, make sure you add the location of the
775 ghc <Filename>bin/</Filename> directory to your path (e.g.
776 <Filename>/ghc/ghc-4.08/bin </Filename>).
777 You need to do this in order to bring the various GHC binaries into scope.
778 </Para>
779
780 <Para>
781 Note: If you haven't got perl already installed, you will have to manually
782 copy the <Filename>perl.exe</Filename> binary from the ghc
783 <Filename>bin/</Filename> into your <Filename>/bin</Filename> directory
784 before continuing&mdash;the installer will not currently do this.
785 </Para>
786 </ListItem>
787
788 </VarListEntry>
789
790 </VariableList>
791
792 <Para>
793 Make sure that you set all the environment variables described above
794 under Cygwin installation, including <Constant>TMPDIR</Constant>.
795 </Para>
796 <Para>
797 To test the fruits of your labour, try now to compile a simple
798 Haskell program:
799 </Para>
800
801 <Screen>
802 bash$ cat main.hs
803 module Main(main) where
804
805 main = putStrLn "Hello, world!"
806 bash$ ghc -o main main.hs
807 ..
808 bash$ ./main
809 Hello, world!
810 bash$ </Screen>
811
812 <Para>
813 OK, assuming that worked, you're all set. Go forth and write useful
814 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">).
815 </Para>
816
817 <Para> Further information on using GHC under Windows can be found in <ULink
818 URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbj&oslash;rn Finne's
819 pages</ULink>. Note: ignore the installation instructions, which are rather
820 out of date; the <Emphasis>Miscellaneous</Emphasis> section at the bottom of
821 the page is of most interest, covering topics beyond the scope of this
822 manual. </Para>
823
824 </Sect2>
825
826
827 <Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>
828
829 <QandASet>
830
831 <QandAEntry>
832
833 <Question>
834 <Para>
835 I'm having trouble with symlinks.
836 </Para>
837 </Question>
838
839 <Answer>
840 <Para>
841 Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
842 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
843 work with symlinks.
844 </Para>
845 </Answer>
846
847 </QandAEntry>
848
849 <QandAEntry>
850
851 <Question>
852 <Para>
853 I'm getting &ldquo;permission denied&rdquo; messages from <Command>rm</Command> or
854 <Command>mv</Command>.
855 </Para>
856 </Question>
857
858 <Answer>
859 <Para>
860 This can have various causes: trying to rename a directory when an Explorer
861 window is open on it tends to fail. Closing the window generally cures the
862 problem, but sometimes its cause is more mysterious, and logging off and back
863 on or rebooting may be the quickest cure.
864 </Para>
865 </Answer>
866
867 </QandAEntry>
868
869 <QandAEntry>
870
871 <Question>
872 <Para>
873 I get errors when trying to build GHC 4.08 with GHC 4.05.
874 </Para>
875 </Question>
876
877 <Answer> <Para> This seems to work better if you don't use
878 <Option>-O</Option> in <Constant>GhcHcOpts</Constant>. It's a bug in 4.05,
879 unfortunately. Anyway, better to install 4.08 binaries and use those.
880 </Para> </Answer>
881
882 </QandAEntry>
883
884 </QandASet>
885
886 </Sect2>
887
888 </Sect1>
889
890
891 <Sect1 id="building-docs">
892 <Title>Building the documentation</Title>
893
894 <Para>
895 We use the DocBook DTD, which is widely used. Most shrink-wrapped
896 distributions seem to be broken in one way or another; thanks to
897 heroic efforts by Sven Panne and Manuel Chakravarty, we now support
898 most of them, plus properly installed versions.
899 </Para>
900
901 <Para>
902 Instructions on installing and configuring the DocBook tools follow.
903 </Para>
904
905 <Sect2>
906 <Title>Installing the DocBook tools from RPMs</Title>
907
908 <Para> If you're using a system that can handle RedHat RPM packages,
909 you can probably use the <ULink
910 URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
911 tools</ULink>, which is the most shrink-wrapped SGML suite that we
912 could find. You need all the RPMs except for psgml (i.e.
913 <Filename>docbook</Filename>, <Filename>jade</Filename>,
914 <Filename>jadetex</Filename>, <Filename>sgmlcommon</Filename> and
915 <Filename>stylesheets</Filename>). Note that most of these RPMs are
916 architecture neutral, so are likely to be found in a
917 <Filename>noarch</Filename> directory. The SuSE RPMs also work; the
918 RedHat ones <Emphasis>don't</Emphasis> in RedHat 6.2 (7.0 and later
919 should be OK), but they are easy to fix: just make a symlink from
920 <Filename>/usr/lib/sgml/stylesheets/nwalsh-modular/lib/dblib.dsl</Filename>
921 to <Filename>/usr/lib/sgml/lib/dblib.dsl</Filename>. </Para>
922
923 </Sect2>
924
925
926 <Sect2>
927 <Title>Installing from binaries on Windows</Title>
928
929 <Para>
930 It's a good idea to use Norman Walsh's <ULink
931 URL="http://nwalsh.com/docbook/dsssl/doc/install.html">installation
932 notes</ULink> as a guide. You should get version 3.1 of DocBook, and note
933 that his file <Filename>test.sgm</Filename> won't work, as it needs version
934 3.0. You should unpack Jade into <Filename>\Jade</Filename>, along with the
935 entities, DocBook into <Filename>\docbook</Filename>, and the DocBook
936 stylesheets into <Filename>\docbook\stylesheets</Filename> (so they actually
937 end up in <Filename>\docbook\stylesheets\docbook</Filename>).
938 </Para>
939
940 </Sect2>
941
942
943 <Sect2>
944 <Title>Installing the DocBook tools from source</Title>
945
946 <Sect3>
947 <Title>Jade</Title>
948
949 <Para>
950 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>
951 subdirectory. (If you get the error:
952
953 <Screen>
954 ! LaTeX Error: Unknown option implicit=false' for package hyperref'.
955 </Screen>
956
957 your version of <Command>hyperref</Command> is out of date; download it from
958 CTAN (<Filename>macros/latex/contrib/supported/hyperref</Filename>), and
959 make it, ensuring that you have first removed or renamed your old copy. If
960 you start getting file not found errors when making the test for
961 <Command>hyperref</Command>, you can abort at that point and proceed
962 straight to <Command>make install</Command>, or enter them as
963 <Filename>../</Filename><Emphasis>filename</Emphasis>.)
964 </Para>
965
966 <Para>
967 Make links from <Filename>virtex</Filename> to <Filename>jadetex</Filename>
968 and <Filename>pdfvirtex</Filename> to <Filename>pdfjadetex</Filename>
969 (otherwise DVI, PostScript and PDF output will not work). Copy
970 <Filename>dsssl/*.{dtd,dsl}</Filename> and <Filename>catalog</Filename> to <Filename>/usr/[local/]lib/sgml</Filename>.
971 </Para>
972
973 </Sect3>
974
975 <Sect3>
976 <Title>DocBook and the DocBook stylesheets</Title>
977
978 <Para>
979 Get a Zip of <ULink
980 URL="http://www.oasis-open.org/docbook/sgml/3.1/index.html">DocBook</ULink> 
981 and install the contents in <Filename>/usr/[local/]/lib/sgml</Filename>.
982 </Para>
983
984 <Para>
985 Get the <ULink URL="http://nwalsh.com/docbook/dsssl/">DocBook
986 stylesheets</ULink> and install in
987 <Filename>/usr/[local/]lib/sgml/stylesheets</Filename> (thereby creating a
988 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>.
989 </Para>
990
991 <Para>
992 Download the <ULink
993 URL="http://www.oasis-open.org/cover/ISOEnts.zip">ISO
994 entities</ULink> into <Filename>/usr/[local/]lib/sgml</Filename>.
995 </Para>
996
997 </Sect3>
998
999 </Sect2>
1000
1001 <Sect2>
1002 <Title>Configuring the DocBook tools</Title>
1003
1004 <Para>
1005 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.
1006 </Para>
1007
1008 </Sect2>
1009
1010 <Sect2>
1011 <Title>Remaining problems</Title>
1012
1013 <Para>
1014 If you install from source, you'll get a pile of warnings of the form
1015
1016 <Screen>DTDDECL catalog entries are not supported</Screen>
1017
1018 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>.
1019 </Para>
1020
1021 </Sect2>
1022
1023 </Sect1>
1024
1025 </Chapter>
1026
1027 <!-- Emacs stuff:
1028      ;;; Local Variables: ***
1029      ;;; mode: sgml ***
1030      ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
1031      ;;; End: ***
1032  -->