Subject: Re: Correct build method?
To: Greg 'groggy' Lehey <grog@lemis.com>
From: Luke Mewburn <lukem@netbsd.org>
List: current-users
Date: 12/28/2002 21:46:01
On Fri, Dec 27, 2002 at 02:34:27PM +1030, Greg 'groggy' Lehey wrote:
  | Anyway, thanks for an answer to one of my questions.  It's still not
  | clear whether I should be using 'make build' or ./build.sh, and if the
  | latter, why.

build.sh is (arguably) more useful, especially if you're
cross-building NetBSD, or building from an (older) release to a
(newer) release.

build.sh is a front-end to the top-level Makefile.  It performs
various sanity checks, and then creates 
	${TOOLDIR}/bin/nbmake-${MACHINE}
which is a shell script wrapper to ${TOOLDIR}/bin/nbmake.
nbmake-${MACHINE} contains various make(1) environment variables
to control how the build is performed.  It then runs "make build"
which builds various tools under ${TOOLDIR}, and then the
distribution to ${DESTDIR}.

build.sh can also be used to build kernels with the tools in
${TOOLDIR}, which is handy for easily-cross building kernels.
E.g,
	./build.sh -k GENERIC
will configure and build the kernel sys/arch/${MACHINE}/conf/GENERIC.


Some build.sh options which I think are useful:

    -D destdir	Set DESTDIR=destdir, which is where to do the build.
		I do this to a scratch directory rather than use '/'.

    -M mkobj	Set MAKEOBJDIRPREFIX to mkobj, which is the top of
    		the "obj dir" tree, so /usr/src can be read-only.

    -u		Set UPDATE=1, which prevents "make clean" and other
		operations between runs.

    -U		Set UNPRIVED=1, which removes the need to do the
    		build as "root".  The only operation which should be
		run as root is "make installworld" or "build.sh -i idir".

    -b		Just build ${TOOLDIR}/bin/nbmake-${MACHINE}, remembering
		the other settings above.


Often I just use build.sh .... -b to create ${TOOLDIR}/bin/nbmake-${MACHINE},
and then run that with various targets such as "build", "cleandir",
"buildworld" or "installworld".

Hope that helps,
Luke.