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 | |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 4 | # You can set TARGET_ARCH_VARIANT to use an arch version other |
| 5 | # than ARMv5TE. Each value should correspond to a file named |
| 6 | # $(BUILD_COMBOS)/arch/<name>.mk which must contain |
| 7 | # makefile variable definitions similar to the preprocessor |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 8 | # defines in system/core/include/arch/<combo>/AndroidConfig.h. Their |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 9 | # purpose is to allow module Android.mk files to selectively compile |
| 10 | # different versions of code based upon the funtionality and |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 11 | # instructions available in a given architecture version. |
| 12 | # |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 13 | # The blocks also define specific arch_variant_cflags, which |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 14 | # include defines, and compiler settings for the given architecture |
| 15 | # version. |
| 16 | # |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 17 | ifeq ($(strip $(TARGET_ARCH_VARIANT)),) |
| 18 | TARGET_ARCH_VARIANT := armv5te |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 19 | endif |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 20 | |
| 21 | # TARGET_ARCH_VARIANT used to be called TARGET_ARCH_VERSION |
| 22 | # to avoid any weirdness, issue an error message if the latter |
| 23 | # is defined. |
| 24 | # |
| 25 | ifneq ($(strip $(TARGET_ARCH_VERSION)),) |
| 26 | $(info Definition for TARGET_ARCH_VERSION encountered !) |
| 27 | $(info This variable has been renamed TARGET_ARCH_VARIANT, please update your build files !!) |
| 28 | $(error Aborting the build.) |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 29 | endif |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 30 | |
| 31 | TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk |
| 32 | ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),) |
| 33 | $(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT)) |
Andy McFadden | 8f51a2a | 2009-05-28 12:47:23 -0700 | [diff] [blame] | 34 | endif |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 35 | |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 36 | include $(TARGET_ARCH_SPECIFIC_MAKEFILE) |
| 37 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 38 | # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else |
| 39 | ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),) |
| 40 | $(combo_target)TOOLS_PREFIX := \ |
Jing Yu | b845c2f | 2009-06-17 12:06:23 -0700 | [diff] [blame] | 41 | prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin/arm-eabi- |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 42 | endif |
| 43 | |
| 44 | $(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX) |
| 45 | $(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX) |
| 46 | $(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX) |
| 47 | $(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX) |
| 48 | $(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX) |
| 49 | |
| 50 | $(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined |
| 51 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 52 | TARGET_arm_CFLAGS := -O2 \ |
| 53 | -fomit-frame-pointer \ |
| 54 | -fstrict-aliasing \ |
| 55 | -funswitch-loops \ |
| 56 | -finline-limit=300 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 | |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 58 | # Modules can choose to compile some source as thumb. As |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 59 | # non-thumb enabled targets are supported, this is treated |
| 60 | # as a 'hint'. If thumb is not enabled, these files are just |
| 61 | # compiled as ARM. |
| 62 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 63 | TARGET_thumb_CFLAGS := -mthumb \ |
| 64 | -Os \ |
| 65 | -fomit-frame-pointer \ |
| 66 | -fno-strict-aliasing \ |
| 67 | -finline-limit=64 |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 68 | else |
Dave Bort | 8acd848 | 2009-05-05 17:04:20 -0700 | [diff] [blame] | 69 | TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS) |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 70 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 71 | |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 72 | # Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk |
| 73 | # or in your environment to force a full arm build, even for |
| 74 | # files that are normally built as thumb; this can make |
| 75 | # gdb debugging easier. Don't forget to do a clean build. |
| 76 | # |
| 77 | # 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] | 78 | # of the libraries (libpv, libwebcore, libkjs) need to be built |
| 79 | # with -mlong-calls. When built at -O0, those libraries are |
| 80 | # 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] | 81 | ifeq ($(FORCE_ARM_DEBUGGING),true) |
Dave Bort | 8acd848 | 2009-05-05 17:04:20 -0700 | [diff] [blame] | 82 | TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing |
Dave Bort | 9528248 | 2009-04-23 18:44:55 -0700 | [diff] [blame] | 83 | TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer |
| 84 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 85 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 86 | android_config_h := $(call select-android-config-h,linux-arm) |
| 87 | arch_include_dir := $(dir $(android_config_h)) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 88 | |
| 89 | $(combo_target)GLOBAL_CFLAGS += \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 90 | -msoft-float -fpic \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 91 | -ffunction-sections \ |
| 92 | -funwind-tables \ |
| 93 | -fstack-protector \ |
The Android Open Source Project | 4f85cc5 | 2009-01-09 17:50:54 -0800 | [diff] [blame] | 94 | -fno-short-enums \ |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 95 | $(arch_variant_cflags) \ |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 96 | -include $(android_config_h) \ |
| 97 | -I $(arch_include_dir) |
| 98 | |
Erik Gilling | c12c518 | 2009-07-17 15:57:10 -0700 | [diff] [blame] | 99 | $(combo_target)GLOBAL_LDFLAGS += \ |
| 100 | $(arch_variant_ldflags) |
| 101 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 102 | # We only need thumb interworking in cases where thumb support |
| 103 | # is available in the architecture, and just to be sure, (and |
| 104 | # since sometimes thumb-interwork appears to be default), we |
| 105 | # specifically disable when thumb support is unavailable. |
| 106 | ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) |
| 107 | $(combo_target)GLOBAL_CFLAGS += -mthumb-interwork |
| 108 | else |
| 109 | $(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork |
| 110 | endif |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 111 | |
| 112 | $(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden |
| 113 | |
| 114 | $(combo_target)RELEASE_CFLAGS := \ |
Mike Reed | 8dd26ee | 2009-10-30 08:32:28 -0400 | [diff] [blame^] | 115 | -DNDEBUG \ |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 116 | -g \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 117 | -Wstrict-aliasing=2 \ |
| 118 | -finline-functions \ |
| 119 | -fno-inline-functions-called-once \ |
| 120 | -fgcse-after-reload \ |
| 121 | -frerun-cse-after-loop \ |
| 122 | -frename-registers |
| 123 | |
| 124 | libc_root := bionic/libc |
| 125 | libm_root := bionic/libm |
| 126 | libstdc++_root := bionic/libstdc++ |
| 127 | libthread_db_root := bionic/libthread_db |
| 128 | |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 129 | |
| 130 | ## on some hosts, the target cross-compiler is not available so do not run this command |
| 131 | ifneq ($(wildcard $($(combo_target)CC)),) |
David 'Digit' Turner | d53c81d | 2009-05-29 15:34:02 +0200 | [diff] [blame] | 132 | # We compile with the global cflags to ensure that |
Ben Leslie | e03f023 | 2008-10-30 10:41:09 -0500 | [diff] [blame] | 133 | # any flags which affect libgcc are correctly taken |
| 134 | # into account. |
| 135 | $(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name) |
| 136 | endif |
| 137 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 138 | # unless CUSTOM_KERNEL_HEADERS is defined, we're going to use |
| 139 | # symlinks located in out/ to point to the appropriate kernel |
| 140 | # headers. see 'config/kernel_headers.make' for more details |
| 141 | # |
| 142 | ifneq ($(CUSTOM_KERNEL_HEADERS),) |
| 143 | KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) |
| 144 | KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) |
| 145 | else |
| 146 | KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common |
| 147 | KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) |
| 148 | endif |
| 149 | KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) |
| 150 | |
| 151 | $(combo_target)C_INCLUDES := \ |
| 152 | $(libc_root)/arch-arm/include \ |
| 153 | $(libc_root)/include \ |
| 154 | $(libstdc++_root)/include \ |
| 155 | $(KERNEL_HEADERS) \ |
| 156 | $(libm_root)/include \ |
| 157 | $(libm_root)/include/arch/arm \ |
| 158 | $(libthread_db_root)/include |
| 159 | |
| 160 | TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o |
| 161 | TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o |
| 162 | TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o |
| 163 | |
| 164 | TARGET_STRIP_MODULE:=true |
| 165 | |
| 166 | $(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm |
| 167 | |
| 168 | $(combo_target)CUSTOM_LD_COMMAND := true |
| 169 | define transform-o-to-shared-lib-inner |
| 170 | $(TARGET_CXX) \ |
| 171 | -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \ |
| 172 | -Wl,--gc-sections \ |
| 173 | -Wl,-shared,-Bsymbolic \ |
| 174 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 175 | $(PRIVATE_ALL_OBJECTS) \ |
| 176 | -Wl,--whole-archive \ |
| 177 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ |
| 178 | -Wl,--no-whole-archive \ |
| 179 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 180 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 181 | -o $@ \ |
| 182 | $(PRIVATE_LDFLAGS) \ |
Erik Gilling | c12c518 | 2009-07-17 15:57:10 -0700 | [diff] [blame] | 183 | $(TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 184 | $(TARGET_LIBGCC) |
| 185 | endef |
| 186 | |
| 187 | define transform-o-to-executable-inner |
| 188 | $(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 189 | -Wl,-dynamic-linker,/system/bin/linker \ |
| 190 | -Wl,--gc-sections \ |
| 191 | -Wl,-z,nocopyreloc \ |
| 192 | -o $@ \ |
| 193 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 194 | -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \ |
| 195 | $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ |
| 196 | $(TARGET_CRTBEGIN_DYNAMIC_O) \ |
| 197 | $(PRIVATE_ALL_OBJECTS) \ |
| 198 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 199 | $(PRIVATE_LDFLAGS) \ |
Erik Gilling | c12c518 | 2009-07-17 15:57:10 -0700 | [diff] [blame] | 200 | $(TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 201 | $(TARGET_LIBGCC) \ |
| 202 | $(TARGET_CRTEND_O) |
| 203 | endef |
| 204 | |
| 205 | define transform-o-to-static-executable-inner |
| 206 | $(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \ |
| 207 | -Wl,--gc-sections \ |
| 208 | -o $@ \ |
| 209 | $(TARGET_GLOBAL_LD_DIRS) \ |
| 210 | $(TARGET_CRTBEGIN_STATIC_O) \ |
| 211 | $(PRIVATE_LDFLAGS) \ |
Erik Gilling | c12c518 | 2009-07-17 15:57:10 -0700 | [diff] [blame] | 212 | $(TARGET_GLOBAL_LDFLAGS) \ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 213 | $(PRIVATE_ALL_OBJECTS) \ |
| 214 | $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ |
| 215 | $(TARGET_LIBGCC) \ |
| 216 | $(TARGET_CRTEND_O) |
| 217 | endef |