summaryrefslogtreecommitdiff
blob: 9885280d9d32e556d1833e598ed06a2c9482890b (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

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

inherit toolchain-funcs

DESCRIPTION="SCM is a Scheme implementation from the author of slib"
HOMEPAGE="http://swiss.csail.mit.edu/~jaffer/SCM"
SRC_URI="http://groups.csail.mit.edu/mac/ftpdir/scm/${MY_P}.zip"
S=${WORKDIR}/${PN}

SLOT="0"
LICENSE="LGPL-3"
KEYWORDS="~amd64 ~x86 ~amd64-linux"
IUSE="arrays bignums cautious dynamic-linking engineering-notation gsubr inexact ioext libscm macro ncurses posix readline regex sockets unix"

BDEPEND="app-arch/unzip"
DEPEND=">=dev-scheme/slib-3.1.5
	dev-util/cproto
	ncurses? ( sys-libs/ncurses:0= )
	readline? ( sys-libs/libtermcap-compat )"
RDEPEND="${DEPEND}"

PATCHES=( "${FILESDIR}/${P}-multiplefixes.patch"
	"${FILESDIR}/${P}-respect-ldflags.patch" )

src_prepare() {
	default

	sed \
		-e "s|\"gcc\"|\"$(tc-getCC)\"|g" \
		-e "s|\"ld\"|\"$(tc-getLD)\"|g" \
		-i ./build.scm || die
}

src_compile() {
	# SLIB is required to build SCM.
	local slibpath="${EPREFIX}/usr/share/slib/"
	if [ -n "$SCHEME_LIBRARY_PATH" ]; then
		einfo "using SLIB $SCHEME_LIBRARY_PATH"
	elif [ -d ${slibpath} ]; then
		export SCHEME_LIBRARY_PATH=${slibpath}
	fi

	einfo "Making scmlit"
	emake -j1 CC=$(tc-getCC) scmlit clean

	einfo "Building scm"
	local features=""
	use arrays && features+="arrays"
	use bignums && features+=" bignums"
	use cautious && features+=" cautious"
	use engineering-notation && features+=" engineering-notation"
	use inexact && features+=" inexact"
	use macro && features+=" macro"

	( use readline ||
	  use ncurses ||
	  use regex ||
	  use posix ||
	  use ioext ||
	  use gsubr ||
	  use sockets ||
	  use unix ||
	  use dynamic-linking ) && features+=" dynamic-linking"

	./build \
		--compiler-options="${CFLAGS}" \
		--linker-options="${LDFLAGS} -L${EPREFIX}/$(get_libdir)" \
		-s "${EPREFIX}"/usr/$(get_libdir)/scm \
		-F ${features:="none"} \
		-h system \
		-o scm || die

	einfo "Building DLLs"
	if use readline; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-h system \
			-F edit-line \
			-t dll || die
	fi
	if use ncurses ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-F curses \
			-h system \
			-t dll || die
	fi
	if use regex ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c rgx.c \
			-h system \
			-t dll || die
	fi
	if use gsubr ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c gsubr.c \
			-h system \
			-t dll || die
	fi
	if use ioext ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c ioext.c \
			-h system \
			-t dll || die
	fi
	if use posix; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c posix.c \
			-h system \
			-t dll || die
	fi
	if use sockets ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c socket.c \
			-h system \
			-t dll || die
	fi
	if use unix ; then
		./build \
			--compiler-options="${CFLAGS}" \
			--linker-options="${LDFLAGS}" \
			-c unix.c \
			-h system \
			-t dll || die
	fi

	if use libscm ; then
		emake libscm.a
	fi
}

src_test() {
	emake check
}

src_install() {
	emake DESTDIR="${D}" man1dir="${EPREFIX}"/usr/share/man/man1/ \
		install

	if use libscm; then
		emake DESTDIR="${D}" libdir="${EPREFIX}"/usr/$(get_libdir)/ \
			installlib
	fi

	doinfo scm.info
	doinfo hobbit.info
}

regen_catalog() {
	einfo "Regenerating catalog..."
	scm -e "(require 'new-catalog)"
}

pkg_postinst() {
	[[ -z ${ROOT} ]] && regen_catalog
}

pkg_config() {
	regen_catalog
}