eclass/ruby-ng.eclass: make ruby23 a no-op
[gentoo.git] / eclass / oasis.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: oasis.eclass
5 # @MAINTAINER:
6 # ml@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 [ -n "${OASIS_BUILD_TESTS}" ] && IUSE="${IUSE} test"
64
65 DEPEND="${RDEPEND}
66         dev-ml/ocamlbuild"
67
68 # @FUNCTION: oasis_use_enable
69 # @USAGE: < useflag > < variable >
70 # @DESCRIPTION:
71 # A use_enable-like function for oasis configure variables.
72 # Outputs '--override variable (true|false)', whether useflag is enabled or
73 # not.
74 # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
75 # argument.
76 oasis_use_enable() {
77         echo "--override $2 $(usex $1 true false)"
78 }
79
80 # @FUNCTION: oasis_src_configure
81 # @DESCRIPTION:
82 # src_configure phase shared by oasis-based packages.
83 # Extra arguments may be passed via oasis_configure_opts.
84 oasis_src_configure() {
85         local confargs=""
86         [ -n "${OASIS_BUILD_TESTS}" ] && confargs="${confargs} $(use_enable test tests)"
87         [ -n "${OASIS_NO_DEBUG}"    ] || confargs="${confargs} $(oasis_use_enable debug debug)"
88         ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -configure \
89                 --prefix "${ED}/usr" \
90                 --libdir "${ED}/usr/$(get_libdir)" \
91                 --docdir "${ED}${OASIS_DOC_DIR}" \
92                 $(oasis_use_enable ocamlopt is_native) \
93                 ${confargs} \
94                 ${oasis_configure_opts} \
95                 || die
96 }
97
98 # @FUNCTION: oasis_src_compile
99 # @DESCRIPTION:
100 # Builds an oasis-based package.
101 # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
102 # enabled.
103 oasis_src_compile() {
104         ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -build || die
105         if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
106                 ocaml setup.ml -doc || die
107         fi
108 }
109
110 # @FUNCTION: oasis_src_test
111 # @DESCRIPTION:
112 # Runs the testsuite of an oasis-based package.
113 oasis_src_test() {
114          LD_LIBRARY_PATH="${S}/_build/lib" ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -test || die
115 }
116
117 # @FUNCTION: oasis_src_install
118 # @DESCRIPTION:
119 # Installs an oasis-based package.
120 # It calls base_src_install_docs, so will install documentation declared in the
121 # DOCS variable.
122 oasis_src_install() {
123         findlib_src_preinst
124         ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -install || die
125         base_src_install_docs
126 }
127
128 EXPORT_FUNCTIONS src_configure src_compile src_test src_install