NativeCode.mk revision 6914efca8fe737a753d234d7e91222da6a8cdabe
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 556914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Set up the test library first 566914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(LIBCORE_SKIP_TESTS),) 576914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(CLEAR_VARS) 586914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE := $(core_magic_local_target) 596914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootcore_src_files := 606914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 616914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Include the sub.mk files. 626914efca8fe737a753d234d7e91222da6a8cdabeKenny Root$(foreach dir, \ 636914efca8fe737a753d234d7e91222da6a8cdabeKenny Root luni/src/test/native, \ 646914efca8fe737a753d234d7e91222da6a8cdabeKenny Root $(eval $(call include-core-native-dir,$(dir)))) 656914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 666914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# This is for the test library, so rename the variable. 676914efca8fe737a753d234d7e91222da6a8cdabeKenny Roottest_src_files := $(core_src_files) 686914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootcore_src_files := 696914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 706914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Extract out the allowed LOCAL_* variables. Note: $(sort) also 716914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# removes duplicates. 726914efca8fe737a753d234d7e91222da6a8cdabeKenny Roottest_c_includes := $(sort libcore/include $(LOCAL_C_INCLUDES) $(JNI_H_INCLUDE)) 736914efca8fe737a753d234d7e91222da6a8cdabeKenny Roottest_shared_libraries := $(sort $(LOCAL_SHARED_LIBRARIES)) 746914efca8fe737a753d234d7e91222da6a8cdabeKenny Roottest_static_libraries := $(sort $(LOCAL_STATIC_LIBRARIES)) 756914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif # LIBCORE_SKIP_TESTS 766914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 776914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 786ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS) 796ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := $(core_magic_local_target) 8073d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 816ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_src_files := 826ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 836ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Include the sub.mk files. 846ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein$(foreach dir, \ 852e7fae93da826b9aeb3b207dee0858ab85c87957Jean-Baptiste Queru dalvik/src/main/native luni/src/main/native, \ 866ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein $(eval $(call include-core-native-dir,$(dir)))) 876ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 886ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Extract out the allowed LOCAL_* variables. Note: $(sort) also 896ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# removes duplicates. 906e1c2a95596e3ea72b48c7b54395131acbeab1daJean-Baptiste Querucore_c_includes := $(sort libcore/include $(LOCAL_C_INCLUDES) $(JNI_H_INCLUDE)) 916ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_shared_libraries := $(sort $(LOCAL_SHARED_LIBRARIES)) 926ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_static_libraries := $(sort $(LOCAL_STATIC_LIBRARIES)) 936ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 946ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 956ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 966ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the target (device). 976ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 986ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 996ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS) 1006ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 10124144d482dcd5deac58a5dca7042379c05b56b5eElliott HughesLOCAL_CFLAGS += -Wall -Wextra -Werror 1022f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott HughesLOCAL_CFLAGS += $(core_cflags) 1031f504c8a04a1ca4131bcfa57c5080b3702224a25Andy McFaddenLOCAL_CPPFLAGS += $(core_cppflags) 10464f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughesifeq ($(TARGET_ARCH),arm) 10564f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughes# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4" 10664f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott HughesLOCAL_CFLAGS += -Wno-psabi 10764f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughesendif 10864f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughes 1096ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Define the rules. 1106ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_SRC_FILES := $(core_src_files) 111bb2532130c1c52755916d8608b7057496c6b395aMarco NelissenLOCAL_C_INCLUDES := $(core_c_includes) 1127cd6760f7045d771faae8080a8c6150bf678f679Elliott HughesLOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz libnativehelper 1136ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_STATIC_LIBRARIES := $(core_static_libraries) 11453fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse WilsonLOCAL_MODULE_TAGS := optional 1156ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := libjavacore 11673d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 11718fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen 118c3d30bfb532fc1e609a67a324d6bfb9776f88778Elliott HughesLOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include 1192cfb2ad66741e923bcd99719bb6b8f4e1189dd4dBrian CarlstromLOCAL_SHARED_LIBRARIES += libstlport 12018fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen 1217cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughesinclude $(BUILD_SHARED_LIBRARY) 1226ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 1236914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1246914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Test library 1256914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(LIBCORE_SKIP_TESTS),) 1266914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(CLEAR_VARS) 1276914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1286914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += -Wall -Wextra -Werror 1296914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += $(core_cflags) 1306914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CPPFLAGS += $(core_cppflags) 1316914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(TARGET_ARCH),arm) 1326914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4" 1336914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += -Wno-psabi 1346914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif 1356914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1366914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Define the rules. 1376914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_SRC_FILES := $(test_src_files) 1386914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_C_INCLUDES := $(test_c_includes) 1396914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_SHARED_LIBRARIES := $(test_shared_libraries) 1406914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_STATIC_LIBRARIES := $(test_static_libraries) 1416914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE_TAGS := optional 1426914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE := libjavacore-test 1436914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 1446914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1456914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(BUILD_SHARED_LIBRARY) 1466914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif # LIBCORE_SKIP_TESTS 1476914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1486914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1496ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 1506ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the host. 1516ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# 1526ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein 1536ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteinifeq ($(WITH_HOST_DALVIK),true) 1546ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein include $(CLEAR_VARS) 1556ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein # Define the rules. 1566ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein LOCAL_SRC_FILES := $(core_src_files) 1572f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott Hughes LOCAL_CFLAGS += $(core_cflags) 1586ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein LOCAL_C_INCLUDES := $(core_c_includes) 1597cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_CPPFLAGS += $(core_cppflags) 1607cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_LDLIBS += -ldl -lpthread 16153fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse Wilson LOCAL_MODULE_TAGS := optional 1627cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_MODULE := libjavacore 16373d3e262ecf514ef17f47da335fdad899aecc3dcElliott Hughes LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 1647cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz-host 1657cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes LOCAL_STATIC_LIBRARIES := $(core_static_libraries) 1667cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes include $(BUILD_HOST_SHARED_LIBRARY) 1676914efca8fe737a753d234d7e91222da6a8cdabeKenny Root 1686914efca8fe737a753d234d7e91222da6a8cdabeKenny Root ifeq ($(LIBCORE_SKIP_TESTS),) 1696914efca8fe737a753d234d7e91222da6a8cdabeKenny Root include $(CLEAR_VARS) 1706914efca8fe737a753d234d7e91222da6a8cdabeKenny Root # Define the rules. 1716914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_SRC_FILES := $(test_src_files) 1726914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_CFLAGS += $(core_cflags) 1736914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_C_INCLUDES := $(test_c_includes) 1746914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_CPPFLAGS += $(core_cppflags) 1756914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_LDLIBS += -ldl -lpthread 1766914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_MODULE_TAGS := optional 1776914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_MODULE := libjavacore-test 1786914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk 1796914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_SHARED_LIBRARIES := $(test_shared_libraries) 1806914efca8fe737a753d234d7e91222da6a8cdabeKenny Root LOCAL_STATIC_LIBRARIES := $(test_static_libraries) 1816914efca8fe737a753d234d7e91222da6a8cdabeKenny Root include $(BUILD_HOST_SHARED_LIBRARY) 1826914efca8fe737a753d234d7e91222da6a8cdabeKenny Root endif # LIBCORE_SKIP_TESTS 183845ce3cbfd6972542b275c95eddfbb6e94469737Elliott Hughesendif 184