NativeCode.mk revision 73d3e262ecf514ef17f47da335fdad899aecc3dc
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.
546ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS)
556ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := $(core_magic_local_target)
5673d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
576ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_src_files :=
586ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
596ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Include the sub.mk files.
606ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein$(foreach dir, \
612e7fae93da826b9aeb3b207dee0858ab85c87957Jean-Baptiste Queru    dalvik/src/main/native luni/src/main/native, \
626ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    $(eval $(call include-core-native-dir,$(dir))))
636ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
646ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Extract out the allowed LOCAL_* variables. Note: $(sort) also
656ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# removes duplicates.
666e1c2a95596e3ea72b48c7b54395131acbeab1daJean-Baptiste Querucore_c_includes := $(sort libcore/include $(LOCAL_C_INCLUDES) $(JNI_H_INCLUDE))
676ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_shared_libraries := $(sort $(LOCAL_SHARED_LIBRARIES))
686ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteincore_static_libraries := $(sort $(LOCAL_STATIC_LIBRARIES))
696ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
706ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
716ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
726ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the target (device).
736ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
746ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
756ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteininclude $(CLEAR_VARS)
766ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
7724144d482dcd5deac58a5dca7042379c05b56b5eElliott HughesLOCAL_CFLAGS += -Wall -Wextra -Werror
782f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott HughesLOCAL_CFLAGS += $(core_cflags)
791f504c8a04a1ca4131bcfa57c5080b3702224a25Andy McFaddenLOCAL_CPPFLAGS += $(core_cppflags)
8064f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughesifeq ($(TARGET_ARCH),arm)
8164f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughes# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
8264f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott HughesLOCAL_CFLAGS += -Wno-psabi
8364f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughesendif
8464f2ba48fb9306ab1d97f5f83053ee7f48223de8Elliott Hughes
856ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Define the rules.
866ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_SRC_FILES := $(core_src_files)
87bb2532130c1c52755916d8608b7057496c6b395aMarco NelissenLOCAL_C_INCLUDES := $(core_c_includes)
887cd6760f7045d771faae8080a8c6150bf678f679Elliott HughesLOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz libnativehelper
896ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_STATIC_LIBRARIES := $(core_static_libraries)
9053fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse WilsonLOCAL_MODULE_TAGS := optional
916ac43c29e4f1918d40441178c22bfca7409101beDan BornsteinLOCAL_MODULE := libjavacore
9273d3e262ecf514ef17f47da335fdad899aecc3dcElliott HughesLOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
9318fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen
94c3d30bfb532fc1e609a67a324d6bfb9776f88778Elliott HughesLOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
952cfb2ad66741e923bcd99719bb6b8f4e1189dd4dBrian CarlstromLOCAL_SHARED_LIBRARIES += libstlport
9618fb450a3043d52ff6c134ff901987f4d3a9af96Kristian Monsen
977cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughesinclude $(BUILD_SHARED_LIBRARY)
986ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
996ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1006ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein# Build for the host.
1016ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein#
1026ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein
1036ac43c29e4f1918d40441178c22bfca7409101beDan Bornsteinifeq ($(WITH_HOST_DALVIK),true)
1046ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    include $(CLEAR_VARS)
1056ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    # Define the rules.
1066ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    LOCAL_SRC_FILES := $(core_src_files)
1072f03ccad590827233fcba84a8b6eafcd414e5fe7Elliott Hughes    LOCAL_CFLAGS += $(core_cflags)
1086ac43c29e4f1918d40441178c22bfca7409101beDan Bornstein    LOCAL_C_INCLUDES := $(core_c_includes)
1097cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_CPPFLAGS += $(core_cppflags)
1107cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_LDLIBS += -ldl -lpthread
11153fbc0a776feebcc04f6c24b34f2c7ba39e6b5a1Jesse Wilson    LOCAL_MODULE_TAGS := optional
1127cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_MODULE := libjavacore
11373d3e262ecf514ef17f47da335fdad899aecc3dcElliott Hughes    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
1147cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libexpat libicuuc libicui18n libssl libcrypto libz-host
1157cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    LOCAL_STATIC_LIBRARIES := $(core_static_libraries)
1167cd6760f7045d771faae8080a8c6150bf678f679Elliott Hughes    include $(BUILD_HOST_SHARED_LIBRARY)
117845ce3cbfd6972542b275c95eddfbb6e94469737Elliott Hughesendif
118