NativeCode.mk 4.75 KB
Newer Older
1
# -*- mode: makefile -*-
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# Copyright (C) 2007 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.

#
# Definitions for building the native code needed for the core library.
#

#
# Common definitions for host and target.
#

# These two definitions are used to help sanity check what's put in
# sub.mk. See, the "error" directives immediately below.
core_magic_local_target := ...//::default:://...
core_local_path := $(LOCAL_PATH)

# Include a submakefile, resolve its source file locations,
# and stick them on core_src_files.  The submakefiles are
# free to append to LOCAL_SRC_FILES, LOCAL_C_INCLUDES,
# LOCAL_SHARED_LIBRARIES, or LOCAL_STATIC_LIBRARIES, but nothing
# else. All other LOCAL_* variables will be ignored.
#
# $(1): directory containing the makefile to include
define include-core-native-dir
    LOCAL_SRC_FILES :=
    include $(LOCAL_PATH)/$(1)/sub.mk
    ifneq ($$(LOCAL_MODULE),$(core_magic_local_target))
        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \
            or define LOCAL_MODULE)
    endif
    ifneq ($$(LOCAL_PATH),$(core_local_path))
        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
    endif
    core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
    LOCAL_SRC_FILES :=
endef

# Set up the default state. Note: We use CLEAR_VARS here, even though
# we aren't quite defining a new rule yet, to make sure that the
# sub.mk files don't see anything stray from the last rule that was
# set up.
54

55 56
include $(CLEAR_VARS)
LOCAL_MODULE := $(core_magic_local_target)
57
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
58 59 60 61
core_src_files :=

# Include the sub.mk files.
$(foreach dir, \
62
    dalvik/src/main/native luni/src/main/native, \
63 64
    $(eval $(call include-core-native-dir,$(dir))))

65 66 67 68
# Extract out the allowed LOCAL_* variables.
core_c_includes := libcore/include $(LOCAL_C_INCLUDES)
core_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
core_static_libraries := $(LOCAL_STATIC_LIBRARIES)
69
core_cflags := -Wall -Wextra -Werror
Elliott Hughes's avatar
Elliott Hughes committed
70
core_cppflags += -std=gnu++11
71

72 73 74
core_test_files := \
  luni/src/test/native/test_openssl_engine.cpp \

75 76 77 78 79
#
# Build for the target (device).
#

include $(CLEAR_VARS)
80
LOCAL_CFLAGS += $(core_cflags)
81
LOCAL_CPPFLAGS += $(core_cppflags)
82 83
LOCAL_SRC_FILES += $(core_src_files)
LOCAL_C_INCLUDES += $(core_c_includes)
84
LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libexpat libicuuc libicui18n libnativehelper libz
85
LOCAL_STATIC_LIBRARIES += $(core_static_libraries)
Jesse Wilson's avatar
Jesse Wilson committed
86
LOCAL_MODULE_TAGS := optional
87
LOCAL_MODULE := libjavacore
88
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
89
include external/stlport/libstlport.mk
90
include $(BUILD_SHARED_LIBRARY)
91

92
# Test JNI library.
93 94
ifeq ($(LIBCORE_SKIP_TESTS),)

95
include $(CLEAR_VARS)
96 97
LOCAL_CFLAGS += $(core_cflags)
LOCAL_CPPFLAGS += $(core_cppflags)
98 99 100
LOCAL_SRC_FILES += $(core_test_files)
LOCAL_C_INCLUDES += libcore/include external/openssl/include
LOCAL_SHARED_LIBRARIES += libcrypto
101
LOCAL_MODULE_TAGS := optional
Kenny Root's avatar
Kenny Root committed
102
LOCAL_MODULE := libjavacoretests
103
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
104
include external/stlport/libstlport.mk
105
include $(BUILD_SHARED_LIBRARY)
106

107 108 109
endif # LIBCORE_SKIP_TESTS


110 111 112 113 114 115
#
# Build for the host.
#

ifeq ($(WITH_HOST_DALVIK),true)
    include $(CLEAR_VARS)
116
    LOCAL_SRC_FILES += $(core_src_files)
117
    LOCAL_CFLAGS += $(core_cflags)
118
    LOCAL_C_INCLUDES += $(core_c_includes)
119
    LOCAL_CPPFLAGS += $(core_cppflags)
120
    LOCAL_LDLIBS += -ldl -lpthread -lrt
Jesse Wilson's avatar
Jesse Wilson committed
121
    LOCAL_MODULE_TAGS := optional
122
    LOCAL_MODULE := libjavacore
123
    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
124 125 126 127
    LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat-host libicuuc-host libicui18n-host libcrypto-host libz-host
    LOCAL_STATIC_LIBRARIES += $(core_static_libraries)
    include $(BUILD_HOST_SHARED_LIBRARY)

128 129
    ifeq ($(LIBCORE_SKIP_TESTS),)
    include $(CLEAR_VARS)
130
    LOCAL_SRC_FILES += $(core_test_files)
131
    LOCAL_CFLAGS += $(core_cflags)
132
    LOCAL_C_INCLUDES += libcore/include external/openssl/include
133 134 135
    LOCAL_CPPFLAGS += $(core_cppflags)
    LOCAL_LDLIBS += -ldl -lpthread
    LOCAL_MODULE_TAGS := optional
Kenny Root's avatar
Kenny Root committed
136
    LOCAL_MODULE := libjavacoretests
137
    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
138
    LOCAL_SHARED_LIBRARIES := libcrypto-host
139 140
    include $(BUILD_HOST_SHARED_LIBRARY)
    endif # LIBCORE_SKIP_TESTS
141
endif