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

Contents of /eclass/ruby.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.57 - (hide annotations) (download)
Mon Jan 15 16:22:22 2007 UTC (11 years, 6 months ago) by fuzzyray
Branch: MAIN
Changes since 1.56: +2 -2 lines
Fix typo in previous fix for bug #160339

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 fuzzyray 1.57 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby.eclass,v 1.56 2007/01/06 16:00:22 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 flameeyes 1.55 doruby() {
118     INSDESTTREE="$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')" \
119     INSOPTIONS="-m 0644" \
120     doins "$@" || die "failed to install $@"
121     }
122    
123 usata 1.22 ruby_einstall() {
124     local siteruby
125 agriffis 1.1
126 vapier 1.40 RUBY_ECONF="${RUBY_ECONF} ${EXTRA_ECONF}"
127 usata 1.4 if [ -f install.rb ] ; then
128 usata 1.26 ${RUBY} install.rb config --prefix=${D}/usr "$@" \
129 vapier 1.40 ${RUBY_ECONF} || die "install.rb config failed"
130 usata 1.26 ${RUBY} install.rb install "$@" \
131 vapier 1.40 ${RUBY_ECONF} || die "install.rb install failed"
132 usata 1.21 elif [ -f setup.rb ] ; then
133 usata 1.26 ${RUBY} setup.rb config --prefix=${D}/usr "$@" \
134 vapier 1.40 ${RUBY_ECONF} || die "setup.rb config failed"
135 usata 1.26 ${RUBY} setup.rb install "$@" \
136 vapier 1.40 ${RUBY_ECONF} || die "setup.rb install failed"
137 usata 1.4 elif [ -f extconf.rb -o -f Makefile ] ; then
138 usata 1.26 make DESTDIR=${D} "$@" install || die "make install failed"
139 agriffis 1.1 else
140 usata 1.22 siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitedir"]')
141 usata 1.5 insinto ${siteruby}
142 squinky86 1.31 doins *.rb || die "doins failed"
143 agriffis 1.1 fi
144 usata 1.6 }
145    
146 usata 1.7 erubydoc() {
147     local rdbase=/usr/share/doc/${PF}/rd rdfiles=$(find . -name '*.rd*')
148 usata 1.9
149     einfo "running dodoc for ruby ;)"
150    
151 usata 1.7 insinto ${rdbase}
152     [ -n "${rdfiles}" ] && doins ${rdfiles}
153 usata 1.41 rmdir ${D}${rdbase} 2>/dev/null || true
154 usata 1.33 if [ -d doc -o -d docs ] ; then
155     dohtml -x html -r {doc,docs}/*
156     dohtml -r {doc,docs}/html/*
157 usata 1.7 else
158     dohtml -r *
159     fi
160 caleb 1.49
161 swegener 1.50 if ( use examples ); then
162 caleb 1.49 for dir in sample example examples; do
163     if [ -d ${dir} ] ; then
164     dodir /usr/share/doc/${PF}
165     cp -pPR ${dir} ${D}/usr/share/doc/${PF} || die "cp failed"
166     fi
167     done
168     fi
169    
170 caleb 1.52 # Pattern matching will mismatch for locales without case based
171     # character sorting (from bug #129526)
172     export LC_COLLATE=C
173     unset LC_ALL
174    
175 usata 1.7 for i in ChangeLog* [A-Z][A-Z]* ; do
176     [ -e $i ] && dodoc $i
177     done
178     }
179    
180 usata 1.6 ruby_src_install() {
181    
182 usata 1.26 ruby_einstall "$@" || die
183 agriffis 1.1
184 usata 1.7 erubydoc
185 agriffis 1.1 }
186 usata 1.22
187     # erubyconf, erubymake and erubyinstall are kept for compatibility
188     erubyconf() {
189 usata 1.26 ruby_econf "$@"
190 usata 1.22 }
191    
192     erubymake() {
193 usata 1.26 ruby_emake "$@"
194 usata 1.22 }
195    
196     erubyinstall() {
197 usata 1.26 ruby_einstall "$@"
198 usata 1.22 }
199    
200     # prepall adds SLOT support for ruby.eclass
201     prepall() {
202    
203     [[ ! -x /usr/bin/ruby16 ]] && export USE_RUBY=${USE_RUBY/ruby16/}
204     [[ ! -x /usr/bin/ruby18 ]] && export USE_RUBY=${USE_RUBY/ruby18/}
205     [[ ! -x /usr/bin/ruby19 ]] && export USE_RUBY=${USE_RUBY/ruby19/}
206    
207 usata 1.37 local ruby_slots=$(echo "${USE_RUBY}" | wc -w)
208    
209 usata 1.43 if [ "$ruby_slots" -ge 2 ] || (use ppc-macos && [ "$ruby_slots" -ge 1 ])
210 agriffis 1.38 then
211 usata 1.22 einfo "Now we are building the package for ${USE_RUBY}"
212     for rb in ${USE_RUBY} ruby ; do
213     einfo "Using $rb"
214     export RUBY=/usr/bin/$rb
215 usata 1.25 ruby() { /usr/bin/$rb "$@" ; }
216 usata 1.22 mkdir -p ${S}
217     cd ${WORKDIR}
218     einfo "Unpacking for $rb"
219     src_unpack || die "src_unpack failed"
220     cd ${S}
221 usata 1.29 find . -name '*.[ao]' -exec rm {} \;
222 usata 1.22 einfo "Building for $rb"
223     src_compile || die "src_compile failed"
224     cd ${S}
225     einfo "Installing for $rb"
226     src_install || die "src_install failed"
227     done
228     elif [ "${USE_RUBY}" == "any" ] ; then
229     siteruby=$(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]')
230     # in case no directories found in siteruby
231 flameeyes 1.56 local shopts=$-
232     set -o noglob # so that bash doen't expand "*"
233 usata 1.22
234     for x in ${D}/${siteruby}/* ; do
235     mv $x ${D}/${siteruby}/..
236     done
237     if [ -d ${D}${siteruby} ] ; then
238     rmdir --ignore-fail-on-non-empty ${D}/${siteruby}
239     fi
240 flameeyes 1.56
241 fuzzyray 1.57 set +o noglob; set -$shopts # reset old shell opts
242 usata 1.22 fi
243    
244     prepallman
245     prepallinfo
246     prepallstrip
247     }
248    

  ViewVC Help
Powered by ViewVC 1.1.20