问题
I have a number of files from this expression:
ui_files := $(wildcard $(SUBDIRS:%=%/*.ui)).
Now I need the list of the same file paths, but with "ui_" prefix in file name and another extension (.h). How can I do that?
回答1:
You can iterate over the list using foreach and transform each element:
h_files := $(foreach ui,$(ui_files),$(dir $(ui))ui_$(notdir $(ui:.ui=.h)))
Or, first transform the whole list and then use join:
h_files := $(join $(dir $(ui_files)),$(patsubst %.ui,ui_%.h,$(notdir $(ui_files))))
Both solutions use dir and notdir functions.
来源:https://stackoverflow.com/questions/9048402/separate-file-name-from-its-path