diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-07 19:49:02 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-22 18:46:45 +0100 |
commit | 8e8e978de6b6283b66a6829fa8c5e3b94674ce7d (patch) | |
tree | a9b9e3dfe05653f44fdf9e51c214428371d52a31 | |
parent | 3c17f28eca86ff3ee9e7cef6c4d5198c27b7c03c (diff) | |
download | rockbox-8e8e978de6b6283b66a6829fa8c5e3b94674ce7d.tar.gz rockbox-8e8e978de6b6283b66a6829fa8c5e3b94674ce7d.zip |
Add framework to let make automatically pick optimized asm implementations over generic C ones to firmware.
Example: for a file asm/foo.c, make will look for asm/arm/foo.[cS] and
compile it if found. If not found it'll fall back to asm/foo.c.
Also introduce new ARCH make variable. This is automatically detected by
configure. It is distinct from CPU since CPU defines the dir used for
the target tree (i.e. firmware/target/X, so it can be "hosted").
ARCH really has the target isa and can be x86 for sims/raaa too.
Change-Id: I18e5d2b7b7bbc2ad2be551a74a0fcae5ffbcbf8b
-rw-r--r-- | firmware/asm/SOURCES | 1 | ||||
-rw-r--r-- | firmware/asm/asm.make | 27 | ||||
-rw-r--r-- | firmware/firmware.make | 2 | ||||
-rwxr-xr-x | tools/configure | 35 |
4 files changed, 63 insertions, 2 deletions
diff --git a/firmware/asm/SOURCES b/firmware/asm/SOURCES new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/firmware/asm/SOURCES | |||
@@ -0,0 +1 @@ | |||
diff --git a/firmware/asm/asm.make b/firmware/asm/asm.make new file mode 100644 index 0000000000..410cb6ca11 --- /dev/null +++ b/firmware/asm/asm.make | |||
@@ -0,0 +1,27 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | |||
10 | # Collect dummy C files in firmware/asm | ||
11 | ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES)) | ||
12 | |||
13 | # 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_S_SRC := $(ASM_C_SRC:.c=.S) | ||
16 | |||
17 | # ASM_SRC now contains only files that exist under $ARCH | ||
18 | ASM_SRC := $(wildcard $(ASM_C_SRC)) | ||
19 | ASM_SRC += $(wildcard $(ASM_S_SRC)) | ||
20 | |||
21 | # GEN_SRC now contains a .c for each file in ASM_DUMMY_SRC that's not in ASM_SRC | ||
22 | # I.e. fallback to a generic C source if no correspinding file in $ARCH is found | ||
23 | GEN_SRC := $(filter-out $(notdir $(ASM_SRC:.S=.c)),$(ASM_DUMMY_SRC)) | ||
24 | GEN_SRC := $(addprefix $(FIRMDIR)/asm/,$(GEN_SRC)) | ||
25 | |||
26 | FIRMLIB_SRC += $(ASM_SRC) | ||
27 | FIRMLIB_SRC += $(GEN_SRC) | ||
diff --git a/firmware/firmware.make b/firmware/firmware.make index aab735aa91..94747613ba 100644 --- a/firmware/firmware.make +++ b/firmware/firmware.make | |||
@@ -12,6 +12,8 @@ ifndef APP_TYPE | |||
12 | INCLUDES += -I$(FIRMDIR)/libc/include | 12 | INCLUDES += -I$(FIRMDIR)/libc/include |
13 | endif | 13 | endif |
14 | 14 | ||
15 | include $(FIRMDIR)/asm/asm.make | ||
16 | |||
15 | FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES) | 17 | FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES) |
16 | FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC)) | 18 | FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC)) |
17 | ifeq (,$(findstring -DARCHOS_PLAYER,$(TARGET))) | 19 | ifeq (,$(findstring -DARCHOS_PLAYER,$(TARGET))) |
diff --git a/tools/configure b/tools/configure index 789f6c01db..0a4766d505 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -49,6 +49,7 @@ input() { | |||
49 | prefixtools () { | 49 | prefixtools () { |
50 | prefix="$1" | 50 | prefix="$1" |
51 | CC=${prefix}gcc | 51 | CC=${prefix}gcc |
52 | CPP=${prefix}cpp | ||
52 | WINDRES=${prefix}windres | 53 | WINDRES=${prefix}windres |
53 | DLLTOOL=${prefix}dlltool | 54 | DLLTOOL=${prefix}dlltool |
54 | DLLWRAP=${prefix}dllwrap | 55 | DLLWRAP=${prefix}dllwrap |
@@ -671,6 +672,7 @@ ypr0cc () { | |||
671 | endian="little" | 672 | endian="little" |
672 | thread_support="HAVE_SIGALTSTACK_THREADS" | 673 | thread_support="HAVE_SIGALTSTACK_THREADS" |
673 | app_type="ypr0" | 674 | app_type="ypr0" |
675 | arch="unknown" | ||
674 | 676 | ||
675 | # Include path | 677 | # Include path |
676 | GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" | 678 | GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" |
@@ -3639,6 +3641,7 @@ fi | |||
3639 | HOSTCC=`findtool gcc --lit` | 3641 | HOSTCC=`findtool gcc --lit` |
3640 | HOSTAR=`findtool ar --lit` | 3642 | HOSTAR=`findtool ar --lit` |
3641 | CC=`findtool ${CC} --lit` | 3643 | CC=`findtool ${CC} --lit` |
3644 | CPP=`findtool ${CPP} --lit` | ||
3642 | LD=`findtool ${AR} --lit` | 3645 | LD=`findtool ${AR} --lit` |
3643 | AR=`findtool ${AR} --lit` | 3646 | AR=`findtool ${AR} --lit` |
3644 | AS=`findtool ${AS} --lit` | 3647 | AS=`findtool ${AS} --lit` |
@@ -3648,6 +3651,32 @@ DLLTOOL=`findtool ${DLLTOOL} --lit` | |||
3648 | DLLWRAP=`findtool ${DLLWRAP} --lit` | 3651 | DLLWRAP=`findtool ${DLLWRAP} --lit` |
3649 | RANLIB=`findtool ${RANLIB} --lit` | 3652 | RANLIB=`findtool ${RANLIB} --lit` |
3650 | 3653 | ||
3654 | |||
3655 | if [ -z "$arch" ]; then | ||
3656 | cpp_defines=$(echo "" | $CPP -dD) | ||
3657 | if [ -n "$(echo $cpp_defines | grep -w __sh__)" ]; then | ||
3658 | arch="sh" | ||
3659 | elif [ -n "$(echo $cpp_defines | grep -w __m68k__)" ]; then | ||
3660 | arch="m68k" | ||
3661 | elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then | ||
3662 | arch="arm" | ||
3663 | elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then | ||
3664 | arch="mips" | ||
3665 | elif [ -n "$(echo $cpp_defines | grep -w _X86_)" ]; then | ||
3666 | arch="x86" | ||
3667 | elif [ -n "$(echo $cpp_defines | grep -w __x86_64__)" ]; then | ||
3668 | arch="amd64" | ||
3669 | else | ||
3670 | arch="unknown" | ||
3671 | echo "Warning: Could not determine target arch" | ||
3672 | fi | ||
3673 | if [ "$arch" != "unknown" ]; then | ||
3674 | echo "Automatically selected arch: $arch" | ||
3675 | fi; | ||
3676 | else | ||
3677 | echo "Manually selected arch: $arch" | ||
3678 | fi | ||
3679 | |||
3651 | if test -n "$ccache"; then | 3680 | if test -n "$ccache"; then |
3652 | CC="$ccache $CC" | 3681 | CC="$ccache $CC" |
3653 | fi | 3682 | fi |
@@ -3718,11 +3747,11 @@ EOF | |||
3718 | if test -n "$t_cpu"; then | 3747 | if test -n "$t_cpu"; then |
3719 | TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model" | 3748 | TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model" |
3720 | 3749 | ||
3721 | if [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "maemo" ]; then | 3750 | if [ "$application" = "yes" ] && [ "$t_manufacturer" = "maemo" ]; then |
3722 | # Maemo needs the SDL port, too | 3751 | # Maemo needs the SDL port, too |
3723 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" | 3752 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" |
3724 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" | 3753 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" |
3725 | elif [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "pandora" ]; then | 3754 | elif [ "$application" = "yes" ] && [ "$t_manufacturer" = "pandora" ]; then |
3726 | # Pandora needs the SDL port, too | 3755 | # Pandora needs the SDL port, too |
3727 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" | 3756 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" |
3728 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" | 3757 | TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" |
@@ -3780,6 +3809,7 @@ export ARCHOSROM=${archosrom} | |||
3780 | export FLASHFILE=${flash} | 3809 | export FLASHFILE=${flash} |
3781 | export TARGET_ID=${target_id} | 3810 | export TARGET_ID=${target_id} |
3782 | export TARGET=-D${target} | 3811 | export TARGET=-D${target} |
3812 | export ARCH=${arch} | ||
3783 | export CPU=${t_cpu} | 3813 | export CPU=${t_cpu} |
3784 | export MANUFACTURER=${t_manufacturer} | 3814 | export MANUFACTURER=${t_manufacturer} |
3785 | export OBJDIR=${pwd} | 3815 | export OBJDIR=${pwd} |
@@ -3801,6 +3831,7 @@ export EXTRA_DEFINES=${extradefines} | |||
3801 | export HOSTCC=${HOSTCC} | 3831 | export HOSTCC=${HOSTCC} |
3802 | export HOSTAR=${HOSTAR} | 3832 | export HOSTAR=${HOSTAR} |
3803 | export CC=${CC} | 3833 | export CC=${CC} |
3834 | export CPP=${CPP} | ||
3804 | export LD=${LD} | 3835 | export LD=${LD} |
3805 | export AR=${AR} | 3836 | export AR=${AR} |
3806 | export AS=${AS} | 3837 | export AS=${AS} |