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