title: md5sum fails to find file after changing dir in a Makefile instruction
body: <p>I am having trouble generating a package with a md5sum of the contained files using Makefiles.</p>
  
  <p>I do have found an workaround, but I am not satisfied with it.</p>
  
  <p>This is a example of how my makefile works, it can be used to reproduce my problem with <code>file1</code>, and my workaround with <code>file2</code>.</p>
  
  <pre><code>    VERSION:=1
      DIR:=tmp
  
      file: #rule to build the file with current version tag
              touch $(DIR)/file-$(VERSION)
  
      $(DIR)/file1.tar:file #rule that fails to create the md5 file
              cd $(DIR)
              md5sum -b \
                      file-$(VERSION) \
                      &gt;&gt; file-$(VERSION).md5
              tar -cf $@ \
                      file-$(VERSION) \
                      file-$(VERSION).md5
              cd -
  
      $(DIR)/file2.tar:file #workaround that fails to create the md5 file
              md5sum -b \
                      $(DIR)/file-$(VERSION) \
                      &gt;&gt; $(DIR)/file-$(VERSION).md5
              tar -cf $@ -C $(DIR) \
                      file-$(VERSION) \
                      file-$(VERSION).md5
  
      file1: $(DIR) $(DIR)/file1.tar
  
      file2: $(DIR) $(DIR)/file2.tar
  
      $(DIR):
              mkdir -p $(DIR)
  </code></pre>
  
  <p>Running <code>file1</code>, the build fails and I get the following output:</p>
  
  <pre><code>:~/tmp$ make file1
  mkdir -p tmp
  touch tmp/file-1
  cd tmp
  md5sum -b \
      file-1 \
      &gt;&gt; file-1.md5
  md5sum: file-1: No such file or directory
  Makefile:8: recipe for target 'tmp/file1.tar' failed
  make: *** [tmp/file1.tar] Error 1
  </code></pre>
  
  <p>Running <code>file2</code>, the file is built successfully:</p>
  
  <pre><code>:~/tmp$ make file2
  touch tmp/file-1
  md5sum -b \
      tmp/file-1 \
      &gt;&gt; tmp/file-1.md5
  tar -cf tmp/file2.tar -C tmp \
      file-1 \
      file-1.md5
  </code></pre>
  
  <p>My question is, why <code>md5sum</code> tool fails to find the file in the same dir as it is running after calling <code>cd dir</code> when it is used as a <code>Makefile</code> instruction? Or, what I am missing?</p>