Module Name: src Committed By: apb Date: Thu Aug 7 17:54:28 UTC 2014
Modified Files: src: build.sh Log Message: Add a list-arch operation to build.sh. This lists all known MACHINE/MACHINE_ARCH values, optionally filtered by glob patterns given in the "-m" and "-a" options. For example: build.sh -a '*arm*' list-arch To generate a diff of this commit: cvs rdiff -u -r1.291 -r1.292 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.291 src/build.sh:1.292 --- src/build.sh:1.291 Thu Aug 7 15:15:48 2014 +++ src/build.sh Thu Aug 7 17:54:28 2014 @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.291 2014/08/07 15:15:48 apb Exp $ +# $NetBSD: build.sh,v 1.292 2014/08/07 17:54:28 apb Exp $ # # Copyright (c) 2001-2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -848,6 +848,57 @@ validatearch() 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 + + if $line_matches_machine && $line_matches_arch; then + found=true + echo "$line" + fi + done + if ! $found; then + echo >&2 "No match for" \ + "MACHINE=${machglob} MACHINE_ARCH=${archglob}" + return 1 + fi + return 0 +} + # nobomb_getmakevar -- # Given the name of a make variable in $1, print make's idea of the # value of that variable, or return 1 if there's an error. @@ -990,6 +1041,9 @@ Usage: ${progname} [-EhnorUuxy] [-a arch 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] @@ -1121,7 +1175,6 @@ parseoptions() -m) eval ${optargcmd} MACHINE="${OPTARG}" - [ "${opt_a}" != "yes" ] && getarch ;; -N) @@ -1252,6 +1305,11 @@ parseoptions() usage ;; + list-arch) + listarch "${MACHINE}" "${MACHINE_ARCH}" + exit $? + ;; + makewrapper|cleandir|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params) ;; @@ -1800,7 +1858,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.291 2014/08/07 15:15:48 apb Exp $ +# Generated from: \$NetBSD: build.sh,v 1.292 2014/08/07 17:54:28 apb Exp $ # with these arguments: ${_args} #