automake: Clean

1 
1 13 What Gets Cleaned
1 ********************
1 
1 The GNU Makefile Standards specify a number of different clean rules.
1 ⇒Standard Targets for Users (standards)Standard Targets.
1 
1    Generally the files that can be cleaned are determined automatically
1 by Automake.  Of course, Automake also recognizes some variables that
1 can be defined to specify additional files to clean.  These variables
1 are ‘MOSTLYCLEANFILES’, ‘CLEANFILES’, ‘DISTCLEANFILES’, and
1 ‘MAINTAINERCLEANFILES’.
1 
1    When cleaning involves more than deleting some hard-coded list of
1 files, it is also possible to supplement the cleaning rules with your
1 own commands.  Simply define a rule for any of the ‘mostlyclean-local’,
1 ‘clean-local’, ‘distclean-local’, or ‘maintainer-clean-local’ targets
1 (⇒Extending).  A common case is deleting a directory, for
1 instance, a directory created by the test suite:
1 
1      clean-local:
1              -rm -rf testSubDir
1 
1    Since ‘make’ allows only one set of rules for a given target, a more
1 extensible way of writing this is to use a separate target listed as a
1 dependency:
1 
1      clean-local: clean-local-check
1      .PHONY: clean-local-check
1      clean-local-check:
1              -rm -rf testSubDir
1 
1    As the GNU Standards aren’t always explicit as to which files should
1 be removed by which rule, we’ve adopted a heuristic that we believe was
1 first formulated by François Pinard:
1 
1    • If ‘make’ built it, and it is commonly something that one would
1      want to rebuild (for instance, a ‘.o’ file), then ‘mostlyclean’
1      should delete it.
1 
1    • Otherwise, if ‘make’ built it, then ‘clean’ should delete it.
1 
1    • If ‘configure’ built it, then ‘distclean’ should delete it.
1 
1    • If the maintainer built it (for instance, a ‘.info’ file), then
1      ‘maintainer-clean’ should delete it.  However ‘maintainer-clean’
1      should not delete anything that needs to exist in order to run
1      ‘./configure && make’.
1 
1    We recommend that you follow this same set of heuristics in your
1 ‘Makefile.am’.
1