Use https by default
[gentoo.git] / dev-lang / ruby / ruby-1.9.3_p551-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=4
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)-${RUBYPL:-0}"
14 S=${WORKDIR}/${MY_P}
15
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
19 RUBYVERSION=1.9.1
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/1.9/${MY_P}.tar.bz2
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 +yaml" #libedit
39
40 # libedit support is removed everywhere because of this upstream bug:
41 # http://redmine.ruby-lang.org/issues/show/3698
42
43 RDEPEND="
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 )
51         virtual/libffi
52         sys-libs/zlib
53         >=app-eselect/eselect-ruby-20100402
54         !<dev-ruby/rdoc-3.9.4
55         !<dev-ruby/rubygems-1.8.10-r1"
56 #       libedit? ( dev-libs/libedit )
57 #       !libedit? ( readline? ( sys-libs/readline ) )
58
59 DEPEND="${RDEPEND}"
60 PDEPEND="
61         virtual/rubygems[ruby_targets_ruby19]
62         rdoc? ( >=dev-ruby/rdoc-3.9.4[ruby_targets_ruby19] )
63         xemacs? ( app-xemacs/ruby-modes )"
64
65 src_prepare() {
66         EPATCH_FORCE="yes" EPATCH_SUFFIX="patch" \
67                 epatch "${WORKDIR}/patches"
68
69         einfo "Unbundling gems..."
70         cd "$S"
71         rm -r \
72                 {bin,lib}/rake lib/rake.rb man/rake.1 \
73                 ext/json \
74                 bin/gem || die "removal failed"
75
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"
79
80         eautoreconf
81 }
82
83 src_configure() {
84         local myconf=
85
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
91         # SuperH needs this
92         use sh && append-flags -mieee
93
94         # Socks support via dante
95         if use socks5 ; then
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.
99                 unset SOCKS_SERVER
100         fi
101
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}"
105         fi
106
107         # ipv6 hack, bug 168939. Needs --enable-ipv6.
108         use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
109
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"
116 #       else
117 #               myconf="${myconf} --without-readline"
118 #       fi
119         myconf="${myconf} $(use_with readline)"
120
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} \
126                 --enable-shared \
127                 --enable-pthread \
128                 --without-tk \
129                 $(use_enable socks5 socks) \
130                 $(use_enable doc install-doc) \
131                 --enable-ipv6 \
132                 $(use_enable debug) \
133                 $(use_with berkdb dbm) \
134                 $(use_with gdbm) \
135                 $(use_with ssl openssl) \
136                 $(use_with ncurses curses) \
137                 $(use_with yaml psych) \
138                 ${myconf} \
139                 --enable-option-checking=no \
140                 || die "econf failed"
141 }
142
143 src_compile() {
144         emake V=1 EXTLDFLAGS="${LDFLAGS}" || die "emake failed"
145 }
146
147 src_test() {
148         emake -j1 V=1 test || die "make test failed"
149
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."
152         elog
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."
157                 elog "Then call: "
158                 elog
159                 elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
160         else
161                 elog "Enable the rubytests USE flag to install the make check tests"
162         fi
163 }
164
165 src_install() {
166         # Ruby is involved in the install process, we don't want interference here.
167         unset RUBYOPT
168
169         local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
170
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"
175         done
176         export LD_LIBRARY_PATH RUBYLIB
177
178         emake V=1 DESTDIR="${D}" install || die "make install failed"
179
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"
184
185         if use doc; then
186                 make DESTDIR="${D}" install-doc || die "make install-doc failed"
187         fi
188
189         if use examples; then
190                 insinto /usr/share/doc/${PF}
191                 doins -r sample
192         fi
193
194         dodoc ChangeLog NEWS doc/NEWS* README* ToDo || die
195
196         if use rubytests; then
197                 pushd test
198                 insinto /usr/share/${PN}-${SLOT}/test
199                 doins -r .
200                 popd
201         fi
202 }
203
204 pkg_postinst() {
205         if [[ ! -n $(readlink "${ROOT}"usr/bin/ruby) ]] ; then
206                 eselect ruby set ruby${MY_SUFFIX}
207         fi
208
209         elog
210         elog "To switch between available Ruby profiles, execute as root:"
211         elog "\teselect ruby set ruby(19|20|...)"
212         elog
213 }
214
215 pkg_postrm() {
216         eselect ruby cleanup
217 }