[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New Rule vs. Dependency List
From: |
Paul D. Smith |
Subject: |
Re: New Rule vs. Dependency List |
Date: |
Thu, 27 Jun 2002 18:02:35 -0400 |
%% Charles Gerlach <address@hidden> writes:
cg> I don't understand why adding a path forces GNUmake to see
cg> a dependency list as a rule.
It doesn't.
cg> obj.o : obj.f90 dep1 dep2 dep3
cg> #No Tab, no rule.
cg> Then GNUmake recognizes that this is strictly a dependency
cg> list, and uses the pattern rule that I wrote to compile
cg> the object into the directory from which I ran make.
cg> I want the .o file to live in directory $(DIR), so I
cg> modify the dependency list:
cg> $(DIR)/obj.o : obj.f90 dep1 dep2 dep3
cg> #No Tab, no rule.
cg> Now when $(DIR)/obj.o does not exist, GNUmake checks to see
cg> that the dependencies are up to date, but does nothing if
cg> they are. It does not apply the pattern rule. I belive it
cg> thinks that I'm now writing a new rule, and then assumes that
cg> rule is null since I don't have anything specified.
Your belief is incorrect :). If you use "make -d" you'll see quite
quickly that make _is_ doing implicit rule searching for this target.
The reason it doesn't apply the pattern rule couldn't be simpler: the
target no longer matches the pattern!
The pattern is:
%.o : %.f90
In your first example when make wants to find an implicit rule it comes
to this pattern, sees that "%" matches "obj", then expands the
prerequisite "%.f90" to "obj.f90". It then tries to create the target
"obj.f90", finds a local file, succeeds, and Bob's your uncle.
In your second example when make wants to find an implicit rule it comes
to this pattern and sees that "%" matches "$(DIR)/obj". So, then make
expands the prerequisite "%.f90" to "$(DIR)/obj.f90". It then tries to
create the target "$(DIR)/obj.f90". No such file exists, and make
cannot find any other implicit rule to create it, so this pattern _does
not match_.
In fact, no pattern will match. So, if the file exists already make
decides it must be OK, since it has no rule to create it, and says
"nothing to do". If the file does not exist, it will say "no rule to
create target".
If you want to build $(DIR)/obj.o from obj.f90, you will have to write a
new implicit rule that matches that pattern:
$(DIR)/%.o : %.f90
...
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist