ocaml-4.04.0.ebuild 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit flag-o-matic eutils multilib versionator toolchain-funcs
  5. PATCHLEVEL="8"
  6. MY_P="${P/_/-}"
  7. DESCRIPTION="Type-inferring functional programming language descended from the ML family"
  8. HOMEPAGE="http://www.ocaml.org/"
  9. SRC_URI="https://github.com/ocaml/ocaml/archive/${PV/_/+}.tar.gz -> ${MY_P}.tar.gz
  10. mirror://gentoo/${PN}-patches-${PATCHLEVEL}.tar.bz2"
  11. LICENSE="QPL-1.0 LGPL-2"
  12. # Everytime ocaml is updated to a new version, everything ocaml must be rebuilt,
  13. # so here we go with the subslot.
  14. SLOT="0/${PV}"
  15. KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
  16. IUSE="emacs flambda latex ncurses +ocamlopt X xemacs"
  17. RDEPEND="
  18. sys-libs/binutils-libs:=
  19. ncurses? ( sys-libs/ncurses:0= )
  20. X? ( x11-libs/libX11 x11-proto/xproto )"
  21. DEPEND="${RDEPEND}
  22. virtual/pkgconfig"
  23. PDEPEND="emacs? ( app-emacs/ocaml-mode )
  24. xemacs? ( app-xemacs/ocaml )"
  25. S="${WORKDIR}/${MY_P}"
  26. pkg_setup() {
  27. # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
  28. # results in relocations if gcc wants to create a PIE executable
  29. if gcc-specs-pie ; then
  30. append-ldflags -nopie
  31. ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
  32. ewarn "We have appended -nopie to ocaml build options"
  33. ewarn "because linking an executable with pie while the objects are not pic will not work"
  34. fi
  35. }
  36. src_prepare() {
  37. EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
  38. }
  39. src_configure() {
  40. export LC_ALL=C
  41. local myconf=""
  42. # Causes build failures because it builds some programs with -pg,
  43. # bug #270920
  44. filter-flags -fomit-frame-pointer
  45. # Bug #285993
  46. filter-mfpmath sse
  47. # -ggdb3 & co makes it behave weirdly, breaks sexplib
  48. replace-flags -ggdb* -ggdb
  49. # It doesn't compile on alpha without this LDFLAGS
  50. use alpha && append-ldflags "-Wl,--no-relax"
  51. use ncurses || myconf="${myconf} -no-curses"
  52. use X || myconf="${myconf} -no-graph"
  53. use flambda && myconf="${myconf} -flambda"
  54. # ocaml uses a home-brewn configure script, preventing it to use econf.
  55. RAW_LDFLAGS="$(raw-ldflags)" ./configure \
  56. --prefix "${EPREFIX}"/usr \
  57. --bindir "${EPREFIX}"/usr/bin \
  58. --target-bindir "${EPREFIX}"/usr/bin \
  59. --libdir "${EPREFIX}"/usr/$(get_libdir)/ocaml \
  60. --mandir "${EPREFIX}"/usr/share/man \
  61. -target "${CHOST}" \
  62. -host "${CBUILD}" \
  63. -cc "$(tc-getCC)" \
  64. -as "$(tc-getAS)" \
  65. -aspp "$(tc-getCC) -c" \
  66. -partialld "$(tc-getLD) -r" \
  67. --with-pthread ${myconf} || die "configure failed!"
  68. # http://caml.inria.fr/mantis/view.php?id=4698
  69. export CCLINKFLAGS="${LDFLAGS}"
  70. }
  71. src_compile() {
  72. emake world
  73. # Native code generation can be disabled now
  74. if use ocamlopt ; then
  75. # bug #279968
  76. emake opt
  77. emake opt.opt
  78. fi
  79. }
  80. src_test() {
  81. if use ocamlopt ; then
  82. emake -j1 tests
  83. else
  84. ewarn "${PN} testsuite requires ocamlopt useflag"
  85. fi
  86. }
  87. src_install() {
  88. emake BINDIR="${ED}"/usr/bin \
  89. LIBDIR="${ED}"/usr/$(get_libdir)/ocaml \
  90. MANDIR="${ED}"/usr/share/man \
  91. install
  92. # Symlink the headers to the right place
  93. dodir /usr/include
  94. dosym /usr/$(get_libdir)/ocaml/caml /usr/include/caml
  95. dodoc Changes README.adoc
  96. # Create and envd entry for latex input files
  97. if use latex ; then
  98. echo "TEXINPUTS=${EPREFIX}/usr/$(get_libdir)/ocaml/ocamldoc:" > "${T}"/99ocamldoc
  99. doenvd "${T}"/99ocamldoc
  100. fi
  101. # Install ocaml-rebuild portage set
  102. insinto /usr/share/portage/config/sets
  103. doins "${FILESDIR}/ocaml.conf"
  104. }