Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL
The "all" target in each directory is supposed to have targets from that
directory even if the directory itself is marked
its parent. This was broken by !2816 (merged) which made the
participation of a target in "all" independent of context. Revert much
of the logic change from that commit to restore the old behavior. Then
re-implement the behavior intended by the commit to keep its test
working. Extend the test to cover the old behavior too.
Also revert the main Makefile global graph logic change from !3338 (merged) for the "all" and "preinstall" targets.
The MR cleaned up the Makefile generator to use the same logic for
the "all" target in the top-level directory as for subdirectories. It
exposed a long-existing bug that caused the "all" target in a
subdirectory to include the "all" targets from sub-subdirectories even
if they are marked
Tests/SubDir test should
have failed but the problem was currently covered up by the main bug fixed here.
Revert the top-level "all" and "preinstall" targets to the old approach
so we can fix the main bug without exposing the long-existing bug
at the top-level. Leave the "clean" target in the new approach because
it does not honor
Fixes: #19753 (closed)