Revert "Roll NDK to r11c and extract it into its own repository."
[android_tools.git] / ndk / toolchains / arm-linux-androideabi-clang3.5 / setup.mk
blob3efee68aa57731679e8a7b83880b03a4b1add72e
1 # Copyright (C) 2014 The Android Open Source Project
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 # this file is used to prepare the NDK to build with the arm clang-3.5
17 # toolchain any number of source files
19 # its purpose is to define (or re-define) templates used to build
20 # various sources into target object files, libraries or executables.
22 # Note that this file may end up being parsed several times in future
23 # revisions of the NDK.
27 # Override the toolchain prefix
30 LLVM_VERSION := 3.5
31 LLVM_NAME := llvm-$(LLVM_VERSION)
32 LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME)
33 LLVM_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(LLVM_TOOLCHAIN_ROOT))
34 LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/
36 TOOLCHAIN_VERSION := 4.8
37 TOOLCHAIN_NAME := arm-linux-androideabi-$(TOOLCHAIN_VERSION)
38 TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
39 TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
40 TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi-
42 TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
43 TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
46 # CFLAGS and LDFLAGS
49 TARGET_CFLAGS := \
50 -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
51 -fpic \
52 -ffunction-sections \
53 -funwind-tables \
54 -fstack-protector-strong \
55 -Wno-invalid-command-line-argument \
56 -Wno-unused-command-line-argument \
57 -no-canonical-prefixes
59 # Disable integrated-as for better compatibility
60 TARGET_CFLAGS += \
61 -fno-integrated-as
63 TARGET_LDFLAGS += \
64 -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \
65 -no-canonical-prefixes
67 TARGET_C_INCLUDES := \
68 $(SYSROOT_INC)/usr/include
70 ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),)
71 LLVM_TRIPLE := armv7-none-linux-androideabi
73 TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
74 -march=armv7-a \
75 -mfloat-abi=softfp \
76 -mfpu=vfpv3-d16
78 TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \
79 -Wl,--fix-cortex-a8
80 else
81 ifneq ($(filter %armeabi-v7a-hard,$(TARGET_ARCH_ABI)),)
82 LLVM_TRIPLE := armv7-none-linux-androideabi
84 TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
85 -march=armv7-a \
86 -mfpu=vfpv3-d16 \
87 -mhard-float \
88 -D_NDK_MATH_NO_SOFTFP=1
90 TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \
91 -Wl,--fix-cortex-a8 \
92 -Wl,--no-warn-mismatch \
93 -lm_hard
94 else
95 LLVM_TRIPLE := armv5te-none-linux-androideabi
97 TARGET_CFLAGS += -target $(LLVM_TRIPLE) \
98 -march=armv5te \
99 -mtune=xscale \
100 -msoft-float
102 TARGET_LDFLAGS += -target $(LLVM_TRIPLE)
103 endif
104 endif
106 TARGET_CFLAGS.neon := -mfpu=neon
108 TARGET_arm_release_CFLAGS := -O2 \
109 -g \
110 -DNDEBUG \
111 -fomit-frame-pointer \
112 -fstrict-aliasing
114 TARGET_thumb_release_CFLAGS := -mthumb \
115 -Os \
116 -g \
117 -DNDEBUG \
118 -fomit-frame-pointer \
119 -fno-strict-aliasing
121 # When building for debug, compile everything as arm.
122 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
123 -O0 \
124 -UNDEBUG \
125 -fno-omit-frame-pointer \
126 -fno-strict-aliasing
128 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
129 -O0 \
130 -UNDEBUG \
131 -marm \
132 -fno-omit-frame-pointer
134 # This function will be called to determine the target CFLAGS used to build
135 # a C or Assembler source file, based on its tags.
137 TARGET-process-src-files-tags = \
138 $(eval __arm_sources := $(call get-src-files-with-tag,arm)) \
139 $(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \
140 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
141 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \
142 $(call set-src-files-target-cflags, \
143 $(call set_intersection,$(__arm_sources),$(__debug_sources)), \
144 $(TARGET_arm_debug_CFLAGS)) \
145 $(call set-src-files-target-cflags,\
146 $(call set_intersection,$(__arm_sources),$(__release_sources)),\
147 $(TARGET_arm_release_CFLAGS)) \
148 $(call set-src-files-target-cflags,\
149 $(call set_intersection,$(__arm_sources),$(__debug_sources)),\
150 $(TARGET_arm_debug_CFLAGS)) \
151 $(call set-src-files-target-cflags,\
152 $(call set_intersection,$(__thumb_sources),$(__release_sources)),\
153 $(TARGET_thumb_release_CFLAGS)) \
154 $(call set-src-files-target-cflags,\
155 $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\
156 $(TARGET_thumb_debug_CFLAGS)) \
157 $(call add-src-files-target-cflags,\
158 $(call get-src-files-with-tag,neon),\
159 $(TARGET_CFLAGS.neon)) \
160 $(call set-src-files-text,$(__arm_sources),arm) \
161 $(call set-src-files-text,$(__thumb_sources),thumb)