diff options
author | rillig <rillig@pkgsrc.org> | 2006-07-15 09:52:00 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2006-07-15 09:52:00 +0000 |
commit | 69811464e9e1ce04734bbdc55effe60929659733 (patch) | |
tree | 4924a03e164d36c77aab713f915fecdb4e78c5da /mk/configure | |
parent | 927385d0c21b890bca7762eb17824325c1bcffec (diff) | |
download | pkgsrc-69811464e9e1ce04734bbdc55effe60929659733.tar.gz |
Added some common script interpreters (awk, bash, sh) that can be
replaced automatically by defining REPLACE_AWK, REPLACE_BASH or
REPLACE_SH and an appropriate addition to USE_TOOLS.
The replace-interpreter.mk file is included unconditionally because the
number of variables that would trigger the inclusion of this file is
quite large.
Diffstat (limited to 'mk/configure')
-rw-r--r-- | mk/configure/configure.mk | 6 | ||||
-rw-r--r-- | mk/configure/replace-interpreter.mk | 100 |
2 files changed, 82 insertions, 24 deletions
diff --git a/mk/configure/configure.mk b/mk/configure/configure.mk index bc3d99128d9..d7ead1ea5fd 100644 --- a/mk/configure/configure.mk +++ b/mk/configure/configure.mk @@ -1,4 +1,4 @@ -# $NetBSD: configure.mk,v 1.4 2006/07/07 21:24:28 jlam Exp $ +# $NetBSD: configure.mk,v 1.5 2006/07/15 09:52:00 rillig Exp $ # # CONFIGURE_SCRIPT is the path to the script to run in order to # configure the software for building. If the path is relative, @@ -28,9 +28,7 @@ BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS .if defined(PKGCONFIG_OVERRIDE) . include "${PKGSRCDIR}/mk/configure/pkg-config-override.mk" .endif -.if defined(REPLACE_INTERPRETER) || defined(REPLACE_PERL) -. include "${PKGSRCDIR}/mk/configure/replace-interpreter.mk" -.endif +.include "${PKGSRCDIR}/mk/configure/replace-interpreter.mk" .if defined(USE_PKGLOCALEDIR) . include "${PKGSRCDIR}/mk/configure/replace-localedir.mk" .endif diff --git a/mk/configure/replace-interpreter.mk b/mk/configure/replace-interpreter.mk index a82d1cc3cf2..a07771727e0 100644 --- a/mk/configure/replace-interpreter.mk +++ b/mk/configure/replace-interpreter.mk @@ -1,4 +1,33 @@ -# $NetBSD: replace-interpreter.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $ +# $NetBSD: replace-interpreter.mk,v 1.2 2006/07/15 09:52:00 rillig Exp $ + +# This file provides common templates for replacing #! interpreters +# in script files. +# +# The following variables may be set by a package: +# +# REPLACE_AWK : List of Pathmask (default: none) +# REPLACE_BASH : List of Pathmask (default: none) +# REPLACE_PERL : List of Pathmask (default: none) +# REPLACE_SH : List of Pathmask (default: none) +# In these files the interpreter in the first line is replaced +# with the one that is available in pkgsrc. If any directory names +# appear in the lists, they are silenty skipped, assuming that +# they result from shell globbing expressions. +# +# Use REPLACE_SH for shell programs that don't need any +# special features from bash, and REPLACE_BASH for the +# others. +# +# Note that in all the above cases, you have to add the needed +# tools manually to USE_TOOLS, since there is no way to detect +# automatically whether a tool should be a build-time or a +# run-time dependency. +# +# Packages may also add their own interpreter replacements, which should +# just look like the examples below. For the REPLACE_INTERPRETER +# variable, all identifiers starting with "sys-" are reserved for the +# pkgsrc infrastructure. All others may be used freely. +# ###################################################################### ### replace-interpreter (PRIVATE) @@ -8,11 +37,38 @@ ### do-configure-pre-hook: replace-interpreter -.if defined(REPLACE_PERL) -REPLACE_INTERPRETER+= perl -REPLACE.perl.old= .*/bin/perl -REPLACE.perl.new= ${PERL5} -REPLACE_FILES.perl= ${REPLACE_PERL} +REPLACE_INTERPRETER?= # none +REPLACE_AWK?= # none +REPLACE_BASH?= # none +REPLACE_PERL?= # none +REPLACE_SH?= # none + +.if !empty(REPLACE_AWK:M*) +REPLACE_INTERPRETER+= sys-AWK +REPLACE.sys-AWK.old= .*awk +REPLACE.sys-AWK.new= ${AWK} +REPLACE_FILES.sys-AWK= ${REPLACE_AWK} +.endif + +.if !empty(REPLACE_BASH:M*) +REPLACE_INTERPRETER+= sys-bash +REPLACE.sys-bash.old= .*bash +REPLACE.sys-bash.new= ${BASH} +REPLACE_FILES.sys-bash= ${REPLACE_BASH} +.endif + +.if !empty(REPLACE_PERL:M*) +REPLACE_INTERPRETER+= sys-Perl +REPLACE.sys-Perl.old= .*perl[^[:space:]]* +REPLACE.sys-Perl.new= ${PERL5} +REPLACE_FILES.sys-Perl= ${REPLACE_PERL} +.endif + +.if !empty(REPLACE_SH:M*) +REPLACE_INTERPRETER+= sys-sh +REPLACE.sys-sh.old= [^[:space:]]*sh +REPLACE.sys-sh.new= ${SH} +REPLACE_FILES.sys-sh= ${REPLACE_SH} .endif # XXX After 2006Q2, all instances of _REPLACE.* and _REPLACE_FILES.* should @@ -28,21 +84,25 @@ REPLACE_FILES.${_lang_}?= ${_REPLACE_FILES.${_lang_}} .PHONY: replace-interpreter replace-interpreter: .for _lang_ in ${REPLACE_INTERPRETER} - @${STEP_MSG} "Replacing interpreter paths in scripts" -. for _pattern_ in ${REPLACE_FILES.${_lang_}} - ${_PKG_SILENT}${_PKG_DEBUG} \ +. if defined(REPLACE_FILES.${_lang_}) && !empty(REPLACE_FILES.${_lang_}:M*) + @${STEP_MSG} "Replacing ${_lang_:S/^sys-//} interpreter in "${REPLACE_FILES.${_lang_}:M*:Q}"." + ${_PKG_SILENT}${_PKG_DEBUG} set -eu; \ cd ${WRKSRC}; \ - for file in ${_pattern_}; do \ - if ${TEST} ! -f "$$file"; then \ - ${WARNING_MSG} "[replace-interpreter.mk] Skipping non-existent file \"$$file\"."; \ - continue; \ - fi; \ - ${SED} -e '1s|^#!${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \ - $$file > $$file.new; \ - if ${TEST} -x $$file; then \ - ${CHMOD} a+x $$file.new; \ + for f in ${REPLACE_FILES.${_lang_}}; do \ + if [ -f "$${f}" ]; then \ + ${SED} -e '1s|^#!${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \ + < "$${f}" > "$${f}.new"; \ + if [ -x "$${f}" ]; then \ + ${CHMOD} a+x "$${f}.new"; \ + fi; \ + ${MV} -f "$${f}.new" "$${f}"; \ + elif [ -d "$$f" ]; then \ + ${SHCOMMENT} "Ignore it, most probably comes from shell globs"; \ + else \ + ${WARNING_MSG} "[replace-interpreter] Skipping non-existent file \"$$f\"."; \ fi; \ - ${MV} -f $$file.new $$file; \ done -. endfor +. else + @${WARNING_MSG} "[replace-interpreter] Empty list of files for ${_lang_}." +. endif .endfor |