<Chapter id="sec-installing-bin-distrib">
  <Title>Installing GHC</Title>
<IndexTerm><Primary>binary installations</Primary></IndexTerm>
<IndexTerm><Primary>installation, of binaries</Primary></IndexTerm>

<Para>
Installing from binary distributions is easiest, and recommended!
(Why binaries? Because GHC is a Haskell compiler written in Haskell,
so you've got to bootstrap it somehow.  We provide machine-generated
C-files-from-Haskell for this purpose, but it's really quite a pain to
use them.  If you must build GHC from its sources, using a
binary-distributed GHC to do so is a sensible way to proceed. For the
other <Literal>fptools</Literal> programs, many are written in
Haskell, so binary distributions allow you to install them without
having a Haskell compiler.)
</Para>

<Para>This guide is in several parts:</para>

  <itemizedlist>
    <listitem>
      <para> Installing on Unix-a-likes (<Xref
      LinkEnd="sec-unix-a-likes">). </para>
    </listitem>
    <listitem>
      <para> Installing on Windows (<Xref
      LinkEnd="sec-install-windows">).  </para>
    </listitem>
    <listitem>
      <para> The layout of installed files (<Xref
      LinkEnd="sec-install-files">).  You don't need to know this to
      install GHC, but it's useful if you are changing the
      implementation.</para>
    </listitem>
  </itemizedlist>
  
  <Sect1 id="sec-unix-a-likes"><Title>Installing on Unix-a-likes</Title>

    <sect2>
      <title>When a platform-specific package is available</title>
      
      <para>For certain platforms, we provide GHC binaries packaged
      using the native package format for the platform.  This is
      likely to be by far the best way to install GHC for your
      platform if one of these packages is available, since
      dependencies will automatically be handled and the package
      system normally provides a way to uninstall the package at a
      later date.</para>

      <para>We generally provide the following packages:</para>

      <variablelist>
	<varlistentry>
	  <term>RedHat or SuSE Linux/x86</term>
	  <listitem>
	    <para>RPM source & binary packages for RedHat and SuSE
	    Linux (x86 only) are available for most major
	    releases.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term>Debian Linux/x86</term>
	  <listitem>
	    <para>Debian packages for Linux (x86 only), also for most
	    major releases.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term>FreeBSD/x86</term>
	  <listitem>
	    <para>On FreeBSD/x86, GHC can be installed using either
	    the ports tree (<literal>cd /usr/ports/lang/ghc && make
	    install</literal>) or from a pre-compiled package
	    available from your local FreeBSD mirror.</para>
	  </listitem>
	</varlistentry>
      </variablelist>
      
      <para>Other platform-specific packages may be available, check
      the GHC download page for details.</para>
    </sect2>

<Sect2>
<Title>GHC binary distributions</Title>

<Para>
<IndexTerm><Primary>bundles of binary stuff</Primary></IndexTerm>
</Para>

<Para>
Binary distributions come in &ldquo;bundles,&rdquo; one bundle per file called
<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:
</Para>

<Para>

<Screen>
% cd /your/scratch/space
% gunzip &#60; ghc-x.xx-sun-sparc-solaris2.tar.gz | tar xvf -</Screen>

</Para>

<Para>
Then you should find a single directory,
<Literal>ghc-<replaceable>version</replaceable></Literal>, with the
following structure:
</Para>

<Para>
<IndexTerm><Primary>binary distribution, layout</Primary></IndexTerm>
<IndexTerm><Primary>directory layout (binary distributions)</Primary></IndexTerm>
<VariableList>

<VarListEntry>
<Term><Literal>Makefile.in</Literal></Term>
<ListItem>
<Para>
the raw material from which the <Literal>Makefile</Literal>
will be made (<Xref LinkEnd="sec-install">).
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>configure</Literal></Term>
<ListItem>
<Para>
the configuration script (<Xref LinkEnd="sec-install">).
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>README</Literal></Term>
<ListItem>
<Para>
Contains this file summary.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>INSTALL</Literal></Term>
<ListItem>
<Para>
Contains this description of how to install
the bundle.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>ANNOUNCE</Literal></Term>
<ListItem>
<Para>
The announcement message for the bundle.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>NEWS</Literal></Term>
<ListItem>
<Para>
release notes for the bundle&mdash;a longer version
of <Literal>ANNOUNCE</Literal>.  For GHC, the release notes are contained in the User
Guide and this file isn't present.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
	    <Term><Literal>bin/<replaceable>platform</replaceable></Literal></Term>
