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