[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: |
Tue, 24 Aug 2004 12:07:15 -0400 |
User-agent: |
Mutt/1.5.6i |
On Tue, Aug 24, 2004 at 04:35:33PM +0000, Alexander Farber wrote:
> Hi Ken,
>
> yes, I was going to replicate the directory structure of my
> sources, but later. Currently I want the destination of
> my objects to match the one of the original scripted build
> system, since it is rather large (a 60 MB big log file) and
> I have to compare and verify the produced files...
>
> Do you have an error in your "testcase"? It fails for me:
I cut and pasted the the makefile into the email and cut and pasted it
back out (tabifying the mkdir and g++ which autoconverted to spaces).
Here is a transcript of my session. My suspicion is that you do not
have an "a.cpp" in the directory containing the test makefile.
---Transcript---
% cat Makefile
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 $<
% cat a.cpp
#include "a.hpp"
a::a() {}
a::~a() {}
% cat a.hpp
class a
{
public:
a();
~a();
};
% cat src1/b.cpp
#include "b.hpp"
b::b() {}
b::~b() {}
% cat src1/b.hpp
class b
{
public:
b();
~b();
};
% gmake
mkdir -p objdir
mkdir -p objdir/src1
g++ -o objdir/a.obj -c a.cpp
g++ -o objdir/src1/b.obj -c src1/b.cpp
----------------
>
> bolinux72:afarber {529} gmake -f Makefile2
> gmake: *** No rule to make target `objdir/a.obj', needed by `all'. Stop.
>
> bolinux72:afarber {530} cat Makefile2
> 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 $<
>
>
>
>
> On Mon, Aug 23, 2004 at 12:18:18PM -0400, Ken Smith wrote:
> > On Mon, Aug 23, 2004 at 04:38:52PM +0000, Alexander Farber wrote:
> > > 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
> >
> > 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
> >
>
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make
--
Ken Smith
- Re: flat OBJDIR, (continued)
- 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, 2004/08/23