mlton-20130715.ebuild 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit check-reqs eutils pax-utils
  5. DESCRIPTION="Standard ML optimizing compiler and libraries"
  6. BASE_URI="mirror://sourceforge/${PN}"
  7. SRC_URI="!binary? ( ${BASE_URI}/${P}.src.tgz )
  8. binary? ( amd64? ( ${BASE_URI}/${P}-1.amd64-linux.tgz )
  9. x86? ( ${BASE_URI}/${P}-1.x86-linux.tgz ) )"
  10. HOMEPAGE="http://www.mlton.org"
  11. LICENSE="HPND MIT"
  12. SLOT="0/${PV}"
  13. # there is support for ppc64 and ia64, but no
  14. # binaries are provided and there is no native
  15. # code generation for these platforms
  16. KEYWORDS="-* ~amd64 ~x86"
  17. IUSE="binary doc"
  18. DEPEND="dev-libs/gmp
  19. doc? ( virtual/latex-base )"
  20. RDEPEND="dev-libs/gmp"
  21. QA_PRESTRIPPED="binary? (
  22. usr/bin/mlnlffigen
  23. usr/bin/mllex
  24. usr/bin/mlprof
  25. usr/bin/mlyacc
  26. usr/lib/mlton/mlton-compile
  27. )"
  28. # The resident set size of mlton-compile is 10GB on amd64
  29. CHECKREQS_MEMORY="4G"
  30. pkg_pretend() {
  31. if use !binary; then
  32. check-reqs_pkg_pretend
  33. fi
  34. }
  35. src_unpack() {
  36. if use !binary; then
  37. unpack ${A}
  38. else
  39. mkdir -p "${S}" || die "Could not create ${S} directory"
  40. pushd "${S}" || die "Could not cd to ${S}"
  41. unpack ${A}
  42. popd
  43. fi
  44. }
  45. src_prepare() {
  46. if use !binary; then
  47. # The patch removing executable permissions from mmap'd memory regions is not upstreamed:
  48. # http://pkgs.fedoraproject.org/cgit/mlton.git/tree/mlton-20070826-no-execmem.patch
  49. epatch "${FILESDIR}/${PN}-20070826-no-execmem.patch"
  50. # PIE in hardened requires executables to be linked with -fPIC. mlton by default tries
  51. # to link executables against the non PIC objects in libmlton.a. We may be bootstrapping
  52. # with an old mlton install, if we tried to patch it (to link with libmlton-pic.a) we would
  53. # need a patched binary.
  54. # http://mlton.org/MLtonWorld says Executables that save and load worlds are incompatible
  55. # with address space layout randomization (ASLR) of the executable.
  56. epatch "${FILESDIR}/${PN}-20130715-no-PIE.patch"
  57. # Remove dirs runtime compiler from all-no-docs to avoid repeating these steps.
  58. # As we need to pax-mark the mlton-compiler executable.
  59. epatch "${FILESDIR}/${PN}-20130715-split-make-for-pax-mark.patch"
  60. fi
  61. }
  62. src_compile() {
  63. if use !binary; then
  64. has_version dev-lang/mlton || die "emerge with binary use flag first"
  65. # Fix location in which to install man pages
  66. sed -i 's@^MAN_PREFIX_EXTRA :=.*@MAN_PREFIX_EXTRA := /share@' \
  67. Makefile || die 'sed Makefile failed'
  68. emake -j1 dirs runtime compiler CFLAGS="${CFLAGS}" || die
  69. pax-mark m "${S}/mlton/mlton-compile"
  70. pax-mark m "${S}/build/lib/mlton-compile"
  71. # Does not support parallel make
  72. emake -j1 all-no-docs CFLAGS="${CFLAGS}" || die
  73. if use doc; then
  74. export VARTEXFONTS="${T}/fonts"
  75. emake docs || die "failed to create documentation"
  76. fi
  77. fi
  78. }
  79. src_install() {
  80. if use binary; then
  81. # Fix location in which to install man pages
  82. mv "${S}/usr/man" "${S}/usr/share" || die "mv man failed"
  83. pax-mark m "${S}/usr/lib/mlton/mlton-compile"
  84. pax-mark m "${S}/usr/bin/mllex"
  85. pax-mark m "${S}/usr/bin/mlyacc"
  86. mv "${S}/usr" "${D}" || die "mv failed"
  87. else
  88. emake DESTDIR="${D}" install-no-docs || die
  89. if use doc; then emake DESTDIR="${D}" TDOC="${D}"/usr/share/doc/${P} install-docs || die; fi
  90. fi
  91. }
  92. pkg_postinst() {
  93. # There are PIC objects in libmlton-pic.a. -link-opt -lmlton-pic does not help as mlton
  94. # specifies -lmlton before -lmlton-pic. It appears that it would be necessary to patch mlton
  95. # to convince mlton to use the lib*-pic.a libraries when linking an executable.
  96. ewarn 'PIE in Gentoo hardened requires executables to be linked with -fPIC. mlton by default links'
  97. ewarn 'executables against the non PIC objects in libmlton.a. http://mlton.org/MLtonWorld notes:'
  98. ewarn 'Executables that save and load worlds are incompatible with address space layout'
  99. ewarn 'randomization (ASLR) of the executable.'
  100. ewarn 'To suppress the generation of position-independent executables.'
  101. ewarn '-link-opt -fno-PIE'
  102. }