diff --git a/Mk/Uses/elfctl.mk b/Mk/Uses/elfctl.mk --- 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