Index: ../../Mk/Uses/shebangfix.mk =================================================================== --- ../../Mk/Uses/shebangfix.mk (revision 439601) +++ ../../Mk/Uses/shebangfix.mk (working copy) @@ -9,13 +9,17 @@ # Usage: USES=shebangfix # # SHEBANG_REGEX a regular expression to match files that needs to be converted -# SHEBANG_FILES list of files or glob pattern relative to ${WRKSRC} +# SHEBANG_FILES_* list of files or glob pattern: +# SHEBANG_FILES_PATCH files relative to ${WRKSRC} to fix during +# the patch phase +# SHEBANG_FILES_INSTALL files relative to ${STAGEDIR}${PREFIX} to +# fix during the stage phase # SHEBANG_GLOB list of glob pattern find(1) will match with # # To specify that ${WRKSRC}/path1/file and all .pl files in ${WRKSRC}/path2 # should be processed: # -# SHEBANG_FILES= path1/file path2/*.pl +# SHEBANG_FILES_PATCH= path1/file path2/*.pl # # To define custom shebangs to replace, use the following (note that # shebangs with spaces should be quoted): @@ -78,21 +82,35 @@ . endfor .endfor -_USES_patch+= 210:fix-shebang -fix-shebang: +.if defined(SHEBANG_FILES) +# Allow original SHEBANG_FILES as a synonym for SHEBANG_FILES_PATCH. +SHEBANG_FILES_PATCH= ${SHEBANG_FILES} +.endif +.if defined(SHEBANG_FILES_PATCH) +_USES_patch+= 210:fix-shebang-patch +_SHEBANG_PATCH_DIR= ${WRKSRC} +.endif +.if defined(SHEBANG_FILES_INSTALL) +_USES_install+= 899:fix-shebang-install +_SHEBANG_INSTALL_DIR= ${STAGEDIR}${PREFIX} +.endif +_fix-shebang: .USE + echo TARGET: ${.TARGET} .if defined(SHEBANG_REGEX) - @cd ${WRKSRC}; \ + @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ ${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \ -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + .elif defined(SHEBANG_GLOB) .for f in ${SHEBANG_GLOB} - @cd ${WRKSRC}; \ + @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ ${FIND} . -type f -name '${f}' \ -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} + .endfor .else - @cd ${WRKSRC}; \ - ${ECHO_CMD} ${SHEBANG_FILES} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} + @cd ${_SHEBANG_${.TARGET:C/fix-shebang-//:tu}_DIR}; \ + ${ECHO_CMD} ${SHEBANG_FILES_${.TARGET:C/fix-shebang-//:tu}} | ${XARGS} ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} .endif +fix-shebang-install: _fix-shebang +fix-shebang-patch: _fix-shebang .endif