| # Copyright (C) 2009-2010 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. |
| # |
| |
| # |
| # This script is used to build all wanted NDK binaries. It is included |
| # by several scripts. |
| # |
| |
| # ensure that the following variables are properly defined |
| $(call assert-defined,NDK_APPS NDK_APP_OUT) |
| |
| # ==================================================================== |
| # |
| # Prepare the build for parsing Android.mk files |
| # |
| # ==================================================================== |
| |
| # These phony targets are used to control various stages of the build |
| .PHONY: all \ |
| host_libraries host_executables \ |
| installed_modules \ |
| executables libraries static_libraries shared_libraries \ |
| clean clean-objs-dir \ |
| clean-executables clean-libraries \ |
| clean-installed-modules \ |
| clean-installed-binaries |
| |
| # These macros are used in Android.mk to include the corresponding |
| # build script that will parse the LOCAL_XXX variable definitions. |
| # |
| CLEAR_VARS := $(BUILD_SYSTEM)/clear-vars.mk |
| BUILD_HOST_EXECUTABLE := $(BUILD_SYSTEM)/build-host-executable.mk |
| BUILD_HOST_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-host-static-library.mk |
| BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-static-library.mk |
| BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/build-shared-library.mk |
| BUILD_EXECUTABLE := $(BUILD_SYSTEM)/build-executable.mk |
| PREBUILT_SHARED_LIBRARY := $(BUILD_SYSTEM)/prebuilt-shared-library.mk |
| PREBUILT_STATIC_LIBRARY := $(BUILD_SYSTEM)/prebuilt-static-library.mk |
| |
| ANDROID_MK_INCLUDED := \ |
| $(CLEAR_VARS) \ |
| $(BUILD_HOST_EXECUTABLE) \ |
| $(BUILD_HOST_STATIC_LIBRARY) \ |
| $(BUILD_STATIC_LIBRARY) \ |
| $(BUILD_SHARED_LIBRARY) \ |
| $(BUILD_EXECUTABLE) \ |
| $(PREBUILT_SHARED_LIBRARY) \ |
| |
| |
| # this is the list of directories containing dependency information |
| # generated during the build. It will be updated by build scripts |
| # when module definitions are parsed. |
| # |
| ALL_DEPENDENCY_DIRS := |
| |
| # this is the list of all generated files that we would need to clean |
| ALL_HOST_EXECUTABLES := |
| ALL_HOST_STATIC_LIBRARIES := |
| ALL_STATIC_LIBRARIES := |
| ALL_SHARED_LIBRARIES := |
| ALL_EXECUTABLES := |
| |
| WANTED_INSTALLED_MODULES := |
| |
| # the first rule |
| all: installed_modules host_libraries host_executables |
| |
| |
| $(foreach _app,$(NDK_APPS),\ |
| $(eval include $(BUILD_SYSTEM)/setup-app.mk)\ |
| ) |
| |
| # On Cygwin, we generate a temporary shell script that is capable of |
| # process GCC-generated dependency files to convert all path references |
| # in them from the Windows to the corresponding Cygwin convention. |
| # (e.g. C:/Foo/foo -> /cygdrive/c/Foo/foo) |
| # |
| # This shell script is generated by passing the output of the cygwin |
| # 'mount' command to a special Awk script. |
| # |
| ifeq ($(HOST_OS),cygwin) |
| GEN_CYGWIN_DEPS_CONVERTER := mount | tr '\\' '/' | awk -f $(BUILD_AWK)/gen-cygwin-deps-converter.awk |
| ifeq ($(NDK_LOG),1) |
| $(call __ndk_info,Cygwin dependency file conversion script:) |
| $(info ----- start of script ----) |
| $(info $(shell $(GEN_CYGWIN_DEPS_CONVERTER))) |
| $(info ------ end of script -----) |
| endif |
| $(NDK_DEPENDENCIES_CONVERTER): |
| @$(HOST_ECHO) "Cygwin : Generating dependency file converter script" |
| $(hide) mkdir -p $(dir $@) |
| $(hide) $(GEN_CYGWIN_DEPS_CONVERTER) > $@ && chmod +x $@ |
| |
| clean-dependency-converter: |
| $(hide) $(call host-rm,$(NDK_DEPENDENCIES_CONVERTER)) |
| |
| endif |
| |
| # ==================================================================== |
| # |
| # Now finish the build preparation with a few rules that depend on |
| # what has been effectively parsed and recorded previously |
| # |
| # ==================================================================== |
| |
| clean: clean-intermediates clean-installed-binaries |
| |
| distclean: clean |
| |
| installed_modules: clean-installed-binaries libraries $(WANTED_INSTALLED_MODULES) |
| host_libraries: $(HOST_STATIC_LIBRARIES) |
| host_executables: $(HOST_EXECUTABLES) |
| |
| static_libraries: $(STATIC_LIBRARIES) |
| shared_libraries: $(SHARED_LIBRARIES) |
| executables: $(EXECUTABLES) |
| |
| libraries: static_libraries shared_libraries |
| |
| clean-host-intermediates: |
| $(hide) $(call host-rm,$(HOST_EXECUTABLES) $(HOST_STATIC_LIBRARIES)) |
| |
| clean-intermediates: clean-host-intermediates |
| $(hide) $(call host-rm,$(EXECUTABLES) $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)) |
| |
| ifeq ($(HOST_OS),cygwin) |
| clean: clean-dependency-converter |
| endif |
| |
| # include dependency information |
| ALL_DEPENDENCY_DIRS := $(patsubst %/,%,$(sort $(ALL_DEPENDENCY_DIRS))) |
| -include $(wildcard $(ALL_DEPENDENCY_DIRS:%=%/*.d)) |