diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-03-28 22:57:13 +0200 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-03-28 23:02:39 +0200 |
commit | 7b1a369cf7801f98139189ade463f3a460f78d85 (patch) | |
tree | 27f7fb3628f5692f508c1e3e439fa9d657869c77 /tools/configure | |
parent | c56950ea3a9e0244461ce445f25bd7a80c8f7199 (diff) | |
download | rockbox-7b1a369cf7801f98139189ade463f3a460f78d85.tar.gz rockbox-7b1a369cf7801f98139189ade463f3a460f78d85.zip |
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
Diffstat (limited to 'tools/configure')
-rwxr-xr-x | tools/configure | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/tools/configure b/tools/configure index ffded7eb87..5181ce4a19 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -523,6 +523,8 @@ arm7ejscc () { | |||
523 | } | 523 | } |
524 | 524 | ||
525 | mipselcc () { | 525 | mipselcc () { |
526 | arch="mips" | ||
527 | arch_version=32 # FIXME: autodetect version (32 or 64) | ||
526 | prefixtools mipsel-elf- | 528 | prefixtools mipsel-elf- |
527 | # mips is predefined, but we want it for paths. use __mips instead | 529 | # mips is predefined, but we want it for paths. use __mips instead |
528 | GCCOPTS="$CCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -Umips" | 530 | GCCOPTS="$CCOPTS -march=mips32 -mtune=r4600 -mno-mips16 -mno-long-calls -Umips" |
@@ -3674,21 +3676,36 @@ if [ -z "$arch" ]; then | |||
3674 | arch="m68k" | 3676 | arch="m68k" |
3675 | elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then | 3677 | elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then |
3676 | arch="arm" | 3678 | arch="arm" |
3679 | # cpp defines like "#define __ARM_ARCH_4TE__ 1" (where we want to extract the 4) | ||
3680 | arch_version="$(echo $cpp_defines | sed s,\ ,\\n,g | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,')" | ||
3677 | elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then | 3681 | elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then |
3678 | arch="mips" | 3682 | arch="mips" # FIXME: autodetect version (32 or 64) |
3679 | elif [ -n "$(echo $cpp_defines | grep -w _X86_)" ]; then | 3683 | elif [ -n "$(echo $cpp_defines | grep -w _X86_)" ]; then |
3680 | arch="x86" | 3684 | arch="x86" |
3681 | elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then | 3685 | elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then |
3682 | arch="amd64" | 3686 | arch="amd64" |
3683 | else | 3687 | else |
3684 | arch="unknown" | 3688 | arch="none" |
3685 | echo "Warning: Could not determine target arch" | 3689 | echo "Warning: Could not determine target arch" |
3686 | fi | 3690 | fi |
3687 | if [ "$arch" != "unknown" ]; then | 3691 | if [ "$arch" != "none" ]; then |
3688 | echo "Automatically selected arch: $arch" | 3692 | if [ -n "$arch_version" ]; then |
3693 | echo "Automatically selected arch: $arch (ver $arch_version)" | ||
3694 | else | ||
3695 | echo "Automatically selected arch: $arch" | ||
3696 | fi | ||
3689 | fi; | 3697 | fi; |
3690 | else | 3698 | else |
3691 | echo "Manually selected arch: $arch" | 3699 | if [ -n "$arch_version" ]; then |
3700 | echo "Manually selected arch: $arch (ver $arch_version)" | ||
3701 | else | ||
3702 | echo "Manually selected arch: $arch" | ||
3703 | fi | ||
3704 | fi | ||
3705 | |||
3706 | arch="arch_$arch" | ||
3707 | if [ -n "$arch_version" ]; then | ||
3708 | Darch_version="#define ARCH_VERSION $arch_version" | ||
3692 | fi | 3709 | fi |
3693 | 3710 | ||
3694 | if test -n "$ccache"; then | 3711 | if test -n "$ccache"; then |
@@ -3720,6 +3737,35 @@ cat > autoconf.h <<EOF | |||
3720 | #ifndef __BUILD_AUTOCONF_H | 3737 | #ifndef __BUILD_AUTOCONF_H |
3721 | #define __BUILD_AUTOCONF_H | 3738 | #define __BUILD_AUTOCONF_H |
3722 | 3739 | ||
3740 | /* lower case names match the what's exported in the Makefile | ||
3741 | * upper case name looks nicer in the code */ | ||
3742 | |||
3743 | #define arch_none 0 | ||
3744 | #define ARCH_NONE 0 | ||
3745 | |||
3746 | #define arch_sh 1 | ||
3747 | #define ARCH_SH 1 | ||
3748 | |||
3749 | #define arch_m68k 2 | ||
3750 | #define ARCH_M68K 2 | ||
3751 | |||
3752 | #define arch_arm 3 | ||
3753 | #define ARCH_ARM 3 | ||
3754 | |||
3755 | #define arch_mips 4 | ||
3756 | #define ARCH_MIPS 4 | ||
3757 | |||
3758 | #define arch_x86 5 | ||
3759 | #define ARCH_X86 5 | ||
3760 | |||
3761 | #define arch_amd64 6 | ||
3762 | #define ARCH_AMD64 6 | ||
3763 | |||
3764 | /* Define target machine architecture */ | ||
3765 | #define ARCH ${arch} | ||
3766 | /* Optinally define architecture version */ | ||
3767 | ${Darch_version} | ||
3768 | |||
3723 | /* Define endianess for the target or simulator platform */ | 3769 | /* Define endianess for the target or simulator platform */ |
3724 | #define ${defendian} 1 | 3770 | #define ${defendian} 1 |
3725 | 3771 | ||
@@ -3827,6 +3873,7 @@ export FLASHFILE=${flash} | |||
3827 | export TARGET_ID=${target_id} | 3873 | export TARGET_ID=${target_id} |
3828 | export TARGET=-D${target} | 3874 | export TARGET=-D${target} |
3829 | export ARCH=${arch} | 3875 | export ARCH=${arch} |
3876 | export ARCH_VERSION=${arch_version} | ||
3830 | export CPU=${t_cpu} | 3877 | export CPU=${t_cpu} |
3831 | export MANUFACTURER=${t_manufacturer} | 3878 | export MANUFACTURER=${t_manufacturer} |
3832 | export OBJDIR=${pwd} | 3879 | export OBJDIR=${pwd} |