1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # Author Matthew Kennedy <mkennedy@gentoo.org>
7 # Sundry code common to many Common Lisp related ebuilds.
11 inherit eutils multilib
13 CLFASLROOT=/usr/$(get_libdir)/common-lisp/
14 CLSOURCEROOT=/usr/share/common-lisp/source/
15 CLSYSTEMROOT=/usr/share/common-lisp/systems/
17 # Many of our Common Lisp ebuilds are either inspired by, or actually
18 # use packages and files from the Debian project's archives.
22 for i in copyright README.Debian changelog; do
23 # be silent, since all files are not always present
24 dodoc "${S}"/debian/${i} &>/dev/null || true
29 # Most of the code below is from Debian's Common Lisp Controller
32 register-common-lisp-implementation() {
33 PROGNAME=$(basename $0)
34 # first check if there is at least a compiler-name:
37 usage: $PROGNAME compiler-name
39 registers a Common Lisp compiler to the
40 Common-Lisp-Controller system.
45 FILE="/usr/$(get_libdir)/common-lisp/bin/$IMPL.sh"
46 if [ ! -f "$FILE" ] ; then
48 $PROGNAME: I cannot find the script $FILE for the implementation $IMPL
52 if [ ! -r "$FILE" ] ; then
54 $PROGNAME: I cannot read the script $FILE for the implementation $IMPL
58 # install CLC into the lisp
59 sh "$FILE" install-clc || (echo "Installation of CLC failed" >&2 ; exit 3)
60 mkdir /usr/$(get_libdir)/common-lisp/$IMPL &>/dev/null || true
61 chown cl-builder:cl-builder /usr/$(get_libdir)/common-lisp/$IMPL
63 # now recompile the stuff
64 for i in /usr/share/common-lisp/systems/*.asd ; do
65 if [ -f $i -a -r $i ] ; then
68 clc-autobuild-check $IMPL $package
70 echo recompiling package $package for implementation $IMPL
71 /usr/bin/clc-send-command --quiet recompile $package $IMPL
75 for i in /usr/share/common-lisp/systems/*.system ; do
76 if [ -f $i -a -r $i ] ; then
79 clc-autobuild-check $IMPL $package
81 echo recompiling package $package for implementation $IMPL
82 /usr/bin/clc-send-command --quiet recompile $package $IMPL
86 echo "$PROGNAME: Compiler $IMPL installed"
89 unregister-common-lisp-implementation() {
90 PROGNAME=$(basename $0)
91 if [ `id -u` != 0 ] ; then
92 echo $PROGNAME: you need to be root to run this program
97 usage: $PROGNAME compiler-name
99 un-registers a Common Lisp compiler to the
100 Common-Lisp-Controller system.
105 IMPL_BIN="/usr/$(get_libdir)/common-lisp/bin/$IMPL.sh"
106 if [ ! -f "$IMPL_BIN" ] ; then
108 $PROGNAME: No implementation of the name $IMPL is registered
109 Cannot find the file $IMPL_BIN
111 Maybe you already removed it?
115 if [ ! -r "$IMPL_BIN" ] ; then
117 $PROGNAME: No implementation of the name $IMPL is registered
118 Cannot read the file $IMPL_BIN
120 Maybe you already removed it?
125 sh $IMPL_BIN remove-clc || echo "De-installation of CLC failed" >&2
126 clc-autobuild-impl $IMPL inherit
127 # Just remove the damn subtree
128 (cd / ; rm -rf "/usr/$(get_libdir)/common-lisp/$IMPL/" ; true )
129 echo "$PROGNAME: Common Lisp implementation $IMPL uninstalled"
132 reregister-all-common-lisp-implementations() {
133 # Rebuilds all common lisp implementations
134 # Written by Kevin Rosenberg <kmr@debian.org>
136 local clc_bin_dir=/usr/$(get_libdir)/common-lisp/bin
137 local opt=$(shopt nullglob); shopt -s nullglob
139 for impl_bin in *.sh; do
140 impl=$(echo $impl_bin | sed 's/\(.*\).sh/\1/')
141 unregister-common-lisp-implementation $impl
142 register-common-lisp-implementation $impl
145 [[ $opt = *off ]] && shopt -u nullglob
148 # BIG FAT HACK: Since the Portage emerge step kills file timestamp
149 # information, we need to compensate by ensuring all FASL files are
150 # more recent than their source files.
152 # The following `impl-*-timestamp-hack' functions SHOULD NOT be used
153 # outside of this eclass.
155 impl-save-timestamp-hack() {
157 dodir /usr/share/${impl}
158 tar cpjf "${D}"/usr/share/${impl}/portage-timestamp-compensate -C "${D}"/usr/$(get_libdir)/${impl} .
161 impl-restore-timestamp-hack() {
163 tar xjpfo /usr/share/${impl}/portage-timestamp-compensate -C /usr/$(get_libdir)/${impl}
166 impl-remove-timestamp-hack() {
168 rm -rf /usr/$(get_libdir)/${impl} &>/dev/null || true
175 if [ $i == ${symbol} ]; then
182 standard-impl-postinst() {
184 rm -rf /usr/$(get_libdir)/common-lisp/${impl}/* &>/dev/null || true
185 chown cl-builder:cl-builder /usr/$(get_libdir)/common-lisp/${impl}
186 if test-in ${impl} cmucl sbcl; then
187 impl-restore-timestamp-hack ${impl}
189 chown -R root:0 /usr/$(get_libdir)/${impl}
190 /usr/bin/clc-autobuild-impl ${impl} yes
191 register-common-lisp-implementation ${impl}
194 standard-impl-postrm() {
195 local impl=$1 impl_binary=$2
196 # Since we keep our own time stamps we must manually remove them
198 if [ ! -x ${impl_binary} ]; then
199 if test-in ${impl} cmucl sbcl; then
200 impl-remove-timestamp-hack ${impl}
202 rm -rf /usr/$(get_libdir)/common-lisp/${impl}/*
206 # Local Variables: ***
207 # mode: shell-script ***