NativeCode.mk revision bb2532130c1c52755916d8608b7057496c6b395a
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. 26define all-core-native-dirs 27$(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null)) 28endef 29 30# These two definitions are used to help sanity check what's put in 31# sub.mk. See, the "error" directives immediately below. 32core_magic_local_target := ...//::default:://... 33core_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 42define 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 := 54endef 55 56# Find any native directories containing sub.mk files. 57core_native_dirs := $(strip $(call all-core-native-dirs,main)) 58ifeq ($(core_native_dirs),) 59 $(error No native code defined for libcore) 60endif 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. 66include $(CLEAR_VARS) 67LOCAL_MODULE := $(core_magic_local_target) 68core_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. 77core_c_includes := $(sort libcore/include $(LOCAL_C_INCLUDES) $(JNI_H_INCLUDE)) 78core_shared_libraries := $(sort $(LOCAL_SHARED_LIBRARIES)) 79core_static_libraries := $(sort $(LOCAL_STATIC_LIBRARIES)) 80 81 82# 83# Build for the target (device). 84# 85 86include $(CLEAR_VARS) 87 88LOCAL_CFLAGS += -Wall -Wextra -Werror 89 90ifeq ($(TARGET_ARCH),arm) 91# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4" 92LOCAL_CFLAGS += -Wno-psabi 93endif 94 95# Define the rules. 96LOCAL_SRC_FILES := $(core_src_files) 97LOCAL_C_INCLUDES := $(core_c_includes) 98 99ifneq ($(TARGET_SIMULATOR),true) 100LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include 101endif 102 103LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) 104LOCAL_STATIC_LIBRARIES := $(core_static_libraries) 105LOCAL_MODULE_TAGS := optional 106LOCAL_MODULE := libjavacore 107include $(BUILD_STATIC_LIBRARY) 108 109# Deal with keystores required for security. Note: The path to this file 110# is hardcoded in TrustManagerFactoryImpl.java. 111ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks 112$(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/luni/src/main/files/cacerts.bks | $(ACP) 113 $(transform-prebuilt-to-target) 114 115 116# 117# Build for the host. 118# 119 120ifeq ($(WITH_HOST_DALVIK),true) 121 122 include $(CLEAR_VARS) 123 124 # Define the rules. 125 LOCAL_SRC_FILES := $(core_src_files) 126 LOCAL_C_INCLUDES := $(core_c_includes) 127 LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) 128 LOCAL_STATIC_LIBRARIES := $(core_static_libraries) 129 LOCAL_MODULE_TAGS := optional 130 LOCAL_MODULE := libjavacore-host 131 LOCAL_ADDITIONAL_DEPENDENCIES += $(HOST_OUT)/etc/security/cacerts.bks 132 include $(BUILD_HOST_STATIC_LIBRARY) 133 134 $(eval $(call copy-one-file,$(LOCAL_PATH)/luni/src/main/files/cacerts.bks,$(HOST_OUT)/etc/security/cacerts.bks)) 135 136endif 137