app-emacs/ebuild-mode: arm64 stable (bug #717326)
[gentoo.git] / app-emacs / slime / slime-2.15.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 [[ ${PV} = *9999* ]] && GIT_ECLASS="git-r3" || GIT_ECLASS=""
7
8 inherit common-lisp-3 ${GIT_ECLASS} elisp eutils
9
10 DESCRIPTION="SLIME, the Superior Lisp Interaction Mode (Extended)"
11 HOMEPAGE="http://common-lisp.net/project/slime/"
12 if [[ ${PV} != *9999* ]]; then
13         SRC_URI="https://github.com/slime/slime/archive/v${PV}.tar.gz -> ${P}.tar.gz"
14 fi
15
16 LICENSE="GPL-2 xref? ( xref.lisp )"
17 SLOT="0"
18 if [[ ${PV} != *9999* ]]; then
19         KEYWORDS="amd64 ppc ~sparc x86"
20 fi
21 IUSE="doc xref"
22 RESTRICT=test # tests fail to contact sbcl
23
24 RDEPEND="virtual/commonlisp
25                 dev-lisp/asdf"
26 DEPEND="${RDEPEND}
27                 >=sys-apps/texinfo-5.1
28                 doc? ( virtual/texi2dvi )"
29
30 CLPACKAGE=swank
31 CLSYSTEMS=swank
32 SITEFILE=70${PN}-gentoo.el
33
34 src_unpack() {
35         if [[ ${PV} == *9999* ]]; then
36                 EGIT_REPO_URI="https://github.com/slime/slime.git"
37                 ${GIT_ECLASS}_src_unpack
38         fi
39         elisp_src_unpack
40 }
41
42 src_prepare() {
43         if [[ "${PV}" == "2.11" ]]; then
44                 epatch "${FILESDIR}"/2.11/dont-load-sbcl-pprint.patch
45         fi
46         epatch "${FILESDIR}"/2.0_p20130214/gentoo-module-load.patch
47         epatch "${FILESDIR}"/2.0_p20110617/gentoo-dont-call-init.patch
48         has_version ">=app-editors/emacs-24" && rm -f lib/cl-lib.el
49
50         # extract date of last update from ChangeLog, bug 233270
51         SLIME_CHANGELOG_DATE=$(awk '/^[-0-9]+ / { print $1; exit; }' ChangeLog)
52         [ -n "${SLIME_CHANGELOG_DATE}" ] || die "cannot determine ChangeLog date"
53
54         if [[ "${PV}" == "2.11" ]] || [[ "${PV}" == "2.12" ]]; then
55                 # SLIME uses the changelog date to make sure that the emacs side and the CL side
56                 # are in sync. We hardcode it instead of letting slime determine it at runtime
57                 # because ChangeLog doesn't get installed to $EMACSDIR
58                 epatch "${FILESDIR}"/2.11/gentoo-changelog-date.patch
59         else
60                 epatch "${FILESDIR}"/2.15/gentoo-changelog-date.patch
61         fi
62
63         # When starting slime in emacs, slime looks for ${S}/swank/backend.lisp as
64         # /usr/share/common-lisp/source/swank/swank-backend.lisp
65         pushd swank || die
66         for i in *.lisp
67         do
68                 mv ${i} ../swank-${i}
69         done
70         popd
71
72         sed -i "/(defvar \*swank-wire-protocol-version\*/s:nil:\"${SLIME_CHANGELOG_DATE}\":" swank.lisp \
73                 || die "sed swank.lisp failed"
74         sed -i "s:@SLIME-CHANGELOG-DATE@:${SLIME_CHANGELOG_DATE}:" slime.el \
75                 || die "sed slime.el failed"
76         sed -i "s/@itemx INIT-FUNCTION/@item INIT-FUNCTION/" doc/slime.texi \
77                 || die "sed doc/slime.texi failed"
78
79         # Remove xref.lisp (which is non-free) unless USE flag is set
80         use xref || rm -f xref.lisp
81 }
82
83 src_compile() {
84         elisp-compile *.el
85         BYTECOMPFLAGS="${BYTECOMPFLAGS} -L contrib -l slime" \
86                 elisp-compile contrib/*.el lib/*.el
87         emake -j1 -C doc slime.info
88
89         if use doc; then
90                 VARTEXFONTS="${T}"/fonts \
91                         emake -j1 -C doc slime.pdf
92         fi
93 }
94
95 src_install() {
96         ## install core
97         elisp-install ${PN} *.{el,elc} "${FILESDIR}"/swank-loader.lisp
98         sed "s:/usr/:${EPREFIX}&:g" "${FILESDIR}"/2.0_p20110617/${SITEFILE} \
99                 >"${T}"/${SITEFILE} || die "sed failed"
100         elisp-site-file-install "${T}"/${SITEFILE}
101         cp "${FILESDIR}"/2.0_p20110617/swank.asd "${S}"
102         # remove upstream swank-loader, since it won't be used
103         rm "${S}"/swank-loader.lisp
104         common-lisp-install-sources *.lisp
105         common-lisp-install-asdf swank.asd
106
107         ## install contribs
108         elisp-install ${PN}/contrib/ contrib/*.{el,elc,scm,goo}
109         common-lisp-install-sources contrib/*.lisp
110
111         ## install lib
112         elisp-install ${PN}/lib/ lib/*.{el,elc}
113
114         ## install docs
115         dodoc README.md ChangeLog CONTRIBUTING.md NEWS PROBLEMS
116         newdoc contrib/README.md README-contrib.md
117         newdoc contrib/ChangeLog ChangeLog.contrib
118         doinfo doc/slime.info
119         use doc && dodoc doc/*.pdf
120 }