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 00:27:13 -0700 (PDT)

Thank you Philip,


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?

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?

In the past, I only seen cases which use only one
dependency sign :.


regards,
George

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

> On 8/30/06, Lin George <address@hidden>
> wrote:
> > Suppose I define two macros,
> >
> > OBJ_DIR = debug/foo.o debug/goo.o
> > SRC_DIR = src/foo.c src/goo.c
> >
> > how should I write a rule to compile foo.c and
> goo.c
> > into foo.o and goo.o and put them into debug
> > sub-directory?
> 
> Well, here's a pattern rule to compile _any_ .c file
> under 'src' into
> a .o under 'debug'
> 
> debug/%.o: src/%.c
>         $(COMPILE.c) -o $@ $<
> 
> If you wanted that to _only_ apply to the files
> listed in OBJ_DIR, you
> would change that to a static pattern rule (check
> the GNU make info
> pages for details):
> 
> $(OBJ_DIR): debug/%.o: src/%.c
>         $(COMPILE.c) -o $@ $<
> 
> 
> BTW, it's kinda odd to name a variable containing
> filenames with the
> suffix "_DIR".  In practically every makefile I've
> ever seen or
> written, a variable named SRC_DIR would contain just
> the directory of
> the source files.  The list of source files would be
> named SRCS or
> similar.
> 
> 
> 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]