[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU make to consider files checksum

From: Philip Guenther
Subject: Re: GNU make to consider files checksum
Date: Sun, 6 Sep 2009 19:08:02 -0700

On Fri, Apr 11, 2008 at 2:45 PM, Giuseppe Scrivano<address@hidden> wrote:
> I could find on this ML archives only a thread about this subject: to
> consider the file checksum instead of the timestamp.
> Other systems like scons already support this feature and it would be
> great to have it for GNU Make too.

This is a long dead thread (it's been sitting in my mailbox for a
year, ouch), but I'll throw in my two cents that a makefile can
implement this for itself with pattern rules.  Consider:

%.o: %.c
%.o.new: %.c
        $(COMPILE.c) -o $@ $<
%.o: %.o.new
        @{ [ -f address@hidden ] && md5sum -c --status address@hidden; } ||     
        { md5sum $< >address@hidden; cp $< $@; }


Poof, if you touch a .c file without making changes that affect the
compiler output, the executable will not be relinked.  Indeed, the
presence of the .SECONDARY target means the only thing that will be
rerun each time is the md5sum.

Yes, this is non-trivial to use, but it's also completely flexible,
letting you use whatever checksum comparison you want (need to strip
comments or RCS/CVS tags from the file before checksumming it?  Sure!)
and can be used Right Now.

Anyway, we now return you to your originally scheduled mailing list.

Philip Guenther

reply via email to

[Prev in Thread] Current Thread [Next in Thread]