version 1.171.4.3, 2008/03/23 00:12:06 |
version 1.172, 2007/08/30 05:30:02 |
|
|
#! /usr/bin/env sh |
#! /usr/bin/env sh |
# build.sh,v 1.171.4.2 2008/01/09 01:19:18 matt Exp |
# $NetBSD$ |
# |
# |
# Copyright (c) 2001-2005 The NetBSD Foundation, Inc. |
# Copyright (c) 2001-2005 The NetBSD Foundation, Inc. |
# All rights reserved. |
# All rights reserved. |
|
|
MACHINE_ARCH=mipsel |
MACHINE_ARCH=mipsel |
;; |
;; |
|
|
evbppc64|macppc64|ofppc64) |
pc532) |
|
MACHINE_ARCH=ns32k |
|
;; |
|
|
|
evbppc64|macppc64) |
makewrappermachine=${MACHINE} |
makewrappermachine=${MACHINE} |
MACHINE=${MACHINE%64} |
MACHINE=${MACHINE%64} |
MACHINE_ARCH=powerpc64 |
MACHINE_ARCH=powerpc64 |
;; |
;; |
|
|
amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|prep|rs6000|sandpoint) |
amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|pmppc|prep|sandpoint) |
MACHINE_ARCH=powerpc |
MACHINE_ARCH=powerpc |
;; |
;; |
|
|
|
|
# |
# |
case "${MACHINE_ARCH}" in |
case "${MACHINE_ARCH}" in |
|
|
alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|powerpc|powerpc64|sh3e[bl]|sparc|sparc64|vax|x86_64|ia64) |
alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|ns32k|powerpc|powerpc64|sh[35]e[bl]|sparc|sparc64|vax|x86_64|ia64) |
;; |
;; |
|
|
"") |
"") |
|
|
arches="sh3eb sh3el" |
arches="sh3eb sh3el" |
;; |
;; |
|
|
macppc|evbppc|ofppc) |
macppc|evbppc) |
arches="powerpc powerpc64" |
arches="powerpc powerpc64" |
;; |
;; |
*) |
*) |
|
|
fi |
fi |
cat <<_usage_ |
cat <<_usage_ |
|
|
Usage: ${progname} [-EnorUux] [-a arch] [-B buildid] [-C cdextras] [-D dest] |
Usage: ${progname} [-EnorUux] [-a arch] [-B buildid] [-D dest] [-j njob] |
[-j njob] [-M obj] [-m mach] [-N noisy] [-O obj] [-R release] |
[-M obj] [-m mach] [-N noisy] [-O obj] [-R release] [-T tools] |
[-T tools] [-V var=[value]] [-w wrapper] [-X x11src] [-Z var] |
[-V var=[value]] [-w wrapper] [-X x11src] [-Z var] |
operation [...] |
operation [...] |
|
|
Build operations (all imply "obj" and "tools"): |
Build operations (all imply "obj" and "tools"): |
Line 515 Usage: ${progname} [-EnorUux] [-a arch] |
|
Line 519 Usage: ${progname} [-EnorUux] [-a arch] |
|
except \`etc'. Useful after "distribution" or "release" |
except \`etc'. Useful after "distribution" or "release" |
kernel=conf Build kernel with config file \`conf' |
kernel=conf Build kernel with config file \`conf' |
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR. |
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR. |
sets Create binary sets in |
sets Create binary sets in RELEASEDIR/MACHINE/binary/sets. |
RELEASEDIR/RELEASEMACHINEDIR/binary/sets. |
|
DESTDIR should be populated beforehand. |
DESTDIR should be populated beforehand. |
sourcesets Create source sets in RELEASEDIR/source/sets. |
sourcesets Create source sets in RELEASEDIR/source/sets. |
syspkgs Create syspkgs in |
syspkgs Create syspkgs in RELEASEDIR/MACHINE/binary/syspkgs. |
RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs. |
|
iso-image Create CD-ROM image in RELEASEDIR/iso. |
iso-image Create CD-ROM image in RELEASEDIR/iso. |
iso-image-source Create CD-ROM image with source in RELEASEDIR/iso. |
iso-image-source Create CD-ROM image with source in RELEASEDIR/iso. |
params Display various make(1) parameters. |
params Display various make(1) parameters. |
Line 528 Usage: ${progname} [-EnorUux] [-a arch] |
|
Line 530 Usage: ${progname} [-EnorUux] [-a arch] |
|
Options: |
Options: |
-a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE] |
-a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE] |
-B buildId Set BUILDID to buildId. |
-B buildId Set BUILDID to buildId. |
-C cdextras Set CDEXTRA to cdextras |
|
-D dest Set DESTDIR to dest. [Default: destdir.MACHINE] |
-D dest Set DESTDIR to dest. [Default: destdir.MACHINE] |
-E Set "expert" mode; disables various safety checks. |
-E Set "expert" mode; disables various safety checks. |
Should not be used without expert knowledge of the build system. |
Should not be used without expert knowledge of the build system. |
|
|
|
|
parseoptions() |
parseoptions() |
{ |
{ |
opts='a:B:bC:D:dEhi:j:k:M:m:N:nO:oR:rT:tUuV:w:xX:Z:' |
opts='a:B:bD:dEhi:j:k:M:m:N:nO:oR:rT:tUuV:w:xX:Z:' |
opt_a=no |
opt_a=no |
|
|
if type getopts >/dev/null 2>&1; then |
if type getopts >/dev/null 2>&1; then |
|
|
usage "'-b' has been replaced by 'makewrapper'" |
usage "'-b' has been replaced by 'makewrapper'" |
;; |
;; |
|
|
-C) |
|
eval ${optargcmd}; resolvepath |
|
iso_dir=${OPTARG} |
|
;; |
|
|
|
-D) |
-D) |
eval ${optargcmd}; resolvepath |
eval ${optargcmd}; resolvepath |
setmakeenv DESTDIR "${OPTARG}" |
setmakeenv DESTDIR "${OPTARG}" |
Line 987 validatemakeparams() |
|
Line 983 validatemakeparams() |
|
${runcmd} cd "${TOP}" |
${runcmd} cd "${TOP}" |
fi |
fi |
|
|
# Find TOOLDIR, DESTDIR, RELEASEDIR, and RELEASEMACHINEDIR. |
# Find TOOLDIR, DESTDIR, and RELEASEDIR. |
# |
# |
TOOLDIR=$(getmakevar TOOLDIR) |
TOOLDIR=$(getmakevar TOOLDIR) |
statusmsg "TOOLDIR path: ${TOOLDIR}" |
statusmsg "TOOLDIR path: ${TOOLDIR}" |
DESTDIR=$(getmakevar DESTDIR) |
DESTDIR=$(getmakevar DESTDIR) |
RELEASEDIR=$(getmakevar RELEASEDIR) |
RELEASEDIR=$(getmakevar RELEASEDIR) |
RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR) |
|
if ! $do_expertmode; then |
if ! $do_expertmode; then |
_SRC_TOP_OBJ_=$(getmakevar _SRC_TOP_OBJ_) |
_SRC_TOP_OBJ_=$(getmakevar _SRC_TOP_OBJ_) |
: ${DESTDIR:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}} |
: ${DESTDIR:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}} |
Line 1036 validatemakeparams() |
|
Line 1031 validatemakeparams() |
|
[ "${MKUNPRIVED}" = "no" ] ; then |
[ "${MKUNPRIVED}" = "no" ] ; then |
bomb "-U or -E must be set for build as an unprivileged user." |
bomb "-U or -E must be set for build as an unprivileged user." |
fi |
fi |
fi |
fi |
if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then |
if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then |
bomb "Must set RELEASEDIR with \`releasekernel=...'" |
bomb "Must set RELEASEDIR with \`releasekernel=...'" |
fi |
fi |
|
|
# Install as non-root is a bad idea. |
|
# |
|
if ${do_install} && [ "$(id -u 2>/dev/null)" -ne 0 ] ; then |
|
if ${do_expertmode}; then |
|
warning "Will install as an unprivileged user." |
|
else |
|
bomb "-E must be set for install as an unprivileged user." |
|
fi |
|
fi |
|
|
|
# If a previous build.sh run used -U (and therefore created a |
|
# METALOG file), then most subsequent build.sh runs must also |
|
# use -U. If DESTDIR is about to be removed, then don't perform |
|
# this check. |
|
# |
|
case "${do_removedirs} ${removedirs} " in |
|
true*" ${DESTDIR} "*) |
|
# DESTDIR is about to be removed |
|
;; |
|
*) |
|
if ( ${do_build} || ${do_distribution} || ${do_release} || \ |
|
${do_install} ) && \ |
|
[ -e "${DESTDIR}/METALOG" ] && \ |
|
[ "${MKUNPRIVED}" = "no" ] ; then |
|
if $do_expertmode; then |
|
warning "A previous build.sh run specified -U." |
|
else |
|
bomb "A previous build.sh run specified -U; you must specify it again now." |
|
fi |
|
fi |
|
;; |
|
esac |
|
} |
} |
|
|
|
|
Line 1127 createmakewrapper() |
|
Line 1089 createmakewrapper() |
|
eval cat <<EOF ${makewrapout} |
eval cat <<EOF ${makewrapout} |
#! ${HOST_SH} |
#! ${HOST_SH} |
# Set proper variables to allow easy "make" building of a NetBSD subtree. |
# Set proper variables to allow easy "make" building of a NetBSD subtree. |
# Generated from: \build.sh,v 1.171.4.2 2008/01/09 01:19:18 matt Exp |
# Generated from: \$NetBSD$ |
# with these arguments: ${_args} |
# with these arguments: ${_args} |
# |
# |
|
|
EOF |
EOF |
{ |
for f in ${makeenv}; do |
for f in ${makeenv}; do |
if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then |
if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then |
eval echo "unset ${f}" ${makewrapout} |
eval echo "unset ${f}" |
else |
else |
eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}" ${makewrapout} |
eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}" |
fi |
fi |
done |
done |
|
|
|
eval cat <<EOF |
eval cat <<EOF ${makewrapout} |
MAKEWRAPPERMACHINE=${makewrappermachine:-${MACHINE}}; export MAKEWRAPPERMACHINE |
MAKEWRAPPERMACHINE=${makewrappermachine:-${MACHINE}}; export MAKEWRAPPERMACHINE |
USETOOLS=yes; export USETOOLS |
USETOOLS=yes; export USETOOLS |
EOF |
|
} | eval sort -u "${makewrapout}" |
|
eval cat <<EOF "${makewrapout}" |
|
|
|
exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"} |
exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"} |
EOF |
EOF |
|
|
releasekernel() |
releasekernel() |
{ |
{ |
getkernelconf $1 |
getkernelconf $1 |
kernelreldir="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel" |
kernelreldir="${RELEASEDIR}/${MACHINE}/binary/kernel" |
${runcmd} mkdir -p "${kernelreldir}" |
${runcmd} mkdir -p "${kernelreldir}" |
kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath}) |
kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath}) |
for kern in ${kernlist:-netbsd}; do |
for kern in ${kernlist:-netbsd}; do |
|
|
statusmsg "Building sets from pre-populated ${DESTDIR}" |
statusmsg "Building sets from pre-populated ${DESTDIR}" |
${runcmd} "${makewrapper}" ${parallel} ${op} || |
${runcmd} "${makewrapper}" ${parallel} ${op} || |
bomb "Failed to make ${op}" |
bomb "Failed to make ${op}" |
setdir=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets |
|
statusmsg "Built sets to ${setdir}" |
|
;; |
|
|
|
obj|build|distribution|release|sourcesets|syspkgs|params) |
|
${runcmd} "${makewrapper}" ${parallel} ${op} || |
|
bomb "Failed to make ${op}" |
|
statusmsg "Successful make ${op}" |
statusmsg "Successful make ${op}" |
;; |
;; |
|
|
iso-image|iso-image-source) |
obj|build|distribution|iso-image|iso-image-source|release|sourcesets|syspkgs|params) |
${runcmd} "${makewrapper}" ${parallel} \ |
${runcmd} "${makewrapper}" ${parallel} ${op} || |
CDEXTRA=$iso_dir ${op} || |
|
bomb "Failed to make ${op}" |
bomb "Failed to make ${op}" |
statusmsg "Successful make ${op}" |
statusmsg "Successful make ${op}" |
;; |
;; |