[EABI] add support for EABI/linux toolchains

pretty much a hack right now, more or less testing for
arm-none-linux-eabi- in the toolchain prefix and adding some routines
that have to be implemented.
diff --git a/arch/arm/rules.mk b/arch/arm/rules.mk
index c8e3d5d..8630f52 100644
--- a/arch/arm/rules.mk
+++ b/arch/arm/rules.mk
@@ -1,10 +1,7 @@
 LOCAL_DIR := $(GET_LOCAL_DIR)
 
-TOOLCHAIN_PREFIX ?= arm-elf-
-
-ENABLE_THUMB ?= true
-
-CFLAGS += -finline
+# can override this in local.mk
+ENABLE_THUMB?=true
 
 DEFINES += \
 	ARM_CPU_$(ARM_CPU)=1
@@ -22,8 +19,8 @@
 	ARM_WITH_THUMB2=1 \
 	ARM_WITH_CACHE=1 \
 	ARM_WITH_L2=1
-#CFLAGS += -mcpu=$(ARM_CPU)
-CFLAGS += -mcpu=arm1136jf-s # compiler doesn't understand cortex yet
+CFLAGS += -mcpu=$(ARM_CPU)
+#CFLAGS += -mcpu=arm1136jf-s # compiler doesn't understand cortex yet
 HANDLED_CORE := true
 #CFLAGS += -mfpu=vfp -mfloat-abi=softfp
 endif
@@ -72,8 +69,6 @@
 THUMBINTERWORK := -mthumb-interwork
 endif
 
-CFLAGS += $(THUMBINTERWORK)
-
 INCLUDES += \
 	-I$(LOCAL_DIR)/include
 
@@ -91,6 +86,22 @@
 	$(LOCAL_DIR)/mmu.o \
 	$(LOCAL_DIR)/thread.o
 
+# set the default toolchain to arm elf and set a #define
+TOOLCHAIN_PREFIX ?= arm-elf-
+ifeq ($(TOOLCHAIN_PREFIX),arm-none-linux-gnueabi-)
+DEFINES += \
+	WITH_LINUX_EABI_TOOLCHAIN=1
+
+# eabi compilers dont need this
+THUMBINTERWORK:=
+else
+
+# XXX hack to work around lack of cortex support in regular compilers
+CFLAGS := $(subst cortex-a8,arm1136jf-s,$(CFLAGS))
+endif
+
+CFLAGS += $(THUMBINTERWORK)
+
 # make sure some bits were set up
 MEMVARS_SET := 0
 ifneq ($(MEMBASE),)
diff --git a/lib/libc/eabi.c b/lib/libc/eabi.c
new file mode 100644
index 0000000..6213d68
--- /dev/null
+++ b/lib/libc/eabi.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* some cruft we have to define when using the linux toolchain */
+#if WITH_LINUX_EABI_TOOLCHAIN
+
+#include <unwind.h>
+
+/* Our toolchain has eabi functionality built in, but they're not really used.
+ * so we stub them out here. */
+_Unwind_Reason_Code __aeabi_unwind_cpp_pr0(_Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context)
+{
+	return _URC_FAILURE;
+}
+
+_Unwind_Reason_Code __aeabi_unwind_cpp_pr1(_Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context)
+{
+        return _URC_FAILURE;
+}
+
+_Unwind_Reason_Code __aeabi_unwind_cpp_pr2(_Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context)
+{
+        return _URC_FAILURE;
+}
+
+void raise(void)
+{
+}
+
+#endif
diff --git a/lib/libc/rules.mk b/lib/libc/rules.mk
index 1d43092..e250cfe 100644
--- a/lib/libc/rules.mk
+++ b/lib/libc/rules.mk
@@ -6,6 +6,7 @@
 	$(LOCAL_DIR)/printf.o \
 	$(LOCAL_DIR)/malloc.o \
 	$(LOCAL_DIR)/rand.o \
+	$(LOCAL_DIR)/eabi.o
 
 
 include $(LOCAL_DIR)/string/rules.mk