Subject: Re: How to add compiler flags?
To: gabriel rosenkoetter <>
From: Greywolf <>
List: current-users
Date: 06/19/2002 15:15:21
On Wed, 19 Jun 2002, gabriel rosenkoetter wrote:

# On Wed, Jun 19, 2002 at 12:22:43PM -0700, Greywolf wrote:
# > Does anyone have a suggestion as to what I *should* be using to add
# > build-time compiler flags to /etc/mk.conf, since HOST_CFLAGS,
# > LOCAL_CFLAGS and COPTS all seem to be off limits?
# Is there some reason you *need* to have some C flags always defined
# in the pkgsrc and src Makefiles (the only things that should be
# relying on /etc/mk.conf)?


I like to use -pipe, for one.
I'd like to be able to conditionally include flags depending on architecture
[I cross compile for SPARC a lot because the 800MHz athlon with its 640MB
of RAM makes a nicer build box than the 170MHz SPARCstation 5 with only
128MB of RAM.].  For example:

MY_CFLAGS += -pipe
.if ${ARCH} == "sparc"
MY_CFLAGS += -msupersparc
.elif ${ARCH} = "i386"
# example only , I know it's not implemented on our version...
MY_CFLAGS += -m586

# If this is your own stuff, using a NetBSD-like mk structure makes
# sense, but making it coexist with settings specific to building
# NetBSD is a bad idea.
# I've got a CFLAGS+=-g sitting around commented in my /etc/mk.conf,
# and I'll periodically uncomment it if I'm getting weird issues I
# really need debugged copies of a bunch of OS stuff to figure out.
# Doing that's never caused me problems (you know, more than I was
# already having by *needing* a debug-symbol-linked version of
# *everything*), but I've got no reason to think that it'd always
# work.
# Btw, isn't this a question more apropos to tech-toolchain these
# days?

Didn't know that existed.  I'm certainly not subscribed (yet).

NetBSD: Stable and strong!