Skip to content

Makefiles: Make "all", "clean" and "preinstall" root targets in Makefile2 recursive

In the "Unix Makefiles" generator, the subdirectory targets "all", "clean" and "preinstall" in Makefile2 are recursive. In the build root directory these targets aren't. Instead they're are added separately and additional dependencies are added on a per target basis. This is inconsistent and it complicates per directory commands, like a per directory clean command.

This topic branch makes the "all", "clean" and "preinstall" targets in Makefile2 in the build root directory recursive, using the same algorithm that is already used for subdirectories.

Side effects are:

  • Makefile2 gets smaller and simpler
  • The main "all", "clean" and "preinstall" targets have recursive dependencies, instead of flat (depth of 1) ones.

It also moves the ADDITIONAL_CLEAN_FILES directory target processing from the target level to the directory level, which fixes issue #8164 (closed). The MakeClean test is extended to cover subdirectories without targets.

Merge request reports