1 # Copyright (C) 2009-2010 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 # 17 # This script is used to build all wanted NDK binaries. It is included 18 # by several scripts. 19 # 20 21 # ensure that the following variables are properly defined 22 $(call assert-defined,NDK_APPS NDK_APP_OUT) 23 24 # ==================================================================== 25 # 26 # Prepare the build for parsing Android.mk files 27 # 28 # ==================================================================== 29 30 # These phony targets are used to control various stages of the build 31 .PHONY: all \ 32 host_libraries host_executables \ 33 installed_modules \ 34 executables libraries static_libraries shared_libraries \ 35 clean clean-objs-dir \ 36 clean-executables clean-libraries \ 37 clean-installed-modules \ 38 clean-installed-binaries 39 40 # These macros are used in Android.mk to include the corresponding 41 # build script that will parse the LOCAL_XXX variable definitions. 42 # 43 CLEAR_VARS := $(BUILD_SYSTEM)/clear-vars.mk 44 BUILD_HOST_EXECUTABLE := $(BUILD_SYSTEM)/build-host-executable.mk 45 BUILD_HOST_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-host-static-library.mk 46 BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/build-static-library.mk 47 BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/build-shared-library.mk 48 BUILD_EXECUTABLE := $(BUILD_SYSTEM)/build-executable.mk 49 PREBUILT_SHARED_LIBRARY := $(BUILD_SYSTEM)/prebuilt-shared-library.mk 50 PREBUILT_STATIC_LIBRARY := $(BUILD_SYSTEM)/prebuilt-static-library.mk 51 52 ANDROID_MK_INCLUDED := \ 53 $(CLEAR_VARS) \ 54 $(BUILD_HOST_EXECUTABLE) \ 55 $(BUILD_HOST_STATIC_LIBRARY) \ 56 $(BUILD_STATIC_LIBRARY) \ 57 $(BUILD_SHARED_LIBRARY) \ 58 $(BUILD_EXECUTABLE) \ 59 $(PREBUILT_SHARED_LIBRARY) \ 60 61 62 # this is the list of directories containing dependency information 63 # generated during the build. It will be updated by build scripts 64 # when module definitions are parsed. 65 # 66 ALL_DEPENDENCY_DIRS := 67 68 # this is the list of all generated files that we would need to clean 69 ALL_HOST_EXECUTABLES := 70 ALL_HOST_STATIC_LIBRARIES := 71 ALL_STATIC_LIBRARIES := 72 ALL_SHARED_LIBRARIES := 73 ALL_EXECUTABLES := 74 75 WANTED_INSTALLED_MODULES := 76 77 # the first rule 78 all: installed_modules host_libraries host_executables 79 80 81 $(foreach _app,$(NDK_APPS),\ 82 $(eval include $(BUILD_SYSTEM)/setup-app.mk)\ 83 ) 84 85 # On Cygwin, we generate a temporary shell script that is capable of 86 # process GCC-generated dependency files to convert all path references 87 # in them from the Windows to the corresponding Cygwin convention. 88 # (e.g. C:/Foo/foo -> /cygdrive/c/Foo/foo) 89 # 90 # This shell script is generated by passing the output of the cygwin 91 # 'mount' command to a special Awk script. 92 # 93 ifeq ($(HOST_OS),cygwin) 94 GEN_CYGWIN_DEPS_CONVERTER := mount | tr '\\' '/' | awk -f $(BUILD_AWK)/gen-cygwin-deps-converter.awk 95 ifeq ($(NDK_LOG),1) 96 $(call __ndk_info,Cygwin dependency file conversion script:) 97 $(info ----- start of script ----) 98 $(info $(shell $(GEN_CYGWIN_DEPS_CONVERTER))) 99 $(info ------ end of script -----) 100 endif 101 $(NDK_DEPENDENCIES_CONVERTER): 102 @$(HOST_ECHO) "Cygwin : Generating dependency file converter script" 103 $(hide) mkdir -p $(dir $@) 104 $(hide) $(GEN_CYGWIN_DEPS_CONVERTER) > $@ && chmod +x $@ 105 106 clean-dependency-converter: 107 $(hide) $(call host-rm,$(NDK_DEPENDENCIES_CONVERTER)) 108 109 endif 110 111 # ==================================================================== 112 # 113 # Now finish the build preparation with a few rules that depend on 114 # what has been effectively parsed and recorded previously 115 # 116 # ==================================================================== 117 118 clean: clean-intermediates clean-installed-binaries 119 120 distclean: clean 121 122 installed_modules: clean-installed-binaries libraries $(WANTED_INSTALLED_MODULES) 123 host_libraries: $(HOST_STATIC_LIBRARIES) 124 host_executables: $(HOST_EXECUTABLES) 125 126 static_libraries: $(STATIC_LIBRARIES) 127 shared_libraries: $(SHARED_LIBRARIES) 128 executables: $(EXECUTABLES) 129 130 libraries: static_libraries shared_libraries 131 132 clean-host-intermediates: 133 $(hide) $(call host-rm,$(HOST_EXECUTABLES) $(HOST_STATIC_LIBRARIES)) 134 135 clean-intermediates: clean-host-intermediates 136 $(hide) $(call host-rm,$(EXECUTABLES) $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)) 137 138 ifeq ($(HOST_OS),cygwin) 139 clean: clean-dependency-converter 140 endif 141 142 # include dependency information 143 ALL_DEPENDENCY_DIRS := $(patsubst %/,%,$(sort $(ALL_DEPENDENCY_DIRS))) 144 -include $(wildcard $(ALL_DEPENDENCY_DIRS:%=%/*.d)) 145