I suppose you already have a Makefile that creates the application. So here you can add:
# Use ':=' instead of '=' to avoid multiple evaluation of NOW.
Note the replacement of ':' by '_' . As stated here , if the date contains a colon, it probably wonβt be able to parse the Makefile.
I donβt have access to Mac OS X at the moment, so this was only tested on Ubuntu, but I worked on the Mac once and I didnβt notice any significant differences in make . So this will work for you too.
--- change ---
As Beta correctly comments, the method described above creates a new copy with the current date each time make is called. Sometimes this may be desirable, so I will leave it and offer the following alternative for situations where this is not the case:
# Same as above... NOW := $(shell date +"%c" | tr ' :' '__')
Why did the target foo_$(NOW) disappear? Since you only want to create a copy of the application with a date check if you modified the application directly. This means that you cannot create a target, because then make always created a copy (as in the above scenario).
This, however, means that make not aware of the existence of a copy. A copy is missing from the dependency graph that make creates at startup. Therefore, a copy cannot be used as a prerequisite for any other purpose. This is not a flaw, but a direct result of what we do not know in advance if we are going to create a copy or not. (If anyone has a way to overcome this without performing a minor run, please treat me :)).
source share