Sun Mar 22 21:31:21 2020 UTC ()
mk/configure/replace-interpreter.mk: add missing empty line

The optional /usr/bin/env is independent from sh. It applies to all
languages.


(rillig)
diff -r1.17 -r1.18 pkgsrc/mk/configure/replace-interpreter.mk

cvs diff -r1.17 -r1.18 pkgsrc/mk/configure/replace-interpreter.mk (switch to unified diff)

--- pkgsrc/mk/configure/replace-interpreter.mk 2019/02/18 14:10:37 1.17
+++ pkgsrc/mk/configure/replace-interpreter.mk 2020/03/22 21:31:21 1.18
@@ -1,143 +1,144 @@ @@ -1,143 +1,144 @@
1# $NetBSD: replace-interpreter.mk,v 1.17 2019/02/18 14:10:37 bsiegert Exp $ 1# $NetBSD: replace-interpreter.mk,v 1.18 2020/03/22 21:31:21 rillig Exp $
2 2
3# This file provides common templates for replacing #! interpreters 3# This file provides common templates for replacing #! interpreters
4# in script files. 4# in script files.
5# 5#
6# The following variables may be set by a package: 6# The following variables may be set by a package:
7# 7#
8# REPLACE_AWK 8# REPLACE_AWK
9# REPLACE_BASH 9# REPLACE_BASH
10# REPLACE_CSH 10# REPLACE_CSH
11# REPLACE_KSH 11# REPLACE_KSH
12# REPLACE_PERL 12# REPLACE_PERL
13# REPLACE_PERL6 13# REPLACE_PERL6
14# REPLACE_SH 14# REPLACE_SH
15# Lists of files relative to WRKSRC in which the #! interpreter 15# Lists of files relative to WRKSRC in which the #! interpreter
16# should be replaced by the pkgsrc one. If any directories 16# should be replaced by the pkgsrc one. If any directories
17# appear in the lists, they are silenty skipped, assuming that 17# appear in the lists, they are silenty skipped, assuming that
18# they result from shell globbing expressions. 18# they result from shell globbing expressions.
19# 19#
20# Use REPLACE_SH for shell programs that don't need any 20# Use REPLACE_SH for shell programs that don't need any
21# special features from bash, and REPLACE_BASH for the 21# special features from bash, and REPLACE_BASH for the
22# others. 22# others.
23# 23#
24# Note that in all the above cases, you have to add the needed 24# Note that in all the above cases, you have to add the needed
25# tools manually to USE_TOOLS, since there is no way to detect 25# tools manually to USE_TOOLS, since there is no way to detect
26# automatically whether a tool should be a build-time or a 26# automatically whether a tool should be a build-time or a
27# run-time dependency. 27# run-time dependency.
28# 28#
29# Packages may also add their own interpreter replacements, which should 29# Packages may also add their own interpreter replacements, which should
30# just look like the examples below. For the REPLACE_INTERPRETER 30# just look like the examples below. For the REPLACE_INTERPRETER
31# variable, all identifiers starting with "sys-" are reserved for the 31# variable, all identifiers starting with "sys-" are reserved for the
32# pkgsrc infrastructure. All others may be used freely. 32# pkgsrc infrastructure. All others may be used freely.
33# 33#
34# Keywords: replace_interpreter interpreter interp hashbang #! 34# Keywords: replace_interpreter interpreter interp hashbang #!
35# Keywords: awk bash csh ksh perl sh 35# Keywords: awk bash csh ksh perl sh
36 36
37###################################################################### 37######################################################################
38### replace-interpreter (PRIVATE) 38### replace-interpreter (PRIVATE)
39###################################################################### 39######################################################################
40### replace-interpreter replaces paths to interpreters in scripts with 40### replace-interpreter replaces paths to interpreters in scripts with
41### the paths to the pkgsrc-managed interpreters. 41### the paths to the pkgsrc-managed interpreters.
42### 42###
43do-configure-pre-hook: replace-interpreter 43do-configure-pre-hook: replace-interpreter
44 44
45REPLACE_INTERPRETER?= # none 45REPLACE_INTERPRETER?= # none
46REPLACE_AWK?= # none 46REPLACE_AWK?= # none
47REPLACE_BASH?= # none 47REPLACE_BASH?= # none
48REPLACE_CSH?= # none 48REPLACE_CSH?= # none
49REPLACE_KSH?= # none 49REPLACE_KSH?= # none
50REPLACE_PERL?= # none 50REPLACE_PERL?= # none
51REPLACE_SH?= # none 51REPLACE_SH?= # none
52 52
53.if !empty(REPLACE_AWK:M*) 53.if !empty(REPLACE_AWK:M*)
54REPLACE_INTERPRETER+= sys-AWK 54REPLACE_INTERPRETER+= sys-AWK
55REPLACE.sys-AWK.old= .*awk 55REPLACE.sys-AWK.old= .*awk
56REPLACE.sys-AWK.new= ${AWK} 56REPLACE.sys-AWK.new= ${AWK}
57REPLACE_FILES.sys-AWK= ${REPLACE_AWK} 57REPLACE_FILES.sys-AWK= ${REPLACE_AWK}
58.endif 58.endif
59 59
60.if !empty(REPLACE_BASH:M*) 60.if !empty(REPLACE_BASH:M*)
61REPLACE_INTERPRETER+= sys-bash 61REPLACE_INTERPRETER+= sys-bash
62REPLACE.sys-bash.old= .*sh 62REPLACE.sys-bash.old= .*sh
63REPLACE.sys-bash.new= ${BASH} 63REPLACE.sys-bash.new= ${BASH}
64REPLACE_FILES.sys-bash= ${REPLACE_BASH} 64REPLACE_FILES.sys-bash= ${REPLACE_BASH}
65.endif 65.endif
66 66
67.if !empty(REPLACE_CSH:M*) 67.if !empty(REPLACE_CSH:M*)
68REPLACE_INTERPRETER+= sys-csh 68REPLACE_INTERPRETER+= sys-csh
69REPLACE.sys-csh.old= .*csh 69REPLACE.sys-csh.old= .*csh
70REPLACE.sys-csh.new= ${CSH} 70REPLACE.sys-csh.new= ${CSH}
71REPLACE_FILES.sys-csh= ${REPLACE_CSH} 71REPLACE_FILES.sys-csh= ${REPLACE_CSH}
72.endif 72.endif
73 73
74.if !empty(REPLACE_KSH:M*) 74.if !empty(REPLACE_KSH:M*)
75REPLACE_INTERPRETER+= sys-ksh 75REPLACE_INTERPRETER+= sys-ksh
76REPLACE.sys-ksh.old= [^[:space:]]*sh 76REPLACE.sys-ksh.old= [^[:space:]]*sh
77REPLACE.sys-ksh.new= ${TOOLS_PATH.ksh} 77REPLACE.sys-ksh.new= ${TOOLS_PATH.ksh}
78REPLACE_FILES.sys-ksh= ${REPLACE_KSH} 78REPLACE_FILES.sys-ksh= ${REPLACE_KSH}
79.endif 79.endif
80 80
81.if !empty(REPLACE_PERL:M*) 81.if !empty(REPLACE_PERL:M*)
82REPLACE_INTERPRETER+= sys-Perl 82REPLACE_INTERPRETER+= sys-Perl
83REPLACE.sys-Perl.old= .*perl[^[:space:]]* 83REPLACE.sys-Perl.old= .*perl[^[:space:]]*
84REPLACE.sys-Perl.new= ${PERL5} 84REPLACE.sys-Perl.new= ${PERL5}
85REPLACE_FILES.sys-Perl= ${REPLACE_PERL} 85REPLACE_FILES.sys-Perl= ${REPLACE_PERL}
86.endif 86.endif
87 87
88.if !empty(REPLACE_PERL6:M*) 88.if !empty(REPLACE_PERL6:M*)
89PERL6?= ${PREFIX}/bin/perl6 89PERL6?= ${PREFIX}/bin/perl6
90REPLACE_INTERPRETER+= sys-Perl6 90REPLACE_INTERPRETER+= sys-Perl6
91REPLACE.sys-Perl6.old= .*perl6[^[:space:]]* 91REPLACE.sys-Perl6.old= .*perl6[^[:space:]]*
92REPLACE.sys-Perl6.new= ${PERL6} 92REPLACE.sys-Perl6.new= ${PERL6}
93REPLACE_FILES.sys-Perl6=${REPLACE_PERL6} 93REPLACE_FILES.sys-Perl6=${REPLACE_PERL6}
94.endif 94.endif
95 95
96.if !empty(REPLACE_SH:M*) 96.if !empty(REPLACE_SH:M*)
97REPLACE_INTERPRETER+= sys-sh 97REPLACE_INTERPRETER+= sys-sh
98REPLACE.sys-sh.old= [^[:space:]]*sh 98REPLACE.sys-sh.old= [^[:space:]]*sh
99REPLACE.sys-sh.new= ${SH} 99REPLACE.sys-sh.new= ${SH}
100REPLACE_FILES.sys-sh= ${REPLACE_SH} 100REPLACE_FILES.sys-sh= ${REPLACE_SH}
101.endif 101.endif
 102
