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>
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.)
18 <Para>This guide is in two parts: installing on Unix-a-likes, and installing on Windows.</Para>
21 <Sect1><Title>Installing on Unix-a-likes</Title>
24 <title>When a platform-specific package is available</title>
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
34 <para>We generally provide the following packages:</para>
38 <term>RedHat Linux/x86</term>
40 <para>RPM source & binary packages for RedHat Linux (x86
41 only) are available for most major releases.</para>
46 <term>Debian Linux/x86</term>
48 <para>Debian packages for Linux (x86 only), also for most
49 major releases.</para>
54 <term>FreeBSD/x86</term>
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>
64 <para>Other platform-specific packages may be available, check
65 the GHC download page for details.</para>
69 <Title>GHC binary distributions</Title>
72 <IndexTerm><Primary>bundles of binary stuff</Primary></IndexTerm>
76 Binary distributions come in “bundles,” 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:
83 % cd /your/scratch/space
84 % gunzip < ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -</Screen>
89 Then you should find a single directory, <Literal>fptools</Literal>, with the following
94 <IndexTerm><Primary>binary distribution, layout</Primary></IndexTerm>
95 <IndexTerm><Primary>directory layout (binary distributions)</Primary></IndexTerm>
99 <Term><Literal>Makefile.in</Literal></Term>
102 the raw material from which the <Literal>Makefile</Literal>
103 will be made (<Xref LinkEnd="sec-install">).
105 </ListItem></VarListEntry>
107 <Term><Literal>configure</Literal></Term>
110 the configuration script (<Xref LinkEnd="sec-install">).
112 </ListItem></VarListEntry>
114 <Term><Literal>README</Literal></Term>
117 Contains this file summary.
119 </ListItem></VarListEntry>
121 <Term><Literal>INSTALL</Literal></Term>
124 Contains this description of how to install
127 </ListItem></VarListEntry>
129 <Term><Literal>ANNOUNCE</Literal></Term>
132 The announcement message for the bundle.
134 </ListItem></VarListEntry>
136 <Term><Literal>NEWS</Literal></Term>
139 release notes for the bundle—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.
143 </ListItem></VarListEntry>
145 <Term><Literal>bin/<replaceable>platform</replaceable></Literal></Term>
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.
152 </ListItem></VarListEntry>
154 <Term><Literal>lib/<replaceable>platform</replaceable>/</Literal></Term>
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.
165 These sub-directories have the following general structure:
172 <Term><Literal>libHSstd.a</Literal> etc:</Term>
175 supporting library archives.
177 </ListItem></VarListEntry>
179 <Term><Literal>ghc-iface.prl</Literal> etc:</Term>
184 </ListItem></VarListEntry>
186 <Term><Literal>import/</Literal></Term>
189 <IndexTerm><Primary>Interface files</Primary></IndexTerm> (<Literal>.hi</Literal>) for the prelude.
191 </ListItem></VarListEntry>
193 <Term><Literal>include/</Literal></Term>
196 A few C <Literal>#include</Literal> files.
198 </ListItem></VarListEntry>
201 </ListItem></VarListEntry>
203 <Term><Literal>share/</Literal></Term>
206 contains platform-independent support files
207 for the installation. Again, there is a sub-directory for each
208 <Literal>fptools</Literal> project.
210 </ListItem></VarListEntry>
212 <Term><Literal>html/</Literal></Term>
215 contains HTML documentation files (one
216 sub-directory per project).
218 </ListItem></VarListEntry>
220 <Term><Literal>man/</Literal></Term>
223 contains Unix manual pages.
225 </ListItem></VarListEntry>
229 <Sect3 id="sec-install">
230 <Title>Installing</Title>
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>.
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
255 To install an <Literal>fptools</Literal> package, you'll have to do the following:
264 Edit the <Literal>Makefile</Literal> and check the settings of the following variables:
266 <IndexTerm><Primary>directories, installation</Primary></IndexTerm>
267 <IndexTerm><Primary>installation directories</Primary></IndexTerm>
272 <Term><Literal>platform</Literal></Term>
275 the platform you are going to install for.
277 </ListItem></VarListEntry>
279 <Term><Literal>bindir</Literal></Term>
282 the directory in which to install user-invokable
285 </ListItem></VarListEntry>
287 <Term><Literal>libdir</Literal></Term>
290 the directory in which to install
291 platform-dependent support files.
293 </ListItem></VarListEntry>
295 <Term><Literal>datadir</Literal></Term>
298 the directory in which to install
299 platform-independent support files.
301 </ListItem></VarListEntry>
303 <Term><Literal>infodir</Literal></Term>
306 the directory in which to install Emacs info
309 </ListItem></VarListEntry>
311 <Term><Literal>htmldir</Literal></Term>
314 the directory in which to install HTML
317 </ListItem></VarListEntry>
319 <Term><Literal>dvidir</Literal></Term>
322 the directory in which to install DVI
325 </ListItem></VarListEntry>
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.
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>
345 Run <Literal>make install</Literal>. This <Emphasis>
346 should</Emphasis> work with ordinary Unix
347 <Literal>make</Literal>—no need for fancy stuff like GNU
348 <Literal>make</Literal>.
355 <Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
356 stuff in your bin directory.
363 Once done, test your “installation” 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.
367 If things don't work as expected, check the list of known pitfalls in
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 “wins”, and “<Literal>ghc</Literal>” 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>.
391 <Title>What bundles there are</Title>
394 <IndexTerm><Primary>bundles, binary</Primary></IndexTerm> There are
395 plenty of “non-basic” GHC bundles. The files for them are
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:
406 <Term><Literal>prof</Literal>:</Term>
409 Profiling with cost-centres. You probably want this.
410 <IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
411 <IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
413 </ListItem></VarListEntry>
415 <Term><Literal>par</Literal>:</Term>
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>
423 </ListItem></VarListEntry>
425 <Term><Literal>gran</Literal>:</Term>
428 The “GranSim” parallel-Haskell simulator
429 (hmm… mainly for implementors).
430 <IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
431 <IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
433 </ListItem></VarListEntry>
435 <Term><Literal>ticky</Literal>:</Term>
438 “Ticky-ticky” profiling; very detailed
439 information about “what happened when I ran this program”—really
441 <IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
442 <IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
444 </ListItem></VarListEntry>
449 One likely scenario is that you will grab <Emphasis>two</Emphasis>
450 binary bundles—basic, and profiling. We don't usually make the
451 rest, although you can build them yourself from a source distribution.
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>
462 <Sect3 id="sec-GHC-test">
463 <Title>Testing that GHC seems to be working
467 <IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
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>):
478 main = putStr "Hello, world!\n"
484 Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
485 libraries, etc., are being found properly:
488 % ghc -v -o hello Main.hs</Screen>
497 Hello, world!</Screen>
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 -> 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.
509 <para>For more information on how to “drive” GHC, read
519 <Sect1 id="sec-install-windows"><Title>Installing on Windows</Title>
522 Getting the Glasgow Haskell Compiler (GHC) to run on Windows platforms can
523 be a bit of a trying experience. It should be much easier now than in the
524 past, since all the software required to build and use GHC is included in
529 An installation of GHC requires about 70M of disk space (which can be
530 reduced by choosing a “compact” installation).
531 To run GHC comfortably, your machine should have at least
536 <Sect2><Title>Installing GHC</Title>
539 Download the latest GHC distribution (ghc-4.08 InstallShield installer, 19M)
541 URL="http://www.haskell.org/ghc/download.html">http://www.haskell.org/ghc/download.html</ULink>
542 It is packaged up using an installer that should be familiar-looking to
547 Note: The Cygwin support for long file names containing
548 spaces is not 100%, so make sure that you install ghc in a directory
549 that has no embedded spaces (i.e., resist the temptation to put it
550 in <Filename>/Program Files/</Filename>!)
554 When the installer has completed, make sure you add the location of the
555 ghc <Filename>bin/</Filename> directory to your path (e.g.
556 <Filename>/ghc/ghc-4.08/bin </Filename>).
557 You need to do this in order to bring the various GHC binaries into scope.
558 Also, if the directory <Filename>C:/TEMP</Filename> doesn't already exist,
559 you should create it.
563 To test the fruits of your labour, try now to compile a simple
569 module Main(main) where
571 main = putStrLn "Hello, world!"
572 bash$ ghc -o main main.hs
579 OK, assuming that worked, you're all set. Go forth and write useful
580 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">).
584 Further information on using GHC under Windows can be found in <ULink
585 URL="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbjørn Finne's
586 pages</ULink>. Note: ignore the installation instructions, which are rather
587 out of date; the <Emphasis>Miscellaneous</Emphasis> section at the bottom of
588 the page is of most interest, covering topics beyond the scope of this
595 <Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>
603 I'm having trouble with symlinks.
609 Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
610 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
621 I'm getting “permission denied” messages from <Command>rm</Command> or
622 <Command>mv</Command>.
628 This can have various causes: trying to rename a directory when an Explorer
629 window is open on it tends to fail. Closing the window generally cures the
630 problem, but sometimes its cause is more mysterious, and logging off and back
631 on or rebooting may be the quickest cure.
641 I get errors when trying to build GHC 4.08 with GHC 4.05.
645 <Answer> <Para> This seems to work better if you don't use
646 <Option>-O</Option> in <Constant>GhcHcOpts</Constant>. It's a bug in 4.05,
647 unfortunately. Anyway, better to install 4.08 binaries and use those.
659 <Sect1 id="building-docs">
660 <Title>Building the documentation</Title>
663 We use the DocBook DTD, which is widely used. Most shrink-wrapped
664 distributions seem to be broken in one way or another; thanks to
665 heroic efforts by Sven Panne and Manuel Chakravarty, we now support
666 most of them, plus properly installed versions.
670 Instructions on installing and configuring the DocBook tools follow.
674 <Title>Installing the DocBook tools from RPMs</Title>
676 <Para> If you're using a system that can handle RedHat RPM packages,
677 you can probably use the <ULink
678 URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
679 tools</ULink>, which is the most shrink-wrapped SGML suite that we
680 could find. You need all the RPMs except for psgml (i.e.
681 <Filename>docbook</Filename>, <Filename>jade</Filename>,
682 <Filename>jadetex</Filename>, <Filename>sgmlcommon</Filename> and
683 <Filename>stylesheets</Filename>). Note that most of these RPMs are
684 architecture neutral, so are likely to be found in a
685 <Filename>noarch</Filename> directory. The SuSE RPMs also work; the
686 RedHat ones <Emphasis>don't</Emphasis> in RedHat 6.2 (7.0 and later
687 should be OK), but they are easy to fix: just make a symlink from
688 <Filename>/usr/lib/sgml/stylesheets/nwalsh-modular/lib/dblib.dsl</Filename>
689 to <Filename>/usr/lib/sgml/lib/dblib.dsl</Filename>. </Para>
694 <title>Installing DocBook on FreeBSD</title>
696 <para>On FreeBSD systems, the easiest way to get DocBook up and
697 running is to install it from the ports tree or a pre-compiled
698 package (packages are available from your local FreeBSD mirror
701 <para>To use the ports tree, do this:
703 $ cd /usr/ports/textproc/docproj
706 This installs the FreeBSD documentation project tools, which
707 includes everything needed to format the GHC
708 documentation.</para>
712 <Title>Installing from binaries on Windows</Title>
715 It's a good idea to use Norman Walsh's <ULink
716 URL="http://nwalsh.com/docbook/dsssl/doc/install.html">installation
717 notes</ULink> as a guide. You should get version 3.1 of DocBook, and note
718 that his file <Filename>test.sgm</Filename> won't work, as it needs version
719 3.0. You should unpack Jade into <Filename>\Jade</Filename>, along with the
720 entities, DocBook into <Filename>\docbook</Filename>, and the DocBook
721 stylesheets into <Filename>\docbook\stylesheets</Filename> (so they actually
722 end up in <Filename>\docbook\stylesheets\docbook</Filename>).
729 <Title>Installing the DocBook tools from source</Title>
735 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>
736 subdirectory. (If you get the error:
739 ! LaTeX Error: Unknown option implicit=false' for package hyperref'.
742 your version of <Command>hyperref</Command> is out of date; download it from
743 CTAN (<Filename>macros/latex/contrib/supported/hyperref</Filename>), and
744 make it, ensuring that you have first removed or renamed your old copy. If
745 you start getting file not found errors when making the test for
746 <Command>hyperref</Command>, you can abort at that point and proceed
747 straight to <Command>make install</Command>, or enter them as
748 <Filename>../</Filename><Emphasis>filename</Emphasis>.)
752 Make links from <Filename>virtex</Filename> to <Filename>jadetex</Filename>
753 and <Filename>pdfvirtex</Filename> to <Filename>pdfjadetex</Filename>
754 (otherwise DVI, PostScript and PDF output will not work). Copy
755 <Filename>dsssl/*.{dtd,dsl}</Filename> and <Filename>catalog</Filename> to <Filename>/usr/[local/]lib/sgml</Filename>.
761 <Title>DocBook and the DocBook stylesheets</Title>
765 URL="http://www.oasis-open.org/docbook/sgml/3.1/index.html">DocBook</ULink>
766 and install the contents in <Filename>/usr/[local/]/lib/sgml</Filename>.
770 Get the <ULink URL="http://nwalsh.com/docbook/dsssl/">DocBook
771 stylesheets</ULink> and install in
772 <Filename>/usr/[local/]lib/sgml/stylesheets</Filename> (thereby creating a
773 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>.
778 URL="http://www.oasis-open.org/cover/ISOEnts.zip">ISO
779 entities</ULink> into <Filename>/usr/[local/]lib/sgml</Filename>.
787 <Title>Configuring the DocBook tools</Title>
790 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.
796 <Title>Remaining problems</Title>
799 If you install from source, you'll get a pile of warnings of the form
801 <Screen>DTDDECL catalog entries are not supported</Screen>
803 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>.
813 ;;; Local Variables: ***
815 ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***