- Add support for ./build.sh -k kern, which configures and builds the named
kernel using the $TOOLDIR toolchain. If kern doesn't contain `/', it will be searched for in ${KERNCONFDIR} (typically, sys/arch/${MACHINE}/conf). - Improve ./build.sh usage. - Add some examples to the documentation. This is heavily based on [toolchain/18739] from Alan Barrett <apb@cequrux.com>, with improvements by me.
This commit is contained in:
parent
6fdbe5f4cb
commit
da7aeb45e7
122
build.sh
122
build.sh
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/env sh
|
||||
# $NetBSD: build.sh,v 1.69 2002/10/02 16:57:29 thorpej Exp $
|
||||
# $NetBSD: build.sh,v 1.70 2002/10/20 15:48:01 lukem Exp $
|
||||
#
|
||||
# Top level build wrapper, for a system containing no tools.
|
||||
#
|
||||
|
@ -90,6 +90,7 @@ getmakevar () {
|
|||
_x_:
|
||||
echo \${$1}
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.kernobj.mk>
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -101,31 +102,35 @@ resolvepath () {
|
|||
}
|
||||
|
||||
usage () {
|
||||
echo "Usage:"
|
||||
echo "$0 [-bdorUu] [-a arch] [-B buildid] [-j njob] [-m mach] "
|
||||
echo " [-w wrapper] [-D dest] [-M obj] [-O obj] [-R release] [-T tools]"
|
||||
echo ""
|
||||
echo " -a: set MACHINE_ARCH to arch (otherwise deduced from MACHINE)"
|
||||
echo " -B: set BUILDID to buildid"
|
||||
echo " -b: build nbmake and nbmake wrapper script, if needed"
|
||||
echo " -D: set DESTDIR to dest"
|
||||
echo " -d: build a full distribution into DESTDIR (including etc files)"
|
||||
echo " -j: Run up to njob jobs in parallel; see make(1)"
|
||||
echo " -M: set obj root directory to obj (sets MAKEOBJDIRPREFIX)"
|
||||
echo " -m: set MACHINE to mach (not required if NetBSD native)"
|
||||
echo " -n: show commands that would be executed, but do not execute them"
|
||||
echo " -O: set obj root directory to obj (sets a MAKEOBJDIR pattern)"
|
||||
echo " -o: set MKOBJDIRS=no (do not create objdirs at start of build)"
|
||||
echo " -R: build a release (and set RELEASEDIR to release)"
|
||||
echo " -r: remove contents of TOOLDIR and DESTDIR before building"
|
||||
echo " -T: set TOOLDIR to tools"
|
||||
echo " -t: build and install tools only (implies -b)"
|
||||
echo " -U: set UNPRIVED"
|
||||
echo " -u: set UPDATE"
|
||||
echo " -w: create nbmake script at wrapper (default TOOLDIR/bin/nbmake-MACHINE)"
|
||||
echo ""
|
||||
echo "Note: if -T is unset and TOOLDIR is not set in the environment,"
|
||||
echo " nbmake will be [re]built unconditionally."
|
||||
cat <<_usage_
|
||||
Usage:
|
||||
$0 [-bdorUu] [-a arch] [-B buildid] [-D dest] [-j njob] [-k kernel]
|
||||
[-M obj] [-m mach] [-O obj] [-R release] [-T tools] [-w wrapper]
|
||||
|
||||
-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)
|
||||
-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)
|
||||
-r remove contents of TOOLDIR and DESTDIR before building
|
||||
-T tools set TOOLDIR to tools
|
||||
-t build and install tools only (implies -b)
|
||||
-U set UNPRIVED
|
||||
-u set UPDATE
|
||||
-w wrapper create nbmake script at wrapper
|
||||
(default TOOLDIR/bin/nbmake-MACHINE)
|
||||
|
||||
Note: if -T is unset and TOOLDIR is not set in the environment,
|
||||
nbmake will be [re]built unconditionally.
|
||||
_usage_
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -133,13 +138,14 @@ usage () {
|
|||
MAKEFLAGS=
|
||||
buildtarget=build
|
||||
do_buildsystem=true
|
||||
do_buildonlykernel=false
|
||||
do_buildonlytools=false
|
||||
do_rebuildmake=false
|
||||
do_removedirs=false
|
||||
makeenv=
|
||||
makewrapper=
|
||||
opt_a=no
|
||||
opts='a:B:bdhj:m:nortuw:D:M:O:R:T:U'
|
||||
opts='a:B:bdhj:k:m:nortuw:D:M:O:R:T:U'
|
||||
runcmd=
|
||||
|
||||
if type getopts >/dev/null 2>&1; then
|
||||
|
@ -173,6 +179,10 @@ while eval $getoptcmd; do case $opt in
|
|||
-j) eval $optargcmd
|
||||
parallel="-j $OPTARG";;
|
||||
|
||||
-k) do_buildonlykernel=true; do_buildsystem=false
|
||||
eval $optargcmd
|
||||
KERNCONFNAME=$OPTARG;;
|
||||
|
||||
# -m overrides MACHINE_ARCH unless "-a" is specified
|
||||
-m) eval $optargcmd
|
||||
MACHINE=$OPTARG; [ "$opt_a" != "yes" ] && getarch;;
|
||||
|
@ -308,7 +318,7 @@ fi
|
|||
if [ -z "$TOOLDIR" ] && [ "$MKOBJDIRS" != "no" ]; then
|
||||
$runcmd cd tools
|
||||
$runcmd $make -m ${TOP}/share/mk obj NOSUBDIR= || exit 1
|
||||
$runcmd cd ..
|
||||
$runcmd cd "$TOP"
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -394,7 +404,7 @@ fi
|
|||
eval cat <<EOF $makewrapout
|
||||
#! /bin/sh
|
||||
# Set proper variables to allow easy "make" building of a NetBSD subtree.
|
||||
# Generated from: \$NetBSD: build.sh,v 1.69 2002/10/02 16:57:29 thorpej Exp $
|
||||
# Generated from: \$NetBSD: build.sh,v 1.70 2002/10/20 15:48:01 lukem Exp $
|
||||
#
|
||||
|
||||
EOF
|
||||
|
@ -412,14 +422,52 @@ $runcmd chmod +x "$makewrapper"
|
|||
|
||||
if $do_buildsystem; then
|
||||
${runcmd-exec} "$makewrapper" $parallel $buildtarget
|
||||
elif $do_buildonlytools; then
|
||||
if [ "$MKOBJDIRS" != "no" ]; then
|
||||
$runcmd "$makewrapper" $parallel obj-tools || exit 1
|
||||
else
|
||||
# One or more of do_buildonlytools and do_buildonlykernel
|
||||
# might be set. Do them in the appropriate order.
|
||||
if $do_buildonlytools; then
|
||||
if [ "$MKOBJDIRS" != "no" ]; then
|
||||
$runcmd "$makewrapper" $parallel obj-tools || exit 1
|
||||
fi
|
||||
$runcmd cd tools
|
||||
if [ "$UPDATE" = "" ]; then
|
||||
$runcmd "$makewrapper" cleandir dependall install
|
||||
else
|
||||
$runcmd "$makewrapper" dependall install
|
||||
fi
|
||||
fi
|
||||
$runcmd cd tools
|
||||
if [ "$UPDATE" = "" ]; then
|
||||
${runcmd-exec} "$makewrapper" cleandir dependall install
|
||||
else
|
||||
${runcmd-exec} "$makewrapper" dependall install
|
||||
if $do_buildonlykernel; then
|
||||
$runcmd echo "===> Building kernel ${KERNCONFNAME}"
|
||||
if [ "$runcmd" = "echo" ]; then
|
||||
# shown symbolically with -n
|
||||
# because getmakevar might not work yet
|
||||
KERNCONFDIR='${KERNCONFDIR}'
|
||||
KERNOBJDIR='${KERNOBJDIR}'
|
||||
else
|
||||
KERNCONFDIR="$( getmakevar KERNCONFDIR )"
|
||||
KERNOBJDIR="$( getmakevar KERNOBJDIR )"
|
||||
fi
|
||||
case "${KERNCONFNAME}" in
|
||||
*/*)
|
||||
kernconfpath=${KERNCONFNAME}
|
||||
KERNCONFNAME=`basename ${KERNCONFNAME}`
|
||||
;;
|
||||
*)
|
||||
kernconfpath=${KERNCONFDIR}/${KERNCONFNAME}
|
||||
;;
|
||||
esac
|
||||
$runcmd mkdir -p "${KERNOBJDIR}/${KERNCONFNAME}"
|
||||
if [ "$UPDATE" = "" ]; then
|
||||
$runcmd cd "${KERNOBJDIR}/${KERNCONFNAME}"
|
||||
$runcmd "$makewrapper" cleandir
|
||||
$runcmd cd "$TOP"
|
||||
fi
|
||||
$runcmd "${TOOLDIR}/bin/nbconfig" \
|
||||
-b "${KERNOBJDIR}/${KERNCONFNAME}" \
|
||||
-s "${TOP}/sys" "${kernconfpath}"
|
||||
$runcmd cd "${KERNOBJDIR}/${KERNCONFNAME}"
|
||||
$runcmd "$makewrapper" depend
|
||||
$runcmd "$makewrapper" $parallel all
|
||||
echo "New kernel should be in ${KERNOBJDIR}/${KERNCONFNAME}"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: BUILDING.mdoc,v 1.1 2002/09/21 08:19:29 lukem Exp $
|
||||
.\" $NetBSD: BUILDING.mdoc,v 1.2 2002/10/20 15:48:02 lukem Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -38,7 +38,7 @@
|
|||
.\" NOTE: After changing this file, run "make build-docs" to generate the
|
||||
.\" proper plaintext versions, and check in all BUILDING.* files!
|
||||
.\"
|
||||
.Dd September 21, 2002
|
||||
.Dd October 21, 2002
|
||||
.Dt BUILDING 8
|
||||
.Os NetBSD
|
||||
.
|
||||
|
@ -824,6 +824,40 @@ as necessary to enforce build ordering.
|
|||
If you see build failures with -j, please save complete build logs
|
||||
so the failures can be analyzed.
|
||||
.
|
||||
.It Sy -k Em kernel
|
||||
Build a new kernel.
|
||||
The
|
||||
.Em kernel
|
||||
argument is the name of a configuration file suitable
|
||||
for use by
|
||||
.Xr config 8 .
|
||||
If
|
||||
.Em kernel
|
||||
does not contain any
|
||||
.Sq /
|
||||
characters, the configuration file is expected to be found in the
|
||||
.Sy KERNCONFDIR
|
||||
directory, which is typically
|
||||
.Sy sys/arch/MACHINE/conf .
|
||||
The new kernel will be built in a subdirectory of
|
||||
.Sy KERNOBJDIR ,
|
||||
which is typically
|
||||
.Sy sys/arch/MACHINE/compile
|
||||
or an associated object directory.
|
||||
In order to ensure that the kernel is built using up-to-date tools,
|
||||
it is strongly recommended that the tools be rebuilt (using the
|
||||
.Sy -t
|
||||
option) in a separate invocation of
|
||||
.Nm build.sh
|
||||
prior to using the
|
||||
.Sy -k
|
||||
option, or that the
|
||||
.Sy -t
|
||||
and
|
||||
.Sy -k
|
||||
options be used together in a single invocation of
|
||||
.Nm build.sh .
|
||||
.
|
||||
.It Sy -m Em mach
|
||||
Set the value of
|
||||
.Sy MACHINE
|
||||
|
@ -963,6 +997,28 @@ This script can be symlinked into a directory listed in
|
|||
.Sy PATH ,
|
||||
or called with an absolute path.
|
||||
.
|
||||
.Sh EXAMPLES
|
||||
.Bl -tag -width "build.sh"
|
||||
.It Li "./build.sh -t"
|
||||
Build a new toolchain.
|
||||
.It Li "cd ${KERNCONFDIR} ; ${TOOLDIR}/bin/nbconfig GENERIC"
|
||||
Use the new version of
|
||||
.Xr config 8
|
||||
to prepare to build a new GENERIC kernel.
|
||||
.It Li "cd ${KERNOBJDIR}/GENERIC ; ${TOOLDIR}/bin/nbmake-${MACHINE} dependall"
|
||||
Use the new toolchain to build a new GENERIC kernel.
|
||||
.It Li "./build.sh -t -k GENERIC"
|
||||
Build a new toolchain, and use the new toolchain to
|
||||
configure and build a new GENERIC kernel.
|
||||
.It Li "./build.sh -U -d"
|
||||
Using unprivileged mode,
|
||||
build a complete distribution in
|
||||
.Sy DESTDIR .
|
||||
.It Li "./build.sh -U -R /some/dir/RELEASE"
|
||||
Using unprivileged mode,
|
||||
build a complete release in the specified release directory.
|
||||
.El
|
||||
.
|
||||
.Sh OBSOLETE VARIABLES
|
||||
.
|
||||
.Bl -tag -width "NBUILDJOBS"
|
||||
|
|
Loading…
Reference in New Issue