git: b3ef01b8ab07 - main - science/cdf: improve and lint port

From: Älven <alven_at_FreeBSD.org>
Date: Mon, 08 Sep 2025 22:11:43 UTC
The branch main has been updated by alven:

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

commit b3ef01b8ab07f156d286b07eb393f60faacb2308
Author:     Älven <alven@FreeBSD.org>
AuthorDate: 2025-09-08 22:10:43 +0000
Commit:     Älven <alven@FreeBSD.org>
CommitDate: 2025-09-08 22:10:52 +0000

    science/cdf: improve and lint port
    
    * Lint and sort Makefile according to portclippy(1)
    * Mark as PIE_UNSAFE
    * Split post-install stance to respect DOCS and EXAMPLES options
    * Strip installed binaries and libs
    * Use dynamic SOVERSION via PLIST_SUB
    
    Approved by:    yuri@ (Mentor)
    
    Differential Revision: https://reviews.freebsd.org/D52408
---
 science/cdf/Makefile  | 30 ++++++++++++++++++++----------
 science/cdf/pkg-plist |  2 +-
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/science/cdf/Makefile b/science/cdf/Makefile
index f1b4b8b150c5..6b516cd72448 100644
--- a/science/cdf/Makefile
+++ b/science/cdf/Makefile
@@ -1,9 +1,10 @@
 PORTNAME=	cdf3
 DISTVERSION=	3.9.1
+PORTREVISION=	1
 CATEGORIES=	science
 MASTER_SITES=	https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf39_1/
 DISTNAME=	cdf${VER}-dist-cdf
-DIST_SUBDIR=	${PORTNAME}-${PORTVERSION}
+DIST_SUBDIR=	${PORTNAME}-${DISTVERSION}
 
 MAINTAINER=	alven@FreeBSD.org
 COMMENT=	Device independent view of the CDF data model
@@ -16,25 +17,28 @@ LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
 
 BUILD_DEPENDS=	bash:shells/bash
 
-USES=		fortran ncurses gmake
-
+USES=		fortran gmake ncurses
 USE_LDCONFIG=	yes
+
+MAKE_ARGS+=	OS=freebsd ENV=gnu all
 MAKE_FLAGS=	INSTALLDIR=${STAGEDIR}${PREFIX} OS=freebsd ENV=gnu \
 		FORTRAN=yes FC_freebsd=${F77}
 MAKE_JOBS_UNSAFE=	yes
-TEST_TARGET=	test  # XXX: test segfaults
+TEST_TARGET=	test
+
+PIE_UNSAFE=	yes
 
-WRKSRC=		${WRKDIR}/cdf${VER}-dist
 SUB_FILES=	pkg-message
 
-VER=		${PORTVERSION:S/.//:S/./_/}
-DEFS=		B C K
+WRKSRC=		${WRKDIR}/cdf${VER}-dist
 
+PLIST_SUB=	SOVERSION=${DISTVERSION}
 PORTDOCS=	CDF_copyright.txt CHANGES.txt Release.notes Welcome.txt
 
 OPTIONS_DEFINE=	DOCS EXAMPLES
 
-MAKE_ARGS+=	OS=freebsd ENV=gnu all
+DEFS=		B C K
+VER=		${PORTVERSION:S/.//:S/./_/}
 
 .include <bsd.port.pre.mk>
 
@@ -49,11 +53,17 @@ post-patch:
 .endfor
 
 post-install:
+	${SED} -i '' 's,${STAGEDIR},,g' ${STAGEDIR}${PREFIX}/bin/definitions.?
+	${RM} -f ${STAGEDIR}${PREFIX}/CDFLeapSeconds.txt
+	cd ${STAGEDIR}${PREFIX} && \
+		${FIND} bin/* lib/* -executable -exec ${STRIP_CMD} {} \;
+
+post-install-DOCS-on:
 	${MKDIR} ${STAGEDIR}${DOCSDIR}
 	${INSTALL_DATA} ${PORTDOCS:S|^|${WRKSRC}/|} ${STAGEDIR}${DOCSDIR}
+
+post-install-EXAMPLES-on:
 	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
 	${INSTALL_DATA} ${WRKSRC}/samples/* ${STAGEDIR}${EXAMPLESDIR}
-	${SED} -i '' 's,${STAGEDIR},,g' ${STAGEDIR}${PREFIX}/bin/definitions.?
-	${RM} -f ${STAGEDIR}${PREFIX}/CDFLeapSeconds.txt
 
 .include <bsd.port.post.mk>
diff --git a/science/cdf/pkg-plist b/science/cdf/pkg-plist
index 177ca8658467..24910333ac66 100644
--- a/science/cdf/pkg-plist
+++ b/science/cdf/pkg-plist
@@ -50,9 +50,9 @@ lib/cdf/help/cdfvalidatej.olh
 lib/cdf/help/cdfxp.ilh
 lib/cdf/help/skt2cdf.olh
 lib/cdf/help/skt2cdfj.olh
-lib/libcdf.3.9.1.so
 lib/libcdf.a
 lib/libcdf.so
+lib/libcdf.%%SOVERSION%%.so
 %%PORTEXAMPLES%%%%EXAMPLESDIR%%/OperateAttributes.c
 %%PORTEXAMPLES%%%%EXAMPLESDIR%%/OperateCDF.c
 %%PORTEXAMPLES%%%%EXAMPLESDIR%%/OperateVariables.c