git: 08691f29f5c8 - main - Mk/Uses/pkgconfig.mk: add support for PKGCONFIG_PATHS

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 30 Jul 2023 22:59:33 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=08691f29f5c8d5040ccdda864e174ef1db529ca3

commit 08691f29f5c8d5040ccdda864e174ef1db529ca3
Author:     Andrew "RhodiumToad" Gierth <andrew@tao11.riddles.org.uk>
AuthorDate: 2023-07-28 12:55:15 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-07-30 22:59:04 +0000

    Mk/Uses/pkgconfig.mk: add support for PKGCONFIG_PATHS
    
    USES=pkgconfig now allows you to specify PKGCONFIG_PATHS to allow
    management of PKG_CONFIG_PATHS in a cooperative fashion.
    
    PR:             260960
    Reported by:    Martin Neubauer <m.ne@gmx.net>
    Approved by:    bofh
    Differential Revision:  https://reviews.freebsd.org/D40194
---
 Mk/Uses/pkgconfig.mk | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Mk/Uses/pkgconfig.mk b/Mk/Uses/pkgconfig.mk
index 499be51f1336..671a4f0608c1 100644
--- a/Mk/Uses/pkgconfig.mk
+++ b/Mk/Uses/pkgconfig.mk
@@ -28,4 +28,20 @@ RUN_DEPENDS+=	${_PKGCONFIG_DEPENDS}
 IGNORE=	USES=pkgconfig - invalid args: [${pkgconfig_ARGS}] specified
 .  endif
 
+_USES_POST+= pkgconfig
+.endif
+
+.if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PKGCONFIG_POST_MK)
+_INCLUDE_USES_PKGCONFIG_POST_MK=yes
+
+# Provide a cooperative mechanism for managing PKG_CONFIG_PATH.
+.  if defined(PKGCONFIG_PATHS)
+.    if !${CONFIGURE_ENV:MPKG_CONFIG_PATH=*} && !${MAKE_ENV:MPKG_CONFIG_PATH=*}
+CONFIGURE_ENV+=	PKG_CONFIG_PATH=${PKGCONFIG_PATHS:ts:}
+MAKE_ENV+=	PKG_CONFIG_PATH=${PKGCONFIG_PATHS:ts:}
+.    else
+DEV_WARNING+=	"PKGCONFIG_PATHS was ignored due to conflict with CONFIGURE_ENV or MAKE_ENV"
+.    endif
+.  endif
+
 .endif