help-make
[Top][All Lists]
Advanced

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

RE: makedepends and implicit rule


From: Dave Korn
Subject: RE: makedepends and implicit rule
Date: Tue, 30 Jan 2007 16:42:11 -0000

On 30 January 2007 15:50, sharan basappa wrote:

> I am trying to get my make basics right.
> 
> I have 2 questions about working of make
> 
> 1) Implicit rules
> 
> I write a rule like this
> 
> a : a.o
> 
> When I execute make, the foll. 2 command execute
> 
> cc -c -o b.o b.c
> cc b.o -o b

  If you're reporting a problem or bug, it's a really bad idea to falsify your
bug report.  Cut and paste the actual output into your email, because if you
retype it by hand, you'll get it wrong.  It's such an obvious mistake here
that it didn't do any harm, but if you got a more subtle typo you could waste
hours of somebody's time trying to sort out a problem that wasn't actually
what you said it was.

> Thing which is perplexing is that I have not written a fule which has a.o as
> target, yet make
> compiles a.c and creates a.o (its a different story that this is what I
> really wanted make to do)
> 
> Which implicit rule is making this happen ?

  Make has an implicit "%.o : %.c" rule.  Look in the make info file, section
10.2 "Catalogue of Implicit Rules".


> 2) makedepend
> 
> I am trying to use makedepend to create dependancy rules automatically.
> My make to do that is as follows
> 
> b : b.o
> 
> .PHONY : depend
> depend :
>       @makedepend -f -b.c > dependancies.d
> 
> -include dependancies.d
> 
> Is there a file called dependancies.d created when as a result of executuion
> of this make file ?
> I did not find this file in my dir ? Am I doing some mistake ?

  If you just run "make" without any commands, it treats the very first target
in the makefile as the target to build.  So in your makefile above, you are
telling it to build target "b".  You haven't told it to build the "depend"
target, and making it PHONY doesn't make it automatically get built, it just
means that it will always be assumed to be out-of-date *if* it is the
prerequisite of a target that you /have/ told build to make.  So you could
tell make that target "b" requires "depend" as a prerequisite:

b : depend b.o

.PHONY : depend
depend :
      @makedepend -f -b.c > dependancies.d

-include dependancies.d

or you could manually run "make depend" instead of just "make".

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....





reply via email to

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