| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: subst.mk,v 1.98 2020/06/11 19:38:40 rillig Exp $ | | 1 | # $NetBSD: subst.mk,v 1.99 2020/06/11 20:13:22 rillig Exp $ |
2 | # | | 2 | # |
3 | # The subst framework replaces text in one or more files in the WRKSRC | | 3 | # The subst framework replaces text in one or more files in the WRKSRC |
4 | # directory. Packages can define several ``classes'' of replacements. | | 4 | # directory. Packages can define several ``classes'' of replacements. |
5 | # Each such class defines: | | 5 | # Each such class defines: |
6 | # | | 6 | # |
7 | # - in which stage of the build process the replacement happens | | 7 | # - in which stage of the build process the replacement happens |
8 | # - which files are affected by the replacement | | 8 | # - which files are affected by the replacement |
9 | # - which text or pattern is replaced by which replacement text | | 9 | # - which text or pattern is replaced by which replacement text |
10 | # | | 10 | # |
11 | # A typical example is: | | 11 | # A typical example is: |
12 | # | | 12 | # |
13 | # SUBST_CLASSES+= prefix | | 13 | # SUBST_CLASSES+= prefix |
14 | # SUBST_STAGE.prefix= pre-configure | | 14 | # SUBST_STAGE.prefix= pre-configure |
| @@ -135,27 +135,26 @@ _SUBST_IS_TEXT_FILE_CMD= \ | | | @@ -135,27 +135,26 @@ _SUBST_IS_TEXT_FILE_CMD= \ |
135 | | | 135 | |
136 | .if ${SUBST_CLASSES:U:O} != ${SUBST_CLASSES:U:O:u} | | 136 | .if ${SUBST_CLASSES:U:O} != ${SUBST_CLASSES:U:O:u} |
137 | PKG_FAIL_REASON+= "[subst.mk] duplicate SUBST class in: ${SUBST_CLASSES:O}" | | 137 | PKG_FAIL_REASON+= "[subst.mk] duplicate SUBST class in: ${SUBST_CLASSES:O}" |
138 | .endif | | 138 | .endif |
139 | | | 139 | |
140 | .for class in ${SUBST_CLASSES:O:u} | | 140 | .for class in ${SUBST_CLASSES:O:u} |
141 | _SUBST_COOKIE.${class}= ${WRKDIR}/.subst_${class}_done | | 141 | _SUBST_COOKIE.${class}= ${WRKDIR}/.subst_${class}_done |
142 | | | 142 | |
143 | .if defined(SUBST_FILTER_CMD.${class}) && (defined(SUBST_SED.${class}) || defined(SUBST_VARS.${class})) | | 143 | .if defined(SUBST_FILTER_CMD.${class}) && (defined(SUBST_SED.${class}) || defined(SUBST_VARS.${class})) |
144 | PKG_FAIL_REASON+= "[subst.mk:${class}] SUBST_FILTER_CMD and SUBST_SED/SUBST_VARS cannot be combined." | | 144 | PKG_FAIL_REASON+= "[subst.mk:${class}] SUBST_FILTER_CMD and SUBST_SED/SUBST_VARS cannot be combined." |
145 | .endif | | 145 | .endif |
146 | | | 146 | |
147 | SUBST_FILTER_CMD.${class}?= LC_ALL=C ${SED} ${SUBST_SED.${class}} | | 147 | SUBST_FILTER_CMD.${class}?= LC_ALL=C ${SED} ${SUBST_SED.${class}} |
148 | SUBST_VARS.${class}?= # none | | | |
149 | SUBST_MESSAGE.${class}?= Substituting "${class}" in ${SUBST_FILES.${class}} | | 148 | SUBST_MESSAGE.${class}?= Substituting "${class}" in ${SUBST_FILES.${class}} |
150 | . for v in ${SUBST_VARS.${class}} | | 149 | . for v in ${SUBST_VARS.${class}} |
151 | SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[.[\\*^]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g | | 150 | SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[.[\\*^]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g |
152 | . endfor | | 151 | . endfor |
153 | . if ${SUBST_SHOW_DIFF.${class}:U${SUBST_SHOW_DIFF}:tl} == yes | | 152 | . if ${SUBST_SHOW_DIFF.${class}:U${SUBST_SHOW_DIFF}:tl} == yes |
154 | _SUBST_KEEP.${class}?= LC_ALL=C ${DIFF} -u "$$file" "$$tmpfile" || true | | 153 | _SUBST_KEEP.${class}?= LC_ALL=C ${DIFF} -u "$$file" "$$tmpfile" || true |
155 | . endif | | 154 | . endif |
156 | _SUBST_KEEP.${class}?= ${DO_NADA} | | 155 | _SUBST_KEEP.${class}?= ${DO_NADA} |
157 | SUBST_SKIP_TEXT_CHECK.${class}?= \ | | 156 | SUBST_SKIP_TEXT_CHECK.${class}?= \ |
158 | no | | 157 | no |
159 | SUBST_NOOP_OK.${class}?= ${SUBST_NOOP_OK} | | 158 | SUBST_NOOP_OK.${class}?= ${SUBST_NOOP_OK} |
160 | _SUBST_WARN.${class}= ${${SUBST_NOOP_OK.${class}:tl} == yes:?${INFO_MSG}:${WARNING_MSG}} "[subst.mk:${class}]" | | 159 | _SUBST_WARN.${class}= ${${SUBST_NOOP_OK.${class}:tl} == yes:?${INFO_MSG}:${WARNING_MSG}} "[subst.mk:${class}]" |
161 | | | 160 | |