Annotation of pkgsrc/lang/ruby/replace.mk, revision 1.1
1.1 ! taca 1: # $NetBSD$
! 2: #
! 3:
! 4: .ifndef _RUBY_REPLACE_MK
! 5: _RUBY_REPLACE_MK= # defined
! 6:
! 7: # fix shebang line.
! 8: #
! 9: # REPLACE_RUBY replace shebang line of specified files.
! 10: # REPLACE_RUBY_DIRS replace shebang line of files under specified
! 11: # directories.
! 12: # REPLACE_FILE_PAT specify pattern to match target files under
! 13: # REPLACE_RUBY_DIRS directories.
! 14: #
! 15: REPLACE_FILE_PAT?= *.rb
! 16:
! 17: .if defined(REPLACE_RUBY) || defined(REPLACE_RUBY_DIRS)
! 18: pre-configure: replace-ruby-scripts replace-ruby-dirs
! 19:
! 20: .if defined(REPLACE_RUBY) && !empty(REPLACE_RUBY)
! 21: replace-ruby-scripts:
! 22: ${_PKG_SILENT}${_PKG_DEBUG}for s in ${REPLACE_RUBY}; do \
! 23: case $${s} in \
! 24: /*) f=$${s};; \
! 25: *) f=${WRKSRC}/$${s};; \
! 26: esac; \
! 27: ${ECHO_MSG} "===> Fixing the #! line of $${s}"; \
! 28: ${SED} -e '1s| *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *||g' \
! 29: -e '1s| *[a-z0-9_/\.-]*ruby|${RUBY}|' $$f > $$f.tmp; \
! 30: if ${CMP} -s $$f $$f.tmp; then \
! 31: ${RM} $$f.tmp; \
! 32: else \
! 33: ${MV} $$f.tmp $$f; \
! 34: fi; \
! 35: done
! 36: .else
! 37: replace-ruby-scripts:
! 38: .endif
! 39:
! 40: .for f in ${REPLACE_FILE_PAT}
! 41: _REPLACE_FILE_PAT+= -o -name "${f}"
! 42: .endfor
! 43: _REPLACE_FILE_FIND_ARGS=\( ${_REPLACE_FILE_PAT:S/-o//1} \)
! 44:
! 45: .if defined(REPLACE_RUBY_DIRS) && !empty(REPLACE_RUBY_DIRS)
! 46: replace-ruby-dirs:
! 47: ${_PKG_SILENT}${_PKG_DEBUG}${FIND} ${REPLACE_RUBY_DIRS} \
! 48: -type f ${_REPLACE_FILE_FIND_ARGS} -print | \
! 49: while read f; do \
! 50: ${SED} -e '1s| *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *||g' \
! 51: -e '1s| *[a-z0-9_/\.-]*ruby|${RUBY}|' $$f > $$f.tmp; \
! 52: if ${CMP} -s $$f $$f.tmp; then \
! 53: ${RM} $$f.tmp; \
! 54: else \
! 55: ${MV} $$f.tmp $$f; \
! 56: fi; \
! 57: done
! 58: .else
! 59: replace-ruby-dirs:
! 60: .endif
! 61:
! 62: .endif # defined(REPLACE_RUBY) || defined(REPLACE_RUBY_DIRS)
! 63: .endif # _RUBY_REPLACE_MK
CVSweb <webmaster@jp.NetBSD.org>