title: How does this part of the ASOP makefile work?
body: <p>I am trying to modify the AOSP build system to run a script after 'make dist'</p>
  
  <p>I have code that does what I want it to.... but I don't really understand it and would love an explanation and what is happening.  The file I am looking at is:</p>
  
  <p><a href="https://android.googlesource.com/platform/build.git/+/master/core/distdir.mk" rel="nofollow">https://android.googlesource.com/platform/build.git/+/master/core/distdir.mk</a></p>
  
  <pre><code>.PHONY: dist
  dist: ;
  
  dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
  MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
  ifeq (,$(strip $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))))
  # The commandline was something like "make dist" or "make dist showcommands".
  # Add a dependency on a real target.
  dist: $(DEFAULT_GOAL)
  endif
  </code></pre>
  
  <p>The part that is confusing me is how there are two definitions for dist: but no warnings. If I had a recipe on to the second dist: target it will generate a warning about dist being redefined.  What is the point of this second target?</p>