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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.54 - (hide annotations) (download)
Fri Jul 7 14:09:47 2006 UTC (12 years, 5 months ago) by flameeyes
Branch: MAIN
Changes since 1.53: +5 -2 lines
Add support to make ruby optional when inheriting the 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 flameeyes 1.54 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.53 2006/05/28 21:39:02 flameeyes 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 caleb 1.49 IUSE="examples"
47 usata 1.30
48 agriffis 1.1 SLOT="0"
49     LICENSE="Ruby"
50    
51 flameeyes 1.54 # If you specify RUBY_OPTIONAL you also need to take care of ruby useflag and dependency.
52     if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
53     DEPEND="virtual/ruby"
54     fi
55 usata 1.22
56 usata 1.24 [[ -z "${RUBY}" ]] && export RUBY=/usr/bin/ruby
57 usata 1.6
58     ruby_src_unpack() {
59 usata 1.17
60     unpack ${A}
61 usata 1.34 cd ${S}
62 usata 1.17 # apply bulk patches
63 usata 1.19 if [[ -n "${PATCHES}" ]] ; then
64     for p in ${PATCHES} ; do
65     epatch $p
66     done
67     fi
68 usata 1.6 }
69    
70 usata 1.22 ruby_econf() {
71 agriffis 1.1
72 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
73 usata 1.10 if [ -f configure ] ; then
74     ./configure \
75     --prefix=/usr \
76     --host=${CHOST} \
77     --mandir=/usr/share/man \
78     --infodir=/usr/share/info \
79     --datadir=/usr/share \
80     --sysconfdir=/etc \
81     --localstatedir=/var/lib \
82     --with-ruby=${RUBY} \
83 vapier 1.40 ${RUBY_ECONF} \
84 usata 1.26 "$@" || die "econf failed"
85 usata 1.10 fi
86     if [ -f install.rb ] ; then
87 usata 1.26 ${RUBY} install.rb config --prefix=/usr "$@" \
88 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
89 usata 1.26 ${RUBY} install.rb setup "$@" \
90 vapier 1.40 ${RUBY_ECONF} || die "install.rb setup failed"
91 usata 1.10 fi
92 usata 1.21 if [ -f setup.rb ] ; then
93 usata 1.26 ${RUBY} setup.rb config --prefix=/usr "$@" \
94 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
95 usata 1.26 ${RUBY} setup.rb setup "$@" \
96 vapier 1.40 ${RUBY_ECONF} || die "setup.rb setup failed"
97 usata 1.21 fi
98 usata 1.10 if [ -f extconf.rb ] ; then
99 usata 1.36 ${RUBY} extconf.rb "$@" \
100 vapier 1.40 ${RUBY_ECONF} || die "extconf.rb failed"
101 usata 1.9 fi
102     }
103    
104 usata 1.22 ruby_emake() {
105 usata 1.9 if [ -f makefiles -o -f GNUmakefile -o -f makefile -o -f Makefile ] ; then
106 flameeyes 1.53 make CC="$(tc-getCC)" CXX="$(tc-getCXX)" DLDFLAGS="${LDFLAGS}" ${MAKEOPTS} ${EXTRA_EMAKE} "$@" || die "emake for ruby failed"
107 usata 1.6 fi
108     }
109    
110 usata 1.9 ruby_src_compile() {
111    
112 vapier 1.40 # You can pass configure options via RUBY_ECONF
113 usata 1.9 ruby_econf || die
114 usata 1.26 ruby_emake "$@" || die
115 usata 1.9 }
116    
117 usata 1.22 ruby_einstall() {
118     local siteruby
119 agriffis 1.1
120 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
121 usata 1.4 if [ -f install.rb ] ; then
122 usata 1.26 ${RUBY} install.rb config --prefix=${D}/usr "$@" \
123 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
124 usata 1.26 ${RUBY} install.rb install "$@" \
125 vapier 1.40 ${RUBY_ECONF} || die "install.rb install failed"
126 usata 1.21 elif [ -f setup.rb ] ; then
127 usata 1.26 ${RUBY} setup.rb config --prefix=${D}/usr "$@" \
128 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
129 usata 1.26 ${RUBY} setup.rb install "$@" \
130 vapier 1.40 ${RUBY_ECONF} || die "setup.rb install failed"
131 usata 1.4 elif [ -f extconf.rb -o -f Makefile ] ; then
132 usata 1.26 make DESTDIR=${D} "$@" install || die "make install failed"
133 agriffis 1.1 else
134 usata 1.22 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
135 usata 1.5 insinto ${siteruby}
136 squinky86 1.31 doins *.rb || die "doins failed"
137 agriffis 1.1 fi
138 usata 1.6 }
139    
140 usata 1.7 erubydoc() {
141     local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
142 usata 1.9
143     einfo "running dodoc for ruby ;)"
144    
145 usata 1.7 insinto ${rdbase}
146     [ -n "${rdfiles}" ] && doins ${rdfiles}
147 usata 1.41 rmdir ${D}${rdbase} 2>/dev/null || true
148 usata 1.33 if [ -d doc -o -d docs ] ; then
149     dohtml -x html -r {doc,docs}/*
150     dohtml -r {doc,docs}/html/*
151 usata 1.7 else
152     dohtml -r *
153     fi
154 caleb 1.49
155 swegener 1.50 if ( use examples ); then
156 caleb 1.49 for dir in sample example examples; do
157     if [ -d ${dir} ] ; then
158     dodir /usr/share/doc/${PF}
159     cp -pPR ${dir} ${D}/usr/share/doc/${PF} || die "cp failed"
160     fi
161     done
162     fi
163    
164 caleb 1.52 # Pattern matching will mismatch for locales without case based
165     # character sorting (from bug #129526)
166     export LC_COLLATE=C
167     unset LC_ALL
168    
169 usata 1.7 for i in ChangeLog* [A-Z][A-Z]* ; do
170     [ -e $i ] && dodoc $i
171     done
172     }
173    
174 usata 1.6 ruby_src_install() {
175    
176 usata 1.26 ruby_einstall "$@" || die
177 agriffis 1.1
178 usata 1.7 erubydoc
179 agriffis 1.1 }
180 usata 1.22
181     # erubyconf, erubymake and erubyinstall are kept for compatibility
182     erubyconf() {
183 usata 1.26 ruby_econf "$@"
184 usata 1.22 }
185    
186     erubymake() {
187 usata 1.26 ruby_emake "$@"
188 usata 1.22 }
189    
190     erubyinstall() {
191 usata 1.26 ruby_einstall "$@"
192 usata 1.22 }
193    
194     # prepall adds SLOT support for ruby.eclass
195     prepall() {
196    
197     [[ ! -x /usr/bin/ruby16 ]] && export USE_RUBY=${USE_RUBY/ruby16/}
198     [[ ! -x /usr/bin/ruby18 ]] && export USE_RUBY=${USE_RUBY/ruby18/}
199     [[ ! -x /usr/bin/ruby19 ]] && export USE_RUBY=${USE_RUBY/ruby19/}
200    
201 usata 1.37 local ruby_slots=$(echo "${USE_RUBY}" | wc -w)
202    
203 usata 1.43 if [ "$ruby_slots" -ge 2 ] || (use ppc-macos && [ "$ruby_slots" -ge 1 ])
204 agriffis 1.38 then
205 usata 1.22 einfo "Now we are building the package for ${USE_RUBY}"
206     for rb in ${USE_RUBY} ruby ; do
207     einfo "Using $rb"
208     export RUBY=/usr/bin/$rb
209 usata 1.25 ruby() { /usr/bin/$rb "$@" ; }
210 usata 1.22 mkdir -p ${S}
211     cd ${WORKDIR}
212     einfo "Unpacking for $rb"
213     src_unpack || die "src_unpack failed"
214     cd ${S}
215 usata 1.29 find . -name '*.[ao]' -exec rm {} \;
216 usata 1.22 einfo "Building for $rb"
217     src_compile || die "src_compile failed"
218     cd ${S}
219     einfo "Installing for $rb"
220     src_install || die "src_install failed"
221     done
222     elif [ "${USE_RUBY}" == "any" ] ; then
223     siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
224     # in case no directories found in siteruby
225     shopt -sq nullglob
226    
227     for x in ${D}/${siteruby}/* ; do
228     mv $x ${D}/${siteruby}/..
229     done
230     if [ -d ${D}${siteruby} ] ; then
231     rmdir --ignore-fail-on-non-empty ${D}/${siteruby}
232     fi
233     fi
234    
235     prepallman
236     prepallinfo
237     prepallstrip
238     }
239    

  ViewVC Help
Powered by ViewVC 1.1.20