summaryrefslogtreecommitdiff
path: root/mk/subst.mk
diff options
context:
space:
mode:
authorkim <kim>2003-12-28 17:28:26 +0000
committerkim <kim>2003-12-28 17:28:26 +0000
commit4a349446ec221916e2b0a6332789ae545b38c156 (patch)
treedc592bb8179441d73ea08b4dc5cf0f16e0a2524f /mk/subst.mk
parent20e050426afd08357e9de220cc76f0c5b81d31d0 (diff)
downloadpkgsrc-4a349446ec221916e2b0a6332789ae545b38c156.tar.gz
Revert revision 1.5 as binaries and directories are now being substed
unintentionally. Also revert revision 1.6 as part of the overall change, as I suspect the change might be unnecessary. While I'm not 100% sure, this does just revert to the previous behaviour.
Diffstat (limited to 'mk/subst.mk')
-rw-r--r--mk/subst.mk30
1 files changed, 18 insertions, 12 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index 2a707ab7415..4cbba4ad453 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.7 2003/12/28 15:57:29 jmmv Exp $
+# $NetBSD: subst.mk,v 1.8 2003/12/28 17:28:26 kim Exp $
#
# This Makefile fragment implements a general text replacement facility
# for different classes of files in ${WRKSRC}. For each class of files,
@@ -26,6 +26,10 @@
ECHO_SUBST_MSG?= ${ECHO}
+# _SUBST_IS_TEXT_FILE returns 0 if $${file} is a text file.
+_SUBST_IS_TEXT_FILE?= \
+ ${FILE_CMD} $${file} | ${EGREP} "(shell script|text)" >/dev/null 2>&1
+
.for _class_ in ${SUBST_CLASSES}
_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
@@ -69,17 +73,19 @@ ${_SUBST_COOKIE.${_class_}}:
case "$$files" in \
"") ;; \
*) for file in $${files}; do \
- ${MV} -f $$file $$file.subst.sav || exit 1; \
- ${CAT} $$file.subst.sav \
- | ${SUBST_FILTER_CMD.${_class_}} \
- > $$file; \
- if [ -x $$file.subst.sav ]; then \
- ${CHMOD} +x $$file; \
- fi; \
- if ${CMP} -s $$file.subst.sav $$file; then \
- ${MV} -f $$file.subst.sav $$file; \
- else \
- ${ECHO} $$file >> ${.TARGET}; \
+ if ${_SUBST_IS_TEXT_FILE}; then \
+ ${MV} -f $$file $$file.subst.sav; \
+ ${CAT} $$file.subst.sav \
+ | ${SUBST_FILTER_CMD.${_class_}} \
+ > $$file; \
+ if [ -x $$file.subst.sav ]; then \
+ ${CHMOD} +x $$file; \
+ fi; \
+ if ${CMP} -s $$file.subst.sav $$file; then \
+ ${MV} -f $$file.subst.sav $$file; \
+ else \
+ ${ECHO} $$file >> ${.TARGET}; \
+ fi; \
fi; \
done ;; \
esac