5 messages in com.perforce.jamming[jamming] Use of clean with directories
FromSent OnAttachments
Barrie Stott01 Jul 2003 09:37 
Matt Armstrong01 Jul 2003 10:23 
Diane Holt01 Jul 2003 10:56 
Barrie Stott02 Jul 2003 06:29 
Eric Sunshine07 Jul 2003 00:57 
Subject:[jamming] Use of clean with directories
From:Eric Sunshine (ja@sunshineco.com)
Date:07/07/2003 12:57:53 AM
List:com.perforce.jamming

Barrie Stott wrote:

A simple question. I am happy with Clean for getting rid of files but don't know how to get rid of directories. Can someone help, please?

For the Crystal Space project (http://crystal.sf.net/), I handled this issue by creating a CleanDir rule which parallels the existing Clean rule. The code looks like this:

------ >8 cut here 8< ------ DELTREE ?= "rm -rf" ;

# CleanDir <tag> : <dir> ... # Forcibly delete a set of directories, even if they are not empty. # Tag is one of the standard targets used with the "Clean" rule, such as # "clean" or "distclean". rule CleanDir { Always $(<) ; NotFile $(<) ; NoCare $(>) ; }

actions piecemeal together existing CleanDir { $(DELTREE) $(>) } ------ >8 cut here 8< ------

You use the CleanDir rule just like you would use Clean. For example:

Clean clean : $(OBJS) ; CleanDir clean : $(OBJDIR) ; CleanDir distclean : $(CONFIGDIR) ; CleanDir maintainerclean : autom4te.cache ;

Note that you will probably want to conditionalize DELTREE on a per-platform basis.

-- ES