Difference between revisions of "OCaml package guidelines"

From ArchWiki
Jump to: navigation, search
(added links to related articles with Template:Package Guidelines)
m (use templates instead of space-initial lines)
Line 22: Line 22:
 
OCaml packages that install executables using OASIS ignore {{ic|DESTDIR}}. This is a known limitation of OASIS ([https://forge.ocamlcore.org/tracker/?func=detail&atid=294&aid=852&group_id=54 issue #852]). One way to enable {{ic|DESTDIR}}-like functionality is to run the {{ic|configure}} script with the {{ic|--destdir}} argument, like so:
 
OCaml packages that install executables using OASIS ignore {{ic|DESTDIR}}. This is a known limitation of OASIS ([https://forge.ocamlcore.org/tracker/?func=detail&atid=294&aid=852&group_id=54 issue #852]). One way to enable {{ic|DESTDIR}}-like functionality is to run the {{ic|configure}} script with the {{ic|--destdir}} argument, like so:
  
build() {
+
{{bc|<nowiki>build() {
    cd "${srcdir}/${srcname}-${pkgver}"
+
    cd "${srcdir}/${srcname}-${pkgver}"
    ./configure --prefix /usr --destdir "$pkgdir"  
+
    ./configure --prefix /usr --destdir "$pkgdir"
+
 
    # build commands
+
    # build commands
}
+
}</nowiki>}}
  
 
== OCaml Bytecode and Levels ==
 
== OCaml Bytecode and Levels ==
 +
 
OCaml can run code on multiple "levels", the top level interprets OCaml Code without compiling, the bytecode level creates machine independent bytecode and the native level creates machine code binaries (just like C/C++).
 
OCaml can run code on multiple "levels", the top level interprets OCaml Code without compiling, the bytecode level creates machine independent bytecode and the native level creates machine code binaries (just like C/C++).
  
Line 46: Line 47:
 
== OCaml PKGBUILD Example ==
 
== OCaml PKGBUILD Example ==
  
# Contributor: Your Name <youremail@domain.com>
+
{{bc|1=
+
# Contributor: Your Name <youremail@domain.com>
pkgname=ocaml-<package name>
+
 
pkgver=4.2
+
pkgname=ocaml-<package name>
pkgrel=1
+
pkgver=4.2
license=('')
+
pkgrel=1
arch=('i686' 'x86_64')
+
license=('')
pkgdesc="An OCaml Package"
+
arch=('i686' 'x86_64')
url=""
+
pkgdesc="An OCaml Package"
depends=('ocaml')
+
url=""
makedepends=('ocaml-findlib')
+
depends=('ocaml')
source=()
+
makedepends=('ocaml-findlib')
options=('!strip')
+
source=()
md5sums=()
+
options=('!strip')
+
md5sums=()
OCAMLFIND_DESTDIR="${pkgdir}$(ocamlfind printconf destdir)"
+
 
+
OCAMLFIND_DESTDIR="${pkgdir}$(ocamlfind printconf destdir)"
build() {
+
 
  cd "${srcdir}/${pkgname}-${pkgver}"
+
build() {
  mkdir -p "$OCAMLFIND_DESTDIR"
+
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr
+
  mkdir -p "$OCAMLFIND_DESTDIR"
  make
+
  ./configure --prefix=/usr
}
+
  make
+
}
package() {
+
 
  cd "${srcdir}/${pkgname}-${pkgver}"
+
package() {
  env DESTDIR="${pkgdir}" \
+
  cd "${srcdir}/${pkgname}-${pkgver}"
    OCAMLFIND_DESTDIR="$OCAMLFIND_DESTDIR" \
+
  env DESTDIR="${pkgdir}" \
    make install
+
    OCAMLFIND_DESTDIR="$OCAMLFIND_DESTDIR" \
}
+
    make install
 +
}
 +
}}
  
 
Keep in mind that many OCaml Packages will often need extra parameters passed to make and make install. Also remember to remove the'' '!strip' ''option and change the architecture if the package does not produce bytecode.
 
Keep in mind that many OCaml Packages will often need extra parameters passed to make and make install. Also remember to remove the'' '!strip' ''option and change the architecture if the package does not produce bytecode.

Revision as of 20:36, 18 March 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Summary help replacing me
Writing PKGBUILDs for sowtware written in OCaml.

Template:Package Guidelines

Package Naming

For libraries, use ocaml-modulename. For applications, use the program name. In either case, the name 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 it.

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-findlib. See the example PKGBUILD below for details.

OASIS

OCaml packages that install executables using OASIS ignore DESTDIR. This is a known limitation of OASIS (issue #852). One way to enable DESTDIR-like functionality is to run the configure script with the --destdir argument, like so:

build() {
    cd "${srcdir}/${srcname}-${pkgver}"
    ./configure --prefix /usr --destdir "$pkgdir"

    # build commands
}

OCaml Bytecode and Levels

OCaml can run code on multiple "levels", the top level interprets OCaml Code without compiling, the bytecode level creates machine independent bytecode and the native level creates machine code binaries (just like C/C++).

When building OCaml Packages you need to be aware if the build process is compiling native machine code, bytecode, or as in many cases both. This creates a number of situations which can cause problems with package options and the right dependencies.

If bytecode is produced at all then the PKGBUILD must contain the following to protect the bytecode:

options=('!strip')

If the package does not contain bytecode and only distributes a binary, then ocaml is not needed as a dependency, but it of course is required as a makedepends since the ocaml package provides the OCaml compiler. If the package contains both native code and bytecode then ocaml should be a dependency and a makedepends.

OCaml code is rarely (if ever) distributed as bytecode only and will almost always include native code: the only case where using any as the arch is advisable is when only un-compiled source code is distributed, usually with a library, though many libraries still distribute native code.

The moral of the story here is to be aware of what it is you are distributing, chances are your package contains both native machine code and 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=('ocaml')
makedepends=('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() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  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. Also remember to remove the '!strip' option and change the architecture if the package does not produce bytecode.