OCaml package guidelines

From ArchWiki
Revision as of 09:21, 2 January 2011 by Xyne (Talk | contribs) (Bytecode)

Jump to: navigation, search

Package Naming

For libraries, use ocaml-modulename. For applications, use the program name. In either case, the pkgname should be entirely lowercase.

OCaml Library Locations

OCaml libraries should be installed under /usr/lib/ocaml. Libraries were previously installed under /usr/lib/ocaml or /usr/lib/ocaml/site-lib, depending on the package. This mixture prevented some packages from working with others and fragmented OCaml development on Arch Linux. The use of /usr/lib/ocaml/site-lib has therefore been discontinued.

OCaml libraries should be installed using ocaml-findlib. ocaml-findlib includes library metadata in the package that makes it easy to manage libraries. It is a de-facto standard and a lot of OCaml software now requires.

ocaml-findlib extracts necessary data from a file named META that should be included in the source archive. If this file is not included, one should either be obtained from the corresponding Debian, Ubuntu, or Fedora package, or created for the package by the maintainer. A request to include the file should also be made to the upstream developers of the package.

The OCAMLFIND_DESTDIR variable should be used when installing packages with ocaml-lib. See the example PKGBUILD below for details.

Bytecode And Architecture

If bytecode is produced then the PKGBUILD must contain the following to protect the bytecode and to correctly specify the package architecture:

  • options=('!strip')
  • arch=('i686' 'x86_64')

If bytecode is not produce then the package should be made architecture-independent with the following:

  • arch=('any')

OCaml PKGBUILD Example

# Contributor: Your Name <youremail@domain.com>

pkgname=ocaml-<package name>
arch=('i686' 'x86_64')
pkgdesc="An OCaml Package"

OCAMLFIND_DESTDIR="${pkgdir}$(ocamlfind printconf destdir)"

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr

package() {
  env DESTDIR="${pkgdir}" \
    make install

Keep in mind that many OCaml Packages will often need extra parameters passed to make and make install.