Module Name:    src
Committed By:   apb
Date:           Wed Oct  5 12:34:05 UTC 2011

Modified Files:
        src/share/mk: bsd.README bsd.clean.mk

Log Message:
Add MKCLEANSRC and MKCLEANVERIFY variables, defaulting to "yes".
You may set them to "no" to get the old behaviour of "make clean"
and "make cleandir".


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/share/mk/bsd.README
cvs rdiff -u -r1.3 -r1.4 src/share/mk/bsd.clean.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.286 src/share/mk/bsd.README:1.287
--- src/share/mk/bsd.README:1.286	Sat Sep 10 16:57:35 2011
+++ src/share/mk/bsd.README	Wed Oct  5 12:34:04 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.README,v 1.286 2011/09/10 16:57:35 apb Exp $
+#	$NetBSD: bsd.README,v 1.287 2011/10/05 12:34:04 apb Exp $
 #	@(#)bsd.README	8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -819,12 +819,44 @@ CLEANFILES	Files to remove for both the 
 CLEANDIRFILES	Files to remove for the cleandir target, but not for
 		the clean target.
 
-If ${.OBJDIR} and ${.CURDIR} are different, then the clean and cleandir
-targets will delete files from both those directories.  Deleting files
-from ${.OBJDIR} is the traditional behaviour.  Deleting files from
-${.CURDIR} is intended to remove output files that had been left in
-the source directory by an earlier build that had used ${.OBJDIR} ==
-${.CURDIR}.
+MKCLEANSRC	Controls whether or not the clean and cleandir targets
+		will delete files from both the object directory,
+		${.OBJDIR}, and the source directory, ${.CURDIR}.
+
+		If MKCLEANSRC is set to "no", then the file names in
+		CLEANFILES or CLEANDIRFILES are interpreted relative
+		to the object directory, ${.OBJDIR}.  This is the
+		traditional behaviour.
+
+		If MKCLEANSRC is set to "yes", then the file deletion
+		is performed relative to both the object directory,
+		${.OBJDIR}, and the source directory, ${.CURDIR}.  (This
+		has no effect if ${.OBJDIR} is the same as ${.CURDIR}.)
+		Deleting files from ${.CURDIR} is intended to remove
+		stray output files that had been left in the source
+		directory by an earlier build that did not use object
+		directories.
+
+		The default is MKCLEANSRC=yes.  If you always build with
+		separate object directories, and you are sure that there
+		are no stray files in the source directories, then you
+		may set MKCLEANSRC=no to save some time.
+
+MKCLEANVERIFY	Controls whether or not the clean and cleandir targets
+		will verify that files have been deleted.
+
+		If MKCLEANVERIFY is set to "no", then the files will
+		be deleted using a "rm -f" command, and its success or
+		failure will be ignored.
+
+		If MKCLEANVERIFY is set to "yes", then the success of
+		the "rm -f" command will be verified using an "ls"
+		command.
+
+		The default is MKCLEANVERIFY=yes.  If you are sure that
+		there will be no problems caused by file permissions,
+		read-only file systems, or the like, then you may set
+		MKCLEANVERIFY=no to save some time.
 
 To use the clean and cleandir targets defined in <bsd.clean.mk>, other
 Makefiles or bsd.*.mk files should append file names to the CLEANFILES

Index: src/share/mk/bsd.clean.mk
diff -u src/share/mk/bsd.clean.mk:1.3 src/share/mk/bsd.clean.mk:1.4
--- src/share/mk/bsd.clean.mk:1.3	Fri Sep 23 21:13:14 2011
+++ src/share/mk/bsd.clean.mk	Wed Oct  5 12:34:04 2011
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.clean.mk,v 1.3 2011/09/23 21:13:14 apb Exp $
+# $NetBSD: bsd.clean.mk,v 1.4 2011/10/05 12:34:04 apb Exp $
 
 # <bsd.clean.mk>
 #
@@ -13,12 +13,21 @@
 #
 # CLEANDIRFILES	Files to remove for the cleandir target, but not for
 #		the clean target.
+#
+# MKCLEANSRC	Whether or not to clean the source directory
+# 		in addition to the object directory.
+#
+# MKCLEANVERIFY	Whether or not to verify that the file deletion worked.
+#
 
 .if !defined(_BSD_CLEAN_MK_)
 _BSD_CLEAN_MK_=1
 
 .include <bsd.init.mk>
 
+MKCLEANSRC?=	yes
+MKCLEANVERIFY?=	yes
+
 clean:		.PHONY __doclean
 __doclean:	.PHONY .MADE __cleanuse CLEANFILES
 cleandir:	.PHONY clean __docleandir
@@ -32,24 +41,20 @@ __docleandir:	.PHONY .MADE __cleanuse CL
 # want make to replace any of the file names with the result of
 # searching .PATH.)
 #
-# If the list of file names is non-empty then use "rm -f" to
-# delete the files, and "ls -d" to check that the deletion was
-# successful.  If the list of files is empty, then the commands
+# If the list of files is empty, then the commands
 # reduce to "true", with an "@" prefix to prevent echoing.
 #
-# If .OBJDIR is different from .SRCDIR then repeat all this for
-# both .OBJDIR and .SRCDIR.
-#
 __cleanuse: .USE
 .if 0	# print "# clean CLEANFILES" for debugging
 	${"${.ALLSRC:@v@${${v}:M*}@}" == "":?@true:${_MKMSG} \
 		"clean" ${.ALLSRC} }
 .endif
-.for _d in ${"${.OBJDIR}" == "${.CURDIR}" \
+.for _d in ${"${.OBJDIR}" == "${.CURDIR}" || "${MKCLEANSRC}" == "no" \
 		:? ${.OBJDIR} \
 		:  ${.OBJDIR} ${.CURDIR} }
 	${"${.ALLSRC:@v@${${v}:M*}@}" == "":?@true: \
 	    (cd ${_d} && rm -f ${.ALLSRC:@v@${${v}}@} || true) }
+.if "${MKCLEANVERIFY}" == "yes"
 	@${"${.ALLSRC:@v@${${v}:M*}@}" == "":?true: \
 	    bad="\$(cd ${_d} && ls -d ${.ALLSRC:@v@${${v}}@} 2>/dev/null)"; \
 	    if test -n "\$bad"; then \
@@ -57,6 +62,7 @@ __cleanuse: .USE
 	        echo "\$bad" ; \
 	        false ; \
 	    fi }
+.endif
 .endfor
 
 # Don't automatically load ".depend" files during "make clean"

Reply via email to