2002-09-14 03:27:13 +04:00
|
|
|
#! /usr/bin/env sh
|
2016-06-03 03:00:01 +03:00
|
|
|
# $NetBSD: build.sh,v 1.310 2016/06/03 00:00:01 kre Exp $
|
2003-01-23 19:24:08 +03:00
|
|
|
#
|
2011-09-09 17:29:23 +04:00
|
|
|
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
|
2003-01-23 19:24:08 +03:00
|
|
|
# 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.
|
|
|
|
#
|
2001-10-19 06:21:03 +04:00
|
|
|
#
|
2011-09-09 22:48:34 +04:00
|
|
|
# Top level build wrapper, to build or cross-build NetBSD.
|
2001-10-19 06:21:03 +04:00
|
|
|
#
|
2011-09-09 22:48:34 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# {{{ 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
|
|
|
|
|
|
|
|
#
|
2011-10-17 20:22:12 +04:00
|
|
|
# If shelltest is true, exit now, reporting whether or not the shell is good.
|
2011-09-09 22:48:34 +04:00
|
|
|
#
|
|
|
|
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 \
|
2014-09-30 18:57:51 +04:00
|
|
|
"${HOST_SH}" /usr/xpg4/bin/sh ksh ksh88 mksh pdksh dash bash
|
2011-09-09 22:48:34 +04:00
|
|
|
# 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.
|
2002-09-14 03:27:13 +04:00
|
|
|
#
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
progname=${0##*/}
|
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
|
|
|
toppid=$$
|
2003-05-08 18:19:39 +04:00
|
|
|
results=/dev/null
|
2009-01-03 11:23:00 +03:00
|
|
|
tab=' '
|
2012-10-31 17:05:09 +04:00
|
|
|
nl='
|
|
|
|
'
|
2003-01-23 19:24:08 +03:00
|
|
|
trap "exit 1" 1 2 3 15
|
|
|
|
|
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
|
2003-05-08 18:19:39 +04:00
|
|
|
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
|
|
|
|
2014-07-06 22:04:44 +04:00
|
|
|
# Quote args to make them safe in the shell.
|
|
|
|
# Usage: quotedlist="$(shell_quote args...)"
|
|
|
|
#
|
|
|
|
# After building up a quoted list, use it by evaling it inside
|
|
|
|
# double quotes, like this:
|
|
|
|
# eval "set -- $quotedlist"
|
|
|
|
# or like this:
|
|
|
|
# eval "\$command $quotedlist \$filename"
|
2014-08-05 01:56:30 +04:00
|
|
|
#
|
2014-07-06 22:04:44 +04:00
|
|
|
shell_quote()
|
2014-08-05 01:56:30 +04:00
|
|
|
{(
|
2014-07-06 22:04:44 +04:00
|
|
|
local result=''
|
2014-08-05 01:56:30 +04:00
|
|
|
local arg qarg
|
|
|
|
LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
|
2014-07-06 22:04:44 +04:00
|
|
|
for arg in "$@" ; do
|
2014-08-05 01:56:30 +04:00
|
|
|
case "${arg}" in
|
|
|
|
'')
|
|
|
|
qarg="''"
|
|
|
|
;;
|
|
|
|
*[!-./a-zA-Z0-9]*)
|
|
|
|
# Convert each embedded ' to '\'',
|
|
|
|
# then insert ' at the beginning of the first line,
|
|
|
|
# and append ' at the end of the last line.
|
|
|
|
# Finally, elide unnecessary '' pairs at the
|
|
|
|
# beginning and end of the result and as part of
|
|
|
|
# '\'''\'' sequences that result from multiple
|
|
|
|
# adjacent quotes in he input.
|
|
|
|
qarg="$(printf "%s\n" "$arg" | \
|
|
|
|
${SED:-sed} -e "s/'/'\\\\''/g" \
|
|
|
|
-e "1s/^/'/" -e "\$s/\$/'/" \
|
|
|
|
-e "1s/^''//" -e "\$s/''\$//" \
|
|
|
|
-e "s/'''/'/g"
|
|
|
|
)"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Arg is not the empty string, and does not contain
|
|
|
|
# any unsafe characters. Leave it unchanged for
|
|
|
|
# readability.
|
|
|
|
qarg="${arg}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
result="${result}${result:+ }${qarg}"
|
2014-07-06 22:04:44 +04:00
|
|
|
done
|
|
|
|
printf "%s\n" "$result"
|
2014-08-05 01:56:30 +04:00
|
|
|
)}
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg()
|
|
|
|
{
|
|
|
|
${runcmd} echo "===> $@" | tee -a "${results}"
|
|
|
|
}
|
|
|
|
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2()
|
|
|
|
{
|
2010-08-25 00:52:31 +04:00
|
|
|
local msg
|
|
|
|
|
2010-08-24 17:35:32 +04:00
|
|
|
msg="${1}"
|
|
|
|
shift
|
2010-08-24 19:28:22 +04:00
|
|
|
case "${msg}" in
|
2010-08-24 17:35:32 +04:00
|
|
|
????????????????*) ;;
|
|
|
|
??????????*) msg="${msg} ";;
|
|
|
|
?????*) msg="${msg} ";;
|
|
|
|
*) msg="${msg} ";;
|
|
|
|
esac
|
2010-08-24 19:28:22 +04:00
|
|
|
case "${msg}" in
|
2010-08-24 17:35:32 +04:00
|
|
|
?????????????????????*) ;;
|
|
|
|
????????????????????) msg="${msg} ";;
|
|
|
|
???????????????????) msg="${msg} ";;
|
|
|
|
??????????????????) msg="${msg} ";;
|
|
|
|
?????????????????) msg="${msg} ";;
|
|
|
|
????????????????) msg="${msg} ";;
|
|
|
|
esac
|
2010-08-25 00:52:31 +04:00
|
|
|
statusmsg "${msg}$*"
|
2010-08-24 17:35:32 +04:00
|
|
|
}
|
|
|
|
|
2007-03-25 11:56:38 +04:00
|
|
|
warning()
|
|
|
|
{
|
|
|
|
statusmsg "Warning: $@"
|
|
|
|
}
|
|
|
|
|
2007-04-07 18:49:40 +04:00
|
|
|
# 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.
|
2006-09-29 23:53:54 +04:00
|
|
|
find_in_PATH()
|
|
|
|
{
|
|
|
|
local prog="$1"
|
2007-04-07 18:49:40 +04:00
|
|
|
local result="${2-"$1"}"
|
2006-09-29 23:53:54 +04:00
|
|
|
local oldIFS="${IFS}"
|
|
|
|
local dir
|
|
|
|
IFS=":"
|
|
|
|
for dir in ${PATH}; do
|
|
|
|
if [ -x "${dir}/${prog}" ]; then
|
2007-04-07 18:49:40 +04:00
|
|
|
result="${dir}/${prog}"
|
2006-09-29 23:53:54 +04:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="${oldIFS}"
|
2007-04-07 18:49:40 +04:00
|
|
|
echo "${result}"
|
2006-09-29 23:53:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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="$(
|
2009-01-03 11:23:00 +03:00
|
|
|
(ps -p $$ -o comm | sed -ne "2s/[ ${tab}]*\$//p") 2>/dev/null )"
|
2006-09-29 23:53:54 +04:00
|
|
|
|
|
|
|
# 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."
|
2011-09-09 22:48:34 +04:00
|
|
|
|
|
|
|
# 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."
|
2006-09-29 23:53:54 +04:00
|
|
|
}
|
|
|
|
|
2011-09-09 17:29:23 +04:00
|
|
|
# initdefaults --
|
|
|
|
# Set defaults before parsing command line options.
|
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
initdefaults()
|
|
|
|
{
|
2007-06-26 16:59:38 +04:00
|
|
|
makeenv=
|
|
|
|
makewrapper=
|
|
|
|
makewrappermachine=
|
|
|
|
runcmd=
|
|
|
|
operations=
|
|
|
|
removedirs=
|
|
|
|
|
2007-01-14 20:02:56 +03:00
|
|
|
[ -d usr.bin/make ] || cd "$(dirname $0)"
|
2003-01-23 19:24:08 +03:00
|
|
|
[ -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"
|
|
|
|
|
2011-09-09 17:29:23 +04:00
|
|
|
# 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
|
2013-01-14 17:02:59 +04:00
|
|
|
unsetmakeenv TERMINFO
|
2009-11-17 23:49:34 +03:00
|
|
|
setmakeenv LC_ALL C
|
|
|
|
|
2009-03-06 19:29:40 +03:00
|
|
|
# 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.
|
2007-04-02 14:57:36 +04:00
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
uname_s=$(uname -s 2>/dev/null)
|
2007-04-02 14:57:36 +04:00
|
|
|
uname_r=$(uname -r 2>/dev/null)
|
2003-01-23 19:24:08 +03:00
|
|
|
uname_m=$(uname -m 2>/dev/null)
|
2009-03-06 19:29:40 +03:00
|
|
|
uname_p=$(uname -p 2>/dev/null || echo "unknown")
|
|
|
|
case "${uname_p}" in
|
2009-03-09 09:25:51 +03:00
|
|
|
''|unknown|*[^-_A-Za-z0-9]*) uname_p="${uname_m}" ;;
|
2009-03-06 19:29:40 +03:00
|
|
|
esac
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2009-02-25 01:25:24 +03:00
|
|
|
id_u=$(id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null)
|
|
|
|
|
2003-01-23 19:24:08 +03: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.
|
|
|
|
#
|
2006-06-19 22:12:30 +04:00
|
|
|
# XXX Except that doesn't work on Solaris. Or many Linuces.
|
2003-05-08 18:19:39 +04:00
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
unset PWD
|
2016-06-03 03:00:01 +03:00
|
|
|
TOP=$( (exec pwd -P 2>/dev/null) || (exec pwd 2>/dev/null) )
|
2002-12-25 03:42:50 +03:00
|
|
|
|
2006-09-29 23:53:54 +04:00
|
|
|
# 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}"
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Set defaults.
|
2003-05-08 18:19:39 +04:00
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
toolprefix=nb
|
2003-05-08 18:19:39 +04:00
|
|
|
|
2003-03-14 08:22:50 +03:00
|
|
|
# Some systems have a small ARG_MAX. -X prevents make(1) from
|
|
|
|
# exporting variables in the environment redundantly.
|
2003-05-08 18:19:39 +04:00
|
|
|
#
|
2003-03-14 08:22:50 +03:00
|
|
|
case "${uname_s}" in
|
2003-05-08 16:49:45 +04:00
|
|
|
Darwin | FreeBSD | CYGWIN*)
|
2011-09-09 17:29:23 +04:00
|
|
|
MAKEFLAGS="-X ${MAKEFLAGS}"
|
2003-03-14 08:22:50 +03:00
|
|
|
;;
|
|
|
|
esac
|
2003-05-08 18:19:39 +04:00
|
|
|
|
2007-06-26 16:59:38 +04:00
|
|
|
# do_{operation}=true if given operation is requested.
|
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
do_expertmode=false
|
|
|
|
do_rebuildmake=false
|
|
|
|
do_removedirs=false
|
|
|
|
do_tools=false
|
2008-08-18 09:26:05 +04:00
|
|
|
do_cleandir=false
|
2003-01-23 19:24:08 +03:00
|
|
|
do_obj=false
|
|
|
|
do_build=false
|
|
|
|
do_distribution=false
|
|
|
|
do_release=false
|
|
|
|
do_kernel=false
|
2003-05-25 16:34:27 +04:00
|
|
|
do_releasekernel=false
|
2014-11-06 05:02:48 +03:00
|
|
|
do_kernels=false
|
2009-09-07 08:14:17 +04:00
|
|
|
do_modules=false
|
2011-08-09 02:15:42 +04:00
|
|
|
do_installmodules=false
|
2003-01-23 19:24:08 +03:00
|
|
|
do_install=false
|
2003-01-26 09:19:12 +03:00
|
|
|
do_sets=false
|
2003-05-10 11:12:37 +04:00
|
|
|
do_sourcesets=false
|
2006-01-04 18:31:40 +03:00
|
|
|
do_syspkgs=false
|
2006-02-03 15:29:41 +03:00
|
|
|
do_iso_image=false
|
2007-08-30 09:30:02 +04:00
|
|
|
do_iso_image_source=false
|
2012-02-27 00:32:40 +04:00
|
|
|
do_live_image=false
|
|
|
|
do_install_image=false
|
2013-02-13 06:17:54 +04:00
|
|
|
do_disk_image=false
|
2003-07-16 17:21:47 +04:00
|
|
|
do_params=false
|
2009-11-18 21:05:19 +03:00
|
|
|
do_rump=false
|
2003-05-08 18:19:39 +04:00
|
|
|
|
2009-09-27 21:55:53 +04:00
|
|
|
# done_{operation}=true if given operation has been done.
|
|
|
|
#
|
|
|
|
done_rebuildmake=false
|
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
# 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"
|
2003-09-20 14:14:41 +04:00
|
|
|
|
|
|
|
# Set source directories
|
|
|
|
#
|
|
|
|
setmakeenv NETBSDSRCDIR "${TOP}"
|
2005-05-19 05:37:30 +04:00
|
|
|
|
2010-03-30 17:17:47 +04:00
|
|
|
# Make sure KERNOBJDIR is an absolute path if defined
|
|
|
|
#
|
|
|
|
case "${KERNOBJDIR}" in
|
|
|
|
''|/*) ;;
|
|
|
|
*) KERNOBJDIR="${TOP}/${KERNOBJDIR}"
|
|
|
|
setmakeenv KERNOBJDIR "${KERNOBJDIR}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2007-04-02 14:57:36 +04:00
|
|
|
# Find the version of NetBSD
|
|
|
|
#
|
|
|
|
DISTRIBVER="$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh)"
|
|
|
|
|
2008-08-05 23:43:33 +04:00
|
|
|
# Set the BUILDSEED to NetBSD-"N"
|
|
|
|
#
|
|
|
|
setmakeenv BUILDSEED "NetBSD-$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh -m)"
|
|
|
|
|
2009-03-13 19:23:31 +03:00
|
|
|
# Set MKARZERO to "yes"
|
|
|
|
#
|
|
|
|
setmakeenv MKARZERO "yes"
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
2001-12-03 11:18:00 +03:00
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
# 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
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=cats MACHINE_ARCH=arm ALIAS=ocats
|
|
|
|
MACHINE=cats MACHINE_ARCH=earmv4 ALIAS=ecats DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2013-05-01 17:11:59 +04:00
|
|
|
MACHINE=epoc32 MACHINE_ARCH=arm
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=arm ALIAS=evboarm-el
|
|
|
|
MACHINE=evbarm MACHINE_ARCH=armeb ALIAS=evboarm-eb
|
|
|
|
MACHINE=evbarm MACHINE_ARCH=earm ALIAS=evbearm-el DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmeb ALIAS=evbearm-eb
|
2013-02-03 09:37:43 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmhf ALIAS=evbearmhf-el
|
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmhfeb ALIAS=evbearmhf-eb
|
2013-08-06 09:47:58 +04:00
|
|
|
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
|
2013-08-05 04:28:52 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmv7eb ALIAS=evbearmv7-eb
|
2013-08-06 09:47:58 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmv7hf ALIAS=evbearmv7hf-el
|
2013-08-05 04:28:52 +04:00
|
|
|
MACHINE=evbarm MACHINE_ARCH=earmv7hfeb ALIAS=evbearmv7hf-eb
|
2015-06-27 09:00:28 +03:00
|
|
|
MACHINE=evbarm64 MACHINE_ARCH=aarch64 ALIAS=evbarm64-el DEFAULT
|
2014-08-10 09:56:36 +04:00
|
|
|
MACHINE=evbarm64 MACHINE_ARCH=aarch64eb ALIAS=evbarm64-eb
|
2013-07-19 02:08:59 +04:00
|
|
|
MACHINE=evbcf MACHINE_ARCH=coldfire
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-02-24 11:23:38 +04:00
|
|
|
MACHINE=hppa MACHINE_ARCH=hppa
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=hpcarm MACHINE_ARCH=arm ALIAS=hpcoarm
|
2014-08-03 21:11:44 +04:00
|
|
|
MACHINE=hpcarm MACHINE_ARCH=earmv4 ALIAS=hpcearm DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=iyonix MACHINE_ARCH=arm ALIAS=oiyonix
|
|
|
|
MACHINE=iyonix MACHINE_ARCH=earm ALIAS=eiyonix DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=netwinder MACHINE_ARCH=arm ALIAS=onetwinder
|
|
|
|
MACHINE=netwinder MACHINE_ARCH=earmv4 ALIAS=enetwinder DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-09-03 23:32:18 +04:00
|
|
|
MACHINE=or1k MACHINE_ARCH=or1k
|
2014-03-31 23:29:21 +04:00
|
|
|
MACHINE=playstation2 MACHINE_ARCH=mipsel
|
2012-10-31 17:05:09 +04:00
|
|
|
MACHINE=pmax MACHINE_ARCH=mips64el ALIAS=pmax64
|
|
|
|
MACHINE=pmax MACHINE_ARCH=mipsel DEFAULT
|
|
|
|
MACHINE=prep MACHINE_ARCH=powerpc
|
2014-09-19 21:59:57 +04:00
|
|
|
MACHINE=riscv MACHINE_ARCH=riscv64 ALIAS=riscv64 DEFAULT
|
|
|
|
MACHINE=riscv MACHINE_ARCH=riscv32 ALIAS=riscv32
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=shark MACHINE_ARCH=arm ALIAS=oshark
|
|
|
|
MACHINE=shark MACHINE_ARCH=earmv4 ALIAS=eshark DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-08-03 05:03:41 +04:00
|
|
|
MACHINE=zaurus MACHINE_ARCH=arm ALIAS=ozaurus
|
|
|
|
MACHINE=zaurus MACHINE_ARCH=earm ALIAS=ezaurus DEFAULT
|
2012-10-31 17:05:09 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
# getarch -- find the default MACHINE_ARCH for a MACHINE,
|
|
|
|
# or convert an alias to a MACHINE/MACHINE_ARCH pair.
|
|
|
|
#
|
2014-08-07 19:15:48 +04:00
|
|
|
# Saves the original value of MACHINE in makewrappermachine before
|
|
|
|
# alias processing.
|
2012-10-31 17:05:09 +04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2003-01-03 02:11:07 +03:00
|
|
|
getarch()
|
|
|
|
{
|
2012-10-31 17:05:09 +04:00
|
|
|
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
|
2014-07-06 21:35:09 +04:00
|
|
|
" ")
|
2012-10-31 17:05:09 +04:00
|
|
|
# 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" ;;
|
2014-08-06 16:29:13 +04:00
|
|
|
*) found="MULTIPLE_MATCHES" ;;
|
2012-10-31 17:05:09 +04:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2002-06-10 18:08:05 +04:00
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
case "$found" in
|
|
|
|
*NO_DEFAULT*|*MULTIPLE_MATCHES*)
|
|
|
|
# MACHINE is OK, but MACHINE_ARCH is still unknown
|
|
|
|
return
|
2003-04-26 22:42:34 +04:00
|
|
|
;;
|
2012-10-31 17:05:09 +04:00
|
|
|
"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
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
*)
|
2003-05-08 18:19:39 +04:00
|
|
|
bomb "Unknown target MACHINE: ${MACHINE}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
# validatearch -- check that the MACHINE/MACHINE_ARCH pair is supported.
|
|
|
|
#
|
|
|
|
# Bombs if the pair is not supported.
|
|
|
|
#
|
2003-01-03 02:11:07 +03:00
|
|
|
validatearch()
|
|
|
|
{
|
2012-10-31 17:05:09 +04:00
|
|
|
local IFS
|
|
|
|
local line
|
|
|
|
local foundpair=false foundmachine=false foundarch=false
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
case "${MACHINE_ARCH}" in
|
2003-05-12 06:33:17 +04:00
|
|
|
"")
|
|
|
|
bomb "No MACHINE_ARCH provided"
|
|
|
|
;;
|
2002-03-02 00:06:40 +03:00
|
|
|
esac
|
2003-05-08 18:19:39 +04:00
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
IFS="${nl}"
|
|
|
|
for line in ${valid_MACHINE_ARCH}; do
|
|
|
|
line="${line%%#*}" # ignore comments
|
|
|
|
line="$( IFS=" ${tab}" ; echo $line )" # normalise white space
|
|
|
|
case "${line} " in
|
2014-07-06 21:35:09 +04:00
|
|
|
" ")
|
2012-10-31 17:05:09 +04:00
|
|
|
# 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
|
2006-08-26 03:35:04 +04:00
|
|
|
|
2012-10-31 17:05:09 +04:00
|
|
|
case "${foundpair}:${foundmachine}:${foundarch}" in
|
|
|
|
true:*)
|
|
|
|
: OK
|
2003-05-08 18:19:39 +04:00
|
|
|
;;
|
2012-10-31 17:05:09 +04:00
|
|
|
*:false:*)
|
|
|
|
bomb "Unknown target MACHINE: ${MACHINE}"
|
2003-05-08 18:19:39 +04:00
|
|
|
;;
|
2012-10-31 17:05:09 +04:00
|
|
|
*:*:false)
|
|
|
|
bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
|
2006-06-23 00:00:18 +04:00
|
|
|
;;
|
2003-05-08 18:19:39 +04:00
|
|
|
*)
|
2012-10-31 17:05:09 +04:00
|
|
|
bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
|
2003-05-08 18:19:39 +04:00
|
|
|
;;
|
|
|
|
esac
|
2002-03-02 00:06:40 +03:00
|
|
|
}
|
|
|
|
|
2014-08-07 21:54:28 +04:00
|
|
|
# listarch -- list valid MACHINE/MACHINE_ARCH/ALIAS values,
|
|
|
|
# optionally restricted to those where the MACHINE and/or MACHINE_ARCH
|
|
|
|
# match specifed glob patterns.
|
|
|
|
#
|
|
|
|
listarch()
|
|
|
|
{
|
|
|
|
local machglob="$1" archglob="$2"
|
|
|
|
local IFS
|
|
|
|
local wildcard="*"
|
|
|
|
local line xline frag
|
|
|
|
local line_matches_machine line_matches_arch
|
|
|
|
local found=false
|
|
|
|
|
|
|
|
# Empty machglob or archglob should match anything
|
|
|
|
: "${machglob:=${wildcard}}"
|
|
|
|
: "${archglob:=${wildcard}}"
|
|
|
|
|
|
|
|
IFS="${nl}"
|
|
|
|
for line in ${valid_MACHINE_ARCH}; do
|
|
|
|
line="${line%%#*}" # ignore comments
|
|
|
|
xline="$( IFS=" ${tab}" ; echo $line )" # normalise white space
|
|
|
|
[ -z "${xline}" ] && continue # skip blank or comment lines
|
|
|
|
|
|
|
|
line_matches_machine=false
|
|
|
|
line_matches_arch=false
|
|
|
|
|
|
|
|
IFS=" "
|
|
|
|
for frag in ${xline}; do
|
|
|
|
case "${frag}" in
|
|
|
|
MACHINE=${machglob})
|
|
|
|
line_matches_machine=true ;;
|
|
|
|
ALIAS=${machglob})
|
|
|
|
line_matches_machine=true ;;
|
|
|
|
MACHINE_ARCH=${archglob})
|
|
|
|
line_matches_arch=true ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if $line_matches_machine && $line_matches_arch; then
|
|
|
|
found=true
|
|
|
|
echo "$line"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if ! $found; then
|
|
|
|
echo >&2 "No match for" \
|
|
|
|
"MACHINE=${machglob} MACHINE_ARCH=${archglob}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2009-09-27 21:48:19 +04:00
|
|
|
# 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.
|
|
|
|
#
|
2007-04-07 18:49:40 +04:00
|
|
|
nobomb_getmakevar()
|
2003-01-03 02:11:07 +03:00
|
|
|
{
|
2007-04-07 18:49:40 +04:00
|
|
|
[ -x "${make}" ] || return 1
|
|
|
|
"${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<EOF || return 1
|
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
|
|
|
|
}
|
|
|
|
|
2011-09-14 21:35:44 +04:00
|
|
|
# bomb_getmakevar --
|
2009-09-27 21:48:19 +04:00
|
|
|
# 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()
|
2007-04-07 18:49:40 +04:00
|
|
|
{
|
2009-09-27 21:48:19 +04:00
|
|
|
[ -x "${make}" ] || bomb "bomb_getmakevar $1: ${make} is not executable"
|
|
|
|
nobomb_getmakevar "$1" || bomb "bomb_getmakevar $1: ${make} failed"
|
2007-04-07 18:49:40 +04:00
|
|
|
}
|
|
|
|
|
2011-09-14 21:35:44 +04:00
|
|
|
# getmakevar --
|
2009-09-27 21:48:19 +04:00
|
|
|
# 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.
|
|
|
|
#
|
2003-05-08 18:19:39 +04: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
|
|
|
{
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -x "${make}" ]; then
|
2009-09-27 21:48:19 +04:00
|
|
|
bomb_getmakevar "$1"
|
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
|
|
|
else
|
|
|
|
echo "\$$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv()
|
|
|
|
{
|
|
|
|
eval "$1='$2'; export $1"
|
|
|
|
makeenv="${makeenv} $1"
|
|
|
|
}
|
|
|
|
|
2003-07-29 14:07:15 +04:00
|
|
|
unsetmakeenv()
|
|
|
|
{
|
|
|
|
eval "unset $1"
|
|
|
|
makeenv="${makeenv} $1"
|
|
|
|
}
|
|
|
|
|
2009-09-27 21:25:01 +04:00
|
|
|
# Given a variable name in $1, modify the variable in place as follows:
|
|
|
|
# For each space-separated word in the variable, call resolvepath.
|
2008-06-28 01:38:36 +04:00
|
|
|
resolvepaths()
|
|
|
|
{
|
2009-09-27 21:25:01 +04:00
|
|
|
local var="$1"
|
|
|
|
local val
|
|
|
|
eval val=\"\${${var}}\"
|
|
|
|
local newval=''
|
|
|
|
local word
|
|
|
|
for word in ${val}; do
|
|
|
|
resolvepath word
|
|
|
|
newval="${newval}${newval:+ }${word}"
|
2008-06-28 01:38:36 +04:00
|
|
|
done
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${var}=\"\${newval}\"
|
2008-06-28 01:38:36 +04:00
|
|
|
}
|
|
|
|
|
2009-09-27 21:25:01 +04:00
|
|
|
# Given a variable name in $1, modify the variable in place as follows:
|
2004-08-17 18:00:30 +04:00
|
|
|
# Convert possibly-relative path to absolute path by prepending
|
|
|
|
# ${TOP} if necessary. Also delete trailing "/", if any.
|
2003-01-03 02:11:07 +03:00
|
|
|
resolvepath()
|
|
|
|
{
|
2009-09-27 21:25:01 +04:00
|
|
|
local var="$1"
|
|
|
|
local val
|
|
|
|
eval val=\"\${${var}}\"
|
|
|
|
case "${val}" in
|
2004-08-17 18:00:30 +04:00
|
|
|
/)
|
|
|
|
;;
|
2003-01-23 19:24:08 +03:00
|
|
|
/*)
|
2009-09-27 21:25:01 +04:00
|
|
|
val="${val%/}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
*)
|
2009-09-27 21:25:01 +04:00
|
|
|
val="${TOP}/${val%/}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2001-10-31 01:33:00 +03:00
|
|
|
esac
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${var}=\"\${val}\"
|
2001-10-31 01:33:00 +03:00
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
usage()
|
|
|
|
{
|
2003-01-23 19:24:08 +03:00
|
|
|
if [ -n "$*" ]; then
|
|
|
|
echo ""
|
|
|
|
echo "${progname}: $*"
|
|
|
|
fi
|
2002-10-20 19:48:01 +04:00
|
|
|
cat <<_usage_
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2011-08-15 18:48:00 +04:00
|
|
|
Usage: ${progname} [-EhnorUuxy] [-a arch] [-B buildid] [-C cdextras]
|
2008-08-18 09:26:05 +04:00
|
|
|
[-D dest] [-j njob] [-M obj] [-m mach] [-N noisy]
|
|
|
|
[-O obj] [-R release] [-S seed] [-T tools]
|
2009-11-30 19:13:22 +03:00
|
|
|
[-V var=[value]] [-w wrapper] [-X x11src] [-Y extsrcsrc]
|
|
|
|
[-Z var]
|
2008-08-18 09:26:05 +04:00
|
|
|
operation [...]
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-01-26 08:34:32 +03:00
|
|
|
Build operations (all imply "obj" and "tools"):
|
2003-11-14 15:38:12 +03:00
|
|
|
build Run "make build".
|
|
|
|
distribution Run "make distribution" (includes DESTDIR/etc/ files).
|
|
|
|
release Run "make release" (includes kernels & distrib media).
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
Other operations:
|
2003-11-14 15:38:12 +03:00
|
|
|
help Show this message and exit.
|
2003-05-08 18:19:39 +04:00
|
|
|
makewrapper Create ${toolprefix}make-\${MACHINE} wrapper and ${toolprefix}make.
|
2003-11-14 15:38:12 +03:00
|
|
|
Always performed.
|
2008-08-18 09:26:05 +04:00
|
|
|
cleandir Run "make cleandir". [Default unless -u is used]
|
2003-11-14 15:38:12 +03:00
|
|
|
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
|
2008-08-18 09:26:05 +04:00
|
|
|
except \`etc'. Useful after "distribution" or "release"
|
2003-05-25 16:34:27 +04:00
|
|
|
kernel=conf Build kernel with config file \`conf'
|
2014-05-05 23:12:19 +04:00
|
|
|
kernel.gdb=conf Build kernel (including netbsd.gdb) with config
|
2014-11-16 08:39:09 +03:00
|
|
|
file \`conf'
|
2003-11-14 15:38:12 +03:00
|
|
|
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
|
2014-11-16 08:39:09 +03:00
|
|
|
kernels Build all kernels
|
2011-08-09 02:15:42 +04:00
|
|
|
installmodules=idir Run "make installmodules" to \`idir' to install all
|
|
|
|
kernel modules.
|
2009-12-26 17:13:08 +03:00
|
|
|
modules Build kernel modules.
|
2009-11-18 21:05:19 +03:00
|
|
|
rumptest Do a linktest for rump (for developers).
|
2008-03-16 10:52:59 +03:00
|
|
|
sets Create binary sets in
|
2008-08-18 09:26:05 +04:00
|
|
|
RELEASEDIR/RELEASEMACHINEDIR/binary/sets.
|
|
|
|
DESTDIR should be populated beforehand.
|
2003-11-14 15:38:12 +03:00
|
|
|
sourcesets Create source sets in RELEASEDIR/source/sets.
|
2008-03-16 10:52:59 +03:00
|
|
|
syspkgs Create syspkgs in
|
2008-08-18 09:26:05 +04:00
|
|
|
RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.
|
2014-11-05 11:19:17 +03:00
|
|
|
iso-image Create CD-ROM image in RELEASEDIR/images.
|
|
|
|
iso-image-source Create CD-ROM image with source in RELEASEDIR/images.
|
2012-01-22 07:53:29 +04:00
|
|
|
live-image Create bootable live image in
|
|
|
|
RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage.
|
|
|
|
install-image Create bootable installation image in
|
|
|
|
RELEASEDIR/RELEASEMACHINEDIR/installation/installimage.
|
2015-05-06 20:31:49 +03:00
|
|
|
disk-image=target Create bootable disk image in
|
2014-11-16 08:39:09 +03:00
|
|
|
RELEASEDIR/RELEASEMACHINEDIR/binary/gzimg/target.img.gz.
|
2003-11-14 15:38:12 +03:00
|
|
|
params Display various make(1) parameters.
|
2014-08-07 21:54:28 +04:00
|
|
|
list-arch Display a list of valid MACHINE/MACHINE_ARCH values,
|
|
|
|
and exit. The list may be narrowed by passing glob
|
|
|
|
patterns or exact values in MACHINE or MACHINE_ARCH.
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
Options:
|
2011-08-15 18:48:00 +04:00
|
|
|
-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.
|
2014-08-07 19:15:48 +04:00
|
|
|
-m mach Set MACHINE to mach. Some mach values are actually
|
|
|
|
aliases that set MACHINE/MACHINE_ARCH pairs.
|
|
|
|
[Default: deduced from the host system if the host
|
|
|
|
OS is NetBSD]
|
2011-08-15 18:48:00 +04:00
|
|
|
-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'.
|
2003-01-22 14:26:11 +03:00
|
|
|
|
2002-10-20 19:48:01 +04:00
|
|
|
_usage_
|
2001-10-19 06:21:03 +04:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
parseoptions()
|
|
|
|
{
|
2011-08-15 18:48:00 +04:00
|
|
|
opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:X:xY:yZ:'
|
2014-08-07 22:10:20 +04:00
|
|
|
opt_a=false
|
2014-08-15 22:34:19 +04:00
|
|
|
opt_m=false
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
if type getopts >/dev/null 2>&1; then
|
|
|
|
# Use POSIX getopts.
|
2003-05-08 18:19:39 +04:00
|
|
|
#
|
|
|
|
getoptcmd='getopts ${opts} opt && opt=-${opt}'
|
2003-01-23 19:24:08 +03:00
|
|
|
optargcmd=':'
|
2003-05-08 18:19:39 +04:00
|
|
|
optremcmd='shift $((${OPTIND} -1))'
|
2003-01-23 19:24:08 +03:00
|
|
|
else
|
|
|
|
type getopt >/dev/null 2>&1 ||
|
2011-09-09 22:48:34 +04:00
|
|
|
bomb "Shell does not support getopts or getopt"
|
2001-10-19 06:25:48 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Use old-style getopt(1) (doesn't handle whitespace in args).
|
2003-05-08 18:19:39 +04:00
|
|
|
#
|
|
|
|
args="$(getopt ${opts} $*)"
|
2003-01-23 19:24:08 +03:00
|
|
|
[ $? = 0 ] || usage
|
2003-05-08 18:19:39 +04:00
|
|
|
set -- ${args}
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
getoptcmd='[ $# -gt 0 ] && opt="$1" && shift'
|
|
|
|
optargcmd='OPTARG="$1"; shift'
|
|
|
|
optremcmd=':'
|
|
|
|
fi
|
2001-10-24 06:39:56 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Parse command line options.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
while eval ${getoptcmd}; do
|
|
|
|
case ${opt} in
|
2001-10-31 01:33:00 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-a)
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optargcmd}
|
|
|
|
MACHINE_ARCH=${OPTARG}
|
2014-08-07 22:10:20 +04:00
|
|
|
opt_a=true
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-B)
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optargcmd}
|
|
|
|
BUILDID=${OPTARG}
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-03-14 21:33:04 +03:00
|
|
|
|
2007-09-01 13:32:19 +04:00
|
|
|
-C)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepaths OPTARG
|
2009-09-27 21:28:38 +04:00
|
|
|
CDEXTRA="${CDEXTRA}${CDEXTRA:+ }${OPTARG}"
|
2007-09-01 13:32:19 +04:00
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-D)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv DESTDIR "${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-12-08 11:42:51 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-E)
|
|
|
|
do_expertmode=true
|
|
|
|
;;
|
2002-12-09 01:14:00 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-j)
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optargcmd}
|
|
|
|
parallel="-j ${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-M)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2009-09-27 22:08:24 +04:00
|
|
|
case "${OPTARG}" in
|
2011-08-30 16:04:12 +04:00
|
|
|
\$*) usage "-M argument must not begin with '\$'"
|
2009-09-27 22:08:24 +04:00
|
|
|
;;
|
|
|
|
*\$*) # can use resolvepath, but can't set TOP_objdir
|
|
|
|
resolvepath OPTARG
|
|
|
|
;;
|
|
|
|
*) resolvepath OPTARG
|
|
|
|
TOP_objdir="${OPTARG}${TOP}"
|
|
|
|
;;
|
|
|
|
esac
|
2003-07-29 14:07:15 +04:00
|
|
|
unsetmakeenv MAKEOBJDIR
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv MAKEOBJDIRPREFIX "${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-12-08 11:42:51 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# -m overrides MACHINE_ARCH unless "-a" is specified
|
|
|
|
-m)
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optargcmd}
|
|
|
|
MACHINE="${OPTARG}"
|
2014-08-15 22:34:19 +04:00
|
|
|
opt_m=true
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2001-10-19 20:43:47 +04:00
|
|
|
|
2003-10-25 07:46:09 +04:00
|
|
|
-N)
|
|
|
|
eval ${optargcmd}
|
|
|
|
case "${OPTARG}" in
|
2008-11-13 23:40:11 +03:00
|
|
|
0|1|2|3|4)
|
2003-10-26 05:17:46 +03:00
|
|
|
setmakeenv MAKEVERBOSE "${OPTARG}"
|
2003-10-25 07:46:09 +04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage "'${OPTARG}' is not a valid value for -N"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-n)
|
|
|
|
runcmd=echo
|
|
|
|
;;
|
2001-10-31 01:33:00 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-O)
|
2009-09-27 22:08:24 +04:00
|
|
|
eval ${optargcmd}
|
|
|
|
case "${OPTARG}" in
|
2011-08-30 16:04:12 +04:00
|
|
|
*\$*) usage "-O argument must not contain '\$'"
|
2009-09-27 22:08:24 +04:00
|
|
|
;;
|
|
|
|
*) resolvepath OPTARG
|
|
|
|
TOP_objdir="${OPTARG}"
|
|
|
|
;;
|
|
|
|
esac
|
2003-07-29 14:07:15 +04:00
|
|
|
unsetmakeenv MAKEOBJDIRPREFIX
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-12-08 11:42:51 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-o)
|
|
|
|
MKOBJDIRS=no
|
|
|
|
;;
|
2001-10-31 04:56:10 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-R)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv RELEASEDIR "${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-12-08 11:42:51 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-r)
|
|
|
|
do_removedirs=true
|
|
|
|
do_rebuildmake=true
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2008-08-05 23:43:33 +04:00
|
|
|
-S)
|
|
|
|
eval ${optargcmd}
|
|
|
|
setmakeenv BUILDSEED "${OPTARG}"
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-T)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2003-05-08 18:19:39 +04:00
|
|
|
TOOLDIR="${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
export TOOLDIR
|
|
|
|
;;
|
2002-12-08 11:42:51 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-U)
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv MKUNPRIVED yes
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
2002-02-27 16:55:28 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-u)
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv MKUPDATE yes
|
2003-01-23 19:24:08 +03: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
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
-V)
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optargcmd}
|
2003-01-23 19:24:08 +03:00
|
|
|
case "${OPTARG}" in
|
2003-01-04 15:55:32 +03:00
|
|
|
# XXX: consider restricting which variables can be changed?
|
2003-01-23 19:24:08 +03:00
|
|
|
[a-zA-Z_][a-zA-Z_0-9]*=*)
|
2003-07-20 13:26:49 +04:00
|
|
|
setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage "-V argument must be of the form 'var=[value]'"
|
|
|
|
;;
|
|
|
|
esac
|
2003-01-04 15:55:32 +03:00
|
|
|
;;
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
-w)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2003-05-08 18:19:39 +04:00
|
|
|
makewrapper="${OPTARG}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2004-02-07 02:19:30 +03:00
|
|
|
-X)
|
2009-09-27 21:25:01 +04:00
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
2004-02-07 02:19:30 +03:00
|
|
|
setmakeenv X11SRCDIR "${OPTARG}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
-x)
|
|
|
|
setmakeenv MKX11 yes
|
|
|
|
;;
|
|
|
|
|
2009-11-30 19:13:22 +03:00
|
|
|
-Y)
|
|
|
|
eval ${optargcmd}; resolvepath OPTARG
|
|
|
|
setmakeenv EXTSRCSRCDIR "${OPTARG}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
-y)
|
|
|
|
setmakeenv MKEXTSRC yes
|
|
|
|
;;
|
|
|
|
|
2003-07-29 14:07:15 +04:00
|
|
|
-Z)
|
|
|
|
eval ${optargcmd}
|
|
|
|
# XXX: consider restricting which variables can be unset?
|
|
|
|
unsetmakeenv "${OPTARG}"
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
--)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
|
|
|
|
-'?'|-h)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Validate operations.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
eval ${optremcmd}
|
2003-01-23 19:24:08 +03:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
op=$1; shift
|
2003-05-08 18:19:39 +04:00
|
|
|
operations="${operations} ${op}"
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
case "${op}" in
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-01-26 09:19:12 +03:00
|
|
|
help)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
|
2014-08-07 21:54:28 +04:00
|
|
|
list-arch)
|
|
|
|
listarch "${MACHINE}" "${MACHINE_ARCH}"
|
|
|
|
exit $?
|
|
|
|
;;
|
|
|
|
|
2014-11-30 18:53:29 +03:00
|
|
|
kernel=*|releasekernel=*|kernel.gdb=*)
|
2003-01-23 19:24:08 +03:00
|
|
|
arg=${op#*=}
|
|
|
|
op=${op%%=*}
|
2003-05-08 18:19:39 +04:00
|
|
|
[ -n "${arg}" ] ||
|
2003-05-25 16:34:27 +04:00
|
|
|
bomb "Must supply a kernel name with \`${op}=...'"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2013-02-13 06:17:54 +04:00
|
|
|
disk-image=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
op=disk_image
|
|
|
|
[ -n "${arg}" ] ||
|
|
|
|
bomb "Must supply a target name with \`${op}=...'"
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
2011-08-09 02:15:42 +04:00
|
|
|
install=*|installmodules=*)
|
2003-01-23 19:24:08 +03:00
|
|
|
arg=${op#*=}
|
|
|
|
op=${op%%=*}
|
2003-05-08 18:19:39 +04:00
|
|
|
[ -n "${arg}" ] ||
|
|
|
|
bomb "Must supply a directory with \`install=...'"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2014-11-10 12:59:33 +03:00
|
|
|
build|\
|
|
|
|
cleandir|\
|
|
|
|
distribution|\
|
|
|
|
install-image|\
|
|
|
|
iso-image-source|\
|
|
|
|
iso-image|\
|
|
|
|
kernels|\
|
|
|
|
live-image|\
|
|
|
|
makewrapper|\
|
|
|
|
modules|\
|
|
|
|
obj|\
|
|
|
|
params|\
|
|
|
|
release|\
|
|
|
|
rump|\
|
|
|
|
rumptest|\
|
|
|
|
sets|\
|
|
|
|
sourcesets|\
|
|
|
|
syspkgs|\
|
|
|
|
tools)
|
2009-11-18 21:05:19 +03:00
|
|
|
;;
|
|
|
|
|
2003-01-04 15:55:32 +03:00
|
|
|
*)
|
2003-01-23 19:24:08 +03:00
|
|
|
usage "Unknown operation \`${op}'"
|
|
|
|
;;
|
|
|
|
|
2003-01-04 15:55:32 +03:00
|
|
|
esac
|
2014-11-10 12:59:33 +03:00
|
|
|
# ${op} may contain chars that are not allowed in variable
|
|
|
|
# names. Replace them with '_' before setting do_${op}.
|
|
|
|
op="$( echo "$op" | tr -s '.-' '__')"
|
2003-05-08 18:19:39 +04:00
|
|
|
eval do_${op}=true
|
2003-01-23 19:24:08 +03:00
|
|
|
done
|
2003-05-08 18:19:39 +04:00
|
|
|
[ -n "${operations}" ] || usage "Missing operation to perform."
|
2003-01-04 15:55:32 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Set up MACHINE*. On a NetBSD host, these are allowed to be unset.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -z "${MACHINE}" ]; then
|
|
|
|
[ "${uname_s}" = "NetBSD" ] ||
|
|
|
|
bomb "MACHINE must be set, or -m must be used, for cross builds."
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE=${uname_m}
|
|
|
|
fi
|
2014-08-15 22:34:19 +04:00
|
|
|
if $opt_m && ! $opt_a; then
|
|
|
|
# Settings implied by the command line -m option
|
|
|
|
# override MACHINE_ARCH from the environment (if any).
|
|
|
|
getarch
|
|
|
|
fi
|
|
|
|
[ -n "${MACHINE_ARCH}" ] || getarch
|
2003-01-23 19:24:08 +03:00
|
|
|
validatearch
|
2001-10-31 04:56:10 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Set up default make(1) environment.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
|
|
|
|
[ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
|
2014-08-03 13:22:29 +04:00
|
|
|
[ -z "${BUILDINFO}" ] || makeenv="${makeenv} BUILDINFO"
|
2011-09-09 17:29:23 +04:00
|
|
|
MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS}"
|
|
|
|
MAKEFLAGS="${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
|
2003-01-23 19:24:08 +03:00
|
|
|
export MAKEFLAGS MACHINE MACHINE_ARCH
|
2014-07-06 21:49:20 +04:00
|
|
|
setmakeenv USETOOLS "yes"
|
|
|
|
setmakeenv MAKEWRAPPERMACHINE "${makewrappermachine:-${MACHINE}}"
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2011-09-09 17:29:23 +04:00
|
|
|
# sanitycheck --
|
|
|
|
# Sanity check after parsing command line options, before rebuildmake.
|
|
|
|
#
|
2007-03-25 11:56:38 +04:00
|
|
|
sanitycheck()
|
|
|
|
{
|
2012-12-02 23:19:36 +04:00
|
|
|
# Install as non-root is a bad idea.
|
|
|
|
#
|
|
|
|
if ${do_install} && [ "$id_u" -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
|
|
|
|
|
2007-03-25 11:56:38 +04:00
|
|
|
# If the PATH contains any non-absolute components (including,
|
2007-04-14 14:50:48 +04:00
|
|
|
# but not limited to, "." or ""), then complain. As an exception,
|
|
|
|
# allow "" or "." as the last component of the PATH. This is fatal
|
2007-03-25 11:56:38 +04:00
|
|
|
# if expert mode is not in effect.
|
|
|
|
#
|
2007-04-14 14:50:48 +04:00
|
|
|
local path="${PATH}"
|
|
|
|
path="${path%:}" # delete trailing ":"
|
|
|
|
path="${path%:.}" # delete trailing ":."
|
|
|
|
case ":${path}:/" in
|
|
|
|
*:[!/]*)
|
2007-03-25 11:56:38 +04:00
|
|
|
if ${do_expertmode}; then
|
|
|
|
warning "PATH contains non-absolute components"
|
|
|
|
else
|
2007-03-25 16:36:01 +04:00
|
|
|
bomb "PATH environment variable must not" \
|
|
|
|
"contain non-absolute components"
|
2007-03-25 11:56:38 +04:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2009-09-28 02:02:41 +04:00
|
|
|
# print_tooldir_make --
|
|
|
|
# Try to find and print a path to an existing
|
|
|
|
# ${TOOLDIR}/bin/${toolprefix}make, for use by rebuildmake() before a
|
|
|
|
# new version of ${toolprefix}make has been built.
|
2007-04-07 18:49:40 +04:00
|
|
|
#
|
|
|
|
# * If TOOLDIR was set in the environment or on the command line, use
|
|
|
|
# that value.
|
|
|
|
# * Otherwise try to guess what TOOLDIR would be if not overridden by
|
|
|
|
# /etc/mk.conf, and check whether the resulting directory contains
|
|
|
|
# a copy of ${toolprefix}make (this should work for everybody who
|
|
|
|
# doesn't override TOOLDIR via /etc/mk.conf);
|
|
|
|
# * Failing that, search for ${toolprefix}make, nbmake, bmake, or make,
|
2011-09-14 21:35:44 +04:00
|
|
|
# in the PATH (this might accidentally find a version of make that
|
|
|
|
# does not understand the syntax used by NetBSD make, and that will
|
|
|
|
# lead to failure in the next step);
|
2007-04-07 18:49:40 +04:00
|
|
|
# * If a copy of make was found above, try to use it with
|
2009-09-28 02:02:41 +04:00
|
|
|
# nobomb_getmakevar to find the correct value for TOOLDIR, and believe the
|
|
|
|
# result only if it's a directory that already exists;
|
|
|
|
# * If a value of TOOLDIR was found above, and if
|
|
|
|
# ${TOOLDIR}/bin/${toolprefix}make exists, print that value.
|
2007-04-07 18:49:40 +04:00
|
|
|
#
|
2009-09-28 02:02:41 +04:00
|
|
|
print_tooldir_make()
|
2007-04-07 18:49:40 +04:00
|
|
|
{
|
2009-09-28 02:02:41 +04:00
|
|
|
local possible_TOP_OBJ
|
|
|
|
local possible_TOOLDIR
|
|
|
|
local possible_make
|
|
|
|
local tooldir_make
|
|
|
|
|
|
|
|
if [ -n "${TOOLDIR}" ]; then
|
|
|
|
echo "${TOOLDIR}/bin/${toolprefix}make"
|
|
|
|
return 0
|
|
|
|
fi
|
2007-04-07 18:49:40 +04:00
|
|
|
|
2008-10-27 02:40:06 +03:00
|
|
|
# Set host_ostype to something like "NetBSD-4.5.6-i386". This
|
|
|
|
# is intended to match the HOST_OSTYPE variable in <bsd.own.mk>.
|
|
|
|
#
|
2007-04-07 18:49:40 +04:00
|
|
|
local host_ostype="${uname_s}-$(
|
|
|
|
echo "${uname_r}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
|
2008-08-16 04:10:04 +04:00
|
|
|
)-$(
|
2007-04-07 18:49:40 +04:00
|
|
|
echo "${uname_p}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
|
|
|
|
)"
|
|
|
|
|
2008-10-27 02:40:06 +03:00
|
|
|
# Look in a few potential locations for
|
|
|
|
# ${possible_TOOLDIR}/bin/${toolprefix}make.
|
2009-09-28 02:02:41 +04:00
|
|
|
# If we find it, then set possible_make.
|
2008-10-27 02:40:06 +03:00
|
|
|
#
|
|
|
|
# In the usual case (without interference from environment
|
|
|
|
# variables or /etc/mk.conf), <bsd.own.mk> should set TOOLDIR to
|
2009-09-27 22:08:24 +04:00
|
|
|
# "${_SRC_TOP_OBJ_}/tooldir.${host_ostype}".
|
|
|
|
#
|
|
|
|
# In practice it's difficult to figure out the correct value
|
|
|
|
# for _SRC_TOP_OBJ_. In the easiest case, when the -M or -O
|
|
|
|
# options were passed to build.sh, then ${TOP_objdir} will be
|
|
|
|
# the correct value. We also try a few other possibilities, but
|
|
|
|
# we do not replicate all the logic of <bsd.obj.mk>.
|
2008-10-27 02:40:06 +03:00
|
|
|
#
|
2009-09-27 22:08:24 +04:00
|
|
|
for possible_TOP_OBJ in \
|
|
|
|
"${TOP_objdir}" \
|
|
|
|
"${MAKEOBJDIRPREFIX:+${MAKEOBJDIRPREFIX}${TOP}}" \
|
|
|
|
"${TOP}" \
|
|
|
|
"${TOP}/obj" \
|
2008-10-27 02:40:06 +03:00
|
|
|
"${TOP}/obj.${MACHINE}"
|
|
|
|
do
|
2009-09-27 22:08:24 +04:00
|
|
|
[ -n "${possible_TOP_OBJ}" ] || continue
|
2008-10-27 02:40:06 +03:00
|
|
|
possible_TOOLDIR="${possible_TOP_OBJ}/tooldir.${host_ostype}"
|
2009-09-28 02:02:41 +04:00
|
|
|
possible_make="${possible_TOOLDIR}/bin/${toolprefix}make"
|
|
|
|
if [ -x "${possible_make}" ]; then
|
2009-09-27 22:08:24 +04:00
|
|
|
break
|
2008-10-27 02:40:06 +03:00
|
|
|
else
|
2009-09-28 02:02:41 +04:00
|
|
|
unset possible_make
|
2008-10-27 02:40:06 +03:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# If the above didn't work, search the PATH for a suitable
|
|
|
|
# ${toolprefix}make, nbmake, bmake, or make.
|
|
|
|
#
|
2009-09-28 02:02:41 +04:00
|
|
|
: ${possible_make:=$(find_in_PATH ${toolprefix}make '')}
|
|
|
|
: ${possible_make:=$(find_in_PATH nbmake '')}
|
|
|
|
: ${possible_make:=$(find_in_PATH bmake '')}
|
|
|
|
: ${possible_make:=$(find_in_PATH make '')}
|
|
|
|
|
|
|
|
# At this point, we don't care whether possible_make is in the
|
|
|
|
# correct TOOLDIR or not; we simply want it to be usable by
|
|
|
|
# getmakevar to help us find the correct TOOLDIR.
|
|
|
|
#
|
|
|
|
# Use ${possible_make} with nobomb_getmakevar to try to find
|
|
|
|
# the value of TOOLDIR. Believe the result only if it's
|
|
|
|
# a directory that already exists and contains bin/${toolprefix}make.
|
2008-10-27 02:40:06 +03:00
|
|
|
#
|
2009-09-28 02:02:41 +04:00
|
|
|
if [ -x "${possible_make}" ]; then
|
|
|
|
possible_TOOLDIR="$(
|
2011-09-14 21:35:44 +04:00
|
|
|
make="${possible_make}" \
|
|
|
|
nobomb_getmakevar TOOLDIR 2>/dev/null
|
2009-09-28 02:02:41 +04:00
|
|
|
)"
|
|
|
|
if [ $? = 0 ] && [ -n "${possible_TOOLDIR}" ] \
|
|
|
|
&& [ -d "${possible_TOOLDIR}" ];
|
|
|
|
then
|
|
|
|
tooldir_make="${possible_TOOLDIR}/bin/${toolprefix}make"
|
|
|
|
if [ -x "${tooldir_make}" ]; then
|
|
|
|
echo "${tooldir_make}"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
2007-04-07 18:49:40 +04:00
|
|
|
fi
|
2009-09-28 02:02:41 +04:00
|
|
|
return 1
|
2007-04-07 18:49:40 +04:00
|
|
|
}
|
|
|
|
|
2009-09-28 02:02:41 +04:00
|
|
|
# rebuildmake --
|
|
|
|
# Rebuild nbmake in a temporary directory if necessary. Sets $make
|
|
|
|
# to a path to the nbmake executable. Sets done_rebuildmake=true
|
|
|
|
# if nbmake was rebuilt.
|
|
|
|
#
|
|
|
|
# There is a cyclic dependency between building nbmake and choosing
|
|
|
|
# TOOLDIR: TOOLDIR may be affected by settings in /etc/mk.conf, so we
|
|
|
|
# would like to use getmakevar to get the value of TOOLDIR; but we can't
|
|
|
|
# use getmakevar before we have an up to date version of nbmake; we
|
|
|
|
# might already have an up to date version of nbmake in TOOLDIR, but we
|
|
|
|
# don't yet know where TOOLDIR is.
|
|
|
|
#
|
|
|
|
# The default value of TOOLDIR also depends on the location of the top
|
|
|
|
# level object directory, so $(getmakevar TOOLDIR) invoked before or
|
|
|
|
# after making the top level object directory may produce different
|
|
|
|
# results.
|
|
|
|
#
|
|
|
|
# Strictly speaking, we should do the following:
|
|
|
|
#
|
|
|
|
# 1. build a new version of nbmake in a temporary directory;
|
|
|
|
# 2. use the temporary nbmake to create the top level obj directory;
|
|
|
|
# 3. use $(getmakevar TOOLDIR) with the temporary nbmake to
|
2013-03-07 08:51:58 +04:00
|
|
|
# get the correct value of TOOLDIR;
|
2009-10-03 23:19:59 +04:00
|
|
|
# 4. move the temporary nbmake to ${TOOLDIR}/bin/nbmake.
|
2009-09-28 02:02:41 +04:00
|
|
|
#
|
|
|
|
# However, people don't like building nbmake unnecessarily if their
|
|
|
|
# TOOLDIR has not changed since an earlier build. We try to avoid
|
|
|
|
# rebuilding a temporary version of nbmake by taking some shortcuts to
|
|
|
|
# guess a value for TOOLDIR, looking for an existing version of nbmake
|
|
|
|
# in that TOOLDIR, and checking whether that nbmake is newer than the
|
|
|
|
# sources used to build it.
|
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
rebuildmake()
|
|
|
|
{
|
2009-09-28 02:02:41 +04:00
|
|
|
make="$(print_tooldir_make)"
|
|
|
|
if [ -n "${make}" ] && [ -x "${make}" ]; then
|
2003-01-23 19:24:08 +03:00
|
|
|
for f in usr.bin/make/*.[ch] usr.bin/make/lst.lib/*.[ch]; do
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ "${f}" -nt "${make}" ]; then
|
2009-09-28 02:02:41 +04:00
|
|
|
statusmsg "${make} outdated" \
|
|
|
|
"(older than ${f}), needs building."
|
2003-01-23 19:24:08 +03:00
|
|
|
do_rebuildmake=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
2009-09-28 02:02:41 +04:00
|
|
|
statusmsg "No \$TOOLDIR/bin/${toolprefix}make, needs building."
|
2003-01-23 19:24:08 +03:00
|
|
|
do_rebuildmake=true
|
2001-10-24 06:39:56 +04:00
|
|
|
fi
|
2001-12-04 07:28:23 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Build bootstrap ${toolprefix}make if needed.
|
2016-04-29 19:08:09 +03:00
|
|
|
if ! ${do_rebuildmake}; then
|
|
|
|
return
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2016-04-29 19:08:09 +03:00
|
|
|
|
|
|
|
statusmsg "Bootstrapping ${toolprefix}make"
|
|
|
|
${runcmd} cd "${tmpdir}"
|
|
|
|
${runcmd} env \
|
|
|
|
\
|
|
|
|
CC="${HOST_CC-cc}" \
|
|
|
|
CPPFLAGS="${HOST_CPPFLAGS} -D_PATH_DEFSYSPATH="'\"'${NETBSDSRCDIR}/share/mk'\"' \
|
|
|
|
CFLAGS="${HOST_CFLAGS--O}" \
|
|
|
|
LDFLAGS="${HOST_LDFLAGS}" \
|
|
|
|
\
|
|
|
|
${HOST_SH} "${TOP}/tools/make/configure" ||
|
|
|
|
( cp ${tmpdir}/config.log ${tmpdir}-config.log
|
|
|
|
bomb "Configure of ${toolprefix}make failed, see ${tmpdir}-config.log for details" )
|
|
|
|
${runcmd} ${HOST_SH} buildmake.sh ||
|
|
|
|
bomb "Build of ${toolprefix}make failed"
|
|
|
|
make="${tmpdir}/${toolprefix}make"
|
|
|
|
${runcmd} cd "${TOP}"
|
|
|
|
${runcmd} rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o
|
|
|
|
done_rebuildmake=true
|
2003-01-23 19:24:08 +03: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
|
|
|
|
2011-09-09 17:29:23 +04:00
|
|
|
# validatemakeparams --
|
|
|
|
# Perform some late sanity checks, after rebuildmake,
|
|
|
|
# but before createmakewrapper or any real work.
|
|
|
|
#
|
2012-10-18 20:15:29 +04:00
|
|
|
# Creates the top-level obj directory, because that
|
|
|
|
# is needed by some of the sanity checks.
|
|
|
|
#
|
|
|
|
# Prints status messages reporting the values of several variables.
|
2011-09-09 17:29:23 +04:00
|
|
|
#
|
2003-01-23 19:24:08 +03:00
|
|
|
validatemakeparams()
|
|
|
|
{
|
2012-10-18 20:15:29 +04:00
|
|
|
# MAKECONF (which defaults to /etc/mk.conf in share/mk/bsd.own.mk)
|
|
|
|
# can affect many things, so mention it in an early status message.
|
|
|
|
#
|
|
|
|
MAKECONF=$(getmakevar MAKECONF)
|
|
|
|
if [ -e "${MAKECONF}" ]; then
|
|
|
|
statusmsg2 "MAKECONF file:" "${MAKECONF}"
|
|
|
|
else
|
|
|
|
statusmsg2 "MAKECONF file:" "${MAKECONF} (File not found)"
|
|
|
|
fi
|
|
|
|
|
2014-02-10 12:20:05 +04:00
|
|
|
# Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE.
|
|
|
|
# These may be set as build.sh options or in "mk.conf".
|
|
|
|
# Don't export them as they're only used for tests in build.sh.
|
|
|
|
#
|
|
|
|
MKOBJDIRS=$(getmakevar MKOBJDIRS)
|
|
|
|
MKUNPRIVED=$(getmakevar MKUNPRIVED)
|
|
|
|
MKUPDATE=$(getmakevar MKUPDATE)
|
|
|
|
|
|
|
|
# Non-root should always use either the -U or -E flag.
|
|
|
|
#
|
|
|
|
if ! ${do_expertmode} && \
|
|
|
|
[ "$id_u" -ne 0 ] && \
|
|
|
|
[ "${MKUNPRIVED}" = "no" ] ; then
|
|
|
|
bomb "-U or -E must be set for build as an unprivileged user."
|
|
|
|
fi
|
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ "${runcmd}" = "echo" ]; then
|
2003-01-23 19:24:08 +03:00
|
|
|
TOOLCHAIN_MISSING=no
|
|
|
|
EXTERNAL_TOOLCHAIN=""
|
|
|
|
else
|
2009-09-27 21:48:19 +04:00
|
|
|
TOOLCHAIN_MISSING=$(bomb_getmakevar TOOLCHAIN_MISSING)
|
|
|
|
EXTERNAL_TOOLCHAIN=$(bomb_getmakevar EXTERNAL_TOOLCHAIN)
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
|
|
|
if [ "${TOOLCHAIN_MISSING}" = "yes" ] && \
|
2003-01-26 08:34:32 +03:00
|
|
|
[ -z "${EXTERNAL_TOOLCHAIN}" ]; then
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for"
|
|
|
|
${runcmd} echo " MACHINE: ${MACHINE}"
|
|
|
|
${runcmd} echo " MACHINE_ARCH: ${MACHINE_ARCH}"
|
|
|
|
${runcmd} echo ""
|
|
|
|
${runcmd} echo "All builds for this platform should be done via a traditional make"
|
|
|
|
${runcmd} echo "If you wish to use an external cross-toolchain, set"
|
|
|
|
${runcmd} echo " EXTERNAL_TOOLCHAIN=<path to toolchain root>"
|
|
|
|
${runcmd} echo "in either the environment or mk.conf and rerun"
|
|
|
|
${runcmd} echo " ${progname} $*"
|
2003-01-23 19:24:08 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2003-05-26 10:35:17 +04:00
|
|
|
if [ "${MKOBJDIRS}" != "no" ]; then
|
2009-09-27 22:08:24 +04:00
|
|
|
# Create the top-level object directory.
|
2003-05-26 10:35:17 +04:00
|
|
|
#
|
2009-09-27 22:08:24 +04:00
|
|
|
# "make obj NOSUBDIR=" can handle most cases, but it
|
|
|
|
# can't handle the case where MAKEOBJDIRPREFIX is set
|
|
|
|
# while the corresponding directory does not exist
|
|
|
|
# (rules in <bsd.obj.mk> would abort the build). We
|
|
|
|
# therefore have to handle the MAKEOBJDIRPREFIX case
|
|
|
|
# without invoking "make obj". The MAKEOBJDIR case
|
|
|
|
# could be handled either way, but we choose to handle
|
|
|
|
# it similarly to MAKEOBJDIRPREFIX.
|
2008-08-06 02:35:32 +04:00
|
|
|
#
|
2009-09-27 22:08:24 +04:00
|
|
|
if [ -n "${TOP_obj}" ]; then
|
|
|
|
# It must have been set by the "-M" or "-O"
|
|
|
|
# command line options, so there's no need to
|
|
|
|
# use getmakevar
|
|
|
|
:
|
|
|
|
elif [ -n "$MAKEOBJDIRPREFIX" ]; then
|
|
|
|
TOP_obj="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
|
|
|
|
elif [ -n "$MAKEOBJDIR" ]; then
|
|
|
|
TOP_obj="$(getmakevar MAKEOBJDIR)"
|
|
|
|
fi
|
|
|
|
if [ -n "$TOP_obj" ]; then
|
|
|
|
${runcmd} mkdir -p "${TOP_obj}" ||
|
|
|
|
bomb "Can't create top level object directory" \
|
|
|
|
"${TOP_obj}"
|
|
|
|
else
|
|
|
|
${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
|
|
|
|
bomb "Can't create top level object directory" \
|
|
|
|
"using make obj"
|
2003-05-26 10:35:17 +04:00
|
|
|
fi
|
|
|
|
|
2009-09-27 22:08:24 +04:00
|
|
|
# make obj in tools to ensure that the objdir for "tools"
|
|
|
|
# is available.
|
2003-05-26 10:35:17 +04:00
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} cd tools
|
|
|
|
${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
|
|
|
|
bomb "Failed to make obj in tools"
|
|
|
|
${runcmd} cd "${TOP}"
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
|
|
|
|
2009-10-14 23:03:12 +04:00
|
|
|
# Find TOOLDIR, DESTDIR, and RELEASEDIR, according to getmakevar,
|
|
|
|
# and bomb if they have changed from the values we had from the
|
|
|
|
# command line or environment.
|
|
|
|
#
|
2009-09-27 22:08:24 +04:00
|
|
|
# This must be done after creating the top-level object directory.
|
2003-01-23 19:24:08 +03:00
|
|
|
#
|
2009-10-14 23:03:12 +04:00
|
|
|
for var in TOOLDIR DESTDIR RELEASEDIR
|
|
|
|
do
|
|
|
|
eval oldval=\"\$${var}\"
|
|
|
|
newval="$(getmakevar $var)"
|
|
|
|
if ! $do_expertmode; then
|
2009-10-15 07:21:45 +04:00
|
|
|
: ${_SRC_TOP_OBJ_:=$(getmakevar _SRC_TOP_OBJ_)}
|
2009-10-14 23:03:12 +04:00
|
|
|
case "$var" in
|
|
|
|
DESTDIR)
|
|
|
|
: ${newval:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
|
2009-11-04 15:58:01 +03:00
|
|
|
makeenv="${makeenv} DESTDIR"
|
2009-10-14 23:03:12 +04:00
|
|
|
;;
|
|
|
|
RELEASEDIR)
|
|
|
|
: ${newval:=${_SRC_TOP_OBJ_}/releasedir}
|
2009-11-04 15:58:01 +03:00
|
|
|
makeenv="${makeenv} RELEASEDIR"
|
2009-10-14 23:03:12 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
if [ -n "$oldval" ] && [ "$oldval" != "$newval" ]; then
|
|
|
|
bomb "Value of ${var} has changed" \
|
|
|
|
"(was \"${oldval}\", now \"${newval}\")"
|
|
|
|
fi
|
|
|
|
eval ${var}=\"\${newval}\"
|
|
|
|
eval export ${var}
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "${var} path:" "${newval}"
|
2009-10-14 23:03:12 +04:00
|
|
|
done
|
|
|
|
|
|
|
|
# RELEASEMACHINEDIR is just a subdir name, e.g. "i386".
|
2008-03-16 10:52:59 +03:00
|
|
|
RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR)
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
# Check validity of TOOLDIR and DESTDIR.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -z "${TOOLDIR}" ] || [ "${TOOLDIR}" = "/" ]; then
|
|
|
|
bomb "TOOLDIR '${TOOLDIR}' invalid"
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2003-05-08 18:19:39 +04:00
|
|
|
removedirs="${TOOLDIR}"
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then
|
2012-12-02 23:19:36 +04:00
|
|
|
if ${do_distribution} || ${do_release} || \
|
|
|
|
[ "${uname_s}" != "NetBSD" ] || \
|
|
|
|
[ "${uname_m}" != "${MACHINE}" ]; then
|
|
|
|
bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
|
|
|
|
fi
|
|
|
|
if ! ${do_expertmode}; then
|
|
|
|
bomb "DESTDIR must != / for non -E (expert) builds"
|
2002-12-09 01:14:00 +03:00
|
|
|
fi
|
2012-12-02 23:19:36 +04:00
|
|
|
statusmsg "WARNING: Building to /, in expert mode."
|
|
|
|
statusmsg " This may cause your system to break! Reasons include:"
|
|
|
|
statusmsg " - your kernel is not up to date"
|
|
|
|
statusmsg " - the libraries or toolchain have changed"
|
|
|
|
statusmsg " YOU HAVE BEEN WARNED!"
|
2003-01-23 19:24:08 +03:00
|
|
|
else
|
2003-05-08 18:19:39 +04:00
|
|
|
removedirs="${removedirs} ${DESTDIR}"
|
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
|
2003-05-25 16:34:27 +04:00
|
|
|
if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then
|
|
|
|
bomb "Must set RELEASEDIR with \`releasekernel=...'"
|
|
|
|
fi
|
2008-02-25 14:14:31 +03:00
|
|
|
|
|
|
|
# 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
|
|
|
|
;;
|
|
|
|
*)
|
2012-12-02 23:19:36 +04:00
|
|
|
if [ -e "${DESTDIR}/METALOG" ] && \
|
2008-02-25 14:14:31 +03:00
|
|
|
[ "${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
|
2012-02-27 00:32:40 +04:00
|
|
|
|
|
|
|
# live-image and install-image targets require binary sets
|
|
|
|
# (actually DESTDIR/etc/mtree/set.* files) built with MKUNPRIVED.
|
|
|
|
# If release operation is specified with live-image or install-image,
|
|
|
|
# the release op should be performed with -U for later image ops.
|
|
|
|
#
|
|
|
|
if ${do_release} && ( ${do_live_image} || ${do_install_image} ) && \
|
|
|
|
[ "${MKUNPRIVED}" = "no" ] ; then
|
|
|
|
bomb "-U must be specified on building release to create images later."
|
|
|
|
fi
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createmakewrapper()
|
|
|
|
{
|
|
|
|
# Remove the target directories.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
if ${do_removedirs}; then
|
|
|
|
for f in ${removedirs}; do
|
|
|
|
statusmsg "Removing ${f}"
|
|
|
|
${runcmd} rm -r -f "${f}"
|
2003-01-23 19:24:08 +03:00
|
|
|
done
|
2002-12-25 03:42:50 +03:00
|
|
|
fi
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Recreate $TOOLDIR.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} mkdir -p "${TOOLDIR}/bin" ||
|
|
|
|
bomb "mkdir of '${TOOLDIR}/bin' failed"
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2009-10-03 23:19:59 +04:00
|
|
|
# If we did not previously rebuild ${toolprefix}make, then
|
|
|
|
# check whether $make is still valid and the same as the output
|
|
|
|
# from print_tooldir_make. If not, then rebuild make now. A
|
|
|
|
# possible reason for this being necessary is that the actual
|
|
|
|
# value of TOOLDIR might be different from the value guessed
|
|
|
|
# before the top level obj dir was created.
|
|
|
|
#
|
|
|
|
if ! ${done_rebuildmake} && \
|
|
|
|
( [ ! -x "$make" ] || [ "$make" != "$(print_tooldir_make)" ] )
|
|
|
|
then
|
|
|
|
rebuildmake
|
|
|
|
fi
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Install ${toolprefix}make if it was built.
|
|
|
|
#
|
2009-09-27 21:55:53 +04:00
|
|
|
if ${done_rebuildmake}; then
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} rm -f "${TOOLDIR}/bin/${toolprefix}make"
|
|
|
|
${runcmd} cp "${make}" "${TOOLDIR}/bin/${toolprefix}make" ||
|
|
|
|
bomb "Failed to install \$TOOLDIR/bin/${toolprefix}make"
|
|
|
|
make="${TOOLDIR}/bin/${toolprefix}make"
|
|
|
|
statusmsg "Created ${make}"
|
2002-03-14 21:33:04 +03:00
|
|
|
fi
|
2001-10-24 06:39:56 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
# Build a ${toolprefix}make wrapper script, usable by hand as
|
|
|
|
# well as by build.sh.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -z "${makewrapper}" ]; then
|
2003-05-12 07:01:16 +04:00
|
|
|
makewrapper="${TOOLDIR}/bin/${toolprefix}make-${makewrappermachine:-${MACHINE}}"
|
2003-05-08 18:19:39 +04:00
|
|
|
[ -z "${BUILDID}" ] || makewrapper="${makewrapper}-${BUILDID}"
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} rm -f "${makewrapper}"
|
|
|
|
if [ "${runcmd}" = "echo" ]; then
|
|
|
|
echo 'cat <<EOF >'${makewrapper}
|
2003-01-23 19:24:08 +03:00
|
|
|
makewrapout=
|
|
|
|
else
|
2003-05-08 18:19:39 +04:00
|
|
|
makewrapout=">>\${makewrapper}"
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2005-09-25 09:34:21 +04:00
|
|
|
case "${KSH_VERSION:-${SH_VERSION}}" in
|
2006-08-10 02:13:12 +04:00
|
|
|
*PD\ KSH*|*MIRBSD\ KSH*)
|
2005-03-26 09:02:13 +03:00
|
|
|
set +o braceexpand
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
eval cat <<EOF ${makewrapout}
|
2006-09-29 23:53:54 +04:00
|
|
|
#! ${HOST_SH}
|
2001-10-24 06:39:56 +04:00
|
|
|
# Set proper variables to allow easy "make" building of a NetBSD subtree.
|
2016-06-03 03:00:01 +03:00
|
|
|
# Generated from: \$NetBSD: build.sh,v 1.310 2016/06/03 00:00:01 kre Exp $
|
2004-07-02 08:25:24 +04:00
|
|
|
# with these arguments: ${_args}
|
2001-10-24 06:39:56 +04:00
|
|
|
#
|
2007-11-20 04:30:07 +03:00
|
|
|
|
2001-11-02 08:07:22 +03:00
|
|
|
EOF
|
2007-11-20 04:30:07 +03:00
|
|
|
{
|
2014-07-06 22:04:44 +04:00
|
|
|
sorted_vars="$(for var in ${makeenv}; do echo "${var}" ; done \
|
|
|
|
| sort -u )"
|
|
|
|
for var in ${sorted_vars}; do
|
|
|
|
eval val=\"\${${var}}\"
|
|
|
|
eval is_set=\"\${${var}+set}\"
|
|
|
|
if [ -z "${is_set}" ]; then
|
|
|
|
echo "unset ${var}"
|
2007-11-20 04:30:07 +03:00
|
|
|
else
|
2014-07-06 22:04:44 +04:00
|
|
|
qval="$(shell_quote "${val}")"
|
|
|
|
echo "${var}=${qval}; export ${var}"
|
2007-11-20 04:30:07 +03:00
|
|
|
fi
|
|
|
|
done
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2014-07-06 22:04:44 +04:00
|
|
|
cat <<EOF
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"}
|
2001-10-24 06:39:56 +04:00
|
|
|
EOF
|
2014-07-06 22:04:44 +04:00
|
|
|
} | eval cat "${makewrapout}"
|
2003-05-08 18:19:39 +04:00
|
|
|
[ "${runcmd}" = "echo" ] && echo EOF
|
|
|
|
${runcmd} chmod +x "${makewrapper}"
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "Updated makewrapper:" "${makewrapper}"
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir()
|
|
|
|
{
|
|
|
|
dir="$1"
|
|
|
|
op="$2"
|
|
|
|
${runcmd} cd "${dir}" ||
|
|
|
|
bomb "Failed to cd to \"${dir}\""
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} ${op} ||
|
|
|
|
bomb "Failed to make ${op} in \"${dir}\""
|
|
|
|
${runcmd} cd "${TOP}" ||
|
|
|
|
bomb "Failed to cd back to \"${TOP}\""
|
|
|
|
}
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
buildtools()
|
|
|
|
{
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ "${MKOBJDIRS}" != "no" ]; then
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} obj-tools ||
|
|
|
|
bomb "Failed to make obj-tools"
|
2001-11-01 03:14:17 +03:00
|
|
|
fi
|
2003-11-12 18:51:45 +03:00
|
|
|
if [ "${MKUPDATE}" = "no" ]; then
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir tools cleandir
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2012-11-16 03:51:53 +04:00
|
|
|
make_in_dir tools build_install
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg "Tools built to ${TOOLDIR}"
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2003-05-25 16:34:27 +04:00
|
|
|
getkernelconf()
|
2003-01-23 19:24:08 +03:00
|
|
|
{
|
2003-05-25 16:34:27 +04:00
|
|
|
kernelconf="$1"
|
2003-08-16 15:46:44 +04:00
|
|
|
if [ "${MKOBJDIRS}" != "no" ]; then
|
2003-01-23 19:24:08 +03:00
|
|
|
# The correct value of KERNOBJDIR might
|
|
|
|
# depend on a prior "make obj" in
|
|
|
|
# ${KERNSRCDIR}/${KERNARCHDIR}/compile.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
KERNSRCDIR="$(getmakevar KERNSRCDIR)"
|
|
|
|
KERNARCHDIR="$(getmakevar KERNARCHDIR)"
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir "${KERNSRCDIR}/${KERNARCHDIR}/compile" obj
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2003-05-08 18:19:39 +04:00
|
|
|
KERNCONFDIR="$(getmakevar KERNCONFDIR)"
|
|
|
|
KERNOBJDIR="$(getmakevar KERNOBJDIR)"
|
2003-05-25 16:34:27 +04:00
|
|
|
case "${kernelconf}" in
|
2003-01-23 19:24:08 +03:00
|
|
|
*/*)
|
2003-05-25 16:34:27 +04:00
|
|
|
kernelconfpath="${kernelconf}"
|
|
|
|
kernelconfname="${kernelconf##*/}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
*)
|
2003-05-25 16:34:27 +04:00
|
|
|
kernelconfpath="${KERNCONFDIR}/${kernelconf}"
|
|
|
|
kernelconfname="${kernelconf}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
esac
|
2003-05-25 16:34:27 +04:00
|
|
|
kernelbuildpath="${KERNOBJDIR}/${kernelconfname}"
|
|
|
|
}
|
|
|
|
|
2013-02-13 06:17:54 +04:00
|
|
|
diskimage()
|
|
|
|
{
|
|
|
|
ARG="$(echo $1 | tr '[:lower:]' '[:upper:]')"
|
|
|
|
[ -f "${DESTDIR}/etc/mtree/set.base" ] ||
|
|
|
|
bomb "The release binaries must be built first"
|
|
|
|
kerneldir="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel"
|
|
|
|
kernel="${kerneldir}/netbsd-${ARG}.gz"
|
|
|
|
[ -f "${kernel}" ] ||
|
|
|
|
bomb "The kernel ${kernel} must be built first"
|
|
|
|
make_in_dir "${NETBSDSRCDIR}/etc" "smp_${1}"
|
|
|
|
}
|
|
|
|
|
2003-05-25 16:34:27 +04:00
|
|
|
buildkernel()
|
|
|
|
{
|
|
|
|
if ! ${do_tools} && ! ${buildkernelwarned:-false}; 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.
|
|
|
|
#
|
|
|
|
statusmsg "Building kernel without building new tools"
|
|
|
|
buildkernelwarned=true
|
|
|
|
fi
|
|
|
|
getkernelconf $1
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "Building kernel:" "${kernelconf}"
|
|
|
|
statusmsg2 "Build directory:" "${kernelbuildpath}"
|
2003-05-25 16:34:27 +04:00
|
|
|
${runcmd} mkdir -p "${kernelbuildpath}" ||
|
|
|
|
bomb "Cannot mkdir: ${kernelbuildpath}"
|
2003-11-12 18:51:45 +03:00
|
|
|
if [ "${MKUPDATE}" = "no" ]; then
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir "${kernelbuildpath}" cleandir
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
2007-01-17 06:43:18 +03:00
|
|
|
[ -x "${TOOLDIR}/bin/${toolprefix}config" ] \
|
|
|
|
|| bomb "${TOOLDIR}/bin/${toolprefix}config does not exist. You need to \"$0 tools\" first."
|
2014-11-30 18:53:29 +03:00
|
|
|
CONFIGOPTS=$(getmakevar CONFIGOPTS)
|
|
|
|
${runcmd} "${TOOLDIR}/bin/${toolprefix}config" ${CONFIGOPTS} \
|
|
|
|
-b "${kernelbuildpath}" -s "${TOP}/sys" ${configopts} \
|
|
|
|
"${kernelconfpath}" ||
|
2003-05-25 16:34:27 +04:00
|
|
|
bomb "${toolprefix}config failed for ${kernelconf}"
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir "${kernelbuildpath}" depend
|
|
|
|
make_in_dir "${kernelbuildpath}" all
|
2003-05-08 18:19:39 +04:00
|
|
|
|
|
|
|
if [ "${runcmd}" != "echo" ]; then
|
2003-05-25 16:34:27 +04:00
|
|
|
statusmsg "Kernels built from ${kernelconf}:"
|
|
|
|
kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
|
2003-02-16 07:35:03 +03:00
|
|
|
for kern in ${kernlist:-netbsd}; do
|
2003-05-25 16:34:27 +04:00
|
|
|
[ -f "${kernelbuildpath}/${kern}" ] && \
|
|
|
|
echo " ${kernelbuildpath}/${kern}"
|
2003-05-08 18:19:39 +04:00
|
|
|
done | tee -a "${results}"
|
2003-02-16 07:35:03 +03:00
|
|
|
fi
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2003-05-25 16:34:27 +04:00
|
|
|
releasekernel()
|
|
|
|
{
|
|
|
|
getkernelconf $1
|
2008-03-16 10:52:59 +03:00
|
|
|
kernelreldir="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel"
|
2003-05-25 16:34:27 +04:00
|
|
|
${runcmd} mkdir -p "${kernelreldir}"
|
|
|
|
kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
|
|
|
|
for kern in ${kernlist:-netbsd}; do
|
|
|
|
builtkern="${kernelbuildpath}/${kern}"
|
|
|
|
[ -f "${builtkern}" ] || continue
|
|
|
|
releasekern="${kernelreldir}/${kern}-${kernelconfname}.gz"
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "Kernel copy:" "${releasekern}"
|
2008-08-18 10:40:09 +04:00
|
|
|
if [ "${runcmd}" = "echo" ]; then
|
|
|
|
echo "gzip -c -9 < ${builtkern} > ${releasekern}"
|
|
|
|
else
|
|
|
|
gzip -c -9 < "${builtkern}" > "${releasekern}"
|
|
|
|
fi
|
2003-05-25 16:34:27 +04:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-11-06 05:02:48 +03:00
|
|
|
buildkernels()
|
|
|
|
{
|
2015-02-01 21:49:25 +03:00
|
|
|
allkernels=$( runcmd= make_in_dir etc '-V ${ALL_KERNELS}' )
|
2014-11-06 05:02:48 +03:00
|
|
|
for k in $allkernels; do
|
|
|
|
buildkernel "${k}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:14:17 +04:00
|
|
|
buildmodules()
|
|
|
|
{
|
2010-05-09 22:53:03 +04:00
|
|
|
setmakeenv MKBINUTILS no
|
2009-09-07 08:14:17 +04:00
|
|
|
if ! ${do_tools} && ! ${buildmoduleswarned:-false}; then
|
|
|
|
# Building tools every time we build modules is clearly
|
|
|
|
# unnecessary as well as a kernel.
|
|
|
|
#
|
|
|
|
statusmsg "Building modules without building new tools"
|
|
|
|
buildmoduleswarned=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
statusmsg "Building kernel modules for NetBSD/${MACHINE} ${DISTRIBVER}"
|
|
|
|
if [ "${MKOBJDIRS}" != "no" ]; then
|
2012-09-29 08:02:42 +04:00
|
|
|
make_in_dir sys/modules obj
|
2009-09-07 08:14:17 +04:00
|
|
|
fi
|
|
|
|
if [ "${MKUPDATE}" = "no" ]; then
|
|
|
|
make_in_dir sys/modules cleandir
|
|
|
|
fi
|
2012-09-29 08:02:42 +04:00
|
|
|
make_in_dir sys/modules dependall
|
|
|
|
make_in_dir sys/modules install
|
2009-09-07 08:14:17 +04:00
|
|
|
|
2010-05-27 09:41:54 +04:00
|
|
|
statusmsg "Successful build of kernel modules for NetBSD/${MACHINE} ${DISTRIBVER}"
|
2009-09-07 08:14:17 +04:00
|
|
|
}
|
|
|
|
|
2011-08-09 02:15:42 +04:00
|
|
|
installmodules()
|
|
|
|
{
|
|
|
|
dir="$1"
|
|
|
|
${runcmd} "${makewrapper}" INSTALLMODULESDIR="${dir}" installmodules ||
|
|
|
|
bomb "Failed to make installmodules to ${dir}"
|
|
|
|
statusmsg "Successful installmodules to ${dir}"
|
|
|
|
}
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
installworld()
|
|
|
|
{
|
|
|
|
dir="$1"
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} "${makewrapper}" INSTALLWORLDDIR="${dir}" installworld ||
|
|
|
|
bomb "Failed to make installworld to ${dir}"
|
|
|
|
statusmsg "Successful installworld to ${dir}"
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2009-11-18 21:05:19 +03:00
|
|
|
# Run rump build&link tests.
|
|
|
|
#
|
|
|
|
# To make this feasible for running without having to install includes and
|
|
|
|
# libraries into destdir (i.e. quick), we only run ld. This is possible
|
|
|
|
# since the rump kernel is a closed namespace apart from calls to rumpuser.
|
|
|
|
# Therefore, if ld complains only about rumpuser symbols, rump kernel
|
|
|
|
# linking was successful.
|
2011-08-15 18:48:00 +04:00
|
|
|
#
|
2009-11-18 21:05:19 +03:00
|
|
|
# We test that rump links with a number of component configurations.
|
|
|
|
# These attempt to mimic what is encountered in the full build.
|
|
|
|
# See list below. The list should probably be either autogenerated
|
2011-08-15 18:48:00 +04:00
|
|
|
# or managed elsewhere; keep it here until a better idea arises.
|
2009-11-18 21:05:19 +03:00
|
|
|
#
|
|
|
|
# Above all, note that THIS IS NOT A SUBSTITUTE FOR A FULL BUILD.
|
|
|
|
#
|
|
|
|
|
|
|
|
RUMP_LIBSETS='
|
|
|
|
-lrump,
|
|
|
|
-lrumpvfs -lrump,
|
2011-12-06 03:04:39 +04:00
|
|
|
-lrumpvfs -lrumpdev -lrump,
|
2010-05-12 00:36:04 +04:00
|
|
|
-lrumpnet -lrump,
|
2010-06-17 12:19:02 +04:00
|
|
|
-lrumpkern_tty -lrumpvfs -lrump,
|
2009-11-18 21:05:19 +03:00
|
|
|
-lrumpfs_tmpfs -lrumpvfs -lrump,
|
2010-03-07 19:57:41 +03:00
|
|
|
-lrumpfs_ffs -lrumpfs_msdos -lrumpvfs -lrumpdev_disk -lrumpdev -lrump,
|
2009-11-18 21:05:19 +03:00
|
|
|
-lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet -lrump,
|
|
|
|
-lrumpnet_sockin -lrumpfs_smbfs -lrumpdev_netsmb
|
2010-12-06 12:08:39 +03:00
|
|
|
-lrumpkern_crypto -lrumpdev -lrumpnet -lrumpvfs -lrump,
|
2009-11-23 17:07:45 +03:00
|
|
|
-lrumpnet_sockin -lrumpfs_nfs -lrumpnet -lrumpvfs -lrump,
|
|
|
|
-lrumpdev_cgd -lrumpdev_raidframe -lrumpdev_disk -lrumpdev_rnd
|
2010-12-06 12:08:39 +03:00
|
|
|
-lrumpdev_dm -lrumpdev -lrumpvfs -lrumpkern_crypto -lrump'
|
2009-11-18 21:05:19 +03:00
|
|
|
dorump()
|
|
|
|
{
|
|
|
|
local doclean=""
|
|
|
|
local doobjs=""
|
|
|
|
|
|
|
|
# we cannot link libs without building csu, and that leads to lossage
|
|
|
|
[ "${1}" != "rumptest" ] && bomb 'build.sh rump not yet functional. ' \
|
|
|
|
'did you mean "rumptest"?'
|
|
|
|
|
2013-08-30 14:29:06 +04:00
|
|
|
export RUMPKERN_ONLY=1
|
2010-01-13 05:18:25 +03:00
|
|
|
# create obj and distrib dirs
|
2010-01-13 05:24:06 +03:00
|
|
|
if [ "${MKOBJDIRS}" != "no" ]; then
|
|
|
|
make_in_dir "${NETBSDSRCDIR}/etc/mtree" obj
|
|
|
|
make_in_dir "${NETBSDSRCDIR}/sys/rump" obj
|
|
|
|
fi
|
2010-01-13 05:18:25 +03:00
|
|
|
${runcmd} "${makewrapper}" ${parallel} do-distrib-dirs \
|
|
|
|
|| bomb 'could not create distrib-dirs'
|
2009-11-18 21:05:19 +03:00
|
|
|
|
2010-01-13 05:18:25 +03:00
|
|
|
[ "${MKUPDATE}" = "no" ] && doclean="cleandir"
|
2009-11-18 21:05:19 +03:00
|
|
|
targlist="${doclean} ${doobjs} dependall install"
|
|
|
|
# optimize: for test we build only static libs (3x test speedup)
|
|
|
|
if [ "${1}" = "rumptest" ] ; then
|
|
|
|
setmakeenv NOPIC 1
|
|
|
|
setmakeenv NOPROFILE 1
|
|
|
|
fi
|
|
|
|
for cmd in ${targlist} ; do
|
|
|
|
make_in_dir "${NETBSDSRCDIR}/sys/rump" ${cmd}
|
|
|
|
done
|
|
|
|
|
|
|
|
# if we just wanted to build & install rump, we're done
|
|
|
|
[ "${1}" != "rumptest" ] && return
|
|
|
|
|
2009-11-24 16:39:07 +03:00
|
|
|
${runcmd} cd "${NETBSDSRCDIR}/sys/rump/librump/rumpkern" \
|
|
|
|
|| bomb "cd to rumpkern failed"
|
|
|
|
md_quirks=`${runcmd} "${makewrapper}" -V '${_SYMQUIRK}'`
|
|
|
|
# one little, two little, three little backslashes ...
|
2010-03-07 20:34:25 +03:00
|
|
|
md_quirks="$(echo ${md_quirks} | sed 's,\\,\\\\,g'";s/'//g" )"
|
2009-11-24 16:39:07 +03:00
|
|
|
${runcmd} cd "${TOP}" || bomb "cd to ${TOP} failed"
|
2009-11-18 21:05:19 +03:00
|
|
|
tool_ld=`${runcmd} "${makewrapper}" -V '${LD}'`
|
2009-11-24 16:39:07 +03:00
|
|
|
|
2009-11-18 21:05:19 +03:00
|
|
|
local oIFS="${IFS}"
|
|
|
|
IFS=","
|
|
|
|
for set in ${RUMP_LIBSETS} ; do
|
|
|
|
IFS="${oIFS}"
|
|
|
|
${runcmd} ${tool_ld} -nostdlib -L${DESTDIR}/usr/lib \
|
2010-11-23 21:30:26 +03:00
|
|
|
-static --whole-archive ${set} 2>&1 -o /tmp/rumptest.$$ | \
|
2009-11-24 16:39:07 +03:00
|
|
|
awk -v quirks="${md_quirks}" '
|
2009-11-18 21:05:19 +03:00
|
|
|
/undefined reference/ &&
|
|
|
|
!/more undefined references.*follow/{
|
2009-11-24 16:39:07 +03:00
|
|
|
if (match($NF,
|
2013-04-28 16:54:39 +04:00
|
|
|
"`(rumpuser_|rumpcomp_|__" quirks ")") == 0)
|
2009-11-18 21:05:19 +03:00
|
|
|
fails[NR] = $0
|
2009-11-24 16:39:07 +03:00
|
|
|
}
|
2010-03-07 19:57:41 +03:00
|
|
|
/cannot find -l/{fails[NR] = $0}
|
2010-11-23 21:30:26 +03:00
|
|
|
/cannot open output file/{fails[NR] = $0}
|
2009-11-18 21:05:19 +03:00
|
|
|
END{
|
|
|
|
for (x in fails)
|
|
|
|
print fails[x]
|
|
|
|
exit x!=0
|
|
|
|
}'
|
|
|
|
[ $? -ne 0 ] && bomb "Testlink of rump failed: ${set}"
|
|
|
|
done
|
|
|
|
statusmsg "Rump build&link tests successful"
|
|
|
|
}
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
initdefaults
|
2004-07-02 08:25:24 +04:00
|
|
|
_args=$@
|
2003-01-23 19:24:08 +03:00
|
|
|
parseoptions "$@"
|
2003-03-04 05:20:28 +03:00
|
|
|
|
2007-03-25 11:56:38 +04:00
|
|
|
sanitycheck
|
|
|
|
|
2003-03-04 05:20:28 +03:00
|
|
|
build_start=$(date)
|
2010-08-25 00:52:31 +04:00
|
|
|
statusmsg2 "${progname} command:" "$0 $*"
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "${progname} started:" "${build_start}"
|
|
|
|
statusmsg2 "NetBSD version:" "${DISTRIBVER}"
|
|
|
|
statusmsg2 "MACHINE:" "${MACHINE}"
|
|
|
|
statusmsg2 "MACHINE_ARCH:" "${MACHINE_ARCH}"
|
|
|
|
statusmsg2 "Build platform:" "${uname_s} ${uname_r} ${uname_m}"
|
|
|
|
statusmsg2 "HOST_SH:" "${HOST_SH}"
|
2014-06-14 16:25:00 +04:00
|
|
|
if [ -n "${BUILDID}" ]; then
|
|
|
|
statusmsg2 "BUILDID:" "${BUILDID}"
|
|
|
|
fi
|
2014-08-03 13:22:29 +04:00
|
|
|
if [ -n "${BUILDINFO}" ]; then
|
|
|
|
printf "%b\n" "${BUILDINFO}" | \
|
|
|
|
while read -r line ; do
|
|
|
|
[ -s "${line}" ] && continue
|
|
|
|
statusmsg2 "BUILDINFO:" "${line}"
|
|
|
|
done
|
|
|
|
fi
|
2006-09-29 23:53:54 +04:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
rebuildmake
|
|
|
|
validatemakeparams
|
|
|
|
createmakewrapper
|
|
|
|
|
|
|
|
# Perform the operations.
|
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
for op in ${operations}; do
|
|
|
|
case "${op}" in
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-01-26 08:34:32 +03:00
|
|
|
makewrapper)
|
|
|
|
# no-op
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
tools)
|
|
|
|
buildtools
|
2002-10-20 19:48:01 +04:00
|
|
|
;;
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2003-11-14 15:38:12 +03:00
|
|
|
sets)
|
|
|
|
statusmsg "Building sets from pre-populated ${DESTDIR}"
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} ${op} ||
|
|
|
|
bomb "Failed to make ${op}"
|
2008-03-16 10:52:59 +03:00
|
|
|
setdir=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
|
|
|
|
statusmsg "Built sets to ${setdir}"
|
2003-11-14 15:38:12 +03:00
|
|
|
;;
|
2006-01-04 18:31:40 +03:00
|
|
|
|
2008-08-18 09:26:05 +04:00
|
|
|
cleandir|obj|build|distribution|release|sourcesets|syspkgs|params)
|
2003-05-08 18:19:39 +04:00
|
|
|
${runcmd} "${makewrapper}" ${parallel} ${op} ||
|
|
|
|
bomb "Failed to make ${op}"
|
|
|
|
statusmsg "Successful make ${op}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2007-09-01 12:15:27 +04:00
|
|
|
iso-image|iso-image-source)
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} \
|
2009-09-27 21:28:38 +04:00
|
|
|
CDEXTRA="$CDEXTRA" ${op} ||
|
2007-09-01 12:15:27 +04:00
|
|
|
bomb "Failed to make ${op}"
|
|
|
|
statusmsg "Successful make ${op}"
|
|
|
|
;;
|
|
|
|
|
2012-02-27 00:32:40 +04:00
|
|
|
live-image|install-image)
|
|
|
|
# install-image and live-image require mtree spec files
|
|
|
|
# built with UNPRIVED. Assume UNPRIVED build has been
|
|
|
|
# performed if METALOG file is created in DESTDIR.
|
|
|
|
if [ ! -e "${DESTDIR}/METALOG" ] ; then
|
|
|
|
bomb "The release binaries must have been built with -U to create images."
|
|
|
|
fi
|
2012-01-22 07:53:29 +04:00
|
|
|
${runcmd} "${makewrapper}" ${parallel} ${op} ||
|
|
|
|
bomb "Failed to make ${op}"
|
|
|
|
statusmsg "Successful make ${op}"
|
|
|
|
;;
|
2003-01-23 19:24:08 +03:00
|
|
|
kernel=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
buildkernel "${arg}"
|
|
|
|
;;
|
2014-05-05 23:12:19 +04:00
|
|
|
kernel.gdb=*)
|
|
|
|
arg=${op#*=}
|
2014-11-16 08:38:10 +03:00
|
|
|
configopts="-D DEBUG=-g"
|
|
|
|
buildkernel "${arg}"
|
|
|
|
;;
|
2003-05-25 16:34:27 +04:00
|
|
|
releasekernel=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
releasekernel "${arg}"
|
|
|
|
;;
|
|
|
|
|
2014-11-06 05:02:48 +03:00
|
|
|
kernels)
|
|
|
|
buildkernels
|
|
|
|
;;
|
|
|
|
|
2013-02-13 06:17:54 +04:00
|
|
|
disk-image=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
diskimage "${arg}"
|
|
|
|
;;
|
|
|
|
|
2009-09-07 08:14:17 +04:00
|
|
|
modules)
|
|
|
|
buildmodules
|
|
|
|
;;
|
|
|
|
|
2011-08-09 02:15:42 +04:00
|
|
|
installmodules=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
if [ "${arg}" = "/" ] && \
|
|
|
|
( [ "${uname_s}" != "NetBSD" ] || \
|
|
|
|
[ "${uname_m}" != "${MACHINE}" ] ); then
|
|
|
|
bomb "'${op}' must != / for cross builds."
|
|
|
|
fi
|
|
|
|
installmodules "${arg}"
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
install=*)
|
|
|
|
arg=${op#*=}
|
2003-01-24 04:17:52 +03:00
|
|
|
if [ "${arg}" = "/" ] && \
|
|
|
|
( [ "${uname_s}" != "NetBSD" ] || \
|
2003-05-08 18:19:39 +04:00
|
|
|
[ "${uname_m}" != "${MACHINE}" ] ); then
|
2003-01-24 04:17:52 +03:00
|
|
|
bomb "'${op}' must != / for cross builds."
|
|
|
|
fi
|
2003-01-23 19:24:08 +03:00
|
|
|
installworld "${arg}"
|
|
|
|
;;
|
|
|
|
|
2009-11-18 21:05:19 +03:00
|
|
|
rump|rumptest)
|
|
|
|
dorump "${op}"
|
|
|
|
;;
|
|
|
|
|
2002-10-20 19:48:01 +04:00
|
|
|
*)
|
2003-01-23 19:24:08 +03:00
|
|
|
bomb "Unknown operation \`${op}'"
|
2002-10-20 19:48:01 +04:00
|
|
|
;;
|
2003-01-23 19:24:08 +03:00
|
|
|
|
2002-10-20 19:48:01 +04:00
|
|
|
esac
|
2003-01-23 19:24:08 +03:00
|
|
|
done
|
2002-12-25 03:42:50 +03:00
|
|
|
|
2010-08-24 17:35:32 +04:00
|
|
|
statusmsg2 "${progname} ended:" "$(date)"
|
2003-05-08 18:19:39 +04:00
|
|
|
if [ -s "${results}" ]; then
|
|
|
|
echo "===> Summary of results:"
|
|
|
|
sed -e 's/^===>//;s/^/ /' "${results}"
|
|
|
|
echo "===> ."
|
|
|
|
fi
|
2003-03-04 05:20:28 +03:00
|
|
|
}
|
2003-02-19 02:59:06 +03:00
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
main "$@"
|