102# sed regexp to match optional "/usr/bin/env" followed by one or more spaces 103# sed regexp to match optional "/usr/bin/env" followed by one or more spaces
103REPLACE.optional-env-space= \(/usr/bin/env[[:space:]][[:space:]]*\)\{0,1\} 104REPLACE.optional-env-space= \(/usr/bin/env[[:space:]][[:space:]]*\)\{0,1\}
104 105
105.PHONY: replace-interpreter 106.PHONY: replace-interpreter
106replace-interpreter: 107replace-interpreter:
107.for _lang_ in ${REPLACE_INTERPRETER} 108.for _lang_ in ${REPLACE_INTERPRETER}
108. if defined(REPLACE_FILES.${_lang_}) && !empty(REPLACE_FILES.${_lang_}:M*) 109. if defined(REPLACE_FILES.${_lang_}) && !empty(REPLACE_FILES.${_lang_}:M*)
109 @${STEP_MSG} "Replacing ${_lang_:S/^sys-//} interpreter in "${REPLACE_FILES.${_lang_}:M*:Q}"." 110 @${STEP_MSG} "Replacing ${_lang_:S/^sys-//} interpreter in "${REPLACE_FILES.${_lang_}:M*:Q}"."
110 ${RUN} set -u; \ 111 ${RUN} set -u; \
111 cd ${WRKSRC}; \ 112 cd ${WRKSRC}; \
112 for f in ${REPLACE_FILES.${_lang_}}; do \ 113 for f in ${REPLACE_FILES.${_lang_}}; do \
113 if [ -f "$${f}" ]; then \ 114 if [ -f "$${f}" ]; then \
114 ${SED} -e '1s|^#![[:space:]]*${REPLACE.optional-env-space}${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \ 115 ${SED} -e '1s|^#![[:space:]]*${REPLACE.optional-env-space}${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \
115 < "$${f}" > "$${f}.new"; \ 116 < "$${f}" > "$${f}.new"; \
116 if [ -x "$${f}" ]; then \ 117 if [ -x "$${f}" ]; then \
117 ${CHMOD} a+x "$${f}.new"; \ 118 ${CHMOD} a+x "$${f}.new"; \
118 fi; \ 119 fi; \
119 if ${CMP} -s "$${f}.new" "$${f}"; then \ 120 if ${CMP} -s "$${f}.new" "$${f}"; then \
120 ${INFO_MSG} "[replace-interpreter] Nothing changed in $${f}."; \ 121 ${INFO_MSG} "[replace-interpreter] Nothing changed in $${f}."; \
121 ${RM} -f "$${f}.new"; \ 122 ${RM} -f "$${f}.new"; \
122 else \ 123 else \
123 ${MV} -f "$${f}.new" "$${f}"; \ 124 ${MV} -f "$${f}.new" "$${f}"; \
124 fi; \ 125 fi; \
125 elif [ -d "$$f" ]; then \ 126 elif [ -d "$$f" ]; then \
126 ${SHCOMMENT} "Ignore it, most probably comes from shell globs"; \ 127 ${SHCOMMENT} "Ignore it, most probably comes from shell globs"; \
127 else \ 128 else \
128 ${WARNING_MSG} "[replace-interpreter] Skipping non-existent file \"$$f\"."; \ 129 ${WARNING_MSG} "[replace-interpreter] Skipping non-existent file \"$$f\"."; \
129 fi; \ 130 fi; \
130 done 131 done
131. else 132. else
132 @${WARNING_MSG} "[replace-interpreter] Empty list of files for ${_lang_}." 133 @${WARNING_MSG} "[replace-interpreter] Empty list of files for ${_lang_}."
133. endif 134. endif
134.endfor 135.endfor
135 136
136_VARGROUPS+= interp 137_VARGROUPS+= interp
137.for varname in REPLACE_AWK REPLACE_BASH REPLACE_CSH REPLACE_KSH REPLACE_PERL REPLACE_PERL6 REPLACE_SH 138.for varname in REPLACE_AWK REPLACE_BASH REPLACE_CSH REPLACE_KSH REPLACE_PERL REPLACE_PERL6 REPLACE_SH
138_PKG_VARS.interp+= ${varname} 139_PKG_VARS.interp+= ${varname}
139.endfor 140.endfor
140_PKG_VARS.interp+= REPLACE_INTERPRETER 141_PKG_VARS.interp+= REPLACE_INTERPRETER
141.for interp in ${REPLACE_INTERPRETER} 142.for interp in ${REPLACE_INTERPRETER}
142_DEF_VARS.interp+= REPLACE.${interp}.old REPLACE.${interp}.new REPLACE_FILES.${interp} 143_DEF_VARS.interp+= REPLACE.${interp}.old REPLACE.${interp}.new REPLACE_FILES.${interp}
143.endfor 144.endfor