• 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 included repeatedly from build/core/main.mk
17# and is used to prepare for app-specific build rules.
18#
19
20$(call assert-defined,_app)
21
22_map := NDK_APP.$(_app)
23
24# ok, let's parse all Android.mk source files in order to build
25# the modules for this app.
26#
27
28# Restore the APP_XXX variables just for this pass as NDK_APP_XXX
29#
30NDK_APP_NAME           := $(_app)
31NDK_APP_APPLICATION_MK := $(call get,$(_map),Application.mk)
32
33$(foreach __name,$(NDK_APP_VARS),\
34  $(eval NDK_$(__name) := $(call get,$(_map),$(__name)))\
35)
36
37# make the application depend on the modules it requires
38.PHONY: ndk-app-$(_app)
39ndk-app-$(_app): $(NDK_APP_MODULES)
40all: ndk-app-$(_app)
41
42# which platform/abi/toolchain are we going to use?
43TARGET_PLATFORM := $(call get,$(_map),APP_PLATFORM)
44
45# The ABI(s) to use
46NDK_APP_ABI := $(subst $(comma),$(space),$(strip $(NDK_APP_ABI)))
47ifndef NDK_APP_ABI
48    # the default ABI for now is armeabi
49    NDK_APP_ABI := armeabi
50endif
51
52NDK_ABI_FILTER := $(strip $(NDK_ABI_FILTER))
53ifdef NDK_ABI_FILTER
54    $(eval $(NDK_ABI_FILTER))
55endif
56
57# If APP_ABI is 'all', then set it to all supported ABIs
58# Otherwise, check that we don't have an invalid value here.
59#
60ifeq ($(NDK_APP_ABI),all)
61    NDK_APP_ABI := $(NDK_APP_ABI_ALL_EXPANDED)
62else
63ifeq ($(NDK_APP_ABI),all32)
64    NDK_APP_ABI := $(NDK_APP_ABI_ALL32_EXPANDED)
65else
66ifeq ($(NDK_APP_ABI),all64)
67    NDK_APP_ABI := $(NDK_APP_ABI_ALL64_EXPANDED)
68else
69    # Plug in the unknown
70    _unknown_abis := $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI)))
71    ifneq ($(_unknown_abis),)
72        ifeq (1,$(words $(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS))))
73            ifneq ($(filter %bcall,$(_unknown_abis)),)
74                 _unknown_abis_prefix := $(_unknown_abis:%bcall=%)
75                 NDK_APP_ABI := $(NDK_KNOWN_ABI32S:%=$(_unknown_abis_prefix)bc%)
76            else
77                ifneq ($(filter %all,$(_unknown_abis)),)
78                    _unknown_abis_prefix := $(_unknown_abis:%all=%)
79                    NDK_APP_ABI := $(NDK_KNOWN_ABIS:%=$(_unknown_abis_prefix)%)
80                else
81                    $(foreach _abi,$(NDK_KNOWN_ABIS),\
82                        $(eval _unknown_abis := $(subst $(_abi),,$(subst bc$(_abi),,$(_unknown_abis)))) \
83                    )
84                    _unknown_abis_prefix := $(sort $(_unknown_abis))
85                endif
86            endif
87            ifeq (1,$(words $(_unknown_abis_prefix)))
88                NDK_APP_ABI := $(subst $(_unknown_abis_prefix),$(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)),$(NDK_APP_ABI))
89            endif
90        endif
91    endif
92    # check the target ABIs for this application
93    _bad_abis = $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI)))
94    ifneq ($(_bad_abis),)
95        $(call __ndk_info,NDK Application '$(_app)' targets unknown ABI(s): $(_bad_abis))
96        $(call __ndk_info,Please fix the APP_ABI definition in $(NDK_APP_APPLICATION_MK))
97        $(call __ndk_error,Aborting)
98    endif
99endif
100endif
101endif
102
103# Clear all installed binaries for this application
104# This ensures that if the build fails, you're not going to mistakenly
105# package an obsolete version of it. Or if you change the ABIs you're targetting,
106# you're not going to leave a stale shared library for the old one.
107#
108ifeq ($(NDK_APP.$(_app).cleaned_binaries),)
109    NDK_APP.$(_app).cleaned_binaries := true
110    clean-installed-binaries::
111	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/lib*$(TARGET_SONAME_EXTENSION)))
112	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/gdbserver))
113	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/gdb.setup))
114endif
115
116# Renderscript
117
118RENDERSCRIPT_TOOLCHAIN_ROOT   := $(NDK_ROOT)/toolchains/renderscript
119RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(RENDERSCRIPT_TOOLCHAIN_ROOT))
120RENDERSCRIPT_TOOLCHAIN_PREFIX := $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT)/bin/
121RENDERSCRIPT_TOOLCHAIN_HEADER := $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT)/lib/clang/3.3/include
122
123# Each ABI
124$(foreach _abi,$(NDK_APP_ABI),\
125    $(eval TARGET_ARCH_ABI := $(_abi))\
126    $(eval include $(BUILD_SYSTEM)/setup-abi.mk) \
127)
128