blob: 0dfad3b64c046b00609dc77bb201f74d6338449e [file] [log] [blame]
Dan Bornstein6ac43c22009-10-24 15:33:49 -07001# 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 $(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
88# Define the rules.
89LOCAL_SRC_FILES := $(core_src_files)
90LOCAL_C_INCLUDES := $(core_c_includes)
91LOCAL_SHARED_LIBRARIES := $(core_shared_libraries)
92LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
93LOCAL_MODULE := libjavacore
94include $(BUILD_STATIC_LIBRARY)
95
96# Deal with keystores required for security. Note: The path to this file
97# is hardcoded in TrustManagerFactoryImpl.java.
98ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks
99$(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/security/src/main/files/cacerts.bks | $(ACP)
100 $(transform-prebuilt-to-target)
101
102
103#
104# Build for the host.
105#
106
107ifeq ($(WITH_HOST_DALVIK),true)
108
109 include $(CLEAR_VARS)
110
111 # Define the rules.
112 LOCAL_SRC_FILES := $(core_src_files)
113 LOCAL_C_INCLUDES := $(core_c_includes)
114 LOCAL_SHARED_LIBRARIES := $(core_shared_libraries)
115 LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
116 LOCAL_MODULE := libjavacore-host
117 include $(BUILD_HOST_STATIC_LIBRARY)
118
119 # TODO: Figure out cacerts.bks for the host.
120
121endif