Remove item from a Makefile variable

gnu-makemakefilevariables

I have a makefile, which includes several other makefiles, which in turn all add to a variable like this:

VAR := Something SomethingElse
VAR += SomeOtherThing

(...)

Now I wish to remove SomethingElse from the VAR variable. What do I put in place of (...) to do this?

I am using GNU Make, and a GNU Make specific solution will be fine.

Best Answer

You could use the filter-out text function if you're using GNU Make.

OTHERVAR := $(filter-out SomethingElse,$(VAR))