PORTNAME=	oneVPL
DISTVERSIONPREFIX=	v
DISTVERSION=	2022.1.5
PORTREVISION=	1
CATEGORIES=	multimedia

MAINTAINER=	ports@FreeBSD.org
COMMENT=	oneAPI Video Processing Library dispatcher, tools, and examples
WWW=		https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onevpl.html

LICENSE=	MIT
LICENSE_FILE=	${WRKSRC}/LICENSE

DEPRECATED=	Upstream has been renamed to libvpl and libvpl-tools. Use multimedia/libvpl and multimedia/libvpl-tools instead.
EXPIRATION_DATE=	2026-09-30

ONLY_FOR_ARCHS=	amd64
ONLY_FOR_ARCHS_REASON=	only Intel GPUs on x86 are supported

BUILD_DEPENDS=	wayland-protocols>0:graphics/wayland-protocols
LIB_DEPENDS=	libdrm.so:graphics/libdrm \
		libva.so:multimedia/libva \
		libwayland-client.so:graphics/wayland

USES=		cmake:testing compiler:c++14-lang localbase:ldflags pkgconfig \
		xorg
USE_CXXSTD=	c++14
USE_GITHUB=	yes
GH_ACCOUNT=	oneapi-src
USE_LDCONFIG=	yes
USE_XORG=	x11 xcb

CMAKE_TESTING_ON=	BUILD_TESTS
CONFLICTS_INSTALL=      libvpl
DATADIR=	${PREFIX}/share/vpl

OPTIONS_DEFINE=		PYTHON
OPTIONS_DEFAULT=	PYTHON
OPTIONS_SUB=		yes

PYTHON_BUILD_DEPENDS=	pybind11>0:devel/pybind11
PYTHON_USES=		python
PYTHON_CMAKE_BOOL=	BUILD_PYTHON_BINDING
PYTHON_CMAKE_ON=	-DPython3_EXECUTABLE:FILEPATH="${PYTHON_CMD}"

post-patch:
	@${REINPLACE_CMD} -e '/pkgconfig/s,FULL_LIBDIR},PREFIX}/libdata,' \
		${WRKSRC}/dispatcher/CMakeLists.txt
	@${REINPLACE_CMD} -e 's,/usr,${PREFIX},' \
		${WRKSRC}/dispatcher/vpl/mfx_dispatcher_vpl_loader.cpp
	@${REINPLACE_CMD} -e '/PKG_CONFIG/s,_lib,_prefix/libdata,' \
		${WRKSRC}/modulefiles/vpl

post-patch-PYTHON-on:
	@${REINPLACE_CMD} -e '/LIBDIR/s/python/&${PYTHON_VER}/' \
		${WRKSRC}/preview/python/binding/CMakeLists.txt

post-install:
	@${FIND} ${STAGEDIR} -name \*.orig -delete

.include <bsd.port.mk>
