1# Configuration for Linux on ARM. 2# Included by combo/select.make 3 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 8# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their 9# purpose is to allow module Android.mk files to selectively compile 10# different versions of code based upon the funtionality and 11# instructions available in a given architecture version. 12# 13# The blocks also define specific arch_variant_cflags, which 14# include defines, and compiler settings for the given architecture 15# version. 16# 17ifeq ($(strip $(TARGET_ARCH_VARIANT)),) 18TARGET_ARCH_VARIANT := armv5te 19endif 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# 25ifneq ($(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.) 29endif 30 31TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk 32ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),) 33$(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT)) 34endif 35 36include $(TARGET_ARCH_SPECIFIC_MAKEFILE) 37 38# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else 39ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),) 40$(combo_target)TOOLS_PREFIX := \ 41 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin/arm-eabi- 42endif 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 52TARGET_arm_CFLAGS := -O2 \ 53 -fomit-frame-pointer \ 54 -fstrict-aliasing \ 55 -funswitch-loops \ 56 -finline-limit=300 57 58# Modules can choose to compile some source as thumb. As 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. 62ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) 63TARGET_thumb_CFLAGS := -mthumb \ 64 -Os \ 65 -fomit-frame-pointer \ 66 -fno-strict-aliasing \ 67 -finline-limit=64 68else 69TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS) 70endif 71 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 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. 81ifeq ($(FORCE_ARM_DEBUGGING),true) 82 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing 83 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer 84endif 85 86android_config_h := $(call select-android-config-h,linux-arm) 87arch_include_dir := $(dir $(android_config_h)) 88 89$(combo_target)GLOBAL_CFLAGS += \ 90 -msoft-float -fpic \ 91 -ffunction-sections \ 92 -funwind-tables \ 93 -fstack-protector \ 94 -fno-short-enums \ 95 $(arch_variant_cflags) \ 96 -include $(android_config_h) \ 97 -I $(arch_include_dir) 98 99$(combo_target)GLOBAL_LDFLAGS += \ 100 $(arch_variant_ldflags) 101 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. 106ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true) 107$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork 108else 109$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork 110endif 111 112$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden 113 114$(combo_target)RELEASE_CFLAGS := \ 115 -DSK_RELEASE -DNDEBUG \ 116 -g \ 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 124libc_root := bionic/libc 125libm_root := bionic/libm 126libstdc++_root := bionic/libstdc++ 127libthread_db_root := bionic/libthread_db 128 129 130## on some hosts, the target cross-compiler is not available so do not run this command 131ifneq ($(wildcard $($(combo_target)CC)),) 132# We compile with the global cflags to ensure that 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) 136endif 137 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# 142ifneq ($(CUSTOM_KERNEL_HEADERS),) 143 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS) 144 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS) 145else 146 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common 147 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH) 148endif 149KERNEL_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 160TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o 161TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o 162TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o 163 164TARGET_STRIP_MODULE:=true 165 166$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm 167 168$(combo_target)CUSTOM_LD_COMMAND := true 169define 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) \ 183 $(TARGET_GLOBAL_LDFLAGS) \ 184 $(TARGET_LIBGCC) 185endef 186 187define 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) \ 200 $(TARGET_GLOBAL_LDFLAGS) \ 201 $(TARGET_LIBGCC) \ 202 $(TARGET_CRTEND_O) 203endef 204 205define 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) \ 212 $(TARGET_GLOBAL_LDFLAGS) \ 213 $(PRIVATE_ALL_OBJECTS) \ 214 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 215 $(TARGET_LIBGCC) \ 216 $(TARGET_CRTEND_O) 217endef 218