make: Cleanup

1 
1 2.7 Rules for Cleaning the Directory
1 ====================================
1 
1 Compiling a program is not the only thing you might want to write rules
1 for.  Makefiles commonly tell how to do a few other things besides
1 compiling a program: for example, how to delete all the object files and
1 executables so that the directory is 'clean'.
1 
1    Here is how we could write a 'make' rule for cleaning our example
1 editor:
1 
1      clean:
1              rm edit $(objects)
1 
1    In practice, we might want to write the rule in a somewhat more
1 complicated manner to handle unanticipated situations.  We would do
1 this:
1 
1      .PHONY : clean
1      clean :
1              -rm edit $(objects)
1 
1 This prevents 'make' from getting confused by an actual file called
1 'clean' and causes it to continue in spite of errors from 'rm'.  (See
1 ⇒Phony Targets, and ⇒Errors in Recipes Errors.)
1 
1 A rule such as this should not be placed at the beginning of the
1 makefile, because we do not want it to run by default!  Thus, in the
1 example makefile, we want the rule for 'edit', which recompiles the
1 editor, to remain the default goal.
1 
1    Since 'clean' is not a prerequisite of 'edit', this rule will not run
1 at all if we give the command 'make' with no arguments.  In order to
11 make the rule run, we have to type 'make clean'.  ⇒How to Run
 'make' Running.
1