[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: flat OBJDIR
From: |
Ken Smith |
Subject: |
Re: flat OBJDIR |
Date: |
Mon, 23 Aug 2004 12:18:18 -0400 |
User-agent: |
Mutt/1.5.6i |
On Mon, Aug 23, 2004 at 04:38:52PM +0000, Alexander Farber wrote:
> Sorry for my previous chaotic mail. I've constructed a simple
> test case for my problem and hope that someone will comment:
>
> bolinux72:afarber {555} cat Makefile
>
> OBJDIR = objdir
> SRCS = a.cpp \
> src1/b.cpp
> OBJS = $(addprefix $(OBJDIR)/, $(notdir $(SRCS:.cpp=.obj)))
Instead of trying to build all the objects into a single directory,
could you replicate the directory structure of your sources in your
object directory? For example, your object directory could look like
this.
objdir/a.obj
objdir/src1/b.cpp
You would define OBJS like this.
OBJS = $(addprefix $(OBJDIR)/, $(SRCS:.cpp=.obj))
I assume that the object directory is dynamically created or, at least
that you don't have the same directory structure there that you have in
your source directory. You can overcome this as follows. The following
is a modified version of your test makefile which implements this
suggestion.
OBJDIR = objdir
OBJSUBDIRS = $(addprefix $(OBJDIR)/,$(dir $(SRCS)))
SRCS = a.cpp \
src1/b.cpp
OBJS = $(addprefix $(OBJDIR)/,$(SRCS:.cpp=.obj))
all: $(OBJS)
$(OBJDIR) $(OBJSUBDIRS):
mkdir -p $(@)
$(OBJDIR)/%.obj: %.cpp | $(OBJDIR) $(OBJSUBDIRS)
g++ -o $@ -c $<
--
Ken Smith
- Re: flat OBJDIR, Alexander Farber, 2004/08/22
- Re: flat OBJDIR, Alexander Farber, 2004/08/23
- Re: flat OBJDIR, Noel Yap, 2004/08/23
- Re: flat OBJDIR, Boris Kolpackov, 2004/08/23
- Message not available
- Re: flat OBJDIR, Alexander Farber, 2004/08/23
- Re: flat OBJDIR, Noel Yap, 2004/08/23
- Re: flat OBJDIR, Paul D. Smith, 2004/08/23
- Re: flat OBJDIR, Mike Gibson, 2004/08/23
- Re: flat OBJDIR, Paul D. Smith, 2004/08/23
- Re: flat OBJDIR, Noel Yap, 2004/08/23
Re: flat OBJDIR,
Ken Smith <=
- Re: flat OBJDIR, Ken Smith, 2004/08/23
- Re: flat OBJDIR, Noel Yap, 2004/08/23
- Re: flat OBJDIR, Alexander Farber, 2004/08/24
- Re: flat OBJDIR, Ken Smith, 2004/08/24
- Re: flat OBJDIR, Noel Yap, 2004/08/24