dev-cpp/commoncpp2-1.8.1-r2: stable on amd64
[gentoo.git] / dev-lisp / sbcl / sbcl-1.3.0.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6 inherit multilib eutils flag-o-matic pax-utils
7
8 #same order as http://www.sbcl.org/platform-table.html
9 BV_X86=1.2.7
10 BV_AMD64=1.3.0
11 BV_PPC=1.2.7
12 BV_SPARC=1.0.28
13 BV_ALPHA=1.0.28
14 BV_ARM=1.2.7
15 BV_ARM64=1.3.0
16 BV_PPC_MACOS=1.0.47
17 BV_X86_MACOS=1.1.6
18 BV_X64_MACOS=1.2.11
19 BV_SPARC_SOLARIS=1.0.23
20 BV_X86_SOLARIS=1.2.7
21 BV_X64_SOLARIS=1.2.7
22
23 DESCRIPTION="Steel Bank Common Lisp (SBCL) is an implementation of ANSI Common Lisp"
24 HOMEPAGE="http://sbcl.sourceforge.net/"
25 SRC_URI="mirror://sourceforge/sbcl/${P}-source.tar.bz2
26         x86? ( mirror://sourceforge/sbcl/${PN}-${BV_X86}-x86-linux-binary.tar.bz2 )
27         amd64? ( mirror://sourceforge/sbcl/${PN}-${BV_AMD64}-x86-64-linux-binary.tar.bz2 )
28         ppc? ( mirror://sourceforge/sbcl/${PN}-${BV_PPC}-powerpc-linux-binary.tar.bz2 )
29         sparc? ( mirror://sourceforge/sbcl/${PN}-${BV_SPARC}-sparc-linux-binary.tar.bz2 )
30         alpha? ( mirror://sourceforge/sbcl/${PN}-${BV_ALPHA}-alpha-linux-binary.tar.bz2 )
31         arm? ( mirror://sourceforge/sbcl/${PN}-${BV_ARM}-armhf-linux-binary.tar.bz2 )
32         ppc-macos? ( mirror://sourceforge/sbcl/${PN}-${BV_PPC_MACOS}-powerpc-darwin-binary.tar.bz2 )
33         x86-macos? ( mirror://sourceforge/sbcl/${PN}-${BV_X86_MACOS}-x86-darwin-binary.tar.bz2 )
34         x64-macos? ( mirror://sourceforge/sbcl/${PN}-${BV_X64_MACOS}-x86-64-darwin-binary.tar.bz2 )
35         sparc-solaris? ( mirror://sourceforge/sbcl/${PN}-${BV_SPARC_SOLARIS}-sparc-solaris-binary.tar.bz2 )
36         x86-solaris? ( mirror://sourceforge/sbcl/${PN}-${BV_X86_SOLARIS}-x86-solaris-binary.tar.bz2 )
37         x64-solaris? ( mirror://sourceforge/sbcl/${PN}-${BV_X64_SOLARIS}-x86-64-solaris-binary.tar.bz2 )"
38
39 LICENSE="MIT"
40 SLOT="0/${PV}"
41 KEYWORDS="~amd64 ~ppc ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x86-solaris"
42 IUSE="debug doc source +threads +unicode pax_kernel zlib"
43
44 CDEPEND=">=dev-lisp/asdf-3.1:="
45 DEPEND="${CDEPEND}
46                 doc? ( sys-apps/texinfo >=media-gfx/graphviz-2.26.0 )
47                 pax_kernel? ( sys-apps/elfix )"
48 RDEPEND="${CDEPEND}
49                 !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.6 ) )"
50
51 # Disable warnings about executable stacks, as this won't be fixed soon by upstream
52 QA_EXECSTACK="usr/bin/sbcl"
53
54 CONFIG="${S}/customize-target-features.lisp"
55 ENVD="${T}/50sbcl"
56
57 # Prevent ASDF from using the system libraries
58 CL_SOURCE_REGISTRY="(:source-registry :ignore-inherited-configuration)"
59 ASDF_OUTPUT_TRANSLATIONS="(:output-translations :ignore-inherited-configuration)"
60
61 usep() {
62         use ${1} && echo "true" || echo "false"
63 }
64
65 sbcl_feature() {
66         echo "$( [[ ${1} == "true" ]] && echo "(enable ${2})" || echo "(disable ${2})")" >> "${CONFIG}"
67 }
68
69 sbcl_apply_features() {
70         sed 's/^X//' > "${CONFIG}" <<-'EOF'
71         (lambda (list)
72         X  (flet ((enable  (x) (pushnew x list))
73         X         (disable (x) (setf list (remove x list))))
74         EOF
75         if use x86 || use amd64; then
76                 sbcl_feature "$(usep threads)" ":sb-thread"
77         fi
78         sbcl_feature "true" ":sb-ldb"
79         sbcl_feature "false" ":sb-test"
80         sbcl_feature "$(usep unicode)" ":sb-unicode"
81         sbcl_feature "$(usep zlib)" ":sb-core-compression"
82         sbcl_feature "$(usep debug)" ":sb-xref-for-internals"
83         sed 's/^X//' >> "${CONFIG}" <<-'EOF'
84         X    )
85         X  list)
86         EOF
87         cat "${CONFIG}"
88 }
89
90 src_unpack() {
91         unpack ${A}
92         mv sbcl-*-* sbcl-binary || die
93         cd "${S}"
94 }
95
96 src_prepare() {
97         eapply "${FILESDIR}"/gentoo-fix_install_man.patch
98         # bug #468482
99         eapply "${FILESDIR}"/concurrency-test-1.2.6.patch
100         # bugs #486552, #527666, #517004
101         eapply "${FILESDIR}"/bsd-sockets-test-1.2.11.patch
102         # bugs #560276, #561018
103         eapply "${FILESDIR}"/sb-posix-test-1.2.15.patch
104
105         eapply "${FILESDIR}"/${PN}-1.2.11-solaris.patch
106         eapply "${FILESDIR}"/${PN}-1.2.13-verbose-build.patch
107
108         # To make the hardened compiler NOT compile with -fPIE -pie
109         if gcc-specs-pie ; then
110                 einfo "Disabling PIE..."
111                 eapply "${FILESDIR}"/${PN}-1.1.17-gentoo-fix_nopie_for_hardened_toolchain.patch
112         fi
113
114         eapply_user
115
116         # bug #526194
117         sed -e "s@CFLAGS =.*\$@CFLAGS = ${CFLAGS} -g -Wall -Wsign-compare@" \
118                 -e "s@LINKFLAGS =.*\$@LINKFLAGS = ${LDFLAGS} -g@" \
119                 -i src/runtime/GNUmakefile || die
120
121         sed -e "s@SBCL_PREFIX=\"/usr/local\"@SBCL_PREFIX=\"${EPREFIX}/usr\"@" \
122                 -i make-config.sh || die
123
124         cp "${EPREFIX}"/usr/share/common-lisp/source/asdf/build/asdf.lisp contrib/asdf/ || die
125
126         use source && sed 's%"$(BUILD_ROOT)%$(MODULE).lisp "$(BUILD_ROOT)%' -i contrib/vanilla-module.mk
127
128         # Some shells(such as dash) don't have "time" as builtin
129         # and we don't want to DEPEND on sys-process/time
130         sed "s,^time ,," -i make.sh || die
131         sed "s,/lib,/$(get_libdir),g" -i install.sh || die
132         # #define SBCL_HOME ...
133         sed "s,/usr/local/lib,${EPREFIX}/usr/$(get_libdir),g" -i src/runtime/runtime.c || die
134         # change location of /etc/sbclrc ...
135         sed  "s,/etc/sbclrc,${EPREFIX}/etc/sbclrc,g" -i src/code/toplevel.lisp || die
136
137         find . -type f -name .cvsignore -delete
138 }
139
140 src_configure() {
141         # customizing SBCL version as per
142         # http://sbcl.cvs.sourceforge.net/sbcl/sbcl/doc/PACKAGING-SBCL.txt?view=markup
143         echo -e ";;; Auto-generated by Gentoo\n\"gentoo-${PR}\"" > branch-version.lisp-expr
144
145         # applying customizations
146         sbcl_apply_features
147 }
148
149 src_compile() {
150         local bindir="${WORKDIR}"/sbcl-binary
151
152         strip-unsupported-flags ; filter-flags -fomit-frame-pointer
153
154         if use pax_kernel ; then
155                 # To disable PaX on hardened systems
156                 pax-mark -mr "${bindir}"/src/runtime/sbcl
157
158                 # Hack to disable PaX on second GENESIS stage
159                 sed -i -e '/^[ \t]*echo \/\/doing warm init - compilation phase$/a\    paxmark.sh -mr \.\/src\/runtime\/sbcl' \
160                         "${S}"/make-target-2.sh || die "Cannot disable PaX on second GENESIS runtime"
161         fi
162
163         # clear the environment to get rid of non-ASCII strings, see bug 174702
164         # set HOME for paludis
165         env - HOME="${T}" PATH="${PATH}" \
166                 CC="$(tc-getCC)" AS="$(tc-getAS)" LD="$(tc-getLD)" \
167                 CPPFLAGS="${CPPFLAGS}" CFLAGS="${CFLAGS}" ASFLAGS="${ASFLAGS}" LDFLAGS="${LDFLAGS}" \
168                 GNUMAKE=make ./make.sh \
169                 "sh ${bindir}/run-sbcl.sh --no-sysinit --no-userinit --disable-debugger" \
170                 || die "make failed"
171
172         # need to set HOME because libpango(used by graphviz) complains about it
173         if use doc; then
174                 env - HOME="${T}" PATH="${PATH}" \
175                         CL_SOURCE_REGISTRY="(:source-registry :ignore-inherited-configuration)" \
176                         ASDF_OUTPUT_TRANSLATIONS="(:output-translations :ignore-inherited-configuration)" \
177                         make -C doc/manual info html || die "Cannot build manual"
178                 env - HOME="${T}" PATH="${PATH}" \
179                         CL_SOURCE_REGISTRY="(:source-registry :ignore-inherited-configuration)" \
180                         ASDF_OUTPUT_TRANSLATIONS="(:output-translations :ignore-inherited-configuration)" \
181                         make -C doc/internals info html || die "Cannot build internal docs"
182         fi
183 }
184
185 src_test() {
186         ewarn "Unfortunately, it is known that some tests fail eg."
187         ewarn "run-program.impure.lisp. This is an issue of the upstream's"
188         ewarn "development and not of Gentoo's side. Please, before filing"
189         ewarn "any bug(s) search for older submissions. Thank you."
190         time ( cd tests && sh run-tests.sh )
191 }
192
193 src_install() {
194         # install system-wide initfile
195         dodir /etc/
196         sed 's/^X//' > "${ED}"/etc/sbclrc <<-EOF
197         ;;; The following is required if you want source location functions to
198         ;;; work in SLIME, for example.
199         X
200         (setf (logical-pathname-translations "SYS")
201         X      '(("SYS:SRC;**;*.*.*" #p"${EPREFIX}/usr/$(get_libdir)/sbcl/src/**/*.*")
202         X        ("SYS:CONTRIB;**;*.*.*" #p"${EPREFIX}/usr/$(get_libdir)/sbcl/**/*.*")))
203         X
204         ;;; Setup ASDF2
205         (load "${EPREFIX}/etc/common-lisp/gentoo-init.lisp")
206         EOF
207
208         # Install documentation
209         unset SBCL_HOME
210         INSTALL_ROOT="${ED}/usr" LIB_DIR="${EPREFIX}/usr/$(get_libdir)" DOC_DIR="${ED}/usr/share/doc/${PF}" \
211                 sh install.sh || die "install.sh failed"
212
213         # bug #517008
214         pax-mark -mr "${D}"/usr/bin/sbcl
215
216         # rm empty directories lest paludis complain about this
217         find "${ED}" -empty -type d -exec rmdir -v {} +
218
219         if use doc; then
220                 docinto html
221                 dodoc -r doc/manual/
222                 dodoc -r doc/internals/sbcl-internals
223
224                 doinfo doc/manual/*.info*
225                 doinfo doc/internals/sbcl-internals.info
226
227                 docinto internals-notes
228                 dodoc doc/internals-notes/*
229         else
230                 rm -Rv "${ED}/usr/share/doc/${PF}" || die
231         fi
232
233         dodoc BUGS CREDITS INSTALL NEWS OPTIMIZATIONS PRINCIPLES README TLA TODO
234
235         # install the SBCL source
236         if use source; then
237                 ./clean.sh
238                 cp -av src "${ED}/usr/$(get_libdir)/sbcl/" || die
239         fi
240
241         # necessary for running newly-saved images
242         echo "SBCL_HOME=${EPREFIX}/usr/$(get_libdir)/${PN}" > "${ENVD}"
243         echo "SBCL_SOURCE_ROOT=${EPREFIX}/usr/$(get_libdir)/${PN}/src" >> "${ENVD}"
244         doenvd "${ENVD}"
245 }