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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.81 - (show annotations) (download)
Mon Aug 22 04:46:32 2011 UTC (2 years, 8 months ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.80: +5 -5 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.80 2011/07/08 11:35:01 ssuominen Exp $
4
5 # DEPRECATION NOTICE
6 # This eclass is deprecated because it does not properly handle
7 # multiple ruby targets. Please use ruby-ng.eclass instead.
8 #
9 # @ECLASS: ruby.eclass
10 # @MAINTAINER:
11 # Ruby herd <ruby@gentoo.org>
12 # @AUTHOR:
13 # Author: Mamoru KOMACHI <usata@gentoo.org>
14
15 # The ruby eclass is designed to allow easier installation of ruby
16 # softwares, and their incorporation into the Gentoo Linux system.
17
18 # src_unpack, src_compile and src_install call a set of functions to emerge
19 # ruby with SLOT support; econf, emake and einstall is a wrapper for ruby
20 # to automate configuration, make and install process (they override default
21 # econf, emake and einstall defined by ebuild.sh respectively).
22
23 # Functions:
24 # src_unpack Unpacks source archive(s) and apply patches if any.
25 # src_compile Invokes econf and emake.
26 # src_install Runs einstall and erubydoc.
27 # econf Detects setup.rb, install.rb, extconf.rb and configure,
28 # and then runs the configure script.
29 # emake Runs make if any Makefile exists.
30 # einstall Calls install script or Makefile. If both not present,
31 # installs programs under sitedir.
32 # erubydoc Finds any documents and puts them in the right place.
33 # erubydoc needs more sophistication to handle all types of
34 # appropriate documents.
35
36 # Variables:
37 # USE_RUBY Space delimited list of supported ruby.
38 # Set it to "any" if it installs only version independent files.
39 # If your ebuild supports both ruby 1.6 and 1.8 but has version
40 # depenedent files such as libraries, set it to something like
41 # "ruby16 ruby18". Possible values are "any ruby16 ruby18 ruby19"
42 # RUBY_ECONF You can pass extra arguments to econf by defining this
43 # variable. Note that you cannot specify them by command line
44 # if you are using <sys-apps/portage-2.0.49-r17.
45 # @VARIABLE: PATCHES
46 # @DESCRIPTION:
47 # If you have any patches to apply, set PATCHES to their locations and
48 # epatch will apply them. It also handles epatch-style bulk patches,
49 # if you know how to use them and set the correct variables. If you
50 # don't, read eutils.eclass.
51
52 inherit eutils toolchain-funcs
53
54 EXPORT_FUNCTIONS src_unpack src_compile src_install
55
56 HOMEPAGE="http://raa.ruby-lang.org/list.rhtml?name=${PN}"
57 SRC_URI="mirror://gentoo/${P}.tar.gz"
58
59 SLOT="0"
60 LICENSE="Ruby"
61
62 # If you specify RUBY_OPTIONAL you also need to take care of ruby useflag and dependency.
63 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
64 DEPEND="${DEPEND} =dev-lang/ruby-1.8*"
65 RDEPEND="${RDEPEND} =dev-lang/ruby-1.8*"
66 fi
67
68 [[ -z "${RUBY}" ]] && export RUBY=/usr/bin/ruby
69
70 ruby_patch_mkmf() {
71
72 if [ ! -x /bin/install -a -x /usr/bin/install ]; then
73 einfo "Patching mkmf"
74 cat <<END >"${T}"/mkmf.rb
75 require 'mkmf'
76
77 STDERR.puts 'Modified mkmf is used'
78 CONFIG['INSTALL'] = '/usr/bin/install'
79 END
80 # save it because rubygems needs it (for unsetting RUBYOPT)
81 export GENTOO_RUBYOPT="-r${T}/mkmf.rb"
82 export RUBYOPT="${RUBYOPT} ${GENTOO_RUBYOPT}"
83 fi
84
85 }
86
87 ruby_src_unpack() {
88 #ruby_patch_mkmf
89 unpack ${A}
90 cd "${S}"
91
92 # Apply any patches that have been provided.
93 if [[ ${#PATCHES[@]} -gt 1 ]]; then
94 for x in "${PATCHES[@]}"; do
95 epatch "${x}"
96 done
97 elif [[ -n "${PATCHES}" ]]; then
98 for x in ${PATCHES}; do
99 epatch "${x}"
100 done
101 fi
102 }
103
104 ruby_econf() {
105
106 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
107 if [ -f configure ] ; then
108 ./configure \
109 --prefix=/usr \
110 --host=${CHOST} \
111 --mandir=/usr/share/man \
112 --infodir=/usr/share/info \
113 --datadir=/usr/share \
114 --sysconfdir=/etc \
115 --localstatedir=/var/lib \
116 --with-ruby=${RUBY} \
117 ${RUBY_ECONF} \
118 "$@" || die "econf failed"
119 fi
120 if [ -f install.rb ] ; then
121 ${RUBY} install.rb config --prefix=/usr "$@" \
122 ${RUBY_ECONF} || die "install.rb config failed"
123 ${RUBY} install.rb setup "$@" \
124 ${RUBY_ECONF} || die "install.rb setup failed"
125 fi
126 if [ -f setup.rb ] ; then
127 ${RUBY} setup.rb config --prefix=/usr "$@" \
128 ${RUBY_ECONF} || die "setup.rb config failed"
129 ${RUBY} setup.rb setup "$@" \
130 ${RUBY_ECONF} || die "setup.rb setup failed"
131 fi
132 if [ -f extconf.rb ] ; then
133 ${RUBY} extconf.rb "$@" \
134 ${RUBY_ECONF} || die "extconf.rb failed"
135 fi
136 }
137
138 ruby_emake() {
139 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
140 emake CC="$(tc-getCC)" CXX="$(tc-getCXX)" DLDFLAGS="${LDFLAGS}" "$@" || die "emake for ruby failed"
141 fi
142 }
143
144 ruby_src_compile() {
145 # You can pass configure options via RUBY_ECONF
146 ruby_econf || die
147 ruby_emake "$@" || die
148 }
149
150 doruby() {
151 ( # dont want to pollute calling env
152 insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
153 insopts -m 0644
154 doins "$@"
155 ) || die "failed to install $@"
156 }
157
158 ruby_einstall() {
159 local siteruby
160
161 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
162 if [ -f install.rb ] ; then
163 ${RUBY} install.rb config --prefix="${D}"/usr "$@" \
164 ${RUBY_ECONF} || die "install.rb config failed"
165 ${RUBY} install.rb install "$@" \
166 ${RUBY_ECONF} || die "install.rb install failed"
167 elif [ -f setup.rb ] ; then
168 ${RUBY} setup.rb config --prefix="${D}"/usr "$@" \
169 ${RUBY_ECONF} || die "setup.rb config failed"
170 ${RUBY} setup.rb install "$@" \
171 ${RUBY_ECONF} || die "setup.rb install failed"
172 elif [ -f extconf.rb -o -f Makefile ] ; then
173 make DESTDIR="${D}" "$@" install || die "make install failed"
174 else
175 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
176 insinto ${siteruby}
177 doins *.rb || die "doins failed"
178 fi
179 }
180
181 erubydoc() {
182 local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
183
184 einfo "running dodoc for ruby ;)"
185
186 insinto ${rdbase}
187 [ -n "${rdfiles}" ] && doins ${rdfiles}
188 rmdir "${D}"${rdbase} 2>/dev/null || true
189 if [ -d doc -o -d docs ] ; then
190 dohtml -x html -r {doc,docs}/*
191 dohtml -r {doc,docs}/html/*
192 else
193 dohtml -r *
194 fi
195
196 if has examples ${IUSE} && use examples; then
197 for dir in sample samples example examples; do
198 if [ -d ${dir} ] ; then
199 dodir /usr/share/doc/${PF}
200 cp -pPR ${dir} "${D}"/usr/share/doc/${PF} || die "cp failed"
201 fi
202 done
203 fi
204
205 for i in ChangeLog* [[:upper:]][[:upper:]]* ; do
206 [ -e $i ] && dodoc $i
207 done
208 }
209
210 ruby_src_install() {
211
212 ruby_einstall "$@" || die
213
214 erubydoc
215 }
216
217 # erubyconf, erubymake and erubyinstall are kept for compatibility
218 erubyconf() {
219 ruby_econf "$@"
220 }
221
222 erubymake() {
223 ruby_emake "$@"
224 }
225
226 erubyinstall() {
227 ruby_einstall "$@"
228 }
229
230 # prepall adds SLOT support for ruby.eclass. SLOT support currently
231 # does not work for gems, so if a gem is installed we skip all the
232 # SLOT code to avoid possible errors, in particular the mv command
233 # that is part of the USE_RUBY="any" case.
234 prepall() {
235
236 if [ -z "${GEM_SRC}" ]; then
237
238 [[ ! -x /usr/bin/ruby16 ]] && export USE_RUBY=${USE_RUBY/ruby16/}
239 [[ ! -x /usr/bin/ruby18 ]] && export USE_RUBY=${USE_RUBY/ruby18/}
240 [[ ! -x /usr/bin/ruby19 ]] && export USE_RUBY=${USE_RUBY/ruby19/}
241 [[ ! -x /usr/bin/rubyee ]] && export USE_RUBY=${USE_RUBY/rubyee/}
242
243 local ruby_slots=$(echo "${USE_RUBY}" | wc -w)
244
245 if [ "$ruby_slots" -ge 2 ] ; then
246 einfo "Now we are building the package for ${USE_RUBY}"
247 for rb in ${USE_RUBY} ; do
248 einfo "Using $rb"
249 export RUBY=/usr/bin/$rb
250 ruby() { /usr/bin/$rb "$@" ; }
251 mkdir -p "${S}"
252 cd "${WORKDIR}"
253 einfo "Unpacking for $rb"
254 src_unpack || die "src_unpack failed"
255 cd "${S}"
256 find . -name '*.[ao]' -exec rm {} \;
257 einfo "Building for $rb"
258 src_compile || die "src_compile failed"
259 cd "${S}"
260 einfo "Installing for $rb"
261 src_install || die "src_install failed"
262 done
263 elif [ "${USE_RUBY}" == "any" ] ; then
264 eerror "USE_RUBY=\"any\" is no longer supported. Please use explicit versions instead."
265 die "USE_RUBY=\"any\" is no longer supported."
266 fi
267 fi
268
269 # Continue with the regular prepall, see bug 140697
270 (unset prepall; prepall)
271 }

  ViewVC Help
Powered by ViewVC 1.1.20