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