- 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
|
#! /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.
|
# Top level build wrapper, for a system containing no tools.
|
||||||
#
|
#
|
||||||
|
@ -90,6 +90,7 @@ getmakevar () {
|
||||||
_x_:
|
_x_:
|
||||||
echo \${$1}
|
echo \${$1}
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
.include <bsd.kernobj.mk>
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,31 +102,35 @@ resolvepath () {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo "Usage:"
|
cat <<_usage_
|
||||||
echo "$0 [-bdorUu] [-a arch] [-B buildid] [-j njob] [-m mach] "
|
Usage:
|
||||||
echo " [-w wrapper] [-D dest] [-M obj] [-O obj] [-R release] [-T tools]"
|
$0 [-bdorUu] [-a arch] [-B buildid] [-D dest] [-j njob] [-k kernel]
|
||||||
echo ""
|
[-M obj] [-m mach] [-O obj] [-R release] [-T tools] [-w wrapper]
|
||||||
echo " -a: set MACHINE_ARCH to arch (otherwise deduced from MACHINE)"
|
|
||||||
echo " -B: set BUILDID to buildid"
|
-a arch set MACHINE_ARCH to arch (otherwise deduced from MACHINE)
|
||||||
echo " -b: build nbmake and nbmake wrapper script, if needed"
|
-B buildid set BUILDID to buildid
|
||||||
echo " -D: set DESTDIR to dest"
|
-b build nbmake and nbmake wrapper script, if needed
|
||||||
echo " -d: build a full distribution into DESTDIR (including etc files)"
|
-D dest set DESTDIR to dest
|
||||||
echo " -j: Run up to njob jobs in parallel; see make(1)"
|
-d build a full distribution into DESTDIR (including etc files)
|
||||||
echo " -M: set obj root directory to obj (sets MAKEOBJDIRPREFIX)"
|
-j njob run up to njob jobs in parallel; see make(1)
|
||||||
echo " -m: set MACHINE to mach (not required if NetBSD native)"
|
-k kernel build a kernel using the named configuration file
|
||||||
echo " -n: show commands that would be executed, but do not execute them"
|
-M obj set obj root directory to obj (sets MAKEOBJDIRPREFIX)
|
||||||
echo " -O: set obj root directory to obj (sets a MAKEOBJDIR pattern)"
|
-m mach set MACHINE to mach (not required if NetBSD native)
|
||||||
echo " -o: set MKOBJDIRS=no (do not create objdirs at start of build)"
|
-n show commands that would be executed, but do not execute them
|
||||||
echo " -R: build a release (and set RELEASEDIR to release)"
|
-O obj set obj root directory to obj (sets a MAKEOBJDIR pattern)
|
||||||
echo " -r: remove contents of TOOLDIR and DESTDIR before building"
|
-o set MKOBJDIRS=no (do not create objdirs at start of build)
|
||||||
echo " -T: set TOOLDIR to tools"
|
-R release build a release (and set RELEASEDIR to release)
|
||||||
echo " -t: build and install tools only (implies -b)"
|
-r remove contents of TOOLDIR and DESTDIR before building
|
||||||
echo " -U: set UNPRIVED"
|
-T tools set TOOLDIR to tools
|
||||||
echo " -u: set UPDATE"
|
-t build and install tools only (implies -b)
|
||||||
echo " -w: create nbmake script at wrapper (default TOOLDIR/bin/nbmake-MACHINE)"
|
-U set UNPRIVED
|
||||||
echo ""
|
-u set UPDATE
|
||||||
echo "Note: if -T is unset and TOOLDIR is not set in the environment,"
|
-w wrapper create nbmake script at wrapper
|
||||||
echo " nbmake will be [re]built unconditionally."
|
(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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,13 +138,14 @@ usage () {
|
||||||
MAKEFLAGS=
|
MAKEFLAGS=
|
||||||
buildtarget=build
|
buildtarget=build
|
||||||
do_buildsystem=true
|
do_buildsystem=true
|
||||||
|
do_buildonlykernel=false
|
||||||
do_buildonlytools=false
|
do_buildonlytools=false
|
||||||
do_rebuildmake=false
|
do_rebuildmake=false
|
||||||
do_removedirs=false
|
do_removedirs=false
|
||||||
makeenv=
|
makeenv=
|
||||||
makewrapper=
|
makewrapper=
|
||||||
opt_a=no
|
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=
|
runcmd=
|
||||||
|
|
||||||
if type getopts >/dev/null 2>&1; then
|
if type getopts >/dev/null 2>&1; then
|
||||||
|
@ -173,6 +179,10 @@ while eval $getoptcmd; do case $opt in
|
||||||
-j) eval $optargcmd
|
-j) eval $optargcmd
|
||||||
parallel="-j $OPTARG";;
|
parallel="-j $OPTARG";;
|
||||||
|
|
||||||
|
-k) do_buildonlykernel=true; do_buildsystem=false
|
||||||
|
eval $optargcmd
|
||||||
|
KERNCONFNAME=$OPTARG;;
|
||||||
|
|
||||||
# -m overrides MACHINE_ARCH unless "-a" is specified
|
# -m overrides MACHINE_ARCH unless "-a" is specified
|
||||||
-m) eval $optargcmd
|
-m) eval $optargcmd
|
||||||
MACHINE=$OPTARG; [ "$opt_a" != "yes" ] && getarch;;
|
MACHINE=$OPTARG; [ "$opt_a" != "yes" ] && getarch;;
|
||||||
|
@ -308,7 +318,7 @@ fi
|
||||||
if [ -z "$TOOLDIR" ] && [ "$MKOBJDIRS" != "no" ]; then
|
if [ -z "$TOOLDIR" ] && [ "$MKOBJDIRS" != "no" ]; then
|
||||||
$runcmd cd tools
|
$runcmd cd tools
|
||||||
$runcmd $make -m ${TOP}/share/mk obj NOSUBDIR= || exit 1
|
$runcmd $make -m ${TOP}/share/mk obj NOSUBDIR= || exit 1
|
||||||
$runcmd cd ..
|
$runcmd cd "$TOP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -394,7 +404,7 @@ fi
|
||||||
eval cat <<EOF $makewrapout
|
eval cat <<EOF $makewrapout
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Set proper variables to allow easy "make" building of a NetBSD subtree.
|
# Set proper variables to allow easy "make" building of a NetBSD subtree.
|
||||||
# Generated from: \$NetBSD: 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
|
EOF
|
||||||
|
@ -412,14 +422,52 @@ $runcmd chmod +x "$makewrapper"
|
||||||
|
|
||||||
if $do_buildsystem; then
|
if $do_buildsystem; then
|
||||||
${runcmd-exec} "$makewrapper" $parallel $buildtarget
|
${runcmd-exec} "$makewrapper" $parallel $buildtarget
|
||||||
elif $do_buildonlytools; then
|
else
|
||||||
if [ "$MKOBJDIRS" != "no" ]; then
|
# One or more of do_buildonlytools and do_buildonlykernel
|
||||||
$runcmd "$makewrapper" $parallel obj-tools || exit 1
|
# 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
|
fi
|
||||||
$runcmd cd tools
|
if $do_buildonlykernel; then
|
||||||
if [ "$UPDATE" = "" ]; then
|
$runcmd echo "===> Building kernel ${KERNCONFNAME}"
|
||||||
${runcmd-exec} "$makewrapper" cleandir dependall install
|
if [ "$runcmd" = "echo" ]; then
|
||||||
else
|
# shown symbolically with -n
|
||||||
${runcmd-exec} "$makewrapper" dependall install
|
# 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
|
||||||
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.
|
.\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
.\" NOTE: After changing this file, run "make build-docs" to generate the
|
.\" NOTE: After changing this file, run "make build-docs" to generate the
|
||||||
.\" proper plaintext versions, and check in all BUILDING.* files!
|
.\" proper plaintext versions, and check in all BUILDING.* files!
|
||||||
.\"
|
.\"
|
||||||
.Dd September 21, 2002
|
.Dd October 21, 2002
|
||||||
.Dt BUILDING 8
|
.Dt BUILDING 8
|
||||||
.Os NetBSD
|
.Os NetBSD
|
||||||
.
|
.
|
||||||
|
@ -824,6 +824,40 @@ as necessary to enforce build ordering.
|
||||||
If you see build failures with -j, please save complete build logs
|
If you see build failures with -j, please save complete build logs
|
||||||
so the failures can be analyzed.
|
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
|
.It Sy -m Em mach
|
||||||
Set the value of
|
Set the value of
|
||||||
.Sy MACHINE
|
.Sy MACHINE
|
||||||
|
@ -963,6 +997,28 @@ This script can be symlinked into a directory listed in
|
||||||
.Sy PATH ,
|
.Sy PATH ,
|
||||||
or called with an absolute 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
|
.Sh OBSOLETE VARIABLES
|
||||||
.
|
.
|
||||||
.Bl -tag -width "NBUILDJOBS"
|
.Bl -tag -width "NBUILDJOBS"
|
||||||
|
|
Loading…
Reference in New Issue