8 GHC provides the commands ``runhaskell`` and ``runghc`` (they are equivalent)
9 to allow you to run Haskell programs without first having to compile them
10 (scripts). The low-level Cabal interface is implemented using ``Setup.hs``
11 scripts. You should prefer using higher level interface provided by nix-style
16 $ runhaskell Setup.hs [command] [option...]
18 For the summary of the ``Setup.hs`` script's command syntax, run:
22 $ runhaskell Setup.hs --help
24 Building and installing a system package
25 ----------------------------------------
29 $ runhaskell Setup.hs configure --ghc
30 $ runhaskell Setup.hs build
31 $ runhaskell Setup.hs install
33 The first line readies the system to build the tool using GHC; for
34 example, it checks that GHC exists on the system. The second line
35 performs the actual building, while the last both copies the build
36 results to some permanent place and registers the package with GHC.
40 Global installing of packages is not recommended.
41 The :ref:`nix-style-builds` is the preferred way of building and installing
44 Creating a binary package
45 -------------------------
47 When creating binary packages (e.g. for Red Hat or Debian) one needs to
48 create a tarball that can be sent to another system for unpacking in the
53 $ runhaskell Setup.hs configure --prefix=/usr
54 $ runhaskell Setup.hs build
55 $ runhaskell Setup.hs copy --destdir=/tmp/mypkg
56 $ tar -czf mypkg.tar.gz /tmp/mypkg/
58 If the package contains a library, you need two additional steps:
62 $ runhaskell Setup.hs register --gen-script
63 $ runhaskell Setup.hs unregister --gen-script
65 This creates shell scripts ``register.sh`` and ``unregister.sh``, which
66 must also be sent to the target system. After unpacking there, the
67 package must be registered by running the ``register.sh`` script. The
68 ``unregister.sh`` script would be used in the uninstall procedure of the
69 package. Similar steps may be used for creating binary packages for
72 The following options are understood by all commands:
76 .. option:: --help, -h or -?
78 List the available options for the command.
80 .. option:: --verbose=n or -v n
82 Set the verbosity level (0-3). The normal level is 1; a missing *n*
85 There is also an extended version of this command which can be
86 used to fine-tune the verbosity of output. It takes the
87 form ``[silent|normal|verbose|debug]``\ *flags*, where *flags*
88 is a list of ``+`` flags which toggle various aspects of
89 output. At the moment, only ``+callsite`` and ``+callstack``
90 are supported, which respectively toggle call site and call
91 stack printing (these are only supported if Cabal
92 is built with a sufficiently recent GHC.)
94 The various commands and the additional options they support are
95 described below. In the simple build infrastructure, any other options
96 will be reported as errors.
100 runhaskell Setup.hs configure
101 -----------------------------
103 .. program:: runhaskell Setup.hs configure
105 Prepare to build the package. Typically, this step checks that the
106 target platform is capable of building the package, and discovers
107 platform-specific features that are needed during the build.
109 The user may also adjust the behaviour of later stages using the options
110 listed in the following subsections. In the simple build infrastructure,
111 the values supplied via these options are recorded in a private file
112 read by later stages.
114 If a user-supplied ``configure`` script is run (see the section on
115 :ref:`system-dependent parameters` or
116 on :ref:`more-complex-packages`), it is
117 passed the :option:`--with-hc-pkg`, :option:`--prefix`, :option:`--bindir`,
118 :option:`--libdir`, :option:`--dynlibdir`, :option:`--datadir`, :option:`--libexecdir` and
119 :option:`--sysconfdir` options. In addition the value of the
120 :option:`--with-compiler` option is passed in a :option:`--with-hc-pkg` option
121 and all options specified with :option:`--configure-option` are passed on.
124 `GNU autoconf places restrictions on paths, including the directory
125 that the package is built from.
126 <https://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions>`_
127 The errors produced when this happens can be obscure; Cabal attempts to
128 detect and warn in this situation, but it is not perfect.
130 In Cabal 2.0, support for a single positional argument was added to
131 ``runhaskell Setup.hs configure`` This makes Cabal configure the specific component to
132 be configured. Specified names can be qualified with ``lib:`` or
133 ``exe:`` in case just a name is ambiguous (as would be the case for a
134 package named ``p`` which has a library and an executable named ``p``.)
135 This has the following effects:
137 - Subsequent invocations of ``cabal build``, ``register``, etc. operate only
138 on the configured component.
140 - Cabal requires all "internal" dependencies (e.g., an executable
141 depending on a library defined in the same package) must be found in
142 the set of databases via :option:`--package-db` (and related flags): these
143 dependencies are assumed to be up-to-date. A dependency can be
144 explicitly specified using :option:`--dependency` simply by giving the name
145 of the internal library; e.g., the dependency for an internal library
146 named ``foo`` is given as
147 ``--dependency=pkg-internal=pkg-1.0-internal-abcd``.
149 - Only the dependencies needed for the requested component are
150 required. Similarly, when :option:`--exact-configuration` is specified,
151 it's only necessary to specify :option:`--dependency` for the component.
152 (As mentioned previously, you *must* specify internal dependencies as
155 - Internal ``build-tool-depends`` and ``build-tools`` dependencies are expected
156 to be in the ``PATH`` upon subsequent invocations of ``setup``.
158 Full details can be found in the `Componentized Cabal
159 proposal <https://github.com/ezyang/ghc-proposals/blob/master/proposals/0000-componentized-cabal.rst>`__.
161 Programs used for building
162 ^^^^^^^^^^^^^^^^^^^^^^^^^^
164 The following options govern the programs used to process the source
167 .. option:: --ghc or -g, --jhc, --lhc, --uhc
169 Specify which Haskell implementation to use to build the package. At
170 most one of these flags may be given. If none is given, the
171 implementation under which the setup script was compiled or
174 .. option:: --with-compiler=path or -w *path*
176 Specify the path to a particular compiler. If given, this must match
177 the implementation selected above. The default is to search for the
178 usual name of the selected implementation.
180 This flag also sets the default value of the :option:`--with-hc-pkg`
181 option to the package tool for this compiler. Check the output of
182 ``runhaskell Setup.hs configure -v`` to ensure that it finds the right package
183 tool (or use :option:`--with-hc-pkg` explicitly).
185 .. option:: --with-hc-pkg=path
187 Specify the path to the package tool, e.g. ``ghc-pkg``. The package
188 tool must be compatible with the compiler specified by
189 :option:`--with-compiler`. If this option is omitted, the default value is
190 determined from the compiler selected.
192 .. option:: --with-prog=path
194 Specify the path to the program *prog*. Any program known to Cabal
195 can be used in place of *prog*. It can either be a fully path or the
196 name of a program that can be found on the program search path. For
197 example: ``--with-ghc=ghc-6.6.1`` or
198 ``--with-cpphs=/usr/local/bin/cpphs``. The full list of accepted
199 programs is not enumerated in this user guide. Rather, run
200 ``cabal install --help`` to view the list.
202 .. option:: --prog-options=options
204 Specify additional options to the program *prog*. Any program known
205 to Cabal can be used in place of *prog*. For example:
206 ``--alex-options="--template=mytemplatedir/"``. The *options* is
207 split into program options based on spaces. Any options containing
208 embedded spaced need to be quoted, for example
209 ``--foo-options='--bar="C:\Program File\Bar"'``. As an alternative
210 that takes only one option at a time but avoids the need to quote,
211 use :option:`--prog-option` instead.
213 .. option:: --prog-option=option
215 Specify a single additional option to the program *prog*. For
216 passing an option that contains embedded spaces, such as a file name
217 with embedded spaces, using this rather than :option:`--prog-options`
218 means you do not need an additional level of quoting. Of course if you
219 are using a command shell you may still need to quote, for example
220 ``--foo-options="--bar=C:\Program File\Bar"``.
222 All of the options passed with either :option:`--prog-options`
223 or :option:`--prog-option` are passed in the order they were
224 specified on the configure command line.
229 The following options govern the location of installed files from a
232 .. option:: --prefix=dir
234 The root of the installation. For example for a global install you
235 might use ``/usr/local`` on a Unix system, or ``C:\Program Files``
236 on a Windows system. The other installation paths are usually
237 subdirectories of *prefix*, but they don't have to be.
239 In the simple build system, *dir* may contain the following path
240 variables: ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``,
241 ``$os``, ``$arch``, ``$abi``, ``$abitag``
243 .. option:: --bindir=dir
245 Executables that the user might invoke are installed here.
247 In the simple build system, *dir* may contain the following path
248 variables: ``$prefix``, ``$pkgid``, ``$pkg``, ``$version``,
249 ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
251 .. option:: --libdir=dir
253 Object-code libraries are installed here.
255 In the simple build system, *dir* may contain the following path
256 variables: ``$prefix``, ``$bindir``, ``$pkgid``, ``$pkg``,
257 ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
260 .. option:: --dynlibdir=dir
262 Dynamic libraries are installed here.
264 By default, this is set to `$libdir/$abi`, which is usually not equal to
265 `$libdir/$libsubdir`.
267 In the simple build system, *dir* may contain the following path
268 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$pkgid``, ``$pkg``,
269 ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
272 .. option:: --libexecdir=dir
274 Executables that are not expected to be invoked directly by the user
277 In the simple build system, *dir* may contain the following path
278 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
279 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
280 ``$arch``, ``$abi``, ``$abitag``
282 .. option:: --datadir=dir
284 Architecture-independent data files are installed here.
286 In the simple build system, *dir* may contain the following path
287 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
288 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
289 ``$arch``, ``$abi``, ``$abitag``
291 .. option:: --sysconfdir=dir
293 Installation directory for the configuration files.
295 In the simple build system, *dir* may contain the following path
296 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
297 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
298 ``$arch``, ``$abi``, ``$abitag``
300 In addition the simple build system supports the following installation
303 .. option:: --libsubdir=dir
305 A subdirectory of *libdir* in which libraries are actually installed. For
306 example, in the simple build system on Unix, the default *libdir* is
307 ``/usr/local/lib``, and *libsubdir* contains the compiler ABI and package
309 e.g. ``x86_64-linux-ghc-8.0.2/mypkg-0.1.0-IxQNmCA7qrSEQNkoHSF7A``, so
310 libraries would be installed in
311 ``/usr/local/lib/x86_64-linux-ghc-8.0.2/mypkg-0.1.0-IxQNmCA7qrSEQNkoHSF7A/``.
313 *dir* may contain the following path variables: ``$pkgid``,
314 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
317 .. option:: --libexecsubdir=dir
319 A subdirectory of *libexecdir* in which private executables are
320 installed. For example, in the simple build system on Unix, the default
321 *libexecdir* is ``/usr/local/libexec``, and *libsubdir* is
322 ``x86_64-linux-ghc-8.0.2/mypkg-0.1.0``, so private executables would be
323 installed in ``/usr/local/libexec/x86_64-linux-ghc-8.0.2/mypkg-0.1.0/``
325 *dir* may contain the following path variables: ``$pkgid``,
326 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
329 .. option:: --datasubdir=dir
331 A subdirectory of *datadir* in which data files are actually
334 *dir* may contain the following path variables: ``$pkgid``,
335 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
338 .. option:: --docdir=dir
340 Documentation files are installed relative to this directory.
342 *dir* may contain the following path variables: ``$prefix``,
343 ``$bindir``, ``$libdir``, ``$libsubdir``, ``$datadir``,
344 ``$datasubdir``, ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``,
345 ``$os``, ``$arch``, ``$abi``, ``$abitag``
347 .. option:: --htmldir=dir
349 HTML documentation files are installed relative to this directory.
351 *dir* may contain the following path variables: ``$prefix``,
352 ``$bindir``, ``$libdir``, ``$libsubdir``, ``$datadir``,
353 ``$datasubdir``, ``$docdir``, ``$pkgid``, ``$pkg``, ``$version``,
354 ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
356 .. option:: --program-prefix=prefix
358 Prepend *prefix* to installed program names.
360 *prefix* may contain the following path variables: ``$pkgid``,
361 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
364 .. option:: --program-suffix=suffix
366 Append *suffix* to installed program names. The most obvious use for
367 this is to append the program's version number to make it possible
368 to install several versions of a program at once:
369 ``--program-suffix='$version'``.
371 *suffix* may contain the following path variables: ``$pkgid``,
372 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
375 Path variables in the simple build system
376 """""""""""""""""""""""""""""""""""""""""
378 For the simple build system, there are a number of variables that can be
379 used when specifying installation paths. The defaults are also specified
380 in terms of these variables. A number of the variables are actually for
381 other paths, like ``$prefix``. This allows paths to be specified
382 relative to each other rather than as absolute paths, which is important
383 for building relocatable packages (see :ref:`prefix independence`).
386 The path variable that stands for the root of the installation. For
387 an installation to be relocatable, all other installation paths must
388 be relative to the ``$prefix`` variable.
390 The path variable that expands to the path given by the :option:`--bindir`
391 configure option (or the default).
393 As above but for :option:`--libdir`
395 As above but for :option:`--libsubdir`
397 As above but for :option:`--dynlibdir`
399 As above but for :option:`--datadir`
401 As above but for :option:`--datasubdir`
403 As above but for :option:`--docdir`
405 The name and version of the package, e.g. ``mypkg-0.2``
407 The name of the package, e.g. ``mypkg``
409 The version of the package, e.g. ``0.2``
411 The compiler being used to build the package, e.g. ``ghc-6.6.1``
413 The operating system of the computer being used to build the
414 package, e.g. ``linux``, ``windows``, ``osx``, ``freebsd`` or
417 The architecture of the computer being used to build the package,
418 e.g. ``i386``, ``x86_64``, ``ppc`` or ``sparc``
420 An optional tag that a compiler can use for telling incompatible
421 ABI's on the same architecture apart. GHCJS encodes the underlying
422 GHC version in the ABI tag.
424 A shortcut for getting a path that completely identifies the
425 platform in terms of binary compatibility. Expands to the same value
426 as ``$arch-$os-compiler-$abitag`` if the compiler uses an abi tag,
427 ``$arch-$os-$compiler`` if it doesn't.
429 Paths in the simple build system
430 """"""""""""""""""""""""""""""""
432 For the simple build system, the following defaults apply:
434 .. list-table:: Default installation paths
439 * - :option:`--prefix` (global)
441 - ``%PROGRAMFILES%\Haskell``
442 * - :option:`--prefix` (per-user)
444 - ``%APPDATA%\cabal``
445 * - :option:`--bindir`
448 * - :option:`--libdir`
451 * - :option:`--libsubdir` (others)
452 - ``$pkgid/$compiler``
453 - ``$pkgid\$compiler``
454 * - :option:`--dynlibdir`
457 * - :option:`--libexecdir`
458 - ``$prefix/libexec``
460 * - :option:`--datadir` (executable)
463 * - :option:`--datadir` (library)
465 - ``%PROGRAMFILES%\Haskell``
466 * - :option:`--datasubdir`
469 * - :option:`--docdir`
470 - ``$datadir/doc/$pkgid``
471 - ``$prefix\doc\$pkgid``
472 * - :option:`--sysconfdir`
475 * - :option:`--htmldir`
478 * - :option:`--program-prefix`
481 * - :option:`--program-suffix`
485 .. _prefix independence:
490 On Windows it is possible to obtain the pathname of the running program.
491 This means that we can construct an installable executable package that
492 is independent of its absolute install location. The executable can find
493 its auxiliary files by finding its own path and knowing the location of
494 the other files relative to ``$bindir``. Prefix independence is
495 particularly useful: it means the user can choose the install location
496 (i.e. the value of ``$prefix``) at install-time, rather than having to
497 bake the path into the binary when it is built.
499 In order to achieve this, we require that for an executable on Windows,
500 all of ``$bindir``, ``$libdir``, ``$dynlibdir``, ``$datadir`` and ``$libexecdir`` begin
501 with ``$prefix``. If this is not the case then the compiled executable
502 will have baked-in all absolute paths.
504 The application need do nothing special to achieve prefix independence.
505 If it finds any files using ``getDataFileName`` and the :ref:`other functions
506 provided for the purpose <accessing-data-files>`,
507 the files will be accessed relative to the location of the current
510 A library cannot (currently) be prefix independent, because it will be
511 linked into an executable whose file system location bears no relation
512 to the library package.
514 .. _controlling flag assignments:
516 Controlling Flag Assignments
517 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
519 Flag assignments (see :ref:`resolution-of-conditions-and-flags`)
520 can be controlled with the following command line options.
522 .. option:: -f flagname or -f -flagname
524 Force the specified flag to ``true`` or ``false`` (if preceded with
525 a ``-``). Later specifications for the same flags will override
526 earlier, i.e., specifying ``-fdebug -f-debug`` is equivalent to
529 .. option:: --flags=flagspecs
531 Same as ``-f``, but allows specifying multiple flag assignments at
532 once. The parameter is a space-separated list of flag names (to
533 force a flag to ``true``), optionally preceded by a ``-`` (to force
534 a flag to ``false``). For example,
535 ``--flags="debug -feature1 feature2"`` is equivalent to
536 ``-fdebug -f-feature1 -ffeature2``.
541 .. option:: --enable-tests
543 Build the test suites defined in the package description file during
544 the ``build`` stage. Check for dependencies required by the test
545 suites. If the package is configured with this option, it will be
546 possible to run the test suites with the ``test`` command after the
549 .. option:: --disable-tests
551 (default) Do not build any test suites during the ``build`` stage.
552 Do not check for dependencies required only by the test suites. It
553 will not be possible to invoke the ``test`` command without
554 reconfiguring the package.
556 .. option:: --enable-coverage
558 Build libraries and executables (including test suites) with Haskell
559 Program Coverage enabled. Running the test suites will automatically
560 generate coverage reports with HPC.
562 .. option:: --disable-coverage
564 (default) Do not enable Haskell Program Coverage.
566 Miscellaneous options
567 ^^^^^^^^^^^^^^^^^^^^^
571 Does a per-user installation. This changes the `default installation
572 prefix <#paths-in-the-simple-build-system>`__. It also allow
573 dependencies to be satisfied by the user's package database, in
574 addition to the global database. This also implies a default of
575 ``--user`` for any subsequent ``install`` command, as packages
576 registered in the global database should not depend on packages
577 registered in a user's database.
581 (default) Does a global installation. In this case package
582 dependencies must be satisfied by the global package database. All
583 packages in the user's package database will be ignored. Typically
584 the final installation step will require administrative privileges.
586 .. option:: --package-db=db
588 Allows package dependencies to be satisfied from this additional
589 package database *db* in addition to the global package database.
590 All packages in the user's package database will be ignored. The
591 interpretation of *db* is implementation-specific. Typically it will
592 be a file or directory. Not all implementations support arbitrary
595 This pushes an extra db onto the db stack. The :option:`--global` and
596 :option:`--user` mode switches add the respective [Global] and [Global,
597 User] dbs to the initial stack. There is a compiler-implementation
598 constraint that the global db must appear first in the stack, and if
599 the user one appears at all, it must appear immediately after the
602 To reset the stack, use ``--package-db=clear``.
604 .. option:: --ipid=ipid
606 Specifies the *installed package identifier* of the package to be
607 built; this identifier is passed on to GHC and serves as the basis
608 for linker symbols and the ``id`` field in a ``ghc-pkg``
609 registration. When a package has multiple components, the actual
610 component identifiers are derived off of this identifier. E.g., an
611 internal library ``foo`` from package ``p-0.1-abcd`` will get the
612 identifier ``p-0.1-abcd-foo``.
614 .. option:: --cid=cid
616 Specifies the *component identifier* of the component being built;
617 this is only valid if you are configuring a single component.
619 .. option:: --enable-optimization[=n] or -O [n]
621 (default) Build with optimization flags (if available). This is
622 appropriate for production use, taking more time to build faster
623 libraries and programs.
625 The optional *n* value is the optimisation level. Some compilers
626 support multiple optimisation levels. The range is 0 to 2. Level 0
627 is equivalent to :option:`--disable-optimization`, level 1 is the
628 default if no *n* parameter is given. Level 2 is higher optimisation
629 if the compiler supports it. Level 2 is likely to lead to longer
630 compile times and bigger generated code.
632 When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
634 .. option:: --disable-optimization
636 Build without optimization. This is suited for development: building
637 will be quicker, but the resulting library or programs will be
640 .. option:: --enable-profiling
642 Build libraries and executables with profiling enabled (for
643 compilers that support profiling as a separate mode). For this to
644 work, all libraries used by this package must also have been built
645 with profiling support. For libraries this involves building an
646 additional instance of the library in addition to the normal
647 non-profiling instance. For executables it changes the single
648 executable to be built in profiling mode.
650 This flag covers both libraries and executables, but can be
651 overridden by the :option:`--enable-library-profiling` flag.
653 See also the :option:`--profiling-detail` flag below.
655 .. option:: --disable-profiling
657 (default) Do not enable profiling in generated libraries and
660 .. option:: --enable-library-profiling or -p
662 As with :option:`--enable-profiling` above, but it applies only for
663 libraries. So this generates an additional profiling instance of the
664 library in addition to the normal non-profiling instance.
666 The :option:`--enable-profiling` flag controls the profiling mode for both
667 libraries and executables, but if different modes are desired for
668 libraries versus executables then use :option:`--enable-library-profiling`
671 .. option:: --disable-library-profiling
673 (default) Do not generate an additional profiling version of the library.
675 .. option:: --profiling-detail[=level]
677 Some compilers that support profiling, notably GHC, can allocate
678 costs to different parts of the program and there are different
679 levels of granularity or detail with which this can be done. In
680 particular for GHC this concept is called "cost centers", and GHC
681 can automatically add cost centers, and can do so in different ways.
683 This flag covers both libraries and executables, but can be
684 overridden by the :option:`--library-profiling-detail` flag.
686 Currently this setting is ignored for compilers other than GHC. The
687 levels that cabal currently supports are:
690 For GHC this uses ``exported-functions`` for libraries and
691 ``toplevel-functions`` for executables.
693 No costs will be assigned to any code within this component.
695 Costs will be assigned at the granularity of all top level
696 functions exported from each module. In GHC specifically, this
697 is for non-inline functions.
699 Costs will be assigned at the granularity of all top level
700 functions in each module, whether they are exported from the
701 module or not. In GHC specifically, this is for non-inline
704 Costs will be assigned at the granularity of all functions in
705 each module, whether top level or local. In GHC specifically,
706 this is for non-inline toplevel or where-bound functions or
709 This flag is new in Cabal-1.24. Prior versions used the equivalent
712 .. option:: --library-profiling-detail[=level]
714 As with :option:`--profiling-detail` above, but it applies only for
717 The level for both libraries and executables is set by the
718 :option:`--profiling-detail` flag, but if different levels are desired
719 for libraries versus executables then use
720 :option:`--library-profiling-detail` as well.
722 .. option:: --enable-library-vanilla
724 (default) Build ordinary libraries (as opposed to profiling
725 libraries). This is independent of the
726 :option:`--enable-library-profiling` option. If you enable both, you get
729 .. option:: --disable-library-vanilla
731 Do not build ordinary libraries. This is useful in conjunction with
732 :option:`--enable-library-profiling` to build only profiling libraries,
733 rather than profiling and ordinary libraries.
735 .. option:: --enable-library-for-ghci
737 (default) Build libraries suitable for use with GHCi.
739 .. option:: --disable-library-for-ghci
741 Not all platforms support GHCi and indeed on some platforms, trying
742 to build GHCi libs fails. In such cases this flag can be used as a
745 .. option:: --enable-split-objs
747 Use the GHC ``-split-objs`` feature when building the library. This
748 reduces the final size of the executables that use the library by
749 allowing them to link with only the bits that they use rather than
750 the entire library. The downside is that building the library takes
751 longer and uses considerably more memory.
753 .. option:: --disable-split-objs
755 (default) Do not use the GHC ``-split-objs`` feature. This makes
756 building the library quicker but the final executables that use the
757 library will be larger.
759 .. option:: --enable-executable-stripping
761 (default) When installing binary executable programs, run the
762 ``strip`` program on the binary. This can considerably reduce the
763 size of the executable binary file. It does this by removing
764 debugging information and symbols. While such extra information is
765 useful for debugging C programs with traditional debuggers it is
766 rarely helpful for debugging binaries produced by Haskell compilers.
768 Not all Haskell implementations generate native binaries. For such
769 implementations this option has no effect.
771 .. option:: --disable-executable-stripping
773 Do not strip binary executables during installation. You might want
774 to use this option if you need to debug a program using gdb, for
775 example if you want to debug the C parts of a program containing
776 both Haskell and C code. Another reason is if your are building a
777 package for a system which has a policy of managing the stripping
778 itself (such as some Linux distributions).
780 .. option:: --enable-shared
782 Build shared library. This implies a separate compiler run to
783 generate position independent code as required on most platforms.
785 .. option:: --disable-shared
787 (default) Do not build shared library.
789 .. option:: --enable-static
791 Build a static library. This passes ``-staticlib`` to GHC (available
792 for iOS, and with 8.4 more platforms). The result is an archive ``.a``
793 containing all dependent haskell libararies combined.
795 .. option:: --disable-static
797 (default) Do not build a static library.
799 .. option:: --enable-executable-dynamic
801 Link dependent Haskell libraries into executables dynamically.
802 The executable's library dependencies must have been
803 built as shared objects. This implies :option:`--enable-shared`
804 unless :option:`--disable-shared` is explicitly specified.
806 .. option:: --disable-executable-dynamic
808 (default) Link dependent Haskell libraries into executables statically.
809 Non-Haskell (C) libraries are still linked dynamically, including libc,
810 so the result is still not a fully static executable
811 unless :option:`--enable-executable-static` is given.
813 .. option:: --enable-executable-static
815 Build fully static executables.
816 This links all dependent libraries into executables statically,
819 .. option:: --disable-executable-static
821 (default) Do not build fully static executables.
823 .. option:: --configure-option=str
825 An extra option to an external ``configure`` script, if one is used
826 (see the section on :ref:`system-dependent parameters`).
827 There can be several of these options.
829 .. option:: --extra-include-dirs[=dir]
831 An extra directory to search for C header files. You can use this
832 flag multiple times to get a list of directories.
834 You might need to use this flag if you have standard system header
835 files in a non-standard location that is not mentioned in the
836 package's ``.cabal`` file. Using this option has the same effect as
837 appending the directory *dir* to the ``include-dirs`` field in each
838 library and executable in the package's ``.cabal`` file. The
839 advantage of course is that you do not have to modify the package at
840 all. These extra directories will be used while building the package
841 and for libraries it is also saved in the package registration
842 information and used when compiling modules that use the library.
844 .. option:: --extra-lib-dirs[=dir]
846 An extra directory to search for system libraries files. You can use
847 this flag multiple times to get a list of directories.
849 .. option:: --extra-framework-dirs[=dir]
851 An extra directory to search for frameworks (OS X only). You can use
852 this flag multiple times to get a list of directories.
854 You might need to use this flag if you have standard system
855 libraries in a non-standard location that is not mentioned in the
856 package's ``.cabal`` file. Using this option has the same affect as
857 appending the directory *dir* to the ``extra-lib-dirs`` field in
858 each library and executable in the package's ``.cabal`` file. The
859 advantage of course is that you do not have to modify the package at
860 all. These extra directories will be used while building the package
861 and for libraries it is also saved in the package registration
862 information and used when compiling modules that use the library.
864 .. option:: --dependency[=pkgname=ipid]
866 Specify that a particular dependency should used for a particular
867 package name. In particular, it declares that any reference to
868 *pkgname* in a :pkg-field:`build-depends` should be resolved to
871 .. option:: --exact-configuration
873 This changes Cabal to require every dependency be explicitly
874 specified using :option:`--dependency`, rather than use Cabal's (very
875 simple) dependency solver. This is useful for programmatic use of
876 Cabal's API, where you want to error if you didn't specify enough
877 :option:`--dependency` flags.
880 .. option:: --constraint=constraint
882 Restrict solutions involving a package to given version
883 bounds, flag settings, and other properties. For example, to
884 consider only install plans that use version 2.1 of ``bar``
885 or do not use ``bar`` at all, write:
889 $ cabal install --constraint="bar == 2.1"
891 Version bounds have the same syntax as :pkg-field:`build-depends`.
892 As a special case, the following prevents ``bar`` from being
897 # Note: this is just syntax sugar for '> 1 && < 1', and is
898 # supported by build-depends.
899 $ cabal install --constraint="bar -none"
901 You can also specify flag assignments:
905 # Require bar to be installed with the foo flag turned on and
906 # the baz flag turned off.
907 $ cabal install --constraint="bar +foo -baz"
909 To specify multiple constraints, you may pass the
910 ``constraint`` option multiple times.
912 There are also some more specialized constraints, which most people
913 don't generally need:
917 # Require that a version of bar be used that is already installed in
918 # the global package database.
919 $ cabal install --constraint="bar installed"
921 # Require the local source copy of bar to be used.
922 # (Note: By default, if we have a local package we will
923 # automatically use it, so it will generally not be necessary to
925 $ cabal install --constraint="bar source"
927 # Require that bar have test suites and benchmarks enabled.
928 $ cabal install --constraint="bar test" --constraint="bar bench"
930 By default, constraints only apply to build dependencies
931 (:pkg-field:`build-depends`), build dependencies of build
932 dependencies, and so on. Constraints normally do not apply to
933 dependencies of the ``Setup.hs`` script of any package
934 (:pkg-field:`custom-setup:setup-depends`) nor do they apply to build tools
935 (:pkg-field:`build-tool-depends`) or the dependencies of build
936 tools. To explicitly apply a constraint to a setup or build
937 tool dependency, you can add a qualifier to the constraint as
942 # Example use of the 'any' qualifier. This constraint
943 # applies to package bar anywhere in the dependency graph.
944 $ cabal install --constraint="any.bar == 1.0"
948 # Example uses of 'setup' qualifiers.
950 # This constraint applies to package bar when it is a
951 # dependency of any Setup.hs script.
952 $ cabal install --constraint="setup.bar == 1.0"
954 # This constraint applies to package bar when it is a
955 # dependency of the Setup.hs script of package foo.
956 $ cabal install --constraint="foo:setup.bar == 1.0"
958 .. TODO: Uncomment this example once we decide on a syntax for 'exe'.
959 .. # Example use of the 'exe' (executable build tool)
960 # qualifier. This constraint applies to package baz when it
961 # is a dependency of the build tool bar being used to
963 $ cabal install --constraint="foo:bar:exe.baz == 1.0"
965 .. option:: --disable-response-files
967 Enable workaround for older versions of programs such as ``ar`` or
968 ``ld`` that do not support response file arguments (i.e. ``@file``
969 arguments). You may want this flag only if you specify custom ar
970 executable. For system ``ar`` or the one bundled with ``ghc`` on
971 Windows the ``cabal`` should do the right thing and hence should
972 normally not require this flag.
976 runhaskell Setup.hs build
977 -------------------------
979 Perform any preprocessing or compilation needed to make this package
980 ready for installation.
982 This command takes the following options:
984 .. program:: runhaskell Setup.hs build
986 .. option:: --prog-options=options, --prog-option=option
988 These are mostly the same as the `options configure
989 step <#setup-configure>`__. Unlike the options specified at the
990 configure step, any program options specified at the build step are
991 not persistent but are used for that invocation only. The options
992 specified at the build step are in addition not in replacement of
993 any options specified at the configure step.
997 runhaskell Setup.hs haddock
998 ---------------------------
1000 .. program:: runhaskell Setup.hs haddock
1002 Build the documentation for the package using Haddock_.
1003 By default, only the documentation for the exposed modules is generated
1004 (but see the :option:`--executables` and :option:`--internal` flags below).
1006 This command takes the following options:
1008 .. option:: --hoogle
1010 Generate a file ``dist/doc/html/``\ *pkgid*\ ``.txt``, which can be
1011 converted by Hoogle_ into a
1012 database for searching. This is equivalent to running Haddock_
1013 with the ``--hoogle`` flag.
1015 .. option:: --html-location=url
1017 Specify a template for the location of HTML documentation for
1018 prerequisite packages. The substitutions (`see
1019 listing <#paths-in-the-simple-build-system>`__) are applied to the
1020 template to obtain a location for each package, which will be used
1021 by hyperlinks in the generated documentation. For example, the
1022 following command generates links pointing at Hackage_ pages:
1026 $ runhaskell Setup.hs haddock \
1027 --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
1029 Here the argument is quoted to prevent substitution by the shell. If
1030 this option is omitted, the location for each package is obtained
1031 using the package tool (e.g. ``ghc-pkg``).
1033 .. option:: --executables
1035 Also run Haddock_ for the modules of all the executable programs. By default
1036 Haddock_ is run only on the exported modules.
1038 .. option:: --internal
1040 Run Haddock_ for the all
1041 modules, including unexposed ones, and make
1042 Haddock_ generate documentation
1043 for unexported symbols as well.
1045 .. option:: --css=path
1047 The argument *path* denotes a CSS file, which is passed to
1048 Haddock_ and used to set the
1049 style of the generated documentation. This is only needed to
1050 override the default style that
1053 .. option:: --hyperlink-source
1055 Generate Haddock_ documentation integrated with HsColour_ . First,
1056 HsColour_ is run to generate colourised code. Then Haddock_ is run to
1057 generate HTML documentation. Each entity shown in the documentation is
1058 linked to its definition in the colourised code.
1060 .. option:: --hscolour-css=path
1062 The argument *path* denotes a CSS file, which is passed to HsColour_ as in
1066 $ runhaskell Setup.hs hscolour --css=*path*
1070 runhaskell Setup.hs hscolour
1071 ----------------------------
1073 Produce colourised code in HTML format using HsColour_. Colourised code for
1074 exported modules is put in ``dist/doc/html/``\ *pkgid*\ ``/src``.
1076 This command takes the following options:
1078 .. program:: runhaskell Setup.hs hscolour
1080 .. option:: --executables
1082 Also run HsColour_ on the sources of all executable programs. Colourised
1083 code is put in ``dist/doc/html/``\ *pkgid*/*executable*\ ``/src``.
1085 .. option:: --css=path
1087 Use the given CSS file for the generated HTML files. The CSS file
1088 defines the colours used to colourise code. Note that this copies
1089 the given CSS file to the directory with the generated HTML files
1090 (renamed to ``hscolour.css``) rather than linking to it.
1094 runhaskell Setup.hs install
1095 ---------------------------
1097 .. program:: runhaskell Setup.hs install
1099 Copy the files into the install locations and (for library packages)
1100 register the package with the compiler, i.e. make the modules it
1101 contains available to programs.
1103 The `install locations <#installation-paths>`__ are determined by
1104 options to `runhaskell Setup.hs configure`_.
1106 This command takes the following options:
1108 .. option:: --global
1110 Register this package in the system-wide database. (This is the
1111 default, unless the :option:`runhaskell Setup.hs configure --user` option was supplied
1112 to the ``configure`` command.)
1116 Register this package in the user's local package database. (This is
1117 the default if the :option:`runhaskell Setup.hs configure --user` option was supplied
1118 to the ``configure`` command.)
1122 runhaskell Setup.hs copy
1123 ------------------------
1125 Copy the files without registering them. This command is mainly of use
1126 to those creating binary packages.
1128 This command takes the following option:
1130 .. program:: runhaskell Setup.hs copy
1132 .. option:: --destdir=path
1134 Specify the directory under which to place installed files. If this is
1135 not given, then the root directory is assumed.
1139 runhaskell Setup.hs register
1140 ----------------------------
1142 Register this package with the compiler, i.e. make the modules it
1143 contains available to programs. This only makes sense for library
1144 packages. Note that the ``install`` command incorporates this action.
1145 The main use of this separate command is in the post-installation step
1146 for a binary package.
1148 This command takes the following options:
1150 .. program:: runhaskell Setup.hs register
1152 .. option:: --global
1154 Register this package in the system-wide database. (This is the
1159 Register this package in the user's local package database.
1161 .. option:: --gen-script
1163 Instead of registering the package, generate a script containing
1164 commands to perform the registration. On Unix, this file is called
1165 ``register.sh``, on Windows, ``register.bat``. This script might be
1166 included in a binary bundle, to be run after the bundle is unpacked
1167 on the target system.
1169 .. option:: --gen-pkg-config[=path]
1171 Instead of registering the package, generate a package registration
1172 file (or directory, in some circumstances). This only applies to
1173 compilers that support package registration files which at the
1174 moment is only GHC. The file should be used with the compiler's
1175 mechanism for registering packages. This option is mainly intended
1176 for packaging systems. If possible use the :option:`--gen-script` option
1177 instead since it is more portable across Haskell implementations.
1178 The *path* is optional and can be used to specify a particular
1179 output file to generate. Otherwise, by default the file is the
1180 package name and version with a ``.conf`` extension.
1182 This option outputs a directory if the package requires multiple
1183 registrations: this can occur if internal/convenience libraries are
1184 used. These configuration file names are sorted so that they can be
1185 registered in order.
1187 .. option:: --inplace
1189 Registers the package for use directly from the build tree, without
1190 needing to install it. This can be useful for testing: there's no
1191 need to install the package after modifying it, just recompile and
1194 This flag does not create a build-tree-local package database. It
1195 still registers the package in one of the user or global databases.
1197 However, there are some caveats. It only works with GHC (currently).
1198 It only works if your package doesn't depend on having any
1199 supplemental files installed --- plain Haskell libraries should be
1202 .. _setup-unregister:
1204 runhaskell Setup.hs unregister
1205 ------------------------------
1207 .. program:: runhaskell Setup.hs unregister
1209 Deregister this package with the compiler.
1211 This command takes the following options:
1213 .. option:: --global
1215 Deregister this package in the system-wide database. (This is the
1220 Deregister this package in the user's local package database.
1222 .. option:: --gen-script
1224 Instead of deregistering the package, generate a script containing
1225 commands to perform the deregistration. On Unix, this file is called
1226 ``unregister.sh``, on Windows, ``unregister.bat``. This script might
1227 be included in a binary bundle, to be run on the target system.
1231 runhaskell Setup.hs clean
1232 -------------------------
1234 Remove any local files created during the ``configure``, ``build``,
1235 ``haddock``, ``register`` or ``unregister`` steps, and also any files
1236 and directories listed in the :pkg-field:`extra-tmp-files` field.
1238 This command takes the following options:
1240 .. program:: runhaskell Setup.hs clean
1242 .. option:: --save-configure, -s
1244 Keeps the configuration information so it is not necessary to run
1245 the configure step again before building.
1249 runhaskell Setup.hs test
1250 ------------------------
1252 Run the test suites specified in the package description file. Aside
1253 from the following flags, Cabal accepts the name of one or more test
1254 suites on the command line after ``test``. When supplied, Cabal will run
1255 only the named test suites, otherwise, Cabal will run all test suites in
1258 .. program:: runhaskell Setup.hs test
1260 .. option:: --builddir=dir
1262 The directory where Cabal puts generated build files (default:
1263 ``dist``). Test logs will be located in the ``test`` subdirectory.
1265 .. option:: --human-log=path
1267 The template used to name human-readable test logs; the path is
1268 relative to ``dist/test``. By default, logs are named according to
1269 the template ``$pkgid-$test-suite.log``, so that each test suite
1270 will be logged to its own human-readable log file. Template
1271 variables allowed are: ``$pkgid``, ``$compiler``, ``$os``,
1272 ``$arch``, ``$abi``, ``$abitag``, ``$test-suite``, and ``$result``.
1274 .. option:: --machine-log=path
1276 The path to the machine-readable log, relative to ``dist/test``. The
1277 default template is ``$pkgid.log``. Template variables allowed are:
1278 ``$pkgid``, ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
1281 .. option:: --show-details=filter
1283 Determines if the results of individual test cases are shown on the
1284 terminal. May be ``always`` (always show), ``never`` (never show),
1285 ``failures`` (show only failed results), or ``streaming`` (show all
1286 results in real time).
1288 .. option:: --test-options=options
1290 Give extra options to the test executables.
1292 .. option:: --test-option=option
1294 Give an extra option to the test executables. There is no need to
1295 quote options containing spaces because a single option is assumed,
1296 so options will not be split on spaces.
1298 .. option:: --test-wrapper=path
1300 The wrapper script/application used to setup and tear down the test
1301 execution context. The text executable path and test arguments are
1302 passed as arguments to the wrapper and it is expected that the wrapper
1303 will return the test's return code, as well as a copy of stdout/stderr.
1307 runhaskell Setup.hs bench
1308 -------------------------
1310 Run the benchmarks specified in the package description file. Aside
1311 from the following flags, Cabal accepts the name of one or more benchmarks
1312 on the command line after ``bench``. When supplied, Cabal will run
1313 only the named benchmarks, otherwise, Cabal will run all benchmarks in
1316 .. option:: --benchmark-options=options
1318 Give extra options to the benchmark executables.
1320 .. option:: --benchmark-option=option
1322 Give an extra option to the benchmark executables. There is no need to
1323 quote options containing spaces because a single option is assumed,
1324 so options will not be split on spaces.
1328 runhaskell Setup.hs sdist
1329 -------------------------
1331 Create a system- and compiler-independent source distribution in a file
1332 *package*-*version*\ ``.tar.gz`` in the ``dist`` subdirectory, for
1333 distribution to package builders. When unpacked, the commands listed in
1334 this section will be available.
1336 The files placed in this distribution are the package description file,
1337 the setup script, the sources of the modules named in the package
1338 description file, and files named in the ``license-file``, ``main-is``,
1339 ``c-sources``, ``asm-sources``, ``cmm-sources``, ``js-sources``,
1340 ``data-files``, ``extra-source-files`` and ``extra-doc-files`` fields.
1342 This command takes the following option:
1344 .. program:: runhaskell Setup.hs sdist
1346 .. option:: --snapshot
1348 Append today's date (in "YYYYMMDD" format) to the version number for
1349 the generated source package. The original package is unaffected.
1352 .. include:: references.inc