blob: 67844c80f06faf98c5f816a579f2d91959070956 [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 Yuada132a2010-06-16 20:17:19 -070047 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070048endif
49
Raphael Mollc639c782011-06-20 17:25:01 -070050# Only define these if there's actually a gcc in there.
51# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
52ifneq ($(wildcard $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)),)
53 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
54 TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
55 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
56 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
57 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
58 TARGET_STRIP := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
59 TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip --shady --quiet $< --outfile $@
60endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070061
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080062TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070063
Dave Bort95282482009-04-23 18:44:55 -070064TARGET_arm_CFLAGS := -O2 \
65 -fomit-frame-pointer \
66 -fstrict-aliasing \
67 -funswitch-loops \
68 -finline-limit=300
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070069
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020070# Modules can choose to compile some source as thumb. As
Ben Lesliee03f0232008-10-30 10:41:09 -050071# non-thumb enabled targets are supported, this is treated
72# as a 'hint'. If thumb is not enabled, these files are just
73# compiled as ARM.
74ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Dave Bort95282482009-04-23 18:44:55 -070075TARGET_thumb_CFLAGS := -mthumb \
76 -Os \
77 -fomit-frame-pointer \
78 -fno-strict-aliasing \
79 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050080else
Dave Bort8acd8482009-05-05 17:04:20 -070081TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
Ben Lesliee03f0232008-10-30 10:41:09 -050082endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070083
Dave Bort95282482009-04-23 18:44:55 -070084# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
85# or in your environment to force a full arm build, even for
86# files that are normally built as thumb; this can make
87# gdb debugging easier. Don't forget to do a clean build.
88#
89# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070090# of the libraries (libpv, libwebcore, libkjs) need to be built
91# with -mlong-calls. When built at -O0, those libraries are
92# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -070093ifeq ($(FORCE_ARM_DEBUGGING),true)
Dave Bort8acd8482009-05-05 17:04:20 -070094 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
Dave Bort95282482009-04-23 18:44:55 -070095 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
96endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070097
Ben Lesliee03f0232008-10-30 10:41:09 -050098android_config_h := $(call select-android-config-h,linux-arm)
99arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700100
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800101TARGET_GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700102 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700103 -ffunction-sections \
104 -funwind-tables \
105 -fstack-protector \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700106 -Wa,--noexecstack \
Nick Kralevichd868cad2010-05-14 09:34:59 -0700107 -Werror=format-security \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800108 -fno-short-enums \
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200109 $(arch_variant_cflags) \
Ben Lesliee03f0232008-10-30 10:41:09 -0500110 -include $(android_config_h) \
111 -I $(arch_include_dir)
112
David 'Digit' Turner3e467782010-06-16 16:04:55 -0700113# This is to avoid the dreaded warning compiler message:
114# note: the mangling of 'va_list' has changed in GCC 4.4
115#
116# The fact that the mangling changed does not affect the NDK ABI
117# very fortunately (since none of the exposed APIs used va_list
118# in their exported C++ functions). Also, GCC 4.5 has already
119# removed the warning from the compiler.
120#
121TARGET_GLOBAL_CFLAGS += -Wno-psabi
122
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800123TARGET_GLOBAL_LDFLAGS += \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700124 -Wl,-z,noexecstack \
Erik Gillingc12c5182009-07-17 15:57:10 -0700125 $(arch_variant_ldflags)
126
Ben Lesliee03f0232008-10-30 10:41:09 -0500127# We only need thumb interworking in cases where thumb support
128# is available in the architecture, and just to be sure, (and
129# since sometimes thumb-interwork appears to be default), we
130# specifically disable when thumb support is unavailable.
131ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800132TARGET_GLOBAL_CFLAGS += -mthumb-interwork
Ben Lesliee03f0232008-10-30 10:41:09 -0500133else
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800134TARGET_GLOBAL_CFLAGS += -mno-thumb-interwork
Ben Lesliee03f0232008-10-30 10:41:09 -0500135endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700136
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800137TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700138
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800139TARGET_RELEASE_CFLAGS := \
Mike Reed8dd26ee2009-10-30 08:32:28 -0400140 -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800141 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700142 -Wstrict-aliasing=2 \
143 -finline-functions \
144 -fno-inline-functions-called-once \
145 -fgcse-after-reload \
146 -frerun-cse-after-loop \
147 -frename-registers
148
149libc_root := bionic/libc
150libm_root := bionic/libm
151libstdc++_root := bionic/libstdc++
152libthread_db_root := bionic/libthread_db
153
Ben Lesliee03f0232008-10-30 10:41:09 -0500154
155## on some hosts, the target cross-compiler is not available so do not run this command
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800156ifneq ($(wildcard $(TARGET_CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200157# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500158# any flags which affect libgcc are correctly taken
159# into account.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800160TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Ben Lesliee03f0232008-10-30 10:41:09 -0500161endif
162
Jing Yu2dcc8062009-09-21 16:31:50 -0700163# Define FDO (Feedback Directed Optimization) options.
164
165TARGET_FDO_CFLAGS:=
166TARGET_FDO_LIB:=
167
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800168target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700169 --print-file-name=libgcov.a)
170ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
171 # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
172 # The profile will be generated on /data/local/tmp/profile on the device.
173 TARGET_FDO_CFLAGS := -fprofile-generate=/data/local/tmp/profile -DANDROID_FDO
174 TARGET_FDO_LIB := $(target_libgcov)
175else
176 # If BUILD_FDO_INSTRUMENT is turned off, then consider doing the FDO optimizations.
177 # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
178 ifeq ($(strip $(TARGET_FDO_PROFILE_PATH)),)
179 TARGET_FDO_PROFILE_PATH := fdo/profiles/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT)
180 else
181 ifeq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
182 $(warning Custom TARGET_FDO_PROFILE_PATH supplied, but directory does not exist. Turn off FDO.)
183 endif
184 endif
185
186 # If the FDO profile directory can't be found, then FDO is off.
187 ifneq ($(strip $(wildcard $(TARGET_FDO_PROFILE_PATH))),)
188 TARGET_FDO_CFLAGS := -fprofile-use=$(TARGET_FDO_PROFILE_PATH) -DANDROID_FDO
189 TARGET_FDO_LIB := $(target_libgcov)
190 endif
191endif
192
193
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700194# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
195# symlinks located in out/ to point to the appropriate kernel
196# headers. see 'config/kernel_headers.make' for more details
197#
198ifneq ($(CUSTOM_KERNEL_HEADERS),)
199 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
200 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
201else
202 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
203 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
204endif
205KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
206
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800207TARGET_C_INCLUDES := \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700208 $(libc_root)/arch-arm/include \
209 $(libc_root)/include \
210 $(libstdc++_root)/include \
211 $(KERNEL_HEADERS) \
212 $(libm_root)/include \
213 $(libm_root)/include/arch/arm \
214 $(libthread_db_root)/include
215
216TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
217TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
218TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
219
David 'Digit' Turner438f5f72010-06-18 15:05:01 -0700220TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
221TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
222
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700223TARGET_STRIP_MODULE:=true
224
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800225TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700226
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -0800227TARGET_CUSTOM_LD_COMMAND := true
Ben Chengdb95cb42009-09-08 16:31:55 -0700228
Dan Bornsteinfa477ba2009-10-13 15:56:48 -0700229# Enable the Dalvik JIT compiler if not already specified.
230ifeq ($(strip $(WITH_JIT)),)
231 WITH_JIT := true
232endif
Ben Chengdb95cb42009-09-08 16:31:55 -0700233
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700234define transform-o-to-shared-lib-inner
235$(TARGET_CXX) \
236 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
237 -Wl,--gc-sections \
238 -Wl,-shared,-Bsymbolic \
Ying Wang1a081002010-07-13 14:55:47 -0700239 $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700240 $(PRIVATE_ALL_OBJECTS) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800241 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700242 -Wl,--whole-archive \
243 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
244 -Wl,--no-whole-archive \
245 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
246 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
247 -o $@ \
Ying Wang1a081002010-07-13 14:55:47 -0700248 $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
Nick Kralevich387e4d02010-04-26 14:12:19 -0700249 $(PRIVATE_LDFLAGS) \
Ying Wang1a081002010-07-13 14:55:47 -0700250 $(PRIVATE_TARGET_FDO_LIB) \
Ying Wangf0f60cd2010-07-13 17:21:33 -0700251 $(PRIVATE_TARGET_LIBGCC) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800252 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700253endef
254
255define transform-o-to-executable-inner
256$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
257 -Wl,-dynamic-linker,/system/bin/linker \
258 -Wl,--gc-sections \
259 -Wl,-z,nocopyreloc \
260 -o $@ \
261 $(TARGET_GLOBAL_LD_DIRS) \
262 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
263 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800264 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700265 $(PRIVATE_ALL_OBJECTS) \
266 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700267 $(TARGET_GLOBAL_LDFLAGS) \
Nick Kralevich387e4d02010-04-26 14:12:19 -0700268 $(PRIVATE_LDFLAGS) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700269 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700270 $(TARGET_LIBGCC) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800271 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700272endef
273
274define transform-o-to-static-executable-inner
275$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
276 -Wl,--gc-sections \
277 -o $@ \
278 $(TARGET_GLOBAL_LD_DIRS) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800279 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700280 $(TARGET_GLOBAL_LDFLAGS) \
Nick Kralevich387e4d02010-04-26 14:12:19 -0700281 $(PRIVATE_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700282 $(PRIVATE_ALL_OBJECTS) \
283 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
Jing Yu2dcc8062009-09-21 16:31:50 -0700284 $(TARGET_FDO_LIB) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700285 $(TARGET_LIBGCC) \
Jeff Brownbd528a82011-02-16 14:42:40 -0800286 $(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700287endef