1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
9 inherit autotools eutils flag-o-matic multilib versionator
11 RUBYPL=$(get_version_component_range 4)
13 MY_P="${PN}-$(get_version_component_range 1-3)"
14 #MY_P="${PN}-$(get_version_component_range 1-3)-${RUBYPL:-0}"
17 SLOT=$(get_version_component_range 1-2)
18 MY_SUFFIX=$(delete_version_separator 1 ${SLOT})
21 if [[ -n ${PATCHSET} ]]; then
22 if [[ ${PVR} == ${PV} ]]; then
23 PATCHSET="${PV}-r0.${PATCHSET}"
25 PATCHSET="${PVR}.${PATCHSET}"
31 DESCRIPTION="An object-oriented scripting language"
32 HOMEPAGE="http://www.ruby-lang.org/"
33 SRC_URI="mirror://ruby/2.1/${MY_P}.tar.xz
34 https://dev.gentoo.org/~flameeyes/ruby-team/${PN}-patches-${PATCHSET}.tar.bz2"
36 LICENSE="|| ( Ruby-BSD BSD-2 )"
37 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd"
38 IUSE="berkdb debug doc examples gdbm ipv6 +rdoc rubytests socks5 ssl xemacs ncurses +readline"
41 berkdb? ( sys-libs/db:= )
42 gdbm? ( sys-libs/gdbm )
43 ssl? ( dev-libs/openssl:0 )
44 socks5? ( >=net-proxy/dante-1.1.13 )
45 ncurses? ( sys-libs/ncurses:5= )
46 readline? ( sys-libs/readline:0 )
50 >=app-eselect/eselect-ruby-20131227
52 !<dev-ruby/rubygems-1.8.10-r1"
56 virtual/rubygems[ruby_targets_ruby21]
57 >=dev-ruby/json-1.8.1[ruby_targets_ruby21]
58 >=dev-ruby/rake-0.9.6[ruby_targets_ruby21]
59 rdoc? ( >=dev-ruby/rdoc-4.0.1[ruby_targets_ruby21] )
60 xemacs? ( app-xemacs/ruby-modes )"
63 EPATCH_FORCE="yes" EPATCH_SUFFIX="patch" \
64 epatch "${WORKDIR}/patches"
66 # We can no longer unbundle all of rake because rubygems now depends
67 # on this. We leave the actual rake code around to bootstrap
68 # rubygems, but remove the bits that would cause a file collision.
69 einfo "Unbundling gems..."
72 {bin,lib}/rake lib/rake.rb man/rake.1 \
73 bin/gem || die "removal failed"
75 # Fix a hardcoded lib path in configure script
76 sed -i -e "s:\(RUBY_LIB_PREFIX=\"\${prefix}/\)lib:\1$(get_libdir):" \
77 configure.in || die "sed failed"
85 # The Tk module can no longer be built because the module code is no
86 # longer compatible with newer stable versions.
87 # https://bugs.gentoo.org/show_bug.cgi?id=500894
90 # -fomit-frame-pointer makes ruby segfault, see bug #150413.
91 filter-flags -fomit-frame-pointer
92 # In many places aliasing rules are broken; play it safe
93 # as it's risky with newer compilers to leave it as it is.
94 append-flags -fno-strict-aliasing
96 use sh && append-flags -mieee
98 # Socks support via dante
100 # Socks support can't be disabled as long as SOCKS_SERVER is
101 # set and socks library is present, so need to unset
102 # SOCKS_SERVER in that case.
106 # Increase GC_MALLOC_LIMIT if set (default is 8000000)
107 if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
108 append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
111 # ipv6 hack, bug 168939. Needs --enable-ipv6.
112 use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
114 # Determine which modules *not* to build depending in the USE flags.
115 if ! use readline ; then
116 modules="${modules},readline"
118 if ! use berkdb ; then
119 modules="${modules},dbm"
122 modules="${modules},gdbm"
125 modules="${modules},openssl"
127 if ! use ncurses ; then
128 modules="${modules},curses"
131 INSTALL="${EPREFIX}/usr/bin/install -c" econf \
132 --program-suffix=${MY_SUFFIX} \
133 --with-soname=ruby${MY_SUFFIX} \
134 --docdir=${EPREFIX}/usr/share/doc/${P} \
138 --with-out-ext="${modules}" \
139 $(use_enable socks5 socks) \
140 $(use_enable doc install-doc) \
142 $(use_enable debug) \
144 --enable-option-checking=no \
145 || die "econf failed"
149 emake V=1 EXTLDFLAGS="${LDFLAGS}" || die "emake failed"
153 emake -j1 V=1 test || die "make test failed"
155 elog "Ruby's make test has been run. Ruby also ships with a make check"
156 elog "that cannot be run until after ruby has been installed."
158 if use rubytests; then
159 elog "You have enabled rubytests, so they will be installed to"
160 elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
161 elog "than root, and you must place them into a writeable directory."
164 elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
166 elog "Enable the rubytests USE flag to install the make check tests"
171 # Remove the remaining bundled gems. We do this late in the process
172 # since they are used during the build to e.g. create the
174 rm -rf ext/json || die
176 # Ruby is involved in the install process, we don't want interference here.
179 local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
181 LD_LIBRARY_PATH="${D}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
182 RUBYLIB="${S}:${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
183 for d in $(find "${S}/ext" -type d) ; do
184 RUBYLIB="${RUBYLIB}:$d"
186 export LD_LIBRARY_PATH RUBYLIB
188 emake V=1 DESTDIR="${D}" install || die "make install failed"
190 # Remove installed rubygems copy
191 rm -r "${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
192 rm -r "${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
193 rm -r "${D}/usr/bin/"{ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
196 make DESTDIR="${D}" install-doc || die "make install-doc failed"
199 if use examples; then
200 insinto /usr/share/doc/${PF}
204 dodoc ChangeLog NEWS doc/NEWS* README* || die
206 if use rubytests; then
208 insinto /usr/share/${PN}-${SLOT}/test
215 if [[ ! -n $(readlink "${ROOT}"usr/bin/ruby) ]] ; then
216 eselect ruby set ruby${MY_SUFFIX}
220 elog "To switch between available Ruby profiles, execute as root:"
221 elog "\teselect ruby set ruby(19|20|...)"