f518bd1f450d4f75f77d146d2145dfe66aa54a5e
[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>libHS.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>info/</Literal></Term>
167 <ListItem>
168 <Para>
169 contains Emacs info documentation files (one
170 sub-directory per project).
171 </Para>
172 </ListItem></VarListEntry>
173 <VarListEntry>
174 <Term><Literal>html/</Literal></Term>
175 <ListItem>
176 <Para>
177 contains HTML documentation files (one
178 sub-directory per project).
179 </Para>
180 </ListItem></VarListEntry>
181 <VarListEntry>
182 <Term><Literal>man/</Literal></Term>
183 <ListItem>
184 <Para>
185 contains Unix manual pages.
186 </Para>
187 </ListItem></VarListEntry>
188 </VariableList>
189 </Para>
190
191 <Para>
192 This structure is designed so that you can unpack multiple bundles
193 (including ones from different releases or platforms) into a single
194 <Literal>fptools</Literal> directory
195 <FOOTNOTE>
196
197 <Para>
198 this doesn't work at the
199 moment
200 </Para>
201
202 </FOOTNOTE>
203 :
204 </Para>
205
206 <Para>
207
208 <Screen>
209 % cd /your/scratch/space
210 % gunzip &#60; ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -
211 % gunzip &#60; happy-x.xx-sun-sparc-sunos4.tar.gz | tar xvf -</Screen>
212
213 </Para>
214
215 <Para>
216 When you do multiple unpacks like this, the top level <Literal>Makefile</Literal>,
217 <Literal>README</Literal>, and <Literal>INSTALL</Literal> get overwritten each time.
218 That's fine&mdash;they should be the same.  Likewise, the
219 <Literal>ANNOUNCE-&lt;bundle&gt;</Literal> and <Literal>NEWS-&lt;bundle&gt;</Literal>
220 files will be duplicated across multiple platforms, so they will be
221 harmlessly overwritten when you do multiple unpacks.  Finally, the
222 <Literal>share/</Literal> stuff will get harmlessly overwritten when you do
223 multiple unpacks for one bundle on different platforms.
224 </Para>
225
226 <Sect3 id="sec-install">
227 <Title>Installing</Title>
228
229 <Para>
230 OK, so let's assume that you have unpacked your chosen bundles into a
231 scratch directory <Literal>fptools</Literal>. What next? Well, you will at least need
232 to run the <Literal>configure</Literal><IndexTerm><Primary>configure</Primary></IndexTerm> script by changing your
233 directory to <Literal>fptools</Literal> and typing <Literal>./configure</Literal>.  That should convert
234 <Literal>Makefile.in</Literal> to <Literal>Makefile</Literal>.
235 </Para>
236
237 <Para>
238 <IndexTerm><Primary>installing in-place</Primary></IndexTerm>
239 <IndexTerm><Primary>in-place installation</Primary></IndexTerm>
240 You can now either start using the tools <Emphasis>in-situ</Emphasis> without going
241 through any installation process, just type <Literal>make in-place</Literal> to set the
242 tools up for this. You'll also want to add the path which <Literal>make</Literal> will
243 now echo to your <Literal>PATH</Literal> environment variable. This option is useful if
244 you simply want to try out the package and/or you don't have the
245 necessary privileges (or inclination) to properly install the tools
246 locally. Note that if you do decide to install the package `properly'
247 at a later date, you have to go through the installation steps that
248 follows.
249 </Para>
250
251 <Para>
252 To install an <Literal>fptools</Literal> package, you'll have to do the following:
253 </Para>
254
255 <Para>
256
257 <OrderedList>
258 <ListItem>
259
260 <Para>
261  Edit the <Literal>Makefile</Literal> and check the settings of the following variables:
262
263 <IndexTerm><Primary>directories, installation</Primary></IndexTerm>
264 <IndexTerm><Primary>installation directories</Primary></IndexTerm>
265
266 <VariableList>
267
268 <VarListEntry>
269 <Term><Literal>platform</Literal></Term>
270 <ListItem>
271 <Para>
272 the platform you are going to install for.
273 </Para>
274 </ListItem></VarListEntry>
275 <VarListEntry>
276 <Term><Literal>bindir</Literal></Term>
277 <ListItem>
278 <Para>
279 the directory in which to install user-invokable
280 binaries.
281 </Para>
282 </ListItem></VarListEntry>
283 <VarListEntry>
284 <Term><Literal>libdir</Literal></Term>
285 <ListItem>
286 <Para>
287 the directory in which to install
288 platform-dependent support files.
289 </Para>
290 </ListItem></VarListEntry>
291 <VarListEntry>
292 <Term><Literal>datadir</Literal></Term>
293 <ListItem>
294 <Para>
295 the directory in which to install
296 platform-independent support files.
297 </Para>
298 </ListItem></VarListEntry>
299 <VarListEntry>
300 <Term><Literal>infodir</Literal></Term>
301 <ListItem>
302 <Para>
303 the directory in which to install Emacs info
304 files.
305 </Para>
306 </ListItem></VarListEntry>
307 <VarListEntry>
308 <Term><Literal>htmldir</Literal></Term>
309 <ListItem>
310 <Para>
311 the directory in which to install HTML
312 documentation.
313 </Para>
314 </ListItem></VarListEntry>
315 <VarListEntry>
316 <Term><Literal>dvidir</Literal></Term>
317 <ListItem>
318 <Para>
319 the directory in which to install DVI
320 documentation.
321 </Para>
322 </ListItem></VarListEntry>
323 </VariableList>
324
325 The values for these variables can be set through invocation of the
326 <Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm> script that comes with the distribution,
327 but doing an optical diff to see if the values match your expectations
328 is always a Good Idea.
329
330 <Emphasis>Instead of running <Command>configure</Command>, it is perfectly OK to copy
331 <Filename>Makefile.in</Filename> to <Filename>Makefile</Filename> and set all these variables
332 directly yourself.  But do it right!</Emphasis>
333
334 </Para>
335 </ListItem>
336 <ListItem>
337
338 <Para>
339 Run <Literal>make install</Literal>.  This <Emphasis> should</Emphasis> work with ordinary Unix
340 <Literal>make</Literal>&mdash;no need for fancy stuff like GNU <Literal>make</Literal>. 
341
342 </Para>
343 </ListItem>
344 <ListItem>
345
346 <Para>
347 <Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
348 stuff in your bin directory.
349
350 </Para>
351 </ListItem>
352 <ListItem>
353
354 <Para>
355  Once done, test your &ldquo;installation&rdquo; as suggested in 
356 <XRef LinkEnd="sec-GHC-test">.  Be sure to use a <Literal>-v</Literal>
357 option, so you can see exactly what pathnames it's using.
358
359 If things don't work as expected, check the list of know pitfalls in
360 the building guide.
361 </Para>
362 </ListItem>
363
364 </OrderedList>
365
366 </Para>
367
368 <Para>
369 <IndexTerm><Primary>link, installed as ghc</Primary></IndexTerm>
370 When installing the user-invokable binaries, this installation
371 procedure will install GHC as <Literal>ghc-x.xx</Literal> where <Literal>x.xx</Literal> is the version
372 number of GHC.  It will also make a link (in the binary installation
373 directory) from <Literal>ghc</Literal> to <Literal>ghc-x.xx</Literal>.  If you install multiple versions
374 of GHC then the last one &ldquo;wins&rdquo;, and &ldquo;<Literal>ghc</Literal>&rdquo; will invoke the last
375 one installed.  You can change this manually if you want.  But
376 regardless, <Literal>ghc-x.xx</Literal> should always invoke GHC version <Literal>x.xx</Literal>.
377 </Para>
378
379 </Sect3>
380
381
382 <Sect3>
383 <Title>What bundles there are</Title>
384
385 <Para>
386 <IndexTerm><Primary>bundles, binary</Primary></IndexTerm>
387 There are plenty of &ldquo;non-basic&rdquo; GHC bundles.  The files for them are
388 called <Literal>ghc-x.xx-&lt;bundle&gt;-&lt;platform&gt;.tar.gz</Literal>, where
389 the <Literal>&lt;platform&gt;</Literal> is as above, and <Literal>&lt;bundle&gt;</Literal> is one
390 of these:
391 </Para>
392
393 <Para>
394 <VariableList>
395
396 <VarListEntry>
397 <Term><Literal>prof</Literal>:</Term>
398 <ListItem>
399 <Para>
400 Profiling with cost-centres.  You probably want this.
401 <IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
402 <IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
403 </Para>
404 </ListItem></VarListEntry>
405 <VarListEntry>
406 <Term><Literal>par</Literal>:</Term>
407 <ListItem>
408 <Para>
409 Parallel Haskell features (sits on top of PVM).
410 You'll want this if you're into that kind of thing.
411 <IndexTerm><Primary>parallel bundles</Primary></IndexTerm>
412 <IndexTerm><Primary>bundles, parallel</Primary></IndexTerm>
413 </Para>
414 </ListItem></VarListEntry>
415 <VarListEntry>
416 <Term><Literal>gran</Literal>:</Term>
417 <ListItem>
418 <Para>
419 The &ldquo;GranSim&rdquo; parallel-Haskell simulator
420 (hmm&hellip; mainly for implementors).
421 <IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
422 <IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
423 </Para>
424 </ListItem></VarListEntry>
425 <VarListEntry>
426 <Term><Literal>ticky</Literal>:</Term>
427 <ListItem>
428 <Para>
429 &ldquo;Ticky-ticky&rdquo; profiling; very detailed
430 information about &ldquo;what happened when I ran this program&rdquo;&mdash;really
431 for implementors.
432 <IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
433 <IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
434 </Para>
435 </ListItem></VarListEntry>
436 </VariableList>
437 </Para>
438
439 <Para>
440 One likely scenario is that you will grab <Emphasis>two</Emphasis>
441 binary bundles&mdash;basic, and profiling.  We don't usually make the
442 rest, although you can build them yourself from a source distribution.
443 </Para>
444
445 </Sect3>
446
447 <Sect3 id="sec-GHC-test">
448 <Title>Testing that GHC seems to be working
449 </Title>
450
451 <Para>
452 <IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
453 </Para>
454
455 <Para>
456 The way to do this is, of course, to compile and run <Emphasis>this</Emphasis> program
457 (in a file <Literal>Main.hs</Literal>):
458 </Para>
459
460 <Para>
461
462 <ProgramListing>
463 main = putStr "Hello, world!\n"
464 </ProgramListing>
465
466 </Para>
467
468 <Para>
469 Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
470 libraries, etc., are being found properly:
471
472 <Screen>
473 % ghc -v -o hello Main.hs</Screen>
474
475 </Para>
476
477 <Para>
478 Now run it:
479
480 <Screen>
481 % ./hello
482 Hello, world!</Screen>
483
484 </Para>
485
486 <Para>
487 Some simple-but-profitable tests are to compile and run the notorious
488 <Literal>nfib</Literal><IndexTerm><Primary>nfib</Primary></IndexTerm> program, using different numeric types.  Start with
489 <Literal>nfib :: Int -&gt; Int</Literal>, and then try <Literal>Integer</Literal>, <Literal>Float</Literal>, <Literal>Double</Literal>,
490 <Literal>Rational</Literal> and perhaps the overloaded version.  Code for this is
491 distributed in <Literal>ghc/misc/examples/nfib/</Literal> in a source distribution.
492 </Para>
493
494 <Para>
495 For more information on how to &ldquo;drive&rdquo; GHC, either do <Literal>ghc -help</Literal> or
496 consult the User's Guide (distributed in several pre-compiled formats
497 with a binary distribution, or in source form in
498 <Literal>ghc/docs/users&lowbar;guide</Literal> in a source distribution).
499 </Para>
500
501 </Sect3>
502
503 </Sect2>
504
505 </Sect1>
506
507
508 <Sect1><Title>Installing on Windows</Title>
509
510 <Para>
511 Getting the Glasgow Haskell Compiler(GHC) to run on Windows95/98 or
512 Windows NT4 platforms can be a bit of a trying experience. This document
513 tries to simplify the task by enumerating the steps you need to
514 follow in order to set up and configure your machine to run GHC (at
515 least that's the intention ;-)
516 </Para>
517
518 <Sect2><Title>System requirements</Title>
519
520 <Para>
521 An installation of GHC requires ca. 70M of disk space. The size of the
522 installed GHC distribution is just(!) 17M, the rest is needed by
523 supporting software.
524 </Para>
525
526 <Para>
527 To run GHC comfortably, your machine should have at least 32M of memory.
528 </Para>
529
530 </Sect2>
531
532
533 <Sect2><Title>Your environment variables</Title>
534
535 <Para>
536 Much of the Unixy stuff below involves setting environment variables.  
537 This section summarises  how to set these variables on a Windows machine, in
538 case you don't know alread.y
539 On WinNT/Win2k, to edit your <Constant>PATH</Constant> variable (for example),
540 do the following:
541 </Para>
542
543 <ItemizedList>
544 <ListItem><Para>Press Start/Settings/Control Panels</Para></ListItem>
545 <ListItem><Para>Double-click System</Para></ListItem>
546 <ListItem><Para>Press Advanced</Para></ListItem>
547 <ListItem><Para>Press Environment Variables</Para></ListItem>
548 <ListItem><Para>Under System Variables, select PATH</Para></ListItem>
549 <ListItem><Para>Press Edit</Para></ListItem>
550 <ListItem><Para>Add "<Filename>;C:/whatever/</Filename>" to the end of the string (for example)</Para></ListItem>
551 <ListItem><Para>Press OK</Para></ListItem>
552 </ItemizedList>
553
554 <Para>
555 Some environment variables are &ldquo;user variables&rdquo; and
556 some are &ldquo;system variables&rdquo;.  I'm not sure of the difference
557 but both are changed though the same dialogue.
558 </Para>
559
560 <Para>
561 In addition, when running a Cygwin (see <XRef LinkEnd="sec-required">) shell
562 you can set environment variables in your <Filename>.bashrc</Filename> file.
563 But it is better to set your environment variables from the
564 control panel (they get inherited by bash) because then they are visible
565 to applications that aren't started by bash.  For example,
566 when you're invoking CVS (and ssh) via Emacs keybindings;
567 it invokes <Filename>cvs.exe</Filename> without going via bash.
568 </Para>
569
570 <Para>
571 On a Win9x machine you need to edit <Filename>autoexec.bat</Filename> using
572 <Filename>Windows/system/Sysedit</Filename>.  You need to reboot to make
573 the new settings take effect.
574 </Para>
575
576 </Sect2>
577
578
579 <Sect2 id="sec-required"><Title>Software required</Title>
580
581 <Para>
582 You need two chunks of software other than GHC itself: the Cygwin toolchain, and Perl.  Here's how to get and install them.
583 </Para>
584
585 <Sect3><Title>The cygwin toolchain (beta20.1)</Title>
586
587 <Para>
588 GHC depends at the moment on the cygwin tools to operate, which
589 dresses up the Win32 environment into something more UNIX-like.
590 (notably, it provides <Command>gcc</Command>, <Command>as</Command> and <Command>ld</Command>),
591 so you'll need to install these tools first. You also need
592 Cygwin to use CVS.
593 </Para>
594
595 <Para>
596 Important grungy information about Cygwin:
597 </Para>
598
599 <ItemizedList>
600
601 <ListItem>
602 <Para>
603 Cygwin doesn't deal well with filenames that include
604 spaces. "<Filename>Program Files</Filename>" and "<Filename>Local files</Filename>" are
605 common gotchas.
606 </Para>
607 </ListItem>
608
609 <ListItem>
610 <Para>
611 Cygwin implements a symbolic link as a text file with some
612 magical text in it.  So programs that don't use Cygwin's
613 I/O libraries won't recognise such files as symlinks.  
614 In particular, programs compiled by GHC are meant to be runnable
615 without having Cygwin, so they don't use the Cygwin library, so
616 they don't recognise symlinks.
617 </Para>
618 </ListItem>
619
620 </ItemizedList>
621
622 <Para>
623 Here's how to install Cygwin.
624 </Para>
625
626 <ItemizedList>
627
628 <ListItem>
629 <Para>
630 Download cygwin, beta20.1 (<filename>full.exe</filename>) from
631 <ULink URL="http://sourceware.cygnus.com/cygwin/">sourceware.cygnus.com</ULink>
632 Install this somewhere locally.
633 </Para>
634 </ListItem>
635
636 <ListItem>
637 <Para>
638 Create the following directories (if they aren't already there):
639 </Para>
640
641 <ItemizedList>
642 <ListItem><Para><Filename>c:/etc</Filename></Para></ListItem>
643 <ListItem><Para><Filename>c:/bin</Filename></Para></ListItem>
644 <ListItem><Para><Filename>c:/usr/local/bin</Filename></Para></ListItem>
645 </ItemizedList>
646
647 <Para>
648 (using <Command>mkdir -p /bin</Command>, etc.)
649 </Para>
650 </ListItem>
651
652 <ListItem>
653 <Para>
654 Copy <Filename>bash.exe</Filename> from the <Filename>bin</Filename>
655 directory of the cygwin tree
656 (<Filename>cygwin-b20/H-i586-cygwin32/bin/bash.exe</Filename>) to
657 <Filename>/bin</Filename> as <Filename>sh.exe</Filename>.  You might
658 think that it was easier to use bash directly from it original Cygwin
659 directory, but (a) some UNIX utils have got
660 <Filename>/bin/sh</Filename> hardwired in, and (b) the path following
661 <Literal>#!</Literal> is limited to 32 characters.
662 </Para>
663 </ListItem>
664
665 <ListItem>
666 <Para>
667 If you're an Emacs user and want to be able to run <Command>bash</Command>
668 from within a shell buffer, see the <ULink URL="http://www.cs.washington.edu/homes/voelker/ntemacs.html">NT Emacs home page</ULink> for
669 instructions on how to set this up.
670 </Para>
671 </ListItem>
672
673 </ItemizedList>
674
675 <Para>
676 The following environment variables must be set:
677 </Para>
678
679 <Para>
680 <InformalTable>
681 <TGroup cols="2">
682 <ColSpec Align="Left" Colsep="0">
683 <ColSpec Align="Left" Colsep="0">
684 <TBody>
685
686 <Row>
687 <Entry><Constant>PATH</Constant></Entry>
688 <Entry>System</Entry>
689 <Entry><Para>
690 Add <Filename>C:\cygnus\cygwin-b20\H-i586-cygwin32\bin</Filename>.
691 <Command>bash</Command> needs this, and when it is invoked from <Filename>/bin</Filename> it can't
692 find it. <Filename>c:/bin</Filename> and <Filename>c:/usr/local/bin</Filename> should also be added.
693 </Para></Entry>
694 </Row>
695
696 <Row>
697 <Entry><Constant>SHELL</Constant></Entry>
698 <Entry>User</Entry>
699 <Entry><Para>
700 <Filename>c:/bin/sh</Filename>.
701 </Para></Entry>
702 </Row>
703
704 <Row>
705 <Entry><Constant>HOME</Constant></Entry>
706 <Entry>User</Entry>
707 <Entry><Para>
708 Set to point to your home directory.  This is where, for example,
709 <Command>bash</Command> will look for your <Filename>.bashrc</Filename>
710 file.
711 </Para></Entry>
712 </Row>
713
714 <Row>
715 <Entry><Constant>MAKE_MODE</Constant></Entry>
716 <Entry>User</Entry>
717 <Entry><Para>
718 Set to <Literal>UNIX</Literal>.  If you don't do
719 this you get very weird messages when you type `<Command>make</Command>', such as:
720 </Para><Screen>
721 /c: /c: No such file or directory</Screen></Entry>
722 </Row>
723
724 <Row>
725 <Entry><Constant>TMPDIR</Constant></Entry>
726 <Entry>User</Entry>
727 <Entry><Para>
728 Set to <Filename>c:/tmp</Filename>. For some reason, Win2k invisibly sets
729 this variable to point to a temporary directory in your profile, that
730 contains embedded spaces.  If GHC sees the <Constant>TMPDIR</Constant>
731 variable set, it tries to use it for temporary files, but Cygwin
732 doesn't grok filenames with spaces, so disaster results.
733 </Para><Para>
734 Furthermore, it seems that <Constant>TMPDIR</Constant> must be set to a directory
735 in the same file system in which you invoke GHC.  Otherwise you get very werid messages
736 when you invoke GHC, such as:
737 <Screen>
738 does not exist
739 Action: openFile
740 Reason: file does not exist /tmp/ghc11068.cpp</Screen>
741 We think this is due to a bug in Cygwin.
742 </Para></Entry>
743 </Row>
744 </TBody>
745
746 </TGroup>
747 </InformalTable>
748 </Para>
749
750 </Sect3>
751
752
753 <Sect3><Title>Perl5</Title>
754
755 <Para>
756 The driver script is written in Perl, so you'll need to have this
757 installed too. However, the ghc binary distribution includes a
758 perl binary for you to make use of, should you not already have a
759 cygwin compatible one. Note: GHC does <Emphasis>not</Emphasis>
760 work with the ActiveState port of perl.
761 </Para>
762
763 </Sect3>  <!-- Perl -->
764
765 </Sect2>  <!-- Reqd software -->
766
767
768 <Sect2><Title>Installing GHC</Title>
769
770 <Para>
771 Download a GHC distribution:
772 </Para>
773
774 <VariableList>
775
776 <VarListEntry>
777 <Term>ghc-4.045&mdash;InstallShield installer, 10M: <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-4.045-win32-IS.zip">http</ULink> or <ULink URL="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow/4.04/ghc-4.045-win32-IS.zip">ftp</ULink>
778 </Term>
779
780 <ListItem>
781 <Para>
782 (The version number may change.) It is packaged up using an installer that should be familiar-looking to Windows users. Unpack and double click on <Filename>setup.exe</Filename>.
783 </Para>
784
785 <Para>
786 Note: The cygwin support for long file names containing
787 spaces is not 100%, so make sure that you install ghc in a directory
788 that has no embedded spaces (i.e., resist the temptation to put it
789 in <Filename>/Program Files/</Filename>!)
790 </Para>
791
792 <Para>
793 When the installer has completed its job, you may delete the
794 <Filename>ghcInstall</Filename> directory.
795 </Para>
796
797 <Para>
798 When the installer has completed, make sure you add the location of the
799 ghc <Filename>bin/</Filename> directory to your path (i.e. <Filename>/path/to/wherever/ghc-4.05/bin </Filename>).
800 You need to do this in order to bring the various GHC DLLs into scope;
801 if not, then you need to copy the DLLs into a directory that is (the
802 system directory, for example).
803 </Para>
804
805 <Para>
806 Note: In case you haven't got perl already installed,
807 you will have to manually copy the <Filename>perl.exe</Filename> binary from the
808 ghc <Filename>bin/</Filename> into your <Filename>/bin</Filename> directory before continuing&mdash;the installer will not currently do this.
809 </Para>
810 </ListItem>
811
812 </VarListEntry>
813
814 <VarListEntry>
815 <Term>
816 ghc-4.045 - gzip'ed tarfile, 7.5M: <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-4.045-win32.tar.gz">
817 http</ULink> or <ULink URL="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow/4.04/ghc-4.045-win32.tar.gz">ftp</ULink>
818 </Term>
819
820 <ListItem>
821 <Para>
822 A `normal' GHC binary distribution packaged up as a compressed tar file.
823 If you're already accustomed to installing and using GHC distributions
824 on other platforms, the setup should be familiar to you, I
825 hope. Unpack and read the INSTALL file contained in the
826 distribution for instructions on how to set it up.
827 </Para>
828
829 <Para>
830 Notice that the top directory of the distribution contains
831 (rather clumsily) a perl binary (version 5.005_02). If you
832 haven't already got a working perl, install this somewhere
833 along your path too.
834 </Para>
835 </ListItem>
836
837 </VarListEntry>
838 </VariableList>
839
840 <Para>
841 Make sure that you set all the environment variables described above
842 under Cygwin installation, including <Constant>TMPDIR</Constant>
843 </Para>
844 <Para>
845 To test the fruits of your labour, try now to compile a simple
846 Haskell program:
847 </Para>
848
849 <Screen>
850 bash$ cat main.hs
851 module Main(main) where
852
853 main = putStrLn "Hello, world!"
854 bash$ /path/to/the/ghc/bin/directory/ghc-4.05 -o main main.hs
855 ..
856 bash$ ./main
857 Hello, world!
858 bash$ </Screen>
859
860 <Para>
861 OK, assuming that worked, you're all set. Go forth and write useful
862 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">).
863 </Para>
864
865 <Para>
866 Further information on using GHC under Windows can be found in <ULink URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbj&oslash;rn Finne's pages</ULink>.
867 </Para>
868
869 </Sect2>
870
871 </Sect1>
872
873
874 <Sect1 id="winfaq"><title>Installing ghc-win32 FAQ</title>
875
876 <QandASet>
877
878 <QandAEntry>
879
880 <Question>
881 <Para>
882 Invoking ghc doesn't seem to do anything, it immediately returns without having compiled the input file.
883 </Para>
884 </Question>
885
886 <Answer>
887 <Para>
888 One cause of this is that <Filename>/bin/sh</Filename> is missing. To verify, open up a
889 bash session and type <Command>ls -l /bin/sh.exe</Command>. If <Filename>sh.exe</Filename> is 
890 reported as not being there, copy <Filename>bash.exe</Filename> (which you'll find
891 inside the cygwin installation tree as <Filename>H-i586-cygwin32/bin/bash.exe</Filename>)
892 to <Filename>/bin/sh.exe</Filename>.
893 </Para>
894
895 <Para>
896 All being well, ghc should then start to function.
897 </Para>
898 </Answer>
899
900 </QandAEntry>
901
902 <QandAEntry>
903
904 <Question>
905 <Para>
906 When compiling up the <Literal>Hello World</Literal> example, the following happens:
907 </Para>
908
909 <Screen>
910 bash$ /ghc/ghc-4.05/bin/ghc-4.05 main.hs
911 &lt;stdin&gt;:0:25: Character literal '{-# LINE 1 "main.hs" -}' too long
912 &lt;stdin&gt;:0:25:  on input: "'"
913 bash$ </Screen>
914
915 <Para>
916 or
917 </Para>
918
919 <Screen>
920 bash$ /ghc/ghc-4.05/bin/ghc-4.05 main.hs
921 Program too big fit into memory under NT
922 bash$ </Screen>
923 </Question>
924
925 <Answer>
926 <Para>
927 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.
928 </Para>
929
930 <Para>
931 The GHC driver really needs a <Command>perl</Command> which uses a `UNIX'y  shell instead, so
932 make sure that the version you're using is of an compatible ilk. In particular, 
933 if <Command>perl -v</Command> reports that you've got a copy of the (otherwise fine) port
934 of perl done by ActiveState, you're in trouble.
935 </Para>
936
937 <Para>
938 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.
939 </Para>
940
941 <Para>
942 Notice that copying <Filename>perl.exe</Filename> into <Filename>/bin</Filename> will not cause
943 the GHC install to suddenly start functioning. If you don't want to
944 re-run the InstallShield installer again, you need to edit the following
945 files within the directory tree that the installer created:
946 </Para>
947
948 <Screen>
949 bin/ghc-4.xx   -- where xx is the minor release number
950 bin/stat2resid
951 bin/hstags
952 lib/mkdependHS</Screen>
953
954 <Para>
955 For each of these files, you need to edit the first line from instead
956 saying <Command>#!/path/to/your/other/perl/install</Command> to <Command>#!/bin/perl</Command>.
957 Once that is done, try compiling up the Hello, World example again.
958 </Para>
959
960 <Para>
961 Should you want to pick up a complete installation of a ghc-friendly port
962 of perl instead, a <ULink URL="http://cygutils.netpedia.net/">cygwin port</ULink> is available.
963 </Para>
964 </Answer>
965
966 </QandAEntry>
967
968 <QAndAEntry>
969
970 <Question>
971 <Para>
972 <Function>System.getArgs</Function> always return the empty list, i.e. the following program always prints &ldquo;<Literal>[]</Literal>&rdquo;:
973 </Para>
974
975 <ProgramListing>
976 module Main(main) where
977 import qualified System
978 main = System.getArgs >>= print
979 </ProgramListing>
980
981 </Question>
982
983 <Answer>
984 <Para>
985 This is a bug with the RTS DLL that comes with ghc-4.03. To fix, upgrade to
986 ghc-4.05.
987 </Para>
988 </Answer>
989
990 </QAndAEntry>
991
992 </QandASet>
993
994 </Sect1>
995
996
997 <Sect1>
998 <Title>Building the documentation</Title>
999
1000 <Para>
1001 This is a slightly sore point at the moment, because the GHC team has been unable to strike a good balance between having a documentation system that is easy to maintain and one that is widely available. We use the DocBook DTD, which is widely used; however, shrink-wrapped distributions of DocBook are few and far between, and getting it to work out of the box is a nightmare. We settled on the Cygnus DocBook tools; however, these are only available as Red Hat RPMs, and hence at the moment the documentation can only be built on systems which can use RPMs (i.e. most versions of Linux). Sorry about that. We will probably add pre-built documentation to future binary distributions until the situation is sorted out (either we bite the bullet and have our own version of the DocBook tools, or a more portable distribution is made available).
1002 </Para>
1003
1004 <Para>
1005 See the Building Guide for details of what to install to get the DocBook tools and how to build the documentation (it's done by the build system, but just isn't part of a normal build).
1006 </Para>
1007
1008 </Sect1>
1009
1010 </Chapter>