3 |
3 |
|
4 |
4 |
EAPI=7
|
5 |
5 |
|
6 |
|
inherit flag-o-matic toolchain-funcs
|
|
6 |
inherit flag-o-matic
|
7 |
7 |
|
8 |
|
PATCHLEVEL="9"
|
9 |
|
MY_P="${P/_/-}"
|
10 |
|
DESCRIPTION="Type-inferring functional programming language descended from the ML family"
|
11 |
|
HOMEPAGE="https://ocaml.org"
|
12 |
|
SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
|
13 |
|
mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2
|
|
8 |
DESCRIPTION="Programming language supporting functional, imperative & object-oriented styles"
|
|
9 |
HOMEPAGE="https://ocaml.org/"
|
|
10 |
SRC_URI="https://github.com/ocaml/ocaml/archive/${PV}.tar.gz -> ${P}.tar.gz
|
14 |
11 |
https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-patches-1.tar.bz2"
|
15 |
12 |
|
16 |
|
LICENSE="QPL-1.0 LGPL-2"
|
17 |
|
# Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
|
18 |
|
# so here we go with the subslot.
|
|
13 |
LICENSE="LGPL-2.1"
|
19 |
14 |
SLOT="0/$(ver_cut 1-2)"
|
20 |
|
KEYWORDS="amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos"
|
21 |
|
IUSE="emacs flambda latex ncurses +ocamlopt spacetime X xemacs"
|
|
15 |
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
|
|
16 |
IUSE="emacs flambda latex +ocamlopt spacetime xemacs"
|
22 |
17 |
|
23 |
|
RDEPEND="
|
24 |
|
sys-libs/binutils-libs:=
|
25 |
|
ncurses? ( sys-libs/ncurses:0= )
|
26 |
|
spacetime? ( sys-libs/libunwind:= )
|
27 |
|
X? ( x11-libs/libX11 )
|
28 |
|
!dev-ml/num"
|
|
18 |
RDEPEND="sys-libs/binutils-libs:=
|
|
19 |
spacetime? ( sys-libs/libunwind:= )"
|
29 |
20 |
BDEPEND="${RDEPEND}
|
30 |
21 |
virtual/pkgconfig"
|
31 |
22 |
PDEPEND="emacs? ( app-emacs/ocaml-mode )
|
32 |
23 |
xemacs? ( app-xemacs/ocaml )"
|
33 |
24 |
|
34 |
|
QA_FLAGS_IGNORED='usr/lib.*/ocaml/raw_spacetime_lib.cmxs'
|
35 |
|
|
36 |
|
S="${WORKDIR}/${MY_P}"
|
|
25 |
QA_FLAGS_IGNORED='usr/lib.*/ocaml/bigarray.cmxs'
|
37 |
26 |
|
38 |
27 |
PATCHES=(
|
39 |
|
"${FILESDIR}"/${PN}-4.04.2-tinfo.patch #459512
|
40 |
28 |
"${WORKDIR}"/${P}-patches-1/
|
41 |
29 |
)
|
42 |
30 |
|
43 |
|
pkg_setup() {
|
44 |
|
# dev-lang/ocaml creates its own objects but calls gcc for linking, which will
|
45 |
|
# results in relocations if gcc wants to create a PIE executable
|
46 |
|
if gcc-specs-pie ; then
|
47 |
|
append-ldflags -nopie
|
48 |
|
ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
|
49 |
|
ewarn "We have appended -nopie to ocaml build options"
|
50 |
|
ewarn "because linking an executable with pie while the objects are not pic will not work"
|
51 |
|
fi
|
52 |
|
}
|
53 |
|
|
54 |
31 |
src_prepare() {
|
55 |
|
EPATCH_SUFFIX="patch" eapply "${WORKDIR}/patches"
|
56 |
|
|
57 |
|
cp "${FILESDIR}"/ocaml.conf "${T}" || die
|
58 |
|
|
59 |
32 |
default
|
60 |
|
}
|
61 |
|
|
62 |
|
src_configure() {
|
63 |
|
export LC_ALL=C
|
64 |
|
local myconf=""
|
65 |
33 |
|
66 |
|
# Causes build failures because it builds some programs with -pg,
|
67 |
|
# bug #270920
|
68 |
|
filter-flags -fomit-frame-pointer
|
69 |
|
# Bug #285993
|
70 |
|
filter-mfpmath sse
|
|
34 |
cp "${FILESDIR}"/ocaml.conf "${T}" || die
|
71 |
35 |
|
72 |
36 |
# Broken until 4.12
|
73 |
37 |
# bug #818445
|
74 |
38 |
filter-lto
|
75 |
39 |
append-flags -fno-strict-aliasing
|
76 |
40 |
|
77 |
|
# -ggdb3 & co makes it behave weirdly, breaks sexplib
|
78 |
|
replace-flags -ggdb* -ggdb
|
79 |
|
|
80 |
41 |
# OCaml generates textrels on 32-bit arches
|
81 |
42 |
# We can't do anything about it, but disabling it means that tests
|
82 |
43 |
# for OCaml-based packages won't fail on unexpected output
|
... | ... | |
85 |
46 |
append-ldflags "-Wl,-z,notext"
|
86 |
47 |
fi
|
87 |
48 |
|
88 |
|
# It doesn't compile on alpha without this LDFLAGS
|
89 |
|
use alpha && append-ldflags "-Wl,--no-relax"
|
|
49 |
# Upstream build ignores LDFLAGS in several places.
|
|
50 |
sed -i -e 's/\(^MKDLL=.*\)/\1 $(LDFLAGS)/' \
|
|
51 |
-e 's/\(^OC_CFLAGS=.*\)/\1 $(LDFLAGS)/' \
|
|
52 |
-e 's/\(^OC_LDFLAGS=.*\)/\1 $(LDFLAGS)/' \
|
|
53 |
Makefile.config.in || die "LDFLAGS fix failed"
|
|
54 |
# ${P} overrides upstream build's own P due to a wrong assignment operator.
|
|
55 |
sed -i -e 's/^P ?=/P =/' stdlib/StdlibModules || die "P fix failed"
|
|
56 |
}
|
90 |
57 |
|
91 |
|
use ncurses || myconf="${myconf} -no-curses"
|
92 |
|
use X || myconf="${myconf} -no-graph"
|
93 |
|
use flambda && myconf="${myconf} -flambda"
|
94 |
|
use spacetime && myconf="${myconf} -spacetime"
|
95 |
|
|
96 |
|
# ocaml uses a home-brewn configure script, preventing it to use econf.
|
97 |
|
RAW_LDFLAGS="$(raw-ldflags)" ./configure \
|
98 |
|
--prefix "${EPREFIX}"/usr \
|
99 |
|
--bindir "${EPREFIX}"/usr/bin \
|
100 |
|
--target-bindir "${EPREFIX}"/usr/bin \
|
101 |
|
--libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
|
102 |
|
--mandir "${EPREFIX}"/usr/share/man \
|
103 |
|
-target "${CHOST}" \
|
104 |
|
-host "${CBUILD}" \
|
105 |
|
-cc "$(tc-getCC)" \
|
106 |
|
-as "$(tc-getAS)" \
|
107 |
|
-aspp "$(tc-getCC) -c" \
|
108 |
|
-partialld "$(tc-getLD) -r" \
|
109 |
|
--with-pthread ${myconf} || die "configure failed!"
|
|
58 |
src_configure() {
|
|
59 |
local opt=(
|
|
60 |
--bindir="${EPREFIX}/usr/bin"
|
|
61 |
--libdir="${EPREFIX}/usr/$(get_libdir)/ocaml"
|
|
62 |
--mandir="${EPREFIX}/usr/share/man"
|
|
63 |
--prefix="${EPREFIX}/usr"
|
|
64 |
$(use_enable flambda)
|
|
65 |
$(use_enable spacetime)
|
|
66 |
)
|
110 |
67 |
|
111 |
|
# http://caml.inria.fr/mantis/view.php?id=4698
|
112 |
|
export CCLINKFLAGS="${LDFLAGS}"
|
|
68 |
econf "${opt[@]}"
|
113 |
69 |
}
|
114 |
70 |
|
115 |
71 |
src_compile() {
|
116 |
|
emake world
|
117 |
|
|
118 |
|
# Native code generation can be disabled now
|
119 |
72 |
if use ocamlopt ; then
|
120 |
|
# bug #279968
|
121 |
|
emake opt
|
122 |
|
emake -j1 opt.opt
|
|
73 |
emake world.opt
|
|
74 |
else
|
|
75 |
emake world
|
123 |
76 |
fi
|
124 |
77 |
}
|
125 |
78 |
|
126 |
79 |
src_test() {
|
127 |
80 |
if use ocamlopt ; then
|
128 |
|
emake -j1 tests
|
|
81 |
# OCaml tests only work when run sequentially
|
|
82 |
emake -j1 -C testsuite all
|
129 |
83 |
else
|
130 |
84 |
ewarn "${PN} was built without 'ocamlopt' USE flag; skipping tests."
|
131 |
85 |
fi
|
132 |
86 |
}
|
133 |
87 |
|
134 |
88 |
src_install() {
|
135 |
|
emake BINDIR="${ED}"/usr/bin \
|
136 |
|
LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
|
137 |
|
MANDIR="${ED}"/usr/share/man \
|
138 |
|
install
|
139 |
|
|
140 |
|
# Symlink the headers to the right place
|
|
89 |
default
|
141 |
90 |
dodir /usr/include
|
|
91 |
|
142 |
92 |
# Create symlink for header files
|
143 |
93 |
dosym "../$(get_libdir)/ocaml/caml" /usr/include/caml
|
144 |
94 |
dodoc Changes README.adoc
|
|
95 |
|
145 |
96 |
# Create envd entry for latex input files
|
146 |
97 |
if use latex ; then
|
147 |
|
echo "TEXINPUTS=\"${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:\"" > "${T}"/99ocamldoc || die
|
|
98 |
echo "TEXINPUTS=\"${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:\"" > "${T}/99ocamldoc" || die
|
148 |
99 |
doenvd "${T}"/99ocamldoc
|
149 |
100 |
fi
|
150 |
101 |
|