1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_4,3_5} pypy )
15 PHP_EXT_OPTIONAL_USE=php
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 )
23 inherit db-use eutils mono-env php-ext-source-r2 python-r1 ruby-ng toolchain-funcs versionator
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 )"
31 KEYWORDS="amd64 ~arm x86"
32 IUSE="doc examples libressl +ncurses mono php python ruby test debug"
33 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
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= )
40 $(for slot in ${BERKDB_SLOTS[@]} ; do printf '%s\n' "sys-libs/db:${slot}[cxx]" ; done)
43 python? ( ${PYTHON_DEPS} )
44 ruby? ( $(ruby_implementation_depend ruby23) )
45 mono? ( dev-lang/mono )
46 php? ( dev-lang/php:7.0 )
50 ncurses? ( sys-libs/ncurses:0= sys-libs/readline:0= )
53 dev-python/passlib[${PYTHON_USEDEP}]
57 # TODO: java bindings, multiple ruby versions (supports 2.{1,2,3})
59 S="${WORKDIR}/${P/I/i}"
63 "${FILESDIR}/${P}-no-arch-opts.patch"
64 "${FILESDIR}/${P}-csharp.patch"
65 "${FILESDIR}/${P}-libressl.patch"
69 # prevent ruby-ng.eclass from messing with pkg_setup
74 # prevent ruby-ng.eclass from messing with src_unpack
79 epatch -p1 "${PATCHES[@]}"
82 -e 's|\(install_configdir[[:space:]]*\):=|\1?=|' \
83 -e 's|-L\$\(libdir\)||' \
84 cpp/config/Make.rules || die "sed failed"
87 -e 's|\(install_phpdir[[:space:]]*\):=|\1?=|' \
88 -e 's|\(install_libdir[[:space:]]*\):=|\1?=|' \
89 php/config/Make.rules.php || die "sed failed"
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"
100 cpp/config/Make.rules.Linux || die "sed failed"
103 -e 's|install-common||' \
104 {cpp,csharp,php,python,ruby}/Makefile || die "sed failed"
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"
112 # skip mono tests, bug #498484
114 -e '/SUBDIRS/s|\ test||' \
115 csharp/Makefile || die "sed failed"
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
122 -e 's|allTests.py|allTests.py --rfilter=IceUtil\/stacktrace --rfilter=udp --rfilter=IceSSL --rfilter=IceStorm\/stress|' \
123 cpp/Makefile || die "sed failed"
125 # mainly broken .ice files
127 -e 's|allTests.py|allTests.py --rfilter=operations --rfilter=slicing\/objects|' \
128 python/Makefile || die "sed failed"
130 # fails even on unicode locale
132 -e 's|allTests.py|allTests.py --rfilter=Slice\/unicodePaths|' \
133 ruby/Makefile || die "sed failed"
137 suitable_db_version() {
139 for ver in "${BERKDB_SLOTS[@]}"; do
140 if [[ -n $(db_findver sys-libs/db:${ver}) ]]; then
145 die "No suitable BerkDB versions found, aborting"
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\""
156 "NOTEST=$(usex !test)"
157 "USE_READLINE=$(usex ncurses)"
158 "OPTIMIZE=$(usex !debug)"
161 local BERKDB_VERSION="$(suitable_db_version)"
162 MAKE_RULES+=("DB_FLAGS=-I$(db_includedir ${BERKDB_VERSION})")
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"
172 local S="${S}/python"
177 SITERUBY="$(ruby23 -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]')"
179 "install_rubydir=\"${ED%/}/${SITERUBY}\""
180 "install_libdir=\"${ED%/}/${SITERUBY}\""
183 # make it use ruby23 only
185 -e 's|RUBY = ruby|\022|' \
186 ruby/config/Make.rules || die "sed failed"
188 -e 's|env ruby|\022|' \
189 ruby/config/s2rb.rb || die "sed failed"
191 -e 's|env ruby|\022|' \
192 ruby/scripts/slice2rb || die "sed failed"
194 -e 's|output.write("ruby|\022|' \
195 scripts/TestUtil.py || die "sed failed"
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\""
206 if has_version ">dev-lang/mono-4"; then
207 MAKE_RULES_MONO+=("MCS=mcs")
210 use test && python_setup
214 # Do not remove this export or build will break!
217 emake -C cpp "${MAKE_RULES[@]}"
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"
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
231 emake -C php "${MAKE_RULES[@]}" USE_NAMESPACES=yes "PHP_CONFIG=\"${EPREFIX}/usr/$(get_libdir)/${i}/bin/php-config\""
232 popd >/dev/null || die
238 emake -C "${BUILD_DIR}" "${MAKE_RULES[@]}" PYTHON="${EPYTHON}"
240 local S="${S}/python"
241 python_foreach_impl building
245 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}"
249 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}"
254 local -x LD_LIBRARY_PATH="${S}/cpp/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
255 emake -C cpp "${MAKE_RULES[@]}" test
257 # php tests require the extension loaded and are therefore skipped
261 emake -C "${BUILD_DIR}" \
263 PYTHON="${EPYTHON}" \
264 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
265 install_libdir="\"${D%/}/$(python_get_sitedir)\"" test
267 local S="${S}/python"
268 python_foreach_impl testing
272 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" test
276 # skip mono tests, bug #498484
277 ewarn "Tests for C# are currently disabled."
278 #emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" test
283 local DOCS=( CHANGELOG*.md README.md )
284 use doc && DOCS+=( "${DISTDIR}/${P}.pdf" )
287 insinto /usr/share/${P}
290 emake -C cpp "${MAKE_RULES[@]}" install
292 if use examples; then
294 dodoc cpp/config/*.cfg
295 docompress -x /usr/share/doc/${PF}/examples-cpp
299 insinto "/usr/share/php/${PN}"
302 while IFS="" read -d $'\0' -r i; do
304 done < <(find "${S}/php/lib/" -name '*.php' -print0)
306 pushd "${ED%/}/usr/share/${P}/slice" >/dev/null || die
308 local -x LD_LIBRARY_PATH="${ED%/}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
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}"/*
317 for i in $(php_get_slots); do
318 php_init_slot_env "${i}"
320 newins "php/lib/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
322 php-ext-source-r2_createinifiles
324 popd >/dev/null || die
329 mkdir -p "${D%/}/$(python_get_sitedir)" || die
331 emake -C "${BUILD_DIR}" \
333 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
334 install_libdir="\"${D%/}/$(python_get_sitedir)\"" \
337 local S="${S}/python"
338 python_foreach_impl installation
343 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" install
347 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" install