14.4.4 distcleancheck

distcheck ensures that the distclean rule actually removes all built files. This is done by running ‘make distcleancheck’ at the end of the VPATH build. By default, distcleancheck will run distclean and then make sure the build tree has been emptied by running the value of the variable ‘$(distcleancheck_listfiles)’. Often this check will find generated files that you forgot to add to the DISTCLEANFILES variable (see What Gets Cleaned).

The distcleancheck behavior should be OK for most packages, otherwise you have the possibility to override the definition of either the distcleancheck rule, or the ‘$(distcleancheck_listfiles)’ variable. For instance, to disable distcleancheck completely (not recommended), add the following rule to your top-level Makefile.am:

distcleancheck:
        @:

If you want distcleancheck to ignore built files that have not been cleaned because they are also part of the distribution, make the following definition:

distcleancheck_listfiles = \
  find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \
       sh '{}' ';'

The above definition is not the default because it’s usually an error if your Makefiles cause some distributed files to be rebuilt when the user builds the package: consider the user missing the tool required to build the file; or if the required tool is built by your package, consider the cross-compilation case where it can’t be run.

Please see the (following) section Errors with distclean before playing with distcleancheck_listfiles.