<ListItem>
<Para>
contains platform-specific executable
files to be invoked directly by the user.  These are the files that
must end up in your path.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>lib/<replaceable>platform</replaceable>/</Literal></Term>
<ListItem>
<Para>
contains platform-specific support
files for the installation.  Typically there is a subdirectory for
each <Literal>fptools</Literal> project, whose name is the name of the project with its
version number.  For example, for GHC there would be a sub-directory
<Literal>ghc-x.xx</Literal>/ where <Literal>x.xx</Literal> is the version number of GHC in the bundle.
</Para>

<Para>
These sub-directories have the following general structure:
</Para>

<Para>
<VariableList>

<VarListEntry>
<Term><Literal>libHSstd.a</Literal> etc:</Term>
<ListItem>
<Para>
supporting library archives.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>ghc-iface.prl</Literal> etc:</Term>
<ListItem>
<Para>
support scripts.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>import/</Literal></Term>
<ListItem>
<Para>
<IndexTerm><Primary>Interface files</Primary></IndexTerm> (<Literal>.hi</Literal>) for the prelude.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>include/</Literal></Term>
<ListItem>
<Para>
A few C <Literal>&num;include</Literal> files.
</Para>
</ListItem></VarListEntry>
</VariableList>
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>share/</Literal></Term>
<ListItem>
<Para>
contains platform-independent support files
for the installation.  Again, there is a sub-directory for each
<Literal>fptools</Literal> project.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>html/</Literal></Term>
<ListItem>
<Para>
contains HTML documentation files (one
sub-directory per project).
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>man/</Literal></Term>
<ListItem>
<Para>
contains Unix manual pages.
</Para>
</ListItem></VarListEntry>
</VariableList>
</Para>

<Sect3 id="sec-install">
<Title>Installing</Title>

<Para>
OK, so let's assume that you have unpacked your chosen bundles into a
scratch directory <Literal>fptools</Literal>. What next? Well, you will at least need
to run the <Literal>configure</Literal><IndexTerm><Primary>configure</Primary></IndexTerm> script by changing your
directory to <Literal>fptools</Literal> and typing <Literal>./configure</Literal>.  That should convert
<Literal>Makefile.in</Literal> to <Literal>Makefile</Literal>.
</Para>

