Source-Changes-HG archive

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

[src/trunk]: src/share/mk Move all "clean" and "cleandir" processing to a new...



details:   https://anonhg.NetBSD.org/src/rev/569678cc8a01
branches:  trunk
changeset: 769443:569678cc8a01
user:      apb <apb%NetBSD.org@localhost>
date:      Sat Sep 10 16:57:35 2011 +0000

description:
Move all "clean" and "cleandir" processing to a new bsd.clean.mk
file, as proposed in tech-toolchain.

diffstat:

 share/mk/bsd.README      |  33 ++++++++++++++++++++++++--
 share/mk/bsd.clean.mk    |  60 ++++++++++++++++++++++++++++++++++++++++++++++++
 share/mk/bsd.dep.mk      |   9 ++++---
 share/mk/bsd.files.mk    |  11 +++-----
 share/mk/bsd.hostlib.mk  |   8 ++----
 share/mk/bsd.hostprog.mk |   8 ++----
 share/mk/bsd.info.mk     |  11 ++------
 share/mk/bsd.kmodule.mk  |   8 ++----
 share/mk/bsd.lib.mk      |  19 +++++++--------
 share/mk/bsd.man.mk      |  15 ++++--------
 share/mk/bsd.nls.mk      |   7 ++---
 share/mk/bsd.prog.mk     |  26 ++++----------------
 share/mk/bsd.rpc.mk      |   3 +-
 share/mk/bsd.test.mk     |  17 ++++++-------
 share/mk/bsd.x11.mk      |  17 +++++--------
 15 files changed, 151 insertions(+), 101 deletions(-)

diffs (truncated from 636 to 300 lines):

diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.README
--- a/share/mk/bsd.README       Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.README       Sat Sep 10 16:57:35 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.README,v 1.285 2011/09/09 10:08:14 apb Exp $
+#      $NetBSD: bsd.README,v 1.286 2011/09/10 16:57:35 apb Exp $
 #      @(#)bsd.README  8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -809,6 +809,33 @@
 they use the same default owners etc. as the rest of the tree.
 
 
+=-=-=-=-=   bsd.clean.mk   =-=-=-=-=
+
+The include file <bsd.clean.mk> defines the clean and cleandir
+targets.  It uses the following variables:
+
+CLEANFILES     Files to remove for both the clean and cleandir targets.
+
+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}.
+
+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
+or CLEANDIRFILES variables.  For example:
+
+           CLEANFILES+= a.out
+           CLEANDIRFILES+= .depend
+
+           .include <bsd.clean.mk>
+
+
 =-=-=-=-=   bsd.dep.mk   =-=-=-=-=
 
 The include file <bsd.dep.mk> contains the default targets for building
@@ -1253,6 +1280,8 @@
 
 BINMODE                Binary mode.
 
+CLEANDIRFILES  Additional files to remove for the cleandir target.
+
 CLEANFILES     Additional files to remove for the clean and cleandir targets.
 
 COPTS          Additional flags to the compiler when creating C objects.
@@ -1648,8 +1677,6 @@
                If ${MAN} or ${PROG} is set and ${MKMAN} != "no",
                these rules convert from X11's manual page source
                into an mdoc.old source file.
