blob: 75afbbdde9d115aad0c35ba896bd1484abe56ea9 [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.
27#
28ifeq ($(TARGET_ARCH_VERSION),armv5te)
29ARCH_ARM_HAVE_THUMB_SUPPORT := true
30ARCH_ARM_HAVE_FAST_INTERWORKING := true
31ARCH_ARM_HAVE_64BIT_DATA := true
32ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
33ARCH_ARM_HAVE_CLZ := true
34ARCH_ARM_HAVE_FFS := true
35
36arch_version_cflags := -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ \
37 -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__
38else
39ifeq ($(TARGET_ARCH_VERSION),armv4)
40$(warning ARMv4 support is currently a work in progress. It does not work right now!)
41ARCH_ARM_HAVE_THUMB_SUPPORT := false
42ARCH_ARM_HAVE_THUMB_INTERWORKING := false
43ARCH_ARM_HAVE_64BIT_DATA := false
44ARCH_ARM_HAVE_HALFWORD_MULTIPLY := false
45ARCH_ARM_HAVE_CLZ := false
46ARCH_ARM_HAVE_FFS := false
47
48DEFAULT_TARGET_CPU := arm920
49
50arch_version_cflags := -march=armv4 -mtune=arm920 -D__ARM_ARCH_4__
51else
52$(error Unknown ARM architecture version: $(TARGET_ARCH_VERSION))
53endif
54endif
55
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070056# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
57ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),)
58$(combo_target)TOOLS_PREFIX := \
59 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
60endif
61
62$(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
63$(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
64$(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
65$(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
66$(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
67
68$(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
69
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -080070TARGET_arm_release_CFLAGS := -O2 \
71 -fomit-frame-pointer \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070072 -fstrict-aliasing \
73 -funswitch-loops \
74 -finline-limit=300
75
Ben Lesliee03f0232008-10-30 10:41:09 -050076# Modules can choose to compile some source as thumb. As
77# non-thumb enabled targets are supported, this is treated
78# as a 'hint'. If thumb is not enabled, these files are just
79# compiled as ARM.
80ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070081TARGET_thumb_release_CFLAGS := -mthumb \
82 -Os \
83 -fomit-frame-pointer \
84 -fno-strict-aliasing \
85 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050086else
87TARGET_thumb_release_CFLAGS := $(TARGET_arm_release_CFLAGS)
88endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070089
90# When building for debug, compile everything as arm.
91TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer -fno-strict-aliasing
92TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer
93
94# NOTE: if you try to build a debug build with thumb, several
95# of the libraries (libpv, libwebcore, libkjs) need to be built
96# with -mlong-calls. When built at -O0, those libraries are
97# too big for a thumb "BL <label>" to go from one end to the other.
98
99## As hopefully a temporary hack,
100## use this to force a full ARM build (for easier debugging in gdb)
101## (don't forget to do a clean build)
102##TARGET_arm_release_CFLAGS := $(TARGET_arm_release_CFLAGS) -fno-omit-frame-pointer
103##TARGET_thumb_release_CFLAGS := $(TARGET_thumb_release_CFLAGS) -marm -fno-omit-frame-pointer
104
Ben Lesliee03f0232008-10-30 10:41:09 -0500105android_config_h := $(call select-android-config-h,linux-arm)
106arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700107
108$(combo_target)GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700109 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700110 -ffunction-sections \
111 -funwind-tables \
112 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800113 -fno-short-enums \
Ben Lesliee03f0232008-10-30 10:41:09 -0500114 $(arch_version_cflags) \
115 -include $(android_config_h) \
116 -I $(arch_include_dir)
117
118# We only need thumb interworking in cases where thumb support
119# is available in the architecture, and just to be sure, (and
120# since sometimes thumb-interwork appears to be default), we
121# specifically disable when thumb support is unavailable.
122ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
123$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork
124else
125$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork
126endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700127
128$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
129
130$(combo_target)RELEASE_CFLAGS := \
131 -DSK_RELEASE -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800132 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700133 -Wstrict-aliasing=2 \
134 -finline-functions \
135 -fno-inline-functions-called-once \
136 -fgcse-after-reload \
137 -frerun-cse-after-loop \
138 -frename-registers
139
140libc_root := bionic/libc
141libm_root := bionic/libm
142libstdc++_root := bionic/libstdc++
143libthread_db_root := bionic/libthread_db
144
Ben Lesliee03f0232008-10-30 10:41:09 -0500145
146## on some hosts, the target cross-compiler is not available so do not run this command
147ifneq ($(wildcard $($(combo_target)CC)),)
148# We compile with the global cflags to ensure that
149# any flags which affect libgcc are correctly taken
150# into account.
151$(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
152endif
153
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700154# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
155# symlinks located in out/ to point to the appropriate kernel
156# headers. see 'config/kernel_headers.make' for more details
157#
158ifneq ($(CUSTOM_KERNEL_HEADERS),)
159 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
160 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
161else
162 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
163 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
164endif
165KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
166
167$(combo_target)C_INCLUDES := \
168 $(libc_root)/arch-arm/include \
169 $(libc_root)/include \
170 $(libstdc++_root)/include \
171 $(KERNEL_HEADERS) \
172 $(libm_root)/include \
173 $(libm_root)/include/arch/arm \
174 $(libthread_db_root)/include
175
176TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
177TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
178TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
179
180TARGET_STRIP_MODULE:=true
181
182$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
183
184$(combo_target)CUSTOM_LD_COMMAND := true
185define transform-o-to-shared-lib-inner
186$(TARGET_CXX) \
187 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
188 -Wl,--gc-sections \
189 -Wl,-shared,-Bsymbolic \
190 $(TARGET_GLOBAL_LD_DIRS) \
191 $(PRIVATE_ALL_OBJECTS) \
192 -Wl,--whole-archive \
193 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
194 -Wl,--no-whole-archive \
195 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
196 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
197 -o $@ \
198 $(PRIVATE_LDFLAGS) \
199 $(TARGET_LIBGCC)
200endef
201
202define transform-o-to-executable-inner
203$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
204 -Wl,-dynamic-linker,/system/bin/linker \
205 -Wl,--gc-sections \
206 -Wl,-z,nocopyreloc \
207 -o $@ \
208 $(TARGET_GLOBAL_LD_DIRS) \
209 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
210 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
211 $(TARGET_CRTBEGIN_DYNAMIC_O) \
212 $(PRIVATE_ALL_OBJECTS) \
213 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
214 $(PRIVATE_LDFLAGS) \
215 $(TARGET_LIBGCC) \
216 $(TARGET_CRTEND_O)
217endef
218
219define transform-o-to-static-executable-inner
220$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
221 -Wl,--gc-sections \
222 -o $@ \
223 $(TARGET_GLOBAL_LD_DIRS) \
224 $(TARGET_CRTBEGIN_STATIC_O) \
225 $(PRIVATE_LDFLAGS) \
226 $(PRIVATE_ALL_OBJECTS) \
227 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
228 $(TARGET_LIBGCC) \
229 $(TARGET_CRTEND_O)
230endef