mercury-11.07.ebuild 5.5 KB

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