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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.83 - (show annotations) (download)
Fri Jul 4 02:00:23 2014 UTC (2 months, 2 weeks ago) by mrueg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.82: +1 -1 lines
FILE REMOVED
Remove deprecated ruby.eclass and gems.eclass. Please use ruby-ng.eclass and ruby-fakegem.eclass instead. See bug #479812

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

  ViewVC Help
Powered by ViewVC 1.1.20