[cs631apue] HW5 questions

Jan Schaumann jschauma at stevens.edu
Thu Dec 8 15:54:45 EST 2011

Rob Hoffmann <rhoffman at stevens.edu> wrote:

> In your hw specs you mention "if the patch was already applied, running  
> 'make' won't do this again etc". After reading through the man pages &  
> Google for diff/patch again and again I don't see any way to tell  
> whether or not a file has been patched already before running the patch  
> command, because there is no original file to do a diff or cmp against.  

You are trying to make diff(1) determine whether or not it already ran.
diff(1) can't do that.  make(1) can figure out whether or not something
else has been done by checking dependencies and timestamps.  If whatever
command make(1) invokes does not create a new file (as would be the
example for a compiler creating an object file), then you can do that

For example, you need to encode in make(1) the logic that says "if
patch(1) was not yet invoked, invoke patch(1)", which might translate to
"if some file does not exist, that means that patch(1) was not yet
invoked, so invoke patch(1) and then update the timestamp on some file
(or create that file)".


More information about the cs631apue mailing list