tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: default TOOLDIR



On Sat, 25 Oct 2008, Izumi Tsutsui wrote:
> apb%cequrux.com@localhost wrote:
> 
> > > - Should we also check
> > >   ${guess_TOOLDIR}/obj/bin/${toolprefix}make and
> > >   ${guess_TOOLDIR}/obj.${MACHINE}/bin/${toolprefix}make
> > >   in try_set_TOOLDIR()?
> > 
> > If you think that will help, sure.
> 
> This patch seems to work fine on Cygwin,
> but is there any better expression?
> (I'm not familiar with sh scripts)

Thank you.  I adapted your patch as follows.

--apb (Alan Barrett)

Index: build.sh
===================================================================
--- build.sh    22 Aug 2008 23:41:24 -0000      1.197
+++ build.sh    25 Oct 2008 19:08:48 -0000
@@ -894,24 +894,49 @@
 {
        [ -n "${TOOLDIR}" ] && return
 
-       # Set guess_TOOLDIR, in the same way that <bsd.own.mk> would set
-       # TOOLDIR if /etc/mk.conf isn't interfering.
+       # Set host_ostype to something like "NetBSD-4.5.6-i386".  This
+       # is intended to match the HOST_OSTYPE variable in <bsd.own.mk>.
+       #
        local host_ostype="${uname_s}-$(
                echo "${uname_r}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
                )-$(
                echo "${uname_p}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
                )"
-       local guess_TOOLDIR="${TOP_objdir}/tooldir.${host_ostype}"
 
-       # Look for a suitable ${toolprefix}make, nbmake, bmake, or make.
-       guess_make="${guess_TOOLDIR}/bin/${toolprefix}make"
-       [ -x "${guess_make}" ] || guess_make=""
+       # Look in a few potential locations for
+       # ${possible_TOOLDIR}/bin/${toolprefix}make.
+       # If we find it, then set guess_make.
+       #
+       # In the usual case (without interference from environment
+       # variables or /etc/mk.conf), <bsd.own.mk> should set TOOLDIR to
+       # "${TOP_objdir}/tooldir.${host_ostype}".  However, in practice
+       # we might have the wrong value of TOP_objdir, so we also try
+       # some other possibilities.
+       #
+       local possible_TOP_OBJ
+       local possible_TOOLDIR
+       for possible_TOP_OBJ in "${TOP_objdir}" "${TOP}" "${TOP}/obj" \
+               "${TOP}/obj.${MACHINE}"
+       do
+               possible_TOOLDIR="${possible_TOP_OBJ}/tooldir.${host_ostype}"
+               if [ -x "${possible_TOOLDIR}/bin/${toolprefix}make" ]; then
+                       guess_make="${dir}/bin/${toolprefix}make"
+                       break;
+               fi
+       done
+
+       # If the above didn't work, search the PATH for a suitable
+       # ${toolprefix}make, nbmake, bmake, or make.
+       #
        : ${guess_make:=$(find_in_PATH ${toolprefix}make '')}
        : ${guess_make:=$(find_in_PATH nbmake '')}
        : ${guess_make:=$(find_in_PATH bmake '')}
        : ${guess_make:=$(find_in_PATH make '')}
 
-       # Use ${guess_make} with nobomb_getmakevar
+       # Use ${guess_make} with nobomb_getmakevar to try to find
+       # the value of TOOLDIR.  If this fails, unset TOOLDIR.
+       #
+       unset TOOLDIR
        if [ -x "${guess_make}" ]; then
                TOOLDIR=$(make="${guess_make}" nobomb_getmakevar TOOLDIR)
                [ $? -eq 0 -a -n "${TOOLDIR}" ] || unset TOOLDIR


Home | Main Index | Thread Index | Old Index