[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: flat OBJDIR
From: |
Alexander Farber |
Subject: |
Re: flat OBJDIR |
Date: |
Mon, 23 Aug 2004 17:02:00 +0000 |
User-agent: |
Mutt/1.4.1i |
Hi,
thanks, using VPATH works, but it looks like a hack to me,
since I already _know_ the exact paths to the source files.
Also I have many source files so my VPATH list will be quite long.
Can't I construct a series of rules by using $(foreach ...) instead?
Regards
Alex
On Mon, Aug 23, 2004 at 10:48:29AM -0500, Boris Kolpackov wrote:
> address@hidden (Alexander Farber) writes:
>
> > OBJDIR = objdir
> > SRCS = a.cpp \
> > src1/b.cpp
> > OBJS = $(addprefix $(OBJDIR)/, $(notdir $(SRCS:.cpp=.obj)))
> >
> > all: $(OBJS)
> >
> > $(OBJDIR)/%.obj: %.cpp
> > @echo g++ -o $@ -c $<
> >
> > bolinux72:afarber {556} gmake
> > g++ -o objdir/a.obj -c a.cpp
> > gmake: *** No rule to make target `objdir/b.obj', needed by `all'. Stop.
>
> When make tries to build `objdir/b.obj' the pattern rule after substitution
> will look like this (% = `b'):
>
> objdir/b.obj: b.cpp
> @echo g++ -o $@ -c $<
>
> Then to test if rule is applicable, make checks if prerequisites (`b.cpp'
> in our case) exist or can be made. Obviously there is no `b.cpp' in current
> dir (it is in `src1/'). So you need to add `src1' to the list of dirs make
> will look for `.cpp' files:
>
> vpath %.cpp $(dir $(SRCS))
>
> -boris
>
Re: flat OBJDIR, Ken Smith, 2004/08/23