On 2/5/08, Derek Clegg <dclegg apple.com> wrote:
> On Feb 5, 2008, at 11:45 AM, Mike Shal wrote:
>
> > Pattern rules are treated a little differently.
Specifically, see
> > section 10.5.1 "Introduction to Pattern
Rules" in the make info pages:
> >
> > The order in which pattern rules appear in the
makefile is important
> > since this is the order in which they are
considered. Of equally
> > applicable rules, only the first one found is
used.
> >
> > In your example, only the first pattern rule will
apply, and the foo.h
> > dependency will be ignored.
>
> I'm not sure this is correct. If it were, as you point
out:
>
> > You could move foo.h to the line above and have a
single pattern
> > rule to get your expected behavior in this case.
>
> I tried this, and the behavior is unchanged. Unless
there's a bug,
> this implies that I have a single pattern rule:
> dir/%.c: %.c | dir ; cp $< $
>
> The rule
> dir/%.c: foo.h
>
> does not appear to be treated as a pattern rule.
(Otherwise, putting
> it first would have changed the behavior.)
>
Err, sorry I wasn't clear. I meant putting foo.h in the line
above,
not just swapping the two lines:
start: dir/a.c
dir/%.c: %.c foo.h | dir ; cp $< $
dir: ; mkdir $
a.c foo.h: ; touch $
$ make
touch a.c
touch foo.h
mkdir dir
cp a.c dir/a.c
I suspect just swapping the lines doesn't do what you would
think
because the pattern rule 'dir/%.c: foo.h' doesn't have any
commands
associated with it (such as the other rule does). I tried
swapping the
two lines and adding a command to the foo.h rule, and only
that rule
was executed.
Either way, Paul's advice about making the .o depend on the
.h is
probably the road you should pursue - I was just trying to
get your
script to generate your expected output
-Mike
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|