5

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 ?

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
poloDD
  • 71
  • 6

1 Answers1

6

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
uzsolt
  • 5,832
  • 2
  • 20
  • 32