mercury-13.05.ebuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=2
  4. inherit autotools elisp-common eutils flag-o-matic java-pkg-opt-2 multilib
  5. PATCHSET_VER="0"
  6. MY_P=${PN}-srcdist-${PV}
  7. DESCRIPTION="Mercury is a modern general-purpose logic/functional programming language"
  8. HOMEPAGE="http://www.mercurylang.org/index.html"
  9. SRC_URI="http://dl.mercurylang.org/release/${MY_P}.tar.gz
  10. mirror://gentoo/${P}-gentoo-patchset-${PATCHSET_VER}.tar.gz"
  11. LICENSE="GPL-2 LGPL-2"
  12. SLOT="0"
  13. KEYWORDS="~amd64 ~x86"
  14. IUSE="debug emacs erlang examples java minimal readline threads"
  15. DEPEND="!dev-libs/mpatrol
  16. !dev-util/mono-debugger
  17. readline? ( sys-libs/readline )
  18. erlang? ( dev-lang/erlang )
  19. java? ( >=virtual/jdk-1.5 )"
  20. RDEPEND="${DEPEND}
  21. emacs? ( virtual/emacs )"
  22. S="${WORKDIR}"/${MY_P}
  23. SITEFILE=50${PN}-gentoo.el
  24. src_prepare() {
  25. cd "${WORKDIR}" || die
  26. EPATCH_FORCE=yes
  27. EPATCH_SUFFIX=patch
  28. epatch "${WORKDIR}"/${PV}
  29. sed -i -e "s/@libdir@/$(get_libdir)/" \
  30. "${S}"/scripts/Mmake.vars.in \
  31. || die "sed libdir failed"
  32. cd "${S}" || die
  33. eautoconf
  34. }
  35. src_configure() {
  36. strip-flags
  37. local myconf
  38. myconf="--libdir=/usr/$(get_libdir) \
  39. --disable-deep-profiler \
  40. --disable-dotnet-grades \
  41. $(use_enable erlang erlang-grade) \
  42. $(use_enable java java-grade) \
  43. $(use_enable debug debug-grades) \
  44. $(use_enable threads par-grades) \
  45. $(use_enable !minimal most-grades) \
  46. $(use_with readline)"
  47. econf ${myconf}
  48. }
  49. src_compile() {
  50. # Build Mercury using base llds grade
  51. emake \
  52. PARALLEL=${MAKEOPTS} \
  53. EXTRA_MLFLAGS=--no-strip \
  54. EXTRA_LDFLAGS="${LDFLAGS}" \
  55. EXTRA_LD_LIBFLAGS="${LDFLAGS}" \
  56. || die "emake failed"
  57. # We can now patch .m Mercury compiler files since we
  58. # have just built mercury_compiler.
  59. EPATCH_FORCE=yes
  60. EPATCH_SUFFIX=patch
  61. epatch "${WORKDIR}"/${PV}-mmc
  62. sed -i -e "s/@libdir@/$(get_libdir)/" \
  63. "${S}"/compiler/file_util.m \
  64. "${S}"/compiler/make.program_target.m \
  65. || die "sed libdir failed"
  66. # Rebuild Mercury compiler using the just built mercury_compiler
  67. emake \
  68. PARALLEL=${MAKEOPTS} \
  69. EXTRA_MLFLAGS=--no-strip \
  70. EXTRA_LDFLAGS="${LDFLAGS}" \
  71. EXTRA_LD_LIBFLAGS="${LDFLAGS}" \
  72. MERCURY_COMPILER="${S}"/compiler/mercury_compile \
  73. compiler || die "emake compiler failed"
  74. # The default Mercury grade may not be the same as the grade used to
  75. # compile the llds base grade. Since src_test() is run before
  76. # src_install() we compile the default grade now
  77. emake \
  78. PARALLEL=${MAKEOPTS} \
  79. EXTRA_MLFLAGS=--no-strip \
  80. EXTRA_LDFLAGS="${LDFLAGS}" \
  81. EXTRA_LD_LIBFLAGS="${LDFLAGS}" \
  82. MERCURY_COMPILER="${S}"/compiler/mercury_compile \
  83. default_grade || die "emake default_grade failed"
  84. }
  85. src_test() {
  86. TEST_GRADE=`scripts/ml --print-grade`
  87. if [ -d "${S}"/install_grade_dir.${TEST_GRADE} ] ; then
  88. TWS="${S}"/install_grade_dir.${TEST_GRADE}
  89. cp runtime/mer_rt.init "${TWS}"/runtime/
  90. cp mdbcomp/mer_mdbcomp.init "${TWS}"/mdbcomp/
  91. cp browser/mer_browser.init "${TWS}"/browser/
  92. else
  93. TWS="${S}"
  94. fi
  95. cd "${S}"/tests || die
  96. sed -e "s:@WORKSPACE@:${TWS}:" < WS_FLAGS.ws > WS_FLAGS \
  97. || die "sed WORKSPACE failed"
  98. # Mercury tests must be run in C locale since Mercury output is
  99. # compared to hard-coded warnings/errors
  100. LC_ALL="C" \
  101. PATH="${TWS}"/scripts:"${TWS}"/util:"${S}"/slice:"${PATH}" \
  102. TERM="" \
  103. WORKSPACE="${TWS}" \
  104. WORKSPACE_FLAGS=yes \
  105. MERCURY_COMPILER="${TWS}"/compiler/mercury_compile \
  106. MMAKE_DIR="${TWS}"/scripts \
  107. MERCURY_SUPPRESS_STACK_TRACE=yes \
  108. GRADE=${TEST_GRADE} \
  109. MERCURY_ALL_LOCAL_C_INCL_DIRS=" -I${TWS}/boehm_gc/include \
  110. -I${TWS}/runtime \
  111. -I${TWS}/library" \
  112. mmake || die "mmake test failed"
  113. }
  114. src_install() {
  115. emake \
  116. PARALLEL=${MAKEOPTS} \
  117. EXTRA_LDFLAGS="${LDFLAGS}" \
  118. EXTRA_LD_LIBFLAGS="${LDFLAGS}" \
  119. MERCURY_COMPILER="${S}"/compiler/mercury_compile \
  120. INSTALL_PREFIX="${D}"/usr \
  121. INSTALL_MAN_DIR="${D}"/usr/share/man \
  122. INSTALL_INFO_DIR="${D}"/usr/share/info \
  123. INSTALL_HTML_DIR="${D}"/usr/share/doc/${PF}/html \
  124. INSTALL_ELISP_DIR="${D}/${SITELISP}"/${PN} \
  125. install || die "make install failed"
  126. if use emacs; then
  127. elisp-site-file-install "${FILESDIR}/${SITEFILE}" \
  128. || die "elisp-site-file-install failed"
  129. fi
  130. dodoc \
  131. BUGS HISTORY LIMITATIONS NEWS README README.Linux \
  132. README.Linux-Alpha README.Linux-m68k README.Linux-PPC \
  133. RELEASE_NOTES TODO VERSION WORK_IN_PROGRESS || die
  134. if use erlang; then
  135. dodoc README.Erlang || die
  136. fi
  137. if use java; then
  138. dodoc README.Java || die
  139. fi
  140. if use examples; then
  141. insinto /usr/share/doc/${PF}/samples
  142. doins samples/{*.m,README,Mmakefile} || die
  143. doins -r samples/c_interface \
  144. samples/diff \
  145. samples/muz \
  146. samples/rot13 \
  147. samples/solutions \
  148. samples/solver_types || die
  149. if use java; then
  150. doins -r samples/java_interface || die
  151. fi
  152. ecvs_clean "${D}"/usr/share/doc/${PF}/samples
  153. fi
  154. }
  155. pkg_postinst() {
  156. use emacs && elisp-site-regen
  157. }
  158. pkg_postrm() {
  159. use emacs && elisp-site-regen
  160. }