blob: 6529106b0842d0c1479549c9d6ee4cd86e5871fc [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
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +02004# You can set TARGET_ARCH_VARIANT to use an arch version other
5# than ARMv5TE. Each value should correspond to a file named
6# $(BUILD_COMBOS)/arch/<name>.mk which must contain
7# makefile variable definitions similar to the preprocessor
Ben Lesliee03f0232008-10-30 10:41:09 -05008# defines in system/core/include/arch/<combo>/AndroidConfig.h. Their
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +02009# purpose is to allow module Android.mk files to selectively compile
10# different versions of code based upon the funtionality and
Ben Lesliee03f0232008-10-30 10:41:09 -050011# instructions available in a given architecture version.
12#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020013# The blocks also define specific arch_variant_cflags, which
Ben Lesliee03f0232008-10-30 10:41:09 -050014# include defines, and compiler settings for the given architecture
15# version.
16#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020017ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
18TARGET_ARCH_VARIANT := armv5te
Ben Lesliee03f0232008-10-30 10:41:09 -050019endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020020
21# TARGET_ARCH_VARIANT used to be called TARGET_ARCH_VERSION
22# to avoid any weirdness, issue an error message if the latter
23# is defined.
24#
25ifneq ($(strip $(TARGET_ARCH_VERSION)),)
26$(info Definition for TARGET_ARCH_VERSION encountered !)
27$(info This variable has been renamed TARGET_ARCH_VARIANT, please update your build files !!)
28$(error Aborting the build.)
Ben Lesliee03f0232008-10-30 10:41:09 -050029endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020030
31TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
32ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
33$(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT))
Andy McFadden8f51a2a2009-05-28 12:47:23 -070034endif
Ben Lesliee03f0232008-10-30 10:41:09 -050035
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020036include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
37
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070038# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
39ifeq ($(strip $($(combo_target)TOOLS_PREFIX)),)
40$(combo_target)TOOLS_PREFIX := \
Jing Yub845c2f2009-06-17 12:06:23 -070041 prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070042endif
43
44$(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
45$(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
46$(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
47$(combo_target)OBJCOPY := $($(combo_target)TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
48$(combo_target)LD := $($(combo_target)TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
49
50$(combo_target)NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
51
Dave Bort95282482009-04-23 18:44:55 -070052TARGET_arm_CFLAGS := -O2 \
53 -fomit-frame-pointer \
54 -fstrict-aliasing \
55 -funswitch-loops \
56 -finline-limit=300
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070057
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020058# Modules can choose to compile some source as thumb. As
Ben Lesliee03f0232008-10-30 10:41:09 -050059# non-thumb enabled targets are supported, this is treated
60# as a 'hint'. If thumb is not enabled, these files are just
61# compiled as ARM.
62ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
Dave Bort95282482009-04-23 18:44:55 -070063TARGET_thumb_CFLAGS := -mthumb \
64 -Os \
65 -fomit-frame-pointer \
66 -fno-strict-aliasing \
67 -finline-limit=64
Ben Lesliee03f0232008-10-30 10:41:09 -050068else
Dave Bort8acd8482009-05-05 17:04:20 -070069TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
Ben Lesliee03f0232008-10-30 10:41:09 -050070endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070071
Dave Bort95282482009-04-23 18:44:55 -070072# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
73# or in your environment to force a full arm build, even for
74# files that are normally built as thumb; this can make
75# gdb debugging easier. Don't forget to do a clean build.
76#
77# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070078# of the libraries (libpv, libwebcore, libkjs) need to be built
79# with -mlong-calls. When built at -O0, those libraries are
80# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -070081ifeq ($(FORCE_ARM_DEBUGGING),true)
Dave Bort8acd8482009-05-05 17:04:20 -070082 TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
Dave Bort95282482009-04-23 18:44:55 -070083 TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
84endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070085
Ben Lesliee03f0232008-10-30 10:41:09 -050086android_config_h := $(call select-android-config-h,linux-arm)
87arch_include_dir := $(dir $(android_config_h))
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070088
89$(combo_target)GLOBAL_CFLAGS += \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070090 -msoft-float -fpic \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070091 -ffunction-sections \
92 -funwind-tables \
93 -fstack-protector \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -080094 -fno-short-enums \
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020095 $(arch_variant_cflags) \
Ben Lesliee03f0232008-10-30 10:41:09 -050096 -include $(android_config_h) \
97 -I $(arch_include_dir)
98
Erik Gillingc12c5182009-07-17 15:57:10 -070099$(combo_target)GLOBAL_LDFLAGS += \
100 $(arch_variant_ldflags)
101
Ben Lesliee03f0232008-10-30 10:41:09 -0500102# We only need thumb interworking in cases where thumb support
103# is available in the architecture, and just to be sure, (and
104# since sometimes thumb-interwork appears to be default), we
105# specifically disable when thumb support is unavailable.
106ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
107$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork
108else
109$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork
110endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700111
112$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
113
114$(combo_target)RELEASE_CFLAGS := \
Mike Reed8dd26ee2009-10-30 08:32:28 -0400115 -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800116 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700117 -Wstrict-aliasing=2 \
118 -finline-functions \
119 -fno-inline-functions-called-once \
120 -fgcse-after-reload \
121 -frerun-cse-after-loop \
122 -frename-registers
123
124libc_root := bionic/libc
125libm_root := bionic/libm
126libstdc++_root := bionic/libstdc++
127libthread_db_root := bionic/libthread_db
128
Ben Lesliee03f0232008-10-30 10:41:09 -0500129
130## on some hosts, the target cross-compiler is not available so do not run this command
131ifneq ($(wildcard $($(combo_target)CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200132# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500133# any flags which affect libgcc are correctly taken
134# into account.
135$(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
136endif
137
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700138# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
139# symlinks located in out/ to point to the appropriate kernel
140# headers. see 'config/kernel_headers.make' for more details
141#
142ifneq ($(CUSTOM_KERNEL_HEADERS),)
143 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
144 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
145else
146 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
147 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
148endif
149KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
150
151$(combo_target)C_INCLUDES := \
152 $(libc_root)/arch-arm/include \
153 $(libc_root)/include \
154 $(libstdc++_root)/include \
155 $(KERNEL_HEADERS) \
156 $(libm_root)/include \
157 $(libm_root)/include/arch/arm \
158 $(libthread_db_root)/include
159
160TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
161TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
162TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
163
164TARGET_STRIP_MODULE:=true
165
166$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
167
168$(combo_target)CUSTOM_LD_COMMAND := true
169define transform-o-to-shared-lib-inner
170$(TARGET_CXX) \
171 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
172 -Wl,--gc-sections \
173 -Wl,-shared,-Bsymbolic \
174 $(TARGET_GLOBAL_LD_DIRS) \
175 $(PRIVATE_ALL_OBJECTS) \
176 -Wl,--whole-archive \
177 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
178 -Wl,--no-whole-archive \
179 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
180 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
181 -o $@ \
182 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700183 $(TARGET_GLOBAL_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700184 $(TARGET_LIBGCC)
185endef
186
187define transform-o-to-executable-inner
188$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
189 -Wl,-dynamic-linker,/system/bin/linker \
190 -Wl,--gc-sections \
191 -Wl,-z,nocopyreloc \
192 -o $@ \
193 $(TARGET_GLOBAL_LD_DIRS) \
194 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
195 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
196 $(TARGET_CRTBEGIN_DYNAMIC_O) \
197 $(PRIVATE_ALL_OBJECTS) \
198 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
199 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700200 $(TARGET_GLOBAL_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700201 $(TARGET_LIBGCC) \
202 $(TARGET_CRTEND_O)
203endef
204
205define transform-o-to-static-executable-inner
206$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
207 -Wl,--gc-sections \
208 -o $@ \
209 $(TARGET_GLOBAL_LD_DIRS) \
210 $(TARGET_CRTBEGIN_STATIC_O) \
211 $(PRIVATE_LDFLAGS) \
Erik Gillingc12c5182009-07-17 15:57:10 -0700212 $(TARGET_GLOBAL_LDFLAGS) \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700213 $(PRIVATE_ALL_OBJECTS) \
214 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
215 $(TARGET_LIBGCC) \
216 $(TARGET_CRTEND_O)
217endef