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
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
)
50 -gcc-toolchain
$(call host-path
,$(TOOLCHAIN_PREBUILT_ROOT
)) \
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
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
) \
78 TARGET_LDFLAGS
+= -target
$(LLVM_TRIPLE
) \
81 ifneq ($(filter %armeabi-v7a-hard
,$(TARGET_ARCH_ABI
)),)
82 LLVM_TRIPLE
:= armv7-none-linux-androideabi
84 TARGET_CFLAGS
+= -target
$(LLVM_TRIPLE
) \
88 -D_NDK_MATH_NO_SOFTFP
=1
90 TARGET_LDFLAGS
+= -target
$(LLVM_TRIPLE
) \
92 -Wl
,--no-warn-mismatch \
95 LLVM_TRIPLE
:= armv5te-none-linux-androideabi
97 TARGET_CFLAGS
+= -target
$(LLVM_TRIPLE
) \
102 TARGET_LDFLAGS
+= -target
$(LLVM_TRIPLE
)
106 TARGET_CFLAGS.neon
:= -mfpu
=neon
108 TARGET_arm_release_CFLAGS
:= -O2 \
111 -fomit-frame-pointer \
114 TARGET_thumb_release_CFLAGS
:= -mthumb \
118 -fomit-frame-pointer \
121 # When building for debug, compile everything as arm.
122 TARGET_arm_debug_CFLAGS
:= $(TARGET_arm_release_CFLAGS
) \
125 -fno-omit-frame-pointer \
128 TARGET_thumb_debug_CFLAGS
:= $(TARGET_thumb_release_CFLAGS
) \
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
)