kde-apps/ksirk: x86 stable (bug #661810)
[gentoo.git] / eclass / opam.eclass
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: opam.eclass
5 # @MAINTAINER:
6 # Gentoo ML Project <ml@gentoo.org>
7 # @AUTHOR:
8 # Alexis Ballier <aballier@gentoo.org>
9 # @BLURB: Provides functions for installing opam packages.
10 # @DESCRIPTION:
11 # Provides dependencies on opam and ocaml, opam-install and a default
12 # src_install for opam-based packages.
13
14 case ${EAPI:-0} in
15     0|1|2|3|4) die "You need at least EAPI-5 to use opam.eclass";;
16     *) ;;
17 esac
18
19 RDEPEND=">=dev-lang/ocaml-4:="
20 DEPEND="${RDEPEND}
21         dev-ml/opam"
22
23 # @FUNCTION: opam-install
24 # @USAGE: <list of packages>
25 # @DESCRIPTION:
26 # Installs the opam packages given as arguments. For each "${pkg}" element in
27 # that list, "${pkg}.install" must be readable from current working directory.
28 opam-install() {
29         local pkg
30         for pkg ; do
31                 opam-installer -i \
32                         --prefix="${ED}usr" \
33                         --libdir="${D}$(ocamlc -where)" \
34                         --docdir="${ED}usr/share/doc/${PF}" \
35                         --mandir="${ED}usr/share/man" \
36                         "${pkg}.install" || die
37         done
38 }
39
40 opam_src_install() {
41         local pkg="${1:-${PN}}"
42         opam-install "${pkg}"
43         # Handle opam putting doc in a subdir
44         if [ -d "${ED}usr/share/doc/${PF}/${pkg}" ] ; then
45                 mv "${ED}usr/share/doc/${PF}/${pkg}/"* "${ED}usr/share/doc/${PF}/" || die
46                 rmdir "${ED}usr/share/doc/${PF}/${pkg}" || die
47         fi
48 }
49
50 EXPORT_FUNCTIONS src_install