help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

call for each target within multiple targets in single rule


From: Utku Ozcan
Subject: call for each target within multiple targets in single rule
Date: Fri, 9 Apr 2010 00:48:41 +0200

I have a list, which stores modified name of the variables. Each
variable holds a list of filenames.
I want to store each of these variables to its own separate file,
using "one rule-multiple target" method.

List of variable names, together with the variables come from a file
"filelist.mk". This file includes following:

# variable 1
name1_lib_FILE_LIST :=
name1_lib_FILE_LIST += name1_lib_file1.txt
name1_lib_FILE_LIST += name1_lib_file2.txt
...

# variable 2
name2_lib_FILE_LIST :=
name2_lib_FILE_LIST += name2_lib_file1.txt
name2_lib_FILE_LIST += name2_lib_file2.txt
...

# list of variables but their names are modified
LIB_LIST :=  \
  name1_lib \
  name2_lib \
  ...


Now I tried following in Makefile:

include filelist.mk
write_to_file=$(strip $(shell printf "\# %s\\n" ${1} >> $2)$(foreach
w,$($1),$(shell echo $(w) >> $2 )))
files_list_list := $(addsuffix _FILE_LIST,${LIB_LIST})

$(files_list_list):
<tab>$(call write_to_file,LIB_LIST, $@)

In the rule above, each of the multiple target set cannot call
function "write_to_file" with its own dedicated name, ie

name1_lib must call $(call write_to_file,name1_lib_LIB_LIST, $@)
name2_lib must call $(call write_to_file,name2_lib_LIB_LIST, $@)

I get only the list LIB_LIST in each file. Each target is generated
correctly but content is thus wrong. Each file does not include the
corresponding variable.

Questions:
1. Does it make sense to use multiple targets? (
http://www.gnu.org/software/make/manual/make.html#Multiple-Targets )
2. Where is my mistake?

Cheers,
Utku




reply via email to

[Prev in Thread] Current Thread [Next in Thread]