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 clang-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 26ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) 27 28SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm 29TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-arm/gdbserver/gdbserver 30TARGET_ARCH_ABI := armeabi-v7a 31NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 32TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/armeabi-v7a/libportable.a $(TARGET_LDLIBS) 33TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/armeabi-v7a/libportable.wrap 34include $(NDK_ROOT)/toolchains/arm-linux-androideabi-clang3.1/setup.mk 35 36else 37ifneq ($(filter %armeabi,$(TARGET_ARCH_ABI)),) 38 39SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm 40TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-arm/gdbserver/gdbserver 41TARGET_ARCH_ABI := armeabi 42NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 43TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/armeabi/libportable.a $(TARGET_LDLIBS) 44TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/armeabi/libportable.wrap 45include $(NDK_ROOT)/toolchains/arm-linux-androideabi-clang3.1/setup.mk 46 47else 48ifneq ($(filter %x86,$(TARGET_ARCH_ABI)),) 49 50SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-x86 51TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-x86/gdbserver/gdbserver 52TARGET_ARCH_ABI := x86 53NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 54TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/x86/libportable.a $(TARGET_LDLIBS) 55TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/x86/libportable.wrap 56include $(NDK_ROOT)/toolchains/x86-clang3.1/setup.mk 57 58else 59ifneq ($(filter %mips,$(TARGET_ARCH_ABI)),) 60 61SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-mips 62TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-mips/gdbserver/gdbserver 63TARGET_ARCH_ABI := mips 64NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 65TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/mips/libportable.a $(TARGET_LDLIBS) 66TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/mips/libportable.wrap 67include $(NDK_ROOT)/toolchains/mipsel-linux-android-clang3.1/setup.mk 68 69else 70 71TOOLCHAIN_NAME := clang-3.1 72TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/ 73LLVM_TRIPLE := le32-none-ndk 74 75TARGET_CC := $(TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT) 76TARGET_CXX := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) 77TARGET_LD := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) 78TARGET_AR := $(TOOLCHAIN_PREFIX)llvm-ar$(HOST_EXEEXT) 79TARGET_STRIP := $(TOOLCHAIN_PREFIX)$(LLVM_TRIPLE)-strip$(HOST_EXEEXT) 80 81TARGET_OBJ_EXTENSION := .bc 82TARGET_LIB_EXTENSION := .a #.bc 83TARGET_SONAME_EXTENSION := .bc 84 85TARGET_CFLAGS := \ 86 -target $(LLVM_TRIPLE) \ 87 -emit-llvm \ 88 -ffunction-sections \ 89 -funwind-tables \ 90 -fPIC \ 91 -no-canonical-prefixes 92# -nostdlibinc 93 94#TARGET_CXXFLAGS := $(TARGET_CFLAGS) -fno-exceptions -fno-rtti 95 96# reset backend flags 97TARGET_NO_EXECUTE_CFLAGS := 98 99# Add and LDFLAGS for the target here 100TARGET_LDFLAGS := \ 101 -target $(LLVM_TRIPLE) \ 102 -emit-llvm \ 103 -no-canonical-prefixes 104 105TARGET_C_INCLUDES := \ 106 $(SYSROOT_INC)/usr/include 107 108TARGET_release_CFLAGS := -O2 \ 109 -g \ 110 -DNDEBUG \ 111 -fomit-frame-pointer \ 112 -fstrict-aliasing 113 114TARGET_debug_CFLAGS := $(TARGET_release_CFLAGS) \ 115 -O0 \ 116 -UNDEBUG \ 117 -fno-omit-frame-pointer \ 118 -fno-strict-aliasing 119 120# This function will be called to determine the target CFLAGS used to build 121# a C or Assembler source file, based on its tags. 122# 123TARGET-process-src-files-tags = \ 124$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \ 125$(eval __release_sources := $(call get-src-files-without-tag,debug)) \ 126$(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_debug_CFLAGS)) \ 127$(call set-src-files-target-cflags, $(__release_sources),$(TARGET_release_CFLAGS)) \ 128$(call set-src-files-text,$(LOCAL_SRC_FILES),plus$(space)$(space)) \ 129 130endif 131endif 132endif 133endif 134