PORTNAME=	bullet
PORTVERSION=	3.25
CATEGORIES=	devel

MAINTAINER=	fluffy@FreeBSD.org
COMMENT=	3D collision detection and rigid body dynamics library
WWW=		https://www.bulletphysics.com/

LICENSE=	ZLIB
LICENSE_FILE=	${WRKSRC}/LICENSE.txt

FLAVORS=	single double
FLAVOR?=	${FLAVORS:[1]}

double_PKGNAMESUFFIX=	-double

single_CONFLICTS_INSTALL=${PORTNAME}-double
double_CONFLICTS_INSTALL=${PORTNAME}

USES=		cmake compiler:c++11-lang gl xorg
USE_GL=		gl glu glut
USE_LDCONFIG=	yes
USE_XORG=	x11

USE_GITHUB=	yes
GH_ACCOUNT=	bulletphysics
GH_PROJECT=	bullet3

CMAKE_ON=	BUILD_BULLET3 BUILD_SHARED_LIBS INSTALL_LIBS \
		BUILD_EXTRAS INSTALL_EXTRA_LIBS \
		BULLET2_MULTITHREADING
CMAKE_OFF=	BUILD_CPU_DEMOS BUILD_BULLET2_DEMOS BUILD_BULLET3_DEMOS \
		BUILD_OPENGL3_DEMOS BUILD_PYBULLET BUILD_UNIT_TESTS \
		BULLET2_USE_TBB_MULTITHREADING ENABLE_VHACD \
		BUILD_BULLET_ROBOTICS_EXTRA BUILD_BULLET_ROBOTICS_GUI_EXTRA \
		USE_GRAPHICAL_BENCHMARK
# List available knobs for Extras
#		BUILD_HACD_EXTRA BUILD_OBJ2SDF_EXTRA BUILD_BULLET_ROBOTICS_EXTRA \
#		BUILD_SERIALIZE_EXTRA BUILD_INVERSE_DYNAMIC_EXTRA \
#		BUILD_CONVEX_DECOMPOSITION_EXTRA BUILD_GIMPACTUTILS_EXTRA

.if ${FLAVOR} == double
CMAKE_ON+=	USE_DOUBLE_PRECISION
.endif

PORTDOCS=	*

OPTIONS_DEFINE=	DOCS

PLIST_SUB=	LIB_VERSION=${PORTVERSION}

.if !exists(/usr/include/omp.h)
CMAKE_OFF+=	BULLET2_USE_OPEN_MP_MULTITHREADING
.else
CMAKE_ON+=	BULLET2_USE_OPEN_MP_MULTITHREADING
.endif

post-patch:
	@${RM} -r ${WRKSRC}/examples/pybullet

post-install-DOCS-on:
	@${MKDIR} ${STAGEDIR}/${DOCSDIR}
	${INSTALL_DATA} ${WRKSRC}/docs/*.pdf ${STAGEDIR}/${DOCSDIR}

.include <bsd.port.mk>
