2002-09-14 03:27:13 +04:00
|
|
|
#! /usr/bin/env sh
|
2009-12-05 19:29:10 +03:00
|
|
|
# $NetBSD: build.sh,v 1.223 2009/12/05 16:29:10 pooka Exp $
|
2003-01-23 19:24:08 +03:00
|
|
|
#
|
2009-02-26 02:34:10 +03:00
|
|
|
# Copyright (c) 2001-2009 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
|
|
|
#
|
|
|
|
# Top level build wrapper, for a system containing no tools.
|
|
|
|
#
|
2006-09-29 23:53:54 +04:00
|
|
|
# This script should run on any POSIX-compliant shell. If the
|
|
|
|
# first "sh" found in the PATH is a POSIX-compliant shell, then
|
|
|
|
# you should not need to take any special action. Otherwise, you
|
|
|
|
# should set the environment variable HOST_SH to a POSIX-compliant
|
|
|
|
# shell, and invoke build.sh with that shell. (Depending on your
|
|
|
|
# system, one of /bin/ksh, /usr/local/bin/bash, or /usr/xpg4/bin/sh
|
|
|
|
# might be a suitable shell.)
|
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=' '
|
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
|
|
|
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg()
|
|
|
|
{
|
|
|
|
${runcmd} echo "===> $@" | tee -a "${results}"
|
|
|
|
}
|
|
|
|
|
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."
|
|
|
|
}
|
|
|
|
|
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"
|
|
|
|
|
2009-11-17 23:49:34 +03:00
|
|
|
# Set LC_ALL=C before we try to parse the output from any command
|
|
|
|
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
|
2006-06-19 22:12:30 +04:00
|
|
|
TOP=$(/bin/pwd -P 2>/dev/null || /bin/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*)
|
2003-03-14 08:22:50 +03:00
|
|
|
MAKEFLAGS=-X
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MAKEFLAGS=
|
|
|
|
;;
|
|
|
|
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
|
2009-09-07 08:14:17 +04:00
|
|
|
do_modules=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
|
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
|
|
|
|
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"
|
|
|
|
|
2005-05-19 05:37:30 +04:00
|
|
|
# Set various environment variables to known defaults,
|
|
|
|
# to minimize (cross-)build problems observed "in the field".
|
|
|
|
#
|
|
|
|
unsetmakeenv INFODIR
|
2005-12-12 07:51:55 +03:00
|
|
|
unsetmakeenv LESSCHARSET
|
2003-01-23 19:24:08 +03:00
|
|
|
}
|
2001-12-03 11:18:00 +03:00
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
getarch()
|
|
|
|
{
|
2007-01-27 14:27:33 +03:00
|
|
|
# Translate some MACHINE name aliases (known only to build.sh)
|
|
|
|
# into proper MACHINE and MACHINE_ARCH names. Save the alias
|
|
|
|
# name in makewrappermachine.
|
|
|
|
#
|
|
|
|
case "${MACHINE}" in
|
|
|
|
|
|
|
|
evbarm-e[bl])
|
|
|
|
makewrappermachine=${MACHINE}
|
|
|
|
# MACHINE_ARCH is "arm" or "armeb", not "armel"
|
|
|
|
MACHINE_ARCH=arm${MACHINE##*-}
|
|
|
|
MACHINE_ARCH=${MACHINE_ARCH%el}
|
|
|
|
MACHINE=${MACHINE%-e[bl]}
|
|
|
|
;;
|
|
|
|
|
|
|
|
evbmips-e[bl]|sbmips-e[bl])
|
|
|
|
makewrappermachine=${MACHINE}
|
|
|
|
MACHINE_ARCH=mips${MACHINE##*-}
|
|
|
|
MACHINE=${MACHINE%-e[bl]}
|
|
|
|
;;
|
|
|
|
|
|
|
|
evbmips64-e[bl]|sbmips64-e[bl])
|
|
|
|
makewrappermachine=${MACHINE}
|
|
|
|
MACHINE_ARCH=mips64${MACHINE##*-}
|
|
|
|
MACHINE=${MACHINE%64-e[bl]}
|
|
|
|
;;
|
|
|
|
|
|
|
|
evbsh3-e[bl])
|
|
|
|
makewrappermachine=${MACHINE}
|
|
|
|
MACHINE_ARCH=sh3${MACHINE##*-}
|
|
|
|
MACHINE=${MACHINE%-e[bl]}
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
2001-10-19 06:21:03 +04:00
|
|
|
# Translate a MACHINE into a default MACHINE_ARCH.
|
2003-01-23 19:24:08 +03:00
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
case "${MACHINE}" in
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2007-02-19 17:20:11 +03:00
|
|
|
acorn26|acorn32|cats|hpcarm|iyonix|netwinder|shark|zaurus)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=arm
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2007-02-19 17:20:11 +03:00
|
|
|
evbarm) # unspecified MACHINE_ARCH gets LE
|
|
|
|
MACHINE_ARCH=${MACHINE_ARCH:=arm}
|
|
|
|
;;
|
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
hp700)
|
|
|
|
MACHINE_ARCH=hppa
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
sun2)
|
|
|
|
MACHINE_ARCH=m68000
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=m68k
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-05-12 06:33:17 +04:00
|
|
|
evbmips|sbmips) # no default MACHINE_ARCH
|
|
|
|
;;
|
|
|
|
|
2005-12-29 18:38:54 +03:00
|
|
|
ews4800mips|mipsco|newsmips|sgimips)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=mipseb
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2009-12-05 19:29:10 +03:00
|
|
|
algor|arc|cobalt|hpcmips|pmax)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=mipsel
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2008-01-18 12:45:05 +03:00
|
|
|
evbppc64|macppc64|ofppc64)
|
2007-01-29 03:08:13 +03:00
|
|
|
makewrappermachine=${MACHINE}
|
|
|
|
MACHINE=${MACHINE%64}
|
|
|
|
MACHINE_ARCH=powerpc64
|
|
|
|
;;
|
|
|
|
|
2007-12-17 22:23:44 +03:00
|
|
|
amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|prep|rs6000|sandpoint)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=powerpc
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2003-05-17 11:52:52 +04:00
|
|
|
evbsh3) # no default MACHINE_ARCH
|
|
|
|
;;
|
|
|
|
|
|
|
|
mmeye)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=sh3eb
|
|
|
|
;;
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2006-09-02 01:52:55 +04:00
|
|
|
dreamcast|hpcsh|landisk)
|
2003-01-23 19:24:08 +03:00
|
|
|
MACHINE_ARCH=sh3el
|
|
|
|
;;
|
2002-06-10 18:08:05 +04:00
|
|
|
|
2003-04-26 22:42:34 +04:00
|
|
|
amd64)
|
|
|
|
MACHINE_ARCH=x86_64
|
|
|
|
;;
|
2002-10-02 20:57:29 +04:00
|
|
|
|
2005-08-17 11:13:32 +04:00
|
|
|
alpha|i386|sparc|sparc64|vax|ia64)
|
2003-05-08 18:19:39 +04:00
|
|
|
MACHINE_ARCH=${MACHINE}
|
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-24 06:39:56 +04:00
|
|
|
|
2001-10-19 06:21:03 +04:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2003-01-03 02:11:07 +03:00
|
|
|
validatearch()
|
|
|
|
{
|
2002-03-02 00:06:40 +03:00
|
|
|
# Ensure that the MACHINE_ARCH exists (and is supported by build.sh).
|
2003-01-23 19:24:08 +03:00
|
|
|
#
|
2003-05-08 18:19:39 +04:00
|
|
|
case "${MACHINE_ARCH}" in
|
2002-03-02 00:06:40 +03:00
|
|
|
|
2008-02-03 09:10:53 +03:00
|
|
|
alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|powerpc|powerpc64|sh3e[bl]|sparc|sparc64|vax|x86_64|ia64)
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2003-05-12 06:33:17 +04:00
|
|
|
"")
|
|
|
|
bomb "No MACHINE_ARCH provided"
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
*)
|
2003-05-08 18:19:39 +04:00
|
|
|
bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2002-03-02 00:06:40 +03:00
|
|
|
esac
|
2003-05-08 18:19:39 +04:00
|
|
|
|
|
|
|
# Determine valid MACHINE_ARCHs for MACHINE
|
|
|
|
#
|
|
|
|
case "${MACHINE}" in
|
|
|
|
|
|
|
|
evbarm)
|
|
|
|
arches="arm armeb"
|
|
|
|
;;
|
|
|
|
|
|
|
|
evbmips|sbmips)
|
2006-08-26 03:35:04 +04:00
|
|
|
arches="mipseb mipsel mips64eb mips64el"
|
|
|
|
;;
|
|
|
|
|
|
|
|
sgimips)
|
|
|
|
arches="mipseb mips64eb"
|
2003-05-08 18:19:39 +04:00
|
|
|
;;
|
|
|
|
|
|
|
|
evbsh3)
|
|
|
|
arches="sh3eb sh3el"
|
|
|
|
;;
|
|
|
|
|
2008-01-18 12:45:05 +03:00
|
|
|
macppc|evbppc|ofppc)
|
2006-06-23 00:00:18 +04:00
|
|
|
arches="powerpc powerpc64"
|
|
|
|
;;
|
2003-05-08 18:19:39 +04:00
|
|
|
*)
|
|
|
|
oma="${MACHINE_ARCH}"
|
|
|
|
getarch
|
|
|
|
arches="${MACHINE_ARCH}"
|
|
|
|
MACHINE_ARCH="${oma}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Ensure that MACHINE_ARCH supports MACHINE
|
|
|
|
#
|
|
|
|
archok=false
|
|
|
|
for a in ${arches}; do
|
|
|
|
if [ "${a}" = "${MACHINE_ARCH}" ]; then
|
|
|
|
archok=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
${archok} ||
|
|
|
|
bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
|
2002-03-02 00:06:40 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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 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
|
|
|
}
|
|
|
|
|
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 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
|
|
|
|
2008-08-05 23:43:33 +04:00
|
|
|
Usage: ${progname} [-EnorUux] [-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'
|
2003-11-14 15:38:12 +03:00
|
|
|
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
|
2009-09-07 08:14:17 +04:00
|
|
|
modules Build and install 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.
|
2007-08-30 09:30:02 +04:00
|
|
|
iso-image Create CD-ROM image in RELEASEDIR/iso.
|
|
|
|
iso-image-source Create CD-ROM image with source in RELEASEDIR/iso.
|
2003-11-14 15:38:12 +03:00
|
|
|
params Display various make(1) parameters.
|
2003-01-23 19:24:08 +03:00
|
|
|
|
|
|
|
Options:
|
2003-11-14 15:38:12 +03:00
|
|
|
-a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE]
|
|
|
|
-B buildId Set BUILDID to buildId.
|
2009-09-27 21:28:38 +04:00
|
|
|
-C cdextras Append cdextras to CDEXTRA variable for inclusion on CD-ROM.
|
2003-10-25 07:46:09 +04:00
|
|
|
-D dest Set DESTDIR to dest. [Default: destdir.MACHINE]
|
2003-05-08 18:19:39 +04:00
|
|
|
-E Set "expert" mode; disables various safety checks.
|
2004-02-07 02:19:30 +03:00
|
|
|
Should not be used without expert knowledge of the build system.
|
2004-06-25 19:03:39 +04:00
|
|
|
-h Print this help message.
|
2003-11-14 15:38:12 +03:00
|
|
|
-j njob Run up to njob jobs in parallel; see make(1) -j.
|
|
|
|
-M obj Set obj root directory to obj; sets MAKEOBJDIRPREFIX.
|
2003-07-29 14:07:15 +04:00
|
|
|
Unsets MAKEOBJDIR.
|
2003-11-14 15:38:12 +03:00
|
|
|
-m mach Set MACHINE to mach; not required if NetBSD native.
|
2008-08-18 09:26:05 +04:00
|
|
|
-N noisy Set the noisyness (MAKEVERBOSE) level of the build:
|
2008-11-13 23:40:11 +03:00
|
|
|
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
|
2008-08-18 09:26:05 +04:00
|
|
|
[Default: 2]
|
2003-11-14 15:38:12 +03:00
|
|
|
-n Show commands that would be executed, but do not execute them.
|
|
|
|
-O obj Set obj root directory to obj; sets a MAKEOBJDIR pattern.
|
2003-07-29 14:07:15 +04:00
|
|
|
Unsets MAKEOBJDIRPREFIX.
|
2003-11-14 15:38:12 +03:00
|
|
|
-o Set MKOBJDIRS=no; do not create objdirs at start of build.
|
2003-10-25 07:46:09 +04:00
|
|
|
-R release Set RELEASEDIR to release. [Default: releasedir]
|
2003-11-14 15:38:12 +03:00
|
|
|
-r Remove contents of TOOLDIR and DESTDIR before building.
|
2008-08-05 23:43:33 +04:00
|
|
|
-S seed Set BUILDSEED to seed. [Default: NetBSD-majorversion]
|
2003-05-08 18:19:39 +04:00
|
|
|
-T tools Set TOOLDIR to tools. If unset, and TOOLDIR is not set in
|
2003-11-14 15:38:12 +03:00
|
|
|
the environment, ${toolprefix}make will be (re)built unconditionally.
|
|
|
|
-U Set MKUNPRIVED=yes; build without requiring root privileges,
|
2008-08-18 09:26:05 +04:00
|
|
|
install from an UNPRIVED build with proper file permissions.
|
2008-03-28 07:24:18 +03:00
|
|
|
-u Set MKUPDATE=yes; do not run "make cleandir" first.
|
2008-08-18 09:26:05 +04:00
|
|
|
Without this, everything is rebuilt, including the tools.
|
2003-11-14 15:38:12 +03:00
|
|
|
-V v=[val] Set variable \`v' to \`val'.
|
|
|
|
-w wrapper Create ${toolprefix}make script as wrapper.
|
2003-10-25 07:46:09 +04:00
|
|
|
[Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}]
|
2004-02-07 02:19:30 +03:00
|
|
|
-X x11src Set X11SRCDIR to x11src. [Default: /usr/xsrc]
|
2009-02-22 01:04:35 +03:00
|
|
|
-x Set MKX11=yes; build X11 from X11SRCDIR
|
2009-11-30 19:13:22 +03:00
|
|
|
-Y extsrcsrc
|
|
|
|
Set EXTSRCSRCDIR to extsrcsrc. [Default: /usr/extsrc]
|
|
|
|
-y Set MKEXTSRC=yes; build extsrc from EXTSRCSRCDIR
|
2003-11-14 15:38:12 +03:00
|
|
|
-Z v Unset ("zap") variable \`v'.
|
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()
|
|
|
|
{
|
2009-11-30 19:13:22 +03:00
|
|
|
opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:xX:yY:Z:'
|
2003-01-23 19:24:08 +03:00
|
|
|
opt_a=no
|
|
|
|
|
|
|
|
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 ||
|
|
|
|
bomb "/bin/sh shell is too old; try ksh or bash"
|
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}
|
2003-01-23 19:24:08 +03:00
|
|
|
opt_a=yes
|
|
|
|
;;
|
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
|
|
|
|
\$*) usage "-M argument must not begin with '$'"
|
|
|
|
;;
|
|
|
|
*\$*) # 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}"
|
|
|
|
[ "${opt_a}" != "yes" ] && getarch
|
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
|
|
|
|
*\$*) usage "-O argument must not contain '$'"
|
|
|
|
;;
|
|
|
|
*) 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
|
|
|
|
;;
|
|
|
|
|
2008-08-18 09:26:05 +04:00
|
|
|
makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params)
|
2003-01-23 19:24:08 +03:00
|
|
|
;;
|
|
|
|
|
2006-02-03 15:29:41 +03:00
|
|
|
iso-image)
|
|
|
|
op=iso_image # used as part of a variable name
|
|
|
|
;;
|
|
|
|
|
2007-08-30 09:30:02 +04:00
|
|
|
iso-image-source)
|
|
|
|
op=iso_image_source # used as part of a variable name
|
|
|
|
;;
|
|
|
|
|
2003-05-25 16:34:27 +04:00
|
|
|
kernel=*|releasekernel=*)
|
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
|
|
|
;;
|
|
|
|
|
2009-09-07 08:14:17 +04:00
|
|
|
modules)
|
|
|
|
op=modules
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
install=*)
|
|
|
|
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
|
|
|
;;
|
|
|
|
|
2009-11-18 21:05:19 +03:00
|
|
|
rump|rumptest)
|
|
|
|
op=${op}
|
|
|
|
;;
|
|
|
|
|
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
|
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
|
2003-05-08 18:19:39 +04:00
|
|
|
[ -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"
|
2003-09-10 22:05:52 +04:00
|
|
|
MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
|
2003-01-23 19:24:08 +03:00
|
|
|
export MAKEFLAGS MACHINE MACHINE_ARCH
|
|
|
|
}
|
2001-10-19 06:21:03 +04:00
|
|
|
|
2007-03-25 11:56:38 +04:00
|
|
|
sanitycheck()
|
|
|
|
{
|
|
|
|
# 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,
|
|
|
|
# in the PATH (this might accidentally find a non-NetBSD version of
|
|
|
|
# make, which will lead to failure in the next step);
|
|
|
|
# * 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="$(
|
|
|
|
make="${possible_make}" nobomb_getmakevar TOOLDIR
|
|
|
|
)"
|
|
|
|
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
|
|
|
|
# get the corect 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.
|
2003-05-08 18:19:39 +04:00
|
|
|
if ${do_rebuildmake}; then
|
|
|
|
statusmsg "Bootstrapping ${toolprefix}make"
|
|
|
|
${runcmd} cd "${tmpdir}"
|
|
|
|
${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
|
2003-01-23 19:24:08 +03:00
|
|
|
CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
|
2006-09-29 23:53:54 +04:00
|
|
|
${HOST_SH} "${TOP}/tools/make/configure" ||
|
2003-05-08 18:19:39 +04:00
|
|
|
bomb "Configure of ${toolprefix}make failed"
|
2006-09-29 23:53:54 +04:00
|
|
|
${runcmd} ${HOST_SH} buildmake.sh ||
|
2003-05-08 18:19:39 +04:00
|
|
|
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
|
2009-09-27 21:55:53 +04:00
|
|
|
done_rebuildmake=true
|
2003-01-23 19:24:08 +03:00
|
|
|
fi
|
|
|
|
}
|
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
|
|
|
validatemakeparams()
|
|
|
|
{
|
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-10-26 05:00:37 +03: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)
|
|
|
|
|
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}
|
|
|
|
statusmsg "${var} path: ${newval}"
|
|
|
|
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
|
|
|
|
if ${do_build} || ${do_distribution} || ${do_release}; then
|
|
|
|
if ! ${do_build} || \
|
2003-01-23 19:24:08 +03:00
|
|
|
[ "${uname_s}" != "NetBSD" ] || \
|
2003-05-08 18:19:39 +04:00
|
|
|
[ "${uname_m}" != "${MACHINE}" ]; then
|
2003-01-23 19:24:08 +03:00
|
|
|
bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
|
|
|
|
fi
|
2003-05-08 18:19:39 +04:00
|
|
|
if ! ${do_expertmode}; then
|
2003-01-23 19:24:08 +03:00
|
|
|
bomb "DESTDIR must != / for non -E (expert) builds"
|
|
|
|
fi
|
2003-05-08 18:19:39 +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!"
|
2002-12-09 01:14:00 +03:00
|
|
|
fi
|
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-08 18:19:39 +04:00
|
|
|
if ${do_build} || ${do_distribution} || ${do_release}; then
|
|
|
|
if ! ${do_expertmode} && \
|
2009-02-25 01:25:24 +03:00
|
|
|
[ "$id_u" -ne 0 ] && \
|
2003-11-12 18:51:45 +03:00
|
|
|
[ "${MKUNPRIVED}" = "no" ] ; then
|
2003-01-26 08:34:32 +03:00
|
|
|
bomb "-U or -E must be set for build as an unprivileged user."
|
|
|
|
fi
|
2008-02-25 14:14:31 +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
|
|
|
|
|
|
|
# Install as non-root is a bad idea.
|
|
|
|
#
|
2009-02-25 01:25:24 +03:00
|
|
|
if ${do_install} && [ "$id_u" -ne 0 ] ; then
|
2008-02-25 14:14:31 +03:00
|
|
|
if ${do_expertmode}; then
|
|
|
|
warning "Will install as an unprivileged user."
|
|
|
|
else
|
|
|
|
bomb "-E must be set for install as an unprivileged user."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If a previous build.sh run used -U (and therefore created a
|
|
|
|
# METALOG file), then most subsequent build.sh runs must also
|
|
|
|
# use -U. If DESTDIR is about to be removed, then don't perform
|
|
|
|
# this check.
|
|
|
|
#
|
|
|
|
case "${do_removedirs} ${removedirs} " in
|
|
|
|
true*" ${DESTDIR} "*)
|
|
|
|
# DESTDIR is about to be removed
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if ( ${do_build} || ${do_distribution} || ${do_release} || \
|
|
|
|
${do_install} ) && \
|
|
|
|
[ -e "${DESTDIR}/METALOG" ] && \
|
|
|
|
[ "${MKUNPRIVED}" = "no" ] ; then
|
|
|
|
if $do_expertmode; then
|
|
|
|
warning "A previous build.sh run specified -U."
|
|
|
|
else
|
|
|
|
bomb "A previous build.sh run specified -U; you must specify it again now."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
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.
|
2009-12-05 19:29:10 +03:00
|
|
|
# Generated from: \$NetBSD: build.sh,v 1.223 2009/12/05 16:29:10 pooka 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
|
|
|
{
|
|
|
|
for f in ${makeenv}; do
|
|
|
|
if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then
|
|
|
|
eval echo "unset ${f}"
|
|
|
|
else
|
|
|
|
eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}"
|
|
|
|
fi
|
|
|
|
done
|
2001-11-02 08:07:22 +03:00
|
|
|
|
2007-11-20 04:30:07 +03:00
|
|
|
eval cat <<EOF
|
2006-12-09 23:13:13 +03:00
|
|
|
MAKEWRAPPERMACHINE=${makewrappermachine:-${MACHINE}}; export MAKEWRAPPERMACHINE
|
|
|
|
USETOOLS=yes; export USETOOLS
|
2007-11-20 04:30:07 +03:00
|
|
|
EOF
|
|
|
|
} | eval sort -u "${makewrapout}"
|
2007-11-20 04:33:32 +03:00
|
|
|
eval cat <<EOF "${makewrapout}"
|
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
|
2003-05-08 18:19:39 +04:00
|
|
|
[ "${runcmd}" = "echo" ] && echo EOF
|
|
|
|
${runcmd} chmod +x "${makewrapper}"
|
2003-05-25 16:34:27 +04:00
|
|
|
statusmsg "makewrapper: ${makewrapper}"
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg "Updated ${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
|
2009-02-26 02:34:10 +03:00
|
|
|
make_in_dir tools dependall
|
|
|
|
make_in_dir tools 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}"
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
statusmsg "Building kernel: ${kernelconf}"
|
|
|
|
statusmsg "Build directory: ${kernelbuildpath}"
|
|
|
|
${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."
|
2003-05-25 16:34:27 +04:00
|
|
|
${runcmd} "${TOOLDIR}/bin/${toolprefix}config" -b "${kernelbuildpath}" \
|
|
|
|
-s "${TOP}/sys" "${kernelconfpath}" ||
|
|
|
|
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"
|
|
|
|
statusmsg "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
|
|
|
|
}
|
|
|
|
|
2009-09-07 08:14:17 +04:00
|
|
|
buildmodules()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
make_in_dir sys/modules obj ||
|
|
|
|
bomb "Failed to make obj in sys/modules"
|
|
|
|
fi
|
|
|
|
if [ "${MKUPDATE}" = "no" ]; then
|
|
|
|
make_in_dir sys/modules cleandir
|
|
|
|
fi
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} do-sys-modules ||
|
|
|
|
bomb "Failed to make do-sys-modules"
|
|
|
|
|
|
|
|
statusmsg "Successful build kernel modules for NetBSD/${MACHINE} ${DISTRIBVER}"
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# or managed elsewhere. But keep it here until a better idea arises.
|
|
|
|
#
|
|
|
|
# Above all, note that THIS IS NOT A SUBSTITUTE FOR A FULL BUILD.
|
|
|
|
#
|
|
|
|
|
|
|
|
RUMP_LIBSETS='
|
|
|
|
-lrump,
|
|
|
|
-lrumpvfs -lrump,
|
|
|
|
-lrumpfs_tmpfs -lrumpvfs -lrump,
|
|
|
|
-lrumpfs_ffs -lrumpfs_msdosfs -lrumpvfs -lrump,
|
|
|
|
-lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet -lrump,
|
|
|
|
-lrumpnet_sockin -lrumpfs_smbfs -lrumpdev_netsmb
|
|
|
|
-lrumpcrypto -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
|
|
|
|
-lrumpdev -lrumpvfs -lrumpcrypto -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"?'
|
|
|
|
|
|
|
|
[ "${MKUPDATE}" = "no" ] && doclean="cleandir"
|
|
|
|
[ "${MKOBJDIRS}" = "no" ] || doobjs="obj"
|
|
|
|
${runcmd} "${makewrapper}" ${parallel} do-distrib-dirs
|
|
|
|
|
|
|
|
targlist="${doclean} ${doobjs} dependall install"
|
|
|
|
setmakeenv NORUMPUSER 1
|
|
|
|
# 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 ...
|
|
|
|
md_quirks="`echo ${md_quirks} | sed 's,\\\,\\\\\\\,g'";s/'//g" `"
|
|
|
|
${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 \
|
2009-11-24 16:39:07 +03:00
|
|
|
-static --whole-archive ${set} 2>&1 | \
|
|
|
|
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,
|
|
|
|
"`(rumpuser_|__" quirks ")") == 0)
|
2009-11-18 21:05:19 +03:00
|
|
|
fails[NR] = $0
|
2009-11-24 16:39:07 +03:00
|
|
|
}
|
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)
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg "${progname} command: $0 $@"
|
|
|
|
statusmsg "${progname} started: ${build_start}"
|
2007-04-02 14:57:36 +04:00
|
|
|
statusmsg "NetBSD version: ${DISTRIBVER}"
|
|
|
|
statusmsg "MACHINE: ${MACHINE}"
|
|
|
|
statusmsg "MACHINE_ARCH: ${MACHINE_ARCH}"
|
|
|
|
statusmsg "Build platform: ${uname_s} ${uname_r} ${uname_m}"
|
2006-09-29 23:53:54 +04:00
|
|
|
statusmsg "HOST_SH: ${HOST_SH}"
|
|
|
|
|
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}"
|
|
|
|
;;
|
|
|
|
|
2003-01-23 19:24:08 +03:00
|
|
|
kernel=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
buildkernel "${arg}"
|
|
|
|
;;
|
|
|
|
|
2003-05-25 16:34:27 +04:00
|
|
|
releasekernel=*)
|
|
|
|
arg=${op#*=}
|
|
|
|
releasekernel "${arg}"
|
|
|
|
;;
|
|
|
|
|
2009-09-07 08:14:17 +04:00
|
|
|
modules)
|
|
|
|
buildmodules
|
|
|
|
;;
|
|
|
|
|
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
|
|
|
|
2003-05-08 18:19:39 +04:00
|
|
|
statusmsg "${progname} ended: $(date)"
|
|
|
|
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 "$@"
|