summaryrefslogtreecommitdiff
blob: 7b118e2da6824f39bd154ef323d64d4e882eb91f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit common-lisp-common-3 eutils toolchain-funcs

PATCHSET=${PV/*_p/}
YEAR=${PATCHSET:0:4}
MONTH=${PATCHSET:4:5}

DESCRIPTION="CMU Common Lisp is an implementation of ANSI Common Lisp"
HOMEPAGE="http://www.cons.org/cmucl/"
SRC_URI="http://common-lisp.net/project/cmucl/downloads/snapshots/${YEAR}/${MONTH}/cmucl-src-${YEAR}-${MONTH}.tar.bz2
		http://common-lisp.net/project/cmucl/downloads/snapshots/${YEAR}/${MONTH}/cmucl-${YEAR}-${MONTH}-x86-linux.tar.bz2"

LICENSE="public-domain"
SLOT="0"
KEYWORDS="~x86"
IUSE="X source sse2"

RDEPEND="x11-libs/openmotif"
DEPEND="${RDEPEND}
		sys-devel/bc"
PDEPEND="dev-lisp/gentoo-init"

PROVIDE="virtual/commonlisp"

S="${WORKDIR}"

src_unpack() {
	unpack ${A} && cd "${S}"

	epatch "${FILESDIR}"/19f-gentoo.patch
	find "${S}" -type f \( -name \*.sh -o -name linux-nm \) \
		-exec chmod +x '{}' \;
	sed -i -e "s,CC = .*,CC = $(tc-getCC),g" src/lisp/Config.linux_gencgc
	sed -i -e 's,"time","",g' src/tools/build.sh
	sed -i -e "s,@CFLAGS@,${CFLAGS},g" src/lisp/Config.linux_gencgc src/motif/server/Config.x86
}

src_compile() {
	use X || local OPTS="-u"
	if use sse2 ; then
		export CMUFPU="sse2"
	else
		export CMUFPU="x87"
	fi
	local buildimage="bin/lisp -core lib/cmucl/lib/lisp-${CMUFPU}.core -batch -noinit -nositeinit"
	src/tools/build.sh -C "" -o "${buildimage}" ${OPTS} -f ${CMUFPU} || die "Cannot build the compiler"
}

src_install() {
	src/tools/make-dist.sh -g -G root -O root build-4 ${PV} x86 linux
	dodir /usr/share/doc
	for i in cmucl-${PV}-x86-linux.{,extra.}tar.gz; do
		tar xzpf $i -C "${D}"/usr
	done

	mv "${D}"/usr/bin/lisp "${D}"/usr/bin/lisp.bin
	cat > "${T}"/lisp <<EOF
#!/bin/sh

exec ${ROOT%/}/usr/bin/lisp.bin -f ${CMUFPU} "\$@"
EOF
	dobin "${T}"/lisp

	mv "${D}"/usr/doc "${D}"/usr/share/doc/${PF}
	mv "${D}"/usr/man "${D}"/usr/share/

	# Install site config file
	sed "s,@PF@,${PF},g ; s,@VERSION@,$(date +%F),g" \
		< "${FILESDIR}"/site-init.lisp.in \
		> "${D}"/usr/$(get_libdir)/cmucl/site-init.lisp
	rm -f "${D}"/etc/lisp-config.lisp
	dodir /etc/common-lisp/cmucl
	dosym /etc/common-lisp/cmucl/site-init.lisp /etc/lisp-config.lisp
	cat > "${D}"/etc/common-lisp/cmucl/site-init.lisp <<EOF
(in-package :common-lisp-user)

(if (probe-file "/etc/gentoo-init.lisp")
	(load "/etc/gentoo-init.lisp")
  (format t "~%;;; Warning: There is no /etc/gentoo-init.lisp file (which should be provided by dev-lisp/gentoo-init"))
EOF

	# Install sources
	if use source; then
		local basedir=/usr/share/common-lisp/source/cmucl
		cd src
		for f in $(find . -name \*.lisp -and -type f); do
			local dir=${basedir}/$(dirname ${f})
			dodir ${dir} ; insinto ${dir}
			doins ${f}
		done
	fi

	impl-save-timestamp-hack cmucl || die
}

pkg_postinst() {
	standard-impl-postinst cmucl
}

pkg_postrm() {
	standard-impl-postrm cmucl /usr/bin/lisp.bin
}