aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Mk/bsd.ruby.mk14
1 files changed, 14 insertions, 0 deletions
diff --git a/Mk/bsd.ruby.mk b/Mk/bsd.ruby.mk
index 0a8ff702ed13..3908f7759fc8 100644
--- a/Mk/bsd.ruby.mk
+++ b/Mk/bsd.ruby.mk
@@ -26,6 +26,7 @@ Ruby_Include_MAINTAINER= knu@FreeBSD.org
# RUBY_SETUP - Set to the alternative name of setup.rb (default: setup.rb).
# USE_RUBY_AMSTD - Says that the port uses amstd for building and running.
# USE_RUBY_RD - Says that the port uses rd to generate documents.
+# RUBY_SHEBANG_FILES - Specify the files which shebang lines you want to fix.
#
# [variables that each port should not define]
#
@@ -114,6 +115,19 @@ PLIST_SUB+= RUBY_VERSION="${RUBY_VERSION}" \
RUBY_NAME="${RUBY_NAME}" \
${PLIST_RUBY_DIRS:S,DIR="${LOCALBASE}/,DIR=",}
+# fix shebang lines
+.if defined(RUBY_SHEBANG_FILES) && !empty(RUBY_SHEBANG_FILES)
+USE_RUBY= yes
+
+post-patch: ruby-shebang-patch
+
+ruby-shebang-patch:
+ @for f in ${RUBY_SHEBANG_FILES}; do \
+ ${ECHO_MSG} "===> Fixing the #! line of $$f"; \
+ ${RUBY} -i -pe '$$. == 1 and sub /^#!\s*\S*(\benv\s+)?\bruby/, "#!${RUBY}"' $$f; \
+ done
+.endif
+
# extconf.rb
.if defined(USE_RUBY_EXTCONF)
USE_RUBY= yes