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

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.39 - (hide annotations) (download)
Mon Aug 22 04:46:32 2011 UTC (3 years ago) by vapier
Branch: MAIN
Changes since 1.38: +4 -7 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

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

  ViewVC Help
Powered by ViewVC 1.1.20