update
[restas-lisp-overlay.git] / eclass / eggs.eclass
blob2a3954327209efa094f5196b33f29ce93fcca608
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
5 # Copyright 2008 Leonardo Valeri Manera <l.valerimanera@gmail.com>
7 # @ECLASS: eggs.eclass
8 # @MAINTAINER:
9 # @BLURB: Eclass for Chicken-Scheme Egg packages
10 # @DESCRIPTION:
12 # This eclass provides generalized functions to compile, test and
13 # install eggs, as well as setting a number of variables to default
14 # or autogenerated values.
16 # @ECLASS-VARIABLE: NEED_CHICKEN
17 # @DESCRIPTION:
18 # If you need anything different from chicken 3.0.5, use the
19 # NEED_CHICKEN variable before inheriting elisp.eclass. Set it to the
20 # major version the egg needs and the dependency will be adjusted.
22 # @ECLASS-VARIABLE: EGG_TESTABLE
23 # @DESCRIPTION:
24 # Enables egg test-phase if set to 'yes'.
26 # @ECLASS-VARIABLE: EGG_NAME
27 # @DESCRIPTION:
28 # Override egg name autogeneration by settting this before importing
29 # this eclass.
31 RESTRICT="primaryuri"
33 inherit flag-o-matic
35 VERSION="${NEED_CHICKEN:-3.1.0}"
36 DEPEND=">=dev-scheme/chicken-${VERSION}"
37 RDEPEND=">=dev-scheme/chicken-${VERSION}"
38 SLOT="0"
39 IUSE=""
41 case ${PN} in
42 srfi*)
43 EGG_NAME=${PN/#srfi/srfi-}
46 EGG_NAME=${EGG_NAME:-${PN}}
48 esac
50 EGGDOC_DIR="/usr/share/doc/chicken-eggs/${PN}"
52 SRC_URI="http://cleo.uwindsor.ca/cgi-bin/gentoo-eggs/${EGG_NAME}-3-${PV}.tar.gz"
54 if [[ -n "${OLD_EGGPAGE}" ]]; then
55 HOMEPAGE="http://www.call-with-current-continuation.org/eggs/${EGG_NAME}"
56 else
57 HOMEPAGE="http://chicken.wiki.br/${EGG_NAME}"
60 # @FUNCTION: eggs-install_binaries
61 # @USAGE:
62 # @DESCRIPTION:
63 # INstall egg binaries/scripts/wrappers into /usr/bin
64 eggs-install_binaries() {
65 if [[ -d "${S}/install/${PROGRAM_PATH}" ]]; then
66 pushd "${S}/install/${PROGRAM_PATH}" >/dev/null
67 local file
68 for file in $(ls); do
69 einfo " => /usr/bin/${file}"
70 dobin "${file}" || die "failed installing ${file}"
71 eend $?
72 done
73 popd >/dev/null
77 # @FUNCTION: eggs-install_files
78 # @USAGE:
79 # @DESCRIPTION:
80 # Install egg files into the correct locations.
81 eggs-install_files() {
82 local destination=${1:-${CHICKEN_REPOSITORY}}
83 local real_destination
84 local file
85 for file in $(ls); do
86 case "${file}" in
87 *.html|*.css)
88 # Hackish, but working, way of displaying real destinations
89 # in info messages. Feel free to improve on it.
90 real_destination=${EGGDOC_DIR}
91 insinto "${EGGDOC_DIR}"
92 insopts -m644
94 *.so)
95 real_destination=${destination}
96 insinto "${destination}"
97 insopts -m755
100 real_destination=${destination}
101 insinto "${destination}"
102 insopts -m644
104 esac
105 if [[ -d "${file}" ]];then
106 # To iterate is human, to recurse, divine.
107 ( cd "${file}"; eggs-install_files "${destination}/${file}" )
108 else
109 einfo " => ${real_destination}/${file}"
110 doins "${file}" || die "failed installing ${file}"
111 eend $?
113 done
116 # @FUNCTION: eggs-set_paths
117 # @USAGE:
118 # @DESCRIPTION:
119 # Modify the .setup-info file(s) to reflect true documentation
120 # installation paths.
121 eggs-set_paths() {
122 ebegin "Processing setup files"
123 for setup_file in $(ls *.setup-info); do
124 einfo " ${setup_file}"
125 sed -e "s:${PROGRAM_PATH}:/usr/bin:g" \
126 -e "s:${CHICKEN_REPOSITORY}/\(.*\).html:${EGGDOC_DIR}/\1.html:g" \
127 -i "${setup_file}" || die "failed processing ${setup_file}"
128 eend $?
129 done
130 einfo "Done processing setup files."
134 # Ebuild function redefintions
137 eggs_src_unpack() {
138 mkdir "${S}"
139 cd "${S}"
140 unpack "${A}" || die
143 eggs_src_compile() {
144 strip-flags || die
145 filter-ldflags -Wl,--as-needed
146 CSC_OPTIONS="-C '$CFLAGS $LDFLAGS'"
148 CHICKEN_SETUP_OPTIONS="-v -k -build-prefix ${S}/build -install-prefix ${S}/install"
150 chicken-setup ${CHICKEN_SETUP_OPTIONS} || die "egg compilation failed"
153 eggs_src_test() {
154 if [[ "${EGG_TESTABLE}" == "yes" ]]; then
155 chicken-setup -n -t ${CHICKEN_SETUP_OPTIONS} || die "egg test phase failed"
159 eggs_src_install() {
160 CHICKEN_REPOSITORY=$(chicken-setup -R) || die
161 PROGRAM_PATH=$(chicken-setup -P) || die
163 pushd "${S}/install/${CHICKEN_REPOSITORY}" >/dev/null
165 [[ -f index.html ]] && rm index.html
166 eggs-set_paths
168 ebegin "Installing files"
169 eggs-install_binaries
170 eggs-install_files
171 einfo "Done with installation."
173 popd >/dev/null
176 EXPORT_FUNCTIONS src_unpack src_compile src_test src_install