Difference between revisions of "OCaml package guidelines"

From ArchWiki
Jump to: navigation, search
(OCaml PKGBUILD Example)
(OCaml Library Locations)
Line 6: Line 6:
  
 
==OCaml Library Locations==
 
==OCaml Library Locations==
All OCaml libraries should be installed via ocaml-findlib, ocaml-findlib maintains a means whereby ocaml packages are more clearly tracked. The only distinction for ocaml-findlib is that it requires that a META file be created. Most OCaml packages already have a META file, for those which do not provide an upstream META file chances are the file can be obtained from the Debian/Ubuntu or Fedora package.
+
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.
  
The OCaml libraries should all be installed under /usr/lib/ocaml, there has been some confusion about where to install OCaml libraries, and many OCaml libraries have been installed under /usr/lib/ocaml/site-lib, this practice can break a number of OCaml program builds and has resulted in a schism in OCaml package development. Maintaining a central location for all OCaml packages will aleviate a number of problems with the continued development of ArchLinux OCaml support.
+
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.
  
In most packages the OCaml findlib directory will need to be specified, this should never be specified statically, but should use the ocaml-findlib destdir variable. Generally this is set in this manner:
+
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.
OCAMLFIND_DESTDIR=${pkgdir}/$(ocamlfind printconf destdir)
+
 
 +
The '''OCAMLFIND_DESTDIR''' variable should be used when installing packages with ocaml-lib. See the example PKGBUILD below for details.
  
 
== Bytecode ==
 
== Bytecode ==

Revision as of 09:18, 2 January 2011


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

If bytecode is produced make sure to include "options=('!strip')". Otherwise the packaging process will damage the OCaml bytecode.

OCaml PKGBUILD Example

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

pkgname=ocaml-<package name>
pkgver=4.2
pkgrel=1
license=('')
arch=('i686' 'x86_64')
pkgdesc="An OCaml Package"
url=""
depends=()
makedepends=('ocaml' 'ocaml-findlib')
source=()
options=('!strip')
md5sums=()

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

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

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

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