The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | # Configuration for Linux on ARM. |
| 2 | # Included by combo/select.make |
| 3 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 4 | # You can set TARGET_ARCH_VERSION to use an arch version other |
| 5 | # than ARMv5TE |
| 6 | ifeq ($(strip $(TARGET_ARCH_VERSION)),) |
| 7 | TARGET_ARCH_VERSION := armv5te |
| 8 | endif |
| 9 | |
| 10 | # This set of if blocks sets makefile variables similar to preprocesser |
| 11 | # defines in system/core/include/arch/<combo>/AndroidConfig.h. Their |
| 12 | # purpose is to allow module Android.mk files to selctively compile |
| 13 | # different versions of code based upon the funtionality and |
| 14 | # instructions available in a given architecture version. |
| 15 | # |
| 16 | # The blocks also define specific arch_version_cflags, which |
| 17 | # include defines, and compiler settings for the given architecture |
| 18 | # version. |
| 19 | # |
| 20 | # Note: Hard coding the 'tune' value here is probably not ideal, |
| 21 | # and a better solution should be found in the future. |
| 22 | # |
| 23 | # With two or three different versions this if block approach is |
| 24 | # fine. If/when this becomes large, please change this to include |
| 25 | # architecture versions specific Makefiles which define these |
| 26 | # variables. |
Fredrik Markström | b7990f7 | 2009-03-24 23:38:51 +0100 | [diff] [blame] | 27 | # |
| 28 | # Supporting armv4 (without thumb) does not make much sense since |
| 29 | # it's mostly an obsoleted instruction set architecture (only available |
| 30 | # in StrongArm and arm8). Supporting armv4 will require a lot of conditional |
| 31 | # code in assembler source since the bx (branch and exchange) instruction is |
| 32 | # not supported. |
| 33 | # |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 34 | ifeq ($(TARGET_ARCH_VERSION),armv5te) |
| 35 | ARCH_ARM_HAVE_THUMB_SUPPORT := true |
| 36 | ARCH_ARM_HAVE_FAST_INTERWORKING := true |
| 37 | ARCH_ARM_HAVE_64BIT_DATA := true |
| 38 | ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true |
| 39 | ARCH_ARM_HAVE_CLZ := true |
| 40 | ARCH_ARM_HAVE_FFS := true |
| 41 | |
| 42 | arch_version_cflags := -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ \ |
| 43 | -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ |
| 44 | else |
Fredrik Markström | b7990f7 | 2009-03-24 23:38:51 +0100 | [diff] [blame] | 45 | ifeq ($(TARGET_ARCH_VERSION),armv4t) |
| 46 | $(warning ARMv4t support is currently a work in progress. It does not work right now!) |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 47 | ARCH_ARM_HAVE_THUMB_SUPPORT := false |
| 48 | ARCH_ARM_HAVE_THUMB_INTERWORKING := false |
| 49 | ARCH_ARM_HAVE_64BIT_DATA := false |
| 50 | ARCH_ARM_HAVE_HALFWORD_MULTIPLY := false |
| 51 | ARCH_ARM_HAVE_CLZ := false |
| 52 | ARCH_ARM_HAVE_FFS := false |
| 53 | |
Fredrik Markström | b7990f7 | 2009-03-24 23:38:51 +0100 | [diff] [blame] | 54 | DEFAULT_TARGET_CPU := arm920t |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 55 | |
Fredrik Markström | b7990f7 | 2009-03-24 23:38:51 +0100 | [diff] [blame] | 56 | arch_version_cflags := -march=armv4t -mtune=arm920t -D__ARM_ARCH_4T__ |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 57 | else |
| 58 | $(error Unknown ARM architecture version: $(TARGET_ARCH_VERSION)) |
| 59 | endif |
| 60 | endif |
| 61 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 62 | # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else |
| 63 | ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),) |
| 64 | $(combo_target)TOOLS_PREFIX := \ |
Doug Kwan | 8c9bef6 | 2009-04-30 14:47:05 -0700 | [diff] [blame] | 65 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.3.1/bin/arm-eabi- |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 66 | endif |
| 67 | |
| 68 | $(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 69 | $(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 70 | $(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 71 | $(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 72 | $(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
| 73 | |
| 74 | $(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
| 75 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 76 | TARGET_arm_CFLAGS := -O2 \ |
| 77 | -fomit-frame-pointer \ |
| 78 | -fstrict-aliasing \ |
| 79 | -funswitch-loops \ |
| 80 | -finline-limit=300 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 81 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 82 | # Modules can choose to compile some source as thumb. As |
| 83 | # non-thumb enabled targets are supported, this is treated |
| 84 | # as a 'hint'. If thumb is not enabled, these files are just |
| 85 | # compiled as ARM. |
| 86 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 87 | TARGET_thumb_CFLAGS := -mthumb \ |
| 88 | -Os \ |
| 89 | -fomit-frame-pointer \ |
| 90 | -fno-strict-aliasing \ |
| 91 | -finline-limit=64 |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 92 | else |
Dave Bort | 8acd848 | 2009-05-05 17:04:20 -0700 | [diff] [blame] | 93 | TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS) |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 94 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 95 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 96 | # Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk |
| 97 | # or in your environment to force a full arm build, even for |
| 98 | # files that are normally built as thumb; this can make |
| 99 | # gdb debugging easier. Don't forget to do a clean build. |
| 100 | # |
| 101 | # NOTE: if you try to build a -O0 build with thumb, several |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 102 | # of the libraries (libpv, libwebcore, libkjs) need to be built |
| 103 | # with -mlong-calls. When built at -O0, those libraries are |
| 104 | # too big for a thumb "BL <label>" to go from one end to the other. |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 105 | ifeq ($(FORCE_ARM_DEBUGGING),true) |
Dave Bort | 8acd848 | 2009-05-05 17:04:20 -0700 | [diff] [blame] | 106 | TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 107 | TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer |
| 108 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 109 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 110 | android_config_h := $(call select-android-config-h,linux-arm) |
| 111 | arch_include_dir := $(dir $(android_config_h)) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 112 | |
| 113 | $(combo_target)GLOBAL_CFLAGS += \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 114 | -msoft-float -fpic \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 115 | -ffunction-sections \ |
| 116 | -funwind-tables \ |
| 117 | -fstack-protector \ |
The Android Open Source Project | 4f85cc5 | 2009-01-09 17:50:54 -0800 | [diff] [blame] | 118 | -fno-short-enums \ |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 119 | $(arch_version_cflags) \ |
| 120 | -include $(android_config_h) \ |
| 121 | -I $(arch_include_dir) |
| 122 | |
| 123 | # We only need thumb interworking in cases where thumb support |
| 124 | # is available in the architecture, and just to be sure, (and |
| 125 | # since sometimes thumb-interwork appears to be default), we |
| 126 | # specifically disable when thumb support is unavailable. |
| 127 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
| 128 | $(combo_target)GLOBAL_CFLAGS += -mthumb-interwork |
| 129 | else |
| 130 | $(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork |
| 131 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 132 | |
| 133 | $(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden |
| 134 | |
| 135 | $(combo_target)RELEASE_CFLAGS := \ |
| 136 | -DSK_RELEASE -DNDEBUG \ |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 137 | -g \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 138 | -Wstrict-aliasing=2 \ |
| 139 | -finline-functions \ |
| 140 | -fno-inline-functions-called-once \ |
| 141 | -fgcse-after-reload \ |
| 142 | -frerun-cse-after-loop \ |
| 143 | -frename-registers |
| 144 | |
| 145 | libc_root := bionic/libc |
| 146 | libm_root := bionic/libm |
| 147 | libstdc++_root := bionic/libstdc++ |
| 148 | libthread_db_root := bionic/libthread_db |
| 149 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 150 | |
| 151 | ## on some hosts, the target cross-compiler is not available so do not run this command |
| 152 | ifneq ($(wildcard $($(combo_target)CC)),) |
| 153 | # We compile with the global cflags to ensure that |
| 154 | # any flags which affect libgcc are correctly taken |
| 155 | # into account. |
| 156 | $(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name) |
| 157 | endif |
| 158 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 159 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 160 | # symlinks located in out/ to point to the appropriate kernel |
| 161 | # headers. see 'config/kernel_headers.make' for more details |
| 162 | # |
| 163 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 164 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 165 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 166 | else |
| 167 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 168 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 169 | endif |
| 170 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 171 | |
| 172 | $(combo_target)C_INCLUDES := \ |
| 173 | $(libc_root)/arch-arm/include \ |
| 174 | $(libc_root)/include \ |
| 175 | $(libstdc++_root)/include \ |
| 176 | $(KERNEL_HEADERS) \ |
| 177 | $(libm_root)/include \ |
| 178 | $(libm_root)/include/arch/arm \ |
| 179 | $(libthread_db_root)/include |
| 180 | |
| 181 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 182 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 183 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
| 184 | |
| 185 | TARGET_STRIP_MODULE:=true |
| 186 | |
| 187 | $(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
| 188 | |
| 189 | $(combo_target)CUSTOM_LD_COMMAND := true |
| 190 | define transform-o-to-shared-lib-inner |
| 191 | $(TARGET_CXX) \ |
| 192 | -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \ |
| 193 | -Wl,--gc-sections \ |
| 194 | -Wl,-shared,-Bsymbolic \ |
| 195 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 196 | $(PRIVATE_ALL_OBJECTS) \ |
| 197 | -Wl,--whole-archive \ |
| 198 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 199 | -Wl,--no-whole-archive \ |
| 200 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 201 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 202 | -o $@ \ |
| 203 | $(PRIVATE_LDFLAGS) \ |
| 204 | $(TARGET_LIBGCC) |
| 205 | endef |
| 206 | |
| 207 | define transform-o-to-executable-inner |
| 208 | $(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 209 | -Wl,-dynamic-linker,/system/bin/linker \ |
| 210 | -Wl,--gc-sections \ |
| 211 | -Wl,-z,nocopyreloc \ |
| 212 | -o $@ \ |
| 213 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 214 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 215 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 216 | $(TARGET_CRTBEGIN_DYNAMIC_O) \ |
| 217 | $(PRIVATE_ALL_OBJECTS) \ |
| 218 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 219 | $(PRIVATE_LDFLAGS) \ |
| 220 | $(TARGET_LIBGCC) \ |
| 221 | $(TARGET_CRTEND_O) |
| 222 | endef |
| 223 | |
| 224 | define transform-o-to-static-executable-inner |
| 225 | $(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 226 | -Wl,--gc-sections \ |
| 227 | -o $@ \ |
| 228 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 229 | $(TARGET_CRTBEGIN_STATIC_O) \ |
| 230 | $(PRIVATE_LDFLAGS) \ |
| 231 | $(PRIVATE_ALL_OBJECTS) \ |
| 232 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 233 | $(TARGET_LIBGCC) \ |
| 234 | $(TARGET_CRTEND_O) |
| 235 | endef |