summaryrefslogtreecommitdiff
path: root/dev-lang/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/ocaml')
-rw-r--r--dev-lang/ocaml/Manifest14
-rw-r--r--dev-lang/ocaml/files/ocaml-rebuild.sh51
-rw-r--r--dev-lang/ocaml/files/ocaml.conf5
-rw-r--r--dev-lang/ocaml/metadata.xml15
-rw-r--r--dev-lang/ocaml/ocaml-4.04.2.ebuild127
-rw-r--r--dev-lang/ocaml/ocaml-4.05.0.ebuild129
-rw-r--r--dev-lang/ocaml/ocaml-4.06.0_beta1.ebuild127
7 files changed, 468 insertions, 0 deletions
diff --git a/dev-lang/ocaml/Manifest b/dev-lang/ocaml/Manifest
new file mode 100644
index 000000000000..3993fa95e4f5
--- /dev/null
+++ b/dev-lang/ocaml/Manifest
@@ -0,0 +1,14 @@
+AUX ocaml-rebuild.sh 1120 SHA256 893320630726c58ea3b501ef16913c150c50ea9d6cd38ecd26fa0679597d3a7c SHA512 05a3e81e95533135d9895091c21621c73ae82851abd4889d64f035979eb25f8d90b60f469d7ef5e789fd1a4adffd6bbe255e6708c14c24a04f8a423507d19a40 WHIRLPOOL 11eec7641f2bced1593f21e3b4d9bc1d6156082e8e23d4abc2cfd05294dccd13a9bf5c102b60c0dcca0b565f6edbf8e7364d3236d57db18dcdd520fe05d379a6
+AUX ocaml.conf 177 SHA256 b7f7ad0ff15bec096dcb87265d87f9b0ce8f946d4a2676dd7638ca0e14bb05c1 SHA512 4f0a48b8101b77d568d8d0a852f2a21fd46b7947c5d3f975ee4cd8a9c37c993d689cf5fb53b54a6b2740cb865051dc50c74c0c373eb697fca800ca143d401aa4 WHIRLPOOL d25c9ac2a565a5384c7f645be433faac192e4c41f55a08d74e99ec022ce06132a560070bb4771b261c6f023d3aec72fddb47279d5ab2cfe8cc93c70c97ff16d5
+DIST ocaml-4.04.2.tar.gz 4061873 SHA256 6277a477956fc7b76f28af9941dce2984d0df809a0361093eb2e28234bf9c8ed SHA512 8b6a0319307cbb7451594d2f7c63851299d3e7d6ae7879e7525373304f9fd5a9b01d503ecd313a12a3cae24a4a7cb909f7aeebbb70efaa5277137189ea4558cb WHIRLPOOL b8b4fe7b86525686765cb02f221e6a75c06466cb172348474a18163648f7269bd29ca2bea4dcb890ce6fef86b91743139bfaa4e4fbda53d288d696b8572c5639
+DIST ocaml-4.05.0.tar.gz 4431750 SHA256 e5d8a6f629020c580473d8afcfcb06c3966d01929f7b734f41dc0c737cd8ea3f SHA512 9a060ae4b741e1687277403e5bdb8f6eda2e2ebf6c45f7c0149b66ea1213cb26d13febfbb3f11c12543e244cfdd053b786b09c4145e2348e5d89a7206f7de225 WHIRLPOOL 75531b9f1f229aab9813b665908bd3df10abe4648c7362584f19e3faeceecadea8fa7bda14dc17466d98d3aac9dc1ce9ca8b40de3434d861060f461c4f972845
+DIST ocaml-4.06.0-beta1.tar.gz 4558889 SHA256 d46ecd2f69782760241f56744bc41f1286d8864e38f8efb15341573577d37435 SHA512 c7ec8468bae99cd5d7b3a44ef856c3b000e60004c9acc590fd0eb0ef4acbc59a79ddee35c765171b3c58f6c1b2663194d6b0d08d668aec418f056a265dd49012 WHIRLPOOL 37b200dd7adf19acc60224b8e8dd51ef146187e00d796a25685b19717fd8d1644bb6c7a80961654db5bff44d4ab9e182c36e4b959b2888cf30718527559fb29f
+DIST ocaml-patches-10.tar.bz2 943 SHA256 4fbd5ca4ed1755f8a37d8c101342552a4f60c8c0b651e46a703b8da8a9451894 SHA512 fe39066c25267f2ff828e6746bcda5f5b1e40e22a063d83268cfcc2fcda28dbd7e714751466491385d054ba2eadff2d0a4c407d5fe5db2f98931bdde612f07e9 WHIRLPOOL 752bfc72838654b8448bb0d5516f10eba77eb399fb71953bbad129db206567340f29b8d8568c2ec728e3fe17ccb858fd161ee3d451570d9447c9f63f5d7ac582
+DIST ocaml-patches-8.tar.bz2 1803 SHA256 bce7ea483842f6e201cdf3de266928b39b5b45322315010291ed28f811720525 SHA512 fc477fbb5bdec60a3c4d3dfa110119bb579560ac0e0e57e30e076da72643bda6359c06fd3745fd3436c5d611dbbd888ec2921e9d1920f4929df633c35a797411 WHIRLPOOL ae73b5377744add3afce012b5745fafd70c0f92f75cd6cf91560e0f2ba359a91f7276afed13db145c307be9fdf79c339c2c69be6946565354c68d701fa61a4be
+DIST ocaml-patches-9.tar.bz2 1700 SHA256 1709c257536e9a8fdd25bfa651c4fb1aaff4c97596dbaa70eb4d4afc7020ae92 SHA512 cc19f9104fac69aecc5effa8cb772342e1fb61cdcd38ba0176efe04cf3d710b1c56d5178748f3bd29099af91fa684da432a8ef8d42de76dbd1b6954a255ea6c0 WHIRLPOOL 185406937ff0fdbfba3eed0e2e4267efac5aff1a15fc3cc5ea4434a57bf4a790bd21a801613d768328f3ab5046a0c85a0b73681c6711c348d0d0755a723c4857
+EBUILD ocaml-4.04.2.ebuild 3525 SHA256 34864087bd68836e6b980412904b17209961a9826cad6de135f60e176bdea9a1 SHA512 5de6fdb7e790131930308d9200a8a9d4403007a1f80430e1d80b4fc97bcf270a533c9a91413266721a4cbc83ba798b831cfe2c2ab6aa698b83a1e127c5e46795 WHIRLPOOL 9f09ab532546e9e032e88047d1795f67a4991152f3845623fa55da7fbcdff0bccdf6fce948696d63a053e107be9068e130a75d1caa7086c6ade63d80a7b504c2
+EBUILD ocaml-4.05.0.ebuild 3683 SHA256 626573c53b07fd1bf44db62403ae3cab709489563de2a78ef71158edc3f8a7f5 SHA512 21c549fd5c02f4850d7f240f386bab8e16e884909d61ff34261cc9faed4e883af766229910ac4baf5e261c4c4a11a33af85f34d29c9681161d892bed79bb859c WHIRLPOOL 8a8874ee33fb81a4873d4c77174eb69fe0b7f8388db2177e396e82658d179ba9edcaceac97d93dc8490dd5e8c351248ce454373f624d905f2d03d025bfe0322d
+EBUILD ocaml-4.06.0_beta1.ebuild 3617 SHA256 d57d16a1ddea24dc76f3a8b1ca02666f7ab52de47f815f5cbe1db1210aaebeef SHA512 203a07d771e228cf4a6f37380f43d3f92d8972e427aef417d3536e05e5e0be9377bb2877caf39121870de71423f9c962cd70269d8198175ca9d333c3fc484a7d WHIRLPOOL b116c36d643f0d0344021b6dc6dd6a5c9463c43249f8712786cfc13aaa43c3356303080c0dd015cfde537c2351b77fb28b75ce303525d837ded5bda20e48e062
+MISC ChangeLog 6950 SHA256 a6352b62089b1248b5e36ea1ed99af19b481ef6b2da7767135959785249ec140 SHA512 b016154abe9904f90f893f38f949691afc5b92fba081bfc8cd58b211b84a0f4e0b8b7253919fd3ebe69ebe97f8c3b477fe26466a55cf1f12f34b3314bf9ce9f3 WHIRLPOOL af739a72c399cdc31e19f12aa6db8e3b3dfbf1d2df310c5a7876e0664467fe7ffee068b0255e14c5cd01c1c71688700835b1b42129c9fea4be95d824cbc46dbd
+MISC ChangeLog-2015 35188 SHA256 85b9f07747d3a242acec77142ea296133a59bb9d79261d6960cf1e407a1ee2e0 SHA512 3658b2c40895f5dd5b2a74f01aa27bac1416ac2abfbfaff9176331cfe6aff3a4a81e62e222c85a5bc9f36779ca2dfda24c64fbc9e530cbfb64a0f1d221954852 WHIRLPOOL 1108b78932d6ecdc15624297ef6165168956587db4cd0c804e63554daede6be88f76860c76bc8de78131c0d10b9c344406de1eb93205765f08aa7644e4dfaea3
+MISC metadata.xml 684 SHA256 1f995f5ba1ee7b37d07d64c88f3d22b5e06cad97df407b28d3f061c766e06b0a SHA512 9b01c74d5b46a1342840bdc6a90dab0943a0072ae5c65d9edf902ab04b6f911600e8aee4c8b89e3b35a7f4e018a13eecda59c4df64e03a05ebeeb2ebededf58c WHIRLPOOL a53011ea2e5c5ba285612854a045e3901709ef30c351390b4523e3fbab88ead8f1b8a9c584bbddcb379b7a8e47fef505c2597a7a0e5427334d87badad9037388
diff --git a/dev-lang/ocaml/files/ocaml-rebuild.sh b/dev-lang/ocaml/files/ocaml-rebuild.sh
new file mode 100644
index 000000000000..7dd14a4eb7d2
--- /dev/null
+++ b/dev-lang/ocaml/files/ocaml-rebuild.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+# run like this: ocaml-rebuild.sh [-h | -f] [emerge_options]
+
+emerge=/usr/bin/emerge
+
+if [ "$1" = "-h" ]
+then
+ echo "usage: ocaml-rebuild.sh [-h | -f(orce)] [emerge_options]"
+ echo "With -f, the packages will first be unmerged and then emerged"
+ echo "with the given options to ensuree correct dependancy analysis."
+ echo "Otherwise emerge is run with the --pretend flag and the given"
+ echo "options."
+ echo "It is recommended to keep the list of rebuilt packages printed"
+ echo "in pretend mode in case something go wrong"
+ exit 1
+fi
+
+if [ "$1" = "-f" ]
+then
+ pretend=0
+ shift
+else
+ pretend=1
+fi
+
+depends=`find /var/db/pkg -name DEPEND -exec grep -l 'dev-lang/ocaml\\|dev-ml/findlib' {} \;`
+
+for dep in $depends
+do
+ dir=`dirname $dep`
+ pkg=`basename $dir`
+ category=`cat $dir/CATEGORY`
+ slot=`cat $dir/SLOT`
+
+ tobuild=">=$category/$pkg:$slot $tobuild"
+ tobuildstr="\">=$category/$pkg:$slot\" $tobuildstr"
+done
+
+if [ "$tobuild" = "" ] ; then
+ echo "Nothing to do!"
+ exit 0
+fi
+
+echo Building $tobuildstr
+
+if [ $pretend -eq 1 ]
+then
+ $emerge --pretend $@ $tobuild
+else
+ $emerge --oneshot $@ $tobuild
+fi
diff --git a/dev-lang/ocaml/files/ocaml.conf b/dev-lang/ocaml/files/ocaml.conf
new file mode 100644
index 000000000000..083b8cef960b
--- /dev/null
+++ b/dev-lang/ocaml/files/ocaml.conf
@@ -0,0 +1,5 @@
+# Rebuild all ocaml modules (must be rebuilt after each ocaml upgrade)
+[ocaml-rebuild]
+class = portage.sets.dbapi.OwnerSet
+files = /usr/lib/ocaml
+exclude-files = /usr/bin/ocaml
diff --git a/dev-lang/ocaml/metadata.xml b/dev-lang/ocaml/metadata.xml
new file mode 100644
index 000000000000..720c6c5d8b36
--- /dev/null
+++ b/dev-lang/ocaml/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>ml@gentoo.org</email>
+ <name>Gentoo ML Project</name>
+</maintainer>
+ <use>
+ <flag name="flambda">Enables the Flambda optimizer: A new intermediate representation (introduced in ocaml 4.03) in the depths of the compiler designed to allow for better inlining.</flag>
+ <flag name="spacetime">Enables the Spacetime memory profiler. See https://caml.inria.fr/pub/docs/manual-ocaml/spacetime.html for more information.</flag>
+ </use>
+ <upstream>
+ <remote-id type="github">ocaml/ocaml</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/dev-lang/ocaml/ocaml-4.04.2.ebuild b/dev-lang/ocaml/ocaml-4.04.2.ebuild
new file mode 100644
index 000000000000..cf9890317ecb
--- /dev/null
+++ b/dev-lang/ocaml/ocaml-4.04.2.ebuild
@@ -0,0 +1,127 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit flag-o-matic eutils multilib versionator toolchain-funcs
+
+PATCHLEVEL="8"
+MY_P="${P/_/-}"
+DESCRIPTION="Type-inferring functional programming language descended from the ML family"
+HOMEPAGE="http://www.ocaml.org/"
+SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
+ mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
+
+LICENSE="QPL-1.0 LGPL-2"
+# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
+# so here we go with the subslot.
+SLOT="0/${PV}"
+KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
+IUSE="emacs flambda latex ncurses +ocamlopt X xemacs"
+
+RDEPEND="
+ sys-libs/binutils-libs:=
+ ncurses? ( sys-libs/ncurses:0= )
+ X? ( x11-libs/libX11 x11-proto/xproto )"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig"
+
+PDEPEND="emacs? ( app-emacs/ocaml-mode )
+ xemacs? ( app-xemacs/ocaml )"
+
+S="${WORKDIR}/${MY_P}"
+pkg_setup() {
+ # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
+ # results in relocations if gcc wants to create a PIE executable
+ if gcc-specs-pie ; then
+ append-ldflags -nopie
+ ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
+ ewarn "We have appended -nopie to ocaml build options"
+ ewarn "because linking an executable with pie while the objects are not pic will not work"
+ fi
+}
+
+src_prepare() {
+ EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
+}
+
+src_configure() {
+ export LC_ALL=C
+ local myconf=""
+
+ # Causes build failures because it builds some programs with -pg,
+ # bug #270920
+ filter-flags -fomit-frame-pointer
+ # Bug #285993
+ filter-mfpmath sse
+
+ # -ggdb3 & co makes it behave weirdly, breaks sexplib
+ replace-flags -ggdb* -ggdb
+
+ # It doesn't compile on alpha without this LDFLAGS
+ use alpha && append-ldflags "-Wl,--no-relax"
+
+ use ncurses || myconf="${myconf} -no-curses"
+ use X || myconf="${myconf} -no-graph"
+ use flambda && myconf="${myconf} -flambda"
+
+ # ocaml uses a home-brewn configure script, preventing it to use econf.
+ RAW_LDFLAGS="$(raw-ldflags)" ./configure \
+ --prefix "${EPREFIX}"/usr \
+ --bindir "${EPREFIX}"/usr/bin \
+ --target-bindir "${EPREFIX}"/usr/bin \
+ --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
+ --mandir "${EPREFIX}"/usr/share/man \
+ -target "${CHOST}" \
+ -host "${CBUILD}" \
+ -cc "$(tc-getCC)" \
+ -as "$(tc-getAS)" \
+ -aspp "$(tc-getCC) -c" \
+ -partialld "$(tc-getLD) -r" \
+ --with-pthread ${myconf} || die "configure failed!"
+
+ # http://caml.inria.fr/mantis/view.php?id=4698
+ export CCLINKFLAGS="${LDFLAGS}"
+}
+
+src_compile() {
+ emake world
+
+ # Native code generation can be disabled now
+ if use ocamlopt ; then
+ # bug #279968
+ emake opt
+ emake opt.opt
+ fi
+}
+
+src_test() {
+ if use ocamlopt ; then
+ emake -j1 tests
+ else
+ ewarn "${PN} testsuite requires ocamlopt useflag"
+ fi
+}
+
+src_install() {
+ emake BINDIR="${ED}"/usr/bin \
+ LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
+ MANDIR="${ED}"/usr/share/man \
+ install
+
+ # Symlink the headers to the right place
+ dodir /usr/include
+ dosym /usr/$(get_libdir)/ocaml/caml /usr/include/caml
+
+ dodoc Changes README.adoc
+
+ # Create and envd entry for latex input files
+ if use latex ; then
+ echo "TEXINPUTS=${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc
+ doenvd "${T}"/99ocamldoc
+ fi
+
+ # Install ocaml-rebuild portage set
+ insinto /usr/share/portage/config/sets
+ doins "${FILESDIR}/ocaml.conf"
+}
diff --git a/dev-lang/ocaml/ocaml-4.05.0.ebuild b/dev-lang/ocaml/ocaml-4.05.0.ebuild
new file mode 100644
index 000000000000..a7d4ff33ac53
--- /dev/null
+++ b/dev-lang/ocaml/ocaml-4.05.0.ebuild
@@ -0,0 +1,129 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit flag-o-matic eutils multilib versionator toolchain-funcs
+
+PATCHLEVEL="9"
+MY_P="${P/_/-}"
+DESCRIPTION="Type-inferring functional programming language descended from the ML family"
+HOMEPAGE="http://www.ocaml.org/"
+SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
+ mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
+
+LICENSE="QPL-1.0 LGPL-2"
+# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
+# so here we go with the subslot.
+SLOT="0/${PV}"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~x86-solaris"
+IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
+
+RDEPEND="
+ sys-libs/binutils-libs:=
+ ncurses? ( sys-libs/ncurses:0= )
+ spacetime? ( sys-libs/libunwind:= )
+ X? ( x11-libs/libX11 x11-proto/xproto )"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig"
+
+PDEPEND="emacs? ( app-emacs/ocaml-mode )
+ xemacs? ( app-xemacs/ocaml )"
+
+S="${WORKDIR}/${MY_P}"
+pkg_setup() {
+ # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
+ # results in relocations if gcc wants to create a PIE executable
+ if gcc-specs-pie ; then
+ append-ldflags -nopie
+ ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
+ ewarn "We have appended -nopie to ocaml build options"
+ ewarn "because linking an executable with pie while the objects are not pic will not work"
+ fi
+}
+
+src_prepare() {
+ EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
+}
+
+src_configure() {
+ export LC_ALL=C
+ local myconf=""
+
+ # Causes build failures because it builds some programs with -pg,
+ # bug #270920
+ filter-flags -fomit-frame-pointer
+ # Bug #285993
+ filter-mfpmath sse
+
+ # -ggdb3 & co makes it behave weirdly, breaks sexplib
+ replace-flags -ggdb* -ggdb
+
+ # It doesn't compile on alpha without this LDFLAGS
+ use alpha && append-ldflags "-Wl,--no-relax"
+
+ use ncurses || myconf="${myconf} -no-curses"
+ use X || myconf="${myconf} -no-graph"
+ use flambda && myconf="${myconf} -flambda"
+ use spacetime && myconf="${myconf} -spacetime"
+
+ # ocaml uses a home-brewn configure script, preventing it to use econf.
+ RAW_LDFLAGS="$(raw-ldflags)" ./configure \
+ --prefix "${EPREFIX}"/usr \
+ --bindir "${EPREFIX}"/usr/bin \
+ --target-bindir "${EPREFIX}"/usr/bin \
+ --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
+ --mandir "${EPREFIX}"/usr/share/man \
+ -target "${CHOST}" \
+ -host "${CBUILD}" \
+ -cc "$(tc-getCC)" \
+ -as "$(tc-getAS)" \
+ -aspp "$(tc-getCC) -c" \
+ -partialld "$(tc-getLD) -r" \
+ --with-pthread ${myconf} || die "configure failed!"
+
+ # http://caml.inria.fr/mantis/view.php?id=4698
+ export CCLINKFLAGS="${LDFLAGS}"
+}
+
+src_compile() {
+ emake world
+
+ # Native code generation can be disabled now
+ if use ocamlopt ; then
+ # bug #279968
+ emake opt
+ emake -j1 opt.opt
+ fi
+}
+
+src_test() {
+ if use ocamlopt ; then
+ emake -j1 tests
+ else
+ ewarn "${PN} testsuite requires ocamlopt useflag"
+ fi
+}
+
+src_install() {
+ emake BINDIR="${ED}"/usr/bin \
+ LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
+ MANDIR="${ED}"/usr/share/man \
+ install
+
+ # Symlink the headers to the right place
+ dodir /usr/include
+ dosym /usr/$(get_libdir)/ocaml/caml /usr/include/caml
+
+ dodoc Changes README.adoc
+
+ # Create and envd entry for latex input files
+ if use latex ; then
+ echo "TEXINPUTS=${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc
+ doenvd "${T}"/99ocamldoc
+ fi
+
+ # Install ocaml-rebuild portage set
+ insinto /usr/share/portage/config/sets
+ doins "${FILESDIR}/ocaml.conf"
+}
diff --git a/dev-lang/ocaml/ocaml-4.06.0_beta1.ebuild b/dev-lang/ocaml/ocaml-4.06.0_beta1.ebuild
new file mode 100644
index 000000000000..0c6b2bbfed86
--- /dev/null
+++ b/dev-lang/ocaml/ocaml-4.06.0_beta1.ebuild
@@ -0,0 +1,127 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="5"
+
+inherit flag-o-matic eutils multilib versionator toolchain-funcs
+
+PATCHLEVEL="10"
+MY_P="${P/_/-}"
+DESCRIPTION="Type-inferring functional programming language descended from the ML family"
+HOMEPAGE="http://www.ocaml.org/"
+SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
+ mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
+
+LICENSE="QPL-1.0 LGPL-2"
+# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
+# so here we go with the subslot.
+SLOT="0/${PV}"
+# still in beta
+#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~x86-solaris"
+IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
+
+RDEPEND="
+ sys-libs/binutils-libs:=
+ ncurses? ( sys-libs/ncurses:0= )
+ spacetime? ( sys-libs/libunwind:= )
+ X? ( x11-libs/libX11 x11-proto/xproto )"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig"
+
+PDEPEND="emacs? ( app-emacs/ocaml-mode )
+ xemacs? ( app-xemacs/ocaml )"
+
+S="${WORKDIR}/${MY_P}"
+pkg_setup() {
+ # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
+ # results in relocations if gcc wants to create a PIE executable
+ if gcc-specs-pie ; then
+ append-ldflags -nopie
+ ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
+ ewarn "We have appended -nopie to ocaml build options"
+ ewarn "because linking an executable with pie while the objects are not pic will not work"
+ fi
+}
+
+src_prepare() {
+ EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
+}
+
+src_configure() {
+ export LC_ALL=C
+ local myconf=""
+
+ # Causes build failures because it builds some programs with -pg,
+ # bug #270920
+ filter-flags -fomit-frame-pointer
+ # Bug #285993
+ filter-mfpmath sse
+
+ # -ggdb3 & co makes it behave weirdly, breaks sexplib
+ replace-flags -ggdb* -ggdb
+
+ # It doesn't compile on alpha without this LDFLAGS
+ use alpha && append-ldflags "-Wl,--no-relax"
+
+ use ncurses || myconf="${myconf} -no-curses"
+ use X || myconf="${myconf} -no-graph"
+ use flambda && myconf="${myconf} -flambda"
+ use spacetime && myconf="${myconf} -spacetime"
+
+ # ocaml uses a home-brewn configure script, preventing it to use econf.
+ RAW_LDFLAGS="$(raw-ldflags)" ./configure \
+ --prefix "${EPREFIX}"/usr \
+ --bindir "${EPREFIX}"/usr/bin \
+ --target-bindir "${EPREFIX}"/usr/bin \
+ --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
+ --mandir "${EPREFIX}"/usr/share/man \
+ -target "${CHOST}" \
+ -host "${CBUILD}" \
+ -cc "$(tc-getCC)" \
+ -as "$(tc-getAS)" \
+ -aspp "$(tc-getCC) -c" \
+ -partialld "$(tc-getLD) -r" \
+ --with-pthread ${myconf} || die "configure failed!"
+}
+
+src_compile() {
+ emake world
+
+ # Native code generation can be disabled now
+ if use ocamlopt ; then
+ # bug #279968
+ emake opt
+ emake -j1 opt.opt
+ fi
+}
+
+src_test() {
+ if use ocamlopt ; then
+ emake -j1 tests
+ else
+ ewarn "${PN} testsuite requires ocamlopt useflag"
+ fi
+}
+
+src_install() {
+ emake BINDIR="${ED}"/usr/bin \
+ LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
+ MANDIR="${ED}"/usr/share/man \
+ install
+
+ # Symlink the headers to the right place
+ dodir /usr/include
+ dosym ../$(get_libdir)/ocaml/caml /usr/include/caml
+
+ dodoc Changes README.adoc
+
+ # Create and envd entry for latex input files
+ if use latex ; then
+ echo "TEXINPUTS=${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc
+ doenvd "${T}"/99ocamldoc
+ fi
+
+ # Install ocaml-rebuild portage set
+ insinto /usr/share/portage/config/sets
+ doins "${FILESDIR}/ocaml.conf"
+}