dev-qt/qtopengl: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / oasis.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: oasis.eclass
5 # @MAINTAINER:
6 # maintainer-needed@gentoo.org
7 # @AUTHOR:
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.
11 # @DESCRIPTION:
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.
15 #
16 # It inherits multilib, findlib, eutils and base eclasses.
17 # Ebuilds using oasis.eclass must be EAPI>=3.
18
19 # @ECLASS-VARIABLE: OASIS_BUILD_DOCS
20 # @DESCRIPTION:
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.
26
27 # @ECLASS-VARIABLE: OASIS_BUILD_TESTS
28 # @DESCRIPTION:
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.
36
37
38 # @ECLASS-VARIABLE: OASIS_NO_DEBUG
39 # @DESCRIPTION:
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.
44
45 # @ECLASS-VARIABLE: OASIS_DOC_DIR
46 # @DESCRIPTION:
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"}
51
52 inherit multilib findlib eutils base
53
54 case ${EAPI:-0} in
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?]";;
58 esac
59
60 IUSE="+ocamlopt"
61 [ -n "${OASIS_NO_DEBUG}" ]   || IUSE="${IUSE} debug"
62 [ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
63 if [[ -n ${OASIS_BUILD_TESTS} ]]; then
64         IUSE+=" test"
65         RESTRICT+=" !test? ( test )"
66 fi
67
68 DEPEND="${RDEPEND}
69         dev-ml/ocamlbuild"
70
71 # @FUNCTION: oasis_use_enable
72 # @USAGE: < useflag > < variable >
73 # @DESCRIPTION:
74 # A use_enable-like function for oasis configure variables.
75 # Outputs '--override variable (true|false)', whether useflag is enabled or
76 # not.
77 # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
78 # argument.
79 oasis_use_enable() {
80         echo "--override $2 $(usex $1 true false)"
81 }
82
83 # @FUNCTION: oasis_src_configure
84 # @DESCRIPTION:
85 # src_configure phase shared by oasis-based packages.
86 # Extra arguments may be passed via oasis_configure_opts.
87 oasis_src_configure() {
88         local confargs=""
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) \
96                 ${confargs} \
97                 ${oasis_configure_opts} \
98                 || die
99 }
100
101 # @FUNCTION: oasis_src_compile
102 # @DESCRIPTION:
103 # Builds an oasis-based package.
104 # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
105 # enabled.
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
110         fi
111 }
112
113 # @FUNCTION: oasis_src_test
114 # @DESCRIPTION:
115 # Runs the testsuite of an oasis-based package.
116 oasis_src_test() {
117          LD_LIBRARY_PATH="${S}/_build/lib" ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -test || die
118 }
119
120 # @FUNCTION: oasis_src_install
121 # @DESCRIPTION:
122 # Installs an oasis-based package.
123 # It calls base_src_install_docs, so will install documentation declared in the
124 # DOCS variable.
125 oasis_src_install() {
126         findlib_src_preinst
127         ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -install || die
128         base_src_install_docs
129 }
130
131 EXPORT_FUNCTIONS src_configure src_compile src_test src_install