After you've unpacked a Cabal package, you can build it
by moving into the root directory of the package and using the
Setup.hs
or Setup.lhs
script there:
runhaskell Setup.hs
[command
] [option
...]
where runhaskell
might be
runhugs
, runghc
or
runnhc
. The command
argument selects a particular step in the build/install process.
You can also get a summary of the command syntax with
runhaskell Setup.hs
--help
Example 5. Building and installing a system package
runhaskell Setup.hs configure --ghc runhaskell Setup.hs build runhaskell Setup.hs install
The first line readies the system to build the tool using GHC; for example, it checks that GHC exists on the system. The second line performs the actual building, while the last both copies the build results to some permanent place and registers the package with GHC.
Example 6. Building and installing a user package
runhaskell Setup.hs configure --ghc --prefix=$HOME runhaskell Setup.hs build runhaskell Setup.hs install --user
In this case, since the package will be registered in the user's package database, we also install it under the user's home directory.
Example 7. Creating a binary package
When creating binary packages (e.g. for RedHat or Debian) one needs to create a tarball that can be sent to another system for unpacking in the root directory:
runhaskell Setup.hs configure --ghc --prefix=/usr runhaskell Setup.hs build runhaskell Setup.hs copy --copy-prefix=/tmp/mypkg/usr (cd /tmp/mypkg; tar cf - .) | gzip -9 >mypkg.tar.gz
If the package contains a library, you need two additional steps:
runhaskell Setup.hs register --gen-script runhaskell Setup.hs unregister --gen-script
This creates shell scripts register.sh
and unregister.sh
, which must also be sent
to the target system. After unpacking there, the package must be
registered by running the register.sh
script.
The unregister.sh
script would be used
in the uninstall procedure of the package. Similar steps may
be used for creating binary packages for Windows.
The following options are understood by all commands:
--help
, -h
or
-?
List the available options for the command.
--verbose
=n
or
-v
n
Set the verbosity level (0-5). The normal level is 1;
a missing n
defaults to 3.
The various commands and the additional options they support
are described below. In the simple build infrastructure, any
other options will be reported as errors, except in the case of
the configure
command.
Prepare to build the package. Typically, this step checks that the target platform is capable of building the package, and discovers platform-specific features that are needed during the build. In addition to the general options, this command recognizes the following
--prefix
=dir
Specify the installation prefix
(default: /usr/local
on Unix systems).
--ghc
or -g
, --nhc
or -n
, --hugs
Specify which Haskell implementation to use to build the package. At most one of these flags may be given. If none is given, the implementation under which the setup script was compiled or interpreted is used.
--with-compiler
=path
or -w
path
Specify the path to a particular compiler. If given, this must match the implementation selected above. The default is to search for the usual name of the selected implementation.
--with-hc-pkg
=path
Specify the path to the package tool, e.g.
ghc-pkg
.
--with-haddock
=path
Specify the path to Haddock.
--with-happy
=path
Specify the path to happy.
--with-alex
=path
Specify the path to alex.
--with-hsc2hs
=path
Specify the path to hsc2hs.
--with-cpphs
=path
Specify the path to cpphs.
--user
Allow dependencies to be satisfied by the user package database, in addition to the global database.
--global
(default) Dependencies must be satisfied by the global package database.
In the simple build infrastructure, an additional option is recognized:
--builddir
=dir
or
-b
dir
Specify the directory into which the package will be
built (default: dist/build
).
In the simple build infrastructure, the values supplied via these options are recorded in a private file for use by later stages.
If a user-supplied configure
script is
run (see Section 2.2, “System-dependent parameters”), it is passed the
--prefix
option and any unrecognized options.
Perform any preprocessing or compilation needed to make this package ready for installation.
Build the interface documentation for a library using Haddock.
Copy the files into the install locations and (for library packages) register the package with the compiler, i.e. make the modules it contains available to programs.
This command takes the following options:
--global
Register this package in the system-wide database. (This is the default.)
--user
Register this package in the user's local package database.
Copy the files without registering them. This command is mainly of use to those creating binary packages.
This command takes the following option:
--copy-prefix
=path
Specify the directory under which to place
installed files. If this is not given, the
argument of the --prefix
option to
configure
is used.
Register this package with the compiler, i.e. make the
modules it contains available to programs. This only makes sense
for library packages. Note that the install
command incorporates this action. The main use of this
separate command is in the post-installation step for a binary
package.
This command takes the following options:
--global
Register this package in the system-wide database. (This is the default.)
--user
Register this package in the user's local package database.
--gen-script
Instead of registering the package, generate a script
containing commands to perform the registration. On Unix,
this file is called register.sh
, on
Windows, register.bat
. This script
might be included in a binary bundle, to be run after the
bundle is unpacked on the target system.
Deregister this package with the compiler.
This command takes the following options:
--global
Deregister this package in the system-wide database. (This is the default.)
--user
Deregister this package in the user's local package database.
--gen-script
Instead of deregistering the package, generate a script
containing commands to perform the deregistration. On Unix,
this file is called unregister.sh
, on
Windows, unregister.bat
. This script
might be included in a binary bundle, to be run on the
target system.
Remove any local files created during the
configure
, build
,
haddock
, register
or
unregister
steps.