# Template file for 'Ice'
pkgname=Ice
version=3.7.8
revision=3
build_style=gnu-makefile
make_build_args="LANGUAGES=cpp OPTIMIZE=yes USR_DIR_INSTALL=yes CONFIGS=shared
 CONFIGS+=cpp11-shared"
make_install_args="LANGUAGES=cpp 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"
changelog="https://doc.zeroc.com/ice/latest/release-notes"
distfiles="https://github.com/zeroc-ice/ice/archive/v${version}.tar.gz"
checksum=f2ab6b151ab0418fab30bafc2524d9ba4c767a1014f102df88d735fc775f9824

if [ "$XBPS_TARGET_LIBC" = "glibc" ]; then
	makedepends+=" libxcrypt-devel"
fi

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