1da72719f91e7c790ec653a2939516e69cc27ef1
[gentoo.git] / dev-ml / findlib / findlib-1.8.1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit multilib eutils
7
8 DESCRIPTION="OCaml tool to find/use non-standard packages"
9 HOMEPAGE="http://projects.camlcity.org/projects/findlib.html"
10 SRC_URI="http://download.camlcity.org/download/${P}.tar.gz"
11 IUSE="doc +ocamlopt tk"
12
13 LICENSE="MIT"
14
15 SLOT="0"
16 KEYWORDS="~alpha ~amd64 arm ~arm64 ~hppa ia64 ~mips ~ppc ~ppc64 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos"
17
18 DEPEND=">=dev-lang/ocaml-4.02.3-r1:=[ocamlopt?]
19         tk? ( dev-ml/labltk:= )"
20 RDEPEND="${DEPEND}"
21
22 src_prepare() {
23         sed -i 's/\$llabltk \$lcamlp4 \$lobuild//' configure || die "Unable to make meta external."
24         export ocamlfind_destdir="${EPREFIX}/usr/$(get_libdir)/ocaml"
25         export stublibs="${ocamlfind_destdir}/stublibs"
26 }
27
28 src_configure() {
29         local myconf
30         use tk && myconf="-with-toolbox"
31         ./configure -bindir "${EPREFIX}"/usr/bin -mandir "${EPREFIX}"/usr/share/man \
32                 -sitelib ${ocamlfind_destdir} \
33                 -config ${ocamlfind_destdir}/findlib/findlib.conf \
34                 -no-custom \
35                 ${myconf} || die "configure failed"
36 }
37
38 src_compile() {
39         emake -j1 all
40         if use ocamlopt; then
41                 emake -j1 opt # optimized code
42         fi
43 }
44
45 src_install() {
46         emake prefix="${D}" install
47
48         dodir "${stublibs#${EPREFIX}}"
49
50         cd "${S}/doc"
51         dodoc QUICKSTART README DOCINFO
52         use doc && dohtml -r ref-html guide-html
53 }
54
55 check_stublibs() {
56         local ocaml_stdlib=`ocamlc -where`
57         local ldconf="${ocaml_stdlib}/ld.conf"
58
59         if [ ! -e ${ldconf} ]
60         then
61                 echo "${ocaml_stdlib}" > ${ldconf}
62                 echo "${ocaml_stdlib}/stublibs" >> ${ldconf}
63         fi
64
65         if [ -z `grep -e ${stublibs} ${ldconf}` ]
66         then
67                 echo ${stublibs} >> ${ldconf}
68         fi
69 }
70
71 pkg_postinst() {
72         check_stublibs
73 }