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 x86 llvm-3.1 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 30LLVM_VERSION := 3.1 31LLVM_NAME := llvm-$(LLVM_VERSION) 32LLVM_TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(LLVM_NAME) 33LLVM_TOOLCHAIN_PREBUILT_ROOT := $(LLVM_TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) 34LLVM_TOOLCHAIN_PREFIX := $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/ 35 36TOOLCHAIN_VERSION := 4.6 37TOOLCHAIN_NAME := x86-$(TOOLCHAIN_VERSION) 38TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME) 39TOOLCHAIN_PREBUILT_ROOT := $(TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) 40TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/i686-linux-android- 41 42TARGET_CC := $(LLVM_TOOLCHAIN_PREFIX)clang 43TARGET_CXX := $(LLVM_TOOLCHAIN_PREFIX)clang++ 44 45LLVM_TRIPLE := i686-none-linux-android 46 47TARGET_CFLAGS := \ 48 -B$(TOOLCHAIN_PREBUILT_ROOT) \ 49 -target $(LLVM_TRIPLE) \ 50 -ffunction-sections \ 51 -funwind-tables \ 52 -fno-builtin \ 53 -fstack-protector \ 54 -fPIC 55 56TARGET_C_INCLUDES := \ 57 $(SYSROOT)/usr/include 58 59# Add and LDFLAGS for the target here 60TARGET_LDFLAGS := \ 61 -B$(TOOLCHAIN_PREBUILT_ROOT) \ 62 -target $(LLVM_TRIPLE) 63 64TARGET_x86_release_CFLAGS := -O2 \ 65 -fomit-frame-pointer \ 66 -fstrict-aliasing 67 68# When building for debug, compile everything as x86. 69TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \ 70 -fno-omit-frame-pointer \ 71 -fno-strict-aliasing 72 73# This function will be called to determine the target CFLAGS used to build 74# a C or Assembler source file, based on its tags. 75# 76TARGET-process-src-files-tags = \ 77$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \ 78$(eval __release_sources := $(call get-src-files-without-tag,debug)) \ 79$(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_x86_debug_CFLAGS)) \ 80$(call set-src-files-target-cflags, $(__release_sources),$(TARGET_x86_release_CFLAGS)) \ 81$(call set-src-files-text,$(LOCAL_SRC_FILES),x86$(space)$(space)) \ 82 83# The ABI-specific sub-directory that the SDK tools recognize for 84# this toolchain's generated binaries 85TARGET_ABI_SUBDIR := x86 86