dev-libs/Ice: x86 stable (bug #672980)
[gentoo.git] / dev-libs / Ice / Ice-3.6.3-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} pypy )
7
8 RUBY_OPTIONAL="yes"
9 USE_RUBY="ruby23"
10
11 PHP_EXT_NAME="IcePHP"
12 PHP_EXT_INI="yes"
13 PHP_EXT_ZENDEXT="no"
14
15 PHP_EXT_OPTIONAL_USE=php
16
17 USE_PHP="php7-0"
18
19 # This variable does not belong to any eclass. It is solely used in this ebuild
20 # db:6.2 breaks the build process
21 BERKDB_SLOTS=( 6.1 5.3 5.1 4.8 )
22
23 inherit db-use eutils mono-env php-ext-source-r2 python-r1 ruby-ng toolchain-funcs versionator
24
25 DESCRIPTION="ICE middleware C++ library and generator tools"
26 HOMEPAGE="https://zeroc.com/products/ice"
27 SRC_URI="https://github.com/zeroc-ice/ice/archive/v${PV}.tar.gz -> ${P}.tar.gz
28         doc? ( http://download.zeroc.com/Ice/$(get_version_component_range 1-2)/${P}.pdf )"
29 LICENSE="GPL-2"
30 SLOT="0/36"
31 KEYWORDS="amd64 ~arm x86"
32 IUSE="doc examples libressl +ncurses mono php python ruby test debug"
33 RESTRICT="test"
34 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
35
36 RDEPEND=">=dev-libs/expat-2.0.1
37         >=app-arch/bzip2-1.0.5
38         !libressl? ( dev-libs/openssl:0= )
39         libressl? ( dev-libs/libressl:0= )
40         || (
41                 $(for slot in ${BERKDB_SLOTS[@]} ; do printf '%s\n' "sys-libs/db:${slot}[cxx]" ; done)
42         )
43         dev-cpp/libmcpp
44         python? ( ${PYTHON_DEPS} )
45         ruby? ( $(ruby_implementation_depend ruby23) )
46         mono? ( dev-lang/mono )
47         php? ( dev-lang/php:7.0 )
48         !dev-python/IcePy
49         !dev-ruby/IceRuby"
50 DEPEND="${RDEPEND}
51         ncurses? ( sys-libs/ncurses:0= sys-libs/readline:0= )
52         test? (
53                 ${PYTHON_DEPS}
54                 dev-python/passlib[${PYTHON_USEDEP}]
55         )"
56
57 # Maintainer notes:
58 # TODO: java bindings, multiple ruby versions (supports 2.{1,2,3})
59
60 S="${WORKDIR}/${P/I/i}"
61 PHP_EXT_S="${S}/php"
62
63 PATCHES=(
64         "${FILESDIR}/${P}-no-arch-opts.patch"
65         "${FILESDIR}/${P}-csharp.patch"
66         "${FILESDIR}/${P}-libressl.patch"
67 )
68
69 pkg_setup() {
70         # prevent ruby-ng.eclass from messing with pkg_setup
71         return
72 }
73
74 src_unpack() {
75         # prevent ruby-ng.eclass from messing with src_unpack
76         default
77 }
78
79 src_prepare() {
80         epatch -p1 "${PATCHES[@]}"
81
82         sed -i \
83                 -e 's|\(install_configdir[[:space:]]*\):=|\1?=|' \
84                 -e 's|-L\$\(libdir\)||' \
85                 cpp/config/Make.rules || die "sed failed"
86
87         sed -i \
88                 -e 's|\(install_phpdir[[:space:]]*\):=|\1?=|' \
89                 -e 's|\(install_libdir[[:space:]]*\):=|\1?=|' \
90                 php/config/Make.rules.php || die "sed failed"
91
92         sed -i \
93                 -e 's|\(install_pythondir[[:space:]]*\)=|\1?=|' \
94                 -e 's|\(install_rubydir[[:space:]]*\)=|\1?=|' \
95                 -e 's|\(install_libdir[[:space:]]*\):=|\1?=|' \
96                 {python,ruby}/config/Make.rules || die "sed failed"
97
98         sed -i \
99                 -e 's|-O2 ||g' \
100                 -e 's|-Werror ||g' \
101                 cpp/config/Make.rules.Linux || die "sed failed"
102
103         sed -i \
104                 -e 's|install-common||' \
105                 {cpp,csharp,php,python,ruby}/Makefile || die "sed failed"
106
107         sed -i \
108                 -e 's|-f -root|-f -gacdir $(GAC_DIR) -root|' \
109                 -e 's|\(install_libdir[[:space:]]*\):=|\1?=|' \
110                 -e 's|\(install_pkgconfigdir[[:space:]]*\):=|\1?=|' \
111                 csharp/config/Make.rules.cs || die "sed failed"
112
113         # skip mono tests, bug #498484
114         sed -i \
115                 -e '/SUBDIRS/s|\ test||' \
116                 csharp/Makefile || die "sed failed"
117
118         # skip udp test due to multicast
119         # skip IceGrid/admin bug #649850
120         # skip IceSSL tests due to requirement of internet connection
121         # skip IceStorm/single bug #636834
122         # IceStorm/stress fails without USE=debug
123         # IceUtil/stacktrace fails with USE=debug
124         sed -i \
125                 -e 's|allTests.py|allTests.py --rfilter=IceUtil\/stacktrace --rfilter=udp --rfilter=IceGrid\/admin --rfilter=IceSSL --rfilter=IceStorm\/single --rfilter=IceStorm\/stress|' \
126                 cpp/Makefile || die "sed failed"
127
128         # mainly broken .ice files
129         sed -i \
130                 -e 's|allTests.py|allTests.py --rfilter=operations --rfilter=slicing\/objects|' \
131                 python/Makefile || die "sed failed"
132
133         # fails even on unicode locale
134         sed -i \
135                 -e 's|allTests.py|allTests.py --rfilter=Slice\/unicodePaths|' \
136                 ruby/Makefile || die "sed failed"
137
138         # fix for x86 IceBox test
139         sed -i \
140                 -e 's|"32"|""|' \
141                 scripts/TestUtil.py || die "sed failed"
142 }
143
144 src_configure() {
145         suitable_db_version() {
146                 local ver
147                 for ver in "${BERKDB_SLOTS[@]}"; do
148                         if [[ -n $(db_findver sys-libs/db:${ver}) ]]; then
149                                 echo "${ver}"
150                                 return 0
151                         fi
152                 done
153                 die "No suitable BerkDB versions found, aborting"
154         }
155
156         MAKE_RULES=(
157                 "prefix=\"${ED%/}/usr\""
158                 "install_docdir=\"${ED%/}/usr/share/doc/${PF}\""
159                 "install_configdir=\"${ED%/}/usr/share/${P}/config\""
160                 "install_mandir=\"${ED%/}/usr/share/man\""
161                 "embedded_runpath_prefix=\"${EPREFIX}/usr\""
162                 "LP64=yes"
163                 "new_dtags=yes"
164                 "NOTEST=$(usex !test)"
165                 "USE_READLINE=$(usex ncurses)"
166                 "OPTIMIZE=$(usex !debug)"
167         )
168
169         local BERKDB_VERSION="$(suitable_db_version)"
170         MAKE_RULES+=("DB_FLAGS=-I$(db_includedir ${BERKDB_VERSION})")
171         sed -i \
172                 -e "s|g++|$(tc-getCXX)|" \
173                 -e "s|\(CFLAGS[[:space:]]*=\)|\1 ${CFLAGS}|" \
174                 -e "s|\(CXXFLAGS[[:space:]]*=\)|\1 ${CXXFLAGS}|" \
175                 -e "s|\(LDFLAGS[[:space:]]*=\)|\1 ${LDFLAGS}|" \
176                 -e "s|\(DB_LIBS[[:space:]]*=\) \-ldb_cxx|\1 -ldb_cxx-$(db_findver sys-libs/db:${BERKDB_VERSION})|" \
177                 cpp/config/Make.rules{,.Linux} python/config/Make.rules || die "sed failed"
178
179         if use python; then
180                 local S="${S}/python"
181                 python_copy_sources
182         fi
183
184         if use ruby; then
185                 SITERUBY="$(ruby23 -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]')"
186                 MAKE_RULES_RUBY=(
187                         "install_rubydir=\"${ED%/}/${SITERUBY}\""
188                         "install_libdir=\"${ED%/}/${SITERUBY}\""
189                 )
190
191                 # make it use ruby23 only
192                 sed -i \
193                         -e 's|RUBY = ruby|\023|' \
194                         ruby/config/Make.rules || die "sed failed"
195                 sed -i \
196                         -e 's|env ruby|\023|' \
197                         ruby/config/s2rb.rb || die "sed failed"
198                 sed -i \
199                         -e 's|env ruby|\023|' \
200                         ruby/scripts/slice2rb || die "sed failed"
201                 sed -i \
202                         -e 's|output.write("ruby|\023|' \
203                         scripts/TestUtil.py || die "sed failed"
204         fi
205
206         MAKE_RULES_MONO=(
207                 "GACINSTALL=yes"
208                 "GAC_ROOT=\"${ED%/}/usr/$(get_libdir)\""
209                 "GAC_DIR=\"${EPREFIX}/usr/$(get_libdir)\""
210                 "install_libdir=\"${ED%/}/usr/$(get_libdir)\""
211                 "install_pkgconfigdir=\"${ED%/}/usr/$(get_libdir)/pkgconfig\""
212         )
213
214         if has_version ">dev-lang/mono-4"; then
215                 MAKE_RULES_MONO+=("MCS=mcs")
216         fi
217
218         use test && python_setup
219 }
220
221 src_compile() {
222         # Do not remove this export or build will break!
223         tc-export CXX
224
225         emake -C cpp "${MAKE_RULES[@]}"
226
227         if use php; then
228                 local i
229                 for i in $(php_get_slots); do
230                         mkdir -p "${WORKDIR}/${i}" || die
231                         cp -r "${PHP_EXT_S}" "${WORKDIR}/${i}/" || die "Failed to copy source ${PHP_EXT_S} to PHP target directory"
232
233                         pushd "${WORKDIR}/${i}" >/dev/null || die
234                         ln -s "${S}/cpp" || die
235                         ln -s "${S}/config" || die
236                         ln -s "${S}/slice" || die
237                         ln -s "${S}/Makefile" || die
238
239                         emake -C php "${MAKE_RULES[@]}" USE_NAMESPACES=yes "PHP_CONFIG=\"${EPREFIX}/usr/$(get_libdir)/${i}/bin/php-config\""
240                         popd >/dev/null || die
241                 done
242         fi
243
244         if use python; then
245                 building() {
246                         emake -C "${BUILD_DIR}" "${MAKE_RULES[@]}" PYTHON="${EPYTHON}"
247                 }
248                 local S="${S}/python"
249                 python_foreach_impl building
250         fi
251
252         if use ruby; then
253                 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}"
254         fi
255
256         if use mono; then
257                 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}"
258         fi
259 }
260
261 src_test() {
262         local -x LD_LIBRARY_PATH="${S}/cpp/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
263         emake -C cpp "${MAKE_RULES[@]}" test
264
265         # php tests require the extension loaded and are therefore skipped
266
267         if use python; then
268                 testing() {
269                         emake -C "${BUILD_DIR}" \
270                                 "${MAKE_RULES[@]}" \
271                                 PYTHON="${EPYTHON}" \
272                                 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
273                                 install_libdir="\"${D%/}/$(python_get_sitedir)\"" test
274                 }
275                 local S="${S}/python"
276                 python_foreach_impl testing
277         fi
278
279         if use ruby; then
280                 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" test
281         fi
282
283         if use mono; then
284                 # skip mono tests, bug #498484
285                 ewarn "Tests for C# are currently disabled."
286                 #emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" test
287         fi
288 }
289
290 src_install() {
291         local DOCS=( CHANGELOG*.md README.md )
292         use doc && DOCS+=( "${DISTDIR}/${P}.pdf" )
293         einstalldocs
294
295         insinto /usr/share/${P}
296         doins -r slice
297
298         emake -C cpp "${MAKE_RULES[@]}" install
299
300         if use examples; then
301                 docinto examples-cpp
302                 dodoc cpp/config/*.cfg
303                 docompress -x /usr/share/doc/${PF}/examples-cpp
304         fi
305
306         if use php; then
307                 insinto "/usr/share/php/${PN}"
308
309                 local i
310                 while IFS="" read -d $'\0' -r i; do
311                         doins "${i}"
312                 done < <(find "${S}/php/lib/" -name '*.php' -print0)
313
314                 pushd "${ED%/}/usr/share/${P}/slice" >/dev/null || die
315
316                 local -x LD_LIBRARY_PATH="${ED%/}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
317                 for i in *; do
318                         mkdir -p "${ED%/}/usr/share/php/${i}" || die
319                         "${ED%/}"/usr/bin/slice2php \
320                                 -I"${ED%/}/usr/share/${P}/slice/" --all \
321                                 --output-dir "${ED%/}/usr/share/php/${i}" \
322                                 --ice "${ED%/}/usr/share/${P}/slice/${i}"/*
323                 done
324
325                 for i in $(php_get_slots); do
326                         php_init_slot_env "${i}"
327                         insinto "${EXT_DIR}"
328                         newins "php/lib/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
329                 done
330                 php-ext-source-r2_createinifiles
331
332                 popd >/dev/null || die
333         fi
334
335         if use python; then
336                 installation() {
337                         mkdir -p "${D%/}/$(python_get_sitedir)" || die
338
339                         emake -C "${BUILD_DIR}" \
340                                 "${MAKE_RULES[@]}" \
341                                 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
342                                 install_libdir="\"${D%/}/$(python_get_sitedir)\"" \
343                                 install
344                 }
345                 local S="${S}/python"
346                 python_foreach_impl installation
347         fi
348
349         if use ruby; then
350                 dodir "${SITERUBY}"
351                 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" install
352         fi
353
354         if use mono; then
355                 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" install
356         fi
357 }