blob: 6f56edd146becddfb728136a5a97bc79928f0948 [file] [log] [blame]
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07001LOCAL_DIR := $(GET_LOCAL_DIR)
2
Travis Geiselbrecht82f74202008-09-05 04:35:45 -07003# can override this in local.mk
4ENABLE_THUMB?=true
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07005
6DEFINES += \
7 ARM_CPU_$(ARM_CPU)=1
8
9# do set some options based on the cpu core
10HANDLED_CORE := false
11ifeq ($(ARM_CPU),cortex-a8)
12DEFINES += \
13 ARM_WITH_CP15=1 \
14 ARM_WITH_MMU=1 \
15 ARM_ISA_ARMv7=1 \
16 ARM_WITH_VFP=1 \
17 ARM_WITH_NEON=1 \
18 ARM_WITH_THUMB=1 \
19 ARM_WITH_THUMB2=1 \
20 ARM_WITH_CACHE=1 \
21 ARM_WITH_L2=1
Travis Geiselbrecht82f74202008-09-05 04:35:45 -070022CFLAGS += -mcpu=$(ARM_CPU)
23#CFLAGS += -mcpu=arm1136jf-s # compiler doesn't understand cortex yet
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070024HANDLED_CORE := true
25#CFLAGS += -mfpu=vfp -mfloat-abi=softfp
26endif
Brian Swetland544bf4e2008-09-06 23:56:16 -070027ifeq ($(ARM_CPU),arm1136j-s)
28DEFINES += \
29 ARM_WITH_CP15=1 \
30 ARM_WITH_MMU=1 \
31 ARM_ISA_ARMv6=1 \
32 ARM_WITH_THUMB=1 \
33 ARM_WITH_CACHE=1 \
34 ARM_CPU_ARM1136=1
35CFLAGS += -mcpu=$(ARM_CPU)
36HANDLED_CORE := true
37endif
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070038ifeq ($(ARM_CPU),arm1176jzf-s)
39DEFINES += \
40 ARM_WITH_CP15=1 \
41 ARM_WITH_MMU=1 \
42 ARM_ISA_ARMv6=1 \
43 ARM_WITH_VFP=1 \
44 ARM_WITH_THUMB=1 \
45 ARM_WITH_CACHE=1 \
46 ARM_CPU_ARM1136=1
47CFLAGS += -mcpu=$(ARM_CPU)
48HANDLED_CORE := true
49endif
50ifeq ($(ARM_CPU),arm926ej-s)
51DEFINES += \
52 ARM_WITH_CP15=1 \
53 ARM_WITH_MMU=1 \
54 ARM_ISA_ARMv5E=1 \
55 ARM_WITH_THUMB=1 \
56 ARM_WITH_CACHE=1 \
57 ARM_CPU_ARM9=1 \
58 ARM_CPU_ARM926=1
59CFLAGS += -mcpu=$(ARM_CPU)
60HANDLED_CORE := true
61endif
62ifeq ($(ARM_CPU),arm7tdmi)
63DEFINES += \
64 ARM_ISA_ARMv4=1 \
65 ARM_WITH_THUMB=1 \
66 ARM_CPU_ARM7=1
67CFLAGS += -mcpu=$(ARM_CPU)
68HANDLED_CORE := true
69endif
70
71ifneq ($(HANDLED_CORE),true)
72$(warning $(LOCAL_DIR)/rules.mk doesnt have logic for arm core $(ARM_CPU))
73$(warning this is likely to be broken)
74endif
75
76THUMBCFLAGS :=
77THUMBINTERWORK :=
78ifeq ($(ENABLE_THUMB),true)
79THUMBCFLAGS := -mthumb -D__thumb__
80THUMBINTERWORK := -mthumb-interwork
81endif
82
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -070083INCLUDES += \
84 -I$(LOCAL_DIR)/include
85
86BOOTOBJS += \
87 $(LOCAL_DIR)/crt0.o
88
89OBJS += \
90 $(LOCAL_DIR)/arch.Ao \
91 $(LOCAL_DIR)/asm.o \
92 $(LOCAL_DIR)/cache.o \
93 $(LOCAL_DIR)/cache-ops.o \
94 $(LOCAL_DIR)/ops.o \
95 $(LOCAL_DIR)/exceptions.o \
96 $(LOCAL_DIR)/faults.o \
97 $(LOCAL_DIR)/mmu.o \
Brian Swetlande1d0b572008-09-07 02:08:41 -070098 $(LOCAL_DIR)/thread.o \
99 $(LOCAL_DIR)/dcc.o
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700100
Chandan Uddarajuc53a1a12009-11-18 14:53:40 -0800101# set the default toolchain to arm eabi and set a #define
102TOOLCHAIN_PREFIX ?= arm-eabi-
Travis Geiselbrecht82f74202008-09-05 04:35:45 -0700103ifeq ($(TOOLCHAIN_PREFIX),arm-none-linux-gnueabi-)
Travis Geiselbrecht97481e62008-09-05 04:50:56 -0700104# XXX test for EABI better than this
Travis Geiselbrecht82f74202008-09-05 04:35:45 -0700105# eabi compilers dont need this
106THUMBINTERWORK:=
Travis Geiselbrecht82f74202008-09-05 04:35:45 -0700107endif
108
109CFLAGS += $(THUMBINTERWORK)
110
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700111# make sure some bits were set up
112MEMVARS_SET := 0
113ifneq ($(MEMBASE),)
114MEMVARS_SET := 1
115endif
116ifneq ($(MEMSIZE),)
117MEMVARS_SET := 1
118endif
119ifeq ($(MEMVARS_SET),0)
120$(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk)
121endif
122
123LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) $(THUMBCFLAGS) -print-libgcc-file-name)
124#$(info LIBGCC = $(LIBGCC))
125
126# potentially generated files that should be cleaned out with clean make rule
127GENERATED += \
128 $(BUILDDIR)/system-onesegment.ld \
129 $(BUILDDIR)/system-twosegment.ld
130
131# rules for generating the linker scripts
132
133$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld
134 @echo generating $@
135 @$(MKDIR)
136 $(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
137
138$(BUILDDIR)/system-twosegment.ld: $(LOCAL_DIR)/system-twosegment.ld
139 @echo generating $@
140 @$(MKDIR)
141 $(NOECHO)sed "s/%ROMBASE%/$(ROMBASE)/;s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
142