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)-${RUBYPL:-0}"
16 SLOT=$(get_version_component_range 1-2)
17 MY_SUFFIX=$(delete_version_separator 1 ${SLOT})
18 # 1.9.3 still uses 1.9.1
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/1.9/${MY_P}.tar.bz2
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 +yaml" #libedit
40 # libedit support is removed everywhere because of this upstream bug:
41 # http://redmine.ruby-lang.org/issues/show/3698
44 berkdb? ( sys-libs/db )
45 gdbm? ( sys-libs/gdbm )
46 ssl? ( dev-libs/openssl:0 )
47 socks5? ( >=net-proxy/dante-1.1.13 )
48 ncurses? ( sys-libs/ncurses )
49 readline? ( sys-libs/readline )
50 yaml? ( dev-libs/libyaml )
53 >=app-eselect/eselect-ruby-20100402
55 !<dev-ruby/rubygems-1.8.10-r1"
56 # libedit? ( dev-libs/libedit )
57 # !libedit? ( readline? ( sys-libs/readline ) )
61 virtual/rubygems[ruby_targets_ruby19]
62 rdoc? ( >=dev-ruby/rdoc-3.9.4[ruby_targets_ruby19] )
63 xemacs? ( app-xemacs/ruby-modes )"
66 EPATCH_FORCE="yes" EPATCH_SUFFIX="patch" \
67 epatch "${WORKDIR}/patches"
69 einfo "Unbundling gems..."
72 {bin,lib}/rake lib/rake.rb man/rake.1 \
74 bin/gem || die "removal failed"
76 # Fix a hardcoded lib path in configure script
77 sed -i -e "s:\(RUBY_LIB_PREFIX=\"\${prefix}/\)lib:\1$(get_libdir):" \
78 configure.in || die "sed failed"
86 # -fomit-frame-pointer makes ruby segfault, see bug #150413.
87 filter-flags -fomit-frame-pointer
88 # In many places aliasing rules are broken; play it safe
89 # as it's risky with newer compilers to leave it as it is.
90 append-flags -fno-strict-aliasing
92 use sh && append-flags -mieee
94 # Socks support via dante
96 # Socks support can't be disabled as long as SOCKS_SERVER is
97 # set and socks library is present, so need to unset
98 # SOCKS_SERVER in that case.
102 # Increase GC_MALLOC_LIMIT if set (default is 8000000)
103 if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
104 append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
107 # ipv6 hack, bug 168939. Needs --enable-ipv6.
108 use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
110 # if use libedit; then
111 # einfo "Using libedit to provide readline extension"
112 # myconf="${myconf} --enable-libedit --with-readline"
113 # elif use readline; then
114 # einfo "Using readline to provide readline extension"
115 # myconf="${myconf} --with-readline"
117 # myconf="${myconf} --without-readline"
119 myconf="${myconf} $(use_with readline)"
121 # Always disable tk because the module is no longer compatible with
122 # stable tcl/tk: https://bugs.gentoo.org/show_bug.cgi?id=500894
123 INSTALL="${EPREFIX}/usr/bin/install -c" econf \
124 --program-suffix=${MY_SUFFIX} \
125 --with-soname=ruby${MY_SUFFIX} \
129 $(use_enable socks5 socks) \
130 $(use_enable doc install-doc) \
132 $(use_enable debug) \
133 $(use_with berkdb dbm) \
135 $(use_with ssl openssl) \
136 $(use_with ncurses curses) \
137 $(use_with yaml psych) \
139 --enable-option-checking=no \
140 || die "econf failed"
144 emake V=1 EXTLDFLAGS="${LDFLAGS}" || die "emake failed"
148 emake -j1 V=1 test || die "make test failed"
150 elog "Ruby's make test has been run. Ruby also ships with a make check"
151 elog "that cannot be run until after ruby has been installed."
153 if use rubytests; then
154 elog "You have enabled rubytests, so they will be installed to"
155 elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
156 elog "than root, and you must place them into a writeable directory."
159 elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
161 elog "Enable the rubytests USE flag to install the make check tests"
166 # Ruby is involved in the install process, we don't want interference here.
169 local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
171 LD_LIBRARY_PATH="${D}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
172 RUBYLIB="${S}:${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
173 for d in $(find "${S}/ext" -type d) ; do
174 RUBYLIB="${RUBYLIB}:$d"
176 export LD_LIBRARY_PATH RUBYLIB
178 emake V=1 DESTDIR="${D}" install || die "make install failed"
180 # Remove installed rubygems copy
181 rm -r "${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
182 rm -r "${D}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
183 rm -r "${D}/usr/bin/"{ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
186 make DESTDIR="${D}" install-doc || die "make install-doc failed"
189 if use examples; then
190 insinto /usr/share/doc/${PF}
194 dodoc ChangeLog NEWS doc/NEWS* README* ToDo || die
196 if use rubytests; then
198 insinto /usr/share/${PN}-${SLOT}/test
205 if [[ ! -n $(readlink "${ROOT}"usr/bin/ruby) ]] ; then
206 eselect ruby set ruby${MY_SUFFIX}
210 elog "To switch between available Ruby profiles, execute as root:"
211 elog "\teselect ruby set ruby(19|20|...)"