title: How to get exit status of a shell command used in GNU Makefile?
body: <p>I have a makefile rule in while I am executing a linux tool. I need to check the exit status of the tool command, and if that command fails the make has to be aborted. </p>
  
  <p>I tried checking with $?, $$? \$? etc in the makefile. But they gives me syntax error when makefile runs.</p>
  
  <p>What is the right way to do this ?</p>
  
  <p>Here is the relevant rule in Makefile</p>
  
  <blockquote>
  <pre><code>    mycommand \
      if [ $$? -ne 0 ]; \
      then \
          echo "mycommand failed"; \
          false; \
      fi
  </code></pre>
  </blockquote>