[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Replacing characters in a pattern rule
From: |
natch |
Subject: |
Replacing characters in a pattern rule |
Date: |
Tue, 06 Sep 2005 21:23:43 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.6 (Windows/20050716) |
I have a list of directories (discovered automatically, but explicitly
defined for this example):
DIRECTORIES := a b c
Some of these directories have index.html files in them. I wish to copy
these into the local directory as
DIRECTORY_index.html
The straight forward solution is
INDEX_HTML_FILES := $(DIRECTORIES:%=%_index.html)
$(INDEX_HTML_FILES): %_index.html : %/index.html
cp $< $@
Now, this words great for immediate subdirectories. However, I want
this to work recursively, for example:
DIRECTORIES := a b c group/d group/e
I need both directory names in the file name, such as:
group_d_index.html group_e_index.html
I can easily alter the copy command to be
cp $< $(subst /,_,$@)
but I can't figure out how to generate the list of [ group_d_index.html
group_e_index.html] files as a prerequisite. If I try and use the
pattern expansion with a substitute command:
INDEX_HTML_FILES := $(subst /,_,$(DIRECTORIES:%=%_index.html))
It won't work as a prerequisite because of how make expands the
variables. I would really appreciate any suggestions on getting this to
work.
-
natch
- Replacing characters in a pattern rule,
natch <=