Module Name:    src
Committed By:   apb
Date:           Fri Aug 15 18:34:19 UTC 2014

Modified Files:
        src: build.sh

Log Message:
Only the -m command line option, not MACHINE from the environment,
is supposed override MACHINE_ARCH from the environment with the
default MACHINE_ARCH for the requested machine.

Add and use an opt_m variable to enforce this.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/build.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/build.sh
diff -u src/build.sh:1.294 src/build.sh:1.295
--- src/build.sh:1.294	Sun Aug 10 05:56:36 2014
+++ src/build.sh	Fri Aug 15 18:34:19 2014
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#	$NetBSD: build.sh,v 1.294 2014/08/10 05:56:36 matt Exp $
+#	$NetBSD: build.sh,v 1.295 2014/08/15 18:34:19 apb Exp $
 #
 # Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1100,6 +1100,7 @@ parseoptions()
 {
 	opts='a:B:C:D:Ehj:M:m:N:nO:oR:rS:T:UuV:w:X:xY:yZ:'
 	opt_a=false
+	opt_m=false
 
 	if type getopts >/dev/null 2>&1; then
 		# Use POSIX getopts.
@@ -1177,6 +1178,7 @@ parseoptions()
 		-m)
 			eval ${optargcmd}
 			MACHINE="${OPTARG}"
+			opt_m=true
 			;;
 
 		-N)
@@ -1372,16 +1374,17 @@ 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
+	if $opt_m && ! $opt_a; then
+		# Settings implied by the command line -m option
+		# override MACHINE_ARCH from the environment (if any).
+		getarch
+	fi
+	[ -n "${MACHINE_ARCH}" ] || getarch
 	validatearch
 
 	# Set up default make(1) environment.
@@ -1864,7 +1867,7 @@ createmakewrapper()
 	eval cat <<EOF ${makewrapout}
 #! ${HOST_SH}
 # Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from:  \$NetBSD: build.sh,v 1.294 2014/08/10 05:56:36 matt Exp $
+# Generated from:  \$NetBSD: build.sh,v 1.295 2014/08/15 18:34:19 apb Exp $
 # with these arguments: ${_args}
 #
 

Reply via email to