1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <chapter id="sec-installing-bin-distrib">
3 <title>Installing GHC</title>
4 <indexterm><primary>binary installations</primary></indexterm>
5 <indexterm><primary>installation, of binaries</primary></indexterm>
8 Installing from binary distributions is easiest, and recommended!
9 (Why binaries? Because GHC is a Haskell compiler written in Haskell,
10 so you've got to bootstrap it somehow. We provide machine-generated
11 C-files-from-Haskell for this purpose, but it's really quite a pain to
12 use them. If you must build GHC from its sources, using a
13 binary-distributed GHC to do so is a sensible way to proceed. For the
14 other <literal>fptools</literal> programs, many are written in
15 Haskell, so binary distributions allow you to install them without
16 having a Haskell compiler.)
19 <para>This guide is in several parts:</para>
23 <para> Installing on Unix-a-likes (<xref
24 linkend="sec-unix-a-likes"/>). </para>
27 <para> Installing on Windows (<xref
28 linkend="sec-install-windows"/>). </para>
31 <para> The layout of installed files (<xref
32 linkend="sec-install-files"/>). You don't need to know this to
33 install GHC, but it's useful if you are changing the
34 implementation.</para>
38 <sect1 id="sec-unix-a-likes"><title>Installing on Unix-a-likes</title>
41 <title>When a platform-specific package is available</title>
43 <para>For certain platforms, we provide GHC binaries packaged
44 using the native package format for the platform. This is
45 likely to be by far the best way to install GHC for your
46 platform if one of these packages is available, since
47 dependencies will automatically be handled and the package
48 system normally provides a way to uninstall the package at a
51 <para>We generally provide the following packages:</para>
55 <term>RedHat or SuSE Linux/x86</term>
57 <para>RPM source & binary packages for RedHat and SuSE
58 Linux (x86 only) are available for most major
64 <term>Debian Linux/x86</term>
66 <para>Debian packages for Linux (x86 only), also for most
67 major releases.</para>
72 <term>FreeBSD/x86</term>
74 <para>On FreeBSD/x86, GHC can be installed using either
75 the ports tree (<literal>cd /usr/ports/lang/ghc && make
76 install</literal>) or from a pre-compiled package
77 available from your local FreeBSD mirror.</para>
82 <para>Other platform-specific packages may be available, check
83 the GHC download page for details.</para>
87 <title>GHC binary distributions</title>
90 <indexterm><primary>bundles of binary stuff</primary></indexterm>
94 Binary distributions come in “bundles,” one bundle per file called
95 <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:
101 % cd /your/scratch/space
102 % gunzip < ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -</screen>
107 Then you should find a single directory,
108 <literal>ghc-<replaceable>version</replaceable></literal>, with the
113 <indexterm><primary>binary distribution, layout</primary></indexterm>
114 <indexterm><primary>directory layout (binary distributions)</primary></indexterm>
118 <term><literal>Makefile.in</literal></term>
121 the raw material from which the <literal>Makefile</literal>
122 will be made (<xref linkend="sec-install"/>).
124 </listitem></varlistentry>
126 <term><literal>configure</literal></term>
129 the configuration script (<xref linkend="sec-install"/>).
131 </listitem></varlistentry>
133 <term><literal>README</literal></term>
136 Contains this file summary.
138 </listitem></varlistentry>
140 <term><literal>INSTALL</literal></term>
143 Contains this description of how to install
146 </listitem></varlistentry>
148 <term><literal>ANNOUNCE</literal></term>
151 The announcement message for the bundle.
153 </listitem></varlistentry>
155 <term><literal>NEWS</literal></term>
158 release notes for the bundle—a longer version
159 of <literal>ANNOUNCE</literal>. For GHC, the release notes are contained in the User
160 Guide and this file isn't present.
162 </listitem></varlistentry>
164 <term><literal>bin/<replaceable>platform</replaceable></literal></term>
167 contains platform-specific executable
168 files to be invoked directly by the user. These are the files that
169 must end up in your path.
171 </listitem></varlistentry>
173 <term><literal>lib/<replaceable>platform</replaceable>/</literal></term>
176 contains platform-specific support
177 files for the installation. Typically there is a subdirectory for
178 each <literal>fptools</literal> project, whose name is the name of the project with its
179 version number. For example, for GHC there would be a sub-directory
180 <literal>ghc-x.xx</literal>/ where <literal>x.xx</literal> is the version number of GHC in the bundle.
184 These sub-directories have the following general structure:
191 <term><literal>libHSstd.a</literal> etc:</term>
194 supporting library archives.
196 </listitem></varlistentry>
198 <term><literal>ghc-iface.prl</literal> etc:</term>
203 </listitem></varlistentry>
205 <term><literal>import/</literal></term>
208 <indexterm><primary>Interface files</primary></indexterm> (<literal>.hi</literal>) for the prelude.
210 </listitem></varlistentry>
212 <term><literal>include/</literal></term>
215 A few C <literal>#include</literal> files.
217 </listitem></varlistentry>
220 </listitem></varlistentry>
222 <term><literal>share/</literal></term>
225 contains platform-independent support files
226 for the installation. Again, there is a sub-directory for each
227 <literal>fptools</literal> project.
229 </listitem></varlistentry>
231 <term><literal>html/</literal></term>
234 contains HTML documentation files (one
235 sub-directory per project).
237 </listitem></varlistentry>
241 <sect3 id="sec-install">
242 <title>Installing</title>
245 OK, so let's assume that you have unpacked your chosen bundles. What
246 next? Well, you will at least need to run the
247 <literal>configure</literal><indexterm><primary>configure</primary></indexterm>
248 script by changing directory into the top-level directory for the
249 bundle and typing <literal>./configure</literal>. That should convert
250 <literal>Makefile.in</literal> to <literal>Makefile</literal>.
254 <indexterm><primary>installing in-place</primary></indexterm>
255 <indexterm><primary>in-place installation</primary></indexterm>
256 You can now either start using the tools <emphasis>in-situ</emphasis> without going
257 through any installation process, just type <literal>make in-place</literal> to set the
258 tools up for this. You'll also want to add the path which <literal>make</literal> will
259 now echo to your <literal>PATH</literal> environment variable. This option is useful if
260 you simply want to try out the package and/or you don't have the
261 necessary privileges (or inclination) to properly install the tools
262 locally. Note that if you do decide to install the package `properly'
263 at a later date, you have to go through the installation steps that
268 To install a package, you'll have to do the following:
277 Edit the <literal>Makefile</literal> and check the settings of the following variables:
279 <indexterm><primary>directories, installation</primary></indexterm>
280 <indexterm><primary>installation directories</primary></indexterm>
285 <term><literal>platform</literal></term>
288 the platform you are going to install for.
290 </listitem></varlistentry>
292 <term><literal>bindir</literal></term>
295 the directory in which to install user-invokable
298 </listitem></varlistentry>
300 <term><literal>libdir</literal></term>
303 the directory in which to install
304 platform-dependent support files.
306 </listitem></varlistentry>
308 <term><literal>datadir</literal></term>
311 the directory in which to install
312 platform-independent support files.
314 </listitem></varlistentry>
316 <term><literal>infodir</literal></term>
319 the directory in which to install Emacs info
322 </listitem></varlistentry>
324 <term><literal>htmldir</literal></term>
327 the directory in which to install HTML
330 </listitem></varlistentry>
332 <term><literal>dvidir</literal></term>
335 the directory in which to install DVI
338 </listitem></varlistentry>
341 The values for these variables can be set through invocation of the
342 <command>configure</command><indexterm><primary>configure</primary></indexterm>
343 script that comes with the distribution, but doing an optical diff to
344 see if the values match your expectations is always a Good Idea.
348 <emphasis>Instead of running <command>configure</command>, it is
349 perfectly OK to copy <filename>Makefile.in</filename> to
350 <filename>Makefile</filename> and set all these variables directly
351 yourself. But do it right!</emphasis>
358 Run <literal>make install</literal>. This <emphasis>
359 should</emphasis> work with ordinary Unix
360 <literal>make</literal>—no need for fancy stuff like GNU
361 <literal>make</literal>.
368 <literal>rehash</literal> (t?csh or zsh users), so your shell will see the new
369 stuff in your bin directory.
376 Once done, test your “installation” as suggested in
377 <xref linkend="sec-GHC-test"/>. Be sure to use a <literal>-v</literal>
378 option, so you can see exactly what pathnames it's using.
380 If things don't work as expected, check the list of known pitfalls in
390 <indexterm><primary>link, installed as ghc</primary></indexterm>
391 When installing the user-invokable binaries, this installation
392 procedure will install GHC as <literal>ghc-x.xx</literal> where <literal>x.xx</literal> is the version
393 number of GHC. It will also make a link (in the binary installation
394 directory) from <literal>ghc</literal> to <literal>ghc-x.xx</literal>. If you install multiple versions
395 of GHC then the last one “wins”, and “<literal>ghc</literal>” will invoke the last
396 one installed. You can change this manually if you want. But
397 regardless, <literal>ghc-x.xx</literal> should always invoke GHC version <literal>x.xx</literal>.
404 <title>What bundles there are</title>
407 <indexterm><primary>bundles, binary</primary></indexterm> There are
408 plenty of “non-basic” GHC bundles. The files for them are
410 <literal>ghc-x.xx-<replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</literal>,
411 where the <replaceable>platform</replaceable> is as above, and
412 <replaceable>bundle</replaceable> is one of these:
419 <term><literal>prof</literal>:</term>
422 Profiling with cost-centres. You probably want this.
423 <indexterm><primary>profiling bundles</primary></indexterm>
424 <indexterm><primary>bundles, profiling</primary></indexterm>
426 </listitem></varlistentry>
428 <term><literal>par</literal>:</term>
431 Parallel Haskell features (sits on top of PVM).
432 You'll want this if you're into that kind of thing.
433 <indexterm><primary>parallel bundles</primary></indexterm>
434 <indexterm><primary>bundles, parallel</primary></indexterm>
436 </listitem></varlistentry>
438 <term><literal>gran</literal>:</term>
441 The “GranSim” parallel-Haskell simulator
442 (hmm… mainly for implementors).
443 <indexterm><primary>bundles, gransim</primary></indexterm>
444 <indexterm><primary>gransim bundles</primary></indexterm>
446 </listitem></varlistentry>
448 <term><literal>ticky</literal>:</term>
451 “Ticky-ticky” profiling; very detailed
452 information about “what happened when I ran this program”—really
454 <indexterm><primary>bundles, ticky-ticky</primary></indexterm>
455 <indexterm><primary>ticky-ticky bundles</primary></indexterm>
457 </listitem></varlistentry>
462 One likely scenario is that you will grab <emphasis>two</emphasis>
463 binary bundles—basic, and profiling. We don't usually make the
464 rest, although you can build them yourself from a source distribution.
467 <para>The various GHC bundles are designed to be unpacked into the
468 same directory; then installing as per the directions above will
469 install the whole lot in one go. Note: you <emphasis>must</emphasis>
470 at least have the basic GHC binary distribution bundle, these extra
471 bundles won't install on their own.</para>
475 <sect3 id="sec-GHC-test">
476 <title>Testing that GHC seems to be working
480 <indexterm><primary>testing a new GHC</primary></indexterm>
484 The way to do this is, of course, to compile and run <emphasis>this</emphasis> program
485 (in a file <literal>Main.hs</literal>):
491 main = putStr "Hello, world!\n"
497 Compile the program, using the <literal>-v</literal> (verbose) flag to verify that
498 libraries, etc., are being found properly:
501 % ghc -v -o hello Main.hs</screen>
510 Hello, world!</screen>
515 Some simple-but-profitable tests are to compile and run the notorious
516 <literal>nfib</literal><indexterm><primary>nfib</primary></indexterm> program, using different numeric types. Start with
517 <literal>nfib :: Int -> Int</literal>, and then try <literal>Integer</literal>, <literal>Float</literal>, <literal>Double</literal>,
518 <literal>Rational</literal> and perhaps the overloaded version. Code for this is
519 distributed in <literal>ghc/misc/examples/nfib/</literal> in a source distribution.
522 <para>For more information on how to “drive” GHC, read
532 <sect1 id="sec-install-windows"><title>Installing on Windows</title>
535 Getting the Glasgow Haskell Compiler (post 5.02) to run on Windows platforms is
536 a snap: the Installshield does everything you need.
539 <sect2><title>Installing GHC on Windows</title>
542 To install GHC, use the following steps:
545 <listitem><para>Download the Installshield <filename>setup.exe</filename>
546 from the GHC download page
548 url="http://www.haskell.org/ghc">haskell.org</ulink>.
551 <listitem><para>Run <filename>setup.exe</filename>.
552 On Windows, all of GHC's files are installed in a single directory.
553 If you choose ``Custom'' from the list of install options, you will be given a
554 choice about where this directory is; otherwise it will be installed
555 in <filename>c:/ghc/<replaceable>ghc-version</replaceable></filename>.
556 The executable binary for GHC will be installed in the <filename>bin/</filename> sub-directory
557 of the installation directory you choose.
559 <para>(If you have already installed the same version of GHC, Installshield will offer to "modify",
560 or "remove" GHC. Choose "remove"; then run <filename>setup.exe</filename> a
561 second time. This time it should offer to install.)
564 When installation is complete, you should find GHCi and the GHC documentation are
565 available in your Start menu under "Start/Programs/Glasgow Haskell Compiler".
570 The final dialogue box from the install process reminds you where the GHC binary
571 has been installed (usually <filename>c:/ghc/<replaceable>ghc-version</replaceable>/bin/</filename>.
572 If you want to invoke GHC from a command line, add this
573 to your PATH environment variable.
577 GHC needs a directory in which to create, and later delete, temporary files.
578 It uses the standard Windows procedure <literal>GetTempPath()</literal> to
579 find a suitable directory. This procedure returns:
581 <listitem><para>The path in environment variable TMP,
582 if TMP is set.</para></listitem>
583 <listitem><para>Otherwise, the path in environment variable TEMP,
584 if TEMP is set.</para></listitem>
585 <listitem><para>Otherwise, there is a per-user default which varies
586 between versions of Windows. On NT and XP-ish versions, it might
588 <filename>c:\Documents and Settings\<username>\Local Settings\Temp</filename>
591 The main point is that if you don't do anything GHC will work fine;
592 but if you want to control where the directory is, you can do so by
598 To test the fruits of your labour, try now to compile a simple
604 module Main(main) where
606 main = putStrLn "Hello, world!"
607 bash$ ghc -o main main.hs
616 You do <emphasis>not</emphasis> need the Cygwin toolchain, or anything
617 else, to install and run GHC.
620 An installation of GHC requires about 140M of disk space.
621 To run GHC comfortably, your machine should have at least
626 <sect2><title>Moving GHC around</title>
628 At the moment, GHC installs in a fixed place (<filename>c:/ghc/ghc-x.yy</filename>,
629 but once it is installed, you can freely move the entire GHC tree just by copying
630 the <filename>ghc-x.yy</filename> directory. (You may need to fix up
631 the links in "Start/Programs/Glasgow Haskell Compiler" if you do this.)
634 It is OK to put GHC tree in a directory whose path involves spaces. However,
635 don't do this if you use want to use GHC with the Cygwin tools,
636 because Cygwin can get confused when this happpens.
637 We havn't quite got to the bottom of this, but so far as we know it's not
638 a problem with GHC itself. Nevertheless, just to keep life simple we usually
639 put GHC in a place with a space-free path.
644 <title>Installing ghc-win32 FAQ</title>
652 I'm having trouble with symlinks.
658 Symlinks only work under Cygwin (<xref linkend="sec-install"/>), so binaries
659 not linked to the Cygwin DLL, in particular those built for Mingwin, will not
670 I'm getting “permission denied” messages from the <command>rm</command> or
671 <command>mv</command>.
677 This can have various causes: trying to rename a directory when an Explorer
678 window is open on it tends to fail. Closing the window generally cures the
679 problem, but sometimes its cause is more mysterious, and logging off and back
680 on or rebooting may be the quickest cure.
688 <!-- doesn't add much value any longer; leave out [sof 7/2002].
690 Further information on using GHC under Windows can be found in <ulink
691 url="http://www.dcs.gla.ac.uk/~sof/ghc-win32.html">Sigbjørn Finne's
692 pages</ulink>. Note: ignore the installation instructions, which are rather
693 out of date; the <emphasis>Miscellaneous</emphasis> section at the bottom of
694 the page is of most interest, covering topics beyond the scope of this
703 <sect1 id="sec-install-files"><title>The layout of installed files</title>
706 This section describes what files get installed where. You don't need to know it
707 if you are simply installing GHC, but it is vital information if you are changing
710 <para> GHC is installed in two directory trees:</para>
713 <term>Library directory,</term>
714 <listitem> <para> known as <filename>$(libdir)</filename>, holds all the
715 support files needed to run GHC. On Unix, this
716 directory is usually something like <filename>/usr/lib/ghc/ghc-5.02</filename>. </para>
720 <term>Binary directory</term>
721 <listitem> <para> known as <filename>$(bindir)</filename>, holds executables that
722 the user is expected to invoke.
724 <filename>ghc</filename> and <filename>ghci</filename>. On Unix, this directory
725 can be anywhere, but is typically something like <filename>/usr/local/bin</filename>. On Windows,
726 however, this directory <emphasis>must be</emphasis> <filename>$(libdir)/bin</filename>.
733 When GHC runs, it must know where its library directory is.
734 It finds this out in one of two ways:
739 <filename>$(libdir)</filename> is passed to GHC using the <option>-B</option> flag.
740 On Unix (but not Windows), the installed <filename>ghc</filename> is just a one-line
741 shell script that invokes the real GHC, passing a suitable <option>-B</option> flag.
742 [All the user-supplied flags
743 follow, and a later <option>-B</option> flag overrides an earlier one, so a user-supplied
748 <para> On Windows (but not Unix), if no <option>-B</option> flag is given, GHC uses a system
749 call to find the directory in which the running GHC executable lives, and derives
750 <filename>$(libdir)</filename> from that. [Unix lacks such a system call.]
751 That is why <filename>$(bindir)</filename> must be <filename>$(libdir)/bin</filename>.
756 <sect2> <title>The binary directory</title>
758 <para>The binary directory, <filename>$(bindir)</filename> contains user-visible
759 executables, notably <filename>ghc</filename> and <filename>ghci</filename>.
760 You should add it to your <literal>$PATH</literal>
763 <para>On Unix, the user-invokable <filename>ghc</filename> invokes <filename>$(libdir)/ghc-<replaceable>version</replaceable></filename>,
764 passing a suitable <option>-B</option> flag to tell <filename>ghc-<replaceable>version</replaceable></filename> where
765 <filename>$(libdir)</filename> is.
766 Similarly <filename>ghci</filename>, except the extra flag <literal>--interactive</literal> is passed.
769 <para>On Win32, the user-invokable <filename>ghc</filename> binary
770 is the Real Thing (no intervening
771 shell scripts or <filename>.bat</filename> files).
772 Reason: we sometimes invoke GHC with very long command lines,
773 and <filename>cmd.exe</filename> (which executes <filename>.bat</filename> files)
774 truncates them. Similarly <filename>ghci</filename> is a C wrapper program that invokes <filename>ghc --interactive</filename>
775 (passing on all other arguments), not a <filename>.bat</filename> file.
781 <sect2> <title>The library directory</title>
783 <para>The layout of the library directory, <filename>$(libdir)</filename> is almost identical on
784 Windows and Unix, as follows. Differences between Windows and Unix
785 are noted thus <literal>[Win32 only]</literal> and are commented below.</para>
789 package.conf GHC package configuration
790 ghc-usage.txt Message displayed by ghc ––help
792 bin/ [Win32 only] User-visible binaries
796 unlit Remove literate markup
798 touchy.exe [Win32 only]
799 perl.exe [Win32 only]
802 ghc-x.xx GHC executable [Unix only]
804 ghc-split Asm code splitter
805 ghc-asm Asm code mangler
807 gcc-lib/ [Win32 only] Support files for gcc
808 specs gcc configuration
810 cpp0.exe gcc support binaries
817 libmingw32.a Standard
822 imports/ GHC interface files
823 std/*.hi 'std' library
824 lang/*.hi 'lang' library
827 include/ C header files
828 StgMacros.h GHC-specific
829 ..etc... header files
831 mingw/*.h [Win32 only] Mingwin header files
833 libHSrts.a GHC library archives
838 HSstd1.o GHC library linkables
839 HSstd2.o (used by ghci, which does
840 HSlang.o not grok .a files yet)
847 <para><filename>$(libdir)</filename> also contains support
848 binaries. These are <emphasis>not</emphasis> expected to be
849 on the user's <filename>PATH</filename>, but and are invoked
850 directly by GHC. In the Makefile system, this directory is
851 also called <filename>$(libexecdir)</filename>, but
852 <emphasis>you are not free to change it</emphasis>. It must
853 be the same as <filename>$(libdir)</filename>.</para>
857 <para>We distribute <filename>gcc</filename> with the Win32 distribution of GHC, so that users
858 don't need to install <filename>gcc</filename>, nor need to care about which version it is.
859 All <filename>gcc</filename>'s support files are kept in <filename>$(libdir)/gcc-lib/</filename>.
864 <para>Similarly, we distribute <filename>perl</filename> and a <filename>touch</filename>
865 replacement (<filename>touchy.exe</filename>)
866 with the Win32 distribution of GHC. </para>
870 <para>The support programs <filename>ghc-split</filename>
871 and <filename>ghc-asm</filename> are Perl scripts. The
872 first line says <literal>#!/bin/perl</literal>; on Unix, the
873 script is indeed invoked as a shell script, which invokes
874 Perl; on Windows, GHC invokes
875 <filename>$(libdir)/perl.exe</filename> directly, which
876 treats the <literal>#!/bin/perl</literal> as a comment.
877 Reason: on Windows we want to invoke the Perl distributed
878 with GHC, rather than assume some installed one. </para>
890 ;;; Local Variables: ***
892 ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter") ***