Re: makefile question: always recompile a file

Eric Sosman <[email protected]> Wed, 26 Aug 2009 17:12:11 -0400
Newsgroups gmane.comp.gnu.utils
Organization A noiseless patient Spider
Message-ID <h748gi$35l$1__1658.29967377267$1251333647$gmane$org@news.eternal-september.org>
Jim wrote:
> Hi,
> 
> I'm using a make program similar to gnu make.  I'd like to always
> recompile a file whenever ANY file is compiled (or assembled).
> Preferably (but not absolutely necessary), I'd like the file to
> recompile if the linker runs as well, but this sounds really tough.
> In case you're wondering, this file contains a global array that has
> time and date stamp information in it so we can tell when the project
> was last built.
> 
> Some engineers don't like a simple "delete the object file always when
> make runs" approach because if you inadvertently run make a second
> time, you get a recompile even if no sources changed.
> 
> Any ideas on how to do this?

     Maybe you could find half a dozen more newsgroups to ask?

     A first cut might be to put the recompile *in* the link
step, unconditionally, along the lines of (sketch)

	OBJECTS = ... everything *except* timestamp.o ...
	target: $(OBJECTS)
		cc $(CFLAGS) -o target timestamp.c $(OBJECTS)

If you run make twice and it sees that target is up to date
(note that timestamp.c doesn't count toward that decision), it
will not run the link step and will not recompile timestamp.c.

-- 
Eric Sosman
[email protected]