help-make
[Top][All Lists]
Advanced

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

Re: how to deal if source code and object file are in different director


From: Lin George
Subject: Re: how to deal if source code and object file are in different directory?
Date: Thu, 31 Aug 2006 02:25:44 -0700 (PDT)

Thank you for your comments, Philip!


I have read related parts of GNU Make manual and it is
very informative. I have also updated my Makefile
according to your comments. Please help to check
whether it is better now. :-)

SRC_DIR=src
OBJ_DIR=debug
SRC=foo.c goo.c
OBJ=goo.o goo.o

I think in this way, it is more elegant according to
your comments. Agree?

Then, I think I need a rule to compile foo.c and goo.c
from src directory into foo.o and goo.c to debug
directory. Do you know how to write such a rule?


thank you,
George

--- Philip Guenther <address@hidden> wrote:

> On 8/31/06, Lin George <address@hidden>
> wrote:
> > I have two further questions,
> >
> > 1. when you say "a pattern rule" or "static
> pattern
> > rule", do you mean the built-in implicit rules of
> GNU
> > Make?
> 
> Nope.  The terms "pattern rule" and "static pattern
> rule" are
> described in the GNU make info pages.  Please check
> there for the full
> explanations.
> 
> 
> > 2. This line you suggested,
> >
> > > $(OBJ_DIR): debug/%.o: src/%.c
> >
> > I am confused about it. Since there are two :
> sign,
> > means two dependencies? In one line?
> 
> Nope.  The presence of two colons is part of what
> makes this a static
> pattern rule.  That line specifies that for each
> file in the
> $(OBJ_DIR) variable, make should try to match the
> pattern "debug/%.o"
> against it.  If that succeeds, then make should act
> like there's a
> rule building that file with a dependency on the
> matching file
> "src/%.c"
> 
> 
> Philip Guenther
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

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