# Template file for 'Ice'
pkgname=Ice
version=3.7.7
revision=1
wrksrc="ice-${version}"
build_style=gnu-makefile
make_build_args="LANGUAGES=cpp prefix=/usr OPTIMIZE=yes
 USR_DIR_INSTALL=yes CONFIGS=shared CONFIGS+=cpp11-shared"
make_install_args="LANGUAGES=cpp prefix=/usr lib-suffix="
makedepends="zlib-devel bzip2-devel zeroc-mcpp db-devel expat-devel
 openssl-devel lmdb-devel editline-devel"
short_desc="Internet Communications Engine (Ice)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only, custom:ICE"
homepage="https://www.zeroc.com"
distfiles="https://github.com/zeroc-ice/ice/archive/v${version}.tar.gz"
checksum=3aef143a44a664f3101cfe02fd13356c739c922e353ef0c186895b5843a312ae

if [ "$CROSS_BUILD" ]; then
	# Cross build requires the host's slice2cpp
	hostmakedepends+=" Ice"
fi

do_configure() {
	# Disable building tests
	vsed 's|include \$(top_srcdir)/config/Make.tests.rules||' -i config/Make.rules

	# Disable errors on warnings
	vsed 's|-Werror|-Wno-error|' -i config/Make.rules.Linux

	# Patch to fix finding editline
	vsed 's|-ledit|-leditline|' -i config/Make.rules.Linux
	vsed 's|editline/readline.h|editline.h|' -i cpp/src/IceStorm/Parser.cpp cpp/src/IceGrid/Parser.cpp

	if [ "$CROSS_BUILD" ]; then
		# Use host's slice2cpp
		vsed -i config/Make.project.rules \
			-e 's/$($6_path) |/|/' \
			-e 's|$(Q)$($6_path)|$(Q)/usr/bin/slice2cpp|'
	fi
}

post_install() {
	vlicense ICE_LICENSE
}

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

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