blob: f2524455cde7089ab927b7832de0dde634ff01a7 [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
Ben Lesliee03f0232008-10-30 10:41:09 -05004# You can set TARGET_ARCH_VERSION to use an arch version other
5# than ARMv5TE
6ifeq ($(strip $(TARGET_ARCH_VERSION)),)
7TARGET_ARCH_VERSION := armv5te
8endif
9
10# This set of if blocks sets makefile variables similar to preprocesser
11# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their
12# purpose is to allow module Android.mk files to selctively compile
13# different versions of code based upon the funtionality and
14# instructions available in a given architecture version.
15#
16# The blocks also define specific arch_version_cflags, which
17# include defines, and compiler settings for the given architecture
18# version.
19#
20# Note: Hard coding the 'tune' value here is probably not ideal,
21# and a better solution should be found in the future.
22#
23# With two or three different versions this if block approach is
24# fine. If/when this becomes large, please change this to include
25# architecture versions specific Makefiles which define these
26# variables.
Fredrik Markströmb7990f72009-03-24 23:38:51 +010027#
28# Supporting armv4 (without thumb) does not make much sense since
29# it's mostly an obsoleted instruction set architecture (only available
30# in StrongArm and arm8). Supporting armv4 will require a lot of conditional
31# code in assembler source since the bx (branch and exchange) instruction is
32# not supported.
33#
Ben Lesliee03f0232008-10-30 10:41:09 -050034ifeq ($(TARGET_ARCH_VERSION),armv5te)
35ARCH_ARM_HAVE_THUMB_SUPPORT := true
36ARCH_ARM_HAVE_FAST_INTERWORKING := true
37ARCH_ARM_HAVE_64BIT_DATA := true
38ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
39ARCH_ARM_HAVE_CLZ := true
40ARCH_ARM_HAVE_FFS := true
41
42arch_version_cflags := -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ \
43 -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__
44else
Fredrik Markströmb7990f72009-03-24 23:38:51 +010045ifeq ($(TARGET_ARCH_VERSION),armv4t)
46$(warning ARMv4t support is currently a work in progress. It does not work right now!)
Ben Lesliee03f0232008-10-30 10:41:09 -050047ARCH_ARM_HAVE_THUMB_SUPPORT := false
48ARCH_ARM_HAVE_THUMB_INTERWORKING := false
49ARCH_ARM_HAVE_64BIT_DATA := false
50ARCH_ARM_HAVE_HALFWORD_MULTIPLY := false
51ARCH_ARM_HAVE_CLZ := false
52ARCH_ARM_HAVE_FFS := false
53
Fredrik Markströmb7990f72009-03-24 23:38:51 +010054DEFAULT_TARGET_CPU := arm920t
Ben Lesliee03f0232008-10-30 10:41:09 -050055
Fredrik Markströmb7990f72009-03-24 23:38:51 +010056arch_version_cflags := -march=armv4t -mtune=arm920t -D__ARM_ARCH_4T__
Ben Lesliee03f0232008-10-30 10:41:09 -050057else
58$(error Unknown ARM architecture version: $(TARGET_ARCH_VERSION))
59endif
60endif
61
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070062# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
63ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),)
64$(combo_target)TOOLS_PREFIX := \
Doug Kwan8c9bef62009-04-30 14:47:05 -070065 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.3.1/bin/arm-eabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070066endif
67
68$(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
69$(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
70$(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
71$(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
72$(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
73
74$(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
75
Dave Bort95282482009-04-23 18:44:55 -070076TARGET_arm_CFLAGS := -O2 \
77 -fomit-frame-pointer \
78 -fstrict-aliasing \
79 -funswitch-loops \
80 -finline-limit=300
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070081
Ben Lesliee03f0232008-10-30 10:41:09 -050082# Modules can choose to compile some source as thumb. As
83# non-thumb enabled targets are supported, this is treated
84# as a 'hint'. If thumb is not enabled, these files are just
85# compiled as ARM.
86ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Dave Bort95282482009-04-23 18:44:55 -070087TARGET_thumb_CFLAGS := -mthumb \
88 -Os \
89 -fomit-frame-pointer \
90 -fno-strict-aliasing \
91 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050092else
Dave Bort8acd8482009-05-05 17:04:20 -070093TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
Ben Lesliee03f0232008-10-30 10:41:09 -050094endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070095
Dave Bort95282482009-04-23 18:44:55 -070096# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
97# or in your environment to force a full arm build, even for
98# files that are normally built as thumb; this can make
99# gdb debugging easier. Don't forget to do a clean build.
100#
101# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700102# of the libraries (libpv, libwebcore, libkjs) need to be built
103# with -mlong-calls. When built at -O0, those libraries are
104# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -0700105ifeq ($(FORCE_ARM_DEBUGGING),true)
Dave Bort8acd8482009-05-05 17:04:20 -0700106 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
Dave Bort95282482009-04-23 18:44:55 -0700107 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
108endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700109
Ben Lesliee03f0232008-10-30 10:41:09 -0500110android_config_h := $(call select-android-config-h,linux-arm)
111arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700112
113$(combo_target)GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700114 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700115 -ffunction-sections \
116 -funwind-tables \
117 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800118 -fno-short-enums \
Ben Lesliee03f0232008-10-30 10:41:09 -0500119 $(arch_version_cflags) \
120 -include $(android_config_h) \
121 -I $(arch_include_dir)
122
123# We only need thumb interworking in cases where thumb support
124# is available in the architecture, and just to be sure, (and
125# since sometimes thumb-interwork appears to be default), we
126# specifically disable when thumb support is unavailable.
127ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
128$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork
129else
130$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork
131endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700132
133$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
134
135$(combo_target)RELEASE_CFLAGS := \
136 -DSK_RELEASE -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800137 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700138 -Wstrict-aliasing=2 \
139 -finline-functions \
140 -fno-inline-functions-called-once \
141 -fgcse-after-reload \
142 -frerun-cse-after-loop \
143 -frename-registers
144
145libc_root := bionic/libc
146libm_root := bionic/libm
147libstdc++_root := bionic/libstdc++
148libthread_db_root := bionic/libthread_db
149
Ben Lesliee03f0232008-10-30 10:41:09 -0500150
151## on some hosts, the target cross-compiler is not available so do not run this command
152ifneq ($(wildcard $($(combo_target)CC)),)
153# We compile with the global cflags to ensure that
154# any flags which affect libgcc are correctly taken
155# into account.
156$(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
157endif
158
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700159# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
160# symlinks located in out/ to point to the appropriate kernel
161# headers. see 'config/kernel_headers.make' for more details
162#
163ifneq ($(CUSTOM_KERNEL_HEADERS),)
164 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
165 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
166else
167 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
168 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
169endif
170KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
171
172$(combo_target)C_INCLUDES := \
173 $(libc_root)/arch-arm/include \
174 $(libc_root)/include \
175 $(libstdc++_root)/include \
176 $(KERNEL_HEADERS) \
177 $(libm_root)/include \
178 $(libm_root)/include/arch/arm \
179 $(libthread_db_root)/include
180
181TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
182TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
183TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
184
185TARGET_STRIP_MODULE:=true
186
187$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
188
189$(combo_target)CUSTOM_LD_COMMAND := true
190define transform-o-to-shared-lib-inner
191$(TARGET_CXX) \
192 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
193 -Wl,--gc-sections \
194 -Wl,-shared,-Bsymbolic \
195 $(TARGET_GLOBAL_LD_DIRS) \
196 $(PRIVATE_ALL_OBJECTS) \
197 -Wl,--whole-archive \
198 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
199 -Wl,--no-whole-archive \
200 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
201 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
202 -o $@ \
203 $(PRIVATE_LDFLAGS) \
204 $(TARGET_LIBGCC)
205endef
206
207define transform-o-to-executable-inner
208$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
209 -Wl,-dynamic-linker,/system/bin/linker \
210 -Wl,--gc-sections \
211 -Wl,-z,nocopyreloc \
212 -o $@ \
213 $(TARGET_GLOBAL_LD_DIRS) \
214 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
215 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
216 $(TARGET_CRTBEGIN_DYNAMIC_O) \
217 $(PRIVATE_ALL_OBJECTS) \
218 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
219 $(PRIVATE_LDFLAGS) \
220 $(TARGET_LIBGCC) \
221 $(TARGET_CRTEND_O)
222endef
223
224define transform-o-to-static-executable-inner
225$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
226 -Wl,--gc-sections \
227 -o $@ \
228 $(TARGET_GLOBAL_LD_DIRS) \
229 $(TARGET_CRTBEGIN_STATIC_O) \
230 $(PRIVATE_LDFLAGS) \
231 $(PRIVATE_ALL_OBJECTS) \
232 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
233 $(TARGET_LIBGCC) \
234 $(TARGET_CRTEND_O)
235endef