Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Feb 2004 19:41:58 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        hackers@freebsd.org
Subject:   Re: Adding 'realclean' target to /usr/src/Makefile
Message-ID:  <p06020414bc55bcb45ebc@[128.113.24.47]>
In-Reply-To: <20040215.101900.20429400.imp@bsdimp.com>
References:  <p0602040fbc54cd0d3342@[128.113.24.47]> <20040215.101900.20429400.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
At 10:19 AM -0700 2/15/04, M. Warner Losh wrote:
>
>If you can tolerate errors in the output, the following is
>faster because the chflags has lots less work to do:
>
>realclean :
>	@rm -Rf ${.OBJDIR}/*
>	@chflags -R 0 ${.OBJDIR}/*
>	@rm -Rf ${.OBJDIR}/*


After some testing, I am planning to go with:

Index: Makefile
===================================================================
RCS file: /home/ncvs/src/Makefile,v
retrieving revision 1.292
diff -u -r1.292 Makefile
--- Makefile	9 Dec 2003 02:08:19 -0000	1.292
+++ Makefile	16 Feb 2004 00:29:54 -0000
@@ -104,6 +104,21 @@
  .endif

  #
+# This 'realclean' target is not included in TGTS, because it is not
+# a recursive target.  All of the work for it is done right here.
+# The first 'rm' will usually remove all files and directories.  If
+# it does not, then there are probably some files with chflags set.
+# Unset all special chflags, and try the 'rm' a second time.
+realclean :
+	-rm -Rf ${.OBJDIR}/* 2>/dev/null
+	@-if [ "`echo ${.OBJDIR}/*`" != "${.OBJDIR}/*" ] ; then \
+	    echo "chflags -R 0 ${.OBJDIR}/*" ; \
+	    chflags -R 0 ${.OBJDIR}/* ;  \
+	    echo "rm -Rf ${.OBJDIR}/*" ; \
+	    rm -Rf ${.OBJDIR}/* ; \
+	fi
+
+#
  # Handle the user-driven targets, using the source relative mk files.
  #

  = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

If the first 'rm' works, the other two commands will not be
executed, and the user will only see the first 'rm'.  If the
other two commands are executed, then the user will also see
echoed-versions of those commands before they are executed.

So, if there is some chflag'ed file in /usr/obj/..., what the
user sees is:

(330) keep-talking/root # make realclean
rm -Rf /usr/obj/usr/src/* 2>/dev/null
*** Error code 1 (ignored)
chflags -R 0 /usr/obj/usr/src/*
rm -Rf /usr/obj/usr/src/*

-- 
Garance Alistair Drosehn            =   gad@gilead.netel.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p06020414bc55bcb45ebc>