NativeCode.mk revision 20ec13bd54d56d6832ef2a02a02e65a5f0a304db
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, \
8538375a4d0b3d34e2babbd2f6a013976c7c439696Kenny Root    crypto/src/main/native 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))
9338375a4d0b3d34e2babbd2f6a013976c7c439696Kenny Rootcore_cflags := -DJNI_JARJAR_PREFIX="com/android/"
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)
11138375a4d0b3d34e2babbd2f6a013976c7c439696Kenny RootLOCAL_CFLAGS := $(core_cflags)
112bb2532130c1c52755916d8608b7057496c6b395aMarco NelissenLOCAL_C_INCLUDES := $(core_c_includes)
1137cd6760f7045d771faae8080a8c6150bf678f679Elliott HughesLOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz libnativehelper
1146ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_STATIC_LIBRARIES := $(core_static_libraries)
11553fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse WilsonLOCAL_MODULE_TAGS := optional
1166ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := libjavacore
11773d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
11818fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen
119c3d30bfb532fc1e609a67a324d6bfb9776f88778Elliott HughesLOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
1202cfb2ad66741e923bcd99719bb6b8f4e1189dd4dBrian CarlstromLOCAL_SHARED_LIBRARIES += libstlport
12118fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen
1227cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughesinclude $(BUILD_SHARED_LIBRARY)
1236ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
1246914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1256914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Test library
1266914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(LIBCORE_SKIP_TESTS),)
1276914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(CLEAR_VARS)
1286914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1296914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += -Wall -Wextra -Werror
1306914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += $(core_cflags)
1316914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CPPFLAGS += $(core_cppflags)
1326914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootifeq ($(TARGET_ARCH),arm)
1336914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
1346914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_CFLAGS += -Wno-psabi
1356914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif
1366914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1376914efca8fe737a753d234d7e91222da6a8cdabeKenny Root# Define the rules.
1386914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_SRC_FILES := $(test_src_files)
1396914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_C_INCLUDES := $(test_c_includes)
1406914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_SHARED_LIBRARIES := $(test_shared_libraries)
1416914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_STATIC_LIBRARIES := $(test_static_libraries)
1426914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_MODULE_TAGS := optional
1435f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny RootLOCAL_MODULE := libjavacoretests
1446914efca8fe737a753d234d7e91222da6a8cdabeKenny RootLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1456914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1466914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootinclude $(BUILD_SHARED_LIBRARY)
1476914efca8fe737a753d234d7e91222da6a8cdabeKenny Rootendif # LIBCORE_SKIP_TESTS
1486914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1496914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
1506ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1516ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the host.
1526ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1536ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
1546ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteinifeq ($(WITH_HOST_DALVIK),true)
1556ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    include $(CLEAR_VARS)
1566ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    # Define the rules.
1576ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    LOCAL_SRC_FILES := $(core_src_files)
1582f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott Hughes    LOCAL_CFLAGS += $(core_cflags)
1596ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    LOCAL_C_INCLUDES := $(core_c_includes)
1607cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_CPPFLAGS += $(core_cppflags)
1617cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_LDLIBS += -ldl -lpthread
16253fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse Wilson    LOCAL_MODULE_TAGS := optional
1637cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_MODULE := libjavacore
16473d3e262ecf514ef17f47da335fdad899aecc3dcElliott Hughes    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1657cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz-host
1667cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
1677cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    include $(BUILD_HOST_SHARED_LIBRARY)
1686914efca8fe737a753d234d7e91222da6a8cdabeKenny Root
16920ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    # Conscrypt native library for nojarjar'd version
17020ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    include $(CLEAR_VARS)
17120ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_SRC_FILES := \
17220ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root            crypto/src/main/native/org_conscrypt_NativeCrypto.cpp \
17320ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root            luni/src/main/native/AsynchronousSocketCloseMonitor.cpp
17420ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_C_INCLUDES := $(core_c_includes)
17520ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_CPPFLAGS += $(core_cppflags)
17620ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_LDLIBS += -lpthread
17720ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_MODULE_TAGS := optional
17820ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_MODULE := libconscrypt_jni
17920ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
18020ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libssl libcrypto
18120ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
18220ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root    include $(BUILD_HOST_SHARED_LIBRARY)
18320ec13bd54d56d6832ef2a02a02e65a5f0a304dbKenny Root
1846914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    ifeq ($(LIBCORE_SKIP_TESTS),)
1856914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    include $(CLEAR_VARS)
1866914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    # Define the rules.
1876914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_SRC_FILES := $(test_src_files)
1886914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_CFLAGS += $(core_cflags)
1896914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_C_INCLUDES := $(test_c_includes)
1906914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_CPPFLAGS += $(core_cppflags)
1916914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_LDLIBS += -ldl -lpthread
1926914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_MODULE_TAGS := optional
1935f1f97c39628995ed1d1913c192d91e17ea26ef1Kenny Root    LOCAL_MODULE := libjavacoretests
1946914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1956914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_SHARED_LIBRARIES := $(test_shared_libraries)
1966914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    LOCAL_STATIC_LIBRARIES := $(test_static_libraries)
1976914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    include $(BUILD_HOST_SHARED_LIBRARY)
1986914efca8fe737a753d234d7e91222da6a8cdabeKenny Root    endif # LIBCORE_SKIP_TESTS
199845ce3cbfd6972542b275c95eddfbb6e94469737Elliott Hughesendif
200