Re: VPATH question

Ishan <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <9af003f3-06ab-491e-ba1a-f432e3fb0f8e@z17g2000hsg.googlegroups.com>
On Jan 7, 9:16 am, Ishan <[email protected]> wrote:
> On Jan 6, 7:34 am, Steve Calfee <[email protected]> wrote:
>
> > > CC = g++
>
> > > vpath %.cpp .:../../parent/comp01
>
> > That is not the syntax for vpath. Look in the make manual. A very good
> > source ishttp://make.paulandlesley.org/
>
> What's wrong here? What I'm trying to say here is, for any
> prerequisite ending with .cpp, look either in the current directory or
> in "../../parent/comp01" directory. This is how the manual says. Am I
> wrong?
>
> Thanks,
> Ishan.

I found what was wrong. The problem is that "make cannot use the
appropriate path to the source if you hardcode the filename" [1].

When automatic variables are used as shown below, the problem is
solved.

CC = g++

VPATH = .:../../parent/comp01
CXXFLAGS = -ggdb -I ../../parent/comp01

OBJECTS = main.o Factory.o Context.o FactoryEx.o ContextEx.o

comp01: $(OBJECTS)
        $(CC) $(OBJECTS) -o $@

clean:
        rm *.o comp01



[1] Managing Projects with GNU make, 3/e (Chap 02)
<http://www.oreilly.com/catalog/make3/book/ch02.pdf>

Cheers,
Ishan De Silva
-- Blogs are ideal for Personal Knowledge Bases --
[http://personal-knowledge-base.blogspot.com/]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.