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

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.38 - (hide annotations) (download)
Fri Jul 22 09:41:17 2011 UTC (3 years ago) by graaff
Branch: MAIN
Changes since 1.37: +35 -10 lines
Provide ruby_implementations_depend() to facilitate ebuilds with RUBY_OPTIONAL=yes. Also use it internally to avoid duplication of code. Patch by Nathan Phillip Brink in bug 373139.

1 a3li 1.6 # Copyright 1999-2009 Gentoo Foundation
2 graaff 1.1 # Distributed under the terms of the GNU General Public License v2
3 graaff 1.38 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.37 2011/07/22 09:10:22 graaff Exp $
4 graaff 1.1 #
5     # @ECLASS: ruby-ng.eclass
6     # @MAINTAINER:
7     # Ruby herd <ruby@gentoo.org>
8     #
9     # Author: Diego E. Pettenò <flameeyes@gentoo.org>
10     #
11     # Author: Alex Legler <a3li@gentoo.org>
12     #
13     # Author: Hans de Graaff <graaff@gentoo.org>
14     #
15     # @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots.
16     # @DESCRIPTION:
17     # The Ruby eclass is designed to allow an easier installation of Ruby packages
18     # and their incorporation into the Gentoo Linux system.
19     #
20     # Currently available targets are:
21     # * ruby18 - Ruby (MRI) 1.8.x
22     # * ruby19 - Ruby (MRI) 1.9.x
23     # * ree18 - Ruby Enterprise Edition 1.8.x
24     # * jruby - JRuby
25     #
26     # This eclass does not define the implementation of the configure,
27     # compile, test, or install phases. Instead, the default phases are
28     # used. Specific implementations of these phases can be provided in
29     # the ebuild either to be run for each Ruby implementation, or for all
30     # Ruby implementations, as follows:
31     #
32     # * each_ruby_configure
33     # * all_ruby_configure
34    
35     # @ECLASS-VARIABLE: USE_RUBY
36 graaff 1.26 # @REQUIRED
37 graaff 1.1 # @DESCRIPTION:
38     # This variable contains a space separated list of targets (see above) a package
39     # is compatible to. It must be set before the `inherit' call. There is no
40     # default. All ebuilds are expected to set this variable.
41    
42     # @ECLASS-VARIABLE: RUBY_PATCHES
43 graaff 1.26 # @DEFAULT_UNSET
44 graaff 1.1 # @DESCRIPTION:
45     # A String or Array of filenames of patches to apply to all implementations.
46    
47     # @ECLASS-VARIABLE: RUBY_OPTIONAL
48     # @DESCRIPTION:
49 graaff 1.38 # Set the value to "yes" to make the dependency on a Ruby interpreter
50     # optional and then ruby_implementations_depend() to help populate
51     # DEPEND and RDEPEND.
52 graaff 1.1
53 graaff 1.31 # @ECLASS-VARIABLE: RUBY_S
54     # @DEFAULT_UNSET
55     # @DESCRIPTION:
56     # If defined this variable determines the source directory name after
57     # unpacking. This defaults to the name of the package. Note that this
58     # variable supports a wildcard mechanism to help with github tarballs
59     # that contain the commit hash as part of the directory name.
60    
61 graaff 1.34 # @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
62     # @DEFAULT_UNSET
63     # @DESCRIPTION:
64     # If defined this variable contains a whitelist of shared objects that
65     # are allowed to exist even if they don't link to libruby. This avoids
66     # the QA check that makes this mandatory. This is most likely not what
67     # you are looking for if you get the related "Missing links" QA warning,
68     # since the proper fix is almost always to make sure the shared object
69     # is linked against libruby. There are cases were this is not the case
70     # and the shared object is generic code to be used in some other way
71     # (e.g. selenium's firefox driver extension). When set this argument is
72     # passed to "grep -E" to remove reporting of these shared objects.
73    
74 graaff 1.1 inherit eutils toolchain-funcs
75    
76     EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
77    
78     case ${EAPI} in
79     0|1)
80     die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
81 flameeyes 1.24 2|3) ;;
82 graaff 1.31 4)
83     # S is no longer automatically assigned when it doesn't exist.
84     S="${WORKDIR}"
85     ;;
86 graaff 1.1 *)
87     die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
88     esac
89    
90     # @FUNCTION: ruby_implementation_depend
91     # @USAGE: target [comparator [version]]
92     # @RETURN: Package atom of a Ruby implementation to be used in dependencies.
93     # @DESCRIPTION:
94     # This function returns the formal package atom for a Ruby implementation.
95     #
96     # `target' has to be one of the valid values for USE_RUBY (see above)
97     #
98     # Set `comparator' and `version' to include a comparator (=, >=, etc.) and a
99     # version string to the returned string
100     ruby_implementation_depend() {
101     local rubypn=
102     local rubyslot=
103    
104     case $1 in
105     ruby18)
106     rubypn="dev-lang/ruby"
107     rubyslot=":1.8"
108     ;;
109     ruby19)
110     rubypn="dev-lang/ruby"
111     rubyslot=":1.9"
112     ;;
113     ree18)
114     rubypn="dev-lang/ruby-enterprise"
115     rubyslot=":1.8"
116     ;;
117     jruby)
118     rubypn="dev-java/jruby"
119     rubyslot=""
120     ;;
121     *) die "$1: unknown Ruby implementation"
122     esac
123    
124     echo "$2${rubypn}$3${rubyslot}"
125     }
126    
127     # @FUNCTION: ruby_samelib
128     # @RETURN: use flag string with current ruby implementations
129     # @DESCRIPTION:
130     # Convenience function to output the use dependency part of a
131     # dependency. Used as a building block for ruby_add_rdepend() and
132     # ruby_add_bdepend(), but may also be useful in an ebuild to specify
133     # more complex dependencies.
134     ruby_samelib() {
135     local res=
136     for _ruby_implementation in $USE_RUBY; do
137     has -${_ruby_implementation} $@ || \
138     res="${res}ruby_targets_${_ruby_implementation}?,"
139     done
140    
141     echo "[${res%,}]"
142     }
143    
144 flameeyes 1.17 _ruby_atoms_samelib_generic() {
145 flameeyes 1.18 eshopts_push -o noglob
146 flameeyes 1.17 echo "RUBYTARGET? ("
147 flameeyes 1.14 for token in $*; do
148     case "$token" in
149 flameeyes 1.16 "||" | "(" | ")" | *"?")
150 flameeyes 1.14 echo "${token}" ;;
151 flameeyes 1.21 *])
152     echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
153 flameeyes 1.14 *)
154 flameeyes 1.17 echo "${token}[RUBYTARGET]" ;;
155 flameeyes 1.14 esac
156     done
157 flameeyes 1.17 echo ")"
158 flameeyes 1.18 eshopts_pop
159 flameeyes 1.17 }
160    
161 flameeyes 1.27 # @FUNCTION: ruby_implementation_command
162     # @RETURN: the path to the given ruby implementation
163     # @DESCRIPTION:
164     # Not all implementations have the same command basename as the
165     # target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
166     # respectively. This function translate between the two
167     ruby_implementation_command() {
168     local _ruby_name=$1
169    
170     # Add all USE_RUBY values where the flag name diverts from the binary here
171     case $1 in
172     ree18)
173     _ruby_name=rubyee18
174     ;;
175     esac
176    
177     echo $(type -p ${_ruby_name} 2>/dev/null)
178     }
179    
180 flameeyes 1.17 _ruby_atoms_samelib() {
181     local atoms=$(_ruby_atoms_samelib_generic "$*")
182    
183     for _ruby_implementation in $USE_RUBY; do
184     echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
185     done
186 flameeyes 1.14 }
187    
188 flameeyes 1.16 _ruby_wrap_conditions() {
189     local conditions="$1"
190     local atoms="$2"
191    
192     for condition in $conditions; do
193     atoms="${condition}? ( ${atoms} )"
194     done
195    
196     echo "$atoms"
197     }
198    
199 graaff 1.1 # @FUNCTION: ruby_add_rdepend
200 flameeyes 1.16 # @USAGE: dependencies
201 graaff 1.1 # @DESCRIPTION:
202 flameeyes 1.16 # Adds the specified dependencies, with use condition(s) to RDEPEND,
203     # taking the current set of ruby targets into account. This makes sure
204     # that all ruby dependencies of the package are installed for the same
205     # ruby targets. Use this function for all ruby dependencies instead of
206     # setting RDEPEND yourself. The list of atoms uses the same syntax as
207     # normal dependencies.
208     #
209     # Note: runtime dependencies are also added as build-time test
210     # dependencies.
211 graaff 1.1 ruby_add_rdepend() {
212     case $# in
213 flameeyes 1.16 1) ;;
214 graaff 1.1 2)
215 flameeyes 1.16 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF"
216     ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")"
217     return
218 graaff 1.1 ;;
219     *)
220     die "bad number of arguments to $0"
221     ;;
222     esac
223    
224 flameeyes 1.16 local dependency=$(_ruby_atoms_samelib "$1")
225    
226     RDEPEND="${RDEPEND} $dependency"
227    
228     # Add the dependency as a test-dependency since we're going to
229     # execute the code during test phase.
230 flameeyes 1.20 DEPEND="${DEPEND} test? ( ${dependency} )"
231 ssuominen 1.33 has test "$IUSE" || IUSE="${IUSE} test"
232 graaff 1.1 }
233    
234     # @FUNCTION: ruby_add_bdepend
235 flameeyes 1.16 # @USAGE: dependencies
236 graaff 1.1 # @DESCRIPTION:
237 flameeyes 1.16 # Adds the specified dependencies, with use condition(s) to DEPEND,
238     # taking the current set of ruby targets into account. This makes sure
239     # that all ruby dependencies of the package are installed for the same
240     # ruby targets. Use this function for all ruby dependencies instead of
241     # setting DEPEND yourself. The list of atoms uses the same syntax as
242     # normal dependencies.
243 graaff 1.1 ruby_add_bdepend() {
244     case $# in
245 flameeyes 1.16 1) ;;
246 graaff 1.1 2)
247 flameeyes 1.16 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF"
248     ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")"
249     return
250 graaff 1.1 ;;
251     *)
252     die "bad number of arguments to $0"
253     ;;
254     esac
255    
256 flameeyes 1.16 local dependency=$(_ruby_atoms_samelib "$1")
257    
258     DEPEND="${DEPEND} $dependency"
259 flameeyes 1.19 RDEPEND="${RDEPEND}"
260 graaff 1.1 }
261    
262 graaff 1.37 # @FUNCTION: ruby_get_use_implementations
263     # @DESCRIPTION:
264     # Gets an array of ruby use targets enabled by the user
265     ruby_get_use_implementations() {
266     local i implementation
267     for implementation in ${USE_RUBY}; do
268     use ruby_targets_${implementation} && i+=" ${implementation}"
269     done
270     echo $i
271     }
272    
273 graaff 1.36 # @FUNCTION: ruby_get_use_targets
274     # @DESCRIPTION:
275     # Gets an array of ruby use targets that the ebuild sets
276     ruby_get_use_targets() {
277     local t implementation
278     for implementation in ${USE_RUBY}; do
279     t+=" ruby_targets_${implementation}"
280     done
281     echo $t
282     }
283    
284     if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
285     REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
286     fi
287    
288 graaff 1.38 # @FUNCTION: ruby_implementations_depend
289     # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
290     # @DESCRIPTION:
291     # Produces the dependency string for the various implementations of ruby
292     # which the package is being built against. This should not be used when
293     # RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
294     # confuse this function with ruby_implementation_depend().
295     #
296     # @EXAMPLE:
297     # EAPI=4
298     # RUBY_OPTIONAL=yes
299     #
300     # inherit ruby-ng
301     # ...
302     # DEPEND="ruby? ( $(ruby_implementations_depend) )"
303     # RDEPEND="${DEPEND}"
304     ruby_implementations_depend() {
305     local depend
306     for _ruby_implementation in ${USE_RUBY}; do
307     depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
308     done
309     echo "${depend}"
310     }
311    
312     for _ruby_implementation in ${USE_RUBY}; do
313 graaff 1.1 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
314     done
315 graaff 1.38 # If you specify RUBY_OPTIONAL you also need to take care of
316     # ruby useflag and dependency.
317     if [[ ${RUBY_OPTIONAL} != yes ]]; then
318     DEPEND="${DEPEND} $(ruby_implementations_depend)"
319     RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
320     fi
321 graaff 1.1
322     _ruby_invoke_environment() {
323     old_S=${S}
324 graaff 1.31 case ${EAPI} in
325     4)
326 graaff 1.32 if [ -z ${RUBY_S} ]; then
327     sub_S=${P}
328     else
329     sub_S=${RUBY_S}
330     fi
331 graaff 1.31 ;;
332     *)
333     sub_S=${S#${WORKDIR}/}
334     ;;
335     esac
336 flameeyes 1.12
337     # Special case, for the always-lovely GitHub fetches. With this,
338     # we allow the star glob to just expand to whatever directory it's
339     # called.
340 flameeyes 1.28 if [[ ${sub_S} = *"*"* ]]; then
341 graaff 1.35 case ${EAPI} in
342     2|3)
343     #The old method of setting S depends on undefined package
344     # manager behaviour, so encourage upgrading to EAPI=4.
345     eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
346     ;;
347     esac
348 flameeyes 1.12 pushd "${WORKDIR}"/all &>/dev/null
349 flameeyes 1.13 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
350 flameeyes 1.12 popd &>/dev/null
351     fi
352 graaff 1.1
353     environment=$1; shift
354    
355     my_WORKDIR="${WORKDIR}"/${environment}
356     S="${my_WORKDIR}"/"${sub_S}"
357    
358     if [[ -d "${S}" ]]; then
359     pushd "$S" &>/dev/null
360     elif [[ -d "${my_WORKDIR}" ]]; then
361     pushd "${my_WORKDIR}" &>/dev/null
362     else
363     pushd "${WORKDIR}" &>/dev/null
364     fi
365    
366     ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment"
367     "$@"
368     popd &>/dev/null
369    
370     S=${old_S}
371     }
372    
373     _ruby_each_implementation() {
374     local invoked=no
375     for _ruby_implementation in ${USE_RUBY}; do
376     # only proceed if it's requested
377     use ruby_targets_${_ruby_implementation} || continue
378    
379 flameeyes 1.27 RUBY=$(ruby_implementation_command ${_ruby_implementation})
380 graaff 1.1 invoked=yes
381    
382     if [[ -n "$1" ]]; then
383 flameeyes 1.27 _ruby_invoke_environment ${_ruby_implementation} "$@"
384 graaff 1.1 fi
385    
386     unset RUBY
387     done
388    
389     [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf."
390     }
391    
392     # @FUNCTION: ruby-ng_pkg_setup
393     # @DESCRIPTION:
394     # Check whether at least one ruby target implementation is present.
395     ruby-ng_pkg_setup() {
396     # This only checks that at least one implementation is present
397     # before doing anything; by leaving the parameters empty we know
398     # it's a special case.
399     _ruby_each_implementation
400     }
401    
402     # @FUNCTION: ruby-ng_src_unpack
403     # @DESCRIPTION:
404 graaff 1.5 # Unpack the source archive.
405 graaff 1.1 ruby-ng_src_unpack() {
406     mkdir "${WORKDIR}"/all
407     pushd "${WORKDIR}"/all &>/dev/null
408    
409     # We don't support an each-unpack, it's either all or nothing!
410     if type all_ruby_unpack &>/dev/null; then
411     _ruby_invoke_environment all all_ruby_unpack
412     else
413     [[ -n ${A} ]] && unpack ${A}
414     fi
415    
416     popd &>/dev/null
417     }
418    
419     _ruby_apply_patches() {
420     for patch in "${RUBY_PATCHES[@]}"; do
421     if [ -f "${patch}" ]; then
422     epatch "${patch}"
423     elif [ -f "${FILESDIR}/${patch}" ]; then
424     epatch "${FILESDIR}/${patch}"
425     else
426     die "Cannot find patch ${patch}"
427     fi
428     done
429    
430     # This is a special case: instead of executing just in the special
431     # "all" environment, this will actually copy the effects on _all_
432     # the other environments, and is thus executed before the copy
433     type all_ruby_prepare &>/dev/null && all_ruby_prepare
434     }
435    
436     _ruby_source_copy() {
437     # Until we actually find a reason not to, we use hardlinks, this
438     # should reduce the amount of disk space that is wasted by this.
439 fauli 1.30 cp -prl all ${_ruby_implementation} \
440 graaff 1.1 || die "Unable to copy ${_ruby_implementation} environment"
441     }
442    
443     # @FUNCTION: ruby-ng_src_prepare
444     # @DESCRIPTION:
445     # Apply patches and prepare versions for each ruby target
446     # implementation. Also carry out common clean up tasks.
447     ruby-ng_src_prepare() {
448     # Way too many Ruby packages are prepared on OSX without removing
449     # the extra data forks, we do it here to avoid repeating it for
450     # almost every other ebuild.
451     find . -name '._*' -delete
452    
453     _ruby_invoke_environment all _ruby_apply_patches
454    
455 flameeyes 1.7 _PHASE="source copy" \
456     _ruby_each_implementation _ruby_source_copy
457 graaff 1.1
458     if type each_ruby_prepare &>/dev/null; then
459     _ruby_each_implementation each_ruby_prepare
460     fi
461     }
462    
463     # @FUNCTION: ruby-ng_src_configure
464     # @DESCRIPTION:
465     # Configure the package.
466     ruby-ng_src_configure() {
467     if type each_ruby_configure &>/dev/null; then
468     _ruby_each_implementation each_ruby_configure
469     fi
470    
471     type all_ruby_configure &>/dev/null && \
472     _ruby_invoke_environment all all_ruby_configure
473     }
474    
475     # @FUNCTION: ruby-ng_src_compile
476     # @DESCRIPTION:
477     # Compile the package.
478     ruby-ng_src_compile() {
479     if type each_ruby_compile &>/dev/null; then
480     _ruby_each_implementation each_ruby_compile
481     fi
482    
483     type all_ruby_compile &>/dev/null && \
484     _ruby_invoke_environment all all_ruby_compile
485     }
486    
487     # @FUNCTION: ruby-ng_src_test
488     # @DESCRIPTION:
489     # Run tests for the package.
490     ruby-ng_src_test() {
491     if type each_ruby_test &>/dev/null; then
492     _ruby_each_implementation each_ruby_test
493     fi
494    
495     type all_ruby_test &>/dev/null && \
496     _ruby_invoke_environment all all_ruby_test
497     }
498    
499     _each_ruby_check_install() {
500 flameeyes 1.24 local scancmd=scanelf
501     # we have a Mach-O object here
502     [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
503    
504     has "${EAPI}" 2 && ! use prefix && EPREFIX=
505    
506 graaff 1.1 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]')
507 flameeyes 1.25 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
508 flameeyes 1.2 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')
509     local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')
510    
511     # Look for wrong files in sitedir
512 flameeyes 1.22 # if [[ -d "${D}${sitedir}" ]]; then
513     # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
514     # if [[ -n ${f} ]]; then
515     # eerror "Found files in sitedir, outsite sitelibdir:"
516     # eerror "${f}"
517     # die "Misplaced files in sitedir"
518     # fi
519     # fi
520 graaff 1.1
521     # The current implementation lacks libruby (i.e.: jruby)
522     [[ -z ${libruby_soname} ]] && return 0
523    
524 flameeyes 1.23 # Check also the gems directory, since we could be installing compiled
525     # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
526     # that's what changes between two implementations (otherwise you'd get false
527     # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
528 flameeyes 1.24 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
529 graaff 1.1 | fgrep -v "${libruby_soname}" \
530 graaff 1.34 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
531 graaff 1.1 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
532    
533     if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
534 flameeyes 1.15 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
535 graaff 1.1 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
536 flameeyes 1.15 die "Missing links to ${libruby_soname}"
537 graaff 1.1 fi
538     }
539    
540     # @FUNCTION: ruby-ng_src_install
541     # @DESCRIPTION:
542     # Install the package for each ruby target implementation.
543     ruby-ng_src_install() {
544     if type each_ruby_install &>/dev/null; then
545     _ruby_each_implementation each_ruby_install
546     fi
547    
548     type all_ruby_install &>/dev/null && \
549     _ruby_invoke_environment all all_ruby_install
550    
551     _PHASE="check install" \
552     _ruby_each_implementation _each_ruby_check_install
553     }
554    
555 a3li 1.11 # @FUNCTION: ruby_rbconfig_value
556     # @USAGE: rbconfig item
557     # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
558     ruby_rbconfig_value() {
559     echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']")
560     }
561    
562 graaff 1.1 # @FUNCTION: doruby
563     # @USAGE: file [file...]
564     # @DESCRIPTION:
565     # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
566     doruby() {
567 flameeyes 1.4 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
568 flameeyes 1.24 has "${EAPI}" 2 && ! use prefix && EPREFIX=
569 graaff 1.1 ( # don't want to pollute calling env
570 flameeyes 1.24 sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
571     insinto ${sitelibdir#${EPREFIX}}
572 graaff 1.1 insopts -m 0644
573     doins "$@"
574     ) || die "failed to install $@"
575     }
576    
577     # @FUNCTION: ruby_get_libruby
578     # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
579     ruby_get_libruby() {
580     ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])'
581     }
582    
583     # @FUNCTION: ruby_get_hdrdir
584     # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
585     ruby_get_hdrdir() {
586 a3li 1.11 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
587 graaff 1.1
588     if [[ "${rubyhdrdir}" = "nil" ]] ; then
589 a3li 1.11 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
590 graaff 1.1 fi
591    
592     echo "${rubyhdrdir}"
593     }
594 a3li 1.10
595     # @FUNCTION: ruby_get_version
596     # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
597     ruby_get_version() {
598     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
599    
600     echo $(${ruby} -e 'puts RUBY_VERSION')
601     }
602    
603     # @FUNCTION: ruby_get_implementation
604     # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
605     ruby_get_implementation() {
606     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
607    
608     case $(${ruby} --version) in
609     *Enterprise*)
610     echo "ree"
611     ;;
612     *jruby*)
613     echo "jruby"
614     ;;
615     *)
616     echo "mri"
617     ;;
618     esac
619     }

  ViewVC Help
Powered by ViewVC 1.1.20