# Template file for 'coin3'
pkgname=coin3
version=3.1.3
revision=4
wrksrc="Coin-${version}"
patch_args="-Np1"
build_style=gnu-configure
configure_args="--includedir=/usr/include/Coin3 --disable-dependency-tracking
 --disable-static --enable-threadsafe --enable-exceptions
 --disable-dl-simage --disable-dl-glu --disable-dl-libbzip2
 --disable-dl-zlib --disable-dl-freetype --disable-dl-fontconfig
 --enable-3ds-import --enable-html"
hostmakedepends="pkg-config doxygen perl"
makedepends="freetype-devel glu-devel zlib-devel bzip2-devel
 fontconfig-devel boost-devel simage-devel"

# depends on script simage-config
nocross=yes

short_desc="High-level 3D graphics toolkit"
maintainer="yopito <pierre.bourgin@free.fr>"

# HomePage tells BSD 3-Clause license, but tarball is GPLv2
license="GPL-2"
homepage="https://bitbucket.org/Coin3D/coin/wiki/Home"
distfiles="https://bitbucket.org/Coin3D/coin/downloads/Coin-${version}.tar.gz"
checksum=583478c581317862aa03a19f14c527c3888478a06284b9a46a0155fa5886d417

post_extract() {
	# remove bundled boost headers
	rm -rf ${wrksrc}/include/boost
}

do_configure() {
	# only way to compute and point freetype2 stuff to configure
	: ${configure_script:=./configure}
	CPPFLAGS+="$(pkg-config --cflags freetype2)" ${configure_script} ${configure_args}
}

post_configure() {
	case "$XBPS_TARGET_MACHINE" in
	*-musl)
		# configure checks are awfull
		sed -i -e 's,^#define SIM_TIMEVAL_TV_SEC_T { },#define SIM_TIMEVAL_TV_SEC_T time_t,' \
		       -e 's,^#define SIM_TIMEVAL_TV_USEC_T { },#define SIM_TIMEVAL_TV_USEC_T suseconds_t,' \
		       ${wrksrc}/src/config.h
		;;
	esac
}

coin3-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/bin/coin-config
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
		vmove usr/share/aclocal
		vmove usr/share/man
	}
}

coin3-doc_package() {
	short_desc+=" - documentation"
	noarch=yes
	pkg_install() {
		vmove usr/share/doc
	}
}
