Search code examples
makefilegnuvariable-substitution

Can a Gnu Make variable substitution expression match more than one pattern?


Say I have a list of files with mixed suffixes, e.g. .cpp and .c, and I want to make a list where each .cpp and each .c extension is changed to .o. I realize I could sequentially process my list multiple times, one for each extension of interest. But is there a way to use a variable substitution to do it in one step?


Solution

  • You could always just remove any suffix, like this:

    OBJECTS := $(addsuffix .o,$(basename $(FILES)))