From Fedora Project Wiki
(→‎Lib and BinLib packages: expand %ghc_compiler to avoid koji srpm problems)
 
(284 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Haskell Packaging Guidelines =
= Haskell Packaging Guidelines =
This page documents the guidelines and conventions for packaging [[Haskell]] projects in Fedora.


This document seeks to document the guidelines and conventions for packaging Haskell projects in Fedora.
[http://haskell.org/ghc GHC] (Glasgow Haskell Compiler) is the current mainstream Haskell compiler.
Most Haskell packages are released on [http://hackage.haskell.org Hackage] and use the [http://www.haskell.org/cabal/ Cabal] package system.  So the current guidelines mostly focus on packaging for GHC using Cabal.


== Spec file templates ==
Spec files in line with these templates are generated automatically by the [https://apps.fedoraproject.org/packages/cabal-rpm cabal-rpm] packaging tool
which also adds dependencies listed in the package's <code>.cabal</code> configuration file.
Most packages should then build, though for some packages
it may be necessary to specify some additional BuildRequires and/or Requires, and to check non-Haskell devel dependencies.


There are three types of Haskell Cabal packages: library only (Lib), binary only (Bin), and binary and library (BinLib):


== What is Haskell? ==
* [http://git.fedorahosted.org/cgit/haskell-sig.git/tree/templates/ghc-Lib-pkg.spec Lib Template] ([http://git.fedorahosted.org/cgit/haskell-sig.git/plain/templates/ghc-Lib-pkg.spec plain])
* [http://git.fedorahosted.org/cgit/haskell-sig.git/tree/templates/Bin-pkg.spec Bin Template] ([http://git.fedorahosted.org/cgit/haskell-sig.git/plain/templates/Bin-pkg.spec plain])
* [http://git.fedorahosted.org/cgit/haskell-sig.git/tree/templates/BinLib-pkg.spec BinLib Template] ([http://git.fedorahosted.org/cgit/haskell-sig.git/plain/templates/BinLib-pkg.spec plain]).


(from http://haskell.org/)
Standardizing the packaging helps to lower the maintenance burden across Fedora's Haskell packages.


Haskell is an advanced purely functional programming language. The product of more than twenty years of cutting edge research, it allows rapid development of robust, concise, correct software. With strong support for integration with other languages, built-in concurrency, debuggers, profilers, rich libraries and an active community, Haskell makes it easier to produce flexible, maintainable high-quality software.
== Package Naming ==
Haskell Bin and BinLib packages should follow the usual Fedora Package Naming Guidelines for base package naming: ie follow the upstream name. Examples include projects like <code>darcs</code> and <code>xmonad</code>.
However there may be cases where a Haskell BinLib package is really a Lib package with a minor or unimportant executable: in this case it is better to treat the package a Lib package, optionally with a executable subpackage if appropriate.


GHC, or the Glasgow Haskell Compiler, is one of the more popular Haskell compilersIt complies with Haskell 98, the latest official language specification, and also includes numerous experimental language ideas.  It represents a good picture of what the future of Haskell will look like, so it is a good choice for development.  Many Haskell programs work better or only with GHC.
The names of Haskell Lib packages, packaged for <code>ghc</code>, are prefixed by "ghc-"For example the Haskell X11 library package is named <code>ghc-X11</code>, and the Haskell mmap library package is named <code>ghc-mmap</code>, etc.


== Base package naming ==
Note that having different Haskell source packages named "ghc-xyz" and "xyz" is not allowed since they would both correspond to the same upstream package named "xyz" on Hackage.


=== Libraries ===
BinLib packages should subpackage their libraries with naming following Lib packages.
Haskell library packages should be named after the compiler or interpreter they are used with. For example, if a Haskell library called <code>trunks</code> is only for GHC, the base package name in Fedora should be called <code>ghc-trucks</code>.
For example the <code>xmonad</code> BinLib package has library subpackages
* <code>ghc-xmonad</code> for the shared library, and
* <code>ghc-xmonad-devel</code> for devel files and the static library.


If a library supports multiple Haskell compilers or interpreters, the base name should instead be prefixed with <code>haskell</code>, e.g. <code>haskell-trunks</code>.  Such a package would then have subpackages for each compiler and/or interpreter it is built for (e.g. <code>ghc-trunks</code>, <code>hug98-trunks</code>, etc.
If a library is packaged for more than one Haskell compiler or interpreter, the base name should instead be prefixed with <code>haskell</code>, e.g. <code>haskell-X11</code>.  Such a package would then have subpackages for each compiler and/or interpreter it is built for (e.g. <code>ghc-X11</code>, <code>hugs98-X11</code>, etc).


=== Binaries ===
Package naming preserves case to follow the upstream naming conventions as closely as possible.
For Haskell packages for programs the usual Fedora Package Naming Guidelines must be followed: ie in they should follow the upstream name. Examples include projects like darcs, haddock, and xmonad.  If the package also generates libraries, then the libraries SHOULD be subpackaged as a Haskell library package named after the compiler or interpreter as above.  For example, if compiled against GHC the library <code>tubes</code>'s base name would be called <code>ghc-tubes</code>.


Summarizing: in CVS, library packages with no binaries are named like <code>ghc-trucks</code>.  Program packages are named like <code>tubes</code>.
== Headers ==


== Description ==
The macro <code>pkg_name</code> is used to carry the name of the upstream library package (i.e. without the Fedora "ghc-" prefix).
It should be defined at the top of Lib and BinLib packages:


When packaging things out of [http://hackage.haskell.org Hackage] or other sources, you may find that the description is incomplete or improperly labeled.  Please double check all parts of the package description so that it meets Fedora's standards for writing quality.
  %global pkg_name <package>


== Packaging libraries ==
== Cabal Flags ==
Cabal flags for build options should be set by changing the package's <code>.cabal</code> file: this can be done with the <code>cabal-tweak-flag</code> script to avoid having to carry and maintain patches for this.
<code>%cabal_configure_options</code> can be set to pass other options to Cabal.


GHC libraries are installed under libdir/ghc by cabal.
Modifying the <code>.cabal</code> file flags defaults allows packagers and tools like <code>cabal-rpm</code> to track actual package dependencies correctly.


=== Using Cabal ===
== Dependency Generation ==
If you use Cabal to build and install the packages, you can use the following snippet to define filelists, rather than doing it by hand:
Spec file build dependencies are generated by the <code>cabal-rpm</code> packaging tool.
 
RPM dependencies for Haskell libraries are automatically generated at build-time by the <code>ghc-deps.sh</code> script.
 
The <code>cabal-tweak-dep-ver</code> script can be used to bump versions of dependencies in the package .cabal file.
 
== Shared and static library linking ==
GHC uses static libraries by default, but supports shared libraries on some architectures: currently i686 and x86_64.  Lib and BinLib packages should provide static, shared, and profiling libraries:
* the shared library lives in the base library package, and
* the static and profiling library and header files in the -devel subpackage.
 
Because GHC still assumes static versions of libraries are installed they need to be in the devel subpackage and it doesn't make sense to subpackage them yet.
 
Executables in Bin and BinLib packages should be dynamically linked to shared libraries.
 
Note that executables in most BinLib packages are currently staticly linked against the library in their own package (unless the .cabal file explicitly lists it as a dependency), but dynamically linked against other dependent libraries. BinLib executables that do link dynamically against their own library should use <code>%ghc_fix_dynamic_rpath</code> to fix its RPATH.
 
Some particular packages may do user compilation during runtime in which case they will need Requires as well as BuildRequires for their dependencies: examples include xmonad and yi which require their devel package to be present to allow users to relink their configuration or customization.
 
== RPM Macros ==
The templates all have buildrequires for ghc-rpm-macros, which provides [http://pkgs.fedoraproject.org/cgit/ghc-rpm-macros.git/tree/ghc-rpm-macros.ghc macros.ghc] to assist with packaging Haskell Cabal packages.


<pre>
<pre>
cd ${RPM_BUILD_ROOT}
BuildRequires:  ghc-rpm-macros
echo '%defattr(-,root,root,-)' > %{_builddir}/%{?buildsubdir}/%{name}-files.prof
</pre>
find .%{pkg_libdir} \( -name '*_p.a' -o -name '*.p_hi' \) | sed s/^.// >> %{_builddir}/%{?buildsubdir}/%{name}-files.prof
 
echo '%defattr(-,root,root,-)' > %{_builddir}/%{?buildsubdir}/%{name}-files.nonprof
The main commonly used macros are:
find .%{pkg_libdir} -type d | sed 's/^./%dir /' >> %{_builddir}/%{?buildsubdir}/%{name}-files.nonprof
find .%{pkg_libdir} ! \( -type d -o -name '*_p.a' -o -name '*.p_hi' \) | sed s/^.// >> %{_builddir}/%{?buildsubdir}/%{name}-files.nonprof
sed 's,^/,%exclude /,' %{_builddir}/%{?buildsubdir}/%{name}-files.prof >> %{_builddir}/%{?buildsubdir}/%{name}-files.nonprof


cd ${RPM_BUILD_ROOT}/%{_datadir}/doc/%{hsc_namever}-%{f_pkg_name}-%{version}
* %ghc_bin_build
rm -rf doc LICENSE README
* %ghc_lib_build
* %ghc_bin_install
* %ghc_lib_install
 
They are used in the templates and explained in more detail below.
 
== Bin packages ==
 
Bin package executables should be dynamically linked to shared Haskell libraries when available, but this can be overridden if necessary by defining the <code>ghc_without_dynamic</code> macro.
 
<pre>
%build
%ghc_bin_build
 
 
%install
%ghc_bin_install
</pre>
</pre>


=== Install scripts ===
<code>%ghc_bin_build</code> is used to configure and build bin packages. It runs:
Libraries must be registered with the installed ghc.
* <code>%global debug_package %{nil}</code>: debuginfo is disabled since ghc's output is not in GDB format.
* <code>%cabal_configure</code>: configure the package for building and dynamic linking.
* <code>%cabal build</code>: builds the package.


* Not sure about using cabal for this --JensPetersen
<code>%ghc_bin_install</code> is used to install bin packages.  It runs:
* What about security?  As such the current system using ghc-pkg works ok and is safe.
* <code>%cabal_install</code>: installs the package.
* <code>%ghc_strip_dynlinked</code>: strips the dynamically linked binary.
 
== Lib and BinLib packages ==
 
BinLib package executables should be dynamically linked to other shared Haskell libraries when available, but this can be overridden if necessary by defining the <code>ghc_without_dynamic</code> macro.
 
Devel subpackages need to setup some Requires:


To generate registration scripts that can be embedded in the package, include the following in %build
<pre>
<pre>
runghc Setup register --gen-script
%package -n ghc-%{pkg_name}-devel
runghc Setup unregister --gen-script
Summary:        Haskell %{pkg_name} library development files
Requires:      ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
Requires(postun): ghc-compiler = %{ghc_version}
Requires:      ghc-%{pkg_name} = %{version}-%{release}
</pre>
</pre>


To separate the copying phase from the registration phase of installation, include the following in %install
Lib packages need to use <code>%setup -n</code>:
 
<pre>
<pre>
runghc Setup copy --destdir=${RPM_BUILD_ROOT}
%prep
install -m 755 register.sh unregister.sh ${RPM_BUILD_ROOT}%{pkg_libdir}
%setup -q -n %{pkg_name}-%{version}
</pre>
</pre>


To register packages at install time, make sure to include the following bits:
Both Lib and BinLib have:
 
<pre>
<pre>
%pre -n %{hsc_namever}-%{f_pkg_name}
%build
[ "$1" = 2 ]  && %{pkg_libdir}/unregister.sh >&/dev/null || :
%ghc_lib_build




%post -n %{hsc_namever}-%{f_pkg_name}
%install
%{pkg_libdir}/register.sh >&/dev/null
%ghc_lib_install




%preun -n %{hsc_namever}-%{f_pkg_name}
%post devel
%{pkg_libdir}/unregister.sh >&/dev/null
%ghc_pkg_recache




%postun -n %{hsc_namever}-%{f_pkg_name}
%postun devel
[ "$1" = 1 ]  && %{pkg_libdir}/register.sh >& /dev/null || :
%ghc_pkg_recache
</pre>
</pre>


== Packaging binaries ==
<code>%ghc_lib_build</code> is used to configure, build and generate documentation for Lib and BinLib packagesIt runs:
Binaries are packaged by their simple name.  <code>xmonad</code> would remain <code>xmonad</code>.  This does not apply to the libraries that are included in the cabal package.  A spec file for xmonad would generate two rpms, both of which are required for runtime, xmonad and ghc-xmonadxmonad would require ghc-xmonad, but not visa versa. ghc-xmonad would contain a line in the description explaining that these are the libraries necessary for xmonad to run.
* <code>%global debug_package %{nil}</code>: debuginfo is disabled since ghc's output is not in DWARF format.
 
* <code>%cabal_configure --ghc -p</code>: configures the package for building with ghc and profilingLibraries should build profiling versions of their static libraries.
Binary packages should be compiled with GHC when possible. Some Haskell packages might require some compiler extension not provided in GHC. Alternate compilers may be used so long as they are packaged for Fedora.  Please make it clear what feature is needed when submitting that package for review, and leave an appropriate comment in the spec file.
* <code>%cabal build</code>: builds the package.
* <code>%cabal haddock</code>: generates HTML library documentation from the source code.
** If necessary (if e.g. documentation is failing to build for some reason) this can be skipped by defining <code>without_haddock</code>.
** Additionally links to colored html sourcecode are also generated with <code>hscolour</code>, which can be disabled by defining <code>without_hscolour</code>.


If a compiler is not available in Fedora, please submit it for package review as wellWe can block your review request on the compiler, and if they pass review, they can be accepted simultaneously. Please note that your compiler must follow Fedora's guidelines for packaging and package submission.
<code>%ghc_lib_install</code> is used to install Lib and BinLib packagesIt runs:
* <code>%cabal_install</code>: installs the package without registering it in ghc-pkg.
* <code>%cabal_pkg_conf</code>: creates ghc-pkg .conf metadata file for package installation time
* <code>%ghc_gen_filelists</code>: generates rpm filelists.
* <code>%ghc_strip_dynlinked</code>: strips dynamically linked objects.


Rationale: Binaries are recognized on their name alone.  Furthermore, they do not require a compiler to run.  Therefore the name provided should simply be the upstream name. GHC is the best supported compiler in Fedora currently.  Therefore, if something goes wrong, we have a larger skill base to ask for help.
<code>%ghc_pkg_recache</code>: used in %post and %postun for devel subpackage - refreshes the ghc package cache database with .conf file data.


== Documentation ==
== Directories ==
Need to make sure Haddock interacts correctly with all the other included packages.  The biggest challenge is making sure all packages are hyperlinked to each other correctly.  (This may require an expensive post package install relinking phase for '''every''' Haskell library.  I would like to avoid this, so it will involve some research. [I certainly hope not --JensPetersen] )
GHC libraries are installed under <code>%ghcpkgdir/%{pkg_name}-%{version}</code>:


== Debug Information ==
Library documentation lives under <code>%ghclibdocdir/%{pkg_name}-%{version}</code>.


debuginfo packages shouldn't even be built.  GHC doesn't emit DWARF debug data.
== File lists ==
Filelists for shared and devel library subpackages are generated through <code>%ghc_lib_install</code> using the macro <code>%ghc_gen_filelists</code>.


== Spec Templates ==
It generates the filelists <code>ghc-%{pkg_name}.files</code> and <code>ghc-%{pkg_name}-devel.files</code>.
There are three types of packages: Library only, Library and Binary, and Binary only.  The program cabal-rpm can generate a SPEC file suited to all three cases. The following templates are the output from cabal-rpm with a few minor changes.


# [[PackagingDrafts/Haskell/LibraryOnlyTemplate|  Library Only Template]]
== Compiling non-Cabal packages ==
# [[PackagingDrafts/Haskell/LibraryAndBinaryTemplate|  Library and Binary Template]]
Packages compiling Haskell code without Cabal, ie directly with <code>ghc</code> or <code>ghc --make</code>, should use <code>-O1</code> optimization, like Cabal does by default.
# [[PackagingDrafts/Haskell/BinaryOnlyTemplate|  Binary Only Template]]


== Comments ==
== References ==
* Some libraries (like X11 until ghc-6.8.1) included with GHC are not the newest version. Some packages like xmonad need a newer version. Do we break apart the GHC package into multiple libraries that other packages can also update from other sources?
* http://fedorahosted.org/cabal2spec
* I would love to do this. --YaakovNemoy
* http://pkgs.fedoraproject.org/gitweb/?p=ghc-rpm-macros.git
* I'm not thrilled with the idea of splitting up ghc and the extralibs,
* http://pkg-haskell.alioth.debian.org/haskell-policy/ - Debian Haskell packaging policy
because it's a pain to have to install a dozen packages after ghc itself
* [[Packaging/OCaml|Fedora OCaml Packaging Guidelines]]
on systems that do the split, like Debian.
* [[SIGs/Haskell|Fedora Haskell SIG]]


If we can come up with some scheme that does the split, but gets the
whole lot installed in one go, then fine.


It's also perfectly reasonable, as far as GHC is concerned, to have
[[Category:Packaging guidelines drafts]]
multiple versions of a package installed at once. --BryanSullivan
* Do we keep GHC installed libraries in one place, RPM installed libraries in another place, and pray that cabal keeps things organized?
* GHC puts it's packaged libraries in /usr/lib/ghc/lib.  There are no conflicts. --YaakovNemoy
* Fedora is only concerned with rpm packages
* users can install their own libraries locally in their homedir if they wish.
* How do we handle Haddock data?  Do we mandate haddock packages go in -doc? -haddock? should we enforce special build time requirements to make sure all haddock packages hyperlink to one another?
* More research is needed here.  This will not make it into Fedora 9 most likely. --YaakovNemoy
* The standard for doc packages is a -doc suffix, so we're already doing the right thing.  --BryanSullivan
* Haddock should pick up links across packages properly by default. --BryanSullivan
* Update: It's been pointed out that this probably already works.  --YaakovNemoy
* Some libraries take build time options via flags in cabal.  Do we provide sane defaults? Both types?  (This doesn't apply to trivial flags, like ones used to determine if they are compiled with the new/old versions of GHC.)
* This decision should be made on a per package basis.  If a sample RPM can be built that handles options, perhaps we can look at integrating it into cabal-rpm. --YaakovNemoy
* Other than what cabal-rpm does already, are there any rules we need for profiling packages?
* I would say no. -- YaakovNemoy
* Do we need -devel sub-packages?
* No. --BryanSullivan
* Package names are entirely lower case.  Hackage package names should be converted.  cabal-rpm does this automatically. -- YaakovNemoy
* I disagree with this: I think we should preserve case of names as usual -- JensPetersen
* I pulled this from python's playbook.  I believe that it is what is generally prefered by Fedora people, rather than having RidiculousNamingSCHeMES.  --Yaakov
* I agree with Yaakov's proposal to lowercase all names.  The Haskell package naming capitalisation conventions are nonexistent and often ugly. -- BryanSullivan

Latest revision as of 07:44, 17 May 2013

Haskell Packaging Guidelines

This page documents the guidelines and conventions for packaging Haskell projects in Fedora.

GHC (Glasgow Haskell Compiler) is the current mainstream Haskell compiler. Most Haskell packages are released on Hackage and use the Cabal package system. So the current guidelines mostly focus on packaging for GHC using Cabal.

Spec file templates

Spec files in line with these templates are generated automatically by the cabal-rpm packaging tool which also adds dependencies listed in the package's .cabal configuration file. Most packages should then build, though for some packages it may be necessary to specify some additional BuildRequires and/or Requires, and to check non-Haskell devel dependencies.

There are three types of Haskell Cabal packages: library only (Lib), binary only (Bin), and binary and library (BinLib):

Standardizing the packaging helps to lower the maintenance burden across Fedora's Haskell packages.

Package Naming

Haskell Bin and BinLib packages should follow the usual Fedora Package Naming Guidelines for base package naming: ie follow the upstream name. Examples include projects like darcs and xmonad. However there may be cases where a Haskell BinLib package is really a Lib package with a minor or unimportant executable: in this case it is better to treat the package a Lib package, optionally with a executable subpackage if appropriate.

The names of Haskell Lib packages, packaged for ghc, are prefixed by "ghc-". For example the Haskell X11 library package is named ghc-X11, and the Haskell mmap library package is named ghc-mmap, etc.

Note that having different Haskell source packages named "ghc-xyz" and "xyz" is not allowed since they would both correspond to the same upstream package named "xyz" on Hackage.

BinLib packages should subpackage their libraries with naming following Lib packages. For example the xmonad BinLib package has library subpackages

  • ghc-xmonad for the shared library, and
  • ghc-xmonad-devel for devel files and the static library.

If a library is packaged for more than one Haskell compiler or interpreter, the base name should instead be prefixed with haskell, e.g. haskell-X11. Such a package would then have subpackages for each compiler and/or interpreter it is built for (e.g. ghc-X11, hugs98-X11, etc).

Package naming preserves case to follow the upstream naming conventions as closely as possible.

Headers

The macro pkg_name is used to carry the name of the upstream library package (i.e. without the Fedora "ghc-" prefix). It should be defined at the top of Lib and BinLib packages:

%global pkg_name <package>

Cabal Flags

Cabal flags for build options should be set by changing the package's .cabal file: this can be done with the cabal-tweak-flag script to avoid having to carry and maintain patches for this. %cabal_configure_options can be set to pass other options to Cabal.

Modifying the .cabal file flags defaults allows packagers and tools like cabal-rpm to track actual package dependencies correctly.

Dependency Generation

Spec file build dependencies are generated by the cabal-rpm packaging tool.

RPM dependencies for Haskell libraries are automatically generated at build-time by the ghc-deps.sh script.

The cabal-tweak-dep-ver script can be used to bump versions of dependencies in the package .cabal file.

Shared and static library linking

GHC uses static libraries by default, but supports shared libraries on some architectures: currently i686 and x86_64. Lib and BinLib packages should provide static, shared, and profiling libraries:

  • the shared library lives in the base library package, and
  • the static and profiling library and header files in the -devel subpackage.

Because GHC still assumes static versions of libraries are installed they need to be in the devel subpackage and it doesn't make sense to subpackage them yet.

Executables in Bin and BinLib packages should be dynamically linked to shared libraries.

Note that executables in most BinLib packages are currently staticly linked against the library in their own package (unless the .cabal file explicitly lists it as a dependency), but dynamically linked against other dependent libraries. BinLib executables that do link dynamically against their own library should use %ghc_fix_dynamic_rpath to fix its RPATH.

Some particular packages may do user compilation during runtime in which case they will need Requires as well as BuildRequires for their dependencies: examples include xmonad and yi which require their devel package to be present to allow users to relink their configuration or customization.

RPM Macros

The templates all have buildrequires for ghc-rpm-macros, which provides macros.ghc to assist with packaging Haskell Cabal packages.

BuildRequires:  ghc-rpm-macros

The main commonly used macros are:

  • %ghc_bin_build
  • %ghc_lib_build
  • %ghc_bin_install
  • %ghc_lib_install

They are used in the templates and explained in more detail below.

Bin packages

Bin package executables should be dynamically linked to shared Haskell libraries when available, but this can be overridden if necessary by defining the ghc_without_dynamic macro.

%build
%ghc_bin_build


%install
%ghc_bin_install

%ghc_bin_build is used to configure and build bin packages. It runs:

  • %global debug_package %{nil}: debuginfo is disabled since ghc's output is not in GDB format.
  • %cabal_configure: configure the package for building and dynamic linking.
  • %cabal build: builds the package.

%ghc_bin_install is used to install bin packages. It runs:

  • %cabal_install: installs the package.
  • %ghc_strip_dynlinked: strips the dynamically linked binary.

Lib and BinLib packages

BinLib package executables should be dynamically linked to other shared Haskell libraries when available, but this can be overridden if necessary by defining the ghc_without_dynamic macro.

Devel subpackages need to setup some Requires:

%package -n ghc-%{pkg_name}-devel
Summary:        Haskell %{pkg_name} library development files
Requires:       ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
Requires(postun): ghc-compiler = %{ghc_version}
Requires:       ghc-%{pkg_name} = %{version}-%{release}

Lib packages need to use %setup -n:

%prep
%setup -q -n %{pkg_name}-%{version}

Both Lib and BinLib have:

%build
%ghc_lib_build


%install
%ghc_lib_install


%post devel
%ghc_pkg_recache


%postun devel
%ghc_pkg_recache

%ghc_lib_build is used to configure, build and generate documentation for Lib and BinLib packages. It runs:

  • %global debug_package %{nil}: debuginfo is disabled since ghc's output is not in DWARF format.
  • %cabal_configure --ghc -p: configures the package for building with ghc and profiling. Libraries should build profiling versions of their static libraries.
  • %cabal build: builds the package.
  • %cabal haddock: generates HTML library documentation from the source code.
    • If necessary (if e.g. documentation is failing to build for some reason) this can be skipped by defining without_haddock.
    • Additionally links to colored html sourcecode are also generated with hscolour, which can be disabled by defining without_hscolour.

%ghc_lib_install is used to install Lib and BinLib packages. It runs:

  • %cabal_install: installs the package without registering it in ghc-pkg.
  • %cabal_pkg_conf: creates ghc-pkg .conf metadata file for package installation time
  • %ghc_gen_filelists: generates rpm filelists.
  • %ghc_strip_dynlinked: strips dynamically linked objects.

%ghc_pkg_recache: used in %post and %postun for devel subpackage - refreshes the ghc package cache database with .conf file data.

Directories

GHC libraries are installed under %ghcpkgdir/%{pkg_name}-%{version}:

Library documentation lives under %ghclibdocdir/%{pkg_name}-%{version}.

File lists

Filelists for shared and devel library subpackages are generated through %ghc_lib_install using the macro %ghc_gen_filelists.

It generates the filelists ghc-%{pkg_name}.files and ghc-%{pkg_name}-devel.files.

Compiling non-Cabal packages

Packages compiling Haskell code without Cabal, ie directly with ghc or ghc --make, should use -O1 optimization, like Cabal does by default.

References