Subject: Re: another makefile mystery: COPTS
To: Bill Studenmund <email@example.com>
From: Todd Whitesel <firstname.lastname@example.org>
Date: 01/19/2000 01:43:59
> > Why do kernel makefiles put things like -O2 and warning flags in COPTS?
> > Worse, the default contents appear to vary by arch.
> Because that's where it belongs? ;-) COPTS is for things for cc1, and is
> passed to the c compiler when it's compiling.
Actually CFLAGS is used for that, and it is put together from COPTS and
other macros (this also varies by arch, which strikes me as natural but
unnecessary code drift of the balkanization kind).
bsd.prog.mk and friends seem to be doing much of the same thing, except that
COPTS has no default and the -O2 shows up as the initial default for CFLAGS,
which then gets a lot of stuff added to it using += lines. (This is based on
a less-than-thorough UTSL; those include'd .mk files are getting pretty
I've seen other conventions in reserving macros for users to set things on
the command line: vxWorks user makefiles have macros like ADDED_CFLAGS; the
GNU ones (in GDB anyway) use CFLAGS (yup) for this and default it to -g.
> What defaults get blown away?
threegx:101% grep ^COPTS */conf/Makefile.*
macppc/conf/Makefile.macppc:COPTS?= -O2 -pipe
pc532/conf/Makefile.pc532:COPTS?= -O2 -msb
sh3/conf/Makefile.sh3.be:COPTS?= -g -O
sh3/conf/Makefile.sh3.le:COPTS?= -g -O -ml
sun3/conf/Makefile.sun3:COPTS?= -O2 -fno-defer-pop
> Part of the idea (I thought) of how the kernel make files worked is that
> you config a kernel, and then make it. They don't include any other make
> files (except for kernel ones, like libkern and friends) - they are fairly
> independent of the normal build process (much more self contained than
> userland builds).
That is correct.
But I don't think it should presume that I'll never want to throw in an
extra option (like -pipe) from the command line without editing the makefile.
I also might be using a higher-level process to config and build kernels,
and that might want to add its own options too, perhaps in the environment.
I am in fact doing this to rebuild systems from source and to do snapshots.
I use an upper-level make with empty timestamp files because that has other
nice properties which are useful for continuing after an error. In the ideal
case where no errors occur, the current procedure can be as simple as this:
get new sources onto the machine.
``make cleandir'' (not the cleandir you know; clears log files)
``make kernel'' (updates /netbsd and /netbsd.old, and stops)
reboot and smoke-test the new kernel (best done manually).
``make world'' (make build && make snapshot, mainly)
upload contents of RELEASEDIR to FTP site.
For now I think I will just work up a set of diffs that add ADDED_CFLAGS or
something like that to both kernel & userland, and if it works out well I
will just send-PR it.
toddpw @ best.com