help-make
[Top][All Lists]
Advanced

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

Re: Bug or correct behavior?


From: Derek Clegg
Subject: Re: Bug or correct behavior?
Date: Tue, 5 Feb 2008 13:22:41 -0800

On Feb 5, 2008, at 11:40 AM, Paul Smith wrote:

On Tue, 2008-02-05 at 11:32 -0800, Derek Clegg wrote:
Given this simple makefile

start: dir/a.c
dir/%.c: %.c | dir ; cp $< $@
dir/%.c: foo.h
dir: ; mkdir $@
a.c foo.h: ; touch $@

I'm seeing the following when I run make:

touch a.c
mkdir dir
cp a.c dir/a.c

This is surprising; my expectation is that the dependency "dir/%c.:
foo.h" would force "foo.h" to be created as well.  Is this a bug or
correct behavior?

This is correct.

Pattern rules are not the same as explicit rules: only one pattern rule will ever match a given target. Make goes through them in the order you define them and whichever one matches first will be used; the rest will
be ignored.

I responded to Mike Shal in a similar vein. If you're correct, changing the order of the "dir/%.c:" lines would change the behavior, but it doesn't appear to.

Anyway, I don't think you really want the .c file to depend on the .h
file, do you?  That's pretty unusual.  You don't need to copy the .c
file again just because the .h file changes?!?!

This is a trivial makefile for illustration purposes only. Best not to take it literally :-)

Derek




reply via email to

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