<Para>
<IndexTerm><Primary>installing in-place</Primary></IndexTerm>
<IndexTerm><Primary>in-place installation</Primary></IndexTerm>
You can now either start using the tools <Emphasis>in-situ</Emphasis> without going
through any installation process, just type <Literal>make in-place</Literal> to set the
tools up for this. You'll also want to add the path which <Literal>make</Literal> will
now echo to your <Literal>PATH</Literal> environment variable. This option is useful if
you simply want to try out the package and/or you don't have the
necessary privileges (or inclination) to properly install the tools
locally. Note that if you do decide to install the package `properly'
at a later date, you have to go through the installation steps that
follow.
</Para>

<Para>
To install an <Literal>fptools</Literal> package, you'll have to do the following:
</Para>

<Para>

<OrderedList>
<ListItem>

<Para>
 Edit the <Literal>Makefile</Literal> and check the settings of the following variables:

<IndexTerm><Primary>directories, installation</Primary></IndexTerm>
<IndexTerm><Primary>installation directories</Primary></IndexTerm>

<VariableList>

<VarListEntry>
<Term><Literal>platform</Literal></Term>
<ListItem>
<Para>
the platform you are going to install for.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>bindir</Literal></Term>
<ListItem>
<Para>
the directory in which to install user-invokable
binaries.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>libdir</Literal></Term>
<ListItem>
<Para>
the directory in which to install
platform-dependent support files.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>datadir</Literal></Term>
<ListItem>
<Para>
the directory in which to install
platform-independent support files.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>infodir</Literal></Term>
<ListItem>
<Para>
the directory in which to install Emacs info
files.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>htmldir</Literal></Term>
<ListItem>
<Para>
the directory in which to install HTML
documentation.
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>dvidir</Literal></Term>
<ListItem>
<Para>
the directory in which to install DVI
documentation.
</Para>
</ListItem></VarListEntry>
</VariableList>

The values for these variables can be set through invocation of the
<Command>configure</Command><IndexTerm><Primary>configure</Primary></IndexTerm>
script that comes with the distribution, but doing an optical diff to
see if the values match your expectations is always a Good Idea.
</para>

<para>
<Emphasis>Instead of running <Command>configure</Command>, it is
perfectly OK to copy <Filename>Makefile.in</Filename> to
<Filename>Makefile</Filename> and set all these variables directly
yourself.  But do it right!</Emphasis>
</Para>

</ListItem>
<ListItem>

<Para>
Run <Literal>make install</Literal>.  This <Emphasis>
should</Emphasis> work with ordinary Unix
<Literal>make</Literal>&mdash;no need for fancy stuff like GNU
<Literal>make</Literal>.

</Para>
</ListItem>
<ListItem>

<Para>
<Literal>rehash</Literal> (t?csh or zsh users), so your shell will see the new
stuff in your bin directory.

</Para>
</ListItem>
<ListItem>

<Para>
 Once done, test your &ldquo;installation&rdquo; as suggested in 
<XRef LinkEnd="sec-GHC-test">.  Be sure to use a <Literal>-v</Literal>
option, so you can see exactly what pathnames it's using.

If things don't work as expected, check the list of known pitfalls in
the building guide.
</Para>
</ListItem>

</OrderedList>

</Para>

<Para>
<IndexTerm><Primary>link, installed as ghc</Primary></IndexTerm>
When installing the user-invokable binaries, this installation
procedure will install GHC as <Literal>ghc-x.xx</Literal> where <Literal>x.xx</Literal> is the version
number of GHC.  It will also make a link (in the binary installation
directory) from <Literal>ghc</Literal> to <Literal>ghc-x.xx</Literal>.  If you install multiple versions
of GHC then the last one &ldquo;wins&rdquo;, and &ldquo;<Literal>ghc</Literal>&rdquo; will invoke the last
one installed.  You can change this manually if you want.  But
regardless, <Literal>ghc-x.xx</Literal> should always invoke GHC version <Literal>x.xx</Literal>.
</Para>

</Sect3>


<Sect3>
<Title>What bundles there are</Title>

<Para>
<IndexTerm><Primary>bundles, binary</Primary></IndexTerm> There are
plenty of &ldquo;non-basic&rdquo; GHC bundles.  The files for them are
called
<Literal>ghc-x.xx-<replaceable>bundle</replaceable>-<replaceable>platform</replaceable>.tar.gz</Literal>,
where the <replaceable>platform</replaceable> is as above, and
<replaceable>bundle</replaceable> is one of these:
</Para>

<Para>
<VariableList>

<VarListEntry>
<Term><Literal>prof</Literal>:</Term>
<ListItem>
<Para>
Profiling with cost-centres.  You probably want this.
<IndexTerm><Primary>profiling bundles</Primary></IndexTerm>
<IndexTerm><Primary>bundles, profiling</Primary></IndexTerm>
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>par</Literal>:</Term>
<ListItem>
<Para>
Parallel Haskell features (sits on top of PVM).
You'll want this if you're into that kind of thing.
<IndexTerm><Primary>parallel bundles</Primary></IndexTerm>
<IndexTerm><Primary>bundles, parallel</Primary></IndexTerm>
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>gran</Literal>:</Term>
<ListItem>
<Para>
The &ldquo;GranSim&rdquo; parallel-Haskell simulator
(hmm&hellip; mainly for implementors).
<IndexTerm><Primary>bundles, gransim</Primary></IndexTerm>
<IndexTerm><Primary>gransim bundles</Primary></IndexTerm>
</Para>
</ListItem></VarListEntry>
<VarListEntry>
<Term><Literal>ticky</Literal>:</Term>
<ListItem>
<Para>
&ldquo;Ticky-ticky&rdquo; profiling; very detailed
information about &ldquo;what happened when I ran this program&rdquo;&mdash;really
for implementors.
<IndexTerm><Primary>bundles, ticky-ticky</Primary></IndexTerm>
<IndexTerm><Primary>ticky-ticky bundles</Primary></IndexTerm>
</Para>
</ListItem></VarListEntry>
</VariableList>
</Para>

<Para>
One likely scenario is that you will grab <Emphasis>two</Emphasis>
binary bundles&mdash;basic, and profiling.  We don't usually make the
rest, although you can build them yourself from a source distribution.
</Para>

<para>The various GHC bundles are designed to be unpacked into the
same directory; then installing as per the directions above will
install the whole lot in one go.  Note: you <emphasis>must</emphasis>
at least have the basic GHC binary distribution bundle, these extra
bundles won't install on their own.</para>

</Sect3>

<Sect3 id="sec-GHC-test">
<Title>Testing that GHC seems to be working
</Title>

<Para>
<IndexTerm><Primary>testing a new GHC</Primary></IndexTerm>
</Para>

<Para>
The way to do this is, of course, to compile and run <Emphasis>this</Emphasis> program
(in a file <Literal>Main.hs</Literal>):
</Para>

<Para>

<ProgramListing>
main = putStr "Hello, world!\n"
</ProgramListing>

</Para>

<Para>
Compile the program, using the <Literal>-v</Literal> (verbose) flag to verify that
libraries, etc., are being found properly:

<Screen>
% ghc -v -o hello Main.hs</Screen>

</Para>

<Para>
Now run it:

<Screen>
% ./hello
Hello, world!</Screen>

</Para>

<Para>
Some simple-but-profitable tests are to compile and run the notorious
<Literal>nfib</Literal><IndexTerm><Primary>nfib</Primary></IndexTerm> program, using different numeric types.  Start with
<Literal>nfib :: Int -&gt; Int</Literal>, and then try <Literal>Integer</Literal>, <Literal>Float</Literal>, <Literal>Double</Literal>,
<Literal>Rational</Literal> and perhaps the overloaded version.  Code for this is
distributed in <Literal>ghc/misc/examples/nfib/</Literal> in a source distribution.
</Para>

<para>For more information on how to &ldquo;drive&rdquo; GHC, read
on...</para>

</Sect3>

</Sect2>

</Sect1>


<Sect1 id="sec-install-windows"><Title>Installing on Windows</Title>

<para>
Getting the Glasgow Haskell Compiler (post 5.02) to run on Windows platforms is
a snap: the Installshield does everything you need.  
</para>

<Sect2><Title>Installing GHC on Windows</Title>

<para>
To install GHC, use the following steps:
</para>
<itemizedlist>
<listitem><para>Download the Installshield <Filename>setup.exe</Filename>
from the GHC download page
<ULink
URL="http://www.haskell.org/ghc">haskell.org</ULink>.
</para></listitem>

<listitem><para>Run <Filename>setup.exe</Filename>.
(If you have a previous version of GHC, Installshield will offer to "modify", 
or "remove" GHC.  Choose "remove"; then run <Filename>setup.exe</Filename> a
second time.  This time it should offer to install.)
</para>
<para>
At this point you should find GHCi and the GHC documentation are 
available in your Start menu under "Start/Programs/Glasgow Haskell Compiler".
</para>
</listitem>

<listitem><para>
The final dialogue box from the install process tells you where GHC has
been installed.  If you want to invoke GHC from a command line, add this 
to your PATH environment variable.  Usually, GHC installs into
<Filename>c:/ghc/ghc-5.02</Filename>, though the last part of this path
depends on which version of GHC you are installing, of course. 
You need to add <Filename>c:/ghc/ghc-5.02/bin</Filename> to your path if yo
</para></listitem>

<listitem><para>
GHC needs a directory in which to create, and later delete, temporary files.
It uses the standard Windows procedure <literal>GetTempPath()</literal> to
find a suitable directory.  This procedure returns:
<itemizedlist>
<listitem><para>The path in environment variable TMP, 
if TMP is set.</para></listitem>
<listitem><para>Otherwise, the path in environment variable TEMP, 
if TEMP is set.</para></listitem>
<listitem><para>Otherwise, there is a per-user default which varies
between versions of Windows. On NT and XP-ish versions, it might 
be:
<Filename>c:\Documents and Settings\&lt;username&gt;\Local Settings\Temp</filename>
</para></listitem>
</itemizedlist>
The main point is that if you don't do anything GHC will work fine;
but if you want to control where the directory is, you can do so by
setting TMP or TEMP.
</para></listitem>

<listitem>
<Para>
To test the fruits of your labour, try now to compile a simple
Haskell program:
</Para>

<Screen>
bash$ cat main.hs
module Main(main) where

main = putStrLn "Hello, world!"
bash$ ghc -o main main.hs
..
bash$ ./main
Hello, world!
bash$ </Screen>
</listitem>
</itemizedlist>

<para>
You do <emphasis>not</emphasis> need the Cygwin toolchain, or anything
else, to install and run GHC.
</para>
<Para>
An installation of GHC requires about 140M of disk space.
To run GHC comfortably, your machine should have at least
64M of memory.
</Para>
</sect2>

<Sect2><title>Moving GHC around</title>
<Para>
At the moment, GHC installs in a fixed place (<Filename>c:/ghc/ghc-x.yy</Filename>,
but once it is installed, you can freely move the entire GHC tree just by copying
the <Filename>ghc-x.yy</Filename> directory.   (You may need to fix up 
the links in "Start/Programs/Glasgow Haskell Compiler" if you do this.)
</para>
<para>
It is OK to put GHC tree in a directory whose path involves spaces.  However,
don't do this if you use want to use GHC with the Cygwin tools, 
because Cygwin can get confused when this happpens.
We havn't quite got to the bottom of this, but so far as we know it's not 
a problem with GHC itself.  Nevertheless, just to keep life simple we usually
put GHC in a place with a space-free path.
</Para>
</sect2>

<Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>

<QandASet>

<QandAEntry>

<Question>
<Para>
I'm having trouble with symlinks.
</Para>
</Question>

<Answer>
<Para>
Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
not linked to the Cygwin DLL, in particular those built for Mingwin, will not
work with symlinks.
</Para>
</Answer>

</QandAEntry>

<QandAEntry>

<Question>
<Para>
I'm getting &ldquo;permission denied&rdquo; messages from the <Command>rm</Command> or
<Command>mv</Command>.
</Para>
</Question>

<Answer>
<Para>
This can have various causes: trying to rename a directory when an Explorer
window is open on it tends to fail. Closing the window generally cures the
problem, but sometimes its cause is more mysterious, and logging off and back
on or rebooting may be the quickest cure.
</Para>
</Answer>

</QandAEntry>

</QandASet>

<!-- doesn't add much value any longer; leave out [sof 7/2002].
<Para>
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>. Note: ignore the installation instructions, which are rather
out of date; the <Emphasis>Miscellaneous</Emphasis> section at the bottom of
the page is of most interest, covering topics beyond the scope of this
manual.
</Para>
-->
</Sect2>

</Sect1>


<Sect1 id="sec-install-files"><Title>The layout of installed files</Title>

<para>
This section describes what files get installed where.  You don't need to know it
if you are simply installing GHC, but it is vital information if you are changing
the implementation.
</para>
<para> GHC is installed in two directory trees:</para>
<variablelist>
<varlistentry>
<term>Binary directory</term>
<listitem> <para> known as <Filename>$(bindir)</Filename>, holds executables that 
the user is expected to invoke.  Notably,
<Filename>ghc</Filename> and <Filename>ghci</FileName>.  On Unix, this directory
is typically something like <Filename>/usr/local/bin</Filename>.  On Windows,
however, this directory is always <Filename>$(libdir)/bin</Filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Library directory,</term>
<listitem> <para> known as <Filename>$(libdir)</Filename>, holds all the 
support files needed to run GHC.  On Unix, this 
directory is usually something like <Filename>/usr/lib/ghc/ghc-5.02</Filename>. </para>
</listitem>
</varlistentry>
</variablelist>

<para>
When GHC runs, it must know where its library directory is.
It finds this out in one of two ways:
</para>
<itemizedlist>
<listitem>
<para>
<Filename>$(libdir)</Filename> is passed to GHC using the <option>-B</option> flag.
On Unix (but not Windows), the installed <filename>ghc</filename> is just a one-line 
shell script that invokes the real GHC, passing a suitable <option>-B</option> flag. 
[All the user-supplied flags
follow, and a later <option>-B</option> flag overrides an earlier one, so a user-supplied
one wins.]
</para>
</listitem>
<listitem>
<para> On Windows (but not Unix), if no <option>-B</option> flag is given, GHC uses a system
call to find the directory in which the running GHC executable lives, and derives 
<Filename>$(libdir)</Filename> from that. [Unix lacks such a system call.]
</para>
</listitem>
</itemizedlist>

<sect2> <title>Layout of the library directory</title>

<para>The layout of the library directory is almost identical on
Windows and Unix, as follows: layout:</para>

<programlisting>
  $(libdir)/
    package.conf           GHC package configuration
    ghc-usage.txt          Message displayed by ghc &ndash;&ndash;help
    
    bin/                   [Win32 only]  User-visible binaries
         ghc.exe
         ghci.bat

    unlit                  Remove literate markup
    
    touchy.exe             [Win32 only]
    perl.exe               [Win32 only]
    gcc.exe                [Win32 only]
   
    ghc-x.xx               GHC executable [Unix only]
   
    ghc-split              Asm code splitter
    ghc-asm	           Asm code mangler

    gcc-lib/               [Win32 only] Support files for gcc
        specs              gcc configuration
 
        cpp0.exe           gcc support binaries
        as.exe
        ld.exe

        crt0.o              Standard
	   ..etc..	    binaries
        
        libmingw32.a        Standard
	   ..etc..	    libraries

        *.h                 Include files

    imports/                GHC interface files
        std/*.hi              'std' library
	lang/*.hi             'lang' library
        ..etc..

    include/                 C header files
        StgMacros.h           GHC-specific
        ..etc...              header files

        mingw/*.h            [Win32 only] Mingwin header files

    libHSrts.a              GHC library archives
    libHSstd.a
    libHSlang.a
      ..etc..

    HSstd1.o                GHC library linkables
    HSstd2.o                  (used by ghci, which does
    HSlang.o                  not grok .a files yet)
</programlisting>

<para>Note that:</para>
<itemizedlist>
<listitem>
<para>On Win32, the <filename>$(libdir)/bin</filename> directory contains user-visible binaries; 
add it to your <filename>PATH</filename>.  The <filename>ghci</filename> executable is a <filename>.bat</filename>
file which invokes <filename>ghc</filename>.   </para>

<para>The GHC executable is the Real Thing (no intervening
shell scripts or <filename>.bat</filename> files).  
Reason: we sometimes invoke GHC with very long command lines,
and <filename>cmd.exe</filename> (which executes <filename>.bat</filename> files)
truncates them.  [We assume people won't invoke ghci with very long
command lines.]</para>

<para>On Unix, the user-invokable <filename>ghc</filename> invokes <filename>$(libdir)/ghc-<replaceable>version</replaceable></filename>,
passing a suitable <option>-B</option> flag. 
</para>
</listitem>

	<listitem>
	  <para><filename>$(libdir)</filename> also contains support
          binaries.  These are <emphasis>not</emphasis> expected to be
          on the user's <filename>PATH</filename>, but and are invoked
          directly by GHC.  In the Makefile system, this directory is
          also called <filename>$(libexecdir)</filename>, but
          <emphasis>you are not free to change it</emphasis>.  It must
          be the same as <filename>$(libdir)</filename>.</para>
	</listitem>

<listitem>
<para>We distribute <filename>gcc</filename> with the Win32 distribution of GHC, so that users
don't need to install <filename>gcc</filename>, nor need to care about which version it is.
All <filename>gcc</filename>'s support files are kept in  <filename>$(libdir)/gcc-lib/</filename>.
</para> 
</listitem>

<listitem>
<para>Similarly, we distribute <filename>perl</filename> and a <filename>touch</filename> 
replacement (<filename>touchy.exe</filename>)
with the Win32 distribution of GHC. </para> 
</listitem>

	<listitem>
	  <para>The support programs <filename>ghc-split</filename>
          and <filename>ghc-asm</filename> are Perl scripts.  The
          first line says <literal>#!/bin/perl</literal>; on Unix, the
          script is indeed invoked as a shell script, which invokes
          Perl; on Windows, GHC invokes
          <filename>$(libdir)/perl.exe</filename> directly, which
          treats the <literal>#!/bin/perl</literal> as a comment.
          Reason: on Windows we want to invoke the Perl distributed
          with GHC, rather than assume some installed one.  </para>
	</listitem>
</itemizedlist>

</sect2>

</sect1>

</Chapter>

<!-- Emacs stuff:
     ;;; Local Variables: ***
     ;;; mode: sgml ***
     ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
     ;;; End: ***
 -->
