2002-09-14 03:27:13 +04:00
|
|
|
#! /usr/bin/env sh
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
# $NetBSD: build.sh,v 1.82 2003/01/15 01:49:03 lukem Exp $
|
2001-10-19 06:21:03 +04:00
|
|
|
#
|
|
|
|
# Top level build wrapper, for a system containing no tools.
|
|
|
|
#
|
|
|
|
# This script should run on any POSIX-compliant shell. For systems
|
2001-12-12 00:13:35 +03:00
|
|
|
# with a strange /bin/sh, "ksh" or "bash" may be an ample alternative.
|
2001-10-19 06:21:03 +04:00
|
|
|
#
|
2002-09-14 03:27:13 +04:00
|
|
|
# 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.
|
|
|
|
#
|
2001-10-19 06:21:03 +04:00
|
|
|
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
trap "exit 1" 1 2 3 15
|
|
|
|
toppid=$$
|
2003-01-03 02:11:07 +03:00
|
|
|
bomb()
|
|
|
|
{
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
cat >&2 <<ERRORMESSAGE
|
|
|
|
|
|
|
|
ERROR: $@
|
|
|
|
*** BUILD ABORTED ***
|
|
|
|
ERRORMESSAGE
|
|
|
|
kill $toppid # in case we were invoked from a subshell
|
2001-10-19 06:21:03 +04:00
|
|
|
exit 1
|
|
|
|
}
|
2003-01-02 08:11:12 +03:00
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
cd "$(dirname $0)"
|
|
|
|
[ -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"
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-12-25 03:42:50 +03:00
|
|
|
uname_s=$(uname -s 2>/dev/null)
|
|
|
|
uname_m=$(uname -m 2>/dev/null)
|
|
|
|
|
2002-09-04 02:03:48 +04:00
|
|
|
# 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.
|
2002-09-14 03:27:13 +04:00
|
|
|
#
|
|
|
|
# XXX Except that doesn't work on Solaris.
|
2002-09-04 02:03:48 +04:00
|
|
|
unset PWD
|
2002-12-25 03:42:50 +03:00
|
|
|
if [ "${uname_s}" = "SunOS" ]; then
|
2003-01-03 02:11:07 +03:00
|
|
|
TOP=$(pwd -P)
|
2002-09-14 03:27:13 +04:00
|
|
|
else
|
2003-01-03 02:11:07 +03:00
|
|
|
TOP=$(pwd)
|
2002-09-14 03:27:13 +04:00
|
|
|
fi
|
2001-12-03 11:18:00 +03:00
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
getarch()
|
|
|
|
{
|
2001-10-19 06:21:03 +04:00
|
|
|
# Translate a MACHINE into a default MACHINE_ARCH.
|
|
|
|
case $MACHINE in
|
2002-04-02 20:34:49 +04:00
|
|
|
acorn26|acorn32|cats|netwinder|shark|*arm)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=arm;;
|
|
|
|
|
|
|
|
sun2)
|
|
|
|
MACHINE_ARCH=m68000;;
|
|
|
|
|
|
|
|
amiga|atari|cesfic|hp300|sun3|*68k)
|
|
|
|
MACHINE_ARCH=m68k;;
|
|
|
|
|
2002-03-07 02:32:52 +03:00
|
|
|
mipsco|newsmips|sbmips|sgimips)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=mipseb;;
|
|
|
|
|
2002-03-07 17:59:04 +03:00
|
|
|
algor|arc|cobalt|evbmips|hpcmips|playstation2|pmax)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=mipsel;;
|
|
|
|
|
|
|
|
pc532)
|
|
|
|
MACHINE_ARCH=ns32k;;
|
|
|
|
|
2002-12-09 15:49:55 +03:00
|
|
|
bebox|prep|sandpoint|*ppc)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=powerpc;;
|
|
|
|
|
2001-11-12 11:54:58 +03:00
|
|
|
evbsh3|mmeye)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=sh3eb;;
|
|
|
|
|
2001-11-12 11:54:58 +03:00
|
|
|
dreamcast|hpcsh)
|
2001-10-19 06:21:03 +04:00
|
|
|
MACHINE_ARCH=sh3el;;
|
|
|
|
|
2002-06-10 18:08:05 +04:00
|
|
|
hp700)
|
|
|
|
MACHINE_ARCH=hppa;;
|
|
|
|
|
2002-10-02 20:57:29 +04:00
|
|
|
evbsh5)
|
|
|
|
MACHINE_ARCH=sh5el;;
|
|
|
|
|
2001-10-24 18:00:24 +04:00
|
|
|
alpha|i386|sparc|sparc64|vax|x86_64)
|
2001-10-24 06:39:56 +04:00
|
|
|
MACHINE_ARCH=$MACHINE;;
|
|
|
|
|
|
|
|
*) bomb "unknown target MACHINE: $MACHINE";;
|
2001-10-19 06:21:03 +04:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
validatearch()
|
|
|
|
{
|
2002-03-02 00:06:40 +03:00
|
|
|
# Ensure that the MACHINE_ARCH exists (and is supported by build.sh).
|
|
|
|
case $MACHINE_ARCH in
|
2002-10-02 20:57:29 +04:00
|
|
|
alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|ns32k|powerpc|sh[35]e[bl]|sparc|sparc64|vax|x86_64)
|
2002-03-02 00:06:40 +03:00
|
|
|
;;
|
|
|
|
|
|
|
|
*) bomb "unknown target MACHINE_ARCH: $MACHINE_ARCH";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
getmakevar()
|
|
|
|
{
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
[ -x $make ] || bomb "getmakevar $1: $make is not executable"
|
2001-12-04 07:28:23 +03:00
|
|
|
$make -m ${TOP}/share/mk -s -f- _x_ <<EOF
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
_x_:
|
|
|
|
echo \${$1}
|
|
|
|
.include <bsd.prog.mk>
|
2002-10-20 19:48:01 +04:00
|
|
|
.include <bsd.kernobj.mk>
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
# getmakevar doesn't work properly if $make hasn't yet been built, which
|
|
|
|
# can happen when running with the "-n" option. safe_getmakevar deals
|
|
|
|
# with this by emitting a literal '$' followed by the variable name,
|
|
|
|
# instead of trying to find the variable's value.
|
|
|
|
safe_getmakevar()
|
|
|
|
{
|
|
|
|
if [ -x $make ]; then
|
|
|
|
getmakevar "$1"
|
|
|
|
else
|
|
|
|
echo "\$$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
resolvepath()
|
|
|
|
{
|
2001-10-31 01:33:00 +03:00
|
|
|
case $OPTARG in
|
|
|
|
/*) ;;
|
2002-09-14 03:27:13 +04:00
|
|
|
*) OPTARG="$TOP/$OPTARG";;
|
2001-10-31 01:33:00 +03:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
usage()
|
|
|
|
{
|
2002-10-20 19:48:01 +04:00
|
|
|
cat <<_usage_
|
2003-01-04 17:55:44 +03:00
|
|
|
Usage: $(basename $0) [-bdEnortUu] [-a arch] [-B buildid] [-D dest]
|
|
|
|
[-i instdir] [-j njob] [-k kernel] [-M obj] [-m mach]
|
|
|
|
[-O obj] [-R release] [-T tools] [-V var=[value]] [-w wrapper]
|
2002-10-20 19:48:01 +04:00
|
|
|
|
|
|
|
-a arch set MACHINE_ARCH to arch (otherwise deduced from MACHINE)
|
|
|
|
-B buildid set BUILDID to buildid
|
|
|
|
-b build nbmake and nbmake wrapper script, if needed
|
|
|
|
-D dest set DESTDIR to dest
|
|
|
|
-d build a full distribution into DESTDIR (including etc files)
|
2002-12-09 01:14:00 +03:00
|
|
|
-E set "expert" mode; disables some DESTDIR checks
|
2003-01-04 17:55:44 +03:00
|
|
|
-i instdir installworld from DESTDIR to instdir (after build completes)
|
2002-10-20 19:48:01 +04:00
|
|
|
-j njob run up to njob jobs in parallel; see make(1)
|
|
|
|
-k kernel build a kernel using the named configuration file
|
|
|
|
-M obj set obj root directory to obj (sets MAKEOBJDIRPREFIX)
|
|
|
|
-m mach set MACHINE to mach (not required if NetBSD native)
|
|
|
|
-n show commands that would be executed, but do not execute them
|
|
|
|
-O obj set obj root directory to obj (sets a MAKEOBJDIR pattern)
|
|
|
|
-o set MKOBJDIRS=no (do not create objdirs at start of build)
|
|
|
|
-R release build a release (and set RELEASEDIR to release)
|
2002-11-05 04:53:58 +03:00
|
|
|
-r remove contents of TOOLDIR and DESTDIR before building
|
2002-10-20 19:48:01 +04:00
|
|
|
-T tools set TOOLDIR to tools
|
|
|
|
-t build and install tools only (implies -b)
|
|
|
|
-U set UNPRIVED
|
|
|
|
-u set UPDATE
|
2003-01-04 15:55:32 +03:00
|
|
|
-V v=[val] set variable \`v' to \`val'
|
2002-10-20 19:48:01 +04:00
|
|
|
-w wrapper create nbmake script at wrapper
|
|
|
|
(default TOOLDIR/bin/nbmake-MACHINE)
|
|
|
|
|
2003-01-04 17:55:44 +03:00
|
|
|
Notes:
|
|
|
|
* The last specified option with "build" functionality will be run.
|
|
|
|
* If -T is unset and TOOLDIR is not set in the environment,
|
|
|
|
nbmake will be [re]built unconditionally.
|
2002-10-20 19:48:01 +04:00
|
|
|
_usage_
|
2001-10-19 06:21:03 +04:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2001-10-31 01:33:00 +03:00
|
|
|
# Set defaults.
|
2001-11-02 08:07:22 +03:00
|
|
|
MAKEFLAGS=
|
2001-10-31 04:56:10 +03:00
|
|
|
buildtarget=build
|
2001-10-31 01:33:00 +03:00
|
|
|
do_buildsystem=true
|
2002-11-17 15:59:37 +03:00
|
|
|
do_buildkernel=false
|
|
|
|
do_buildtools=false
|
2001-10-31 01:33:00 +03:00
|
|
|
do_rebuildmake=false
|
|
|
|
do_removedirs=false
|
2002-12-09 01:14:00 +03:00
|
|
|
expert_mode=false
|
2001-11-02 08:07:22 +03:00
|
|
|
makeenv=
|
|
|
|
makewrapper=
|
2002-12-25 03:42:50 +03:00
|
|
|
installworlddir=
|
2001-10-31 01:33:00 +03:00
|
|
|
opt_a=no
|
2003-01-04 15:55:32 +03:00
|
|
|
opts='a:B:bD:dEhi:j:k:M:m:nO:oR:rT:tUuV:w:'
|
2001-11-02 08:07:22 +03:00
|
|
|
runcmd=
|
2001-10-19 06:25:48 +04:00
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
if type getopts >/dev/null 2>&1; then
|
|
|
|
# Use POSIX getopts.
|
|
|
|
getoptcmd='getopts $opts opt && opt=-$opt'
|
|
|
|
optargcmd=':'
|
|
|
|
else
|
2003-01-03 02:11:07 +03:00
|
|
|
type getopt >/dev/null 2>&1 ||
|
|
|
|
bomb "/bin/sh shell is too old; try ksh or bash"
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
# Use old-style getopt(1) (doesn't handle whitespace in args).
|
2003-01-03 02:11:07 +03:00
|
|
|
args="$(getopt $opts $*)"
|
2001-10-24 06:39:56 +04:00
|
|
|
[ $? = 0 ] || usage
|
|
|
|
set -- $args
|
|
|
|
|
|
|
|
getoptcmd='[ $# -gt 0 ] && opt="$1" && shift'
|
|
|
|
optargcmd='OPTARG="$1"; shift'
|
|
|
|
fi
|
2001-10-31 01:33:00 +03:00
|
|
|
|
|
|
|
# Parse command line options.
|
2003-01-03 02:11:07 +03:00
|
|
|
while eval $getoptcmd; do
|
|
|
|
case $opt in
|
2001-10-24 06:39:56 +04:00
|
|
|
-a) eval $optargcmd
|
|
|
|
MACHINE_ARCH=$OPTARG; opt_a=yes;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-03-14 21:33:04 +03:00
|
|
|
-B) eval $optargcmd
|
|
|
|
BUILDID=$OPTARG;;
|
|
|
|
|
2001-10-31 01:33:00 +03:00
|
|
|
-b) do_buildsystem=false;;
|
2001-10-31 00:04:05 +03:00
|
|
|
|
2002-12-08 11:42:51 +03:00
|
|
|
-D) eval $optargcmd; resolvepath
|
|
|
|
DESTDIR="$OPTARG"; export DESTDIR
|
|
|
|
makeenv="$makeenv DESTDIR";;
|
|
|
|
|
2001-11-25 21:35:06 +03:00
|
|
|
-d) buildtarget=distribution;;
|
|
|
|
|
2002-12-09 01:14:00 +03:00
|
|
|
-E) expert_mode=true;;
|
|
|
|
|
2002-12-25 03:42:50 +03:00
|
|
|
-i) eval $optargcmd
|
|
|
|
installworlddir=$OPTARG;;
|
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
-j) eval $optargcmd
|
2002-05-03 02:13:30 +04:00
|
|
|
parallel="-j $OPTARG";;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-11-17 15:59:37 +03:00
|
|
|
-k) do_buildkernel=true; do_buildsystem=false
|
2002-10-20 19:48:01 +04:00
|
|
|
eval $optargcmd
|
2002-11-17 15:59:37 +03:00
|
|
|
kernconfname=$OPTARG;;
|
2002-10-20 19:48:01 +04:00
|
|
|
|
2002-12-08 11:42:51 +03:00
|
|
|
-M) eval $optargcmd; resolvepath
|
|
|
|
MAKEOBJDIRPREFIX="$OPTARG"; export MAKEOBJDIRPREFIX
|
|
|
|
makeobjdir=$OPTARG
|
|
|
|
makeenv="$makeenv MAKEOBJDIRPREFIX";;
|
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
# -m overrides MACHINE_ARCH unless "-a" is specified
|
|
|
|
-m) eval $optargcmd
|
|
|
|
MACHINE=$OPTARG; [ "$opt_a" != "yes" ] && getarch;;
|
2001-10-19 20:43:47 +04:00
|
|
|
|
2001-10-31 01:33:00 +03:00
|
|
|
-n) runcmd=echo;;
|
|
|
|
|
2002-12-08 11:42:51 +03:00
|
|
|
-O) eval $optargcmd; resolvepath
|
|
|
|
MAKEOBJDIR="\${.CURDIR:C,^$TOP,$OPTARG,}"; export MAKEOBJDIR
|
|
|
|
makeobjdir=$OPTARG
|
|
|
|
makeenv="$makeenv MAKEOBJDIR";;
|
|
|
|
|
2001-10-31 04:56:10 +03:00
|
|
|
-o) MKOBJDIRS=no;;
|
|
|
|
|
2002-12-08 11:42:51 +03:00
|
|
|
-R) eval $optargcmd; resolvepath
|
|
|
|
RELEASEDIR=$OPTARG; export RELEASEDIR
|
|
|
|
makeenv="$makeenv RELEASEDIR"
|
|
|
|
buildtarget=release;;
|
|
|
|
|
2001-10-31 01:33:00 +03:00
|
|
|
-r) do_removedirs=true; do_rebuildmake=true;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-12-08 11:42:51 +03:00
|
|
|
-T) eval $optargcmd; resolvepath
|
|
|
|
TOOLDIR="$OPTARG"; export TOOLDIR;;
|
|
|
|
|
2002-11-17 15:59:37 +03:00
|
|
|
-t) do_buildtools=true; do_buildsystem=false;;
|
2001-11-01 03:14:17 +03:00
|
|
|
|
2002-02-27 16:55:28 +03:00
|
|
|
-U) UNPRIVED=yes; export UNPRIVED
|
|
|
|
makeenv="$makeenv UNPRIVED";;
|
|
|
|
|
2001-11-02 08:07:22 +03:00
|
|
|
-u) UPDATE=yes; export UPDATE
|
|
|
|
makeenv="$makeenv UPDATE";;
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
|
2003-01-04 15:55:32 +03:00
|
|
|
-V) eval $optargcmd
|
|
|
|
case "${OPTARG}" in
|
|
|
|
# XXX: consider restricting which variables can be changed?
|
|
|
|
[a-zA-Z_][a-zA-Z_0-9]*=*)
|
|
|
|
var=${OPTARG%%=*}
|
|
|
|
value=${OPTARG#*=}
|
|
|
|
eval "${var}=\"${value}\"; export ${var}"
|
|
|
|
makeenv="$makeenv ${var}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "-V argument must be of the form 'var=[value]'"
|
|
|
|
usage;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
-w) eval $optargcmd; resolvepath
|
|
|
|
makewrapper="$OPTARG";;
|
2001-10-31 04:56:10 +03:00
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
--) break;;
|
|
|
|
-'?'|-h) usage;;
|
2003-01-03 02:11:07 +03:00
|
|
|
esac
|
|
|
|
done
|
2001-10-19 06:21:03 +04:00
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Set up MACHINE*. On a NetBSD host, these are allowed to be unset.
|
|
|
|
if [ -z "$MACHINE" ]; then
|
2002-12-25 03:42:50 +03:00
|
|
|
if [ "${uname_s}" != "NetBSD" ]; then
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
echo "MACHINE must be set, or -m must be used, for cross builds."
|
2001-10-24 06:39:56 +04:00
|
|
|
echo ""; usage
|
|
|
|
fi
|
2002-12-25 03:42:50 +03:00
|
|
|
MACHINE=${uname_m}
|
2001-10-19 06:21:03 +04:00
|
|
|
fi
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
[ -n "$MACHINE_ARCH" ] || getarch
|
2002-03-02 00:06:40 +03:00
|
|
|
validatearch
|
2001-10-19 06:21:03 +04:00
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Set up default make(1) environment.
|
2001-11-02 08:07:22 +03:00
|
|
|
makeenv="$makeenv TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
|
2002-03-14 21:33:04 +03:00
|
|
|
if [ ! -z "$BUILDID" ]; then
|
|
|
|
makeenv="$makeenv BUILDID"
|
|
|
|
fi
|
2002-09-14 03:27:13 +04:00
|
|
|
MAKEFLAGS="-m $TOP/share/mk $MAKEFLAGS MKOBJDIRS=${MKOBJDIRS-yes}"
|
2001-11-02 08:07:22 +03:00
|
|
|
export MAKEFLAGS MACHINE MACHINE_ARCH
|
2001-10-19 20:43:47 +04:00
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Test make source file timestamps against installed nbmake binary,
|
|
|
|
# if TOOLDIR is pre-set.
|
2002-03-01 23:57:26 +03:00
|
|
|
#
|
|
|
|
# Note that we do NOT try to grovel "mk.conf" here to find out if TOOLDIR
|
|
|
|
# is set there, because it can contain make variable expansions and other
|
|
|
|
# stuff only parseable *after* we have a working nbmake. So this logic
|
|
|
|
# can only work if the user has pre-set TOOLDIR in the environment or
|
|
|
|
# used the -T option to build.sh.
|
|
|
|
#
|
2002-03-21 13:54:50 +03:00
|
|
|
make="${TOOLDIR-nonexistent}/bin/nbmake"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
if [ -x $make ]; then
|
2001-10-19 06:21:03 +04:00
|
|
|
for f in usr.bin/make/*.[ch] usr.bin/make/lst.lib/*.[ch]; do
|
2002-09-14 02:17:04 +04:00
|
|
|
if [ $f -nt $make ]; then
|
2001-10-31 01:33:00 +03:00
|
|
|
do_rebuildmake=true; break
|
2001-10-19 06:21:03 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
2001-10-31 01:33:00 +03:00
|
|
|
do_rebuildmake=true
|
2001-10-19 06:21:03 +04:00
|
|
|
fi
|
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Build bootstrap nbmake if needed.
|
2001-10-31 01:33:00 +03:00
|
|
|
if $do_rebuildmake; then
|
2001-11-02 08:07:22 +03:00
|
|
|
$runcmd echo "===> Bootstrapping nbmake"
|
2002-03-21 13:54:50 +03:00
|
|
|
tmpdir="${TMPDIR-/tmp}/nbbuild$$"
|
2001-10-24 06:39:56 +04:00
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd mkdir "$tmpdir" || bomb "cannot mkdir: $tmpdir"
|
|
|
|
trap "cd /; rm -r -f \"$tmpdir\"" 0
|
|
|
|
$runcmd cd "$tmpdir"
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
|
|
|
|
CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
|
|
|
|
"$TOP/tools/make/configure" \
|
|
|
|
|| bomb "configure of nbmake failed"
|
2002-01-15 22:19:35 +03:00
|
|
|
$runcmd sh buildmake.sh || bomb "build of nbmake failed"
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
make="$tmpdir/nbmake"
|
2002-09-14 03:27:13 +04:00
|
|
|
$runcmd cd "$TOP"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
$runcmd rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o
|
|
|
|
fi
|
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
if [ "$runcmd" = "echo" ]; then
|
2002-09-18 19:20:53 +04:00
|
|
|
TOOLCHAIN_MISSING=no
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
EXTERNAL_TOOLCHAIN=""
|
2002-03-21 13:54:50 +03:00
|
|
|
else
|
2003-01-03 02:11:07 +03:00
|
|
|
TOOLCHAIN_MISSING=$(getmakevar TOOLCHAIN_MISSING)
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
EXTERNAL_TOOLCHAIN=$(getmakevar EXTERNAL_TOOLCHAIN)
|
2002-03-21 13:54:50 +03:00
|
|
|
fi
|
2002-09-18 19:20:53 +04:00
|
|
|
if [ "${TOOLCHAIN_MISSING}" = "yes" -a \
|
|
|
|
"${EXTERNAL_TOOLCHAIN}" = "" ]; then
|
|
|
|
echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for"
|
2001-12-04 07:28:23 +03:00
|
|
|
echo
|
|
|
|
echo "MACHINE: ${MACHINE}"
|
|
|
|
echo "MACHINE_ARCH: ${MACHINE_ARCH}"
|
|
|
|
echo
|
|
|
|
echo "All builds for this platform should be done via a traditional make"
|
|
|
|
echo
|
2002-09-18 19:20:53 +04:00
|
|
|
echo "If you wish to use an external cross-toolchain, set"
|
2001-12-04 07:28:23 +03:00
|
|
|
echo
|
2002-09-18 19:20:53 +04:00
|
|
|
echo "EXTERNAL_TOOLCHAIN=<path to toolchain root>"
|
2001-12-04 07:28:23 +03:00
|
|
|
echo
|
|
|
|
echo "in either the environment or mk.conf and rerun"
|
|
|
|
echo
|
|
|
|
echo "$0 $*"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# If TOOLDIR isn't already set, make objdirs in "tools" in case the
|
|
|
|
# default setting from <bsd.own.mk> is used.
|
|
|
|
if [ -z "$TOOLDIR" ] && [ "$MKOBJDIRS" != "no" ]; then
|
2001-11-02 08:07:22 +03:00
|
|
|
$runcmd cd tools
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd $make -m ${TOP}/share/mk obj NOSUBDIR= \
|
|
|
|
|| bomb "make obj failed in tools"
|
2002-10-20 19:48:01 +04:00
|
|
|
$runcmd cd "$TOP"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
fi
|
|
|
|
|
2001-11-26 08:57:33 +03:00
|
|
|
#
|
2002-05-13 05:44:34 +04:00
|
|
|
# If setting -M or -O to root an obj dir make sure the base directory is made
|
2001-11-26 08:57:33 +03:00
|
|
|
# before continuing as bsd.own.mk will need this to pick up _SRC_TOP_OBJ_
|
|
|
|
#
|
|
|
|
if [ "$MKOBJDIRS" != "no" ] && [ ! -z "$makeobjdir" ]; then
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd mkdir -p "$makeobjdir"
|
2001-11-26 08:57:33 +03:00
|
|
|
fi
|
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Find DESTDIR and TOOLDIR.
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
DESTDIR=$(safe_getmakevar DESTDIR)
|
|
|
|
$runcmd echo "===> DESTDIR path: $DESTDIR"
|
|
|
|
TOOLDIR=$(safe_getmakevar TOOLDIR)
|
|
|
|
$runcmd echo "===> TOOLDIR path: $TOOLDIR"
|
|
|
|
export DESTDIR TOOLDIR
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
|
|
|
|
# Check validity of TOOLDIR and DESTDIR.
|
|
|
|
if [ -z "$TOOLDIR" ] || [ "$TOOLDIR" = "/" ]; then
|
|
|
|
bomb "TOOLDIR '$TOOLDIR' invalid"
|
|
|
|
fi
|
|
|
|
removedirs="$TOOLDIR"
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ] || [ "$DESTDIR" = "/" ]; then
|
2002-12-08 11:42:51 +03:00
|
|
|
if $do_buildsystem; then
|
|
|
|
if [ "$buildtarget" != "build" ] || \
|
2002-12-25 03:42:50 +03:00
|
|
|
[ "${uname_s}" != "NetBSD" ] || \
|
|
|
|
[ "${uname_m}" != "$MACHINE" ]; then
|
2002-12-08 11:42:51 +03:00
|
|
|
bomb "DESTDIR must be set to a non-root path for cross builds or -d or -R."
|
|
|
|
fi
|
2002-12-09 01:14:00 +03:00
|
|
|
if ! $expert_mode; then
|
|
|
|
bomb "DESTDIR must be set to a non-root path for non -E (expert) builds"
|
|
|
|
fi
|
|
|
|
$runcmd echo "===> WARNING: Building to /, in expert mode."
|
2002-12-09 06:13:41 +03:00
|
|
|
$runcmd echo "===> This may cause your system to break! Reasons include:"
|
2002-12-09 01:14:00 +03:00
|
|
|
$runcmd echo "===> - your kernel is not up to date"
|
|
|
|
$runcmd echo "===> - the libraries or toolchain have changed"
|
|
|
|
$runcmd echo "===> YOU HAVE BEEN WARNED!"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
removedirs="$removedirs $DESTDIR"
|
|
|
|
fi
|
|
|
|
|
2002-12-25 03:42:50 +03:00
|
|
|
if [ "$installworlddir" = "/" ]; then
|
|
|
|
if [ "${uname_s}" != "NetBSD" ] || \
|
|
|
|
[ "${uname_m}" != "$MACHINE" ]; then
|
|
|
|
bomb "-i installworlddir must be set to a non-root path for cross builds."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
# Remove the target directories.
|
|
|
|
if $do_removedirs; then
|
|
|
|
for f in $removedirs; do
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd echo "===> Removing $f"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
$runcmd rm -r -f $f
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Recreate $TOOLDIR.
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd mkdir -p "$TOOLDIR/bin" || bomb "mkdir of '$TOOLDIR/bin' failed"
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
|
|
|
|
# Install nbmake if it was built.
|
|
|
|
if $do_rebuildmake; then
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd rm -f "$TOOLDIR/bin/nbmake"
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd cp $make "$TOOLDIR/bin/nbmake" \
|
|
|
|
|| bomb "failed to install \$TOOLDIR/bin/nbmake"
|
|
|
|
make="$TOOLDIR/bin/nbmake"
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd rm -r -f "$tmpdir"
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
trap 0
|
2001-10-19 06:21:03 +04:00
|
|
|
fi
|
|
|
|
|
2001-10-24 06:39:56 +04:00
|
|
|
# Build a nbmake wrapper script, usable by hand as well as by build.sh.
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
if [ -z "$makewrapper" ]; then
|
2002-03-21 13:54:50 +03:00
|
|
|
makewrapper="$TOOLDIR/bin/nbmake-$MACHINE"
|
2002-03-14 21:33:04 +03:00
|
|
|
if [ ! -z "$BUILDID" ]; then
|
2002-03-21 13:54:50 +03:00
|
|
|
makewrapper="$makewrapper-$BUILDID"
|
2002-03-14 21:33:04 +03:00
|
|
|
fi
|
Major cleanup and overhaul:
* Allow MACHINE to be set automatically on NetBSD native builds.
Require -m only if the host is not NetBSD.
* Fail if DESTDIR is set to root (/) and the build is not NetBSD native,
or the build is attempting a "make release" (option -R).
* Warn the user if DESTDIR is set to root (/) that the kernel must be up
to date, or else the build might hose the system. Also, do not remove
DESTDIR on -r if it is set to root.
* Fail if TOOLDIR is set to / or empty after checking with nbmake.
* Allow DESTDIR and TOOLDIR to be set in mk.conf and/or by the new default
from <bsd.own.mk>. Note that if -T is not used to set TOOLDIR, and
TOOLDIR is not set in the environment, then nbmake will always be
bootstrapped (rather than looking at nbmake's timestamp). This is
because /bin/sh doesn't know how to get TOOLDIR from mk.conf without
first having nbmake (...which lives in TOOLDIR).
* Do a pass of "make obj" through src/tools before installing nbmake (so
long as -o/MKOBJDIRS=no is not specified). This ensures that objdirs
exist if they are desired, and paves the way for using build.sh to
build all the src/tools without building everything else.
* Add "-w" option, which allows the builder to specify where the nbmake
wrapper shell script should be created. If not specified,
$TOOLDIR/bin/nbmake-$MACHINE is still created as a default.
* Print the values of DESTDIR and TOOLDIR after bootstrapping nbmake,
for informational purposes.
It should now be possible to type just "./build.sh" on a NetBSD-current
host and get a new build in / for the appropriate architecture.
However, building in-place like this has *not* been extensively tested
yet, so be careful.
2001-10-31 22:59:43 +03:00
|
|
|
fi
|
2001-10-24 06:39:56 +04:00
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd rm -f "$makewrapper"
|
2001-11-11 04:34:30 +03:00
|
|
|
if [ "$runcmd" = "echo" ]; then
|
|
|
|
echo 'cat <<EOF >'$makewrapper
|
|
|
|
makewrapout=
|
|
|
|
else
|
2002-03-21 13:54:50 +03:00
|
|
|
makewrapout=">>\$makewrapper"
|
2001-11-11 04:34:30 +03:00
|
|
|
fi
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2001-11-11 04:34:30 +03:00
|
|
|
eval cat <<EOF $makewrapout
|
2001-10-24 06:39:56 +04:00
|
|
|
#! /bin/sh
|
|
|
|
# Set proper variables to allow easy "make" building of a NetBSD subtree.
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
# Generated from: \$NetBSD: build.sh,v 1.82 2003/01/15 01:49:03 lukem Exp $
|
2001-10-24 06:39:56 +04:00
|
|
|
#
|
2001-11-02 08:07:22 +03:00
|
|
|
|
|
|
|
EOF
|
2001-11-11 04:34:30 +03:00
|
|
|
for f in $makeenv; do
|
2003-01-03 02:11:07 +03:00
|
|
|
eval echo "$f=\'\$$(echo $f)\'\;\ export\ $f" $makewrapout
|
2001-11-11 04:34:30 +03:00
|
|
|
done
|
|
|
|
eval echo "USETOOLS=yes\; export USETOOLS" $makewrapout
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
eval cat <<'EOF' $makewrapout
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2002-03-21 13:54:50 +03:00
|
|
|
exec "$TOOLDIR/bin/nbmake" ${1+"$@"}
|
2001-10-24 06:39:56 +04:00
|
|
|
EOF
|
2001-11-11 04:34:30 +03:00
|
|
|
[ "$runcmd" = "echo" ] && echo EOF
|
2002-03-21 13:54:50 +03:00
|
|
|
$runcmd chmod +x "$makewrapper"
|
2001-10-24 06:39:56 +04:00
|
|
|
|
2001-10-31 01:33:00 +03:00
|
|
|
if $do_buildsystem; then
|
2002-11-17 15:59:37 +03:00
|
|
|
# Build everything.
|
|
|
|
${runcmd-exec} "$makewrapper" $parallel $buildtarget \
|
|
|
|
|| bomb "failed to make $buildtarget"
|
2002-10-20 19:48:01 +04:00
|
|
|
else
|
2002-11-17 15:59:37 +03:00
|
|
|
# One or more of do_buildtools and do_buildkernel
|
2002-10-20 19:48:01 +04:00
|
|
|
# might be set. Do them in the appropriate order.
|
2002-11-17 15:59:37 +03:00
|
|
|
if $do_buildtools; then
|
2002-10-20 19:48:01 +04:00
|
|
|
if [ "$MKOBJDIRS" != "no" ]; then
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd "$makewrapper" $parallel obj-tools \
|
|
|
|
|| bomb "failed to make obj-tools"
|
2002-10-20 19:48:01 +04:00
|
|
|
fi
|
|
|
|
$runcmd cd tools
|
|
|
|
if [ "$UPDATE" = "" ]; then
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd "$makewrapper" cleandir dependall install \
|
|
|
|
|| bomb "failed to make tools"
|
2002-10-20 19:48:01 +04:00
|
|
|
else
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd "$makewrapper" dependall install \
|
|
|
|
|| bomb "failed to make tools"
|
2002-10-20 19:48:01 +04:00
|
|
|
fi
|
2001-11-01 03:14:17 +03:00
|
|
|
fi
|
2002-11-17 15:59:37 +03:00
|
|
|
if $do_buildkernel; then
|
|
|
|
if ! $do_buildtools; then
|
|
|
|
# Building tools every time we build a kernel
|
|
|
|
# is clearly unnecessary. We could try to
|
|
|
|
# figure out whether rebuilding the tools is
|
|
|
|
# necessary this time, but it doesn't seem
|
|
|
|
# worth the trouble. Instead, we say it's the
|
|
|
|
# user's responsibility to rebuild the tools if
|
|
|
|
# necessary.
|
|
|
|
$runcmd echo "===> Building kernel" \
|
|
|
|
"without building new tools"
|
|
|
|
fi
|
|
|
|
$runcmd echo "===> Building kernel ${kernconfname}"
|
|
|
|
if [ "$MKOBJDIRS" != "no" ] && [ ! -z "$makeobjdir" ]; then
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
# The correct value of KERNOBJDIR might
|
|
|
|
# depend on a prior "make obj" in
|
|
|
|
# ${KERNSRCDIR}/${KERNARCHDIR}/compile.
|
|
|
|
KERNSRCDIR="$(safe_getmakevar KERNSRCDIR)"
|
|
|
|
KERNARCHDIR="$(safe_getmakevar KERNARCHDIR)"
|
|
|
|
$runcmd cd "${KERNSRCDIR}/${KERNARCHDIR}/compile"
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd "$makewrapper" obj \
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
|| bomb "failed to make obj in " \
|
|
|
|
"${KERNSRCDIR}/${KERNARCHDIR}/compile"
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd cd "$TOP"
|
|
|
|
fi
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
KERNCONFDIR="$(safe_getmakevar KERNCONFDIR)"
|
|
|
|
KERNOBJDIR="$(safe_getmakevar KERNOBJDIR)"
|
2002-11-17 15:59:37 +03:00
|
|
|
case "${kernconfname}" in
|
2002-10-20 19:48:01 +04:00
|
|
|
*/*)
|
2002-11-17 15:59:37 +03:00
|
|
|
kernconfpath="${kernconfname}"
|
Improvements from Alan Barrett (in private email), with minor tweaking:
(Thanks Alan!)
* Before attempting to use KERNOBJDIR, we now need to "make obj" in
${KERNSRCDIR}/${KERNARCHDIR}/compile, not in ${TOP}/etc as used to be
the case.
* Fix one place where getmakevar was invoked unconditionally. It needs
to be conditional on $runcmd != "echo", so that we can rely on the
existence of the new $make executable.
* Add a sanity check to getmakevar, to bomb if a similar error is
introduced in the future.
* Changed the bomb function to print to stderr instead of to stdout, and
to kill the top level shell process. Without this, an attempted bomb
from inside getmakevar did not work properly.
* Moved some duplicated code into a new safe_getmakevar function, which
calls getmakevar if that is safe, or else emits a literal '$' followed
by the variable name.
Improvements from me:
* Always 'trap "exit 1" 1 2 3 15', so the kill in bomb() doesn't cause ugly
output.
2003-01-15 04:49:03 +03:00
|
|
|
kernconfbase="$(basename "${kernconfname}")"
|
2002-10-20 19:48:01 +04:00
|
|
|
;;
|
|
|
|
*)
|
2002-11-17 15:59:37 +03:00
|
|
|
kernconfpath="${KERNCONFDIR}/${kernconfname}"
|
|
|
|
kernconfbase="${kernconfname}"
|
2002-10-20 19:48:01 +04:00
|
|
|
;;
|
|
|
|
esac
|
2002-11-17 15:59:37 +03:00
|
|
|
kernbuilddir="${KERNOBJDIR}/${kernconfbase}"
|
|
|
|
$runcmd echo "===> Kernel build directory: ${kernbuilddir}"
|
|
|
|
$runcmd mkdir -p "${kernbuilddir}" \
|
|
|
|
|| bomb "cannot mkdir: ${kernbuilddir}"
|
2002-10-20 19:48:01 +04:00
|
|
|
if [ "$UPDATE" = "" ]; then
|
2002-11-17 15:59:37 +03:00
|
|
|
$runcmd cd "${kernbuilddir}"
|
|
|
|
$runcmd "$makewrapper" cleandir \
|
|
|
|
|| bomb "make cleandir failed in " \
|
|
|
|
"${kernbuilddir}"
|
2002-10-20 19:48:01 +04:00
|
|
|
$runcmd cd "$TOP"
|
|
|
|
fi
|
|
|
|
$runcmd "${TOOLDIR}/bin/nbconfig" \
|
2002-11-17 15:59:37 +03:00
|
|
|
-b "${kernbuilddir}" \
|
|
|
|
-s "${TOP}/sys" "${kernconfpath}" \
|
|
|
|
|| bomb "nbconfig failed for ${kernconfname}"
|
|
|
|
$runcmd cd "${kernbuilddir}"
|
|
|
|
$runcmd "$makewrapper" depend \
|
|
|
|
|| bomb "make depend failed in ${kernbuilddir}"
|
|
|
|
$runcmd "$makewrapper" $parallel all \
|
|
|
|
|| bomb "make all failed in ${kernbuilddir}"
|
|
|
|
$runcmd echo "===> New kernel should be in ${kernbuilddir}"
|
2001-12-09 09:07:16 +03:00
|
|
|
fi
|
2001-10-31 00:04:05 +03:00
|
|
|
fi
|
2002-12-25 03:42:50 +03:00
|
|
|
|
|
|
|
if [ -n "$installworlddir" ]; then
|
|
|
|
${runcmd-exec} "$makewrapper" INSTALLWORLDDIR=${installworlddir} \
|
|
|
|
installworld || bomb "failed to make installworld"
|
|
|
|
fi
|