version 1.58, 2002/05/13 01:44:34 |
version 1.58.2.5, 2002/11/03 16:36:06 |
|
|
#! /bin/sh |
#! /usr/bin/env sh |
# $NetBSD$ |
# $NetBSD$ |
# |
# |
# 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. For systems |
# with a strange /bin/sh, "ksh" or "bash" may be an ample alternative. |
# with a strange /bin/sh, "ksh" or "bash" may be an ample alternative. |
# |
# |
|
# Note, however, that due to the way the interpreter is invoked above, |
|
# if a POSIX-compliant shell is the first in the PATH, you won't have |
|
# to take any further action. |
|
# |
|
|
bomb () { |
bomb () { |
echo "" |
echo "" |
|
|
[ -d usr.bin/make ] || bomb "build.sh must be run from the top source level" |
[ -d usr.bin/make ] || bomb "build.sh must be run from the top source level" |
[ -f share/mk/bsd.own.mk ] || bomb "src/share/mk is missing; please re-fetch the source tree" |
[ -f share/mk/bsd.own.mk ] || bomb "src/share/mk is missing; please re-fetch the source tree" |
|
|
TOP=`pwd` |
# If $PWD is a valid name of the current directory, POSIX mandates that pwd |
|
# return it by default which causes problems in the presence of symlinks. |
|
# Unsetting PWD is simpler than changing every occurrence of pwd to use -P. |
|
# |
|
# XXX Except that doesn't work on Solaris. |
|
unset PWD |
|
if [ "x`uname -s`" = "xSunOS" ]; then |
|
TOP=`pwd -P` |
|
else |
|
TOP=`pwd` |
|
fi |
|
|
getarch () { |
getarch () { |
# Translate a MACHINE into a default MACHINE_ARCH. |
# Translate a MACHINE into a default MACHINE_ARCH. |
|
|
validatearch () { |
validatearch () { |
# Ensure that the MACHINE_ARCH exists (and is supported by build.sh). |
# Ensure that the MACHINE_ARCH exists (and is supported by build.sh). |
case $MACHINE_ARCH in |
case $MACHINE_ARCH in |
alpha|arm|i386|m68000|m68k|mipse[bl]|powerpc|sh3e[bl]|sparc|sparc64|vax|x86_64) |
alpha|arm|armeb|i386|m68000|m68k|mipse[bl]|powerpc|sh3e[bl]|sparc|sparc64|vax|x86_64) |
;; |
;; |
|
|
*) bomb "unknown target MACHINE_ARCH: $MACHINE_ARCH";; |
*) bomb "unknown target MACHINE_ARCH: $MACHINE_ARCH";; |
|
|
resolvepath () { |
resolvepath () { |
case $OPTARG in |
case $OPTARG in |
/*) ;; |
/*) ;; |
*) OPTARG="$cwd/$OPTARG";; |
*) OPTARG="$TOP/$OPTARG";; |
esac |
esac |
} |
} |
|
|
|
|
# Set defaults. |
# Set defaults. |
MAKEFLAGS= |
MAKEFLAGS= |
buildtarget=build |
buildtarget=build |
cwd=`pwd` |
|
do_buildsystem=true |
do_buildsystem=true |
do_buildonlytools=false |
do_buildonlytools=false |
do_rebuildmake=false |
do_rebuildmake=false |
Line 185 while eval $getoptcmd; do case $opt in |
|
Line 198 while eval $getoptcmd; do case $opt in |
|
makeenv="$makeenv MAKEOBJDIRPREFIX";; |
makeenv="$makeenv MAKEOBJDIRPREFIX";; |
|
|
-O) eval $optargcmd; resolvepath |
-O) eval $optargcmd; resolvepath |
MAKEOBJDIR="\${.CURDIR:C,^$cwd,$OPTARG,}"; export MAKEOBJDIR |
MAKEOBJDIR="\${.CURDIR:C,^$TOP,$OPTARG,}"; export MAKEOBJDIR |
makeobjdir=$OPTARG |
makeobjdir=$OPTARG |
makeenv="$makeenv MAKEOBJDIR";; |
makeenv="$makeenv MAKEOBJDIR";; |
|
|
Line 217 makeenv="$makeenv TOOLDIR MACHINE MACHIN |
|
Line 230 makeenv="$makeenv TOOLDIR MACHINE MACHIN |
|
if [ ! -z "$BUILDID" ]; then |
if [ ! -z "$BUILDID" ]; then |
makeenv="$makeenv BUILDID" |
makeenv="$makeenv BUILDID" |
fi |
fi |
MAKEFLAGS="-m $cwd/share/mk $MAKEFLAGS MKOBJDIRS=${MKOBJDIRS-yes}" |
MAKEFLAGS="-m $TOP/share/mk $MAKEFLAGS MKOBJDIRS=${MKOBJDIRS-yes}" |
export MAKEFLAGS MACHINE MACHINE_ARCH |
export MAKEFLAGS MACHINE MACHINE_ARCH |
|
|
# Test make source file timestamps against installed nbmake binary, |
# Test make source file timestamps against installed nbmake binary, |
Line 251 if $do_rebuildmake; then |
|
Line 264 if $do_rebuildmake; then |
|
$runcmd cd "$tmpdir" |
$runcmd cd "$tmpdir" |
|
|
$runcmd env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \ |
$runcmd env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \ |
"$cwd/tools/make/configure" || bomb "configure of nbmake failed" |
"$TOP/tools/make/configure" || bomb "configure of nbmake failed" |
$runcmd sh buildmake.sh || bomb "build of nbmake failed" |
$runcmd sh buildmake.sh || bomb "build of nbmake failed" |
|
|
make="$tmpdir/nbmake" |
make="$tmpdir/nbmake" |
$runcmd cd "$cwd" |
$runcmd cd "$TOP" |
$runcmd rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o |
$runcmd rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o |
fi |
fi |
|
|
|
|
echo "===> DESTDIR path: $DESTDIR" |
echo "===> DESTDIR path: $DESTDIR" |
|
|
TOOLDIR=`getmakevar TOOLDIR`; |
TOOLDIR=`getmakevar TOOLDIR`; |
[ $? = 0 ] || bomb "getmakevar DESTDIR failed"; |
[ $? = 0 ] || bomb "getmakevar TOOLDIR failed"; |
echo "===> TOOLDIR path: $TOOLDIR" |
echo "===> TOOLDIR path: $TOOLDIR" |
|
|
export DESTDIR TOOLDIR |
export DESTDIR TOOLDIR |