# Created by: gahr
# $FreeBSD: head/graphics/libosmesa/Makefile 443828 2017-06-18 14:02:35Z rezny $

PORTNAME=	libosmesa
PORTVERSION=	${MESAVERSION}
CATEGORIES=	graphics

COMMENT=	Off-Screen Mesa implementation of the OpenGL API

USE_XORG=	glproto

# As of version 17.0.5 / 17.1.2, the Gallium variant fails to build due to
# incorrectly ordered linker flags. Fortunately, autoreconf fixes the problem.
# Unfortunately, we must reconf before we know if we're doing a Gallium build.
USES=		autoreconf
EXTRA_PATCHES=	${PATCHDIR}/configure.ac

.include <bsd.port.options.mk>
.include "${.CURDIR:H:H}/graphics/mesa-dri/Makefile.common"

CONFIGURE_ARGS+=	--disable-dri --disable-egl --disable-gbm \
			--disable-gles2 --with-gallium-drivers=swrast
MESA_BUILD_WRKSRC=	src/util src/compiler src/mapi src/mesa

.if "${MESA_LLVM_VER}" != ""
CONFIGURE_ARGS+=	--enable-osmesa-gallium
MESA_BUILD_WRKSRC+=	src/gallium
MESA_INSTALL_WRKSRC=	src/gallium/state_trackers/osmesa src/gallium/targets/osmesa
.else
CONFIGURE_ARGS+=	--enable-osmesa
MESA_INSTALL_WRKSRC=	src/mesa/drivers/osmesa
.endif

.include "${MASTERDIR}/Makefile.targets"

post-install:
	@${MKDIR} ${STAGEDIR}${PREFIX}/include/GL
	${INSTALL_DATA} ${WRKSRC}/include/GL/osmesa.h \
		${STAGEDIR}${PREFIX}/include/GL

.include <bsd.port.post.mk>
