From 105997fbc4f2995a3b463a4cfe8eaf88127ac6ba Mon Sep 17 00:00:00 2001 From: schmonz Date: Sun, 6 Jun 2004 04:22:23 +0000 Subject: Usually there's no need to keep the original version of a file "foo" as "foo.subst.sav". Implement SUBST_POSTCMD, which by default cleans up these leftovers. If you need to keep them around, e.g. while debugging, set it to ${DO_NADA}. Remove superfluous whitespace in a comment. --- mk/subst.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mk/subst.mk') diff --git a/mk/subst.mk b/mk/subst.mk index c56e9c1afe2..6531c799a99 100644 --- a/mk/subst.mk +++ b/mk/subst.mk @@ -1,4 +1,4 @@ -# $NetBSD: subst.mk,v 1.11 2004/03/07 09:29:25 grant Exp $ +# $NetBSD: subst.mk,v 1.12 2004/06/06 04:22:23 schmonz Exp $ # # This Makefile fragment implements a general text replacement facility. # Package makefiles define a ``class'', for each of which a paricular @@ -16,7 +16,7 @@ # # SUBST_MESSAGE. # message to display, noting what is being substituted -# +# # SUBST_FILES. # files on which to run the substitution; these are relative to # ${WRKSRC} @@ -27,6 +27,10 @@ # SUBST_FILTER_CMD. # filter used to perform the actual substitution on the specified # files. Defaults to ${SED} ${SUBST_SED.}. +# +# SUBST_POSTCMD. +# command to clean up after sed(1). Defaults to ${RM} -f +# $$file.subst.sav. For debugging, set it to ${DO_NADA}. ECHO_SUBST_MSG?= ${ECHO} @@ -39,6 +43,7 @@ _SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done . if defined(SUBST_SED.${_class_}) && !empty(SUBST_SED.${_class_}) SUBST_FILTER_CMD.${_class_}?= ${SED} ${SUBST_SED.${_class_}} +SUBST_POSTCMD.${_class_}?= ${RM} -f $$file.subst.sav . else SUBST_FILTER_CMD.${_class_}?= # empty . endif @@ -88,6 +93,7 @@ ${_SUBST_COOKIE.${_class_}}: if ${CMP} -s $$file.subst.sav $$file; then \ ${MV} -f $$file.subst.sav $$file; \ else \ + ${SUBST_POSTCMD.${_class_}}; \ ${ECHO} $$file >> ${.TARGET}; \ fi; \ fi; \ -- cgit v1.2.3