# Template file for 'Ice'
pkgname=Ice
version=3.5.1
revision=1
build_wrksrc=cpp
homepage="http://www.zeroc.com"
# XXX: other language bindings
makedepends="zlib-devel bzip2-devel mcpp-devel db-devel>=5.3 expat-devel openssl-devel"
short_desc="The Internet Communications Engine (Ice)"
maintainer="davehome <davehome@redthumb.info.tm>"
license="GPL-2, ICE"
distfiles="${homepage}/download/Ice/3.5/${pkgname}-${version}.tar.gz"
checksum=989e51194c6adadbd156da3288e37bad847b93b3b876502e83033b70493af392

do_configure() {
	sed -i -e "s|^#OPTIMIZE|OPTIMIZE|" config/Make.rules
	sed -i -e "s|x)/config|x)/lib/Ice/config|" config/Make.rules
	sed -i '/^embedded_runpath_prefix*/d' config/Make.rules
	sed -i -e "s|test demo||" Makefile
}

do_build() {
	export CXXFLAGS+=" -fPIC -DPIC"
	make prefix=/usr ${makejobs}
}

do_install() {
	if [ "$XBPS_MACHINE" = "x86_64" ]; then
		vmkdir usr/lib
		cd ${DESTDIR}/usr && ln -s lib lib64
		cd ${wrksrc}/${build_wrksrc}
	fi
	make prefix=${DESTDIR}/usr install
	[ -h ${DESTDIR}/usr/lib64 ] && rm -f ${DESTDIR}/usr/lib64

	vmkdir usr/share/licenses/${pkgname}
	mv ${DESTDIR}/usr/slice ${DESTDIR}/usr/share
	rm ${DESTDIR}/usr/LICENSE
	mv ${DESTDIR}/usr/ICE_LICENSE \
		${DESTDIR}/usr/share/licenses/${pkgname}/LICENSE

	# remove unused cruft
	rm -f ${DESTDIR}/usr/lib/*.class
}

libIce_package() {
	short_desc+=" - runtime libraries"
	pkg_install() {
		vmove "usr/lib/*.so.*"
		vmove usr/lib/Ice
	}
}

Ice-devel_package() {
	depends="libIce>=${version}_${revision} Ice>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
	}
}
