title: Exiting from a Makefile based on the state of two shell variables
body: <p>During <code>make checksource</code>, <code>$CROSS_COMPILE</code> should be <code>&quot;whatever&quot;</code>.  If <code>$CROSS_COMPILE</code> is not set, <code>make</code> should throw an error and exit.</p>
  <p>I have the following rule in my <code>Makefile</code>:</p>
  <pre><code>.PHONY: checksource
  
  all: checksource default
  
  checksource:
      $(if $(and $(ifeq ($(CROSS_COMPILE), whatever)), $(ifeq ($(VARIABLE),))), \
      ($(shell echo &quot;Error! VARIABLE not defined!&quot;) \
       $(shell exit 2)))
  </code></pre>
  <p>Right now if <code>$CROSS_COMPILE</code> is set to whatever and <code>$VARIABLE</code> is undefined, the <code>make</code> doesn't exit.</p>
  <p><code>$CROSS_COMPILE</code>:</p>
  <pre><code>$&gt; echo $CROSS_COMPILE
  whatever
  $&gt;
  </code></pre>
  <p><code>$VARIABLE</code> is not defined:</p>
  <pre><code>$&gt; echo $VARIABLE
  $&gt;
  </code></pre>
  <p>I could use a nested <code>ifeq</code>, but I want to make it pretty (and learn a bit more about <code>Makefile</code> operations).</p>