[arm] Automate --with-cpu

Paul Brook paul@codesourcery.com
Fri Apr 30 14:59:00 GMT 2004


On Thursday 29 April 2004 16:42, Nathanael Nerode wrote:
> I like the concept, but:
>
> +                       # See if it matches any of the entries in
> arm-cores.def eval "val=\$with_$which"
> !                       [ x"$val" = x ] && val=unset
> !                       for opt in `sed -e '/ARM_CORE/!d' \
> !                         -e 's/ARM_CORE(\([^,]*\),.*$/\1/' \
> !                         ${srcdir}/config/arm/arm-cores.def` unset .
> !                       do
> !                               [ x$opt = x"$val" ] && break
> !                       done
>
> Isn't there a clearer way to write this logic?  It's hideously unreadable.

Now I think about it, there is.

Tested with cross to arm-none-elf.
Ok?

Paul

2004-04-30  Paul Brook  <paul@codesourcery.com>

	* config.gcc: Simplify arm --with-{cpu,tune} test.

Index: config.gcc
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config.gcc,v
retrieving revision 1.454
diff -u -p -r1.454 config.gcc
--- a/config.gcc	30 Apr 2004 13:14:02 -0000	1.454
+++ b/config.gcc	30 Apr 2004 14:13:07 -0000
@@ -2223,17 +2223,15 @@ fi
 		for which in cpu tune; do
 			# See if it matches any of the entries in arm-cores.def
 			eval "val=\$with_$which"
-			[ x"$val" = x ] && val=unset
-			for opt in `sed -e '/ARM_CORE/!d' \
-			  -e 's/ARM_CORE(\([^,]*\),.*$/\1/' \
-			  ${srcdir}/config/arm/arm-cores.def` unset .
-			do
-				[ x$opt = x"$val" ] && break
-			done
-			if [ $opt = . ]; then
-				echo "Unknown CPU used in --with-$which=$val" 1>&2
-				exit 1
-			  
+			if [ x"$val" = x ] \
+			    || grep "^ARM_CORE($val," \
+				    ${srcdir}/config/arm/arm-cores.def \
+				    > /dev/null; then
+			  # Ok
+			  true
+			else
+			  echo "Unknown CPU used in --with-$which=$val" 1>&2
+			  exit 1
 			fi
 		done
 



More information about the Gcc-patches mailing list