title: Can a Makefile execute code ONLY when an error has occurred?
body: <p>In my Makefile, I have some code that checks for network connectivity. This code takes a decent amount of time to run and I would only like to run it if another target fails to build.</p>
  
  <h1>Current Makefile</h1>
  
  <pre><code>all: files network
      # compile files
  
  files:
      # get files from network resources
  
  network:
      # check for network connectivity
      # echo and return an error if it's not available
  </code></pre>
  
  <p>Execution Order:</p>
  
  <pre><code>if not network:
      # exit with error
  if not files:
      # exit with error
  if not all:
      # exit with error
  </code></pre>
  
  <h1>Desired Makefile</h1>
  
  <p>In the above example, I would like the <code>network</code> target to be "made", only if the <code>files</code> target fails to get "made".</p>
  
  <p>Execution Order:</p>
  
  <pre><code>if not files:
      if not network:
          # exit with error
  if not all:
      # exit with error
  </code></pre>