Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

recursive wildcard target in makefile

37 views
Skip to first unread message

crim...@googlemail.com

unread,
Nov 16, 2009, 3:35:02 PM11/16/09
to
Hi all!

I have .cpp sources in c/ directory of project and want to
generate .dep files for every .cpp in temp/ directory.

For example:
c/tester.cpp produced temp/tester.dep
c/lib1/file.cpp produced temp/lib1/file.dep
and so on.

makefile in c/ directory

I can collect names to generate:

CPP_SOURCES = $(wildcard *.cpp */*.cpp */*/*.cpp */*/*/*.cpp)
DEPS = $(patsubst %,../temp/%,$(patsubst %.cpp,%.dep, $
(CPP_SOURCES)))

But I can't write rule for this case. Here is first variant I write:

%.dep: ../c/%.cpp
g++ -MM -MF $@ $(INCLUDES) $<
g++ -MM -MT $@ $(INCLUDES) $< >> $@

But this case valid only for c/*.cpp and not valid for any
subdirectory like c/lib1/*.cpp. I want to make something like this:

%.dep: $(patsubst ../temp/%,./%, $%*.cpp)

How to write it right? temp/lib1/file.dep must depends on c/lib1/
file.cpp and so on.

crim...@googlemail.com

unread,
Nov 18, 2009, 8:09:52 AM11/18/09
to
On 16 ноя, 22:35, "criman...@googlemail.com"

<criman...@googlemail.com> wrote:
> I want to make something like this:
>
> %.dep: $(patsubst ../temp/%,./%, $%*.cpp)
>
> How to write it right? temp/lib1/file.dep must depends on c/lib1/
> file.cpp and so on.

I found it!
The key is .SECONDEXPANSION: directive:
http://www.gnu.org/software/automake/manual/make/Secondary-Expansion.html

0 new messages