dev-lang/ocaml: x86 stable wrt bug #708696
[gentoo.git] / dev-lang / ocaml / ocaml-4.09.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 HOMEPAGE="https://ocaml.org/"
7 SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz"
8 DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
9
10 LICENSE="LGPL-2.1"
11 SLOT="0/${PV}"
12 KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~x86-solaris"
13 IUSE="emacs flambda latex +ocamlopt spacetime xemacs"
14
15 RDEPEND="sys-libs/binutils-libs:=
16         spacetime? ( sys-libs/libunwind:= )"
17 BDEPEND="${RDEPEND}
18         virtual/pkgconfig"
19 PDEPEND="emacs? ( app-emacs/ocaml-mode )
20         xemacs? ( app-xemacs/ocaml )"
21
22 PATCHES=("${FILESDIR}"/${PN}-4.09.0-gcc-10.patch)
23
24 src_prepare() {
25         default
26         # Upstream build ignores LDFLAGS in several places.
27         sed -i -e 's/\(^MKDLL=.*\)/\1 $(LDFLAGS)/' \
28                 -e 's/\(^OC_CFLAGS=.*\)/\1 $(LDFLAGS)/' \
29                 -e 's/\(^OC_LDFLAGS=.*\)/\1 $(LDFLAGS)/' \
30                 Makefile.config.in || die "LDFLAGS fix failed"
31         # ${P} overrides upstream build's own P due to a wrong assignment operator.
32         sed -i -e 's/^P ?=/P =/' stdlib/StdlibModules || die "P fix failed"
33 }
34
35 src_configure() {
36         local opt=(
37                 --bindir="${EPREFIX}/usr/bin"
38                 --libdir="${EPREFIX}/usr/$(get_libdir)/ocaml"
39                 --mandir="${EPREFIX}/usr/share/man"
40                 --prefix="${EPREFIX}/usr"
41                 $(use_enable flambda)
42                 $(use_enable spacetime)
43         )
44         econf ${opt[@]}
45 }
46
47 src_compile() {
48         if use ocamlopt ; then
49                 emake world.opt
50         else
51                 emake world
52         fi
53 }
54
55 src_test() {
56         if use ocamlopt ; then
57                 # OCaml tests only work when run sequentially
58                 emake -j1 -C testsuite all
59         else
60                 ewarn "${PN} was built without 'ocamlopt' USE flag; skipping tests."
61         fi
62 }
63
64 src_install() {
65         default
66         dodir /usr/include
67         # Create symlink for header files
68         dosym "../$(get_libdir)/ocaml/caml" /usr/include/caml
69         dodoc Changes README.adoc
70         # Create envd entry for latex input files
71         if use latex ; then
72                 echo "TEXINPUTS=\"${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:\"" > "${T}/99ocamldoc"
73                 doenvd "${T}/99ocamldoc"
74         fi
75         # Install ocaml-rebuild portage set
76         insinto /usr/share/portage/config/sets
77         doins "${FILESDIR}/ocaml.conf"
78 }