-       cleanx11man:
-               Clean up the mdoc.old files generated by the above.
 
 It sets the following variables:
 
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.clean.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/mk/bsd.clean.mk     Sat Sep 10 16:57:35 2011 +0000
@@ -0,0 +1,60 @@
+# $NetBSD: bsd.clean.mk,v 1.1 2011/09/10 16:57:35 apb Exp $
+
+# <bsd.clean.mk>
+#
+# Public targets:
+#
+# clean:       Delete files listed in ${CLEANFILES}.
+# cleandir:    Delete files listed in ${CLEANFILES} and ${CLEANDIRFILES}.
+#
+# Public variables:
+#
+# CLEANFILES   Files to remove for both the clean and cleandir targets.
+#
+# CLEANDIRFILES        Files to remove for the cleandir target, but not for
+#              the clean target.
+
+.if !defined(_BSD_CLEAN_MK_)
+_BSD_CLEAN_MK_=1
+
+.include <bsd.init.mk>
+
+clean:         .PHONY __doclean
+__doclean:     .PHONY .MADE __cleanuse CLEANFILES
+cleandir:      .PHONY clean __docleandir
+__docleandir:  .PHONY .MADE __cleanuse CLEANDIRFILES
+
+# __cleanuse is invoked with ${.ALLSRC} as the name of a variable
+# (such as CLEANFILES or CLEANDIRFILES), or possibly a list of
+# variable names.  ${.ALLSRC:@v@${${v}}@} will be the list of
+# files to delete.  (We pass the variable name, e.g. CLEANFILES,
+# instead of the file names, e.g. ${CLEANFILES}, because we don't
+# 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
+# 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
+       ${"${.ALLSRC:@v@${${v}}@}" == "":?@true:${_MKMSG} \
+               "clean" ${.ALLSRC} }
+.for _d in ${"${.OBJDIR}" == "${.CURDIR}" \
+               :? ${.OBJDIR} \
+               :  ${.OBJDIR} ${.CURDIR} }
+       -${"${.ALLSRC:@v@${${v}}@}" == "":?@true: \
+           (cd ${_d} && rm -f ${.ALLSRC:@v@${${v}}@}) }
+       @${"${.ALLSRC:@v@${${v}}@}" == "":?true: \
+           bad="\$(cd ${_d} && ls -d ${.ALLSRC:@v@${${v}}@} 2>/dev/null)"; \
+           if test -n "\$bad"; then \
+               echo "Failed to remove files from ${_d}:" ; \
+               echo "\$bad" ; \
+               false ; \
+           fi }
+.endfor
+
+.endif # !defined(_BSD_CLEAN_MK)
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.dep.mk
--- a/share/mk/bsd.dep.mk       Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.dep.mk       Sat Sep 10 16:57:35 2011 +0000
@@ -1,7 +1,6 @@
-#      $NetBSD: bsd.dep.mk,v 1.72 2011/04/10 16:52:36 joerg Exp $
+#      $NetBSD: bsd.dep.mk,v 1.73 2011/09/10 16:57:35 apb Exp $
 
 ##### Basic targets
-cleandir:      cleandepend
 realdepend:    beforedepend .depend afterdepend
 .ORDER:                beforedepend .depend afterdepend
 
@@ -62,9 +61,8 @@
 .endif # defined(SRCS)                                                 # }
 
 ##### Clean rules
-cleandepend: .PHONY
 .if defined(SRCS)
-       rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
+CLEANDIRFILES+= .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
 .endif
 
 ##### Custom rules
@@ -75,3 +73,6 @@
            ${TOOL_SED} "s;\${.CURDIR}/;;" > tags
 .endif
 .endif
+
+##### Pull in related .mk logic
+.include <bsd.clean.mk>
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.files.mk
--- a/share/mk/bsd.files.mk     Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.files.mk     Sat Sep 10 16:57:35 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.files.mk,v 1.41 2010/02/03 15:34:44 roy Exp $
+#      $NetBSD: bsd.files.mk,v 1.42 2011/09/10 16:57:35 apb Exp $
 
 .if !defined(_BSD_FILES_MK_)
 _BSD_FILES_MK_=1
@@ -118,9 +118,7 @@
 
 realall: ${BUILDSYMLINKS.t}
 
-cleandir: cleanbuildsymlinks
-cleanbuildsymlinks: .PHONY
-       rm -f ${BUILDSYMLINKS.t}
+CLEANDIRFILES+= ${BUILDSYMLINKS.t}
 
 .endif                                                         # }
 
@@ -149,13 +147,12 @@
 CLEANUUDECODE_FILES+=${UUDECODE_FILES_RENAME_${i}}
 .endfor
 
-clean: cleanuudecodefiles
-cleanuudecodefiles: .PHONY
-       rm -f ${CLEANUUDECODE_FILES}
+CLEANFILES+= ${CLEANUUDECODE_FILES}
 .endif                                                         # }
 
 ##### Pull in related .mk logic
 .include <bsd.obj.mk>
 .include <bsd.sys.mk>
+.include <bsd.clean.mk>
 
 .endif # !defined(_BSD_FILES_MK_)
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.hostlib.mk
--- a/share/mk/bsd.hostlib.mk   Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.hostlib.mk   Sat Sep 10 16:57:35 2011 +0000
@@ -1,10 +1,9 @@
-#      $NetBSD: bsd.hostlib.mk,v 1.15 2011/08/05 09:36:28 plunky Exp $
+#      $NetBSD: bsd.hostlib.mk,v 1.16 2011/09/10 16:57:35 apb Exp $
 
 .include <bsd.init.mk>
 .include <bsd.sys.mk>
 
 ##### Basic targets
