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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Thu Jan 22 07:37:25 2004 UTC (14 years, 6 months ago) by usata
Branch: MAIN
Changes since 1.20: +12 -1 lines
Added setup.rb support

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.20 2004/01/22 07:25:32 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 HOMEPAGE="http://raa.ruby-lang.org/list.rhtml?name=${PN}"
36 SRC_URI="mirror://gentoo/${P}.tar.gz"
37
38 SLOT="0"
39 LICENSE="Ruby"
40
41 newdepend ">=dev-lang/ruby-1.6.8"
42 if has_version '=dev-lang/ruby-1.6*' && [[ "${USE_RUBY/ruby16/}" != "${USE_RUBY}" ]] ; then
43 WITH_RUBY="${WITH_RUBY} ruby16"
44 fi
45 if has_version '=dev-lang/ruby-1.8*' && [[ "${USE_RUBY/ruby18/}" != "${USE_RUBY}" ]] ; then
46 WITH_RUBY="${WITH_RUBY} ruby18"
47 fi
48 if has_version '=dev-lang/ruby-1.6*' && has_version '=dev-lang/ruby-1.8*' \
49 && [[ "${USE_RUBY/any/}" != "${USE_RUBY}" ]] ; then
50 WITH_RUBY="${WITH_RUBY} any"
51 fi
52
53 ruby_src_unpack() {
54
55 unpack ${A}
56 # apply bulk patches
57 if [[ -n "${PATCHES}" ]] ; then
58 for p in ${PATCHES} ; do
59 epatch $p
60 done
61 fi
62
63 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
64 cd ${WORKDIR}
65 mkdir ${T}/build
66 tar cf - . | ( cd ${T}/build ; tar xpf - )
67 fi
68 }
69
70 erubyconf() {
71 local RUBY
72 if [ "$1" = ruby16 ] ; then
73 RUBY=/usr/bin/ruby16
74 elif [ "$1" = ruby18 ] ; then
75 RUBY=/usr/bin/ruby18
76 else
77 RUBY=/usr/bin/ruby
78 fi
79 shift
80
81 if [ -f configure ] ; then
82 ./configure \
83 --prefix=/usr \
84 --host=${CHOST} \
85 --mandir=/usr/share/man \
86 --infodir=/usr/share/info \
87 --datadir=/usr/share \
88 --sysconfdir=/etc \
89 --localstatedir=/var/lib \
90 --with-ruby=${RUBY} \
91 ${EXTRA_ECONF} \
92 $@ || die "econf failed"
93 fi
94 if [ -f install.rb ] ; then
95 ${RUBY} install.rb config --prefix=/usr $@ \
96 || die "install.rb config failed"
97 ${RUBY} install.rb setup $@ \
98 || die "install.rb setup failed"
99 fi
100 if [ -f setup.rb ] ; then
101 ${RUBY} setup.rb config --prefix=/usr $@ \
102 || die "setup.rb config failed"
103 ${RUBY} setup.rb setup $@ \
104 || die "setup.rb setup failed"
105 fi
106 if [ -f extconf.rb ] ; then
107 ${RUBY} extconf.rb $@ || die "extconf.rb failed"
108 fi
109 }
110
111 ruby_econf() {
112 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
113 einfo "running econf for ruby 1.6 ;)"
114 erubyconf ruby16 $@ || die
115 einfo "running econf for ruby 1.8 ;)"
116 cd ${T}/build/${S#${WORKDIR}}
117 erubyconf ruby18 $@ || die
118 cd -
119 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
120 einfo "running econf for ruby 1.6 ;)"
121 erubyconf ruby16 $@ || die
122 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
123 einfo "running econf for ruby 1.8 ;)"
124 erubyconf ruby18 $@ || die
125 else
126 einfo "running econf for ruby ;)"
127 erubyconf ruby $@ || die
128 fi
129 }
130
131 erubymake() {
132 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
133 make $@ || die "emake for ruby failed"
134 fi
135 }
136
137 ruby_emake() {
138 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
139 einfo "running emake for ruby 1.6 ;)"
140 erubymake $@ || die
141 einfo "running emake for ruby 1.8 ;)"
142 cd ${T}/build/${S#${WORKDIR}}
143 erubymake $@ || die
144 cd -
145 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
146 einfo "running emake for ruby 1.6 ;)"
147 [[ -x /usr/bin/ruby16 ]] && RUBY=ruby16 || RUBY=ruby
148 erubymake RUBY=${RUBY} $@
149 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
150 einfo "running emake for ruby 1.8 ;)"
151 [[ -x /usr/bin/ruby18 ]] && RUBY=ruby18 || RUBY=ruby
152 erubymake RUBY=${RUBY} $@
153 else
154 einfo "running emake for ruby ;)"
155 erubymake $@ || die
156 fi
157 }
158
159 ruby_src_compile() {
160
161 ruby_econf || die
162 ruby_emake $@ || die
163 }
164
165 erubyinstall() {
166 local RUBY siteruby
167 if [ "$1" = ruby16 -a -x /usr/bin/ruby16 ] ; then
168 RUBY=/usr/bin/ruby16
169 elif [ "$1" = ruby18 -a -x /usr/bin/ruby18 ] ; then
170 RUBY=/usr/bin/ruby18
171 else
172 RUBY=/usr/bin/ruby
173 fi
174 shift
175
176 if [ -f install.rb ] ; then
177 ${RUBY} install.rb config --prefix=${D}/usr $@ \
178 || die "install.rb config failed"
179 ${RUBY} install.rb install $@ \
180 || die "install.rb install failed"
181 elif [ -f setup.rb ] ; then
182 ${RUBY} setup.rb config --prefix=${D}/usr $@ \
183 || die "setup.rb config failed"
184 ${RUBY} setup.rb install $@ \
185 || die "setup.rb install failed"
186 elif [ -f extconf.rb -o -f Makefile ] ; then
187 make DESTDIR=${D} $@ install || die "make install failed"
188 else
189 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
190 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
191 else
192 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
193 fi
194 insinto ${siteruby}
195 doins *.rb || "doins failed"
196 fi
197 }
198
199 ruby_einstall() {
200
201 local siteruby=$(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
202
203 if [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" && "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
204 einfo "running einstall for ruby 1.6 ;)"
205 erubyinstall ruby16 $@
206 einfo "running einstall for ruby 1.8 ;)"
207 cd ${T}/build/${S#${WORKDIR}}
208 erubyinstall ruby18 $@
209 cd -
210 elif [[ "${WITH_RUBY/ruby16/}" != "${WITH_RUBY}" ]] ; then
211 einfo "running einstall for ruby 1.6 ;)"
212 erubyinstall ruby16 $@
213 elif [[ "${WITH_RUBY/ruby18/}" != "${WITH_RUBY}" ]] ; then
214 einfo "running einstall for ruby 1.8 ;)"
215 erubyinstall ruby18 $@
216 elif [[ "${WITH_RUBY/any/}" != "${WITH_RUBY}" ]] ; then
217 if [ -n "`use ruby16`" ] ; then
218 erubyinstall ruby16 $@
219 if [ -d ${D}${siteruby}/../1.6 ] ; then
220 cd ${D}${siteruby}/../1.6
221 dodir ${siteruby}/../1.8
222 for x in * ; do
223 ln -s ../1.6/$x ../1.8/$x
224 done
225 cd -
226 fi
227 else
228 erubyinstall ruby18 $@
229 if [ -d ${D}${siteruby}/../1.8 ] ; then
230 cd ${D}${siteruby}/../1.8
231 dodir ${siteruby}/../1.6
232 for x in * ; do
233 ln -s ../1.8/$x ../1.6/$x
234 done
235 cd -
236 fi
237 fi
238 erubyinstall
239 else
240 einfo "running einstall for ruby ;)"
241 erubyinstall ruby $@
242 fi
243 }
244
245 erubydoc() {
246 local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
247
248 einfo "running dodoc for ruby ;)"
249
250 insinto ${rdbase}
251 [ -n "${rdfiles}" ] && doins ${rdfiles}
252 rmdir --ignore-fail-on-non-empty ${D}${rdbase}
253 if [ -d doc -o -d docs -o examples ] ; then
254 dohtml -x html -r {doc,docs,examples}/*
255 dohtml -r {doc,docs,examples}/html/*
256 else
257 dohtml -r *
258 fi
259 if [ -d sample ] ; then
260 dodir /usr/share/doc/${PF}
261 cp -a sample ${D}/usr/share/doc/${PF} || "cp failed"
262 fi
263 for i in ChangeLog* [A-Z][A-Z]* ; do
264 [ -e $i ] && dodoc $i
265 done
266 }
267
268 ruby_src_install() {
269
270 ruby_einstall $@ || die
271
272 erubydoc
273 }

  ViewVC Help
Powered by ViewVC 1.1.20