1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools flag-o-matic multilib
8 MY_P="${PN}-$(ver_cut 1-3)"
12 MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
15 DESCRIPTION="An object-oriented scripting language"
16 HOMEPAGE="https://www.ruby-lang.org/"
17 SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
19 LICENSE="|| ( Ruby-BSD BSD-2 )"
20 KEYWORDS="~alpha amd64 arm arm64 hppa ~mips ppc ppc64 s390 sparc x86"
21 IUSE="berkdb debug doc examples gdbm ipv6 jemalloc libressl +rdoc rubytests socks5 +ssl static-libs tk xemacs"
24 berkdb? ( sys-libs/db:= )
25 gdbm? ( sys-libs/gdbm:= )
26 jemalloc? ( dev-libs/jemalloc )
28 !libressl? ( dev-libs/openssl:0= )
29 libressl? ( dev-libs/libressl )
31 socks5? ( >=net-proxy/dante-1.1.13 )
33 dev-lang/tcl:0=[threads]
34 dev-lang/tk:0=[threads]
40 >=app-eselect/eselect-ruby-20161226
42 !<dev-ruby/rubygems-1.8.10-r1"
47 >=dev-ruby/did_you_mean-1.1.0:2.4[ruby_targets_ruby24]
48 >=dev-ruby/minitest-5.10.1[ruby_targets_ruby24]
49 >=dev-ruby/net-telnet-0.1.1[ruby_targets_ruby24]
50 >=dev-ruby/power_assert-0.4.1[ruby_targets_ruby24]
51 >=dev-ruby/rake-12.0.0[ruby_targets_ruby24]
52 >=dev-ruby/test-unit-3.2.3[ruby_targets_ruby24]
53 >=dev-ruby/xmlrpc-0.2.1[ruby_targets_ruby24]
58 virtual/rubygems[ruby_targets_ruby24]
59 >=dev-ruby/json-2.0.2[ruby_targets_ruby24]
60 rdoc? ( >=dev-ruby/rdoc-5.1.0-r1[ruby_targets_ruby24] )
61 xemacs? ( app-xemacs/ruby-modes )"
64 eapply "${FILESDIR}"/${SLOT}/{002,005,009,012}*.patch
66 einfo "Unbundling gems..."
68 # Remove bundled gems that we will install via PDEPEND, bug
69 # 539700. Use explicit version numbers to ensure rm fails when they
70 # change so we can update dependencies accordingly.
71 rm -f gems/{did_you_mean-1.1.0,minitest-5.10.1,net-telnet-0.1.1,power_assert-0.4.1,rake-12.0.0,test-unit-3.2.3,xmlrpc-0.2.1}.gem || die
73 einfo "Removing bundled libraries..."
74 rm -fr ext/fiddle/libffi-3.2.1 || die
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 local modules= myconf=
88 # -fomit-frame-pointer makes ruby segfault, see bug #150413.
89 filter-flags -fomit-frame-pointer
90 # In many places aliasing rules are broken; play it safe
91 # as it's risky with newer compilers to leave it as it is.
92 append-flags -fno-strict-aliasing
94 use sh && append-flags -mieee
96 # Socks support via dante
98 # Socks support can't be disabled as long as SOCKS_SERVER is
99 # set and socks library is present, so need to unset
100 # SOCKS_SERVER in that case.
104 # Increase GC_MALLOC_LIMIT if set (default is 8000000)
105 if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
106 append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
109 # ipv6 hack, bug 168939. Needs --enable-ipv6.
110 use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
112 # Determine which modules *not* to build depending in the USE flags.
113 if ! use berkdb ; then
114 modules="${modules},dbm"
117 modules="${modules},gdbm"
120 modules="${modules},openssl"
123 modules="${modules},tk"
126 # Provide an empty LIBPATHENV because we disable rpath but we do not
127 # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
129 INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
130 --program-suffix=${MY_SUFFIX} \
131 --with-soname=ruby${MY_SUFFIX} \
135 --with-out-ext="${modules}" \
136 $(use_with jemalloc jemalloc) \
137 $(use_enable socks5 socks) \
138 $(use_enable doc install-doc) \
140 $(use_enable static-libs static) \
141 $(use_enable static-libs install-static-library) \
142 $(use_with static-libs static-linked-ext) \
143 $(use_enable debug) \
145 --enable-option-checking=no
149 emake V=1 EXTLDFLAGS="${LDFLAGS}"
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="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
182 RUBYLIB="${S}:${ED}/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
190 # Remove installed rubygems and rdoc copy
191 rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
192 rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
193 rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
194 rm -rf "${ED}/usr/bin/"{ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
197 make DESTDIR="${D}" install-doc || die "make install-doc failed"
200 if use examples; then
204 dodoc ChangeLog NEWS doc/NEWS* README*
206 if use rubytests; then
208 insinto /usr/share/${PN}-${SLOT}/test
215 if [[ ! -n $(readlink "${EROOT}"/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(23|24|...)"