8000 minix/build.sh at master · blackskygg/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
executable file
·
2164 lines (1960 loc) · 61 KB

build.sh

File metadata and controls

executable file
·
2164 lines (1960 loc) · 61 KB
#! /usr/bin/env sh
# $NetBSD: build.sh,v 1.273 2013/08/30 10:29:06 pooka Exp $
#
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Todd Vierling and Luke Mewburn.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# Top level build wrapper, to build or cross-build NetBSD.
#
#
# {{{ Begin shell feature tests.
#
# We try to determine whether or not this script is being run under
# a shell that supports the features that we use. If not, we try to
# re-exec the script under another shell. If we can't find another
# suitable shell, then we print a message and exit.
#
errmsg='' # error message, if not empty
shelltest=false # if true, exit after testing the shell
re_exec_allowed=true # if true, we may exec under another shell
# Parse special command line options in $1. These special options are
# for internal use only, are not documented, and are not valid anywhere
# other than $1.
case "$1" in
"--shelltest")
shelltest=true
re_exec_allowed=false
shift
;;
"--no-re-exec")
re_exec_allowed=false
shift
;;
esac
# Solaris /bin/sh, and other SVR4 shells, do not support "!".
# This is the first feature that we test, because subsequent
# tests use "!".
#
if test -z "$errmsg"; then
if ( eval '! false' ) >/dev/null 2>&1 ; then
:
else
errmsg='Shell does not support "!".'
fi
fi
# Does the shell support functions?
#
if test -z "$errmsg"; then
if ! (
eval 'somefunction() { : ; }'
) >/dev/null 2>&1
then
errmsg='Shell does not support functions.'
fi
fi
# Does the shell support the "local" keyword for variables in functions?
#
# Local variables are not required by SUSv3, but some scripts run during
# the NetBSD build use them.
#
# ksh93 fails this test; it uses an incompatible syntax involving the
# keywords 'function' and 'typeset'.
#
if test -z "$errmsg"; then
if ! (
eval 'f() { local v=2; }; v=1; f && test x"$v" = x"1"'
) >/dev/null 2>&1
then
errmsg='Shell does not support the "local" keyword in functions.'
fi
fi
# Does the shell support ${var%suffix}, ${var#prefix}, and their variants?
#
# We don't bother testing for ${var+value}, ${var-value}, or their variants,
# since shells without those are sure to fail other tests too.
#
if test -z "$errmsg"; then
if ! (
eval 'var=a/b/c ;
test x"${var#*/};${var##*/};${var%/*};${var%%/*}" = \
x"b/c;c;a/b;a" ;'
) >/dev/null 2>&1
then
errmsg='Shell does not support "${var%suffix}" or "${var#prefix}".'
fi
fi
# Does the shell support IFS?
#
# zsh in normal mode (as opposed to "emulate sh" mode) fails this test.
#
if test -z "$errmsg"; then
if ! (
eval 'IFS=: ; v=":a b::c" ; set -- $v ; IFS=+ ;
test x"$#;$1,$2,$3,$4;$*" = x"4;,a b,,c;+a b++c"'
) >/dev/null 2>&1
then
errmsg='Shell does not support IFS word splitting.'
fi
fi
# Does the shell support ${1+"$@"}?
#
# Some versions of zsh fail this test, even in "emulate sh" mode.
#
if test -z "$errmsg"; then
if ! (
eval 'set -- "a a a" "b b b"; set -- ${1+"$@"};
test x"$#;$1;$2" = x"2;a a a;b b b";'
) >/dev/null 2>&1
then
errmsg='Shell does not support ${1+"$@"}.'
fi
fi
# Does the shell support $(...) command substitution?
#
if test -z "$errmsg"; then
if ! (
eval 'var=$(echo abc); test x"$var" = x"abc"'
) >/dev/null 2>&1
then
errmsg='Shell does not support "$(...)" command substitution.'
fi
fi
# Does the shell support $(...) command substitution with
# unbalanced parentheses?
#
# Some shells known to fail this test are: NetBSD /bin/ksh (as of 2009-12),
# bash-3.1, pdksh-5.2.14, zsh-4.2.7 in "emulate sh" mode.
#
if test -z "$errmsg"; then
if ! (
eval 'var=$(case x in x) echo abc;; esac); test x"$var" = x"abc"'
) >/dev/null 2>&1
then
# XXX: This test is ignored because so many shells fail it; instead,
# the NetBSD build avoids using the problematic construct.
: ignore 'Shell does not support "$(...)" with unbalanced ")".'
fi
fi
# Does the shell support getopts or getopt?
#
if test -z "$errmsg"; then
if ! (
eval 'type getopts || type getopt'
) >/dev/null 2>&1
then
errmsg='Shell does not support getopts or getopt.'
fi
fi
#
# If shelltest is true, exit now, reporting whether or not the shell is good.
#
if $shelltest; then
if test -n "$errmsg"; then
echo >&2 "$0: $errmsg"
exit 1
else
exit 0
fi
fi
#
# If the shell was bad, try to exec a better shell, or report an error.
#
# Loops are broken by passing an extra "--no-re-exec" flag to the new
# instance of this script.
#
if test -n "$errmsg"; then
if $re_exec_allowed; then
for othershell in \
"${HOST_SH}" /usr/xpg4/bin/sh ksh ksh88 mksh pdksh bash dash
# NOTE: some shells known not to work are:
# any shell using csh syntax;
# Solaris /bin/sh (missing many modern features);
# ksh93 (incompatible syntax for local variables);
# zsh (many differences, unless run in compatibility mode).
do
test -n "$othershell" || continue
if eval 'type "$othershell"' >/dev/null 2>&1 \
&& "$othershell" "$0" --shelltest >/dev/null 2>&1
then
cat <<EOF
$0: $errmsg
$0: Retrying under $othershell
EOF
HOST_SH="$othershell"
export HOST_SH
exec $othershell "$0" --no-re-exec "$@" # avoid ${1+"$@"}
fi
# If HOST_SH was set, but failed the test above,
# then give up without trying any other shells.
test x"${othershell}" = x"${HOST_SH}" && break
done
fi
#
# If we get here, then the shell is bad, and we either could not
# find a replacement, or were not allowed to try a replacement.
#
cat <<EOF
$0: $errmsg
The NetBSD build system requires a shell that supports modern POSIX
features, as well as the "local" keyword in functions (which is a
widely-implemented but non-standardised feature).
Please re-run this script under a suitable shell. For example:
/path/to/suitable/shell $0 ...
The above command will usually enable build.sh to automatically set
HOST_SH=/path/to/suitable/shell, but if that fails, then you may also
need to explicitly set the HOST_SH environment variable, as follows:
HOST_SH=/path/to/suitable/shell
export HOST_SH
\${HOST_SH} $0 ...
EOF
exit 1
fi
#
# }}} End shell feature tests.
#
progname=${0##*/}
toppid=$$
results=/dev/null
tab=' '
nl='
'
trap "exit 1" 1 2 3 15
bomb()
{
cat >&2 <<ERRORMESSAGE
ERROR: $@
*** BUILD ABORTED ***
ERRORMESSAGE
kill ${toppid} # in case we were invoked from a subshell
exit 1
}
statusmsg()
{
${runcmd} echo "===> $@" | tee -a "${results}"
}
statusmsg2()
{
local msg
msg="${1}"
shift
case "${msg}" in
????????????????*) ;;
??????????*) msg="${msg} ";;
?????*) msg="${msg} ";;
*) msg="${msg} ";;
esac
case "${msg}" in
?????????????????????*) ;;
????????????????????) msg="${msg} ";;
???????????????????) msg="${msg} ";;
??????????????????) msg="${msg} ";;
?????????????????) msg="${msg} ";;
????????????????) msg="${msg} ";;
esac
statusmsg "${msg}$*"
}
warning()
{
statusmsg "Warning: $@"
}
# Find a program in the PATH, and print the result. If not found,
# print a default. If $2 is defined (even if it is an empty string),
# then that is the default; otherwise, $1 is used as the default.
find_in_PATH()
{
local prog="$1"
local result="${2-"$1"}"
local oldIFS="${IFS}"
local dir
IFS=":"
for dir in ${PATH}; do
if [ -x "${dir}/${prog}" ]; then
result="${dir}/${prog}"
break
fi
done
IFS="${oldIFS}"
echo "${result}"
}
# Try to find a working POSIX shell, and set HOST_SH to refer to it.
# Assumes that uname_s, uname_m, and PWD have been set.
set_HOST_SH()
{
# Even if ${HOST_SH} is already defined, we still do the
# sanity checks at the end.
# Solaris has /usr/xpg4/bin/sh.
#
[ -z "${HOST_SH}" ] && [ x"${uname_s}" = x"SunOS" ] && \
[ -x /usr/xpg4/bin/sh ] && HOST_SH="/usr/xpg4/bin/sh"
# Try to get the name of the shell that's running this script,
# by parsing the output from "ps". We assume that, if the host
# system's ps command supports -o comm at all, it will do so
# in the usual way: a one-line header followed by a one-line
# result, possibly including trailing white space. And if the
# host system's ps command doesn't support -o comm, we assume
# that we'll get an error message on stderr and nothing on
# stdout. (We don't try to use ps -o 'comm=' to suppress the
# header line, because that is less widely supported.)
#
# If we get the wrong result here, the user can override it by
# specifying HOST_SH in the environment.
#
[ -z "${HOST_SH}" ] && HOST_SH="$(
(ps -p $$ -o comm | sed -ne "2s/[ ${tab}]*\$//p") 2>/dev/null )"
# If nothing above worked, use "sh". We will later find the
# first directory in the PATH that has a "sh" program.
#
[ -z "${HOST_SH}" ] && HOST_SH="sh"
# If the result so far is not an absolute path, try to prepend
# PWD or search the PATH.
#
case "${HOST_SH}" in
/*) :
;;
*/*) HOST_SH="${PWD}/${HOST_SH}"
;;
*) HOST_SH="$(find_in_PATH "${HOST_SH}")"
;;
esac
# If we don't have an absolute path by now, bomb.
#
case "${HOST_SH}" in
/*) :
;;
*) bomb "HOST_SH=\"${HOST_SH}\" is not an absolute path."
;;
esac
# If HOST_SH is not executable, bomb.
#
[ -x "${HOST_SH}" ] ||
bomb "HOST_SH=\"${HOST_SH}\" is not executable."
# If HOST_SH fails tests, bomb.
# ("$0" may be a path that is no longer valid, because we have
# performed "cd $(dirname $0)", so don't use $0 here.)
#
"${HOST_SH}" build.sh --shelltest ||
bomb "HOST_SH=\"${HOST_SH}\" failed functionality tests."
}
# initdefaults --
# Set defaults before parsing command line options.
#
initdefaults()
{
makeenv=
makewrapper=
makewrappermachine=
runcmd=
operations=
removedirs=
[ -d usr.bin/make ] || 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"
# Set various environment variables to known defaults,
# to minimize (cross-)build problems observed "in the field".
#
# LC_ALL=C must be set before we try to parse the output from
# any command. Other variables are set (or unset) here, before
# we parse command line arguments.
#
# These variables can be overridden via "-V var=value" if
# you know what you are doing.
#
unsetmakeenv INFODIR
unsetmakeenv LESSCHARSET
unsetmakeenv MAKEFLAGS
unsetmakeenv TERMINFO
setmakeenv LC_ALL C
# Find information about the build platform. This should be
# kept in sync with _HOST_OSNAME, _HOST_OSREL, and _HOST_ARCH
# variables in share/mk/bsd.sys.mk.
#
# Note that "uname -p" is not part of POSIX, but we want uname_p
# to be set to the host MACHINE_ARCH, if possible. On systems
# where "uname -p" fails, prints "unknown", or prints a string
# that does not look like an identifier, fall back to using the
# output from "uname -m" instead.
#
uname_s=$(uname -s 2>/dev/null)
uname_r=$(uname -r 2>/dev/null)
uname_m=$(uname -m 2>/dev/null)
uname_p=$(uname -p 2>/dev/null || echo "unknown")
case "${uname_p}" in
''|unknown|*[^-_A-Za-z0-9]*) uname_p="${uname_m}" ;;
esac
id_u=$(id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null)
# If $PWD is a valid name of the current directory, POSIX mandates
# that pwd return it by default which causes problems in the
# presence of symlinks. Unsetting PWD is simpler than changing
# every occurrence of pwd to use -P.
#
# XXX Except that doesn't work on Solaris. Or many Linuces.
#
unset PWD
TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)
# The user can set HOST_SH in the environment, or we try to
# guess an appropriate value. Then we set several other
# variables from HOST_SH.
#
set_HOST_SH
setmakeenv HOST_SH "${HOST_SH}"
setmakeenv BSHELL "${HOST_SH}"
setmakeenv CONFIG_SHELL "${HOST_SH}"
# Set defaults.
#
toolprefix=nb
# Some systems have a small ARG_MAX. -X prevents make(1) from
# exporting variables in the environment redundantly.
#
case "${uname_s}" in
Darwin | FreeBSD | CYGWIN*)
MAKEFLAGS="-X ${MAKEFLAGS}"
;;
esac
# do_{operation}=true if given operation is requested.
#
do_expertmode=false
do_rebuildmake=false
do_removedirs=false
do_tools=false
do_cleandir=false
do_obj=false
do_build=false
do_distribution=false
do_release=false
do_kernel=false
do_releasekernel=false
do_modules=false
do_installmodules=false
do_install=false
do_sets=false
do_sourcesets=false
do_syspkgs=false
do_iso_image=false
do_iso_image_source=false
do_live_image=false
do_install_image=false
do_disk_image=false
do_show_params=false
do_rump=false
# done_{operation}=true if given operation has been done.
#
done_rebuildmake=false
# Create scratch directory
#
tmpdir="${TMPDIR-/tmp}/nbbuild$$"
mkdir "${tmpdir}" || bomb "Cannot mkdir: ${tmpdir}"
trap "cd /; rm -r -f \"${tmpdir}\"" 0
results="${tmpdir}/build.sh.results"
# Set source directories
#
setmakeenv NETBSDSRCDIR "${TOP}"
# Make sure KERNOBJDIR is an absolute path if defined
#
case "${KERNOBJDIR}" in
''|/*) ;;
*) KERNOBJDIR="${TOP}/${KERNOBJDIR}"
setmakeenv KERNOBJDIR "${KERNOBJDIR}"
;;
esac
# Find the version of NetBSD
#
DISTRIBVER="$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh)"
# Set the BUILDSEED to NetBSD-"N"
#
setmakeenv BUILDSEED "MINIX-$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh -m)"
# Set MKARZERO to "yes"
#
setmakeenv MKARZERO "yes"
}
# valid_MACHINE_ARCH -- A multi-line string, listing all valid
# MACHINE/MACHINE_ARCH pairs.
#
# Each line contains a MACHINE and MACHINE_ARCH value, an optional ALIAS
# which may be used to refer to the MACHINE/MACHINE_ARCH pair, and an
# optional DEFAULT or NO_DEFAULT keyword.
#
# When a MACHINE corresponds to multiple possible values of
# MACHINE_ARCH, then this table should list all allowed combinations.
# If the MACHINE is associated with a default MACHINE_ARCH (to be
# used when the user specifies the MACHINE but fails to specify the
# MACHINE_ARCH), then one of the lines should have the "DEFAULT"
# keyword. If there is no default MACHINE_ARCH for a particular
# MACHINE, then there should be a line with the "NO_DEFAULT" keyword,
# and with a blank MACHINE_ARCH.
#
valid_MACHINE_ARCH='
MACHINE=acorn26 MACHINE_ARCH=arm
MACHINE=acorn32 MACHINE_ARCH=arm
MACHINE=algor MACHINE_ARCH=mips64el ALIAS=algor64
MACHINE=algor MACHINE_ARCH=mipsel DEFAULT
MACHINE=alpha MACHINE_ARCH=alpha
MACHINE=amd64 MACHINE_ARCH=x86_64
MACHINE=amiga MACHINE_ARCH=m68k
MACHINE=amigappc MACHINE_ARCH=powerpc
MACHINE=arc MACHINE_ARCH=mips64el ALIAS=arc64
MACHINE=arc MACHINE_ARCH=mipsel DEFAULT
MACHINE=atari MACHINE_ARCH=m68k
MACHINE=bebox MACHINE_ARCH=powerpc
MACHINE=cats MACHINE_ARCH=arm DEFAULT
MACHINE=cats MACHINE_ARCH=earmv4 ALIAS=ecats
MACHINE=cesfic MACHINE_ARCH=m68k
MACHINE=cobalt MACHINE_ARCH=mips64el ALIAS=cobalt64
MACHINE=cobalt MACHINE_ARCH=mipsel DEFAULT
MACHINE=dreamcast MACHINE_ARCH=sh3el
MACHINE=emips MACHINE_ARCH=mipseb
MACHINE=epoc32 MACHINE_ARCH=arm
MACHINE=evbarm MACHINE_ARCH=arm ALIAS=evbarm-el DEFAULT
MACHINE=evbarm MACHINE_ARCH=armeb ALIAS=evbarm-eb
MACHINE=evbarm MACHINE_ARCH=earm ALIAS=evbearm-el
MACHINE=evbarm MACHINE_ARCH=earmeb ALIAS=evbearm-eb
MACHINE=evbarm MACHINE_ARCH=earmhf ALIAS=evbearmhf-el
MACHINE=evbarm MACHINE_ARCH=earmhfeb ALIAS=evbearmhf-eb
MACHINE=evbarm MACHINE_ARCH=earmv4 ALIAS=evbearmv4-el
MACHINE=evbarm MACHINE_ARCH=earmv4eb ALIAS=evbearmv4-eb
MACHINE=evbarm MACHINE_ARCH=earmv5 ALIAS=evbearmv5-el
MACHINE=evbarm MACHINE_ARCH=earmv5eb ALIAS=evbearmv5-eb
MACHINE=evbarm MACHINE_ARCH=earmv6 ALIAS=evbearmv6-el
MACHINE=evbarm MACHINE_ARCH=earmv6hf ALIAS=evbearmv6hf-el
MACHINE=evbarm MACHINE_ARCH=earmv6eb ALIAS=evbearmv6-eb
MACHINE=evbarm MACHINE_ARCH=earmv6hfeb ALIAS=evbearmv6hf-eb
MACHINE=evbarm MACHINE_ARCH=earmv7 ALIAS=evbearmv7-el
MACHINE=evbarm MACHINE_ARCH=earmv7eb ALIAS=evbearmv7-eb
MACHINE=evbarm MACHINE_ARCH=earmv7hf ALIAS=evbearmv7hf-el
MACHINE=evbarm MACHINE_ARCH=earmv7hfeb ALIAS=evbearmv7hf-eb
MACHINE=evbcf MACHINE_ARCH=coldfire
MACHINE=evbmips MACHINE_ARCH= NO_DEFAULT
MACHINE=evbmips MACHINE_ARCH=mips64eb ALIAS=evbmips64-eb
MACHINE=evbmips MACHINE_ARCH=mips64el ALIAS=evbmips64-el
MACHINE=evbmips MACHINE_ARCH=mipseb ALIAS=evbmips-eb
MACHINE=evbmips MACHINE_ARCH=mipsel ALIAS=evbmips-el
MACHINE=evbppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=evbppc MACHINE_ARCH=powerpc64 ALIAS=evbppc64
MACHINE=evbsh3 MACHINE_ARCH= NO_DEFAULT
MACHINE=evbsh3 MACHINE_ARCH=sh3eb ALIAS=evbsh3-eb
MACHINE=evbsh3 MACHINE_ARCH=sh3el ALIAS=evbsh3-el
MACHINE=ews4800mips MACHINE_ARCH=mipseb
MACHINE=hp300 MACHINE_ARCH=m68k
MACHINE=hp700 MACHINE_ARCH=hppa
MACHINE=hpcarm MACHINE_ARCH=arm DEFAULT
MACHINE=hpcarm MACHINE_ARCH=earm ALIAS=hpcearm
MACHINE=hpcmips MACHINE_ARCH=mipsel
MACHINE=hpcsh MACHINE_ARCH=sh3el
MACHINE=i386 MACHINE_ARCH=i386
MACHINE=ia64 MACHINE_ARCH=ia64
MACHINE=ibmnws MACHINE_ARCH=powerpc
MACHINE=iyonix MACHINE_ARCH=arm DEFAULT
MACHINE=iyonix MACHINE_ARCH=earm ALIAS=eiyonix
MACHINE=landisk MACHINE_ARCH=sh3el
MACHINE=luna68k MACHINE_ARCH=m68k
MACHINE=mac68k MACHINE_ARCH=m68k
MACHINE=macppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=macppc MACHINE_ARCH=powerpc64 ALIAS=macppc64
MACHINE=mipsco MACHINE_ARCH=mipseb
MACHINE=mmeye MACHINE_ARCH=sh3eb
MACHINE=mvme68k MACHINE_ARCH=m68k
MACHINE=mvmeppc MACHINE_ARCH=powerpc
MACHINE=netwinder MACHINE_ARCH=arm DEFAULT
MACHINE=netwinder MACHINE_ARCH=earmv4 ALIAS=enetwinder
MACHINE=news68k MACHINE_ARCH=m68k
MACHINE=newsmips MACHINE_ARCH=mipseb
MACHINE=next68k MACHINE_ARCH=m68k
MACHINE=ofppc MACHINE_ARCH=powerpc DEFAULT
MACHINE=ofppc MACHINE_ARCH=powerpc64 ALIAS=ofppc64
MACHINE=pmax MACHINE_ARCH=mips64el ALIAS=pmax64
MACHINE=pmax MACHINE_ARCH=mipsel DEFAULT
MACHINE=prep MACHINE_ARCH=powerpc
MACHINE=rs6000 MACHINE_ARCH=powerpc
MACHINE=sandpoint MACHINE_ARCH=powerpc
MACHINE=sbmips MACHINE_ARCH= NO_DEFAULT
MACHINE=sbmips MACHINE_ARCH=mips64eb ALIAS=sbmips64-eb
MACHINE=sbmips MACHINE_ARCH=mips64el ALIAS=sbmips64-el
MACHINE=sbmips MACHINE_ARCH=mipseb ALIAS=sbmips-eb
MACHINE=sbmips MACHINE_ARCH=mipsel ALIAS=sbmips-el
MACHINE=sgimips MACHINE_ARCH=mips64eb ALIAS=sgimips64
MACHINE=sgimips MACHINE_ARCH=mipseb DEFAULT
MACHINE=shark MACHINE_ARCH=arm DEFAULT
MACHINE=shark MACHINE_ARCH=earmv4 ALIAS=eshark
MACHINE=sparc MACHINE_ARCH=sparc
MACHINE=sparc64 MACHINE_ARCH=sparc64
MACHINE=sun2 MACHINE_ARCH=m68000
MACHINE=sun3 MACHINE_ARCH=m68k
MACHINE=vax MACHINE_ARCH=vax
MACHINE=x68k MACHINE_ARCH=m68k
MACHINE=zaurus MACHINE_ARCH=arm DEFAULT
MACHINE=zaurus MACHINE_ARCH=earm ALIAS=ezaurus
'
# getarch -- find the default MACHINE_ARCH for a MACHINE,
# or convert an alias to a MACHINE/MACHINE_ARCH pair.
#
# Saves MACHINE in makewrappermachine before possibly modifying MACHINE.
#
# Sets MACHINE and MACHINE_ARCH if the input MACHINE value is
# recognised as an alias, or recognised as a machine that has a default
# MACHINE_ARCH (or that has only one possible MACHINE_ARCH).
#
# Leaves MACHINE and MACHINE_ARCH unchanged if MACHINE is recognised
# as being associated with multiple MACHINE_ARCH values with no default.
#
# Bombs if MACHINE is not recognised.
#
getarch()
{
local IFS
local found=""
local line
IFS="${nl}"
makewrappermachine="${MACHINE}"
for line in ${valid_MACHINE_ARCH}; do
line="${line%%#*}" # ignore comments
line="$( IFS=" ${tab}" ; echo $line )" # normalise white space
case "${line} " in
"")
# skip blank lines or comment lines
continue
;;
*" ALIAS=${MACHINE} "*)
# Found a line with a matching ALIAS=<alias>.
found="$line"
break
;;
"MACHINE=${MACHINE} "*" NO_DEFAULT"*)
# Found an explicit "NO_DEFAULT" for this MACHINE.
found="$line"
break
;;
"MACHINE=${MACHINE} "*" DEFAULT"*)
# Found an explicit "DEFAULT" for this MACHINE.
found="$line"
break
;;
"MACHINE=${MACHINE} "*)
# Found a line for this MACHINE. If it's the
# first such line, then tentatively accept it.
# If it's not the first matching line, then
# remember that there was more than one match.
case "$found" in
'') found="$line" ;;
*) found="MULTIPLE_MATCHES" ; break ;;
esac
;;
esac
done
case "$found" in
*NO_DEFAULT*|*MULTIPLE_MATCHES*)
# MACHINE is OK, but MACHINE_ARCH is still unknown
return
;;
"MACHINE="*" MACHINE_ARCH="*)
# Obey the MACHINE= and MACHINE_ARCH= parts of the line.
IFS=" "
for frag in ${found}; do
case "$frag" in
MACHINE=*|MACHINE_ARCH=*)
eval "$frag"
;;
esac
done
;;
*)
bomb "Unknown target MACHINE: ${MACHINE}"
;;
esac
}
# validatearch -- check that the MACHINE/MACHINE_ARCH pair is supported.
#
# Bombs if the pair is not supported.
#
validatearch()
{
local IFS
local line
local foundpair=false foundmachine=false foundarch=false
case "${MACHINE_ARCH}" in
"")
bomb "No MACHINE_ARCH provided"
;;
esac
IFS="${nl}"
for line in ${valid_MACHINE_ARCH}; do
line="${line%%#*}" # ignore comments
line="$( IFS=" ${tab}" ; echo $line )" # normalise white space
case "${line} " in
"")
# skip blank lines or comment lines
continue
;;
"MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} "*)
foundpair=true
;;
"MACHINE=${MACHINE} "*)
foundmachine=true
;;
*"MACHINE_ARCH=${MACHINE_ARCH} "*)
foundarch=true
;;
esac
done
case "${foundpair}:${foundmachine}:${foundarch}" in
true:*)
: OK
;;
*:false:*)
bomb "Unknown target MACHINE: ${MACHINE}"
;;
*:*:false)
bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
;;
*)
bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
;;
esac
}
# nobomb_getmakevar --
# Given the name of a make variable in $1, print make's idea of the
# value of that variable, or return 1 if there's an error.
#
nobomb_getmakevar()
{
[ -x "${make}" ] || return 1
"${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<EOF || return 1
_x_:
echo \${$1}
# LSC FIXME: We are cross compiling, so overwrite default and build tools
USETOOLS:=yes
.include <bsd.prog.mk>
.include <bsd.kernobj.mk>
EOF
}
# bomb_getmakevar --
# Given the name of a make variable in $1, print make's idea of the
# value of that variable, or bomb if there's an error.
#
bomb_getmakevar()
{
[ -x "${make}" ] || bomb "bomb_getmakevar $1: ${make} is not executable"
nobomb_getmakevar "$1" || bomb "bomb_getmakevar $1: ${make} failed"
}
# getmakevar --
# Given the name of a make variable in $1, print make's idea of the
# value of that variable, or print a literal '$' followed by the
# variable name if ${make} is not executable. This is intended for use in
# messages that need to be readable even if $make hasn't been built,
# such as when build.sh is run with the "-n" option.
#
getmakevar()
{
if [ -x "${make}" ]; then
bomb_getmakevar "$1"
else
echo "\$$1"
fi
}
setmakeenv()
{
eval "$1='$2'; export $1"
makeenv="${makeenv} $1"
}
unsetmakeenv()
{
eval "unset $1"
makeenv="${makeenv} $1"
}
# Given a variable name in $1, modify the variable in place as follows:
# For each space-separated word in the variable, call resolvepath.
resolvepaths()
{
local var="$1"
local val
eval val=\"\${${var}}\"
local newval=''
local word
for word in ${val}; do
resolvepath word
newval="${newval}${newval:+ }${word}"
done
eval ${var}=\"\${newval}\"
}
# Given a variable name in $1, modify the variable in place as follows:
# Convert possibly-relative path to absolute path by prepending
# ${TOP} if necessary. Also delete trailing "/", if any.
resolvepath()
{
local var="$1"
local val
eval val=\"\${${var}}\"
case "${val}" in
/)
;;
/*)
val="${val%/}"
;;
*)
val="${TOP}/${val%/}"
;;
esac
eval ${var}=\"\${val}\"
}
usage()
{
if [ -n "$*" ]; then
echo ""
echo "${progname}: $*"
fi
cat <<_usage_
Usage: ${progname} [-EhnorUuxy] [-a arch] [-B buildid] [-C cdextras]
[-D dest] [-j njob] [-M obj] [-m mach] [-N noisy]
[-O obj] [-R release] [-S seed] [-T tools]
[-V var=[value]] [-w wrapper] [-X x11src] [-Y extsrcsrc]
[-Z var]
operation [...]
Build operations (all imply "obj" and "tools"):
build Run "make build".
distribution Run "make distribution" (includes DESTDIR/etc/ files).
release Run "make release" (includes kernels & distrib media).
Other operations:
help Show this message and exit.
makewrapper Create ${toolprefix}make-\${MACHINE} wrapper and ${toolprefix}make.
Always performed.
cleandir Run "make cleandir". [Default unless -u is used]
obj Run "make obj". [Default unless -o is used]
tools Build and install tools.
install=idir Run "make installworld" to \`idir' to install all sets
except \`etc'. Useful after "distribution" or "release"
kernel=conf Build kernel with config file \`conf'
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
installmodules=idir Run "make installmodules" to \`idir' to install all
kernel modules.
modules Build kernel modules.
rumptest Do a linktest for rump (for developers).
sets Create binary sets in
RELEASEDIR/RELEASEMACHINEDIR/binary/sets.
DESTDIR should be populated beforehand.
sourcesets Create source sets in RELEASEDIR/source/sets.
syspkgs Create syspkgs in
RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.
iso-image Create CD-ROM image in RELEASEDIR/iso.
iso-image-source Create CD-ROM image with source in RELEASEDIR/iso.
live-image Create bootable live image in
RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage.
install-image Create bootable installation image in
RELEASEDIR/RELEASEMACHINEDIR/installation/installimage.
disk-image=target Creae bootable disk image in
RELEASEDIR/RELEASEMACHINEDIR/binary/gzimg/target.img.gz.
show-params Display various make(1) parameters.
Options:
-a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE]
-B buildid Set BUILDID to buildid.
-C cdextras Append cdextras to CDEXTRA variable for inclusion on CD-ROM.
-D dest Set DESTDIR to dest. [Default: destdir.MACHINE]
-E Set "expert" mode; disables various safety checks.
Should not be used without expert knowledge of the build system.
-h Print this help message.
-j njob Run up to njob jobs in parallel; see make(1) -j.
-M obj Set obj root directory to obj; sets MAKEOBJDIRPREFIX.
Unsets MAKEOBJDIR.
-m mach Set MACHINE to mach; not required if NetBSD native.
-N noisy Set the noisyness (MAKEVERBOSE) level of the build:
0 Minimal output ("quiet")
1 Describe what is occurring
2 Describe what is occurring and echo the actual command
3 Ignore the effect of the "@" prefix in make commands
4 Trace shell commands using the shell's -x flag
[Default: 2]
-n Show commands that would be executed, but do not execute them.
-O obj Set obj root directory to obj; sets a MAKEOBJDIR pattern.
Unsets MAKEOBJDIRPREFIX.
-o Set MKOBJDIRS=no; do not create objdirs at start of build.
-R release Set RELEASEDIR to release. [Default: releasedir]
-r Remove contents of TOOLDIR and DESTDIR before building.
-S seed Set BUILDSEED to seed. [Default: NetBSD-majorversion]
-T tools Set TOOLDIR to tools. If unset, and TOOLDIR is not set in
the environment, ${toolprefix}make will be (re)built
unconditionally.
-U Set MKUNPRIVED=yes; build without requiring root privileges,
install from an UNPRIVED build with proper file permissions.
-u Set MKUPDATE=yes; do not run "make cleandir" first.
Without this, everything is rebuilt, including the tools.
-V var=[value] Set variable \`var' to \`value'.
-w wrapper Create ${toolprefix}make script as wrapper.
[Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}]
-X x11src Set X11SRCDIR to x11src. [Default: /usr/xsrc]
-x Set MKX11=yes; build X11 from X11SRCDIR
-Y extsrcsrc Set EXTSRCSRCDIR to extsrcsrc. [Default: /usr/extsrc]
-y Set MKEXTSRC=yes; build extsrc from EXTSRCSRCDIR
-Z var Unset ("zap") variable \`var'.
_usage_
exit 1
}
parseoptions()
{
opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:X:xY:yZ:'
opt_a=no
if type getopts >/dev/null 2>&1; then
# Use POSIX getopts.
#
0