git: 682808b321a3 - main - Mk/bsd.port.mk: Setup SHLIB_PROVIDE_PATHS* vars for pkg

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Thu, 06 Mar 2025 11:08:39 UTC
The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=682808b321a3d0313deb97f9fd9ac72754d4d93a

commit 682808b321a3d0313deb97f9fd9ac72754d4d93a
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2025-02-26 15:19:08 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2025-03-06 11:08:34 +0000

    Mk/bsd.port.mk: Setup SHLIB_PROVIDE_PATHS* vars for pkg
    
    This changes picks a new pkg feature: https://github.com/freebsd/pkg/pull/2422
    
    The idea behind the `.if ${LINUX_DEFAULT} ...` check comes from the Linux
    ld.so(8) man page that says
    
    > (5)  In the default path /lib, and then /usr/lib.  (On some 64-bit
    >      architectures, the default paths for 64-bit shared objects
    >      are /lib64, and then /usr/lib64.)
    
    CentOS 7 and Rocky Linux 9 that we have in Ports install 32 bit libraries
    into `/usr/lib` and 64 bit libraries into `/usr/lib64`. `/lib` and `/lib64` are
    symlinks, so I omitted them.
    
    Differential Revision: https://reviews.freebsd.org/D49136
    Approved by:    bapt
---
 Mk/bsd.port.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 4063193af49b..32752e31b2e6 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1882,6 +1882,18 @@ USE_LDCONFIG=	${PREFIX}/lib
 IGNORE=			has USE_LDCONFIG32 set to yes, which is not correct
 .    endif
 
+_ALL_LIB_DIRS=	${LIB_DIRS} ${USE_LDCONFIG}
+PKG_ENV+=	SHLIB_PROVIDE_PATHS_NATIVE="${_ALL_LIB_DIRS:O:u:ts,}"
+.    if defined(HAVE_COMPAT_IA32_KERN)
+PKG_ENV+=	SHLIB_PROVIDE_PATHS_COMPAT_32="/usr/lib32,${LOCALBASE}/lib32"
+.    endif
+.    if ${LINUX_DEFAULT} == c7 || ${LINUX_DEFAULT} == rl9
+PKG_ENV+=	SHLIB_PROVIDE_PATHS_COMPAT_LINUX="${LINUXBASE}/usr/lib64"
+PKG_ENV+=	SHLIB_PROVIDE_PATHS_COMPAT_LINUX_32="${LINUXBASE}/usr/lib"
+.    else
+.      warning "Unknown Linux distribution ${LINUX_DEFAULT}, SHLIB_PROVIDE_PATHS_COMPAT_LINUX will not be set!"
+.    endif
+
 .    if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
 .      if defined(USE_LINUX_PREFIX)
 PLIST_FILES+=	"@ldconfig-linux ${LINUXBASE}"