git: d5dd5e79d2ad - main - devel/libepoll-shim: Add i386 flavor, which only installs 32-bit libraries

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Thu, 30 Jan 2025 12:48:02 UTC
The branch main has been updated by arrowd:

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

commit d5dd5e79d2ad105f20949e9d749f15a207db3683
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2025-01-26 16:13:23 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2025-01-30 12:47:45 +0000

    devel/libepoll-shim: Add i386 flavor, which only installs 32-bit libraries
    
    It is going to be used by 32-bit pieces of emulators/libc6-shim
    
    Approved by:    manu (via IRC)
    Differential Revision: https://reviews.freebsd.org/D48692
---
 devel/libepoll-shim/Makefile       | 21 ++++++++++++++++++++-
 devel/libepoll-shim/pkg-plist.i386 |  7 +++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/devel/libepoll-shim/Makefile b/devel/libepoll-shim/Makefile
index 3d1def668d12..fd2f263550d8 100644
--- a/devel/libepoll-shim/Makefile
+++ b/devel/libepoll-shim/Makefile
@@ -10,6 +10,11 @@ WWW=		https://github.com/jiixyj/epoll-shim
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
+FLAVORS=	default i386
+FLAVOR?=	${FLAVORS:[1]}
+i386_PKGNAMESUFFIX=	-i386
+i386_PLIST=	${.CURDIR}/pkg-plist.i386
+
 USES=		cmake compiler:c11
 USE_LDCONFIG=	yes
 USE_GITHUB=	yes
@@ -18,6 +23,20 @@ GH_PROJECT=	epoll-shim
 PLIST_SUB=	SHIM_EVENTFD="${exists(/usr/include/sys/eventfd.h):?@comment :}" \
 	SHIM_TIMERFD="${exists(/usr/include/sys/timerfd.h):?@comment :}"
 
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} != amd64 && ${FLAVOR:U} == i386
+IGNORE=		i386 flavor only makes sense for amd64 arch
+.endif
+
+.if ${FLAVOR:U} == i386
+CFLAGS+=	-m32
+CMAKE_ARGS+=	-DCMAKE_INSTALL_LIBDIR=lib32
+
+post-stage:
+	${RM} -r ${STAGEDIR}${PREFIX}/include ${STAGEDIR}${PREFIX}/libdata
+.endif
+
 do-test:
 	# Exclude certain tests in resource restricted environments
 	@(if [ `ulimit -n` -lt 20100 ]; then \
@@ -32,4 +51,4 @@ do-test:
 	cd ${TEST_WRKSRC} && \
 	${SETENV} ${TEST_ENV} ctest -C ${CMAKE_BUILD_TYPE} $$SKIP_TESTS)
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff --git a/devel/libepoll-shim/pkg-plist.i386 b/devel/libepoll-shim/pkg-plist.i386
new file mode 100644
index 000000000000..3814619a2833
--- /dev/null
+++ b/devel/libepoll-shim/pkg-plist.i386
@@ -0,0 +1,7 @@
+lib32/cmake/epoll-shim/epoll-shim-config.cmake
+lib32/cmake/epoll-shim/epoll-shim-targets-%%CMAKE_BUILD_TYPE%%.cmake
+lib32/cmake/epoll-shim/epoll-shim-targets.cmake
+lib32/libepoll-shim-interpose.so
+lib32/libepoll-shim-interpose.so.0
+lib32/libepoll-shim.so
+lib32/libepoll-shim.so.0