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