From: "Smirnov Dmitry" <Dmitry.Smirnov@tlmcom.ru>
To: <gcc-help@gcc.gnu.org>
Subject: Make: Filtering prerequisites
Date: Mon, 03 Apr 2006 05:43:00 -0000 [thread overview]
Message-ID: <037B212B293B504F881E3D9B32C4B17DC89958@tlmsrv.tlm.nn> (raw)
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
reply other threads:[~2006-04-03 5:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=037B212B293B504F881E3D9B32C4B17DC89958@tlmsrv.tlm.nn \
--to=dmitry.smirnov@tlmcom.ru \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).