diff --git a/build.sh b/build.sh index 7cbcd95af138..4a6748bfbeb7 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.203 2009/02/25 23:34:10 lukem Exp $ +# $NetBSD: build.sh,v 1.204 2009/03/06 16:29:40 apb Exp $ # # Copyright (c) 2001-2009 The NetBSD Foundation, Inc. # All rights reserved. @@ -163,14 +163,23 @@ initdefaults() [ -f share/mk/bsd.own.mk ] || bomb "src/share/mk is missing; please re-fetch the source tree" - # Find information about the build platform. Note that "uname -p" - # is not part of POSIX, but NetBSD's uname -p prints MACHINE_ARCH, - # while uname -m prints MACHINE. + # Find information about the build platform. This should be + # kept in sync with _HOST_OSNAME, _HOST_OSREL, and _HOST_ARCH + # variables in share/mk/bsd.sys.mk. + # + # Note that "uname -p" is not part of POSIX, but we want uname_p + # to be set to the host MACHINE_ARCH, if possible. On systems + # where "uname -p" fails, prints "unknown", or prints a string + # that does not look like an identifier, fall back to using the + # output from "uname -m" instead. # uname_s=$(uname -s 2>/dev/null) uname_r=$(uname -r 2>/dev/null) uname_m=$(uname -m 2>/dev/null) - uname_p=$(uname -p 2>/dev/null || uname -m 2>/dev/null) + uname_p=$(uname -p 2>/dev/null || echo "unknown") + case "${uname_p}" in + ''|unknown|*[^a-z0-9]*) uname_p="${uname_m}" ;; + esac id_u=$(id -u 2>/dev/null || /usr/xpg4/bin/id -u 2>/dev/null) @@ -1204,7 +1213,7 @@ createmakewrapper() eval cat </dev/null || uname -m +# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints +# something that does not look like an identifier, then use uname -m. +_HOST_ARCH!= uname -p 2>/dev/null +_HOST_ARCH:= ${HOST_ARCH:tW:C/.*[^a-z0-9].*//:S/unknown//} +.if empty(_HOST_ARCH) +_HOST_ARCH!= uname -m +.endif HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g} .MAKEOVERRIDES+= HOST_OSTYPE -.endif +.endif # !defined(HOST_OSTYPE) .if ${USETOOLS} == "yes" # {