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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.68 - (hide annotations) (download)
Sat Aug 25 18:49:44 2007 UTC (10 years, 10 months ago) by graaff
Branch: MAIN
Changes since 1.67: +45 -39 lines
USE_RUBY does not work for gems but does generate a (harmless) error, so ignore this code in prepall when installing a gem

1 vapier 1.35 # Copyright 1999-2004 Gentoo Foundation
2 agriffis 1.1 # Distributed under the terms of the GNU General Public License v2
3 graaff 1.68 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.67 2007/08/25 06:06:20 pclouds Exp $
4 agriffis 1.1 #
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 usata 1.12 # 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 usata 1.22 # Functions:
16     # src_unpack Unpacks source archive(s) and apply patches if any.
17     # src_compile Invokes econf and emake.
18     # src_install Runs einstall and erubydoc.
19     # econf Detects setup.rb, install.rb, extconf.rb and configure,
20     # and then runs the configure script.
21     # emake Runs make if any Makefile exists.
22     # einstall Calls install script or Makefile. If both not present,
23     # installs programs under sitedir.
24     # erubydoc Finds any documents and puts them in the right place.
25     # erubydoc needs more sophistication to handle all types of
26     # appropriate documents.
27    
28 usata 1.12 # Variables:
29 usata 1.15 # USE_RUBY Space delimited list of supported ruby.
30     # Set it to "any" if it installs only version independent files.
31     # If your ebuild supports both ruby 1.6 and 1.8 but has version
32     # depenedent files such as libraries, set it to something like
33 usata 1.22 # "ruby16 ruby18". Possible values are "any ruby16 ruby18 ruby19"
34 vapier 1.40 # RUBY_ECONF You can pass extra arguments to econf by defining this
35 usata 1.12 # variable. Note that you cannot specify them by command line
36     # if you are using <sys-apps/portage-2.0.49-r17.
37 usata 1.22 # PATCHES Space delimited list of patch files.
38 usata 1.12
39 usata 1.41 inherit eutils toolchain-funcs
40 agriffis 1.32
41 caleb 1.51 EXPORT_FUNCTIONS src_unpack src_compile src_install
42 agriffis 1.1
43     HOMEPAGE="http://raa.ruby-lang.org/list.rhtml?name=${PN}"
44     SRC_URI="mirror://gentoo/${P}.tar.gz"
45    
46     SLOT="0"
47     LICENSE="Ruby"
48    
49 flameeyes 1.54 # If you specify RUBY_OPTIONAL you also need to take care of ruby useflag and dependency.
50     if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
51 rbrown 1.65 DEPEND="${DEPEND} virtual/ruby"
52     RDEPEND="${RDEPEND} virtual/ruby"
53 flameeyes 1.54 fi
54 usata 1.22
55 usata 1.24 [[ -z "${RUBY}" ]] && export RUBY=/usr/bin/ruby
56 usata 1.6
57 pclouds 1.61 ruby_patch_mkmf() {
58 usata 1.17
59 pclouds 1.59 if [ ! -x /bin/install -a -x /usr/bin/install ]; then
60 pclouds 1.61 einfo "Patching mkmf"
61 pclouds 1.59 cat <<END >${T}/mkmf.rb
62     require 'mkmf'
63    
64 pclouds 1.61 STDERR.puts 'Modified mkmf is used'
65 pclouds 1.59 CONFIG['INSTALL'] = '/usr/bin/install'
66     END
67     # save it because rubygems needs it (for unsetting RUBYOPT)
68     export GENTOO_RUBYOPT="-r${T}/mkmf.rb"
69     export RUBYOPT="${RUBYOPT} ${GENTOO_RUBYOPT}"
70     fi
71    
72 pclouds 1.61 }
73    
74     ruby_src_unpack() {
75 pclouds 1.62 #ruby_patch_mkmf
76 usata 1.17 unpack ${A}
77 usata 1.34 cd ${S}
78 usata 1.17 # apply bulk patches
79 usata 1.19 if [[ -n "${PATCHES}" ]] ; then
80     for p in ${PATCHES} ; do
81     epatch $p
82     done
83     fi
84 usata 1.6 }
85    
86 usata 1.22 ruby_econf() {
87 agriffis 1.1
88 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
89 usata 1.10 if [ -f configure ] ; then
90     ./configure \
91     --prefix=/usr \
92     --host=${CHOST} \
93     --mandir=/usr/share/man \
94     --infodir=/usr/share/info \
95     --datadir=/usr/share \
96     --sysconfdir=/etc \
97     --localstatedir=/var/lib \
98     --with-ruby=${RUBY} \
99 vapier 1.40 ${RUBY_ECONF} \
100 usata 1.26 "$@" || die "econf failed"
101 usata 1.10 fi
102     if [ -f install.rb ] ; then
103 usata 1.26 ${RUBY} install.rb config --prefix=/usr "$@" \
104 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
105 usata 1.26 ${RUBY} install.rb setup "$@" \
106 vapier 1.40 ${RUBY_ECONF} || die "install.rb setup failed"
107 usata 1.10 fi
108 usata 1.21 if [ -f setup.rb ] ; then
109 usata 1.26 ${RUBY} setup.rb config --prefix=/usr "$@" \
110 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
111 usata 1.26 ${RUBY} setup.rb setup "$@" \
112 vapier 1.40 ${RUBY_ECONF} || die "setup.rb setup failed"
113 usata 1.21 fi
114 usata 1.10 if [ -f extconf.rb ] ; then
115 usata 1.36 ${RUBY} extconf.rb "$@" \
116 vapier 1.40 ${RUBY_ECONF} || die "extconf.rb failed"
117 usata 1.9 fi
118     }
119    
120 usata 1.22 ruby_emake() {
121 usata 1.9 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
122 flameeyes 1.53 make CC="$(tc-getCC)" CXX="$(tc-getCXX)" DLDFLAGS="${LDFLAGS}" ${MAKEOPTS} ${EXTRA_EMAKE} "$@" || die "emake for ruby failed"
123 usata 1.6 fi
124     }
125    
126 usata 1.9 ruby_src_compile() {
127 vapier 1.40 # You can pass configure options via RUBY_ECONF
128 usata 1.9 ruby_econf || die
129 usata 1.26 ruby_emake "$@" || die
130 usata 1.9 }
131    
132 flameeyes 1.55 doruby() {
133 vapier 1.64 ( # dont want to pollute calling env
134     insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
135     insopts -m 0644
136     doins "$@"
137     ) || die "failed to install $@"
138 flameeyes 1.55 }
139    
140 usata 1.22 ruby_einstall() {
141     local siteruby
142 agriffis 1.1
143 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
144 usata 1.4 if [ -f install.rb ] ; then
145 usata 1.26 ${RUBY} install.rb config --prefix=${D}/usr "$@" \
146 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
147 usata 1.26 ${RUBY} install.rb install "$@" \
148 vapier 1.40 ${RUBY_ECONF} || die "install.rb install failed"
149 usata 1.21 elif [ -f setup.rb ] ; then
150 usata 1.26 ${RUBY} setup.rb config --prefix=${D}/usr "$@" \
151 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
152 usata 1.26 ${RUBY} setup.rb install "$@" \
153 vapier 1.40 ${RUBY_ECONF} || die "setup.rb install failed"
154 usata 1.4 elif [ -f extconf.rb -o -f Makefile ] ; then
155 usata 1.26 make DESTDIR=${D} "$@" install || die "make install failed"
156 agriffis 1.1 else
157 usata 1.22 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
158 usata 1.5 insinto ${siteruby}
159 squinky86 1.31 doins *.rb || die "doins failed"
160 agriffis 1.1 fi
161 usata 1.6 }
162    
163 usata 1.7 erubydoc() {
164     local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
165 usata 1.9
166     einfo "running dodoc for ruby ;)"
167    
168 usata 1.7 insinto ${rdbase}
169     [ -n "${rdfiles}" ] && doins ${rdfiles}
170 usata 1.41 rmdir ${D}${rdbase} 2>/dev/null || true
171 usata 1.33 if [ -d doc -o -d docs ] ; then
172     dohtml -x html -r {doc,docs}/*
173     dohtml -r {doc,docs}/html/*
174 usata 1.7 else
175     dohtml -r *
176     fi
177 caleb 1.49
178 pclouds 1.67 if hasq examples ${IUSE} && use examples; then
179 rbrown 1.63 for dir in sample samples example examples; do
180 caleb 1.49 if [ -d ${dir} ] ; then
181     dodir /usr/share/doc/${PF}
182     cp -pPR ${dir} ${D}/usr/share/doc/${PF} || die "cp failed"
183     fi
184     done
185     fi
186    
187 caleb 1.52 # Pattern matching will mismatch for locales without case based
188     # character sorting (from bug #129526)
189     export LC_COLLATE=C
190     unset LC_ALL
191    
192 usata 1.7 for i in ChangeLog* [A-Z][A-Z]* ; do
193     [ -e $i ] && dodoc $i
194     done
195     }
196    
197 usata 1.6 ruby_src_install() {
198    
199 usata 1.26 ruby_einstall "$@" || die
200 agriffis 1.1
201 usata 1.7 erubydoc
202 agriffis 1.1 }
203 usata 1.22
204     # erubyconf, erubymake and erubyinstall are kept for compatibility
205     erubyconf() {
206 usata 1.26 ruby_econf "$@"
207 usata 1.22 }
208    
209     erubymake() {
210 usata 1.26 ruby_emake "$@"
211 usata 1.22 }
212    
213     erubyinstall() {
214 usata 1.26 ruby_einstall "$@"
215 usata 1.22 }
216    
217 graaff 1.68 # prepall adds SLOT support for ruby.eclass. SLOT support currently
218     # does not work for gems, so if a gem is installed we skip all the
219     # SLOT code to avoid possible errors, in particular the mv command
220     # that is part of the USE_RUBY="any" case.
221 usata 1.22 prepall() {
222    
223 graaff 1.68 if [ -z "${GEM_SRC}" ]; then
224 usata 1.22
225 graaff 1.68 [[ ! -x /usr/bin/ruby16 ]] && export USE_RUBY=${USE_RUBY/ruby16/}
226     [[ ! -x /usr/bin/ruby18 ]] && export USE_RUBY=${USE_RUBY/ruby18/}
227     [[ ! -x /usr/bin/ruby19 ]] && export USE_RUBY=${USE_RUBY/ruby19/}
228    
229     local ruby_slots=$(echo "${USE_RUBY}" | wc -w)
230    
231     if [ "$ruby_slots" -ge 2 ] || (use ppc-macos && [ "$ruby_slots" -ge 1 ])
232     then
233     einfo "Now we are building the package for ${USE_RUBY}"
234     for rb in ${USE_RUBY} ruby ; do
235     einfo "Using $rb"
236     export RUBY=/usr/bin/$rb
237     ruby() { /usr/bin/$rb "$@" ; }
238     mkdir -p ${S}
239     cd ${WORKDIR}
240     einfo "Unpacking for $rb"
241     src_unpack || die "src_unpack failed"
242     cd ${S}
243     find . -name '*.[ao]' -exec rm {} \;
244     einfo "Building for $rb"
245     src_compile || die "src_compile failed"
246     cd ${S}
247     einfo "Installing for $rb"
248     src_install || die "src_install failed"
249     done
250     elif [ "${USE_RUBY}" == "any" ] ; then
251     siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
252     # in case no directories found in siteruby
253     local shopts=$-
254     set -o noglob # so that bash doen't expand "*"
255    
256     for x in ${D}/${siteruby}/* ; do
257     mv $x ${D}/${siteruby}/..
258     done
259     if [ -d ${D}${siteruby} ] ; then
260     rmdir --ignore-fail-on-non-empty ${D}/${siteruby}
261     fi
262    
263     set +o noglob; set -$shopts # reset old shell opts
264 usata 1.22 fi
265     fi
266    
267 graaff 1.66 # Continue with the regular prepall, see bug 140697
268     (unset prepall; prepall)
269 usata 1.22 }
270    

  ViewVC Help
Powered by ViewVC 1.1.20