setup-app.mk 4.43 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

16
# this file is included repeatedly from build/core/main.mk
17 18 19 20 21
# and is used to prepare for app-specific build rules.
#

$(call assert-defined,_app)

22 23
_map := NDK_APP.$(_app)

24 25 26 27 28 29 30
# ok, let's parse all Android.mk source files in order to build
# the modules for this app.
#

# Restore the APP_XXX variables just for this pass as NDK_APP_XXX
#
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 38 39 40 41
)

# make the application depend on the modules it requires
.PHONY: ndk-app-$(_app)
ndk-app-$(_app): $(NDK_APP_MODULES)
all: ndk-app-$(_app)

42 43 44
# which platform/abi/toolchain are we going to use?
TARGET_PLATFORM := $(call get,$(_map),APP_PLATFORM)

45
# The ABI(s) to use
46
NDK_APP_ABI := $(subst $(comma),$(space),$(strip $(NDK_APP_ABI)))
47
ifndef NDK_APP_ABI
48
    # the default ABI for now is armeabi
49
    NDK_APP_ABI := armeabi
50 51
endif

52 53 54 55 56
NDK_ABI_FILTER := $(strip $(NDK_ABI_FILTER))
ifdef NDK_ABI_FILTER
    $(eval $(NDK_ABI_FILTER))
endif

57 58 59 60
# If APP_ABI is 'all', then set it to all supported ABIs
# Otherwise, check that we don't have an invalid value here.
#
ifeq ($(NDK_APP_ABI),all)
Andrew Hsieh's avatar
Andrew Hsieh committed
61
    NDK_APP_ABI := $(NDK_KNOWN_ABIS)
62
else
Andrew Hsieh's avatar
Andrew Hsieh committed
63 64 65 66
    # Plug in the unknown
    _unknown_abis := $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI)))
    ifneq ($(_unknown_abis),)
        ifeq (1,$(words $(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS))))
Lai Wei-Chih's avatar
Lai Wei-Chih committed
67 68 69
            ifneq ($(filter %bcall,$(_unknown_abis)),)
                 _unknown_abis_prefix := $(_unknown_abis:%bcall=%)
                 NDK_APP_ABI := $(NDK_KNOWN_ABIS:%=$(_unknown_abis_prefix)bc%)
70
            else
Lai Wei-Chih's avatar
Lai Wei-Chih committed
71 72 73 74 75 76 77 78 79
                ifneq ($(filter %all,$(_unknown_abis)),)
                    _unknown_abis_prefix := $(_unknown_abis:%all=%)
                    NDK_APP_ABI := $(NDK_KNOWN_ABIS:%=$(_unknown_abis_prefix)%)
                else
                    $(foreach _abi,$(NDK_KNOWN_ABIS),\
                        $(eval _unknown_abis := $(subst $(_abi),,$(subst bc$(_abi),,$(_unknown_abis)))) \
                    )
                    _unknown_abis_prefix := $(sort $(_unknown_abis))
                endif
80
            endif
Andrew Hsieh's avatar
Andrew Hsieh committed
81 82 83 84 85
            ifeq (1,$(words $(_unknown_abis_prefix)))
                NDK_APP_ABI := $(subst $(_unknown_abis_prefix),$(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)),$(NDK_APP_ABI))
            endif
        endif
    endif
86 87 88 89 90 91 92
    # check the target ABIs for this application
    _bad_abis = $(strip $(filter-out $(NDK_ALL_ABIS),$(NDK_APP_ABI)))
    ifneq ($(_bad_abis),)
        $(call __ndk_info,NDK Application '$(_app)' targets unknown ABI(s): $(_bad_abis))
        $(call __ndk_info,Please fix the APP_ABI definition in $(NDK_APP_APPLICATION_MK))
        $(call __ndk_error,Aborting)
    endif
93 94
endif

95 96 97 98 99
# Clear all installed binaries for this application
# This ensures that if the build fails, you're not going to mistakenly
# package an obsolete version of it. Or if you change the ABIs you're targetting,
# you're not going to leave a stale shared library for the old one.
#
David Turner's avatar
David Turner committed
100 101
ifeq ($(NDK_APP.$(_app).cleaned_binaries),)
    NDK_APP.$(_app).cleaned_binaries := true
102
    clean-installed-binaries::
103 104 105
	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/lib*$(TARGET_SONAME_EXTENSION)))
	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/gdbserver))
	$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_LIBS_OUT)/%/gdb.setup))
106 107
endif

Andrew Hsieh's avatar
Andrew Hsieh committed
108 109 110 111 112 113 114 115
# Renderscript

RENDERSCRIPT_TOOLCHAIN_ROOT   := $(NDK_ROOT)/toolchains/renderscript
RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(RENDERSCRIPT_TOOLCHAIN_ROOT))
RENDERSCRIPT_TOOLCHAIN_PREFIX := $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT)/bin/
RENDERSCRIPT_TOOLCHAIN_HEADER := $(RENDERSCRIPT_TOOLCHAIN_PREBUILT_ROOT)/lib/clang/3.3/include

# Each ABI
116
$(foreach _abi,$(NDK_APP_ABI),\
117 118 119
    $(eval TARGET_ARCH_ABI := $(_abi))\
    $(eval include $(BUILD_SYSTEM)/setup-abi.mk) \
)