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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to