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