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 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +# Collect dummy C files in firmware/asm +ASM_DUMMY_SRC := $(notdir $(call preprocess, $(FIRMDIR)/asm/SOURCES)) + +# Get the corresponding real source files under firmware/asm/$ARCH (C or ASM) +ASM_C_SRC := $(addprefix $(FIRMDIR)/asm/$(ARCH)/,$(ASM_DUMMY_SRC)) +ASM_S_SRC := $(ASM_C_SRC:.c=.S) + +# ASM_SRC now contains only files that exist under $ARCH +ASM_SRC := $(wildcard $(ASM_C_SRC)) +ASM_SRC += $(wildcard $(ASM_S_SRC)) + +# GEN_SRC now contains a .c for each file in ASM_DUMMY_SRC that's not in ASM_SRC +# I.e. fallback to a generic C source if no correspinding file in $ARCH is found +GEN_SRC := $(filter-out $(notdir $(ASM_SRC:.S=.c)),$(ASM_DUMMY_SRC)) +GEN_SRC := $(addprefix $(FIRMDIR)/asm/,$(GEN_SRC)) + +FIRMLIB_SRC += $(ASM_SRC) +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 INCLUDES += -I$(FIRMDIR)/libc/include endif +include $(FIRMDIR)/asm/asm.make + FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES) FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC)) 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() { prefixtools () { prefix="$1" CC=${prefix}gcc + CPP=${prefix}cpp WINDRES=${prefix}windres DLLTOOL=${prefix}dlltool DLLWRAP=${prefix}dllwrap @@ -671,6 +672,7 @@ ypr0cc () { endian="little" thread_support="HAVE_SIGALTSTACK_THREADS" app_type="ypr0" + arch="unknown" # Include path GCCOPTS="$GCCOPTS -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT" @@ -3639,6 +3641,7 @@ fi HOSTCC=`findtool gcc --lit` HOSTAR=`findtool ar --lit` CC=`findtool ${CC} --lit` +CPP=`findtool ${CPP} --lit` LD=`findtool ${AR} --lit` AR=`findtool ${AR} --lit` AS=`findtool ${AS} --lit` @@ -3648,6 +3651,32 @@ DLLTOOL=`findtool ${DLLTOOL} --lit` DLLWRAP=`findtool ${DLLWRAP} --lit` RANLIB=`findtool ${RANLIB} --lit` + +if [ -z "$arch" ]; then + cpp_defines=$(echo "" | $CPP -dD) + if [ -n "$(echo $cpp_defines | grep -w __sh__)" ]; then + arch="sh" + elif [ -n "$(echo $cpp_defines | grep -w __m68k__)" ]; then + arch="m68k" + elif [ -n "$(echo $cpp_defines | grep -w __arm__)" ]; then + arch="arm" + elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then + arch="mips" + 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" + echo "Warning: Could not determine target arch" + fi + if [ "$arch" != "unknown" ]; then + echo "Automatically selected arch: $arch" + fi; +else + echo "Manually selected arch: $arch" +fi + if test -n "$ccache"; then CC="$ccache $CC" fi @@ -3718,11 +3747,11 @@ EOF if test -n "$t_cpu"; then TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model" - if [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "maemo" ]; then + if [ "$application" = "yes" ] && [ "$t_manufacturer" = "maemo" ]; then # Maemo needs the SDL port, too TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" - elif [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "pandora" ]; then + elif [ "$application" = "yes" ] && [ "$t_manufacturer" = "pandora" ]; then # Pandora needs the SDL port, too TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app" TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl" @@ -3780,6 +3809,7 @@ export ARCHOSROM=${archosrom} export FLASHFILE=${flash} export TARGET_ID=${target_id} export TARGET=-D${target} +export ARCH=${arch} export CPU=${t_cpu} export MANUFACTURER=${t_manufacturer} export OBJDIR=${pwd} @@ -3801,6 +3831,7 @@ export EXTRA_DEFINES=${extradefines} export HOSTCC=${HOSTCC} export HOSTAR=${HOSTAR} export CC=${CC} +export CPP=${CPP} export LD=${LD} export AR=${AR} export AS=${AS}