public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Make: Filtering prerequisites
@ 2006-04-03  5:43 Smirnov Dmitry
  0 siblings, 0 replies; only message in thread
From: Smirnov Dmitry @ 2006-04-03  5:43 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm trying to implement the following in the make file:
Suppose I have few source files. I can create the list of targets corresponding to each source. 
I need to create the rule which builds the targets from sources.
Here is the example:
SOURCES := \
  dir1/subdir1/file1 \
  dir2/subdir2/file2 

TEST:=file3

TARGETS = $(addprefix dir3/subdir3/, $(notdir $(SOURCES)))

$(TARGETS): dir3/subdir3/% : $(foreach src,$(SOURCES),$(if $(findstring $(notdir $(src)),%),$(src),$(dir $(src))%))
            echo 'target: $@, source: $<'

all: $(TARGETS)

Do not be surprised with the rule: I've tried a lot of versions (much simpler than this one) but no one works. It looks that if I use the stem (%) or even the SysV $$(@F) neither $(filter) nor $(findstring) works.

For example, if I write 

$(TARGETS): $(filter %$$(@F), anystring/$$(@F)  anystring2/$$(@F)  ) it works, make produses the following:
make -k all 
make: *** No rule to make target `anystring/file1', needed by `dir3/subdir3/file1'.
make: *** No rule to make target `anystring2/file1', needed by `dir3/subdir3/file1'.
make: *** No rule to make target `anystring/file2', needed by `dir3/subdir3/file2'.
make: *** No rule to make target `anystring2/file2', needed by `dir3/subdir3/file2'.
make: Target `all' not remade because of errors.

But it fails if I replace it with 

$(TARGETS): $(filter %$$(@F), $(SOURCES) )

make -k all 
echo 'target: dir3/subdir3/file1, source: '
target: dir3/subdir3/file1, source: 
echo 'target: dir3/subdir3/file2, source: '
target: dir3/subdir3/file2, source:

Why it is so???!!!

Dmitry

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-03  5:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-03  5:43 Make: Filtering prerequisites Smirnov Dmitry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).