Home | History | Annotate | Line # | Download | only in src
build.sh revision 1.153.2.2
      1 #! /usr/bin/env sh
      2 #	$NetBSD: build.sh,v 1.153.2.2 2007/04/16 19:55:07 bouyer Exp $
      3 #
      4 # Copyright (c) 2001-2005 The NetBSD Foundation, Inc.
      5 # All rights reserved.
      6 #
      7 # This code is derived from software contributed to The NetBSD Foundation
      8 # by Todd Vierling and Luke Mewburn.
      9 #
     10 # Redistribution and use in source and binary forms, with or without
     11 # modification, are permitted provided that the following conditions
     12 # are met:
     13 # 1. Redistributions of source code must retain the above copyright
     14 #    notice, this list of conditions and the following disclaimer.
     15 # 2. Redistributions in binary form must reproduce the above copyright
     16 #    notice, this list of conditions and the following disclaimer in the
     17 #    documentation and/or other materials provided with the distribution.
     18 # 3. All advertising materials mentioning features or use of this software
     19 #    must display the following acknowledgement:
     20 #        This product includes software developed by the NetBSD
     21 #        Foundation, Inc. and its contributors.
     22 # 4. Neither the name of The NetBSD Foundation nor the names of its
     23 #    contributors may be used to endorse or promote products derived
     24 #    from this software without specific prior written permission.
     25 #
     26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36 # POSSIBILITY OF SUCH DAMAGE.
     37 #
     38 #
     39 # Top level build wrapper, for a system containing no tools.
     40 #
     41 # This script should run on any POSIX-compliant shell.  If the
     42 # first "sh" found in the PATH is a POSIX-compliant shell, then
     43 # you should not need to take any special action.  Otherwise, you
     44 # should set the environment variable HOST_SH to a POSIX-compliant
     45 # shell, and invoke build.sh with that shell.  (Depending on your
     46 # system, one of /bin/ksh, /usr/local/bin/bash, or /usr/xpg4/bin/sh
     47 # might be a suitable shell.)
     48 #
     49 
     50 progname=${0##*/}
     51 toppid=$$
     52 results=/dev/null
     53 trap "exit 1" 1 2 3 15
     54 
     55 bomb()
     56 {
     57 	cat >&2 <<ERRORMESSAGE
     58 
     59 ERROR: $@
     60 *** BUILD ABORTED ***
     61 ERRORMESSAGE
     62 	kill ${toppid}		# in case we were invoked from a subshell
     63 	exit 1
     64 }
     65 
     66 
     67 statusmsg()
     68 {
     69 	${runcmd} echo "===> $@" | tee -a "${results}"
     70 }
     71 
     72 # Find a program in the PATH
     73 find_in_PATH()
     74 {
     75 	local prog="$1"
     76 	local oldIFS="${IFS}"
     77 	local dir
     78 	IFS=":"
     79 	for dir in ${PATH}; do
     80 		if [ -x "${dir}/${prog}" ]; then
     81 			prog="${dir}/${prog}"
     82 			break
     83 		fi
     84 	done
     85 	IFS="${oldIFS}"
     86 	echo "${prog}"
     87 }
     88 
     89 # Try to find a working POSIX shell, and set HOST_SH to refer to it.
     90 # Assumes that uname_s, uname_m, and PWD have been set.
     91 set_HOST_SH()
     92 {
     93 	# Even if ${HOST_SH} is already defined, we still do the
     94 	# sanity checks at the end.
     95 
     96 	# Solaris has /usr/xpg4/bin/sh.
     97 	#
     98 	[ -z "${HOST_SH}" ] && [ x"${uname_s}" = x"SunOS" ] && \
     99 		[ -x /usr/xpg4/bin/sh ] && HOST_SH="/usr/xpg4/bin/sh"
    100 
    101 	# Try to get the name of the shell that's running this script,
    102 	# by parsing the output from "ps".  We assume that, if the host
    103 	# system's ps command supports -o comm at all, it will do so
    104 	# in the usual way: a one-line header followed by a one-line
    105 	# result, possibly including trailing white space.  And if the
    106 	# host system's ps command doesn't support -o comm, we assume
    107 	# that we'll get an error message on stderr and nothing on
    108 	# stdout.  (We don't try to use ps -o 'comm=' to suppress the
    109 	# header line, because that is less widely supported.)
    110 	#
    111 	# If we get the wrong result here, the user can override it by
    112 	# specifying HOST_SH in the environment.
    113 	#
    114 	[ -z "${HOST_SH}" ] && HOST_SH="$(
    115 		(ps -p $$ -o comm | sed -ne '2s/[ \t]*$//p') 2>/dev/null )"
    116 
    117 	# If nothing above worked, use "sh".  We will later find the
    118 	# first directory in the PATH that has a "sh" program.
    119 	#
    120 	[ -z "${HOST_SH}" ] && HOST_SH="sh"
    121 
    122 	# If the result so far is not an absolute path, try to prepend
    123 	# PWD or search the PATH.
    124 	#
    125 	case "${HOST_SH}" in
    126 	/*)	:
    127 		;;
    128 	*/*)	HOST_SH="${PWD}/${HOST_SH}"
    129 		;;
    130 	*)	HOST_SH="$(find_in_PATH "${HOST_SH}")"
    131 		;;
    132 	esac
    133 
    134 	# If we don't have an absolute path by now, bomb.
    135 	#
    136 	case "${HOST_SH}" in
    137 	/*)	:
    138 		;;
    139 	*)	bomb "HOST_SH=\"${HOST_SH}\" is not an absolute path."
    140 		;;
    141 	esac
    142 
    143 	# If HOST_SH is not executable, bomb.
    144 	#
    145 	[ -x "${HOST_SH}" ] ||
    146 	    bomb "HOST_SH=\"${HOST_SH}\" is not executable."
    147 }
    148 
    149 initdefaults()
    150 {
    151 	cd "$(dirname $0)"
    152 	[ -d usr.bin/make ] ||
    153 	    bomb "build.sh must be run from the top source level"
    154 	[ -f share/mk/bsd.own.mk ] ||
    155 	    bomb "src/share/mk is missing; please re-fetch the source tree"
    156 
    157 	# Find information about the build platform.
    158 	#
    159 	uname_s=$(uname -s 2>/dev/null)
    160 	uname_r=$(uname -r 2>/dev/null)
    161 	uname_m=$(uname -m 2>/dev/null)
    162 
    163 	# If $PWD is a valid name of the current directory, POSIX mandates
    164 	# that pwd return it by default which causes problems in the
    165 	# presence of symlinks.  Unsetting PWD is simpler than changing
    166 	# every occurrence of pwd to use -P.
    167 	#
    168 	# XXX Except that doesn't work on Solaris. Or many Linuces.
    169 	#
    170 	unset PWD
    171 	TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)
    172 
    173 	# The user can set HOST_SH in the environment, or we try to
    174 	# guess an appropriate value.  Then we set several other
    175 	# variables from HOST_SH.
    176 	#
    177 	set_HOST_SH
    178 	setmakeenv HOST_SH "${HOST_SH}"
    179 	setmakeenv BSHELL "${HOST_SH}"
    180 	setmakeenv CONFIG_SHELL "${HOST_SH}"
    181 
    182 	# Set defaults.
    183 	#
    184 	toolprefix=nb
    185 
    186 	# Some systems have a small ARG_MAX.  -X prevents make(1) from
    187 	# exporting variables in the environment redundantly.
    188 	#
    189 	case "${uname_s}" in
    190 	Darwin | FreeBSD | CYGWIN*)
    191 		MAKEFLAGS=-X
    192 		;;
    193 	*)
    194 		MAKEFLAGS=
    195 		;;
    196 	esac
    197 
    198 	makeenv=
    199 	makewrapper=
    200 	makewrappermachine=
    201 	runcmd=
    202 	operations=
    203 	removedirs=
    204 	do_expertmode=false
    205 	do_rebuildmake=false
    206 	do_removedirs=false
    207 
    208 	# do_{operation}=true if given operation is requested.
    209 	#
    210 	do_tools=false
    211 	do_obj=false
    212 	do_build=false
    213 	do_distribution=false
    214 	do_release=false
    215 	do_kernel=false
    216 	do_releasekernel=false
    217 	do_install=false
    218 	do_sets=false
    219 	do_sourcesets=false
    220 	do_syspkgs=false
    221 	do_iso_image=false
    222 	do_params=false
    223 
    224 	# Create scratch directory
    225 	#
    226 	tmpdir="${TMPDIR-/tmp}/nbbuild$$"
    227 	mkdir "${tmpdir}" || bomb "Cannot mkdir: ${tmpdir}"
    228 	trap "cd /; rm -r -f \"${tmpdir}\"" 0
    229 	results="${tmpdir}/build.sh.results"
    230 
    231 	# Set source directories
    232 	#
    233 	setmakeenv NETBSDSRCDIR "${TOP}"
    234 
    235 	# Find the version of NetBSD
    236 	#
    237 	DISTRIBVER="$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh)"
    238 
    239 	# Set various environment variables to known defaults,
    240 	# to minimize (cross-)build problems observed "in the field".
    241 	#
    242 	unsetmakeenv INFODIR
    243 	unsetmakeenv LESSCHARSET
    244 	setmakeenv LC_ALL C
    245 }
    246 
    247 getarch()
    248 {
    249 	# Translate a MACHINE into a default MACHINE_ARCH.
    250 	#
    251 	case "${MACHINE}" in
    252 
    253 	acorn26|acorn32|cats|evbarm|hpcarm|iyonix|netwinder|shark)
    254 		MACHINE_ARCH=arm
    255 		;;
    256 
    257 	hp700)
    258 		MACHINE_ARCH=hppa
    259 		;;
    260 
    261 	sun2)
    262 		MACHINE_ARCH=m68000
    263 		;;
    264 
    265 	amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k)
    266 		MACHINE_ARCH=m68k
    267 		;;
    268 
    269 	evbmips-e[bl]|sbmips-e[bl])
    270 		MACHINE_ARCH=mips${MACHINE##*-}
    271 		makewrappermachine=${MACHINE}
    272 		MACHINE=${MACHINE%-e[bl]}
    273 		;;
    274 
    275 	evbmips64-e[bl]|sbmips64-e[bl])
    276 		MACHINE_ARCH=mips64${MACHINE##*-}
    277 		makewrappermachine=${MACHINE}
    278 		MACHINE=${MACHINE%64-e[bl]}
    279 		;;
    280 
    281 	evbmips|sbmips)		# no default MACHINE_ARCH
    282 		;;
    283 
    284 	ews4800mips|mipsco|newsmips|sgimips)
    285 		MACHINE_ARCH=mipseb
    286 		;;
    287 
    288 	algor|arc|cobalt|hpcmips|playstation2|pmax)
    289 		MACHINE_ARCH=mipsel
    290 		;;
    291 
    292 	pc532)
    293 		MACHINE_ARCH=ns32k
    294 		;;
    295 
    296 	amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|pmppc|prep|sandpoint)
    297 		MACHINE_ARCH=powerpc
    298 		;;
    299 
    300 	evbsh3-e[bl])
    301 		MACHINE_ARCH=sh3${MACHINE##*-}
    302 		makewrappermachine=${MACHINE}
    303 		MACHINE=${MACHINE%-e[bl]}
    304 		;;
    305 
    306 	evbsh3)			# no default MACHINE_ARCH
    307 		;;
    308 
    309 	mmeye)
    310 		MACHINE_ARCH=sh3eb
    311 		;;
    312 
    313 	dreamcast|hpcsh|landisk)
    314 		MACHINE_ARCH=sh3el
    315 		;;
    316 
    317 	evbsh5)
    318 		MACHINE_ARCH=sh5el
    319 		;;
    320 	amd64)
    321 		MACHINE_ARCH=x86_64
    322 		;;
    323 
    324 	alpha|i386|sparc|sparc64|vax|ia64)
    325 		MACHINE_ARCH=${MACHINE}
    326 		;;
    327 
    328 	*)
    329 		bomb "Unknown target MACHINE: ${MACHINE}"
    330 		;;
    331 
    332 	esac
    333 }
    334 
    335 validatearch()
    336 {
    337 	# Ensure that the MACHINE_ARCH exists (and is supported by build.sh).
    338 	#
    339 	case "${MACHINE_ARCH}" in
    340 
    341 	alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|ns32k|powerpc|powerpc64|sh[35]e[bl]|sparc|sparc64|vax|x86_64|ia64)
    342 		;;
    343 
    344 	"")
    345 		bomb "No MACHINE_ARCH provided"
    346 		;;
    347 
    348 	*)
    349 		bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
    350 		;;
    351 
    352 	esac
    353 
    354 	# Determine valid MACHINE_ARCHs for MACHINE
    355 	#
    356 	case "${MACHINE}" in
    357 
    358 	evbarm)
    359 		arches="arm armeb"
    360 		;;
    361 
    362 	evbmips|sbmips)
    363 		arches="mipseb mipsel mips64eb mips64el"
    364 		;;
    365 
    366 	sgimips)
    367 		arches="mipseb mips64eb"
    368 		;;
    369 
    370 	evbsh3)
    371 		arches="sh3eb sh3el"
    372 		;;
    373 
    374 	evbsh5)
    375 		arches="sh5eb sh5el"
    376 		;;
    377 
    378 	macppc|evbppc)
    379 		arches="powerpc powerpc64"
    380 		;;
    381 	*)
    382 		oma="${MACHINE_ARCH}"
    383 		getarch
    384 		arches="${MACHINE_ARCH}"
    385 		MACHINE_ARCH="${oma}"
    386 		;;
    387 
    388 	esac
    389 
    390 	# Ensure that MACHINE_ARCH supports MACHINE
    391 	#
    392 	archok=false
    393 	for a in ${arches}; do
    394 		if [ "${a}" = "${MACHINE_ARCH}" ]; then
    395 			archok=true
    396 			break
    397 		fi
    398 	done
    399 	${archok} ||
    400 	    bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
    401 }
    402 
    403 raw_getmakevar()
    404 {
    405 	[ -x "${make}" ] || bomb "raw_getmakevar $1: ${make} is not executable"
    406 	"${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<EOF
    407 _x_:
    408 	echo \${$1}
    409 .include <bsd.prog.mk>
    410 .include <bsd.kernobj.mk>
    411 EOF
    412 }
    413 
    414 getmakevar()
    415 {
    416 	# raw_getmakevar() doesn't work properly if $make hasn't yet been
    417 	# built, which can happen when running with the "-n" option.
    418 	# getmakevar() deals with this by emitting a literal '$'
    419 	# followed by the variable name, instead of trying to find the
    420 	# variable's value.
    421 	#
    422 	if [ -x "${make}" ]; then
    423 		raw_getmakevar "$1"
    424 	else
    425 		echo "\$$1"
    426 	fi
    427 }
    428 
    429 setmakeenv()
    430 {
    431 	eval "$1='$2'; export $1"
    432 	makeenv="${makeenv} $1"
    433 }
    434 
    435 unsetmakeenv()
    436 {
    437 	eval "unset $1"
    438 	makeenv="${makeenv} $1"
    439 }
    440 
    441 # Convert possibly-relative path to absolute path by prepending
    442 # ${TOP} if necessary.  Also delete trailing "/", if any.
    443 resolvepath()
    444 {
    445 	case "${OPTARG}" in
    446 	/)
    447 		;;
    448 	/*)
    449 		OPTARG="${OPTARG%/}"
    450 		;;
    451 	*)
    452 		OPTARG="${TOP}/${OPTARG%/}"
    453 		;;
    454 	esac
    455 }
    456 
    457 usage()
    458 {
    459 	if [ -n "$*" ]; then
    460 		echo ""
    461 		echo "${progname}: $*"
    462 	fi
    463 	cat <<_usage_
    464 
    465 Usage: ${progname} [-EnorUux] [-a arch] [-B buildid] [-D dest] [-j njob]
    466 		[-M obj] [-m mach] [-N noisy] [-O obj] [-R release] [-T tools]
    467 		[-V var=[value]] [-w wrapper] [-X x11src] [-Z var]
    468 		operation [...]
    469 
    470  Build operations (all imply "obj" and "tools"):
    471     build               Run "make build".
    472     distribution        Run "make distribution" (includes DESTDIR/etc/ files).
    473     release             Run "make release" (includes kernels & distrib media).
    474 
    475  Other operations:
    476     help                Show this message and exit.
    477     makewrapper         Create ${toolprefix}make-\${MACHINE} wrapper and ${toolprefix}make.
    478                         Always performed.
    479     obj                 Run "make obj".  [Default unless -o is used]
    480     tools               Build and install tools.
    481     install=idir        Run "make installworld" to \`idir' to install all sets
    482 			except \`etc'.  Useful after "distribution" or "release"
    483     kernel=conf         Build kernel with config file \`conf'
    484     releasekernel=conf  Install kernel built by kernel=conf to RELEASEDIR.
    485     sets                Create binary sets in RELEASEDIR/MACHINE/binary/sets.
    486 			DESTDIR should be populated beforehand.
    487     sourcesets          Create source sets in RELEASEDIR/source/sets.
    488     syspkgs             Create syspkgs in RELEASEDIR/MACHINE/binary/syspkgs.
    489     iso-image           Create CD-ROM image in RELEASEDIR/MACHINE/installation.
    490     params              Display various make(1) parameters.
    491 
    492  Options:
    493     -a arch     Set MACHINE_ARCH to arch.  [Default: deduced from MACHINE]
    494     -B buildId  Set BUILDID to buildId.
    495     -D dest     Set DESTDIR to dest.  [Default: destdir.MACHINE]
    496     -E          Set "expert" mode; disables various safety checks.
    497                 Should not be used without expert knowledge of the build system.
    498     -h          Print this help message.
    499     -j njob     Run up to njob jobs in parallel; see make(1) -j.
    500     -M obj      Set obj root directory to obj; sets MAKEOBJDIRPREFIX.
    501                 Unsets MAKEOBJDIR.
    502     -m mach     Set MACHINE to mach; not required if NetBSD native.
    503     -N noisy	Set the noisyness (MAKEVERBOSE) level of the build:
    504 		    0	Quiet
    505 		    1	Operations are described, commands are suppressed
    506 		    2	Full output
    507 		[Default: 2]
    508     -n          Show commands that would be executed, but do not execute them.
    509     -O obj      Set obj root directory to obj; sets a MAKEOBJDIR pattern.
    510                 Unsets MAKEOBJDIRPREFIX.
    511     -o          Set MKOBJDIRS=no; do not create objdirs at start of build.
    512     -R release  Set RELEASEDIR to release.  [Default: releasedir]
    513     -r          Remove contents of TOOLDIR and DESTDIR before building.
    514     -T tools    Set TOOLDIR to tools.  If unset, and TOOLDIR is not set in
    515                 the environment, ${toolprefix}make will be (re)built unconditionally.
    516     -U          Set MKUNPRIVED=yes; build without requiring root privileges,
    517     		install from an UNPRIVED build with proper file permissions.
    518     -u          Set MKUPDATE=yes; do not run "make clean" first.
    519 		Without this, everything is rebuilt, including the tools.
    520     -V v=[val]  Set variable \`v' to \`val'.
    521     -w wrapper  Create ${toolprefix}make script as wrapper.
    522                 [Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}]
    523     -X x11src   Set X11SRCDIR to x11src.  [Default: /usr/xsrc]
    524     -x          Set MKX11=yes; build X11R6 from X11SRCDIR
    525     -Z v        Unset ("zap") variable \`v'.
    526 
    527 _usage_
    528 	exit 1
    529 }
    530 
    531 parseoptions()
    532 {
    533 	opts='a:B:bD:dEhi:j:k:M:m:N:nO:oR:rT:tUuV:w:xX:Z:'
    534 	opt_a=no
    535 
    536 	if type getopts >/dev/null 2>&1; then
    537 		# Use POSIX getopts.
    538 		#
    539 		getoptcmd='getopts ${opts} opt && opt=-${opt}'
    540 		optargcmd=':'
    541 		optremcmd='shift $((${OPTIND} -1))'
    542 	else
    543 		type getopt >/dev/null 2>&1 ||
    544 		    bomb "/bin/sh shell is too old; try ksh or bash"
    545 
    546 		# Use old-style getopt(1) (doesn't handle whitespace in args).
    547 		#
    548 		args="$(getopt ${opts} $*)"
    549 		[ $? = 0 ] || usage
    550 		set -- ${args}
    551 
    552 		getoptcmd='[ $# -gt 0 ] && opt="$1" && shift'
    553 		optargcmd='OPTARG="$1"; shift'
    554 		optremcmd=':'
    555 	fi
    556 
    557 	# Parse command line options.
    558 	#
    559 	while eval ${getoptcmd}; do
    560 		case ${opt} in
    561 
    562 		-a)
    563 			eval ${optargcmd}
    564 			MACHINE_ARCH=${OPTARG}
    565 			opt_a=yes
    566 			;;
    567 
    568 		-B)
    569 			eval ${optargcmd}
    570 			BUILDID=${OPTARG}
    571 			;;
    572 
    573 		-b)
    574 			usage "'-b' has been replaced by 'makewrapper'"
    575 			;;
    576 
    577 		-D)
    578 			eval ${optargcmd}; resolvepath
    579 			setmakeenv DESTDIR "${OPTARG}"
    580 			;;
    581 
    582 		-d)
    583 			usage "'-d' has been replaced by 'distribution'"
    584 			;;
    585 
    586 		-E)
    587 			do_expertmode=true
    588 			;;
    589 
    590 		-i)
    591 			usage "'-i idir' has been replaced by 'install=idir'"
    592 			;;
    593 
    594 		-j)
    595 			eval ${optargcmd}
    596 			parallel="-j ${OPTARG}"
    597 			;;
    598 
    599 		-k)
    600 			usage "'-k conf' has been replaced by 'kernel=conf'"
    601 			;;
    602 
    603 		-M)
    604 			eval ${optargcmd}; resolvepath
    605 			makeobjdir="${OPTARG}"
    606 			unsetmakeenv MAKEOBJDIR
    607 			setmakeenv MAKEOBJDIRPREFIX "${OPTARG}"
    608 			;;
    609 
    610 			# -m overrides MACHINE_ARCH unless "-a" is specified
    611 		-m)
    612 			eval ${optargcmd}
    613 			MACHINE="${OPTARG}"
    614 			[ "${opt_a}" != "yes" ] && getarch
    615 			;;
    616 
    617 		-N)
    618 			eval ${optargcmd}
    619 			case "${OPTARG}" in
    620 			0|1|2)
    621 				setmakeenv MAKEVERBOSE "${OPTARG}"
    622 				;;
    623 			*)
    624 				usage "'${OPTARG}' is not a valid value for -N"
    625 				;;
    626 			esac
    627 			;;
    628 
    629 		-n)
    630 			runcmd=echo
    631 			;;
    632 
    633 		-O)
    634 			eval ${optargcmd}; resolvepath
    635 			makeobjdir="${OPTARG}"
    636 			unsetmakeenv MAKEOBJDIRPREFIX
    637 			setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
    638 			;;
    639 
    640 		-o)
    641 			MKOBJDIRS=no
    642 			;;
    643 
    644 		-R)
    645 			eval ${optargcmd}; resolvepath
    646 			setmakeenv RELEASEDIR "${OPTARG}"
    647 			;;
    648 
    649 		-r)
    650 			do_removedirs=true
    651 			do_rebuildmake=true
    652 			;;
    653 
    654 		-T)
    655 			eval ${optargcmd}; resolvepath
    656 			TOOLDIR="${OPTARG}"
    657 			export TOOLDIR
    658 			;;
    659 
    660 		-t)
    661 			usage "'-t' has been replaced by 'tools'"
    662 			;;
    663 
    664 		-U)
    665 			setmakeenv MKUNPRIVED yes
    666 			;;
    667 
    668 		-u)
    669 			setmakeenv MKUPDATE yes
    670 			;;
    671 
    672 		-V)
    673 			eval ${optargcmd}
    674 			case "${OPTARG}" in
    675 		    # XXX: consider restricting which variables can be changed?
    676 			[a-zA-Z_][a-zA-Z_0-9]*=*)
    677 				setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}"
    678 				;;
    679 			*)
    680 				usage "-V argument must be of the form 'var=[value]'"
    681 				;;
    682 			esac
    683 			;;
    684 
    685 		-w)
    686 			eval ${optargcmd}; resolvepath
    687 			makewrapper="${OPTARG}"
    688 			;;
    689 
    690 		-X)
    691 			eval ${optargcmd}; resolvepath
    692 			setmakeenv X11SRCDIR "${OPTARG}"
    693 			;;
    694 
    695 		-x)
    696 			setmakeenv MKX11 yes
    697 			;;
    698 
    699 		-Z)
    700 			eval ${optargcmd}
    701 		    # XXX: consider restricting which variables can be unset?
    702 			unsetmakeenv "${OPTARG}"
    703 			;;
    704 
    705 		--)
    706 			break
    707 			;;
    708 
    709 		-'?'|-h)
    710 			usage
    711 			;;
    712 
    713 		esac
    714 	done
    715 
    716 	# Validate operations.
    717 	#
    718 	eval ${optremcmd}
    719 	while [ $# -gt 0 ]; do
    720 		op=$1; shift
    721 		operations="${operations} ${op}"
    722 
    723 		case "${op}" in
    724 
    725 		help)
    726 			usage
    727 			;;
    728 
    729 		makewrapper|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params)
    730 			;;
    731 
    732 		iso-image)
    733 			op=iso_image	# used as part of a variable name
    734 			;;
    735 
    736 		kernel=*|releasekernel=*)
    737 			arg=${op#*=}
    738 			op=${op%%=*}
    739 			[ -n "${arg}" ] ||
    740 			    bomb "Must supply a kernel name with \`${op}=...'"
    741 			;;
    742 
    743 		install=*)
    744 			arg=${op#*=}
    745 			op=${op%%=*}
    746 			[ -n "${arg}" ] ||
    747 			    bomb "Must supply a directory with \`install=...'"
    748 			;;
    749 
    750 		*)
    751 			usage "Unknown operation \`${op}'"
    752 			;;
    753 
    754 		esac
    755 		eval do_${op}=true
    756 	done
    757 	[ -n "${operations}" ] || usage "Missing operation to perform."
    758 
    759 	# Set up MACHINE*.  On a NetBSD host, these are allowed to be unset.
    760 	#
    761 	if [ -z "${MACHINE}" ]; then
    762 		[ "${uname_s}" = "NetBSD" ] ||
    763 		    bomb "MACHINE must be set, or -m must be used, for cross builds."
    764 		MACHINE=${uname_m}
    765 	fi
    766 	[ -n "${MACHINE_ARCH}" ] || getarch
    767 	validatearch
    768 
    769 	# Set up default make(1) environment.
    770 	#
    771 	makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
    772 	[ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
    773 	MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
    774 	export MAKEFLAGS MACHINE MACHINE_ARCH
    775 }
    776 
    777 rebuildmake()
    778 {
    779 	# Test make source file timestamps against installed ${toolprefix}make
    780 	# binary, if TOOLDIR is pre-set.
    781 	#
    782 	# Note that we do NOT try to grovel "mk.conf" here to find out if
    783 	# TOOLDIR is set there, because it can contain make variable
    784 	# expansions and other stuff only parseable *after* we have a working
    785 	# ${toolprefix}make.  So this logic can only work if the user has
    786 	# pre-set TOOLDIR in the environment or used the -T option to build.sh.
    787 	#
    788 	make="${TOOLDIR-nonexistent}/bin/${toolprefix}make"
    789 	if [ -x "${make}" ]; then
    790 		for f in usr.bin/make/*.[ch] usr.bin/make/lst.lib/*.[ch]; do
    791 			if [ "${f}" -nt "${make}" ]; then
    792 				statusmsg "${make} outdated (older than ${f}), needs building."
    793 				do_rebuildmake=true
    794 				break
    795 			fi
    796 		done
    797 	else
    798 		statusmsg "No ${make}, needs building."
    799 		do_rebuildmake=true
    800 	fi
    801 
    802 	# Build bootstrap ${toolprefix}make if needed.
    803 	if ${do_rebuildmake}; then
    804 		statusmsg "Bootstrapping ${toolprefix}make"
    805 		${runcmd} cd "${tmpdir}"
    806 		${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
    807 			CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
    808 			${HOST_SH} "${TOP}/tools/make/configure" ||
    809 		    bomb "Configure of ${toolprefix}make failed"
    810 		${runcmd} ${HOST_SH} buildmake.sh ||
    811 		    bomb "Build of ${toolprefix}make failed"
    812 		make="${tmpdir}/${toolprefix}make"
    813 		${runcmd} cd "${TOP}"
    814 		${runcmd} rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o
    815 	fi
    816 }
    817 
    818 validatemakeparams()
    819 {
    820 	if [ "${runcmd}" = "echo" ]; then
    821 		TOOLCHAIN_MISSING=no
    822 		EXTERNAL_TOOLCHAIN=""
    823 	else
    824 		TOOLCHAIN_MISSING=$(raw_getmakevar TOOLCHAIN_MISSING)
    825 		EXTERNAL_TOOLCHAIN=$(raw_getmakevar EXTERNAL_TOOLCHAIN)
    826 	fi
    827 	if [ "${TOOLCHAIN_MISSING}" = "yes" ] && \
    828 	   [ -z "${EXTERNAL_TOOLCHAIN}" ]; then
    829 		${runcmd} echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for"
    830 		${runcmd} echo "	MACHINE:      ${MACHINE}"
    831 		${runcmd} echo "	MACHINE_ARCH: ${MACHINE_ARCH}"
    832 		${runcmd} echo ""
    833 		${runcmd} echo "All builds for this platform should be done via a traditional make"
    834 		${runcmd} echo "If you wish to use an external cross-toolchain, set"
    835 		${runcmd} echo "	EXTERNAL_TOOLCHAIN=<path to toolchain root>"
    836 		${runcmd} echo "in either the environment or mk.conf and rerun"
    837 		${runcmd} echo "	${progname} $*"
    838 		exit 1
    839 	fi
    840 
    841 	# Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE
    842 	# These may be set as build.sh options or in "mk.conf".
    843 	# Don't export them as they're only used for tests in build.sh.
    844 	#
    845 	MKOBJDIRS=$(getmakevar MKOBJDIRS)
    846 	MKUNPRIVED=$(getmakevar MKUNPRIVED)
    847 	MKUPDATE=$(getmakevar MKUPDATE)
    848 
    849 	if [ "${MKOBJDIRS}" != "no" ]; then
    850 		# If setting -M or -O to the root of an obj dir, make sure
    851 		# the base directory is made before continuing as <bsd.own.mk>
    852 		# will need this to pick up _SRC_TOP_OBJ_
    853 		#
    854 		if [ ! -z "${makeobjdir}" ]; then
    855 			${runcmd} mkdir -p "${makeobjdir}"
    856 		fi
    857 
    858 		# make obj in tools to ensure that the objdir for the top-level
    859 		# of the source tree and for "tools" is available, in case the
    860 		# default TOOLDIR setting from <bsd.own.mk> is used, or the
    861 		# build.sh default DESTDIR and RELEASEDIR is to be used.
    862 		#
    863 		${runcmd} cd tools
    864 		${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
    865 		    bomb "Failed to make obj in tools"
    866 		${runcmd} cd "${TOP}"
    867 	fi
    868 
    869 	# Find TOOLDIR, DESTDIR, and RELEASEDIR.
    870 	#
    871 	TOOLDIR=$(getmakevar TOOLDIR)
    872 	statusmsg "TOOLDIR path:     ${TOOLDIR}"
    873 	DESTDIR=$(getmakevar DESTDIR)
    874 	RELEASEDIR=$(getmakevar RELEASEDIR)
    875 	if ! $do_expertmode; then
    876 		_SRC_TOP_OBJ_=$(getmakevar _SRC_TOP_OBJ_)
    877 		: ${DESTDIR:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
    878 		: ${RELEASEDIR:=${_SRC_TOP_OBJ_}/releasedir}
    879 		makeenv="${makeenv} DESTDIR RELEASEDIR"
    880 	fi
    881 	export TOOLDIR DESTDIR RELEASEDIR
    882 	statusmsg "DESTDIR path:     ${DESTDIR}"
    883 	statusmsg "RELEASEDIR path:  ${RELEASEDIR}"
    884 
    885 	# Check validity of TOOLDIR and DESTDIR.
    886 	#
    887 	if [ -z "${TOOLDIR}" ] || [ "${TOOLDIR}" = "/" ]; then
    888 		bomb "TOOLDIR '${TOOLDIR}' invalid"
    889 	fi
    890 	removedirs="${TOOLDIR}"
    891 
    892 	if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then
    893 		if ${do_build} || ${do_distribution} || ${do_release}; then
    894 			if ! ${do_build} || \
    895 			   [ "${uname_s}" != "NetBSD" ] || \
    896 			   [ "${uname_m}" != "${MACHINE}" ]; then
    897 				bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
    898 			fi
    899 			if ! ${do_expertmode}; then
    900 				bomb "DESTDIR must != / for non -E (expert) builds"
    901 			fi
    902 			statusmsg "WARNING: Building to /, in expert mode."
    903 			statusmsg "         This may cause your system to break!  Reasons include:"
    904 			statusmsg "            - your kernel is not up to date"
    905 			statusmsg "            - the libraries or toolchain have changed"
    906 			statusmsg "         YOU HAVE BEEN WARNED!"
    907 		fi
    908 	else
    909 		removedirs="${removedirs} ${DESTDIR}"
    910 	fi
    911 	if ${do_build} || ${do_distribution} || ${do_release}; then
    912 		if ! ${do_expertmode} && \
    913 		    [ "$(id -u 2>/dev/null)" -ne 0 ] && \
    914 		    [ "${MKUNPRIVED}" = "no" ] ; then
    915 			bomb "-U or -E must be set for build as an unprivileged user."
    916 		fi
    917         fi
    918 	if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then
    919 		bomb "Must set RELEASEDIR with \`releasekernel=...'"
    920 	fi
    921 }
    922 
    923 
    924 createmakewrapper()
    925 {
    926 	# Remove the target directories.
    927 	#
    928 	if ${do_removedirs}; then
    929 		for f in ${removedirs}; do
    930 			statusmsg "Removing ${f}"
    931 			${runcmd} rm -r -f "${f}"
    932 		done
    933 	fi
    934 
    935 	# Recreate $TOOLDIR.
    936 	#
    937 	${runcmd} mkdir -p "${TOOLDIR}/bin" ||
    938 	    bomb "mkdir of '${TOOLDIR}/bin' failed"
    939 
    940 	# Install ${toolprefix}make if it was built.
    941 	#
    942 	if ${do_rebuildmake}; then
    943 		${runcmd} rm -f "${TOOLDIR}/bin/${toolprefix}make"
    944 		${runcmd} cp "${make}" "${TOOLDIR}/bin/${toolprefix}make" ||
    945 		    bomb "Failed to install \$TOOLDIR/bin/${toolprefix}make"
    946 		make="${TOOLDIR}/bin/${toolprefix}make"
    947 		statusmsg "Created ${make}"
    948 	fi
    949 
    950 	# Build a ${toolprefix}make wrapper script, usable by hand as
    951 	# well as by build.sh.
    952 	#
    953 	if [ -z "${makewrapper}" ]; then
    954 		makewrapper="${TOOLDIR}/bin/${toolprefix}make-${makewrappermachine:-${MACHINE}}"
    955 		[ -z "${BUILDID}" ] || makewrapper="${makewrapper}-${BUILDID}"
    956 	fi
    957 
    958 	${runcmd} rm -f "${makewrapper}"
    959 	if [ "${runcmd}" = "echo" ]; then
    960 		echo 'cat <<EOF >'${makewrapper}
    961 		makewrapout=
    962 	else
    963 		makewrapout=">>\${makewrapper}"
    964 	fi
    965 
    966 	case "${KSH_VERSION:-${SH_VERSION}}" in
    967 	*PD\ KSH*|*MIRBSD\ KSH*)
    968 		set +o braceexpand
    969 		;;
    970 	esac
    971 
    972 	eval cat <<EOF ${makewrapout}
    973 #! ${HOST_SH}
    974 # Set proper variables to allow easy "make" building of a NetBSD subtree.
    975 # Generated from:  \$NetBSD: build.sh,v 1.153.2.2 2007/04/16 19:55:07 bouyer Exp $
    976 # with these arguments: ${_args}
    977 #
    978 EOF
    979 	for f in ${makeenv}; do
    980 		if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then
    981 			eval echo "unset ${f}" ${makewrapout}
    982 		else
    983 			eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}" ${makewrapout}
    984 		fi
    985 	done
    986 	eval echo "USETOOLS=yes\; export USETOOLS" ${makewrapout}
    987 
    988 	eval cat <<EOF ${makewrapout}
    989 
    990 exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"}
    991 EOF
    992 	[ "${runcmd}" = "echo" ] && echo EOF
    993 	${runcmd} chmod +x "${makewrapper}"
    994 	statusmsg "makewrapper:      ${makewrapper}"
    995 	statusmsg "Updated ${makewrapper}"
    996 }
    997 
    998 buildtools()
    999 {
   1000 	if [ "${MKOBJDIRS}" != "no" ]; then
   1001 		${runcmd} "${makewrapper}" ${parallel} obj-tools ||
   1002 		    bomb "Failed to make obj-tools"
   1003 	fi
   1004 	${runcmd} cd tools
   1005 	if [ "${MKUPDATE}" = "no" ]; then
   1006 		${runcmd} "${makewrapper}" ${parallel} cleandir ||
   1007 		    bomb "Failed to make cleandir tools"
   1008 	fi
   1009 	${runcmd} "${makewrapper}" ${parallel} dependall ||
   1010 	    bomb "Failed to make dependall tools"
   1011 	${runcmd} "${makewrapper}" ${parallel} install ||
   1012 	    bomb "Failed to make install tools"
   1013 	statusmsg "Tools built to ${TOOLDIR}"
   1014 	${runcmd} cd "${TOP}"
   1015 }
   1016 
   1017 getkernelconf()
   1018 {
   1019 	kernelconf="$1"
   1020 	if [ "${MKOBJDIRS}" != "no" ]; then
   1021 		# The correct value of KERNOBJDIR might
   1022 		# depend on a prior "make obj" in
   1023 		# ${KERNSRCDIR}/${KERNARCHDIR}/compile.
   1024 		#
   1025 		KERNSRCDIR="$(getmakevar KERNSRCDIR)"
   1026 		KERNARCHDIR="$(getmakevar KERNARCHDIR)"
   1027 		${runcmd} cd "${KERNSRCDIR}/${KERNARCHDIR}/compile"
   1028 		${runcmd} "${makewrapper}" ${parallel} obj ||
   1029 		    bomb "Failed to make obj in ${KERNSRCDIR}/${KERNARCHDIR}/compile"
   1030 		${runcmd} cd "${TOP}"
   1031 	fi
   1032 	KERNCONFDIR="$(getmakevar KERNCONFDIR)"
   1033 	KERNOBJDIR="$(getmakevar KERNOBJDIR)"
   1034 	case "${kernelconf}" in
   1035 	*/*)
   1036 		kernelconfpath="${kernelconf}"
   1037 		kernelconfname="${kernelconf##*/}"
   1038 		;;
   1039 	*)
   1040 		kernelconfpath="${KERNCONFDIR}/${kernelconf}"
   1041 		kernelconfname="${kernelconf}"
   1042 		;;
   1043 	esac
   1044 	kernelbuildpath="${KERNOBJDIR}/${kernelconfname}"
   1045 }
   1046 
   1047 buildkernel()
   1048 {
   1049 	if ! ${do_tools} && ! ${buildkernelwarned:-false}; then
   1050 		# Building tools every time we build a kernel is clearly
   1051 		# unnecessary.  We could try to figure out whether rebuilding
   1052 		# the tools is necessary this time, but it doesn't seem worth
   1053 		# the trouble.  Instead, we say it's the user's responsibility
   1054 		# to rebuild the tools if necessary.
   1055 		#
   1056 		statusmsg "Building kernel without building new tools"
   1057 		buildkernelwarned=true
   1058 	fi
   1059 	getkernelconf $1
   1060 	statusmsg "Building kernel:  ${kernelconf}"
   1061 	statusmsg "Build directory:  ${kernelbuildpath}"
   1062 	${runcmd} mkdir -p "${kernelbuildpath}" ||
   1063 	    bomb "Cannot mkdir: ${kernelbuildpath}"
   1064 	if [ "${MKUPDATE}" = "no" ]; then
   1065 		${runcmd} cd "${kernelbuildpath}"
   1066 		${runcmd} "${makewrapper}" ${parallel} cleandir ||
   1067 		    bomb "Failed to make cleandir in ${kernelbuildpath}"
   1068 		${runcmd} cd "${TOP}"
   1069 	fi
   1070 	${runcmd} "${TOOLDIR}/bin/${toolprefix}config" -b "${kernelbuildpath}" \
   1071 		-s "${TOP}/sys" "${kernelconfpath}" ||
   1072 	    bomb "${toolprefix}config failed for ${kernelconf}"
   1073 	${runcmd} cd "${kernelbuildpath}"
   1074 	${runcmd} "${makewrapper}" ${parallel} depend ||
   1075 	    bomb "Failed to make depend in ${kernelbuildpath}"
   1076 	${runcmd} "${makewrapper}" ${parallel} all ||
   1077 	    bomb "Failed to make all in ${kernelbuildpath}"
   1078 	${runcmd} cd "${TOP}"
   1079 
   1080 	if [ "${runcmd}" != "echo" ]; then
   1081 		statusmsg "Kernels built from ${kernelconf}:"
   1082 		kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
   1083 		for kern in ${kernlist:-netbsd}; do
   1084 			[ -f "${kernelbuildpath}/${kern}" ] && \
   1085 			    echo "  ${kernelbuildpath}/${kern}"
   1086 		done | tee -a "${results}"
   1087 	fi
   1088 }
   1089 
   1090 releasekernel()
   1091 {
   1092 	getkernelconf $1
   1093 	kernelreldir="${RELEASEDIR}/${MACHINE}/binary/kernel"
   1094 	${runcmd} mkdir -p "${kernelreldir}"
   1095 	kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
   1096 	for kern in ${kernlist:-netbsd}; do
   1097 		builtkern="${kernelbuildpath}/${kern}"
   1098 		[ -f "${builtkern}" ] || continue
   1099 		releasekern="${kernelreldir}/${kern}-${kernelconfname}.gz"
   1100 		statusmsg "Kernel copy:      ${releasekern}"
   1101 		${runcmd} gzip -c -9 < "${builtkern}" > "${releasekern}"
   1102 	done
   1103 }
   1104 
   1105 installworld()
   1106 {
   1107 	dir="$1"
   1108 	${runcmd} "${makewrapper}" INSTALLWORLDDIR="${dir}" installworld ||
   1109 	    bomb "Failed to make installworld to ${dir}"
   1110 	statusmsg "Successful installworld to ${dir}"
   1111 }
   1112 
   1113 
   1114 main()
   1115 {
   1116 	initdefaults
   1117 	_args=$@
   1118 	parseoptions "$@"
   1119 
   1120 	build_start=$(date)
   1121 	statusmsg "${progname} command: $0 $@"
   1122 	statusmsg "${progname} started: ${build_start}"
   1123 	statusmsg "NetBSD version:   ${DISTRIBVER}"
   1124 	statusmsg "MACHINE:          ${MACHINE}"
   1125 	statusmsg "MACHINE_ARCH:     ${MACHINE_ARCH}"
   1126 	statusmsg "Build platform:   ${uname_s} ${uname_r} ${uname_m}"
   1127 	statusmsg "HOST_SH:          ${HOST_SH}"
   1128 
   1129 	rebuildmake
   1130 	validatemakeparams
   1131 	createmakewrapper
   1132 
   1133 	# Perform the operations.
   1134 	#
   1135 	for op in ${operations}; do
   1136 		case "${op}" in
   1137 
   1138 		makewrapper)
   1139 			# no-op
   1140 			;;
   1141 
   1142 		tools)
   1143 			buildtools
   1144 			;;
   1145 
   1146 		sets)
   1147 			statusmsg "Building sets from pre-populated ${DESTDIR}"
   1148 			${runcmd} "${makewrapper}" ${parallel} ${op} ||
   1149 			    bomb "Failed to make ${op}"
   1150 			statusmsg "Successful make ${op}"
   1151 			;;
   1152 
   1153 		obj|build|distribution|iso-image|release|sourcesets|syspkgs|params)
   1154 			${runcmd} "${makewrapper}" ${parallel} ${op} ||
   1155 			    bomb "Failed to make ${op}"
   1156 			statusmsg "Successful make ${op}"
   1157 			;;
   1158 
   1159 		kernel=*)
   1160 			arg=${op#*=}
   1161 			buildkernel "${arg}"
   1162 			;;
   1163 
   1164 		releasekernel=*)
   1165 			arg=${op#*=}
   1166 			releasekernel "${arg}"
   1167 			;;
   1168 
   1169 		install=*)
   1170 			arg=${op#*=}
   1171 			if [ "${arg}" = "/" ] && \
   1172 			    (	[ "${uname_s}" != "NetBSD" ] || \
   1173 				[ "${uname_m}" != "${MACHINE}" ] ); then
   1174 				bomb "'${op}' must != / for cross builds."
   1175 			fi
   1176 			installworld "${arg}"
   1177 			;;
   1178 
   1179 		*)
   1180 			bomb "Unknown operation \`${op}'"
   1181 			;;
   1182 
   1183 		esac
   1184 	done
   1185 
   1186 	statusmsg "${progname} ended:   $(date)"
   1187 	if [ -s "${results}" ]; then
   1188 		echo "===> Summary of results:"
   1189 		sed -e 's/^===>//;s/^/	/' "${results}"
   1190 		echo "===> ."
   1191 	fi
   1192 }
   1193 
   1194 main "$@"
   1195