|
| 1 | +# Copyright 1999-2020 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=7 |
| 5 | + |
| 6 | +inherit autotools elisp-common eutils flag-o-matic java-pkg-opt-2 multilib vcs-clean xdg-utils |
| 7 | + |
| 8 | +PATCHSET_VER="0" |
| 9 | +MY_P=${PN}-srcdist-${PV} |
| 10 | + |
| 11 | +DESCRIPTION="Mercury is a modern general-purpose logic/functional programming language" |
| 12 | +HOMEPAGE="http://www.mercurylang.org/index.html" |
| 13 | +SRC_URI="http://dl.mercurylang.org/release/${MY_P}.tar.gz |
| 14 | + mirror://gentoo/${P}-gentoo-patchset-${PATCHSET_VER}.tar.gz" |
| 15 | + |
| 16 | +LICENSE="GPL-2 LGPL-2" |
| 17 | +SLOT="0" |
| 18 | +KEYWORDS="~amd64 ~x86" |
| 19 | + |
| 20 | +IUSE="debug doc emacs erlang examples java mono profile readline threads trail" |
| 21 | + |
| 22 | +DEPEND="net-libs/libnsl:0= |
| 23 | + readline? ( sys-libs/readline:= ) |
| 24 | + erlang? ( dev-lang/erlang ) |
| 25 | + java? ( >=virtual/jdk-1.6:= ) |
| 26 | + mono? ( dev-lang/mono ) |
| 27 | + doc? ( sys-apps/texinfo )" |
| 28 | + |
| 29 | +RDEPEND="${DEPEND} |
| 30 | + emacs? ( >=app-editors/emacs-23.1:* )" |
| 31 | + |
| 32 | +S="${WORKDIR}"/${MY_P} |
| 33 | + |
| 34 | +SITEFILE=50${PN}-gentoo.el |
| 35 | + |
| 36 | +src_prepare() { |
| 37 | + if [[ -d "${WORKDIR}"/${PV} ]] ; then |
| 38 | + eapply "${WORKDIR}"/${PV} |
| 39 | + fi |
| 40 | + eapply_user |
| 41 | + |
| 42 | + AT_M4DIR=m4 eautoreconf |
| 43 | + |
| 44 | + xdg_environment_reset |
| 45 | +} |
| 46 | + |
| 47 | +src_configure() { |
| 48 | + strip-flags |
| 49 | + |
| 50 | + local myconf |
| 51 | + myconf="--libdir=/usr/$(get_libdir) \ |
| 52 | + $(use_enable mono csharp-grade) \ |
| 53 | + $(use_enable erlang erlang-grade) \ |
| 54 | + $(use_enable java java-grade) \ |
| 55 | + $(use_enable debug debug-grades) \ |
| 56 | + $(use_enable profile prof-grades) \ |
| 57 | + $(use_enable threads par-grades) \ |
| 58 | + $(use_enable trail trail-grades) \ |
| 59 | + $(use_with readline)" |
| 60 | + |
| 61 | + econf ${myconf} |
| 62 | +} |
| 63 | + |
| 64 | +src_compile() { |
| 65 | + # Prepare mmake flags |
| 66 | + echo "EXTRA_CFLAGS = ${CFLAGS}" >> Mmake.params |
| 67 | + echo "EXTRA_LD_LIBFLAGS = ${LDFLAGS}" >> Mmake.params |
| 68 | + echo "EXTRA_MLFLAGS = --no-strip" >> Mmake.params |
| 69 | + |
| 70 | + echo "EXTRA_LD_LIBFLAGS += -Wl,-soname=libgc.so" >> boehm_gc/Mmake.boehm_gc.params |
| 71 | + echo "EXTRA_LD_LIBFLAGS += -Wl,-soname=libmer_rt.so" >> runtime/Mmake.runtime.params |
| 72 | + echo "EXTRA_LD_LIBFLAGS += -Wl,-soname=libmer_std.so" >> library/Mmake.library.params |
| 73 | + |
| 74 | + # Build Mercury using bootstrap grade |
| 75 | + emake \ |
| 76 | + PARALLEL="'${MAKEOPTS}'" \ |
| 77 | + TEXI2DVI="" PDFTEX="" |
| 78 | + |
| 79 | + # We can now patch .m Mercury compiler files since we |
| 80 | + # have just built mercury_compiler. |
| 81 | + if [[ -d "${WORKDIR}"/${PV}-mmc ]] ; then |
| 82 | + eapply "${WORKDIR}"/${PV}-mmc |
| 83 | + fi |
| 84 | + |
| 85 | + sed -i -e "s/@libdir@/$(get_libdir)/" \ |
| 86 | + "${S}"/compiler/file_util.m \ |
| 87 | + "${S}"/compiler/make.program_target.m \ |
| 88 | + || die "sed libdir failed" |
| 89 | + |
| 90 | + # Rebuild Mercury compiler using the just built mercury_compiler |
| 91 | + emake \ |
| 92 | + PARALLEL="'${MAKEOPTS}'" \ |
| 93 | + MERCURY_COMPILER="${S}"/compiler/mercury_compile \ |
| 94 | + TEXI2DVI="" PDFTEX="" |
| 95 | + |
| 96 | + # The default Mercury grade may not be the same as the bootstrap |
| 97 | + # grade. Since src_test() is run before src_install() we compile |
| 98 | + # the default grade now |
| 99 | + emake \ |
| 100 | + PARALLEL="'${MAKEOPTS}'" \ |
| 101 | + MERCURY_COMPILER="${S}"/compiler/mercury_compile \ |
| 102 | + TEXI2DVI="" PDFTEX="" \ |
| 103 | + default_grade |
| 104 | +} |
| 105 | + |
| 106 | +src_test() { |
| 107 | + TEST_GRADE=$(scripts/ml --print-grade) |
| 108 | + if [ -d "${S}"/install_grade_dir.${TEST_GRADE} ] ; then |
| 109 | + TWS="${S}"/install_grade_dir.${TEST_GRADE} |
| 110 | + cp runtime/mer_rt.init "${TWS}"/runtime/ |
| 111 | + cp mdbcomp/mer_mdbcomp.init "${TWS}"/mdbcomp/ |
| 112 | + cp browser/mer_browser.init "${TWS}"/browser/ |
| 113 | + else |
| 114 | + TWS="${S}" |
| 115 | + fi |
| 116 | + |
| 117 | + cd "${S}"/tests || die |
| 118 | + sed -e "s:@WORKSPACE@:${TWS}:" \ |
| 119 | + < WS_FLAGS.ws \ |
| 120 | + > WS_FLAGS \ |
| 121 | + || die "sed WORKSPACE failed" |
| 122 | + sed -e "s:@WORKSPACE@:${TWS}:" \ |
| 123 | + < .mgnuc_copts.ws \ |
| 124 | + > .mgnuc_copts \ |
| 125 | + || die "sed WORKSPACE failed" |
| 126 | + find . -mindepth 1 -type d -exec cp .mgnuc_opts {} \; |
| 127 | + find . -mindepth 1 -type d -exec cp .mgnuc_copts {} \; |
| 128 | + |
| 129 | + # Mercury tests must be run in C locale since Mercury output is |
| 130 | + # compared to hard-coded warnings/errors |
| 131 | + LC_ALL="C" \ |
| 132 | + PATH="${TWS}"/scripts:"${TWS}"/util:"${S}"/slice:"${PATH}" \ |
| 133 | + TERM="" \ |
| 134 | + WORKSPACE="${TWS}" \ |
| 135 | + WORKSPACE_FLAGS=yes \ |
| 136 | + MERCURY_COMPILER="${TWS}"/compiler/mercury_compile \ |
| 137 | + MMAKE_DIR="${TWS}"/scripts \ |
| 138 | + MERCURY_SUPPRESS_STACK_TRACE=yes \ |
| 139 | + GRADE=${TEST_GRADE} \ |
| 140 | + mmake || die "mmake test failed" |
| 141 | +} |
| 142 | + |
| 143 | +src_install() { |
| 144 | + emake \ |
| 145 | + PARALLEL="'${MAKEOPTS}'" \ |
| 146 | + MERCURY_COMPILER="${S}"/compiler/mercury_compile \ |
| 147 | + TEXI2DVI="" PDFTEX="" \ |
| 148 | + DESTDIR="${D}" \ |
| 149 | + INSTALL_ELISP_DIR="${D}/${SITELISP}"/${PN} \ |
| 150 | + install |
| 151 | + |
| 152 | + if use java; then |
| 153 | + keepdir /usr/$(get_libdir)/mercury/modules/java |
| 154 | + fi |
| 155 | + |
| 156 | + if use mono; then |
| 157 | + keepdir /usr/$(get_libdir)/mercury/modules/csharp |
| 158 | + fi |
| 159 | + |
| 160 | + if use emacs; then |
| 161 | + elisp-site-file-install "${FILESDIR}/${SITEFILE}" \ |
| 162 | + || die "elisp-site-file-install failed" |
| 163 | + fi |
| 164 | + |
| 165 | + dodoc \ |
| 166 | + BUGS HISTORY LIMITATIONS NEWS README README.Linux \ |
| 167 | + README.Linux-Alpha README.Linux-m68k README.Linux-PPC \ |
| 168 | + RELEASE_NOTES VERSION || die |
| 169 | + |
| 170 | + if use erlang; then |
| 171 | + dodoc README.Erlang |
| 172 | + fi |
| 173 | + |
| 174 | + if use java; then |
| 175 | + dodoc README.Java |
| 176 | + fi |
| 177 | + |
| 178 | + if use mono; then |
| 179 | + dodoc README.CSharp |
| 180 | + fi |
| 181 | + |
| 182 | + if use examples; then |
| 183 | + docinto /usr/share/doc/${PF}/samples |
| 184 | + dodoc samples/{*.m,README,Mmakefile} |
| 185 | + dodoc -r samples/c_interface \ |
| 186 | + samples/diff \ |
| 187 | + samples/muz \ |
| 188 | + samples/rot13 \ |
| 189 | + samples/solutions \ |
| 190 | + samples/solver_types |
| 191 | + |
| 192 | + if use java; then |
| 193 | + dodoc -r samples/java_interface |
| 194 | + fi |
| 195 | + |
| 196 | + ecvs_clean "${D}"/usr/share/doc/${PF}/samples |
| 197 | + fi |
| 198 | +} |
| 199 | + |
| 200 | +pkg_postinst() { |
| 201 | + use emacs && elisp-site-regen |
| 202 | +} |
| 203 | + |
| 204 | +pkg_postrm() { |
| 205 | + use emacs && elisp-site-regen |
| 206 | +} |
0 commit comments