blob: 44d3540864d6f192da86342ac993780993667fe4 [file] [log] [blame]
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001# Configuration for Linux on ARM.
2# Included by combo/select.make
3
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +02004# 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 Lesliee03f0232008-10-30 10:41:09 -05008# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +02009# purpose is to allow module Android.mk files to selectively compile
10# different versions of code based upon the funtionality and
Ben Lesliee03f0232008-10-30 10:41:09 -050011# instructions available in a given architecture version.
12#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020013# The blocks also define specific arch_variant_cflags, which
Ben Lesliee03f0232008-10-30 10:41:09 -050014# include defines, and compiler settings for the given architecture
15# version.
16#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020017ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
18TARGET_ARCH_VARIANT := armv5te
Ben Lesliee03f0232008-10-30 10:41:09 -050019endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020020
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.)
Ben Lesliee03f0232008-10-30 10:41:09 -050029endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020030
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))
Andy McFadden8f51a2a2009-05-28 12:47:23 -070034endif
Ben Lesliee03f0232008-10-30 10:41:09 -050035
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020036include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
37
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070038# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
39ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),)
40$(combo_target)TOOLS_PREFIX := \
Jing Yub845c2f2009-06-17 12:06:23 -070041 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070042endif
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 Bort95282482009-04-23 18:44:55 -070052TARGET_arm_CFLAGS := -O2 \
53 -fomit-frame-pointer \
54 -fstrict-aliasing \
55 -funswitch-loops \
56 -finline-limit=300
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070057
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020058# Modules can choose to compile some source as thumb. As
Ben Lesliee03f0232008-10-30 10:41:09 -050059# 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)
Dave Bort95282482009-04-23 18:44:55 -070063TARGET_thumb_CFLAGS := -mthumb \
64 -Os \
65 -fomit-frame-pointer \
66 -fno-strict-aliasing \
67 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050068else
Dave Bort8acd8482009-05-05 17:04:20 -070069TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
Ben Lesliee03f0232008-10-30 10:41:09 -050070endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070071
Dave Bort95282482009-04-23 18:44:55 -070072# 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 Projectb6c1cf62008-10-21 07:00:00 -070078# 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 Bort95282482009-04-23 18:44:55 -070081ifeq ($(FORCE_ARM_DEBUGGING),true)
Dave Bort8acd8482009-05-05 17:04:20 -070082 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
Dave Bort95282482009-04-23 18:44:55 -070083 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
84endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070085
Ben Lesliee03f0232008-10-30 10:41:09 -050086android_config_h := $(call select-android-config-h,linux-arm)
87arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070088
89$(combo_target)GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070090 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070091 -ffunction-sections \
92 -funwind-tables \
93 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -080094 -fno-short-enums \
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020095 $(arch_variant_cflags) \
Ben Lesliee03f0232008-10-30 10:41:09 -050096 -include $(android_config_h) \
97 -I $(arch_include_dir)
98
Erik Gillingc12c5182009-07-17 15:57:10 -070099$(combo_target)GLOBAL_LDFLAGS += \
100 $(arch_variant_ldflags)
101
Ben Lesliee03f0232008-10-30 10:41:09 -0500102# 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
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700111
112$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
113
114$(combo_target)RELEASE_CFLAGS := \
115 -DSK_RELEASE -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800116 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700117 -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
Ben Lesliee03f0232008-10-30 10:41:09 -0500129
130## on some hosts, the target cross-compiler is not available so do not run this command
131ifneq ($(wildcard $($(combo_target)CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200132# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500133# 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
Jing Yu2dcc8062009-09-21 16:31:50 -0700138# Define FDO (Feedback Directed Optimization) options.
139
140TARGET_FDO_CFLAGS:=
141TARGET_FDO_LIB:=
142
143target_libgcov := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) \
144 --print-file-name=libgcov.a)
145ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
146 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
147 # The profile will be generated on /data/local/tmp/profile on the device.
148 TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO
149 TARGET_FDO_LIB := $(target_libgcov)
150else
151 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations.
152 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
153 ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),)
154 TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT)
155 else
156 ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
157 $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.)
158 endif
159 endif
160
161 # If the FDO profile directory can't be found, then FDO is off.
162 ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
163 TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO
164 TARGET_FDO_LIB := $(target_libgcov)
165 endif
166endif
167
168
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700169# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
170# symlinks located in out/ to point to the appropriate kernel
171# headers. see 'config/kernel_headers.make' for more details
172#
173ifneq ($(CUSTOM_KERNEL_HEADERS),)
174 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
175 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
176else
177 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
178 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
179endif
180KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
181
182$(combo_target)C_INCLUDES := \
183 $(libc_root)/arch-arm/include \
184 $(libc_root)/include \
185 $(libstdc++_root)/include \
186 $(KERNEL_HEADERS) \
187 $(libm_root)/include \
188 $(libm_root)/include/arch/arm \
189 $(libthread_db_root)/include
190
191TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
192TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
193TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
194
195TARGET_STRIP_MODULE:=true
196
197$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
198
199$(combo_target)CUSTOM_LD_COMMAND := true
Ben Chengdb95cb42009-09-08 16:31:55 -0700200
201# Enable the Dalvik JIT compiler
202WITH_JIT := true
203
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700204define transform-o-to-shared-lib-inner
205$(TARGET_CXX) \
206 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
207 -Wl,--gc-sections \
208 -Wl,-shared,-Bsymbolic \
209 $(TARGET_GLOBAL_LD_DIRS) \
210 $(PRIVATE_ALL_OBJECTS) \
211 -Wl,--whole-archive \
212 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
213 -Wl,--no-whole-archive \
214 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
215 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
216 -o $@ \
217 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700218 $(TARGET_GLOBAL_LDFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700219 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700220 $(TARGET_LIBGCC)
221endef
222
223define transform-o-to-executable-inner
224$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
225 -Wl,-dynamic-linker,/system/bin/linker \
226 -Wl,--gc-sections \
227 -Wl,-z,nocopyreloc \
228 -o $@ \
229 $(TARGET_GLOBAL_LD_DIRS) \
230 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
231 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
232 $(TARGET_CRTBEGIN_DYNAMIC_O) \
233 $(PRIVATE_ALL_OBJECTS) \
234 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
235 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700236 $(TARGET_GLOBAL_LDFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700237 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700238 $(TARGET_LIBGCC) \
239 $(TARGET_CRTEND_O)
240endef
241
242define transform-o-to-static-executable-inner
243$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
244 -Wl,--gc-sections \
245 -o $@ \
246 $(TARGET_GLOBAL_LD_DIRS) \
247 $(TARGET_CRTBEGIN_STATIC_O) \
248 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700249 $(TARGET_GLOBAL_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700250 $(PRIVATE_ALL_OBJECTS) \
251 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700252 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700253 $(TARGET_LIBGCC) \
254 $(TARGET_CRTEND_O)
255endef