summaryrefslogtreecommitdiff
blob: 2a3954327209efa094f5196b33f29ce93fcca608 (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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
#
# Copyright 2008 Leonardo Valeri Manera <l.valerimanera@gmail.com>
#
# @ECLASS: eggs.eclass
# @MAINTAINER:
# @BLURB: Eclass for Chicken-Scheme Egg packages
# @DESCRIPTION:
#
# This eclass provides generalized functions to compile, test and
# install eggs, as well as setting a number of variables to default
# or autogenerated values.

# @ECLASS-VARIABLE: NEED_CHICKEN
# @DESCRIPTION:
# If you need anything different from chicken 3.0.5, use the
# NEED_CHICKEN variable before inheriting elisp.eclass.  Set it to the
# major version the egg needs and the dependency will be adjusted.

# @ECLASS-VARIABLE: EGG_TESTABLE
# @DESCRIPTION:
# Enables egg test-phase if set to 'yes'.

# @ECLASS-VARIABLE: EGG_NAME
# @DESCRIPTION:
# Override egg name autogeneration by settting this before importing
# this eclass.

RESTRICT="primaryuri"

inherit flag-o-matic

VERSION="${NEED_CHICKEN:-3.1.0}"
DEPEND=">=dev-scheme/chicken-${VERSION}"
RDEPEND=">=dev-scheme/chicken-${VERSION}"
SLOT="0"
IUSE=""

case ${PN} in
	srfi*)
		EGG_NAME=${PN/#srfi/srfi-}
		;;
	*)
		EGG_NAME=${EGG_NAME:-${PN}}
		;;
esac

EGGDOC_DIR="/usr/share/doc/chicken-eggs/${PN}"

SRC_URI="http://cleo.uwindsor.ca/cgi-bin/gentoo-eggs/${EGG_NAME}-3-${PV}.tar.gz"

if [[ -n "${OLD_EGGPAGE}" ]]; then
	HOMEPAGE="http://www.call-with-current-continuation.org/eggs/${EGG_NAME}"
else
	HOMEPAGE="http://chicken.wiki.br/${EGG_NAME}"
fi

# @FUNCTION: eggs-install_binaries
# @USAGE:
# @DESCRIPTION:
# INstall egg binaries/scripts/wrappers into /usr/bin
eggs-install_binaries() {
	if [[ -d "${S}/install/${PROGRAM_PATH}" ]]; then
		pushd "${S}/install/${PROGRAM_PATH}" >/dev/null
		local file
		for file in $(ls); do
			einfo "  => /usr/bin/${file}"
			dobin "${file}" || die "failed installing ${file}"
			eend $?
		done
		popd >/dev/null
	fi
}

# @FUNCTION: eggs-install_files
# @USAGE:
# @DESCRIPTION:
# Install egg files into the correct locations.
eggs-install_files() {
	local destination=${1:-${CHICKEN_REPOSITORY}}
	local real_destination
	local file
	for file in $(ls); do
		case "${file}" in
			*.html|*.css)
				# Hackish, but working, way of displaying real destinations
				# in info messages. Feel free to improve on it.
				real_destination=${EGGDOC_DIR}
				insinto "${EGGDOC_DIR}"
				insopts -m644
				;;
			*.so)
				real_destination=${destination}
				insinto "${destination}"
				insopts -m755
				;;
			*)
				real_destination=${destination}
				insinto "${destination}"
				insopts -m644
				;;
		esac
		if [[ -d "${file}" ]];then
			# To iterate is human, to recurse, divine.
			( cd "${file}"; eggs-install_files "${destination}/${file}" )
		else
			einfo "  => ${real_destination}/${file}"
			doins "${file}" || die "failed installing ${file}"
			eend $?
		fi
	done
}

# @FUNCTION: eggs-set_paths
# @USAGE:
# @DESCRIPTION:
# Modify the .setup-info file(s) to reflect true documentation
# installation paths.
eggs-set_paths() {
	ebegin "Processing setup files"
	for setup_file in $(ls *.setup-info); do
		einfo "  ${setup_file}"
		sed -e "s:${PROGRAM_PATH}:/usr/bin:g" \
			-e "s:${CHICKEN_REPOSITORY}/\(.*\).html:${EGGDOC_DIR}/\1.html:g" \
			-i "${setup_file}" || die "failed processing ${setup_file}"
		eend $?
	done
	einfo "Done processing setup files."
}

#
# Ebuild function redefintions
#

eggs_src_unpack() {
	mkdir "${S}"
	cd "${S}"
	unpack "${A}" || die
}

eggs_src_compile() {
	strip-flags || die
	filter-ldflags -Wl,--as-needed
	CSC_OPTIONS="-C '$CFLAGS $LDFLAGS'"

	CHICKEN_SETUP_OPTIONS="-v -k -build-prefix ${S}/build -install-prefix ${S}/install"

	chicken-setup ${CHICKEN_SETUP_OPTIONS} || die "egg compilation failed"
}

eggs_src_test() {
	if [[ "${EGG_TESTABLE}" == "yes" ]]; then
		chicken-setup -n -t ${CHICKEN_SETUP_OPTIONS} || die "egg test phase failed"
	fi
}

eggs_src_install() {
	CHICKEN_REPOSITORY=$(chicken-setup -R) || die
	PROGRAM_PATH=$(chicken-setup -P) || die

	pushd "${S}/install/${CHICKEN_REPOSITORY}" >/dev/null

	[[ -f index.html ]] && rm index.html
	eggs-set_paths

	ebegin "Installing files"
	eggs-install_binaries
	eggs-install_files
	einfo "Done with installation."

	popd >/dev/null
}

EXPORT_FUNCTIONS src_unpack src_compile src_test src_install