Subject: CFLAGS vs CXXFLAGS
To: None <tech-pkg@netbsd.org>
From: None <segv@netctl.net>
List: tech-pkg
Date: 03/04/2006 05:03:24
I'm using pkgsrc on Sparc Solaris. I want to pass the following flags to
compilers:

C compiler:
-xO3 -xtarget=ultra -Xa -xc99=all

C++ compiler:
-xO3 -xtarget=ultra  -features=%all

so, some options are only valid for C compiler and can't be used with C++
compiler, and vice versa. I had the following in mk.conf:

CFLAGS+=-xO3 -xtarget=ultra -Xa -xc99=all
CXXFLAGS+=-xO3 -xtarget=ultra  -features=%all

what it did was to append some CFLAGS to CXXFLAGS, i.e., CXXFLAGS was set to
'-xO3 -xtarget=ultra -Xa -xc99=all -features=%all' and this was not what I
wanted.

So I changed the above two lines in mk.conf to:

CFLAGS=-xO3 -xtarget=ultra -Xa -xc99=all
CXXFLAGS=-xO3 -xtarget=ultra  -features=%all

which did the trick and made it work the right way.

My question is: will I lose some special optimisation flags for certain
packages when I set CFLAGS= instead of CFLAGS+= and why does pkgsrc append CFLAGS
to CXXFLAGS?