1 # Copyright (C) 2009 The Android Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
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
19 # its purpose is to define (or re-define) templates used to build
20 # various sources into target object files, libraries or executables.
22 # Note that this file may end up being parsed several times in future
23 # revisions of the NDK.
31 -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
32 -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
36 TARGET_C_INCLUDES := \
37 $(SYSROOT)/usr/include
39 # This is to avoid the dreaded warning compiler message:
40 # note: the mangling of 'va_list' has changed in GCC 4.4
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.
47 TARGET_CFLAGS += -Wno-psabi
49 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
50 TARGET_CFLAGS += -march=armv7-a \
54 TARGET_LDFLAGS += -Wl,--fix-cortex-a8
56 TARGET_CFLAGS += -march=armv5te \
61 TARGET_CFLAGS.neon := -mfpu=neon
63 TARGET_arm_release_CFLAGS := -O2 \
64 -fomit-frame-pointer \
69 TARGET_thumb_release_CFLAGS := -mthumb \
71 -fomit-frame-pointer \
72 -fno-strict-aliasing \
75 # When building for debug, compile everything as arm.
76 TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
77 -fno-omit-frame-pointer \
80 TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
82 -fno-omit-frame-pointer
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.
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)
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).
117 # Normally, the toolchain should be configured to do that automatically,
118 # this will be debugged later.
120 define cmd-build-shared-library
122 -Wl,-soname,$(notdir $@) \
124 --sysroot=$(call host-path,$(SYSROOT)) \
125 $(call host-path, $(PRIVATE_OBJECTS)) \
126 $(call link-whole-archives,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
128 $(PRIVATE_STATIC_LIBRARIES) \
129 $(PRIVATE_SHARED_LIBRARIES)) \
133 -o $(call host-path,$@)
136 define cmd-build-executable
140 --sysroot=$(call host-path,$(SYSROOT)) \
141 $(call host-path, $(PRIVATE_OBJECTS)) \
142 $(call link-whole-archives,$(PRIVATE_WHOLE_STATIC_LIBRARIES)) \
144 $(PRIVATE_STATIC_LIBRARIES) \
145 $(PRIVATE_SHARED_LIBRARIES)) \
149 -o $(call host-path,$@)