Other Remove a flag from CFLAGS in a makefile

In a GNU makefile, it is possible to use filter-out to remove a flag from CFLAG like this :

Makefile:
CFLAGS:=$(filter-out -flag,$(CFLAGS))

However, I can't make it work with a FreeBSD makefile.

Is filter-out supported by FreeBSD ? Otherwise, what can I do to remove a specific flag from CFLAGS in a makefile ?
 
Perhaps you can use replace:
Makefile:
CFLAGS:= $(CFLAGS:-flag=)
but be aware this is POSIX make syntax and can collide with more complex make(1) variable modifiers.
 
Here is the filter-out like feature in FreeBSD's Makefile (from man page):

:Npattern This is identical to `:M', but selects all words which do not match pattern.

Usage :
Makefile:
CFLAGS= -foo -bar -flag

all:
    @echo ${CFLAGS}
    @echo ${CFLAGS:N-flag}

Code:
$ make
-foo -bar -flag
-foo -bar
 
Back
Top