Subject: Re: build sourcesets problem
To: John Nemeth <jnemeth@victoria.tc.ca>
From: Frederick Bruckman <fredb@immanent.net>
List: current-users
Date: 08/20/2003 19:25:15
On Wed, 20 Aug 2003, John Nemeth wrote:

>      Now, I have a different problem :->  I do periodic "cvs update"s
> followed by "./build.sh ... sourcesets ...".  I noticed my CD images
> were rather large (over 400M).  When I investigated, I found that my
> sourcesets were full of .o files.  Is this a bug in the way the
> sourcesets are built, or am I supposed to use an object directory in
> order not to have my source tree polluted?

I'm going to go with "yes", and "yes". As to the bug, it's easily
worked around (with "-M"). That's not even the only reason you should
be using object directories: without them, "cvs update" isn't known to
work at all, as there are targets that have the same name as now empty
directories, which "cvs" still has to create, then delete. That hasn't
been a problem for you, no doubt becase "-O /usr/obj" is the default.

> If the latter, what is the
> difference between -M and -O.  The documentation for these options
> isn't very clear.

"-M" is probably what you want. It sets ${MAKEOBJDIRPREFIX} in
"make"'s environment. This feature of NetBSD's "make" is described
tersely near the bottom of the make(1) man page. What it does, is
this: Say you have the sources in "/my/source/tree", and objects are
to go into "/my/obj/tree" (which is given as the argument to "-M").
Then, when "make" is operating in "/my/source/tree/usr.bin/jot",
"jot.o" will go into "/my/obj/tree/my/source/tree/usr.bin/jot",
similarly for all the other source directories, and all the other
objects. The object directories are created during the "make obj"
phase of the build. The source tree stays completely clean.

"-O" uses an older yet only slightly less obscure feature of
"make", which is also described in the make(1) man page, yet even
more tersely. That is, that objects will automatically be placed
into a subdirectory named ${MAKEOBJDIR} or "obj" if it exists. The
"make obj" phase creates the object tree in the designated directory,
similarly to "-M" but with shorter paths, if possible, and also makes
a single symlink into the corresponding place in the object tree in
each source directory. If it's not possible to write to the object
tree, (because it doesn't exist, say) "make obj" will simply create a
directory directly in the source tree, rather than a symlink. I'd like
to bet that that is what actually happenned in your case, and that the
objects are all in sub-directories named "obj" or "obj.<arch>". The
actual terminal value of the symlink or directory, that is, the value
of ${MAKOBJDIR}, can be affected by other options, so I can't say
exactly without more information. Whatever ${MAKOBJDIR} works out to
be, there will either be a symlink or directory of that name in each
source directory.

If that's not clear, just try them both, and you'll see what they do.
;-)

Frederick