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