Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 1 | LOCAL_DIR := $(GET_LOCAL_DIR) |
| 2 | |
Travis Geiselbrecht | 82f7420 | 2008-09-05 04:35:45 -0700 | [diff] [blame] | 3 | # can override this in local.mk |
| 4 | ENABLE_THUMB?=true |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 5 | |
| 6 | DEFINES += \ |
| 7 | ARM_CPU_$(ARM_CPU)=1 |
| 8 | |
| 9 | # do set some options based on the cpu core |
| 10 | HANDLED_CORE := false |
| 11 | ifeq ($(ARM_CPU),cortex-a8) |
| 12 | DEFINES += \ |
| 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 Geiselbrecht | 82f7420 | 2008-09-05 04:35:45 -0700 | [diff] [blame] | 22 | CFLAGS += -mcpu=$(ARM_CPU) |
| 23 | #CFLAGS += -mcpu=arm1136jf-s # compiler doesn't understand cortex yet |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 24 | HANDLED_CORE := true |
| 25 | #CFLAGS += -mfpu=vfp -mfloat-abi=softfp |
| 26 | endif |
Brian Swetland | 544bf4e | 2008-09-06 23:56:16 -0700 | [diff] [blame] | 27 | ifeq ($(ARM_CPU),arm1136j-s) |
| 28 | DEFINES += \ |
| 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 |
| 35 | CFLAGS += -mcpu=$(ARM_CPU) |
| 36 | HANDLED_CORE := true |
| 37 | endif |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 38 | ifeq ($(ARM_CPU),arm1176jzf-s) |
| 39 | DEFINES += \ |
| 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 |
| 47 | CFLAGS += -mcpu=$(ARM_CPU) |
| 48 | HANDLED_CORE := true |
| 49 | endif |
| 50 | ifeq ($(ARM_CPU),arm926ej-s) |
| 51 | DEFINES += \ |
| 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 |
| 59 | CFLAGS += -mcpu=$(ARM_CPU) |
| 60 | HANDLED_CORE := true |
| 61 | endif |
| 62 | ifeq ($(ARM_CPU),arm7tdmi) |
| 63 | DEFINES += \ |
| 64 | ARM_ISA_ARMv4=1 \ |
| 65 | ARM_WITH_THUMB=1 \ |
| 66 | ARM_CPU_ARM7=1 |
| 67 | CFLAGS += -mcpu=$(ARM_CPU) |
| 68 | HANDLED_CORE := true |
| 69 | endif |
| 70 | |
| 71 | ifneq ($(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) |
| 74 | endif |
| 75 | |
| 76 | THUMBCFLAGS := |
| 77 | THUMBINTERWORK := |
| 78 | ifeq ($(ENABLE_THUMB),true) |
| 79 | THUMBCFLAGS := -mthumb -D__thumb__ |
| 80 | THUMBINTERWORK := -mthumb-interwork |
| 81 | endif |
| 82 | |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 83 | INCLUDES += \ |
| 84 | -I$(LOCAL_DIR)/include |
| 85 | |
| 86 | BOOTOBJS += \ |
| 87 | $(LOCAL_DIR)/crt0.o |
| 88 | |
| 89 | OBJS += \ |
| 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 Swetland | e1d0b57 | 2008-09-07 02:08:41 -0700 | [diff] [blame] | 98 | $(LOCAL_DIR)/thread.o \ |
| 99 | $(LOCAL_DIR)/dcc.o |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 100 | |
Chandan Uddaraju | c53a1a1 | 2009-11-18 14:53:40 -0800 | [diff] [blame] | 101 | # set the default toolchain to arm eabi and set a #define |
| 102 | TOOLCHAIN_PREFIX ?= arm-eabi- |
Travis Geiselbrecht | 82f7420 | 2008-09-05 04:35:45 -0700 | [diff] [blame] | 103 | ifeq ($(TOOLCHAIN_PREFIX),arm-none-linux-gnueabi-) |
Travis Geiselbrecht | 97481e6 | 2008-09-05 04:50:56 -0700 | [diff] [blame] | 104 | # XXX test for EABI better than this |
Travis Geiselbrecht | 82f7420 | 2008-09-05 04:35:45 -0700 | [diff] [blame] | 105 | # eabi compilers dont need this |
| 106 | THUMBINTERWORK:= |
| 107 | else |
| 108 | |
| 109 | # XXX hack to work around lack of cortex support in regular compilers |
| 110 | CFLAGS := $(subst cortex-a8,arm1136jf-s,$(CFLAGS)) |
| 111 | endif |
| 112 | |
| 113 | CFLAGS += $(THUMBINTERWORK) |
| 114 | |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 115 | # make sure some bits were set up |
| 116 | MEMVARS_SET := 0 |
| 117 | ifneq ($(MEMBASE),) |
| 118 | MEMVARS_SET := 1 |
| 119 | endif |
| 120 | ifneq ($(MEMSIZE),) |
| 121 | MEMVARS_SET := 1 |
| 122 | endif |
| 123 | ifeq ($(MEMVARS_SET),0) |
| 124 | $(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk) |
| 125 | endif |
| 126 | |
| 127 | LIBGCC := $(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 |
| 131 | GENERATED += \ |
| 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 | |