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 gcc-4.8 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 TARGET_CFLAGS := \ 27 -fpic \ 28 -ffunction-sections \ 29 -funwind-tables \ 30 -fstack-protector \ 31 -no-canonical-prefixes 32 33 TARGET_LDFLAGS := -no-canonical-prefixes 34 35 TARGET_C_INCLUDES := \ 36 $(SYSROOT_INC)/usr/include 37 38 ifneq ($(filter $(TARGET_ARCH_ABI), armeabi-v7a armeabi-v7a-hard),) 39 TARGET_CFLAGS += -march=armv7-a \ 40 -mfpu=vfpv3-d16 41 TARGET_LDFLAGS += -march=armv7-a \ 42 -Wl,--fix-cortex-a8 43 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 44 TARGET_CFLAGS += -mfloat-abi=softfp 45 else 46 TARGET_CFLAGS += -mhard-float \ 47 -D_NDK_MATH_NO_SOFTFP=1 48 TARGET_LDFLAGS += -Wl,--no-warn-mismatch \ 49 -lm_hard 50 endif 51 52 else 53 TARGET_CFLAGS += -march=armv5te \ 54 -mtune=xscale \ 55 -msoft-float 56 endif 57 58 TARGET_CFLAGS.neon := -mfpu=neon 59 60 TARGET_arm_release_CFLAGS := -O2 \ 61 -g \ 62 -DNDEBUG \ 63 -fomit-frame-pointer \ 64 -fstrict-aliasing \ 65 -funswitch-loops \ 66 -finline-limit=300 67 68 TARGET_thumb_release_CFLAGS := -mthumb \ 69 -Os \ 70 -g \ 71 -DNDEBUG \ 72 -fomit-frame-pointer \ 73 -fno-strict-aliasing \ 74 -finline-limit=64 75 76 # When building for debug, compile everything as arm. 77 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \ 78 -O0 \ 79 -UNDEBUG \ 80 -fno-omit-frame-pointer \ 81 -fno-strict-aliasing 82 83 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \ 84 -O0 \ 85 -UNDEBUG \ 86 -marm \ 87 -fno-omit-frame-pointer 88 89 # This function will be called to determine the target CFLAGS used to build 90 # a C or Assembler source file, based on its tags. 91 # 92 TARGET-process-src-files-tags = \ 93 $(eval __arm_sources := $(call get-src-files-with-tag,arm)) \ 94 $(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \ 95 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \ 96 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \ 97 $(call set-src-files-target-cflags, \ 98 $(call set_intersection,$(__arm_sources),$(__debug_sources)), \ 99 $(TARGET_arm_debug_CFLAGS)) \ 100 $(call set-src-files-target-cflags,\ 101 $(call set_intersection,$(__arm_sources),$(__release_sources)),\ 102 $(TARGET_arm_release_CFLAGS)) \ 103 $(call set-src-files-target-cflags,\ 104 $(call set_intersection,$(__arm_sources),$(__debug_sources)),\ 105 $(TARGET_arm_debug_CFLAGS)) \ 106 $(call set-src-files-target-cflags,\ 107 $(call set_intersection,$(__thumb_sources),$(__release_sources)),\ 108 $(TARGET_thumb_release_CFLAGS)) \ 109 $(call set-src-files-target-cflags,\ 110 $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\ 111 $(TARGET_thumb_debug_CFLAGS)) \ 112 $(call add-src-files-target-cflags,\ 113 $(call get-src-files-with-tag,neon),\ 114 $(TARGET_CFLAGS.neon)) \ 115 $(call set-src-files-text,$(__arm_sources),arm) \ 116 $(call set-src-files-text,$(__thumb_sources),thumb) 117