/[gentoo-x86]/eclass/ruby.eclass
Gentoo

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Mon Jan 12 17:55:05 2004 UTC (14 years, 6 months ago) by usata
Branch: MAIN
Changes since 1.17: +7 -6 lines
Explicitly `cd ${WORKDIR}` after xpatch. xpatch may change current
directory after it is called.

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.17 2003/12/24 22:14:55 usata Exp $
4 #
5 # Author: Mamoru KOMACHI <usata@gentoo.org>
6 #
7 # The ruby eclass is designed to allow easier installation of ruby
8 # softwares, and their incorporation into the Gentoo Linux system.
9
10 # src_unpack, src_compile and src_install call a set of functions to emerge
11 # ruby with SLOT support; econf, emake and einstall is a wrapper for ruby
12 # to automate configuration, make and install process (they override default
13 # econf, emake and einstall defined by ebuild.sh respectively).
14
15 # Variables:
16 # USE_RUBY Space delimited list of supported ruby.
17 # Set it to "any" if it installs only version independent files.
18 # If your ebuild supports both ruby 1.6 and 1.8 but has version
19 # depenedent files such as libraries, set it to something like
20 # "ruby16 ruby18". Possible values are "any ruby16 shim18 ruby18"
21 # Note: USE_RUBY="shim18" doesn't take any effect at the moment.
22 # WITH_RUBY Contains space delimited list of installed ruby which is
23 # supported (supported ruby should be specified in USE_RUBY).
24 # It is automatically defined if your ebuild set DEPEND list
25 # correctly, so usually you shouldn't set this variable by hand.
26 # EXTRA_ECONF You can pass extra arguments to econf by defining this
27 # variable. Note that you cannot specify them by command line
28 # if you are using <sys-apps/portage-2.0.49-r17.
29
30 ECLASS=ruby
31 INHERITED="${INHERITED} ${ECLASS}"
32 EXPORT_FUNCTIONS erubyconf erubymake erubyinstall erubydoc \
33 src_unpack econf emake src_compile einstall src_install
34
35 inherit eutils
36
37 HOMEPAGE="http://raa.ruby-lang.org/list.rhtml?name=${PN}"
38 SRC_URI="mirror://gentoo/${P}.tar.gz"
39
40 SLOT="0"
41 LICENSE="Ruby"
42
43 newdepend ">=dev-lang/ruby-1.6.8"
44 if has_version '=dev-lang/ruby-1.6*' && [[ "${USE_RUBY/ruby16/}" != "${USE_RUBY}" ]] ; then
45 WITH_RUBY="${WITH_RUBY} ruby16"
46 fi
47 if has_version '=dev-lang/ruby-1.8*' && [[ "${USE_RUBY/ruby18/}" != "${USE_RUBY}" ]] ; then
48 WITH_RUBY="${WITH_RUBY} ruby18"
49 fi
50 if has_version '=dev-lang/ruby-1.6*' && has_version '=dev-lang/ruby-1.8*' \
51 && [[ "${USE_RUBY/any/}" != "${USE_RUBY}" ]] ; then
52 WITH_RUBY="${WITH_RUBY} any"
53 fi
54
55 ruby_src_unpack() {
56
57 unpack ${A}
58 # apply bulk patches
59 [[ -n "${PATCHES}" ]] && xpatch "${PATCHES}"
60
61 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
62 cd ${WORKDIR}
63 mkdir ${T}/build
64 tar cf - . | ( cd ${T}/build ; tar xpf - )
65 fi
66 }
67
68 erubyconf() {
69 local RUBY
70 if [ "$1" = ruby16 ] ; then
71 RUBY=/usr/bin/ruby16
72 elif [ "$1" = ruby18 ] ; then
73 RUBY=/usr/bin/ruby18
74 else
75 RUBY=/usr/bin/ruby
76 fi
77 shift
78
79 if [ -f configure ] ; then
80 ./configure \
81 --prefix=/usr \
82 --host=${CHOST} \
83 --mandir=/usr/share/man \
84 --infodir=/usr/share/info \
85 --datadir=/usr/share \
86 --sysconfdir=/etc \
87 --localstatedir=/var/lib \
88 --with-ruby=${RUBY} \
89 ${EXTRA_ECONF} \
90 $@ || die "econf failed"
91 fi
92 if [ -f install.rb ] ; then
93 ${RUBY} install.rb config --prefix=/usr $@ \
94 || die "install.rb config failed"
95 ${RUBY} install.rb setup $@ \
96 || die "install.rb setup failed"
97 fi
98 if [ -f extconf.rb ] ; then
99 ${RUBY} extconf.rb $@ || die "extconf.rb failed"
100 fi
101 }
102
103 ruby_econf() {
104 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
105 einfo "running econf for ruby 1.6 ;)"
106 erubyconf ruby16 $@ || die
107 einfo "running econf for ruby 1.8 ;)"
108 cd ${T}/build/${S#${WORKDIR}}
109 erubyconf ruby18 $@ || die
110 cd -
111 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
112 einfo "running econf for ruby 1.6 ;)"
113 erubyconf ruby16 $@ || die
114 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
115 einfo "running econf for ruby 1.8 ;)"
116 erubyconf ruby18 $@ || die
117 else
118 einfo "running econf for ruby ;)"
119 erubyconf ruby $@ || die
120 fi
121 }
122
123 erubymake() {
124 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
125 make $@ || die "emake for ruby failed"
126 fi
127 }
128
129 ruby_emake() {
130 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
131 einfo "running emake for ruby 1.6 ;)"
132 erubymake $@ || die
133 einfo "running emake for ruby 1.8 ;)"
134 cd ${T}/build/${S#${WORKDIR}}
135 erubymake $@ || die
136 cd -
137 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
138 einfo "running emake for ruby 1.6 ;)"
139 [[ -x /usr/bin/ruby16 ]] && RUBY=ruby16 || RUBY=ruby
140 erubymake RUBY=${RUBY} $@
141 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
142 einfo "running emake for ruby 1.8 ;)"
143 [[ -x /usr/bin/ruby18 ]] && RUBY=ruby18 || RUBY=ruby
144 erubymake RUBY=${RUBY} $@
145 else
146 einfo "running emake for ruby ;)"
147 erubymake $@ || die
148 fi
149 }
150
151 ruby_src_compile() {
152
153 ruby_econf || die
154 ruby_emake $@ || die
155 }
156
157 erubyinstall() {
158 local RUBY siteruby
159 if [ "$1" = ruby16 -a -x /usr/bin/ruby16 ] ; then
160 RUBY=/usr/bin/ruby16
161 elif [ "$1" = ruby18 -a -x /usr/bin/ruby18 ] ; then
162 RUBY=/usr/bin/ruby18
163 else
164 RUBY=/usr/bin/ruby
165 fi
166 shift
167
168 if [ -f install.rb ] ; then
169 ${RUBY} install.rb config --prefix=${D}/usr $@ \
170 || die "install.rb config failed"
171 ${RUBY} install.rb install $@ \
172 || die "install.rb install failed"
173 elif [ -f extconf.rb -o -f Makefile ] ; then
174 make DESTDIR=${D} $@ install || die "make install failed"
175 else
176 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
177 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
178 else
179 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
180 fi
181 insinto ${siteruby}
182 doins *.rb || "doins failed"
183 fi
184 }
185
186 ruby_einstall() {
187
188 local siteruby=$(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
189
190 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
191 einfo "running einstall for ruby 1.6 ;)"
192 erubyinstall ruby16 $@
193 einfo "running einstall for ruby 1.8 ;)"
194 cd ${T}/build/${S#${WORKDIR}}
195 erubyinstall ruby18 $@
196 cd -
197 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
198 einfo "running einstall for ruby 1.6 ;)"
199 erubyinstall ruby16 $@
200 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
201 einfo "running einstall for ruby 1.8 ;)"
202 erubyinstall ruby18 $@
203 elif [[ "${WITH_RUBY/any/}" != "${WITH_RUBY}" ]] ; then
204 if [ -n "`use ruby16`" ] ; then
205 erubyinstall ruby16 $@
206 if [ -d ${D}${siteruby}/../1.6 ] ; then
207 cd ${D}${siteruby}/../1.6
208 dodir ${siteruby}/../1.8
209 for x in * ; do
210 ln -s ../1.6/$x ../1.8/$x
211 done
212 cd -
213 fi
214 else
215 erubyinstall ruby18 $@
216 if [ -d ${D}${siteruby}/../1.8 ] ; then
217 cd ${D}${siteruby}/../1.8
218 dodir ${siteruby}/../1.6
219 for x in * ; do
220 ln -s ../1.8/$x ../1.6/$x
221 done
222 cd -
223 fi
224 fi
225 erubyinstall
226 else
227 einfo "running einstall for ruby ;)"
228 erubyinstall ruby $@
229 fi
230 }
231
232 erubydoc() {
233 local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
234
235 einfo "running dodoc for ruby ;)"
236
237 insinto ${rdbase}
238 [ -n "${rdfiles}" ] && doins ${rdfiles}
239 rmdir --ignore-fail-on-non-empty ${D}${rdbase}
240 if [ -d doc -o -d docs -o examples ] ; then
241 dohtml -r doc/* docs/* examples/*
242 else
243 dohtml -r *
244 fi
245 if [ -d sample ] ; then
246 dodir /usr/share/doc/${PF}
247 cp -a sample ${D}/usr/share/doc/${PF} || "cp failed"
248 fi
249 for i in ChangeLog* [A-Z][A-Z]* ; do
250 [ -e $i ] && dodoc $i
251 done
252 }
253
254 ruby_src_install() {
255
256 ruby_einstall $@ || die
257
258 erubydoc
259 }

  ViewVC Help
Powered by ViewVC 1.1.20