help-make
[Top][All Lists]
Advanced

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

Re: Help with multiple dependencies in pattern rules


From: Noel David Torres Taño
Subject: Re: Help with multiple dependencies in pattern rules
Date: Mon, 8 Feb 2010 18:59:03 +0100
User-agent: KMail/1.9.9

On Monday 08 February 2010 15:03:14 Paul Smith wrote:
> On Mon, 2010-02-08 at 14:08 +0100, Noel David Torres Taño wrote:
> > I want to express in a Makefile that all *.o files must be compiled
> > from their *.F95 sources, and that all *_m.o files depend on the *.o
> > file (without the '_m'). This is because foo_m.F95 includes foo.F95,
> > and thus if either foo{,_m}.F95 changes, the foo_m.o must be rebuilt.
> > 
> > I tried using
> > 
> > %.o : %.F95
> >         $(FC) $(FFLAGS) -o $@ -c $<
> > 
> > %_m.o : %.F95
> > 
> > but the second rule seems to be ignored.
> 
> There are a number of issues here.
> 
> First, note that GNU make matches pattern rules in the order they are
> defined in the makefile, so the first pattern rule, which is a strict
> superset of the second one, will always match and the second one will be
> ignored.  You'd need to switch the order.
> 
> Second, every pattern rule MUST have a command with it.  If a pattern
> rule has no command, then it actually deletes the pattern rule; so your
> second line has no effect anyway (it's deleting that pattern rule).
> 
> Both of these behaviors are described in the GNU make manual.

I've readed the manual. Just think that not everybody in the world is english 
native speaker.
> 
> Third, in your description you say that "if either foo{,_m}.F95 changes,
> the foo_m.o must be rebuilt" but that's not what the above rule says
> even if it worked.  It says that foo_m.o depends on foo.F95, and nothing
> more.

I tried to add this dependency to the first one, but now that you explained how 
the pattern rules work (better than in the manual, at least for me, maybe 'cos 
it is an example here) I understand that it didn't work.
> 
> One way to do what your description says is this, although I'm not sure
> I understand what you really want based on that description:
> 
>       %_m.o : %_m.F95 %.F95
>               $(FC) $(FFLAGS) -o $@ -c $<
>       %.o : %.F95
>               $(FC) $(FFLAGS) -o $@ -c $<
> 

Yes, it is what I wanted and it works. Thanks

Noel

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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