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 included repeatedly from build/core/main.mk
17 # and is used to prepare for app-specific build rules.
20 $(call assert-defined
,_app
)
22 _map
:= NDK_APP.
$(_app
)
24 # ok, let's parse all Android.mk source files in order to build
25 # the modules for this app.
28 # Restore the APP_XXX variables just for this pass as NDK_APP_XXX
30 NDK_APP_NAME
:= $(_app
)
31 NDK_APP_APPLICATION_MK
:= $(call
get,$(_map
),Application.mk
)
33 $(foreach __name
,$(NDK_APP_VARS
),\
34 $(eval NDK_
$(__name
) := $(call
get,$(_map
),$(__name
)))\
37 # make the application depend on the modules it requires
38 .PHONY
: ndk-app-
$(_app
)
39 ndk-app-
$(_app
): $(NDK_APP_MODULES
)
42 # which platform/abi/toolchain are we going to use?
43 TARGET_PLATFORM
:= $(call
get,$(_map
),APP_PLATFORM
)
44 ifeq ($(TARGET_PLATFORM
),android-L
)
45 $(call __ndk_warning
,WARNING
: android-L is renamed
as android-21
)
46 TARGET_PLATFORM
:= android-21
51 NDK_APP_ABI
:= $(subst $(comma
),$(space
),$(strip $(NDK_APP_ABI
)))
53 # the default ABI for now is armeabi
54 NDK_APP_ABI
:= armeabi
57 NDK_ABI_FILTER
:= $(strip $(NDK_ABI_FILTER
))
59 $(eval
$(NDK_ABI_FILTER
))
62 # If APP_ABI is 'all', then set it to all supported ABIs
63 # Otherwise, check that we don't have an invalid value here.
65 ifeq ($(NDK_APP_ABI
),all)
66 NDK_APP_ABI
:= $(NDK_APP_ABI_ALL_EXPANDED
)
67 _abis_without_toolchain
:= $(filter-out $(NDK_ALL_ABIS
),$(NDK_APP_ABI
))
68 ifneq (,$(_abis_without_toolchain
))
69 $(call ndk_log
,Remove the following abis expanded from
'all' due to no toolchain
: $(_abis_without_toolchain
))
70 NDK_APP_ABI
:= $(filter-out $(_abis_without_toolchain
),$(NDK_APP_ABI
))
73 ifeq ($(NDK_APP_ABI
),all32
)
74 NDK_APP_ABI
:= $(NDK_APP_ABI_ALL32_EXPANDED
)
75 _abis_without_toolchain
:= $(filter-out $(NDK_ALL_ABIS
),$(NDK_APP_ABI
))
76 ifneq (,$(_abis_without_toolchain
))
77 $(call ndk_log
,Remove the following abis expanded from
'all32' due to no toolchain
: $(_abis_without_toolchain
))
78 NDK_APP_ABI
:= $(filter-out $(_abis_without_toolchain
),$(NDK_APP_ABI
))
81 ifeq ($(NDK_APP_ABI
),all64
)
82 NDK_APP_ABI
:= $(NDK_APP_ABI_ALL64_EXPANDED
)
83 _abis_without_toolchain
:= $(filter-out $(NDK_ALL_ABIS
),$(NDK_APP_ABI
))
84 ifneq (,$(_abis_without_toolchain
))
85 $(call ndk_log
,Remove the following abis expanded from
'all64' due to no toolchain
: $(_abis_without_toolchain
))
86 NDK_APP_ABI
:= $(filter-out $(_abis_without_toolchain
),$(NDK_APP_ABI
))
90 _unknown_abis
:= $(strip $(filter-out $(NDK_ALL_ABIS
),$(NDK_APP_ABI
)))
91 ifneq ($(_unknown_abis
),)
92 ifeq (1,$(words $(filter-out $(NDK_KNOWN_ARCHS
),$(NDK_FOUND_ARCHS
))))
93 ifneq ($(filter %bcall
,$(_unknown_abis
)),)
94 _unknown_abis_prefix
:= $(_unknown_abis
:%bcall
=%)
95 NDK_APP_ABI
:= $(NDK_KNOWN_ABI32S
:%=$(_unknown_abis_prefix
)bc
%)
97 ifneq ($(filter %all,$(_unknown_abis
)),)
98 _unknown_abis_prefix
:= $(_unknown_abis
:%all=%)
99 NDK_APP_ABI
:= $(NDK_KNOWN_ABIS
:%=$(_unknown_abis_prefix
)%)
101 $(foreach _abi
,$(NDK_KNOWN_ABIS
),\
102 $(eval _unknown_abis
:= $(subst $(_abi
),,$(subst bc
$(_abi
),,$(_unknown_abis
)))) \
104 _unknown_abis_prefix
:= $(sort $(_unknown_abis
))
107 ifeq (1,$(words $(_unknown_abis_prefix
)))
108 NDK_APP_ABI
:= $(subst $(_unknown_abis_prefix
),$(filter-out $(NDK_KNOWN_ARCHS
),$(NDK_FOUND_ARCHS
)),$(NDK_APP_ABI
))
111 TARGET_PLATFORM
:= android-21
113 # check the target ABIs for this application
114 _bad_abis
= $(strip $(filter-out $(NDK_ALL_ABIS
),$(NDK_APP_ABI
)))
115 ifneq ($(_bad_abis
),)
116 $(call __ndk_info
,NDK Application
'$(_app)' targets unknown ABI
(s
): $(_bad_abis
))
117 $(call __ndk_info
,Please fix the APP_ABI definition in
$(NDK_APP_APPLICATION_MK
))
118 $(call __ndk_error
,Aborting
)
124 # Clear all installed binaries for this application
125 # This ensures that if the build fails, you're not going to mistakenly
126 # package an obsolete version of it. Or if you change the ABIs you're targetting,
127 # you're not going to leave a stale shared library for the old one.
129 ifeq ($(NDK_APP.
$(_app
).cleaned_binaries
),)
130 NDK_APP.
$(_app
).cleaned_binaries
:= true
131 clean-installed-binaries
::
132 $(hide
) $(call host-rm
,$(NDK_ALL_ABIS
:%=$(NDK_APP_LIBS_OUT
)/%/lib
*$(TARGET_SONAME_EXTENSION
)))
133 $(hide
) $(call host-rm
,$(NDK_ALL_ABIS
:%=$(NDK_APP_LIBS_OUT
)/%/gdbserver
))
134 $(hide
) $(call host-rm
,$(NDK_ALL_ABIS
:%=$(NDK_APP_LIBS_OUT
)/%/gdb.setup
))
139 RENDERSCRIPT_TOOLCHAIN_ROOT
:= $(NDK_ROOT
)/toolchains
/renderscript
140 RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT
:= $(call host-prebuilt-tag
,$(RENDERSCRIPT_TOOLCHAIN_ROOT
))
141 RENDERSCRIPT_TOOLCHAIN_PREFIX
:= $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT
)/bin
/
142 RENDERSCRIPT_TOOLCHAIN_HEADER
:= $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT
)/lib
/clang
/3.5/include
145 $(foreach _abi
,$(NDK_APP_ABI
),\
146 $(eval TARGET_ARCH_ABI
:= $(_abi
))\
147 $(eval
include $(BUILD_SYSTEM
)/setup-abi.mk
) \