Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/mk Add MKCLEANSRC and MKCLEANVERIFY variables, default...



details:   https://anonhg.NetBSD.org/src/rev/68414eba8afa
branches:  trunk
changeset: 770138:68414eba8afa
user:      apb <apb%NetBSD.org@localhost>
date:      Wed Oct 05 12:34:04 2011 +0000

description:
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".

diffstat:

 share/mk/bsd.README   |  46 +++++++++++++++++++++++++++++++++++++++-------
 share/mk/bsd.clean.mk |  22 ++++++++++++++--------
 2 files changed, 53 insertions(+), 15 deletions(-)

diffs (127 lines):

diff -r 854cde233a0d -r 68414eba8afa share/mk/bsd.README
--- a/share/mk/bsd.README       Wed Oct 05 10:48:54 2011 +0000
+++ b/share/mk/bsd.README       Wed Oct 05 12:34:04 2011 +0000
@@ -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 @@
 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
diff -r 854cde233a0d -r 68414eba8afa share/mk/bsd.clean.mk
--- a/share/mk/bsd.clean.mk     Wed Oct 05 10:48:54 2011 +0000
+++ b/share/mk/bsd.clean.mk     Wed Oct 05 12:34:04 2011 +0000
@@ -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 @@
 # 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 @@
                echo "\$bad" ; \
                false ; \
            fi }
+.endif
 .endfor
 
 # Don't automatically load ".depend" files during "make clean"



Home | Main Index | Thread Index | Old Index