git: 9f41e650f564 - main - graphics/mesa: Fix port when elfutils is installed

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 04 Dec 2023 08:55:10 UTC
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9f41e650f5645f1e50d8e51eb53ea231ff9f5149

commit 9f41e650f5645f1e50d8e51eb53ea231ff9f5149
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2023-12-04 08:51:25 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2023-12-04 08:55:01 +0000

    graphics/mesa: Fix port when elfutils is installed
    
    By default when building in a clean env (i.e. poudriere) libelf from base
    will be used.
    When building with an unclean env and if devel/elfutils is installed build
    system will be confused and use libelf headers from ${LOCALBASE}/include but
    libelf from base.
    
    Fix this.
    
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
    PR:             275388
---
 graphics/mesa-dri/Makefile.common | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/graphics/mesa-dri/Makefile.common b/graphics/mesa-dri/Makefile.common
index 9c76d24a46a9..aee858a5e9d2 100644
--- a/graphics/mesa-dri/Makefile.common
+++ b/graphics/mesa-dri/Makefile.common
@@ -81,6 +81,14 @@ BINARY_ALIAS+=	python3=${PYTHON_VERSION}
 
 CONFIGURE_ENV+=	LLVM_CONFIG=${LLVM_CONFIG}
 
+# Deal with unclean env if the user have elfutils installed
+# and build the port directly without poudriere
+.if exists(${LOCALBASE}/include/libelf.h)
+LIB_DEPENDS+=	libelf.so:devel/elfutils
+MESON_ARGS+=	-Dlibelf=enabled
+.else
+MESON_ARGS+=	-Dlibelf=disabled
+.endif
 
 # Some symbols in mesa's linker version scripts are not always defined,
 # depending on configuration options. Suppress errors with lld >= 17 due to
@@ -89,5 +97,4 @@ LDFLAGS+=	-Wl,--undefined-version
 
 LDFLAGS+=	-Wl,-rpath=${LOCALBASE}/llvm${LLVM_VERSION}/lib
 MESON_ARGS+=	-Dllvm=enabled \
-		-Dlibunwind=disabled \
-		-Dlibelf=disabled
+		-Dlibunwind=disabled