Properly controlling CFLAGS/CXXFLAGS

Freddie Cash fcash at ocis.net
Thu Dec 21 09:16:08 PST 2006


On Wednesday 20 December 2006 07:57 pm, Garrett Cooper wrote:
> Hello,
> 	Coming from Gentoo we were taught how to 'rice' our machines.
> Based on my experience though with FreeBSD, this is an improper
> methodology for one to use.
> 	I was wondering (looking at the make.conf manpage), what's the
> best way to control one's CFLAGS/CXXFLAGS. I'd prefer if only a few
> ports would have optimized compiler flags, while the rest of the system
> used a safe set of compiler flags.
> 	So, I was wondering what the best course of action for setting
> variables in /etc/make.conf would be? Is this proper given what I'm
> trying to accomplish:
>
> /etc/make.conf snippet:
> CFLAGS= -O2 -pipe
> CXXFLAGS= ${CFLAGS}
> COPTFLAGS= ${CFLAGS} -msse -msse2 -mfpmath=sse,387
>
> NO_CPU_CFLAGS="YES"
> NO_CPU_COPTFLAGS="YES"
>
> CPUTYPE?=pentium4

My suggestion is to leave all mention of *CFLAGS out of /etc/make.conf to 
use the system defaults (-O2 -pipe -fno-strict-aliasing), set CPUTYPE 
accordingly, and install sysutils/portconf.

That gives you a separate /usr/local/etc/ports.conf file where you can set 
global and per-port settings that are only used when compiling things 
under /usr/ports (actually $PORTSDIR).

-- 
Freddie Cash
fcash at ocis.net


More information about the freebsd-hackers mailing list