proski | 1 Jun 04:03 2006

revision 1615 committed by proski

Project     : madwifi
Revision    : 1615
Author      : proski
Date        : 2006-06-01 04:03:09 +0200 (Thu, 01 Jun 2006)

Log Message :
Full rewrite of get_arch_target.sh

This was destined for Makefile.inc originally, and the code is still in
a format that would allow easy integration into a makefile.

If .config is missing, make it an error.

Separate ARCH and TARGET calculation.  ARCH can often be determined much
more reliably, so that part of code won't need to change much.

CONFIG_SPARC is not defined for 32-bit SPARC.  Use CONFIG_SPARC32
instead.

Determine endianess more reliably.  Don't use variable endianess for
CPUs when there is no choice in the kernel or in the HAL.

Recognize CONFIG_CPU_SA110 and CONFIG_CPU_SA1100 as xscale.

Initial attempt at distinguishing misp1, mips and mipsisa32 targets.

Affected Files:
* trunk/scripts/get_arch_target.sh                    updated             

Modified: trunk/scripts/get_arch_target.sh
===================================================================
--- trunk/scripts/get_arch_target.sh	2006-05-31 21:05:08 UTC (rev 1614)
+++ trunk/scripts/get_arch_target.sh	2006-06-01 02:03:09 UTC (rev 1615)
 <at>  <at>  -3,26 +3,80  <at>  <at> 
 # Report ARCH and TARGET for the given Linux .config file.
 # Argument 1 should be path to .config

-report () {
-	echo "$1 ${2-$1-elf}"
-	exit 0
-}
-
-test -r "$1" || report "" ""
+test -r "$1" || { echo "" ""; exit 1; }
 . "$1"

-test "$CONFIG_X86_64" && report x86_64
-test "$CONFIG_X86" && report i386
-test "$CONFIG_ALPHA" && report alpha
-test "$CONFIG_SPARC64" && report sparc64 sparc64-be-elf
-test "$CONFIG_SPARC" && report sparc sparc-be-elf
-test "$CONFIG_PPC32" && test "$CONFIG_PPC_MERGE" && report powerpc powerpc-be-elf
-test "$CONFIG_PPC32" && report ppc powerpc-be-elf
-test "$CONFIG_CPU_SH4" && report sh sh4-le-elf
-test "$CONFIG_CPU_XSCALE" && test "$CONFIG_CPU_BIG_ENDIAN" && report arm xscale-be-elf
-test "$CONFIG_CPU_XSCALE" && report arm xscale-le-elf
-test "$CONFIG_CPU_32v4" && test "$CONFIG_CPU_BIG_ENDIAN" && report arm armv4-be-elf
-test "$CONFIG_CPU_32v4" && report arm armv4-le-elf
-test "$CONFIG_MIPS" && test "$CONFIG_CPU_LITTLE_ENDIAN" && report mips mips1-le-elf
-test "$CONFIG_MIPS" && report mips mips1-be-elf
-report "" ""
+# Calculate ARCH first.  This covers all architectures supported by
+# Linux 2.4 and 2.6, whether they are supported by HAL or not.
+# Note that more specific entries must follow less specific ones, e.g.
+# CONFIG_X86_64 overrides CONFIG_X86.
+eval ARCH_${CONFIG_ALPHA}=alpha
+eval ARCH_${CONFIG_ARM}=arm
+eval ARCH_${CONFIG_ARM26}=arm26
+eval ARCH_${CONFIG_CRIS}=cris
+eval ARCH_${CONFIG_FRV}=frv
+eval ARCH_${CONFIG_H8300}=h8300
+eval ARCH_${CONFIG_X86}=i386
+eval ARCH_${CONFIG_IA64}=ia64
+eval ARCH_${CONFIG_M32R}=m32r
+eval ARCH_${CONFIG_M68K}=m68k
+eval ARCH_${CONFIG_M68KNOMMU}=m68knommu
+eval ARCH_${CONFIG_MIPS}=mips
+eval ARCH_${CONFIG_MIPS64}=mips64
+eval ARCH_${CONFIG_PARISC}=parisc
+eval ARCH_${CONFIG_PPC}=ppc
+eval ARCH_${CONFIG_PPC64}=ppc64
+eval ARCH_${CONFIG_PPC_MERGE}=powerpc
+eval ARCH_${CONFIG_ARCH_S390}=s390
+eval ARCH_${CONFIG_ARCH_S390X}=s390x
+eval ARCH_${CONFIG_SUPERH}=sh
+eval ARCH_${CONFIG_CPU_SH5}=sh64
+eval ARCH_${CONFIG_SUPERH64}=sh64
+eval ARCH_${CONFIG_SPARC32}=sparc
+eval ARCH_${CONFIG_SPARC64}=sparc64
+eval ARCH_${CONFIG_UML}=um
+eval ARCH_${CONFIG_V850}=v850
+eval ARCH_${CONFIG_X86_64}=x86_64
+eval ARCH_${CONFIG_XTENSA}=xtensa
+ARCH=${ARCH_y}
+
+
+# Determine endianess.  Note that it's not indicated for some CPUs at
+# all, so this value is only valid for certain processors.
+case ${ARCH} in
+	arm*) ENDIAN=le;;
+	mips*) ENDIAN=be;;
+esac
+
+if test -n "${CONFIG_CPU_BIG_ENDIAN}${CONFIG_BIG_ENDIAN}"; then
+	ENDIAN=be
+fi
+
+if test -n "${CONFIG_CPU_LITTLE_ENDIAN}${CONFIG_LITTLE_ENDIAN}"; then
+	ENDIAN=le
+fi
+
+
+# Determine the target (i.e. which HAL to use).
+# The default is ${ARCH}-elf
+eval TARGET_${CONFIG_CPU_32v4}=armv4-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_MIPS32_R1}=mips1-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_MIPS32_R2}=mips-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_R4X00}=mipsisa32-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_TX49XX}=mipsisa32-${ENDIAN}-elf
+eval TARGET_${CONFIG_PPC32}=powerpc-be-elf
+eval TARGET_${CONFIG_CPU_SH4}=sh4-le-elf
+eval TARGET_${CONFIG_SPARC32}=sparc-be-elf
+eval TARGET_${CONFIG_SPARC64}=sparc64-be-elf
+eval TARGET_${CONFIG_CPU_SA110}=xscale-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_SA1100}=xscale-${ENDIAN}-elf
+eval TARGET_${CONFIG_CPU_XSCALE}=xscale-${ENDIAN}-elf
+
+if test -n "${TARGET_y}"; then
+	TARGET="${TARGET_y}"
+else
+	TARGET="${ARCH}-elf"
+fi
+
+echo "${ARCH}" "${TARGET}"
+exit 0

-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642

Gmane