Re: CFLAGS.xx/yy.c += ?
- Reply: Konstantin Belousov : "Re: CFLAGS.xx/yy.c += ?"
- In reply to: Bjoern A. Zeeb: "CFLAGS.xx/yy.c += ?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Aug 2025 07:05:16 UTC
On Mon Aug 18, 2025 at 11:02 PM +0300, Bjoern A. Zeeb wrote:
> Hi,
>
> I would love to add CFLAGS for just one file as in:
> CFLAGS.bar.c += -W...
>
> My problems are:
>
> (a) the file is foo/bar.c += ; do we have a way to write that out which
> works?
The per-file CFLAGS get added using ${CFLAGS.${.IMPSRC:T}}, so you
should just be able to use the name of the file. The :T modifier acts
like basename(1).
CFLAGS.bar.c= ...
>
> (b) to further complicate it I believe I need two different -Wno-..
> flags depending on gcc vs. clang on top. Do we support that
> (per-file and per-compiler)?
I don't think we have a built-in way to do this, but adding this to
CFLAGS should do the trick:
CFLAGS+= ${CFLAGS.${COMPILER_TYPE}.${.IMPSRC:T}}
This allows you to do:
CFLAGS.clang.bar.c= ...
CFLAGS.gcc.bar.c= ...
>
> /bz