I want to apply a patch in a makefile. This works great if the patch is not yet applied. However, if I try to do it after the source file has already been fixed, it will force the makefile to exit before completion.
Makefile -
all:
echo "starting patch"
patch -N < patchfiles/foo.patch
echo "patched"
The results after trying to run after the file are already fixed -
usr-mbp:makefile usr$ make
echo "starting patch"
starting patch
patch -N < patchfiles/foo.patch
patching file foo
Reversed (or previously applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file foo.rej
make: *** [all] Error 1
I figured that using the -N option would just skip the patch and not cause any errors. Apparently, I was wrong. Any ideas on how to fix the makefile so that it doesn't interpret the missing patch as an error?
Thank!
EDIT:
If I want to write cd to the directory before the patch, then using -patch does not work. This is the result:
Makefile:
all:
echo "starting..."
cd tmp && \
-patch -N < ../patchfiles/Makefile.linux-p3041-3_0.patch
echo "finished."
Results:
usr-mbp:makefile usr$ make
echo "starting..."
starting...
cd tmp && \
-patch -N < ../patchfiles/Makefile.linux-p3041-3_0.patch
/bin/sh: line 1: -patch: command not found
make: *** [all] Error 127
source
share