help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .mak file for directory with source code in subdirectories


From: Henrik Carlqvist
Subject: Re: .mak file for directory with source code in subdirectories
Date: Fri, 24 Nov 2006 21:28:49 +0100
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

"earthwormgaz" <earthwormgaz@googlemail.com> wrote:
> So, I have my list of sources ...
> 
> SRCS = \
>   example/file.cpp
>   different/example/file.cpp

Lets make things simple, something like:

SRCS = $(wildcard *.cpp */*.cpp */*/*.cpp */*/*/*.cpp)
 
> I then have the following ...
> OBJS := $(patsubst %.cpp, $(BLD)/%.o, $(SRCS))

My guess is that you want to replace it with something like:

OBJS = $(patsubst %.cpp, $(BLD)/%.o, $(notdir $(SRCS)))

> In the example I copied this from, the files were all in the same
> subdirectory, and the author had used this trick ...
> 
> vpath %.cpp code/directory

So you could add all your directories as searchable with vpath, or
write one rule for each of your source directory that describes how to
make an .o file from a .cpp file.

One way to get the vpath right might be:

empty:=
space:= $(empty) $(empty)

vpath %.cpp $(subst $(space),:,$(sort $(dir $(SRCS))))

I haven't tried the above in any Makefile myself, but I think it should
work. If it still has some bug I hope that it at least will give you some
inspiration on how to fix your Makefile.

regards Henrik
-- 
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
root@variousus.net root@localhost



reply via email to

[Prev in Thread] Current Thread [Next in Thread]