summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Ballier <aballier@gentoo.org>2017-08-02 12:07:33 +0200
committerAlexis Ballier <aballier@gentoo.org>2017-08-02 13:22:38 +0200
commitb069fa7918bf57940e3f2420b14067f91609ef76 (patch)
tree71d90e0171d8d6e009809b79af50645079bbcae2 /eclass/opam.eclass
parentdev-ml/ppx_optcomp: add missing dev-ml/ocaml-migrate-parsetree:= dep (diff)
downloadgentoo-b069fa7918bf57940e3f2420b14067f91609ef76.tar.gz
gentoo-b069fa7918bf57940e3f2420b14067f91609ef76.tar.bz2
gentoo-b069fa7918bf57940e3f2420b14067f91609ef76.zip
opam.eclass: Initial import.
Diffstat (limited to 'eclass/opam.eclass')
-rw-r--r--eclass/opam.eclass49
1 files changed, 49 insertions, 0 deletions
diff --git a/eclass/opam.eclass b/eclass/opam.eclass
new file mode 100644
index 000000000000..861d6cc2380a
--- /dev/null
+++ b/eclass/opam.eclass
@@ -0,0 +1,49 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: opam.eclass
+# @MAINTAINER:
+# Gentoo ML Project <ml@gentoo.org>
+# @AUTHOR:
+# Alexis Ballier <aballier@gentoo.org>
+# @BLURB: Provides functions for installing opam packages.
+# @DESCRIPTION:
+# Provides dependencies on opam and ocaml, opam-install and a default
+# src_install for opam-based packages.
+
+case ${EAPI:-0} in
+ 0|1|2|3|4) die "You need at least EAPI-5 to use opam.eclass";;
+ *) ;;
+esac
+
+RDEPEND=">=dev-lang/ocaml-4:="
+DEPEND="${RDEPEND}
+ dev-ml/opam"
+
+# @FUNCTION: opam-install
+# @USAGE: <list of packages>
+# @DESCRIPTION:
+# Installs the opam packages given as arguments. For each "${pkg}" element in
+# that list, "${pkg}.install" must be readable from current working directory.
+opam-install() {
+ local pkg
+ for pkg ; do
+ opam-installer -i \
+ --prefix="${ED}usr" \
+ --libdir="${D}$(ocamlc -where)" \
+ --docdir="${ED}usr/share/doc/${PF}" \
+ --mandir="${ED}usr/share/man" \
+ "${pkg}.install" || die
+ done
+}
+
+opam_src_install() {
+ opam-install "${PN}"
+ # Handle opam putting doc in a subdir
+ if [ -d "${ED}usr/share/doc/${PF}/${PN}" ] ; then
+ mv "${ED}usr/share/doc/${PF}/${PN}/"* "${ED}usr/share/doc/${PF}/" || die
+ rmdir "${ED}usr/share/doc/${PF}/${PN}" || die
+ fi
+}
+
+EXPORT_FUNCTIONS src_install