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
12 builds. However, the documentation of the low level interface below may be helpful
13 to high level interface users as well, because it delves into internal details
14 common to both and omitted elsewhere.
18 $ runhaskell Setup.hs [command] [option...]
20 For the summary of the ``Setup.hs`` script's command syntax, run:
24 $ runhaskell Setup.hs --help
26 Building and installing a system package
27 ----------------------------------------
31 $ runhaskell Setup.hs configure --ghc
32 $ runhaskell Setup.hs build
33 $ runhaskell Setup.hs install
35 The first line readies the system to build the tool using GHC; for
36 example, it checks that GHC exists on the system. The second line
37 performs the actual building, while the last both copies the build
38 results to some permanent place and registers the package with GHC.
42 Global installing of packages is not recommended.
43 The :ref:`nix-style-builds` is the preferred way of building and installing
46 Creating a binary package
47 -------------------------
49 When creating binary packages (e.g. for Red Hat or Debian) one needs to
50 create a tarball that can be sent to another system for unpacking in the
55 $ runhaskell Setup.hs configure --prefix=/usr
56 $ runhaskell Setup.hs build
57 $ runhaskell Setup.hs copy --destdir=/tmp/mypkg
58 $ tar -czf mypkg.tar.gz /tmp/mypkg/
60 If the package contains a library, you need two additional steps:
64 $ runhaskell Setup.hs register --gen-script
65 $ runhaskell Setup.hs unregister --gen-script
67 This creates shell scripts ``register.sh`` and ``unregister.sh``, which
68 must also be sent to the target system. After unpacking there, the
69 package must be registered by running the ``register.sh`` script. The
70 ``unregister.sh`` script would be used in the uninstall procedure of the
71 package. Similar steps may be used for creating binary packages for
74 The following options are understood by all commands:
78 .. option:: --help, -h or -?
80 List the available options for the command.
82 .. option:: --verbose=n or -v n
84 Set the verbosity level (0-3). The normal level is 1; a missing *n*
87 There is also an extended version of this command which can be
88 used to fine-tune the verbosity of output. It takes the
89 form ``[silent|normal|verbose|debug]``\ *flags*, where *flags*
90 is a list of ``+`` flags which toggle various aspects of
91 output. At the moment, only ``+callsite`` and ``+callstack``
92 are supported, which respectively toggle call site and call
93 stack printing (these are only supported if Cabal
94 is built with a sufficiently recent GHC.)
96 The various commands and the additional options they support are
97 described below. In the simple build infrastructure, any other options
98 will be reported as errors.
102 runhaskell Setup.hs configure
103 -----------------------------
105 .. program:: runhaskell Setup.hs configure
107 Prepare to build the package. Typically, this step checks that the
108 target platform is capable of building the package, and discovers
109 platform-specific features that are needed during the build.
111 The user may also adjust the behaviour of later stages using the options
112 listed in the following subsections. In the simple build infrastructure,
113 the values supplied via these options are recorded in a private file
114 read by later stages.
116 If a user-supplied ``configure`` script is run (see the section on
117 :ref:`system-dependent parameters` or
118 on :ref:`more-complex-packages`), it is
119 passed the :option:`--with-hc-pkg`, :option:`--prefix`, :option:`--bindir`,
120 :option:`--libdir`, :option:`--dynlibdir`, :option:`--datadir`, :option:`--libexecdir` and
121 :option:`--sysconfdir` options. In addition the value of the
122 :option:`--with-compiler` option is passed in a :option:`--with-hc-pkg` option
123 and all options specified with :option:`--configure-option` are passed on.
126 `GNU autoconf places restrictions on paths, including the directory
127 that the package is built from.
128 <https://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions>`_
129 The errors produced when this happens can be obscure; Cabal attempts to
130 detect and warn in this situation, but it is not perfect.
132 In Cabal 2.0, support for a single positional argument was added to
133 ``runhaskell Setup.hs configure`` This makes Cabal configure the specific component to
134 be configured. Specified names can be qualified with ``lib:`` or
135 ``exe:`` in case just a name is ambiguous (as would be the case for a
136 package named ``p`` which has a library and an executable named ``p``.)
137 This has the following effects:
139 - Subsequent invocations of ``cabal build``, ``register``, etc. operate only
140 on the configured component.
142 - Cabal requires all "internal" dependencies (e.g., an executable
143 depending on a library defined in the same package) must be found in
144 the set of databases via :option:`--package-db` (and related flags): these
145 dependencies are assumed to be up-to-date. A dependency can be
146 explicitly specified using :option:`--dependency` simply by giving the name
147 of the sublibrary; e.g., the dependency for a sublibrary
148 named ``foo`` is given as
149 ``--dependency=Lib:foo=foo-0.1-abc``.
151 - Only the dependencies needed for the requested component are
152 required. Similarly, when :option:`--exact-configuration` is specified,
153 it's only necessary to specify :option:`--dependency` for the component.
154 (As mentioned previously, you *must* specify internal dependencies as
157 - Internal ``build-tool-depends`` and ``build-tools`` dependencies are expected
158 to be in the ``PATH`` upon subsequent invocations of ``setup``.
160 Full details can be found in the `Componentized Cabal
161 proposal <https://github.com/ezyang/ghc-proposals/blob/master/proposals/0000-componentized-cabal.rst>`__.
163 Programs used for building
164 ^^^^^^^^^^^^^^^^^^^^^^^^^^
166 The following options govern the programs used to process the source
169 .. option:: -g, --ghc
174 Specify which Haskell implementation to use to build the package. At
175 most one of these flags may be given. If none is given, the
176 implementation under which the setup script was compiled or
179 .. option:: -w PATH or -wPATH, --with-compiler=PATH
181 Specify the path to a particular compiler. If given, this must match
182 the implementation selected above. The default is to search for the
183 usual name of the selected implementation.
185 This flag also sets the default value of the :option:`--with-hc-pkg`
186 option to the package tool for this compiler. Check the output of
187 ``runhaskell Setup.hs configure -v`` to ensure that it finds the right package
188 tool (or use :option:`--with-hc-pkg` explicitly).
190 .. option:: --with-hc-pkg=PATH
192 Specify the path to the package tool, e.g. ``ghc-pkg``. The package
193 tool must be compatible with the compiler specified by
194 :option:`--with-compiler`. If this option is omitted, the default value is
195 determined from the compiler selected.
197 .. option:: --with-PROG=PATH
199 Specify the path to the program *prog*. Any program known to Cabal
200 can be used in place of *prog*. It can either be a fully path or the
201 name of a program that can be found on the program search path. For
202 example: ``--with-ghc=ghc-6.6.1`` or
203 ``--with-cpphs=/usr/local/bin/cpphs``. The full list of accepted
204 programs is not enumerated in this user guide. Rather, run
205 ``cabal install --help`` to view the list.
207 .. option:: --PROG-options=OPTS
209 Specify additional options to the program *prog*. Any program known
210 to Cabal can be used in place of *prog*. For example:
211 ``--alex-options="--template=mytemplatedir/"``. The *options* is
212 split into program options based on spaces. Any options containing
213 embedded spaced need to be quoted, for example
214 ``--foo-options='--bar="C:\Program File\Bar"'``. As an alternative
215 that takes only one option at a time but avoids the need to quote,
216 use :option:`--PROG-option` instead.
218 .. option:: --PROG-option=OPT
220 Specify a single additional option to the program *prog*. For
221 passing an option that contains embedded spaces, such as a file name
222 with embedded spaces, using this rather than :option:`--PROG-options`
223 means you do not need an additional level of quoting. Of course if you
224 are using a command shell you may still need to quote, for example
225 ``--foo-options="--bar=C:\Program File\Bar"``.
227 All of the options passed with either :option:`--PROG-options`
228 or :option:`--PROG-option` are passed in the order they were
229 specified on the configure command line.
234 The following options govern the location of installed files from a
237 .. option:: --prefix=DIR
239 The root of the installation. For example for a global install you
240 might use ``/usr/local`` on a Unix system, or ``C:\Program Files``
241 on a Windows system. The other installation paths are usually
242 subdirectories of *prefix*, but they don't have to be.
244 In the simple build system, *dir* may contain the following path
245 variables: ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``,
246 ``$os``, ``$arch``, ``$abi``, ``$abitag``
248 .. option:: --bindir=DIR
250 Executables that the user might invoke are installed here.
252 In the simple build system, *dir* may contain the following path
253 variables: ``$prefix``, ``$pkgid``, ``$pkg``, ``$version``,
254 ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
256 .. option:: --libdir=DIR
258 Object-code libraries are installed here.
260 In the simple build system, *dir* may contain the following path
261 variables: ``$prefix``, ``$bindir``, ``$pkgid``, ``$pkg``,
262 ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
265 .. option:: --dynlibdir=DIR
267 Dynamic libraries are installed here.
269 By default, this is set to `$libdir/$abi`, which is usually not equal to
270 `$libdir/$libsubdir`.
272 In the simple build system, *dir* may contain the following path
273 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$pkgid``, ``$pkg``,
274 ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
277 .. option:: --libexecdir=DIR
279 Executables that are not expected to be invoked directly by the user
282 In the simple build system, *dir* may contain the following path
283 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
284 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
285 ``$arch``, ``$abi``, ``$abitag``
287 .. option:: --datadir=DIR
289 Architecture-independent data files are installed here.
291 In the simple build system, *dir* may contain the following path
292 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
293 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
294 ``$arch``, ``$abi``, ``$abitag``
296 .. option:: --sysconfdir=DIR
298 Installation directory for the configuration files.
300 In the simple build system, *dir* may contain the following path
301 variables: ``$prefix``, ``$bindir``, ``$libdir``, ``$libsubdir``,
302 ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``, ``$os``,
303 ``$arch``, ``$abi``, ``$abitag``
305 In addition the simple build system supports the following installation
308 .. option:: --libsubdir=DIR
310 A subdirectory of *libdir* in which libraries are actually installed. For
311 example, in the simple build system on Unix, the default *libdir* is
312 ``/usr/local/lib``, and *libsubdir* contains the compiler ABI and package
314 e.g. ``x86_64-linux-ghc-8.0.2/mypkg-0.1.0-IxQNmCA7qrSEQNkoHSF7A``, so
315 libraries would be installed in
316 ``/usr/local/lib/x86_64-linux-ghc-8.0.2/mypkg-0.1.0-IxQNmCA7qrSEQNkoHSF7A/``.
318 *dir* may contain the following path variables: ``$pkgid``,
319 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
322 .. option:: --libexecsubdir=DIR
324 A subdirectory of *libexecdir* in which private executables are
325 installed. For example, in the simple build system on Unix, the default
326 *libexecdir* is ``/usr/local/libexec``, and *libsubdir* is
327 ``x86_64-linux-ghc-8.0.2/mypkg-0.1.0``, so private executables would be
328 installed in ``/usr/local/libexec/x86_64-linux-ghc-8.0.2/mypkg-0.1.0/``
330 *dir* may contain the following path variables: ``$pkgid``,
331 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
334 .. option:: --datasubdir=DIR
336 A subdirectory of *datadir* in which data files are actually
339 *dir* may contain the following path variables: ``$pkgid``,
340 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
343 .. option:: --docdir=DIR
345 Documentation files are installed relative to this directory.
347 *dir* may contain the following path variables: ``$prefix``,
348 ``$bindir``, ``$libdir``, ``$libsubdir``, ``$datadir``,
349 ``$datasubdir``, ``$pkgid``, ``$pkg``, ``$version``, ``$compiler``,
350 ``$os``, ``$arch``, ``$abi``, ``$abitag``
352 .. option:: --htmldir=DIR
354 HTML documentation files are installed relative to this directory.
356 *dir* may contain the following path variables: ``$prefix``,
357 ``$bindir``, ``$libdir``, ``$libsubdir``, ``$datadir``,
358 ``$datasubdir``, ``$docdir``, ``$pkgid``, ``$pkg``, ``$version``,
359 ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
361 .. option:: --program-prefix=PREFIX
363 Prepend *prefix* to installed program names.
365 *prefix* may contain the following path variables: ``$pkgid``,
366 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
369 .. option:: --program-suffix=SUFFIX
371 Append *suffix* to installed program names. The most obvious use for
372 this is to append the program's version number to make it possible
373 to install several versions of a program at once:
374 ``--program-suffix='$version'``.
376 *suffix* may contain the following path variables: ``$pkgid``,
377 ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
380 Path variables in the simple build system
381 """""""""""""""""""""""""""""""""""""""""
383 For the simple build system, there are a number of variables that can be
384 used when specifying installation paths. The defaults are also specified
385 in terms of these variables. A number of the variables are actually for
386 other paths, like ``$prefix``. This allows paths to be specified
387 relative to each other rather than as absolute paths, which is important
388 for building relocatable packages (see :ref:`prefix independence`).
391 The path variable that stands for the root of the installation. For
392 an installation to be relocatable, all other installation paths must
393 be relative to the ``$prefix`` variable.
395 The path variable that expands to the path given by the :option:`--bindir`
396 configure option (or the default).
398 As above but for :option:`--libdir`
400 As above but for :option:`--libsubdir`
402 As above but for :option:`--dynlibdir`
404 As above but for :option:`--datadir`
406 As above but for :option:`--datasubdir`
408 As above but for :option:`--docdir`
410 The name and version of the package, e.g. ``mypkg-0.2``
412 The name of the package, e.g. ``mypkg``
414 The version of the package, e.g. ``0.2``
416 The compiler being used to build the package, e.g. ``ghc-6.6.1``
418 The operating system of the computer being used to build the
419 package, e.g. ``linux``, ``windows``, ``osx``, ``freebsd`` or
422 The architecture of the computer being used to build the package,
423 e.g. ``i386``, ``x86_64``, ``ppc`` or ``sparc``
425 An optional tag that a compiler can use for telling incompatible
426 ABI's on the same architecture apart. GHCJS encodes the underlying
427 GHC version in the ABI tag.
429 A shortcut for getting a path that completely identifies the
430 platform in terms of binary compatibility. Expands to the same value
431 as ``$arch-$os-compiler-$abitag`` if the compiler uses an abi tag,
432 ``$arch-$os-$compiler`` if it doesn't.
434 Paths in the simple build system
435 """"""""""""""""""""""""""""""""
437 For the simple build system, the following defaults apply:
439 .. list-table:: Default installation paths
444 * - :option:`--prefix` (global)
446 - ``%PROGRAMFILES%\Haskell``
447 * - :option:`--prefix` (per-user)
449 - ``%APPDATA%\cabal``
450 * - :option:`--bindir`
453 * - :option:`--libdir`
456 * - :option:`--libsubdir` (others)
457 - ``$pkgid/$compiler``
458 - ``$pkgid\$compiler``
459 * - :option:`--dynlibdir`
462 * - :option:`--libexecdir`
463 - ``$prefix/libexec``
465 * - :option:`--datadir` (executable)
468 * - :option:`--datadir` (library)
470 - ``%PROGRAMFILES%\Haskell``
471 * - :option:`--datasubdir`
474 * - :option:`--docdir`
475 - ``$datadir/doc/$pkgid``
476 - ``$prefix\doc\$pkgid``
477 * - :option:`--sysconfdir`
480 * - :option:`--htmldir`
483 * - :option:`--program-prefix`
486 * - :option:`--program-suffix`
490 .. _prefix independence:
495 On Windows it is possible to obtain the pathname of the running program.
496 This means that we can construct an installable executable package that
497 is independent of its absolute install location. The executable can find
498 its auxiliary files by finding its own path and knowing the location of
499 the other files relative to ``$bindir``. Prefix independence is
500 particularly useful: it means the user can choose the install location
501 (i.e. the value of ``$prefix``) at install-time, rather than having to
502 bake the path into the binary when it is built.
504 In order to achieve this, we require that for an executable on Windows,
505 all of ``$bindir``, ``$libdir``, ``$dynlibdir``, ``$datadir`` and ``$libexecdir`` begin
506 with ``$prefix``. If this is not the case then the compiled executable
507 will have baked-in all absolute paths.
509 The application need do nothing special to achieve prefix independence.
510 If it finds any files using ``getDataFileName`` and the :ref:`other functions
511 provided for the purpose <accessing-data-files>`,
512 the files will be accessed relative to the location of the current
515 A library cannot (currently) be prefix independent, because it will be
516 linked into an executable whose file system location bears no relation
517 to the library package.
519 .. _controlling flag assignments:
521 Controlling Flag Assignments
522 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
524 Flag assignments (see :ref:`resolution-of-conditions-and-flags`)
525 can be controlled with the following command line options.
527 .. option:: -f flagname or -f -flagname
529 Force the specified flag to ``true`` or ``false`` (if preceded with
530 a ``-``). Later specifications for the same flags will override
531 earlier, i.e., specifying ``-fdebug -f-debug`` is equivalent to
534 .. option:: --flags=flagspecs
536 Same as ``-f``, but allows specifying multiple flag assignments at
537 once. The parameter is a space-separated list of flag names (to
538 force a flag to ``true``), optionally preceded by a ``-`` (to force
539 a flag to ``false``). For example,
540 ``--flags="debug -feature1 feature2"`` is equivalent to
541 ``-fdebug -f-feature1 -ffeature2``.
546 .. option:: --enable-tests
548 Build the test suites defined in the package description file during
549 the ``build`` stage. Check for dependencies required by the test
550 suites. If the package is configured with this option, it will be
551 possible to run the test suites with the ``test`` command after the
554 .. option:: --disable-tests
556 (default) Do not build any test suites during the ``build`` stage.
557 Do not check for dependencies required only by the test suites. It
558 will not be possible to invoke the ``test`` command without
559 reconfiguring the package.
561 .. option:: --enable-coverage
563 Build libraries and executables (including test suites) with Haskell
564 Program Coverage enabled. Running the test suites will automatically
565 generate coverage reports with HPC.
567 .. option:: --disable-coverage
569 (default) Do not enable Haskell Program Coverage.
571 Miscellaneous options
572 ^^^^^^^^^^^^^^^^^^^^^
576 Does a per-user installation. This changes the `default installation
577 prefix <#paths-in-the-simple-build-system>`__. It also allow
578 dependencies to be satisfied by the user's package database, in
579 addition to the global database. This also implies a default of
580 ``--user`` for any subsequent ``install`` command, as packages
581 registered in the global database should not depend on packages
582 registered in a user's database.
586 (default) Does a global installation. In this case package
587 dependencies must be satisfied by the global package database. All
588 packages in the user's package database will be ignored. Typically
589 the final installation step will require administrative privileges.
591 .. option:: --package-db=DB
593 Allows package dependencies to be satisfied from this additional
594 package database *db* in addition to the global package database.
595 All packages in the user's package database will be ignored. The
596 interpretation of *db* is implementation-specific. Typically it will
597 be a file or directory. Not all implementations support arbitrary
600 This pushes an extra db onto the db stack. The :option:`--global` and
601 :option:`--user` mode switches add the respective [Global] and [Global,
602 User] dbs to the initial stack. There is a compiler-implementation
603 constraint that the global db must appear first in the stack, and if
604 the user one appears at all, it must appear immediately after the
607 To reset the stack, use ``--package-db=clear``.
609 .. option:: --ipid=IPID
611 Specifies the *installed package identifier* of the package to be
612 built; this identifier is passed on to GHC and serves as the basis
613 for linker symbols and the ``id`` field in a ``ghc-pkg``
614 registration. When a package has multiple components, the actual
615 component identifiers are derived off of this identifier. E.g., a
616 sublibrary ``foo`` from package ``p-0.1-abcd`` will get the
617 identifier ``p-0.1-abcd-foo``.
619 .. option:: --cid=CID
621 Specifies the *component identifier* of the component being built;
622 this is only valid if you are configuring a single component.
624 .. option:: -O[n], --enable-optimization[=n]
626 (default) Build with optimization flags (if available). This is
627 appropriate for production use, taking more time to build faster
628 libraries and programs.
630 The optional *n* value is the optimisation level. Some compilers
631 support multiple optimisation levels. The range is 0 to 2. Level 0
632 is equivalent to :option:`--disable-optimization`, level 1 is the
633 default if no *n* parameter is given. Level 2 is higher optimisation
634 if the compiler supports it. Level 2 is likely to lead to longer
635 compile times and bigger generated code.
637 When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
639 .. option:: --disable-optimization
641 Build without optimization. This is suited for development: building
642 will be quicker, but the resulting library or programs will be
645 .. option:: --enable-profiling
647 Build libraries and executables with profiling enabled (for
648 compilers that support profiling as a separate mode). For this to
649 work, all libraries used by this package must also have been built
650 with profiling support. For libraries this involves building an
651 additional instance of the library in addition to the normal
652 non-profiling instance. For executables it changes the single
653 executable to be built in profiling mode.
655 This flag covers both libraries and executables, but can be
656 overridden by the :option:`--enable-library-profiling` flag.
658 See also the :option:`--profiling-detail` flag below.
660 .. option:: --disable-profiling
662 (default) Do not enable profiling in generated libraries and
665 .. option:: -p, --enable-library-profiling
667 As with :option:`--enable-profiling` above, but it applies only for
668 libraries. So this generates an additional profiling instance of the
669 library in addition to the normal non-profiling instance.
671 The :option:`--enable-profiling` flag controls the profiling mode for both
672 libraries and executables, but if different modes are desired for
673 libraries versus executables then use :option:`--enable-library-profiling`
676 .. option:: --disable-library-profiling
678 (default) Do not generate an additional profiling version of the library.
680 .. option:: --profiling-detail=level
682 Some compilers that support profiling, notably GHC, can allocate
683 costs to different parts of the program and there are different
684 levels of granularity or detail with which this can be done. In
685 particular for GHC this concept is called "cost centers", and GHC
686 can automatically add cost centers, and can do so in different ways.
688 This flag covers both libraries and executables, but can be
689 overridden by the :option:`--library-profiling-detail` flag.
691 Currently this setting is ignored for compilers other than GHC. The
692 levels that cabal currently supports are:
695 For GHC this uses ``exported-functions`` for libraries and
696 ``toplevel-functions`` for executables.
698 No costs will be assigned to any code within this component.
700 Costs will be assigned at the granularity of all top level
701 functions exported from each module. In GHC specifically, this
702 is for non-inline functions.
704 Costs will be assigned at the granularity of all top level
705 functions in each module, whether they are exported from the
706 module or not. In GHC specifically, this is for non-inline
709 Costs will be assigned at the granularity of all functions in
710 each module, whether top level or local. In GHC specifically,
711 this is for non-inline toplevel or where-bound functions or
714 Like top-level but costs will be assigned to top level definitions after
715 optimization. This lowers profiling overhead massively while giving similar
716 levels of detail as toplevle-functions. However it means functions introduced
717 by GHC during optimization will show up in profiles as well.
718 Corresponds to ``-fprof-late`` if supported and ``-fprof-auto-top`` otherwise.
720 Currently an alias for late-toplevel
722 This flag is new in Cabal-1.24. Prior versions used the equivalent
725 .. option:: --library-profiling-detail=level
727 As with :option:`--profiling-detail` above, but it applies only for
730 The level for both libraries and executables is set by the
731 :option:`--profiling-detail` flag, but if different levels are desired
732 for libraries versus executables then use
733 :option:`--library-profiling-detail` as well.
735 .. option:: --enable-library-vanilla
737 (default) Build ordinary libraries (as opposed to profiling
738 libraries). This is independent of the
739 :option:`--enable-library-profiling` option. If you enable both, you get
742 .. option:: --disable-library-vanilla
744 Do not build ordinary libraries. This is useful in conjunction with
745 :option:`--enable-library-profiling` to build only profiling libraries,
746 rather than profiling and ordinary libraries.
748 .. option:: --enable-library-for-ghci
750 (default) Build libraries suitable for use with GHCi.
752 .. option:: --disable-library-for-ghci
754 Not all platforms support GHCi and indeed on some platforms, trying
755 to build GHCi libs fails. In such cases this flag can be used as a
758 .. option:: --enable-split-objs
760 Use the GHC ``-split-objs`` feature when building the library. This
761 reduces the final size of the executables that use the library by
762 allowing them to link with only the bits that they use rather than
763 the entire library. The downside is that building the library takes
764 longer and uses considerably more memory.
766 .. option:: --disable-split-objs
768 (default) Do not use the GHC ``-split-objs`` feature. This makes
769 building the library quicker but the final executables that use the
770 library will be larger.
772 .. option:: --enable-executable-stripping
774 (default) When installing binary executable programs, run the
775 ``strip`` program on the binary. This can considerably reduce the
776 size of the executable binary file. It does this by removing
777 debugging information and symbols. While such extra information is
778 useful for debugging C programs with traditional debuggers it is
779 rarely helpful for debugging binaries produced by Haskell compilers.
781 Not all Haskell implementations generate native binaries. For such
782 implementations this option has no effect.
784 .. option:: --disable-executable-stripping
786 Do not strip binary executables during installation. You might want
787 to use this option if you need to debug a program using gdb, for
788 example if you want to debug the C parts of a program containing
789 both Haskell and C code. Another reason is if your are building a
790 package for a system which has a policy of managing the stripping
791 itself (such as some Linux distributions).
793 .. option:: --enable-shared
795 Build shared library. This implies a separate compiler run to
796 generate position independent code as required on most platforms.
798 ``--enable-shared`` is enabled automatically if GHC is dynamically linked or
799 you request to build dynamic executables.
801 .. option:: --disable-shared
803 (default) Do not build shared library.
805 .. option:: --enable-profiling-shared
807 Build a profiling shared library.
809 .. option:: --disable-profiling-shared
811 (default) Do not built a profiling shared library.
813 .. option:: --enable-static
815 Build a static library. This passes ``-staticlib`` to GHC (available
816 for iOS, and with 8.4 more platforms). The result is an archive ``.a``
817 containing all dependent haskell libraries combined.
819 .. option:: --disable-static
821 (default) Do not build a static library.
823 .. option:: --enable-executable-dynamic
825 Link dependent Haskell libraries into executables dynamically.
826 The executable's library dependencies must have been
827 built as shared objects. This implies :option:`--enable-shared`
828 unless :option:`--disable-shared` is explicitly specified.
830 .. option:: --disable-executable-dynamic
832 (default) Link dependent Haskell libraries into executables statically.
833 Non-Haskell (C) libraries are still linked dynamically, including libc,
834 so the result is still not a fully static executable
835 unless :option:`--enable-executable-static` is given.
837 .. option:: --enable-executable-static
839 Build fully static executables.
840 This links all dependent libraries into executables statically,
843 .. option:: --disable-executable-static
845 (default) Do not build fully static executables.
847 .. option:: --configure-option=str
849 An extra option to an external ``configure`` script, if one is used
850 (see the section on :ref:`system-dependent parameters`).
851 There can be several of these options.
853 .. option:: --extra-include-dirs=PATH
855 An extra directory to search for C header files. You can use this
856 flag multiple times to get a list of directories.
858 You might need to use this flag if you have standard system header
859 files in a non-standard location that is not mentioned in the
860 package's ``.cabal`` file. Using this option has the same effect as
861 appending the directory *dir* to the ``include-dirs`` field in each
862 library and executable in the package's ``.cabal`` file. The
863 advantage of course is that you do not have to modify the package at
864 all. These extra directories will be used while building the package
865 and for libraries it is also saved in the package registration
866 information and used when compiling modules that use the library.
868 .. option:: --extra-lib-dirs=PATH
870 An extra directory to search for system libraries files. You can use
871 this flag multiple times to get a list of directories.
873 .. option:: --extra-framework-dirs=PATH
875 An extra directory to search for frameworks (OS X only). You can use
876 this flag multiple times to get a list of directories.
878 You might need to use this flag if you have standard system
879 libraries in a non-standard location that is not mentioned in the
880 package's ``.cabal`` file. Using this option has the same affect as
881 appending the directory *dir* to the ``extra-lib-dirs`` field in
882 each library and executable in the package's ``.cabal`` file. The
883 advantage of course is that you do not have to modify the package at
884 all. These extra directories will be used while building the package
885 and for libraries it is also saved in the package registration
886 information and used when compiling modules that use the library.
888 .. option:: --dependency[=pkgname=IPID]
890 Specify that a particular dependency should used for a particular
891 package name. In particular, it declares that any reference to
892 *pkgname* in a :pkg-field:`build-depends` should be resolved to
895 .. option:: --promised-dependency[=pkgname=IPID]
897 Very much like ``--dependency`` but the package doesn't need to already
898 be installed. This is useful when attempting to start multiple component
899 sessions with cabal's multi-repl or projects such as Haskell Language Server.
901 Several checks which are enabled for ``--dependency``s are disabled for promised
902 dependencies, so prefer to use ``--dependency`` if you know that the dependency
903 is already installed.
905 .. option:: --exact-configuration
907 This changes Cabal to require every dependency be explicitly
908 specified using :option:`--dependency`, rather than use Cabal's (very
909 simple) dependency solver. This is useful for programmatic use of
910 Cabal's API, where you want to error if you didn't specify enough
911 :option:`--dependency` flags.
914 .. option:: -c CONSTRAINT or -cCONSTRAINT, --constraint=CONSTRAINT
916 Restrict solutions involving a package to given version
917 bounds, flag settings, and other properties.
919 The following considers only install plans where ``bar``,
920 if used, is restricted to version 2.1:
924 $ cabal install --constraint="bar == 2.1"
926 The following prevents ``bar`` from being used at all:
930 $ cabal install --constraint="bar <0"
932 Version bounds have the same syntax as :pkg-field:`build-depends`.
933 Yet extra pseudo version bounds are available here in addition:
935 - ``installed`` to fix a package to the already installed version.
936 Often useful for GHC-supplied packages in combination with :cfg-field:`allow-newer`,
937 e.g., ``--allow-newer='*:base' --constraint='base installed'``.
939 - ``source`` to fix a package to the local source copy.
943 # Require that a version of bar be used that is already installed in
944 # the global package database.
945 $ cabal install --constraint="bar installed"
947 # Require the local source copy of bar to be used.
948 # (Note: By default, if we have a local package we will
949 # automatically use it, so it will generally not be necessary to
951 $ cabal install --constraint="bar source"
953 Further, we can specify flag assignments with ``+FLAG`` and ``-FLAG``
954 or enable test (``test``) and benchmark (``bench``) suites:
958 # Require bar to be installed with the foo flag turned on and
959 # the baz flag turned off.
960 $ cabal install --constraint="bar +foo -baz"
962 # Require that bar have test suites and benchmarks enabled.
963 $ cabal install --constraint="bar test" --constraint="bar bench"
965 To specify multiple constraints, you may pass the
966 ``constraint`` option multiple times.
968 By default, constraints only apply to build dependencies
969 (:pkg-field:`build-depends`), build dependencies of build
970 dependencies, and so on. Constraints normally do not apply to
971 dependencies of the ``Setup.hs`` script of any package
972 (:pkg-field:`custom-setup:setup-depends`) nor do they apply to build tools
973 (:pkg-field:`build-tool-depends`) or the dependencies of build
974 tools. To explicitly apply a constraint to a setup or build
975 tool dependency, you can add a qualifier ``setup`` or ``any``
976 to the constraint as follows:
980 # Example use of the 'any' qualifier. This constraint
981 # applies to package bar anywhere in the dependency graph.
982 $ cabal install --constraint="any.bar == 1.0"
986 # Example uses of 'setup' qualifiers.
988 # This constraint applies to package bar when it is a
989 # dependency of any Setup.hs script.
990 $ cabal install --constraint="setup.bar == 1.0"
992 # This constraint applies to package bar when it is a
993 # dependency of the Setup.hs script of package foo.
994 $ cabal install --constraint="foo:setup.bar == 1.0"
996 .. TODO: Uncomment this example once we decide on a syntax for 'exe'.
997 .. # Example use of the 'exe' (executable build tool)
998 # qualifier. This constraint applies to package baz when it
999 # is a dependency of the build tool bar being used to
1000 # build package foo.
1001 $ cabal install --constraint="foo:bar:exe.baz == 1.0"
1003 .. option:: --disable-response-files
1005 Enable workaround for older versions of programs such as ``ar`` or
1006 ``ld`` that do not support response file arguments (i.e. ``@file``
1007 arguments). You may want this flag only if you specify custom ar
1008 executable. For system ``ar`` or the one bundled with ``ghc`` on
1009 Windows the ``cabal`` should do the right thing and hence should
1010 normally not require this flag.
1014 runhaskell Setup.hs build
1015 -------------------------
1017 Perform any preprocessing or compilation needed to make this package
1018 ready for installation.
1020 This command takes the following options:
1022 .. program:: runhaskell Setup.hs build
1024 .. option:: --PROG-options=OPTS, --PROG-option=OPT
1026 These are mostly the same as the `options configure
1027 step <#setup-configure>`__. Unlike the options specified at the
1028 configure step, any program options specified at the build step are
1029 not persistent but are used for that invocation only. The options
1030 specified at the build step are in addition not in replacement of
1031 any options specified at the configure step.
1035 runhaskell Setup.hs haddock
1036 ---------------------------
1038 .. program:: runhaskell Setup.hs haddock
1040 Build the documentation for the package using Haddock_.
1041 By default, only the documentation for the exposed modules is generated
1042 (but see the :option:`--executables` and :option:`--internal` flags below).
1044 This command takes the following options:
1046 .. option:: --hoogle
1048 Generate a file ``dist/doc/html/``\ *pkgid*\ ``.txt``, which can be
1049 converted by Hoogle_ into a
1050 database for searching. This is equivalent to running Haddock_
1051 with the ``--hoogle`` flag.
1053 .. option:: --html-location=url
1055 Specify a template for the location of HTML documentation for
1056 prerequisite packages. The substitutions (`see
1057 listing <#paths-in-the-simple-build-system>`__) are applied to the
1058 template to obtain a location for each package, which will be used
1059 by hyperlinks in the generated documentation. For example, the
1060 following command generates links pointing at Hackage_ pages:
1064 $ runhaskell Setup.hs haddock \
1065 --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
1067 Here the argument is quoted to prevent substitution by the shell. If
1068 this option is omitted, the location for each package is obtained
1069 using the package tool (e.g. ``ghc-pkg``).
1071 .. option:: --executables
1073 Also run Haddock_ for the modules of all the executable programs. By default
1074 Haddock_ is run only on the exported modules.
1076 .. option:: --internal
1078 Run Haddock_ for the all
1079 modules, including unexposed ones, and make
1080 Haddock_ generate documentation
1081 for unexported symbols as well.
1083 .. option:: --css=path
1085 The argument *path* denotes a CSS file, which is passed to
1086 Haddock_ and used to set the
1087 style of the generated documentation. This is only needed to
1088 override the default style that
1091 .. option:: --hyperlink-source
1093 Generate Haddock_ documentation integrated with HsColour_ . First,
1094 HsColour_ is run to generate colourised code. Then Haddock_ is run to
1095 generate HTML documentation. Each entity shown in the documentation is
1096 linked to its definition in the colourised code.
1098 .. option:: --hscolour-css=path
1100 The argument *path* denotes a CSS file, which is passed to HsColour_ as in
1104 $ runhaskell Setup.hs hscolour --css=*path*
1108 runhaskell Setup.hs hscolour
1109 ----------------------------
1111 Produce colourised code in HTML format using HsColour_. Colourised code for
1112 exported modules is put in ``dist/doc/html/``\ *pkgid*\ ``/src``.
1114 This command takes the following options:
1116 .. program:: runhaskell Setup.hs hscolour
1118 .. option:: --executables
1120 Also run HsColour_ on the sources of all executable programs. Colourised
1121 code is put in ``dist/doc/html/``\ *pkgid*/*executable*\ ``/src``.
1123 .. option:: --css=path
1125 Use the given CSS file for the generated HTML files. The CSS file
1126 defines the colours used to colourise code. Note that this copies
1127 the given CSS file to the directory with the generated HTML files
1128 (renamed to ``hscolour.css``) rather than linking to it.
1132 runhaskell Setup.hs install
1133 ---------------------------
1135 .. program:: runhaskell Setup.hs install
1137 Copy the files into the install locations and (for library packages)
1138 register the package with the compiler, i.e. make the modules it
1139 contains available to programs.
1141 Additionally for GHC the ``extra-compilation-artifacts`` directory is copied if present.
1142 GHC plugins can store extra data in subfolders.
1143 (e.g. *extra-compilation-artifacts/PLUGIN_NAME/HS_MODULE.txt*)
1145 The `install locations <#installation-paths>`__ are determined by
1146 options to `runhaskell Setup.hs configure`_.
1148 This command takes the following options:
1150 .. option:: --global
1152 Register this package in the system-wide database. (This is the
1153 default, unless the :option:`runhaskell Setup.hs configure --user` option was supplied
1154 to the ``configure`` command.)
1158 Register this package in the user's local package database. (This is
1159 the default if the :option:`runhaskell Setup.hs configure --user` option was supplied
1160 to the ``configure`` command.)
1164 runhaskell Setup.hs copy
1165 ------------------------
1167 Copy the files without registering them. This command is mainly of use
1168 to those creating binary packages.
1170 This command takes the following option:
1172 .. program:: runhaskell Setup.hs copy
1174 .. option:: --destdir=path
1176 Specify the directory under which to place installed files. If this is
1177 not given, then the root directory is assumed.
1181 runhaskell Setup.hs register
1182 ----------------------------
1184 Register this package with the compiler, i.e. make the modules it
1185 contains available to programs. This only makes sense for library
1186 packages. Note that the ``install`` command incorporates this action.
1187 The main use of this separate command is in the post-installation step
1188 for a binary package.
1190 This command takes the following options:
1192 .. program:: runhaskell Setup.hs register
1194 .. option:: --global
1196 Register this package in the system-wide database. (This is the
1201 Register this package in the user's local package database.
1203 .. option:: --gen-script
1205 Instead of registering the package, generate a script containing
1206 commands to perform the registration. On Unix, this file is called
1207 ``register.sh``, on Windows, ``register.bat``. This script might be
1208 included in a binary bundle, to be run after the bundle is unpacked
1209 on the target system.
1211 .. option:: --gen-pkg-config[=path]
1213 Instead of registering the package, generate a package registration
1214 file (or directory, in some circumstances). This only applies to
1215 compilers that support package registration files which at the
1216 moment is only GHC. The file should be used with the compiler's
1217 mechanism for registering packages. This option is mainly intended
1218 for packaging systems. If possible use the :option:`--gen-script` option
1219 instead since it is more portable across Haskell implementations.
1220 The *path* is optional and can be used to specify a particular
1221 output file to generate. Otherwise, by default the file is the
1222 package name and version with a ``.conf`` extension.
1224 This option outputs a directory if the package requires multiple
1225 registrations: this can occur if internal/convenience libraries are
1226 used. These configuration file names are sorted so that they can be
1227 registered in order.
1229 .. option:: --inplace
1231 Registers the package for use directly from the build tree, without
1232 needing to install it. This can be useful for testing: there's no
1233 need to install the package after modifying it, just recompile and
1236 This flag does not create a build-tree-local package database. It
1237 still registers the package in one of the user or global databases.
1239 However, there are some caveats. It only works with GHC (currently).
1240 It only works if your package doesn't depend on having any
1241 supplemental files installed --- plain Haskell libraries should be
1244 .. _setup-unregister:
1246 runhaskell Setup.hs unregister
1247 ------------------------------
1249 .. program:: runhaskell Setup.hs unregister
1251 Deregister this package with the compiler.
1253 This command takes the following options:
1255 .. option:: --global
1257 Deregister this package in the system-wide database. (This is the
1262 Deregister this package in the user's local package database.
1264 .. option:: --gen-script
1266 Instead of deregistering the package, generate a script containing
1267 commands to perform the deregistration. On Unix, this file is called
1268 ``unregister.sh``, on Windows, ``unregister.bat``. This script might
1269 be included in a binary bundle, to be run on the target system.
1273 runhaskell Setup.hs clean
1274 -------------------------
1276 Remove any local files created during the ``configure``, ``build``,
1277 ``haddock``, ``register`` or ``unregister`` steps, and also any files
1278 and directories listed in the :pkg-field:`extra-tmp-files` field.
1280 This command takes the following options:
1282 .. program:: runhaskell Setup.hs clean
1284 .. option:: --save-configure, -s
1286 Keeps the configuration information so it is not necessary to run
1287 the configure step again before building.
1291 runhaskell Setup.hs test
1292 ------------------------
1294 Run the test suites specified in the package description file. Aside
1295 from the following flags, Cabal accepts the name of one or more test
1296 suites on the command line after ``test``. When supplied, Cabal will run
1297 only the named test suites, otherwise, Cabal will run all test suites in
1300 .. program:: runhaskell Setup.hs test
1302 .. option:: --builddir=DIR
1304 The directory where Cabal puts generated build files (default:
1305 ``dist``). Test logs will be located in the ``test`` subdirectory.
1307 .. option:: --test-log=TEMPLATE
1309 The template used to name human-readable test logs; the path is
1310 relative to ``dist/test``. By default, logs are named according to
1311 the template ``$pkgid-$test-suite.log``, so that each test suite
1312 will be logged to its own human-readable log file. Template
1313 variables allowed are: ``$pkgid``, ``$compiler``, ``$os``,
1314 ``$arch``, ``$abi``, ``$abitag``, ``$test-suite``, and ``$result``.
1316 .. option:: --test-machine-log=TEMPLATE
1318 The path to the machine-readable log, relative to ``dist/test``. The
1319 default template is ``$pkgid.log``. Template variables allowed are:
1320 ``$pkgid``, ``$compiler``, ``$os``, ``$arch``, ``$abi``, ``$abitag``
1323 .. option:: --test-show-details=FILTER
1325 Determines if the results of individual test cases are shown on the
1326 terminal. May be ``always`` (always show), ``never`` (never show),
1327 ``failures`` (show only failed results), ``streaming`` (show all
1328 results in real time) and ``direct`` (same as ``streaming`` but no log
1329 file and possibly prettier).
1331 Default value is ``direct``: it leaves test output untouched and does not
1332 produce a log. This allows for colored output, which is popular with testing
1333 frameworks. (On the other hand, ``streaming`` creates a log but looses
1336 .. option:: --test-options=TEMPLATES
1338 Give extra options to the test executables.
1340 .. option:: --test-option=TEMPLATE
1342 Give an extra option to the test executables. There is no need to
1343 quote options containing spaces because a single option is assumed,
1344 so options will not be split on spaces.
1346 .. option:: --test-wrapper=FILE
1348 The wrapper script/application used to setup and tear down the test
1349 execution context. The text executable path and test arguments are
1350 passed as arguments to the wrapper and it is expected that the wrapper
1351 will return the test's return code, as well as a copy of stdout/stderr.
1355 runhaskell Setup.hs bench
1356 -------------------------
1358 Run the benchmarks specified in the package description file. Aside
1359 from the following flags, Cabal accepts the name of one or more benchmarks
1360 on the command line after ``bench``. When supplied, Cabal will run
1361 only the named benchmarks, otherwise, Cabal will run all benchmarks in
1364 .. option:: --benchmark-options=TEMPLATES
1366 Give extra options to the benchmark executables.
1368 .. option:: --benchmark-option=TEMPLATE
1370 Give an extra option to the benchmark executables. There is no need to
1371 quote options containing spaces because a single option is assumed,
1372 so options will not be split on spaces.
1376 runhaskell Setup.hs sdist
1377 -------------------------
1379 Create a system- and compiler-independent source distribution in a file
1380 *package*-*version*\ ``.tar.gz`` in the ``dist`` subdirectory, for
1381 distribution to package builders. When unpacked, the commands listed in
1382 this section will be available.
1384 The files placed in this distribution are the package description file,
1385 the setup script, the sources of the modules named in the package
1386 description file, and files named in the ``license-file``, ``main-is``,
1387 ``c-sources``, ``asm-sources``, ``cmm-sources``, ``js-sources``,
1388 ``data-files``, ``extra-source-files`` and ``extra-doc-files`` fields.
1390 This command takes the following option:
1392 .. program:: runhaskell Setup.hs sdist
1394 .. option:: --snapshot
1396 Append today's date (in "YYYYMMDD" format) to the version number for
1397 the generated source package. The original package is unaffected.
1400 .. include:: references.inc