# Template file for 'Ice'
pkgname=Ice
version=3.7.5
revision=2
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="a dinosaur <nick@a-dinosaur.com>"
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=36bf45591a95e6ee7216153d45d8eca05ff00c1da35608f0c400e6ddc8049da9
patch_args="-Np1"

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"
	}
}
