Annotation of pkgsrc/lang/ruby/replace.mk, revision 1.12
1.12 ! minskim 1: # $NetBSD: replace.mk,v 1.11 2008/09/21 21:50:31 minskim Exp $
1.1 taca 2: #
3:
1.3 rillig 4: .if !defined(_RUBY_REPLACE_MK)
1.1 taca 5: _RUBY_REPLACE_MK= # defined
6:
1.5 rillig 7: .include "${.PARSEDIR}/rubyversion.mk"
8:
1.1 taca 9: # fix shebang line.
10: #
11: # REPLACE_RUBY replace shebang line of specified files.
1.2 taca 12: #
13: .if defined(REPLACE_RUBY)
14: REPLACE_INTERPRETER+= ${RUBY_NAME}
15:
1.7 minskim 16: REPLACE.${RUBY_NAME}.old= .*ruby[0-9]*
1.6 jlam 17: REPLACE.${RUBY_NAME}.new= ${RUBY}
18: REPLACE_FILES.${RUBY_NAME}= ${REPLACE_RUBY}
1.2 taca 19:
20: .endif # defined(REPLACE_RUBY)
21:
1.1 taca 22: # REPLACE_RUBY_DIRS replace shebang line of files under specified
1.9 jlam 23: # directories; relative paths are assumed to be
24: # under ${WRKSRC}.
1.8 taca 25: # REPLACE_RUBY_PAT specify pattern to match target files under
1.1 taca 26: # REPLACE_RUBY_DIRS directories.
27: #
1.8 taca 28: REPLACE_RUBY_PAT?= *.rb
29:
1.2 taca 30: .if defined(REPLACE_RUBY_DIRS) && !empty(REPLACE_RUBY_DIRS)
31: pre-configure: replace-ruby-dirs
1.1 taca 32:
1.8 taca 33: .for f in ${REPLACE_RUBY_PAT}
34: _REPLACE_RUBY_PAT+= -o -name "${f}"
1.1 taca 35: .endfor
1.8 taca 36: _REPLACE_RUBY_FIND_ARGS=\( ${_REPLACE_RUBY_PAT:S/-o//1} \)
1.1 taca 37:
38: replace-ruby-dirs:
1.10 taca 39: ${RUN} cd ${WRKSRC} && \
40: for d in ${REPLACE_RUBY_DIRS}; do \
1.12 ! minskim 41: if [ -d $$d ]; then \
! 42: dirs="$$dirs $$d"; \
! 43: fi; \
1.10 taca 44: done; \
45: if [ -z "$$dirs" ]; then \
46: exit 0; \
47: fi; \
48: ${FIND} $$dirs \
49: -type f ${_REPLACE_RUBY_FIND_ARGS} -print | \
1.1 taca 50: while read f; do \
1.11 minskim 51: ${SED} -e '1s|^#! *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *|#!|g' \
52: -e '1s|^#! *[a-z0-9_/\.-]*ruby|#!${RUBY}|' $$f > $$f.tmp; \
1.1 taca 53: if ${CMP} -s $$f $$f.tmp; then \
54: ${RM} $$f.tmp; \
55: else \
56: ${MV} $$f.tmp $$f; \
57: fi; \
58: done
59: .else
60: replace-ruby-dirs:
1.2 taca 61: .endif # defined(REPLACE_RUBY_DIRS)
1.1 taca 62: .endif # _RUBY_REPLACE_MK
CVSweb <webmaster@jp.NetBSD.org>