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