blob: f998cf44b7f7e6eebafefa97500cae12c0bf57d2 [file] [log] [blame]
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -08001#
2# Copyright (C) 2006 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070017# Configuration for Linux on ARM.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080018# Included by combo/select.mk
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070019
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020020# You can set TARGET_ARCH_VARIANT to use an arch version other
21# than ARMv5TE. Each value should correspond to a file named
22# $(BUILD_COMBOS)/arch/<name>.mk which must contain
23# makefile variable definitions similar to the preprocessor
Ben Lesliee03f0232008-10-30 10:41:09 -050024# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020025# purpose is to allow module Android.mk files to selectively compile
26# different versions of code based upon the funtionality and
Ben Lesliee03f0232008-10-30 10:41:09 -050027# instructions available in a given architecture version.
28#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020029# The blocks also define specific arch_variant_cflags, which
Ben Lesliee03f0232008-10-30 10:41:09 -050030# include defines, and compiler settings for the given architecture
31# version.
32#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020033ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
34TARGET_ARCH_VARIANT := armv5te
Ben Lesliee03f0232008-10-30 10:41:09 -050035endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020036
37TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
38ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
39$(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT))
Andy McFadden8f51a2a2009-05-28 12:47:23 -070040endif
Ben Lesliee03f0232008-10-30 10:41:09 -050041
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020042include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
43
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070044# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080045ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
46TARGET_TOOLS_PREFIX := \
Jing Yub845c2f2009-06-17 12:06:23 -070047 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070048endif
49
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080050TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
51TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
52TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
53TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
54TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
Bruce Beare45ac4342010-06-24 14:02:00 -070055TARGET_STRIP := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
56TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip --shady --quiet $< --outfile $@
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070057
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080058TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070059
Dave Bort95282482009-04-23 18:44:55 -070060TARGET_arm_CFLAGS := -O2 \
61 -fomit-frame-pointer \
62 -fstrict-aliasing \
63 -funswitch-loops \
64 -finline-limit=300
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070065
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020066# Modules can choose to compile some source as thumb. As
Ben Lesliee03f0232008-10-30 10:41:09 -050067# non-thumb enabled targets are supported, this is treated
68# as a 'hint'. If thumb is not enabled, these files are just
69# compiled as ARM.
70ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Dave Bort95282482009-04-23 18:44:55 -070071TARGET_thumb_CFLAGS := -mthumb \
72 -Os \
73 -fomit-frame-pointer \
74 -fno-strict-aliasing \
75 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050076else
Dave Bort8acd8482009-05-05 17:04:20 -070077TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
Ben Lesliee03f0232008-10-30 10:41:09 -050078endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070079
Dave Bort95282482009-04-23 18:44:55 -070080# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
81# or in your environment to force a full arm build, even for
82# files that are normally built as thumb; this can make
83# gdb debugging easier. Don't forget to do a clean build.
84#
85# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070086# of the libraries (libpv, libwebcore, libkjs) need to be built
87# with -mlong-calls. When built at -O0, those libraries are
88# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -070089ifeq ($(FORCE_ARM_DEBUGGING),true)
Dave Bort8acd8482009-05-05 17:04:20 -070090 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
Dave Bort95282482009-04-23 18:44:55 -070091 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
92endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070093
Ben Lesliee03f0232008-10-30 10:41:09 -050094android_config_h := $(call select-android-config-h,linux-arm)
95arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070096
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080097TARGET_GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070098 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070099 -ffunction-sections \
100 -funwind-tables \
101 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800102 -fno-short-enums \
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200103 $(arch_variant_cflags) \
Ben Lesliee03f0232008-10-30 10:41:09 -0500104 -include $(android_config_h) \
105 -I $(arch_include_dir)
106
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800107TARGET_GLOBAL_LDFLAGS += \
Erik Gillingc12c5182009-07-17 15:57:10 -0700108 $(arch_variant_ldflags)
109
Ben Lesliee03f0232008-10-30 10:41:09 -0500110# We only need thumb interworking in cases where thumb support
111# is available in the architecture, and just to be sure, (and
112# since sometimes thumb-interwork appears to be default), we
113# specifically disable when thumb support is unavailable.
114ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800115TARGET_GLOBAL_CFLAGS += -mthumb-interwork
Ben Lesliee03f0232008-10-30 10:41:09 -0500116else
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800117TARGET_GLOBAL_CFLAGS += -mno-thumb-interwork
Ben Lesliee03f0232008-10-30 10:41:09 -0500118endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700119
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800120TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700121
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800122TARGET_RELEASE_CFLAGS := \
Mike Reed8dd26ee2009-10-30 08:32:28 -0400123 -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800124 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700125 -Wstrict-aliasing=2 \
126 -finline-functions \
127 -fno-inline-functions-called-once \
128 -fgcse-after-reload \
129 -frerun-cse-after-loop \
130 -frename-registers
131
132libc_root := bionic/libc
133libm_root := bionic/libm
134libstdc++_root := bionic/libstdc++
135libthread_db_root := bionic/libthread_db
136
Ben Lesliee03f0232008-10-30 10:41:09 -0500137
138## on some hosts, the target cross-compiler is not available so do not run this command
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800139ifneq ($(wildcard $(TARGET_CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200140# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500141# any flags which affect libgcc are correctly taken
142# into account.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800143TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Ben Lesliee03f0232008-10-30 10:41:09 -0500144endif
145
Jing Yu2dcc8062009-09-21 16:31:50 -0700146# Define FDO (Feedback Directed Optimization) options.
147
148TARGET_FDO_CFLAGS:=
149TARGET_FDO_LIB:=
150
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800151target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700152 --print-file-name=libgcov.a)
153ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
154 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
155 # The profile will be generated on /data/local/tmp/profile on the device.
156 TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO
157 TARGET_FDO_LIB := $(target_libgcov)
158else
159 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations.
160 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
161 ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),)
162 TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT)
163 else
164 ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
165 $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.)
166 endif
167 endif
168
169 # If the FDO profile directory can't be found, then FDO is off.
170 ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
171 TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO
172 TARGET_FDO_LIB := $(target_libgcov)
173 endif
174endif
175
176
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700177# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
178# symlinks located in out/ to point to the appropriate kernel
179# headers. see 'config/kernel_headers.make' for more details
180#
181ifneq ($(CUSTOM_KERNEL_HEADERS),)
182 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
183 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
184else
185 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
186 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
187endif
188KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
189
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800190TARGET_C_INCLUDES := \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700191 $(libc_root)/arch-arm/include \
192 $(libc_root)/include \
193 $(libstdc++_root)/include \
194 $(KERNEL_HEADERS) \
195 $(libm_root)/include \
196 $(libm_root)/include/arch/arm \
197 $(libthread_db_root)/include
198
199TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
200TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
201TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
202
203TARGET_STRIP_MODULE:=true
204
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800205TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700206
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800207TARGET_CUSTOM_LD_COMMAND := true
Ben Chengdb95cb42009-09-08 16:31:55 -0700208
Dan Bornsteinfa477ba2009-10-13 15:56:48 -0700209# Enable the Dalvik JIT compiler if not already specified.
210ifeq ($(strip $(WITH_JIT)),)
211 WITH_JIT := true
212endif
Ben Chengdb95cb42009-09-08 16:31:55 -0700213
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700214define transform-o-to-shared-lib-inner
215$(TARGET_CXX) \
216 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
217 -Wl,--gc-sections \
218 -Wl,-shared,-Bsymbolic \
219 $(TARGET_GLOBAL_LD_DIRS) \
220 $(PRIVATE_ALL_OBJECTS) \
221 -Wl,--whole-archive \
222 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
223 -Wl,--no-whole-archive \
224 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
225 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
226 -o $@ \
227 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700228 $(TARGET_GLOBAL_LDFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700229 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700230 $(TARGET_LIBGCC)
231endef
232
233define transform-o-to-executable-inner
234$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
235 -Wl,-dynamic-linker,/system/bin/linker \
236 -Wl,--gc-sections \
237 -Wl,-z,nocopyreloc \
238 -o $@ \
239 $(TARGET_GLOBAL_LD_DIRS) \
240 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
241 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
242 $(TARGET_CRTBEGIN_DYNAMIC_O) \
243 $(PRIVATE_ALL_OBJECTS) \
244 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
245 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700246 $(TARGET_GLOBAL_LDFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700247 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700248 $(TARGET_LIBGCC) \
249 $(TARGET_CRTEND_O)
250endef
251
252define transform-o-to-static-executable-inner
253$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
254 -Wl,--gc-sections \
255 -o $@ \
256 $(TARGET_GLOBAL_LD_DIRS) \
257 $(TARGET_CRTBEGIN_STATIC_O) \
258 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700259 $(TARGET_GLOBAL_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700260 $(PRIVATE_ALL_OBJECTS) \
261 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700262 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700263 $(TARGET_LIBGCC) \
264 $(TARGET_CRTEND_O)
265endef