summaryrefslogtreecommitdiff
path: root/mk/subst.mk
diff options
context:
space:
mode:
authorjlam <jlam>2005-05-20 21:36:05 +0000
committerjlam <jlam>2005-05-20 21:36:05 +0000
commit67b2ed173f158ea7e82e37c85ab827c98d467e22 (patch)
tree5a7819f8df8584a274396aac5fd6a1e58c3da052 /mk/subst.mk
parent0428d4cdeb4fa7611c08790eedafb03e8963fa09 (diff)
downloadpkgsrc-67b2ed173f158ea7e82e37c85ab827c98d467e22.tar.gz
Change instances where we stored `shell command` in a make variable into
variables that use the :sh modifier. This still causes expansion to only happen when referenced, and has the advantage of being :Q-safe. Bring back the changes from revision 1.19 of mk/subst.mk now that the problem noted above has been fixed. This passes the buildlink-unwrap regression test.
Diffstat (limited to 'mk/subst.mk')
-rw-r--r--mk/subst.mk45
1 files changed, 22 insertions, 23 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index 8d0f993a0ca..da36a4c914d 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.20 2005/05/20 18:40:42 jlam Exp $
+# $NetBSD: subst.mk,v 1.21 2005/05/20 21:36:05 jlam Exp $
#
# This Makefile fragment implements a general text replacement facility.
# Package makefiles define a ``class'', for each of which a paricular
@@ -47,7 +47,7 @@ _SUBST_BACKUP_SUFFIX= .subst.sav
_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
SUBST_FILTER_CMD.${_class_}?= ${SED} ${SUBST_SED.${_class_}}
-SUBST_POSTCMD.${_class_}?= ${RM} -f $$file${_SUBST_BACKUP_SUFFIX}
+SUBST_POSTCMD.${_class_}?= ${RM} -f "$$tmpfile"
SUBST_TARGETS+= subst-${_class_}
_SUBST_TARGETS.${_class_}= subst-${_class_}-message
@@ -77,26 +77,25 @@ subst-${_class_}: ${_SUBST_TARGETS.${_class_}}
${_SUBST_COOKIE.${_class_}}:
${_PKG_SILENT}${_PKG_DEBUG} \
- cd ${WRKSRC}; \
- files="${SUBST_FILES.${_class_}}"; \
- case "$$files" in \
- "") ;; \
- *) for file in $${files}; do \
- if ${_SUBST_IS_TEXT_FILE}; then \
- ${MV} -f $$file $$file${_SUBST_BACKUP_SUFFIX} || exit 1; \
- ${CAT} $$file${_SUBST_BACKUP_SUFFIX} \
- | ${SUBST_FILTER_CMD.${_class_}} \
- > $$file; \
- if [ -x $$file${_SUBST_BACKUP_SUFFIX} ]; then \
- ${CHMOD} +x $$file; \
- fi; \
- if ${CMP} -s $$file${_SUBST_BACKUP_SUFFIX} $$file; then \
- ${MV} -f $$file${_SUBST_BACKUP_SUFFIX} $$file; \
- else \
- ${SUBST_POSTCMD.${_class_}}; \
- ${ECHO} $$file >> ${.TARGET}; \
- fi; \
+ cd ${WRKSRC:Q}; \
+ files=${SUBST_FILES.${_class_}:Q}; \
+ for file in $$files; do \
+ file="./$$file"; \
+ tmpfile="$$file"${_SUBST_BACKUP_SUFFIX:Q}; \
+ if ${_SUBST_IS_TEXT_FILE}; then \
+ ${MV} -f "$$file" "$$tmpfile" || exit 1; \
+ ${CAT} "$$tmpfile" \
+ | ${SUBST_FILTER_CMD.${_class_}} \
+ > "$$file"; \
+ if ${TEST} -x "$$tmpfile"; then \
+ ${CHMOD} +x "$$file"; \
fi; \
- done ;; \
- esac
+ if ${CMP} -s "$$tmpfile" "$$file"; then \
+ ${MV} -f "$$tmpfile" "$$file"; \
+ else \
+ ${SUBST_POSTCMD.${_class_}}; \
+ ${ECHO} "$$file" >> ${.TARGET}; \
+ fi; \
+ fi; \
+ done
.endfor