title: Dependency on a remote file in make
body: <p>I have a situation where I need to execute a rule in make depending on a remote file. This is an example of what I'm trying to do (the actual Makefile is a lot more complicated in ways that aren't relevant here):</p>
  
  <pre><code>URL = http://cdn.sstatic.net/stackoverflow/img/favicon.ico
  
  stackoverflow.png: favico.ico modified | check_modified
      convert favicon.ico $@
  
  check_modified: modified
      @echo Icon was modified. Downloading.
      rm -f favicon.ico
      wget $(URL)
  
  .PHONY: check_modified
  
  favico.ico: check_modified
  
  modified:
      touch -d "`wget --spider -S $(URL) 2&gt;&amp;1 | sed -n 's/.*Modified: //p'`" $@
  </code></pre>
  
  <p>The idea is:</p>
  
  <ul>
  <li>The rule to build <code>modified</code> should <em>always</em> be run. The function of that rule is to change the modification time of the file to be the same as the modification time of what the URL points to.</li>
  <li>After that, I want <code>modified</code> to behave normally in terms of dependencies. If <code>modified</code> is more recent than <code>favicon.ico</code>, I want to retrieve the new file and then let the dependency on it cause the target file to be remade.</li>
  </ul>
  
  <p>As a wrinkle, in some applications, I have to retrieve the file manually. In those cases, I want to just have a rule that fires and tells me to manually download the file, but that doesn't otherwise affect building the target. As an example, if the source image that I'm converting were behind a site login, I'd need to manually login to the site and download it to a fixed location and then rerun make.</p>
  
  <p>Everything I've tried either:</p>
  
  <ul>
  <li>Fails to check the URL if the target is up to date, or</li>
  <li>Always checks the URL and rebuilds the target, even if <code>modified</code> is not more recent than the target.</li>
  </ul>
  
  <p>Any words of wisdom?</p>