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

M. Warner Losh imp at bsdimp.com
Sun Feb 15 09:20:01 PST 2004


In message: <p0602040fbc54cd0d3342@[128.113.24.47]>
            Garance A Drosihn <drosih at rpi.edu> writes:
: realclean :
: 	rm -Rf ${.OBJDIR}/*

I'd make that be more like:

realclean :
	@chflags -R 0 ${.OBJDIR}/*
	@rm -Rf ${.OBJDIR}/*

since sometimes you wind up files that have flags set on them.  I once
looked into hacking rm to do that in one step, but couldn't figure out
a way to do it race free and punted.  There was no notion of a
funlink.  this is conceptually as close as I got:

	 fd = open(path, O_RDRW);	/*1*/
	 fchflags(fd, 0);
	 unlink(path);			/*2*/

which races between /*1*/ and /*2*/.

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}/*


Warner


More information about the freebsd-hackers mailing list