Annotation of src/build.sh, Revision 1.224
1.67 thorpej 1: #! /usr/bin/env sh
1.224 ! matt 2: # $NetBSD: build.sh,v 1.198.2.3.4.2 2009/09/09 04:46:10 matt Exp $
1.84 lukem 3: #
1.203 lukem 4: # Copyright (c) 2001-2009 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: #
19: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22: # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29: # POSSIBILITY OF SUCH DAMAGE.
30: #
1.1 tv 31: #
32: # Top level build wrapper, for a system containing no tools.
33: #
1.153 apb 34: # This script should run on any POSIX-compliant shell. If the
35: # first "sh" found in the PATH is a POSIX-compliant shell, then
36: # you should not need to take any special action. Otherwise, you
37: # should set the environment variable HOST_SH to a POSIX-compliant
38: # shell, and invoke build.sh with that shell. (Depending on your
39: # system, one of /bin/ksh, /usr/local/bin/bash, or /usr/xpg4/bin/sh
40: # might be a suitable shell.)
1.67 thorpej 41: #
1.1 tv 42:
1.84 lukem 43: progname=${0##*/}
44: toppid=$$
1.98 lukem 45: results=/dev/null
1.200 apb 46: tab=' '
1.82 lukem 47: trap "exit 1" 1 2 3 15
1.84 lukem 48:
1.79 lukem 49: bomb()
50: {
1.82 lukem 51: cat >&2 <<ERRORMESSAGE
52:
53: ERROR: $@
54: *** BUILD ABORTED ***
55: ERRORMESSAGE
1.98 lukem 56: kill ${toppid} # in case we were invoked from a subshell
1.1 tv 57: exit 1
58: }
1.78 lukem 59:
1.84 lukem 60:
1.98 lukem 61: statusmsg()
62: {
63: ${runcmd} echo "===> $@" | tee -a "${results}"
64: }
65:
1.163 apb 66: warning()
67: {
68: statusmsg "Warning: $@"
69: }
70:
1.168 apb 71: # Find a program in the PATH, and print the result. If not found,
72: # print a default. If $2 is defined (even if it is an empty string),
73: # then that is the default; otherwise, $1 is used as the default.
1.153 apb 74: find_in_PATH()
75: {
76: local prog="$1"
1.168 apb 77: local result="${2-"$1"}"
1.153 apb 78: local oldIFS="${IFS}"
79: local dir
80: IFS=":"
81: for dir in ${PATH}; do
82: if [ -x "${dir}/${prog}" ]; then
1.168 apb 83: result="${dir}/${prog}"
1.153 apb 84: break
85: fi
86: done
87: IFS="${oldIFS}"
1.168 apb 88: echo "${result}"
1.153 apb 89: }
90:
91: # Try to find a working POSIX shell, and set HOST_SH to refer to it.
92: # Assumes that uname_s, uname_m, and PWD have been set.
93: set_HOST_SH()
94: {
95: # Even if ${HOST_SH} is already defined, we still do the
96: # sanity checks at the end.
97:
98: # Solaris has /usr/xpg4/bin/sh.
99: #
100: [ -z "${HOST_SH}" ] && [ x"${uname_s}" = x"SunOS" ] && \
101: [ -x /usr/xpg4/bin/sh ] && HOST_SH="/usr/xpg4/bin/sh"
102:
103: # Try to get the name of the shell that's running this script,
104: # by parsing the output from "ps". We assume that, if the host
105: # system's ps command supports -o comm at all, it will do so
106: # in the usual way: a one-line header followed by a one-line
107: # result, possibly including trailing white space. And if the
108: # host system's ps command doesn't support -o comm, we assume
109: # that we'll get an error message on stderr and nothing on
110: # stdout. (We don't try to use ps -o 'comm=' to suppress the
111: # header line, because that is less widely supported.)
112: #
113: # If we get the wrong result here, the user can override it by
114: # specifying HOST_SH in the environment.
115: #
116: [ -z "${HOST_SH}" ] && HOST_SH="$(
1.200 apb 117: (ps -p $$ -o comm | sed -ne "2s/[ ${tab}]*\$//p") 2>/dev/null )"
1.153 apb 118:
119: # If nothing above worked, use "sh". We will later find the
120: # first directory in the PATH that has a "sh" program.
121: #
122: [ -z "${HOST_SH}" ] && HOST_SH="sh"
123:
124: # If the result so far is not an absolute path, try to prepend
125: # PWD or search the PATH.
126: #
127: case "${HOST_SH}" in
128: /*) :
129: ;;
130: */*) HOST_SH="${PWD}/${HOST_SH}"
131: ;;
132: *) HOST_SH="$(find_in_PATH "${HOST_SH}")"
133: ;;
134: esac
135:
136: # If we don't have an absolute path by now, bomb.
137: #
138: case "${HOST_SH}" in
139: /*) :
140: ;;
141: *) bomb "HOST_SH=\"${HOST_SH}\" is not an absolute path."
142: ;;
143: esac
144:
145: # If HOST_SH is not executable, bomb.
146: #
147: [ -x "${HOST_SH}" ] ||
148: bomb "HOST_SH=\"${HOST_SH}\" is not executable."
149: }
150:
1.84 lukem 151: initdefaults()
152: {
1.171 apb 153: makeenv=
154: makewrapper=
155: makewrappermachine=
156: runcmd=
157: operations=
158: removedirs=
159:
1.156 dsl 160: [ -d usr.bin/make ] || cd "$(dirname $0)"
1.84 lukem 161: [ -d usr.bin/make ] ||
162: bomb "build.sh must be run from the top source level"
163: [ -f share/mk/bsd.own.mk ] ||
164: bomb "src/share/mk is missing; please re-fetch the source tree"
165:
1.218 apb 166: # Set LC_ALL=C before we try to parse the output from any command
167: setmakeenv LC_ALL C
168:
1.204 apb 169: # Find information about the build platform. This should be
170: # kept in sync with _HOST_OSNAME, _HOST_OSREL, and _HOST_ARCH
171: # variables in share/mk/bsd.sys.mk.
172: #
173: # Note that "uname -p" is not part of POSIX, but we want uname_p
174: # to be set to the host MACHINE_ARCH, if possible. On systems
175: # where "uname -p" fails, prints "unknown", or prints a string
176: # that does not look like an identifier, fall back to using the
177: # output from "uname -m" instead.
1.165 apb 178: #
1.84 lukem 179: uname_s=$(uname -s 2>/dev/null)
1.165 apb 180: uname_r=$(uname -r 2>/dev/null)
1.84 lukem 181: uname_m=$(uname -m 2>/dev/null)
1.204 apb 182: uname_p=$(uname -p 2>/dev/null || echo "unknown")
183: case "${uname_p}" in
1.205 apb 184: ''|unknown|*[^-_A-Za-z0-9]*) uname_p="${uname_m}" ;;
1.204 apb 185: esac
1.84 lukem 186:
1.202 sketch 187: id_u=$(id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null)
188:
1.84 lukem 189: # If $PWD is a valid name of the current directory, POSIX mandates
190: # that pwd return it by default which causes problems in the
191: # presence of symlinks. Unsetting PWD is simpler than changing
192: # every occurrence of pwd to use -P.
193: #
1.147 dogcow 194: # XXX Except that doesn't work on Solaris. Or many Linuces.
1.98 lukem 195: #
1.84 lukem 196: unset PWD
1.147 dogcow 197: TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)
1.84 lukem 198:
1.153 apb 199: # The user can set HOST_SH in the environment, or we try to
200: # guess an appropriate value. Then we set several other
201: # variables from HOST_SH.
202: #
203: set_HOST_SH
204: setmakeenv HOST_SH "${HOST_SH}"
205: setmakeenv BSHELL "${HOST_SH}"
206: setmakeenv CONFIG_SHELL "${HOST_SH}"
207:
1.84 lukem 208: # Set defaults.
1.98 lukem 209: #
1.84 lukem 210: toolprefix=nb
1.98 lukem 211:
1.95 thorpej 212: # Some systems have a small ARG_MAX. -X prevents make(1) from
213: # exporting variables in the environment redundantly.
1.98 lukem 214: #
1.95 thorpej 215: case "${uname_s}" in
1.97 christos 216: Darwin | FreeBSD | CYGWIN*)
1.95 thorpej 217: MAKEFLAGS=-X
218: ;;
219: *)
220: MAKEFLAGS=
221: ;;
222: esac
1.98 lukem 223:
1.171 apb 224: # do_{operation}=true if given operation is requested.
225: #
1.84 lukem 226: do_expertmode=false
227: do_rebuildmake=false
228: do_removedirs=false
229: do_tools=false
1.195 lukem 230: do_cleandir=false
1.84 lukem 231: do_obj=false
232: do_build=false
233: do_distribution=false
234: do_release=false
235: do_kernel=false
1.105 lukem 236: do_releasekernel=false
1.207 jnemeth 237: do_modules=false
1.84 lukem 238: do_install=false
1.87 lukem 239: do_sets=false
1.100 lukem 240: do_sourcesets=false
1.142 apb 241: do_syspkgs=false
1.146 apb 242: do_iso_image=false
1.172 jnemeth 243: do_iso_image_source=false
1.107 lukem 244: do_params=false
1.219 pooka 245: do_rump=false
1.98 lukem 246:
1.211 apb 247: # done_{operation}=true if given operation has been done.
248: #
249: done_rebuildmake=false
250:
1.98 lukem 251: # Create scratch directory
252: #
253: tmpdir="${TMPDIR-/tmp}/nbbuild$$"
254: mkdir "${tmpdir}" || bomb "Cannot mkdir: ${tmpdir}"
255: trap "cd /; rm -r -f \"${tmpdir}\"" 0
256: results="${tmpdir}/build.sh.results"
1.116 jmmv 257:
258: # Set source directories
259: #
260: setmakeenv NETBSDSRCDIR "${TOP}"
1.136 lukem 261:
1.165 apb 262: # Find the version of NetBSD
263: #
264: DISTRIBVER="$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh)"
265:
1.190 perry 266: # Set the BUILDSEED to NetBSD-"N"
267: #
268: setmakeenv BUILDSEED "NetBSD-$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh -m)"
269:
1.206 perry 270: # Set MKARZERO to "yes"
271: #
272: setmakeenv MKARZERO "yes"
273:
1.136 lukem 274: # Set various environment variables to known defaults,
275: # to minimize (cross-)build problems observed "in the field".
276: #
277: unsetmakeenv INFODIR
1.140 jmc 278: unsetmakeenv LESSCHARSET
1.84 lukem 279: }
1.29 jmc 280:
1.79 lukem 281: getarch()
282: {
1.158 apb 283: # Translate some MACHINE name aliases (known only to build.sh)
284: # into proper MACHINE and MACHINE_ARCH names. Save the alias
285: # name in makewrappermachine.
286: #
287: case "${MACHINE}" in
288:
289: evbarm-e[bl])
290: makewrappermachine=${MACHINE}
291: # MACHINE_ARCH is "arm" or "armeb", not "armel"
292: MACHINE_ARCH=arm${MACHINE##*-}
293: MACHINE_ARCH=${MACHINE_ARCH%el}
294: MACHINE=${MACHINE%-e[bl]}
295: ;;
296:
297: evbmips-e[bl]|sbmips-e[bl])
298: makewrappermachine=${MACHINE}
299: MACHINE_ARCH=mips${MACHINE##*-}
300: MACHINE=${MACHINE%-e[bl]}
301: ;;
302:
303: evbmips64-e[bl]|sbmips64-e[bl])
304: makewrappermachine=${MACHINE}
305: MACHINE_ARCH=mips64${MACHINE##*-}
306: MACHINE=${MACHINE%64-e[bl]}
307: ;;
308:
309: evbsh3-e[bl])
310: makewrappermachine=${MACHINE}
311: MACHINE_ARCH=sh3${MACHINE##*-}
312: MACHINE=${MACHINE%-e[bl]}
313: ;;
314:
315: esac
316:
1.1 tv 317: # Translate a MACHINE into a default MACHINE_ARCH.
1.84 lukem 318: #
1.98 lukem 319: case "${MACHINE}" in
1.1 tv 320:
1.162 briggs 321: acorn26|acorn32|cats|hpcarm|iyonix|netwinder|shark|zaurus)
1.84 lukem 322: MACHINE_ARCH=arm
323: ;;
324:
1.162 briggs 325: evbarm) # unspecified MACHINE_ARCH gets LE
326: MACHINE_ARCH=${MACHINE_ARCH:=arm}
327: ;;
328:
1.98 lukem 329: hp700)
330: MACHINE_ARCH=hppa
331: ;;
332:
1.84 lukem 333: sun2)
334: MACHINE_ARCH=m68000
335: ;;
336:
1.98 lukem 337: amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k)
1.84 lukem 338: MACHINE_ARCH=m68k
339: ;;
1.1 tv 340:
1.101 lukem 341: evbmips|sbmips) # no default MACHINE_ARCH
342: ;;
343:
1.224 ! matt 344: sgimips64)
! 345: makewrappermachine=${MACHINE}
! 346: MACHINE=${MACHINE%64}
! 347: MACHINE_ARCH=mips64eb
! 348: ;;
! 349:
1.141 tsutsui 350: ews4800mips|mipsco|newsmips|sgimips)
1.84 lukem 351: MACHINE_ARCH=mipseb
352: ;;
1.1 tv 353:
1.224 ! matt 354: algor64|pmax64)
! 355: makewrappermachine=${MACHINE}
! 356: MACHINE=${MACHINE%64}
! 357: MACHINE_ARCH=mips64el
! 358: ;;
! 359:
1.223 pooka 360: algor|arc|cobalt|hpcmips|pmax)
1.84 lukem 361: MACHINE_ARCH=mipsel
362: ;;
1.1 tv 363:
1.183 jmmv 364: evbppc64|macppc64|ofppc64)
1.160 matt 365: makewrappermachine=${MACHINE}
366: MACHINE=${MACHINE%64}
367: MACHINE_ARCH=powerpc64
368: ;;
369:
1.181 garbled 370: amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|prep|rs6000|sandpoint)
1.84 lukem 371: MACHINE_ARCH=powerpc
372: ;;
1.1 tv 373:
1.103 lukem 374: evbsh3) # no default MACHINE_ARCH
375: ;;
376:
377: mmeye)
1.84 lukem 378: MACHINE_ARCH=sh3eb
379: ;;
1.1 tv 380:
1.152 uwe 381: dreamcast|hpcsh|landisk)
1.84 lukem 382: MACHINE_ARCH=sh3el
383: ;;
1.1 tv 384:
1.96 fvdl 385: amd64)
386: MACHINE_ARCH=x86_64
387: ;;
1.62 fredette 388:
1.138 skrll 389: alpha|i386|sparc|sparc64|vax|ia64)
1.98 lukem 390: MACHINE_ARCH=${MACHINE}
1.84 lukem 391: ;;
1.69 thorpej 392:
1.84 lukem 393: *)
1.98 lukem 394: bomb "Unknown target MACHINE: ${MACHINE}"
1.84 lukem 395: ;;
1.4 tv 396:
1.1 tv 397: esac
398: }
399:
1.79 lukem 400: validatearch()
401: {
1.47 tv 402: # Ensure that the MACHINE_ARCH exists (and is supported by build.sh).
1.84 lukem 403: #
1.98 lukem 404: case "${MACHINE_ARCH}" in
1.47 tv 405:
1.184 matt 406: alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|powerpc|powerpc64|sh3e[bl]|sparc|sparc64|vax|x86_64|ia64)
1.84 lukem 407: ;;
408:
1.101 lukem 409: "")
410: bomb "No MACHINE_ARCH provided"
411: ;;
412:
1.84 lukem 413: *)
1.98 lukem 414: bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
415: ;;
416:
417: esac
418:
419: # Determine valid MACHINE_ARCHs for MACHINE
420: #
421: case "${MACHINE}" in
422:
423: evbarm)
424: arches="arm armeb"
425: ;;
426:
1.224 ! matt 427: algor|pmax)
! 428: arches="mipsel mips64el"
! 429: ;;
! 430:
1.98 lukem 431: evbmips|sbmips)
1.150 matt 432: arches="mipseb mipsel mips64eb mips64el"
433: ;;
434:
435: sgimips)
436: arches="mipseb mips64eb"
1.98 lukem 437: ;;
438:
439: evbsh3)
440: arches="sh3eb sh3el"
441: ;;
442:
1.183 jmmv 443: macppc|evbppc|ofppc)
1.148 mrg 444: arches="powerpc powerpc64"
445: ;;
1.98 lukem 446: *)
447: oma="${MACHINE_ARCH}"
448: getarch
449: arches="${MACHINE_ARCH}"
450: MACHINE_ARCH="${oma}"
1.84 lukem 451: ;;
452:
1.47 tv 453: esac
1.98 lukem 454:
455: # Ensure that MACHINE_ARCH supports MACHINE
456: #
457: archok=false
458: for a in ${arches}; do
459: if [ "${a}" = "${MACHINE_ARCH}" ]; then
460: archok=true
461: break
462: fi
463: done
464: ${archok} ||
465: bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
1.47 tv 466: }
467:
1.210 apb 468: # nobomb_getmakevar --
469: # Given the name of a make variable in $1, print make's idea of the
470: # value of that variable, or return 1 if there's an error.
471: #
1.168 apb 472: nobomb_getmakevar()
1.79 lukem 473: {
1.168 apb 474: [ -x "${make}" ] || return 1
475: "${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<EOF || return 1
1.15 tv 476: _x_:
477: echo \${$1}
478: .include <bsd.prog.mk>
1.70 lukem 479: .include <bsd.kernobj.mk>
1.15 tv 480: EOF
481: }
482:
1.210 apb 483: # nobomb_getmakevar --
484: # Given the name of a make variable in $1, print make's idea of the
485: # value of that variable, or bomb if there's an error.
486: #
487: bomb_getmakevar()
1.168 apb 488: {
1.210 apb 489: [ -x "${make}" ] || bomb "bomb_getmakevar $1: ${make} is not executable"
490: nobomb_getmakevar "$1" || bomb "bomb_getmakevar $1: ${make} failed"
1.168 apb 491: }
492:
1.210 apb 493: # nobomb_getmakevar --
494: # Given the name of a make variable in $1, print make's idea of the
495: # value of that variable, or print a literal '$' followed by the
496: # variable name if ${make} is not executable. This is intended for use in
497: # messages that need to be readable even if $make hasn't been built,
498: # such as when build.sh is run with the "-n" option.
499: #
1.98 lukem 500: getmakevar()
1.82 lukem 501: {
1.98 lukem 502: if [ -x "${make}" ]; then
1.210 apb 503: bomb_getmakevar "$1"
1.82 lukem 504: else
505: echo "\$$1"
506: fi
507: }
508:
1.109 lukem 509: setmakeenv()
510: {
511: eval "$1='$2'; export $1"
512: makeenv="${makeenv} $1"
513: }
514:
1.111 lukem 515: unsetmakeenv()
516: {
517: eval "unset $1"
518: makeenv="${makeenv} $1"
519: }
520:
1.208 apb 521: # Given a variable name in $1, modify the variable in place as follows:
522: # For each space-separated word in the variable, call resolvepath.
1.189 dyoung 523: resolvepaths()
524: {
1.208 apb 525: local var="$1"
526: local val
527: eval val=\"\${${var}}\"
528: local newval=''
529: local word
530: for word in ${val}; do
531: resolvepath word
532: newval="${newval}${newval:+ }${word}"
1.189 dyoung 533: done
1.208 apb 534: eval ${var}=\"\${newval}\"
1.189 dyoung 535: }
536:
1.208 apb 537: # Given a variable name in $1, modify the variable in place as follows:
1.131 junyoung 538: # Convert possibly-relative path to absolute path by prepending
539: # ${TOP} if necessary. Also delete trailing "/", if any.
1.79 lukem 540: resolvepath()
541: {
1.208 apb 542: local var="$1"
543: local val
544: eval val=\"\${${var}}\"
545: case "${val}" in
1.131 junyoung 546: /)
547: ;;
1.84 lukem 548: /*)
1.208 apb 549: val="${val%/}"
1.84 lukem 550: ;;
551: *)
1.208 apb 552: val="${TOP}/${val%/}"
1.84 lukem 553: ;;
1.10 tv 554: esac
1.208 apb 555: eval ${var}=\"\${val}\"
1.10 tv 556: }
557:
1.79 lukem 558: usage()
559: {
1.84 lukem 560: if [ -n "$*" ]; then
561: echo ""
562: echo "${progname}: $*"
563: fi
1.70 lukem 564: cat <<_usage_
1.83 lukem 565:
1.190 perry 566: Usage: ${progname} [-EnorUux] [-a arch] [-B buildid] [-C cdextras]
1.195 lukem 567: [-D dest] [-j njob] [-M obj] [-m mach] [-N noisy]
568: [-O obj] [-R release] [-S seed] [-T tools]
1.222 uebayasi 569: [-V var=[value]] [-w wrapper] [-X x11src] [-Y extsrcsrc]
570: [-Z var]
1.195 lukem 571: operation [...]
1.84 lukem 572:
1.86 lukem 573: Build operations (all imply "obj" and "tools"):
1.125 lukem 574: build Run "make build".
575: distribution Run "make distribution" (includes DESTDIR/etc/ files).
576: release Run "make release" (includes kernels & distrib media).
1.84 lukem 577:
578: Other operations:
1.125 lukem 579: help Show this message and exit.
1.98 lukem 580: makewrapper Create ${toolprefix}make-\${MACHINE} wrapper and ${toolprefix}make.
1.125 lukem 581: Always performed.
1.195 lukem 582: cleandir Run "make cleandir". [Default unless -u is used]
1.125 lukem 583: obj Run "make obj". [Default unless -o is used]
584: tools Build and install tools.
585: install=idir Run "make installworld" to \`idir' to install all sets
1.195 lukem 586: except \`etc'. Useful after "distribution" or "release"
1.105 lukem 587: kernel=conf Build kernel with config file \`conf'
1.125 lukem 588: releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
1.207 jnemeth 589: modules Build and install kernel modules.
1.219 pooka 590: rumptest Do a linktest for rump (for developers).
1.186 lukem 591: sets Create binary sets in
1.195 lukem 592: RELEASEDIR/RELEASEMACHINEDIR/binary/sets.
593: DESTDIR should be populated beforehand.
1.125 lukem 594: sourcesets Create source sets in RELEASEDIR/source/sets.
1.186 lukem 595: syspkgs Create syspkgs in
1.195 lukem 596: RELEASEDIR/RELEASEMACHINEDIR/binary/syspkgs.
1.172 jnemeth 597: iso-image Create CD-ROM image in RELEASEDIR/iso.
598: iso-image-source Create CD-ROM image with source in RELEASEDIR/iso.
1.125 lukem 599: params Display various make(1) parameters.
1.84 lukem 600:
601: Options:
1.125 lukem 602: -a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE]
603: -B buildId Set BUILDID to buildId.
1.209 apb 604: -C cdextras Append cdextras to CDEXTRA variable for inclusion on CD-ROM.
1.119 lukem 605: -D dest Set DESTDIR to dest. [Default: destdir.MACHINE]
1.98 lukem 606: -E Set "expert" mode; disables various safety checks.
1.127 lukem 607: Should not be used without expert knowledge of the build system.
1.129 wiz 608: -h Print this help message.
1.125 lukem 609: -j njob Run up to njob jobs in parallel; see make(1) -j.
610: -M obj Set obj root directory to obj; sets MAKEOBJDIRPREFIX.
1.111 lukem 611: Unsets MAKEOBJDIR.
1.125 lukem 612: -m mach Set MACHINE to mach; not required if NetBSD native.
1.195 lukem 613: -N noisy Set the noisyness (MAKEVERBOSE) level of the build:
1.199 apb 614: 0 Minimal output ("quiet")
615: 1 Describe what is occurring
616: 2 Describe what is occurring and echo the actual command
617: 3 Ignore the effect of the "@" prefix in make commands
618: 4 Trace shell commands using the shell's -x flag
1.195 lukem 619: [Default: 2]
1.125 lukem 620: -n Show commands that would be executed, but do not execute them.
621: -O obj Set obj root directory to obj; sets a MAKEOBJDIR pattern.
1.111 lukem 622: Unsets MAKEOBJDIRPREFIX.
1.125 lukem 623: -o Set MKOBJDIRS=no; do not create objdirs at start of build.
1.119 lukem 624: -R release Set RELEASEDIR to release. [Default: releasedir]
1.125 lukem 625: -r Remove contents of TOOLDIR and DESTDIR before building.
1.190 perry 626: -S seed Set BUILDSEED to seed. [Default: NetBSD-majorversion]
1.98 lukem 627: -T tools Set TOOLDIR to tools. If unset, and TOOLDIR is not set in
1.125 lukem 628: the environment, ${toolprefix}make will be (re)built unconditionally.
629: -U Set MKUNPRIVED=yes; build without requiring root privileges,
1.195 lukem 630: install from an UNPRIVED build with proper file permissions.
1.187 dholland 631: -u Set MKUPDATE=yes; do not run "make cleandir" first.
1.195 lukem 632: Without this, everything is rebuilt, including the tools.
1.125 lukem 633: -V v=[val] Set variable \`v' to \`val'.
634: -w wrapper Create ${toolprefix}make script as wrapper.
1.119 lukem 635: [Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}]
1.127 lukem 636: -X x11src Set X11SRCDIR to x11src. [Default: /usr/xsrc]
1.201 plunky 637: -x Set MKX11=yes; build X11 from X11SRCDIR
1.222 uebayasi 638: -Y extsrcsrc
639: Set EXTSRCSRCDIR to extsrcsrc. [Default: /usr/extsrc]
640: -y Set MKEXTSRC=yes; build extsrc from EXTSRCSRCDIR
1.125 lukem 641: -Z v Unset ("zap") variable \`v'.
1.83 lukem 642:
1.70 lukem 643: _usage_
1.1 tv 644: exit 1
645: }
646:
1.84 lukem 647: parseoptions()
648: {
1.222 uebayasi 649: opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:xX:yY:Z:'
1.84 lukem 650: opt_a=no
651:
652: if type getopts >/dev/null 2>&1; then
653: # Use POSIX getopts.
1.98 lukem 654: #
655: getoptcmd='getopts ${opts} opt && opt=-${opt}'
1.84 lukem 656: optargcmd=':'
1.98 lukem 657: optremcmd='shift $((${OPTIND} -1))'
1.84 lukem 658: else
659: type getopt >/dev/null 2>&1 ||
660: bomb "/bin/sh shell is too old; try ksh or bash"
661:
662: # Use old-style getopt(1) (doesn't handle whitespace in args).
1.98 lukem 663: #
664: args="$(getopt ${opts} $*)"
1.84 lukem 665: [ $? = 0 ] || usage
1.98 lukem 666: set -- ${args}
1.84 lukem 667:
668: getoptcmd='[ $# -gt 0 ] && opt="$1" && shift'
669: optargcmd='OPTARG="$1"; shift'
670: optremcmd=':'
671: fi
672:
673: # Parse command line options.
674: #
1.98 lukem 675: while eval ${getoptcmd}; do
676: case ${opt} in
1.84 lukem 677:
678: -a)
1.98 lukem 679: eval ${optargcmd}
680: MACHINE_ARCH=${OPTARG}
1.84 lukem 681: opt_a=yes
682: ;;
683:
684: -B)
1.98 lukem 685: eval ${optargcmd}
686: BUILDID=${OPTARG}
1.84 lukem 687: ;;
688:
1.174 jnemeth 689: -C)
1.208 apb 690: eval ${optargcmd}; resolvepaths OPTARG
1.209 apb 691: CDEXTRA="${CDEXTRA}${CDEXTRA:+ }${OPTARG}"
1.174 jnemeth 692: ;;
693:
1.84 lukem 694: -D)
1.208 apb 695: eval ${optargcmd}; resolvepath OPTARG
1.109 lukem 696: setmakeenv DESTDIR "${OPTARG}"
1.84 lukem 697: ;;
698:
699: -E)
700: do_expertmode=true
701: ;;
702:
703: -j)
1.98 lukem 704: eval ${optargcmd}
705: parallel="-j ${OPTARG}"
1.84 lukem 706: ;;
707:
708: -M)
1.208 apb 709: eval ${optargcmd}; resolvepath OPTARG
1.212 apb 710: case "${OPTARG}" in
711: \$*) usage "-M argument must not begin with '$'"
712: ;;
713: *\$*) # can use resolvepath, but can't set TOP_objdir
714: resolvepath OPTARG
715: ;;
716: *) resolvepath OPTARG
717: TOP_objdir="${OPTARG}${TOP}"
718: ;;
719: esac
1.111 lukem 720: unsetmakeenv MAKEOBJDIR
1.109 lukem 721: setmakeenv MAKEOBJDIRPREFIX "${OPTARG}"
1.84 lukem 722: ;;
723:
724: # -m overrides MACHINE_ARCH unless "-a" is specified
725: -m)
1.98 lukem 726: eval ${optargcmd}
727: MACHINE="${OPTARG}"
728: [ "${opt_a}" != "yes" ] && getarch
1.84 lukem 729: ;;
730:
1.119 lukem 731: -N)
732: eval ${optargcmd}
733: case "${OPTARG}" in
1.199 apb 734: 0|1|2|3|4)
1.121 lukem 735: setmakeenv MAKEVERBOSE "${OPTARG}"
1.119 lukem 736: ;;
737: *)
738: usage "'${OPTARG}' is not a valid value for -N"
739: ;;
740: esac
741: ;;
742:
1.84 lukem 743: -n)
744: runcmd=echo
745: ;;
746:
747: -O)
1.212 apb 748: eval ${optargcmd}
749: case "${OPTARG}" in
750: *\$*) usage "-O argument must not contain '$'"
751: ;;
752: *) resolvepath OPTARG
753: TOP_objdir="${OPTARG}"
754: ;;
755: esac
1.111 lukem 756: unsetmakeenv MAKEOBJDIRPREFIX
1.109 lukem 757: setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
1.84 lukem 758: ;;
759:
760: -o)
761: MKOBJDIRS=no
762: ;;
763:
764: -R)
1.208 apb 765: eval ${optargcmd}; resolvepath OPTARG
1.109 lukem 766: setmakeenv RELEASEDIR "${OPTARG}"
1.84 lukem 767: ;;
768:
769: -r)
770: do_removedirs=true
771: do_rebuildmake=true
772: ;;
773:
1.190 perry 774: -S)
775: eval ${optargcmd}
776: setmakeenv BUILDSEED "${OPTARG}"
777: ;;
778:
1.84 lukem 779: -T)
1.208 apb 780: eval ${optargcmd}; resolvepath OPTARG
1.98 lukem 781: TOOLDIR="${OPTARG}"
1.84 lukem 782: export TOOLDIR
783: ;;
784:
785: -U)
1.109 lukem 786: setmakeenv MKUNPRIVED yes
1.84 lukem 787: ;;
1.44 lukem 788:
1.84 lukem 789: -u)
1.109 lukem 790: setmakeenv MKUPDATE yes
1.84 lukem 791: ;;
1.15 tv 792:
1.84 lukem 793: -V)
1.98 lukem 794: eval ${optargcmd}
1.84 lukem 795: case "${OPTARG}" in
1.80 lukem 796: # XXX: consider restricting which variables can be changed?
1.84 lukem 797: [a-zA-Z_][a-zA-Z_0-9]*=*)
1.109 lukem 798: setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}"
1.84 lukem 799: ;;
800: *)
801: usage "-V argument must be of the form 'var=[value]'"
802: ;;
803: esac
804: ;;
805:
806: -w)
1.208 apb 807: eval ${optargcmd}; resolvepath OPTARG
1.98 lukem 808: makewrapper="${OPTARG}"
1.84 lukem 809: ;;
810:
1.127 lukem 811: -X)
1.208 apb 812: eval ${optargcmd}; resolvepath OPTARG
1.127 lukem 813: setmakeenv X11SRCDIR "${OPTARG}"
814: ;;
815:
816: -x)
817: setmakeenv MKX11 yes
818: ;;
819:
1.222 uebayasi 820: -Y)
821: eval ${optargcmd}; resolvepath OPTARG
822: setmakeenv EXTSRCSRCDIR "${OPTARG}"
823: ;;
824:
825: -y)
826: setmakeenv MKEXTSRC yes
827: ;;
828:
1.111 lukem 829: -Z)
830: eval ${optargcmd}
831: # XXX: consider restricting which variables can be unset?
832: unsetmakeenv "${OPTARG}"
833: ;;
834:
1.84 lukem 835: --)
836: break
837: ;;
838:
839: -'?'|-h)
840: usage
841: ;;
842:
843: esac
844: done
845:
846: # Validate operations.
847: #
1.98 lukem 848: eval ${optremcmd}
1.84 lukem 849: while [ $# -gt 0 ]; do
850: op=$1; shift
1.98 lukem 851: operations="${operations} ${op}"
1.84 lukem 852:
1.98 lukem 853: case "${op}" in
1.84 lukem 854:
1.87 lukem 855: help)
856: usage
857: ;;
858:
1.195 lukem 859: makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params)
1.80 lukem 860: ;;
1.84 lukem 861:
1.146 apb 862: iso-image)
863: op=iso_image # used as part of a variable name
864: ;;
865:
1.172 jnemeth 866: iso-image-source)
867: op=iso_image_source # used as part of a variable name
868: ;;
869:
1.105 lukem 870: kernel=*|releasekernel=*)
1.84 lukem 871: arg=${op#*=}
872: op=${op%%=*}
1.98 lukem 873: [ -n "${arg}" ] ||
1.105 lukem 874: bomb "Must supply a kernel name with \`${op}=...'"
1.84 lukem 875: ;;
876:
1.207 jnemeth 877: modules)
878: op=modules
879: ;;
880:
1.84 lukem 881: install=*)
882: arg=${op#*=}
883: op=${op%%=*}
1.98 lukem 884: [ -n "${arg}" ] ||
885: bomb "Must supply a directory with \`install=...'"
1.84 lukem 886: ;;
887:
1.219 pooka 888: rump|rumptest)
889: op=${op}
890: ;;
891:
1.80 lukem 892: *)
1.84 lukem 893: usage "Unknown operation \`${op}'"
894: ;;
895:
1.80 lukem 896: esac
1.98 lukem 897: eval do_${op}=true
1.84 lukem 898: done
1.98 lukem 899: [ -n "${operations}" ] || usage "Missing operation to perform."
1.84 lukem 900:
901: # Set up MACHINE*. On a NetBSD host, these are allowed to be unset.
902: #
1.98 lukem 903: if [ -z "${MACHINE}" ]; then
904: [ "${uname_s}" = "NetBSD" ] ||
905: bomb "MACHINE must be set, or -m must be used, for cross builds."
1.84 lukem 906: MACHINE=${uname_m}
907: fi
1.98 lukem 908: [ -n "${MACHINE_ARCH}" ] || getarch
1.84 lukem 909: validatearch
910:
911: # Set up default make(1) environment.
912: #
1.98 lukem 913: makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
914: [ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
1.115 jmmv 915: MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
1.84 lukem 916: export MAKEFLAGS MACHINE MACHINE_ARCH
917: }
918:
1.163 apb 919: sanitycheck()
920: {
921: # If the PATH contains any non-absolute components (including,
1.170 apb 922: # but not limited to, "." or ""), then complain. As an exception,
923: # allow "" or "." as the last component of the PATH. This is fatal
1.163 apb 924: # if expert mode is not in effect.
925: #
1.170 apb 926: local path="${PATH}"
927: path="${path%:}" # delete trailing ":"
928: path="${path%:.}" # delete trailing ":."
929: case ":${path}:/" in
930: *:[!/]*)
1.163 apb 931: if ${do_expertmode}; then
932: warning "PATH contains non-absolute components"
933: else
1.164 apb 934: bomb "PATH environment variable must not" \
935: "contain non-absolute components"
1.163 apb 936: fi
937: ;;
938: esac
939: }
940:
1.213 apb 941: # print_tooldir_make --
942: # Try to find and print a path to an existing
943: # ${TOOLDIR}/bin/${toolprefix}make, for use by rebuildmake() before a
944: # new version of ${toolprefix}make has been built.
1.168 apb 945: #
946: # * If TOOLDIR was set in the environment or on the command line, use
947: # that value.
948: # * Otherwise try to guess what TOOLDIR would be if not overridden by
949: # /etc/mk.conf, and check whether the resulting directory contains
950: # a copy of ${toolprefix}make (this should work for everybody who
951: # doesn't override TOOLDIR via /etc/mk.conf);
952: # * Failing that, search for ${toolprefix}make, nbmake, bmake, or make,
953: # in the PATH (this might accidentally find a non-NetBSD version of
954: # make, which will lead to failure in the next step);
955: # * If a copy of make was found above, try to use it with
1.213 apb 956: # nobomb_getmakevar to find the correct value for TOOLDIR, and believe the
957: # result only if it's a directory that already exists;
958: # * If a value of TOOLDIR was found above, and if
959: # ${TOOLDIR}/bin/${toolprefix}make exists, print that value.
1.168 apb 960: #
1.213 apb 961: print_tooldir_make()
1.168 apb 962: {
1.213 apb 963: local possible_TOP_OBJ
964: local possible_TOOLDIR
965: local possible_make
966: local tooldir_make
967:
968: if [ -n "${TOOLDIR}" ]; then
969: echo "${TOOLDIR}/bin/${toolprefix}make"
970: return 0
971: fi
1.168 apb 972:
1.198 apb 973: # Set host_ostype to something like "NetBSD-4.5.6-i386". This
974: # is intended to match the HOST_OSTYPE variable in <bsd.own.mk>.
975: #
1.168 apb 976: local host_ostype="${uname_s}-$(
977: echo "${uname_r}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
1.194 lukem 978: )-$(
1.168 apb 979: echo "${uname_p}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
980: )"
981:
1.198 apb 982: # Look in a few potential locations for
983: # ${possible_TOOLDIR}/bin/${toolprefix}make.
1.213 apb 984: # If we find it, then set possible_make.
1.198 apb 985: #
986: # In the usual case (without interference from environment
987: # variables or /etc/mk.conf), <bsd.own.mk> should set TOOLDIR to
1.212 apb 988: # "${_SRC_TOP_OBJ_}/tooldir.${host_ostype}".
989: #
990: # In practice it's difficult to figure out the correct value
991: # for _SRC_TOP_OBJ_. In the easiest case, when the -M or -O
992: # options were passed to build.sh, then ${TOP_objdir} will be
993: # the correct value. We also try a few other possibilities, but
994: # we do not replicate all the logic of <bsd.obj.mk>.
1.198 apb 995: #
1.212 apb 996: for possible_TOP_OBJ in \
997: "${TOP_objdir}" \
998: "${MAKEOBJDIRPREFIX:+${MAKEOBJDIRPREFIX}${TOP}}" \
999: "${TOP}" \
1000: "${TOP}/obj" \
1.198 apb 1001: "${TOP}/obj.${MACHINE}"
1002: do
1.212 apb 1003: [ -n "${possible_TOP_OBJ}" ] || continue
1.198 apb 1004: possible_TOOLDIR="${possible_TOP_OBJ}/tooldir.${host_ostype}"
1.213 apb 1005: possible_make="${possible_TOOLDIR}/bin/${toolprefix}make"
1006: if [ -x "${possible_make}" ]; then
1.212 apb 1007: break
1.198 apb 1008: else
1.213 apb 1009: unset possible_make
1.198 apb 1010: fi
1011: done
1012:
1013: # If the above didn't work, search the PATH for a suitable
1014: # ${toolprefix}make, nbmake, bmake, or make.
1015: #
1.213 apb 1016: : ${possible_make:=$(find_in_PATH ${toolprefix}make '')}
1017: : ${possible_make:=$(find_in_PATH nbmake '')}
1018: : ${possible_make:=$(find_in_PATH bmake '')}
1019: : ${possible_make:=$(find_in_PATH make '')}
1020:
1021: # At this point, we don't care whether possible_make is in the
1022: # correct TOOLDIR or not; we simply want it to be usable by
1023: # getmakevar to help us find the correct TOOLDIR.
1024: #
1025: # Use ${possible_make} with nobomb_getmakevar to try to find
1026: # the value of TOOLDIR. Believe the result only if it's
1027: # a directory that already exists and contains bin/${toolprefix}make.
1028: #
1029: if [ -x "${possible_make}" ]; then
1030: possible_TOOLDIR="$(
1031: make="${possible_make}" nobomb_getmakevar TOOLDIR
1032: )"
1033: if [ $? = 0 ] && [ -n "${possible_TOOLDIR}" ] \
1034: && [ -d "${possible_TOOLDIR}" ];
1035: then
1036: tooldir_make="${possible_TOOLDIR}/bin/${toolprefix}make"
1037: if [ -x "${tooldir_make}" ]; then
1038: echo "${tooldir_make}"
1039: return 0
1040: fi
1041: fi
1.168 apb 1042: fi
1.213 apb 1043: return 1
1.168 apb 1044: }
1045:
1.213 apb 1046: # rebuildmake --
1047: # Rebuild nbmake in a temporary directory if necessary. Sets $make
1048: # to a path to the nbmake executable. Sets done_rebuildmake=true
1049: # if nbmake was rebuilt.
1050: #
1051: # There is a cyclic dependency between building nbmake and choosing
1052: # TOOLDIR: TOOLDIR may be affected by settings in /etc/mk.conf, so we
1053: # would like to use getmakevar to get the value of TOOLDIR; but we can't
1054: # use getmakevar before we have an up to date version of nbmake; we
1055: # might already have an up to date version of nbmake in TOOLDIR, but we
1056: # don't yet know where TOOLDIR is.
1057: #
1058: # The default value of TOOLDIR also depends on the location of the top
1059: # level object directory, so $(getmakevar TOOLDIR) invoked before or
1060: # after making the top level object directory may produce different
1061: # results.
1062: #
1063: # Strictly speaking, we should do the following:
1064: #
1065: # 1. build a new version of nbmake in a temporary directory;
1066: # 2. use the temporary nbmake to create the top level obj directory;
1067: # 3. use $(getmakevar TOOLDIR) with the temporary nbmake to
1068: # get the corect value of TOOLDIR;
1.214 apb 1069: # 4. move the temporary nbmake to ${TOOLDIR}/bin/nbmake.
1.213 apb 1070: #
1071: # However, people don't like building nbmake unnecessarily if their
1072: # TOOLDIR has not changed since an earlier build. We try to avoid
1073: # rebuilding a temporary version of nbmake by taking some shortcuts to
1074: # guess a value for TOOLDIR, looking for an existing version of nbmake
1075: # in that TOOLDIR, and checking whether that nbmake is newer than the
1076: # sources used to build it.
1077: #
1.84 lukem 1078: rebuildmake()
1079: {
1.213 apb 1080: make="$(print_tooldir_make)"
1081: if [ -n "${make}" ] && [ -x "${make}" ]; then
1.84 lukem 1082: for f in usr.bin/make/*.[ch] usr.bin/make/lst.lib/*.[ch]; do
1.98 lukem 1083: if [ "${f}" -nt "${make}" ]; then
1.213 apb 1084: statusmsg "${make} outdated" \
1085: "(older than ${f}), needs building."
1.84 lukem 1086: do_rebuildmake=true
1087: break
1088: fi
1089: done
1090: else
1.213 apb 1091: statusmsg "No \$TOOLDIR/bin/${toolprefix}make, needs building."
1.84 lukem 1092: do_rebuildmake=true
1093: fi
1094:
1095: # Build bootstrap ${toolprefix}make if needed.
1.98 lukem 1096: if ${do_rebuildmake}; then
1097: statusmsg "Bootstrapping ${toolprefix}make"
1098: ${runcmd} cd "${tmpdir}"
1099: ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
1.84 lukem 1100: CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
1.153 apb 1101: ${HOST_SH} "${TOP}/tools/make/configure" ||
1.98 lukem 1102: bomb "Configure of ${toolprefix}make failed"
1.153 apb 1103: ${runcmd} ${HOST_SH} buildmake.sh ||
1.98 lukem 1104: bomb "Build of ${toolprefix}make failed"
1105: make="${tmpdir}/${toolprefix}make"
1106: ${runcmd} cd "${TOP}"
1107: ${runcmd} rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o
1.211 apb 1108: done_rebuildmake=true
1.84 lukem 1109: fi
1110: }
1111:
1112: validatemakeparams()
1113: {
1.98 lukem 1114: if [ "${runcmd}" = "echo" ]; then
1.84 lukem 1115: TOOLCHAIN_MISSING=no
1116: EXTERNAL_TOOLCHAIN=""
1117: else
1.210 apb 1118: TOOLCHAIN_MISSING=$(bomb_getmakevar TOOLCHAIN_MISSING)
1119: EXTERNAL_TOOLCHAIN=$(bomb_getmakevar EXTERNAL_TOOLCHAIN)
1.84 lukem 1120: fi
1121: if [ "${TOOLCHAIN_MISSING}" = "yes" ] && \
1.86 lukem 1122: [ -z "${EXTERNAL_TOOLCHAIN}" ]; then
1.98 lukem 1123: ${runcmd} echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for"
1124: ${runcmd} echo " MACHINE: ${MACHINE}"
1125: ${runcmd} echo " MACHINE_ARCH: ${MACHINE_ARCH}"
1126: ${runcmd} echo ""
1127: ${runcmd} echo "All builds for this platform should be done via a traditional make"
1128: ${runcmd} echo "If you wish to use an external cross-toolchain, set"
1129: ${runcmd} echo " EXTERNAL_TOOLCHAIN=<path to toolchain root>"
1130: ${runcmd} echo "in either the environment or mk.conf and rerun"
1131: ${runcmd} echo " ${progname} $*"
1.84 lukem 1132: exit 1
1133: fi
1134:
1.120 lukem 1135: # Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE
1136: # These may be set as build.sh options or in "mk.conf".
1137: # Don't export them as they're only used for tests in build.sh.
1138: #
1139: MKOBJDIRS=$(getmakevar MKOBJDIRS)
1140: MKUNPRIVED=$(getmakevar MKUNPRIVED)
1141: MKUPDATE=$(getmakevar MKUPDATE)
1142:
1.106 lukem 1143: if [ "${MKOBJDIRS}" != "no" ]; then
1.212 apb 1144: # Create the top-level object directory.
1.106 lukem 1145: #
1.212 apb 1146: # "make obj NOSUBDIR=" can handle most cases, but it
1147: # can't handle the case where MAKEOBJDIRPREFIX is set
1148: # while the corresponding directory does not exist
1149: # (rules in <bsd.obj.mk> would abort the build). We
1150: # therefore have to handle the MAKEOBJDIRPREFIX case
1151: # without invoking "make obj". The MAKEOBJDIR case
1152: # could be handled either way, but we choose to handle
1153: # it similarly to MAKEOBJDIRPREFIX.
1.191 apb 1154: #
1.212 apb 1155: if [ -n "${TOP_obj}" ]; then
1156: # It must have been set by the "-M" or "-O"
1157: # command line options, so there's no need to
1158: # use getmakevar
1159: :
1160: elif [ -n "$MAKEOBJDIRPREFIX" ]; then
1161: TOP_obj="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
1162: elif [ -n "$MAKEOBJDIR" ]; then
1163: TOP_obj="$(getmakevar MAKEOBJDIR)"
1164: fi
1165: if [ -n "$TOP_obj" ]; then
1166: ${runcmd} mkdir -p "${TOP_obj}" ||
1167: bomb "Can't create top level object directory" \
1168: "${TOP_obj}"
1169: else
1170: ${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
1171: bomb "Can't create top level object directory" \
1172: "using make obj"
1.106 lukem 1173: fi
1174:
1.212 apb 1175: # make obj in tools to ensure that the objdir for "tools"
1176: # is available.
1.106 lukem 1177: #
1.98 lukem 1178: ${runcmd} cd tools
1179: ${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
1180: bomb "Failed to make obj in tools"
1181: ${runcmd} cd "${TOP}"
1.84 lukem 1182: fi
1.80 lukem 1183:
1.215 apb 1184: # Find TOOLDIR, DESTDIR, and RELEASEDIR, according to getmakevar,
1185: # and bomb if they have changed from the values we had from the
1186: # command line or environment.
1187: #
1.212 apb 1188: # This must be done after creating the top-level object directory.
1.84 lukem 1189: #
1.215 apb 1190: for var in TOOLDIR DESTDIR RELEASEDIR
1191: do
1192: eval oldval=\"\$${var}\"
1193: newval="$(getmakevar $var)"
1194: if ! $do_expertmode; then
1.216 enami 1195: : ${_SRC_TOP_OBJ_:=$(getmakevar _SRC_TOP_OBJ_)}
1.215 apb 1196: case "$var" in
1197: DESTDIR)
1198: : ${newval:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
1.217 apb 1199: makeenv="${makeenv} DESTDIR"
1.215 apb 1200: ;;
1201: RELEASEDIR)
1202: : ${newval:=${_SRC_TOP_OBJ_}/releasedir}
1.217 apb 1203: makeenv="${makeenv} RELEASEDIR"
1.215 apb 1204: ;;
1205: esac
1206: fi
1207: if [ -n "$oldval" ] && [ "$oldval" != "$newval" ]; then
1208: bomb "Value of ${var} has changed" \
1209: "(was \"${oldval}\", now \"${newval}\")"
1210: fi
1211: eval ${var}=\"\${newval}\"
1212: eval export ${var}
1213: statusmsg "${var} path: ${newval}"
1214: done
1215:
1216: # RELEASEMACHINEDIR is just a subdir name, e.g. "i386".
1.186 lukem 1217: RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR)
1.84 lukem 1218:
1219: # Check validity of TOOLDIR and DESTDIR.
1220: #
1.98 lukem 1221: if [ -z "${TOOLDIR}" ] || [ "${TOOLDIR}" = "/" ]; then
1222: bomb "TOOLDIR '${TOOLDIR}' invalid"
1.84 lukem 1223: fi
1.98 lukem 1224: removedirs="${TOOLDIR}"
1.15 tv 1225:
1.98 lukem 1226: if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then
1227: if ${do_build} || ${do_distribution} || ${do_release}; then
1228: if ! ${do_build} || \
1.84 lukem 1229: [ "${uname_s}" != "NetBSD" ] || \
1.98 lukem 1230: [ "${uname_m}" != "${MACHINE}" ]; then
1.84 lukem 1231: bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
1232: fi
1.98 lukem 1233: if ! ${do_expertmode}; then
1.84 lukem 1234: bomb "DESTDIR must != / for non -E (expert) builds"
1235: fi
1.98 lukem 1236: statusmsg "WARNING: Building to /, in expert mode."
1237: statusmsg " This may cause your system to break! Reasons include:"
1238: statusmsg " - your kernel is not up to date"
1239: statusmsg " - the libraries or toolchain have changed"
1240: statusmsg " YOU HAVE BEEN WARNED!"
1.1 tv 1241: fi
1.84 lukem 1242: else
1.98 lukem 1243: removedirs="${removedirs} ${DESTDIR}"
1.84 lukem 1244: fi
1.98 lukem 1245: if ${do_build} || ${do_distribution} || ${do_release}; then
1246: if ! ${do_expertmode} && \
1.202 sketch 1247: [ "$id_u" -ne 0 ] && \
1.124 lukem 1248: [ "${MKUNPRIVED}" = "no" ] ; then
1.86 lukem 1249: bomb "-U or -E must be set for build as an unprivileged user."
1250: fi
1.185 apb 1251: fi
1.105 lukem 1252: if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then
1253: bomb "Must set RELEASEDIR with \`releasekernel=...'"
1254: fi
1.185 apb 1255:
1256: # Install as non-root is a bad idea.
1257: #
1.202 sketch 1258: if ${do_install} && [ "$id_u" -ne 0 ] ; then
1.185 apb 1259: if ${do_expertmode}; then
1260: warning "Will install as an unprivileged user."
1261: else
1262: bomb "-E must be set for install as an unprivileged user."
1263: fi
1264: fi
1265:
1266: # If a previous build.sh run used -U (and therefore created a
1267: # METALOG file), then most subsequent build.sh runs must also
1268: # use -U. If DESTDIR is about to be removed, then don't perform
1269: # this check.
1270: #
1271: case "${do_removedirs} ${removedirs} " in
1272: true*" ${DESTDIR} "*)
1273: # DESTDIR is about to be removed
1274: ;;
1275: *)
1276: if ( ${do_build} || ${do_distribution} || ${do_release} || \
1277: ${do_install} ) && \
1278: [ -e "${DESTDIR}/METALOG" ] && \
1279: [ "${MKUNPRIVED}" = "no" ] ; then
1280: if $do_expertmode; then
1281: warning "A previous build.sh run specified -U."
1282: else
1283: bomb "A previous build.sh run specified -U; you must specify it again now."
1284: fi
1285: fi
1286: ;;
1287: esac
1.84 lukem 1288: }
1.30 jmc 1289:
1.15 tv 1290:
1.84 lukem 1291: createmakewrapper()
1292: {
1293: # Remove the target directories.
1294: #
1.98 lukem 1295: if ${do_removedirs}; then
1296: for f in ${removedirs}; do
1297: statusmsg "Removing ${f}"
1298: ${runcmd} rm -r -f "${f}"
1.84 lukem 1299: done
1300: fi
1.15 tv 1301:
1.84 lukem 1302: # Recreate $TOOLDIR.
1303: #
1.98 lukem 1304: ${runcmd} mkdir -p "${TOOLDIR}/bin" ||
1305: bomb "mkdir of '${TOOLDIR}/bin' failed"
1.84 lukem 1306:
1.214 apb 1307: # If we did not previously rebuild ${toolprefix}make, then
1308: # check whether $make is still valid and the same as the output
1309: # from print_tooldir_make. If not, then rebuild make now. A
1310: # possible reason for this being necessary is that the actual
1311: # value of TOOLDIR might be different from the value guessed
1312: # before the top level obj dir was created.
1313: #
1314: if ! ${done_rebuildmake} && \
1315: ( [ ! -x "$make" ] || [ "$make" != "$(print_tooldir_make)" ] )
1316: then
1317: rebuildmake
1318: fi
1319:
1.84 lukem 1320: # Install ${toolprefix}make if it was built.
1321: #
1.211 apb 1322: if ${done_rebuildmake}; then
1.98 lukem 1323: ${runcmd} rm -f "${TOOLDIR}/bin/${toolprefix}make"
1324: ${runcmd} cp "${make}" "${TOOLDIR}/bin/${toolprefix}make" ||
1325: bomb "Failed to install \$TOOLDIR/bin/${toolprefix}make"
1326: make="${TOOLDIR}/bin/${toolprefix}make"
1327: statusmsg "Created ${make}"
1.84 lukem 1328: fi
1.15 tv 1329:
1.84 lukem 1330: # Build a ${toolprefix}make wrapper script, usable by hand as
1331: # well as by build.sh.
1332: #
1.98 lukem 1333: if [ -z "${makewrapper}" ]; then
1.102 lukem 1334: makewrapper="${TOOLDIR}/bin/${toolprefix}make-${makewrappermachine:-${MACHINE}}"
1.98 lukem 1335: [ -z "${BUILDID}" ] || makewrapper="${makewrapper}-${BUILDID}"
1.52 thorpej 1336: fi
1.4 tv 1337:
1.98 lukem 1338: ${runcmd} rm -f "${makewrapper}"
1339: if [ "${runcmd}" = "echo" ]; then
1340: echo 'cat <<EOF >'${makewrapper}
1.84 lukem 1341: makewrapout=
1342: else
1.98 lukem 1343: makewrapout=">>\${makewrapper}"
1.84 lukem 1344: fi
1.18 tv 1345:
1.139 isaki 1346: case "${KSH_VERSION:-${SH_VERSION}}" in
1.149 jnemeth 1347: *PD\ KSH*|*MIRBSD\ KSH*)
1.135 isaki 1348: set +o braceexpand
1349: ;;
1350: esac
1351:
1.98 lukem 1352: eval cat <<EOF ${makewrapout}
1.153 apb 1353: #! ${HOST_SH}
1.4 tv 1354: # Set proper variables to allow easy "make" building of a NetBSD subtree.
1.224 ! matt 1355: # Generated from: \$NetBSD: build.sh,v 1.198.2.3.4.2 2009/09/09 04:46:10 matt Exp $
1.130 jmc 1356: # with these arguments: ${_args}
1.4 tv 1357: #
1.177 uebayasi 1358:
1.18 tv 1359: EOF
1.177 uebayasi 1360: {
1361: for f in ${makeenv}; do
1362: if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then
1363: eval echo "unset ${f}"
1364: else
1365: eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}"
1366: fi
1367: done
1.18 tv 1368:
1.177 uebayasi 1369: eval cat <<EOF
1.154 dyoung 1370: MAKEWRAPPERMACHINE=${makewrappermachine:-${MACHINE}}; export MAKEWRAPPERMACHINE
1371: USETOOLS=yes; export USETOOLS
1.177 uebayasi 1372: EOF
1373: } | eval sort -u "${makewrapout}"
1.178 uebayasi 1374: eval cat <<EOF "${makewrapout}"
1.18 tv 1375:
1.98 lukem 1376: exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"}
1.4 tv 1377: EOF
1.98 lukem 1378: [ "${runcmd}" = "echo" ] && echo EOF
1379: ${runcmd} chmod +x "${makewrapper}"
1.105 lukem 1380: statusmsg "makewrapper: ${makewrapper}"
1.98 lukem 1381: statusmsg "Updated ${makewrapper}"
1.84 lukem 1382: }
1383:
1.203 lukem 1384: make_in_dir()
1385: {
1386: dir="$1"
1387: op="$2"
1388: ${runcmd} cd "${dir}" ||
1389: bomb "Failed to cd to \"${dir}\""
1390: ${runcmd} "${makewrapper}" ${parallel} ${op} ||
1391: bomb "Failed to make ${op} in \"${dir}\""
1392: ${runcmd} cd "${TOP}" ||
1393: bomb "Failed to cd back to \"${TOP}\""
1394: }
1395:
1.84 lukem 1396: buildtools()
1397: {
1.98 lukem 1398: if [ "${MKOBJDIRS}" != "no" ]; then
1399: ${runcmd} "${makewrapper}" ${parallel} obj-tools ||
1400: bomb "Failed to make obj-tools"
1.84 lukem 1401: fi
1.124 lukem 1402: if [ "${MKUPDATE}" = "no" ]; then
1.203 lukem 1403: make_in_dir tools cleandir
1.84 lukem 1404: fi
1.203 lukem 1405: make_in_dir tools dependall
1406: make_in_dir tools install
1.98 lukem 1407: statusmsg "Tools built to ${TOOLDIR}"
1.84 lukem 1408: }
1.4 tv 1409:
1.105 lukem 1410: getkernelconf()
1.84 lukem 1411: {
1.105 lukem 1412: kernelconf="$1"
1.114 lukem 1413: if [ "${MKOBJDIRS}" != "no" ]; then
1.84 lukem 1414: # The correct value of KERNOBJDIR might
1415: # depend on a prior "make obj" in
1416: # ${KERNSRCDIR}/${KERNARCHDIR}/compile.
1417: #
1.98 lukem 1418: KERNSRCDIR="$(getmakevar KERNSRCDIR)"
1419: KERNARCHDIR="$(getmakevar KERNARCHDIR)"
1.203 lukem 1420: make_in_dir "${KERNSRCDIR}/${KERNARCHDIR}/compile" obj
1.84 lukem 1421: fi
1.98 lukem 1422: KERNCONFDIR="$(getmakevar KERNCONFDIR)"
1423: KERNOBJDIR="$(getmakevar KERNOBJDIR)"
1.105 lukem 1424: case "${kernelconf}" in
1.84 lukem 1425: */*)
1.105 lukem 1426: kernelconfpath="${kernelconf}"
1427: kernelconfname="${kernelconf##*/}"
1.84 lukem 1428: ;;
1429: *)
1.105 lukem 1430: kernelconfpath="${KERNCONFDIR}/${kernelconf}"
1431: kernelconfname="${kernelconf}"
1.84 lukem 1432: ;;
1433: esac
1.105 lukem 1434: kernelbuildpath="${KERNOBJDIR}/${kernelconfname}"
1435: }
1436:
1437: buildkernel()
1438: {
1439: if ! ${do_tools} && ! ${buildkernelwarned:-false}; then
1440: # Building tools every time we build a kernel is clearly
1441: # unnecessary. We could try to figure out whether rebuilding
1442: # the tools is necessary this time, but it doesn't seem worth
1443: # the trouble. Instead, we say it's the user's responsibility
1444: # to rebuild the tools if necessary.
1445: #
1446: statusmsg "Building kernel without building new tools"
1447: buildkernelwarned=true
1448: fi
1449: getkernelconf $1
1450: statusmsg "Building kernel: ${kernelconf}"
1451: statusmsg "Build directory: ${kernelbuildpath}"
1452: ${runcmd} mkdir -p "${kernelbuildpath}" ||
1453: bomb "Cannot mkdir: ${kernelbuildpath}"
1.124 lukem 1454: if [ "${MKUPDATE}" = "no" ]; then
1.203 lukem 1455: make_in_dir "${kernelbuildpath}" cleandir
1.16 thorpej 1456: fi
1.157 rillig 1457: [ -x "${TOOLDIR}/bin/${toolprefix}config" ] \
1458: || bomb "${TOOLDIR}/bin/${toolprefix}config does not exist. You need to \"$0 tools\" first."
1.105 lukem 1459: ${runcmd} "${TOOLDIR}/bin/${toolprefix}config" -b "${kernelbuildpath}" \
1460: -s "${TOP}/sys" "${kernelconfpath}" ||
1461: bomb "${toolprefix}config failed for ${kernelconf}"
1.203 lukem 1462: make_in_dir "${kernelbuildpath}" depend
1463: make_in_dir "${kernelbuildpath}" all
1.91 lukem 1464:
1.98 lukem 1465: if [ "${runcmd}" != "echo" ]; then
1.105 lukem 1466: statusmsg "Kernels built from ${kernelconf}:"
1467: kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
1.91 lukem 1468: for kern in ${kernlist:-netbsd}; do
1.105 lukem 1469: [ -f "${kernelbuildpath}/${kern}" ] && \
1470: echo " ${kernelbuildpath}/${kern}"
1.98 lukem 1471: done | tee -a "${results}"
1.91 lukem 1472: fi
1.84 lukem 1473: }
1474:
1.105 lukem 1475: releasekernel()
1476: {
1477: getkernelconf $1
1.186 lukem 1478: kernelreldir="${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/kernel"
1.105 lukem 1479: ${runcmd} mkdir -p "${kernelreldir}"
1480: kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
1481: for kern in ${kernlist:-netbsd}; do
1482: builtkern="${kernelbuildpath}/${kern}"
1483: [ -f "${builtkern}" ] || continue
1484: releasekern="${kernelreldir}/${kern}-${kernelconfname}.gz"
1485: statusmsg "Kernel copy: ${releasekern}"
1.196 lukem 1486: if [ "${runcmd}" = "echo" ]; then
1487: echo "gzip -c -9 < ${builtkern} > ${releasekern}"
1488: else
1489: gzip -c -9 < "${builtkern}" > "${releasekern}"
1490: fi
1.105 lukem 1491: done
1492: }
1493:
1.207 jnemeth 1494: buildmodules()
1495: {
1496: if ! ${do_tools} && ! ${buildmoduleswarned:-false}; then
1497: # Building tools every time we build modules is clearly
1498: # unnecessary as well as a kernel.
1499: #
1500: statusmsg "Building modules without building new tools"
1501: buildmoduleswarned=true
1502: fi
1503:
1504: statusmsg "Building kernel modules for NetBSD/${MACHINE} ${DISTRIBVER}"
1505: if [ "${MKOBJDIRS}" != "no" ]; then
1506: make_in_dir sys/modules obj ||
1507: bomb "Failed to make obj in sys/modules"
1508: fi
1509: if [ "${MKUPDATE}" = "no" ]; then
1510: make_in_dir sys/modules cleandir
1511: fi
1512: ${runcmd} "${makewrapper}" ${parallel} do-sys-modules ||
1513: bomb "Failed to make do-sys-modules"
1514:
1515: statusmsg "Successful build kernel modules for NetBSD/${MACHINE} ${DISTRIBVER}"
1516: }
1517:
1.84 lukem 1518: installworld()
1519: {
1520: dir="$1"
1.98 lukem 1521: ${runcmd} "${makewrapper}" INSTALLWORLDDIR="${dir}" installworld ||
1522: bomb "Failed to make installworld to ${dir}"
1523: statusmsg "Successful installworld to ${dir}"
1.84 lukem 1524: }
1525:
1.219 pooka 1526: # Run rump build&link tests.
1527: #
1528: # To make this feasible for running without having to install includes and
1529: # libraries into destdir (i.e. quick), we only run ld. This is possible
1530: # since the rump kernel is a closed namespace apart from calls to rumpuser.
1531: # Therefore, if ld complains only about rumpuser symbols, rump kernel
1532: # linking was successful.
1533: #
1534: # We test that rump links with a number of component configurations.
1535: # These attempt to mimic what is encountered in the full build.
1536: # See list below. The list should probably be either autogenerated
1537: # or managed elsewhere. But keep it here until a better idea arises.
1538: #
1539: # Above all, note that THIS IS NOT A SUBSTITUTE FOR A FULL BUILD.
1540: #
1541:
1542: RUMP_LIBSETS='
1543: -lrump,
1544: -lrumpvfs -lrump,
1545: -lrumpfs_tmpfs -lrumpvfs -lrump,
1546: -lrumpfs_ffs -lrumpfs_msdosfs -lrumpvfs -lrump,
1547: -lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet -lrump,
1548: -lrumpnet_sockin -lrumpfs_smbfs -lrumpdev_netsmb
1549: -lrumpcrypto -lrumpdev -lrumpnet -lrumpvfs -lrump,
1.220 pooka 1550: -lrumpnet_sockin -lrumpfs_nfs -lrumpnet -lrumpvfs -lrump,
1551: -lrumpdev_cgd -lrumpdev_raidframe -lrumpdev_disk -lrumpdev_rnd
1552: -lrumpdev -lrumpvfs -lrumpcrypto -lrump'
1.219 pooka 1553: dorump()
1554: {
1555: local doclean=""
1556: local doobjs=""
1557:
1558: # we cannot link libs without building csu, and that leads to lossage
1559: [ "${1}" != "rumptest" ] && bomb 'build.sh rump not yet functional. ' \
1560: 'did you mean "rumptest"?'
1561:
1562: [ "${MKUPDATE}" = "no" ] && doclean="cleandir"
1563: [ "${MKOBJDIRS}" = "no" ] || doobjs="obj"
1564: ${runcmd} "${makewrapper}" ${parallel} do-distrib-dirs
1565:
1566: targlist="${doclean} ${doobjs} dependall install"
1567: setmakeenv NORUMPUSER 1
1568: # optimize: for test we build only static libs (3x test speedup)
1569: if [ "${1}" = "rumptest" ] ; then
1570: setmakeenv NOPIC 1
1571: setmakeenv NOPROFILE 1
1572: fi
1573: for cmd in ${targlist} ; do
1574: make_in_dir "${NETBSDSRCDIR}/sys/rump" ${cmd}
1575: done
1576:
1577: # if we just wanted to build & install rump, we're done
1578: [ "${1}" != "rumptest" ] && return
1579:
1.221 pooka 1580: ${runcmd} cd "${NETBSDSRCDIR}/sys/rump/librump/rumpkern" \
1581: || bomb "cd to rumpkern failed"
1582: md_quirks=`${runcmd} "${makewrapper}" -V '${_SYMQUIRK}'`
1583: # one little, two little, three little backslashes ...
1584: md_quirks="`echo ${md_quirks} | sed 's,\\\,\\\\\\\,g'";s/'//g" `"
1585: ${runcmd} cd "${TOP}" || bomb "cd to ${TOP} failed"
1.219 pooka 1586: tool_ld=`${runcmd} "${makewrapper}" -V '${LD}'`
1.221 pooka 1587:
1.219 pooka 1588: local oIFS="${IFS}"
1589: IFS=","
1590: for set in ${RUMP_LIBSETS} ; do
1591: IFS="${oIFS}"
1592: ${runcmd} ${tool_ld} -nostdlib -L${DESTDIR}/usr/lib \
1.221 pooka 1593: -static --whole-archive ${set} 2>&1 | \
1594: awk -v quirks="${md_quirks}" '
1.219 pooka 1595: /undefined reference/ &&
1596: !/more undefined references.*follow/{
1.221 pooka 1597: if (match($NF,
1598: "`(rumpuser_|__" quirks ")") == 0)
1.219 pooka 1599: fails[NR] = $0
1.221 pooka 1600: }
1.219 pooka 1601: END{
1602: for (x in fails)
1603: print fails[x]
1604: exit x!=0
1605: }'
1606: [ $? -ne 0 ] && bomb "Testlink of rump failed: ${set}"
1607: done
1608: statusmsg "Rump build&link tests successful"
1609: }
1.84 lukem 1610:
1611: main()
1612: {
1613: initdefaults
1.130 jmc 1614: _args=$@
1.84 lukem 1615: parseoptions "$@"
1.93 lukem 1616:
1.163 apb 1617: sanitycheck
1618:
1.93 lukem 1619: build_start=$(date)
1.98 lukem 1620: statusmsg "${progname} command: $0 $@"
1621: statusmsg "${progname} started: ${build_start}"
1.165 apb 1622: statusmsg "NetBSD version: ${DISTRIBVER}"
1623: statusmsg "MACHINE: ${MACHINE}"
1624: statusmsg "MACHINE_ARCH: ${MACHINE_ARCH}"
1625: statusmsg "Build platform: ${uname_s} ${uname_r} ${uname_m}"
1.153 apb 1626: statusmsg "HOST_SH: ${HOST_SH}"
1627:
1.84 lukem 1628: rebuildmake
1629: validatemakeparams
1630: createmakewrapper
1631:
1632: # Perform the operations.
1633: #
1.98 lukem 1634: for op in ${operations}; do
1635: case "${op}" in
1.86 lukem 1636:
1637: makewrapper)
1638: # no-op
1639: ;;
1.84 lukem 1640:
1641: tools)
1642: buildtools
1643: ;;
1644:
1.125 lukem 1645: sets)
1646: statusmsg "Building sets from pre-populated ${DESTDIR}"
1647: ${runcmd} "${makewrapper}" ${parallel} ${op} ||
1648: bomb "Failed to make ${op}"
1.186 lukem 1649: setdir=${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
1650: statusmsg "Built sets to ${setdir}"
1.125 lukem 1651: ;;
1.142 apb 1652:
1.195 lukem 1653: cleandir|obj|build|distribution|release|sourcesets|syspkgs|params)
1.98 lukem 1654: ${runcmd} "${makewrapper}" ${parallel} ${op} ||
1655: bomb "Failed to make ${op}"
1656: statusmsg "Successful make ${op}"
1.84 lukem 1657: ;;
1658:
1.173 jnemeth 1659: iso-image|iso-image-source)
1660: ${runcmd} "${makewrapper}" ${parallel} \
1.209 apb 1661: CDEXTRA="$CDEXTRA" ${op} ||
1.173 jnemeth 1662: bomb "Failed to make ${op}"
1663: statusmsg "Successful make ${op}"
1664: ;;
1665:
1.84 lukem 1666: kernel=*)
1667: arg=${op#*=}
1668: buildkernel "${arg}"
1.105 lukem 1669: ;;
1670:
1671: releasekernel=*)
1672: arg=${op#*=}
1673: releasekernel "${arg}"
1.84 lukem 1674: ;;
1675:
1.207 jnemeth 1676: modules)
1677: buildmodules
1678: ;;
1679:
1.84 lukem 1680: install=*)
1681: arg=${op#*=}
1.85 lukem 1682: if [ "${arg}" = "/" ] && \
1683: ( [ "${uname_s}" != "NetBSD" ] || \
1.98 lukem 1684: [ "${uname_m}" != "${MACHINE}" ] ); then
1.85 lukem 1685: bomb "'${op}' must != / for cross builds."
1686: fi
1.84 lukem 1687: installworld "${arg}"
1.70 lukem 1688: ;;
1.84 lukem 1689:
1.219 pooka 1690: rump|rumptest)
1691: dorump "${op}"
1692: ;;
1693:
1.70 lukem 1694: *)
1.84 lukem 1695: bomb "Unknown operation \`${op}'"
1.70 lukem 1696: ;;
1.84 lukem 1697:
1.70 lukem 1698: esac
1.84 lukem 1699: done
1.93 lukem 1700:
1.98 lukem 1701: statusmsg "${progname} ended: $(date)"
1702: if [ -s "${results}" ]; then
1703: echo "===> Summary of results:"
1704: sed -e 's/^===>//;s/^/ /' "${results}"
1705: echo "===> ."
1706: fi
1.84 lukem 1707: }
1708:
1709: main "$@"
CVSweb <webmaster@jp.NetBSD.org>