title: How to get the exit status of a bash command in makefile?
body: <p>I have a Makefile like this:</p>
  
  <pre><code>k:
          status=$(shell ./x.sh;echo $?)
          ifeq ( $(status),0)
                     echo success
          else
                     echo failure
                     exit 1
          endif
  </code></pre>
  
  <p><code>x.sh</code> is simple script that prints numbers 1 to 10.</p>
  
  <p>So when I execute make:</p>
  
  <pre><code>ramana@Ramana:$make k
  status=1 2 3 4 5 6 7 8 9 10
  /bin/sh: 1: 2: not found
  Makefile:2: recipe for target 'k' failed
  make: *** [k] Error 127
  </code></pre>
  
  <p>Here I get the output of script instead of <code>$?</code>. And when I compare in <code>ifeq</code> <code>status</code> value is null.</p>
  
  <p>How do I get this work? Also how do I use .ONESHELL directive? Can I really exit from make if something goes wrong instead of executing the following instructions with <code>exit 1</code>?</p>