blob: ec786c01f25e07781be49dc70938561360175ddc [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
99# We only need thumb interworking in cases where thumb support
100# is available in the architecture, and just to be sure, (and
101# since sometimes thumb-interwork appears to be default), we
102# specifically disable when thumb support is unavailable.
103ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
104$(combo_target)GLOBAL_CFLAGS += -mthumb-interwork
105else
106$(combo_target)GLOBAL_CFLAGS += -mno-thumb-interwork
107endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700108
109$(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
110
111$(combo_target)RELEASE_CFLAGS := \
112 -DSK_RELEASE -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800113 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700114 -Wstrict-aliasing=2 \
115 -finline-functions \
116 -fno-inline-functions-called-once \
117 -fgcse-after-reload \
118 -frerun-cse-after-loop \
119 -frename-registers
120
121libc_root := bionic/libc
122libm_root := bionic/libm
123libstdc++_root := bionic/libstdc++
124libthread_db_root := bionic/libthread_db
125
Ben Lesliee03f0232008-10-30 10:41:09 -0500126
127## on some hosts, the target cross-compiler is not available so do not run this command
128ifneq ($(wildcard $($(combo_target)CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200129# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500130# any flags which affect libgcc are correctly taken
131# into account.
132$(combo_target)LIBGCC := $(shell $($(combo_target)CC) $($(combo_target)GLOBAL_CFLAGS) -print-libgcc-file-name)
133endif
134
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700135# unless CUSTOM_KERNEL_HEADERS is defined, we're going to use
136# symlinks located in out/ to point to the appropriate kernel
137# headers. see 'config/kernel_headers.make' for more details
138#
139ifneq ($(CUSTOM_KERNEL_HEADERS),)
140 KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
141 KERNEL_HEADERS_ARCH := $(CUSTOM_KERNEL_HEADERS)
142else
143 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
144 KERNEL_HEADERS_ARCH := $(libc_root)/kernel/arch-$(TARGET_ARCH)
145endif
146KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
147
148$(combo_target)C_INCLUDES := \
149 $(libc_root)/arch-arm/include \
150 $(libc_root)/include \
151 $(libstdc++_root)/include \
152 $(KERNEL_HEADERS) \
153 $(libm_root)/include \
154 $(libm_root)/include/arch/arm \
155 $(libthread_db_root)/include
156
157TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
158TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
159TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
160
161TARGET_STRIP_MODULE:=true
162
163$(combo_target)DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
164
165$(combo_target)CUSTOM_LD_COMMAND := true
166define transform-o-to-shared-lib-inner
167$(TARGET_CXX) \
168 -nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
169 -Wl,--gc-sections \
170 -Wl,-shared,-Bsymbolic \
171 $(TARGET_GLOBAL_LD_DIRS) \
172 $(PRIVATE_ALL_OBJECTS) \
173 -Wl,--whole-archive \
174 $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
175 -Wl,--no-whole-archive \
176 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
177 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
178 -o $@ \
179 $(PRIVATE_LDFLAGS) \
180 $(TARGET_LIBGCC)
181endef
182
183define transform-o-to-executable-inner
184$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
185 -Wl,-dynamic-linker,/system/bin/linker \
186 -Wl,--gc-sections \
187 -Wl,-z,nocopyreloc \
188 -o $@ \
189 $(TARGET_GLOBAL_LD_DIRS) \
190 -Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
191 $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
192 $(TARGET_CRTBEGIN_DYNAMIC_O) \
193 $(PRIVATE_ALL_OBJECTS) \
194 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
195 $(PRIVATE_LDFLAGS) \
196 $(TARGET_LIBGCC) \
197 $(TARGET_CRTEND_O)
198endef
199
200define transform-o-to-static-executable-inner
201$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
202 -Wl,--gc-sections \
203 -o $@ \
204 $(TARGET_GLOBAL_LD_DIRS) \
205 $(TARGET_CRTBEGIN_STATIC_O) \
206 $(PRIVATE_LDFLAGS) \
207 $(PRIVATE_ALL_OBJECTS) \
208 $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
209 $(TARGET_LIBGCC) \
210 $(TARGET_CRTEND_O)
211endef