NativeCode.mk revision 3153886475686963f81a0c40dc4e7f2a902af0c2
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, \
62ba07db54a902e6741cd085901264e4e45c9c844eKenny Root    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)
693e58734d651080009c9190c7062837fca5c7cf4ePaul Jensencore_cflags := $(LOCAL_CFLAGS) -Wall -Wextra -Werror
70a04b5c3d39232c7616591883ee2124520e3ab622Elliott Hughescore_cppflags += -std=gnu++11 -DU_USING_ICU_NAMESPACE=0
716ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
723042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstromcore_test_files := \
73a515759d83bac3e3b6bfdea20eb9576621e6596aIan Rogers  luni/src/test/native/dalvik_system_JniTest.cpp \
743042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstrom
756ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
766ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the target (device).
776ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
786ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
796ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS)
802f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott HughesLOCAL_CFLAGS += $(core_cflags)
811f504c8a04a1ca4131bcfa57c5080b3702224a25Andy McFaddenLOCAL_CPPFLAGS += $(core_cppflags)
8279ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SRC_FILES += $(core_src_files)
8379ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_C_INCLUDES += $(core_c_includes)
841bc030b6c8a52e1911efcd58d6fbc7f982649167Elliott HughesLOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libdl libexpat libicuuc libicui18n libnativehelper libz libutils
85a9b386f30a903c42f460b71d97fc130178614052Narayan KamathLOCAL_STATIC_LIBRARIES += $(core_static_libraries) libziparchive libbase
8653fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse WilsonLOCAL_MODULE_TAGS := optional
876ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := libjavacore
8873d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
89b3aacde3d8af759ee4a7b395c636ea360547d92dIan RogersLOCAL_CXX_STL := libc++
907cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughesinclude $(BUILD_SHARED_LIBRARY)
916ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
9279ffafe17f06420d62904ce84e12424d28354219Elliott Hughes# Test JNI library.
936914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(LIBCORE_SKIP_TESTS),)
946914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
9579ffafe17f06420d62904ce84e12424d28354219Elliott Hughesinclude $(CLEAR_VARS)
966914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += $(core_cflags)
976914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CPPFLAGS += $(core_cppflags)
9879ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SRC_FILES += $(core_test_files)
99fc0498f0dd9af3c86b67d0536fceaf9ed04781fbElliott HughesLOCAL_C_INCLUDES += libcore/include
10079ffafe17f06420d62904ce84e12424d28354219Elliott HughesLOCAL_SHARED_LIBRARIES += libcrypto
1016914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE_TAGS := optional
1025f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny RootLOCAL_MODULE := libjavacoretests
1036914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
104b3aacde3d8af759ee4a7b395c636ea360547d92dIan RogersLOCAL_CXX_STL := libc++
1056914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(BUILD_SHARED_LIBRARY)
10679ffafe17f06420d62904ce84e12424d28354219Elliott Hughes
1076914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif # LIBCORE_SKIP_TESTS
1086914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
10908d97aee56db51f718544562f5b74671be34dfafChristopher Ferris# Set of gtest unit tests.
11008d97aee56db51f718544562f5b74671be34dfafChristopher Ferrisinclude $(CLEAR_VARS)
11108d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CFLAGS += $(core_cflags)
11208d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CPPFLAGS += $(core_cppflags)
11308d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_SRC_FILES += \
11408d97aee56db51f718544562f5b74671be34dfafChristopher Ferris  luni/src/test/native/libcore_io_Memory_test.cpp \
11508d97aee56db51f718544562f5b74671be34dfafChristopher Ferris
11608d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_C_INCLUDES += libcore/include
11708d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE_TAGS := debug
11808d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE := libjavacore-unit-tests
11908d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
12008d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CXX_STL := libc++
12108d97aee56db51f718544562f5b74671be34dfafChristopher Ferrisinclude $(BUILD_NATIVE_TEST)
12208d97aee56db51f718544562f5b74671be34dfafChristopher Ferris
12308d97aee56db51f718544562f5b74671be34dfafChristopher Ferris# Set of benchmarks for libjavacore functions.
12408d97aee56db51f718544562f5b74671be34dfafChristopher Ferrisinclude $(CLEAR_VARS)
12508d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CFLAGS += $(core_cflags)
12608d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CPPFLAGS += $(core_cppflags)
12708d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_SRC_FILES += \
12808d97aee56db51f718544562f5b74671be34dfafChristopher Ferris  luni/src/benchmark/native/libcore_io_Memory_bench.cpp \
12908d97aee56db51f718544562f5b74671be34dfafChristopher Ferris
13008d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_C_INCLUDES += libcore/include bionic/benchmarks
13108d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE_TAGS := debug
13208d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE := libjavacore-benchmarks
13308d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
13408d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_CXX_STL := libc++
13508d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MULTILIB := both
13608d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
13708d97aee56db51f718544562f5b74671be34dfafChristopher FerrisLOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
13808d97aee56db51f718544562f5b74671be34dfafChristopher Ferrisinclude $(BUILD_NATIVE_BENCHMARK)
13908d97aee56db51f718544562f5b74671be34dfafChristopher Ferris
1406914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1416ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1426ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the host.
1436ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1446ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
1454bf04854fc7e16bad65fd9436bb4513bf16a0c47Elliott Hughesifeq ($(HOST_OS),linux)
1464bf04854fc7e16bad65fd9436bb4513bf16a0c47Elliott Hughes
1473deabd220cf7b1ca0824987e90b8ecc07087f05aIan Rogersinclude $(CLEAR_VARS)
1483deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_CLANG := true
1493deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_SRC_FILES += $(core_src_files)
1503deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_CFLAGS += $(core_cflags)
1513deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_C_INCLUDES += $(core_c_includes)
1523deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_CPPFLAGS += $(core_cppflags)
153efae3837b3eb79dea3400735fdcdd5a39020e0b0Ian RogersLOCAL_LDLIBS += -ldl -lpthread
154efae3837b3eb79dea3400735fdcdd5a39020e0b0Ian Rogersifeq ($(HOST_OS),linux)
155efae3837b3eb79dea3400735fdcdd5a39020e0b0Ian RogersLOCAL_LDLIBS += -lrt
156efae3837b3eb79dea3400735fdcdd5a39020e0b0Ian Rogersendif
1573deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_MODULE_TAGS := optional
1583deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_MODULE := libjavacore
1593deabd220cf7b1ca0824987e90b8ecc07087f05aIan RogersLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1603153886475686963f81a0c40dc4e7f2a902af0c2Narayan KamathLOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat-host libicuuc-host libicui18n-host libcrypto-host libz-host libziparchive-host
1613153886475686963f81a0c40dc4e7f2a902af0c2Narayan KamathLOCAL_STATIC_LIBRARIES += $(core_static_libraries)
16264c039e810824a6b9e058b3a910ef3238d5128d7Ian RogersLOCAL_MULTILIB := both
163f277bbcc1368de99dbee1817c08f1b2be8e17113Dan AlbertLOCAL_CXX_STL := libc++
1643deabd220cf7b1ca0824987e90b8ecc07087f05aIan Rogersinclude $(BUILD_HOST_SHARED_LIBRARY)
165ba07db54a902e6741cd085901264e4e45c9c844eKenny Root
1663deabd220cf7b1ca0824987e90b8ecc07087f05aIan Rogersifeq ($(LIBCORE_SKIP_TESTS),)
1676914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    include $(CLEAR_VARS)
1686c738216f9ecbcd90b23279d7abea7d3182fe6b3Ian Rogers    LOCAL_CLANG := true
16979ffafe17f06420d62904ce84e12424d28354219Elliott Hughes    LOCAL_SRC_FILES += $(core_test_files)
1706914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_CFLAGS += $(core_cflags)
171fc0498f0dd9af3c86b67d0536fceaf9ed04781fbElliott Hughes    LOCAL_C_INCLUDES += libcore/include
1726914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_CPPFLAGS += $(core_cppflags)
1736914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_LDLIBS += -ldl -lpthread
1746914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_MODULE_TAGS := optional
1755f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny Root    LOCAL_MODULE := libjavacoretests
1766914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1773042efc693a56888cdd0194ba1fd2504ef1ab67dBrian Carlstrom    LOCAL_SHARED_LIBRARIES := libcrypto-host
178f277bbcc1368de99dbee1817c08f1b2be8e17113Dan Albert    LOCAL_CXX_STL := libc++
1796914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    include $(BUILD_HOST_SHARED_LIBRARY)
1803deabd220cf7b1ca0824987e90b8ecc07087f05aIan Rogersendif # LIBCORE_SKIP_TESTS
1814bf04854fc7e16bad65fd9436bb4513bf16a0c47Elliott Hughes
1824bf04854fc7e16bad65fd9436bb4513bf16a0c47Elliott Hughesendif # HOST_OS == linux
183