Subject: Re: build.sh parameter confusion
To: William Allen Simpson <wsimpson@greendragon.com>
From: Frederick Bruckman <fredb@immanent.net>
List: current-users
Date: 06/17/2003 23:38:08
On Tue, 17 Jun 2003, William Allen Simpson wrote:

> I'm trying to figure out the build.sh parameters.  Documentation is
> somewhat confusing.
>
> For example, http://netbsd.org/Documentation/current/ has the parameter
> order as
>   ./build.sh -O /usr/obj -D /usr/NetBSD-new-build -T /usr/tools build
>
> and as
>   ./build.sh -D /usr/NetBSD-new-build -O /usr/obj -T /usr/tools -u build
>
> but as far as I can tell, the order of -D and -O makes no difference.

Correct. "build.sh" uses normal getopt parsing, so order doesn't
matter. In unix and unix-like systems, for the order to matter is the
exception, not the rule.

> Also, I don't understand why both -O and -M are useful?  History?
> There's enough examples (in BUILDING) to show what happens for -O, but
> not for -M.

"-O" is historical, and it's also the default. "-M" leaves you a
completely clean source tree, no "obj*" directory or symlink
whatsoever. If BSDSRCDIR is in "/usr/src", and MAKEOBJDIRPREFIX is
"/usr/obj", an entire tree of directories will be created under
"/usr/obj/usr/src".

> And, the example in "Updating an existing system" is just plain wrong,
> saying:
>   mv sys/arch/<ARCH>/compile/GENERIC/netbsd /
>
> which is the equivalent of:
>   /usr/src/sys/arch/<ARCH>/compile/GENERIC/netbsd

Yeah, that's where it used to end up if you compiled it without the
benefit of build.sh.

> but the kernel actually shows up in:
>   /usr/obj/sys/arch/<ARCH>/compile/GENERIC/netbsd
>        ^^^
>
> because build.sh now defaults to running 'make obj'.

I find it more natural to follow the obj symlink to
/usr/src/sys/arch/<ARCH>/compile/obj/GENERIC/netbsd, but build.sh
prints the directory after "kernel=GENERIC", so that shouldn't be
an issue.

> If I'm in /usr/src and run ./build.sh build, it would be nice to have the
> defaults just be /usr/obj and /usr/obj/tools and /usr/obj/release.  Is
> this what happens?

Yes!

> Likewise, if I'm in /home/NetBSD-current and run ./build.sh build, it
> would be nice to have the defaults just be /home/NetBSD-current/obj and
> /home/NetBSD-current/obj/tools and /home/NetBSD-current/obj/release.
> AFAIK, this isn't what happens.

That's not the same thing at all. You're putting the object directory
inside the source directory. Putting anything in a directory named
"obj" but objects for sources in the containing directory is a really
bad idea. (Trust me on this.)

> Is that -M?

No. This is -M -- sources in "/s/netbsd/src-current"; -M is given as
"/t/netbsd-current/obj.mac68k":

 1   fredb@tautology-> pwd
 2   /s/netbsd/src-current/usr.bin/jot
 3   fredb@tautology-> ls
 4   CVS      Makefile jot.1    jot.c
 5   fredb@tautology-> cd / /t/netbsd-current/obj.mac68k/
 6   /t/netbsd-current/obj.mac68k/s/netbsd/src-current/usr.bin/jot

Note the obscure feature of "ksh" used on line 5. The exact same
command whisks you into the correct object directory, no matter where
you start. (Like "cd obj", with -O.) The real benefit is that it's
easier to keep the tree groomed without those pesky "obj" symlinks.

Frederick