-clean:         cleanlib
 
 ##### Default values
 CFLAGS+=       ${COPTS}
@@ -44,9 +43,7 @@
 
 realall: lib${HOSTLIB}.a
 
-cleanlib: .PHONY
-       rm -f a.out [Ee]rrs mklog core *.core \
-           lib${HOSTLIB}.a ${OBJS} ${CLEANFILES}
+CLEANFILES+= a.out [Ee]rrs mklog core *.core lib${HOSTLIB}.a ${OBJS}
 
 beforedepend:
 CFLAGS:=       ${HOST_CFLAGS}
@@ -55,5 +52,6 @@
 ##### Pull in related .mk logic
 .include <bsd.obj.mk>
 .include <bsd.dep.mk>
+.include <bsd.clean.mk>
 
 ${TARGETS}:    # ensure existence
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.hostprog.mk
--- a/share/mk/bsd.hostprog.mk  Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.hostprog.mk  Sat Sep 10 16:57:35 2011 +0000
@@ -1,11 +1,10 @@
-#      $NetBSD: bsd.hostprog.mk,v 1.63 2011/06/05 23:09:15 christos Exp $
+#      $NetBSD: bsd.hostprog.mk,v 1.64 2011/09/10 16:57:35 apb Exp $
 #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
 
 .include <bsd.init.mk>
 .include <bsd.sys.mk>
 
 ##### Basic targets
-clean:         cleanprog
 
 ##### Default values
 LIBATF_C?=     /usr/lib/libatf-c.a
@@ -123,9 +122,7 @@
 
 realall: ${HOSTPROG}
 
-cleanprog: .PHONY
-       rm -f a.out [Ee]rrs mklog core *.core \
-           ${HOSTPROG} ${OBJS} ${LOBJS} ${CLEANFILES}
+CLEANFILES+= a.out [Ee]rrs mklog core *.core ${HOSTPROG} ${OBJS} ${LOBJS}
 
 beforedepend:
 CFLAGS:=       ${HOST_CFLAGS}
@@ -144,6 +141,7 @@
 .include <bsd.inc.mk>
 .include <bsd.links.mk>
 .include <bsd.dep.mk>
+.include <bsd.clean.mk>
 
 ${TARGETS}:    # ensure existence
 
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.info.mk
--- a/share/mk/bsd.info.mk      Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.info.mk      Sat Sep 10 16:57:35 2011 +0000
@@ -1,9 +1,8 @@
-#      $NetBSD: bsd.info.mk,v 1.39 2009/02/28 19:18:52 joerg Exp $
+#      $NetBSD: bsd.info.mk,v 1.40 2011/09/10 16:57:35 apb Exp $
 
 .include <bsd.init.mk>
 
 ##### Basic targets
-cleandir:      cleaninfo
 realinstall:   infoinstall
 
 ##### Default values
@@ -78,15 +77,11 @@
 .endif # ${MKINFO} != "no"
 
 ##### Clean rules
-CLEANFILES+=   ${INFOFILES}
-
-cleaninfo: .PHONY
-.if !empty(CLEANFILES)
-       rm -f ${CLEANFILES}
-.endif
+CLEANDIRFILES+=        ${INFOFILES}
 
 ##### Pull in related .mk logic
 .include <bsd.obj.mk>
 .include <bsd.sys.mk>
+.include <bsd.clean.mk>
 
 ${TARGETS}:    # ensure existence
diff -r 60abc505f2de -r 569678cc8a01 share/mk/bsd.kmodule.mk
--- a/share/mk/bsd.kmodule.mk   Sat Sep 10 11:44:34 2011 +0000
+++ b/share/mk/bsd.kmodule.mk   Sat Sep 10 16:57:35 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.kmodule.mk,v 1.31 2011/07/14 18:12:35 matt Exp $
+#      $NetBSD: bsd.kmodule.mk,v 1.32 2011/09/10 16:57:35 apb Exp $
 
 # We are not building this with PIE
 MKPIE=no



Home | Main Index | Thread Index | Old Index