cvs commit: src Makefile

Ruslan Ermilov ru at FreeBSD.org
Thu Feb 19 05:41:13 PST 2004


On Tue, Feb 17, 2004 at 04:16:34PM -0500, Garance A Drosehn wrote:
> At 12:18 PM -0800 2/16/04, Garance A Drosehn wrote:
> >gad         2004/02/16 12:18:26 PST
> >
> >  FreeBSD src repository
> >
> >  Modified files:
> >    .                    Makefile
> >  Log:
> >  Add a 'realclean' target, which simply and quickly removes
> >  everything that was built in previous 'make buildworld' and
> >  'make buildkernel'.
> 
> Just a note on this.  The target might need some extra logic so
> it is smarter in how it handles some situations, so don't start
> using it in documentation just yet.
> 
Sorry, I could not reply earlier, been busy with real life issues,
so I'm doing the post-commit review.  The committed version has a
number of issues, namely:

- it's dangerous -- if .OBJDIR doesn't exist, it will wipe
  away your .CURDIR (typically /usr/src) which will upset
  many people out there including myself,

- it doesn't respect the -s option of make(1) -- the "echo"
  commands should be spelled ${ECHO} to respect this (see
  how ECHO is set in sys.mk),

- (minor) it uses home-grown style (space after a colon
  after a target name, -R vs. -r for rm(1), etc.),

- the comment mostly repeats what the code does, where it
  should actually document the intent of this target, not
  the gory details of how it achives its goal.  ;)

Also, why "rm -rf ${.OBJDIR}/*" instead of "rm -rf ${.OBJDIR}"?
Is it to preserve a possibly symlinked /usr/obj?

I suggest to commit the following which fixes all but the last
issue mentioned above.

%%%
Index: Makefile
===================================================================
RCS file: /home/ncvs/src/Makefile,v
retrieving revision 1.293
diff -u -r1.293 Makefile
--- Makefile	16 Feb 2004 20:18:25 -0000	1.293
+++ Makefile	19 Feb 2004 12:50:04 -0000
@@ -109,14 +109,12 @@
 # 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
+realclean:
+.if ${.OBJDIR} != ${.CURDIR}
+	-rm -rf ${.OBJDIR}/* 2>/dev/null
+	-chflags -R 0 ${.OBJDIR}/.
+	rm -rf ${.OBJDIR}/*
+.endif
 
 #
 # Handle the user-driven targets, using the source relative mk files.
%%%



Cheers,
-- 
Ruslan Ermilov
FreeBSD committer
ru at FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20040219/ac0865ba/attachment.bin


More information about the cvs-src mailing list