help-make
[Top][All Lists]
Advanced

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

Re: Dependency of a dependency in make?


From: Paul D. Smith
Subject: Re: Dependency of a dependency in make?
Date: Thu, 22 Nov 2001 14:47:51 -0500

%% Peter Sherwood <address@hidden> writes:

  ps> source.o: source.h header1.h

  ps> header1.h: header2.h

  ps> By writing the makefile in this way, I expected that changes in
  ps> header2.h would cause source.c to get recompiled to source.o,
  ps> since source.o depends on header1.h and header1.h depends on
  ps> header2.h. But this is not the case.

No.  What that means is that, if the file header1.h does not exist or is
older than header file header2.h, then make will try to build header1.h
from header2.h.  Since you didn't define a rule that would do that, it
will give an error in that situation.

  ps> How can I accomplish what I want, without putting header2.h in as an
  ps> explicit dependency wherever I have header1.h now?

You can't.  All the files that are needed to build a target must be
listed as prerequisites of that target.  That's how make works.


You can investigate my web site below for information on how to build a
makefile that automatically constructs dependencies, so you don't have
to do it by hand at all.

-- 
-------------------------------------------------------------------------------
 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



reply via email to

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