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,3_6} 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"
34 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
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= )
41 $(for slot in ${BERKDB_SLOTS[@]} ; do printf '%s\n' "sys-libs/db:${slot}[cxx]" ; done)
44 python? ( ${PYTHON_DEPS} )
45 ruby? ( $(ruby_implementation_depend ruby23) )
46 mono? ( dev-lang/mono )
47 php? ( dev-lang/php:7.0 )
51 ncurses? ( sys-libs/ncurses:0= sys-libs/readline:0= )
54 dev-python/passlib[${PYTHON_USEDEP}]
58 # TODO: java bindings, multiple ruby versions (supports 2.{1,2,3})
60 S="${WORKDIR}/${P/I/i}"
64 "${FILESDIR}/${P}-no-arch-opts.patch"
65 "${FILESDIR}/${P}-csharp.patch"
66 "${FILESDIR}/${P}-libressl.patch"
70 # prevent ruby-ng.eclass from messing with pkg_setup
75 # prevent ruby-ng.eclass from messing with src_unpack
80 epatch -p1 "${PATCHES[@]}"
83 -e 's|\(install_configdir[[:space:]]*\):=|\1?=|' \
84 -e 's|-L\$\(libdir\)||' \
85 cpp/config/Make.rules || die "sed failed"
88 -e 's|\(install_phpdir[[:space:]]*\):=|\1?=|' \
89 -e 's|\(install_libdir[[:space:]]*\):=|\1?=|' \
90 php/config/Make.rules.php || die "sed failed"
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"
101 cpp/config/Make.rules.Linux || die "sed failed"
104 -e 's|install-common||' \
105 {cpp,csharp,php,python,ruby}/Makefile || die "sed failed"
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"
113 # skip mono tests, bug #498484
115 -e '/SUBDIRS/s|\ test||' \
116 csharp/Makefile || die "sed failed"
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
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"
128 # mainly broken .ice files
130 -e 's|allTests.py|allTests.py --rfilter=operations --rfilter=slicing\/objects|' \
131 python/Makefile || die "sed failed"
133 # fails even on unicode locale
135 -e 's|allTests.py|allTests.py --rfilter=Slice\/unicodePaths|' \
136 ruby/Makefile || die "sed failed"
138 # fix for x86 IceBox test
141 scripts/TestUtil.py || die "sed failed"
145 suitable_db_version() {
147 for ver in "${BERKDB_SLOTS[@]}"; do
148 if [[ -n $(db_findver sys-libs/db:${ver}) ]]; then
153 die "No suitable BerkDB versions found, aborting"
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\""
164 "NOTEST=$(usex !test)"
165 "USE_READLINE=$(usex ncurses)"
166 "OPTIMIZE=$(usex !debug)"
169 local BERKDB_VERSION="$(suitable_db_version)"
170 MAKE_RULES+=("DB_FLAGS=-I$(db_includedir ${BERKDB_VERSION})")
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"
180 local S="${S}/python"
185 SITERUBY="$(ruby23 -r rbconfig -e 'print RbConfig::CONFIG["sitelibdir"]')"
187 "install_rubydir=\"${ED%/}/${SITERUBY}\""
188 "install_libdir=\"${ED%/}/${SITERUBY}\""
191 # make it use ruby23 only
193 -e 's|RUBY = ruby|\023|' \
194 ruby/config/Make.rules || die "sed failed"
196 -e 's|env ruby|\023|' \
197 ruby/config/s2rb.rb || die "sed failed"
199 -e 's|env ruby|\023|' \
200 ruby/scripts/slice2rb || die "sed failed"
202 -e 's|output.write("ruby|\023|' \
203 scripts/TestUtil.py || die "sed failed"
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\""
214 if has_version ">dev-lang/mono-4"; then
215 MAKE_RULES_MONO+=("MCS=mcs")
218 use test && python_setup
222 # Do not remove this export or build will break!
225 emake -C cpp "${MAKE_RULES[@]}"
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"
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
239 emake -C php "${MAKE_RULES[@]}" USE_NAMESPACES=yes "PHP_CONFIG=\"${EPREFIX}/usr/$(get_libdir)/${i}/bin/php-config\""
240 popd >/dev/null || die
246 emake -C "${BUILD_DIR}" "${MAKE_RULES[@]}" PYTHON="${EPYTHON}"
248 local S="${S}/python"
249 python_foreach_impl building
253 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}"
257 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}"
262 local -x LD_LIBRARY_PATH="${S}/cpp/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
263 emake -C cpp "${MAKE_RULES[@]}" test
265 # php tests require the extension loaded and are therefore skipped
269 emake -C "${BUILD_DIR}" \
271 PYTHON="${EPYTHON}" \
272 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
273 install_libdir="\"${D%/}/$(python_get_sitedir)\"" test
275 local S="${S}/python"
276 python_foreach_impl testing
280 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" test
284 # skip mono tests, bug #498484
285 ewarn "Tests for C# are currently disabled."
286 #emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" test
291 local DOCS=( CHANGELOG*.md README.md )
292 use doc && DOCS+=( "${DISTDIR}/${P}.pdf" )
295 insinto /usr/share/${P}
298 emake -C cpp "${MAKE_RULES[@]}" install
300 if use examples; then
302 dodoc cpp/config/*.cfg
303 docompress -x /usr/share/doc/${PF}/examples-cpp
307 insinto "/usr/share/php/${PN}"
310 while IFS="" read -d $'\0' -r i; do
312 done < <(find "${S}/php/lib/" -name '*.php' -print0)
314 pushd "${ED%/}/usr/share/${P}/slice" >/dev/null || die
316 local -x LD_LIBRARY_PATH="${ED%/}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
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}"/*
325 for i in $(php_get_slots); do
326 php_init_slot_env "${i}"
328 newins "php/lib/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
330 php-ext-source-r2_createinifiles
332 popd >/dev/null || die
337 mkdir -p "${D%/}/$(python_get_sitedir)" || die
339 emake -C "${BUILD_DIR}" \
341 install_pythondir="\"${D%/}/$(python_get_sitedir)\"" \
342 install_libdir="\"${D%/}/$(python_get_sitedir)\"" \
345 local S="${S}/python"
346 python_foreach_impl installation
351 emake -C ruby "${MAKE_RULES[@]}" "${MAKE_RULES_RUBY[@]}" install
355 emake -C csharp "${MAKE_RULES[@]}" "${MAKE_RULES_MONO[@]}" install