[BACK]Return to build.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/build.sh between version 1.152 and 1.153

version 1.152, 2006/09/01 21:52:55 version 1.153, 2006/09/29 19:53:54
Line 38 
Line 38 
 #  #
 # Top level build wrapper, for a system containing no tools.  # Top level build wrapper, for a system containing no tools.
 #  #
 # This script should run on any POSIX-compliant shell.  For systems  # This script should run on any POSIX-compliant shell.  If the
 # with a strange /bin/sh, "ksh" or "bash" may be an ample alternative.  # first "sh" found in the PATH is a POSIX-compliant shell, then
 #  # you should not need to take any special action.  Otherwise, you
 # Note, however, that due to the way the interpreter is invoked above,  # should set the environment variable HOST_SH to a POSIX-compliant
 # if a POSIX-compliant shell is the first in the PATH, you won't have  # shell, and invoke build.sh with that shell.  (Depending on your
 # to take any further action.  # system, one of /bin/ksh, /usr/local/bin/bash, or /usr/xpg4/bin/sh
   # might be a suitable shell.)
 #  #
   
 progname=${0##*/}  progname=${0##*/}
Line 68  statusmsg()
Line 69  statusmsg()
         ${runcmd} echo "===> $@" | tee -a "${results}"          ${runcmd} echo "===> $@" | tee -a "${results}"
 }  }
   
   # Find a program in the PATH
   find_in_PATH()
   {
           local prog="$1"
           local oldIFS="${IFS}"
           local dir
           IFS=":"
           for dir in ${PATH}; do
                   if [ -x "${dir}/${prog}" ]; then
                           prog="${dir}/${prog}"
                           break
                   fi
           done
           IFS="${oldIFS}"
           echo "${prog}"
   }
   
   # Try to find a working POSIX shell, and set HOST_SH to refer to it.
   # Assumes that uname_s, uname_m, and PWD have been set.
   set_HOST_SH()
   {
           # Even if ${HOST_SH} is already defined, we still do the
           # sanity checks at the end.
   
           # Solaris has /usr/xpg4/bin/sh.
           #
           [ -z "${HOST_SH}" ] && [ x"${uname_s}" = x"SunOS" ] && \
                   [ -x /usr/xpg4/bin/sh ] && HOST_SH="/usr/xpg4/bin/sh"
   
           # Try to get the name of the shell that's running this script,
           # by parsing the output from "ps".  We assume that, if the host
           # system's ps command supports -o comm at all, it will do so
           # in the usual way: a one-line header followed by a one-line
           # result, possibly including trailing white space.  And if the
           # host system's ps command doesn't support -o comm, we assume
           # that we'll get an error message on stderr and nothing on
           # stdout.  (We don't try to use ps -o 'comm=' to suppress the
           # header line, because that is less widely supported.)
           #
           # If we get the wrong result here, the user can override it by
           # specifying HOST_SH in the environment.
           #
           [ -z "${HOST_SH}" ] && HOST_SH="$(
                   (ps -p $$ -o comm | sed -ne '2s/[ \t]*$//p') 2>/dev/null )"
   
           # If nothing above worked, use "sh".  We will later find the
           # first directory in the PATH that has a "sh" program.
           #
           [ -z "${HOST_SH}" ] && HOST_SH="sh"
   
           # If the result so far is not an absolute path, try to prepend
           # PWD or search the PATH.
           #
           case "${HOST_SH}" in
           /*)     :
                   ;;
           */*)    HOST_SH="${PWD}/${HOST_SH}"
                   ;;
           *)      HOST_SH="$(find_in_PATH "${HOST_SH}")"
                   ;;
           esac
   
           # If we don't have an absolute path by now, bomb.
           #
           case "${HOST_SH}" in
           /*)     :
                   ;;
           *)      bomb "HOST_SH=\"${HOST_SH}\" is not an absolute path."
                   ;;
           esac
   
           # If HOST_SH is not executable, bomb.
           #
           [ -x "${HOST_SH}" ] ||
               bomb "HOST_SH=\"${HOST_SH}\" is not executable."
   }
   
 initdefaults()  initdefaults()
 {  {
         cd "$(dirname $0)"          cd "$(dirname $0)"
Line 89  initdefaults()
Line 167  initdefaults()
         unset PWD          unset PWD
         TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)          TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)
   
           # The user can set HOST_SH in the environment, or we try to
           # guess an appropriate value.  Then we set several other
           # variables from HOST_SH.
           #
           set_HOST_SH
           setmakeenv HOST_SH "${HOST_SH}"
           setmakeenv BSHELL "${HOST_SH}"
           setmakeenv CONFIG_SHELL "${HOST_SH}"
   
         # Set defaults.          # Set defaults.
         #          #
         toolprefix=nb          toolprefix=nb
Line 711  rebuildmake()
Line 798  rebuildmake()
                 ${runcmd} cd "${tmpdir}"                  ${runcmd} cd "${tmpdir}"
                 ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \                  ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
                         CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \                          CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
                         sh "${TOP}/tools/make/configure" ||                          ${HOST_SH} "${TOP}/tools/make/configure" ||
                     bomb "Configure of ${toolprefix}make failed"                      bomb "Configure of ${toolprefix}make failed"
                 ${runcmd} sh buildmake.sh ||                  ${runcmd} ${HOST_SH} buildmake.sh ||
                     bomb "Build of ${toolprefix}make failed"                      bomb "Build of ${toolprefix}make failed"
                 make="${tmpdir}/${toolprefix}make"                  make="${tmpdir}/${toolprefix}make"
                 ${runcmd} cd "${TOP}"                  ${runcmd} cd "${TOP}"
Line 819  validatemakeparams()
Line 906  validatemakeparams()
         fi          fi
         if ${do_build} || ${do_distribution} || ${do_release}; then          if ${do_build} || ${do_distribution} || ${do_release}; then
                 if ! ${do_expertmode} && \                  if ! ${do_expertmode} && \
                     [ $(id -u 2>/dev/null) -ne 0 ] && \                      [ "$(id -u 2>/dev/null)" -ne 0 ] && \
                     [ "${MKUNPRIVED}" = "no" ] ; then                      [ "${MKUNPRIVED}" = "no" ] ; then
                         bomb "-U or -E must be set for build as an unprivileged user."                          bomb "-U or -E must be set for build as an unprivileged user."
                 fi                  fi
Line 879  createmakewrapper()
Line 966  createmakewrapper()
         esac          esac
   
         eval cat <<EOF ${makewrapout}          eval cat <<EOF ${makewrapout}
 #! /bin/sh  #! ${HOST_SH}
 # Set proper variables to allow easy "make" building of a NetBSD subtree.  # Set proper variables to allow easy "make" building of a NetBSD subtree.
 # Generated from:  \$NetBSD$  # Generated from:  \$NetBSD$
 # with these arguments: ${_args}  # with these arguments: ${_args}
Line 1030  main()
Line 1117  main()
         statusmsg "${progname} command: $0 $@"          statusmsg "${progname} command: $0 $@"
         statusmsg "${progname} started: ${build_start}"          statusmsg "${progname} started: ${build_start}"
   
           statusmsg "HOST_SH:          ${HOST_SH}"
   
         rebuildmake          rebuildmake
         validatemakeparams          validatemakeparams
         createmakewrapper          createmakewrapper

Legend:
Removed from v.1.152  
changed lines
  Added in v.1.153

CVSweb <webmaster@jp.NetBSD.org>