Android.executable.mk revision 1d74e57fa22fbcad1e14d776c771472b2d8438fb
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) ../sigchainlib/sigchain.cc
58  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime $$(art_c_includes)
59  LOCAL_SHARED_LIBRARIES += $$(art_shared_libraries)
60
61  ifeq ($$(art_ndebug_or_debug),ndebug)
62    LOCAL_MODULE := $$(art_executable)
63  else #debug
64    LOCAL_MODULE := $$(art_executable)d
65  endif
66
67  LOCAL_CFLAGS := $(ART_EXECUTABLES_CFLAGS)
68  # Mac OS linker doesn't understand --export-dynamic/--version-script.
69  ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
70    LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
71  else
72    LOCAL_LDFLAGS := -Wl,-export_dynamic
73  endif
74
75  ifeq ($$(art_target_or_host),target)
76  	$(call set-target-local-clang-vars)
77  	$(call set-target-local-cflags-vars,$(6))
78    LOCAL_SHARED_LIBRARIES += libdl
79  else # host
80    LOCAL_CLANG := $(ART_HOST_CLANG)
81    LOCAL_CFLAGS += $(ART_HOST_CFLAGS)
82    ifeq ($$(art_ndebug_or_debug),debug)
83      LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
84    else
85      LOCAL_CFLAGS += $(ART_HOST_NON_DEBUG_CFLAGS)
86    endif
87    LOCAL_LDLIBS += -lpthread -ldl
88  endif
89
90  ifeq ($$(art_ndebug_or_debug),ndebug)
91    LOCAL_SHARED_LIBRARIES += libart
92  else # debug
93    LOCAL_SHARED_LIBRARIES += libartd
94  endif
95
96  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
97  LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.executable.mk
98
99  ifeq ($$(art_target_or_host),target)
100    LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH)
101  endif
102  LOCAL_MULTILIB := $$(art_multilib)
103
104  include external/libcxx/libcxx.mk
105  ifeq ($$(art_target_or_host),target)
106    include $(BUILD_EXECUTABLE)
107    ART_TARGET_EXECUTABLES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
108  else # host
109    LOCAL_IS_HOST_MODULE := true
110    include $(BUILD_HOST_EXECUTABLE)
111    ART_HOST_EXECUTABLES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
112  endif
113
114endef
115