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. |
| 27 | # |
| 28 | ifeq ($(TARGET_ARCH_VERSION),armv5te) |
| 29 | ARCH_ARM_HAVE_THUMB_SUPPORT := true |
| 30 | ARCH_ARM_HAVE_FAST_INTERWORKING := true |
| 31 | ARCH_ARM_HAVE_64BIT_DATA := true |
| 32 | ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true |
| 33 | ARCH_ARM_HAVE_CLZ := true |
| 34 | ARCH_ARM_HAVE_FFS := true |
| 35 | |
| 36 | arch_version_cflags := -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ \ |
| 37 | -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ |
| 38 | else |
| 39 | ifeq ($(TARGET_ARCH_VERSION),armv4) |
| 40 | $(warning ARMv4 support is currently a work in progress. It does not work right now!) |
| 41 | ARCH_ARM_HAVE_THUMB_SUPPORT := false |
| 42 | ARCH_ARM_HAVE_THUMB_INTERWORKING := false |
| 43 | ARCH_ARM_HAVE_64BIT_DATA := false |
| 44 | ARCH_ARM_HAVE_HALFWORD_MULTIPLY := false |
| 45 | ARCH_ARM_HAVE_CLZ := false |
| 46 | ARCH_ARM_HAVE_FFS := false |
| 47 | |
| 48 | DEFAULT_TARGET_CPU := arm920 |
| 49 | |
| 50 | arch_version_cflags := -march=armv4 -mtune=arm920 -D__ARM_ARCH_4__ |
| 51 | else |
| 52 | $(error Unknown ARM architecture version: $(TARGET_ARCH_VERSION)) |
| 53 | endif |
| 54 | endif |
| 55 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 56 | # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else |
| 57 | ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),) |
| 58 | $(combo_target)TOOLS_PREFIX := \ |
| 59 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.2.1/bin/arm-eabi- |
| 60 | endif |
| 61 | |
| 62 | $(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 63 | $(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 64 | $(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 65 | $(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 66 | $(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
| 67 | |
| 68 | $(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
| 69 | |
| 70 | TARGET_arm_release_CFLAGS := -fomit-frame-pointer \ |
| 71 | -fstrict-aliasing \ |
| 72 | -funswitch-loops \ |
| 73 | -finline-limit=300 |
| 74 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame^] | 75 | # Modules can choose to compile some source as thumb. As |
| 76 | # non-thumb enabled targets are supported, this is treated |
| 77 | # as a 'hint'. If thumb is not enabled, these files are just |
| 78 | # compiled as ARM. |
| 79 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 80 | TARGET_thumb_release_CFLAGS := -mthumb \ |
| 81 | -Os \ |
| 82 | -fomit-frame-pointer \ |
| 83 | -fno-strict-aliasing \ |
| 84 | -finline-limit=64 |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame^] | 85 | else |
| 86 | TARGET_thumb_release_CFLAGS := $(TARGET_arm_release_CFLAGS) |
| 87 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 88 | |
| 89 | # When building for debug, compile everything as arm. |
| 90 | TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing |
| 91 | TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer |
| 92 | |
| 93 | # NOTE: if you try to build a debug build with thumb, several |
| 94 | # of the libraries (libpv, libwebcore, libkjs) need to be built |
| 95 | # with -mlong-calls. When built at -O0, those libraries are |
| 96 | # too big for a thumb "BL <label>" to go from one end to the other. |
| 97 | |
| 98 | ## As hopefully a temporary hack, |
| 99 | ## use this to force a full ARM build (for easier debugging in gdb) |
| 100 | ## (don't forget to do a clean build) |
| 101 | ##TARGET_arm_release_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer |
| 102 | ##TARGET_thumb_release_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer |
| 103 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame^] | 104 | android_config_h := $(call select-android-config-h,linux-arm) |
| 105 | arch_include_dir := $(dir $(android_config_h)) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 106 | |
| 107 | $(combo_target)GLOBAL_CFLAGS += \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 108 | -msoft-float -fpic \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 109 | -ffunction-sections \ |
| 110 | -funwind-tables \ |
| 111 | -fstack-protector \ |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame^] | 112 | $(arch_version_cflags) \ |
| 113 | -include $(android_config_h) \ |
| 114 | -I $(arch_include_dir) |
| 115 | |
| 116 | # We only need thumb interworking in cases where thumb support |
| 117 | # is available in the architecture, and just to be sure, (and |
| 118 | # since sometimes thumb-interwork appears to be default), we |
| 119 | # specifically disable when thumb support is unavailable. |
| 120 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
| 121 | $(combo_target)GLOBAL_CFLAGS += -mthumb-interwork |
| 122 | else |
| 123 | $(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork |
| 124 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 125 | |
| 126 | $(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden |
| 127 | |
| 128 | $(combo_target)RELEASE_CFLAGS := \ |
| 129 | -DSK_RELEASE -DNDEBUG \ |
| 130 | -O2 -g \ |
| 131 | -Wstrict-aliasing=2 \ |
| 132 | -finline-functions \ |
| 133 | -fno-inline-functions-called-once \ |
| 134 | -fgcse-after-reload \ |
| 135 | -frerun-cse-after-loop \ |
| 136 | -frename-registers |
| 137 | |
| 138 | libc_root := bionic/libc |
| 139 | libm_root := bionic/libm |
| 140 | libstdc++_root := bionic/libstdc++ |
| 141 | libthread_db_root := bionic/libthread_db |
| 142 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame^] | 143 | |
| 144 | ## on some hosts, the target cross-compiler is not available so do not run this command |
| 145 | ifneq ($(wildcard $($(combo_target)CC)),) |
| 146 | # We compile with the global cflags to ensure that |
| 147 | # any flags which affect libgcc are correctly taken |
| 148 | # into account. |
| 149 | $(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name) |
| 150 | endif |
| 151 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 152 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 153 | # symlinks located in out/ to point to the appropriate kernel |
| 154 | # headers. see 'config/kernel_headers.make' for more details |
| 155 | # |
| 156 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 157 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 158 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 159 | else |
| 160 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 161 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 162 | endif |
| 163 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 164 | |
| 165 | $(combo_target)C_INCLUDES := \ |
| 166 | $(libc_root)/arch-arm/include \ |
| 167 | $(libc_root)/include \ |
| 168 | $(libstdc++_root)/include \ |
| 169 | $(KERNEL_HEADERS) \ |
| 170 | $(libm_root)/include \ |
| 171 | $(libm_root)/include/arch/arm \ |
| 172 | $(libthread_db_root)/include |
| 173 | |
| 174 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 175 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 176 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
| 177 | |
| 178 | TARGET_STRIP_MODULE:=true |
| 179 | |
| 180 | $(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
| 181 | |
| 182 | $(combo_target)CUSTOM_LD_COMMAND := true |
| 183 | define transform-o-to-shared-lib-inner |
| 184 | $(TARGET_CXX) \ |
| 185 | -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \ |
| 186 | -Wl,--gc-sections \ |
| 187 | -Wl,-shared,-Bsymbolic \ |
| 188 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 189 | $(PRIVATE_ALL_OBJECTS) \ |
| 190 | -Wl,--whole-archive \ |
| 191 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 192 | -Wl,--no-whole-archive \ |
| 193 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 194 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 195 | -o $@ \ |
| 196 | $(PRIVATE_LDFLAGS) \ |
| 197 | $(TARGET_LIBGCC) |
| 198 | endef |
| 199 | |
| 200 | define transform-o-to-executable-inner |
| 201 | $(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 202 | -Wl,-dynamic-linker,/system/bin/linker \ |
| 203 | -Wl,--gc-sections \ |
| 204 | -Wl,-z,nocopyreloc \ |
| 205 | -o $@ \ |
| 206 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 207 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 208 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 209 | $(TARGET_CRTBEGIN_DYNAMIC_O) \ |
| 210 | $(PRIVATE_ALL_OBJECTS) \ |
| 211 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 212 | $(PRIVATE_LDFLAGS) \ |
| 213 | $(TARGET_LIBGCC) \ |
| 214 | $(TARGET_CRTEND_O) |
| 215 | endef |
| 216 | |
| 217 | define transform-o-to-static-executable-inner |
| 218 | $(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 219 | -Wl,--gc-sections \ |
| 220 | -o $@ \ |
| 221 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 222 | $(TARGET_CRTBEGIN_STATIC_O) \ |
| 223 | $(PRIVATE_LDFLAGS) \ |
| 224 | $(PRIVATE_ALL_OBJECTS) \ |
| 225 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 226 | $(TARGET_LIBGCC) \ |
| 227 | $(TARGET_CRTEND_O) |
| 228 | endef |