Subject: toolchain/37504: build.sh needs /usr/src/obj to exist for consistent usage on default values of DESTDIR, TOOLDIR and so on
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <cjep@fawlty.net>
List: netbsd-bugs
Date: 12/08/2007 21:30:02
>Number:         37504
>Category:       toolchain
>Synopsis:       build.sh needs /usr/src/obj to exist for consistent usage on default values of DESTDIR, TOOLDIR and so on
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 08 21:30:02 +0000 2007
>Originator:     Chris Pinnock
>Release:        NetBSD 4.99.40
>Organization:
	Fawlty Networks	
>Environment:
System: NetBSD frodo.fawlty.net 4.99.40 NetBSD 4.99.40 (FRODO) #0: Tue Dec 4 09:16:11 UTC 2007 cjep@frodo.fawlty.net:/usr/obj/sys/arch/i386/compile/FRODO i386
Architecture: i386
Machine: i386
>Description:

Without a /etc/mk.conf, run "./build.sh -U distribution" on a clean /usr/src 
then run "./build.sh -U install=/" and see a bit of confusion over where 
DESTDIR, TOOLDIR and so on are.

On the second run /usr/src/obj exists. On the first run it doesn't.

>How-To-Repeat:

You can see the problem by focusing on build.sh as here:

frodo% sh chris.sh 
SRCTOP: /usr/src
TOOLDIR: /usr/src/tooldir.NetBSD-4.99.40-i386
frodo% ln -s /usr/obj .
frodo% sh chris.sh
SRCTOP: /usr/src/obj
TOOLDIR: /usr/src/obj/tooldir.NetBSD-4.99.40-i386

where chris.sh is a snippet of build.sh
#!/bin/sh
make=/usr/bin/make

nobomb_getmakevar()
{
        [ -x "${make}" ] || return 1
        "${make}" -m share/mk -s -B -f- _x_ <<EOF || return 1
_x_:
        echo \${$1}
.include <bsd.prog.mk>
.include <bsd.kernobj.mk>
EOF
}

_SRC_TOP_OBJ_=$(nobomb_getmakevar _SRC_TOP_OBJ_)
TOOLDIR=$(nobomb_getmakevar TOOLDIR)
echo "SRCTOP: $_SRC_TOP_OBJ_"
echo "TOOLDIR: $TOOLDIR"

>Fix:
	Ensure that /usr/src/obj exists correctly earlier in build.sh.

>Unformatted:
 	Current sources as of 2 days ago