title: GNU Makefile equivalent of shell 'TRAP' command for concise identification of build failure on exit
body: <p>Criteria: Makefile is a GNU Make Makefile - I'm not interested in makepp, qmake, cmake, etc. They're all nice (especially cmake), but this is for work and at work we use GNU Make. The optimal solution is a pure Makefile solution rather than a shell script that parses make for you. </p>
  
  <p>I also don't want to do a 'continue on failure' solution - if it's broken, it's broken and needs to be fixed.</p>
  
  <p>The situation is this, I've got a makefile that builds several directories in parallel - if one of them fails, of course the whole build fails, but not until all the running makes run to completion (or failure). This means that the reason why make actually failed is buried somewhere arbitrarily far from the end of make's output.</p>
  
  <p>Here's an example of what I've got:</p>
  
  <pre><code>all: $(SUBDIRS)
  
  SUBDIRS = \
    apple \
    orange \
    banana \
    pineapple \
    lemon \
    watermelon \
    grapefruit
  
  $(SUBDIRS):
    cd $@ &amp;&amp; $(MAKE) $(MFLAGS) 2&gt;&amp;1 | sed -e "s/^/$(notdir $(@)): /g"
  </code></pre>
  
  <p>If I run 'make -j 5' and 'orange' happens to fail - I'd like to see a table like this at the end
  of the make process</p>
  
  <pre><code>  apple     - passed
    orange    - FAILED
    banana    - passed
    pineapple - passed
    lemon     - passed
  </code></pre>
  
  <p>I've considered having an &amp;&amp; echo "passed" >.result || echo "FAILED" >.result, but make still needs some sort of TRAP or __onexit() cleanup command to print at them on exit.</p>
  
  <p>Any Makefile ninjas out there have a pure-makefile solution for this? </p>
  
  <p>un-edit - my solution wasn't actually working the way I had hoped.. STYMIED!</p>