2007-12-13 15:46:58 +01:00
|
|
|
# $NetBSD: replace.mk,v 1.8 2007/12/13 14:46:58 taca Exp $
|
2004-11-27 14:57:20 +01:00
|
|
|
#
|
|
|
|
|
2005-12-05 21:49:47 +01:00
|
|
|
.if !defined(_RUBY_REPLACE_MK)
|
2004-11-27 14:57:20 +01:00
|
|
|
_RUBY_REPLACE_MK= # defined
|
|
|
|
|
2006-06-25 11:31:43 +02:00
|
|
|
.include "${.PARSEDIR}/rubyversion.mk"
|
|
|
|
|
2004-11-27 14:57:20 +01:00
|
|
|
# fix shebang line.
|
|
|
|
#
|
|
|
|
# REPLACE_RUBY replace shebang line of specified files.
|
2005-11-02 08:44:33 +01:00
|
|
|
#
|
|
|
|
.if defined(REPLACE_RUBY)
|
|
|
|
REPLACE_INTERPRETER+= ${RUBY_NAME}
|
|
|
|
|
2007-05-02 01:03:29 +02:00
|
|
|
REPLACE.${RUBY_NAME}.old= .*ruby[0-9]*
|
2006-07-20 15:54:44 +02:00
|
|
|
REPLACE.${RUBY_NAME}.new= ${RUBY}
|
|
|
|
REPLACE_FILES.${RUBY_NAME}= ${REPLACE_RUBY}
|
2005-11-02 08:44:33 +01:00
|
|
|
|
|
|
|
.endif # defined(REPLACE_RUBY)
|
|
|
|
|
2004-11-27 14:57:20 +01:00
|
|
|
# REPLACE_RUBY_DIRS replace shebang line of files under specified
|
|
|
|
# directories.
|
2007-12-13 15:46:58 +01:00
|
|
|
# REPLACE_RUBY_PAT specify pattern to match target files under
|
2004-11-27 14:57:20 +01:00
|
|
|
# REPLACE_RUBY_DIRS directories.
|
|
|
|
#
|
2007-12-13 15:46:58 +01:00
|
|
|
REPLACE_RUBY_PAT?= *.rb
|
|
|
|
|
2005-11-02 08:44:33 +01:00
|
|
|
.if defined(REPLACE_RUBY_DIRS) && !empty(REPLACE_RUBY_DIRS)
|
|
|
|
pre-configure: replace-ruby-dirs
|
2004-11-27 14:57:20 +01:00
|
|
|
|
2007-12-13 15:46:58 +01:00
|
|
|
.for f in ${REPLACE_RUBY_PAT}
|
|
|
|
_REPLACE_RUBY_PAT+= -o -name "${f}"
|
2004-11-27 14:57:20 +01:00
|
|
|
.endfor
|
2007-12-13 15:46:58 +01:00
|
|
|
_REPLACE_RUBY_FIND_ARGS=\( ${_REPLACE_RUBY_PAT:S/-o//1} \)
|
2004-11-27 14:57:20 +01:00
|
|
|
|
|
|
|
replace-ruby-dirs:
|
|
|
|
${_PKG_SILENT}${_PKG_DEBUG}${FIND} ${REPLACE_RUBY_DIRS} \
|
2007-12-13 15:46:58 +01:00
|
|
|
-type f ${_REPLACE_RUBY_FIND_ARGS} -print | \
|
2004-11-27 14:57:20 +01:00
|
|
|
while read f; do \
|
|
|
|
${SED} -e '1s| *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *||g' \
|
|
|
|
-e '1s| *[a-z0-9_/\.-]*ruby|${RUBY}|' $$f > $$f.tmp; \
|
|
|
|
if ${CMP} -s $$f $$f.tmp; then \
|
|
|
|
${RM} $$f.tmp; \
|
|
|
|
else \
|
|
|
|
${MV} $$f.tmp $$f; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
.else
|
|
|
|
replace-ruby-dirs:
|
2005-11-02 08:44:33 +01:00
|
|
|
.endif # defined(REPLACE_RUBY_DIRS)
|
2004-11-27 14:57:20 +01:00
|
|
|
.endif # _RUBY_REPLACE_MK
|