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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.61 - (hide annotations) (download)
Mon Jan 29 12:15:50 2007 UTC (11 years, 7 months ago) by pclouds
Branch: MAIN
Changes since 1.60: +8 -3 lines
Separating mkmf patching code and reuse it in gems.eclass

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 pclouds 1.61 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.60 2007/01/26 16:03:48 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     DEPEND="virtual/ruby"
52     fi
53 usata 1.22
54 usata 1.24 [[ -z "${RUBY}" ]] && export RUBY=/usr/bin/ruby
55 usata 1.6
56 pclouds 1.61 ruby_patch_mkmf() {
57 usata 1.17
58 pclouds 1.59 if [ ! -x /bin/install -a -x /usr/bin/install ]; then
59 pclouds 1.61 einfo "Patching mkmf"
60 pclouds 1.59 cat <<END >${T}/mkmf.rb
61     require 'mkmf'
62    
63 pclouds 1.61 STDERR.puts 'Modified mkmf is used'
64 pclouds 1.59 CONFIG['INSTALL'] = '/usr/bin/install'
65     END
66     # save it because rubygems needs it (for unsetting RUBYOPT)
67     export GENTOO_RUBYOPT="-r${T}/mkmf.rb"
68     export RUBYOPT="${RUBYOPT} ${GENTOO_RUBYOPT}"
69     fi
70    
71 pclouds 1.61 }
72    
73     ruby_src_unpack() {
74     ruby_patch_mkmf
75 usata 1.17 unpack ${A}
76 usata 1.34 cd ${S}
77 usata 1.17 # apply bulk patches
78 usata 1.19 if [[ -n "${PATCHES}" ]] ; then
79     for p in ${PATCHES} ; do
80     epatch $p
81     done
82     fi
83 usata 1.6 }
84    
85 usata 1.22 ruby_econf() {
86 agriffis 1.1
87 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
88 usata 1.10 if [ -f configure ] ; then
89     ./configure \
90     --prefix=/usr \
91     --host=${CHOST} \
92     --mandir=/usr/share/man \
93     --infodir=/usr/share/info \
94     --datadir=/usr/share \
95     --sysconfdir=/etc \
96     --localstatedir=/var/lib \
97     --with-ruby=${RUBY} \
98 vapier 1.40 ${RUBY_ECONF} \
99 usata 1.26 "$@" || die "econf failed"
100 usata 1.10 fi
101     if [ -f install.rb ] ; then
102 usata 1.26 ${RUBY} install.rb config --prefix=/usr "$@" \
103 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
104 usata 1.26 ${RUBY} install.rb setup "$@" \
105 vapier 1.40 ${RUBY_ECONF} || die "install.rb setup failed"
106 usata 1.10 fi
107 usata 1.21 if [ -f setup.rb ] ; then
108 usata 1.26 ${RUBY} setup.rb config --prefix=/usr "$@" \
109 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
110 usata 1.26 ${RUBY} setup.rb setup "$@" \
111 vapier 1.40 ${RUBY_ECONF} || die "setup.rb setup failed"
112 usata 1.21 fi
113 usata 1.10 if [ -f extconf.rb ] ; then
114 usata 1.36 ${RUBY} extconf.rb "$@" \
115 vapier 1.40 ${RUBY_ECONF} || die "extconf.rb failed"
116 usata 1.9 fi
117     }
118    
119 usata 1.22 ruby_emake() {
120 usata 1.9 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
121 flameeyes 1.53 make CC="$(tc-getCC)" CXX="$(tc-getCXX)" DLDFLAGS="${LDFLAGS}" ${MAKEOPTS} ${EXTRA_EMAKE} "$@" || die "emake for ruby failed"
122 usata 1.6 fi
123     }
124    
125 usata 1.9 ruby_src_compile() {
126    
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     INSDESTTREE="$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')" \
134     INSOPTIONS="-m 0644" \
135     doins "$@" || die "failed to install $@"
136     }
137    
138 usata 1.22 ruby_einstall() {
139     local siteruby
140 agriffis 1.1
141 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
142 usata 1.4 if [ -f install.rb ] ; then
143 usata 1.26 ${RUBY} install.rb config --prefix=${D}/usr "$@" \
144 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
145 usata 1.26 ${RUBY} install.rb install "$@" \
146 vapier 1.40 ${RUBY_ECONF} || die "install.rb install failed"
147 usata 1.21 elif [ -f setup.rb ] ; then
148 usata 1.26 ${RUBY} setup.rb config --prefix=${D}/usr "$@" \
149 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
150 usata 1.26 ${RUBY} setup.rb install "$@" \
151 vapier 1.40 ${RUBY_ECONF} || die "setup.rb install failed"
152 usata 1.4 elif [ -f extconf.rb -o -f Makefile ] ; then
153 usata 1.26 make DESTDIR=${D} "$@" install || die "make install failed"
154 agriffis 1.1 else
155 usata 1.22 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
156 usata 1.5 insinto ${siteruby}
157 squinky86 1.31 doins *.rb || die "doins failed"
158 agriffis 1.1 fi
159 usata 1.6 }
160    
161 usata 1.7 erubydoc() {
162     local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
163 usata 1.9
164     einfo "running dodoc for ruby ;)"
165    
166 usata 1.7 insinto ${rdbase}
167     [ -n "${rdfiles}" ] && doins ${rdfiles}
168 usata 1.41 rmdir ${D}${rdbase} 2>/dev/null || true
169 usata 1.33 if [ -d doc -o -d docs ] ; then
170     dohtml -x html -r {doc,docs}/*
171     dohtml -r {doc,docs}/html/*
172 usata 1.7 else
173     dohtml -r *
174     fi
175 caleb 1.49
176 swegener 1.50 if ( use examples ); then
177 caleb 1.49 for dir in sample example examples; do
178     if [ -d ${dir} ] ; then
179     dodir /usr/share/doc/${PF}
180     cp -pPR ${dir} ${D}/usr/share/doc/${PF} || die "cp failed"
181     fi
182     done
183     fi
184    
185 caleb 1.52 # Pattern matching will mismatch for locales without case based
186     # character sorting (from bug #129526)
187     export LC_COLLATE=C
188     unset LC_ALL
189    
190 usata 1.7 for i in ChangeLog* [A-Z][A-Z]* ; do
191     [ -e $i ] && dodoc $i
192     done
193     }
194    
195 usata 1.6 ruby_src_install() {
196    
197 usata 1.26 ruby_einstall "$@" || die
198 agriffis 1.1
199 usata 1.7 erubydoc
200 agriffis 1.1 }
201 usata 1.22
202     # erubyconf, erubymake and erubyinstall are kept for compatibility
203     erubyconf() {
204 usata 1.26 ruby_econf "$@"
205 usata 1.22 }
206    
207     erubymake() {
208 usata 1.26 ruby_emake "$@"
209 usata 1.22 }
210    
211     erubyinstall() {
212 usata 1.26 ruby_einstall "$@"
213 usata 1.22 }
214    
215     # prepall adds SLOT support for ruby.eclass
216     prepall() {
217    
218     [[ ! -x /usr/bin/ruby16 ]] && export USE_RUBY=${USE_RUBY/ruby16/}
219     [[ ! -x /usr/bin/ruby18 ]] && export USE_RUBY=${USE_RUBY/ruby18/}
220     [[ ! -x /usr/bin/ruby19 ]] && export USE_RUBY=${USE_RUBY/ruby19/}
221    
222 usata 1.37 local ruby_slots=$(echo "${USE_RUBY}" | wc -w)
223    
224 usata 1.43 if [ "$ruby_slots" -ge 2 ] || (use ppc-macos && [ "$ruby_slots" -ge 1 ])
225 agriffis 1.38 then
226 usata 1.22 einfo "Now we are building the package for ${USE_RUBY}"
227     for rb in ${USE_RUBY} ruby ; do
228     einfo "Using $rb"
229     export RUBY=/usr/bin/$rb
230 usata 1.25 ruby() { /usr/bin/$rb "$@" ; }
231 usata 1.22 mkdir -p ${S}
232     cd ${WORKDIR}
233     einfo "Unpacking for $rb"
234     src_unpack || die "src_unpack failed"
235     cd ${S}
236 usata 1.29 find . -name '*.[ao]' -exec rm {} \;
237 usata 1.22 einfo "Building for $rb"
238     src_compile || die "src_compile failed"
239     cd ${S}
240     einfo "Installing for $rb"
241     src_install || die "src_install failed"
242     done
243     elif [ "${USE_RUBY}" == "any" ] ; then
244     siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
245     # in case no directories found in siteruby
246 flameeyes 1.56 local shopts=$-
247     set -o noglob # so that bash doen't expand "*"
248 usata 1.22
249     for x in ${D}/${siteruby}/* ; do
250     mv $x ${D}/${siteruby}/..
251     done
252     if [ -d ${D}${siteruby} ] ; then
253     rmdir --ignore-fail-on-non-empty ${D}/${siteruby}
254     fi
255 flameeyes 1.56
256 fuzzyray 1.57 set +o noglob; set -$shopts # reset old shell opts
257 usata 1.22 fi
258    
259     prepallman
260     prepallinfo
261     prepallstrip
262     }
263    

  ViewVC Help
Powered by ViewVC 1.1.20