From 4a349446ec221916e2b0a6332789ae545b38c156 Mon Sep 17 00:00:00 2001 From: kim Date: Sun, 28 Dec 2003 17:28:26 +0000 Subject: 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. --- mk/subst.mk | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'mk/subst.mk') 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 -- cgit v1.2.3