summaryrefslogtreecommitdiff
blob: a239934da6175f44022332f9cf08605c8f65d2ac (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="6"

inherit versionator

#version magic thanks to masterdriverz and UberLord using bash array instead of tr
trarr="0abcdefghi"
MY_PV="$(get_version_component_range 1)${trarr:$(get_version_component_range 2):1}$(get_version_component_range 3)"

DESCRIPTION="Portable Scheme library for all standard Scheme implementations"
HOMEPAGE="http://people.csail.mit.edu/jaffer/SLIB"
SRC_URI="http://groups.csail.mit.edu/mac/ftpdir/scm/${PN}-${MY_PV}.zip"

RESTRICT="mirror"

LICENSE="public-domain BSD"
SLOT="0"
KEYWORDS="~alpha amd64 ~ia64 ppc ~ppc64 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-solaris"
IUSE="gambit scm"

RDEPEND="
	>=sys-apps/texinfo-5.0
	>=dev-scheme/guile-1.8.8:=
	gambit? ( dev-scheme/gambit )
	scm? ( dev-scheme/scm )"
DEPEND="${RDEPEND}
	app-arch/unzip"

DOCS=( ANNOUNCE COPYING FAQ README ChangeLog slib.{txt,html} )

PATCHES=(
	"${FILESDIR}/${P}-fix-paths.patch"
	"${FILESDIR}/${P}-fix-makefile-guile.patch"
)

S="${WORKDIR}/${PN}"

src_configure() {
	./configure \
		--prefix=/usr \
		--libdir=/usr/share || die
}

src_compile() {
	default

	makeinfo -o slib.txt --plaintext --force slib.texi || die
	makeinfo -o slib.html --html --no-split --force slib.texi || die
}

src_install() {
	# core
	dodir /usr/share/${PN}
	insinto /usr/share/${PN}
	doins *.{dat,init,ps,scm,sh}

	# permissions
	local i
	for i in "${ED%/}"/usr/share/${PN}/*.sh ; do
		fperms +x /usr/share/${PN}/$(basename "$i")
	done

	# bin
	dodir /usr/bin/
	dosym /usr/share/${PN}/${PN}.sh /usr/bin/${PN}

	# env
	doenvd "${FILESDIR}/50slib"

	# docs
	doinfo slib.info
	doman slib.1

	# guile
	if has_version '=dev-scheme/guile-2.0*'; then
		dodir /usr/share/guile/2.0
		dosym /usr/share/${PN}/ /usr/share/guile/2.0/${PN}
	else
		dodir /usr/share/guile/1.8
		dosym /usr/share/${PN}/ /usr/share/guile/1.8/${PN}
	fi

	# backwards compatibility
	dodir /usr/lib/
	dosym /usr/share/${PN}/ /usr/lib/${PN}
}

_new_catalog() {
	if [[ ! "$1" =~ ^(guile|scm)$ ]]; then
		echo -n "(load \"${ROOT}/usr/share/slib/$1.init\")" || die
	fi
	echo " (require 'new-catalog) (slib:report-version)" || die
}

pkg_postinst() {
	local SCHEME_LIBRARY_PATH=/usr/share/slib/

	# catalogs
	einfo "Updating implementation catalogs.."
	guile -c "(use-modules (ice-9 slib)) $(_new_catalog guile)" |& grep -i '^slib' || die

	# broken as for now
	#	if use elk ; then
	#		echo "$(_new_catalog elk)" | elk -l -
	#	fi

	if use gambit ; then
		gsi -e "$(_new_catalog gambit)" || die
	fi

	if use scm ; then
		scm -e "$(_new_catalog scm)" || die
	fi
}

pkg_postrm() {
	for impl in 'guile/*' gambc scm; do
		rm -f "${ROOT}/usr/"lib*/${impl}/slibcat \
			"${ROOT}/usr/share/"${impl}/slibcat || die
	done
}