git: ccc21de09381 - main - devel/binutils: Add devel/elfutils dependency options

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Wed, 28 Aug 2024 16:03:05 UTC
The branch main has been updated by cy:

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

commit ccc21de09381b5fc0e19980d69c0d1ee2bde84de
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-09-17 01:40:57 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2024-08-28 15:56:33 +0000

    devel/binutils: Add devel/elfutils dependency options
    
    Currently binutils auto-discovers libdebuginfod.so existence in
    $LOCALBASE and if found, it will use it. This doesn't matter when
    building under poudriere because devel/elfutils is never
    pre-installed as a dependency.
    
    However users building binutils on systems with a pre-installed
    devel/elfutils will discover that binutils will auto-detect the
    existence of libdebuginfod.so and use it. This is not always desired.
    Therefore add an option so that users who build binuitls by hand
    can optionally force binutils not to detect or use libdebuginfod.so.
    
    On the flip side other users may want to depend on devel/elfutils and
    have the ports infrastructure preinstall it for them.
    
    The default option is to auto-detect and depend on devel/elfutils if
    found.
    
    PR:             273798
---
 devel/binutils/Makefile | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/devel/binutils/Makefile b/devel/binutils/Makefile
index ea2124ab2344..059ccaa36a8e 100644
--- a/devel/binutils/Makefile
+++ b/devel/binutils/Makefile
@@ -50,8 +50,10 @@ LDFLAGS+=	-Wl,--undefined-version
 CONFLICTS=	libbfd
 
 OPTIONS_DEFINE=	INFO NLS RELRO
-OPTIONS_DEFAULT=	INFO
+OPTIONS_DEFAULT=	ELFU_AUTO INFO
 OPTIONS_EXCLUDE=	NLS
+OPTIONS_RADIO=	ELFUTILS_ENABLE
+OPTIONS_RADIO_ELFUTILS_ENABLE=	ELFU_AUTO ELFU_YES ELFU_NO
 OPTIONS_SUB=	yes
 
 INFO_EXTRA_PATCHES_OFF=	${PATCHDIR}/extra-patch-no-info
@@ -61,6 +63,12 @@ NLS_CONFIGURE_ENABLE=	nls
 RELRO_CONFIGURE_ON=	--enable-relro
 RELRO_CONFIGURE_OFF=	--enable-relro=no
 RELRO_DESC=	Enable relocation memory corruption mitigation (-z relro) by default
+NLS_CONFIGURE_ENABLE=	nls
+ELFU_AUTO_DESC=	Auto-detect pre-installed devel/elfutils
+ELFU_YES_DESC=	Depend on and install devel/elfutils
+ELFU_YESLIB_DEPENDS=	libdebuginfod.so:devel/elfutils
+ELFU_NO_DESC=	Ingore pre-installed devel/elfutils
+ELFU_NO_CONFIGURE_ON=	--without-libelf --without-debuginfod
 
 aarch64_COMMENT=	GNU binutils for ${FLAVOR} development
 
@@ -128,6 +136,11 @@ INFO_INFO=	as \
 
 .include <bsd.port.pre.mk>
 
+# In case devel/elfutils has been previously installed.
+.if ${PORT_OPTIONS:MELFU_AUTO} && exists(${LOCALBASE}/lib/libdebuginfod.so)
+LIB_DEPENDS+=	libdebuginfod.so:devel/elfutils
+.endif
+
 # Actual earliest version may differ slightly
 .if (${ARCH} != mips && ${ARCH} != mips64 && ${ARCH} != powerpcspe && ${ARCH} != powerpc && ${ARCH} != powerpc64 && ${ARCH} != riscv64 && !defined(PKGNAMEPREFIX)) || ((${ARCH} == powerpc || ${ARCH} == powerpc64) && ${CHOSEN_COMPILER_TYPE} != gcc && !defined(PKGNAMEPREFIX))
 CONFIGURE_ARGS+=	--enable-gold --enable-plugins