[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Make: Filtering prerequisites
From: |
Smirnov Dmitry |
Subject: |
Make: Filtering prerequisites |
Date: |
Fri, 7 Apr 2006 14:06:31 +0400 |
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), Notfound)
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???!!!
If such filtering is impossible, could you please advice the method to
implement my goal...
Dmitry
- Make: Filtering prerequisites,
Smirnov Dmitry <=