blob: 6826c7965eaf1a1ed6af129ef58453bbbb281f32 [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
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -080076TARGET_arm_release_CFLAGS := -O2 \
77 -fomit-frame-pointer \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070078 -fstrict-aliasing \
79 -funswitch-loops \
80 -finline-limit=300
81
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)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070087TARGET_thumb_release_CFLAGS := -mthumb \
88 -Os \
89 -fomit-frame-pointer \
90 -fno-strict-aliasing \
91 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050092else
93TARGET_thumb_release_CFLAGS := $(TARGET_arm_release_CFLAGS)
94endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070095
96# When building for debug, compile everything as arm.
97TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
98TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer
99
100# NOTE: if you try to build a debug build with thumb, several
101# of the libraries (libpv, libwebcore, libkjs) need to be built
102# with -mlong-calls. When built at -O0, those libraries are
103# too big for a thumb "BL <label>" to go from one end to the other.
104
105## As hopefully a temporary hack,
106## use this to force a full ARM build (for easier debugging in gdb)
107## (don't forget to do a clean build)
108##TARGET_arm_release_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer
109##TARGET_thumb_release_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer
110
Ben Lesliee03f0232008-10-30 10:41:09 -0500111android_config_h := $(call select-android-config-h,linux-arm)
112arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700113
114$(combo_target)GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700115 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700116 -ffunction-sections \
117 -funwind-tables \
118 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800119 -fno-short-enums \
Ben Lesliee03f0232008-10-30 10:41:09 -0500120 $(arch_version_cflags) \
121 -include $(android_config_h) \
122 -I $(arch_include_dir)
123
124# We only need thumb interworking in cases where thumb support
125# is available in the architecture, and just to be sure, (and
126# since sometimes thumb-interwork appears to be default), we
127# specifically disable when thumb support is unavailable.
128ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
129$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork
130else
131$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork
132endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700133
134$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
135
136$(combo_target)RELEASE_CFLAGS := \
137 -DSK_RELEASE -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800138 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700139 -Wstrict-aliasing=2 \
140 -finline-functions \
141 -fno-inline-functions-called-once \
142 -fgcse-after-reload \
143 -frerun-cse-after-loop \
144 -frename-registers
145
146libc_root := bionic/libc
147libm_root := bionic/libm
148libstdc++_root := bionic/libstdc++
149libthread_db_root := bionic/libthread_db
150
Ben Lesliee03f0232008-10-30 10:41:09 -0500151
152## on some hosts, the target cross-compiler is not available so do not run this command
153ifneq ($(wildcard $($(combo_target)CC)),)
154# We compile with the global cflags to ensure that
155# any flags which affect libgcc are correctly taken
156# into account.
157$(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
158endif
159
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700160# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
161# symlinks located in out/ to point to the appropriate kernel
162# headers. see 'config/kernel_headers.make' for more details
163#
164ifneq ($(CUSTOM_KERNEL_HEADERS),)
165 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
166 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
167else
168 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
169 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
170endif
171KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
172
173$(combo_target)C_INCLUDES := \
174 $(libc_root)/arch-arm/include \
175 $(libc_root)/include \
176 $(libstdc++_root)/include \
177 $(KERNEL_HEADERS) \
178 $(libm_root)/include \
179 $(libm_root)/include/arch/arm \
180 $(libthread_db_root)/include
181
182TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
183TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
184TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
185
186TARGET_STRIP_MODULE:=true
187
188$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
189
190$(combo_target)CUSTOM_LD_COMMAND := true
191define transform-o-to-shared-lib-inner
192$(TARGET_CXX) \
193 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
194 -Wl,--gc-sections \
195 -Wl,-shared,-Bsymbolic \
196 $(TARGET_GLOBAL_LD_DIRS) \
197 $(PRIVATE_ALL_OBJECTS) \
198 -Wl,--whole-archive \
199 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
200 -Wl,--no-whole-archive \
201 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
202 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
203 -o $@ \
204 $(PRIVATE_LDFLAGS) \
205 $(TARGET_LIBGCC)
206endef
207
208define transform-o-to-executable-inner
209$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
210 -Wl,-dynamic-linker,/system/bin/linker \
211 -Wl,--gc-sections \
212 -Wl,-z,nocopyreloc \
213 -o $@ \
214 $(TARGET_GLOBAL_LD_DIRS) \
215 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
216 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
217 $(TARGET_CRTBEGIN_DYNAMIC_O) \
218 $(PRIVATE_ALL_OBJECTS) \
219 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
220 $(PRIVATE_LDFLAGS) \
221 $(TARGET_LIBGCC) \
222 $(TARGET_CRTEND_O)
223endef
224
225define transform-o-to-static-executable-inner
226$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
227 -Wl,--gc-sections \
228 -o $@ \
229 $(TARGET_GLOBAL_LD_DIRS) \
230 $(TARGET_CRTBEGIN_STATIC_O) \
231 $(PRIVATE_LDFLAGS) \
232 $(PRIVATE_ALL_OBJECTS) \
233 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
234 $(TARGET_LIBGCC) \
235 $(TARGET_CRTEND_O)
236endef