Remove a flag from CFLAGS in FreeBSD makefile

913 Views Asked by At

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

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 ?

1

There are 1 best solutions below

0
On

Yes, there is filter-out-like feature in FreeBSD's Makefile but with different syntax:

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

From man make.

Usage example:

CFLAGS= -foo -bar -flag

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

The output:

$ make
-foo -bar -flag
-foo -bar