1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: oasis.eclass
6 # maintainer-needed@gentoo.org
8 # Original Author: Alexis Ballier <aballier@gentoo.org>
9 # @SUPPORTED_EAPIS: 3 4 5 6 7
10 # @BLURB: Provides common ebuild phases for oasis-based packages.
12 # Provides common ebuild phases for oasis-based packages.
13 # Most of these packages will just have to inherit the eclass, set their
14 # dependencies and the DOCS variable for base.eclass to install it and be done.
16 # It inherits multilib, findlib, eutils and base eclasses.
17 # Ebuilds using oasis.eclass must be EAPI>=3.
19 # @ECLASS-VARIABLE: OASIS_BUILD_DOCS
21 # Will make oasis_src_compile build the documentation if this variable is
22 # defined and the doc useflag is enabled.
23 # The eclass takes care of setting doc in IUSE but the ebuild should take care
24 # of the extra dependencies it may need.
25 # Set before inheriting the eclass.
27 # @ECLASS-VARIABLE: OASIS_BUILD_TESTS
29 # Will make oasis_src_configure enable building the tests if the test useflag is
30 # enabled. oasis_src_test will then run them.
31 # Note that you sometimes need to enable this for src_test to be useful,
32 # sometimes not. It has to be enabled on a per-case basis.
33 # The eclass takes care of setting test in IUSE but the ebuild should take care
34 # of the extra dependencies it may need.
35 # Set before inheriting the eclass.
38 # @ECLASS-VARIABLE: OASIS_NO_DEBUG
40 # Disable debug useflag usage. Old oasis versions did not support it so we allow
41 # disabling it in those cases.
42 # The eclass takes care of setting debug in IUSE.
43 # Set before inheriting the eclass.
45 # @ECLASS-VARIABLE: OASIS_DOC_DIR
47 # Specify where to install documentation. Default is for ocamldoc HTML.
48 # Change it before inherit if this is not what you want.
49 # EPREFIX is automatically prepended.
50 : ${OASIS_DOC_DIR:="/usr/share/doc/${PF}/html"}
52 inherit multilib findlib eutils base
55 0|1|2) die "You need at least EAPI-3 to use oasis.eclass";;
56 3|4) RDEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]";;
57 *) RDEPEND=">=dev-lang/ocaml-3.12:=[ocamlopt?]";;
61 [ -n "${OASIS_NO_DEBUG}" ] || IUSE="${IUSE} debug"
62 [ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
63 if [[ -n ${OASIS_BUILD_TESTS} ]]; then
65 RESTRICT+=" !test? ( test )"
71 # @FUNCTION: oasis_use_enable
72 # @USAGE: < useflag > < variable >
74 # A use_enable-like function for oasis configure variables.
75 # Outputs '--override variable (true|false)', whether useflag is enabled or
77 # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
80 echo "--override $2 $(usex $1 true false)"
83 # @FUNCTION: oasis_src_configure
85 # src_configure phase shared by oasis-based packages.
86 # Extra arguments may be passed via oasis_configure_opts.
87 oasis_src_configure() {
89 [ -n "${OASIS_BUILD_TESTS}" ] && confargs="${confargs} $(use_enable test tests)"
90 [ -n "${OASIS_NO_DEBUG}" ] || confargs="${confargs} $(oasis_use_enable debug debug)"
91 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -configure \
92 --prefix "${ED}/usr" \
93 --libdir "${ED}/usr/$(get_libdir)" \
94 --docdir "${ED}${OASIS_DOC_DIR}" \
95 $(oasis_use_enable ocamlopt is_native) \
97 ${oasis_configure_opts} \
101 # @FUNCTION: oasis_src_compile
103 # Builds an oasis-based package.
104 # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
106 oasis_src_compile() {
107 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -build || die
108 if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
109 ocaml setup.ml -doc || die
113 # @FUNCTION: oasis_src_test
115 # Runs the testsuite of an oasis-based package.
117 LD_LIBRARY_PATH="${S}/_build/lib" ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -test || die
120 # @FUNCTION: oasis_src_install
122 # Installs an oasis-based package.
123 # It calls base_src_install_docs, so will install documentation declared in the
125 oasis_src_install() {
127 ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -install || die
128 base_src_install_docs
131 EXPORT_FUNCTIONS src_configure src_compile src_test src_install