SRC := hello_world.c board_io.c time.c qq.c
FULL := /home/wyang2/test/kmodule/hello_world.c /home/wyang2/test/boardio/board_io.c
full_named_files=$(foreach file, $(SRC), $(filter %$(file),$(FULL)))
$(warning full_named_files $(full_named_files))
上面这句话先在FULL的这个文件列表中过滤出有用的文件名来,这个是全路径的。
filter是过滤的函数,后面加pattern和要过滤的字符串。pattern用%做前缀
unsorted_short_named_files=$(foreach file, $(full_named_files), $(word $(words $(subst test/, ,$(file))), $(subst test/, ,$(file))))
$(warning $(unsorted_short_named_files))
这个语句是用来从绝对路径中取得相对路径的。 这里用了两个subst函数,都是将绝对路径以test为界,分成两个部分。
第一个subst的作用是得到2这个数字。
然后用word来选中分成两部分的文件名的后半部分。 高