Subject: Re: man mk.conf (was kern/21311: Generic kernel doesnt compile in 1.6.1_STABLE)
To: Mipam <mipam@ibb.net>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-bugs
Date: 04/25/2003 20:33:46
>To continue on the matter and how i initially came with the idea
>that
>COPTS+= would add options instead of replace them is this:
>
>man 5 mk.conf
>
>COPTS 	Extra options for the C compiler. Should be appended to
>	(e.g., COPTS+= -g), rather then explicitly set.
>
>So, this line made me think that by applying this
>options were appended. You made me aware it actually isnt.
>Though, i should have looked more carefully and should have noticed
>that by having COPTS+=-pipe, -O2 is omitted during the build process
>of the kernel, that is, CFLAGS is set by this option. My bad.
>Its replacing options instead of appending them.
>Looking at mk.sys as you pointed out to me
>that i should just add -O2 does the trick.
>Perhaps i may be wrong, but shouldnt this line be changed in
>/usr/share/man/man5/mk.conf.5 ?

in general, yes, using += does append to options.  here are two
thoughts on this:

(1) when you invoke make, make first parses the command line, setting
any variables that it finds there (and afaict, never changes them
again if they are set here), then it sucks in pertinent environment
variables, then reads sys.mk (where you find the ?= variants, which
can be overridden by the previous two sources of settings), and then
reads the Makefile.  the Makefile typically includes something that
ultimately leads to /etc/mk.conf being included.

(2) the way the kernel is built is different, in that it overrides
most of the settings that come from sys.mk anyway, so sys.mk doesn't
*really* affect a kernel build as much as it affects everything else.
a given kernel Makefile includes bsd.own.mk near the top in order to
get the toolchain settings (which is how /etc/mk.conf gets pulled in),
then makes any += adjustments it needs, and then when
sys/conf/Makefile.kern.inc gets included at the bottom, more stuff is
piled on.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."