git: 6ccc29514e16 - main - devel/binutils: Enable shared

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Wed, 15 Mar 2023 17:40:08 UTC
The branch main has been updated by cy:

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

commit 6ccc29514e16e9d9b8ccc5da9ae4e74ff93953ea
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-03-12 18:10:55 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-03-15 17:39:10 +0000

    devel/binutils: Enable shared
    
    The submittor's reason for this change is that shared libraries makes
    dependencies easier to track. However, this is not the primary reason
    to add shared library support. Shared libraries are more secure because
    should a depending package, such as binutils, require a security update
    any depending packages will immediately reap the benefit of the newly
    secured package.
    
    This change only affects the native flavor because when 2f26d37a5937
    (SVN r517642) changed the port from slave ports of binutils to FLAVORS,
    it mistakenly removed shared libraries from the native package. Prior to
    this 2f26d37a5937 only non-native packages were built producing only
    static libraries. This revision restores the behabviour of prior to
    2f26d37a5937.
    
    PR:             270146
    Reported by:    yuri
    Fixes:          2f26d37a5937 (SVN r517642)
---
 devel/binutils/Makefile  | 17 ++++++++++++++---
 devel/binutils/pkg-plist | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/devel/binutils/Makefile b/devel/binutils/Makefile
index 8b8f9a3c200d..a468d736263d 100644
--- a/devel/binutils/Makefile
+++ b/devel/binutils/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	binutils
 DISTVERSION=	2.40
-PORTREVISION=	1
+PORTREVISION=	2
 PORTEPOCH?=	1
 CATEGORIES?=	devel
 MASTER_SITES=	SOURCEWARE/binutils/releases
@@ -82,10 +82,18 @@ BUTARGET=	x86_64-unknown-${OPSYS:tl}${OSREL}
 USES+=		iconv
 .endif
 
-CONFIGURE_ARGS+=	--disable-shared \
-			--target=${BUTARGET}
+CONFIGURE_ARGS+=	--target=${BUTARGET}
 .endif
 
+.if ${FLAVOR} == native
+CONFIGURE_ARGS+=	--enable-shared
+PLIST_SUB+=		SHARED=''
+.else
+CONFIGURE_ARGS+=	--disable-shared
+PLIST_SUB+=		SHARED='@comment'
+.endif
+
+
 .if ${FLAVOR} == native
 BUREMOVE=	coffdump \
 		dlltool \
@@ -146,6 +154,9 @@ post-patch:
 
 post-install:
 .if ${FLAVOR} == native
+	@${STRIP_CMD} \
+		${STAGEDIR}${PREFIX}/lib/lib*.so* \
+		${STAGEDIR}${PREFIX}/lib/bfd-plugins/libdep.so
 	${INSTALL_DATA} ${WRKSRC}/include/plugin-api.h ${STAGEDIR}${PREFIX}/include/
 	@${FIND} -ds ${STAGEDIR}${PREFIX}/${CONFIGURE_TARGET} ! -type d | \
 		${SED} -e 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST}
diff --git a/devel/binutils/pkg-plist b/devel/binutils/pkg-plist
index 5a4e30936592..7aff2860c5ec 100644
--- a/devel/binutils/pkg-plist
+++ b/devel/binutils/pkg-plist
@@ -27,12 +27,25 @@ include/dis-asm.h
 include/sframe-api.h
 include/sframe.h
 include/symcat.h
-lib/bfd-plugins/libdep.so
+%%SHARED%%lib/bfd-plugins/libdep.so
+%%SHARED%%lib/libbfd-2.40.so
 lib/libbfd.a
+%%SHARED%%lib/libbfd.so
 lib/libctf-nobfd.a
+%%SHARED%%lib/libctf-nobfd.so
+%%SHARED%%lib/libctf-nobfd.so.0
+%%SHARED%%lib/libctf-nobfd.so.0.0.0
 lib/libctf.a
+%%SHARED%%lib/libctf.so
+%%SHARED%%lib/libctf.so.0
+%%SHARED%%lib/libctf.so.0.0.0
+%%SHARED%%lib/libopcodes-2.40.so
 lib/libopcodes.a
+%%SHARED%%lib/libopcodes.so
 lib/libsframe.a
+%%SHARED%%lib/libsframe.so
+%%SHARED%%lib/libsframe.so.0
+%%SHARED%%lib/libsframe.so.0.0.0
 man/man1/addr2line.1.gz
 man/man1/ar.1.gz
 man/man1/as.1.gz