From: Andreas Wenzke on
Suppose, I have the following directory structure:

project
|
+bin
| +Debug
| +Release
|
+include
| +foo
|
+src
| +foo
|
+somelib
+lib
+Debug
+Release

What I want is something like this:

cd somelib/lib
make $(CFG) # build somelib first
cd (back to where we started from)
g++ -I somelib/lib -c -o bin/$(CFG)/*.obj src/*.cpp src/foo/*.cxx
g++ -o -L somelib/lib -l somelib -o bin/$(CFG)/myapp bin/$(CFG)/*.obj

So, build somelib first, then build everything within src (recursively),
taking into account all includes (recursively, with dependencies) and
put all binaries/object files into bin.
Finally link everything together.

Could someone please point me into the right direction?
Unfortunately I have to meet a deadline, so I don't really have time to
read thick manuals. :-(
However, I don't expect a complete solution, some advice on where to
look would already help me a lot!

E.g., do I have do define targets with a path?
I.e. targets like "bin/$(CFG)/*.o:" or something like that?

Thanks,
Andreas
From: Ersek, Laszlo on
On Thu, 22 Apr 2010, Andreas Wenzke wrote:

> So, build somelib first, then build everything within src (recursively),
> taking into account all includes (recursively, with dependencies) and
> put all binaries/object files into bin.
> Finally link everything together.

Googling "recursive make considered harmful" might pertain to your
interests.

lacos
From: TerryP on
On Apr 24, 11:14 am, "Ersek, Laszlo" <la...(a)caesar.elte.hu> wrote:
> On Thu, 22 Apr 2010, Andreas Wenzke wrote:
> > So, build somelib first, then build everything within src (recursively),
> > taking into account all includes (recursively, with dependencies) and
> > put all binaries/object files into bin.
> > Finally link everything together.
>
> Googling "recursive make considered harmful" might pertain to your
> interests.
>
> lacos

As might be looking up what

target: dependencies
shell commands

means in a makefile ;).

hint: http://en.wikipedia.org/wiki/Make_(software)
From: Andreas Wenzke on
I got it working in the end:

$(OUTPUTDIR)/%.o: %.cpp

vpath %.cpp $(subst ,:,$(SRCDIRS))

SRC=$(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c $(dir)/*.cc
$(dir)/*.cpp $(dir)/*.cxx))

OBJECTS=$(addprefix $(OUTPUTDIR)/,$(notdir $(patsubst %.c,%.o,$(patsubst
%.cc,%.o,$(patsubst %.cpp,%.o,$(patsubst %.cxx,*.o,$(SRC)))))))

Did the trick.