aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
authormat <mat@FreeBSD.org>2016-10-24 22:16:23 +0800
committermat <mat@FreeBSD.org>2016-10-24 22:16:23 +0800
commit9f9b3f1131e4c91d837254635959c2794ee145f3 (patch)
tree7e3b2c3fb317e61670b7531df0e4bf3cb2333853 /Mk
parentde1b307ae2f5e681760dbbccc622c206a4a40a6d (diff)
downloadfreebsd-ports-graphics-9f9b3f1131e4c91d837254635959c2794ee145f3.tar.gz
freebsd-ports-graphics-9f9b3f1131e4c91d837254635959c2794ee145f3.tar.zst
freebsd-ports-graphics-9f9b3f1131e4c91d837254635959c2794ee145f3.zip
Add SHEBANG_REGEX and SHEBANG_GLOB, similar as the DOS2UNIX ones.
Sponsored by: Absolight
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Uses/shebangfix.mk16
1 files changed, 16 insertions, 0 deletions
diff --git a/Mk/Uses/shebangfix.mk b/Mk/Uses/shebangfix.mk
index 520cec286c9..670bfa00106 100644
--- a/Mk/Uses/shebangfix.mk
+++ b/Mk/Uses/shebangfix.mk
@@ -8,6 +8,10 @@
# Feature: shebangfix
# 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_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:
#
@@ -75,7 +79,19 @@ _SHEBANG_REINPLACE_ARGS+= -e "1s|^\#![[:space:]]*${old_cmd:C/\"//g}$$|\#!${${lan
_USES_patch+= 210:fix-shebang
fix-shebang:
+.if defined(SHEBANG_REGEX)
+ @cd ${WRKSRC}; \
+ ${FIND} -E . -type f -iregex '${SHEBANG_REGEX}' \
+ -exec ${SED} -i '' ${_SHEBANG_REINPLACE_ARGS} {} +
+.elif defined(SHEBANG_GLOB)
+.for f in ${SHEBANG_GLOB}
+ @cd ${WRKSRC}; \
+ ${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}
+.endif
.endif