blob: 9ffcb860988dbd70d3324a4479b9d3a2fcbb5ba7 [file] [log] [blame]
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -08001#
2# Copyright (C) 2006 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070017# Configuration for Linux on ARM.
Jean-Baptiste Queru9b4a8122010-02-23 12:36:56 -080018# Included by combo/select.mk
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070019
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020020# You can set TARGET_ARCH_VARIANT to use an arch version other
21# than ARMv5TE. Each value should correspond to a file named
22# $(BUILD_COMBOS)/arch/<name>.mk which must contain
23# makefile variable definitions similar to the preprocessor
Ying Wang5bdf3052012-09-20 10:06:33 -070024# defines in build/core/combo/include/arch/<combo>/AndroidConfig.h. Their
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020025# purpose is to allow module Android.mk files to selectively compile
26# different versions of code based upon the funtionality and
Ben Lesliee03f0232008-10-30 10:41:09 -050027# instructions available in a given architecture version.
28#
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020029# The blocks also define specific arch_variant_cflags, which
Ben Lesliee03f0232008-10-30 10:41:09 -050030# include defines, and compiler settings for the given architecture
31# version.
32#
Ying Wange1d44c32013-12-27 11:09:36 -080033ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
34TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te
Ben Lesliee03f0232008-10-30 10:41:09 -050035endif
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020036
Ben Cheng4de6fa42014-04-10 22:46:26 -070037# Decouple NDK library selection with platform compiler version
38$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
39
Ben Chengec4caba2012-12-12 16:22:54 -080040ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
Ying Wange1d44c32013-12-27 11:09:36 -080041$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.8
Ben Chengec4caba2012-12-12 16:22:54 -080042else
Ying Wange1d44c32013-12-27 11:09:36 -080043$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
Ben Cheng054ffd22012-12-11 14:01:10 -080044endif
45
Ying Wange1d44c32013-12-27 11:09:36 -080046TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020047ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
Ying Wange1d44c32013-12-27 11:09:36 -080048$(error Unknown ARM architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
Andy McFadden8f51a2a2009-05-28 12:47:23 -070049endif
Ben Lesliee03f0232008-10-30 10:41:09 -050050
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020051include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
Dehao Chen25671e12014-07-23 14:28:58 -070052include $(BUILD_SYSTEM)/combo/fdo.mk
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +020053
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070054# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
Ying Wange1d44c32013-12-27 11:09:36 -080055ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
56$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
57$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070058endif
59
Ying Wange1d44c32013-12-27 11:09:36 -080060$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
61$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
62$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
63$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
64$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
Christopher Ferrisa6e2f932014-03-18 14:50:09 -070065$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf$(HOST_EXECUTABLE_SUFFIX)
Ying Wange1d44c32013-12-27 11:09:36 -080066$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070067
Ying Wange1d44c32013-12-27 11:09:36 -080068$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070069
Ying Wange1d44c32013-12-27 11:09:36 -080070$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \
Dave Bort95282482009-04-23 18:44:55 -070071 -fomit-frame-pointer \
72 -fstrict-aliasing \
Jing Yua83b7692010-12-21 16:33:48 -080073 -funswitch-loops
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070074
Elliott Hughes03d2aa42013-02-14 12:04:48 -080075# Modules can choose to compile some source as thumb.
Ying Wange1d44c32013-12-27 11:09:36 -080076$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \
Dave Bort95282482009-04-23 18:44:55 -070077 -Os \
78 -fomit-frame-pointer \
Jing Yua83b7692010-12-21 16:33:48 -080079 -fno-strict-aliasing
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070080
Dave Bort95282482009-04-23 18:44:55 -070081# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
82# or in your environment to force a full arm build, even for
83# files that are normally built as thumb; this can make
84# gdb debugging easier. Don't forget to do a clean build.
85#
86# NOTE: if you try to build a -O0 build with thumb, several
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070087# of the libraries (libpv, libwebcore, libkjs) need to be built
88# with -mlong-calls. When built at -O0, those libraries are
89# too big for a thumb "BL <label>" to go from one end to the other.
Dave Bort95282482009-04-23 18:44:55 -070090ifeq ($(FORCE_ARM_DEBUGGING),true)
Ying Wange1d44c32013-12-27 11:09:36 -080091 $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
92 $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
Dave Bort95282482009-04-23 18:44:55 -070093endif
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070094
Ying Wangf4723fa2013-08-15 11:01:10 -070095android_config_h := $(call select-android-config-h,linux-arm)
96
Ying Wange1d44c32013-12-27 11:09:36 -080097$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
Dan Albert4803ce22014-08-06 12:36:46 -070098 -msoft-float \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070099 -ffunction-sections \
Doug Kwanbaff0892010-06-29 11:14:42 -0700100 -fdata-sections \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700101 -funwind-tables \
102 -fstack-protector \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700103 -Wa,--noexecstack \
Nick Kralevichd868cad2010-05-14 09:34:59 -0700104 -Werror=format-security \
Nick Kralevich316f7202013-04-25 16:49:10 -0700105 -D_FORTIFY_SOURCE=2 \
The Android Open Source Project4f85cc52009-01-09 17:50:54 -0800106 -fno-short-enums \
Andrew Hsieh48f239c2014-05-09 14:13:13 +0800107 -no-canonical-prefixes \
108 -fno-canonical-system-headers \
Ying Wangf4723fa2013-08-15 11:01:10 -0700109 $(arch_variant_cflags) \
110 -include $(android_config_h) \
111 -I $(dir $(android_config_h))
Ben Lesliee03f0232008-10-30 10:41:09 -0500112
Ben Cheng1cea0752013-08-28 11:00:54 -0700113# The "-Wunused-but-set-variable" option often breaks projects that enable
114# "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned
115# into no-op in some builds while mesg is defined earlier. So we explicitly
116# disable "-Wunused-but-set-variable" here.
Ying Wange1d44c32013-12-27 11:09:36 -0800117ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
118$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
Ben Cheng1cea0752013-08-28 11:00:54 -0700119 -fno-strict-volatile-bitfields
Doug Kwanbe3689e2011-07-14 16:34:26 -0700120endif
121
David 'Digit' Turner3e467782010-06-16 16:04:55 -0700122# This is to avoid the dreaded warning compiler message:
123# note: the mangling of 'va_list' has changed in GCC 4.4
124#
125# The fact that the mangling changed does not affect the NDK ABI
126# very fortunately (since none of the exposed APIs used va_list
127# in their exported C++ functions). Also, GCC 4.5 has already
128# removed the warning from the compiler.
129#
Ying Wange1d44c32013-12-27 11:09:36 -0800130$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi
David 'Digit' Turner3e467782010-06-16 16:04:55 -0700131
Ying Wange1d44c32013-12-27 11:09:36 -0800132$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
Nick Kralevich2915cc32010-05-05 11:09:52 -0700133 -Wl,-z,noexecstack \
Nick Kralevich233d4602012-04-26 09:09:24 -0700134 -Wl,-z,relro \
135 -Wl,-z,now \
Nick Kralevichb2382102012-08-10 12:51:26 -0700136 -Wl,--warn-shared-textrel \
Nick Kralevich077007e2012-10-18 14:21:26 -0700137 -Wl,--fatal-warnings \
Doug Kwanbaff0892010-06-29 11:14:42 -0700138 -Wl,--icf=safe \
Dmitriy Ivanov179685c2014-11-13 14:51:10 -0800139 -Wl,--hash-style=gnu \
Erik Gillingc12c5182009-07-17 15:57:10 -0700140 $(arch_variant_ldflags)
141
Ying Wange1d44c32013-12-27 11:09:36 -0800142$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700143
Ying Wange1d44c32013-12-27 11:09:36 -0800144$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700145
Ben Chengefd24892010-10-21 15:15:09 -0700146# More flags/options can be added here
Ying Wange1d44c32013-12-27 11:09:36 -0800147$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
Mike Reed8dd26ee2009-10-30 08:32:28 -0400148 -DNDEBUG \
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800149 -g \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700150 -Wstrict-aliasing=2 \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700151 -fgcse-after-reload \
152 -frerun-cse-after-loop \
153 -frename-registers
154
155libc_root := bionic/libc
156libm_root := bionic/libm
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700157
Ben Lesliee03f0232008-10-30 10:41:09 -0500158
159## on some hosts, the target cross-compiler is not available so do not run this command
Ying Wange1d44c32013-12-27 11:09:36 -0800160ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
David 'Digit' Turnerd53c81d2009-05-29 15:34:02 +0200161# We compile with the global cflags to ensure that
Ben Lesliee03f0232008-10-30 10:41:09 -0500162# any flags which affect libgcc are correctly taken
163# into account.
Ying Wange1d44c32013-12-27 11:09:36 -0800164$(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
165 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
Andrew Hsieh4c952d72014-05-29 02:47:27 -0700166$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
167 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
Dan Albert7655a972014-09-24 09:42:39 -0700168$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
169 $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcov.a)
Ben Lesliee03f0232008-10-30 10:41:09 -0500170endif
171
Elliott Hughesdddb5662014-01-10 16:35:08 -0800172KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
Colin Cross3814cbf2014-01-21 16:54:00 -0800173KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_$(combo_2nd_arch_prefix)ARCH)
Christopher Ferris9824ce42013-12-16 13:58:39 -0800174KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700175
Ying Wange1d44c32013-12-27 11:09:36 -0800176$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700177 $(libc_root)/arch-arm/include \
178 $(libc_root)/include \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700179 $(KERNEL_HEADERS) \
180 $(libm_root)/include \
Dima Zavin6d98f5f2010-08-05 17:46:47 -0700181 $(libm_root)/include/arm \
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700182
Ying Wange1d44c32013-12-27 11:09:36 -0800183$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
184$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
185$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700186
Ying Wange1d44c32013-12-27 11:09:36 -0800187$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
188$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
David 'Digit' Turner438f5f72010-06-18 15:05:01 -0700189
Ying Wange1d44c32013-12-27 11:09:36 -0800190$(combo_2nd_arch_prefix)TARGET_STRIP_MODULE:=true
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700191
Dan Albertb05f2ca2014-09-12 14:46:57 -0700192$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700193
Dan Alberte088c0d2014-11-13 10:15:46 -0800194$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker