Adding 'realclean' target to /usr/src/Makefile

Garance A Drosihn drosih at rpi.edu
Sun Feb 15 16:42:00 PST 2004


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 at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu


More information about the freebsd-hackers mailing list