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 included multiple times by build/core/setup-app.mk
17#
18
19$(call ndk_log,Building application '$(NDK_APP_NAME)' for ABI '$(TARGET_ARCH_ABI)')
20
21TARGET_ARCH := $(strip $(NDK_ABI.$(TARGET_ARCH_ABI).arch))
22ifndef TARGET_ARCH
23    $(call __ndk_info,ERROR: The $(TARGET_ARCH_ABI) ABI has no associated architecture!)
24    $(call __ndk_error,Aborting...)
25endif
26
27TARGET_OUT := $(NDK_APP_OUT)/$(_app)/$(TARGET_ARCH_ABI)
28
29# For x86 and mips: the minimal platform level is android-9
30TARGET_PLATFORM_SAVED := $(TARGET_PLATFORM)
31ifneq ($(filter %x86 %mips,$(TARGET_ARCH_ABI)),)
32$(foreach _plat,3 4 5 8,\
33    $(eval TARGET_PLATFORM := $$(subst android-$(_plat),android-9,$$(TARGET_PLATFORM)))\
34)
35endif
36
37# For 64-bit ABIs: the minimal platform level is android-21
38ifneq ($(filter $(NDK_KNOWN_DEVICE_ABI64S),$(TARGET_ARCH_ABI)),)
39$(foreach _plat,3 4 5 8 9 10 11 12 13 14 15 16 17 18 19 20,\
40    $(eval TARGET_PLATFORM := $$(subst android-$(_plat),android-21,$$(TARGET_PLATFORM)))\
41)
42endif
43
44TARGET_PLATFORM_LEVEL := $(strip $(subst android-,,$(TARGET_PLATFORM)))
45ifneq (,$(call gte,$(TARGET_PLATFORM_LEVEL),$(NDK_FIRST_PIE_PLATFORM_LEVEL)))
46    TARGET_PIE := true
47    $(call ndk_log,  Enabling -fPIE for TARGET_PLATFORM $(TARGET_PLATFORM))
48else
49    TARGET_PIE := false
50endif
51
52# Separate the debug and release objects. This prevents rebuilding
53# everything when you switch between these two modes. For projects
54# with lots of C++ sources, this can be a considerable time saver.
55ifeq ($(NDK_APP_OPTIM),debug)
56TARGET_OBJS := $(TARGET_OUT)/objs-debug
57else
58TARGET_OBJS := $(TARGET_OUT)/objs
59endif
60
61TARGET_GDB_SETUP := $(TARGET_OUT)/setup.gdb
62
63# RS triple
64ifneq ($(filter $(TARGET_ARCH_ABI), armeabi-v7a armeabi-v7a-hard),)
65  RS_TRIPLE := armv7-none-linux-gnueabi
66endif
67ifeq ($(TARGET_ARCH_ABI),armeabi)
68  RS_TRIPLE := arm-none-linux-gnueabi
69endif
70ifeq ($(TARGET_ARCH_ABI),mips)
71  RS_TRIPLE := mipsel-unknown-linux
72endif
73ifeq ($(TARGET_ARCH_ABI),x86)
74  RS_TRIPLE := i686-unknown-linux
75endif
76
77
78include $(BUILD_SYSTEM)/setup-toolchain.mk
79
80# Restore TARGET_PLATFORM, see above.
81TARGET_PLATFORM := $(TARGET_PLATFORM_SAVED)
82