From 7b1a369cf7801f98139189ade463f3a460f78d85 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 28 Mar 2012 22:57:13 +0200 Subject: build system: completely autodetect target cpu architecture. The existing ARCH Makefile variable is exported to the C code as well. Additionally the version (arm-only for now) is detected as well. This allows to for complete autodetection, i.e. that optimized ASM is picked up if determined by preprocessor (CPU_ARM, etc). Building a sim/raaa on a arm host will now automatically generate a arm optmized build like we have for native targets. Change-Id: I0b35393f8fb3ebd20beaa9e7371fa57bf3782107 --- tools/configure | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'tools/configure') diff --git a/tools/configure b/tools/configure index ffded7eb87..5181ce4a19 100755 --- a/tools/configure +++ b/tools/configure @@ -523,6 +523,8 @@ arm7ejscc () { } mipselcc () { + arch="mips" + arch_version=32 # FIXME: autodetect version (32 or 64) prefixtools mipsel-elf- # mips is predefined, but we want it for paths. use __mips instead GCCOPTS="$CCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -Umips" @@ -3674,21 +3676,36 @@ if [ -z "$arch" ]; then arch="m68k" elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then arch="arm" + # cpp defines like "#define __ARM_ARCH_4TE__ 1" (where we want to extract the 4) + arch_version="$(echo $cpp_defines | sed s,\ ,\\n,g | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,')" elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then - arch="mips" + arch="mips" # FIXME: autodetect version (32 or 64) elif [ -n "$(echo $cpp_defines | grep -w _X86_)" ]; then arch="x86" elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then arch="amd64" else - arch="unknown" + arch="none" echo "Warning: Could not determine target arch" fi - if [ "$arch" != "unknown" ]; then - echo "Automatically selected arch: $arch" + if [ "$arch" != "none" ]; then + if [ -n "$arch_version" ]; then + echo "Automatically selected arch: $arch (ver $arch_version)" + else + echo "Automatically selected arch: $arch" + fi fi; else - echo "Manually selected arch: $arch" + if [ -n "$arch_version" ]; then + echo "Manually selected arch: $arch (ver $arch_version)" + else + echo "Manually selected arch: $arch" + fi +fi + +arch="arch_$arch" +if [ -n "$arch_version" ]; then + Darch_version="#define ARCH_VERSION $arch_version" fi if test -n "$ccache"; then @@ -3720,6 +3737,35 @@ cat > autoconf.h <