Understanding a complex Makefile

I am trying to improve my ability to read and understand what a Makefile is doing so that I can be better at troubleshooting issues when attempting to compile software to be used on our system.

So I am going to use an example Makefile from TexLive.

On line 870, there is a target called check that has a pre-requisite called “check-recursive”.

I don’t see “check-recursive” defined anywhere in the Makefile, other than listed in an the environment variable RECURSIVE_TARGETS on line 244:

Then I see RECURSIVE_TARGETS set to am__recursive_targets on line 259:

Then starting on line 573 I see am__recursive_targets seems to be defined as a target and actually runs a target recursively through the subdirectories:

So when I run make check, it seems check-recursive, RECURSIVE_TARGETS and am__recursive_targets are involved to make this work, but I am confused on what steps make is taking.
Can someone explain this to me? Or point me to a resource that may satisfy my curiosity?

I found some of the logic of what is happening in the following Stackoverflow post:

It appears this complex Makefile is generated by Autotools. The RECURSIVE_TARGETS variable contains a list of targets that will be defined. It is appended to am__recursive_targets, along with some other lists.

am__recursive_targets is substituted into line 573 via $(am__recursive_targets): where a list of targets is populated like this:

all-recursive check-recursive cscopelist-recursive \
	ctags-recursive dvi-recursive html-recursive info-recursive \
	install-data-recursive install-dvi-recursive \
	install-exec-recursive install-html-recursive \
	install-info-recursive install-pdf-recursive \
	install-ps-recursive install-recursive installcheck-recursive \
	installdirs-recursive pdf-recursive ps-recursive \
	tags-recursive uninstall-recursive: .....
      <target definition>

If one looks at the commands in this target, there is a sed command at line 581:

This is where the -recursive tail of the target is removed and check-recursive becomes check, which is then used in the sub-directories to run the desired make command.