2 fix title to state the right command that's failing
| link

why Why does patchdiff fail when invoked from a Makefile?

1
source | link

why does patch fail when invoked from a Makefile

Narrow-down of a patch problem I am trying to troubleshoot: Only two files, each with a size of 1 byte:

  • file a (containing 'a')
  • file b (containing 'b') and

Goal is to make and then apply a patch that will change the value of 'b' to 'a'. Contents of Makefile are:

patch:
        diff -u b a > b2a.patch
        patch -o b.corrected b < b2a.patch
        diff a b.corrected

clean:
        rm -f b2a.patch b.corrected

Given the above, make fails with the following output:

$ make
diff -u b a > b2a.patch
make: *** [patch] Error 1

If, however, I execute the commands in the Makefile one after the other on the bash shell, there is no problem at all.