1#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17include art/build/Android.common_build.mk
18
19ART_HOST_EXECUTABLES ?=
20ART_TARGET_EXECUTABLES ?=
21
22ART_EXECUTABLES_CFLAGS :=
23ifeq ($(ART_USE_PORTABLE_COMPILER),true)
24  ART_EXECUTABLES_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
25endif
26
27# $(1): executable ("d" will be appended for debug version)
28# $(2): source
29# $(3): extra shared libraries
30# $(4): extra include directories
31# $(5): target or host
32# $(6): ndebug or debug
33# $(7): value for LOCAL_MULTILIB (empty means default)
34define build-art-executable
35  ifneq ($(5),target)
36    ifneq ($(5),host)
37      $$(error expected target or host for argument 5, received $(5))
38    endif
39  endif
40  ifneq ($(6),ndebug)
41    ifneq ($(6),debug)
42      $$(error expected ndebug or debug for argument 6, received $(6))
43    endif
44  endif
45
46  art_executable := $(1)
47  art_source := $(2)
48  art_shared_libraries := $(3)
49  art_c_includes := $(4)
50  art_target_or_host := $(5)
51  art_ndebug_or_debug := $(6)
52  art_multilib := $(7)
53
54  include $(CLEAR_VARS)
55  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
56  LOCAL_MODULE_TAGS := optional
57  LOCAL_SRC_FILES := $$(art_source)
58  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime $$(art_c_includes)
59  LOCAL_SHARED_LIBRARIES += $$(art_shared_libraries)
60  LOCAL_WHOLE_STATIC_LIBRARIES += libsigchain
61
62  ifeq ($$(art_ndebug_or_debug),ndebug)
63    LOCAL_MODULE := $$(art_executable)
64  else #debug
65    LOCAL_MODULE := $$(art_executable)d
66  endif
67
68  LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS)
69  # Mac OS linker doesn't understand --export-dynamic/--version-script.
70  ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
71    LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
72  endif
73
74  ifeq ($$(art_target_or_host),target)
75  	$(call set-target-local-clang-vars)
76  	$(call set-target-local-cflags-vars,$(6))
77    LOCAL_SHARED_LIBRARIES += libdl
78  else # host
79    LOCAL_CLANG := $(ART_HOST_CLANG)
80    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
81    ifeq ($$(art_ndebug_or_debug),debug)
82      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
83    else
84      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
85    endif
86    LOCAL_LDLIBS += -lpthread -ldl
87  endif
88
89  ifeq ($$(art_ndebug_or_debug),ndebug)
90    LOCAL_SHARED_LIBRARIES += libart
91  else # debug
92    LOCAL_SHARED_LIBRARIES += libartd
93  endif
94
95  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
96  LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.executable.mk
97
98  ifeq ($$(art_target_or_host),target)
99    LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH)
100  endif
101  LOCAL_MULTILIB := $$(art_multilib)
102
103  include external/libcxx/libcxx.mk
104  ifeq ($$(art_target_or_host),target)
105    include $(BUILD_EXECUTABLE)
106    ART_TARGET_EXECUTABLES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
107  else # host
108    LOCAL_IS_HOST_MODULE := true
109    include $(BUILD_HOST_EXECUTABLE)
110    ART_HOST_EXECUTABLES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
111  endif
112
113endef
114