1 # Copyright (C) 2007 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 # Definitions for building the native code needed for the core library. 17 # 18 19 # 20 # Common definitions for host and target. 21 # 22 23 # Get the list of all native directories that contain sub.mk files. 24 # We're using "sub.mk" to make it clear that these are not typical 25 # android makefiles. 26 define all-core-native-dirs 27 $(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null)) 28 endef 29 30 # These two definitions are used to help sanity check what's put in 31 # sub.mk. See, the "error" directives immediately below. 32 core_magic_local_target := ...//::default:://... 33 core_local_path := $(LOCAL_PATH) 34 35 # Include a submakefile, resolve its source file locations, 36 # and stick them on core_src_files. The submakefiles are 37 # free to append to LOCAL_SRC_FILES, LOCAL_C_INCLUDES, 38 # LOCAL_SHARED_LIBRARIES, or LOCAL_STATIC_LIBRARIES, but nothing 39 # else. All other LOCAL_* variables will be ignored. 40 # 41 # $(1): directory containing the makefile to include 42 define include-core-native-dir 43 LOCAL_SRC_FILES := 44 include $(LOCAL_PATH)/$(1)/sub.mk 45 ifneq ($$(LOCAL_MODULE),$(core_magic_local_target)) 46 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \ 47 or define LOCAL_MODULE) 48 endif 49 ifneq ($$(LOCAL_PATH),$(core_local_path)) 50 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH) 51 endif 52 core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES)) 53 LOCAL_SRC_FILES := 54 endef 55 56 # Find any native directories containing sub.mk files. 57 core_native_dirs := $(strip $(call all-core-native-dirs,main)) 58 ifeq ($(core_native_dirs),) 59 $(error No native code defined for libcore) 60 endif 61 62 # Set up the default state. Note: We use CLEAR_VARS here, even though 63 # we aren't quite defining a new rule yet, to make sure that the 64 # sub.mk files don't see anything stray from the last rule that was 65 # set up. 66 include $(CLEAR_VARS) 67 LOCAL_MODULE := $(core_magic_local_target) 68 core_src_files := 69 70 # Include the sub.mk files. 71 $(foreach dir, \ 72 $(core_native_dirs), \ 73 $(eval $(call include-core-native-dir,$(dir)))) 74 75 # Extract out the allowed LOCAL_* variables. Note: $(sort) also 76 # removes duplicates. 77 core_c_includes := $(sort libcore/include $(LOCAL_C_INCLUDES) $(JNI_H_INCLUDE)) 78 core_shared_libraries := $(sort $(LOCAL_SHARED_LIBRARIES)) 79 core_static_libraries := $(sort $(LOCAL_STATIC_LIBRARIES)) 80 81 82 # 83 # Build for the target (device). 84 # 85 86 include $(CLEAR_VARS) 87 88 LOCAL_CFLAGS += -Wall -Wextra -Werror 89 90 ifeq ($(TARGET_ARCH),arm) 91 # Ignore "note: the mangling of 'va_list' has changed in GCC 4.4" 92 LOCAL_CFLAGS += -Wno-psabi 93 endif 94 95 # Define the rules. 96 LOCAL_SRC_FILES := $(core_src_files) 97 LOCAL_C_INCLUDES := $(core_c_includes) 98 LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) 99 LOCAL_STATIC_LIBRARIES := $(core_static_libraries) 100 LOCAL_MODULE_TAGS := optional 101 LOCAL_MODULE := libjavacore 102 include $(BUILD_STATIC_LIBRARY) 103 104 # Deal with keystores required for security. Note: The path to this file 105 # is hardcoded in TrustManagerFactoryImpl.java. 106 ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks 107 $(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/luni/src/main/files/cacerts.bks | $(ACP) 108 $(transform-prebuilt-to-target) 109 110 111 # 112 # Build for the host. 113 # 114 115 ifeq ($(WITH_HOST_DALVIK),true) 116 117 include $(CLEAR_VARS) 118 119 # Define the rules. 120 LOCAL_SRC_FILES := $(core_src_files) 121 LOCAL_C_INCLUDES := $(core_c_includes) 122 LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) 123 LOCAL_STATIC_LIBRARIES := $(core_static_libraries) 124 LOCAL_MODULE_TAGS := optional 125 LOCAL_MODULE := libjavacore-host 126 LOCAL_ADDITIONAL_DEPENDENCIES += $(HOST_OUT)/etc/security/cacerts.bks 127 include $(BUILD_HOST_STATIC_LIBRARY) 128 129 $(eval $(call copy-one-file,$(LOCAL_PATH)/luni/src/main/files/cacerts.bks,$(HOST_OUT)/etc/security/cacerts.bks)) 130 131 endif 132