3 # Building and installing packages #
5 After you've unpacked a Cabal package, you can build it by moving into
6 the root directory of the package and running the `cabal` tool there:
8 > `cabal [command] [option...]`
10 The _command_ argument selects a particular step in the build/install process.
12 You can also get a summary of the command syntax with
16 Alternatively, you can also use the `Setup.hs` or `Setup.lhs` script:
18 > `runhaskell Setup.hs [command] [option...]`
20 For the summary of the command syntax, run:
26 > `runhaskell Setup.hs --help`
28 ## Building and installing a system package ##
31 runhaskell Setup.hs configure --ghc
32 runhaskell Setup.hs build
33 runhaskell Setup.hs install
36 The first line readies the system to build the tool using GHC; for
37 example, it checks that GHC exists on the system. The second line
38 performs the actual building, while the last both copies the build
39 results to some permanent place and registers the package with GHC.
41 ## Building and installing a user package ##
44 runhaskell Setup.hs configure --user
45 runhaskell Setup.hs build
46 runhaskell Setup.hs install
49 The package is installed under the user's home directory and is
50 registered in the user's package database (`--user`).
52 ## Installing packages from Hackage ##
54 The `cabal` tool also can download, configure, build and install a [Hackage]
55 package and all of its dependencies in a single step. To do this, run:
58 cabal install [PACKAGE...]
61 To browse the list of available packages, visit the [Hackage] web site.
63 ## Developing with sandboxes ##
65 By default, any dependencies of the package are installed into the global or
66 user package databases (e.g. using `cabal install --only-dependencies`). If
67 you're building several different packages that have incompatible dependencies,
68 this can cause the build to fail. One way to avoid this problem is to build each
69 package in an isolated environment ("sandbox"), with a sandbox-local package
70 database. Because sandboxes are per-project, inconsistent dependencies can be
73 For more on sandboxes, see also
74 [this article](http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html).
76 ### Sandboxes: basic usage ###
78 To initialise a fresh sandbox in the current directory, run `cabal sandbox
79 init`. All subsequent commands (such as `build` and `install`) from this point
83 $ cd /path/to/my/haskell/library
84 $ cabal sandbox init # Initialise the sandbox
85 $ cabal install --only-dependencies # Install dependencies into the sandbox
86 $ cabal build # Build your package inside the sandbox
89 It can be useful to make a source package available for installation in the
90 sandbox - for example, if your package depends on a patched or an unreleased
91 version of a library. This can be done with the `cabal sandbox add-source`
92 command - think of it as "local [Hackage]". If an add-source dependency is later
93 modified, it is reinstalled automatically.
96 $ cabal sandbox add-source /my/patched/library # Add a new add-source dependency
97 $ cabal install --dependencies-only # Install it into the sandbox
98 $ cabal build # Build the local package
99 $ $EDITOR /my/patched/library/Source.hs # Modify the add-source dependency
100 $ cabal build # Modified dependency is automatically reinstalled
103 Normally, the sandbox settings (such as optimisation level) are inherited from
104 the main Cabal config file (`$HOME/cabal/config`). Sometimes, though, you need
105 to change some settings specifically for a single sandbox. You can do this by
106 creating a `cabal.config` file in the same directory with your
107 `cabal.sandbox.config` (which was created by `sandbox init`). This file has the
108 same syntax as the main Cabal config file.
113 constraints: foo == 1.0, bar >= 2.0, baz
114 $ cabal build # Uses settings from the cabal.config file
117 When you have decided that you no longer want to build your package inside a
118 sandbox, just delete it:
121 $ cabal sandbox delete # Built-in command
122 $ rm -rf .cabal-sandbox cabal.sandbox.config # Alternative manual method
125 ### Sandboxes: advanced usage ###
127 The default behaviour of the `add-source` command is to track modifications done
128 to the added dependency and reinstall the sandbox copy of the package when
129 needed. Sometimes this is not desirable: in these cases you can use `add-source
130 --snapshot`, which disables the change tracking. In addition to `add-source`,
131 there are also `list-sources` and `delete-source` commands.
133 Sometimes one wants to share a single sandbox between multiple packages. This
134 can be easily done with the `--sandbox` option:
137 $ mkdir -p /path/to/shared-sandbox
138 $ cd /path/to/shared-sandbox
139 $ cabal sandbox init --sandbox .
140 $ cd /path/to/package-a
141 $ cabal sandbox init --sandbox /path/to/shared-sandbox
142 $ cd /path/to/package-b
143 $ cabal sandbox init --sandbox /path/to/shared-sandbox
146 Note that `cabal sandbox init --sandbox .` puts all sandbox files into the
147 current directory. By default, `cabal sandbox init` initialises a new sandbox in
148 a newly-created subdirectory of the current working directory
149 (`./.cabal-sandbox`).
151 Using multiple different compiler versions simultaneously is also supported, via
156 $ cabal install --only-dependencies -w /path/to/ghc-1 # Install dependencies for both compilers
157 $ cabal install --only-dependencies -w /path/to/ghc-2
158 $ cabal configure -w /path/to/ghc-1 # Build with the first compiler
160 $ cabal configure -w /path/to/ghc-2 # Build with the second compiler
164 It can be occasionally useful to run the compiler-specific package manager tool
165 (e.g. `ghc-pkg`) tool on the sandbox package DB directly (for example, you may
166 need to unregister some packages). The `cabal sandbox hc-pkg` command is a
167 convenient wrapper that runs the compiler-specific package manager tool with the
171 $ cabal -v sandbox hc-pkg list
172 Using a sandbox located at /path/to/.cabal-sandbox
173 'ghc-pkg' '--global' '--no-user-package-conf'
174 '--package-conf=/path/to/.cabal-sandbox/i386-linux-ghc-7.4.2-packages.conf.d'
179 The `--require-sandbox` option makes all sandbox-aware commands
180 (`install`/`build`/etc.) exit with error if there is no sandbox present. This
181 makes it harder to accidentally modify the user package database. The option can
182 be also turned on via the per-user configuration file (`~/.cabal/config`) or the
183 per-project one (`$PROJECT_DIR/cabal.config`). The error can be squelched with
184 `--no-require-sandbox`.
186 The option `--sandbox-config-file` allows to specify the location of the
187 `cabal.sandbox.config` file (by default, `cabal` searches for it in the current
188 directory). This provides the same functionality as shared sandboxes, but
189 sometimes can be more convenient. Example:
195 $ cd /path/to/my/project
196 $ cabal --sandbox-config-file=/path/to/my/sandbox/cabal.sandbox.config install
197 # Uses the sandbox located at /path/to/my/sandbox/.cabal-sandbox
199 $ cabal --sandbox-config-file=/path/to/my/sandbox/cabal.sandbox.config install
200 # Still uses the same sandbox
203 The sandbox config file can be also specified via the `CABAL_SANDBOX_CONFIG`
204 environment variable.
206 Finally, the flag `--ignore-sandbox` lets you temporarily ignore an existing
213 $ cabal --ignore-sandbox install text
214 # Installs 'text' in the user package database ('~/.cabal').
217 ## Creating a binary package ##
219 When creating binary packages (e.g. for RedHat or Debian) one needs to
220 create a tarball that can be sent to another system for unpacking in the
224 runhaskell Setup.hs configure --prefix=/usr
225 runhaskell Setup.hs build
226 runhaskell Setup.hs copy --destdir=/tmp/mypkg
227 tar -czf mypkg.tar.gz /tmp/mypkg/
230 If the package contains a library, you need two additional steps:
233 runhaskell Setup.hs register --gen-script
234 runhaskell Setup.hs unregister --gen-script
237 This creates shell scripts `register.sh` and `unregister.sh`, which must
238 also be sent to the target system. After unpacking there, the package
239 must be registered by running the `register.sh` script. The
240 `unregister.sh` script would be used in the uninstall procedure of the
241 package. Similar steps may be used for creating binary packages for
245 The following options are understood by all commands:
247 `--help`, `-h` or `-?`
248 : List the available options for the command.
250 `--verbose=`_n_ or `-v`_n_
251 : Set the verbosity level (0-3). The normal level is 1; a missing _n_
254 The various commands and the additional options they support are
255 described below. In the simple build infrastructure, any other options
256 will be reported as errors.
258 ## setup configure ##
260 Prepare to build the package. Typically, this step checks that the
261 target platform is capable of building the package, and discovers
262 platform-specific features that are needed during the build.
264 The user may also adjust the behaviour of later stages using the options
265 listed in the following subsections. In the simple build
266 infrastructure, the values supplied via these options are recorded in a
267 private file read by later stages.
269 If a user-supplied `configure` script is run (see the section on
271 parameters](developing-packages.html#system-dependent-parameters) or on
272 [complex packages](developing-packages.html#more-complex-packages)), it
273 is passed the `--with-hc-pkg`, `--prefix`, `--bindir`, `--libdir`,
274 `--datadir`, `--libexecdir` and `--sysconfdir` options. In addition the
275 value of the `--with-compiler` option is passed in a `--with-hc` option
276 and all options specified with `--configure-option=` are passed on.
278 ### Programs used for building ###
280 The following options govern the programs used to process the source
283 `--ghc` or `-g`, `--nhc`, `--jhc`, `--hugs`
284 : Specify which Haskell implementation to use to build the package.
285 At most one of these flags may be given. If none is given, the
286 implementation under which the setup script was compiled or
289 `--with-compiler=`_path_ or `-w`_path_
290 : Specify the path to a particular compiler. If given, this must match
291 the implementation selected above. The default is to search for the
292 usual name of the selected implementation.
294 This flag also sets the default value of the `--with-hc-pkg` option
295 to the package tool for this compiler. Check the output of `setup
296 configure -v` to ensure that it finds the right package tool (or use
297 `--with-hc-pkg` explicitly).
300 `--with-hc-pkg=`_path_
301 : Specify the path to the package tool, e.g. `ghc-pkg`. The package
302 tool must be compatible with the compiler specified by
303 `--with-compiler`. If this option is omitted, the default value is
304 determined from the compiler selected.
306 `--with-`_`prog`_`=`_path_
307 : Specify the path to the program _prog_. Any program known to Cabal
308 can be used in place of _prog_. It can either be a fully path or the
309 name of a program that can be found on the program search path. For
310 example: `--with-ghc=ghc-6.6.1` or
311 `--with-cpphs=/usr/local/bin/cpphs`.
312 The full list of accepted programs is not enumerated in this user guide.
313 Rather, run `cabal install --help` to view the list.
315 `--`_`prog`_`-options=`_options_
316 : Specify additional options to the program _prog_. Any program known
317 to Cabal can be used in place of _prog_. For example:
318 `--alex-options="--template=mytemplatedir/"`. The _options_ is split
319 into program options based on spaces. Any options containing embeded
320 spaced need to be quoted, for example
321 `--foo-options='--bar="C:\Program File\Bar"'`. As an alternative
322 that takes only one option at a time but avoids the need to quote,
323 use `--`_`prog`_`-option` instead.
325 `--`_`prog`_`-option=`_option_
326 : Specify a single additional option to the program _prog_. For
327 passing an option that contain embeded spaces, such as a file name
328 with embeded spaces, using this rather than `--`_`prog`_`-options`
329 means you do not need an additional level of quoting. Of course if
330 you are using a command shell you may still need to quote, for
331 example `--foo-options="--bar=C:\Program File\Bar"`.
333 All of the options passed with either `--`_`prog`_`-options` or
334 `--`_`prog`_`-option` are passed in the order they were specified on the
335 configure command line.
337 ### Installation paths ###
339 The following options govern the location of installed files from a
343 : The root of the installation. For example for a global install you
344 might use `/usr/local` on a Unix system, or `C:\Program Files` on a
345 Windows system. The other installation paths are usually
346 subdirectories of _prefix_, but they don't have to be.
348 In the simple build system, _dir_ may contain the following path
349 variables: `$pkgid`, `$pkg`, `$version`, `$compiler`, `$os`,
353 : Executables that the user might invoke are installed here.
355 In the simple build system, _dir_ may contain the following path
356 variables: `$prefix`, `$pkgid`, `$pkg`, `$version`, `$compiler`,
360 : Object-code libraries are installed here.
362 In the simple build system, _dir_ may contain the following path
363 variables: `$prefix`, `$bindir`, `$pkgid`, `$pkg`, `$version`,
364 `$compiler`, `$os`, `$arch`
367 : Executables that are not expected to be invoked directly by the user
370 In the simple build system, _dir_ may contain the following path
371 variables: `$prefix`, `$bindir`, `$libdir`, `$libsubdir`, `$pkgid`,
372 `$pkg`, `$version`, `$compiler`, `$os`, `$arch`
375 : Architecture-independent data files are installed here.
377 In the simple build system, _dir_ may contain the following path
378 variables: `$prefix`, `$bindir`, `$libdir`, `$libsubdir`, `$pkgid`, `$pkg`,
379 `$version`, `$compiler`, `$os`, `$arch`
382 : Installation directory for the configuration files.
384 In the simple build system, _dir_ may contain the following path variables:
385 `$prefix`, `$bindir`, `$libdir`, `$libsubdir`, `$pkgid`, `$pkg`, `$version`,
386 `$compiler`, `$os`, `$arch`
388 In addition the simple build system supports the following installation path options:
391 : A subdirectory of _libdir_ in which libraries are actually
392 installed. For example, in the simple build system on Unix, the
393 default _libdir_ is `/usr/local/lib`, and _libsubdir_ contains the
394 package identifier and compiler, e.g. `mypkg-0.2/ghc-6.4`, so
395 libraries would be installed in `/usr/local/lib/mypkg-0.2/ghc-6.4`.
397 _dir_ may contain the following path variables: `$pkgid`, `$pkg`,
398 `$version`, `$compiler`, `$os`, `$arch`
401 : A subdirectory of _datadir_ in which data files are actually
404 _dir_ may contain the following path variables: `$pkgid`, `$pkg`,
405 `$version`, `$compiler`, `$os`, `$arch`
408 : Documentation files are installed relative to this directory.
410 _dir_ may contain the following path variables: `$prefix`, `$bindir`,
411 `$libdir`, `$libsubdir`, `$datadir`, `$datasubdir`, `$pkgid`, `$pkg`,
412 `$version`, `$compiler`, `$os`, `$arch`
415 : HTML documentation files are installed relative to this directory.
417 _dir_ may contain the following path variables: `$prefix`, `$bindir`,
418 `$libdir`, `$libsubdir`, `$datadir`, `$datasubdir`, `$docdir`, `$pkgid`,
419 `$pkg`, `$version`, `$compiler`, `$os`, `$arch`
421 `--program-prefix=`_prefix_
422 : Prepend _prefix_ to installed program names.
424 _prefix_ may contain the following path variables: `$pkgid`, `$pkg`,
425 `$version`, `$compiler`, `$os`, `$arch`
427 `--program-suffix=`_suffix_
428 : Append _suffix_ to installed program names. The most obvious use for
429 this is to append the program's version number to make it possible
430 to install several versions of a program at once:
431 `--program-suffix='$version'`.
433 _suffix_ may contain the following path variables: `$pkgid`, `$pkg`,
434 `$version`, `$compiler`, `$os`, `$arch`
436 #### Path variables in the simple build system ####
438 For the simple build system, there are a number of variables that can be
439 used when specifying installation paths. The defaults are also specified
440 in terms of these variables. A number of the variables are actually for
441 other paths, like `$prefix`. This allows paths to be specified relative
442 to each other rather than as absolute paths, which is important for
443 building relocatable packages (see [prefix
444 independence](#prefix-independence)).
447 : The path variable that stands for the root of the installation. For
448 an installation to be relocatable, all other instllation paths must
449 be relative to the `$prefix` variable.
452 : The path variable that expands to the path given by the `--bindir`
453 configure option (or the default).
456 : As above but for `--libdir`
459 : As above but for `--libsubdir`
462 : As above but for `--datadir`
465 : As above but for `--datasubdir`
468 : As above but for `--docdir`
471 : The name and version of the package, eg `mypkg-0.2`
474 : The name of the package, eg `mypkg`
477 : The version of the package, eg `0.2`
480 : The compiler being used to build the package, eg `ghc-6.6.1`
483 : The operating system of the computer being used to build the
484 package, eg `linux`, `windows`, `osx`, `freebsd` or `solaris`
487 : The architecture of the computer being used to build the package, eg
488 `i386`, `x86_64`, `ppc` or `sparc`
490 #### Paths in the simple build system ####
492 For the simple build system, the following defaults apply:
494 Option Windows Default Unix Default
495 ------- ---------------- -------------
496 `--prefix` (global) `C:\Program Files\Haskell` `/usr/local`
497 `--prefix` (per-user) `C:\Documents And Settings\user\Application Data\cabal` `$HOME/.cabal`
498 `--bindir` `$prefix\bin` `$prefix/bin`
499 `--libdir` `$prefix` `$prefix/lib`
500 `--libsubdir` (Hugs) `hugs\packages\$pkg` `hugs/packages/$pkg`
501 `--libsubdir` (others) `$pkgid\$compiler` `$pkgid/$compiler`
502 `--libexecdir` `$prefix\$pkgid` `$prefix/libexec`
503 `--datadir` (executable) `$prefix` `$prefix/share`
504 `--datadir` (library) `C:\Program Files\Haskell` `$prefix/share`
505 `--datasubdir` `$pkgid` `$pkgid`
506 `--docdir` `$prefix\doc\$pkgid` `$datadir/doc/$pkgid`
507 `--sysconfdir` `$prefix\etc` `$prefix/etc`
508 `--htmldir` `$docdir\html` `$docdir/html`
509 `--program-prefix` (empty) (empty)
510 `--program-suffix` (empty) (empty)
513 #### Prefix-independence ####
515 On Windows, and when using Hugs on any system, it is possible to obtain
516 the pathname of the running program. This means that we can construct an
517 installable executable package that is independent of its absolute
518 install location. The executable can find its auxiliary files by finding
519 its own path and knowing the location of the other files relative to
520 `$bindir`. Prefix-independence is particularly
521 useful: it means the user can choose the install location (i.e. the
522 value of `$prefix`) at install-time, rather than
523 having to bake the path into the binary when it is built.
525 In order to achieve this, we require that for an executable on Windows,
526 all of `$bindir`, `$libdir`, `$datadir` and `$libexecdir` begin with
527 `$prefix`. If this is not the case then the compiled executable will
528 have baked-in all absolute paths.
530 The application need do nothing special to achieve prefix-independence.
531 If it finds any files using `getDataFileName` and the [other functions
533 purpose](developing-packages.html#accessing-data-files-from-package-code),
534 the files will be accessed relative to the location of the current
537 A library cannot (currently) be prefix-independent, because it will be
538 linked into an executable whose file system location bears no relation
539 to the library package.
541 ### Controlling Flag Assignments ###
543 Flag assignments (see the [resolution of conditions and
544 flags](developing-packages.html#resolution-of-conditions-and-flags)) can
545 be controlled with the following command line options.
547 `-f` _flagname_ or `-f` `-`_flagname_
548 : Force the specified flag to `true` or `false` (if preceded with a `-`). Later
549 specifications for the same flags will override earlier, i.e.,
550 specifying `-fdebug -f-debug` is equivalent to `-f-debug`
552 `--flags=`_flagspecs_
553 : Same as `-f`, but allows specifying multiple flag assignments at
554 once. The parameter is a space-separated list of flag names (to
555 force a flag to `true`), optionally preceded by a `-` (to force a
556 flag to `false`). For example, `--flags="debug -feature1 feature2"` is
557 equivalent to `-fdebug -f-feature1 -ffeature2`.
559 ### Building Test Suites ###
562 : Build the test suites defined in the package description file during the
563 `build` stage. Check for dependencies required by the test suites. If the
564 package is configured with this option, it will be possible to run the test
565 suites with the `test` command after the package is built.
568 : (default) Do not build any test suites during the `build` stage.
569 Do not check for dependencies required only by the test suites. It will not
570 be possible to invoke the `test` command without reconfiguring the package.
572 ### Miscellaneous options ##
575 : Does a per-user installation. This changes the [default installation
576 prefix](#paths-in-the-simple-build-system). It also allow
577 dependencies to be satisfied by the user's package database, in
578 addition to the global database. This also implies a default of
579 `--user` for any subsequent `install` command, as packages
580 registered in the global database should not depend on packages
581 registered in a user's database.
584 : (default) Does a global installation. In this case package
585 dependencies must be satisfied by the global package database. All
586 packages in the user's package database will be ignored. Typically
587 the final instllation step will require administrative privileges.
590 : Allows package dependencies to be satisfied from this additional
591 package database _db_ in addition to the global package database.
592 All packages in the user's package database will be ignored. The
593 interpretation of _db_ is implementation-specific. Typically it will
594 be a file or directory. Not all implementations support arbitrary
597 `--enable-optimization`[=_n_] or `-O`[_n_]
598 : (default) Build with optimization flags (if available). This is
599 appropriate for production use, taking more time to build faster
600 libraries and programs.
602 The optional _n_ value is the optimisation level. Some compilers
603 support multiple optimisation levels. The range is 0 to 2. Level 0
604 is equivalent to `--disable-optimization`, level 1 is the default if
605 no _n_ parameter is given. Level 2 is higher optimisation if the
606 compiler supports it. Level 2 is likely to lead to longer compile
607 times and bigger generated code.
609 `--disable-optimization`
610 : Build without optimization. This is suited for development: building
611 will be quicker, but the resulting library or programs will be slower.
613 `--enable-library-profiling` or `-p`
614 : Request that an additional version of the library with profiling
615 features enabled be built and installed (only for implementations
616 that support profiling).
618 `--disable-library-profiling`
619 : (default) Do not generate an additional profiling version of the
622 `--enable-executable-profiling`
623 : Any executables generated should have profiling enabled (only for
624 implementations that support profiling). For this to work, all
625 libraries used by these executables must also have been built with
628 `--disable-executable-profiling`
629 : (default) Do not enable profiling in generated executables.
631 `--enable-library-vanilla`
632 : (default) Build ordinary libraries (as opposed to profiling
633 libraries). This is independent of the `--enable-library-profiling`
634 option. If you enable both, you get both.
636 `--disable-library-vanilla`
637 : Do not build ordinary libraries. This is useful in conjunction with
638 `--enable-library-profiling` to build only profiling libraries,
639 rather than profiling and ordinary libraries.
641 `--enable-library-for-ghci`
642 : (default) Build libraries suitable for use with GHCi.
644 `--disable-library-for-ghci`
645 : Not all platforms support GHCi and indeed on some platforms, trying
646 to build GHCi libs fails. In such cases this flag can be used as a
649 `--enable-split-objs`
650 : Use the GHC `-split-objs` feature when building the library. This
651 reduces the final size of the executables that use the library by
652 allowing them to link with only the bits that they use rather than
653 the entire library. The downside is that building the library takes
654 longer and uses considerably more memory.
656 `--disable-split-objs`
657 : (default) Do not use the GHC `-split-objs` feature. This makes
658 building the library quicker but the final executables that use the
659 library will be larger.
661 `--enable-executable-stripping`
662 : (default) When installing binary executable programs, run the
663 `strip` program on the binary. This can considerably reduce the size
664 of the executable binary file. It does this by removing debugging
665 information and symbols. While such extra information is useful for
666 debugging C programs with traditional debuggers it is rarely helpful
667 for debugging binaries produced by Haskell compilers.
669 Not all Haskell implementations generate native binaries. For such
670 implementations this option has no effect.
672 `--disable-executable-stripping`
673 : Do not strip binary executables during installation. You might want
674 to use this option if you need to debug a program using gdb, for
675 example if you want to debug the C parts of a program containing
676 both Haskell and C code. Another reason is if your are building a
677 package for a system which has a policy of managing the stripping
678 itself (such as some linux distributions).
681 : Build shared library. This implies a separate compiler run to
682 generate position independent code as required on most platforms.
685 : (default) Do not build shared library.
687 `--configure-option=`_str_
688 : An extra option to an external `configure` script, if one is used
689 (see the section on [system-dependent
690 parameters](developing-packages.html#system-dependent-parameters)).
691 There can be several of these options.
693 `--extra-include-dirs`[=_dir_]
694 : An extra directory to search for C header files. You can use this
695 flag multiple times to get a list of directories.
697 You might need to use this flag if you have standard system header
698 files in a non-standard location that is not mentioned in the
699 package's `.cabal` file. Using this option has the same affect as
700 appending the directory _dir_ to the `include-dirs` field in each
701 library and executable in the package's `.cabal` file. The advantage
702 of course is that you do not have to modify the package at all.
703 These extra directories will be used while building the package and
704 for libraries it is also saved in the package registration
705 information and used when compiling modules that use the library.
707 `--extra-lib-dirs`[=_dir_]
708 : An extra directory to search for system libraries files. You can use
709 this flag multiple times to get a list of directories.
711 You might need to use this flag if you have standard system
712 libraries in a non-standard location that is not mentioned in the
713 package's `.cabal` file. Using this option has the same affect as
714 appending the directory _dir_ to the `extra-lib-dirs` field in each
715 library and executable in the package's `.cabal` file. The advantage
716 of course is that you do not have to modify the package at all.
717 These extra directories will be used while building the package and
718 for libraries it is also saved in the package registration
719 information and used when compiling modules that use the library.
721 `--allow-newer`[=_pkgs_]
722 : Selectively relax upper bounds in dependencies without editing the
725 If you want to install a package A that depends on B >= 1.0 && < 2.0, but
726 you have the version 2.0 of B installed, you can compile A against B 2.0 by
727 using `cabal install --allow-newer=B A`. This works for the whole package
728 index: if A also depends on C that in turn depends on B < 2.0, C's
729 dependency on B will be also relaxed.
736 Resolving dependencies...
737 cabal: Could not resolve dependencies:
739 $ cabal configure --allow-newer
740 Resolving dependencies...
747 # Relax upper bounds in all dependencies.
748 $ cabal install --allow-newer foo
750 # Relax upper bounds only in dependencies on bar, baz and quux.
751 $ cabal install --allow-newer=bar,baz,quux foo
753 # Relax the upper bound on bar and force bar==2.1.
754 $ cabal install --allow-newer=bar --constraint="bar==2.1" foo
757 It's also possible to enable `--allow-newer` permanently by setting
758 `allow-newer: True` in the `~/.cabal/config` file.
761 In the simple build infrastructure, an additional option is recognized:
764 : Specify the directory into which the Hugs output will be placed
765 (default: `dist/scratch`).
769 Perform any preprocessing or compilation needed to make this package ready for installation.
771 This command takes the following options:
773 --_prog_-options=_options_, --_prog_-option=_option_
774 : These are mostly the same as the [options configure
775 step](#setup-configure). Unlike the options specified at the
776 configure step, any program options specified at the build step are
777 not persistent but are used for that invocation only. They options
778 specified at the build step are in addition not in replacement of
779 any options specified at the configure step.
783 Build the documentation for the package using [haddock][]. By default,
784 only the documentation for the exposed modules is generated (but see the
785 `--executables` and `--internal` flags below).
787 This command takes the following options:
790 : Generate a file `dist/doc/html/`_pkgid_`.txt`, which can be
791 converted by [Hoogle](http://www.haskell.org/hoogle/) into a
792 database for searching. This is equivalent to running [haddock][]
793 with the `--hoogle` flag.
795 `--html-location=`_url_
796 : Specify a template for the location of HTML documentation for
797 prerequisite packages. The substitutions ([see
798 listing](#paths-in-the-simple-build-system)) are applied to the
799 template to obtain a location for each package, which will be used
800 by hyperlinks in the generated documentation. For example, the
801 following command generates links pointing at [Hackage] pages:
803 > setup haddock --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
805 Here the argument is quoted to prevent substitution by the shell. If
806 this option is omitted, the location for each package is obtained
807 using the package tool (e.g. `ghc-pkg`).
810 : Also run [haddock][] for the modules of all the executable programs.
811 By default [haddock][] is run only on the exported modules.
814 : Run [haddock][] for the all modules, including unexposed ones, and
815 make [haddock][] generate documentation for unexported symbols as
819 : The argument _path_ denotes a CSS file, which is passed to
820 [haddock][] and used to set the style of the generated
821 documentation. This is only needed to override the default style
822 that [haddock][] uses.
825 : Generate [haddock][] documentation integrated with [HsColour][].
826 First, [HsColour][] is run to generate colourised code. Then
827 [haddock][] is run to generate HTML documentation. Each entity
828 shown in the documentation is linked to its definition in the
831 `--hscolour-css=`_path_
832 : The argument _path_ denotes a CSS file, which is passed to [HsColour][] as in
834 > runhaskell Setup.hs hscolour --css=_path_
838 Produce colourised code in HTML format using [HsColour][]. Colourised
839 code for exported modules is put in `dist/doc/html/`_pkgid_`/src`.
841 This command takes the following options:
844 : Also run [HsColour][] on the sources of all executable programs.
845 Colourised code is put in `dist/doc/html/`_pkgid_/_executable_`/src`.
848 : Use the given CSS file for the generated HTML files. The CSS file
849 defines the colours used to colourise code. Note that this copies
850 the given CSS file to the directory with the generated HTML files
851 (renamed to `hscolour.css`) rather than linking to it.
855 Copy the files into the install locations and (for library packages)
856 register the package with the compiler, i.e. make the modules it
857 contains available to programs.
859 The [install locations](#installation-paths) are determined by options
860 to `setup configure`.
862 This command takes the following options:
865 : Register this package in the system-wide database. (This is the
866 default, unless the `--user` option was supplied to the `configure`
870 : Register this package in the user's local package database. (This is
871 the default if the `--user` option was supplied to the `configure`
876 Copy the files without registering them. This command is mainly of use
877 to those creating binary packages.
879 This command takes the following option:
883 Specify the directory under which to place installed files. If this is
884 not given, then the root directory is assumed.
888 Register this package with the compiler, i.e. make the modules it
889 contains available to programs. This only makes sense for library
890 packages. Note that the `install` command incorporates this action. The
891 main use of this separate command is in the post-installation step for a
894 This command takes the following options:
897 : Register this package in the system-wide database. (This is the default.)
901 : Register this package in the user's local package database.
905 : Instead of registering the package, generate a script containing
906 commands to perform the registration. On Unix, this file is called
907 `register.sh`, on Windows, `register.bat`. This script might be
908 included in a binary bundle, to be run after the bundle is unpacked
909 on the target system.
911 `--gen-pkg-config`[=_path_]
912 : Instead of registering the package, generate a package registration
913 file. This only applies to compilers that support package
914 registration files which at the moment is only GHC. The file should
915 be used with the compiler's mechanism for registering packages. This
916 option is mainly intended for packaging systems. If possible use the
917 `--gen-script` option instead since it is more portable across
918 Haskell implementations. The _path_ is
919 optional and can be used to specify a particular output file to
920 generate. Otherwise, by default the file is the package name and
921 version with a `.conf` extension.
924 : Registers the package for use directly from the build tree, without
925 needing to install it. This can be useful for testing: there's no
926 need to install the package after modifying it, just recompile and
929 This flag does not create a build-tree-local package database. It
930 still registers the package in one of the user or global databases.
932 However, there are some caveats. It only works with GHC
933 (currently). It only works if your package doesn't depend on having
934 any supplemental files installed --- plain Haskell libraries should
937 ## setup unregister ##
939 Deregister this package with the compiler.
941 This command takes the following options:
944 : Deregister this package in the system-wide database. (This is the default.)
947 : Deregister this package in the user's local package database.
950 : Instead of deregistering the package, generate a script containing
951 commands to perform the deregistration. On Unix, this file is
952 called `unregister.sh`, on Windows, `unregister.bat`. This script
953 might be included in a binary bundle, to be run on the target
958 Remove any local files created during the `configure`, `build`,
959 `haddock`, `register` or `unregister` steps, and also any files and
960 directories listed in the `extra-tmp-files` field.
962 This command takes the following options:
964 `--save-configure` or `-s`
965 : Keeps the configuration information so it is not necessary to run
966 the configure step again before building.
970 Run the test suites specified in the package description file. Aside from
971 the following flags, Cabal accepts the name of one or more test suites on the
972 command line after `test`. When supplied, Cabal will run only the named test
973 suites, otherwise, Cabal will run all test suites in the package.
976 : The directory where Cabal puts generated build files (default: `dist`).
977 Test logs will be located in the `test` subdirectory.
980 : The template used to name human-readable test logs; the path is relative
981 to `dist/test`. By default, logs are named according to the template
982 `$pkgid-$test-suite.log`, so that each test suite will be logged to its own
983 human-readable log file. Template variables allowed are: `$pkgid`,
984 `$compiler`, `$os`, `$arch`, `$test-suite`, and `$result`.
986 `--machine-log=`_path_
987 : The path to the machine-readable log, relative to `dist/test`. The default
988 template is `$pkgid.log`. Template variables allowed are: `$pkgid`,
989 `$compiler`, `$os`, `$arch`, and `$result`.
991 `--show-details=`_filter_
992 : Determines if the results of individual test cases are shown on the
993 terminal. May be `always` (always show), `never` (never show), or
994 `failures` (show only the test cases of failing test suites).
996 `--test-options=`_options_
997 : Give extra options to the test executables.
999 `--test-option=`_option_
1000 : give an extra option to the test executables. There is no need to quote
1001 options containing spaces because a single option is assumed, so options
1002 will not be split on spaces.
1006 Create a system- and compiler-independent source distribution in a file
1007 _package_-_version_`.tar.gz` in the `dist` subdirectory, for
1008 distribution to package builders. When unpacked, the commands listed in
1009 this section will be available.
1011 The files placed in this distribution are the package description file,
1012 the setup script, the sources of the modules named in the package
1013 description file, and files named in the `license-file`, `main-is`,
1014 `c-sources`, `data-files`, `extra-source-files` and `extra-doc-files`
1017 This command takes the following option:
1020 : Append today's date (in "YYYYMMDD" format) to the version number for
1021 the generated source package. The original package is unaffected.
1024 [dist-simple]: ../release/cabal-latest/doc/API/Cabal/Distribution-Simple.html
1025 [dist-make]: ../release/cabal-latest/doc/API/Cabal/Distribution-Make.html
1026 [dist-license]: ../release/cabal-latest/doc/API/Cabal/Distribution-License.html#t:License
1027 [extension]: ../release/cabal-latest/doc/API/Cabal/Language-Haskell-Extension.html#t:Extension
1028 [BuildType]: ../release/cabal-latest/doc/API/Cabal/Distribution-PackageDescription.html#t:BuildType
1029 [alex]: http://www.haskell.org/alex/
1030 [autoconf]: http://www.gnu.org/software/autoconf/
1031 [c2hs]: http://www.cse.unsw.edu.au/~chak/haskell/c2hs/
1032 [cpphs]: http://projects.haskell.org/cpphs/
1033 [greencard]: http://hackage.haskell.org/package/greencard
1034 [haddock]: http://www.haskell.org/haddock/
1035 [HsColour]: http://www.cs.york.ac.uk/fp/darcs/hscolour/
1036 [happy]: http://www.haskell.org/happy/
1037 [Hackage]: http://hackage.haskell.org/
1038 [pkg-config]: http://www.freedesktop.org/wiki/Software/pkg-config/