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.2 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 ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) 27 28 SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm 29 TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-arm/gdbserver/gdbserver 30 TARGET_ARCH_ABI := armeabi-v7a 31 NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 32 TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/armeabi-v7a/libportable.a $(TARGET_LDLIBS) 33 TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/armeabi-v7a/libportable.wrap 34 include $(NDK_ROOT)/toolchains/arm-linux-androideabi-clang3.2/setup.mk 35 36 else 37 ifneq ($(filter %armeabi,$(TARGET_ARCH_ABI)),) 38 39 SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm 40 TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-arm/gdbserver/gdbserver 41 TARGET_ARCH_ABI := armeabi 42 NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 43 TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/armeabi/libportable.a $(TARGET_LDLIBS) 44 TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/armeabi/libportable.wrap 45 include $(NDK_ROOT)/toolchains/arm-linux-androideabi-clang3.2/setup.mk 46 47 else 48 ifneq ($(filter %x86,$(TARGET_ARCH_ABI)),) 49 50 SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-x86 51 TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-x86/gdbserver/gdbserver 52 TARGET_ARCH_ABI := x86 53 NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 54 TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/x86/libportable.a $(TARGET_LDLIBS) 55 TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/x86/libportable.wrap 56 include $(NDK_ROOT)/toolchains/x86-clang3.2/setup.mk 57 58 else 59 ifneq ($(filter %mips,$(TARGET_ARCH_ABI)),) 60 61 SYSROOT_LINK := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-mips 62 TARGET_GDBSERVER := $(NDK_ROOT)/prebuilt/android-mips/gdbserver/gdbserver 63 TARGET_ARCH_ABI := mips 64 NDK_APP_DST_DIR := $(NDK_APP_PROJECT_PATH)/libs/$(TARGET_ARCH_ABI) 65 TARGET_LDLIBS := $(NDK_ROOT)/sources/android/libportable/libs/mips/libportable.a $(TARGET_LDLIBS) 66 TARGET_LDFLAGS += -Wl,@$(NDK_ROOT)/sources/android/libportable/libs/mips/libportable.wrap 67 include $(NDK_ROOT)/toolchains/mipsel-linux-android-clang3.2/setup.mk 68 69 else 70 71 TOOLCHAIN_NAME := clang-3.2 72 TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/ 73 LLVM_TRIPLE := le32-none-ndk 74 75 TARGET_CC := $(TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT) 76 TARGET_CXX := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) 77 TARGET_LD := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT) 78 TARGET_AR := $(TOOLCHAIN_PREFIX)llvm-ar$(HOST_EXEEXT) 79 TARGET_STRIP := $(TOOLCHAIN_PREFIX)$(LLVM_TRIPLE)-strip$(HOST_EXEEXT) 80 81 TARGET_OBJ_EXTENSION := .bc 82 TARGET_LIB_EXTENSION := .a #.bc 83 TARGET_SONAME_EXTENSION := .bc 84 85 TARGET_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 97 TARGET_NO_EXECUTE_CFLAGS := 98 99 # Add and LDFLAGS for the target here 100 TARGET_LDFLAGS := \ 101 -target $(LLVM_TRIPLE) \ 102 -emit-llvm \ 103 -no-canonical-prefixes 104 105 TARGET_C_INCLUDES := \ 106 $(SYSROOT_INC)/usr/include 107 108 TARGET_release_CFLAGS := -O2 \ 109 -g \ 110 -DNDEBUG \ 111 -fomit-frame-pointer \ 112 -fstrict-aliasing 113 114 TARGET_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 # 123 TARGET-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 130 endif 131 endif 132 endif 133 endif 134