1 # Copyright (C) 2009 The Android Open Source Project 2 # 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 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 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. 14 # 15 16 # this file is used to prepare the NDK to build with the arm clang-3.3 17 # toolchain any number of source files 18 # 19 # its purpose is to define (or re-define) templates used to build 20 # various sources into target object files, libraries or executables. 21 # 22 # Note that this file may end up being parsed several times in future 23 # revisions of the NDK. 24 # 25 26 # 27 # Override the toolchain prefix 28 # 29 30 LLVM_VERSION := 3.3 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/ 35 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- 41 42 TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT) 43 TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) 44 45 # 46 # CFLAGS and LDFLAGS 47 # 48 49 TARGET_CFLAGS := \ 50 -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \ 51 -fpic \ 52 -ffunction-sections \ 53 -funwind-tables \ 54 -fstack-protector \ 55 -no-canonical-prefixes 56 57 TARGET_LDFLAGS += \ 58 -gcc-toolchain $(call host-path,$(TOOLCHAIN_PREBUILT_ROOT)) \ 59 -no-canonical-prefixes 60 61 TARGET_C_INCLUDES := \ 62 $(SYSROOT_INC)/usr/include 63 64 ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) 65 LLVM_TRIPLE := armv7-none-linux-androideabi 66 67 TARGET_CFLAGS += -target $(LLVM_TRIPLE) \ 68 -march=armv7-a \ 69 -mfloat-abi=softfp \ 70 -mfpu=vfpv3-d16 71 72 TARGET_LDFLAGS += -target $(LLVM_TRIPLE) \ 73 -Wl,--fix-cortex-a8 74 else 75 LLVM_TRIPLE := armv5te-none-linux-androideabi 76 77 TARGET_CFLAGS += -target $(LLVM_TRIPLE) \ 78 -march=armv5te \ 79 -mtune=xscale \ 80 -msoft-float 81 82 TARGET_LDFLAGS += -target $(LLVM_TRIPLE) 83 endif 84 85 TARGET_CFLAGS.neon := -mfpu=neon 86 87 TARGET_arm_release_CFLAGS := -O2 \ 88 -g \ 89 -DNDEBUG \ 90 -fomit-frame-pointer \ 91 -fstrict-aliasing 92 93 TARGET_thumb_release_CFLAGS := -mthumb \ 94 -Os \ 95 -g \ 96 -DNDEBUG \ 97 -fomit-frame-pointer \ 98 -fno-strict-aliasing 99 100 # When building for debug, compile everything as arm. 101 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \ 102 -O0 \ 103 -UNDEBUG \ 104 -fno-omit-frame-pointer \ 105 -fno-strict-aliasing 106 107 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \ 108 -O0 \ 109 -UNDEBUG \ 110 -marm \ 111 -fno-omit-frame-pointer 112 113 # This function will be called to determine the target CFLAGS used to build 114 # a C or Assembler source file, based on its tags. 115 # 116 TARGET-process-src-files-tags = \ 117 $(eval __arm_sources := $(call get-src-files-with-tag,arm)) \ 118 $(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \ 119 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \ 120 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \ 121 $(call set-src-files-target-cflags, \ 122 $(call set_intersection,$(__arm_sources),$(__debug_sources)), \ 123 $(TARGET_arm_debug_CFLAGS)) \ 124 $(call set-src-files-target-cflags,\ 125 $(call set_intersection,$(__arm_sources),$(__release_sources)),\ 126 $(TARGET_arm_release_CFLAGS)) \ 127 $(call set-src-files-target-cflags,\ 128 $(call set_intersection,$(__arm_sources),$(__debug_sources)),\ 129 $(TARGET_arm_debug_CFLAGS)) \ 130 $(call set-src-files-target-cflags,\ 131 $(call set_intersection,$(__thumb_sources),$(__release_sources)),\ 132 $(TARGET_thumb_release_CFLAGS)) \ 133 $(call set-src-files-target-cflags,\ 134 $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\ 135 $(TARGET_thumb_debug_CFLAGS)) \ 136 $(call add-src-files-target-cflags,\ 137 $(call get-src-files-with-tag,neon),\ 138 $(TARGET_CFLAGS.neon)) \ 139 $(call set-src-files-text,$(__arm_sources),arm$(space)$(space)) \ 140 $(call set-src-files-text,$(__thumb_sources),thumb) 141