COMMENT=		C++ and python library of 2D and 3D vector & matrix

V=			3.2.2
GH_ACCOUNT=		AcademySoftwareFoundation
GH_PROJECT=		Imath
GH_TAGNAME=		v${V}

MAINTAINER=		Antoine Jacoutot <ajacoutot@openbsd.org>

# /!\ see symlinks creation in post-install (LIBImath-3_2_VERSION is used)
SHARED_LIBS +=	Imath			0.0 # 0.0
SHARED_LIBS +=	Imath-3_2		0.0 # 0.0
SHARED_LIBS +=	PyImath			0.0 # 0.0
SHARED_LIBS +=	PyImath_Python3_12-3_2	0.0 # 0.0

CATEGORIES=		math graphics devel

# BSD-3-Clause
PERMIT_PACKAGE=		Yes

WANTLIB += ${COMPILER_LIBCXX} boost_container-mt boost_graph-mt
WANTLIB += boost_python${MODPY_VERSION:C/\.//g}-mt m

COMPILER=		base-clang ports-gcc base-gcc

MODULES=		devel/cmake \
			lang/python

BUILD_DEPENDS=		math/py-numpy

LIB_DEPENDS=		devel/boost

.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
CXXFLAGS +=		-mxgot
.endif

CONFIGURE_ARGS =	-DPYTHON=ON

MODCMAKE_LDFLAGS =		-L${LOCALBASE}/lib

DEBUG_PACKAGES=		${BUILD_PACKAGES}

post-install:
# fix links target; symlinks are required for FindIlmbase.cmake etc. to find the
# corresponding libs (e.g. find_library(ILMBASE_IMATH_LIBRARY Imath))
	cd ${PREFIX}/lib && \
		for i in *.so; do \
			test -h $$i && lib=$${i#lib} && lib=$${lib%.so} && \
			f="$$(readlink $$i)" && \
			ln -sf $${f:##*/}.${LIBImath-3_2_VERSION} \
			lib$${lib}.so.${LIBImath-3_2_VERSION} && rm $$i ;\
		done

.include <bsd.port.mk>
