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 | |
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
-rw-r--r-- | apps/codecs/codecs.make | 4 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac.make | 2 | ||||
-rw-r--r-- | apps/codecs/lib/libcodec.make | 2 | ||||
-rw-r--r-- | apps/codecs/libmad/libmad.make | 2 | ||||
-rw-r--r-- | apps/codecs/libspeex/libspeex.make | 2 | ||||
-rw-r--r-- | apps/codecs/libwmavoice/libwmavoice.make | 2 | ||||
-rw-r--r-- | firmware/asm/asm.make | 3 | ||||
-rw-r--r-- | firmware/export/config.h | 30 | ||||
-rwxr-xr-x | tools/configure | 57 | ||||
-rw-r--r-- | tools/root.make | 4 |
10 files changed, 69 insertions, 39 deletions
diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make index 605d8a3556..f2d2f13794 100644 --- a/apps/codecs/codecs.make +++ b/apps/codecs/codecs.make | |||
@@ -88,7 +88,7 @@ $(WMAPROLIB) : CODECFLAGS += -O1 | |||
88 | $(WMAVOICELIB) : CODECFLAGS += -O1 | 88 | $(WMAVOICELIB) : CODECFLAGS += -O1 |
89 | 89 | ||
90 | # fine-tuning of CODECFLAGS per cpu arch | 90 | # fine-tuning of CODECFLAGS per cpu arch |
91 | ifeq ($(ARCH),arm) | 91 | ifeq ($(ARCH),arch_arm) |
92 | # redo per arm generation | 92 | # redo per arm generation |
93 | $(ALACLIB) : CODECFLAGS += -O2 | 93 | $(ALACLIB) : CODECFLAGS += -O2 |
94 | $(AYLIB) : CODECFLAGS += -O1 | 94 | $(AYLIB) : CODECFLAGS += -O1 |
@@ -100,7 +100,7 @@ ifeq ($(ARCH),arm) | |||
100 | $(VGMLIB) : CODECFLAGS += -O1 | 100 | $(VGMLIB) : CODECFLAGS += -O1 |
101 | $(EMU2413LIB) : CODECFLAGS += -O3 | 101 | $(EMU2413LIB) : CODECFLAGS += -O3 |
102 | $(WAVPACKLIB) : CODECFLAGS += -O3 | 102 | $(WAVPACKLIB) : CODECFLAGS += -O3 |
103 | else ifeq ($(ARCH),m68k) | 103 | else ifeq ($(ARCH),arch_m68k) |
104 | $(A52LIB) : CODECFLAGS += -O2 | 104 | $(A52LIB) : CODECFLAGS += -O2 |
105 | $(ASFLIB) : CODECFLAGS += -O3 | 105 | $(ASFLIB) : CODECFLAGS += -O3 |
106 | $(ATRACLIB) : CODECFLAGS += -O2 | 106 | $(ATRACLIB) : CODECFLAGS += -O2 |
diff --git a/apps/codecs/demac/libdemac.make b/apps/codecs/demac/libdemac.make index 4614344849..62ad53dfcc 100644 --- a/apps/codecs/demac/libdemac.make +++ b/apps/codecs/demac/libdemac.make | |||
@@ -12,7 +12,7 @@ DEMACLIB := $(CODECDIR)/libdemac.a | |||
12 | DEMACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/demac/libdemac/SOURCES) | 12 | DEMACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/demac/libdemac/SOURCES) |
13 | DEMACLIB_OBJ := $(call c2obj, $(DEMACLIB_SRC)) | 13 | DEMACLIB_OBJ := $(call c2obj, $(DEMACLIB_SRC)) |
14 | OTHER_SRC += $(DEMACLIB_SRC) | 14 | OTHER_SRC += $(DEMACLIB_SRC) |
15 | ifeq ($(CPU),arm) | 15 | ifeq ($(ARCH),arch_arm) |
16 | OTHER_SRC += $(APPSDIR)/codecs/demac/libdemac/udiv32_arm-pre.S | 16 | OTHER_SRC += $(APPSDIR)/codecs/demac/libdemac/udiv32_arm-pre.S |
17 | endif | 17 | endif |
18 | DEMACLIB_PRE := $(subst .a,-pre.a,$(DEMACLIB)) | 18 | DEMACLIB_PRE := $(subst .a,-pre.a,$(DEMACLIB)) |
diff --git a/apps/codecs/lib/libcodec.make b/apps/codecs/lib/libcodec.make index ca9b2c4fe2..7aef72f2b1 100644 --- a/apps/codecs/lib/libcodec.make +++ b/apps/codecs/lib/libcodec.make | |||
@@ -20,7 +20,7 @@ CODECLIBFLAGS = $(filter-out -O%,$(CODECFLAGS)) | |||
20 | 20 | ||
21 | ifeq ($(MEMORYSIZE),2) | 21 | ifeq ($(MEMORYSIZE),2) |
22 | CODECLIBFLAGS += -Os | 22 | CODECLIBFLAGS += -Os |
23 | else ifeq ($(CPU),coldfire) | 23 | else ifeq ($(ARCH),arch_m68k) |
24 | CODECLIBFLAGS += -O2 | 24 | CODECLIBFLAGS += -O2 |
25 | else | 25 | else |
26 | CODECLIBFLAGS += -O1 | 26 | CODECLIBFLAGS += -O1 |
diff --git a/apps/codecs/libmad/libmad.make b/apps/codecs/libmad/libmad.make index f8423b88fe..4ed8ab1e8c 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 | |||
16 | MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H | 16 | MADFLAGS += -UDEBUG -DNDEBUG -DHAVE_LIMITS_H |
17 | 17 | ||
18 | # libmad is faster on ARM-targets with -O1 than -O2 | 18 | # libmad is faster on ARM-targets with -O1 than -O2 |
19 | ifeq ($(CPU),arm) | 19 | ifeq ($(ARCH),arch_arm) |
20 | MADFLAGS += -O1 | 20 | MADFLAGS += -O1 |
21 | else | 21 | else |
22 | MADFLAGS += -O2 | 22 | MADFLAGS += -O2 |
diff --git a/apps/codecs/libspeex/libspeex.make b/apps/codecs/libspeex/libspeex.make index cc2c3caee1..1089982d27 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 | |||
23 | # libspeex is faster on ARM-targets with -O1 instead of -O2 | 23 | # libspeex is faster on ARM-targets with -O1 instead of -O2 |
24 | SPEEXFLAGS = $(filter-out -O%,$(_SPEEXFLAGS)) | 24 | SPEEXFLAGS = $(filter-out -O%,$(_SPEEXFLAGS)) |
25 | 25 | ||
26 | ifeq ($(CPU),arm) | 26 | ifeq ($(ARCH),arch_arm) |
27 | SPEEXFLAGS += -O1 | 27 | SPEEXFLAGS += -O1 |
28 | else | 28 | else |
29 | SPEEXFLAGS += -O2 | 29 | SPEEXFLAGS += -O2 |
diff --git a/apps/codecs/libwmavoice/libwmavoice.make b/apps/codecs/libwmavoice/libwmavoice.make index 0497e18e1b..b35756c64a 100644 --- a/apps/codecs/libwmavoice/libwmavoice.make +++ b/apps/codecs/libwmavoice/libwmavoice.make | |||
@@ -19,7 +19,7 @@ $(WMAVOICELIB): $(WMAVOICELIB_OBJ) | |||
19 | 19 | ||
20 | WMAVOICEFLAGS = -I$(APPSDIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS)) | 20 | WMAVOICEFLAGS = -I$(APPSDIR)/codecs/libwmavoice $(filter-out -O%,$(CODECFLAGS)) |
21 | 21 | ||
22 | ifeq ($(CPU),coldfire) | 22 | ifeq ($(ARCH),arch_m68k) |
23 | WMAVOICEFLAGS += -O2 | 23 | WMAVOICEFLAGS += -O2 |
24 | else | 24 | else |
25 | WMAVOICEFLAGS += -O1 | 25 | WMAVOICEFLAGS += -O1 |
diff --git a/firmware/asm/asm.make b/firmware/asm/asm.make index 17b666ee5e..69147c506e 100644 --- a/firmware/asm/asm.make +++ b/firmware/asm/asm.make | |||
@@ -10,8 +10,9 @@ | |||
10 | # Collect dummy C files in firmware/asm | 10 | # Collect dummy C files in firmware/asm |
11 | ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES)) | 11 | ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES)) |
12 | 12 | ||
13 | ASM_ARCH := $(subst arch_,,$(ARCH)) # strip arch_ prefix from $(ARCH) | ||
13 | # Get the corresponding real source files under firmware/asm/$ARCH (C or ASM) | 14 | # Get the corresponding real source files under firmware/asm/$ARCH (C or ASM) |
14 | ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ARCH)/,$(ASM_DUMMY_SRC)) | 15 | ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ASM_ARCH)/,$(ASM_DUMMY_SRC)) |
15 | ASM_S_SRC := $(ASM_C_SRC:.c=.S) | 16 | ASM_S_SRC := $(ASM_C_SRC:.c=.S) |
16 | 17 | ||
17 | # ASM_SRC now contains only files that exist under $ARCH | 18 | # ASM_SRC now contains only files that exist under $ARCH |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 80bd83d61d..254128c844 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -526,12 +526,12 @@ Lyre prototype 1 */ | |||
526 | #ifndef __PCTOOL__ | 526 | #ifndef __PCTOOL__ |
527 | 527 | ||
528 | /* define for all cpus from SH family */ | 528 | /* define for all cpus from SH family */ |
529 | #if (CONFIG_CPU == SH7034) | 529 | #if (ARCH == ARCH_SH) && (CONFIG_CPU == SH7034) |
530 | #define CPU_SH | 530 | #define CPU_SH |
531 | #endif | 531 | #endif |
532 | 532 | ||
533 | /* define for all cpus from coldfire family */ | 533 | /* define for all cpus from coldfire family */ |
534 | #if (CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250) | 534 | #if (ARCH == ARCH_M68K) && ((CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250)) |
535 | #define CPU_COLDFIRE | 535 | #define CPU_COLDFIRE |
536 | #endif | 536 | #endif |
537 | 537 | ||
@@ -565,31 +565,13 @@ Lyre prototype 1 */ | |||
565 | #endif | 565 | #endif |
566 | 566 | ||
567 | /* define for all cpus from ARM family */ | 567 | /* define for all cpus from ARM family */ |
568 | #if ((CONFIG_PLATFORM & PLATFORM_MAEMO5) && defined(MAEMO_ARM_BUILD)) \ | 568 | #if ARCH == ARCH_ARM |
569 | || (CONFIG_PLATFORM & PLATFORM_PANDORA) | ||
570 | #define CPU_ARM | 569 | #define CPU_ARM |
571 | #define ARM_ARCH 7 /* ARMv7 */ | 570 | #define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7} */ |
572 | |||
573 | #elif (CONFIG_CPU == IMX31L) || defined(SAMSUNG_YPR0) \ | ||
574 | || ((CONFIG_PLATFORM & PLATFORM_MAEMO4) && defined(MAEMO_ARM_BUILD)) | ||
575 | #define CPU_ARM | ||
576 | #define ARM_ARCH 6 /* ARMv6 */ | ||
577 | |||
578 | #elif defined(CPU_TCC77X) || defined(CPU_TCC780X) || (CONFIG_CPU == DM320) \ | ||
579 | || (CONFIG_CPU == AT91SAM9260) || (CONFIG_CPU == AS3525v2) \ | ||
580 | || (CONFIG_CPU == S5L8702) || (CONFIG_CPU == IMX233) \ | ||
581 | || (CONFIG_CPU == RK27XX) ||(CONFIG_PLATFORM & PLATFORM_ANDROID) | ||
582 | #define CPU_ARM | ||
583 | #define ARM_ARCH 5 /* ARMv5 */ | ||
584 | |||
585 | #elif defined(CPU_PP) || (CONFIG_CPU == PNX0101) || (CONFIG_CPU == S3C2440) \ | ||
586 | || (CONFIG_CPU == DSC25) || defined(CPU_S5L870X) || (CONFIG_CPU == AS3525) | ||
587 | #define CPU_ARM | ||
588 | #define ARM_ARCH 4 /* ARMv4 */ | ||
589 | #endif | 571 | #endif |
590 | 572 | ||
591 | #if (CONFIG_CPU == JZ4732) | 573 | #if ARCH == ARCH_MIPS |
592 | #define CPU_MIPS 32 | 574 | #define CPU_MIPS ARCH_VERSION /* 32, 64 */ |
593 | #endif | 575 | #endif |
594 | 576 | ||
595 | #endif /*__PCTOOL__*/ | 577 | #endif /*__PCTOOL__*/ |
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} |
diff --git a/tools/root.make b/tools/root.make index 51886a09f9..b12ed2abfa 100644 --- a/tools/root.make +++ b/tools/root.make | |||
@@ -79,12 +79,12 @@ endif | |||
79 | #included before codecs.make and plugins.make so they see them) | 79 | #included before codecs.make and plugins.make so they see them) |
80 | ifndef APP_TYPE | 80 | ifndef APP_TYPE |
81 | include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make | 81 | include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make |
82 | ifeq (arm,$(ARCH)) | 82 | ifeq (arch_arm,$(ARCH)) |
83 | include $(ROOTDIR)/lib/arm_support/arm_support.make | 83 | include $(ROOTDIR)/lib/arm_support/arm_support.make |
84 | endif | 84 | endif |
85 | endif | 85 | endif |
86 | 86 | ||
87 | ifeq (arm,$(ARCH)) | 87 | ifeq (arch_arm,$(ARCH)) |
88 | include $(ROOTDIR)/lib/unwarminder/unwarminder.make | 88 | include $(ROOTDIR)/lib/unwarminder/unwarminder.make |
89 | endif | 89 | endif |
90 | 90 | ||