title: Make: Capture output of shell command and return code at same time
body: <p>In make, if I want to capture the output of a shell command, I do something like this</p>
  
  <pre><code>RESULT:=$(shell $(COMMAND))
  </code></pre>
  
  <p>If I want to check if a command executed properly, I do this</p>
  
  <pre><code>RETURN_CODE := $(shell $(COMMAND); echo $$?)
  </code></pre>
  
  <p>How can I do both simultaneously, i.e. execute the command once, store the output, but also check the return code?</p>
  
  <p><strong>EDIT</strong>
  Duplicate here although his solution is not pleasant:
  <a href="https://stackoverflow.com/questions/11157083/makefile-output-and-exitcode-to-variable">Makefile: Output and Exitcode to variable?</a></p>