summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-03-28 22:57:13 +0200
committerThomas Martitz <kugel@rockbox.org>2012-03-28 23:02:39 +0200
commit7b1a369cf7801f98139189ade463f3a460f78d85 (patch)
tree27f7fb3628f5692f508c1e3e439fa9d657869c77
parentc56950ea3a9e0244461ce445f25bd7a80c8f7199 (diff)
downloadrockbox-7b1a369cf7801f98139189ade463f3a460f78d85.zip
rockbox-7b1a369cf7801f98139189ade463f3a460f78d85.tar.gz
rockbox-7b1a369cf7801f98139189ade463f3a460f78d85.tar.bz2
rockbox-7b1a369cf7801f98139189ade463f3a460f78d85.tar.xz
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
-rw-r--r--apps/codecs/codecs.make4
-rw-r--r--apps/codecs/demac/libdemac.make2
-rw-r--r--apps/codecs/lib/libcodec.make2
-rw-r--r--apps/codecs/libmad/libmad.make2
-rw-r--r--apps/codecs/libspeex/libspeex.make2
-rw-r--r--apps/codecs/libwmavoice/libwmavoice.make2
-rw-r--r--firmware/asm/asm.make3
-rw-r--r--firmware/export/config.h30
-rwxr-xr-xtools/configure57
-rw-r--r--tools/root.make4
10 files changed, 69 insertions, 39 deletions
diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make
index 605d8a3..f2d2f13 100644
--- a/apps/codecs/codecs.make
+++ b/apps/codecs/codecs.make
@@ -88,7 +88,7 @@ $(WMAPROLIB) : CODECFLAGS += -O1
$(WMAVOICELIB) : CODECFLAGS += -O1
# fine-tuning of CODECFLAGS per cpu arch
-ifeq ($(ARCH),arm)
+ifeq ($(ARCH),arch_arm)
# redo per arm generation
$(ALACLIB) : CODECFLAGS += -O2
$(AYLIB) : CODECFLAGS += -O1
@@ -100,7 +100,7 @@ ifeq ($(ARCH),arm)
$(VGMLIB) : CODECFLAGS += -O1
$(EMU2413LIB) : CODECFLAGS += -O3
$(WAVPACKLIB) : CODECFLAGS += -O3
-else ifeq ($(ARCH),m68k)
+else ifeq ($(ARCH),arch_m68k)
$(A52LIB) : CODECFLAGS += -O2
$(ASFLIB) : CODECFLAGS += -O3
$(ATRACLIB) : CODECFLAGS += -O2
diff --git a/apps/codecs/demac/libdemac.make b/apps/codecs/demac/libdemac.make
index 4614344..62ad53d 100644
--- a/apps/codecs/demac/libdemac.make
+++ b/apps/codecs/demac/libdemac.make
@@ -12,7 +12,7 @@ DEMACLIB := $(CODECDIR)/libdemac.a
DEMACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/demac/libdemac/SOURCES)
DEMACLIB_OBJ := $(call c2obj, $(DEMACLIB_SRC))
OTHER_SRC += $(DEMACLIB_SRC)
-ifeq ($(CPU),arm)
+ifeq ($(ARCH),arch_arm)
OTHER_SRC += $(APPSDIR)/codecs/demac/libdemac/udiv32_arm-pre.S
endif
DEMACLIB_PRE := $(subst .a,-pre.a,$(DEMACLIB))
diff --git a/apps/codecs/lib/libcodec.make b/apps/codecs/lib/libcodec.make
index ca9b2c4..7aef72f 100644
--- a/apps/codecs/lib/libcodec.make
+++ b/apps/codecs/lib/libcodec.make
@@ -20,7 +20,7 @@ CODECLIBFLAGS = $(filter-out -O%,$(CODECFLAGS))
ifeq ($(MEMORYSIZE),2)
CODECLIBFLAGS += -Os
-else ifeq ($(CPU),coldfire)
+else ifeq ($(ARCH),arch_m68k)
CODECLIBFLAGS += -O2
else
CODECLIBFLAGS += -O1
diff --git a/apps/codecs/libmad/libmad.make b/apps/codecs/libmad/libmad.make
index f8423b8..4ed8ab1 100644
--- a/apps/codecs/libmad/libmad.make
+++ b/apps/codecs/libmad/libmad.make
@@ -16,7 +16,7 @@ MADFLAGS = $(filter-out -O%,$(CODECFLAGS)) -I$(APPSDIR)/codecs/libmad
MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H
# libmad is faster on ARM-targets with -O1 than -O2
-ifeq ($(CPU),arm)
+ifeq ($(ARCH),arch_arm)
MADFLAGS += -O1
else
MADFLAGS += -O2
diff --git a/apps/codecs/libspeex/libspeex.make b/apps/codecs/libspeex/libspeex.make
index cc2c3ca..1089982 100644
--- a/apps/codecs/libspeex/libspeex.make
+++ b/apps/codecs/libspeex/libspeex.make
@@ -23,7 +23,7 @@ VOICESPEEXFLAGS = $(filter-out -ffunction-sections, $(filter-out -DCODEC,$(_SPEE
# libspeex is faster on ARM-targets with -O1 instead of -O2
SPEEXFLAGS = $(filter-out -O%,$(_SPEEXFLAGS))
-ifeq ($(CPU),arm)
+ifeq ($(ARCH),arch_arm)
SPEEXFLAGS += -O1
else
SPEEXFLAGS += -O2
diff --git a/apps/codecs/libwmavoice/libwmavoice.make b/apps/codecs/libwmavoice/libwmavoice.make
index 0497e18..b35756c 100644
--- a/apps/codecs/libwmavoice/libwmavoice.make
+++ b/apps/codecs/libwmavoice/libwmavoice.make
@@ -19,7 +19,7 @@ $(WMAVOICELIB): $(WMAVOICELIB_OBJ)
WMAVOICEFLAGS = -I$(APPSDIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS))
-ifeq ($(CPU),coldfire)
+ifeq ($(ARCH),arch_m68k)
WMAVOICEFLAGS += -O2
else
WMAVOICEFLAGS += -O1
diff --git a/firmware/asm/asm.make b/firmware/asm/asm.make
index 17b666e..69147c5 100644
--- a/firmware/asm/asm.make
+++ b/firmware/asm/asm.make
@@ -10,8 +10,9 @@
# Collect dummy C files in firmware/asm
ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES))
+ASM_ARCH := $(subst arch_,,$(ARCH)) # strip arch_ prefix from $(ARCH)
# Get the corresponding real source files under firmware/asm/$ARCH (C or ASM)
-ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ARCH)/,$(ASM_DUMMY_SRC))
+ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ASM_ARCH)/,$(ASM_DUMMY_SRC))
ASM_S_SRC := $(ASM_C_SRC:.c=.S)
# ASM_SRC now contains only files that exist under $ARCH
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 80bd83d..254128c 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -526,12 +526,12 @@ Lyre prototype 1 */
#ifndef __PCTOOL__
/* define for all cpus from SH family */
-#if (CONFIG_CPU == SH7034)
+#if (ARCH == ARCH_SH) && (CONFIG_CPU == SH7034)
#define CPU_SH
#endif
/* define for all cpus from coldfire family */
-#if (CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250)
+#if (ARCH == ARCH_M68K) && ((CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250))
#define CPU_COLDFIRE
#endif
@@ -565,31 +565,13 @@ Lyre prototype 1 */
#endif
/* define for all cpus from ARM family */
-#if ((CONFIG_PLATFORM & PLATFORM_MAEMO5) && defined(MAEMO_ARM_BUILD)) \
- || (CONFIG_PLATFORM & PLATFORM_PANDORA)
+#if ARCH == ARCH_ARM
#define CPU_ARM
-#define ARM_ARCH 7 /* ARMv7 */
-
-#elif (CONFIG_CPU == IMX31L) || defined(SAMSUNG_YPR0) \
- || ((CONFIG_PLATFORM & PLATFORM_MAEMO4) && defined(MAEMO_ARM_BUILD))
-#define CPU_ARM
-#define ARM_ARCH 6 /* ARMv6 */
-
-#elif defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \
- || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) \
- || (CONFIG_CPU == S5L8702) || (CONFIG_CPU == IMX233) \
- || (CONFIG_CPU == RK27XX) ||(CONFIG_PLATFORM & PLATFORM_ANDROID)
-#define CPU_ARM
-#define ARM_ARCH 5 /* ARMv5 */
-
-#elif defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \
- || (CONFIG_CPU == DSC25) || defined(CPU_S5L870X) || (CONFIG_CPU == AS3525)
-#define CPU_ARM
-#define ARM_ARCH 4 /* ARMv4 */
+#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7} */
#endif
-#if (CONFIG_CPU == JZ4732)
-#define CPU_MIPS 32
+#if ARCH == ARCH_MIPS
+#define CPU_MIPS ARCH_VERSION /* 32, 64 */
#endif
#endif /*__PCTOOL__*/
diff --git a/tools/configure b/tools/configure
index ffded7e..5181ce4 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 <<EOF
#ifndef __BUILD_AUTOCONF_H
#define __BUILD_AUTOCONF_H
+/* lower case names match the what's exported in the Makefile
+ * upper case name looks nicer in the code */
+
+#define arch_none 0
+#define ARCH_NONE 0
+
+#define arch_sh 1
+#define ARCH_SH 1
+
+#define arch_m68k 2
+#define ARCH_M68K 2
+
+#define arch_arm 3
+#define ARCH_ARM 3
+
+#define arch_mips 4
+#define ARCH_MIPS 4
+
+#define arch_x86 5
+#define ARCH_X86 5
+
+#define arch_amd64 6
+#define ARCH_AMD64 6
+
+/* Define target machine architecture */
+#define ARCH ${arch}
+/* Optinally define architecture version */
+${Darch_version}
+
/* Define endianess for the target or simulator platform */
#define ${defendian} 1
@@ -3827,6 +3873,7 @@ export FLASHFILE=${flash}
export TARGET_ID=${target_id}
export TARGET=-D${target}
export ARCH=${arch}
+export ARCH_VERSION=${arch_version}
export CPU=${t_cpu}
export MANUFACTURER=${t_manufacturer}
export OBJDIR=${pwd}
diff --git a/tools/root.make b/tools/root.make
index 51886a0..b12ed2a 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -79,12 +79,12 @@ endif
#included before codecs.make and plugins.make so they see them)
ifndef APP_TYPE
include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
- ifeq (arm,$(ARCH))
+ ifeq (arch_arm,$(ARCH))
include $(ROOTDIR)/lib/arm_support/arm_support.make
endif
endif
-ifeq (arm,$(ARCH))
+ifeq (arch_arm,$(ARCH))
include $(ROOTDIR)/lib/unwarminder/unwarminder.make
endif