Annotation of pkgsrc/lang/ruby/replace.mk, revision 1.9

1.9     ! jlam        1: # $NetBSD: replace.mk,v 1.8 2007/12/13 14:46:58 taca 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.9     ! jlam       39:        ${RUN} cd ${WRKSRC} && ${FIND} ${REPLACE_RUBY_DIRS} \
1.8       taca       40:            -type f ${_REPLACE_RUBY_FIND_ARGS} -print | \
1.1       taca       41:            while read f; do \
                     42:                ${SED}  -e '1s| *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *||g' \
                     43:                        -e '1s| *[a-z0-9_/\.-]*ruby|${RUBY}|' $$f > $$f.tmp; \
                     44:                if ${CMP} -s $$f $$f.tmp; then \
                     45:                        ${RM} $$f.tmp; \
                     46:                else \
                     47:                        ${MV} $$f.tmp $$f; \
                     48:                fi; \
                     49:            done
                     50: .else
                     51: replace-ruby-dirs:
1.2       taca       52: .endif # defined(REPLACE_RUBY_DIRS)
1.1       taca       53: .endif # _RUBY_REPLACE_MK

CVSweb <webmaster@jp.NetBSD.org>