| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/dev-lang/ocaml/ocaml-4.00.0_beta2.ebuild,v 1.1 2012/06/10 20:12:21 aballier Exp $ |
| 4 |
|
| 5 |
EAPI="1" |
| 6 |
|
| 7 |
inherit flag-o-matic eutils multilib versionator toolchain-funcs |
| 8 |
|
| 9 |
PATCHLEVEL="4" |
| 10 |
MY_P="${P/_/+}" |
| 11 |
DESCRIPTION="Fast modern type-inferring functional programming language descended from the ML family" |
| 12 |
HOMEPAGE="http://www.ocaml.org/" |
| 13 |
SRC_URI="ftp://ftp.inria.fr/INRIA/Projects/cristal/ocaml/ocaml-$(get_version_component_range 1-2)/${MY_P}.tar.bz2 |
| 14 |
mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2" |
| 15 |
|
| 16 |
LICENSE="QPL-1.0 LGPL-2" |
| 17 |
SLOT="0" |
| 18 |
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd" |
| 19 |
IUSE="emacs latex ncurses +ocamlopt tk X xemacs" |
| 20 |
|
| 21 |
DEPEND="tk? ( >=dev-lang/tk-3.3.3 ) |
| 22 |
ncurses? ( sys-libs/ncurses ) |
| 23 |
X? ( x11-libs/libX11 x11-proto/xproto )" |
| 24 |
RDEPEND="${DEPEND}" |
| 25 |
|
| 26 |
PDEPEND="emacs? ( app-emacs/ocaml-mode ) |
| 27 |
xemacs? ( app-xemacs/ocaml )" |
| 28 |
|
| 29 |
S="${WORKDIR}/${MY_P}" |
| 30 |
pkg_setup() { |
| 31 |
# dev-lang/ocaml creates its own objects but calls gcc for linking, which will |
| 32 |
# results in relocations if gcc wants to create a PIE executable |
| 33 |
if gcc-specs-pie ; then |
| 34 |
append-ldflags -nopie |
| 35 |
ewarn "Ocaml generates its own native asm, you're using a PIE compiler" |
| 36 |
ewarn "We have appended -nopie to ocaml build options" |
| 37 |
ewarn "because linking an executable with pie while the objects are not pic will not work" |
| 38 |
fi |
| 39 |
} |
| 40 |
|
| 41 |
src_unpack() { |
| 42 |
unpack ${A} |
| 43 |
cd "${S}" |
| 44 |
EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches" |
| 45 |
} |
| 46 |
|
| 47 |
src_compile() { |
| 48 |
export LC_ALL=C |
| 49 |
local myconf="" |
| 50 |
|
| 51 |
# Causes build failures because it builds some programs with -pg, |
| 52 |
# bug #270920 |
| 53 |
filter-flags -fomit-frame-pointer |
| 54 |
# Bug #285993 |
| 55 |
filter-mfpmath sse |
| 56 |
|
| 57 |
# It doesn't compile on alpha without this LDFLAGS |
| 58 |
use alpha && append-ldflags "-Wl,--no-relax" |
| 59 |
|
| 60 |
use tk || myconf="${myconf} -no-tk" |
| 61 |
use ncurses || myconf="${myconf} -no-curses" |
| 62 |
use X || myconf="${myconf} -no-graph" |
| 63 |
|
| 64 |
# ocaml uses a home-brewn configure script, preventing it to use econf. |
| 65 |
RAW_LDFLAGS="$(raw-ldflags)" ./configure -prefix /usr \ |
| 66 |
--bindir /usr/bin \ |
| 67 |
--libdir /usr/$(get_libdir)/ocaml \ |
| 68 |
--mandir /usr/share/man \ |
| 69 |
-host "${CHOST}" \ |
| 70 |
-cc "$(tc-getCC)" \ |
| 71 |
-as "$(tc-getAS)" \ |
| 72 |
-aspp "$(tc-getCC) -c" \ |
| 73 |
-partialld "$(tc-getLD) -r" \ |
| 74 |
--with-pthread ${myconf} || die "configure failed!" |
| 75 |
|
| 76 |
emake -j1 world || die "make world failed!" |
| 77 |
|
| 78 |
# Native code generation can be disabled now |
| 79 |
if use ocamlopt ; then |
| 80 |
# bug #279968 |
| 81 |
emake -j1 opt || die "make opt failed!" |
| 82 |
emake -j1 opt.opt || die "make opt.opt failed!" |
| 83 |
fi |
| 84 |
} |
| 85 |
|
| 86 |
src_install() { |
| 87 |
make BINDIR="${D}"/usr/bin \ |
| 88 |
LIBDIR="${D}"/usr/$(get_libdir)/ocaml \ |
| 89 |
MANDIR="${D}"/usr/share/man \ |
| 90 |
install || die "make install failed!" |
| 91 |
|
| 92 |
# Install the compiler libs |
| 93 |
dodir /usr/$(get_libdir)/ocaml/compiler-libs |
| 94 |
insinto /usr/$(get_libdir)/ocaml/compiler-libs |
| 95 |
doins {utils,typing,parsing}/*.{mli,cmi,cmo} |
| 96 |
use ocamlopt && doins {utils,typing,parsing}/*.{cmx,o} |
| 97 |
|
| 98 |
# Symlink the headers to the right place |
| 99 |
dodir /usr/include |
| 100 |
dosym /usr/$(get_libdir)/ocaml/caml /usr/include/ |
| 101 |
|
| 102 |
# Remove ${D} from ld.conf, as the buildsystem isn't $(DESTDIR) aware |
| 103 |
dosed "s:${D}::g" /usr/$(get_libdir)/ocaml/ld.conf |
| 104 |
|
| 105 |
dodoc Changes INSTALL README Upgrading |
| 106 |
|
| 107 |
# Create and envd entry for latex input files (this definitely belongs into |
| 108 |
# CONTENT and not in pkg_postinst. |
| 109 |
if use latex ; then |
| 110 |
echo "TEXINPUTS=/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc |
| 111 |
doenvd "${T}"/99ocamldoc |
| 112 |
fi |
| 113 |
|
| 114 |
# Install ocaml-rebuild portage set |
| 115 |
insinto /usr/share/portage/config/sets |
| 116 |
doins "${FILESDIR}/ocaml.conf" || die |
| 117 |
} |
| 118 |
|
| 119 |
pkg_postinst() { |
| 120 |
echo |
| 121 |
ewarn "OCaml is not binary compatible from version to version, so you" |
| 122 |
ewarn "need to rebuild all packages depending on it, that are actually" |
| 123 |
ewarn "installed on your system. To do so, you can run:" |
| 124 |
ewarn "emerge @ocaml-rebuild" |
| 125 |
ewarn "Or, (almost) equivalently: emerge -1 /usr/$(get_libdir)/ocaml" |
| 126 |
echo |
| 127 |
} |