1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: oasis.eclass
8 # Original Author: Alexis Ballier <aballier@gentoo.org>
9 # @BLURB: Provides common ebuild phases for oasis-based packages.
11 # Provides common ebuild phases for oasis-based packages.
12 # Most of these packages will just have to inherit the eclass, set their
13 # dependencies and the DOCS variable for base.eclass to install it and be done.
15 # It inherits multilib, findlib, eutils and base eclasses.
16 # Ebuilds using oasis.eclass must be EAPI>=3.
18 # @ECLASS-VARIABLE: OASIS_BUILD_DOCS
20 # Will make oasis_src_compile build the documentation if this variable is
21 # defined and the doc useflag is enabled.
22 # The eclass takes care of setting doc in IUSE but the ebuild should take care
23 # of the extra dependencies it may need.
24 # Set before inheriting the eclass.
26 # @ECLASS-VARIABLE: OASIS_BUILD_TESTS
28 # Will make oasis_src_configure enable building the tests if the test useflag is
29 # enabled. oasis_src_test will then run them.
30 # Note that you sometimes need to enable this for src_test to be useful,
31 # sometimes not. It has to be enabled on a per-case basis.
32 # The eclass takes care of setting test in IUSE but the ebuild should take care
33 # of the extra dependencies it may need.
34 # Set before inheriting the eclass.
37 # @ECLASS-VARIABLE: OASIS_NO_DEBUG
39 # Disable debug useflag usage. Old oasis versions did not support it so we allow
40 # disabling it in those cases.
41 # The eclass takes care of setting debug in IUSE.
42 # Set before inheriting the eclass.
44 # @ECLASS-VARIABLE: OASIS_DOC_DIR
46 # Specify where to install documentation. Default is for ocamldoc HTML.
47 # Change it before inherit if this is not what you want.
48 # EPREFIX is automatically prepended.
49 : ${OASIS_DOC_DIR:="/usr/share/doc/${PF}/html"}
51 inherit multilib findlib eutils base
54 0|1|2) die "You need at least EAPI-3 to use oasis.eclass";;
55 3|4) RDEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]";;
56 *) RDEPEND=">=dev-lang/ocaml-3.12:=[ocamlopt?]";;
60 [ -n "${OASIS_NO_DEBUG}" ] || IUSE="${IUSE} debug"
61 [ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
62 [ -n "${OASIS_BUILD_TESTS}" ] && IUSE="${IUSE} test"
67 # @FUNCTION: oasis_use_enable
68 # @USAGE: < useflag > < variable >
70 # A use_enable-like function for oasis configure variables.
71 # Outputs '--override variable (true|false)', whether useflag is enabled or
73 # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
76 echo "--override $2 $(usex $1 true false)"
79 # @FUNCTION: oasis_src_configure
81 # src_configure phase shared by oasis-based packages.
82 # Extra arguments may be passed via oasis_configure_opts.
83 oasis_src_configure() {
85 [ -n "${OASIS_BUILD_TESTS}" ] && confargs="${confargs} $(use_enable test tests)"
86 [ -n "${OASIS_NO_DEBUG}" ] || confargs="${confargs} $(oasis_use_enable debug debug)"
87 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -configure \
88 --prefix "${ED}/usr" \
89 --libdir "${ED}/usr/$(get_libdir)" \
90 --docdir "${ED}${OASIS_DOC_DIR}" \
91 $(oasis_use_enable ocamlopt is_native) \
93 ${oasis_configure_opts} \
97 # @FUNCTION: oasis_src_compile
99 # Builds an oasis-based package.
100 # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
102 oasis_src_compile() {
103 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -build || die
104 if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
105 ocaml setup.ml -doc || die
109 # @FUNCTION: oasis_src_test
111 # Runs the testsuite of an oasis-based package.
113 LD_LIBRARY_PATH="${S}/_build/lib" ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -test || die
116 # @FUNCTION: oasis_src_install
118 # Installs an oasis-based package.
119 # It calls base_src_install_docs, so will install documentation declared in the
121 oasis_src_install() {
123 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -install || die
124 base_src_install_docs
127 EXPORT_FUNCTIONS src_configure src_compile src_test src_install