[Top][All Lists]

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

Re: non-recursive build question

From: Boris Kolpackov
Subject: Re: non-recursive build question
Date: Thu, 29 Apr 2004 13:05:17 -0500
User-agent: Mutt/1.5.4i

Paul D. Smith <address@hidden> writes:
> How do you handle header files?
>     foo.o: foo.c foo.h bar.h baz.h

Good point ;-)

> There is no target for creating header files, so there's nowhere to hook
> the checksum process into.
> You would have to make it visible to the user, by having them write a
> different name in the prerequisite list:
>     foo.o: foo.c foo.h.md5 bar.h.md5 baz.h.md5

That's true. One idea came into my mind: imagine we have double expansion 
in implicit rules ;-) plus we have a special variable (let's call
it $^) defined during this expansion which holds the list of prerequisites
that come from non-pattern rules. In example above it will contain 
"foo.c foo.h bar.h baz.h". Then we could write something like this:

%.o: %.c.md5 $$(addsuffix\ .md5,$$^)
        $(CC) -o $@ -c $(<:.md5=) && echo $+

%.md5: %
        md5sum $< | cmp -s $@ -; if test $$? -ne 0; then md5sum $< > $@; fi

Interestingly, after some more think I don't quite understand how my
original example works (and it does work, I tested: when I touch foo.c,
foo.o is not rebuilt). When I run it with -p I see the following expansion
of the implicit rule:

foo.o: foo.c.md5 foo.c

This means that if foo.c is touched then foo.o is out of date. It doesn't
work that way for some reason, however.


Attachment: pgptux84yTQVJ.pgp
Description: PGP signature

reply via email to

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