1#
2# Copyright (C) 2010 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
17# The prebuilt tools should be used when we are doing app-only build.
18ifeq ($(TARGET_BUILD_APPS),)
19
20LOCAL_PATH := $(call my-dir)
21
22local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
23ifeq ($(TARGET_BUILD_VARIANT),eng)
24local_cflags_for_slang += -O0
25else
26local_cflags_for_slang += -D__DISABLE_ASSERTS
27endif
28local_cflags_for_slang += -DTARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT)
29
30ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
31  RS_VERSION := $(PLATFORM_SDK_VERSION)
32else
33  # Increment by 1 whenever this is not a final release build, since we want to
34  # be able to see the RS version number change during development.
35  # See build/core/version_defaults.mk for more information about this.
36  RS_VERSION := "(1 + $(PLATFORM_SDK_VERSION))"
37endif
38local_cflags_for_slang += -DRS_VERSION=$(RS_VERSION)
39
40static_libraries_needed_by_slang := \
41	libLLVMBitWriter_2_9 \
42	libLLVMBitWriter_2_9_func \
43	libLLVMBitWriter_3_2
44
45# Static library libslang for host
46# ========================================================
47include $(CLEAR_VARS)
48include $(CLEAR_TBLGEN_VARS)
49
50LLVM_ROOT_PATH := external/llvm
51CLANG_ROOT_PATH := external/clang
52
53include $(CLANG_ROOT_PATH)/clang.mk
54
55LOCAL_MODULE := libslang
56LOCAL_MODULE_TAGS := optional
57
58LOCAL_CFLAGS += $(local_cflags_for_slang)
59
60TBLGEN_TABLES :=    \
61	AttrList.inc	\
62	Attrs.inc	\
63	CommentCommandList.inc \
64	CommentNodes.inc \
65	DeclNodes.inc	\
66	DiagnosticCommonKinds.inc	\
67	DiagnosticFrontendKinds.inc	\
68	DiagnosticSemaKinds.inc	\
69	StmtNodes.inc
70
71LOCAL_SRC_FILES :=	\
72	slang.cpp	\
73	slang_utils.cpp	\
74	slang_backend.cpp	\
75	slang_pragma_recorder.cpp	\
76	slang_diagnostic_buffer.cpp
77
78LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
79
80LOCAL_LDLIBS := -ldl -lpthread
81
82include $(CLANG_HOST_BUILD_MK)
83include $(CLANG_TBLGEN_RULES_MK)
84include $(LLVM_GEN_INTRINSICS_MK)
85include $(BUILD_HOST_STATIC_LIBRARY)
86
87# Host static library containing rslib.bc
88# ========================================================
89include $(CLEAR_VARS)
90
91input_data_file := frameworks/compile/slang/rslib.bc
92slangdata_output_var_name := rslib_bc
93
94LOCAL_IS_HOST_MODULE := true
95LOCAL_MODULE := librslib
96LOCAL_MODULE_TAGS := optional
97
98LOCAL_MODULE_CLASS := STATIC_LIBRARIES
99
100include $(LOCAL_PATH)/SlangData.mk
101include $(BUILD_HOST_STATIC_LIBRARY)
102
103# Executable slang-data for host
104# ========================================================
105include $(CLEAR_VARS)
106
107LOCAL_MODULE := slang-data
108LOCAL_MODULE_TAGS := optional
109
110LOCAL_MODULE_CLASS := EXECUTABLES
111
112LOCAL_SRC_FILES := slang-data.c
113
114include $(BUILD_HOST_EXECUTABLE)
115
116# Executable rs-spec-gen for host
117# ========================================================
118include $(CLEAR_VARS)
119
120LOCAL_MODULE := rs-spec-gen
121LOCAL_MODULE_TAGS := optional
122
123LOCAL_MODULE_CLASS := EXECUTABLES
124
125LOCAL_SRC_FILES :=	\
126	slang_rs_spec_table.cpp
127
128include $(BUILD_HOST_EXECUTABLE)
129
130# ========================================================
131include $(CLEAR_VARS)
132
133LOCAL_MODULE := llvm-rs-as
134LOCAL_MODULE_TAGS := optional
135
136LOCAL_MODULE_CLASS := EXECUTABLES
137
138LOCAL_SRC_FILES :=	\
139	llvm-rs-as.cpp
140
141LOCAL_CFLAGS += $(local_cflags_for_slang)
142LOCAL_STATIC_LIBRARIES :=	\
143	libslang \
144	$(static_libraries_needed_by_slang)
145LOCAL_SHARED_LIBRARIES := \
146	libLLVM
147
148include $(CLANG_HOST_BUILD_MK)
149include $(BUILD_HOST_EXECUTABLE)
150
151# Executable llvm-rs-cc for host
152# ========================================================
153include $(CLEAR_VARS)
154include $(CLEAR_TBLGEN_VARS)
155
156LOCAL_IS_HOST_MODULE := true
157LOCAL_MODULE := llvm-rs-cc
158LOCAL_MODULE_TAGS := optional
159
160LOCAL_MODULE_CLASS := EXECUTABLES
161
162LOCAL_CFLAGS += $(local_cflags_for_slang)
163
164TBLGEN_TABLES :=    \
165	AttrList.inc    \
166	Attrs.inc    \
167	CommentCommandList.inc \
168	CommentNodes.inc \
169	DeclNodes.inc    \
170	DiagnosticCommonKinds.inc   \
171	DiagnosticDriverKinds.inc	\
172	DiagnosticFrontendKinds.inc	\
173	DiagnosticSemaKinds.inc	\
174	StmtNodes.inc	\
175	RSCCOptions.inc
176
177RS_SPEC_TABLES :=	\
178	RSClangBuiltinEnums.inc	\
179	RSDataTypeEnums.inc	\
180	RSDataElementEnums.inc	\
181	RSMatrixTypeEnums.inc	\
182	RSObjectTypeEnums.inc
183
184LOCAL_SRC_FILES :=	\
185	llvm-rs-cc.cpp	\
186	slang_rs.cpp	\
187	slang_rs_ast_replace.cpp	\
188	slang_rs_check_ast.cpp	\
189	slang_rs_context.cpp	\
190	slang_rs_pragma_handler.cpp	\
191	slang_rs_backend.cpp	\
192	slang_rs_exportable.cpp	\
193	slang_rs_export_type.cpp	\
194	slang_rs_export_element.cpp	\
195	slang_rs_export_var.cpp	\
196	slang_rs_export_func.cpp	\
197	slang_rs_export_foreach.cpp \
198	slang_rs_object_ref_count.cpp	\
199	slang_rs_reflection.cpp \
200	slang_rs_reflection_base.cpp \
201	slang_rs_reflection_cpp.cpp \
202	slang_rs_reflect_utils.cpp
203
204LOCAL_STATIC_LIBRARIES :=	\
205	libslang \
206	$(static_libraries_needed_by_slang)
207
208LOCAL_SHARED_LIBRARIES := \
209	libclang \
210	libLLVM
211
212ifeq ($(HOST_OS),windows)
213  LOCAL_LDLIBS := -limagehlp -lpsapi
214else
215  LOCAL_LDLIBS := -ldl -lpthread
216endif
217
218# For build RSCCOptions.inc from RSCCOptions.td
219intermediates := $(call local-intermediates-dir)
220LOCAL_GENERATED_SOURCES += $(intermediates)/RSCCOptions.inc
221$(intermediates)/RSCCOptions.inc: $(LOCAL_PATH)/RSCCOptions.td $(LLVM_ROOT_PATH)/include/llvm/Option/OptParser.td $(TBLGEN)
222	@echo "Building Renderscript compiler (llvm-rs-cc) Option tables with tblgen"
223	$(call transform-host-td-to-out,opt-parser-defs)
224
225include frameworks/compile/slang/RSSpec.mk
226include $(CLANG_HOST_BUILD_MK)
227include $(CLANG_TBLGEN_RULES_MK)
228include $(BUILD_HOST_EXECUTABLE)
229
230endif  # TARGET_BUILD_APPS
231
232#=====================================================================
233# Include Subdirectories
234#=====================================================================
235include $(call all-makefiles-under,$(LOCAL_PATH))
236