git: 7a0d64f7840e - main - Mk/Uses/elfctl.mk: Add `build` and `stage` arguments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 05 Jan 2025 13:50:49 UTC
The branch main has been updated by jrm:
URL: https://cgit.FreeBSD.org/ports/commit/?id=7a0d64f7840e94f000f3cacbd959147d54cfe37b
commit 7a0d64f7840e94f000f3cacbd959147d54cfe37b
Author: Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2025-01-04 22:11:25 +0000
Commit: Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2025-01-05 13:50:45 +0000
Mk/Uses/elfctl.mk: Add `build` and `stage` arguments
Introduce new arguments, `build` and `stage`, to control the location
and timing of ELF feature flag modifications.
Files listed in ELF_FEATURES are interpreted as relative to:
- ${BUILD_WRKSRC} when the `build` argument is supplied
- ${STAGEDIR} when the `stage` argument is supplied
Operating on binaries under ${STAGEDIR} is useful when binaries are
modified after the build phase. Conversely, working with binaries under
${BUILD_WRKSRC} is preferable when test targets are run against the
build tree.
Reviewed by: arrowd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48324
---
Mk/Uses/elfctl.mk | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/Mk/Uses/elfctl.mk b/Mk/Uses/elfctl.mk
index 442f13db596f..446a57c43425 100644
--- a/Mk/Uses/elfctl.mk
+++ b/Mk/Uses/elfctl.mk
@@ -1,26 +1,39 @@
-# Change an ELF binary's feature control note
+# Set ELF binary feature control notes
#
# Feature: elfctl
-# Usage: USES=elfctl
-# Valid ARGS: none
+# Usage: USES=elfctl or USES=elfctl:ARGS
+# Valid ARGS: build (default, implicit), stage
#
-# Variables
+# Files listed in ELF_FEATURES are relative to:
+# - ${BUILD_WRKSRC} when the `build` argument is supplied
+# - ${STAGEDIR} when the `stage` argument is supplied.
#
-# ELF_FEATURES= featurelist:path/to/file1 \
-# featurelist:path/to/file1 \
- featurelist:path/to/file2
+# Variables:
#
-# The file paths listed in ELF_FEATURES are relative to ${BUILD_WRKSRC}.
+# ELF_FEATURES= featurelist:path/to/file1 \
+# featurelist:path/to/file2
#
.if !defined(_INCLUDE_USES_ELFCTL_MK)
_INCLUDE_USES_ELFCTL_MK= yes
-. if ! empty(ELF_FEATURES)
-_USES_build+= 720:elfctl-post-build
-elfctl-post-build:
+. if empty(elfctl_ARGS)
+elfctl_ARGS= build
+. endif
+
+. if ${elfctl_ARGS} == "build"
+_ELFCTL_TOPDIR= ${BUILD_WRKSRC}
+. elif ${elfctl_ARGS} == "stage"
+_ELFCTL_TOPDIR= ${STAGEDIR}
+. else
+IGNORE= USES=elfctl - invalid args: [${elfctl_ARGS}] specified
+. endif
+
+. if !empty(ELF_FEATURES)
+_USES_${elfctl_ARGS}+= 720:elfctl-post-${elfctl_ARGS}
+elfctl-post-${elfctl_ARGS}:
. for feat in ${ELF_FEATURES}
- ${ELFCTL} -i -e ${feat:C/:.*//} ${BUILD_WRKSRC}/${feat:C/.*://}
+ ${ELFCTL} -i -e ${feat:C/:.*//} ${_ELFCTL_TOPDIR}/${feat:C/.*://}
. endfor
. endif