>From: R?mi Delmas <[email protected]> >To: [email protected] >Subject: Filtering-out files from a list >Message-ID: <[email protected]> >Content-Type: text/plain; charset=ISO-8859-1 > >Hello, > >In the project I am working on, I build the list of files to compile with >the following expression: > >BMS_SRCS ?=$(foreach w,*.cpp *.c,$(wildcard src/$(w)))) > >This line is actually generated, as the user can specify wildcards (he >specified *.cpp and *.c in that case). > >Now, I would like to be able to achieve the same result, but to be able to >filter out some files based on a pattern. A general-purpose pattern would be >nice, but what I really need right now is to filter-out files matching the >regexp ".*_[A-Z]*\..*" (= any file where the name ends with an underscore >and capital letters). > >Looking at documentation, it seems to me that this is not doable with >wildcards. Am I wrong? Is there any other way to achieve this? > >Thanks a lot in advance,
You're going to have to pass off the filtering aspect to an external program run in a $(shell) command. I'm most familiar with sed, so you can try the following. space_to_line_delimiter_sed_script:=-e "G" -e ":loop" -e "s/ \(.*\)\(.\)$/\2\1\2/" -e "tloop" -e "s/.$//" my_file_filter:=-e "/.*_[A-Z]*\..*/d" FILTERED_BMS_SRCS:=$(shell echo $(BMS_SRCS) | sed $(space_to_line_delimiter_sed_script) | sed $(my_file_filter)) I put the raw script in the makefile variable. Will likely need to replace '$' with '$$'. Try it in the shell first. Hopefully you have access to a sed program, or can apply the same technique in another text scripting language like sed, awk, perl, etc. Not tested. Hope it helps, John Dill
<<winmail.dat>>
_______________________________________________ Help-make mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-make
