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 # 30 NDK_APP_NAME := $(_app) 31 NDK_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) 39 ndk-app-$(_app): $(NDK_APP_MODULES) 40 all: ndk-app-$(_app) 41 42 # which platform/abi/toolchain are we going to use? 43 TARGET_PLATFORM := $(call get,$(_map),APP_PLATFORM) 44 45 # The ABI(s) to use 46 NDK_APP_ABI := $(strip $(NDK_APP_ABI)) 47 ifndef NDK_APP_ABI 48 # the default ABI for now is armeabi 49 NDK_APP_ABI := armeabi 50 endif 51 52 NDK_ABI_FILTER := $(strip $(NDK_ABI_FILTER)) 53 ifdef NDK_ABI_FILTER 54 $(eval $(NDK_ABI_FILTER)) 55 endif 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 # 60 ifeq ($(NDK_APP_ABI),all) 61 NDK_APP_ABI := $(NDK_KNOWN_ABIS) 62 else 63 # Plug in the unknown 64 _unknown_abis := $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI))) 65 ifneq ($(_unknown_abis),) 66 ifeq (1,$(words $(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)))) 67 ifneq ($(filter %all,$(_unknown_abis)),) 68 _unknown_abis_prefix := $(_unknown_abis:%all=%) 69 NDK_APP_ABI := $(NDK_KNOWN_ABIS:%=$(_unknown_abis_prefix)%) 70 else 71 $(foreach _abi,$(NDK_KNOWN_ABIS),\ 72 $(eval _unknown_abis := $(subst $(_abi),,$(_unknown_abis)))\ 73 ) 74 _unknown_abis_prefix := $(sort $(_unknown_abis)) 75 endif 76 ifeq (1,$(words $(_unknown_abis_prefix))) 77 NDK_APP_ABI := $(subst $(_unknown_abis_prefix),$(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)),$(NDK_APP_ABI)) 78 endif 79 endif 80 endif 81 # check the target ABIs for this application 82 _bad_abis = $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI))) 83 ifneq ($(_bad_abis),) 84 $(call __ndk_info,NDK Application '$(_app)' targets unknown ABI(s): $(_bad_abis)) 85 $(call __ndk_info,Please fix the APP_ABI definition in $(NDK_APP_APPLICATION_MK)) 86 $(call __ndk_error,Aborting) 87 endif 88 endif 89 90 # Clear all installed binaries for this application 91 # This ensures that if the build fails, you're not going to mistakenly 92 # package an obsolete version of it. Or if you change the ABIs you're targetting, 93 # you're not going to leave a stale shared library for the old one. 94 # 95 ifeq ($(NDK_APP.$(_app).cleaned_binaries),) 96 NDK_APP.$(_app).cleaned_binaries := true 97 clean-installed-binaries:: 98 $(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/lib*$(TARGET_SONAME_EXTENSION))) 99 $(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/gdbserver)) 100 $(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/gdb.setup)) 101 endif 102 103 $(foreach _abi,$(NDK_APP_ABI),\ 104 $(eval TARGET_ARCH_ABI := $(_abi))\ 105 $(eval include $(BUILD_SYSTEM)/setup-abi.mk) \ 106 ) 107