NativeCode.mk revision 771ff9990e146b858ebb6ded9fd8b7a6493d3ddb
1c3d30bfb532fc1e609a67a324d6bfb9776f88778Elliott Hughes# -*- mode: makefile -*- 26ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Copyright (C) 2007 The Android Open Source Project 36ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 46ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Licensed under the Apache License, Version 2.0 (the "License"); 56ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# you may not use this file except in compliance with the License. 66ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# You may obtain a copy of the License at 76ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 86ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# http://www.apache.org/licenses/LICENSE-2.0 96ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 106ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Unless required by applicable law or agreed to in writing, software 116ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# distributed under the License is distributed on an "AS IS" BASIS, 126ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# See the License for the specific language governing permissions and 146ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# limitations under the License. 156ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 166ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 176ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Definitions for building the native code needed for the core library. 186ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 196ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 206ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 216ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Common definitions for host and target. 226ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 236ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 246ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# These two definitions are used to help sanity check what's put in 256ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# sub.mk. See, the "error" directives immediately below. 266ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_magic_local_target := ...//::default:://... 276ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_local_path := $(LOCAL_PATH) 286ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 296ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Include a submakefile, resolve its source file locations, 306ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# and stick them on core_src_files. The submakefiles are 316ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# free to append to LOCAL_SRC_FILES, LOCAL_C_INCLUDES, 326ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# LOCAL_SHARED_LIBRARIES, or LOCAL_STATIC_LIBRARIES, but nothing 336ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# else. All other LOCAL_* variables will be ignored. 346ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 356ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# $(1): directory containing the makefile to include 366ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteindefine include-core-native-dir 376ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein LOCAL_SRC_FILES := 386ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein include $(LOCAL_PATH)/$(1)/sub.mk 396ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein ifneq ($$(LOCAL_MODULE),$(core_magic_local_target)) 406ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \ 416ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein or define LOCAL_MODULE) 426ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein endif 436ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein ifneq ($$(LOCAL_PATH),$(core_local_path)) 446ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH) 456ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein endif 466ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES)) 476ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein LOCAL_SRC_FILES := 486ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteinendef 496ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 506ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Set up the default state. Note: We use CLEAR_VARS here, even though 516ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# we aren't quite defining a new rule yet, to make sure that the 526ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# sub.mk files don't see anything stray from the last rule that was 536ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# set up. 546914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 556ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS) 566ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := $(core_magic_local_target) 5773d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 586ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_src_files := 596ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 606ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Include the sub.mk files. 616ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein$(foreach dir, \ 6238375a4d0b3d34e2babbd2f6a013976c7c439696Kenny Root crypto/src/main/native dalvik/src/main/native luni/src/main/native, \ 636ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein $(eval $(call include-core-native-dir,$(dir)))) 646ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 6525fb6e59cb26300701c3e945c1e042af68e47e3bElliott Hughes# Extract out the allowed LOCAL_* variables. 6625fb6e59cb26300701c3e945c1e042af68e47e3bElliott Hughescore_c_includes := libcore/include $(LOCAL_C_INCLUDES) 6725fb6e59cb26300701c3e945c1e042af68e47e3bElliott Hughescore_shared_libraries := $(LOCAL_SHARED_LIBRARIES) 6825fb6e59cb26300701c3e945c1e042af68e47e3bElliott Hughescore_static_libraries := $(LOCAL_STATIC_LIBRARIES) 6979ffafe17f06420d62904ce84e12424d28354219Elliott Hughescore_cflags := -Wall -Wextra -Werror 7079ffafe17f06420d62904ce84e12424d28354219Elliott Hughescore_cflags += -DJNI_JARJAR_PREFIX="com/android/" 71771ff9990e146b858ebb6ded9fd8b7a6493d3ddbElliott Hughescore_cppflags += -std=gnu++11 726ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 733042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstromcore_test_files := \ 743042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstrom luni/src/test/native/test_openssl_engine.cpp \ 753042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstrom 766ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 776ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the target (device). 786ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 796ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 806ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS) 812f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott HughesLOCAL_CFLAGS += $(core_cflags) 821f504c8a04a1ca4131bcfa57c5080b3702224a25Andy McFaddenLOCAL_CPPFLAGS += $(core_cppflags) 8379ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SRC_FILES += $(core_src_files) 8479ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_C_INCLUDES += $(core_c_includes) 8579ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz libnativehelper 8679ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_STATIC_LIBRARIES += $(core_static_libraries) 8753fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse WilsonLOCAL_MODULE_TAGS := optional 886ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := libjavacore 8973d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 9079ffafe17f06420d62904ce84e12424d28354219Elliott Hughesinclude external/stlport/libstlport.mk 917cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughesinclude $(BUILD_SHARED_LIBRARY) 926ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 936914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 9479ffafe17f06420d62904ce84e12424d28354219Elliott Hughes# Test JNI library. 956914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(LIBCORE_SKIP_TESTS),) 966914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 9779ffafe17f06420d62904ce84e12424d28354219Elliott Hughesinclude $(CLEAR_VARS) 986914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += $(core_cflags) 996914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CPPFLAGS += $(core_cppflags) 10079ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SRC_FILES += $(core_test_files) 10179ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_C_INCLUDES += libcore/include external/openssl/include 10279ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SHARED_LIBRARIES += libcrypto 1036914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE_TAGS := optional 1045f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny RootLOCAL_MODULE := libjavacoretests 1056914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 106992bc97a7c13d2b7d99b6811bc796fd93412fe0cBrian Carlstrominclude external/stlport/libstlport.mk 1076914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(BUILD_SHARED_LIBRARY) 10879ffafe17f06420d62904ce84e12424d28354219Elliott Hughes 1096914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif # LIBCORE_SKIP_TESTS 1106914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1116914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1126ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 1136ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the host. 1146ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 1156ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 1166ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteinifeq ($(WITH_HOST_DALVIK),true) 1176ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein include $(CLEAR_VARS) 11879ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_SRC_FILES += $(core_src_files) 1192f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott Hughes LOCAL_CFLAGS += $(core_cflags) 12079ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_C_INCLUDES += $(core_c_includes) 1217cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_CPPFLAGS += $(core_cppflags) 12222ccdd01e2fabc37d858be32291a854ff72f1840Elliott Hughes LOCAL_LDLIBS += -ldl -lpthread -lrt 12353fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse Wilson LOCAL_MODULE_TAGS := optional 1247cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_MODULE := libjavacore 12573d3e262ecf514ef17f47da335fdad899aecc3dcElliott Hughes LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 12679ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat-host libicuuc-host libicui18n-host libssl-host libcrypto-host libz-host 12779ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_STATIC_LIBRARIES += $(core_static_libraries) 1287cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes include $(BUILD_HOST_SHARED_LIBRARY) 1296914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 13020ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root # Conscrypt native library for nojarjar'd version 13120ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root include $(CLEAR_VARS) 13279ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_SRC_FILES += \ 13320ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root crypto/src/main/native/org_conscrypt_NativeCrypto.cpp \ 13420ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root luni/src/main/native/AsynchronousSocketCloseMonitor.cpp 13579ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_C_INCLUDES += $(core_c_includes) 13620ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root LOCAL_CPPFLAGS += $(core_cppflags) 13720ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root LOCAL_LDLIBS += -lpthread 13820ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root LOCAL_MODULE_TAGS := optional 13920ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root LOCAL_MODULE := libconscrypt_jni 14020ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 14179ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libssl-host libcrypto-host 14279ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_STATIC_LIBRARIES += $(core_static_libraries) 14320ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root include $(BUILD_HOST_SHARED_LIBRARY) 14420ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root 1456914efca8fe737a753d234d7e91222da6a8cdabeKenny Root ifeq ($(LIBCORE_SKIP_TESTS),) 1466914efca8fe737a753d234d7e91222da6a8cdabeKenny Root include $(CLEAR_VARS) 14779ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_SRC_FILES += $(core_test_files) 1486914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_CFLAGS += $(core_cflags) 14979ffafe17f06420d62904ce84e12424d28354219Elliott Hughes LOCAL_C_INCLUDES += libcore/include external/openssl/include 1506914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_CPPFLAGS += $(core_cppflags) 1516914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_LDLIBS += -ldl -lpthread 1526914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_MODULE_TAGS := optional 1535f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny Root LOCAL_MODULE := libjavacoretests 1546914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 1553042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstrom LOCAL_SHARED_LIBRARIES := libcrypto-host 1566914efca8fe737a753d234d7e91222da6a8cdabeKenny Root include $(BUILD_HOST_SHARED_LIBRARY) 1576914efca8fe737a753d234d7e91222da6a8cdabeKenny Root endif # LIBCORE_SKIP_TESTS 158845ce3cbfd6972542b275c95eddfbb6e94469737Elliott Hughesendif 159