Use https by default
[gentoo.git] / dev-lang / ruby / ruby-2.1.6-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 #PATCHSET=1
8
9 inherit autotools eutils flag-o-matic multilib versionator
10
11 RUBYPL=$(get_version_component_range 4)
12
13 MY_P="${PN}-$(get_version_component_range 1-3)"
14 #MY_P="${PN}-$(get_version_component_range 1-3)-${RUBYPL:-0}"
15 S=${WORKDIR}/${MY_P}
16
17 SLOT=$(get_version_component_range 1-2)
18 MY_SUFFIX=$(delete_version_separator 1 ${SLOT})
19 RUBYVERSION=2.1.0
20
21 if [[ -n ${PATCHSET} ]]; then
22         if [[ ${PVR} == ${PV} ]]; then
23                 PATCHSET="${PV}-r0.${PATCHSET}"
24         else
25                 PATCHSET="${PVR}.${PATCHSET}"
26         fi
27 else
28         PATCHSET="${PVR}"
29 fi
30
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"
35
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"
39
40 RDEPEND="
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 )
47         dev-libs/libyaml
48         virtual/libffi
49         sys-libs/zlib
50         >=app-eselect/eselect-ruby-20131227
51         !<dev-ruby/rdoc-3.9.4
52         !<dev-ruby/rubygems-1.8.10-r1"
53
54 DEPEND="${RDEPEND}"
55 PDEPEND="
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 )"
61
62 src_prepare() {
63         EPATCH_FORCE="yes" EPATCH_SUFFIX="patch" \
64                 epatch "${WORKDIR}/patches"
65
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..."
70         cd "$S"
71         rm -r \
72                 {bin,lib}/rake lib/rake.rb man/rake.1 \
73                 bin/gem || die "removal failed"
74
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"
78
79         eautoreconf
80 }
81
82 src_configure() {
83         local myconf=
84
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
88         local modules="tk"
89
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
95         # SuperH needs this
96         use sh && append-flags -mieee
97
98         # Socks support via dante
99         if use socks5 ; then
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.
103                 unset SOCKS_SERVER
104         fi
105
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}"
109         fi
110
111         # ipv6 hack, bug 168939. Needs --enable-ipv6.
112         use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
113
114         # Determine which modules *not* to build depending in the USE flags.
115         if ! use readline ; then
116                 modules="${modules},readline"
117         fi
118         if ! use berkdb ; then
119                 modules="${modules},dbm"
120         fi
121         if ! use gdbm ; then
122                 modules="${modules},gdbm"
123         fi
124         if ! use ssl ; then
125                 modules="${modules},openssl"
126         fi
127         if ! use ncurses ; then
128                 modules="${modules},curses"
129         fi
130
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} \
135                 --enable-shared \
136                 --enable-pthread \
137                 --disable-rpath \
138                 --with-out-ext="${modules}" \
139                 $(use_enable socks5 socks) \
140                 $(use_enable doc install-doc) \
141                 --enable-ipv6 \
142                 $(use_enable debug) \
143                 ${myconf} \
144                 --enable-option-checking=no \
145                 || die "econf failed"
146 }
147
148 src_compile() {
149         emake V=1 EXTLDFLAGS="${LDFLAGS}" || die "emake failed"
150 }
151
152 src_test() {
153         emake -j1 V=1 test || die "make test failed"
154
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."
157         elog
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."
162                 elog "Then call: "
163                 elog
164                 elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
165         else
166                 elog "Enable the rubytests USE flag to install the make check tests"
167         fi
168 }
169
170 src_install() {
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
173         # documentation.
174         rm -rf ext/json || die
175
176         # Ruby is involved in the install process, we don't want interference here.
177         unset RUBYOPT
178
179         local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
180
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"
185         done
186         export LD_LIBRARY_PATH RUBYLIB
187
188         emake V=1 DESTDIR="${D}" install || die "make install failed"
189
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"
194
195         if use doc; then
196                 make DESTDIR="${D}" install-doc || die "make install-doc failed"
197         fi
198
199         if use examples; then
200                 insinto /usr/share/doc/${PF}
201                 doins -r sample
202         fi
203
204         dodoc ChangeLog NEWS doc/NEWS* README* || die
205
206         if use rubytests; then
207                 pushd test
208                 insinto /usr/share/${PN}-${SLOT}/test
209                 doins -r .
210                 popd
211         fi
212 }
213
214 pkg_postinst() {
215         if [[ ! -n $(readlink "${ROOT}"usr/bin/ruby) ]] ; then
216                 eselect ruby set ruby${MY_SUFFIX}
217         fi
218
219         elog
220         elog "To switch between available Ruby profiles, execute as root:"
221         elog "\teselect ruby set ruby(19|20|...)"
222         elog
223 }
224
225 pkg_postrm() {
226         eselect ruby cleanup
227 }