I have a version.c file in my project that contains current revision of the project and some other stuff that is passed as a definition (-D compiler option) from makefile.
The classic way to do it is:
version.o: .FORCE
.FORCE:
(and you might add .PHONY: .FORCE
). The file '.FORCE' is presumed not to exist, so it is always 'created', so version.o
is always out of date w.r.t it, so version.o
is always compiled.
I'm not sure that making version.o
into a phony file is correct; it is actually a real file, not a phony one.