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