Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/build.sh,v rcsdiff: /ftp/cvs/cvsroot/src/build.sh,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.255.2.4 retrieving revision 1.256 diff -u -p -r1.255.2.4 -r1.256 --- src/build.sh 2014/08/19 23:45:10 1.255.2.4 +++ src/build.sh 2012/09/29 04:02:42 1.256 @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.255.2.4 2014/08/19 23:45:10 tls Exp $ +# $NetBSD: build.sh,v 1.256 2012/09/29 04:02:42 tsutsui Exp $ # # Copyright (c) 2001-2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -263,8 +263,6 @@ progname=${0##*/} toppid=$$ results=/dev/null tab=' ' -nl=' -' trap "exit 1" 1 2 3 15 bomb() @@ -278,51 +276,6 @@ ERRORMESSAGE exit 1 } -# Quote args to make them safe in the shell. -# Usage: quotedlist="$(shell_quote args...)" -# -# After building up a quoted list, use it by evaling it inside -# double quotes, like this: -# eval "set -- $quotedlist" -# or like this: -# eval "\$command $quotedlist \$filename" -# -shell_quote() -{( - local result='' - local arg qarg - LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII - for arg in "$@" ; do - case "${arg}" in - '') - qarg="''" - ;; - *[!-./a-zA-Z0-9]*) - # Convert each embedded ' to '\'', - # then insert ' at the beginning of the first line, - # and append ' at the end of the last line. - # Finally, elide unnecessary '' pairs at the - # beginning and end of the result and as part of - # '\'''\'' sequences that result from multiple - # adjacent quotes in he input. - qarg="$(printf "%s\n" "$arg" | \ - ${SED:-sed} -e "s/'/'\\\\''/g" \ - -e "1s/^/'/" -e "\$s/\$/'/" \ - -e "1s/^''//" -e "\$s/''\$//" \ - -e "s/'''/'/g" - )" - ;; - *) - # Arg is not the empty string, and does not contain - # any unsafe characters. Leave it unchanged for - # readability. - qarg="${arg}" - ;; - esac - result="${result}${result:+ }${qarg}" - done - printf "%s\n" "$result" -)} statusmsg() { @@ -475,7 +428,6 @@ initdefaults() unsetmakeenv INFODIR unsetmakeenv LESSCHARSET unsetmakeenv MAKEFLAGS - unsetmakeenv TERMINFO setmakeenv LC_ALL C # Find information about the build platform. This should be @@ -553,7 +505,6 @@ initdefaults() do_iso_image_source=false do_live_image=false do_install_image=false - do_disk_image=false do_params=false do_rump=false @@ -595,310 +546,203 @@ initdefaults() } -# valid_MACHINE_ARCH -- A multi-line string, listing all valid -# MACHINE/MACHINE_ARCH pairs. -# -# Each line contains a MACHINE and MACHINE_ARCH value, an optional ALIAS -# which may be used to refer to the MACHINE/MACHINE_ARCH pair, and an -# optional DEFAULT or NO_DEFAULT keyword. -# -# When a MACHINE corresponds to multiple possible values of -# MACHINE_ARCH, then this table should list all allowed combinations. -# If the MACHINE is associated with a default MACHINE_ARCH (to be -# used when the user specifies the MACHINE but fails to specify the -# MACHINE_ARCH), then one of the lines should have the "DEFAULT" -# keyword. If there is no default MACHINE_ARCH for a particular -# MACHINE, then there should be a line with the "NO_DEFAULT" keyword, -# and with a blank MACHINE_ARCH. -# -valid_MACHINE_ARCH=' -MACHINE=acorn26 MACHINE_ARCH=arm -MACHINE=acorn32 MACHINE_ARCH=arm -MACHINE=algor MACHINE_ARCH=mips64el ALIAS=algor64 -MACHINE=algor MACHINE_ARCH=mipsel DEFAULT -MACHINE=alpha MACHINE_ARCH=alpha -MACHINE=amd64 MACHINE_ARCH=x86_64 -MACHINE=amiga MACHINE_ARCH=m68k -MACHINE=amigappc MACHINE_ARCH=powerpc -MACHINE=arc MACHINE_ARCH=mips64el ALIAS=arc64 -MACHINE=arc MACHINE_ARCH=mipsel DEFAULT -MACHINE=atari MACHINE_ARCH=m68k -MACHINE=bebox MACHINE_ARCH=powerpc -MACHINE=cats MACHINE_ARCH=arm ALIAS=ocats -MACHINE=cats MACHINE_ARCH=earmv4 ALIAS=ecats DEFAULT -MACHINE=cesfic MACHINE_ARCH=m68k -MACHINE=cobalt MACHINE_ARCH=mips64el ALIAS=cobalt64 -MACHINE=cobalt MACHINE_ARCH=mipsel DEFAULT -MACHINE=dreamcast MACHINE_ARCH=sh3el -MACHINE=emips MACHINE_ARCH=mipseb -MACHINE=epoc32 MACHINE_ARCH=arm -MACHINE=evbarm MACHINE_ARCH=arm ALIAS=evboarm-el -MACHINE=evbarm MACHINE_ARCH=armeb ALIAS=evboarm-eb -MACHINE=evbarm MACHINE_ARCH=earm ALIAS=evbearm-el DEFAULT -MACHINE=evbarm MACHINE_ARCH=earmeb ALIAS=evbearm-eb -MACHINE=evbarm MACHINE_ARCH=earmhf ALIAS=evbearmhf-el -MACHINE=evbarm MACHINE_ARCH=earmhfeb ALIAS=evbearmhf-eb -MACHINE=evbarm MACHINE_ARCH=earmv4 ALIAS=evbearmv4-el -MACHINE=evbarm MACHINE_ARCH=earmv4eb ALIAS=evbearmv4-eb -MACHINE=evbarm MACHINE_ARCH=earmv5 ALIAS=evbearmv5-el -MACHINE=evbarm MACHINE_ARCH=earmv5eb ALIAS=evbearmv5-eb -MACHINE=evbarm MACHINE_ARCH=earmv6 ALIAS=evbearmv6-el -MACHINE=evbarm MACHINE_ARCH=earmv6hf ALIAS=evbearmv6hf-el -MACHINE=evbarm MACHINE_ARCH=earmv6eb ALIAS=evbearmv6-eb -MACHINE=evbarm MACHINE_ARCH=earmv6hfeb ALIAS=evbearmv6hf-eb -MACHINE=evbarm MACHINE_ARCH=earmv7 ALIAS=evbearmv7-el -MACHINE=evbarm MACHINE_ARCH=earmv7eb ALIAS=evbearmv7-eb -MACHINE=evbarm MACHINE_ARCH=earmv7hf ALIAS=evbearmv7hf-el -MACHINE=evbarm MACHINE_ARCH=earmv7hfeb ALIAS=evbearmv7hf-eb -MACHINE=evbarm64 MACHINE_ARCH=aarch64 ALIAS=evbarm64-el -MACHINE=evbarm64 MACHINE_ARCH=aarch64eb ALIAS=evbarm64-eb -MACHINE=evbcf MACHINE_ARCH=coldfire -MACHINE=evbmips MACHINE_ARCH= NO_DEFAULT -MACHINE=evbmips MACHINE_ARCH=mips64eb ALIAS=evbmips64-eb -MACHINE=evbmips MACHINE_ARCH=mips64el ALIAS=evbmips64-el -MACHINE=evbmips MACHINE_ARCH=mipseb ALIAS=evbmips-eb -MACHINE=evbmips MACHINE_ARCH=mipsel ALIAS=evbmips-el -MACHINE=evbppc MACHINE_ARCH=powerpc DEFAULT -MACHINE=evbppc MACHINE_ARCH=powerpc64 ALIAS=evbppc64 -MACHINE=evbsh3 MACHINE_ARCH= NO_DEFAULT -MACHINE=evbsh3 MACHINE_ARCH=sh3eb ALIAS=evbsh3-eb -MACHINE=evbsh3 MACHINE_ARCH=sh3el ALIAS=evbsh3-el -MACHINE=ews4800mips MACHINE_ARCH=mipseb -MACHINE=hp300 MACHINE_ARCH=m68k -MACHINE=hppa MACHINE_ARCH=hppa -MACHINE=hpcarm MACHINE_ARCH=arm ALIAS=hpcoarm -MACHINE=hpcarm MACHINE_ARCH=earmv4 ALIAS=hpcearm DEFAULT -MACHINE=hpcmips MACHINE_ARCH=mipsel -MACHINE=hpcsh MACHINE_ARCH=sh3el -MACHINE=i386 MACHINE_ARCH=i386 -MACHINE=ia64 MACHINE_ARCH=ia64 -MACHINE=ibmnws MACHINE_ARCH=powerpc -MACHINE=iyonix MACHINE_ARCH=arm ALIAS=oiyonix -MACHINE=iyonix MACHINE_ARCH=earm ALIAS=eiyonix DEFAULT -MACHINE=landisk MACHINE_ARCH=sh3el -MACHINE=luna68k MACHINE_ARCH=m68k -MACHINE=mac68k MACHINE_ARCH=m68k -MACHINE=macppc MACHINE_ARCH=powerpc DEFAULT -MACHINE=macppc MACHINE_ARCH=powerpc64 ALIAS=macppc64 -MACHINE=mipsco MACHINE_ARCH=mipseb -MACHINE=mmeye MACHINE_ARCH=sh3eb -MACHINE=mvme68k MACHINE_ARCH=m68k -MACHINE=mvmeppc MACHINE_ARCH=powerpc -MACHINE=netwinder MACHINE_ARCH=arm ALIAS=onetwinder -MACHINE=netwinder MACHINE_ARCH=earmv4 ALIAS=enetwinder DEFAULT -MACHINE=news68k MACHINE_ARCH=m68k -MACHINE=newsmips MACHINE_ARCH=mipseb -MACHINE=next68k MACHINE_ARCH=m68k -MACHINE=ofppc MACHINE_ARCH=powerpc DEFAULT -MACHINE=ofppc MACHINE_ARCH=powerpc64 ALIAS=ofppc64 -MACHINE=playstation2 MACHINE_ARCH=mipsel -MACHINE=pmax MACHINE_ARCH=mips64el ALIAS=pmax64 -MACHINE=pmax MACHINE_ARCH=mipsel DEFAULT -MACHINE=prep MACHINE_ARCH=powerpc -MACHINE=rs6000 MACHINE_ARCH=powerpc -MACHINE=sandpoint MACHINE_ARCH=powerpc -MACHINE=sbmips MACHINE_ARCH= NO_DEFAULT -MACHINE=sbmips MACHINE_ARCH=mips64eb ALIAS=sbmips64-eb -MACHINE=sbmips MACHINE_ARCH=mips64el ALIAS=sbmips64-el -MACHINE=sbmips MACHINE_ARCH=mipseb ALIAS=sbmips-eb -MACHINE=sbmips MACHINE_ARCH=mipsel ALIAS=sbmips-el -MACHINE=sgimips MACHINE_ARCH=mips64eb ALIAS=sgimips64 -MACHINE=sgimips MACHINE_ARCH=mipseb DEFAULT -MACHINE=shark MACHINE_ARCH=arm ALIAS=oshark -MACHINE=shark MACHINE_ARCH=earmv4 ALIAS=eshark DEFAULT -MACHINE=sparc MACHINE_ARCH=sparc -MACHINE=sparc64 MACHINE_ARCH=sparc64 -MACHINE=sun2 MACHINE_ARCH=m68000 -MACHINE=sun3 MACHINE_ARCH=m68k -MACHINE=vax MACHINE_ARCH=vax -MACHINE=x68k MACHINE_ARCH=m68k -MACHINE=zaurus MACHINE_ARCH=arm ALIAS=ozaurus -MACHINE=zaurus MACHINE_ARCH=earm ALIAS=ezaurus DEFAULT -' - -# getarch -- find the default MACHINE_ARCH for a MACHINE, -# or convert an alias to a MACHINE/MACHINE_ARCH pair. -# -# Saves the original value of MACHINE in makewrappermachine before -# alias processing. -# -# Sets MACHINE and MACHINE_ARCH if the input MACHINE value is -# recognised as an alias, or recognised as a machine that has a default -# MACHINE_ARCH (or that has only one possible MACHINE_ARCH). -# -# Leaves MACHINE and MACHINE_ARCH unchanged if MACHINE is recognised -# as being associated with multiple MACHINE_ARCH values with no default. -# -# Bombs if MACHINE is not recognised. -# getarch() { - local IFS - local found="" - local line - - IFS="${nl}" - makewrappermachine="${MACHINE}" - for line in ${valid_MACHINE_ARCH}; do - line="${line%%#*}" # ignore comments - line="$( IFS=" ${tab}" ; echo $line )" # normalise white space - case "${line} " in - " ") - # skip blank lines or comment lines - continue - ;; - *" ALIAS=${MACHINE} "*) - # Found a line with a matching ALIAS=. - found="$line" - break - ;; - "MACHINE=${MACHINE} "*" NO_DEFAULT"*) - # Found an explicit "NO_DEFAULT" for this MACHINE. - found="$line" - break - ;; - "MACHINE=${MACHINE} "*" DEFAULT"*) - # Found an explicit "DEFAULT" for this MACHINE. - found="$line" - break - ;; - "MACHINE=${MACHINE} "*) - # Found a line for this MACHINE. If it's the - # first such line, then tentatively accept it. - # If it's not the first matching line, then - # remember that there was more than one match. - case "$found" in - '') found="$line" ;; - *) found="MULTIPLE_MATCHES" ;; - esac - ;; - esac - done + # Translate some MACHINE name aliases (known only to build.sh) + # into proper MACHINE and MACHINE_ARCH names. Save the alias + # name in makewrappermachine. + # + case "${MACHINE}" in - case "$found" in - *NO_DEFAULT*|*MULTIPLE_MATCHES*) - # MACHINE is OK, but MACHINE_ARCH is still unknown - return - ;; - "MACHINE="*" MACHINE_ARCH="*) - # Obey the MACHINE= and MACHINE_ARCH= parts of the line. - IFS=" " - for frag in ${found}; do - case "$frag" in - MACHINE=*|MACHINE_ARCH=*) - eval "$frag" - ;; - esac - done + evbearm-e[bl]) + makewrappermachine=${MACHINE} + # MACHINE_ARCH is "arm" or "armeb", not "armel" + MACHINE_ARCH=earm${MACHINE##*-} + MACHINE_ARCH=${MACHINE_ARCH%el} + MACHINE=evbarm + ;; + + evbarm-e[bl]) + makewrappermachine=${MACHINE} + # MACHINE_ARCH is "arm" or "armeb", not "armel" + MACHINE_ARCH=arm${MACHINE##*-} + MACHINE_ARCH=${MACHINE_ARCH%el} + MACHINE=${MACHINE%-e[bl]} + ;; + + evbmips-e[bl]|sbmips-e[bl]) + makewrappermachine=${MACHINE} + MACHINE_ARCH=mips${MACHINE##*-} + MACHINE=${MACHINE%-e[bl]} + ;; + + evbmips64-e[bl]|sbmips64-e[bl]) + makewrappermachine=${MACHINE} + MACHINE_ARCH=mips64${MACHINE##*-} + MACHINE=${MACHINE%64-e[bl]} + ;; + + evbsh3-e[bl]) + makewrappermachine=${MACHINE} + MACHINE_ARCH=sh3${MACHINE##*-} + MACHINE=${MACHINE%-e[bl]} + ;; + + esac + + # Translate a MACHINE into a default MACHINE_ARCH. + # + case "${MACHINE}" in + + acorn26|acorn32|cats|hpcarm|iyonix|netwinder|shark|zaurus) + MACHINE_ARCH=arm + ;; + + evbarm) # unspecified MACHINE_ARCH gets LE + MACHINE_ARCH=${MACHINE_ARCH:=arm} + ;; + + hp700) + MACHINE_ARCH=hppa + ;; + + sun2) + MACHINE_ARCH=m68000 + ;; + + amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k) + MACHINE_ARCH=m68k ;; + + evbmips|sbmips) # no default MACHINE_ARCH + ;; + + sgimips64) + makewrappermachine=${MACHINE} + MACHINE=${MACHINE%64} + MACHINE_ARCH=mips64eb + ;; + + ews4800mips|mipsco|newsmips|sgimips|emips) + MACHINE_ARCH=mipseb + ;; + + algor64|arc64|cobalt64|pmax64) + makewrappermachine=${MACHINE} + MACHINE=${MACHINE%64} + MACHINE_ARCH=mips64el + ;; + + algor|arc|cobalt|hpcmips|pmax) + MACHINE_ARCH=mipsel + ;; + + evbppc64|macppc64|ofppc64) + makewrappermachine=${MACHINE} + MACHINE=${MACHINE%64} + MACHINE_ARCH=powerpc64 + ;; + + amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|prep|rs6000|sandpoint) + MACHINE_ARCH=powerpc + ;; + + evbsh3) # no default MACHINE_ARCH + ;; + + mmeye) + MACHINE_ARCH=sh3eb + ;; + + dreamcast|hpcsh|landisk) + MACHINE_ARCH=sh3el + ;; + + amd64) + MACHINE_ARCH=x86_64 + ;; + + alpha|i386|sparc|sparc64|vax|ia64) + MACHINE_ARCH=${MACHINE} + ;; + *) bomb "Unknown target MACHINE: ${MACHINE}" ;; + esac } -# validatearch -- check that the MACHINE/MACHINE_ARCH pair is supported. -# -# Bombs if the pair is not supported. -# validatearch() { - local IFS - local line - local foundpair=false foundmachine=false foundarch=false - + # Ensure that the MACHINE_ARCH exists (and is supported by build.sh). + # case "${MACHINE_ARCH}" in + + alpha|arm|armeb|earm|earmeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|powerpc|powerpc64|sh3e[bl]|sparc|sparc64|vax|x86_64|ia64) + ;; + "") bomb "No MACHINE_ARCH provided" ;; + + *) + bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}" + ;; + esac - IFS="${nl}" - for line in ${valid_MACHINE_ARCH}; do - line="${line%%#*}" # ignore comments - line="$( IFS=" ${tab}" ; echo $line )" # normalise white space - case "${line} " in - " ") - # skip blank lines or comment lines - continue - ;; - "MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} "*) - foundpair=true - ;; - "MACHINE=${MACHINE} "*) - foundmachine=true - ;; - *"MACHINE_ARCH=${MACHINE_ARCH} "*) - foundarch=true - ;; - esac - done + # Determine valid MACHINE_ARCHs for MACHINE + # + case "${MACHINE}" in - case "${foundpair}:${foundmachine}:${foundarch}" in - true:*) - : OK + evbarm) + arches="arm armeb earm earmeb" ;; - *:false:*) - bomb "Unknown target MACHINE: ${MACHINE}" + + cats|iyonix|netwinder|shark|zaurus) + arches="arm earm" ;; - *:*:false) - bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}" + + algor|arc|cobalt|pmax) + arches="mipsel mips64el" + ;; + + evbmips|sbmips) + arches="mipseb mipsel mips64eb mips64el" + ;; + + sgimips) + arches="mipseb mips64eb" + ;; + + evbsh3) + arches="sh3eb sh3el" + ;; + + macppc|evbppc|ofppc) + arches="powerpc powerpc64" ;; *) - bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'" + oma="${MACHINE_ARCH}" + getarch + arches="${MACHINE_ARCH}" + MACHINE_ARCH="${oma}" ;; - esac -} -# listarch -- list valid MACHINE/MACHINE_ARCH/ALIAS values, -# optionally restricted to those where the MACHINE and/or MACHINE_ARCH -# match specifed glob patterns. -# -listarch() -{ - local machglob="$1" archglob="$2" - local IFS - local wildcard="*" - local line xline frag - local line_matches_machine line_matches_arch - local found=false - - # Empty machglob or archglob should match anything - : "${machglob:=${wildcard}}" - : "${archglob:=${wildcard}}" - - IFS="${nl}" - for line in ${valid_MACHINE_ARCH}; do - line="${line%%#*}" # ignore comments - xline="$( IFS=" ${tab}" ; echo $line )" # normalise white space - [ -z "${xline}" ] && continue # skip blank or comment lines - - line_matches_machine=false - line_matches_arch=false - - IFS=" " - for frag in ${xline}; do - case "${frag}" in - MACHINE=${machglob}) - line_matches_machine=true ;; - ALIAS=${machglob}) - line_matches_machine=true ;; - MACHINE_ARCH=${archglob}) - line_matches_arch=true ;; - esac - done + esac - if $line_matches_machine && $line_matches_arch; then - found=true - echo "$line" + # Ensure that MACHINE_ARCH supports MACHINE + # + archok=false + for a in ${arches}; do + if [ "${a}" = "${MACHINE_ARCH}" ]; then + archok=true + break fi done - if ! $found; then - echo >&2 "No match for" \ - "MACHINE=${machglob} MACHINE_ARCH=${archglob}" - return 1 - fi - return 0 + ${archok} || + bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'" } # nobomb_getmakevar -- @@ -1021,8 +865,6 @@ Usage: ${progname} [-EhnorUuxy] [-a arch install=idir Run "make installworld" to \`idir' to install all sets except \`etc'. Useful after "distribution" or "release" kernel=conf Build kernel with config file \`conf' - kernel.gdb=conf Build kernel (including netbsd.gdb) with config - file \`conf' releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR. installmodules=idir Run "make installmodules" to \`idir' to install all kernel modules. @@ -1040,12 +882,7 @@ Usage: ${progname} [-EhnorUuxy] [-a arch RELEASEDIR/RELEASEMACHINEDIR/installation/liveimage. install-image Create bootable installation image in RELEASEDIR/RELEASEMACHINEDIR/installation/installimage. - disk-image=target Creae bootable disk image in - RELEASEDIR/RELEASEMACHINEDIR/binary/gzimg/target.img.gz. params Display various make(1) parameters. - list-arch Display a list of valid MACHINE/MACHINE_ARCH values, - and exit. The list may be narrowed by passing glob - patterns or exact values in MACHINE or MACHINE_ARCH. Options: -a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE] @@ -1058,10 +895,7 @@ Usage: ${progname} [-EhnorUuxy] [-a arch -j njob Run up to njob jobs in parallel; see make(1) -j. -M obj Set obj root directory to obj; sets MAKEOBJDIRPREFIX. Unsets MAKEOBJDIR. - -m mach Set MACHINE to mach. Some mach values are actually - aliases that set MACHINE/MACHINE_ARCH pairs. - [Default: deduced from the host system if the host - OS is NetBSD] + -m mach Set MACHINE to mach; not required if NetBSD native. -N noisy Set the noisyness (MAKEVERBOSE) level of the build: 0 Minimal output ("quiet") 1 Describe what is occurring @@ -1099,7 +933,7 @@ _usage_ parseoptions() { opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:X:xY:yZ:' - opt_a=false + opt_a=no if type getopts >/dev/null 2>&1; then # Use POSIX getopts. @@ -1130,7 +964,7 @@ parseoptions() -a) eval ${optargcmd} MACHINE_ARCH=${OPTARG} - opt_a=true + opt_a=yes ;; -B) @@ -1177,6 +1011,7 @@ parseoptions() -m) eval ${optargcmd} MACHINE="${OPTARG}" + [ "${opt_a}" != "yes" ] && getarch ;; -N) @@ -1307,11 +1142,6 @@ parseoptions() usage ;; - list-arch) - listarch "${MACHINE}" "${MACHINE_ARCH}" - exit $? - ;; - makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params) ;; @@ -1331,21 +1161,13 @@ parseoptions() op=install_image # used as part of a variable name ;; - kernel=*|releasekernel=*|kernel.gdb=*) + kernel=*|releasekernel=*) arg=${op#*=} op=${op%%=*} [ -n "${arg}" ] || bomb "Must supply a kernel name with \`${op}=...'" ;; - disk-image=*) - arg=${op#*=} - op=disk_image - [ -n "${arg}" ] || - bomb "Must supply a target name with \`${op}=...'" - - ;; - modules) op=modules ;; @@ -1372,28 +1194,21 @@ parseoptions() # Set up MACHINE*. On a NetBSD host, these are allowed to be unset. # - # MACHINE_ARCH from the environment may be overridden by getarch - # (based on the MACHINE), but MACHINE_ARCH from the -a option should - # not be overridden. - # if [ -z "${MACHINE}" ]; then [ "${uname_s}" = "NetBSD" ] || bomb "MACHINE must be set, or -m must be used, for cross builds." MACHINE=${uname_m} fi - $opt_a || getarch + [ -n "${MACHINE_ARCH}" ] || getarch validatearch # Set up default make(1) environment. # makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS" [ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID" - [ -z "${BUILDINFO}" ] || makeenv="${makeenv} BUILDINFO" MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS}" MAKEFLAGS="${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}" export MAKEFLAGS MACHINE MACHINE_ARCH - setmakeenv USETOOLS "yes" - setmakeenv MAKEWRAPPERMACHINE "${makewrappermachine:-${MACHINE}}" } # sanitycheck -- @@ -1401,16 +1216,6 @@ parseoptions() # sanitycheck() { - # Install as non-root is a bad idea. - # - if ${do_install} && [ "$id_u" -ne 0 ] ; then - if ${do_expertmode}; then - warning "Will install as an unprivileged user." - else - bomb "-E must be set for install as an unprivileged user." - fi - fi - # If the PATH contains any non-absolute components (including, # but not limited to, "." or ""), then complain. As an exception, # allow "" or "." as the last component of the PATH. This is fatal @@ -1560,7 +1365,7 @@ print_tooldir_make() # 1. build a new version of nbmake in a temporary directory; # 2. use the temporary nbmake to create the top level obj directory; # 3. use $(getmakevar TOOLDIR) with the temporary nbmake to -# get the correct value of TOOLDIR; +# get the corect value of TOOLDIR; # 4. move the temporary nbmake to ${TOOLDIR}/bin/nbmake. # # However, people don't like building nbmake unnecessarily if their @@ -1594,8 +1399,7 @@ rebuildmake() ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \ CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \ ${HOST_SH} "${TOP}/tools/make/configure" || - ( cp ${tmpdir}/config.log ${tmpdir}-config.log - bomb "Configure of ${toolprefix}make failed, see ${tmpdir}-config.log for details" ) + bomb "Configure of ${toolprefix}make failed" ${runcmd} ${HOST_SH} buildmake.sh || bomb "Build of ${toolprefix}make failed" make="${tmpdir}/${toolprefix}make" @@ -1609,39 +1413,10 @@ rebuildmake() # Perform some late sanity checks, after rebuildmake, # but before createmakewrapper or any real work. # -# Creates the top-level obj directory, because that -# is needed by some of the sanity checks. -# -# Prints status messages reporting the values of several variables. +# Also create the top-level obj directory. # validatemakeparams() { - # MAKECONF (which defaults to /etc/mk.conf in share/mk/bsd.own.mk) - # can affect many things, so mention it in an early status message. - # - MAKECONF=$(getmakevar MAKECONF) - if [ -e "${MAKECONF}" ]; then - statusmsg2 "MAKECONF file:" "${MAKECONF}" - else - statusmsg2 "MAKECONF file:" "${MAKECONF} (File not found)" - fi - - # Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE. - # These may be set as build.sh options or in "mk.conf". - # Don't export them as they're only used for tests in build.sh. - # - MKOBJDIRS=$(getmakevar MKOBJDIRS) - MKUNPRIVED=$(getmakevar MKUNPRIVED) - MKUPDATE=$(getmakevar MKUPDATE) - - # Non-root should always use either the -U or -E flag. - # - if ! ${do_expertmode} && \ - [ "$id_u" -ne 0 ] && \ - [ "${MKUNPRIVED}" = "no" ] ; then - bomb "-U or -E must be set for build as an unprivileged user." - fi - if [ "${runcmd}" = "echo" ]; then TOOLCHAIN_MISSING=no EXTERNAL_TOOLCHAIN="" @@ -1663,6 +1438,14 @@ validatemakeparams() exit 1 fi + # Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE + # These may be set as build.sh options or in "mk.conf". + # Don't export them as they're only used for tests in build.sh. + # + MKOBJDIRS=$(getmakevar MKOBJDIRS) + MKUNPRIVED=$(getmakevar MKUNPRIVED) + MKUPDATE=$(getmakevar MKUPDATE) + if [ "${MKOBJDIRS}" != "no" ]; then # Create the top-level object directory. # @@ -1747,26 +1530,45 @@ validatemakeparams() removedirs="${TOOLDIR}" if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then - if ${do_distribution} || ${do_release} || \ - [ "${uname_s}" != "NetBSD" ] || \ - [ "${uname_m}" != "${MACHINE}" ]; then - bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'." - fi - if ! ${do_expertmode}; then - bomb "DESTDIR must != / for non -E (expert) builds" + if ${do_build} || ${do_distribution} || ${do_release}; then + if ! ${do_build} || \ + [ "${uname_s}" != "NetBSD" ] || \ + [ "${uname_m}" != "${MACHINE}" ]; then + bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'." + fi + if ! ${do_expertmode}; then + bomb "DESTDIR must != / for non -E (expert) builds" + fi + statusmsg "WARNING: Building to /, in expert mode." + statusmsg " This may cause your system to break! Reasons include:" + statusmsg " - your kernel is not up to date" + statusmsg " - the libraries or toolchain have changed" + statusmsg " YOU HAVE BEEN WARNED!" fi - statusmsg "WARNING: Building to /, in expert mode." - statusmsg " This may cause your system to break! Reasons include:" - statusmsg " - your kernel is not up to date" - statusmsg " - the libraries or toolchain have changed" - statusmsg " YOU HAVE BEEN WARNED!" else removedirs="${removedirs} ${DESTDIR}" fi + if ${do_build} || ${do_distribution} || ${do_release}; then + if ! ${do_expertmode} && \ + [ "$id_u" -ne 0 ] && \ + [ "${MKUNPRIVED}" = "no" ] ; then + bomb "-U or -E must be set for build as an unprivileged user." + fi + fi if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then bomb "Must set RELEASEDIR with \`releasekernel=...'" fi + # Install as non-root is a bad idea. + # + if ${do_install} && [ "$id_u" -ne 0 ] ; then + if ${do_expertmode}; then + warning "Will install as an unprivileged user." + else + bomb "-E must be set for install as an unprivileged user." + fi + fi + # If a previous build.sh run used -U (and therefore created a # METALOG file), then most subsequent build.sh runs must also # use -U. If DESTDIR is about to be removed, then don't perform @@ -1777,7 +1579,9 @@ validatemakeparams() # DESTDIR is about to be removed ;; *) - if [ -e "${DESTDIR}/METALOG" ] && \ + if ( ${do_build} || ${do_distribution} || ${do_release} || \ + ${do_install} ) && \ + [ -e "${DESTDIR}/METALOG" ] && \ [ "${MKUNPRIVED}" = "no" ] ; then if $do_expertmode; then warning "A previous build.sh run specified -U." @@ -1864,30 +1668,29 @@ createmakewrapper() eval cat <