blob: 20557c7b588430ac192fcd63a9005c689d1c0d3a [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:=
107else
108
109# XXX hack to work around lack of cortex support in regular compilers
110CFLAGS := $(subst cortex-a8,arm1136jf-s,$(CFLAGS))
111endif
112
113CFLAGS += $(THUMBINTERWORK)
114
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700115# make sure some bits were set up
116MEMVARS_SET := 0
117ifneq ($(MEMBASE),)
118MEMVARS_SET := 1
119endif
120ifneq ($(MEMSIZE),)
121MEMVARS_SET := 1
122endif
123ifeq ($(MEMVARS_SET),0)
124$(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk)
125endif
126
127LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) $(THUMBCFLAGS) -print-libgcc-file-name)
128#$(info LIBGCC = $(LIBGCC))
129
130# potentially generated files that should be cleaned out with clean make rule
131GENERATED += \
132 $(BUILDDIR)/system-onesegment.ld \
133 $(BUILDDIR)/system-twosegment.ld
134
135# rules for generating the linker scripts
136
137$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld
138 @echo generating $@
139 @$(MKDIR)
140 $(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
141
142$(BUILDDIR)/system-twosegment.ld: $(LOCAL_DIR)/system-twosegment.ld
143 @echo generating $@
144 @$(MKDIR)
145 $(NOECHO)sed "s/%ROMBASE%/$(ROMBASE)/;s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
146