OSDN Git Service

original
[gb-231r1-is01/GB_2.3_IS01.git] / ndk / toolchains / arm-linux-androideabi-4.4.3 / setup.mk
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-eabi-4.4.0
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     -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
32     -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
33
34 TARGET_LDFLAGS :=
35
36 TARGET_C_INCLUDES := \
37     $(SYSROOT)/usr/include
38
39 # This is to avoid the dreaded warning compiler message:
40 #   note: the mangling of 'va_list' has changed in GCC 4.4
41 #
42 # The fact that the mangling changed does not affect the NDK ABI
43 # very fortunately (since none of the exposed APIs used va_list
44 # in their exported C++ functions). Also, GCC 4.5 has already
45 # removed the warning from the compiler.
46 #
47 TARGET_CFLAGS += -Wno-psabi
48
49 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
50     TARGET_CFLAGS += -march=armv7-a \
51                      -mfloat-abi=softfp \
52                      -mfpu=vfp
53
54     TARGET_LDFLAGS += -Wl,--fix-cortex-a8
55 else
56     TARGET_CFLAGS += -march=armv5te \
57                             -mtune=xscale \
58                             -msoft-float
59 endif
60
61 TARGET_CFLAGS.neon := -mfpu=neon
62
63 TARGET_arm_release_CFLAGS :=  -O2 \
64                               -fomit-frame-pointer \
65                               -fstrict-aliasing    \
66                               -funswitch-loops     \
67                               -finline-limit=300
68
69 TARGET_thumb_release_CFLAGS := -mthumb \
70                                -Os \
71                                -fomit-frame-pointer \
72                                -fno-strict-aliasing \
73                                -finline-limit=64
74
75 # When building for debug, compile everything as arm.
76 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
77                            -fno-omit-frame-pointer \
78                            -fno-strict-aliasing
79
80 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
81                              -marm \
82                              -fno-omit-frame-pointer
83
84 # This function will be called to determine the target CFLAGS used to build
85 # a C or Assembler source file, based on its tags.
86 #
87 TARGET-process-src-files-tags = \
88 $(eval __arm_sources := $(call get-src-files-with-tag,arm)) \
89 $(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \
90 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
91 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \
92 $(call set-src-files-target-cflags, \
93     $(call set_intersection,$(__arm_sources),$(__debug_sources)), \
94     $(TARGET_arm_debug_CFLAGS)) \
95 $(call set-src-files-target-cflags,\
96     $(call set_intersection,$(__arm_sources),$(__release_sources)),\
97     $(TARGET_arm_release_CFLAGS)) \
98 $(call set-src-files-target-cflags,\
99     $(call set_intersection,$(__arm_sources),$(__debug_sources)),\
100     $(TARGET_arm_debug_CFLAGS)) \
101 $(call set-src-files-target-cflags,\
102     $(call set_intersection,$(__thumb_sources),$(__release_sources)),\
103     $(TARGET_thumb_release_CFLAGS)) \
104 $(call set-src-files-target-cflags,\
105     $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\
106     $(TARGET_thumb_debug_CFLAGS)) \
107 $(call add-src-files-target-cflags,\
108     $(call get-src-files-with-tag,neon),\
109     $(TARGET_CFLAGS.neon)) \
110 $(call set-src-files-text,$(__arm_sources),arm$(space)$(space)) \
111 $(call set-src-files-text,$(__thumb_sources),thumb)
112
113 #
114 # We need to add -lsupc++ to the final link command to make exceptions
115 # and RTTI work properly (when -fexceptions and -frtti are used).
116 #
117 # Normally, the toolchain should be configured to do that automatically,
118 # this will be debugged later.
119 #
120 define cmd-build-shared-library
121 $(TARGET_CXX) \
122     -Wl,-soname,$(notdir $@) \
123     -shared \
124     --sysroot=$(call host-path,$(SYSROOT)) \
125     $(call host-path, $(PRIVATE_OBJECTS)) \
126     $(call link-whole-archives,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
127     $(call host-path,\
128         $(PRIVATE_STATIC_LIBRARIES) \
129         $(PRIVATE_SHARED_LIBRARIES)) \
130     $(PRIVATE_LDFLAGS) \
131     $(PRIVATE_LDLIBS) \
132     -lsupc++ \
133     -o $(call host-path,$@)
134 endef
135
136 define cmd-build-executable
137 $(TARGET_CXX) \
138     -Wl,--gc-sections \
139     -Wl,-z,nocopyreloc \
140     --sysroot=$(call host-path,$(SYSROOT)) \
141     $(call host-path, $(PRIVATE_OBJECTS)) \
142     $(call link-whole-archives,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
143     $(call host-path,\
144         $(PRIVATE_STATIC_LIBRARIES) \
145         $(PRIVATE_SHARED_LIBRARIES)) \
146     $(PRIVATE_LDFLAGS) \
147     $(PRIVATE_LDLIBS) \
148     -lsupc++ \
149     -o $(call host-path,$@)
150 endef