sys-fs/bees: Specify package version to Makefile
[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 # @SUPPORTED_EAPIS: 5 6 7
10 # @BLURB: Provides functions for installing opam packages.
11 # @DESCRIPTION:
12 # Provides dependencies on opam and ocaml, opam-install and a default
13 # src_install for opam-based packages.
14
15 case ${EAPI:-0} in
16     0|1|2|3|4) die "You need at least EAPI-5 to use opam.eclass";;
17     *) ;;
18 esac
19
20 RDEPEND=">=dev-lang/ocaml-4:="
21 DEPEND="${RDEPEND}
22         dev-ml/opam"
23
24 # @FUNCTION: opam-install
25 # @USAGE: <list of packages>
26 # @DESCRIPTION:
27 # Installs the opam packages given as arguments. For each "${pkg}" element in
28 # that list, "${pkg}.install" must be readable from current working directory.
29 opam-install() {
30         local pkg
31         for pkg ; do
32                 opam-installer -i \
33                         --prefix="${ED}usr" \
34                         --libdir="${D}$(ocamlc -where)" \
35                         --docdir="${ED}usr/share/doc/${PF}" \
36                         --mandir="${ED}usr/share/man" \
37                         "${pkg}.install" || die
38         done
39 }
40
41 opam_src_install() {
42         local pkg="${1:-${PN}}"
43         opam-install "${pkg}"
44         # Handle opam putting doc in a subdir
45         if [ -d "${ED}usr/share/doc/${PF}/${pkg}" ] ; then
46                 mv "${ED}usr/share/doc/${PF}/${pkg}/"* "${ED}usr/share/doc/${PF}/" || die
47                 rmdir "${ED}usr/share/doc/${PF}/${pkg}" || die
48         fi
49 }
50
51 EXPORT_FUNCTIONS src_install