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

1.10    ! taca        1: # $NetBSD: replace.mk,v 1.9 2008/03/17 20:57:04 jlam 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 \
        !            41:                test -d $$d && dirs="$$dirs $$d"; \
        !            42:            done; \
        !            43:            if [ -z "$$dirs" ]; then \
        !            44:                exit 0; \
        !            45:            fi; \
        !            46:            ${FIND} $$dirs \
        !            47:                -type f ${_REPLACE_RUBY_FIND_ARGS} -print | \
1.1       taca       48:            while read f; do \
                     49:                ${SED}  -e '1s| *[a-z0-9_/\.-][a-z0-9_/\.-]*/env *||g' \
                     50:                        -e '1s| *[a-z0-9_/\.-]*ruby|${RUBY}|' $$f > $$f.tmp; \
                     51:                if ${CMP} -s $$f $$f.tmp; then \
                     52:                        ${RM} $$f.tmp; \
                     53:                else \
                     54:                        ${MV} $$f.tmp $$f; \
                     55:                fi; \
                     56:            done
                     57: .else
                     58: replace-ruby-dirs:
1.2       taca       59: .endif # defined(REPLACE_RUBY_DIRS)
1.1       taca       60: .endif # _RUBY_REPLACE_MK

CVSweb <webmaster@jp.NetBSD.org>