From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 15 16:42:00 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 64FF716A4EC for ; Sun, 15 Feb 2004 16:42:00 -0800 (PST) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 22F4343D1F for ; Sun, 15 Feb 2004 16:42:00 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i1G0fxnI022939 for ; Sun, 15 Feb 2004 19:41:59 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20040215.101900.20429400.imp@bsdimp.com> References: <20040215.101900.20429400.imp@bsdimp.com> Date: Sun, 15 Feb 2004 19:41:58 -0500 To: hackers@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: CanIt (www . canit . ca) Subject: Re: Adding 'realclean' target to /usr/src/Makefile X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Feb 2004 00:42:00 -0000 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